Subversion Repositories freemyipod

Rev

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