Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

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