Automatically rerun tools/configure if it is newer than Makefile.
[kugel-rb.git] / tools / root.make
blobb9742448e61579b1abda8a7822f48cf00ed827a5
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 include $(TOOLSDIR)/functions.make
12 DEFINES = -DROCKBOX -DMEMORYSIZE=$(MEMORYSIZE) -DMEM=$(MEMORYSIZE) $(TARGET) \
13 -DTARGET_ID=$(TARGET_ID) -DTARGET_NAME=\"$(MODELNAME)\" \
14 -DAPPSVERSION=\"$(VERSION)\" $(BUILDDATE) \
15 $(EXTRA_DEFINES) # <-- -DSIMULATOR or not
16 INCLUDES = -I$(BUILDDIR) $(TARGET_INC)
18 CFLAGS = $(INCLUDES) $(DEFINES) $(GCCOPTS)
19 PPCFLAGS = $(filter-out -Dmain=SDL_main,$(CFLAGS)) # cygwin sdl-config fix
21 TOOLS = $(TOOLSDIR)/rdf2binary $(TOOLSDIR)/convbdf \
22 $(TOOLSDIR)/codepages $(TOOLSDIR)/scramble $(TOOLSDIR)/bmp2rb \
23 $(TOOLSDIR)/uclpack $(TOOLSDIR)/mktccboot $(TOOLSDIR)/mkboot
25 RBINFO = $(BUILDDIR)/rockbox-info.txt
27 # list suffixes to be understood by $*
28 .SUFFIXES: .rock .codec .map .elf .c .S .o .bmp .a
30 .PHONY: all clean tags zip tools manual bin build info langs
32 ifeq (,$(filter clean veryclean tags voice voicetools manual manual-pdf manual-html manual-zhtml manual-txt manual-ztxt manual-zip help fontzip ,$(MAKECMDGOALS)))
33 # none of the above
34 DEPFILE = $(BUILDDIR)/make.dep
36 endif
38 all: $(DEPFILE) build
40 # Subdir makefiles. their primary purpose is to populate SRC & OTHER_SRC
41 # but they also define special dependencies and compile rules
42 include $(TOOLSDIR)/tools.make
43 include $(FIRMDIR)/firmware.make
44 include $(ROOTDIR)/apps/bitmaps/bitmaps.make
46 ifneq (,$(findstring bootloader,$(APPSDIR)))
47 include $(APPSDIR)/bootloader.make
48 else ifneq (,$(findstring bootbox,$(APPSDIR)))
49 BOOTBOXLDOPTS = -Wl,--gc-sections
50 include $(APPSDIR)/bootbox.make
51 else
52 include $(APPSDIR)/apps.make
53 include $(APPSDIR)/lang/lang.make
55 ifdef SOFTWARECODECS
56 include $(APPSDIR)/codecs/codecs.make
57 endif
59 ifdef ENABLEDPLUGINS
60 include $(APPSDIR)/plugins/bitmaps/pluginbitmaps.make
61 include $(APPSDIR)/plugins/plugins.make
62 endif
64 ifdef SIMVER
65 include $(ROOTDIR)/uisimulator/uisimulator.make
66 endif
67 endif # bootloader
69 OBJ := $(SRC:.c=.o)
70 OBJ := $(OBJ:.S=.o)
71 OBJ += $(BMP:.bmp=.o)
72 OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
74 build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
76 $(RBINFO): $(BUILDDIR)/$(BINARY)
77 $(SILENT)echo Creating $(@F)
78 $(SILENT)$(TOOLSDIR)/mkinfo.pl $@
80 $(DEPFILE) dep:
81 $(call PRINTS,Generating dependencies)
82 @echo foo > /dev/null # there must be a "real" command in the rule
83 $(call mkdepfile,$(DEPFILE),$(SRC) $(OTHER_SRC))
84 $(call bmpdepfile,$(DEPFILE),$(BMP) $(PBMP))
86 bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY)
87 rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
88 codecs: $(DEPFILE) $(TOOLS) $(CODECS)
90 -include $(DEPFILE)
92 veryclean: clean
93 $(SILENT)rm -rf $(TOOLS)
95 clean:
96 $(SILENT)echo Cleaning build directory
97 $(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
98 rockbox.tar.bz2 TAGS apps firmware comsim sim lang.[ch] \
99 manual *.pdf *.a credits.raw rockbox.ipod bitmaps \
100 pluginbitmaps UI256.bmp rockbox-full.zip html txt \
101 rockbox-manual*.zip sysfont.h rockbox-info.txt voicefontids \
102 *.wav *.mp3 *.voice max_language_size.h $(CLEANOBJS) \
103 $(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
104 make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
105 $(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK)
107 #### linking the binaries: ####
109 .SECONDEXPANSION:
111 ifeq (,$(findstring bootloader,$(APPSDIR)))
112 # not bootloader
114 OBJ += $(LANG_O)
116 ifndef SIMVER
118 ## target build
119 RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
120 LINKRAM := $(BUILDDIR)/ram.link
121 ROMLDS := $(FIRMDIR)/rom.lds
122 LINKROM := $(BUILDDIR)/rom.link
125 $(LINKRAM): $(RAMLDS)
126 $(call PRINTS,PP $(@F))
127 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
129 $(LINKROM): $(ROMLDS)
130 $(call PRINTS,PP $(@F))
131 $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS))
133 $(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKRAM)
134 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
135 -L$(BUILDDIR)/firmware -lfirmware \
136 -L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
137 -lgcc $(BOOTBOXLDOPTS) \
138 -T$(LINKRAM) -Wl,-Map,$(BUILDDIR)/rockbox.map
140 $(BUILDDIR)/rombox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(LINKROM)
141 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
142 $(VOICESPEEXLIB) $(FIRMLIB) -lgcc -L$(BUILDDIR)/firmware \
143 -T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
145 $(BUILDDIR)/rockbox.bin : $(BUILDDIR)/rockbox.elf
146 $(call PRINTS,OC $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
148 $(BUILDDIR)/rombox.bin : $(BUILDDIR)/rombox.elf
149 $(call PRINTS,OC $(@F))$(OC) -O binary $< $@
152 # If there's a flashfile defined for this target (rockbox.ucl for Archos
153 # models) Then check if the mkfirmware script fails, as then it is (likely)
154 # because the image is too big and we need to create a compressed image
155 # instead.
157 $(BUILDDIR)/$(BINARY) : $(BUILDDIR)/rockbox.bin $(FLASHFILE)
158 $(call PRINTS,SCRAMBLE $(notdir $@))($(MKFIRMWARE) $< $@; \
159 stat=$$?; \
160 if test -n "$(FLASHFILE)"; then \
161 if test "$$stat" -ne 0; then \
162 echo "Image too big, making a compressed version!"; \
163 $(MAKE) -C $(FIRMDIR)/decompressor OBJDIR=$(BUILDDIR)/firmware/decompressor; \
164 $(MKFIRMWARE) $(BUILDDIR)/firmware/decompressor/compressed.bin $@; \
165 fi \
166 fi )
168 # archos
169 $(BUILDDIR)/rockbox.ucl: $(BUILDDIR)/rockbox.bin
170 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null 2>&1
172 MAXINFILE = $(BUILDDIR)/temp.txt
173 MAXOUTFILE = $(BUILDDIR)/romstart.txt
175 $(BUILDDIR)/rombox.ucl: $(BUILDDIR)/rombox.bin $(MAXOUTFILE)
176 $(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --none $< $@ >/dev/null; \
177 perl $(TOOLSDIR)/romsizetest.pl `cat $(MAXOUTFILE)` $<; \
178 if test $$? -ne 0; then \
179 echo "removing UCL file again, making it a fake one"; \
180 echo "fake" > $@; \
183 $(MAXOUTFILE):
184 $(call PRINTS,Creating $(@F))
185 $(SILENT)$(shell echo '#include "config.h"' > $(MAXINFILE))
186 $(SILENT)$(shell echo "ROM_START" >> $(MAXINFILE))
187 $(call preprocess2file,$(MAXINFILE),$(MAXOUTFILE))
188 $(SILENT)rm $(MAXINFILE)
190 # iriver
191 $(BUILDDIR)/rombox.iriver: $(BUILDDIR)/rombox.bin
192 $(call PRINTS,Build ROM file)$(MKFIRMWARE) $< $@
194 endif # !SIMVER
195 endif # !bootloader
198 voicetools:
199 $(SILENT)$(MAKE) -C $(TOOLSDIR) CC=$(HOSTCC) AR=$(HOSTAR) rbspeexenc voicefont wavtrim
201 tags:
202 $(SILENT)rm -f TAGS
203 $(SILENT)etags -o $(BUILDDIR)/TAGS $(filter-out %.o,$(SRC) $(OTHER_SRC))
205 fontzip:
206 $(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
208 zip:
209 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
210 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
212 mapzip:
213 $(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
215 fullzip:
216 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
217 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
219 7zip:
220 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
221 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
223 tar:
224 $(SILENT)rm -f rockbox.tar
225 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
226 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
228 bzip2: tar
229 $(SILENT)bzip2 -f9 rockbox.tar
231 gzip: tar
232 $(SILENT)gzip -f9 rockbox.tar
234 manual manual-pdf:
235 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-pdf
236 manual-html:
237 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-html
238 manual-zhtml: manual-zip
239 manual-txt:
240 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt
241 manual-ztxt:
242 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-txt-zip
243 manual-zip:
244 $(SILENT)$(MAKE) -C $(MANUALDIR) OBJDIR=$(BUILDDIR)/manual manual-zip
246 ifdef TTS_ENGINE
248 voice: voicetools features
249 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
250 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 \
252 endif
254 ifdef SIMVER
256 install:
257 @echo "Installing your build in your 'simdisk' dir"
258 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
259 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -s -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
261 fullinstall:
262 @echo "Installing a full setup in your 'simdisk' dir"
263 $(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
264 $(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -t \"$(MODELNAME)$$feat\" -i \"$(TARGET_ID)\" -s -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
266 endif
268 help:
269 @echo "A few helpful make targets"
270 @echo ""
271 @echo "all - builds a full Rockbox (default), including tools"
272 @echo "bin - builds only the Rockbox.<target name> file"
273 @echo "rocks - builds only plugins"
274 @echo "codecs - builds only codecs"
275 @echo "dep - regenerates make dependency database"
276 @echo "clean - cleans a build directory (not tools)"
277 @echo "veryclean - cleans the build and tools directories"
278 @echo "manual - builds a manual (pdf)"
279 @echo "manual-html - HTML manual"
280 @echo "manual-zip - HTML manual (zipped)"
281 @echo "manual-txt - txt manual"
282 @echo "fullzip - creates a rockbox.zip of your build with fonts"
283 @echo "zip - creates a rockbox.zip of your build (no fonts)"
284 @echo "gzip - creates a rockbox.tar.gz of your build (no fonts)"
285 @echo "bzip2 - creates a rockbox.tar.bz2 of your build (no fonts)"
286 @echo "7zip - creates a rockbox.7z of your build (no fonts)"
287 @echo "fontzip - creates rockbox-fonts.zip"
288 @echo "mapzip - creates rockbox-maps.zip with all .map files"
289 @echo "tools - builds the tools only"
290 @echo "voice - creates the voice clips (voice builds only)"
291 @echo "voicetools - builds the voice tools only"
292 @echo "install - installs your build (for simulator builds only, no fonts)"
293 @echo "fullinstall - installs your build (for simulator builds only, with fonts)"
294 @echo "reconf - rerun configure with the same selection"
296 ### general compile rules:
298 # when source and object are in different locations (normal):
299 $(BUILDDIR)/%.o: $(ROOTDIR)/%.c
300 $(SILENT)mkdir -p $(dir $@)
301 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
303 $(BUILDDIR)/%.o: $(ROOTDIR)/%.S
304 $(SILENT)mkdir -p $(dir $@)
305 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
307 # when source and object are both in BUILDDIR (generated code):
308 %.o: %.c
309 $(SILENT)mkdir -p $(dir $@)
310 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
312 %.o: %.S
313 $(SILENT)mkdir -p $(dir $@)
314 $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) $(CFLAGS) -c $< -o $@
316 Makefile: $(TOOLSDIR)/configure
317 $(SILENT)$(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)