blob: fad5fe9943aa7b594c7b16f8da463ad3a3588e52 [file] [log] [blame]
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +00001# 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
mstarzinger@chromium.org71fc3462013-02-27 09:34:27 +000029ANDROID_ARCHES = android_ia32 android_arm android_mipsel
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000030MODES = release debug
31
32# Generates all combinations of ANDROID ARCHES and MODES,
33# e.g. "android_ia32.release" or "android_arm.release"
34ANDROID_BUILDS = $(foreach mode,$(MODES), \
35 $(addsuffix .$(mode),$(ANDROID_ARCHES)))
36
37HOST_OS = $(shell uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +000038ANDROID_NDK_HOST_ARCH ?= $(shell uname -m | sed -e 's/i[3456]86/x86/')
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000039ifeq ($(HOST_OS), linux)
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +000040 TOOLCHAIN_DIR = linux-$(ANDROID_NDK_HOST_ARCH)
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000041else
42 ifeq ($(HOST_OS), mac)
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +000043 TOOLCHAIN_DIR = darwin-$(ANDROID_NDK_HOST_ARCH)
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000044 else
45 $(error Host platform "${HOST_OS}" is not supported)
46 endif
47endif
48
49ifeq ($(ARCH), android_arm)
50 DEFINES = target_arch=arm v8_target_arch=arm android_target_arch=arm
hpayer@chromium.org80108f72013-12-17 07:57:53 +000051 DEFINES += arm_neon=0 arm_version=7
verwaest@chromium.org33e09c82012-10-10 17:07:22 +000052 TOOLCHAIN_ARCH = arm-linux-androideabi-4.6
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000053else
mstarzinger@chromium.org71fc3462013-02-27 09:34:27 +000054 ifeq ($(ARCH), android_mipsel)
55 DEFINES = target_arch=mipsel v8_target_arch=mipsel android_target_arch=mips
56 DEFINES += mips_arch_variant=mips32r2
57 TOOLCHAIN_ARCH = mipsel-linux-android-4.6
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000058 else
mstarzinger@chromium.org71fc3462013-02-27 09:34:27 +000059 ifeq ($(ARCH), android_ia32)
60 DEFINES = target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86
61 TOOLCHAIN_ARCH = x86-4.6
62 else
63 $(error Target architecture "${ARCH}" is not supported)
64 endif
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000065 endif
66endif
67
68TOOLCHAIN_PATH = ${ANDROID_NDK_ROOT}/toolchains/${TOOLCHAIN_ARCH}/prebuilt
jkummerow@chromium.org78502a92012-09-06 13:50:42 +000069ANDROID_TOOLCHAIN ?= ${TOOLCHAIN_PATH}/${TOOLCHAIN_DIR}
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000070ifeq ($(wildcard $(ANDROID_TOOLCHAIN)),)
jkummerow@chromium.orgba72ec82013-07-22 09:21:20 +000071 $(error Cannot find Android toolchain in "${ANDROID_TOOLCHAIN}". Please \
72 check that ANDROID_NDK_ROOT and ANDROID_NDK_HOST_ARCH are set \
73 correctly)
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000074endif
75
76# For mksnapshot host generation.
77DEFINES += host_os=${HOST_OS}
78
79.SECONDEXPANSION:
hpayer@chromium.org80108f72013-12-17 07:57:53 +000080$(ANDROID_BUILDS): $(OUTDIR)/Makefile.$$@
81 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +000082 CXX="$(ANDROID_TOOLCHAIN)/bin/*-g++" \
83 AR="$(ANDROID_TOOLCHAIN)/bin/*-ar" \
84 RANLIB="$(ANDROID_TOOLCHAIN)/bin/*-ranlib" \
85 CC="$(ANDROID_TOOLCHAIN)/bin/*-gcc" \
86 LD="$(ANDROID_TOOLCHAIN)/bin/*-ld" \
87 LINK="$(ANDROID_TOOLCHAIN)/bin/*-g++" \
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000088 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
89 python -c "print raw_input().capitalize()") \
90 builddir="$(shell pwd)/$(OUTDIR)/$@"
91
92# Android GYP file generation targets.
hpayer@chromium.org80108f72013-12-17 07:57:53 +000093ANDROID_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ANDROID_BUILDS))
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000094$(ANDROID_MAKEFILES):
hpayer@chromium.org80108f72013-12-17 07:57:53 +000095 GYP_GENERATORS=make-android \
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +000096 GYP_DEFINES="${DEFINES}" \
jkummerow@chromium.org78502a92012-09-06 13:50:42 +000097 CC="${ANDROID_TOOLCHAIN}/bin/*-gcc" \
98 CXX="${ANDROID_TOOLCHAIN}/bin/*-g++" \
jkummerow@chromium.org10480472013-07-17 08:22:15 +000099 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
ulan@chromium.orgea52b5f2012-07-30 13:05:33 +0000100 build/gyp/gyp --generator-output="${OUTDIR}" build/all.gyp \
101 -Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \
hpayer@chromium.org80108f72013-12-17 07:57:53 +0000102 -S$(suffix $(basename $@))$(suffix $@) ${GYPFLAGS}