Subversion Repositories freemyipod

Rev

Rev 866 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
870 theseven 1
NAME := installer-ipodnano2g
2
STACKSIZE := 4096
3
COMPRESS := false
4
AUTOBUILD_FLASHFILES ?= true
5
AUTOBUILD_FSFILES ?= true
6
BASENAME ?= $(NAME)
7
FATNAME ?= INSTAL~1BOO
8
 
9
EMCOREDIR ?= ../../emcore/trunk/
10
UNINSTDIR ?= ../uninstaller-ipodnano2g/
11
BOOTMENUDIR ?= ../bootmenu-ipodnano2g/
12
BOOTMENUTHEMEDIR ?= ../bootmenu-ipodnano2g-wintertheme/
13
LIBBOOTDIR ?= ../../libs/boot/
14
LIBPNGDIR ?= ../../libs/png/
15
LIBUIDIR ?= ../../libs/ui/
16
LIBMKFAT32DIR ?= ../../libs/mkfat32/
17
UMSBOOTDIR ?= ../../umsboot/
18
NOTEBOOTDIR ?= ../../noteboot/
19
TOOLSDIR ?= ../../tools/
20
 
21
FLASHFILES = flashfiles/boot.emcorelib flashfiles/png.emcorelib flashfiles/ui.emcorelib flashfiles/mkfat32.emcorelib \
22
             flashfiles/uninstaller-ipodnano2g.emcoreapp flashfiles/bootmenu-ipodnano2g.emcoreapp flashfiles/rockbox.ipod.ucl \
23
	         flashfiles/emcoreldr-ipodnano2g.dfu flashfiles/emcore-ipodnano2g.ucl flashfiles/umsboot-ipodnano2g.ucl
24
 
25
FSFILES = fsfiles/.apps/bootmenu/theme.emcoreapp
26
 
27
ifeq ($(shell uname),WindowsNT)
28
CCACHE :=
29
else
30
CCACHE := $(shell which ccache)
31
endif
32
 
33
CROSS   ?= arm-elf-eabi-
34
CC      := $(CCACHE) $(CROSS)gcc
35
AS      := $(CROSS)as
36
LD      := $(CROSS)ld
37
OBJCOPY := $(CROSS)objcopy
38
ELF2ECA := $(CROSS)elf2emcoreapp
39
UCLPACK := ucl2e10singleblk
40
STUBEMBED := python tools/stubembed.py
41
EMCOREBOOTCFG := python $(EMCOREDIR)/tools/emcorebootcfg.py
42
EMCOREEMBEDAPP := python $(EMCOREDIR)/tools/emcoreembedapp.py
43
CRYPTFW := python $(EMCOREDIR)/tools/ipodcrypt.py s5l8701-cryptfirmware
44
GENNOTE := python $(NOTEBOOTDIR)/gennote.py
45
SCRAMBLE := python $(TOOLSDIR)/scramble.py
46
 
47
LIBINCLUDES := -I$(LIBPNGDIR)/export -I$(LIBUIDIR)/export
48
 
49
CFLAGS  += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -I$(EMCOREDIR)/export $(LIBINCLUDES) -ffunction-sections -fdata-sections -mcpu=arm940t -DARM_ARCH=4 -DBASENAME=$(BASENAME) -marm
50
LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --emit-relocs --gc-sections
51
 
52
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
53
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:" | sed -e "s:^\\./::")
54
 
55
REVISION := $(shell svnversion .)
56
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
57
 
58
HELPERS := build/__emcore_armhelpers.o
59
LIBS := build/libucl.a
60
 
61
SRC := $(call preprocesspaths,SOURCES,-I. -I..)
62
OBJ := $(SRC:%.c=build/%.o)
63
OBJ := $(OBJ:%.S=build/%.o) $(HELPERS)
64
 
65
all: $(NAME)
66
 
67
-include $(OBJ:%=%.dep)
68
 
69
$(NAME): build/$(BASENAME).bootnote build/$(BASENAME).ipodx
70
 
71
build/$(BASENAME).ipodx: build/$(NAME).fw
72
	@echo [SCRAMB] $<
73
	@$(SCRAMBLE) $< $@ --signature=nn2x --targetid=62
74
 
75
build/$(NAME).fw: build/$(NAME).bin
76
	@echo [CFW]    $<
77
	@$(CRYPTFW) $< $@
78
 
79
build/$(BASENAME).bootnote: build/$(NAME).bin
80
	@echo [GENNOT] $<
