X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=rules.mk;h=e764924e29685b7ba8c214363d30bee3e05dc077;hb=7920ccf2c9be523f680d88ef7d681d09af7da209;hp=4b53a17f50ca83692906b7d283d1bae7639bafec;hpb=cc15bc8568ee6dc6032687a6f8d892b702e9c8a2;p=bertos.git diff --git a/rules.mk b/rules.mk index 4b53a17f..e764924e 100755 --- a/rules.mk +++ b/rules.mk @@ -10,6 +10,15 @@ # Author: Bernardo Innocenti # # $Log$ +# Revision 1.4 2006/07/19 12:56:24 bernie +# Convert to new Doxygen style. +# +# Revision 1.3 2006/05/27 22:42:24 bernie +# Search for verstag.h in app subdirs first. +# +# Revision 1.2 2006/03/27 04:48:33 bernie +# Add CXXFLAGS; Add recursive targets. +# # Revision 1.1 2006/03/22 09:51:53 bernie # Add build infrastructure. # @@ -96,9 +105,12 @@ TRG_BIN = $(TRG:%=$(OUTDIR)/%.bin) TRG_ROM = $(TRG:%=$(OUTDIR)/%.rom) TRG_COF = $(TRG:%=$(OUTDIR)/%.cof) + +RECURSIVE_TARGETS = all-recursive install-recursive clean-recursive + # The default target .PHONY: all -all:: $(TRG_S19) $(TRG_HEX) +all:: all-recursive $(TRG_S19) $(TRG_HEX) # Generate project documentation .PHONY: docs @@ -130,27 +142,27 @@ OBJ += $$($(1)_OBJ) # Compile: instructions to create assembler and/or object files from C source $$($(1)_COBJ) : $$(OBJDIR)/$(1)/%.o : %.c - $L "$(1): Compiling $$<" + $L "$(1): Compiling $$< (C)" @$$(MKDIR_P) $$(dir $$@) - $Q $$(CC) -c $$(CFLAGS) $$($(1)_CFLAGS) $$< -o $$@ + $Q $$(CC) -c $$($(1)_CFLAGS) $$(CFLAGS) $$< -o $$@ # Compile: instructions to create assembler and/or object files from C++ source $$($(1)_CXXOBJ) : $$(OBJDIR)/$(1)/%.o : %.cpp - $L "$(1): Compiling $$<" + $L "$(1): Compiling $$< (C++)" @$$(MKDIR_P) $$(dir $$@) - $Q $$(CXX) -c $$(CFLAGS) $$($(1)_CFLAGS) $$< -o $$@ + $Q $$(CXX) -c $$($(1)_CXXFLAGS) $$(CXXFLAGS) $$< -o $$@ # Generate assembly sources from C files (debug) $$(OBJDIR)/$(1)/%.s : %.c $L "$(1): Generating asm source $$<" @$$(MKDIR_P) $$(dir $$@) - $Q $$(CC) -S $$(CFLAGS) $$($(1)_CFLAGS) $$< -o $$@ + $Q $$(CC) -S $$($(1)_CFLAGS) $$(CFLAGS) $$< -o $$@ # Generate special progmem variant of a source file $$($(1)_PCOBJ) : $$(OBJDIR)/$(1)/%_P.o : %.c $L "$(1): Compiling $$< (PROGMEM)" @$$(MKDIR_P) $$(dir $$@) - $Q $$(CC) -c -D_PROGMEM $$(CFLAGS) $$($(1)_CFLAGS) $$< -o $$@ + $Q $$(CC) -c -D_PROGMEM $$($(1)_CFLAGS) $$(CFLAGS) $$< -o $$@ # Assemble: instructions to create object file from assembler files $$($(1)_AOBJ): $$(OBJDIR)/$(1)/%.o : %.s @@ -173,7 +185,7 @@ $$(OUTDIR)/$(1).elf: bumprev $$($(1)_OBJ) $$($(1)_LDSCRIPT) $$(OUTDIR)/$(1)_whole.elf: bumprev $$($(1)_SRC) $$($(1)_LDSCRIPT) $L "$(1): Compiling and Linking whole program $$@" @$$(MKDIR_P) $$(dir $$@) - $Q $$(CC) $$($(1)_SRC) $$(CFLAGS) $$($(1)_CFLAGS) $$(LIB) $$(LDFLAGS) $$($(1)_LDFLAGS) -o $$@ + $Q $$(CC) $$($(1)_SRC) $$($(1)_CFLAGS) $$(CFLAGS) $$(LIB) $$(LDFLAGS) $$($(1)_LDFLAGS) -o $$@ # Flash target # NOTE: we retry in case of failure because the STK500 programmer is crappy @@ -182,6 +194,7 @@ flash_$(1): $(OUTDIR)/$(1).s19 flash_$(1)_local if ! $(AVRDUDE) $(DPROG) -p $$($(1)_MCU) -U flash:w:$$< ; then \ $(AVRDUDE) $(DPROG) -p $$($(1)_MCU) -U flash:w:$$< ; \ fi + #avarice --mkII -j usb --erase --program --verify --file images/triface.elf .PHONY: flash_$(1)_local flash_$(1)_local: @@ -235,12 +248,33 @@ $(foreach t,$(TRG),$(eval $(call build_target,$(t)))) # $(COFFCONVERT) -O coff-avr $< $@ # For use with AVRstudio 3 #make instruction to delete created files -clean: +clean: clean-recursive -$(RM_R) $(OBJDIR) -$(RM_R) $(OUTDIR) +$(RECURSIVE_TARGETS): + @target=`echo $@ | sed s/-recursive//`; \ + for dir in $(SUBDIRS); do \ + if [ -e $$dir/configure.in ] || [ -e $$dir/configure.ac ] && [ ! -x $$dir/configure ]; then \ + echo "Running autogen.sh in $$dir..."; \ + ( cd $$dir && chmod a+x autogen.sh && ./autogen.sh && rm -f Makefile || exit 1 ); \ + fi; \ + if [ ! -e $$dir/Makefile ]; then \ + if [ -e "$$dir/build-$(ARCH)" ]; then \ + echo "Running build script in $$dir..."; \ + ( cd $$dir && chmod a+x build && ./build || exit 1 ); \ + else \ + echo "Running configure in $$dir..."; \ + ( cd $$dir && ./configure --prefix=$(PREFIX) || exit 1 ); \ + fi; \ + fi; \ + $(MAKE) -C $$dir $$target || exit 1; \ + done + BUILDREV_H = buildrev.h +ifeq ($(shell [ -e verstag.c ] && echo yes), yes) +.PHONY: bumprev bumprev: @buildnr=0; \ if [ -f $(BUILDREV_H) ]; then \ @@ -251,7 +285,13 @@ bumprev: echo "#define VERS_BUILD $$buildnr" >"$(BUILDREV_H)"; \ echo "#define VERS_HOST \"$$buildhost\"" >>"$(BUILDREV_H)"; \ echo "Building revision $$buildnr" +else +.PHONY: bumprev +bumprev: + +endif # Include dependencies +ifneq ($(strip $(OBJ)),) -include $(OBJ:%.o=%.d) - +endif