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 CXX ?= g++
     31 LINK ?= g++
     32 OUTDIR ?= out
     33 TESTJOBS ?=
     34 GYPFLAGS ?=
     35 TESTFLAGS ?=
     36 ANDROID_NDK_ROOT ?=
     37 ANDROID_NDK_HOST_ARCH ?=
     38 ANDROID_TOOLCHAIN ?=
     39 ANDROID_V8 ?= /data/local/tmp/v8
     40 NACL_SDK_ROOT ?=
     41 
     42 # Special build flags. Use them like this: "make library=shared"
     43 
     44 # library=shared || component=shared_library
     45 ifeq ($(library), shared)
     46   GYPFLAGS += -Dcomponent=shared_library
     47 endif
     48 ifdef component
     49   GYPFLAGS += -Dcomponent=$(component)
     50 endif
     51 # console=readline
     52 ifdef console
     53   GYPFLAGS += -Dconsole=$(console)
     54 endif
     55 # disassembler=on
     56 ifeq ($(disassembler), on)
     57   GYPFLAGS += -Dv8_enable_disassembler=1
     58 endif
     59 # objectprint=on
     60 ifeq ($(objectprint), on)
     61   GYPFLAGS += -Dv8_object_print=1
     62 endif
     63 # verifyheap=on
     64 ifeq ($(verifyheap), on)
     65   GYPFLAGS += -Dv8_enable_verify_heap=1
     66 endif
     67 # backtrace=off
     68 ifeq ($(backtrace), off)
     69   GYPFLAGS += -Dv8_enable_backtrace=0
     70 else
     71   GYPFLAGS += -Dv8_enable_backtrace=1
     72 endif
     73 # snapshot=off
     74 ifeq ($(snapshot), off)
     75   GYPFLAGS += -Dv8_use_snapshot='false'
     76 endif
     77 # extrachecks=on/off
     78 ifeq ($(extrachecks), on)
     79   GYPFLAGS += -Dv8_enable_extra_checks=1 -Dv8_enable_handle_zapping=1
     80 endif
     81 ifeq ($(extrachecks), off)
     82   GYPFLAGS += -Dv8_enable_extra_checks=0 -Dv8_enable_handle_zapping=0
     83 endif
     84 # gdbjit=on/off
     85 ifeq ($(gdbjit), on)
     86   GYPFLAGS += -Dv8_enable_gdbjit=1
     87 endif
     88 ifeq ($(gdbjit), off)
     89   GYPFLAGS += -Dv8_enable_gdbjit=0
     90 endif
     91 # vtunejit=on
     92 ifeq ($(vtunejit), on)
     93   GYPFLAGS += -Dv8_enable_vtunejit=1
     94 endif
     95 # optdebug=on
     96 ifeq ($(optdebug), on)
     97   GYPFLAGS += -Dv8_optimized_debug=2
     98 endif
     99 # debuggersupport=off
    100 ifeq ($(debuggersupport), off)
    101   GYPFLAGS += -Dv8_enable_debugger_support=0
    102 endif
    103 # unalignedaccess=on
    104 ifeq ($(unalignedaccess), on)
    105   GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
    106 endif
    107 # randomseed=12345, disable random seed via randomseed=0
    108 ifdef randomseed
    109   GYPFLAGS += -Dv8_random_seed=$(randomseed)
    110 endif
    111 # soname_version=1.2.3
    112 ifdef soname_version
    113   GYPFLAGS += -Dsoname_version=$(soname_version)
    114 endif
    115 # werror=no
    116 ifeq ($(werror), no)
    117   GYPFLAGS += -Dwerror=''
    118 endif
    119 # presubmit=no
    120 ifeq ($(presubmit), no)
    121   TESTFLAGS += --no-presubmit
    122 endif
    123 # strictaliasing=off (workaround for GCC-4.5)
    124 ifeq ($(strictaliasing), off)
    125   GYPFLAGS += -Dv8_no_strict_aliasing=1
    126 endif
    127 # regexp=interpreted
    128 ifeq ($(regexp), interpreted)
    129   GYPFLAGS += -Dv8_interpreted_regexp=1
    130 endif
    131 # i18nsupport=off
    132 ifeq ($(i18nsupport), off)
    133   GYPFLAGS += -Dv8_enable_i18n_support=0
    134   TESTFLAGS += --noi18n
    135 endif
    136 # deprecation_warnings=on
    137 ifeq ($(deprecationwarnings), on)
    138   GYPFLAGS += -Dv8_deprecation_warnings=1
    139 endif 
    140 # arm specific flags.
    141 # armv7=false/true
    142 ifeq ($(armv7), false)
    143   GYPFLAGS += -Darmv7=0
    144 else
    145 ifeq ($(armv7), true)
    146   GYPFLAGS += -Darmv7=1
    147 endif
    148 endif
    149 # vfp2=off. Deprecated, use armfpu=
    150 # vfp3=off. Deprecated, use armfpu=
    151 ifeq ($(vfp3), off)
    152   GYPFLAGS += -Darm_fpu=vfp
    153 endif
    154 # hardfp=on/off. Deprecated, use armfloatabi
    155 ifeq ($(hardfp),on)
    156   GYPFLAGS += -Darm_float_abi=hard
    157 else
    158 ifeq ($(hardfp),off)
    159   GYPFLAGS += -Darm_float_abi=softfp
    160 endif
    161 endif
    162 # armneon=on/off
    163 ifeq ($(armneon), on)
    164   GYPFLAGS += -Darm_neon=1
    165 endif
    166 # fpu: armfpu=xxx
    167 # xxx: vfp, vfpv3-d16, vfpv3, neon.
    168 ifeq ($(armfpu),)
    169 ifneq ($(vfp3), off)
    170   GYPFLAGS += -Darm_fpu=default
    171 endif
    172 else
    173   GYPFLAGS += -Darm_fpu=$(armfpu)
    174 endif
    175 # float abi: armfloatabi=softfp/hard
    176 ifeq ($(armfloatabi),)
    177 ifeq ($(hardfp),)
    178   GYPFLAGS += -Darm_float_abi=default
    179 endif
    180 else
    181   GYPFLAGS += -Darm_float_abi=$(armfloatabi)
    182 endif
    183 # armthumb=on/off
    184 ifeq ($(armthumb), off)
    185   GYPFLAGS += -Darm_thumb=0
    186 else
    187 ifeq ($(armthumb), on)
    188   GYPFLAGS += -Darm_thumb=1
    189 endif
    190 endif
    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.
    198 ifeq ($(armtest), on)
    199   GYPFLAGS += -Darm_test=on
    200 endif
    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).
    221 ARCHES = ia32 x64 arm mipsel
    222 DEFAULT_ARCHES = ia32 x64 arm
    223 MODES = release debug optdebug
    224 DEFAULT_MODES = release debug
    225 ANDROID_ARCHES = android_ia32 android_arm android_mipsel
    226 NACL_ARCHES = nacl_ia32 nacl_x64
    227 
    228 # List of files that trigger Makefile regeneration:
    229 GYPFILES = 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.
    234 ifeq ($(vtunejit), on)
    235   GYPFILES += src/third_party/vtune/v8vtune.gyp
    236 endif
    237 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
    238 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
    239 ANDROID_BUILDS = $(foreach mode,$(MODES), \
    240                    $(addsuffix .$(mode),$(ANDROID_ARCHES)))
    241 NACL_BUILDS = $(foreach mode,$(MODES), \
    242                    $(addsuffix .$(mode),$(NACL_ARCHES)))
    243 # Generates corresponding test targets, e.g. "ia32.release.check".
    244 CHECKS = $(addsuffix .check,$(BUILDS))
    245 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
    246 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
    247 # File where previously used GYPFLAGS are stored.
    248 ENVFILE = $(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.
    260 all: $(DEFAULT_MODES)
    261 
    262 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
    263 # having been created before.
    264 buildbot:
    265 	$(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
    266 	        builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
    267 
    268 mips 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 
    287 native: $(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.
    313 check: 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 
    352 native.check: native
    353 	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
    354 	    --arch-and-mode=. $(TESTFLAGS)
    355 
    356 FASTTESTMODES = ia32.release,x64.release,ia32.optdebug,x64.optdebug,arm.optdebug
    357 
    358 COMMA = ,
    359 EMPTY =
    360 SPACE = $(EMPTY) $(EMPTY)
    361 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTTESTMODES))
    362 	tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
    363 	    --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
    364 qc: 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 
    373 native.clean:
    374 	rm -f $(OUTDIR)/Makefile.native
    375 	rm -rf $(OUTDIR)/native
    376 	find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
    377 
    378 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean
    379 
    380 # GYP file generation targets.
    381 OUT_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 
    397 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
    398 ifndef ANDROID_NDK_ROOT
    399 ifndef ANDROID_TOOLCHAIN
    400 	  $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
    401 endif
    402 endif
    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.
    411 must-set-NACL_SDK_ROOT:
    412 ifndef NACL_SDK_ROOT
    413 	  $(error NACL_SDK_ROOT must be set)
    414 endif
    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.
    429 DUMP_FILE = tools/v8heapconst.py
    430 grokdump: 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.
    436 dependencies:
    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