Subversion Repositories freemyipod

Rev

Rev 697 | Rev 705 | 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
 
698 theseven 105
ifeq ($(AUTOBUILD_FLASHFILES),true)
106
flashfiles.built: flashfiles
107
endif
108
 
160 theseven 109
build/$(NAME).elf: ls.x $(OBJ) $(LIBS)
110
	@echo [LD]     $@
111
	@$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ) $(LIBS)
112
 
113
build/%.o: %.c build/version.h
114
	@echo [CC]     $<
115
ifeq ($(shell uname),WindowsNT)
116
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
117
else
118
	@-mkdir -p $(dir $@)
119
endif
120
	@$(CC) -c $(CFLAGS) -o $@ $<
121
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
122
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
123
ifeq ($(shell uname),WindowsNT)
124
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
125
else
126
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
127
endif
128
	@rm -f $@.dep.tmp
129
 
130
build/%.o: %.S build/version.h
131
	@echo [CC]     $<
132
ifeq ($(shell uname),WindowsNT)
133
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
134
else
135
	@-mkdir -p $(dir $@)
136
endif
137
	@$(CC) -c $(CFLAGS) -o $@ $<
138
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
139
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
140
ifeq ($(shell uname),WindowsNT)
141
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
142
else
143
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
144
endif
145
	@rm -f $@.dep.tmp
146
 
551 theseven 147
build/__emcore_%.o: $(EMCOREDIR)/export/%.c
160 theseven 148
	@echo [CC]     $<
149
ifeq ($(shell uname),WindowsNT)
150
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
151
else
152
	@-mkdir -p $(dir $@)
153
endif
154
	@$(CC) -c $(CFLAGS) -o $@ $<
155
 
551 theseven 156
build/__emcore_%.o: $(EMCOREDIR)/export/%.S
157
	@echo [CC]     $<
158
ifeq ($(shell uname),WindowsNT)
159
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
160
else
161
	@-mkdir -p $(dir $@)
162
endif
163
	@$(CC) -c $(CFLAGS) -o $@ $<
164
 
160 theseven 165
build/libucl.a: libucl
166
 
167
libucl:
697 theseven 168
	@$(MAKE) -C libucl CFLAGS="$(CFLAGS) -I../$(EMCOREDIR)/export"
160 theseven 169
 
170
build/version.h: version.h .svn/entries
171
	@echo [PP]     $<
172
ifeq ($(shell uname),WindowsNT)
173
	@-if not exist build md build
174
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
175
else
176
	@-mkdir -p build
177
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
178
endif
179
 
180
flashfiles: $(FLASHFILES)
165 theseven 181
	@touch flashfiles.built
160 theseven 182
 
551 theseven 183
$(LIBBOOTDIR)/build/boot.emcorelib: libboot
181 theseven 184
 
551 theseven 185
flashfiles/boot.emcorelib: $(LIBBOOTDIR)/build/boot.emcorelib libboot
160 theseven 186
	@echo [CP]     $@
187
	@cp $< $@
188
 
551 theseven 189
$(LIBPNGDIR)/build/png.emcorelib: libpng
190
 
191
flashfiles/png.emcorelib: $(LIBPNGDIR)/build/png.emcorelib libpng
192
	@echo [CP]     $@
193
	@cp $< $@
194
 
195
$(LIBUIDIR)/build/ui.emcorelib: libui
196
 
197
flashfiles/ui.emcorelib: $(LIBUIDIR)/build/ui.emcorelib libui
198
	@echo [CP]     $@
199
	@cp $< $@
200
 
672 theseven 201
$(LIBMKFAT32DIR)/build/mkfat32.emcorelib: libmkfat32
202
 
203
flashfiles/mkfat32.emcorelib: $(LIBMKFAT32DIR)/build/mkfat32.emcorelib libmkfat32
204
	@echo [CP]     $@
205
	@cp $< $@
206
 
243 theseven 207
$(UMSBOOTDIR)/build/ipodnano2g/umsboot-ipodnano2g.ucl: umsboot
208
 
209
flashfiles/umsboot-ipodnano2g.ucl: $(UMSBOOTDIR)/build/ipodnano2g/umsboot-ipodnano2g.ucl umsboot
210
	@echo [CP]     $@
211
	@cp $< $@
212
 
672 theseven 213
$(UNINSTDIR)/build/uninstaller-ipodnano2g.emcoreapp: uninstaller-ipodnano2g
214
 
