Subversion Repositories freemyipod

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
160 theseven 1
NAME := installer-nano2g
253 theseven 2
BASENAME ?= $(NAME)
3
FATNAME ?= INSTAL~1BOO
160 theseven 4
 
5
EMBIOSDIR ?= ../../embios/trunk/
6
ILOADERDIR ?= ../iloader/
7
UNINSTDIR ?= ../uninstaller-nano2g/
243 theseven 8
UMSBOOTDIR ?= ../../umsboot/
253 theseven 9
NOTEBOOTDIR ?= ../../noteboot/
160 theseven 10
TOOLSDIR ?= ../../tools/
11
 
12
BITMAPS = build/backdrop.ucl build/welcome.ucl build/repartition.ucl build/installing.ucl build/badpartition.ucl \
13
          build/cancelled.ucl build/repartitioning.ucl build/preparing.ucl build/installfiles.ucl build/flashing.ucl
14
 
15
FLASHFILES = flashfiles/uninstaller-nano2g.embiosapp.ucl flashfiles/iloader.cfg.ucl flashfiles/iloader.embiosapp.ucl \
243 theseven 16
             flashfiles/embiosldr-ipodnano2g.dfu flashfiles/embios-ipodnano2g.ucl flashfiles/umsboot-ipodnano2g.ucl
160 theseven 17
 
462 theseven 18
ifeq ($(shell uname),WindowsNT)
19
CCACHE :=
20
else
21
CCACHE := $(shell which ccache)
22
endif
23
 
457 theseven 24
CROSS   ?= arm-elf-eabi-
462 theseven 25
CC      := $(CCACHE) $(CROSS)gcc
160 theseven 26
AS      := $(CROSS)as
27
LD      := $(CROSS)ld
28
OBJCOPY := $(CROSS)objcopy
29
UCLPACK := ucl2e10singleblk
30
GENINSTALLER := python tools/geninstaller.py
31
STUBEMBED := python tools/stubembed.py
32
COMPILECONFIG := python $(ILOADERDIR)/tools/compileconfig.py
33
EMBIOSBOOTCFG := python $(EMBIOSDIR)/tools/embiosbootcfg.py
34
EMBIOSEMBEDAPP := python $(EMBIOSDIR)/tools/embiosembedapp.py
272 theseven 35
CRYPTFW := python $(EMBIOSDIR)/tools/ipodcrypt.py s5l8701-cryptfirmware
253 theseven 36
GENNOTE := python $(NOTEBOOTDIR)/gennote.py
160 theseven 37
SCRAMBLE := python $(TOOLSDIR)/scramble.py
38
 
39
CFLAGS  += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -I$(EMBIOSDIR)/export -ffunction-sections -fdata-sections -mcpu=arm940t
40
LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --gc-sections
41
 
42
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
43
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
44
 
45
REVISION := $(shell svnversion .)
46
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
47
 
48
HELPERS := build/__embios_armhelpers.o
49
LIBS := build/libucl.a
50
 
51
SRC := $(call preprocesspaths,SOURCES,-I. -I..)
52
OBJ := $(SRC:%.c=build/%.o)
53
OBJ := $(OBJ:%.S=build/%.o) $(HELPERS)
54
 
55
all: $(NAME)
56
 
57
-include $(OBJ:%=%.dep)
58
 
253 theseven 59
$(NAME): build/$(BASENAME).bootnote build/$(BASENAME).ipodx
160 theseven 60
 
253 theseven 61
build/$(BASENAME).ipodx: build/$(NAME).fw
160 theseven 62
	@echo [SCRAMB] $<
63
	@$(SCRAMBLE) $< $@ --signature=nn2x --targetid=62
64
 
65
build/$(NAME).fw: build/$(NAME).bin
66
	@echo [CFW]    $<
67
	@$(CRYPTFW) $< $@
68
 
253 theseven 69
build/$(BASENAME).bootnote: build/$(NAME).bin
70
	@echo [GENNOT] $<
71
	@$(GENNOTE) $< "$(FATNAME)" $@
72
 
160 theseven 73
build/$(NAME).bin: build/bootstub.bin build/$(NAME).integrated.bin
74
	@echo [STUBEM] $@
75
	@$(STUBEMBED) $^ $@
76
 
253 theseven 77
build/$(NAME).integrated.bin: $(EMBIOSDIR)/build/ipodnano2g/embios.bin build/$(NAME).embiosapp.ucl
160 theseven 78
	@echo [EMBAPP] $@
253 theseven 79
	@$(EMBIOSEMBEDAPP) $^ $@ --run-from=0x08f00000 --compressed
160 theseven 80
 
253 theseven 81
build/$(NAME).embiosapp.ucl: build/$(NAME).embiosapp
82
	@echo [UCL]    $<
83
	@$(UCLPACK) $< $@
84
 
165 theseven 85
build/$(NAME).embiosapp: build/$(NAME).plain.embiosapp $(BITMAPS) flashfiles.built
161 theseven 86
	@echo [GENINS] $<
253 theseven 87
	@$(GENINSTALLER) $< $@ /notes/$(BASENAME).bootnote fsfiles
