deps: update v8 to 4.3.61.21
[platform/upstream/nodejs.git] / deps / v8 / Makefile.android
1 # Copyright 2012 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are
4 # met:
5 #
6 #     * Redistributions of source code must retain the above copyright
7 #       notice, this list of conditions and the following disclaimer.
8 #     * Redistributions in binary form must reproduce the above
9 #       copyright notice, this list of conditions and the following
10 #       disclaimer in the documentation and/or other materials provided
11 #       with the distribution.
12 #     * Neither the name of Google Inc. nor the names of its
13 #       contributors may be used to endorse or promote products derived
14 #       from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 # Those definitions should be consistent with the main Makefile
29 ANDROID_ARCHES = android_ia32 android_x64 android_arm android_arm64 \
30                  android_mipsel android_x87
31 MODES = release debug
32
33 # Generates all combinations of ANDROID ARCHES and MODES,
34 # e.g. "android_ia32.release" or "android_arm.release"
35 ANDROID_BUILDS = $(foreach mode,$(MODES), \
36                    $(addsuffix .$(mode),$(ANDROID_ARCHES)))
37
38 HOST_OS = $(shell uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
39 ANDROID_NDK_HOST_ARCH ?= $(shell uname -m | sed -e 's/i[3456]86/x86/')
40 ifeq ($(HOST_OS), linux)
41   TOOLCHAIN_DIR = linux-$(ANDROID_NDK_HOST_ARCH)
42 else ifeq ($(HOST_OS), mac)
43   TOOLCHAIN_DIR = darwin-$(ANDROID_NDK_HOST_ARCH)
44 else
45   $(error Host platform "${HOST_OS}" is not supported)
46 endif
47
48 ifeq ($(ARCH), android_arm)
49   DEFINES  = target_arch=arm v8_target_arch=arm android_target_arch=arm android_target_platform=14
50   DEFINES += arm_neon=0 arm_version=7
51   TOOLCHAIN_ARCH = arm-linux-androideabi
52   TOOLCHAIN_PREFIX = $(TOOLCHAIN_ARCH)
53   TOOLCHAIN_VER = 4.8
54 else ifeq ($(ARCH), android_arm64)
55   DEFINES  = target_arch=arm64 v8_target_arch=arm64 android_target_arch=arm64 android_target_platform=21
56   TOOLCHAIN_ARCH = aarch64-linux-android
57   TOOLCHAIN_PREFIX = $(TOOLCHAIN_ARCH)
58   TOOLCHAIN_VER = 4.9
59 else ifeq ($(ARCH), android_mipsel)
60   DEFINES  = target_arch=mipsel v8_target_arch=mipsel android_target_platform=14
61   DEFINES += android_target_arch=mips mips_arch_variant=mips32r2
62   TOOLCHAIN_ARCH = mipsel-linux-android
63   TOOLCHAIN_PREFIX = $(TOOLCHAIN_ARCH)
64   TOOLCHAIN_VER = 4.8
65 else ifeq ($(ARCH), android_ia32)
66   DEFINES = target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86 android_target_platform=14
67   TOOLCHAIN_ARCH = x86
68   TOOLCHAIN_PREFIX = i686-linux-android
69   TOOLCHAIN_VER = 4.8
70 else ifeq ($(ARCH), android_x64)
71   DEFINES = target_arch=x64 v8_target_arch=x64 android_target_arch=x86_64 android_target_platform=21
72   TOOLCHAIN_ARCH = x86_64
73   TOOLCHAIN_PREFIX = x86_64-linux-android
74   TOOLCHAIN_VER = 4.9
75 else ifeq ($(ARCH), android_x87)
76   DEFINES = target_arch=x87 v8_target_arch=x87 android_target_arch=x86 android_target_platform=14
77   TOOLCHAIN_ARCH = x86
78   TOOLCHAIN_PREFIX = i686-linux-android
79   TOOLCHAIN_VER = 4.8
80 else
81   $(error Target architecture "${ARCH}" is not supported)
82 endif
83
84 TOOLCHAIN_PATH = \
85     ${ANDROID_NDK_ROOT}/toolchains/${TOOLCHAIN_ARCH}-${TOOLCHAIN_VER}/prebuilt
86 ANDROID_TOOLCHAIN ?= ${TOOLCHAIN_PATH}/${TOOLCHAIN_DIR}
87
88 ifeq ($(wildcard $(ANDROID_TOOLCHAIN)),)
89   $(error Cannot find Android toolchain in "${ANDROID_TOOLCHAIN}".  Please \
90           check that ANDROID_NDK_ROOT and ANDROID_NDK_HOST_ARCH are set    \
91           correctly)
92 endif
93
94 # For mksnapshot host generation.
95 DEFINES += host_os=${HOST_OS}
96 DEFINES += OS=android
97
98 .SECONDEXPANSION:
99 $(ANDROID_BUILDS): $(OUTDIR)/Makefile.$$@
100         @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
101                   CXX="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-g++" \
102                   AR="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-ar" \
103                   RANLIB="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-ranlib" \
104                   CC="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-gcc" \
105                   LD="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-ld" \
106                   LINK="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-g++" \
107                   BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
108                               python -c "print raw_input().capitalize()") \
109                   builddir="$(shell pwd)/$(OUTDIR)/$@"
110
111 # Android GYP file generation targets.
112 ANDROID_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ANDROID_BUILDS))
113 $(ANDROID_MAKEFILES):
114         GYP_GENERATORS=make-android \
115         GYP_DEFINES="${DEFINES}" \
116         CC="${ANDROID_TOOLCHAIN}/bin/${TOOLCHAIN_PREFIX}-gcc" \
117         CXX="${ANDROID_TOOLCHAIN}/bin/${TOOLCHAIN_PREFIX}-g++" \
118         PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH)" \
119         build/gyp/gyp --generator-output="${OUTDIR}" build/all.gyp \
120                       -Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \
121                       -S$(suffix $(basename $@))$(suffix $@) ${GYPFLAGS}