Avoid duplicated code, create a formatting function for FM frequency
[kugel-rb.git] / bootloader / Makefile
blob3272510051781863bb0ab4bf94207858fe7a80c8
1 # __________ __ ___.
2 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
3 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
4 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
5 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
6 # \/ \/ \/ \/ \/
7 # $Id$
10 INCLUDES= $(TARGET_INC) -I$(FIRMDIR)/include -I$(FIRMDIR)/export -I. -I$(OBJDIR) \
11 -I$(BUILDDIR) -I$(BUILDDIR)/bitmaps
13 DEPFILE = $(OBJDIR)/dep-bootloader
14 LDS := $(FIRMDIR)/target/$(CPU)/$(MANUFACTURER)/boot.lds
16 # Set up the bitmap libraries
17 BITMAPLIBS =
18 LINKBITMAPS =
19 ifneq ($(strip $(BMP2RB_MONO)),)
20 BITMAPLIBS += $(BUILDDIR)/libbitmapsmono.a
21 LINKBITMAPS += -lbitmapsmono
22 endif
23 ifneq ($(strip $(BMP2RB_NATIVE)),)
24 BITMAPLIBS += $(BUILDDIR)/libbitmapsnative.a
25 LINKBITMAPS += -lbitmapsnative
26 endif
27 ifneq ($(strip $(BMP2RB_REMOTEMONO)),)
28 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotemono.a
29 LINKBITMAPS += -lbitmapsremotemono
30 endif
31 ifneq ($(strip $(BMP2RB_REMOTENATIVE)),)
32 BITMAPLIBS += $(BUILDDIR)/libbitmapsremotenative.a
33 LINKBITMAPS += -lbitmapsremotenative
34 endif
36 ifdef DEBUG
37 DEFINES := -DDEBUG
38 CFLAGS += -g
39 endif
41 SRC := $(shell cat SOURCES | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) $(EXTRA_DEFINES) -E -P -include "config.h" - )
42 DIRS = .
44 ifdef APPEXTRA
45 DIRS += $(subst :, ,$(APPEXTRA))
46 INCLUDES += $(patsubst %,-I%,$(subst :, ,$(APPEXTRA)))
47 endif
49 ifndef VERSION
50 VERSION=$(shell date +%y%m%d-%H%M)
51 endif
53 CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(DEFINES) \
54 -DAPPSVERSION=\"$(VERSION)\" $(EXTRA_DEFINES) -DMEM=${MEMORYSIZE}
56 OBJS := $(SRC:%.c=$(OBJDIR)/%.o)
57 SOURCES = $(SRC)
58 LINKFILE = $(OBJDIR)/linkage.lds
59 MAXINFILE = $(OBJDIR)/romstart.temp
60 MAXOUTFILE = $(OBJDIR)/romstart
62 LIBROCKBOX = $(BUILDDIR)/librockbox.a
64 ifdef DEBUG
65 all: $(OBJDIR)/bootloader.elf
66 else
67 all: $(BUILDDIR)/$(BINARY) $(FLASHFILE)
68 endif
70 $(DEPFILE): $(BITMAPLIBS)
72 dep: $(DEPFILE)
74 $(LINKFILE): $(LDS)
75 $(call PRINTS,Build $(@F))cat $< | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) $(DEFINES) -E -P $(ROMBUILD) - >$@
77 $(MAXOUTFILE):
78 $(SILENT)echo '#include "config.h"' > $(MAXINFILE)
79 $(SILENT)echo "ROM_START" >> $(MAXINFILE)
80 $(SILENT)cat $(MAXINFILE) | $(CC) -DMEMORYSIZE=$(MEMORYSIZE) $(INCLUDES) $(TARGET) $(DEFINES) -E -P $(ROMBUILD) - > $(MAXOUTFILE)
81 $(SILENT)rm $(MAXINFILE)
83 build-bitmapsmono:
84 $(call PRINTS,MAKE in bitmaps/mono)$(MAKE) -C ../apps/bitmaps/mono OBJDIR=$(OBJDIR)/bitmaps/mono
86 build-bitmapsnative:
87 $(call PRINTS,MAKE in bitmaps/native)$(MAKE) -C ../apps/bitmaps/native OBJDIR=$(OBJDIR)/bitmaps/native
89 build-bitmapsremotemono:
90 $(call PRINTS,MAKE in bitmaps/remote_mono)$(MAKE) -C ../apps/bitmaps/remote_mono OBJDIR=$(OBJDIR)/bitmaps/remote_mono
92 build-bitmapsremotenative:
93 $(call PRINTS,MAKE in bitmaps/remote_native)$(MAKE) -C ../apps/bitmaps/remote_native OBJDIR=$(OBJDIR)/bitmaps/remote_native
95 $(BITMAPLIBS): $(BUILDDIR)/lib%.a: build-%
97 $(OBJDIR)/bootloader.elf : $(OBJS) $(LINKFILE) $(DEPFILE) $(LIBROCKBOX) $(BITMAPLIBS)
98 $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Wl,--gc-sections -Os -nostdlib -o $@ $(OBJS) -L$(BUILDDIR) -L$(BUILDDIR)/firmware -lrockbox $(LINKBITMAPS) -lgcc -T$(LINKFILE) -Wl,-Map,$(OBJDIR)/bootloader.map
100 $(OBJDIR)/bootloader.bin : $(OBJDIR)/bootloader.elf
101 $(call PRINTS,OBJCOPY $(@F))$(OC) $(if $(filter yes, $(USE_ELF)), -S -x, -O binary) $< $@
103 $(OBJDIR)/bootloader.asm: $(OBJDIR)/bootloader.bin
104 $(TOOLSDIR)/sh2d -sh1 $< > $@
106 $(BUILDDIR)/$(BINARY) : $(OBJDIR)/bootloader.bin
107 $(call PRINTS,Build bootloader file)$(MKFIRMWARE) $< $@
109 include $(TOOLSDIR)/make.inc
111 clean:
112 $(call PRINTS,cleaning bootloader)-rm -f $(OBJS) $(BUILDDIR)/$(BINARY) $(OBJDIR)/bootloader.asm \
113 $(OBJDIR)/bootloader.bin $(OBJDIR)/bootloader.elf $(OBJDIR)/*.map \
114 $(LINKFILE) $(MAXOUTFILE) $(DEPFILE)
115 $(SILENT)$(MAKE) -C bitmaps/mono clean OBJDIR=$(OBJDIR)/bitmaps/mono
116 $(SILENT)$(MAKE) -C bitmaps/native clean OBJDIR=$(OBJDIR)/bitmaps/native
117 $(SILENT)$(MAKE) -C bitmaps/remote_mono clean OBJDIR=$(OBJDIR)/bitmaps/remote_mono
118 $(SILENT)$(MAKE) -C bitmaps/remote_native clean OBJDIR=$(OBJDIR)/bitmaps/remote_native
120 -include $(DEPFILE)