#######################################
HW?=trennfix_0.4
-PROG?=smokefix
-
-#######################################
+PROG?=trennfix
+BUILD_DIR=build
#######################################
# VERBOSITY CONTROL
$(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.
# 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
@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 $$@
$(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