1 # Microb Technology, Eirbot, Droids-corp 2005 - Zer0
2 # Makefile for projects
4 # Inspired by the WinAVR Sample makefile written by Eric
5 # B. Weddington, J÷rg Wunsch, et al.
8 MSG_COMPILING = Compiling:
9 MSG_PREPROC = Preprocessing:
18 OBJ = $(addprefix compiler_files/,$(SRC:.c=.$(HOST).o) $(ASRC:.S=.$(HOST).o))
20 DEPS = $(addprefix compiler_files/,$(SRC:.c=.$(HOST).d))
22 PREPROC= $(addprefix compiler_files/,$(SRC:.c=.$(HOST).preproc))
28 all: compiler_files/$(TARGET).$(HOST).a
31 compiler_files/$(TARGET).$(HOST).a: $(PREPROC) $(OBJ)
32 ${AR} rs $@ $(OBJ) 2>&1
34 # Automatically generate C source code dependencies.
35 compiler_files/%.$(HOST).d : %.c
38 $(CC) -M $(CFLAGS) $< > $@.$$$$; \
39 sed 's,\($*\)\.o[ :]*,compiler_files/\1.$(HOST).o $@ : ,g' < $@.$$$$ > $@; \
42 compiler_files/%.$(HOST).o : %.c
43 @echo $(MSG_COMPILING) $<
44 $(CC) $(CFLAGS) $< -c -o $@
46 compiler_files/%.$(HOST).preproc : %.c
47 @echo $(MSG_PREPROC) $<
48 $(CC) $(CFLAGS) $< -E -o $@
50 # Compile: create assembler files from C source files.
51 compiler_files/%.$(HOST).s : %.c
52 $(CC) -S $(CFLAGS) $< -o $@
54 # Assemble: create object files from assembler source files.
55 compiler_files/%.$(HOST).o : %.S
56 $(CC) -c -Wa,-adhlns=$(@:.o=.lst) $(ASFLAGS) $< -o $@
59 # Remove the '-' if you want to see the dependency files generated.
60 ifeq (,$(findstring clean,$(MAKECMDGOALS)))
66 $(REMOVE) compiler_files/$(TARGET).$(HOST).a
74 # Listing of phony targets.
75 .PHONY : all clean deps