summaryrefslogtreecommitdiffstats
path: root/tools/functions.make
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2008-11-20 11:27:31 +0000
committerBjörn Stenberg <bjorn@haxx.se>2008-11-20 11:27:31 +0000
commitc6b3d38a156dd624760a8eb1bb374affd43b4f2a (patch)
tree493eba929e2396d86cf4f077709aa09fe172cd35 /tools/functions.make
parentf66c30346783a400a029bedcd60ab67c81c34a07 (diff)
downloadrockbox-c6b3d38a156dd624760a8eb1bb374affd43b4f2a.tar.gz
rockbox-c6b3d38a156dd624760a8eb1bb374affd43b4f2a.tar.bz2
rockbox-c6b3d38a156dd624760a8eb1bb374affd43b4f2a.zip
New makefile solution: A single invocation of 'make' to build the entire tree. Fully controlled dependencies give faster and more correct recompiles.
Many #include lines adjusted to conform to the new standards. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19146 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/functions.make')
-rw-r--r--tools/functions.make68
1 files changed, 68 insertions, 0 deletions
diff --git a/tools/functions.make b/tools/functions.make
new file mode 100644
index 0000000000..bab8a8d148
--- /dev/null
+++ b/tools/functions.make
@@ -0,0 +1,68 @@
+# __________ __ ___.
+# Open \______ \ ____ ____ | | _\_ |__ _______ ___
+# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+# \/ \/ \/ \/ \/
+# $Id: Makefile 19082 2008-11-10 23:54:24Z zagor $
+#
+
+# preprocess - run preprocessor on a file and return the result as a string
+#
+# This uses the native 'gcc' compiler and not $(CC) since we use the -imacros
+# option and older gcc compiler doesn't have that. We use one such older
+# compiler for the win32 cross-compiles on Linux.
+#
+# The weird grep -v thing in here is due to Apple's stupidities and is needed
+# to make this do right when used on Mac OS X.
+#
+# The sed line is to prepend the directory to all source files
+
+preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) | \
+ grep -v '^\#' | \
+ sed -e 's:^.\+:$(dir $(1))&:')
+
+preprocess2file = $(shell $(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \
+ grep -v '^\#' | grep -v "^$$" > $(2))
+
+c2obj = $(subst .c,.o,$(subst .S,.o,$(subst $(ROOTDIR),$(BUILDDIR),$(1))))
+
+# calculate dependencies for a list of source files $(2) and output them
+# to a file $(1)
+
+mkdepfile = $(shell \
+ for each in $(2); do \
+ obj=`echo $$each | sed -e 's/\.[cS]/.o/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \
+ $(CC) $(PPCFLAGS) $(OTHER_INC) -MG -MM -include config.h -MT "$$obj" $$each 2>/dev/null; \
+ done | sed -e "s: lang.h: $(BUILDDIR)/lang.o:" \
+ -e "s: sysfont.h: $(BUILDDIR)/sysfont.h:" \
+ -e "s: max_language_size.h: $(BUILDDIR)/max_language_size.h:" \
+ -e "s: bitmaps/: $(BUILDDIR)/bitmaps/:g" \
+ -e "s: pluginbitmaps/: $(BUILDDIR)/pluginbitmaps/:g" \
+ -e "s: lib/: $(APPSDIR)/plugins/lib/:g" \
+ -e "s: codeclib.h: $(APPSDIR)/codecs/lib/codeclib.h:g" \
+ > $(1); )
+
+# function to create .bmp dependencies
+bmpdepfile = $(shell \
+ for each in $(2); do \
+ obj=`echo $$each | sed -e 's/\.bmp/.o/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \
+ src=`echo $$each | sed -e 's/\.bmp/.c/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \
+ echo $$obj: $$src; \
+ echo $$src: $$each; \
+ done \
+ >> $(1); )
+
+ifndef V
+SILENT:=@
+else
+VERBOSEOPT:=-v
+endif
+PRINTS=$(SILENT)$(call info,$(1))
+
+# old 'make' versions don't have the built-in 'info' function
+info=old$(shell echo >&2 "Consider upgrading to GNU make 3.81+ for optimum build performance.")
+ifeq ($(call info),old)
+export info=echo "$$(1)";
+endif
+