Subversion Repositories freemyipod

Rev

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

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