Subversion Repositories freemyipod

Rev

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