irrational unblocking, low speed obstacle bug and spicke pack when y too big
[aversive.git] / mk / aversive_module.mk
1 # Microb Technology, Eirbot, Droids-corp 2005 - Zer0
2 # Makefile for projects
3
4 # Inspired by the WinAVR Sample makefile written by Eric
5 # B. Weddington, J÷rg Wunsch, et al.
6 #
7
8 MSG_COMPILING = Compiling:
9 MSG_PREPROC = Preprocessing:
10
11 # default HOST is avr
12 ifeq ($(H),)
13 HOST=avr
14 else
15 HOST=host
16 endif
17
18 OBJ = $(addprefix compiler_files/,$(SRC:.c=.$(HOST).o) $(ASRC:.S=.$(HOST).o))
19 LST = $(OBJ:.o=.lst)
20 DEPS = $(addprefix compiler_files/,$(SRC:.c=.$(HOST).d))
21 ifneq ($(P),)
22 PREPROC= $(addprefix compiler_files/,$(SRC:.c=.$(HOST).preproc))
23 else
24 PREPROC=
25 endif
26
27 # Default target.
28 all: compiler_files/$(TARGET).$(HOST).a
29
30 # Module library file
31 compiler_files/$(TARGET).$(HOST).a: $(PREPROC) $(OBJ)
32         ${AR} rs $@ $(OBJ) 2>&1
33
34 # Automatically generate C source code dependencies. 
35 compiler_files/%.$(HOST).d : %.c
36         @echo Generating $@
37         @set -e; rm -f $@; \
38         $(CC) -M $(CFLAGS) $< > $@.$$$$; \
39         sed 's,\($*\)\.o[ :]*,compiler_files/\1.$(HOST).o $@ : ,g' < $@.$$$$ > $@; \
40         rm -f $@.$$$$
41
42 compiler_files/%.$(HOST).o : %.c
43         @echo $(MSG_COMPILING) $< 
44         $(CC) $(CFLAGS) $< -c -o $@
45
46 compiler_files/%.$(HOST).preproc : %.c
47         @echo $(MSG_PREPROC) $< 
48         $(CC) $(CFLAGS) $< -E -o $@
49
50 # Compile: create assembler files from C source files.
51 compiler_files/%.$(HOST).s : %.c
52         $(CC) -S $(CFLAGS) $< -o $@
53
54 # Assemble: create object files from assembler source files.
55 compiler_files/%.$(HOST).o : %.S
56         $(CC) -c -Wa,-adhlns=$(@:.o=.lst) $(ASFLAGS) $< -o $@
57
58
59 # Remove the '-' if you want to see the dependency files generated.
60 ifeq (,$(findstring clean,$(MAKECMDGOALS)))
61 -include $(DEPS)
62 endif
63
64 # Clean all objects 
65 clean:
66         $(REMOVE) compiler_files/$(TARGET).$(HOST).a
67         $(REMOVE) $(OBJ) 
68         $(REMOVE) $(LST)
69         $(REMOVE) $(PREPROC)
70
71 depclean:
72         $(REMOVE) $(DEPS)
73
74 # Listing of phony targets.
75 .PHONY : all clean deps