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