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
146 # imminentdeprecationwarnings=on
147 ifeq ($(imminentdeprecationwarnings), on)
148 GYPFLAGS += -Dv8_imminent_deprecation_warnings=1
152 GYPFLAGS += -Dasan=1 -Dclang=1
159 GYPFLAGS += -Dembed_script=$(embedscript)
162 GYPFLAGS += -Duse_goma=1
164 # arm specific flags.
165 # arm_version=<number | "default">
166 ifneq ($(strip $(arm_version)),)
167 GYPFLAGS += -Darm_version=$(arm_version)
169 # Deprecated (use arm_version instead): armv7=false/true
170 ifeq ($(armv7), false)
171 GYPFLAGS += -Darm_version=6
173 ifeq ($(armv7), true)
174 GYPFLAGS += -Darm_version=7
178 # hardfp=on/off. Deprecated, use armfloatabi
180 GYPFLAGS += -Darm_float_abi=hard
183 GYPFLAGS += -Darm_float_abi=softfp
187 # xxx: vfp, vfpv3-d16, vfpv3, neon.
189 GYPFLAGS += -Darm_fpu=default
191 GYPFLAGS += -Darm_fpu=$(armfpu)
193 # float abi: armfloatabi=softfp/hard
194 ifeq ($(armfloatabi),)
196 GYPFLAGS += -Darm_float_abi=default
199 GYPFLAGS += -Darm_float_abi=$(armfloatabi)
202 ifeq ($(armthumb), off)
203 GYPFLAGS += -Darm_thumb=0
205 ifeq ($(armthumb), on)
206 GYPFLAGS += -Darm_thumb=1
209 # arm_test_noprobe=on
210 # With this flag set, by default v8 will only use features implied
211 # by the compiler (no probe). This is done by modifying the default
212 # values of enable_armv7, enable_vfp3, enable_32dregs and enable_neon.
213 # Modifying these flags when launching v8 will enable the probing for
214 # the specified values.
215 ifeq ($(arm_test_noprobe), on)
216 GYPFLAGS += -Darm_test_noprobe=on
219 # Optionally enable wasm prototype.
220 # Assume you've placed a link to v8-native-prototype in third_party/wasm.
222 GYPFLAGS += -Dv8_wasm=1
225 # ----------------- available targets: --------------------
226 # - "grokdump": rebuilds heap constants lists used by grokdump
227 # - any arch listed in ARCHES (see below)
228 # - any mode listed in MODES
229 # - every combination <arch>.<mode>, e.g. "ia32.release"
230 # - "native": current host's architecture, release mode
231 # - any of the above with .check appended, e.g. "ia32.release.check"
232 # - "android": cross-compile for Android/ARM
233 # - "nacl" : cross-compile for Native Client (ia32 and x64)
234 # - default (no target specified): build all DEFAULT_ARCHES and MODES
235 # - "check": build all targets and run all tests
236 # - "<arch>.clean" for any <arch> in ARCHES
237 # - "clean": clean all ARCHES
239 # ----------------- internal stuff ------------------------
241 # Architectures and modes to be compiled. Consider these to be internal
242 # variables, don't override them (use the targets instead).
243 ARCHES = ia32 x64 x32 arm arm64 mips mipsel mips64el x87 ppc ppc64
244 DEFAULT_ARCHES = ia32 x64 arm
245 MODES = release debug optdebug
246 DEFAULT_MODES = release debug
247 ANDROID_ARCHES = android_ia32 android_x64 android_arm android_arm64 \
248 android_mipsel android_x87
249 NACL_ARCHES = nacl_ia32 nacl_x64
251 # List of files that trigger Makefile regeneration:
252 GYPFILES = third_party/icu/icu.gypi third_party/icu/icu.gyp \
253 build/shim_headers.gypi build/features.gypi build/standalone.gypi \
254 build/toolchain.gypi build/all.gyp build/mac/asan.gyp \
255 test/cctest/cctest.gyp \
256 test/unittests/unittests.gyp tools/gyp/v8.gyp \
257 tools/parser-shell.gyp testing/gmock.gyp testing/gtest.gyp \
258 buildtools/third_party/libc++abi/libc++abi.gyp \
259 buildtools/third_party/libc++/libc++.gyp samples/samples.gyp \
260 src/third_party/vtune/v8vtune.gyp src/d8.gyp
262 # If vtunejit=on, the v8vtune.gyp will be appended.
263 ifeq ($(vtunejit), on)
264 GYPFILES += src/third_party/vtune/v8vtune.gyp
266 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
267 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
268 ANDROID_BUILDS = $(foreach mode,$(MODES), \
269 $(addsuffix .$(mode),$(ANDROID_ARCHES)))
270 NACL_BUILDS = $(foreach mode,$(MODES), \
271 $(addsuffix .$(mode),$(NACL_ARCHES)))
272 # Generates corresponding test targets, e.g. "ia32.release.check".
273 CHECKS = $(addsuffix .check,$(BUILDS))
274 QUICKCHECKS = $(addsuffix .quickcheck,$(BUILDS))
275 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
276 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
277 # File where previously used GYPFLAGS are stored.
278 ENVFILE = $(OUTDIR)/environment
280 .PHONY: all check clean builddeps dependencies $(ENVFILE).new native \
281 qc quickcheck $(QUICKCHECKS) turbocheck \
282 $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \
283 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
284 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
285 $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
286 $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
287 must-set-NACL_SDK_ROOT
289 # Target definitions. "all" is the default.
290 all: $(DEFAULT_MODES)
292 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
293 # having been created before.
295 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
296 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
298 # Compile targets. MODES and ARCHES are convenience targets.
300 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
302 $(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
304 # Defines how to build a particular target (e.g. ia32.release).
305 $(BUILDS): $(OUTDIR)/Makefile.$$@
306 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
307 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
309 raw_input().replace('opt', '').capitalize()") \
310 builddir="$(shell pwd)/$(OUTDIR)/$@"
312 native: $(OUTDIR)/Makefile.native
313 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
315 builddir="$(shell pwd)/$(OUTDIR)/$@"
317 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
319 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) Makefile.android
320 @$(MAKE) -f Makefile.android $@ \
321 ARCH="$(basename $@)" \
322 MODE="$(subst .,,$(suffix $@))" \
324 GYPFLAGS="$(GYPFLAGS)"
326 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
328 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
329 Makefile.nacl must-set-NACL_SDK_ROOT
330 @$(MAKE) -f Makefile.nacl $@ \
331 ARCH="$(basename $@)" \
332 MODE="$(subst .,,$(suffix $@))" \
334 GYPFLAGS="$(GYPFLAGS)"
338 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
339 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
342 $(addsuffix .check,$(MODES)): $$(basename $$@)
343 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
344 --mode=$(basename $@) $(TESTFLAGS)
346 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
347 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
348 --arch=$(basename $@) $(TESTFLAGS)
350 $(CHECKS): $$(basename $$@)
351 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
352 --arch-and-mode=$(basename $@) $(TESTFLAGS)
354 $(addsuffix .quickcheck,$(MODES)): $$(basename $$@)
355 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
356 --mode=$(basename $@) $(TESTFLAGS) --quickcheck
358 $(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@)
359 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
360 --arch=$(basename $@) $(TESTFLAGS) --quickcheck
362 $(QUICKCHECKS): $$(basename $$@)
363 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
364 --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck
366 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
367 @tools/android-sync.sh $(basename $@) $(OUTDIR) \
368 $(shell pwd) $(ANDROID_V8)
370 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
371 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
372 --arch-and-mode=$(basename $@) \
374 --command-prefix="tools/android-run.py" $(TESTFLAGS)
376 $(addsuffix .check, $(ANDROID_ARCHES)): \
377 $(addprefix $$(basename $$@).,$(MODES)).check
379 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
380 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
381 --arch-and-mode=$(basename $@) \
382 --timeout=600 --nopresubmit --noi18n \
383 --command-prefix="tools/nacl-run.py"
385 $(addsuffix .check, $(NACL_ARCHES)): \
386 $(addprefix $$(basename $$@).,$(MODES)).check
389 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
390 --arch-and-mode=. $(TESTFLAGS)
392 SUPERFASTTESTMODES = ia32.release
393 FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release
394 FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug
398 SPACE = $(EMPTY) $(EMPTY)
399 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
400 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
401 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \
402 --download-data mozilla webkit
403 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
404 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
407 turbocheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
408 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
409 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) \
410 --quickcheck --variants=turbofan --download-data mozilla webkit
411 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
412 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) \
413 --quickcheck --variants=turbofan
416 # Clean targets. You can clean each architecture individually, or everything.
417 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
418 rm -f $(OUTDIR)/Makefile.$(basename $@)*
419 rm -rf $(OUTDIR)/$(basename $@).release
420 rm -rf $(OUTDIR)/$(basename $@).debug
421 rm -rf $(OUTDIR)/$(basename $@).optdebug
422 find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
425 rm -f $(OUTDIR)/Makefile.native
426 rm -rf $(OUTDIR)/native
427 find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
429 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean gtags.clean
431 # GYP file generation targets.
432 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
433 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
434 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
435 cut -f 2 -d " " | cut -f 1 -d "-" ))
436 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
437 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
438 $(eval V8_TARGET_ARCH:=$(subst .,,$(suffix $(basename $@))))
439 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
440 GYP_GENERATORS=make \
441 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
442 -Ibuild/standalone.gypi --depth=. \
443 -Dv8_target_arch=$(V8_TARGET_ARCH) \
444 $(if $(findstring $(CXX_TARGET_ARCH),$(V8_TARGET_ARCH)), \
445 -Dtarget_arch=$(V8_TARGET_ARCH),) \
446 $(if $(findstring optdebug,$@),-Dv8_optimized_debug=1,) \
447 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
449 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
450 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
451 GYP_GENERATORS=make \
452 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
453 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
455 # Note that NACL_SDK_ROOT must be set to point to an appropriate
456 # Native Client SDK before using this makefile. You can download
458 # https://developers.google.com/native-client/sdk/download
459 # The path indicated by NACL_SDK_ROOT will typically end with
460 # a folder for a pepper version such as "pepper_25" that should
461 # have "tools" and "toolchain" subdirectories.
462 must-set-NACL_SDK_ROOT:
464 $(error NACL_SDK_ROOT must be set)
467 # Replaces the old with the new environment file if they're different, which
468 # will trigger GYP to regenerate Makefiles.
469 $(ENVFILE): $(ENVFILE).new
470 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
471 then rm $(ENVFILE).new; \
472 else mv $(ENVFILE).new $(ENVFILE); fi
474 # Stores current GYPFLAGS in a file.
476 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
477 cut -f 2 -d " " | cut -f 1 -d "-" ))
478 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
479 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
480 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS) -Dtarget_arch=$(CXX_TARGET_ARCH)" > $(ENVFILE).new;
482 # Heap constants for grokdump.
483 DUMP_FILE = tools/v8heapconst.py
484 grokdump: ia32.release
485 @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
486 @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
488 # Support for the GNU GLOBAL Source Code Tag System.
489 gtags.files: $(GYPFILES) $(ENVFILE)
490 @find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@
492 # We need to manually set the stack limit here, to work around bugs in
493 # gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
494 GPATH GRTAGS GSYMS GTAGS: gtags.files $(shell cat gtags.files 2> /dev/null)
495 @bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
498 rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
500 dependencies builddeps:
501 $(error Use 'gclient sync' instead)