From c6b3d38a156dd624760a8eb1bb374affd43b4f2a Mon Sep 17 00:00:00 2001 From: Björn Stenberg Date: Thu, 20 Nov 2008 11:27:31 +0000 Subject: 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 --- tools/Makefile | 4 +- tools/configure | 183 +------------------------------ tools/functions.make | 68 ++++++++++++ tools/makebmp.inc | 33 ------ tools/makesubdirs.inc | 14 --- tools/root.make | 294 ++++++++++++++++++++++++++++++++++++++++++++++++++ tools/tools.make | 40 +++++++ 7 files changed, 409 insertions(+), 227 deletions(-) create mode 100644 tools/functions.make delete mode 100644 tools/makebmp.inc delete mode 100644 tools/makesubdirs.inc create mode 100644 tools/root.make create mode 100644 tools/tools.make (limited to 'tools') diff --git a/tools/Makefile b/tools/Makefile index 0bd0209b86..569a727139 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -15,8 +15,8 @@ CLEANALL := scramble descramble iriver sh2d bmp2rb rdf2binary convbdf \ generate_rocklatin mkboot ipod_fw codepages uclpack mi4 gigabeat database \ lngdump telechips gigabeats creative hmac-sha1 mktccboot mknkboot rbspeexenc mkzenboot -all: - @echo "Run make in your build directory!" +all: scramble descramble sh2d rdf2binary mkboot mktccboot mknkboot mkzenboot \ + convbdf codepages uclpack rbspeexenc voicefont scramble: scramble.o iriver.o mi4.o gigabeat.o gigabeats.o telechips.o iaudio_bl_flash.o creative.o hmac-sha1.o descramble: descramble.o iriver.o gigabeat.o diff --git a/tools/configure b/tools/configure index 433dc6683c..0f6c3bb8c0 100755 --- a/tools/configure +++ b/tools/configure @@ -1325,8 +1325,6 @@ fi boottool="$rootdir/tools/scramble -tcc=crc" bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_native="$rootdir/tools/bmp2rb -f 4" - bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" - bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" output="rockbox.d2" appextra="recorder:gui" plugins="yes" @@ -1414,8 +1412,6 @@ fi tool="cp " bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_native="$rootdir/tools/bmp2rb -f 4" - bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" - bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" output="rockbox.mrobe500" appextra="recorder:gui" plugins="yes" @@ -1438,8 +1434,6 @@ fi tool="$rootdir/tools/scramble -mi4v2 -model=m100 -type=RBOS" bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_native="$rootdir/tools/bmp2rb -f 0" - bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" - bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" output="rockbox.mi4" appextra="recorder:gui" plugins="yes" @@ -1487,8 +1481,6 @@ fi arm926ejscc bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_native="$rootdir/tools/bmp2rb -f 4" - bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" - bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" tool="$rootdir/tools/scramble -creative=zvm" USE_ELF="yes" output="rockbox.zvm" @@ -1512,8 +1504,6 @@ fi arm926ejscc bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_native="$rootdir/tools/bmp2rb -f 4" - bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" - bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" tool="$rootdir/tools/scramble -creative=zvm60 -no-ciff" USE_ELF="yes" output="rockbox.zvm60" @@ -1537,8 +1527,6 @@ fi arm926ejscc bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_native="$rootdir/tools/bmp2rb -f 4" - bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" - bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" tool="$rootdir/tools/scramble -creative=zenvision -no-ciff" USE_ELF="yes" output="rockbox.zv" @@ -2074,6 +2062,8 @@ fi debug="-DDEBUG" simulator="yes" extradefines="-DSIMULATOR" + archosrom="" + flash="" echo "Simulator build selected" ;; [Aa]) @@ -2397,18 +2387,6 @@ sed > Makefile \ <&2 "Consider upgrading to GNU make 3.81+ for optimum build performance.") -ifeq (\$(call info),old) -export info=echo "\$\$(1)"; -endif - export ROOTDIR=@ROOTDIR@ export FIRMDIR=@FIRMDIR@ export APPSDIR=@APPSDIR@ @@ -2428,8 +2406,8 @@ export BUILDDIR=@PWD@ export LANGUAGE=@LANGUAGE@ export VOICELANGUAGE=@VOICELANGUAGE@ export MEMORYSIZE=@MEMORY@ -export VERSION=\$(shell \$(ROOTDIR)/tools/svnversion.sh \$(ROOTDIR)) -export BUILDDATE=\$(shell date -u +'-DYEAR=%Y -DMONTH=%m -DDAY=%d') +export VERSION:=\$(shell \$(ROOTDIR)/tools/svnversion.sh \$(ROOTDIR)) +export BUILDDATE:=\$(shell date -u +'-DYEAR=%Y -DMONTH=%m -DDAY=%d') export MKFIRMWARE=@TOOL@ export BMP2RB_MONO=@BMP2RB_MONO@ export BMP2RB_NATIVE=@BMP2RB_NATIVE@ @@ -2469,159 +2447,8 @@ export ENC_OPTS=@ENC_OPTS@ export ENCODER=@ENCODER@ export USE_ELF=@USE_ELF@ -# Do not print "Entering directory ..." -MAKEFLAGS += --no-print-directory - -.PHONY: all clean tags zip tools manual bin build info langs - -all: info - -info: build - \$(SILENT)\$(TOOLSDIR)/mkinfo.pl \$(BUILDDIR)/rockbox-info.txt - -build: tools @LANGS@ - @SIMUL1@ - @SIMUL2@ - \$(SILENT)\$(MAKE) -C \$(FIRMDIR) OBJDIR=\$(BUILDDIR)/firmware - \$(SILENT)\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@ - -bin: tools @LANGS@ - @SIMUL1@ - @SIMUL2@ - \$(SILENT)\$(MAKE) -C \$(FIRMDIR) OBJDIR=\$(BUILDDIR)/firmware - \$(SILENT)\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@ \$(BUILDDIR)/\$(BINARY) - -rocks: tools - \$(SILENT)\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@ rocks - -veryclean: clean toolsclean - -toolsclean: - \$(SILENT)\$(MAKE) -C \$(TOOLSDIR) clean - -clean: - \$(SILENT)echo Cleaning build directory - \$(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \ - rockbox.tar.bz2 TAGS @APPS@ firmware comsim sim lang.[ch] \ - manual *.pdf *.a credits.raw @OUTPUT@ bitmaps pluginbitmaps \ - @ARCHOSROM@ @FLASHFILE@ UI256.bmp rockbox-full.zip \ - html txt rockbox-manual*.zip sysfont.h rockbox-info.txt \ - voicefontids *.wav *.mp3 *.voice max_language_size.h - -tools: - \$(SILENT)\$(MAKE) -C \$(TOOLSDIR) CC=\$(HOSTCC) AR=\$(HOSTAR) @TOOLSET@ - -voicetools: - \$(SILENT)\$(MAKE) -C \$(TOOLSDIR) CC=\$(HOSTCC) AR=\$(HOSTAR) @VOICETOOLSET@ - -tags: - \$(SILENT)rm -f TAGS - \$(SILENT)\$(MAKE) -C \$(FIRMDIR) tags - \$(SILENT)\$(MAKE) -C \$(APPSDIR) tags - \$(SILENT)\$(MAKE) -C \$(APPSDIR)/plugins tags - \$(SILENT)\$(MAKE) -C \$(APPSDIR)/plugins/lib tags - -fontzip: - \$(SILENT)\$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(MODELNAME)\" -r "\$(ROOTDIR)" -f 1 -o rockbox-fonts.zip \$(TARGET) \$(BINARY) - -zip: info - \$(SILENT)for f in \`cat \$(BUILDDIR)/@APPS@/features\`; do feat="\$\$feat:\$\$f" ; done ; \\ - \$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(MODELNAME)\$\$feat\" -i \"\$(TARGET_ID)\" -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY) - -mapzip: info - \$(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip - -fullzip: info - \$(SILENT)for f in \`cat \$(BUILDDIR)/@APPS@/features\`; do feat="\$\$feat:\$\$f" ; done; \\ - \$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(MODELNAME)\$\$feat\" -i \"\$(TARGET_ID)\" -r "\$(ROOTDIR)" -f 2 -o rockbox-full.zip \$(TARGET) \$(BINARY) - -7zip: info - \$(SILENT)for f in \`cat \$(BUILDDIR)/@APPS@/features\`; do feat="\$\$feat:\$\$f" ; done; \\ - \$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(MODELNAME)\$\$feat\" -i \"\$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY) - -tar: info - \$(SILENT)rm -f rockbox.tar - \$(SILENT)for f in \`cat \$(BUILDDIR)/@APPS@/features\`; do feat="\$\$feat:\$\$f" ; done; \\ - \$(TOOLSDIR)/buildzip.pl \$(VERBOSEOPT) -t \"\$(MODELNAME)\$\$feat\" -i \"\$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "\$(ROOTDIR)" \$(TARGET) \$(BINARY) - -bzip2: tar - \$(SILENT)bzip2 -f9 rockbox.tar - -gzip: tar - \$(SILENT)gzip -f9 rockbox.tar - -langs: features - \$(SILENT)mkdir -p \$(BUILDDIR)/apps/lang - \$(SILENT)\$(MAKE) -C \$(APPSDIR)/lang OBJDIR=\$(BUILDDIR)/apps/lang - -manual: manual-pdf -manual-pdf: - \$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-pdf -manual-html: - \$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-html -manual-zhtml: manual-zip -manual-txt: - \$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-txt -manual-ztxt: - \$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-txt-zip -manual-zip: - \$(SILENT)\$(MAKE) -C \$(MANUALDIR) OBJDIR=\$(BUILDDIR)/manual manual-zip - -features: tools - \$(SILENT)\$(MAKE) -C \$(APPSDIR) OBJDIR=\$(BUILDDIR)/@APPS@ features - -help: - @echo "A few helpful make targets" - @echo "" - @echo "all - builds a full Rockbox (default), including tools" - @echo "bin - builds only the Rockbox. file" - @echo "rocks - builds only plugins and codecs" - @echo "clean - cleans a build directory (not tools)" - @echo "veryclean - cleans the build and tools directories" - @echo "manual - builds a manual" - @echo "manual-html - HTML manual" - @echo "manual-zip - HTML manual (zipped)" - @echo "manual-txt - txt manual" - @echo "fullzip - creates a rockbox.zip of your build with fonts" - @echo "zip - creates a rockbox.zip of your build (no fonts)" - @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)" - @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)" - @echo "7zip - creates a rockbox.7z of your build (no fonts)" - @echo "fontzip - creates rockbox-fonts.zip" - @echo "mapzip - creates rockbox-maps.zip with all .map files" - @echo "tools - builds the tools only" - @echo "voicetools - builds the voice tools only" - @echo "install - installs your build (for simulator builds only, no fonts)" - @echo "fullinstall - installs your build (for simulator builds only, with fonts)" +include \$(TOOLSDIR)/root.make EOF -if [ "yes" = "$simulator" ]; then - - cat >> Makefile <> Makefile < ) \___| < | \_\ ( <_> > < < +# 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 + diff --git a/tools/makebmp.inc b/tools/makebmp.inc deleted file mode 100644 index 987a21457f..0000000000 --- a/tools/makebmp.inc +++ /dev/null @@ -1,33 +0,0 @@ -all: $(OUTPUT) - -dep: $(DEPFILE) - -ifndef V -SILENT=@ -endif -PRINTS=$(SILENT)$(call info,$(1)) - -$(OBJDIR)/%.c: %.bmp - $(SILENT)mkdir -p $(dir $@) - $(SILENT)mkdir -p $(BMPINCDIR) - $(call PRINTS,BMP2RB $<)$(BMP2RB) -h $(BMPINCDIR) $< > $@ - -$(OBJDIR)/%.o: $(OBJDIR)/%.c - $(SILENT)mkdir -p $(dir $@) - $(call PRINTS,CC $(> $(DEPFILE) ; \ - obj=`echo $$each | sed -e 's/\.bmp/.o/'`; \ - echo $(OBJDIR)/$$obj: $(OBJDIR)/$$src >> $(DEPFILE) ; \ - fi; \ - done) - -$(OUTPUT): $(OBJS) - $(call PRINTS,AR+RANLIB $(@F))$(AR) ruv $@ $+ >/dev/null 2>&1 - $(SILENT)$(RANLIB) $@ diff --git a/tools/makesubdirs.inc b/tools/makesubdirs.inc deleted file mode 100644 index b233430f78..0000000000 --- a/tools/makesubdirs.inc +++ /dev/null @@ -1,14 +0,0 @@ -# -*- Makefile -*- - -# return the list of extra sub-directories to build in the SUBDIRS variable - -# This uses the native 'gcc' compiler and not $(CC) since we use the -include -# 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. - -SUBDIRS := $(shell cat SUBDIRS | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) \ -$(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - | \ -grep -v "^\#") diff --git a/tools/root.make b/tools/root.make new file mode 100644 index 0000000000..87937d9cd1 --- /dev/null +++ b/tools/root.make @@ -0,0 +1,294 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id: Makefile 19082 2008-11-10 23:54:24Z zagor $ +# + +include $(TOOLSDIR)/functions.make + +DEFINES = -DROCKBOX -DMEMORYSIZE=$(MEMORYSIZE) -DMEM=$(MEMORYSIZE) $(TARGET) \ + -DTARGET_ID=$(TARGET_ID) -DTARGET_NAME=\"$(MODELNAME)\" \ + -DAPPSVERSION=\"$(VERSION)\" $(BUILDDATE) \ + $(EXTRA_DEFINES) # <-- -DSIMULATOR or not +INCLUDES = -I$(BUILDDIR) $(TARGET_INC) + +CFLAGS = $(INCLUDES) $(DEFINES) $(GCCOPTS) +PPCFLAGS = $(filter-out -Dmain=SDL_main,$(CFLAGS)) # cygwin sdl-config fix + +TOOLS = $(TOOLSDIR)/rdf2binary $(TOOLSDIR)/convbdf \ + $(TOOLSDIR)/codepages $(TOOLSDIR)/scramble $(TOOLSDIR)/bmp2rb \ + $(TOOLSDIR)/uclpack $(TOOLSDIR)/mktccboot $(TOOLSDIR)/mkboot + +# list suffixes to be understood by $* +.SUFFIXES: .rock .codec .map .elf .c .S .o .bmp .a + +.PHONY: all clean tags zip tools manual bin build info langs + +DEPFILE = $(BUILDDIR)/make.dep + +all: $(DEPFILE) build + +# Subdir makefiles. their primary purpose is to populate SRC & OTHER_SRC +# but they also define special dependencies and compile rules +include $(TOOLSDIR)/tools.make +include $(FIRMDIR)/firmware.make +include $(ROOTDIR)/apps/bitmaps/bitmaps.make + +ifneq (,$(findstring bootloader,$(APPSDIR))) + include $(APPSDIR)/bootloader.make +else ifneq (,$(findstring bootbox,$(APPSDIR))) + include $(APPSDIR)/bootbox.make +else + include $(APPSDIR)/apps.make + include $(APPSDIR)/lang/lang.make + + ifdef SOFTWARECODECS + include $(APPSDIR)/codecs/codecs.make + endif + + ifdef ENABLEDPLUGINS + include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make + include $(APPSDIR)/plugins/plugins.make + endif + + ifdef SIMVER + include $(ROOTDIR)/uisimulator/uisimulator.make + endif +endif # bootloader + +OBJ := $(SRC:.c=.o) +OBJ := $(OBJ:.S=.o) +OBJ += $(BMP:.bmp=.o) +OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ)) + +build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) + $(SILENT)$(TOOLSDIR)/mkinfo.pl $(BUILDDIR)/rockbox-info.txt + +ifneq (clean,$(findstring clean,$(MAKECMDGOALS))) # don't build deps before cleaning +$(DEPFILE) dep: + $(call PRINTS,Generating dependencies) + @echo foo > /dev/null # there must be a "real" command in the rule + $(call mkdepfile,$(DEPFILE),$(SRC) $(OTHER_SRC)) + $(call bmpdepfile,$(DEPFILE),$(BMP) $(PBMP)) +endif + +bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) +rocks: $(DEPFILE) $(TOOLS) $(ROCKS) +codecs: $(DEPFILE) $(TOOLS) $(CODECS) + +-include $(DEPFILE) + +veryclean: clean + $(SILENT)rm -rf $(TOOLS) + +clean: + $(SILENT)echo Cleaning build directory + $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz rockbox.tar.bz2 TAGS apps firmware comsim sim lang.[ch] manual *.pdf *.a credits.raw rockbox.ipod bitmaps pluginbitmaps UI256.bmp rockbox-full.zip html txt rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids *.wav *.mp3 *.voice max_language_size.h $(CLEANOBJS) $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin $(DEPFILE) rombox.elf rombox.map rombox.bin $(BINARY) $(FLASHFILE) uisimulator bootloader flash + +#### linking the binaries: #### + +.SECONDEXPANSION: + +ifndef SIMVER + +ifeq (,$(findstring bootloader,$(APPSDIR))) +# not bootloader + +## target build +RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds +LINKRAM := $(BUILDDIR)/ram.link +ROMLDS := $(FIRMDIR)/rom.lds +LINKROM := $(BUILDDIR)/rom.link + +$(LINKRAM): $(RAMLDS) + $(call PRINTS,PP $(@F)) + $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS)) + +$(LINKROM): $(ROMLDS) + $(call PRINTS,PP $(@F)) + $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS)) + +$(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKRAM) + $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Wl,--gc-sections -Os -nostdlib -o $@ $(OBJ) \ + -L$(BUILDDIR)/firmware -lfirmware\ + -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \ + -lgcc \ + -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map + +$(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKROM) + $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \ + $(VOICESPEEXLIB) $(FIRMLIB) -lgcc -L$(BUILDDIR)/firmware \ + -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rockbox.map + +$(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf + $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@ + +$(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf + $(call PRINTS,OC $(@F))$(OC) -O binary $< $@ + +# +# If there's a flashfile defined for this target (rockbox.ucl for Archos +# models) Then check if the mkfirmware script fails, as then it is (likely) +# because the image is too big and we need to create a compressed image +# instead. +# +$(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE) + $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \ + stat=$$?; \ + if test -n "$(FLASHFILE)"; then \ + if test "$$stat" -ne 0; then \ + echo "Image too big, making a compressed version!"; \ + $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \ + $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \ + fi \ + fi ) + +# archos +$(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin + $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null 2>&1 + +MAXINFILE = $(BUILDDIR)/temp.txt +MAXOUTFILE = $(BUILDDIR)/romstart.txt + +$(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE) + $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \ + perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \ + if test $$? -ne 0; then \ + echo "removing UCL file again, making it a fake one"; \ + echo "fake" > $@; \ + fi + +$(MAXOUTFILE): + $(call PRINTS,Creating $(@F)) + $(SILENT)$(shell echo '#include "config.h"' > $(MAXINFILE)) + $(SILENT)$(shell echo "ROM_START" >> $(MAXINFILE)) + $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE)) + $(SILENT)rm $(MAXINFILE) + +# iriver +$(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin + $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@ + +endif # !bootloader +endif # !SIMVER + + +voicetools: + $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim + +tags: + $(SILENT)rm -f TAGS + $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC)) + +fontzip: + $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)\" -r "$(ROOTDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY) + +zip: + $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \ + $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" $(TARGET) $(BINARY) + +mapzip: + $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip + +fullzip: + $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \ + $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY) + +7zip: + $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \ + $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" $(TARGET) $(BINARY) + +tar: + $(SILENT)rm -f rockbox.tar + $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \ + $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" $(TARGET) $(BINARY) + +bzip2: tar + $(SILENT)bzip2 -f9 rockbox.tar + +gzip: tar + $(SILENT)gzip -f9 rockbox.tar + +manual manual-pdf: + $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf +manual-html: + $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html +manual-zhtml: manual-zip +manual-txt: + $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt +manual-ztxt: + $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip +manual-zip: + $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip + +ifdef TTS_ENGINE + +voice: voicetools features + $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \ + for lang in `echo $(VOICELANGUAGE) |sed "s/,/ /g"`; do $(TOOLSDIR)/voice.pl -V -l=$$lang -t=$(MODELNAME)$$feat -i=$(TARGET_ID) -e="$(ENCODER)" -E="$(ENC_OPTS)" -s=$(TTS_ENGINE) -S="$(TTS_OPTS)"; done \ + +endif + +ifdef SIMVER + +install: + @echo "Installing your build in your archos dir" + $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \ + $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -s -r "$(ROOTDIR)" -f 0 $(TARGET) $(BINARY) + +fullinstall: + @echo "Installing a full setup in your archos dir" + $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \ + $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -s -r "$(ROOTDIR)" -f 2 $(TARGET) $(BINARY) + +endif + +help: + @echo "A few helpful make targets" + @echo "" + @echo "all - builds a full Rockbox (default), including tools" + @echo "bin - builds only the Rockbox. file" + @echo "rocks - builds only plugins" + @echo "codecs - builds only codecs" + @echo "dep - regenerates make dependency database" + @echo "clean - cleans a build directory (not tools)" + @echo "veryclean - cleans the build and tools directories" + @echo "manual - builds a manual (pdf)" + @echo "manual-html - HTML manual" + @echo "manual-zip - HTML manual (zipped)" + @echo "manual-txt - txt manual" + @echo "fullzip - creates a rockbox.zip of your build with fonts" + @echo "zip - creates a rockbox.zip of your build (no fonts)" + @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)" + @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)" + @echo "7zip - creates a rockbox.7z of your build (no fonts)" + @echo "fontzip - creates rockbox-fonts.zip" + @echo "mapzip - creates rockbox-maps.zip with all .map files" + @echo "tools - builds the tools only" + @echo "voice - creates the voice clips (voice builds only)" + @echo "voicetools - builds the voice tools only" + @echo "install - installs your build (for simulator builds only, no fonts)" + @echo "fullinstall - installs your build (for simulator builds only, with fonts)" + +### general compile rules: + +# when source and object are in different locations (normal): +$(BUILDDIR)/%.o: $(ROOTDIR)/%.c + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@ + +$(BUILDDIR)/%.o: $(ROOTDIR)/%.S + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@ + +# when source and object are both in BUILDDIR (generated code): +%.o: %.c + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@ + +%.o: %.S + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@ diff --git a/tools/tools.make b/tools/tools.make new file mode 100644 index 0000000000..48717c1220 --- /dev/null +++ b/tools/tools.make @@ -0,0 +1,40 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id: Makefile 19082 2008-11-10 23:54:24Z zagor $ +# + +TOOLSCFLAGS := -O -g -W -Wall -Wshadow -pedantic -I$(ROOTDIR)/tools + +$(TOOLSDIR)/scramble: $(TOOLSDIR)/scramble.c $(TOOLSDIR)/iriver.c \ + $(TOOLSDIR)/mi4.c $(TOOLSDIR)/gigabeat.c \ + $(TOOLSDIR)/gigabeats.c $(TOOLSDIR)/telechips.c \ + $(TOOLSDIR)/iaudio_bl_flash.c \ + $(TOOLSDIR)/creative.c $(TOOLSDIR)/hmac-sha1.c +$(TOOLSDIR)/rdf2binary: $(TOOLSDIR)/rdf2binary.c +$(TOOLSDIR)/convbdf: $(TOOLSDIR)/convbdf.c +$(TOOLSDIR)/codepages: $(TOOLSDIR)/codepages.c $(TOOLSDIR)/codepage_tables.c +$(TOOLSDIR)/mkboot: $(TOOLSDIR)/mkboot.c +$(TOOLSDIR)/mktccboot: $(TOOLSDIR)/mktccboot.c $(TOOLSDIR)/telechips.c +$(TOOLSDIR)/wavtrim: $(TOOLSDIR)/wavtrim.c +$(TOOLSDIR)/voicefont: $(TOOLSDIR)/voicefont.c + +$(TOOLSDIR)/iaudio_bl_flash.c $(TOOLSDIR)/iaudio_bl_flash.h: $(TOOLSDIR)/iaudio_bl_flash.bmp $(TOOLSDIR)/bmp2rb + $(call PRINTS,BMP2RB $(@F)) + $(SILENT)$(TOOLSDIR)/bmp2rb -f 7 -h $(TOOLSDIR) $< >$(TOOLSDIR)/iaudio_bl_flash.c + +$(TOOLSDIR)/bmp2rb: $(TOOLSDIR)/bmp2rb.c + $(call PRINTS,CC $(@F)) + $(SILENT)$(HOSTCC) -DAPPLICATION_NAME=\"$@\" $(TOOLSCFLAGS) $+ -o $@ + +$(TOOLSDIR)/uclpack: $(TOOLSDIR)/ucl/uclpack.c $(wildcard $(TOOLSDIR)/ucl/src/*.c) + $(call PRINTS,CC $(@F))$(HOSTCC) $(TOOLSCFLAGS) -I$(TOOLSDIR)/ucl \ + -I$(TOOLSDIR)/ucl/include -o $@ $^ + +# implicit rule for simple tools +$(TOOLSDIR)/%: $(TOOLSDIR)/%.c + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$@)) + $(SILENT)$(HOSTCC) $(TOOLSCFLAGS) -o $@ $^ -- cgit