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