2a3640382b4f5f4535604c6c72783d87e8879239
[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_arm android_arm64 android_mipsel android_x87
30 MODES = release debug
31
32 # Generates all combinations of ANDROID ARCHES and MODES,
33 # e.g. "android_ia32.release" or "android_arm.release"
34 ANDROID_BUILDS = $(foreach mode,$(MODES), \
35                    $(addsuffix .$(mode),$(ANDROID_ARCHES)))
36
37 HOST_OS = $(shell uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
38 ANDROID_NDK_HOST_ARCH ?= $(shell uname -m | sed -e 's/i[3456]86/x86/')
39 ifeq ($(HOST_OS), linux)
40   TOOLCHAIN_DIR = linux-$(ANDROID_NDK_HOST_ARCH)
41 else ifeq ($(HOST_OS), mac)
42   TOOLCHAIN_DIR = darwin-$(ANDROID_NDK_HOST_ARCH)
43 else
44   $(error Host platform "${HOST_OS}" is not supported)
45 endif
46
47 ifeq ($(ARCH), android_arm)
48   DEFINES  = target_arch=arm v8_target_arch=arm android_target_arch=arm android_target_platform=14
49   DEFINES += arm_neon=0 arm_version=7
50   TOOLCHAIN_ARCH = arm-linux-androideabi
51   TOOLCHAIN_PREFIX = $(TOOLCHAIN_ARCH)
52   TOOLCHAIN_VER = 4.8
53 else ifeq ($(ARCH), android_arm64)
54   DEFINES  = target_arch=arm64 v8_target_arch=arm64 android_target_arch=arm64 android_target_platform=21
55   TOOLCHAIN_ARCH = aarch64-linux-android
56   TOOLCHAIN_PREFIX = $(TOOLCHAIN_ARCH)
57   TOOLCHAIN_VER = 4.9
58 else ifeq ($(ARCH), android_mipsel)
59   DEFINES  = target_arch=mipsel v8_target_arch=mipsel android_target_platform=14
60   DEFINES += android_target_arch=mips mips_arch_variant=mips32r2
61   TOOLCHAIN_ARCH = mipsel-linux-android
62   TOOLCHAIN_PREFIX = $(TOOLCHAIN_ARCH)
63   TOOLCHAIN_VER = 4.8
64 else ifeq ($(ARCH), android_ia32)
65   DEFINES = target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86 android_target_platform=14
66   TOOLCHAIN_ARCH = x86
67   TOOLCHAIN_PREFIX = i686-linux-android
68   TOOLCHAIN_VER = 4.8
69 else ifeq ($(ARCH), android_x87)
70   DEFINES = target_arch=x87 v8_target_arch=x87 android_target_arch=x86 android_target_platform=14
71   TOOLCHAIN_ARCH = x86
72   TOOLCHAIN_PREFIX = i686-linux-android
73   TOOLCHAIN_VER = 4.8
74 else
75   $(error Target architecture "${ARCH}" is not supported)
76 endif
77
78 TOOLCHAIN_PATH = \
79     ${ANDROID_NDK_ROOT}/toolchains/${TOOLCHAIN_ARCH}-${TOOLCHAIN_VER}/prebuilt
80 ANDROID_TOOLCHAIN ?= ${TOOLCHAIN_PATH}/${TOOLCHAIN_DIR}
81
82 ifeq ($(wildcard $(ANDROID_TOOLCHAIN)),)
83   $(error Cannot find Android toolchain in "${ANDROID_TOOLCHAIN}".  Please \
84           check that ANDROID_NDK_ROOT and ANDROID_NDK_HOST_ARCH are set    \
85           correctly)
86 endif
87
88 # For mksnapshot host generation.
89 DEFINES += host_os=${HOST_OS}
90 DEFINES += OS=android
91
92 .SECONDEXPANSION:
93 $(ANDROID_BUILDS): $(OUTDIR)/Makefile.$$@
94         @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
95                   CXX="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-g++" \
96                   AR="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-ar" \
97                   RANLIB="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-ranlib" \
98                   CC="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-gcc" \
99                   LD="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-ld" \
100                   LINK="$(ANDROID_TOOLCHAIN)/bin/${TOOLCHAIN_PREFIX}-g++" \
101                   BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
102                               python -c "print raw_input().capitalize()") \
103                   builddir="$(shell pwd)/$(OUTDIR)/$@"
104
105 # Android GYP file generation targets.
106 ANDROID_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ANDROID_BUILDS))
107 $(ANDROID_MAKEFILES):
108         GYP_GENERATORS=make-android \
109         GYP_DEFINES="${DEFINES}" \
110         CC="${ANDROID_TOOLCHAIN}/bin/${TOOLCHAIN_PREFIX}-gcc" \
111         CXX="${ANDROID_TOOLCHAIN}/bin/${TOOLCHAIN_PREFIX}-g++" \
112         PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH)" \
113         build/gyp/gyp --generator-output="${OUTDIR}" build/all.gyp \
114                       -Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \
115                       -S$(suffix $(basename $@))$(suffix $@) ${GYPFLAGS}