Subversion Repositories freemyipod

Rev

Rev 697 | Rev 705 | 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 "^\#")
668 theseven 42
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:" | sed -e "s:^\\./::")
366 theseven 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
 
698 theseven 89
ifeq ($(AUTOBUILD_FLASHFILES),true)
90
flashfiles.built: flashfiles
91
endif
92
 
366 theseven 93
build/$(NAME).elf: ls.x $(OBJ)
94
	@echo [LD]     $@
95
	@$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ)
96
 
97
build/%.o: %.c build/version.h
98
	@echo [CC]     $<
99
ifeq ($(shell uname),WindowsNT)
100
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
101
else
102
	@-mkdir -p $(dir $@)
103
endif
104
	@$(CC) -c $(CFLAGS) -o $@ $<
105
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
106
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
107
ifeq ($(shell uname),WindowsNT)
108
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
109
else
110
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
111
endif
112
	@rm -f $@.dep.tmp
113
 
114
build/%.o: %.S build/version.h
115
	@echo [CC]     $<
116
ifeq ($(shell uname),WindowsNT)
117
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
118
else
119
	@-mkdir -p $(dir $@)
120
endif
121
	@$(CC) -c $(CFLAGS) -o $@ $<
122
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
123
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
124
ifeq ($(shell uname),WindowsNT)
125
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
126
else
127
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
128
endif
129
	@rm -f $@.dep.tmp
130
 
530 theseven 131
build/__emcore_%.o: $(EMCOREDIR)/export/%.c
366 theseven 132
	@echo [CC]     $<
133
ifeq ($(shell uname),WindowsNT)
134
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
135
else
136
	@-mkdir -p $(dir $@)
137
endif
138
	@$(CC) -c $(CFLAGS) -o $@ $<
139
 
530 theseven 140
build/__emcore_%.o: $(EMCOREDIR)/export/%.S
141
	@echo [CC]     $<
142
ifeq ($(shell uname),WindowsNT)
143
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
144
else
145
	@-mkdir -p $(dir $@)
146
endif
147
	@$(CC) -c $(CFLAGS) -o $@ $<
148
 
366 theseven 149
build/version.h: version.h .svn/entries
150
	@echo [PP]     $<
151
ifeq ($(shell uname),WindowsNT)
152
	@-if not exist build md build
153
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
154
else
155
	@-mkdir -p build
156
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
157
endif
158
 
159
flashfiles: $(FLASHFILES)
160
	@touch flashfiles.built
161
 
530 theseven 162
$(LIBBOOTDIR)/build/boot.emcorelib: libboot
383 theseven 163
 
530 theseven 164
flashfiles/boot.emcorelib: $(LIBBOOTDIR)/build/boot.emcorelib libboot
383 theseven 165
	@echo [CP]     $@
166
	@cp $< $@
167
 
530 theseven 168
$(LIBPNGDIR)/build/png.emcorelib: libpng
169
 
170
flashfiles/png.emcorelib: $(LIBPNGDIR)/build/png.emcorelib libpng
171
	@echo [CP]     $@
172
	@cp $< $@
173
 
174
$(LIBUIDIR)/build/ui.emcorelib: libui
175
 
176
flashfiles/ui.emcorelib: $(LIBUIDIR)/build/ui.emcorelib libui
177
	@echo [CP]     $@
178
	@cp $< $@
179
 
661 theseven 180
$(LIBMKFAT32DIR)/build/mkfat32.emcorelib: libmkfat32
660 theseven 181
 
182
flashfiles/mkfat32.emcorelib: $(LIBMKFAT32DIR)/build/mkfat32.emcorelib libmkfat32
183
	@echo [CP]     $@
184
	@cp $< $@
185
 
366 theseven 186
$(UMSBOOTDIR)/build/ipodclassic/umsboot-ipodclassic.ucl: umsboot
187
 
188
flashfiles/umsboot-ipodclassic.ucl: $(UMSBOOTDIR)/build/ipodclassic/umsboot-ipodclassic.ucl umsboot
189
	@echo [CP]     $@
