Subversion Repositories freemyipod

Rev

Rev 660 | Rev 668 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
530 theseven 1
NAME := installer-ipodclassic
2
STACKSIZE := 4096
3
COMPRESS := false
366 theseven 4
 
530 theseven 5
EMCOREDIR ?= ../../emcore/trunk/
6
BOOTMENUDIR ?= ../bootmenu-ipodclassic/
7
LIBBOOTDIR ?= ../../libs/boot/
8
LIBPNGDIR ?= ../../libs/png/
9
LIBUIDIR ?= ../../libs/ui/
660 theseven 10
LIBMKFAT32DIR ?= ../../libs/mkfat32/
366 theseven 11
UMSBOOTDIR ?= ../../umsboot/
12
TOOLSDIR ?= ../../tools/
13
 
660 theseven 14
FLASHFILES = flashfiles/boot.emcorelib flashfiles/png.emcorelib flashfiles/ui.emcorelib flashfiles/mkfat32.emcorelib \
530 theseven 15
             flashfiles/bootmenu-ipodclassic.emcoreapp flashfiles/background.png flashfiles/icons.png flashfiles/rockbox.png \
16
             flashfiles/emcoreldr-ipodclassic.bin flashfiles/emcore-ipodclassic.ucl flashfiles/umsboot-ipodclassic.ucl
366 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
366 theseven 26
AS      := $(CROSS)as
27
LD      := $(CROSS)ld
28
OBJCOPY := $(CROSS)objcopy
530 theseven 29
ELF2ECA := $(CROSS)elf2emcoreapp
366 theseven 30
UCLPACK := ucl2e10singleblk
31
STUBEMBED := python tools/stubembed.py
530 theseven 32
EMCOREBOOTCFG := python $(EMCOREDIR)/tools/emcorebootcfg.py
33
EMCOREEMBEDAPP := python $(EMCOREDIR)/tools/emcoreembedapp.py
34
GENPWN := python $(EMCOREDIR)/tools/ipodcrypt.py s5l8702-genpwnage
366 theseven 35
 
660 theseven 36
LIBINCLUDES := -I$(LIBPNGDIR)/export -I$(LIBUIDIR)/export -I$(LIBMKFAT32DIR)/export
366 theseven 37
 
530 theseven 38
CFLAGS  += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -I$(EMCOREDIR)/export $(LIBINCLUDES) -ffunction-sections -fdata-sections -mcpu=arm940t -DARM_ARCH=4
39
LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --emit-relocs --gc-sections
40
 
366 theseven 41
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
42
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
43
 
44
REVISION := $(shell svnversion .)
45
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
46
 
530 theseven 47
HELPERS := build/__emcore_armhelpers.o
366 theseven 48
 
49
SRC := $(call preprocesspaths,SOURCES,-I. -I..)
50
OBJ := $(SRC:%.c=build/%.o)
51
OBJ := $(OBJ:%.S=build/%.o) $(HELPERS)
52
 
53
all: $(NAME)
54
 
55
-include $(OBJ:%=%.dep)
56
 
57
$(NAME): build/bootstrap-ipodclassic.dfu build/$(NAME).ubi
58
 
59
build/bootstrap-ipodclassic.dfu: build/bootstrap.bin
60
	@echo [GENPWN] $<
61
	@$(GENPWN) $< $@
62
 
63
build/bootstrap.bin: build/bootstub.bin $(UMSBOOTDIR)/build/ipodclassic/umsboot.bin
64
	@echo [STUBEM] $@
65
	@$(STUBEMBED) $^ $@
66
 
530 theseven 67
build/$(NAME).ubi: $(EMCOREDIR)/build/ipodclassic/emcore.bin build/$(NAME).emcoreapp
366 theseven 68
	@echo [EMBAPP] $@
530 theseven 69
	@$(EMCOREEMBEDAPP) $^ $@
366 theseven 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
 
530 theseven 79
build/$(NAME).emcoreapp: build/$(NAME).elf
80
	@echo [EMCAPP] $<
81
ifeq ($(COMPRESS),true)
82
	@$(ELF2ECA) -z -s $(STACKSIZE) -o $@ $^
366 theseven 83
else
530 theseven 84
	@$(ELF2ECA) -s $(STACKSIZE) -o $@ $^
366 theseven 85
endif
86
 
530 theseven 87
build/resources.o: flashfiles.built
366 theseven 88
 
89
build/$(NAME).elf: ls.x $(OBJ)
90
	@echo [LD]     $@
91
	@$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ)
92
 
93
build/%.o: %.c build/version.h
94
	@echo [CC]     $<
95
ifeq ($(shell uname),WindowsNT)
96
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
97
else
98
	@-mkdir -p $(dir $@)
99
endif
100
	@$(CC) -c $(CFLAGS) -o $@ $<
101
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
102
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
103
ifeq ($(shell uname),WindowsNT)
104
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
105
else
106
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
107
endif
108
	@rm -f $@.dep.tmp
109
 
110
build/%.o: %.S build/version.h
111
	@echo [CC]     $<
112
ifeq ($(shell uname),WindowsNT)
113
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
114
else
115
	@-mkdir -p $(dir $@)
116
endif
117
	@$(CC) -c $(CFLAGS) -o $@ $<
118
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
119
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
120
ifeq ($(shell uname),WindowsNT)
121
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
122
else
123
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
124
endif
125
	@rm -f $@.dep.tmp
126
 
530 theseven 127
build/__emcore_%.o: $(EMCOREDIR)/export/%.c
366 theseven 128
	@echo [CC]     $<
129
ifeq ($(shell uname),WindowsNT)
130
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
131
else
132
	@-mkdir -p $(dir $@)
133
endif
134
	@$(CC) -c $(CFLAGS) -o $@ $<
135
 
