2011-11-01 23:50:47 +00:00
|
|
|
# This is a procedure to define the targets for building
|
|
|
|
# the runtime.
|
|
|
|
#
|
|
|
|
# Argument 1 is the target triple.
|
|
|
|
#
|
|
|
|
# This is not really the right place to explain this, but
|
|
|
|
# for those of you who are not Makefile gurus, let me briefly
|
|
|
|
# cover the $ expansion system in use here, because it
|
|
|
|
# confused me for a while! The variable DEF_RUNTIME_TARGETS
|
|
|
|
# will be defined once and then expanded with different
|
|
|
|
# values substituted for $(1) each time it is called.
|
|
|
|
# That resulting text is then eval'd.
|
|
|
|
#
|
|
|
|
# For most variables, you could use a single $ sign. The result
|
|
|
|
# is that the substitution would occur when the CALL occurs,
|
|
|
|
# I believe. The problem is that the automatic variables $< and $@
|
|
|
|
# need to be expanded-per-rule. Therefore, for those variables at
|
|
|
|
# least, you need $$< and $$@ in the variable text. This way, after
|
|
|
|
# the CALL substitution occurs, you will have $< and $@. This text
|
|
|
|
# will then be evaluated, and all will work as you like.
|
|
|
|
#
|
|
|
|
# Reader beware, this explanantion could be wrong, but it seems to
|
|
|
|
# fit the experimental data (i.e., I was able to get the system
|
|
|
|
# working under these assumptions).
|
|
|
|
|
2011-11-02 04:05:56 +00:00
|
|
|
# Hack for passing flags into LIBUV, see below.
|
2011-12-01 07:17:42 +00:00
|
|
|
LIBUV_FLAGS_i386 = -m32 -fPIC
|
|
|
|
LIBUV_FLAGS_x86_64 = -m64 -fPIC
|
2011-11-02 04:05:56 +00:00
|
|
|
|
2012-03-26 22:54:22 +00:00
|
|
|
# when we're doing a snapshot build, we intentionally degrade as many
|
|
|
|
# features in libuv and the runtime as possible, to ease portability.
|
|
|
|
|
|
|
|
SNAP_DEFINES:=
|
|
|
|
ifneq ($(strip $(findstring snap,$(MAKECMDGOALS))),)
|
|
|
|
SNAP_DEFINES=-DRUST_SNAPSHOT
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2011-11-01 23:50:47 +00:00
|
|
|
define DEF_RUNTIME_TARGETS
|
|
|
|
|
2011-05-01 20:18:52 +00:00
|
|
|
######################################################################
|
|
|
|
# Runtime (C++) library variables
|
|
|
|
######################################################################
|
|
|
|
|
2011-11-01 23:50:47 +00:00
|
|
|
RUNTIME_CS_$(1) := \
|
|
|
|
rt/sync/timer.cpp \
|
2011-05-01 20:18:52 +00:00
|
|
|
rt/sync/lock_and_signal.cpp \
|
2012-02-09 22:24:19 +00:00
|
|
|
rt/sync/rust_thread.cpp \
|
2011-05-01 20:18:52 +00:00
|
|
|
rt/rust.cpp \
|
|
|
|
rt/rust_builtin.cpp \
|
|
|
|
rt/rust_run_program.cpp \
|
2011-07-27 21:34:39 +00:00
|
|
|
rt/rust_env.cpp \
|
2012-03-29 23:31:30 +00:00
|
|
|
rt/rust_sched_loop.cpp \
|
2012-03-29 22:21:32 +00:00
|
|
|
rt/rust_sched_launcher.cpp \
|
2012-03-31 00:10:02 +00:00
|
|
|
rt/rust_sched_driver.cpp \
|
2012-02-03 23:12:18 +00:00
|
|
|
rt/rust_scheduler.cpp \
|
2012-03-30 20:54:37 +00:00
|
|
|
rt/rust_sched_reaper.cpp \
|
2011-05-01 20:18:52 +00:00
|
|
|
rt/rust_task.cpp \
|
2012-02-08 23:28:25 +00:00
|
|
|
rt/rust_stack.cpp \
|
2011-05-01 20:18:52 +00:00
|
|
|
rt/rust_port.cpp \
|
|
|
|
rt/rust_upcall.cpp \
|
2011-12-01 07:26:23 +00:00
|
|
|
rt/rust_uv.cpp \
|
2011-05-01 20:18:52 +00:00
|
|
|
rt/rust_log.cpp \
|
2012-02-15 06:23:16 +00:00
|
|
|
rt/rust_port_selector.cpp \
|
2012-06-18 20:16:38 +00:00
|
|
|
rt/rust_util.cpp \
|
2011-05-01 20:18:52 +00:00
|
|
|
rt/circular_buffer.cpp \
|
|
|
|
rt/isaac/randport.cpp \
|
2012-08-28 20:59:48 +00:00
|
|
|
rt/miniz.cpp \
|
2011-05-01 20:18:52 +00:00
|
|
|
rt/rust_kernel.cpp \
|
2011-08-04 03:25:44 +00:00
|
|
|
rt/rust_shape.cpp \
|
2011-08-20 21:22:09 +00:00
|
|
|
rt/rust_abi.cpp \
|
2011-09-20 23:47:59 +00:00
|
|
|
rt/rust_cc.cpp \
|
2011-09-23 18:42:20 +00:00
|
|
|
rt/rust_debug.cpp \
|
2012-03-24 00:51:54 +00:00
|
|
|
rt/rust_box_annihilator.cpp \
|
2011-05-01 20:18:52 +00:00
|
|
|
rt/memory_region.cpp \
|
2012-02-02 02:52:08 +00:00
|
|
|
rt/boxed_region.cpp \
|
2012-04-05 03:32:23 +00:00
|
|
|
rt/arch/$$(HOST_$(1))/context.cpp \
|
|
|
|
rt/arch/$$(HOST_$(1))/gpr.cpp
|
2011-05-18 19:43:48 +00:00
|
|
|
|
2011-11-01 23:50:47 +00:00
|
|
|
RUNTIME_S_$(1) := rt/arch/$$(HOST_$(1))/_context.S \
|
|
|
|
rt/arch/$$(HOST_$(1))/ccall.S \
|
2011-11-22 02:52:12 +00:00
|
|
|
rt/arch/$$(HOST_$(1))/record_sp.S
|
2011-05-24 21:00:45 +00:00
|
|
|
|
2011-11-01 23:50:47 +00:00
|
|
|
ifeq ($$(HOST_$(1)), i386)
|
|
|
|
LIBUV_ARCH_$(1) := ia32
|
2011-09-23 23:13:14 +00:00
|
|
|
else
|
2011-11-01 23:50:47 +00:00
|
|
|
LIBUV_ARCH_$(1) := x86_64
|
2011-09-23 23:13:14 +00:00
|
|
|
endif
|
|
|
|
|
2011-11-01 23:50:47 +00:00
|
|
|
ifeq ($$(CFG_WINDOWSY), 1)
|
|
|
|
LIBUV_OSTYPE_$(1) := win
|
2012-02-03 01:39:47 +00:00
|
|
|
LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/obj.target/src/libuv/libuv.a
|
2011-11-01 23:50:47 +00:00
|
|
|
else ifeq ($(CFG_OSTYPE), apple-darwin)
|
|
|
|
LIBUV_OSTYPE_$(1) := mac
|
2012-02-03 01:39:47 +00:00
|
|
|
LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/libuv.a
|
2011-12-30 08:18:55 +00:00
|
|
|
else ifeq ($(CFG_OSTYPE), unknown-freebsd)
|
2012-02-09 06:08:24 +00:00
|
|
|
LIBUV_OSTYPE_$(1) := unix/freebsd
|
2012-02-03 01:39:47 +00:00
|
|
|
LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/obj.target/src/libuv/libuv.a
|
2011-11-01 23:50:47 +00:00
|
|
|
else
|
2012-02-09 06:08:24 +00:00
|
|
|
LIBUV_OSTYPE_$(1) := unix/linux
|
2012-02-03 01:39:47 +00:00
|
|
|
LIBUV_LIB_$(1) := rt/$(1)/libuv/Release/obj.target/src/libuv/libuv.a
|
2011-11-01 23:50:47 +00:00
|
|
|
endif
|
2011-05-01 20:18:52 +00:00
|
|
|
|
2011-11-01 23:50:47 +00:00
|
|
|
RUNTIME_DEF_$(1) := rt/rustrt$$(CFG_DEF_SUFFIX)
|
2011-12-06 07:11:11 +00:00
|
|
|
RUNTIME_INCS_$(1) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \
|
2011-11-01 23:50:47 +00:00
|
|
|
-I $$(S)src/rt/arch/$$(HOST_$(1)) \
|
2011-11-08 22:36:19 +00:00
|
|
|
-I $$(S)src/libuv/include
|
2011-11-01 23:50:47 +00:00
|
|
|
RUNTIME_OBJS_$(1) := $$(RUNTIME_CS_$(1):rt/%.cpp=rt/$(1)/%.o) \
|
|
|
|
$$(RUNTIME_S_$(1):rt/%.S=rt/$(1)/%.o)
|
2012-06-14 18:07:19 +00:00
|
|
|
ALL_OBJ_FILES += $$(RUNTIME_OBJS_$(1))
|
|
|
|
|
|
|
|
MORESTACK_OBJ_$(1) := rt/$(1)/arch/$$(HOST_$(1))/morestack.o
|
|
|
|
ALL_OBJ_FILES += $$(MORESTACK_OBJS_$(1))
|
|
|
|
|
2011-11-01 23:50:47 +00:00
|
|
|
RUNTIME_LIBS_$(1) := $$(LIBUV_LIB_$(1))
|
|
|
|
|
2012-06-14 18:07:19 +00:00
|
|
|
rt/$(1)/%.o: rt/%.cpp $$(MKFILE_DEPS)
|
2011-11-01 23:50:47 +00:00
|
|
|
@$$(call E, compile: $$@)
|
2012-03-26 22:54:22 +00:00
|
|
|
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, $$(RUNTIME_INCS_$(1)) \
|
|
|
|
$$(SNAP_DEFINES)) $$<
|
2011-11-01 23:50:47 +00:00
|
|
|
|
2012-06-14 18:07:19 +00:00
|
|
|
rt/$(1)/%.o: rt/%.S $$(MKFILE_DEPS) \
|
2012-03-22 01:30:30 +00:00
|
|
|
$$(LLVM_CONFIG_$$(CFG_HOST_TRIPLE))
|
2011-11-01 23:50:47 +00:00
|
|
|
@$$(call E, compile: $$@)
|
2011-12-10 00:02:50 +00:00
|
|
|
$$(Q)$$(call CFG_ASSEMBLE_$(1),$$@,$$<)
|
2011-11-01 23:50:47 +00:00
|
|
|
|
2012-06-14 18:07:19 +00:00
|
|
|
rt/$(1)/arch/$$(HOST_$(1))/libmorestack.a: $$(MORESTACK_OBJ_$(1))
|
2011-11-29 01:23:13 +00:00
|
|
|
@$$(call E, link: $$@)
|
|
|
|
$$(Q)ar rcs $$@ $$<
|
|
|
|
|
2011-11-23 23:20:28 +00:00
|
|
|
rt/$(1)/$(CFG_RUNTIME): $$(RUNTIME_OBJS_$(1)) $$(MKFILE_DEPS) \
|
|
|
|
$$(RUNTIME_DEF_$(1)) \
|
|
|
|
$$(RUNTIME_LIBS_$(1))
|
2011-11-01 23:50:47 +00:00
|
|
|
@$$(call E, link: $$@)
|
|
|
|
$$(Q)$$(call CFG_LINK_C_$(1),$$@, $$(RUNTIME_OBJS_$(1)) \
|
|
|
|
$$(CFG_GCCISH_POST_LIB_FLAGS) $$(RUNTIME_LIBS_$(1)) \
|
|
|
|
$$(CFG_LIBUV_LINK_FLAGS),$$(RUNTIME_DEF_$(1)),$$(CFG_RUNTIME))
|
2011-06-14 15:28:10 +00:00
|
|
|
|
2012-06-13 22:07:19 +00:00
|
|
|
# FIXME: For some reason libuv's makefiles can't figure out the
|
|
|
|
# correct definition of CC on the mingw I'm using, so we are
|
|
|
|
# explicitly using gcc. Also, we have to list environment variables
|
|
|
|
# first on windows... mysterious
|
2012-02-10 20:07:01 +00:00
|
|
|
|
|
|
|
ifdef CFG_ENABLE_FAST_MAKE
|
|
|
|
LIBUV_DEPS := $$(S)/.gitmodules
|
|
|
|
else
|
|
|
|
LIBUV_DEPS := $$(wildcard \
|
|
|
|
$$(S)src/libuv/* \
|
|
|
|
$$(S)src/libuv/*/* \
|
|
|
|
$$(S)src/libuv/*/*/* \
|
|
|
|
$$(S)src/libuv/*/*/*/*)
|
|
|
|
endif
|
|
|
|
|
|
|
|
$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS)
|
2011-11-01 23:50:47 +00:00
|
|
|
$$(Q)$$(MAKE) -C $$(S)mk/libuv/$$(LIBUV_ARCH_$(1))/$$(LIBUV_OSTYPE_$(1)) \
|
2012-03-26 22:54:22 +00:00
|
|
|
CFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
|
2011-11-02 04:05:56 +00:00
|
|
|
LDFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1)))" \
|
2011-11-01 23:50:47 +00:00
|
|
|
CC="$$(CFG_GCCISH_CROSS)$$(CC)" \
|
|
|
|
CXX="$$(CFG_GCCISH_CROSS)$$(CXX)" \
|
|
|
|
AR="$$(CFG_GCCISH_CROSS)$$(AR)" \
|
2012-02-03 01:39:47 +00:00
|
|
|
BUILDTYPE=Release \
|
2011-11-01 23:50:47 +00:00
|
|
|
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \
|
|
|
|
V=$$(VERBOSE) FLOCK= uv
|
2011-05-01 20:18:52 +00:00
|
|
|
|
|
|
|
# These could go in rt.mk or rustllvm.mk, they're needed for both.
|
|
|
|
|
2011-11-02 21:22:07 +00:00
|
|
|
# This regexp has a single $, escaped twice
|
2011-12-30 08:18:55 +00:00
|
|
|
%.bsd.def: %.def.in $$(MKFILE_DEPS)
|
|
|
|
@$$(call E, def: $$@)
|
|
|
|
$$(Q)echo "{" > $$@
|
|
|
|
$$(Q)sed 's/.$$$$/&;/' $$< >> $$@
|
|
|
|
$$(Q)echo "};" >> $$@
|
|
|
|
|
2011-11-23 23:20:28 +00:00
|
|
|
%.linux.def: %.def.in $$(MKFILE_DEPS)
|
2011-11-01 23:50:47 +00:00
|
|
|
@$$(call E, def: $$@)
|
|
|
|
$$(Q)echo "{" > $$@
|
2011-11-02 21:22:07 +00:00
|
|
|
$$(Q)sed 's/.$$$$/&;/' $$< >> $$@
|
2011-11-01 23:50:47 +00:00
|
|
|
$$(Q)echo "};" >> $$@
|
2011-05-01 20:18:52 +00:00
|
|
|
|
2011-11-23 23:20:28 +00:00
|
|
|
%.darwin.def: %.def.in $$(MKFILE_DEPS)
|
2011-11-01 23:50:47 +00:00
|
|
|
@$$(call E, def: $$@)
|
|
|
|
$$(Q)sed 's/^./_&/' $$< > $$@
|
2011-05-01 20:18:52 +00:00
|
|
|
|
|
|
|
ifdef CFG_WINDOWSY
|
2011-11-23 23:20:28 +00:00
|
|
|
%.def: %.def.in $$(MKFILE_DEPS)
|
2011-11-01 23:50:47 +00:00
|
|
|
@$$(call E, def: $$@)
|
|
|
|
$$(Q)echo LIBRARY $$* > $$@
|
|
|
|
$$(Q)echo EXPORTS >> $$@
|
|
|
|
$$(Q)sed 's/^./ &/' $$< >> $$@
|
2011-05-01 20:18:52 +00:00
|
|
|
endif
|
2011-11-01 23:50:47 +00:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Instantiate template for all stages
|
|
|
|
$(foreach target,$(CFG_TARGET_TRIPLES), \
|
|
|
|
$(eval $(call DEF_RUNTIME_TARGETS,$(target))))
|