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 29# Variable default definitions. Override them by exporting them in your shell. 30CXX ?= g++ 31LINK ?= g++ 32OUTDIR ?= out 33TESTJOBS ?= 34GYPFLAGS ?= 35TESTFLAGS ?= 36ANDROID_NDK_ROOT ?= 37ANDROID_NDK_HOST_ARCH ?= 38ANDROID_TOOLCHAIN ?= 39ANDROID_V8 ?= /data/local/tmp/v8 40NACL_SDK_ROOT ?= 41 42# Special build flags. Use them like this: "make library=shared" 43 44# library=shared || component=shared_library 45ifeq ($(library), shared) 46 GYPFLAGS += -Dcomponent=shared_library 47endif 48ifdef component 49 GYPFLAGS += -Dcomponent=$(component) 50endif 51# console=readline 52ifdef console 53 GYPFLAGS += -Dconsole=$(console) 54endif 55# disassembler=on 56ifeq ($(disassembler), on) 57 GYPFLAGS += -Dv8_enable_disassembler=1 58endif 59# objectprint=on 60ifeq ($(objectprint), on) 61 GYPFLAGS += -Dv8_object_print=1 62endif 63# verifyheap=on 64ifeq ($(verifyheap), on) 65 GYPFLAGS += -Dv8_enable_verify_heap=1 66endif 67# backtrace=off 68ifeq ($(backtrace), off) 69 GYPFLAGS += -Dv8_enable_backtrace=0 70else 71 GYPFLAGS += -Dv8_enable_backtrace=1 72endif 73# snapshot=off 74ifeq ($(snapshot), off) 75 GYPFLAGS += -Dv8_use_snapshot='false' 76endif 77# extrachecks=on/off 78ifeq ($(extrachecks), on) 79 GYPFLAGS += -Dv8_enable_extra_checks=1 -Dv8_enable_handle_zapping=1 80endif 81ifeq ($(extrachecks), off) 82 GYPFLAGS += -Dv8_enable_extra_checks=0 -Dv8_enable_handle_zapping=0 83endif 84# gdbjit=on/off 85ifeq ($(gdbjit), on) 86 GYPFLAGS += -Dv8_enable_gdbjit=1 87endif 88ifeq ($(gdbjit), off) 89 GYPFLAGS += -Dv8_enable_gdbjit=0 90endif 91# vtunejit=on 92ifeq ($(vtunejit), on) 93 GYPFLAGS += -Dv8_enable_vtunejit=1 94endif 95# optdebug=on 96ifeq ($(optdebug), on) 97 GYPFLAGS += -Dv8_optimized_debug=2 98endif 99# debuggersupport=off 100ifeq ($(debuggersupport), off) 101 GYPFLAGS += -Dv8_enable_debugger_support=0 102endif 103# unalignedaccess=on 104ifeq ($(unalignedaccess), on) 105 GYPFLAGS += -Dv8_can_use_unaligned_accesses=true 106endif 107# randomseed=12345, disable random seed via randomseed=0 108ifdef randomseed 109 GYPFLAGS += -Dv8_random_seed=$(randomseed) 110endif 111# soname_version=1.2.3 112ifdef soname_version 113 GYPFLAGS += -Dsoname_version=$(soname_version) 114endif 115# werror=no 116ifeq ($(werror), no) 117 GYPFLAGS += -Dwerror='' 118endif 119# presubmit=no 120ifeq ($(presubmit), no) 121 TESTFLAGS += --no-presubmit 122endif 123# strictaliasing=off (workaround for GCC-4.5) 124ifeq ($(strictaliasing), off) 125 GYPFLAGS += -Dv8_no_strict_aliasing=1 126endif 127# regexp=interpreted 128ifeq ($(regexp), interpreted) 129 GYPFLAGS += -Dv8_interpreted_regexp=1 130endif 131# i18nsupport=off 132ifeq ($(i18nsupport), off) 133 GYPFLAGS += -Dv8_enable_i18n_support=0 134 TESTFLAGS += --noi18n 135endif 136# deprecation_warnings=on 137ifeq ($(deprecationwarnings), on) 138 GYPFLAGS += -Dv8_deprecation_warnings=1 139endif 140# arm specific flags. 141# armv7=false/true 142ifeq ($(armv7), false) 143 GYPFLAGS += -Darmv7=0 144else 145ifeq ($(armv7), true) 146 GYPFLAGS += -Darmv7=1 147endif 148endif 149# vfp2=off. Deprecated, use armfpu= 150# vfp3=off. Deprecated, use armfpu= 151ifeq ($(vfp3), off) 152 GYPFLAGS += -Darm_fpu=vfp 153endif 154# hardfp=on/off. Deprecated, use armfloatabi 155ifeq ($(hardfp),on) 156 GYPFLAGS += -Darm_float_abi=hard 157else 158ifeq ($(hardfp),off) 159 GYPFLAGS += -Darm_float_abi=softfp 160endif 161endif 162# armneon=on/off 163ifeq ($(armneon), on) 164 GYPFLAGS += -Darm_neon=1 165endif 166# fpu: armfpu=xxx 167# xxx: vfp, vfpv3-d16, vfpv3, neon. 168ifeq ($(armfpu),) 169ifneq ($(vfp3), off) 170 GYPFLAGS += -Darm_fpu=default 171endif 172else 173 GYPFLAGS += -Darm_fpu=$(armfpu) 174endif 175# float abi: armfloatabi=softfp/hard 176ifeq ($(armfloatabi),) 177ifeq ($(hardfp),) 178 GYPFLAGS += -Darm_float_abi=default 179endif 180else 181 GYPFLAGS += -Darm_float_abi=$(armfloatabi) 182endif 183# armthumb=on/off 184ifeq ($(armthumb), off) 185 GYPFLAGS += -Darm_thumb=0 186else 187ifeq ($(armthumb), on) 188 GYPFLAGS += -Darm_thumb=1 189endif 190endif 191# armtest=on 192# With this flag set, by default v8 will only use features implied 193# by the compiler (no probe). This is done by modifying the default 194# values of enable_armv7, enable_vfp2, enable_vfp3 and enable_32dregs. 195# Modifying these flags when launching v8 will enable the probing for 196# the specified values. 197# When using the simulator, this flag is implied. 198ifeq ($(armtest), on) 199 GYPFLAGS += -Darm_test=on 200endif 201 202# ----------------- available targets: -------------------- 203# - "dependencies": pulls in external dependencies (currently: GYP) 204# - "grokdump": rebuilds heap constants lists used by grokdump 205# - any arch listed in ARCHES (see below) 206# - any mode listed in MODES 207# - every combination <arch>.<mode>, e.g. "ia32.release" 208# - "native": current host's architecture, release mode 209# - any of the above with .check appended, e.g. "ia32.release.check" 210# - "android": cross-compile for Android/ARM 211# - "nacl" : cross-compile for Native Client (ia32 and x64) 212# - default (no target specified): build all DEFAULT_ARCHES and MODES 213# - "check": build all targets and run all tests 214# - "<arch>.clean" for any <arch> in ARCHES 215# - "clean": clean all ARCHES 216 217# ----------------- internal stuff ------------------------ 218 219# Architectures and modes to be compiled. Consider these to be internal 220# variables, don't override them (use the targets instead). 221ARCHES = ia32 x64 arm mipsel 222DEFAULT_ARCHES = ia32 x64 arm 223MODES = release debug optdebug 224DEFAULT_MODES = release debug 225ANDROID_ARCHES = android_ia32 android_arm android_mipsel 226NACL_ARCHES = nacl_ia32 nacl_x64 227 228# List of files that trigger Makefile regeneration: 229GYPFILES = build/all.gyp build/features.gypi build/standalone.gypi \ 230 build/toolchain.gypi samples/samples.gyp src/d8.gyp \ 231 test/cctest/cctest.gyp tools/gyp/v8.gyp 232 233# If vtunejit=on, the v8vtune.gyp will be appended. 234ifeq ($(vtunejit), on) 235 GYPFILES += src/third_party/vtune/v8vtune.gyp 236endif 237# Generates all combinations of ARCHES and MODES, e.g. "ia32.release". 238BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES))) 239ANDROID_BUILDS = $(foreach mode,$(MODES), \ 240 $(addsuffix .$(mode),$(ANDROID_ARCHES))) 241NACL_BUILDS = $(foreach mode,$(MODES), \ 242 $(addsuffix .$(mode),$(NACL_ARCHES))) 243# Generates corresponding test targets, e.g. "ia32.release.check". 244CHECKS = $(addsuffix .check,$(BUILDS)) 245ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS)) 246NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS)) 247# File where previously used GYPFLAGS are stored. 248ENVFILE = $(OUTDIR)/environment 249 250.PHONY: all check clean dependencies $(ENVFILE).new native \ 251 qc quickcheck \ 252 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \ 253 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \ 254 $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \ 255 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \ 256 $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \ 257 must-set-NACL_SDK_ROOT 258 259# Target definitions. "all" is the default. 260all: $(DEFAULT_MODES) 261 262# Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile 263# having been created before. 264buildbot: 265 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \ 266 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)" 267 268mips mips.release mips.debug: 269 @echo "V8 does not support big-endian MIPS builds at the moment," \ 270 "please use little-endian builds (mipsel)." 271 272# Compile targets. MODES and ARCHES are convenience targets. 273.SECONDEXPANSION: 274$(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES)) 275 276$(ARCHES): $(addprefix $$@.,$(MODES)) 277 278# Defines how to build a particular target (e.g. ia32.release). 279$(BUILDS): $(OUTDIR)/Makefile.$$@ 280 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \ 281 CXX="$(CXX)" LINK="$(LINK)" \ 282 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \ 283 python -c "print \ 284 raw_input().replace('opt', '').capitalize()") \ 285 builddir="$(shell pwd)/$(OUTDIR)/$@" 286 287native: $(OUTDIR)/Makefile.native 288 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \ 289 CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \ 290 builddir="$(shell pwd)/$(OUTDIR)/$@" 291 292$(ANDROID_ARCHES): $(addprefix $$@.,$(MODES)) 293 294$(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \ 295 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN Makefile.android 296 @$(MAKE) -f Makefile.android $@ \ 297 ARCH="$(basename $@)" \ 298 MODE="$(subst .,,$(suffix $@))" \ 299 OUTDIR="$(OUTDIR)" \ 300 GYPFLAGS="$(GYPFLAGS)" 301 302$(NACL_ARCHES): $(addprefix $$@.,$(MODES)) 303 304$(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \ 305 Makefile.nacl must-set-NACL_SDK_ROOT 306 @$(MAKE) -f Makefile.nacl $@ \ 307 ARCH="$(basename $@)" \ 308 MODE="$(subst .,,$(suffix $@))" \ 309 OUTDIR="$(OUTDIR)" \ 310 GYPFLAGS="$(GYPFLAGS)" 311 312# Test targets. 313check: all 314 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ 315 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \ 316 $(TESTFLAGS) 317 318$(addsuffix .check,$(MODES)): $$(basename $$@) 319 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ 320 --mode=$(basename $@) $(TESTFLAGS) 321 322$(addsuffix .check,$(ARCHES)): $$(basename $$@) 323 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ 324 --arch=$(basename $@) $(TESTFLAGS) 325 326$(CHECKS): $$(basename $$@) 327 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ 328 --arch-and-mode=$(basename $@) $(TESTFLAGS) 329 330$(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@) 331 @tools/android-sync.sh $(basename $@) $(OUTDIR) \ 332 $(shell pwd) $(ANDROID_V8) 333 334$(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync 335 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ 336 --arch-and-mode=$(basename $@) \ 337 --timeout=600 \ 338 --command-prefix="tools/android-run.py" $(TESTFLAGS) 339 340$(addsuffix .check, $(ANDROID_ARCHES)): \ 341 $(addprefix $$(basename $$@).,$(MODES)).check 342 343$(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@) 344 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ 345 --arch-and-mode=$(basename $@) \ 346 --timeout=600 --nopresubmit --noi18n \ 347 --command-prefix="tools/nacl-run.py" 348 349$(addsuffix .check, $(NACL_ARCHES)): \ 350 $(addprefix $$(basename $$@).,$(MODES)).check 351 352native.check: native 353 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \ 354 --arch-and-mode=. $(TESTFLAGS) 355 356FASTTESTMODES = ia32.release,x64.release,ia32.optdebug,x64.optdebug,arm.optdebug 357 358COMMA = , 359EMPTY = 360SPACE = $(EMPTY) $(EMPTY) 361quickcheck: $(subst $(COMMA),$(SPACE),$(FASTTESTMODES)) 362 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \ 363 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck 364qc: quickcheck 365 366# Clean targets. You can clean each architecture individually, or everything. 367$(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)): 368 rm -f $(OUTDIR)/Makefile.$(basename $@)* 369 rm -rf $(OUTDIR)/$(basename $@).release 370 rm -rf $(OUTDIR)/$(basename $@).debug 371 find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete 372 373native.clean: 374 rm -f $(OUTDIR)/Makefile.native 375 rm -rf $(OUTDIR)/native 376 find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete 377 378clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean 379 380# GYP file generation targets. 381OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS)) 382$(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE) 383 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \ 384 GYP_GENERATORS=make \ 385 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ 386 -Ibuild/standalone.gypi --depth=. \ 387 -Dv8_target_arch=$(subst .,,$(suffix $(basename $@))) \ 388 -Dv8_optimized_debug=$(if $(findstring optdebug,$@),2,0) \ 389 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS) 390 391$(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE) 392 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \ 393 GYP_GENERATORS=make \ 394 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ 395 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS) 396 397must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN: 398ifndef ANDROID_NDK_ROOT 399ifndef ANDROID_TOOLCHAIN 400 $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set)) 401endif 402endif 403 404# Note that NACL_SDK_ROOT must be set to point to an appropriate 405# Native Client SDK before using this makefile. You can download 406# an SDK here: 407# https://developers.google.com/native-client/sdk/download 408# The path indicated by NACL_SDK_ROOT will typically end with 409# a folder for a pepper version such as "pepper_25" that should 410# have "tools" and "toolchain" subdirectories. 411must-set-NACL_SDK_ROOT: 412ifndef NACL_SDK_ROOT 413 $(error NACL_SDK_ROOT must be set) 414endif 415 416# Replaces the old with the new environment file if they're different, which 417# will trigger GYP to regenerate Makefiles. 418$(ENVFILE): $(ENVFILE).new 419 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \ 420 then rm $(ENVFILE).new; \ 421 else mv $(ENVFILE).new $(ENVFILE); fi 422 423# Stores current GYPFLAGS in a file. 424$(ENVFILE).new: 425 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \ 426 echo "CXX=$(CXX)" >> $(ENVFILE).new 427 428# Heap constants for grokdump. 429DUMP_FILE = tools/v8heapconst.py 430grokdump: ia32.release 431 @cat $(DUMP_FILE).tmpl > $(DUMP_FILE) 432 @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE) 433 434# Dependencies. 435# Remember to keep these in sync with the DEPS file. 436dependencies: 437 svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \ 438 --revision 1685 439 svn checkout --force \ 440 https://src.chromium.org/chrome/trunk/deps/third_party/icu46 \ 441 third_party/icu --revision 214189 442