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.
35 ANDROID_NDK_HOST_ARCH ?=
37 ANDROID_V8 ?= /data/local/tmp/v8
40 # Special build flags. Use them like this: "make library=shared"
42 # library=shared || component=shared_library
43 ifeq ($(library), shared)
44 GYPFLAGS += -Dcomponent=shared_library
47 GYPFLAGS += -Dcomponent=$(component)
51 GYPFLAGS += -Dconsole=$(console)
54 ifeq ($(disassembler), on)
55 GYPFLAGS += -Dv8_enable_disassembler=1
58 ifeq ($(objectprint), on)
59 GYPFLAGS += -Dv8_object_print=1
62 ifeq ($(verifyheap), on)
63 GYPFLAGS += -Dv8_enable_verify_heap=1
66 ifeq ($(tracemaps), on)
67 GYPFLAGS += -Dv8_trace_maps=1
70 ifeq ($(backtrace), off)
71 GYPFLAGS += -Dv8_enable_backtrace=0
73 GYPFLAGS += -Dv8_enable_backtrace=1
75 # verifypredictable=on
76 ifeq ($(verifypredictable), on)
77 GYPFLAGS += -Dv8_enable_verify_predictable=1
80 ifeq ($(snapshot), off)
81 GYPFLAGS += -Dv8_use_snapshot='false'
83 ifeq ($(snapshot), external)
84 GYPFLAGS += -Dv8_use_external_startup_data=1
87 ifeq ($(extrachecks), on)
88 GYPFLAGS += -Ddcheck_always_on=1 -Dv8_enable_handle_zapping=1
90 ifeq ($(extrachecks), off)
91 GYPFLAGS += -Ddcheck_always_on=0 -Dv8_enable_handle_zapping=0
94 ifeq ($(slowdchecks), on)
95 GYPFLAGS += -Dv8_enable_slow_dchecks=1
97 ifeq ($(slowdchecks), off)
98 GYPFLAGS += -Dv8_enable_slow_dchecks=0
101 ifeq ($(debugsymbols), on)
102 GYPFLAGS += -Drelease_extra_cflags=-ggdb3
106 GYPFLAGS += -Dv8_enable_gdbjit=1
108 ifeq ($(gdbjit), off)
109 GYPFLAGS += -Dv8_enable_gdbjit=0
112 ifeq ($(vtunejit), on)
113 GYPFLAGS += -Dv8_enable_vtunejit=1
116 ifeq ($(unalignedaccess), on)
117 GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
119 # randomseed=12345, disable random seed via randomseed=0
121 GYPFLAGS += -Dv8_random_seed=$(randomseed)
123 # soname_version=1.2.3
125 GYPFLAGS += -Dsoname_version=$(soname_version)
129 GYPFLAGS += -Dwerror=''
132 ifeq ($(presubmit), no)
133 TESTFLAGS += --no-presubmit
135 # strictaliasing=off (workaround for GCC-4.5)
136 ifeq ($(strictaliasing), off)
137 GYPFLAGS += -Dv8_no_strict_aliasing=1
140 ifeq ($(regexp), interpreted)
141 GYPFLAGS += -Dv8_interpreted_regexp=1
144 ifeq ($(i18nsupport), off)
145 GYPFLAGS += -Dv8_enable_i18n_support=0
146 TESTFLAGS += --noi18n
148 # deprecation_warnings=on
149 ifeq ($(deprecationwarnings), on)
150 GYPFLAGS += -Dv8_deprecation_warnings=1
154 GYPFLAGS += -Dasan=1 -Dclang=1
161 GYPFLAGS += -Dembed_script=$(embedscript)
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 # ----------------- available targets: --------------------
220 # - "grokdump": rebuilds heap constants lists used by grokdump
221 # - any arch listed in ARCHES (see below)
222 # - any mode listed in MODES
223 # - every combination <arch>.<mode>, e.g. "ia32.release"
224 # - "native": current host's architecture, release mode
225 # - any of the above with .check appended, e.g. "ia32.release.check"
226 # - "android": cross-compile for Android/ARM
227 # - "nacl" : cross-compile for Native Client (ia32 and x64)
228 # - default (no target specified): build all DEFAULT_ARCHES and MODES
229 # - "check": build all targets and run all tests
230 # - "<arch>.clean" for any <arch> in ARCHES
231 # - "clean": clean all ARCHES
233 # ----------------- internal stuff ------------------------
235 # Architectures and modes to be compiled. Consider these to be internal
236 # variables, don't override them (use the targets instead).
237 ARCHES = ia32 x64 x32 arm arm64 mips mipsel mips64el x87 ppc ppc64
238 DEFAULT_ARCHES = ia32 x64 arm
239 MODES = release debug optdebug
240 DEFAULT_MODES = release debug
241 ANDROID_ARCHES = android_ia32 android_x64 android_arm android_arm64 \
242 android_mipsel android_x87
243 NACL_ARCHES = nacl_ia32 nacl_x64
245 # List of files that trigger Makefile regeneration:
246 GYPFILES = third_party/icu/icu.gypi third_party/icu/icu.gyp \
247 build/shim_headers.gypi build/features.gypi build/standalone.gypi \
248 build/toolchain.gypi build/all.gyp build/mac/asan.gyp \
249 build/android.gypi test/cctest/cctest.gyp \
250 test/unittests/unittests.gyp tools/gyp/v8.gyp \
251 tools/parser-shell.gyp testing/gmock.gyp testing/gtest.gyp \
252 buildtools/third_party/libc++abi/libc++abi.gyp \
253 buildtools/third_party/libc++/libc++.gyp samples/samples.gyp \
254 src/third_party/vtune/v8vtune.gyp src/d8.gyp
256 # If vtunejit=on, the v8vtune.gyp will be appended.
257 ifeq ($(vtunejit), on)
258 GYPFILES += src/third_party/vtune/v8vtune.gyp
260 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
261 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
262 ANDROID_BUILDS = $(foreach mode,$(MODES), \
263 $(addsuffix .$(mode),$(ANDROID_ARCHES)))
264 NACL_BUILDS = $(foreach mode,$(MODES), \
265 $(addsuffix .$(mode),$(NACL_ARCHES)))
266 # Generates corresponding test targets, e.g. "ia32.release.check".
267 CHECKS = $(addsuffix .check,$(BUILDS))
268 QUICKCHECKS = $(addsuffix .quickcheck,$(BUILDS))
269 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
270 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
271 # File where previously used GYPFLAGS are stored.
272 ENVFILE = $(OUTDIR)/environment
274 .PHONY: all check clean builddeps dependencies $(ENVFILE).new native \
275 qc quickcheck $(QUICKCHECKS) turbocheck \
276 $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \
277 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
278 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
279 $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
280 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \
281 $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
282 must-set-NACL_SDK_ROOT
284 # Target definitions. "all" is the default.
285 all: $(DEFAULT_MODES)
287 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
288 # having been created before.
290 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
291 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
293 # Compile targets. MODES and ARCHES are convenience targets.
295 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
297 $(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
299 # Defines how to build a particular target (e.g. ia32.release).
300 $(BUILDS): $(OUTDIR)/Makefile.$$@
301 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
302 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
304 raw_input().replace('opt', '').capitalize()") \
305 builddir="$(shell pwd)/$(OUTDIR)/$@"
307 native: $(OUTDIR)/Makefile.native
308 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
310 builddir="$(shell pwd)/$(OUTDIR)/$@"
312 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
314 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \
315 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN Makefile.android
316 @$(MAKE) -f Makefile.android $@ \
317 ARCH="$(basename $@)" \
318 MODE="$(subst .,,$(suffix $@))" \
320 GYPFLAGS="$(GYPFLAGS)"
322 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
324 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
325 Makefile.nacl must-set-NACL_SDK_ROOT
326 @$(MAKE) -f Makefile.nacl $@ \
327 ARCH="$(basename $@)" \
328 MODE="$(subst .,,$(suffix $@))" \
330 GYPFLAGS="$(GYPFLAGS)"
334 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
335 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
338 $(addsuffix .check,$(MODES)): $$(basename $$@)
339 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
340 --mode=$(basename $@) $(TESTFLAGS)
342 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
343 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
344 --arch=$(basename $@) $(TESTFLAGS)
346 $(CHECKS): $$(basename $$@)
347 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
348 --arch-and-mode=$(basename $@) $(TESTFLAGS)
350 $(addsuffix .quickcheck,$(MODES)): $$(basename $$@)
351 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
352 --mode=$(basename $@) $(TESTFLAGS) --quickcheck
354 $(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@)
355 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
356 --arch=$(basename $@) $(TESTFLAGS) --quickcheck
358 $(QUICKCHECKS): $$(basename $$@)
359 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
360 --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck
362 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
363 @tools/android-sync.sh $(basename $@) $(OUTDIR) \
364 $(shell pwd) $(ANDROID_V8)
366 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
367 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
368 --arch-and-mode=$(basename $@) \
370 --command-prefix="tools/android-run.py" $(TESTFLAGS)
372 $(addsuffix .check, $(ANDROID_ARCHES)): \
373 $(addprefix $$(basename $$@).,$(MODES)).check
375 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
376 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
377 --arch-and-mode=$(basename $@) \
378 --timeout=600 --nopresubmit --noi18n \
379 --command-prefix="tools/nacl-run.py"
381 $(addsuffix .check, $(NACL_ARCHES)): \
382 $(addprefix $$(basename $$@).,$(MODES)).check
385 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
386 --arch-and-mode=. $(TESTFLAGS)
388 SUPERFASTTESTMODES = ia32.release
389 FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release
390 FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug
394 SPACE = $(EMPTY) $(EMPTY)
395 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
396 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
397 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \
398 --download-data mozilla webkit
399 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
400 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
403 turbocheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
404 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
405 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) \
406 --quickcheck --variants=turbofan --download-data mozilla webkit
407 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
408 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) \
409 --quickcheck --variants=turbofan
412 # Clean targets. You can clean each architecture individually, or everything.
413 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
414 rm -f $(OUTDIR)/Makefile.$(basename $@)*
415 rm -rf $(OUTDIR)/$(basename $@).release
416 rm -rf $(OUTDIR)/$(basename $@).debug
417 rm -rf $(OUTDIR)/$(basename $@).optdebug
418 find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
421 rm -f $(OUTDIR)/Makefile.native
422 rm -rf $(OUTDIR)/native
423 find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
425 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean gtags.clean
427 # GYP file generation targets.
428 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
429 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
430 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
431 cut -f 2 -d " " | cut -f 1 -d "-" ))
432 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
433 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
434 $(eval V8_TARGET_ARCH:=$(subst .,,$(suffix $(basename $@))))
435 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
436 GYP_GENERATORS=make \
437 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
438 -Ibuild/standalone.gypi --depth=. \
439 -Dv8_target_arch=$(V8_TARGET_ARCH) \
440 $(if $(findstring $(CXX_TARGET_ARCH),$(V8_TARGET_ARCH)), \
441 -Dtarget_arch=$(V8_TARGET_ARCH),) \
442 $(if $(findstring optdebug,$@),-Dv8_optimized_debug=1,) \
443 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
445 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
446 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
447 GYP_GENERATORS=make \
448 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
449 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
451 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
452 ifndef ANDROID_NDK_ROOT
453 ifndef ANDROID_TOOLCHAIN
454 $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
458 # Note that NACL_SDK_ROOT must be set to point to an appropriate
459 # Native Client SDK before using this makefile. You can download
461 # https://developers.google.com/native-client/sdk/download
462 # The path indicated by NACL_SDK_ROOT will typically end with
463 # a folder for a pepper version such as "pepper_25" that should
464 # have "tools" and "toolchain" subdirectories.
465 must-set-NACL_SDK_ROOT:
467 $(error NACL_SDK_ROOT must be set)
470 # Replaces the old with the new environment file if they're different, which
471 # will trigger GYP to regenerate Makefiles.
472 $(ENVFILE): $(ENVFILE).new
473 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
474 then rm $(ENVFILE).new; \
475 else mv $(ENVFILE).new $(ENVFILE); fi
477 # Stores current GYPFLAGS in a file.
479 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
480 cut -f 2 -d " " | cut -f 1 -d "-" ))
481 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
482 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
483 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS) -Dtarget_arch=$(CXX_TARGET_ARCH)" > $(ENVFILE).new;
485 # Heap constants for grokdump.
486 DUMP_FILE = tools/v8heapconst.py
487 grokdump: ia32.release
488 @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
489 @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
491 # Support for the GNU GLOBAL Source Code Tag System.
492 gtags.files: $(GYPFILES) $(ENVFILE)
493 @find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@
495 # We need to manually set the stack limit here, to work around bugs in
496 # gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
497 GPATH GRTAGS GSYMS GTAGS: gtags.files $(shell cat gtags.files 2> /dev/null)
498 @bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
501 rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
503 dependencies builddeps:
504 $(error Use 'gclient sync' instead)