Use Rockbox version for created voicefile version.
[maemo-rb.git] / tools / functions.make
blob2a26e48bf2698ea71bbb817aa02afc104d6f6e7b
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 # preprocess - run preprocessor on a file and return the result as a string
12 # The weird grep -v thing in here is due to Apple's stupidities and is needed
13 # to make this do right when used on Mac OS X.
15 # The sed line is to prepend the directory to all source files
17 preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c -include config.h $(1) | \
18 grep -v '^\#' | grep -v "^ *$$" | \
19 sed -e 's:^..*:$(dir $(1))&:')
21 preprocess2file = $(SILENT)$(CC) $(PPCFLAGS) $(3) -E -P -x c -include config.h $(1) | \
22 grep -v '^\#' | grep -v "^$$" > $(2)
24 asmdefs2file = $(SILENT)$(CC) $(PPCFLAGS) $(3) -S -x c -o - -include config.h $(1) | \
25 perl -ne 'if(/^_?AD_(\w+):$$/){$$var=$$1}else{/^\W\.(?:word|long)\W(.*)$$/ && $$var && print "\#define $$var $$1\n";$$var=0}' > $(2)
27 c2obj = $(addsuffix .o,$(basename $(subst $(ROOTDIR),$(BUILDDIR),$(1))))
29 a2lnk = $(patsubst lib%.a,-l%,$(notdir $(1)))
31 # objcopy wrapper that keeps debug symbols in DEBUG builds
32 # handles the $(1) == $(2) case too
33 ifndef APP_TYPE
34 objcopy = $(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $(1) $(2) # objcopy native
35 else ifneq (,$(findstring sdl-sim,$(APP_TYPE)))
36 objcopy = cp $(1) $(1).tmp;mv -f $(1).tmp $(2) # objcopy simulator
37 else
38 ifdef DEBUG
39 objcopy = cp $(1) $(1).tmp;mv -f $(1).tmp $(2) # objcopy hosted (DEBUG)
40 else
41 objcopy = $(OC) -S -x $(1) $(2) # objcopy hosted (!DEBUG)
42 endif
43 endif
45 # calculate dependencies for a list of source files $(2) and output them to $(1)
46 mkdepfile = $(SILENT)perl $(TOOLSDIR)/multigcc.pl $(CC) $(PPCFLAGS) $(OTHER_INC) -MG -MM -include config.h -- $(2) | \
47 sed -e "s: lang.h: lang/lang.h:" \
48 -e 's:_asmdefs.o:_asmdefs.h:' \
49 -e "s: max_language_size.h: lang/max_language_size.h:" | \
50 $(TOOLSDIR)/addtargetdir.pl $(ROOTDIR) $(BUILDDIR) \
51 >> $(1)
53 # function to create .bmp dependencies
54 bmpdepfile = $(SILENT) \
55 for each in $(2); do \
56 obj=`echo $$each | sed -e 's/\.bmp/.o/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \
57 src=`echo $$each | sed -e 's/\.bmp/.c/' -e 's:$(ROOTDIR):$(BUILDDIR):'`; \
58 echo $$obj: $$src; \
59 echo $$src: $$each; \
60 done \
61 >> $(1)
63 ifndef V
64 SILENT:=@
65 else
66 VERBOSEOPT:=-v
67 endif
68 PRINTS=$(SILENT)$(call info,$(1))
70 # old 'make' versions don't have the built-in 'info' function
71 info=old$(shell echo >&2 "Consider upgrading to GNU make 3.81+ for optimum build performance.")
72 ifeq ($(call info),old)
73 export info=echo "$$(1)";
74 endif