81
	@$(GENNOTE) $< "$(FATNAME)" $@
82
 
83
build/$(NAME).bin: build/bootstub.bin build/$(NAME).ubi
84
	@echo [STUBEM] $@
85
	@$(STUBEMBED) $^ $@
86
 
87
build/$(NAME).ubi: $(EMCOREDIR)/build/ipodnano2g/emcore.bin build/$(NAME).emcoreapp
88
	@echo [EMBAPP] $@
89
	@$(EMCOREEMBEDAPP) $^ $@
90
 
91
build/bootstub.bin: build/bootstub.elf
92
	@echo [OC]     $<
93
	@$(OBJCOPY) -O binary $^ $@
94
 
95
build/bootstub.elf: bootstub/ls.x build/bootstub/bootstub.o
96
	@echo [LD]     $@
97
	@$(LD) $(LDFLAGS) -o $@ -T bootstub/ls.x build/bootstub/bootstub.o
98
 
99
build/$(NAME).emcoreapp: build/$(NAME).elf
100
	@echo [EMCAPP] $<
101
ifeq ($(COMPRESS),true)
102
	@$(ELF2ECA) -z -s $(STACKSIZE) -o $@ $^
103
else
104
	@$(ELF2ECA) -s $(STACKSIZE) -o $@ $^
105
endif
106
 
107
ifeq ($(AUTOBUILD_FLASHFILES),true)
108
build/resources.o: $(FLASHFILES)
109
else
110
build/resources.o: flashfiles.built
111
endif
112
 
113
ifeq ($(AUTOBUILD_FSFILES),true)
114
build/resources.o: $(FSFILES)
115
else
116
build/resources.o: fsfiles.built
117
endif
118
 
119
build/$(NAME).elf: ls.x $(OBJ) $(LIBS)
120
	@echo [LD]     $@
121
	@$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ) $(LIBS)
122
 
123
build/%.o: %.c build/version.h
124
	@echo [CC]     $<
125
ifeq ($(shell uname),WindowsNT)
126
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
127
else
128
	@-mkdir -p $(dir $@)
129
endif
130
	@$(CC) -c $(CFLAGS) -o $@ $<
131
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
132
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
133
ifeq ($(shell uname),WindowsNT)
134
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
135
else
136
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
137
endif
138
	@rm -f $@.dep.tmp
139
 
140
build/%.o: %.S build/version.h
141
	@echo [CC]     $<
142
ifeq ($(shell uname),WindowsNT)
143
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
144
else
145
	@-mkdir -p $(dir $@)
146
endif
147
	@$(CC) -c $(CFLAGS) -o $@ $<
148
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
149
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
150
ifeq ($(shell uname),WindowsNT)
151
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
152
else
153
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
154
endif
155
	@rm -f $@.dep.tmp
156
 
157
build/__emcore_%.o: $(EMCOREDIR)/export/%.c
158
	@echo [CC]     $<
159
ifeq ($(shell uname),WindowsNT)
160
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
161
else
162
	@-mkdir -p $(dir $@)
163
endif
164
	@$(CC) -c $(CFLAGS) -o $@ $<
165
 
166
build/__emcore_%.o: $(EMCOREDIR)/export/%.S
167
	@echo [CC]     $<
168
ifeq ($(shell uname),WindowsNT)
169
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
170
else
171
	@-mkdir -p $(dir $@)
172
endif
173
	@$(CC) -c $(CFLAGS) -o $@ $<
174
 
175
build/libucl.a: libucl
176
	@$(MAKE) -C libucl CFLAGS="$(CFLAGS) -I../$(EMCOREDIR)/export"
177
 
178
build/version.h: version.h ../../.svn/entries
179
	@echo [PP]     $<
180
ifeq ($(shell uname),WindowsNT)
181
	@-if not exist build md build
182
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
183
else
184
	@-mkdir -p build
185
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
186
endif
187
 
188
flashfiles: $(FLASHFILES)
189
	@touch flashfiles.built
190
 
191
$(LIBBOOTDIR)/build/boot.emcorelib: libboot
192
	@$(MAKE) -C $(LIBBOOTDIR)
193
 
194
flashfiles/boot.emcorelib: $(LIBBOOTDIR)/build/boot.emcorelib
195
	@echo [CP]     $@
196
	@cp $< $@
197
 
198
$(LIBPNGDIR)/build/png.emcorelib: libpng
199
	@$(MAKE) -C $(LIBPNGDIR)
200
 
