blob: 5eaff47cf9a0a4bc563d1f6d2fc9c24264360372 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001#
2# Copyright 2013 the V8 project authors. All rights reserved.
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are
5# met:
6#
7# * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9# * Redistributions in binary form must reproduce the above
10# copyright notice, this list of conditions and the following
11# disclaimer in the documentation and/or other materials provided
12# with the distribution.
13# * Neither the name of Google Inc. nor the names of its
14# contributors may be used to endorse or promote products derived
15# from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29# Those definitions should be consistent with the main Makefile
30NACL_ARCHES = nacl_ia32 nacl_x64
31MODES = release debug
32
33# Generates all combinations of NACL ARCHES and MODES,
34# e.g. "nacl_ia32.release" or "nacl_x64.release"
35NACL_BUILDS = $(foreach mode,$(MODES), \
36 $(addsuffix .$(mode),$(NACL_ARCHES)))
37
38HOST_OS = $(shell uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
Ben Murdochb8a8cc12014-11-26 15:28:44 +000039TOOLCHAIN_PATH = $(realpath ${NACL_SDK_ROOT}/toolchain)
Emily Bernierd0a1eb72015-03-24 16:35:39 -040040NACL_TOOLCHAIN ?= ${TOOLCHAIN_PATH}/linux_pnacl
Ben Murdochb8a8cc12014-11-26 15:28:44 +000041
42ifeq ($(wildcard $(NACL_TOOLCHAIN)),)
43 $(error Cannot find Native Client toolchain in "${NACL_TOOLCHAIN}")
44endif
45
Emily Bernierd0a1eb72015-03-24 16:35:39 -040046ifeq ($(ARCH), nacl_ia32)
47 GYPENV = nacl_target_arch=nacl_ia32 v8_target_arch=arm v8_host_arch=ia32
48 NACL_CC = "$(NACL_TOOLCHAIN)/bin/pnacl-clang"
49 NACL_CXX = "$(NACL_TOOLCHAIN)/bin/pnacl-clang++"
50 NACL_LINK = "$(NACL_TOOLCHAIN)/bin/pnacl-clang++ --pnacl-allow-native -arch x86-32"
51else
52 ifeq ($(ARCH), nacl_x64)
53 GYPENV = nacl_target_arch=nacl_x64 v8_target_arch=arm v8_host_arch=ia32
54 NACL_CC = "$(NACL_TOOLCHAIN)/bin/pnacl-clang"
55 NACL_CXX = "$(NACL_TOOLCHAIN)/bin/pnacl-clang++"
56 NACL_LINK = "$(NACL_TOOLCHAIN)/bin/pnacl-clang++ --pnacl-allow-native -arch x86-64"
57 else
58 $(error Target architecture "${ARCH}" is not supported)
59 endif
60endif
61
Ben Murdochb8a8cc12014-11-26 15:28:44 +000062# For mksnapshot host generation.
63GYPENV += host_os=${HOST_OS}
64
65# ICU doesn't support NaCl.
66GYPENV += v8_enable_i18n_support=0
67
68# Disable strict aliasing - v8 code often relies on undefined behavior of C++.
69GYPENV += v8_no_strict_aliasing=1
70
71NACL_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(NACL_BUILDS))
72.SECONDEXPANSION:
73# For some reason the $$(basename $$@) expansion didn't work here...
74$(NACL_BUILDS): $(NACL_MAKEFILES)
75 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
Emily Bernierd0a1eb72015-03-24 16:35:39 -040076 CC=${NACL_CC} \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000077 CXX=${NACL_CXX} \
Emily Bernierd0a1eb72015-03-24 16:35:39 -040078 AR="$(NACL_TOOLCHAIN)/bin/pnacl-ar" \
79 RANLIB="$(NACL_TOOLCHAIN)/bin/pnacl-ranlib" \
80 LD="$(NACL_TOOLCHAIN)/bin/pnacl-ld" \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000081 LINK=${NACL_LINK} \
82 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
83 python -c "print raw_input().capitalize()") \
84 builddir="$(shell pwd)/$(OUTDIR)/$@"
85
86# NACL GYP file generation targets.
87$(NACL_MAKEFILES):
88 GYP_GENERATORS=make \
89 GYP_DEFINES="${GYPENV}" \
90 CC=${NACL_CC} \
91 CXX=${NACL_CXX} \
Emily Bernierd0a1eb72015-03-24 16:35:39 -040092 LINK=${NACL_LINK} \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000093 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH)" \
Ben Murdochc5610432016-08-08 18:44:38 +010094 tools/gyp/gyp --generator-output="${OUTDIR}" gypfiles/all.gyp \
95 -Igypfiles/standalone.gypi --depth=. \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000096 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS) \
97 -Dwno_array_bounds=-Wno-array-bounds