forked from servo/servo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
183 lines (140 loc) · 4.75 KB
/
Makefile.in
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Recursive wildcard function
# http://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-function.html
rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) \
$(filter $(subst *,%,$2),$d))
include config.mk
# Target-and-rule "utility variables"
ifdef VERBOSE
Q :=
E =
else
Q := @
E = echo $(1)
endif
S := $(CFG_SRC_DIR)
B := $(CFG_BUILD_DIR)
#VPATH := $(S)src
# Delete the built-in rules.
.SUFFIXES:
%:: %,v
%:: RCS/%,v
%:: RCS/%
%:: s.%
%:: SCCS/s.%
MKFILE_DEPS := config.stamp $(call rwildcard,$(S)mk/,*)
CFG_RUSTC_FLAGS := $(RUSTFLAGS)
ifdef CFG_DISABLE_OPTIMIZE
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
CFG_RUSTC_FLAGS +=
else
CFG_RUSTC_FLAGS += -O
endif
ifdef CFG_ENABLE_DEBUG
$(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
CFG_RUSTC_FLAGS +=
CFG_GCCISH_CFLAGS += -DRUST_DEBUG
else
CFG_GCCISH_CFLAGS += -DRUST_NDEBUG
endif
export CFG_RUSTC
export CFG_RUSTC_FLAGS
export RUSTC=$(CFG_RUSTC)
export RUSTFLAGS=$(CFG_RUSTC_FLAGS)
######################################################################
# Re-configuration
######################################################################
ifndef CFG_DISABLE_MANAGE_SUBMODULES
# This is a pretty expensive operation but I don't see any way to avoid it
NEED_GIT_RECONFIG=$(shell cd "$(S)" && "$(CFG_GIT)" submodule status | grep -c '^\(+\|-\)')
else
NEED_GIT_RECONFIG=0
endif
ifeq ($(NEED_GIT_RECONFIG),0)
else
# If the submodules have changed then always execute config.mk
.PHONY: $(S)config.stamp
endif
$(S)Makefile $(S)config.mk: $(S)config.stamp
$(S)config.stamp : $(S)configure $(S)Makefile.in
@$(call E, cfg: reconfiguring)
$(Q)$(S)configure $(CFG_CONFIGURE_ARGS)
define DEF_SUBMODULE_VARS
DEPS_$(1) =
CFLAGS_$(1) = -O2
# any "done" dummy files must be named libSOMETHING.dummy.
#
# We can't auto-compute this, because some modules have lib* prefix in
# their name already, while others don't.
DONE_$(1) = $$(B)src/$(1)/lib*.dummy
DEPS_SUBMODULES += $(1)
endef
# these will get populated.
DEPS_SUBMODULES =
$(foreach submodule,$(CFG_SUBMODULES),\
$(eval $(call DEF_SUBMODULE_VARS,$(submodule))))
# include submodule dependencies configuration
include $(S)mk/sub.mk
# Define how to make submodule targets
define DEF_SUBMODULE_RULES
# variables that depend on dependency definitions from sub.mk!
ENV_CFLAGS_$(1) = CFLAGS="$$(CFLAGS_$(1))"
ENV_RFLAGS_$(1) = RUSTFLAGS="$$(strip $$(CFG_RUSTC_FLAGS)) $$(addprefix -L $$(B)src/,$$(DEPS_$(1)))"
# use a rough approximation of submodule dependencies to trigger calling submodule make
# whenever a submodule changes
# TODO: this may be a bit brutish, but is there a better way?
ROUGH_DEPS_$(1)=$$(call rwildcard,$$(S)src/$(1),*h *c *cpp *rs *rc)
DONE_DEPS_$(1)=$$(foreach dep,$$(DEPS_$(1)),$$(DONE_$$(dep)))
# the main target for a submodule
# --
$$(DONE_$(1)) : $$(DONE_DEPS_$(1)) $$(ROUGH_DEPS_$(1))
# @$$(call E, make: $(1))
# @$$(call E, $(1) deps= $$(DEPS_$(1)))
# @$$(call E, $(1) done_deps= $$(DONE_DEPS_$(1)))
# @$$(call E, $(1) cflags= $$(ENV_CFLAGS_$(1)))
# @$$(call E, $(1) rflags= $$(ENV_RFLAGS_$(1)))
$$(Q) \
$$(ENV_CFLAGS_$(1)) \
$$(ENV_RFLAGS_$(1)) \
$$(MAKE) -C $$(B)src/$(1) && touch $$(DONE_$(1))
# main submodule target
$(1) : $$(DONE_$(1))
.PHONY : $(1)
.NOTPARALLEL : $(1)
endef
$(foreach submodule,$(CFG_SUBMODULES),\
$(eval $(call DEF_SUBMODULE_RULES,$(submodule))))
DONE_SUBMODULES = $(foreach dep,$(DEPS_SUBMODULES),$(DONE_$(dep)))
RFLAGS_servo_gfx = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES))
SRC_servo_gfx = $(call rwildcard,$(S)src/servo-gfx/,*.rs)
CRATE_servo_gfx = $(S)src/servo-gfx/servo_gfx.rc
DONE_servo_gfx = $(B)src/servo-gfx/libservogfx.dummy
DEPS_servo_gfx = $(CRATE_servo_gfx) $(SRC_servo_gfx) $(DONE_SUBMODULES)
RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES)) -L $(B)src/servo-gfx
SRC_servo = $(call rwildcard,$(S)src/servo/,*.rs)
CRATE_servo = $(S)src/servo/servo.rc
DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES) $(DONE_servo_gfx)
# rules that depend on having correct meta-target vars (DEPS_CLEAN, DEPS_servo, etc)
include $(S)mk/check.mk
include $(S)mk/clean.mk
.DEFAULT_GOAL := all
.PHONY: all
all: servo package
# Servo helper libraries
$(DONE_servo_gfx): $(DEPS_servo_gfx)
$(RUSTC) $(RFLAGS_servo_gfx) -o $@ $< && touch $@
# Servo binaries
servo: $(DEPS_servo)
$(RUSTC) $(RFLAGS_servo) -o $@ $< --bin
# Darwin app packaging
ifeq ($(OSTYPE),darwin)
package: servo
mkdir -p Servo.app/Contents/MacOS/src/rust-cocoa
mkdir -p Servo.app/Contents/MacOS/src/rust-azure
cp $(S)/Info.plist Servo.app/Contents/
cp servo Servo.app/Contents/MacOS/
cp src/rust-cocoa/lib*.dylib Servo.app/Contents/MacOS/src/rust-cocoa/
cp src/rust-azure/lib*.dylib Servo.app/Contents/MacOS/src/rust-azure/
else
.PHONY: package
package:
endif