160 theseven 88
 
89
build/bootstub.bin: build/bootstub.elf
90
	@echo [OC]     $<
91
	@$(OBJCOPY) -O binary $^ $@
92
 
93
build/bootstub.elf: bootstub/ls.x build/bootstub/bootstub.o
94
	@echo [LD]     $@
95
	@$(LD) $(LDFLAGS) -o $@ -T bootstub/ls.x build/bootstub/bootstub.o
96
 
97
build/%.ucl: oobe/%.bmp
98
	@echo [UCL]    $<
99
ifeq ($(shell uname),WindowsNT)
100
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
101
else
102
	@-mkdir -p $(dir $@)
103
endif
104
	@$(UCLPACK) $< $@
105
 
106
build/$(NAME).plain.embiosapp: build/$(NAME).elf
107
	@echo [OC]     $<
108
	@$(OBJCOPY) -O binary $^ $@
109
 
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
 
148
build/__embios_%.o: $(EMBIOSDIR)/export/%.S
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
 
157
build/libucl.a: libucl
158
 
159
libucl:
160
	@make -C libucl CFLAGS="$(CFLAGS) -I../$(EMBIOSDIR)/export"
161
 
162
build/version.h: version.h .svn/entries
163
	@echo [PP]     $<
164
ifeq ($(shell uname),WindowsNT)
165
	@-if not exist build md build
166
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
167
else
168
	@-mkdir -p build
169
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
170
endif
171
 
172
flashfiles: $(FLASHFILES)
165 theseven 173
	@touch flashfiles.built
160 theseven 174
 
181 theseven 175
$(UNINSTDIR)/build/uninstaller-nano2g.embiosapp.ucl: uninstaller-nano2g
176
 
160 theseven 177
flashfiles/uninstaller-nano2g.embiosapp.ucl: $(UNINSTDIR)/build/uninstaller-nano2g.embiosapp.ucl uninstaller-nano2g
178
	@echo [CP]     $@
179
	@cp $< $@
180
 
243 theseven 181
$(UMSBOOTDIR)/build/ipodnano2g/umsboot-ipodnano2g.ucl: umsboot
182
 
183
flashfiles/umsboot-ipodnano2g.ucl: $(UMSBOOTDIR)/build/ipodnano2g/umsboot-ipodnano2g.ucl umsboot
184
	@echo [CP]     $@
185
	@cp $< $@
186
 
160 theseven 187
flashfiles/iloader.cfg: flashfiles/iloader.conf
188
	@echo [COMCFG] $@
189
	@$(COMPILECONFIG) $< $@
190
 
191
flashfiles/iloader.cfg.ucl: flashfiles/iloader.cfg
192
	@echo [UCL]    $<
193
	@$(UCLPACK) $< $@
194
 
181 theseven 195
$(ILOADERDIR)/build/iloader.embiosapp.ucl: iloader
196
 
160 theseven 197
flashfiles/iloader.embiosapp.ucl: $(ILOADERDIR)/build/iloader.embiosapp.ucl iloader
198
	@echo [CP]     $@
199
	@cp $< $@
200
 
181 theseven 201
$(EMBIOSDIR)/loader/ipodnano2g/build/embiosldr-ipodnano2g.dfu: embiosldr-ipodnano2g
202
 
160 theseven 203
flashfiles/embiosldr-ipodnano2g.dfu: $(EMBIOSDIR)/loader/ipodnano2g/build/embiosldr-ipodnano2g.dfu embiosldr-ipodnano2g
204
	@echo [CP]     $@
205
	@cp $< $@
206
 
207
flashfiles/embios-ipodnano2g.ucl: flashfiles/embios-ipodnano2g.bin
208
	@echo [UCL]    $<
209
	@$(UCLPACK) $< $@
210
 
181 theseven 211
$(EMBIOSDIR)/build/ipodnano2g/embios.bin: embios
212
 
213
flashfiles/embios-ipodnano2g.bin: $(EMBIOSDIR)/build/ipodnano2g/embios.bin embios
160 theseven 214
	@echo [EMBCFG] $@
165 theseven 215
	@$(EMBIOSBOOTCFG) $< $@ --file=/iLoader/boot.embiosapp --file-compressed --file-run-from=0x08000000 \
216
	                        --flash=iloader --flash-compressed --flash-run-from=0x09e00000
160 theseven 217
 
218
embios:
165 theseven 219
	@make -C $(EMBIOSDIR) ipodnano2g
160 theseven 220
 
221
embiosldr-ipodnano2g:
222
	@make -C $(EMBIOSDIR)/loader/ipodnano2g
223
 
224
iloader:
225
	@make -C $(ILOADERDIR)
226
 
227
uninstaller-nano2g:
228
	@make -C $(UNINSTDIR)
229
 
243 theseven 230
umsboot:
231
	@make -C $(UMSBOOTDIR) ipodnano2g
232
 
160 theseven 233
clean:
234
	@rm -rf build
235
 
243 theseven 236
.PHONY: all clean uninstaller-nano2g iloader embios embiosldr-ipodnano2g umsboot libucl flashfiles $(NAME)