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 # ----------------- 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 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 $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
281 must-set-NACL_SDK_ROOT
283 # Target definitions. "all" is the default.
284 all: $(DEFAULT_MODES)
286 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
287 # having been created before.
289 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
290 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
292 # Compile targets. MODES and ARCHES are convenience targets.
294 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
296 $(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
298 # Defines how to build a particular target (e.g. ia32.release).
299 $(BUILDS): $(OUTDIR)/Makefile.$$@
300 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
301 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
303 raw_input().replace('opt', '').capitalize()") \
304 builddir="$(shell pwd)/$(OUTDIR)/$@"
306 native: $(OUTDIR)/Makefile.native
307 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
309 builddir="$(shell pwd)/$(OUTDIR)/$@"
311 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
313 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) Makefile.android
314 @$(MAKE) -f Makefile.android $@ \
315 ARCH="$(basename $@)" \
316 MODE="$(subst .,,$(suffix $@))" \
318 GYPFLAGS="$(GYPFLAGS)"
320 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
322 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
323 Makefile.nacl must-set-NACL_SDK_ROOT
324 @$(MAKE) -f Makefile.nacl $@ \
325 ARCH="$(basename $@)" \
326 MODE="$(subst .,,$(suffix $@))" \
328 GYPFLAGS="$(GYPFLAGS)"
332 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
333 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
336 $(addsuffix .check,$(MODES)): $$(basename $$@)
337 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
338 --mode=$(basename $@) $(TESTFLAGS)
340 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
341 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
342 --arch=$(basename $@) $(TESTFLAGS)
344 $(CHECKS): $$(basename $$@)
345 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
346 --arch-and-mode=$(basename $@) $(TESTFLAGS)
348 $(addsuffix .quickcheck,$(MODES)): $$(basename $$@)
349 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
350 --mode=$(basename $@) $(TESTFLAGS) --quickcheck
352 $(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@)
353 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
354 --arch=$(basename $@) $(TESTFLAGS) --quickcheck
356 $(QUICKCHECKS): $$(basename $$@)
357 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
358 --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck
360 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
361 @tools/android-sync.sh $(basename $@) $(OUTDIR) \
362 $(shell pwd) $(ANDROID_V8)
364 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
365 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
366 --arch-and-mode=$(basename $@) \
368 --command-prefix="tools/android-run.py" $(TESTFLAGS)
370 $(addsuffix .check, $(ANDROID_ARCHES)): \
371 $(addprefix $$(basename $$@).,$(MODES)).check
373 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
374 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
375 --arch-and-mode=$(basename $@) \
376 --timeout=600 --nopresubmit --noi18n \
377 --command-prefix="tools/nacl-run.py"
379 $(addsuffix .check, $(NACL_ARCHES)): \
380 $(addprefix $$(basename $$@).,$(MODES)).check
383 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
384 --arch-and-mode=. $(TESTFLAGS)
386 SUPERFASTTESTMODES = ia32.release
387 FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release
388 FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug
392 SPACE = $(EMPTY) $(EMPTY)
393 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
394 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
395 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \
396 --download-data mozilla webkit
397 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
398 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
401 turbocheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
402 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
403 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) \
404 --quickcheck --variants=turbofan --download-data mozilla webkit
405 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
406 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) \
407 --quickcheck --variants=turbofan
410 # Clean targets. You can clean each architecture individually, or everything.
411 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
412 rm -f $(OUTDIR)/Makefile.$(basename $@)*
413 rm -rf $(OUTDIR)/$(basename $@).release
414 rm -rf $(OUTDIR)/$(basename $@).debug
415 rm -rf $(OUTDIR)/$(basename $@).optdebug
416 find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
419 rm -f $(OUTDIR)/Makefile.native
420 rm -rf $(OUTDIR)/native
421 find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
423 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean gtags.clean
425 # GYP file generation targets.
426 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
427 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
428 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
429 cut -f 2 -d " " | cut -f 1 -d "-" ))
430 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
431 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
432 $(eval V8_TARGET_ARCH:=$(subst .,,$(suffix $(basename $@))))
433 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
434 GYP_GENERATORS=make \
435 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
436 -Ibuild/standalone.gypi --depth=. \
437 -Dv8_target_arch=$(V8_TARGET_ARCH) \
438 $(if $(findstring $(CXX_TARGET_ARCH),$(V8_TARGET_ARCH)), \
439 -Dtarget_arch=$(V8_TARGET_ARCH),) \
440 $(if $(findstring optdebug,$@),-Dv8_optimized_debug=1,) \
441 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
443 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
444 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/build:$(PYTHONPATH):$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
445 GYP_GENERATORS=make \
446 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
447 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
449 # Note that NACL_SDK_ROOT must be set to point to an appropriate
450 # Native Client SDK before using this makefile. You can download
452 # https://developers.google.com/native-client/sdk/download
453 # The path indicated by NACL_SDK_ROOT will typically end with
454 # a folder for a pepper version such as "pepper_25" that should
455 # have "tools" and "toolchain" subdirectories.
456 must-set-NACL_SDK_ROOT:
458 $(error NACL_SDK_ROOT must be set)
461 # Replaces the old with the new environment file if they're different, which
462 # will trigger GYP to regenerate Makefiles.
463 $(ENVFILE): $(ENVFILE).new
464 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
465 then rm $(ENVFILE).new; \
466 else mv $(ENVFILE).new $(ENVFILE); fi
468 # Stores current GYPFLAGS in a file.
470 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
471 cut -f 2 -d " " | cut -f 1 -d "-" ))
472 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
473 $(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
474 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS) -Dtarget_arch=$(CXX_TARGET_ARCH)" > $(ENVFILE).new;
476 # Heap constants for grokdump.
477 DUMP_FILE = tools/v8heapconst.py
478 grokdump: ia32.release
479 @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
480 @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
482 # Support for the GNU GLOBAL Source Code Tag System.
483 gtags.files: $(GYPFILES) $(ENVFILE)
484 @find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@
486 # We need to manually set the stack limit here, to work around bugs in
487 # gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
488 GPATH GRTAGS GSYMS GTAGS: gtags.files $(shell cat gtags.files 2> /dev/null)
489 @bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
492 rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
494 dependencies builddeps:
495 $(error Use 'gclient sync' instead)