530 theseven 136
build/__emcore_%.o: $(EMCOREDIR)/export/%.S
137
	@echo [CC]     $<
138
ifeq ($(shell uname),WindowsNT)
139
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
140
else
141
	@-mkdir -p $(dir $@)
142
endif
143
	@$(CC) -c $(CFLAGS) -o $@ $<
144
 
366 theseven 145
build/version.h: version.h .svn/entries
146
	@echo [PP]     $<
147
ifeq ($(shell uname),WindowsNT)
148
	@-if not exist build md build
149
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
150
else
151
	@-mkdir -p build
152
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
153
endif
154
 
155
flashfiles: $(FLASHFILES)
156
	@touch flashfiles.built
157
 
530 theseven 158
$(LIBBOOTDIR)/build/boot.emcorelib: libboot
383 theseven 159
 
530 theseven 160
flashfiles/boot.emcorelib: $(LIBBOOTDIR)/build/boot.emcorelib libboot
383 theseven 161
	@echo [CP]     $@
162
	@cp $< $@
163
 
530 theseven 164
$(LIBPNGDIR)/build/png.emcorelib: libpng
165
 
166
flashfiles/png.emcorelib: $(LIBPNGDIR)/build/png.emcorelib libpng
167
	@echo [CP]     $@
168
	@cp $< $@
169
 
170
$(LIBUIDIR)/build/ui.emcorelib: libui
171
 
172
flashfiles/ui.emcorelib: $(LIBUIDIR)/build/ui.emcorelib libui
173
	@echo [CP]     $@
174
	@cp $< $@
175
 
661 theseven 176
$(LIBMKFAT32DIR)/build/mkfat32.emcorelib: libmkfat32
660 theseven 177
 
178
flashfiles/mkfat32.emcorelib: $(LIBMKFAT32DIR)/build/mkfat32.emcorelib libmkfat32
179
	@echo [CP]     $@
180
	@cp $< $@
181
 
366 theseven 182
$(UMSBOOTDIR)/build/ipodclassic/umsboot-ipodclassic.ucl: umsboot
183
 
184
flashfiles/umsboot-ipodclassic.ucl: $(UMSBOOTDIR)/build/ipodclassic/umsboot-ipodclassic.ucl umsboot
185
	@echo [CP]     $@
186
	@cp $< $@
187
 
530 theseven 188
$(BOOTMENUDIR)/build/bootmenu-ipodclassic.emcoreapp: bootmenu-ipodclassic
366 theseven 189
 
530 theseven 190
flashfiles/bootmenu-ipodclassic.emcoreapp: $(BOOTMENUDIR)/build/bootmenu-ipodclassic.emcoreapp bootmenu-ipodclassic
191
	@echo [CP]     $@
192
	@cp $< $@
366 theseven 193
 
530 theseven 194
flashfiles/background.png: $(BOOTMENUDIR)/images/background.png
195
	@echo [CP]     $@
196
	@cp $< $@
366 theseven 197
 
530 theseven 198
flashfiles/icons.png: $(BOOTMENUDIR)/images/icons.png
366 theseven 199
	@echo [CP]     $@
200
	@cp $< $@
201
 
530 theseven 202
flashfiles/rockbox.png: $(BOOTMENUDIR)/images/rockbox.png
203
	@echo [CP]     $@
204
	@cp $< $@
366 theseven 205
 
530 theseven 206
$(EMCOREDIR)/loader/ipodclassic/build/emcoreldr-ipodclassic.bin: emcoreldr-ipodclassic
207
 
208
flashfiles/emcoreldr-ipodclassic.bin: $(EMCOREDIR)/loader/ipodclassic/build/emcoreldr-ipodclassic.bin emcoreldr-ipodclassic
366 theseven 209
	@echo [CP]     $@
210
	@cp $< $@
211
 
530 theseven 212
flashfiles/emcore-ipodclassic.ucl: flashfiles/emcore-ipodclassic.bin
366 theseven 213
	@echo [UCL]    $<
214
	@$(UCLPACK) $< $@
215
 
530 theseven 216
$(EMCOREDIR)/build/ipodclassic/emcore.bin: emcore
366 theseven 217
 
530 theseven 218
flashfiles/emcore-ipodclassic.bin: $(EMCOREDIR)/build/ipodclassic/emcore.bin emcore
366 theseven 219
	@echo [EMBCFG] $@
546 theseven 220
	@$(EMCOREBOOTCFG) $< $@ "(3, '/.boot/init.emcoreapp', None, (2, 'bootmenu', None, None))"
366 theseven 221
 
530 theseven 222
emcore:
223
	@make -C $(EMCOREDIR) ipodclassic
366 theseven 224
 
530 theseven 225
emcoreldr-ipodclassic:
226
	@make -C $(EMCOREDIR)/loader/ipodclassic
366 theseven 227
 
530 theseven 228
bootmenu-ipodclassic:
229
	@make -C $(BOOTMENUDIR)
383 theseven 230
 
530 theseven 231
libboot:
232
	@make -C $(LIBBOOTDIR)
233
 
234
libpng:
235
	@make -C $(LIBPNGDIR)
236
 
237
libui:
238
	@make -C $(LIBUIDIR)
239
 
660 theseven 240
libmkfat32:
241
	@make -C $(LIBMKFAT32DIR)
242
 
366 theseven 243
$(UMSBOOTDIR)/build/ipodclassic/umsboot.bin: umsboot
244
 
245
umsboot:
246
	@make -C $(UMSBOOTDIR) ipodclassic
247
 
248
clean:
249
	@rm -rf build
250
 
660 theseven 251
.PHONY: all clean emcore emcoreldr-ipodclassic bootmenu-ipodclassic libboot libpng libui libmkfat32 umsboot libucl flashfiles $(NAME)