Home | History | Annotate | Download | only in v8
      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.
     30 OUTDIR ?= out
     31 TESTJOBS ?=
     32 GYPFLAGS ?=
     33 TESTFLAGS ?=
     34 ANDROID_NDK_HOST_ARCH ?=
     35 ANDROID_V8 ?= /data/local/tmp/v8
     36 NACL_SDK_ROOT ?=
     37 
     38 # Special build flags. Use them like this: "make library=shared"
     39 
     40 # library=shared || component=shared_library
     41 ifeq ($(library), shared)
     42   GYPFLAGS += -Dcomponent=shared_library
     43 endif
     44 ifdef component
     45   GYPFLAGS += -Dcomponent=$(component)
     46 endif
     47 # disassembler=on
     48 ifeq ($(disassembler), on)
     49   GYPFLAGS += -Dv8_enable_disassembler=1
     50 endif
     51 # objectprint=on
     52 ifeq ($(objectprint), on)
     53   GYPFLAGS += -Dv8_object_print=1
     54 endif
     55 # verifyheap=on
     56 ifeq ($(verifyheap), on)
     57   GYPFLAGS += -Dv8_enable_verify_heap=1
     58 endif
     59 # tracemaps=on
     60 ifeq ($(tracemaps), on)
     61   GYPFLAGS += -Dv8_trace_maps=1
     62 endif
     63 # backtrace=off
     64 ifeq ($(backtrace), off)
     65   GYPFLAGS += -Dv8_enable_backtrace=0
     66 else
     67   GYPFLAGS += -Dv8_enable_backtrace=1
     68 endif
     69 # verifypredictable=on
     70 ifeq ($(verifypredictable), on)
     71   GYPFLAGS += -Dv8_enable_verify_predictable=1
     72 endif
     73 # snapshot=off
     74 ifeq ($(snapshot), off)
     75   GYPFLAGS += -Dv8_use_snapshot='false'
     76 endif
     77 ifeq ($(snapshot), external)
     78   GYPFLAGS += -Dv8_use_external_startup_data=1
     79 endif
     80 # extrachecks=on/off
     81 ifeq ($(extrachecks), on)
     82   GYPFLAGS += -Ddcheck_always_on=1 -Dv8_enable_handle_zapping=1
     83 endif
     84 ifeq ($(extrachecks), off)
     85   GYPFLAGS += -Ddcheck_always_on=0 -Dv8_enable_handle_zapping=0
     86 endif
     87 # slowdchecks=on/off
     88 ifeq ($(slowdchecks), on)
     89   GYPFLAGS += -Dv8_enable_slow_dchecks=1
     90 endif
     91 ifeq ($(slowdchecks), off)
     92   GYPFLAGS += -Dv8_enable_slow_dchecks=0
     93 endif
     94 # debugsymbols=on
     95 ifeq ($(debugsymbols), on)
     96   GYPFLAGS += -Drelease_extra_cflags=-ggdb3
     97 endif
     98 # gdbjit=on/off
     99 ifeq ($(gdbjit), on)
    100   GYPFLAGS += -Dv8_enable_gdbjit=1
    101 endif
    102 ifeq ($(gdbjit), off)
    103   GYPFLAGS += -Dv8_enable_gdbjit=0
    104 endif
    105 # vtunejit=on
    106 ifeq ($(vtunejit), on)
    107   GYPFLAGS += -Dv8_enable_vtunejit=1
    108 endif
    109 # unalignedaccess=on
    110 ifeq ($(unalignedaccess), on)
    111   GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
    112 endif
    113 # randomseed=12345, disable random seed via randomseed=0
    114 ifdef randomseed
    115   GYPFLAGS += -Dv8_random_seed=$(randomseed)
    116 endif
    117 # soname_version=1.2.3
    118 ifdef soname_version
    119   GYPFLAGS += -Dsoname_version=$(soname_version)
    120 endif
    121 # werror=no
    122 ifeq ($(werror), no)
    123   GYPFLAGS += -Dwerror=''
    124 endif
    125 # presubmit=no
    126 ifeq ($(presubmit), no)
    127   TESTFLAGS += --no-presubmit
    128 endif
    129 # strictaliasing=off (workaround for GCC-4.5)
    130 ifeq ($(strictaliasing), off)
    131   GYPFLAGS += -Dv8_no_strict_aliasing=1
    132 endif
    133 # regexp=interpreted
    134 ifeq ($(regexp), interpreted)
    135   GYPFLAGS += -Dv8_interpreted_regexp=1
    136 endif
    137 # i18nsupport=off
    138 ifeq ($(i18nsupport), off)
    139   GYPFLAGS += -Dv8_enable_i18n_support=0
    140   TESTFLAGS += --noi18n
    141 endif
    142 # deprecationwarnings=on
    143 ifeq ($(deprecationwarnings), on)
    144   GYPFLAGS += -Dv8_deprecation_warnings=1
    145 endif
    146 # vectorstores=on
    147 ifeq ($(vectorstores), on)
    148   GYPFLAGS += -Dv8_vector_stores=1
    149 endif
    150 # imminentdeprecationwarnings=on
    151 ifeq ($(imminentdeprecationwarnings), on)
    152   GYPFLAGS += -Dv8_imminent_deprecation_warnings=1
    153 endif
    154 # asan=on
    155 ifeq ($(asan), on)
    156   GYPFLAGS += -Dasan=1 -Dclang=1
    157   TESTFLAGS += --asan
    158   ifeq ($(lsan), on)
    159     GYPFLAGS += -Dlsan=1
    160   endif
    161 endif
    162 ifdef embedscript
    163   GYPFLAGS += -Dembed_script=$(embedscript)
    164 endif
    165 ifdef warmupscript
    166   GYPFLAGS += -Dwarmup_script=$(warmupscript)
    167 endif
    168 ifeq ($(goma), on)
    169   GYPFLAGS += -Duse_goma=1
    170 endif
    171 # arm specific flags.
    172 # arm_version=<number | "default">
    173 ifneq ($(strip $(arm_version)),)
    174   GYPFLAGS += -Darm_version=$(arm_version)
    175 else
    176 # Deprecated (use arm_version instead): armv7=false/true
    177 ifeq ($(armv7), false)
    178   GYPFLAGS += -Darm_version=6
    179 else
    180 ifeq ($(armv7), true)
    181   GYPFLAGS += -Darm_version=7
    182 endif
    183 endif
    184 endif
    185 # hardfp=on/off. Deprecated, use armfloatabi
    186 ifeq ($(hardfp),on)
    187   GYPFLAGS += -Darm_float_abi=hard
    188 else
    189 ifeq ($(hardfp),off)
    190   GYPFLAGS += -Darm_float_abi=softfp
    191 endif
    192 endif
    193 # fpu: armfpu=xxx
    194 # xxx: vfp, vfpv3-d16, vfpv3, neon.
    195 ifeq ($(armfpu),)
    196   GYPFLAGS += -Darm_fpu=default
    197 else
    198   GYPFLAGS += -Darm_fpu=$(armfpu)
    199 endif
    200 # float abi: armfloatabi=softfp/hard
    201 ifeq ($(armfloatabi),)
    202 ifeq ($(hardfp),)
    203   GYPFLAGS += -Darm_float_abi=default
    204 endif
    205 else
    206   GYPFLAGS += -Darm_float_abi=$(armfloatabi)
    207 endif
    208 # armthumb=on/off
    209 ifeq ($(armthumb), off)
    210   GYPFLAGS += -Darm_thumb=0
    211 else
    212 ifeq ($(armthumb), on)
    213   GYPFLAGS += -Darm_thumb=1
    214 endif
    215 endif
    216 # arm_test_noprobe=on
    217 # With this flag set, by default v8 will only use features implied
    218 # by the compiler (no probe). This is done by modifying the default
    219 # values of enable_armv7, enable_vfp3, enable_32dregs and enable_neon.
    220 # Modifying these flags when launching v8 will enable the probing for
    221 # the specified values.
    222 ifeq ($(arm_test_noprobe), on)
    223   GYPFLAGS += -Darm_test_noprobe=on
    224 endif
    225 # Do not omit the frame pointer, needed for profiling with perf
    226 ifeq ($(no_omit_framepointer), on)
    227   GYPFLAGS += -Drelease_extra_cflags=-fno-omit-frame-pointer
    228 endif
    229 
    230 ifdef android_ndk_root
    231   GYPFLAGS += -Dandroid_ndk_root=$(android_ndk_root)
    232   export ANDROID_NDK_ROOT = $(android_ndk_root)
    233 endif
    234 
    235 # ----------------- available targets: --------------------
    236 # - "grokdump": rebuilds heap constants lists used by grokdump
    237 # - any arch listed in ARCHES (see below)
    238 # - any mode listed in MODES
    239 # - every combination <arch>.<mode>, e.g. "ia32.release"
    240 # - "native": current host's architecture, release mode
    241 # - any of the above with .check appended, e.g. "ia32.release.check"
    242 # - "android": cross-compile for Android/ARM
    243 # - "nacl" : cross-compile for Native Client (ia32 and x64)
    244 # - default (no target specified): build all DEFAULT_ARCHES and MODES
    245 # - "check": build all targets and run all tests
    246 # - "<arch>.clean" for any <arch> in ARCHES
    247 # - "clean": clean all ARCHES
    248 
    249 # ----------------- internal stuff ------------------------
    250 
    251 # Architectures and modes to be compiled. Consider these to be internal
    252 # variables, don't override them (use the targets instead).
    253 ARCHES = ia32 x64 arm arm64 mips mipsel mips64 mips64el x87 ppc ppc64 s390 \
    254          s390x
    255 ARCHES32 = ia32 arm mips mipsel x87 ppc s390
    256 DEFAULT_ARCHES = ia32 x64 arm
    257 MODES = release debug optdebug
    258 DEFAULT_MODES = release debug
    259 ANDROID_ARCHES = android_ia32 android_x64 android_arm android_arm64 \
    260 		 android_mipsel android_x87
    261 NACL_ARCHES = nacl_ia32 nacl_x64
    262 
    263 # List of files that trigger Makefile regeneration:
    264 GYPFILES = third_party/icu/icu.gypi third_party/icu/icu.gyp \
    265 	   gypfiles/shim_headers.gypi gypfiles/features.gypi \
    266            gypfiles/standalone.gypi \
    267 	   gypfiles/toolchain.gypi gypfiles/all.gyp gypfiles/mac/asan.gyp \
    268 	   test/cctest/cctest.gyp test/fuzzer/fuzzer.gyp \
    269 	   test/unittests/unittests.gyp src/v8.gyp \
    270 	   tools/parser-shell.gyp testing/gmock.gyp testing/gtest.gyp \
    271 	   buildtools/third_party/libc++abi/libc++abi.gyp \
    272 	   buildtools/third_party/libc++/libc++.gyp samples/samples.gyp \
    273 	   src/third_party/vtune/v8vtune.gyp src/d8.gyp
    274 
    275 # If vtunejit=on, the v8vtune.gyp will be appended.
    276 ifeq ($(vtunejit), on)
    277   GYPFILES += src/third_party/vtune/v8vtune.gyp
    278 endif
    279 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
    280 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
    281 ANDROID_BUILDS = $(foreach mode,$(MODES), \
    282                    $(addsuffix .$(mode),$(ANDROID_ARCHES)))
    283 NACL_BUILDS = $(foreach mode,$(MODES), \
    284                    $(addsuffix .$(mode),$(NACL_ARCHES)))
    285 # Generates corresponding test targets, e.g. "ia32.release.check".
    286 CHECKS = $(addsuffix .check,$(BUILDS))
    287 QUICKCHECKS = $(addsuffix .quickcheck,$(BUILDS))
    288 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
    289 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
    290 # File where previously used GYPFLAGS are stored.
    291 ENVFILE = $(OUTDIR)/environment
    292 
    293 .PHONY: all check clean builddeps dependencies $(ENVFILE).new native \
    294         qc quickcheck $(QUICKCHECKS) turbocheck \
    295         $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \
    296         $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
    297         $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
    298         $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
    299         $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
    300         must-set-NACL_SDK_ROOT
    301 
    302 # Target definitions. "all" is the default.
    303 all: $(DEFAULT_MODES)
    304 
    305 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
    306 # having been created before.
    307 buildbot:
    308 	$(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
    309 	        builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
    310 
    311 # Compile targets. MODES and ARCHES are convenience targets.
    312 .SECONDEXPANSION:
    313 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
    314 
    315 $(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
    316 
    317 # Defines how to build a particular target (e.g. ia32.release).
    318 $(BUILDS): $(OUTDIR)/Makefile.$$@
    319 	@$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
    320 	         BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
    321 	                     python -c "print \
    322 	                     raw_input().replace('opt', '').capitalize()") \
    323 	         builddir="$(shell pwd)/$(OUTDIR)/$@"
    324 
    325 native: $(OUTDIR)/Makefile.native
    326 	@$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
    327 	         BUILDTYPE=Release \
    328 	         builddir="$(shell pwd)/$(OUTDIR)/$@"
    329 
    330 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
    331 
    332 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) Makefile.android
    333 	@$(MAKE) -f Makefile.android $@ \
    334 	        ARCH="$(basename $@)" \
    335 	        MODE="$(subst .,,$(suffix $@))" \
    336 	        OUTDIR="$(OUTDIR)" \
    337 	        GYPFLAGS="$(GYPFLAGS)"
    338 
    339 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
    340 
    341 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
    342 		   Makefile.nacl must-set-NACL_SDK_ROOT
    343 	@$(MAKE) -f Makefile.nacl $@ \
    344 	        ARCH="$(basename $@)" \
    345 	        MODE="$(subst .,,$(suffix $@))" \
    346 	        OUTDIR="$(OUTDIR)" \
    347 	        GYPFLAGS="$(GYPFLAGS)"
    348 
    349 # Test targets.
    350 check: all
    351 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    352 	    --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
    353 	    $(TESTFLAGS)
    354 
    355 $(addsuffix .check,$(MODES)): $$(basename $$@)
    356 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    357 	    --mode=$(basename $@) $(TESTFLAGS)
    358 
    359 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
    360 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    361 	    --arch=$(basename $@) $(TESTFLAGS)
    362 
    363 $(CHECKS): $$(basename $$@)
    364 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    365 	    --arch-and-mode=$(basename $@) $(TESTFLAGS)
    366 
    367 $(addsuffix .quickcheck,$(MODES)): $$(basename $$@)
    368 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    369 	    --mode=$(basename $@) $(TESTFLAGS) --quickcheck
    370 
    371 $(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@)
    372 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    373 	    --arch=$(basename $@) $(TESTFLAGS) --quickcheck
    374 
    375 $(QUICKCHECKS): $$(basename $$@)
    376 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    377 	    --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck
    378 
    379 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
    380 	@tools/android-sync.sh $(basename $@) $(OUTDIR) \
    381 	                       $(shell pwd) $(ANDROID_V8)
    382 
    383 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
    384 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    385 	     --arch-and-mode=$(basename $@) \
    386 	     --timeout=600 \
    387 	     --command-prefix="tools/android-run.py" $(TESTFLAGS)
    388 
    389 $(addsuffix .check, $(ANDROID_ARCHES)): \
    390                 $(addprefix $$(basename $$@).,$(MODES)).check
    391 
    392 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
    393 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    394 	     --arch-and-mode=$(basename $@) \
    395 	     --timeout=600 --nopresubmit --noi18n \
    396 	     --command-prefix="tools/nacl-run.py"
    397 
    398 $(addsuffix .check, $(NACL_ARCHES)): \
    399                 $(addprefix $$(basename $$@).,$(MODES)).check
    400 
    401 native.check: native
    402 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
    403 	    --arch-and-mode=. $(TESTFLAGS)
    404 
    405 SUPERFASTTESTMODES = ia32.release
    406 FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release
    407 FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug
    408 
    409 COMMA = ,
    410 EMPTY =
    411 SPACE = $(EMPTY) $(EMPTY)
    412 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
    413 	tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    414 	    --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \
    415 	    --download-data mozilla webkit
    416 	tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    417 	    --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
    418 qc: quickcheck
    419 
    420 turbocheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
    421 	tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    422 	    --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) \
    423 	    --quickcheck --variants=turbofan --download-data mozilla webkit
    424 	tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    425 	    --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) \
    426 	    --quickcheck --variants=turbofan
    427 tc: turbocheck
    428 
    429 # Clean targets. You can clean each architecture individually, or everything.
    430 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
    431 	rm -f $(OUTDIR)/Makefile.$(basename $@)*
    432 	rm -rf $(OUTDIR)/$(basename $@).release
    433 	rm -rf $(OUTDIR)/$(basename $@).debug
    434 	rm -rf $(OUTDIR)/$(basename $@).optdebug
    435 	find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
    436 
    437 native.clean:
    438 	rm -f $(OUTDIR)/Makefile.native
    439 	rm -rf $(OUTDIR)/native
    440 	find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
    441 
    442 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean gtags.clean tags.clean
    443 
    444 # GYP file generation targets.
    445 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
    446 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
    447 	$(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
    448 	        cut -f 2 -d " " | cut -f 1 -d "-" ))
    449 	$(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
    450 	$(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
    451 	$(eval CXX_TARGET_ARCH:=$(subst s390x,s390,$(CXX_TARGET_ARCH)))
    452 	$(eval CXX_TARGET_ARCH:=$(subst powerpc,ppc,$(CXX_TARGET_ARCH)))
    453 	$(eval CXX_TARGET_ARCH:=$(subst ppc64,ppc,$(CXX_TARGET_ARCH)))
    454 	$(eval CXX_TARGET_ARCH:=$(subst ppcle,ppc,$(CXX_TARGET_ARCH)))
    455 	$(eval V8_TARGET_ARCH:=$(subst .,,$(suffix $(basename $@))))
    456 	PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/gypfiles:$(PYTHONPATH):$(shell pwd)/tools/gyp/pylib:$(PYTHONPATH)" \
    457 	GYP_GENERATORS=make \
    458 	tools/gyp/gyp --generator-output="$(OUTDIR)" gypfiles/all.gyp \
    459 	              -Igypfiles/standalone.gypi --depth=. \
    460 	              -Dv8_target_arch=$(V8_TARGET_ARCH) \
    461 	              $(if $(findstring $(CXX_TARGET_ARCH),$(V8_TARGET_ARCH)), \
    462 	              -Dtarget_arch=$(V8_TARGET_ARCH), \
    463 	                  $(if $(shell echo $(ARCHES32) | grep $(V8_TARGET_ARCH)), \
    464 	                  -Dtarget_arch=ia32,)) \
    465 	              $(if $(findstring optdebug,$@),-Dv8_optimized_debug=1,) \
    466 	              -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
    467 
    468 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
    469 	PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/gypfiles:$(PYTHONPATH):$(shell pwd)/tools/gyp/pylib:$(PYTHONPATH)" \
    470 	GYP_GENERATORS=make \
    471 	tools/gyp/gyp --generator-output="$(OUTDIR)" gypfiles/all.gyp \
    472 	              -Igypfiles/standalone.gypi --depth=. -S.native $(GYPFLAGS)
    473 
    474 # Note that NACL_SDK_ROOT must be set to point to an appropriate
    475 # Native Client SDK before using this makefile. You can download
    476 # an SDK here:
    477 #   https://developers.google.com/native-client/sdk/download
    478 # The path indicated by NACL_SDK_ROOT will typically end with
    479 # a folder for a pepper version such as "pepper_25" that should
    480 # have "tools" and "toolchain" subdirectories.
    481 must-set-NACL_SDK_ROOT:
    482 ifndef NACL_SDK_ROOT
    483 	  $(error NACL_SDK_ROOT must be set)
    484 endif
    485 
    486 # Replaces the old with the new environment file if they're different, which
    487 # will trigger GYP to regenerate Makefiles.
    488 $(ENVFILE): $(ENVFILE).new
    489 	@if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
    490 	    then rm $(ENVFILE).new; \
    491 	    else mv $(ENVFILE).new $(ENVFILE); fi
    492 
    493 # Stores current GYPFLAGS in a file.
    494 $(ENVFILE).new:
    495 	$(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
    496 	        cut -f 2 -d " " | cut -f 1 -d "-" ))
    497 	$(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
    498 	$(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
    499 	@mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS) -Dtarget_arch=$(CXX_TARGET_ARCH)" > $(ENVFILE).new;
    500 
    501 # Heap constants for grokdump.
    502 DUMP_FILE = tools/v8heapconst.py
    503 grokdump: ia32.release
    504 	@cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
    505 	@$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
    506 
    507 # Support for the GNU GLOBAL Source Code Tag System.
    508 gtags.files: $(GYPFILES) $(ENVFILE)
    509 	@find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@
    510 
    511 # We need to manually set the stack limit here, to work around bugs in
    512 # gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
    513 # Using $(wildcard ...) gracefully ignores non-existing files, so that stale
    514 # gtags.files after switching branches don't cause recipe failures.
    515 GPATH GRTAGS GSYMS GTAGS: gtags.files $(wildcard $(shell cat gtags.files 2> /dev/null))
    516 	@bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
    517 
    518 gtags.clean:
    519 	rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
    520 
    521 tags: gtags.files $(wildcard $(shell cat gtags.files 2> /dev/null))
    522 	@(ctags --version | grep 'Exuberant Ctags' >/dev/null) || \
    523 		(echo "Please install Exuberant Ctags (check 'ctags --version')" >&2; false)
    524 	ctags --fields=+l -L $<
    525 
    526 tags.clean:
    527 	rm -r tags
    528 
    529 dependencies builddeps:
    530 	$(error Use 'gclient sync' instead)
    531