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