ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 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 |
| 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 | ifeq ($(HOST_OS), linux) |
| 39 | TOOLCHAIN_DIR = linux-x86 |
| 40 | else |
| 41 | ifeq ($(HOST_OS), mac) |
| 42 | TOOLCHAIN_DIR = darwin-x86 |
| 43 | else |
| 44 | $(error Host platform "${HOST_OS}" is not supported) |
| 45 | endif |
| 46 | endif |
| 47 | |
| 48 | ifeq ($(ARCH), android_arm) |
| 49 | DEFINES = target_arch=arm v8_target_arch=arm android_target_arch=arm |
| 50 | DEFINES += arm_neon=0 armv7=1 |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 51 | TOOLCHAIN_ARCH = arm-linux-androideabi-4.6 |
ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 52 | else |
| 53 | ifeq ($(ARCH), android_ia32) |
| 54 | DEFINES = target_arch=ia32 v8_target_arch=ia32 android_target_arch=x86 |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 55 | TOOLCHAIN_ARCH = x86-4.6 |
ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 56 | else |
| 57 | $(error Target architecture "${ARCH}" is not supported) |
| 58 | endif |
| 59 | endif |
| 60 | |
| 61 | TOOLCHAIN_PATH = ${ANDROID_NDK_ROOT}/toolchains/${TOOLCHAIN_ARCH}/prebuilt |
jkummerow@chromium.org | 78502a9 | 2012-09-06 13:50:42 +0000 | [diff] [blame] | 62 | ANDROID_TOOLCHAIN ?= ${TOOLCHAIN_PATH}/${TOOLCHAIN_DIR} |
ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 63 | ifeq ($(wildcard $(ANDROID_TOOLCHAIN)),) |
| 64 | $(error Cannot find Android toolchain in "${ANDROID_TOOLCHAIN}") |
| 65 | endif |
| 66 | |
| 67 | # For mksnapshot host generation. |
| 68 | DEFINES += host_os=${HOST_OS} |
| 69 | |
| 70 | .SECONDEXPANSION: |
| 71 | $(ANDROID_BUILDS): $(OUTDIR)/Makefile.$$(basename $$@) |
| 72 | @$(MAKE) -C "$(OUTDIR)" -f Makefile.$(basename $@) \ |
jkummerow@chromium.org | 78502a9 | 2012-09-06 13:50:42 +0000 | [diff] [blame] | 73 | CXX="$(ANDROID_TOOLCHAIN)/bin/*-g++" \ |
| 74 | AR="$(ANDROID_TOOLCHAIN)/bin/*-ar" \ |
| 75 | RANLIB="$(ANDROID_TOOLCHAIN)/bin/*-ranlib" \ |
| 76 | CC="$(ANDROID_TOOLCHAIN)/bin/*-gcc" \ |
| 77 | LD="$(ANDROID_TOOLCHAIN)/bin/*-ld" \ |
| 78 | LINK="$(ANDROID_TOOLCHAIN)/bin/*-g++" \ |
ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 79 | BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \ |
| 80 | python -c "print raw_input().capitalize()") \ |
| 81 | builddir="$(shell pwd)/$(OUTDIR)/$@" |
| 82 | |
| 83 | # Android GYP file generation targets. |
| 84 | ANDROID_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ANDROID_ARCHES)) |
| 85 | $(ANDROID_MAKEFILES): |
| 86 | @GYP_GENERATORS=make-android \ |
| 87 | GYP_DEFINES="${DEFINES}" \ |
jkummerow@chromium.org | 78502a9 | 2012-09-06 13:50:42 +0000 | [diff] [blame] | 88 | CC="${ANDROID_TOOLCHAIN}/bin/*-gcc" \ |
| 89 | CXX="${ANDROID_TOOLCHAIN}/bin/*-g++" \ |
ulan@chromium.org | ea52b5f | 2012-07-30 13:05:33 +0000 | [diff] [blame] | 90 | build/gyp/gyp --generator-output="${OUTDIR}" build/all.gyp \ |
| 91 | -Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \ |
| 92 | -S.${ARCH} ${GYPFLAGS} |