Subversion Repositories freemyipod

Rev

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