2008-11-20 11:27:31 +00:00
# __________ __ ___.
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
# \/ \/ \/ \/ \/
2008-11-25 19:54:23 +00:00
# $Id$
2008-11-20 11:27:31 +00:00
#
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
2009-03-02 06:13:18 +00:00
INCLUDES = -I$(BUILDDIR) -I$(BUILDDIR)/lang $(TARGET_INC)
2008-11-20 11:27:31 +00:00
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 \
2009-10-28 21:11:43 +00:00
$(TOOLSDIR)/uclpack $(TOOLSDIR)/mkboot
2008-11-20 11:27:31 +00:00
2009-04-12 01:28:33 +00:00
ifeq (,$(PREFIX))
ifdef SIMVER
# for sims, set simdisk/ as default
PREFIX = simdisk
INSTALL = --install="$(PREFIX)"
else
# /dev/null as magic to tell it wasn't set, error out later in buildzip.pl
INSTALL = --install=/dev/null
endif
else
INSTALL = --install="$(PREFIX)"
endif
2008-11-21 13:21:25 +00:00
RBINFO = $(BUILDDIR)/rockbox-info.txt
2008-11-20 11:27:31 +00:00
# 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
2009-03-10 19:06:14 +00:00
ifeq (,$(filter clean veryclean reconf tags voice voicetools manual manual-pdf manual-html manual-zhtml manual-txt manual-ztxt manual-zip help fontzip ,$(MAKECMDGOALS)))
2008-11-26 23:21:30 +00:00
# none of the above
2008-11-20 11:27:31 +00:00
DEPFILE = $(BUILDDIR)/make.dep
2008-11-26 23:21:30 +00:00
endif
2008-11-20 11:27:31 +00:00
all: $(DEPFILE) build
2009-07-13 00:40:35 +00:00
# Subdir makefiles. their primary purpose is to populate SRC, OTHER_SRC &
# ASMDEFS_SRC but they also define special dependencies and compile rules
2008-11-20 11:27:31 +00:00
include $(TOOLSDIR)/tools.make
2009-09-01 14:53:37 +00:00
ifeq (,$(findstring checkwps,$(APPSDIR)))
include $(FIRMDIR)/firmware.make
include $(ROOTDIR)/apps/bitmaps/bitmaps.make
endif
2008-11-20 11:27:31 +00:00
ifneq (,$(findstring bootloader,$(APPSDIR)))
include $(APPSDIR)/bootloader.make
else ifneq (,$(findstring bootbox,$(APPSDIR)))
2008-11-20 16:17:22 +00:00
BOOTBOXLDOPTS = -Wl,--gc-sections
2008-11-20 11:27:31 +00:00
include $(APPSDIR)/bootbox.make
2009-08-21 20:28:26 +00:00
else ifneq (,$(findstring checkwps,$(APPSDIR)))
include $(APPSDIR)/checkwps.make
2009-10-07 16:54:15 +00:00
else ifneq (,$(findstring database,$(APPSDIR)))
include $(APPSDIR)/database.make
2008-11-20 11:27:31 +00:00
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)
2009-04-11 23:20:09 +00:00
OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ))
2008-11-20 11:27:31 +00:00
2008-11-21 13:21:25 +00:00
build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO)
$(RBINFO): $(BUILDDIR)/$(BINARY)
$(SILENT)echo Creating $(@F)
$(SILENT)$(TOOLSDIR)/mkinfo.pl $@
2008-11-20 11:27:31 +00:00
$(DEPFILE) dep:
$(call PRINTS,Generating dependencies)
@echo foo > /dev/null # there must be a "real" command in the rule
2009-02-04 20:59:27 +00:00
$(call mkdepfile,$(DEPFILE),$(SRC))
2009-12-30 13:30:32 +00:00
$(call mkdepfile,$(DEPFILE),$(OTHER_SRC:%.lua=))
2009-07-13 00:40:35 +00:00
$(call mkdepfile,$(DEPFILE),$(ASMDEFS_SRC))
2009-02-04 20:59:27 +00:00
@mv $(DEPFILE)_ $(DEPFILE)
2008-11-20 11:27:31 +00:00
$(call bmpdepfile,$(DEPFILE),$(BMP) $(PBMP))
2009-04-03 13:44:47 +00:00
bin: $(DEPFILE) $(TOOLS) $(BUILDDIR)/$(BINARY) $(RBINFO)
2008-11-20 11:27:31 +00:00
rocks: $(DEPFILE) $(TOOLS) $(ROCKS)
codecs: $(DEPFILE) $(TOOLS) $(CODECS)
2009-03-11 16:13:46 +00:00
tools: $(TOOLS)
2008-11-20 11:27:31 +00:00
-include $(DEPFILE)
veryclean: clean
$(SILENT)rm -rf $(TOOLS)
clean:
$(SILENT)echo Cleaning build directory
2008-11-22 23:34:24 +00:00
$(SILENT)rm -rf rockbox.zip rockbox.7z rockbox.tar rockbox.tar.gz \
2009-09-13 15:24:59 +00:00
rockbox.tar.bz2 TAGS apps firmware tools comsim sim lang \
2008-11-22 23:34:24 +00:00
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 \
2009-03-02 06:13:18 +00:00
*.wav *.mp3 *.voice $(CLEANOBJS) \
2008-11-22 23:34:24 +00:00
$(LINKRAM) $(LINKROM) rockbox.elf rockbox.map rockbox.bin \
2008-11-28 22:22:47 +00:00
make.dep rombox.elf rombox.map rombox.bin rombox.ucl romstart.txt \
2008-11-22 23:34:24 +00:00
$(BINARY) $(FLASHFILE) uisimulator bootloader flash $(BOOTLINK)
2008-11-20 11:27:31 +00:00
#### linking the binaries: ####
.SECONDEXPANSION:
ifeq (,$(findstring bootloader,$(APPSDIR)))
# not bootloader
2008-11-21 15:27:16 +00:00
OBJ += $(LANG_O)
ifndef SIMVER
2008-11-20 11:27:31 +00:00
## target build
RAMLDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/app.lds
LINKRAM := $(BUILDDIR)/ram.link
ROMLDS := $(FIRMDIR)/rom.lds
LINKROM := $(BUILDDIR)/rom.link
2008-11-21 15:07:15 +00:00
2008-11-20 11:27:31 +00:00
$(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)
2008-11-20 15:04:30 +00:00
$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -nostdlib -o $@ $(OBJ) \
-L$(BUILDDIR)/firmware -lfirmware \
2008-11-20 11:27:31 +00:00
-L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
2008-11-20 16:17:22 +00:00
-lgcc $(BOOTBOXLDOPTS) \
2008-11-20 11:27:31 +00:00
-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 \
2008-11-21 20:33:52 +00:00
-T$(LINKROM) -Wl,-Map,$(BUILDDIR)/rombox.map
2008-11-20 11:27:31 +00:00
$(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
2009-02-23 08:45:16 +00:00
$(call PRINTS,UCLPACK $(@F))$(TOOLSDIR)/uclpack --best --2e -b1048576 $< $@ >/dev/null
2008-11-20 11:27:31 +00:00
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 # !SIMVER
2008-11-21 15:27:16 +00:00
endif # !bootloader
2008-11-20 11:27:31 +00:00
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:
2009-01-31 12:23:35 +00:00
$(SILENT)$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 1 -o rockbox-fonts.zip $(TARGET) $(BINARY)
2008-11-20 11:27:31 +00:00
zip:
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done ; \
2009-01-31 12:23:35 +00:00
$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
2008-11-20 11:27:31 +00:00
mapzip:
$(SILENT)find . -name "*.map" | xargs zip rockbox-maps.zip
fullzip:
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
2009-01-31 12:23:35 +00:00
$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 -o rockbox-full.zip $(TARGET) $(BINARY)
2008-11-20 11:27:31 +00:00
7zip:
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
2009-01-31 12:23:35 +00:00
$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.7z" -z "7za a -mx=9" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
2008-11-20 11:27:31 +00:00
tar:
$(SILENT)rm -f rockbox.tar
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
2009-01-31 12:23:35 +00:00
$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m \"$(MODELNAME)\" -i \"$(TARGET_ID)\" -o "rockbox.tar" -z "tar -cf" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" $(TARGET) $(BINARY)
2008-11-20 11:27:31 +00:00
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
install:
2009-04-12 01:28:33 +00:00
@echo "Installing your build in your '$(PREFIX)' dir"
2008-11-20 11:27:31 +00:00
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
2009-04-12 01:28:33 +00:00
$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 0 $(TARGET) $(BINARY)
2008-11-20 11:27:31 +00:00
fullinstall:
2009-04-12 01:28:33 +00:00
@echo "Installing a full setup in your '$(PREFIX)' dir"
2008-11-20 11:27:31 +00:00
$(SILENT)for f in `cat $(BUILDDIR)/apps/features`; do feat="$$feat:$$f" ; done; \
2009-04-12 01:28:33 +00:00
$(TOOLSDIR)/buildzip.pl $(VERBOSEOPT) -m "$(MODELNAME)" -i "$(TARGET_ID)" $(INSTALL) -z "zip -r0" -r "$(ROOTDIR)" --rbdir="$(RBDIR)" -f 2 $(TARGET) $(BINARY)
2008-11-20 11:27:31 +00:00
help:
@echo "A few helpful make targets"
@echo ""
@echo "all - builds a full Rockbox (default), including tools"
@echo "bin - builds only the Rockbox.<target name> 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"
2009-04-12 01:28:33 +00:00
@echo "install - installs your build (at PREFIX, defaults to simdisk/ for simulators (no fonts))"
@echo "fullinstall - installs your build (like install, but with fonts)"
2009-01-09 23:15:27 +00:00
@echo "reconf - rerun configure with the same selection"
2008-11-20 11:27:31 +00:00
### 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 $@
2009-07-13 00:40:35 +00:00
# generated definitions for use in .S files
$(BUILDDIR)/%_asmdefs.h: $(ROOTDIR)/%_asmdefs.c
$(call PRINTS,ASMDEFS $(@F))
$(SILENT)mkdir -p $(dir $@)
$(call asmdefs2file,$<,$@)
2008-11-20 11:27:31 +00:00
# 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 $@
2009-01-09 23:15:27 +00:00
2009-01-10 22:23:27 +00:00
Makefile: $(TOOLSDIR)/configure
2009-08-02 09:45:51 +00:00
ifneq (reconf,$(MAKECMDGOALS))
2009-01-10 22:36:41 +00:00
$(SILENT)echo "*** tools/configure is newer than Makefile. You should run 'make reconf'."
2009-08-02 09:45:51 +00:00
endif
2009-01-10 22:36:41 +00:00
reconf:
2009-04-12 01:28:33 +00:00
$(SILENT$)PREFIX=$(PREFIX) $(TOOLSDIR)/configure $(CONFIGURE_OPTIONS)