Subversion Repositories freemyipod

Rev

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