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
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.
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.
29 # Variable default definitions. Override them by exporting them in your shell.
34 ANDROID_NDK_HOST_ARCH ?=
35 ANDROID_V8 ?= /data/local/tmp/v8
38 # Special build flags. Use them like this: "make library=shared"
40 # library=shared || component=shared_library
41 ifeq ($(library), shared)
42 GYPFLAGS += -Dcomponent=shared_library
45 GYPFLAGS += -Dcomponent=$(component)
48 ifeq ($(disassembler), on)
49 GYPFLAGS += -Dv8_enable_disassembler=1
52 ifeq ($(objectprint), on)
53 GYPFLAGS += -Dv8_object_print=1
56 ifeq ($(verifyheap), on)
57 GYPFLAGS += -Dv8_enable_verify_heap=1
60 ifeq ($(tracemaps), on)
61 GYPFLAGS += -Dv8_trace_maps=1
64 ifeq ($(backtrace), off)
65 GYPFLAGS += -Dv8_enable_backtrace=0
67 GYPFLAGS += -Dv8_enable_backtrace=1
69 # verifypredictable=on
70 ifeq ($(verifypredictable), on)
71 GYPFLAGS += -Dv8_enable_verify_predictable=1
74 ifeq ($(snapshot), off)
75 GYPFLAGS += -Dv8_use_snapshot='false'
77 ifeq ($(snapshot), external)
78 GYPFLAGS += -Dv8_use_external_startup_data=1
81 ifeq ($(extrachecks), on)
82 GYPFLAGS += -Ddcheck_always_on=1 -Dv8_enable_handle_zapping=1
84 ifeq ($(extrachecks), off)
85 GYPFLAGS += -Ddcheck_always_on=0 -Dv8_enable_handle_zapping=0
88 ifeq ($(slowdchecks), on)
89 GYPFLAGS += -Dv8_enable_slow_dchecks=1
91 ifeq ($(slowdchecks), off)
92 GYPFLAGS += -Dv8_enable_slow_dchecks=0
95 ifeq ($(debugsymbols), on)
96 GYPFLAGS += -Drelease_extra_cflags=-ggdb3
100 GYPFLAGS += -Dv8_enable_gdbjit=1
102 ifeq ($(gdbjit), off)
103 GYPFLAGS += -Dv8_enable_gdbjit=0
106 ifeq ($(vtunejit), on)
107 GYPFLAGS += -Dv8_enable_vtunejit=1
110 ifeq ($(unalignedaccess), on)
111 GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
113 # randomseed=12345, disable random seed via randomseed=0
115 GYPFLAGS += -Dv8_random_seed=$(randomseed)
117 # soname_version=1.2.3
119 GYPFLAGS += -Dsoname_version=$(soname_version)
123 GYPFLAGS += -Dwerror=''
126 ifeq ($(presubmit), no)
127 TESTFLAGS += --no-presubmit
129 # strictaliasing=off (workaround for GCC-4.5)
130 ifeq ($(strictaliasing), off)
131 GYPFLAGS += -Dv8_no_strict_aliasing=1
134 ifeq ($(regexp), interpreted)
135 GYPFLAGS += -Dv8_interpreted_regexp=1
138 ifeq ($(i18nsupport), off)
139 GYPFLAGS += -Dv8_enable_i18n_support=0
140 TESTFLAGS += --noi18n
142 # deprecationwarnings=on
143 ifeq ($(deprecationwarnings), on)
144 GYPFLAGS += -Dv8_deprecation_warnings=1
147 ifeq ($(vectorstores), on)
148 GYPFLAGS += -Dv8_vector_stores=1
150 # imminentdeprecationwarnings=on
151 ifeq ($(imminentdeprecationwarnings), on)
152 GYPFLAGS += -Dv8_imminent_deprecation_warnings=1
156 GYPFLAGS += -Dasan=1 -Dclang=1
163 GYPFLAGS += -Dembed_script=$(embedscript)
166 GYPFLAGS += -Duse_goma=1
168 # arm specific flags.
169 # arm_version=<number | "default">
170 ifneq ($(strip $(arm_version)),)
171 GYPFLAGS += -Darm_version=$(arm_version)
173 # Deprecated (use arm_version instead): armv7=false/true
174 ifeq ($(armv7), false)
175 GYPFLAGS += -Darm_version=6
177 ifeq ($(armv7), true)
178 GYPFLAGS += -Darm_version=7
182 # hardfp=on/off. Deprecated, use armfloatabi
184 GYPFLAGS += -Darm_float_abi=hard
187 GYPFLAGS += -Darm_float_abi=softfp
191 # xxx: vfp, vfpv3-d16, vfpv3, neon.
193 GYPFLAGS += -Darm_fpu=default
195 GYPFLAGS += -Darm_fpu=$(armfpu)
197 # float abi: armfloatabi=softfp/hard
198 ifeq ($(armfloatabi),)
200 GYPFLAGS += -Darm_float_abi=default
203 GYPFLAGS += -Darm_float_abi=$(armfloatabi)
206 ifeq ($(armthumb), off)
207 GYPFLAGS += -Darm_thumb=0
209 ifeq ($(armthumb), on)
210 GYPFLAGS += -Darm_thumb=1
213 # arm_test_noprobe=on
214 # With this flag set, by default v8 will only use features implied
215 # by the compiler (no probe). This is done by modifying the default
216 # values of enable_armv7, enable_vfp3, enable_32dregs and enable_neon.
217 # Modifying these flags when launching v8 will enable the probing for
218 # the specified values.
219 ifeq ($(arm_test_noprobe), on)
220 GYPFLAGS += -Darm_test_noprobe=on
223 # Optionally enable wasm prototype.
224 # Assume you've placed a link to v8-native-prototype in third_party/wasm.
226 GYPFLAGS += -Dv8_wasm=1
229 # ----------------- available targets: --------------------
230 # - "grokdump": rebuilds heap constants lists used by grokdump
231 # - any arch listed in ARCHES (see below)
232 # - any mode listed in MODES
233 # - every combination <arch>.<mode>, e.g. "ia32.release"
234 # - "native": current host's architecture, release mode
235 # - any of the above with .check appended, e.g. "ia32.release.check"
236 # - "android": cross-compile for Android/ARM
237 # - "nacl" : cross-compile for Native Client (ia32 and x64)
238 # - default (no target specified): build all DEFAULT_ARCHES and MODES
239 # - "check": build all targets and run all tests
240 # - "<arch>.clean" for any <arch> in ARCHES
241 # - "clean": clean all ARCHES
243 # ----------------- internal stuff ------------------------
245 # Architectures and modes to be compiled. Consider these to be internal
246 # variables, don't override them (use the targets instead).
247 ARCHES = ia32 x64 x32 arm arm64 mips mipsel mips64el x87 ppc ppc64
248 DEFAULT_ARCHES = ia32 x64 arm
249 MODES = release debug optdebug
250 DEFAULT_MODES = release debug
251 ANDROID_ARCHES = android_ia32 android_x64 android_arm android_arm64 \
252 android_mipsel android_x87
253 NACL_ARCHES = nacl_ia32 nacl_x64
255 # List of files that trigger Makefile regeneration:
256 GYPFILES = third_party/icu/icu.gypi third_party/icu/icu.gyp \
257 build/shim_headers.gypi build/features.gypi build/standalone.gypi \
258 build/toolchain.gypi build/all.gyp build/mac/asan.gyp \
259 test/cctest/cctest.gyp \
260 test/unittests/unittests.gyp tools/gyp/v8.gyp \
261 tools/parser-shell.gyp testing/gmock.gyp testing/gtest.gyp \
262 buildtools/third_party/libc++abi/libc++abi.gyp \
263 buildtools/third_party/libc++/libc++.gyp samples/samples.gyp \
264 src/third_party/vtune/v8vtune.gyp src/d8.gyp
266 # If vtunejit=on, the v8vtune.gyp will be appended.
267 ifeq ($(vtunejit), on)
268 GYPFILES += src/third_party/vtune/v8vtune.gyp
270 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
271 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
272 ANDROID_BUILDS = $(foreach mode,$(MODES), \
273 $(addsuffix .$(mode),$(ANDROID_ARCHES)))
274 NACL_BUILDS = $(foreach mode,$(MODES), \
275 $(addsuffix .$(mode),$(NACL_ARCHES)))
276 # Generates corresponding test targets, e.g. "ia32.release.check".
277 CHECKS = $(addsuffix .check,$(BUILDS))
278 QUICKCHECKS = $(addsuffix .quickcheck,$(BUILDS))
279 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
280 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
281 # File where previously used GYPFLAGS are stored.
282 ENVFILE = $(OUTDIR)/environment
284 .PHONY: all check clean builddeps dependencies $(ENVFILE).new native \
285 qc quickcheck $(QUICKCHECKS) turbocheck \
286 $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \
287 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
288 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
289 $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
290 $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
291 must-set-NACL_SDK_ROOT
293 # Target definitions. "all" is the default.
294 all: $(DEFAULT_MODES)
296 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
297 # having been created before.
299 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
300 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
302 # Compile targets. MODES and ARCHES are convenience targets.
304 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
306 $(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
308 # Defines how to build a particular target (e.g. ia32.release).
309 $(BUILDS): $(OUTDIR)/Makefile.$$@
310 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
311 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
313 raw_input().replace('opt', '').capitalize()") \
314 builddir="$(shell pwd)/$(OUTDIR)/$@"
316 native: $(OUTDIR)/Makefile.native
317 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
319 builddir="$(shell pwd)/$(OUTDIR)/$@"
321 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
323 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) Makefile.android
324 @$(MAKE) -f Makefile.android $@ \
325 ARCH="$(basename $@)" \
326 MODE="$(subst .,,$(suffix $@))" \
328 GYPFLAGS="$(GYPFLAGS)"
330 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
332 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
333 Makefile.nacl must-set-NACL_SDK_ROOT
334 @$(MAKE) -f Makefile.nacl $@ \
335 ARCH="$(basename $@)" \
336 MODE="$(subst .,,$(suffix $@))" \
338 GYPFLAGS="$(GYPFLAGS)"
342 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
343 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
346 $(addsuffix .check,$(MODES)): $$(basename $$@)
347 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
348 --mode=$(basename $@) $(TESTFLAGS)
350 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
351 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
352 --arch=$(basename $@) $(TESTFLAGS)
354 $(CHECKS): $$(basename $$@)
355 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
356 --arch-and-mode=$(basename $@) $(TESTFLAGS)
358 $(addsuffix .quickcheck,$(MODES)): $$(basename $$@)
359 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
360 --mode=$(basename $@) $(TESTFLAGS) --quickcheck
362 $(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@)
363 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
364 --arch=$(basename $@) $(TESTFLAGS) --quickcheck
366 $(QUICKCHECKS): $$(basename $$@)
367 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
368 --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck
370 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
371 @tools/android-sync.sh $(basename $@) $(OUTDIR) \
372 $(shell pwd) $(ANDROID_V8)
374 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
375 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
376 --arch-and-mode=$(basename $@) \
378 --command-prefix="tools/android-run.py" $(TESTFLAGS)
380 $(addsuffix .check, $(ANDROID_ARCHES)): \
381 $(addprefix $$(basename $$@).,$(MODES)).check
383 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
384 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
385 --arch-and-mode=$(basename $@) \
386 --timeout=600 --nopresubmit --noi18n \
387 --command-prefix="tools/nacl-run.py"
389 $(addsuffix .check, $(NACL_ARCHES)): \
390 $(addprefix $$(basename $$@).,$(MODES)).check
393 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
394 --arch-and-mode=. $(TESTFLAGS)
396 SUPERFASTTESTMODES = ia32.release
397 FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release
398 FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug
402 SPACE = $(EMPTY) $(EMPTY)
403 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
404 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
405 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \
406 --download-data mozilla webkit
407 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
408 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
411 turbocheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
412 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
413 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) \
414 --quickcheck --variants=turbofan --download-data mozilla webkit
415 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
416 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) \
417 --quickcheck --variants=turbofan
420 # Clean targets. You can clean each architecture individually, or everything.
421 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
422 rm -f $(OUTDIR)/Makefile.$(basename $@)*
423 rm -rf $(OUTDIR)/$(basename $@).release
424 rm -rf $(OUTDIR)/$(basename $@).debug
425 rm -rf $(OUTDIR)/$(basename $@).optdebug
426 find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
429 rm -f $(OUTDIR)/Makefile.native
430 rm -rf $(OUTDIR)/native
431 find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
433 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean gtags.clean
435 # GYP file generation targets.
436 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
437 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
438 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
439 cut -f 2 -d " " | cut -f 1 -d "-" ))
440 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
441 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
442 $(eval V8_TARGET_ARCH:=$(subst .,,$(suffix $(basename $@))))
443 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
444 GYP_GENERATORS=make \
445 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
446 -Ibuild/standalone.gypi --depth=. \
447 -Dv8_target_arch=$(V8_TARGET_ARCH) \
448 $(if $(findstring $(CXX_TARGET_ARCH),$(V8_TARGET_ARCH)), \
449 -Dtarget_arch=$(V8_TARGET_ARCH),) \
450 $(if $(findstring optdebug,$@),-Dv8_optimized_debug=1,) \
451 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
453 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
454 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
455 GYP_GENERATORS=make \
456 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
457 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
459 # Note that NACL_SDK_ROOT must be set to point to an appropriate
460 # Native Client SDK before using this makefile. You can download
462 # https://developers.google.com/native-client/sdk/download
463 # The path indicated by NACL_SDK_ROOT will typically end with
464 # a folder for a pepper version such as "pepper_25" that should
465 # have "tools" and "toolchain" subdirectories.
466 must-set-NACL_SDK_ROOT:
468 $(error NACL_SDK_ROOT must be set)
471 # Replaces the old with the new environment file if they're different, which
472 # will trigger GYP to regenerate Makefiles.
473 $(ENVFILE): $(ENVFILE).new
474 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
475 then rm $(ENVFILE).new; \
476 else mv $(ENVFILE).new $(ENVFILE); fi
478 # Stores current GYPFLAGS in a file.
480 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
481 cut -f 2 -d " " | cut -f 1 -d "-" ))
482 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
483 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
484 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS) -Dtarget_arch=$(CXX_TARGET_ARCH)" > $(ENVFILE).new;
486 # Heap constants for grokdump.
487 DUMP_FILE = tools/v8heapconst.py
488 grokdump: ia32.release
489 @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
490 @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
492 # Support for the GNU GLOBAL Source Code Tag System.
493 gtags.files: $(GYPFILES) $(ENVFILE)
494 @find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@
496 # We need to manually set the stack limit here, to work around bugs in
497 # gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
498 GPATH GRTAGS GSYMS GTAGS: gtags.files $(shell cat gtags.files 2> /dev/null)
499 @bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
502 rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
504 dependencies builddeps:
505 $(error Use 'gclient sync' instead)