190
	@cp $< $@
191
 
530 theseven 192
$(BOOTMENUDIR)/build/bootmenu-ipodclassic.emcoreapp: bootmenu-ipodclassic
366 theseven 193
 
530 theseven 194
flashfiles/bootmenu-ipodclassic.emcoreapp: $(BOOTMENUDIR)/build/bootmenu-ipodclassic.emcoreapp bootmenu-ipodclassic
195
	@echo [CP]     $@
196
	@cp $< $@
366 theseven 197
 
530 theseven 198
flashfiles/background.png: $(BOOTMENUDIR)/images/background.png
199
	@echo [CP]     $@
200
	@cp $< $@
366 theseven 201
 
530 theseven 202
flashfiles/icons.png: $(BOOTMENUDIR)/images/icons.png
366 theseven 203
	@echo [CP]     $@
204
	@cp $< $@
205
 
530 theseven 206
flashfiles/rockbox.png: $(BOOTMENUDIR)/images/rockbox.png
207
	@echo [CP]     $@
208
	@cp $< $@
366 theseven 209
 
530 theseven 210
$(EMCOREDIR)/loader/ipodclassic/build/emcoreldr-ipodclassic.bin: emcoreldr-ipodclassic
211
 
212
flashfiles/emcoreldr-ipodclassic.bin: $(EMCOREDIR)/loader/ipodclassic/build/emcoreldr-ipodclassic.bin emcoreldr-ipodclassic
366 theseven 213
	@echo [CP]     $@
214
	@cp $< $@
215
 
530 theseven 216
flashfiles/emcore-ipodclassic.ucl: flashfiles/emcore-ipodclassic.bin
366 theseven 217
	@echo [UCL]    $<
218
	@$(UCLPACK) $< $@
219
 
530 theseven 220
$(EMCOREDIR)/build/ipodclassic/emcore.bin: emcore
366 theseven 221
 
530 theseven 222
flashfiles/emcore-ipodclassic.bin: $(EMCOREDIR)/build/ipodclassic/emcore.bin emcore
366 theseven 223
	@echo [EMBCFG] $@
546 theseven 224
	@$(EMCOREBOOTCFG) $< $@ "(3, '/.boot/init.emcoreapp', None, (2, 'bootmenu', None, None))"
366 theseven 225
 
530 theseven 226
emcore:
697 theseven 227
	@$(MAKE) -C $(EMCOREDIR) ipodclassic
366 theseven 228
 
530 theseven 229
emcoreldr-ipodclassic:
697 theseven 230
	@$(MAKE) -C $(EMCOREDIR)/loader/ipodclassic
366 theseven 231
 
530 theseven 232
bootmenu-ipodclassic:
697 theseven 233
	@$(MAKE) -C $(BOOTMENUDIR)
383 theseven 234
 
530 theseven 235
libboot:
697 theseven 236
	@$(MAKE) -C $(LIBBOOTDIR)
530 theseven 237
 
238
libpng:
697 theseven 239
	@$(MAKE) -C $(LIBPNGDIR)
530 theseven 240
 
241
libui:
697 theseven 242
	@$(MAKE) -C $(LIBUIDIR)
530 theseven 243
 
660 theseven 244
libmkfat32:
697 theseven 245
	@$(MAKE) -C $(LIBMKFAT32DIR)
660 theseven 246
 
366 theseven 247
$(UMSBOOTDIR)/build/ipodclassic/umsboot.bin: umsboot
248
 
249
umsboot:
697 theseven 250
	@$(MAKE) -C $(UMSBOOTDIR) ipodclassic
366 theseven 251
 
252
clean:
253
	@rm -rf build
254
 
660 theseven 255
.PHONY: all clean emcore emcoreldr-ipodclassic bootmenu-ipodclassic libboot libpng libui libmkfat32 umsboot libucl flashfiles $(NAME)