X-Git-Url: http://gitweb.hachti.de/?a=blobdiff_plain;f=trennfix%2Fsw%2FMakefile;h=248a0c7c9c040a0ca33ecd0c105e5deaf8ac8d30;hb=a296a9fc34e682cdfe8ea7a587f6f727ec789efa;hp=0ad4b1b1ff8862a37fe0b070f72dc891e9b0293c;hpb=f12652dfe40fa03634eb01b2cdda861a46e46a03;p=eisenbahn.git diff --git a/trennfix/sw/Makefile b/trennfix/sw/Makefile index 0ad4b1b..248a0c7 100644 --- a/trennfix/sw/Makefile +++ b/trennfix/sw/Makefile @@ -2,10 +2,9 @@ ####################################### HW?=trennfix_0.4 -PROG?=smokefix - -####################################### +PROG?=trennfix +BUILD_DIR=build ####################################### # VERBOSITY CONTROL @@ -152,8 +151,9 @@ $(eval $(call SELECT_DEFAULT_template, $(PROG))) $(Q)$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) # Compile: create object files from C source files. -%.o : %.c Makefile +$(BUILD_DIR)/%.o : %.c Makefile $(wildcard mk/hw/*) @echo CC $@ + @mkdir -p $(@D) $(Q)$(CC) -c $(CFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -164,13 +164,17 @@ $(eval $(call SELECT_DEFAULT_template, $(PROG))) # Assemble: create object files from assembler source files. %.o : %.S @echo ASM $@ + @mkdir -p $(@D) $(Q)$(CC) -c $(ASFLAGS) $< -o $@ ########################### The big template for each program ################## define PROGRAM_template= +$(1)_mupf: + @echo "$(1) Objects: " $$($(1)_OBJS) + # Determine program's object files -$(1)_OBJS=$$($(1)_SRC:.c=.o) +$(1)_OBJS=$$(foreach obj, $$($(1)_SRC:.c=.o), $(BUILD_DIR)/$$(obj)) $(1)_OBJS+=$$($(1)_ASRC:.S=.o) # Collect all listing files - for cleanup @@ -183,9 +187,6 @@ $(1)_program : $(1).hex $(1).eep @echo PROG $(1) $(Q)$(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(1).hex -U eeprom:w:$(1).eep -$(1)_unfug: - @echo UNFUG $$@ - $(1)_fuses.bin: $(1).elf @echo OBJCOPY $$@ $(Q)$(OBJCOPY) -j .fuse $(1).elf -O binary $$@ @@ -216,7 +217,8 @@ $(1)_clean: $(Q)$(RM) $$($(1)_LST) $(Q)$(RM) $$($(1)_SRC:.c=.s) $(Q)$(RM) $$($(1)_SRC:.c=.d) - @$(Q)$(RM) $(1)_fuses.bin + $(Q)$(RM) $(1)_fuses.bin + $(Q) rm -rf $(BUILD_DIR)/ $(1)_build: $(1).hex $(1)_size