Subversion Repositories freemyipod

Rev

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