summaryrefslogtreecommitdiff
path: root/tools/functions.make
diff options
context:
space:
mode:
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 @@
1# __________ __ ___.
2# Open \______ \ ____ ____ | | _\_ |__ _______ ___
3# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6# \/ \/ \/ \/ \/
7# $Id: Makefile 19082 2008-11-10 23:54:24Z zagor $
8#
9
10# preprocess - run preprocessor on a file and return the result as a string
11#
12# This uses the native 'gcc' compiler and not $(CC) since we use the -imacros
13# option and older gcc compiler doesn't have that. We use one such older
14# compiler for the win32 cross-compiles on Linux.
15#
16# The weird grep -v thing in here is due to Apple's stupidities and is needed
17# to make this do right when used on Mac OS X.
18#
19# The sed line is to prepend the directory to all source files
20
21preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) | \
22 grep -v '^\#' | \
23 sed -e 's:^.\+:$(dir $(1))&:')
24
25preprocess2file = $(shell $(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \
26 grep -v '^\#' | grep -v "^$$" > $(2))
27
28c2obj = $(subst .c,.o,$(subst .S,.o,$(subst $(ROOTDIR),$(BUILDDIR),$(1))))
29
30# calculate dependencies for a list of source files $(2) and output them
31# to a file $(1)
32
33mkdepfile = $(shell \
34 for each in $(2); do \
35 obj=`echo $$each | sed -e 's/\.[cS]/.o/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \
36 $(CC) $(PPCFLAGS) $(OTHER_INC) -MG -MM -include config.h -MT "$$obj" $$each 2>/dev/null; \
37 done | sed -e "s: lang.h: $(BUILDDIR)/lang.o:" \
38 -e "s: sysfont.h: $(BUILDDIR)/sysfont.h:" \
39 -e "s: max_language_size.h: $(BUILDDIR)/max_language_size.h:" \
40 -e "s: bitmaps/: $(BUILDDIR)/bitmaps/:g" \
41 -e "s: pluginbitmaps/: $(BUILDDIR)/pluginbitmaps/:g" \
42 -e "s: lib/: $(APPSDIR)/plugins/lib/:g" \
43 -e "s: codeclib.h: $(APPSDIR)/codecs/lib/codeclib.h:g" \
44 > $(1); )
45
46# function to create .bmp dependencies
47bmpdepfile = $(shell \
48 for each in $(2); do \
49 obj=`echo $$each | sed -e 's/\.bmp/.o/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \
50 src=`echo $$each | sed -e 's/\.bmp/.c/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \
51 echo $$obj: $$src; \
52 echo $$src: $$each; \
53 done \
54 >> $(1); )
55
56ifndef V
57SILENT:=@
58else
59VERBOSEOPT:=-v
60endif
61PRINTS=$(SILENT)$(call info,$(1))
62
63# old 'make' versions don't have the built-in 'info' function
64info=old$(shell echo >&2 "Consider upgrading to GNU make 3.81+ for optimum build performance.")
65ifeq ($(call info),old)
66export info=echo "$$(1)";
67endif
68