Subversion Repositories freemyipod

Rev

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