# Author: Bernardo Innocenti <bernie@develer.com>
#
# $Log$
+# Revision 1.6 2006/09/13 18:38:59 bernie
+# Sort CPP options to let apps override include paths.
+#
+# Revision 1.5 2006/09/13 18:30:52 bernie
+# Add CPPFLAGS to all rules.
+#
+# 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.
#
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
# 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 $$(CFLAGS) $$($(1)_CFLAGS) $$($(1)_CPPFLAGS) $$(CPPFLAGS) $$< -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 $$(CXXFLAGS) $$($(1)_CXXFLAGS) $$($(1)_CPPFLAGS) $$(CPPFLAGS) $$< -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 $$(CFLAGS) $$($(1)_CFLAGS) $$($(1)_CPPFLAGS) $$< -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 $$(CFLAGS) $$($(1)_CFLAGS) $$($(1)_CPPFLAGS) $$(CPPFLAGS) $$< -o $$@
# Assemble: instructions to create object file from assembler files
$$($(1)_AOBJ): $$(OBJDIR)/$(1)/%.o : %.s
$$($(1)_CPPAOBJ): $$(OBJDIR)/$(1)/%.o : %.S
$L "$(1): Assembling with CPP $$<"
@$$(MKDIR_P) $$(dir $$@)
- $Q $$(CC) -c $$(CPPAFLAGS) $$($(1)_CPPAFLAGS) $$< -o $$@
+ $Q $$(CC) -c $$(CPPAFLAGS) $$($(1)_CPPAFLAGS) $$($(1)_CPPFLAGS) $$(CPPFLAGS) $$< -o $$@
# Link: instructions to create elf output file from object files
$$(OUTDIR)/$(1).elf: bumprev $$($(1)_OBJ) $$($(1)_LDSCRIPT)
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:
# $(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 \
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