Subversion Repositories freemyipod

Rev

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