Subversion Repositories freemyipod

Rev

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

Rev Author Line No. Line
528 theseven 1
NAME := bootmenu-ipodclassic
2
STACKSIZE := 4096
3
COMPRESS := true
4
 
5
EMCOREDIR ?= ../../emcore/trunk/
6
LIBBOOTDIR ?= ../../libs/boot/
7
LIBPNGDIR ?= ../../libs/png/
8
LIBUIDIR ?= ../../libs/ui/
9
 
10
ifeq ($(shell uname),WindowsNT)
11
CCACHE :=
12
else
13
CCACHE := $(shell which ccache)
14
endif
15
 
16
CROSS   ?= arm-elf-eabi-
17
CC      := $(CCACHE) $(CROSS)gcc
18
AS      := $(CROSS)as
19
LD      := $(CROSS)ld
20
OBJCOPY := $(CROSS)objcopy
21
ELF2ECA := $(CROSS)elf2emcoreapp
22
 
23
LIBINCLUDES := -I$(LIBPNGDIR)/export -I$(LIBUIDIR)/export
24
 
25
CFLAGS  += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -I$(EMCOREDIR)/export $(LIBINCLUDES) -ffunction-sections -fdata-sections -mcpu=arm940t -DARM_ARCH=4
26
LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --emit-relocs --gc-sections
27
 
28
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
29
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
30
 
31
REVISION := $(shell svnversion .)
32
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
33
 
34
HELPERS := build/__emcore_armhelpers.o
35
 
36
SRC := $(call preprocesspaths,SOURCES,-I. -I..)
37
OBJ := $(SRC:%.c=build/%.o)
38
OBJ := $(OBJ:%.S=build/%.o) $(HELPERS)
39
 
40
all: $(NAME)
41
 
42
-include $(OBJ:%=%.dep)
43
 
44
$(NAME): build/$(NAME).emcoreapp
45
 
46
build/$(NAME).emcoreapp: build/$(NAME).elf
47
	@echo [EMCAPP] $<
48
ifeq ($(COMPRESS),true)
49
	@$(ELF2ECA) -z -s $(STACKSIZE) -o $@ $^
50
else
51
	@$(ELF2ECA) -s $(STACKSIZE) -o $@ $^
52
endif
53
 
54
build/$(NAME).elf: ls.x $(OBJ)
55
	@echo [LD]     $@
56
	@$(LD) $(LDFLAGS) -o $@ -T ls.x $(OBJ)
57
 
58
build/%.o: %.c build/version.h
59
	@echo [CC]     $<
60
ifeq ($(shell uname),WindowsNT)
61
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
62
else
63
	@-mkdir -p $(dir $@)
64
endif
65
	@$(CC) -c $(CFLAGS) -o $@ $<
66
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
67
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
68
ifeq ($(shell uname),WindowsNT)
69
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
70
else
71
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
72
endif
73
	@rm -f $@.dep.tmp
74
 
75
build/%.o: %.S build/version.h
76
	@echo [CC]     $<
77
ifeq ($(shell uname),WindowsNT)
78
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
79
else
80
	@-mkdir -p $(dir $@)
81
endif
82
	@$(CC) -c $(CFLAGS) -o $@ $<
83
	@$(CC) -MM $(CFLAGS) $< > $@.dep.tmp
84
	@sed -e "s|.*:|$@:|" < $@.dep.tmp > $@.dep
85
ifeq ($(shell uname),WindowsNT)
86
	@sed -e "s/.*://" -e "s/\\$$//" < $@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$/:/" >> $@.dep
87
else
88
	@sed -e 's/.*://' -e 's/\\$$//' < $@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $@.dep
89
endif
90
	@rm -f $@.dep.tmp
91
 
92
build/__emcore_%.o: $(EMCOREDIR)/export/%.c
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
 
101
build/__emcore_%.o: $(EMCOREDIR)/export/%.S
102
	@echo [CC]     $<
103
ifeq ($(shell uname),WindowsNT)
104
	@-if not exist $(subst /,\,$(dir $@)) md $(subst /,\,$(dir $@))
105
else
106
	@-mkdir -p $(dir $@)
107
endif
108
	@$(CC) -c $(CFLAGS) -o $@ $<
109
 
110
build/version.h: version.h .svn/entries
111
	@echo [PP]     $<
112
ifeq ($(shell uname),WindowsNT)
113
	@-if not exist build md build
114
	@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
115
else
116
	@-mkdir -p build
117
	@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
118
endif
119
 
120
clean:
121
	@rm -rf build
122
 
123
.PHONY: all clean $(NAME)