215
flashfiles/uninstaller-ipodnano2g.emcoreapp: $(UNINSTDIR)/build/uninstaller-ipodnano2g.emcoreapp uninstaller-ipodnano2g
216
	@echo [CP]     $@
217
	@cp $< $@
218
 
551 theseven 219
$(BOOTMENUDIR)/build/bootmenu-ipodnano2g.emcoreapp: bootmenu-ipodnano2g
160 theseven 220
 
551 theseven 221
flashfiles/bootmenu-ipodnano2g.emcoreapp: $(BOOTMENUDIR)/build/bootmenu-ipodnano2g.emcoreapp bootmenu-ipodnano2g
222
	@echo [CP]     $@
223
	@cp $< $@
160 theseven 224
 
551 theseven 225
flashfiles/background.png: $(BOOTMENUDIR)/images/background.png
226
	@echo [CP]     $@
227
	@cp $< $@
181 theseven 228
 
551 theseven 229
flashfiles/icons.png: $(BOOTMENUDIR)/images/icons.png
160 theseven 230
	@echo [CP]     $@
231
	@cp $< $@
232
 
551 theseven 233
flashfiles/rockbox.png: $(BOOTMENUDIR)/images/rockbox.png
234
	@echo [CP]     $@
235
	@cp $< $@
181 theseven 236
 
551 theseven 237
flashfiles/crapple.png: $(BOOTMENUDIR)/images/crapple.png
160 theseven 238
	@echo [CP]     $@
239
	@cp $< $@
240
 
551 theseven 241
$(EMCOREDIR)/loader/ipodnano2g/build/emcoreldr-ipodnano2g.dfu: emcoreldr-ipodnano2g
242
 
243
flashfiles/emcoreldr-ipodnano2g.dfu: $(EMCOREDIR)/loader/ipodnano2g/build/emcoreldr-ipodnano2g.dfu emcoreldr-ipodnano2g
244
	@echo [CP]     $@
245
	@cp $< $@
246
 
247
flashfiles/emcore-ipodnano2g.ucl: flashfiles/emcore-ipodnano2g.bin
160 theseven 248
	@echo [UCL]    $<
249
	@$(UCLPACK) $< $@
250
 
551 theseven 251
$(EMCOREDIR)/build/ipodnano2g/emcore.bin: emcore
181 theseven 252
 
551 theseven 253
flashfiles/emcore-ipodnano2g.bin: $(EMCOREDIR)/build/ipodnano2g/emcore.bin emcore
160 theseven 254
	@echo [EMBCFG] $@
551 theseven 255
	@$(EMCOREBOOTCFG) $< $@ "(3, '/.boot/init.emcoreapp', None, (2, 'bootmenu', None, None))"
160 theseven 256
 
551 theseven 257
emcore:
697 theseven 258
	@$(MAKE) -C $(EMCOREDIR) ipodnano2g
160 theseven 259
 
551 theseven 260
emcoreldr-ipodnano2g:
697 theseven 261
	@$(MAKE) -C $(EMCOREDIR)/loader/ipodnano2g
160 theseven 262
 
672 theseven 263
uninstaller-ipodnano2g:
697 theseven 264
	@$(MAKE) -C $(UNINSTDIR)
672 theseven 265
 
551 theseven 266
bootmenu-ipodnano2g:
697 theseven 267
	@$(MAKE) -C $(BOOTMENUDIR)
160 theseven 268
 
551 theseven 269
libboot:
697 theseven 270
	@$(MAKE) -C $(LIBBOOTDIR)
160 theseven 271
 
551 theseven 272
libpng:
697 theseven 273
	@$(MAKE) -C $(LIBPNGDIR)
551 theseven 274
 
275
libui:
697 theseven 276
	@$(MAKE) -C $(LIBUIDIR)
551 theseven 277
 
672 theseven 278
libmkfat32:
697 theseven 279
	@$(MAKE) -C $(LIBMKFAT32DIR)
672 theseven 280
 
243 theseven 281
umsboot:
697 theseven 282
	@$(MAKE) -C $(UMSBOOTDIR) ipodnano2g
243 theseven 283
 
160 theseven 284
clean:
285
	@rm -rf build
286
 
672 theseven 287
.PHONY: all clean emcore emcoreldr-ipodnano2g bootmenu-ipodnano2g uninstaller-ipodnano2g libboot libpng libui libmkfat32 umsboot libucl flashfiles $(NAME)