diff --git a/Makefile b/Makefile index 86cb98b..45206cb 100644 --- a/Makefile +++ b/Makefile @@ -11,16 +11,16 @@ include $(BASE)/Makefile ifeq (,$(MAKEBASE)) export MAKEBASE=$(realpath $(firstword $(MAKEFILE_LIST))) -else - ifneq (,$(wildcard $(BASE)/.depends.make)) - include $(wildcard $(BASE)/.depends.make) +endif - include $(realpath $(foreach CDEP,$(COMPDEPENDS),$(CDEP)/global.make)) - - CDEPENDS=$(call reverse,$(COMPDEPENDS)) - DEPINC=$(CDEPENDS:%=-I%/include) +ifneq (,$(wildcard $(BASE)/.depends.make)) + include $(wildcard $(BASE)/.depends.make) + + include $(realpath $(foreach CDEP,$(call reverse,$(COMPDEPENDS)),$(CDEP)/global.make)) + + CDEPENDS=$(call reverse,$(COMPDEPENDS)) + DEPINC=$(CDEPENDS:%=-I%/include) - endif endif ifeq (,$(FINALNAME)) @@ -39,6 +39,7 @@ LD=$(COMPILER_PREFIX)gcc AR=$(COMPILER_PREFIX)ar SIZE=$(COMPILER_PREFIX)size OBJCOPY=$(COMPILER_PREFIX)objcopy +AVRDUDE=sudo avrdude ifeq ($(BASE),$(CURDIR)) DEPLIBS:=$(foreach DEPLIB,$(CDEPENDS),$(BASE)/.build/libdep-$(subst /,_,$(DEPLIB).a)) @@ -65,6 +66,20 @@ LDFLAGS+=$(foreach DEP,$(CDEPENDS),$(BASE)/.build/libdep-$(subst /,_,$(DEP)).a) LDFLAGS+=$(foreach DEP,$(CDEPENDS),$(BASE)/.build/libdep-$(subst /,_,$(DEP)).a) +ifneq ($(AVR_FUSE_EXTENDED),) + AVRDUDE_OPERATIONS+=-U efuse:w:$(AVR_FUSE_EXTENDED):m +endif +ifneq ($(AVR_FUSE_HIGH),) + AVRDUDE_OPERATIONS+=-U hfuse:w:$(AVR_FUSE_HIGH):m +endif +ifneq ($(AVR_FUSE_LOW),) + AVRDUDE_OPERATIONS+=-U lfuse:w:$(AVR_FUSE_LOW):m +endif +ifeq (,$(AVR_PROG)) + AVR_PROG=avrisp2 +endif + + .SILENT: .PHONY: clean build null dependslibs libdep.a @@ -128,7 +143,7 @@ $(BASE)/.build/libdep-$(subst /,_,$(CURDIR)).a.d/%.o: $(CURDIR)/src/%.S $(BASE)/.build/libdep-$(subst /,_,$(CURDIR)).a.d/%.o: $(CURDIR)/src/%.cc echo "[ COMPILE C++ ] $<" - $(GCC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) + $(GCC) -c -o $@ $< -MMD -MF "$(dir $@)/.$(notdir $@).dep" $(CFLAGS) $(CPPFLAGS) $(BASE)/.build/libdep-$(subst /,_,$(CURDIR)).a.d/%.o: $(CURDIR)/src/%.txt echo "[ IGNORE ] $<" @@ -155,7 +170,7 @@ $(BASE)/.build/%.o: $(CURDIR)/src/%.S $(BASE)/.build/%.o: $(CURDIR)/src/%.cc echo "[ COMPILE C++ ] $<" - $(GCC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) + $(GCC) -c -o $@ $< -MMD -MF "$(dir $@)/.$(notdir $@).dep" $(CFLAGS) $(CPPFLAGS) $(BASE)/.build/%.o: $(CURDIR)/src/%.txt echo "[ IGNORE ] $<" @@ -164,7 +179,8 @@ $(BASE)/.build/%.o: $(CURDIR)/src/%.txt $(BASE)/.build/.%.dep: - +avrdude: $(BASE)/bin/$(FINALNAME).hex + $(AVRDUDE) -c $(AVR_PROG) -p $(AVR_MCU) -P usb: -B 8 $(AVRDUDE_OPERATIONS) -U flash:w:$(BASE)/bin/$(FINALNAME).hex include $(wildcard $(MODULEDEPS))