Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

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