servo/Makefile.in
Brian Anderson 134632bb45 Don't set the VPATH. Breaks the linux build
On linux this causes make to see the 'servo' rule as targeting the src/servo
directory, which is always up to date. servo never gets built
2012-10-08 16:22:31 -07:00

166 lines
4.1 KiB
Makefile

# 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) =
DONE_$(1) = $$(B)src/$(1)/$(1).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))))
RFLAGS_servo = $(strip $(CFG_RUSTC_FLAGS)) $(addprefix -L $(B)src/,$(DEPS_SUBMODULES))
SRC_servo = $(call rwildcard,$(S)src/servo/,*.rs)
CRATE_servo = $(S)src/servo/servo.rc
DONE_SUBMODULES = $(foreach dep,$(DEPS_SUBMODULES),$(DONE_$(dep)))
DEPS_servo = $(CRATE_servo) $(SRC_servo) $(DONE_SUBMODULES)
# 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 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