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