201
flashfiles/png.emcorelib: $(LIBPNGDIR)/build/png.emcorelib
202
	@echo [CP]     $@
203
	@cp $< $@
204
 
205
$(LIBUIDIR)/build/ui.emcorelib: libui
206
	@$(MAKE) -C $(LIBUIDIR)
207
 
208
flashfiles/ui.emcorelib: $(LIBUIDIR)/build/ui.emcorelib
209
	@echo [CP]     $@
210
	@cp $< $@
211
 
212
$(LIBMKFAT32DIR)/build/mkfat32.emcorelib: libmkfat32
213
	@$(MAKE) -C $(LIBMKFAT32DIR)
214
 
215
flashfiles/mkfat32.emcorelib: $(LIBMKFAT32DIR)/build/mkfat32.emcorelib
216
	@echo [CP]     $@
217
	@cp $< $@
218
 
219
$(UMSBOOTDIR)/build/ipodnano2g/umsboot-ipodnano2g.ucl $(UMSBOOTDIR)/build/ipodnano2g/umsboot.bin: umsboot
220
	@$(MAKE) -C $(UMSBOOTDIR) ipodnano2g
221
 
222
flashfiles/umsboot-ipodnano2g.ucl: $(UMSBOOTDIR)/build/ipodnano2g/umsboot-ipodnano2g.ucl
223
	@echo [CP]     $@
224
	@cp $< $@
225
 
226
$(UNINSTDIR)/build/uninstaller-ipodnano2g.emcoreapp: uninstaller-ipodnano2g
227
	@$(MAKE) -C $(UNINSTDIR)
228
 
229
flashfiles/uninstaller-ipodnano2g.emcoreapp: $(UNINSTDIR)/build/uninstaller-ipodnano2g.emcoreapp
230
	@echo [CP]     $@
231
	@cp $< $@
232
 
233
$(BOOTMENUDIR)/build/bootmenu-ipodnano2g.emcoreapp: bootmenu-ipodnano2g
234
	@$(MAKE) -C $(BOOTMENUDIR)
235
 
236
flashfiles/bootmenu-ipodnano2g.emcoreapp: $(BOOTMENUDIR)/build/bootmenu-ipodnano2g.emcoreapp
237
	@echo [CP]     $@
238
	@cp $< $@
239
 
240
$(BOOTMENUTHEMEDIR)/build/bootmenu-ipodnano2g.emcoreapp: bootmenu-ipodnano2g-theme
241
	@$(MAKE) -C $(BOOTMENUTHEMEDIR)
242
 
243
fsfiles/.apps/bootmenu/theme.emcoreapp: $(BOOTMENUTHEMEDIR)/build/bootmenu-ipodnano2g.emcoreapp
244
	@echo [CP]     $@
245
ifeq ($(shell uname),WindowsNT)
246
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
247
else
248
	@-mkdir -p $(dir $@)
249
endif
250
	@cp $< $@
251
 
252
$(EMCOREDIR)/loader/ipodnano2g/build/emcoreldr-ipodnano2g.dfu: emcoreldr-ipodnano2g
253
	@$(MAKE) -C $(EMCOREDIR)/loader/ipodnano2g
254
 
255
flashfiles/emcoreldr-ipodnano2g.dfu: $(EMCOREDIR)/loader/ipodnano2g/build/emcoreldr-ipodnano2g.dfu
256
	@echo [CP]     $@
257
	@cp $< $@
258
 
259
flashfiles/emcore-ipodnano2g.ucl: flashfiles/emcore-ipodnano2g.bin
260
	@echo [UCL]    $<
261
	@$(UCLPACK) $< $@
262
 
263
$(EMCOREDIR)/build/ipodnano2g/emcore.bin: emcore
264
	@$(MAKE) -C $(EMCOREDIR) ipodnano2g
265
 
266
flashfiles/emcore-ipodnano2g.bin: $(EMCOREDIR)/build/ipodnano2g/emcore.bin
267
	@echo [EMBCFG] $@
268
	@$(EMCOREBOOTCFG) $< $@ "(3, '/.boot/init.emcoreapp', None, (2, 'bootmenu', None, None))"
269
 
270
clean:
271
	@rm -rf build
272
 
273
.PHONY: all clean emcore emcoreldr-ipodnano2g bootmenu-ipodnano2g bootmenu-ipodnano2g-theme uninstaller-ipodnano2g libboot libpng libui libmkfat32 umsboot libucl flashfiles $(NAME)