Subversion Repositories freemyipod

Rev

Rev 843 | Rev 866 | 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
253 theseven 44
GENNOTE := python $(NOTEBOOTDIR)/gennote.py
160 theseven 45
SCRAMBLE := python $(TOOLSDIR)/scramble.py
46
 
843 theseven 47
LIBINCLUDES := -I$(LIBPNGDIR)/export -I$(LIBUIDIR)/export
160 theseven 48
 
551 theseven 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)
50
LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --emit-relocs --gc-sections
51
 
160 theseven 52
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
672 theseven 53
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:" | sed -e "s:^\\./::")
160 theseven 54
 
55
REVISION := $(shell svnversion .)
56
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
57
 
551 theseven 58
HELPERS := build/__emcore_armhelpers.o
160 theseven 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
 
253 theseven 69
$(NAME): build/$(BASENAME).bootnote build/$(BASENAME).ipodx
160 theseven 70
 
253 theseven 71
build/$(BASENAME).ipodx: build/$(NAME).fw
160 theseven 72
	@echo [SCRAMB] $<
73
	@$(SCRAMBLE) $< $@ --signature=nn2x --targetid=62
74
 
75
build/$(NAME).fw: build/$(NAME).bin
76
	@echo [CFW]    $<
77
	@$(CRYPTFW) $< $@
78
 
253 theseven 79
build/$(BASENAME).bootnote: build/$(NAME).bin
80
	@echo [GENNOT] $<
81
	@$(GENNOTE) $< "$(FATNAME)" $@
82
 
551 theseven 83
build/$(NAME).bin: build/bootstub.bin build/$(NAME).ubi
160 theseven 84
	@echo [STUBEM] $@
85
	@$(STUBEMBED) $^ $@
86
 
551 theseven 87
build/$(NAME).ubi: $(EMCOREDIR)/build/ipodnano2g/emcore.bin build/$(NAME).emcoreapp
160 theseven 88
	@echo [EMBAPP] $@
551 theseven 89
	@$(EMCOREEMBEDAPP) $^ $@
160 theseven 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
 
551 theseven 99
build/$(NAME).emcoreapp: build/$(NAME).elf
100
	@echo [EMCAPP] $<
101
ifeq ($(COMPRESS),true)
102
	@$(ELF2ECA) -z -s $(STACKSIZE) -o $@ $^
160 theseven 103
else
551 theseven 104
	@$(ELF2ECA) -s $(STACKSIZE) -o $@ $^
160 theseven 105
endif
106
 
705 theseven 107
ifeq ($(AUTOBUILD_FLASHFILES),true)
108
build/resources.o: $(FLASHFILES)
109
else
551 theseven 110
build/resources.o: flashfiles.built
698 theseven 111
endif
112
 
843 theseven 113
ifeq ($(AUTOBUILD_FSFILES),true)
114
build/resources.o: $(FSFILES)
115
else
116
build/resources.o: fsfiles.built
117
endif
118
 
160 theseven 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
 
551 theseven 157
build/__emcore_%.o: $(EMCOREDIR)/export/%.c
160 theseven 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
 
551 theseven 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
 
160 theseven 175
build/libucl.a: libucl
697 theseven 176
	@$(MAKE) -C libucl CFLAGS="$(CFLAGS) -I../$(EMCOREDIR)/export"
160 theseven 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)
165 theseven 189
	@touch flashfiles.built
160 theseven 190
 
551 theseven 191
$(LIBBOOTDIR)/build/boot.emcorelib: libboot
705 theseven 192
	@$(MAKE) -C $(LIBBOOTDIR)
181 theseven 193
 
705 theseven 194
flashfiles/boot.emcorelib: $(LIBBOOTDIR)/build/boot.emcorelib
160 theseven 195
	@echo [CP]     $@
196
	@cp $< $@
197
 
551 theseven 198
$(LIBPNGDIR)/build/png.emcorelib: libpng
705 theseven 199
	@$(MAKE) -C $(LIBPNGDIR)
551 theseven 200
 
705 theseven 201
flashfiles/png.emcorelib: $(LIBPNGDIR)/build/png.emcorelib
551 theseven 202
	@echo [CP]     $@
203
	@cp $< $@
204
 
