Subversion Repositories freemyipod

Rev

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