forked from numworks/epsilon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
149 lines (121 loc) · 4.15 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
include scripts/config.mak
# Disable default Make rules
.SUFFIXES:
object_for = $(addprefix $(BUILD_DIR)/,$(addsuffix .o,$(basename $(1))))
default: $(BUILD_DIR)/epsilon.$(EXE)
# Define a standard rule helper
# If passed a last parameter value of with_local_version, we also define an
# extra rule that can build source files within the $(BUILD_DIR). This is useful
# for rules that can be applied for intermediate objects (for example, when
# going .png -> .cpp -> .o).
define rule_label
@ echo "$(shell printf "%-8s" $(strip $(1)))$(@:$(BUILD_DIR)/%=%)"
endef
define rule_for
$(addprefix $$(BUILD_DIR)/,$(strip $(2))): $(strip $(3)) | $$$$(@D)/.
@ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(BUILD_DIR)/%=%)"
$(Q) $(4)
ifeq ($(strip $(5)),with_local_version)
$(addprefix $$(BUILD_DIR)/,$(strip $(2))): $(addprefix $$(BUILD_DIR)/,$(strip $(3)))
@ echo "$(shell printf "%-8s" $(strip $(1)))$$(@:$$(BUILD_DIR)/%=%)"
$(Q) $(4)
endif
endef
.PHONY: info
info:
@echo "EPSILON_VERSION = $(EPSILON_VERSION)"
@echo "EPSILON_ONBOARDING_APP = $(EPSILON_ONBOARDING_APP)"
@echo "EPSILON_BOOT_PROMPT = $(EPSILON_BOOT_PROMPT)"
@echo "EPSILON_APPS = $(EPSILON_APPS)"
@echo "EPSILON_I18N = $(EPSILON_I18N)"
# Since we're building out-of-tree, we need to make sure the output directories
# are created, otherwise the receipes will fail (e.g. gcc will fail to create
# "output/foo/bar.o" because the directory "output/foo" doesn't exist).
# We need to mark those directories as precious, otherwise Make will try to get
# rid of them upon completion (and fail, since those folders won't be empty).
.PRECIOUS: $(BUILD_DIR)/. $(BUILD_DIR)%/.
$(BUILD_DIR)/.:
$(Q) mkdir -p $(dir $@)
$(BUILD_DIR)%/.:
$(Q) mkdir -p $(dir $@)
# To make objects dependent on their directory, we need a second expansion
.SECONDEXPANSION:
# Each sub-Makefile can either add sources to the $(src) variable or define a
# new executable target. The $(src) variable lists the sources that will be
# built and linked to every executable being generated.
ifeq ($(USE_LIBA),0)
include liba/Makefile.bridge
else
SFLAGS += -ffreestanding -nostdinc -nostdlib
include liba/Makefile
include libaxx/Makefile
endif
include ion/Makefile
include kandinsky/Makefile
include poincare/Makefile
include python/Makefile
include escher/Makefile
# Executable Makefiles
include apps/Makefile
include scripts/struct_layout/Makefile
include scripts/scenario/Makefile
include quiz/Makefile # Quiz needs to be included at the end
objs = $(call object_for,$(src))
.SECONDARY: $(objs)
# Load source-based dependencies
# Compilers can generate Makefiles that states the dependencies of a given
# objet to other source and headers. This serve no purpose for a clean build,
# but allows correct yet optimal incremental builds.
-include $(objs:.o=.d)
# Load platform-specific targets
# We include them before the standard ones to give them precedence.
-include scripts/targets.$(PLATFORM).mak
# Define rules for executables
# Those can be built directly with make executable.exe as a shortcut. They also
# depends on $(objs)
executables = epsilon test flasher
define rules_for_executable
$$(BUILD_DIR)/$(1).$$(EXE): $$(objs)
.PHONY: $(1).$$(EXE)
$(1).$$(EXE): $$(BUILD_DIR)/$(1).$$(EXE)
endef
$(foreach executable,$(executables),$(eval $(call rules_for_executable,$(executable))))
# Define standard compilation rules
$(eval $(call rule_for, \
AS, %.o, %.s, \
$$(CC) $$(SFLAGS) -c $$< -o $$@ \
))
$(eval $(call rule_for, \
CC, %.o, %.c, \
$$(CC) $$(SFLAGS) $$(CFLAGS) -c $$< -o $$@, \
with_local_version \
))
$(eval $(call rule_for, \
CXX, %.o, %.cpp, \
$$(CXX) $$(SFLAGS) $$(CXXFLAGS) -c $$< -o $$@, \
with_local_version \
))
$(eval $(call rule_for, \
OCC, %.o, %.m, \
$$(CC) $$(SFLAGS) $$(CFLAGS) -c $$< -o $$@ \
))
$(eval $(call rule_for, \
LD, %.$$(EXE), , \
$$(LD) $$^ $$(LDFLAGS) -o $$@ \
))
.PHONY: clean
clean:
@echo "CLEAN"
$(Q) rm -rf $(BUILD_DIR)
.PHONY: cowsay_%
cowsay_%:
@echo " -------"
@echo "| $(*F) |"
@echo " -------"
@echo " \\ ^__^"
@echo " \\ (oo)\\_______"
@echo " (__)\\ )\\/\\"
@echo " ||----w |"
@echo " || ||"
.PHONY: clena
clena: cowsay_CLENA clean