205
$(LIBUIDIR)/build/ui.emcorelib: libui
705 theseven 206
	@$(MAKE) -C $(LIBUIDIR)
551 theseven 207
 
705 theseven 208
flashfiles/ui.emcorelib: $(LIBUIDIR)/build/ui.emcorelib
551 theseven 209
	@echo [CP]     $@
210
	@cp $< $@
211
 
672 theseven 212
$(LIBMKFAT32DIR)/build/mkfat32.emcorelib: libmkfat32
705 theseven 213
	@$(MAKE) -C $(LIBMKFAT32DIR)
672 theseven 214
 
705 theseven 215
flashfiles/mkfat32.emcorelib: $(LIBMKFAT32DIR)/build/mkfat32.emcorelib
672 theseven 216
	@echo [CP]     $@
217
	@cp $< $@
218
 
706 theseven 219
$(UMSBOOTDIR)/build/ipodnano2g/umsboot-ipodnano2g.ucl $(UMSBOOTDIR)/build/ipodnano2g/umsboot.bin: umsboot
705 theseven 220
	@$(MAKE) -C $(UMSBOOTDIR) ipodnano2g
243 theseven 221
 
705 theseven 222
flashfiles/umsboot-ipodnano2g.ucl: $(UMSBOOTDIR)/build/ipodnano2g/umsboot-ipodnano2g.ucl
243 theseven 223
	@echo [CP]     $@
224
	@cp $< $@
225
 
672 theseven 226
$(UNINSTDIR)/build/uninstaller-ipodnano2g.emcoreapp: uninstaller-ipodnano2g
705 theseven 227
	@$(MAKE) -C $(UNINSTDIR)
672 theseven 228
 
705 theseven 229
flashfiles/uninstaller-ipodnano2g.emcoreapp: $(UNINSTDIR)/build/uninstaller-ipodnano2g.emcoreapp
672 theseven 230
	@echo [CP]     $@
231
	@cp $< $@
232
 
551 theseven 233
$(BOOTMENUDIR)/build/bootmenu-ipodnano2g.emcoreapp: bootmenu-ipodnano2g
705 theseven 234
	@$(MAKE) -C $(BOOTMENUDIR)
160 theseven 235
 
705 theseven 236
flashfiles/bootmenu-ipodnano2g.emcoreapp: $(BOOTMENUDIR)/build/bootmenu-ipodnano2g.emcoreapp
551 theseven 237
	@echo [CP]     $@
238
	@cp $< $@
160 theseven 239
 
843 theseven 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
 
551 theseven 252
$(EMCOREDIR)/loader/ipodnano2g/build/emcoreldr-ipodnano2g.dfu: emcoreldr-ipodnano2g
705 theseven 253
	@$(MAKE) -C $(EMCOREDIR)/loader/ipodnano2g
551 theseven 254
 
705 theseven 255
flashfiles/emcoreldr-ipodnano2g.dfu: $(EMCOREDIR)/loader/ipodnano2g/build/emcoreldr-ipodnano2g.dfu
551 theseven 256
	@echo [CP]     $@
257
	@cp $< $@
258
 
259
flashfiles/emcore-ipodnano2g.ucl: flashfiles/emcore-ipodnano2g.bin
160 theseven 260
	@echo [UCL]    $<
261
	@$(UCLPACK) $< $@
262
 
551 theseven 263
$(EMCOREDIR)/build/ipodnano2g/emcore.bin: emcore
705 theseven 264
	@$(MAKE) -C $(EMCOREDIR) ipodnano2g
181 theseven 265
 
705 theseven 266
flashfiles/emcore-ipodnano2g.bin: $(EMCOREDIR)/build/ipodnano2g/emcore.bin
160 theseven 267
	@echo [EMBCFG] $@
551 theseven 268
	@$(EMCOREBOOTCFG) $< $@ "(3, '/.boot/init.emcoreapp', None, (2, 'bootmenu', None, None))"
160 theseven 269
 
270
clean:
271
	@rm -rf build
272
 
843 theseven 273
.PHONY: all clean emcore emcoreldr-ipodnano2g bootmenu-ipodnano2g bootmenu-ipodnano2g-theme uninstaller-ipodnano2g libboot libpng libui libmkfat32 umsboot libucl flashfiles $(NAME)