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)
49 GYPFLAGS += -Dconsole=$(console)
52 ifeq ($(disassembler), on)
53 GYPFLAGS += -Dv8_enable_disassembler=1
56 ifeq ($(objectprint), on)
57 GYPFLAGS += -Dv8_object_print=1
60 ifeq ($(verifyheap), on)
61 GYPFLAGS += -Dv8_enable_verify_heap=1
64 ifeq ($(tracemaps), on)
65 GYPFLAGS += -Dv8_trace_maps=1
68 ifeq ($(backtrace), off)
69 GYPFLAGS += -Dv8_enable_backtrace=0
71 GYPFLAGS += -Dv8_enable_backtrace=1
73 # verifypredictable=on
74 ifeq ($(verifypredictable), on)
75 GYPFLAGS += -Dv8_enable_verify_predictable=1
78 ifeq ($(snapshot), off)
79 GYPFLAGS += -Dv8_use_snapshot='false'
81 ifeq ($(snapshot), external)
82 GYPFLAGS += -Dv8_use_external_startup_data=1
85 ifeq ($(extrachecks), on)
86 GYPFLAGS += -Ddcheck_always_on=1 -Dv8_enable_handle_zapping=1
88 ifeq ($(extrachecks), off)
89 GYPFLAGS += -Ddcheck_always_on=0 -Dv8_enable_handle_zapping=0
92 ifeq ($(slowdchecks), on)
93 GYPFLAGS += -Dv8_enable_slow_dchecks=1
95 ifeq ($(slowdchecks), off)
96 GYPFLAGS += -Dv8_enable_slow_dchecks=0
99 ifeq ($(debugsymbols), on)
100 GYPFLAGS += -Drelease_extra_cflags=-ggdb3
104 GYPFLAGS += -Dv8_enable_gdbjit=1
106 ifeq ($(gdbjit), off)
107 GYPFLAGS += -Dv8_enable_gdbjit=0
110 ifeq ($(vtunejit), on)
111 GYPFLAGS += -Dv8_enable_vtunejit=1
114 ifeq ($(unalignedaccess), on)
115 GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
117 # randomseed=12345, disable random seed via randomseed=0
119 GYPFLAGS += -Dv8_random_seed=$(randomseed)
121 # soname_version=1.2.3
123 GYPFLAGS += -Dsoname_version=$(soname_version)
127 GYPFLAGS += -Dwerror=''
130 ifeq ($(presubmit), no)
131 TESTFLAGS += --no-presubmit
133 # strictaliasing=off (workaround for GCC-4.5)
134 ifeq ($(strictaliasing), off)
135 GYPFLAGS += -Dv8_no_strict_aliasing=1
138 ifeq ($(regexp), interpreted)
139 GYPFLAGS += -Dv8_interpreted_regexp=1
142 ifeq ($(i18nsupport), off)
143 GYPFLAGS += -Dv8_enable_i18n_support=0
144 TESTFLAGS += --noi18n
146 # deprecationwarnings=on
147 ifeq ($(deprecationwarnings), on)
148 GYPFLAGS += -Dv8_deprecation_warnings=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 # ----------------- available targets: --------------------
224 # - "grokdump": rebuilds heap constants lists used by grokdump
225 # - any arch listed in ARCHES (see below)
226 # - any mode listed in MODES
227 # - every combination <arch>.<mode>, e.g. "ia32.release"
228 # - "native": current host's architecture, release mode
229 # - any of the above with .check appended, e.g. "ia32.release.check"
230 # - "android": cross-compile for Android/ARM
231 # - "nacl" : cross-compile for Native Client (ia32 and x64)
232 # - default (no target specified): build all DEFAULT_ARCHES and MODES
233 # - "check": build all targets and run all tests
234 # - "<arch>.clean" for any <arch> in ARCHES
235 # - "clean": clean all ARCHES
237 # ----------------- internal stuff ------------------------
239 # Architectures and modes to be compiled. Consider these to be internal
240 # variables, don't override them (use the targets instead).
241 ARCHES = ia32 x64 x32 arm arm64 mips mipsel mips64el x87 ppc ppc64
242 DEFAULT_ARCHES = ia32 x64 arm
243 MODES = release debug optdebug
244 DEFAULT_MODES = release debug
245 ANDROID_ARCHES = android_ia32 android_x64 android_arm android_arm64 \
246 android_mipsel android_x87
247 NACL_ARCHES = nacl_ia32 nacl_x64
249 # List of files that trigger Makefile regeneration:
250 GYPFILES = third_party/icu/icu.gypi third_party/icu/icu.gyp \
251 build/shim_headers.gypi build/features.gypi build/standalone.gypi \
252 build/toolchain.gypi build/all.gyp build/mac/asan.gyp \
253 test/cctest/cctest.gyp \
254 test/unittests/unittests.gyp tools/gyp/v8.gyp \
255 tools/parser-shell.gyp testing/gmock.gyp testing/gtest.gyp \
256 buildtools/third_party/libc++abi/libc++abi.gyp \
257 buildtools/third_party/libc++/libc++.gyp samples/samples.gyp \
258 src/third_party/vtune/v8vtune.gyp src/d8.gyp
260 # If vtunejit=on, the v8vtune.gyp will be appended.
261 ifeq ($(vtunejit), on)
262 GYPFILES += src/third_party/vtune/v8vtune.gyp
264 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
265 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
266 ANDROID_BUILDS = $(foreach mode,$(MODES), \
267 $(addsuffix .$(mode),$(ANDROID_ARCHES)))
268 NACL_BUILDS = $(foreach mode,$(MODES), \
269 $(addsuffix .$(mode),$(NACL_ARCHES)))
270 # Generates corresponding test targets, e.g. "ia32.release.check".
271 CHECKS = $(addsuffix .check,$(BUILDS))
272 QUICKCHECKS = $(addsuffix .quickcheck,$(BUILDS))
273 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
274 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
275 # File where previously used GYPFLAGS are stored.
276 ENVFILE = $(OUTDIR)/environment
278 .PHONY: all check clean builddeps dependencies $(ENVFILE).new native \
279 qc quickcheck $(QUICKCHECKS) turbocheck \
280 $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \
281 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
282 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
283 $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
284 $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
285 must-set-NACL_SDK_ROOT
287 # Target definitions. "all" is the default.
288 all: $(DEFAULT_MODES)
290 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
291 # having been created before.
293 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
294 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
296 # Compile targets. MODES and ARCHES are convenience targets.
298 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
300 $(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
302 # Defines how to build a particular target (e.g. ia32.release).
303 $(BUILDS): $(OUTDIR)/Makefile.$$@
304 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
305 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
307 raw_input().replace('opt', '').capitalize()") \
308 builddir="$(shell pwd)/$(OUTDIR)/$@"
310 native: $(OUTDIR)/Makefile.native
311 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
313 builddir="$(shell pwd)/$(OUTDIR)/$@"
315 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
317 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) Makefile.android
318 @$(MAKE) -f Makefile.android $@ \
319 ARCH="$(basename $@)" \
320 MODE="$(subst .,,$(suffix $@))" \
322 GYPFLAGS="$(GYPFLAGS)"
324 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
326 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
327 Makefile.nacl must-set-NACL_SDK_ROOT
328 @$(MAKE) -f Makefile.nacl $@ \
329 ARCH="$(basename $@)" \
330 MODE="$(subst .,,$(suffix $@))" \
332 GYPFLAGS="$(GYPFLAGS)"
336 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
337 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
340 $(addsuffix .check,$(MODES)): $$(basename $$@)
341 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
342 --mode=$(basename $@) $(TESTFLAGS)
344 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
345 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
346 --arch=$(basename $@) $(TESTFLAGS)
348 $(CHECKS): $$(basename $$@)
349 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
350 --arch-and-mode=$(basename $@) $(TESTFLAGS)
352 $(addsuffix .quickcheck,$(MODES)): $$(basename $$@)
353 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
354 --mode=$(basename $@) $(TESTFLAGS) --quickcheck
356 $(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@)
357 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
358 --arch=$(basename $@) $(TESTFLAGS) --quickcheck
360 $(QUICKCHECKS): $$(basename $$@)
361 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
362 --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck
364 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
365 @tools/android-sync.sh $(basename $@) $(OUTDIR) \
366 $(shell pwd) $(ANDROID_V8)
368 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
369 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
370 --arch-and-mode=$(basename $@) \
372 --command-prefix="tools/android-run.py" $(TESTFLAGS)
374 $(addsuffix .check, $(ANDROID_ARCHES)): \
375 $(addprefix $$(basename $$@).,$(MODES)).check
377 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
378 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
379 --arch-and-mode=$(basename $@) \
380 --timeout=600 --nopresubmit --noi18n \
381 --command-prefix="tools/nacl-run.py"
383 $(addsuffix .check, $(NACL_ARCHES)): \
384 $(addprefix $$(basename $$@).,$(MODES)).check
387 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
388 --arch-and-mode=. $(TESTFLAGS)
390 SUPERFASTTESTMODES = ia32.release
391 FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release
392 FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug
396 SPACE = $(EMPTY) $(EMPTY)
397 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
398 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
399 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \
400 --download-data mozilla webkit
401 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
402 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
405 turbocheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
406 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
407 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) \
408 --quickcheck --variants=turbofan --download-data mozilla webkit
409 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
410 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) \
411 --quickcheck --variants=turbofan
414 # Clean targets. You can clean each architecture individually, or everything.
415 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
416 rm -f $(OUTDIR)/Makefile.$(basename $@)*
417 rm -rf $(OUTDIR)/$(basename $@).release
418 rm -rf $(OUTDIR)/$(basename $@).debug
419 rm -rf $(OUTDIR)/$(basename $@).optdebug
420 find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
423 rm -f $(OUTDIR)/Makefile.native
424 rm -rf $(OUTDIR)/native
425 find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
427 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean gtags.clean
429 # GYP file generation targets.
430 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
431 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
432 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
433 cut -f 2 -d " " | cut -f 1 -d "-" ))
434 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
435 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
436 $(eval V8_TARGET_ARCH:=$(subst .,,$(suffix $(basename $@))))
437 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
438 GYP_GENERATORS=make \
439 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
440 -Ibuild/standalone.gypi --depth=. \
441 -Dv8_target_arch=$(V8_TARGET_ARCH) \
442 $(if $(findstring $(CXX_TARGET_ARCH),$(V8_TARGET_ARCH)), \
443 -Dtarget_arch=$(V8_TARGET_ARCH),) \
444 $(if $(findstring optdebug,$@),-Dv8_optimized_debug=1,) \
445 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
447 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
448 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
449 GYP_GENERATORS=make \
450 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
451 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
453 # Note that NACL_SDK_ROOT must be set to point to an appropriate
454 # Native Client SDK before using this makefile. You can download
456 # https://developers.google.com/native-client/sdk/download
457 # The path indicated by NACL_SDK_ROOT will typically end with
458 # a folder for a pepper version such as "pepper_25" that should
459 # have "tools" and "toolchain" subdirectories.
460 must-set-NACL_SDK_ROOT:
462 $(error NACL_SDK_ROOT must be set)
465 # Replaces the old with the new environment file if they're different, which
466 # will trigger GYP to regenerate Makefiles.
467 $(ENVFILE): $(ENVFILE).new
468 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
469 then rm $(ENVFILE).new; \
470 else mv $(ENVFILE).new $(ENVFILE); fi
472 # Stores current GYPFLAGS in a file.
474 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
475 cut -f 2 -d " " | cut -f 1 -d "-" ))
476 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
477 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
478 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS) -Dtarget_arch=$(CXX_TARGET_ARCH)" > $(ENVFILE).new;
480 # Heap constants for grokdump.
481 DUMP_FILE = tools/v8heapconst.py
482 grokdump: ia32.release
483 @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
484 @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
486 # Support for the GNU GLOBAL Source Code Tag System.
487 gtags.files: $(GYPFILES) $(ENVFILE)
488 @find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@
490 # We need to manually set the stack limit here, to work around bugs in
491 # gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
492 GPATH GRTAGS GSYMS GTAGS: gtags.files $(shell cat gtags.files 2> /dev/null)
493 @bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
496 rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
498 dependencies builddeps:
499 $(error Use 'gclient sync' instead)