blob: fd5f968736b5d3e5d39d794d8f3743dccb1ef958 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +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
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000029ANDROID_ARCHES = android_ia32 android_x64 android_arm android_arm64 \
30 android_mipsel android_x87
Ben Murdochb8a8cc12014-11-26 15:28:44 +000031MODES = release debug
32
33# Generates all combinations of ANDROID ARCHES and MODES,
34# e.g. "android_ia32.release" or "android_arm.release"
35ANDROID_BUILDS = $(foreach mode,$(MODES), \
36 $(addsuffix .$(mode),$(ANDROID_ARCHES)))
37
Ben Murdochc5610432016-08-08 18:44:38 +010038HOST_OS = $(shell uname -s | sed -e 's/Linux/linux/;s/Darwin/darwin/')
39HOST_ARCH = $(shell uname -m | sed -e 's/i[3456]86/x86/')
40
Ben Murdochb8a8cc12014-11-26 15:28:44 +000041ifeq ($(ARCH), android_arm)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000042 DEFINES = target_arch=arm v8_target_arch=arm
Ben Murdochc5610432016-08-08 18:44:38 +010043 ANDROID_TOOLCHAIN = $(ANDROID_NDK_ROOT)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(HOST_OS)-$(HOST_ARCH)/arm-linux-androideabi/bin
Emily Bernierd0a1eb72015-03-24 16:35:39 -040044else ifeq ($(ARCH), android_arm64)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000045 DEFINES = target_arch=arm64 v8_target_arch=arm64
Ben Murdochc5610432016-08-08 18:44:38 +010046 ANDROID_TOOLCHAIN = $(ANDROID_NDK_ROOT)/toolchains/aarch64-linux-android-4.9/prebuilt/$(HOST_OS)-$(HOST_ARCH)/aarch64-linux-android/bin
Emily Bernierd0a1eb72015-03-24 16:35:39 -040047else ifeq ($(ARCH), android_mipsel)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000048 DEFINES = target_arch=mipsel v8_target_arch=mipsel
Ben Murdochc5610432016-08-08 18:44:38 +010049 ANDROID_TOOLCHAIN = $(ANDROID_NDK_ROOT)/toolchains/mipsel-linux-android-4.9/prebuilt/$(HOST_OS)-$(HOST_ARCH)/mipsel-linux-android/bin
Emily Bernierd0a1eb72015-03-24 16:35:39 -040050else ifeq ($(ARCH), android_ia32)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000051 DEFINES = target_arch=ia32 v8_target_arch=ia32
Ben Murdochc5610432016-08-08 18:44:38 +010052 ANDROID_TOOLCHAIN = $(ANDROID_NDK_ROOT)/toolchains/x86-4.9/prebuilt/$(HOST_OS)-$(HOST_ARCH)/i686-linux-android/bin
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000053else ifeq ($(ARCH), android_x64)
54 DEFINES = target_arch=x64 v8_target_arch=x64
Ben Murdochc5610432016-08-08 18:44:38 +010055 ANDROID_TOOLCHAIN = $(ANDROID_NDK_ROOT)/toolchains/x86_64-4.9/prebuilt/$(HOST_OS)-$(HOST_ARCH)/x86_64-linux-android/bin
Emily Bernierd0a1eb72015-03-24 16:35:39 -040056else ifeq ($(ARCH), android_x87)
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000057 DEFINES = target_arch=ia32 v8_target_arch=x87
Ben Murdochc5610432016-08-08 18:44:38 +010058 ANDROID_TOOLCHAIN = $(ANDROID_NDK_ROOT)/toolchains/x86-4.9/prebuilt/$(HOST_OS)-$(HOST_ARCH)/i686-linux-android/bin
Ben Murdochb8a8cc12014-11-26 15:28:44 +000059else
Emily Bernierd0a1eb72015-03-24 16:35:39 -040060 $(error Target architecture "${ARCH}" is not supported)
Ben Murdochb8a8cc12014-11-26 15:28:44 +000061endif
62
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000063# Common flags.
Ben Murdochb8a8cc12014-11-26 15:28:44 +000064DEFINES += OS=android
65
66.SECONDEXPANSION:
67$(ANDROID_BUILDS): $(OUTDIR)/Makefile.$$@
68 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
Ben Murdochc5610432016-08-08 18:44:38 +010069 AR="$(ANDROID_TOOLCHAIN)/ar" \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000070 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
71 python -c "print raw_input().capitalize()") \
72 builddir="$(shell pwd)/$(OUTDIR)/$@"
73
74# Android GYP file generation targets.
75ANDROID_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ANDROID_BUILDS))
76$(ANDROID_MAKEFILES):
77 GYP_GENERATORS=make-android \
78 GYP_DEFINES="${DEFINES}" \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000079 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH)" \
Ben Murdochc5610432016-08-08 18:44:38 +010080 tools/gyp/gyp --generator-output="${OUTDIR}" gypfiles/all.gyp \
81 -Igypfiles/standalone.gypi --depth=. \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000082 -S$(suffix $(basename $@))$(suffix $@) ${GYPFLAGS}