| 427 |
farthen |
1 |
NAME := emcore
|
| 2 |
theseven |
2 |
|
| 461 |
theseven |
3 |
ifeq ($(shell uname),WindowsNT)
|
|
|
4 |
CCACHE :=
|
|
|
5 |
else
|
|
|
6 |
CCACHE := $(shell which ccache)
|
|
|
7 |
endif
|
|
|
8 |
|
| 455 |
theseven |
9 |
CROSS ?= arm-elf-eabi-
|
| 461 |
theseven |
10 |
CC := $(CCACHE) $(CROSS)gcc
|
| 42 |
theseven |
11 |
AS := $(CROSS)as
|
|
|
12 |
LD := $(CROSS)ld
|
|
|
13 |
OBJCOPY := $(CROSS)objcopy
|
| 2 |
theseven |
14 |
UCLPACK := ucl2e10singleblk
|
|
|
15 |
|
| 111 |
theseven |
16 |
CFLAGS += -Os -fno-pie -fno-stack-protector -fomit-frame-pointer -I. -Iexport -ffunction-sections -fdata-sections
|
| 33 |
theseven |
17 |
LDFLAGS += "$(shell $(CC) -print-libgcc-file-name)" --gc-sections
|
| 2 |
theseven |
18 |
|
| 21 |
theseven |
19 |
preprocess = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#")
|
|
|
20 |
preprocesspaths = $(shell $(CC) $(PPCFLAGS) $(2) -E -P -x c $(1) | grep -v "^\#" | sed -e "s:^..*:$(dir $(1))&:")
|
| 2 |
theseven |
21 |
|
| 28 |
theseven |
22 |
REVISION := $(shell svnversion .)
|
|
|
23 |
REVISIONINT := $(shell echo $(REVISION) | sed -e "s/[^0-9].*$$//")
|
|
|
24 |
|
| 21 |
theseven |
25 |
TARGETS := $(call preprocess,TARGETS,-I.)
|
|
|
26 |
|
| 2 |
theseven |
27 |
define TARGET_template
|
| 91 |
theseven |
28 |
-include target/$(1)/target.mk
|
|
|
29 |
|
| 21 |
theseven |
30 |
SRC_$(1) := $$(call preprocesspaths,SOURCES,-DTARGET_$(1) -Itarget/$(1) -I.)
|
| 2 |
theseven |
31 |
OBJ_$(1) := $$(SRC_$(1):%.c=build/$(1)/%.o)
|
|
|
32 |
OBJ_$(1) := $$(OBJ_$(1):%.S=build/$(1)/%.o)
|
|
|
33 |
|
|
|
34 |
-include $$(OBJ_$(1):%=%.dep)
|
|
|
35 |
|
|
|
36 |
$(1): build/$(1)/$(NAME)-$(1).ucl
|
|
|
37 |
|
|
|
38 |
build/$(1)/$(NAME)-$(1).ucl: build/$(1)/$(NAME).bin
|
| 111 |
theseven |
39 |
@echo [UCL] $$<
|
|
|
40 |
@$(UCLPACK) $$^ $$@
|
| 2 |
theseven |
41 |
|
|
|
42 |
build/$(1)/$(NAME).bin: build/$(1)/$(NAME).elf
|
| 111 |
theseven |
43 |
@echo [OC] $$<
|
|
|
44 |
@$(OBJCOPY) -O binary $$^ $$@
|
| 2 |
theseven |
45 |
|
|
|
46 |
build/$(1)/$(NAME).elf: target/$(1)/ls.x build/$(1)/target/$(1)/crt0.o $$(OBJ_$(1))
|
| 111 |
theseven |
47 |
@echo [LD] $$@
|
|
|
48 |
@$(LD) $(LDFLAGS) $$(LDFLAGS_$(1)) -o $$@ -T target/$(1)/ls.x $$(OBJ_$(1))
|
| 2 |
theseven |
49 |
|
| 28 |
theseven |
50 |
build/$(1)/%.o: %.c build/version.h
|
| 111 |
theseven |
51 |
@echo [CC] $$<
|
| 2 |
theseven |
52 |
ifeq ($(shell uname),WindowsNT)
|
|
|
53 |
@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
|
|
|
54 |
else
|
|
|
55 |
@-mkdir -p $$(dir $$@)
|
|
|
56 |
endif
|
| 111 |
theseven |
57 |
@$(CC) -c $(CFLAGS) $$(CFLAGS_$(1)) -DTARGET_$(1) -DTARGET=\"$(1)\" -DCONFIG_H=\"target/$(1)/config.h\" -DTARGET_H=\"target/$(1)/target.h\" -o $$@ $$<
|
|
|
58 |
@$(CC) -MM $(CFLAGS) $$(CFLAGS_$(1)) -DTARGET_$(1) -DTARGET=\"$(1)\" -DCONFIG_H=\"target/$(1)/config.h\" -DTARGET_H=\"target/$(1)/target.h\" $$< > $$@.dep.tmp
|
| 2 |
theseven |
59 |
@sed -e "s|.*:|$$@:|" < $$@.dep.tmp > $$@.dep
|
| 32 |
theseven |
60 |
ifeq ($(shell uname),WindowsNT)
|
| 11 |
theseven |
61 |
@sed -e "s/.*://" -e "s/\\$$$$//" < $$@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$$$/:/" >> $$@.dep
|
| 32 |
theseven |
62 |
else
|
| 33 |
theseven |
63 |
@sed -e 's/.*://' -e 's/\\$$$$//' < $$@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$$$/:/' >> $$@.dep
|
| 32 |
theseven |
64 |
endif
|
| 2 |
theseven |
65 |
@rm -f $$@.dep.tmp
|
|
|
66 |
|
| 28 |
theseven |
67 |
build/$(1)/%.o: %.S build/version.h
|
| 111 |
theseven |
68 |
@echo [CC] $$<
|
| 2 |
theseven |
69 |
ifeq ($(shell uname),WindowsNT)
|
|
|
70 |
@-if not exist $$(subst /,\,$$(dir $$@)) md $$(subst /,\,$$(dir $$@))
|
|
|
71 |
else
|
|
|
72 |
@-mkdir -p $$(dir $$@)
|
|
|
73 |
endif
|
| 111 |
theseven |
74 |
@$(CC) -c $(CFLAGS) $$(CFLAGS_$(1)) -DTARGET_$(1) -DTARGET=\"$(1)\" -DCONFIG_H=\"target/$(1)/config.h\" -DTARGET_H=\"target/$(1)/target.h\" -o $$@ $$<
|
|
|
75 |
@$(CC) -MM $(CFLAGS) $$(CFLAGS_$(1)) -DTARGET_$(1) -DTARGET=\"$(1)\" -DCONFIG_H=\"target/$(1)/config.h\" -DTARGET_H=\"target/$(1)/target.h\" $$< > $$@.dep.tmp
|
| 2 |
theseven |
76 |
@sed -e "s|.*:|$$@:|" < $$@.dep.tmp > $$@.dep
|
| 32 |
theseven |
77 |
ifeq ($(shell uname),WindowsNT)
|
| 11 |
theseven |
78 |
@sed -e "s/.*://" -e "s/\\$$$$//" < $$@.dep.tmp | fmt -1 | sed -e "s/^ *//" -e "s/$$$$/:/" >> $$@.dep
|
| 32 |
theseven |
79 |
else
|
| 33 |
theseven |
80 |
@sed -e 's/.*://' -e 's/\\$$$$//' < $$@.dep.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$$$/:/' >> $$@.dep
|
| 32 |
theseven |
81 |
endif
|
| 2 |
theseven |
82 |
@rm -f $$@.dep.tmp
|
|
|
83 |
endef
|
|
|
84 |
|
|
|
85 |
all: $(TARGETS)
|
|
|
86 |
|
|
|
87 |
$(foreach target,$(TARGETS),$(eval $(call TARGET_template,$(target))))
|
|
|
88 |
|
| 665 |
theseven |
89 |
build/version.h: version.h .svn/entries
|
| 111 |
theseven |
90 |
@echo [PP] $<
|
| 32 |
theseven |
91 |
ifeq ($(shell uname),WindowsNT)
|
| 665 |
theseven |
92 |
@-if not exist build md build
|
| 28 |
theseven |
93 |
@sed -e "s/\$$REVISION\$$/$(REVISION)/" -e "s/\$$REVISIONINT\$$/$(REVISIONINT)/" < $< > $@
|
| 32 |
theseven |
94 |
else
|
| 665 |
theseven |
95 |
@-mkdir -p build
|
| 33 |
theseven |
96 |
@sed -e 's/\$$REVISION\$$/$(REVISION)/' -e 's/\$$REVISIONINT\$$/$(REVISIONINT)/' < $< > $@
|
| 32 |
theseven |
97 |
endif
|
| 28 |
theseven |
98 |
|
| 2 |
theseven |
99 |
clean:
|
| 659 |
theseven |
100 |
@rm -rf build
|
| 2 |
theseven |
101 |
|
|
|
102 |
.PHONY: all clean $(TARGETS)
|