2014-01-24 21:27:22 -06:00
|
|
|
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
# file at the top-level directory of this distribution and at
|
|
|
|
# http://rust-lang.org/COPYRIGHT.
|
2011-11-01 18:50:47 -05:00
|
|
|
#
|
2014-01-24 21:27:22 -06:00
|
|
|
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
# option. This file may not be copied, modified, or distributed
|
|
|
|
# except according to those terms.
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Native libraries built as part of the rust build process
|
2011-11-01 18:50:47 -05:00
|
|
|
#
|
2014-01-24 21:27:22 -06:00
|
|
|
# This portion of the rust build system is meant to keep track of native
|
|
|
|
# dependencies and how to build them. It is currently required that all native
|
|
|
|
# dependencies are built as static libraries, as slinging around dynamic
|
|
|
|
# libraries isn't exactly the most fun thing to do.
|
2011-11-01 18:50:47 -05:00
|
|
|
#
|
2014-01-24 21:27:22 -06:00
|
|
|
# This section should need minimal modification to add new libraries. The
|
|
|
|
# relevant variables are:
|
2011-11-01 18:50:47 -05:00
|
|
|
#
|
2014-01-24 21:27:22 -06:00
|
|
|
# NATIVE_LIBS
|
|
|
|
# This is a list of all native libraries which are built as part of the
|
|
|
|
# build process. It will build all libraries into RT_OUTPUT_DIR with the
|
|
|
|
# appropriate name of static library as dictated by the target platform
|
|
|
|
#
|
|
|
|
# NATIVE_DEPS_<lib>
|
|
|
|
# This is a list of files relative to the src/rt directory which are
|
|
|
|
# needed to build the native library. Each file will be compiled to an
|
|
|
|
# object file, and then all the object files will be assembled into an
|
|
|
|
# archive (static library). The list contains files of any extension
|
|
|
|
#
|
|
|
|
# If adding a new library, you should update the NATIVE_LIBS list, and then list
|
|
|
|
# the required files below it. The list of required files is a list of files
|
|
|
|
# that's per-target so you're allowed to conditionally add files based on the
|
|
|
|
# target.
|
|
|
|
################################################################################
|
2014-01-24 23:00:31 -06:00
|
|
|
NATIVE_LIBS := rustrt sundown uv_support morestack miniz
|
2014-01-24 21:27:22 -06:00
|
|
|
|
|
|
|
# $(1) is the target triple
|
|
|
|
define NATIVE_LIBRARIES
|
|
|
|
|
|
|
|
NATIVE_DEPS_sundown_$(1) := sundown/src/autolink.c \
|
|
|
|
sundown/src/buffer.c \
|
|
|
|
sundown/src/stack.c \
|
|
|
|
sundown/src/markdown.c \
|
|
|
|
sundown/html/houdini_href_e.c \
|
|
|
|
sundown/html/houdini_html_e.c \
|
|
|
|
sundown/html/html_smartypants.c \
|
|
|
|
sundown/html/html.c
|
|
|
|
NATIVE_DEPS_uv_support_$(1) := rust_uv.c
|
2014-01-24 23:00:31 -06:00
|
|
|
NATIVE_DEPS_miniz_$(1) = miniz.c
|
2014-01-24 21:27:22 -06:00
|
|
|
NATIVE_DEPS_rustrt_$(1) := rust_builtin.c \
|
|
|
|
rust_android_dummy.c \
|
|
|
|
rust_test_helpers.c \
|
|
|
|
rust_try.ll \
|
|
|
|
arch/$$(HOST_$(1))/_context.S \
|
|
|
|
arch/$$(HOST_$(1))/record_sp.S
|
|
|
|
NATIVE_DEPS_morestack_$(1) := arch/$$(HOST_$(1))/morestack.S
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# You shouldn't find it that necessary to edit anything below this line.
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# While we're defining the native libraries for each target, we define some
|
|
|
|
# common rules used to build files for various targets.
|
2011-11-01 18:50:47 -05:00
|
|
|
|
2014-01-24 21:27:22 -06:00
|
|
|
RT_OUTPUT_DIR_$(1) := $(1)/rt
|
|
|
|
|
|
|
|
$$(RT_OUTPUT_DIR_$(1))/%.o: rt/%.ll $$(MKFILE_DEPS) $$(LLVM_CONFIG_$$(CFG_BUILD))
|
|
|
|
@mkdir -p $$(@D)
|
|
|
|
@$$(call E, compile: $$@)
|
|
|
|
$$(Q)$$(LLC_$$(CFG_BUILD)) $$(CFG_LLC_FLAGS_$(1)) \
|
|
|
|
-filetype=obj -mtriple=$(1) -relocation-model=pic -o $$@ $$<
|
|
|
|
|
|
|
|
$$(RT_OUTPUT_DIR_$(1))/%.o: rt/%.c $$(MKFILE_DEPS)
|
|
|
|
@mkdir -p $$(@D)
|
|
|
|
@$$(call E, compile: $$@)
|
|
|
|
$$(Q)$$(call CFG_COMPILE_C_$(1), $$@, \
|
|
|
|
-I $$(S)src/rt/sundown/src -I $$(S)src/rt/sundown/html \
|
|
|
|
-I $$(S)src/libuv/include -I $$(S)src/rt \
|
|
|
|
$$(RUNTIME_CFLAGS_$(1))) $$<
|
|
|
|
|
|
|
|
$$(RT_OUTPUT_DIR_$(1))/%.o: rt/%.S $$(MKFILE_DEPS) $$(LLVM_CONFIG_$$(CFG_BUILD))
|
|
|
|
@mkdir -p $$(@D)
|
|
|
|
@$$(call E, compile: $$@)
|
|
|
|
$$(Q)$$(call CFG_ASSEMBLE_$(1),$$@,$$<)
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(foreach target,$(CFG_TARGET),$(eval $(call NATIVE_LIBRARIES,$(target))))
|
|
|
|
|
|
|
|
# A macro for devining how to build third party libraries listed above (based
|
|
|
|
# on their dependencies).
|
|
|
|
#
|
|
|
|
# $(1) is the target
|
|
|
|
# $(2) is the lib name
|
|
|
|
define THIRD_PARTY_LIB
|
|
|
|
|
|
|
|
OBJS_$(2)_$(1) := $$(NATIVE_DEPS_$(2)_$(1):%=$$(RT_OUTPUT_DIR_$(1))/%)
|
|
|
|
OBJS_$(2)_$(1) := $$(OBJS_$(2)_$(1):.c=.o)
|
|
|
|
OBJS_$(2)_$(1) := $$(OBJS_$(2)_$(1):.cpp=.o)
|
|
|
|
OBJS_$(2)_$(1) := $$(OBJS_$(2)_$(1):.ll=.o)
|
|
|
|
OBJS_$(2)_$(1) := $$(OBJS_$(2)_$(1):.S=.o)
|
|
|
|
NATIVE_$(2)_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),$(2))
|
|
|
|
$$(RT_OUTPUT_DIR_$(1))/$$(NATIVE_$(2)_$(1)): $$(OBJS_$(2)_$(1))
|
|
|
|
@$$(call E, link: $$@)
|
|
|
|
$$(Q)$$(AR_$(1)) rcs $$@ $$^
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
$(foreach target,$(CFG_TARGET), \
|
|
|
|
$(eval $(call RUNTIME_RULES,$(target))))
|
|
|
|
$(foreach lib,$(NATIVE_LIBS), \
|
|
|
|
$(foreach target,$(CFG_TARGET), \
|
|
|
|
$(eval $(call THIRD_PARTY_LIB,$(target),$(lib)))))
|
2012-03-26 17:54:22 -05:00
|
|
|
|
2014-01-24 21:27:22 -06:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Building third-party targets with external build systems
|
|
|
|
#
|
|
|
|
# The only current member of this section is libuv, but long ago this used to
|
|
|
|
# also be occupied by jemalloc. This location is meant for dependencies which
|
|
|
|
# have external build systems. It is still assumed that the output of each of
|
|
|
|
# these steps is a static library in the correct location.
|
|
|
|
################################################################################
|
2012-03-26 17:54:22 -05:00
|
|
|
|
2013-08-28 19:01:44 -05:00
|
|
|
define DEF_LIBUV_ARCH_VAR
|
|
|
|
LIBUV_ARCH_$(1) = $$(subst i386,ia32,$$(subst x86_64,x64,$$(HOST_$(1))))
|
|
|
|
endef
|
2013-10-21 04:18:21 -05:00
|
|
|
$(foreach t,$(CFG_TARGET),$(eval $(call DEF_LIBUV_ARCH_VAR,$(t))))
|
2013-08-28 19:01:44 -05:00
|
|
|
|
2013-10-08 11:20:17 -05: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_NO_LOAD = run-benchmarks.target.mk run-tests.target.mk \
|
|
|
|
uv_dtrace_header.target.mk uv_dtrace_provider.target.mk
|
|
|
|
|
|
|
|
export PYTHONPATH := $(PYTHONPATH):$(S)src/gyp/pylib
|
|
|
|
|
|
|
|
define DEF_THIRD_PARTY_TARGETS
|
|
|
|
|
|
|
|
# $(1) is the target triple
|
|
|
|
|
|
|
|
ifeq ($$(CFG_WINDOWSY_$(1)), 1)
|
|
|
|
LIBUV_OSTYPE_$(1) := win
|
|
|
|
else ifeq ($(OSTYPE_$(1)), apple-darwin)
|
|
|
|
LIBUV_OSTYPE_$(1) := mac
|
|
|
|
else ifeq ($(OSTYPE_$(1)), unknown-freebsd)
|
|
|
|
LIBUV_OSTYPE_$(1) := freebsd
|
|
|
|
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
|
|
|
|
LIBUV_OSTYPE_$(1) := android
|
|
|
|
LIBUV_ARGS_$(1) := PLATFORM=android host=android OS=linux
|
2012-02-10 14:07:01 -06:00
|
|
|
else
|
2013-10-08 11:20:17 -05:00
|
|
|
LIBUV_OSTYPE_$(1) := linux
|
2012-02-10 14:07:01 -06:00
|
|
|
endif
|
|
|
|
|
2013-10-08 11:20:17 -05:00
|
|
|
LIBUV_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),uv)
|
2013-12-19 01:44:10 -06:00
|
|
|
LIBUV_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/libuv
|
2014-01-24 21:27:22 -06:00
|
|
|
LIBUV_LIB_$(1) := $$(RT_OUTPUT_DIR_$(1))/$$(LIBUV_NAME_$(1))
|
2013-08-18 19:11:45 -05:00
|
|
|
|
2013-10-08 11:20:17 -05:00
|
|
|
LIBUV_MAKEFILE_$(1) := $$(CFG_BUILD_DIR)$$(RT_OUTPUT_DIR_$(1))/libuv/Makefile
|
2013-08-18 19:11:45 -05:00
|
|
|
|
2013-12-19 01:44:10 -06:00
|
|
|
LIBUV_STAMP_$(1) = $$(LIBUV_DIR_$(1))/libuv-auto-clean-stamp
|
|
|
|
|
|
|
|
$$(LIBUV_STAMP_$(1)): $(S)src/rt/libuv-auto-clean-trigger
|
|
|
|
$$(Q)rm -rf $$(LIBUV_DIR_$(1))
|
|
|
|
$$(Q)mkdir -p $$(@D)
|
|
|
|
touch $$@
|
|
|
|
|
2013-11-22 20:21:37 -06:00
|
|
|
# libuv triggers a few warnings on some platforms
|
|
|
|
LIBUV_CFLAGS_$(1) := $(subst -Werror,,$(CFG_GCCISH_CFLAGS_$(1)))
|
|
|
|
|
2013-12-19 01:44:10 -06:00
|
|
|
$$(LIBUV_MAKEFILE_$(1)): $$(LIBUV_DEPS) $$(MKFILE_DEPS) $$(LIBUV_STAMP_$(1))
|
2013-08-18 19:11:45 -05:00
|
|
|
(cd $(S)src/libuv/ && \
|
2013-11-07 17:26:47 -06:00
|
|
|
$$(CFG_PYTHON) ./gyp_uv.py -f make -Dtarget_arch=$$(LIBUV_ARCH_$(1)) \
|
2013-10-08 11:20:17 -05:00
|
|
|
-D ninja \
|
|
|
|
-DOS=$$(LIBUV_OSTYPE_$(1)) \
|
2013-08-18 19:11:45 -05:00
|
|
|
-Goutput_dir=$$(@D) --generator-output $$(@D))
|
2013-12-19 01:44:10 -06:00
|
|
|
touch $$@
|
2013-08-18 19:11:45 -05:00
|
|
|
|
2013-10-08 11:20:17 -05:00
|
|
|
# Windows has a completely different build system for libuv because of mingw. In
|
|
|
|
# theory when we support msvc then we should be using gyp's msvc output instead
|
|
|
|
# of mingw's makefile for windows
|
2013-03-02 06:25:12 -06:00
|
|
|
ifdef CFG_WINDOWSY_$(1)
|
2013-12-19 01:44:10 -06:00
|
|
|
$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS) $$(MKFILE_DEPS)
|
2013-08-18 19:11:45 -05:00
|
|
|
$$(Q)$$(MAKE) -C $$(S)src/libuv -f Makefile.mingw \
|
2013-11-22 20:21:37 -06:00
|
|
|
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS_$(1))" \
|
|
|
|
CC="$$(CC_$(1)) $$(LIBUV_CFLAGS_$(1)) $$(SNAP_DEFINES)" \
|
|
|
|
CXX="$$(CXX_$(1))" \
|
2013-08-18 19:11:45 -05:00
|
|
|
AR="$$(AR_$(1))" \
|
2013-02-02 14:14:04 -06:00
|
|
|
V=$$(VERBOSE)
|
2013-08-18 19:11:45 -05:00
|
|
|
$$(Q)cp $$(S)src/libuv/libuv.a $$@
|
2013-02-26 23:53:35 -06:00
|
|
|
else
|
2013-12-19 01:44:10 -06:00
|
|
|
$$(LIBUV_LIB_$(1)): $$(LIBUV_DIR_$(1))/Release/libuv.a $$(MKFILE_DEPS)
|
2014-01-24 21:27:22 -06:00
|
|
|
$$(Q)cp $$< $$@
|
2013-12-19 01:44:10 -06:00
|
|
|
$$(LIBUV_DIR_$(1))/Release/libuv.a: $$(LIBUV_DEPS) $$(LIBUV_MAKEFILE_$(1)) \
|
|
|
|
$$(MKFILE_DEPS)
|
|
|
|
$$(Q)$$(MAKE) -C $$(LIBUV_DIR_$(1)) \
|
2013-11-22 20:21:37 -06:00
|
|
|
CFLAGS="$$(LIBUV_CFLAGS_$(1)) $$(SNAP_DEFINES)" \
|
2013-11-20 05:00:49 -06:00
|
|
|
LDFLAGS="$$(CFG_GCCISH_LINK_FLAGS_$(1))" \
|
2013-03-19 00:32:03 -05:00
|
|
|
CC="$$(CC_$(1))" \
|
|
|
|
CXX="$$(CXX_$(1))" \
|
|
|
|
AR="$$(AR_$(1))" \
|
2013-10-08 11:20:17 -05:00
|
|
|
$$(LIBUV_ARGS_$(1)) \
|
2013-08-18 19:11:45 -05:00
|
|
|
BUILDTYPE=Release \
|
|
|
|
NO_LOAD="$$(LIBUV_NO_LOAD)" \
|
2013-02-02 09:40:40 -06:00
|
|
|
V=$$(VERBOSE)
|
2013-10-31 01:57:27 -05:00
|
|
|
|
2014-01-24 21:27:22 -06:00
|
|
|
endif
|
2013-10-31 01:22:04 -05:00
|
|
|
|
2011-11-01 18:50:47 -05:00
|
|
|
endef
|
|
|
|
|
2013-10-08 11:20:17 -05:00
|
|
|
# Instantiate template for all stages/targets
|
2013-10-21 04:18:21 -05:00
|
|
|
$(foreach target,$(CFG_TARGET), \
|
2013-10-08 11:20:17 -05:00
|
|
|
$(eval $(call DEF_THIRD_PARTY_TARGETS,$(target))))
|