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 # TODO(bnoordhuis) Make i18n support configurable.
35 GYPFLAGS ?= -Dv8_enable_i18n_support=0
38 ANDROID_NDK_HOST_ARCH ?=
40 ANDROID_V8 ?= /data/local/tmp/v8
43 # Special build flags. Use them like this: "make library=shared"
45 # library=shared || component=shared_library
46 ifeq ($(library), shared)
47 GYPFLAGS += -Dcomponent=shared_library
50 GYPFLAGS += -Dcomponent=$(component)
54 GYPFLAGS += -Dconsole=$(console)
57 ifeq ($(disassembler), on)
58 GYPFLAGS += -Dv8_enable_disassembler=1
61 ifeq ($(objectprint), on)
62 GYPFLAGS += -Dv8_object_print=1
65 ifeq ($(verifyheap), on)
66 GYPFLAGS += -Dv8_enable_verify_heap=1
69 ifeq ($(backtrace), off)
70 GYPFLAGS += -Dv8_enable_backtrace=0
72 GYPFLAGS += -Dv8_enable_backtrace=1
74 # verifypredictable=on
75 ifeq ($(verifypredictable), on)
76 GYPFLAGS += -Dv8_enable_verify_predictable=1
79 ifeq ($(snapshot), off)
80 GYPFLAGS += -Dv8_use_snapshot='false'
83 ifeq ($(extrachecks), on)
84 GYPFLAGS += -Dv8_enable_extra_checks=1 -Dv8_enable_handle_zapping=1
86 ifeq ($(extrachecks), off)
87 GYPFLAGS += -Dv8_enable_extra_checks=0 -Dv8_enable_handle_zapping=0
91 GYPFLAGS += -Dv8_enable_gdbjit=1
94 GYPFLAGS += -Dv8_enable_gdbjit=0
97 ifeq ($(vtunejit), on)
98 GYPFLAGS += -Dv8_enable_vtunejit=1
101 ifeq ($(optdebug), on)
102 GYPFLAGS += -Dv8_optimized_debug=2
105 ifeq ($(unalignedaccess), on)
106 GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
108 # randomseed=12345, disable random seed via randomseed=0
110 GYPFLAGS += -Dv8_random_seed=$(randomseed)
112 # soname_version=1.2.3
114 GYPFLAGS += -Dsoname_version=$(soname_version)
118 GYPFLAGS += -Dwerror=''
121 ifeq ($(presubmit), no)
122 TESTFLAGS += --no-presubmit
124 # strictaliasing=off (workaround for GCC-4.5)
125 ifeq ($(strictaliasing), off)
126 GYPFLAGS += -Dv8_no_strict_aliasing=1
129 ifeq ($(regexp), interpreted)
130 GYPFLAGS += -Dv8_interpreted_regexp=1
133 ifeq ($(i18nsupport), off)
134 GYPFLAGS += -Dv8_enable_i18n_support=0
135 TESTFLAGS += --noi18n
137 # deprecation_warnings=on
138 ifeq ($(deprecationwarnings), on)
139 GYPFLAGS += -Dv8_deprecation_warnings=1
141 # asan=/path/to/clang++
142 ifneq ($(strip $(asan)),)
145 export CXX_host=$(asan)
147 export ASAN_SYMBOLIZER_PATH="$(dir $(asan))llvm-symbolizer"
150 # arm specific flags.
151 # arm_version=<number | "default">
152 ifneq ($(strip $(arm_version)),)
153 GYPFLAGS += -Darm_version=$(arm_version)
155 # Deprecated (use arm_version instead): armv7=false/true
156 ifeq ($(armv7), false)
157 GYPFLAGS += -Darm_version=6
159 ifeq ($(armv7), true)
160 GYPFLAGS += -Darm_version=7
164 # hardfp=on/off. Deprecated, use armfloatabi
166 GYPFLAGS += -Darm_float_abi=hard
169 GYPFLAGS += -Darm_float_abi=softfp
173 # xxx: vfp, vfpv3-d16, vfpv3, neon.
175 GYPFLAGS += -Darm_fpu=default
177 GYPFLAGS += -Darm_fpu=$(armfpu)
179 # float abi: armfloatabi=softfp/hard
180 ifeq ($(armfloatabi),)
182 GYPFLAGS += -Darm_float_abi=default
185 GYPFLAGS += -Darm_float_abi=$(armfloatabi)
188 ifeq ($(armthumb), off)
189 GYPFLAGS += -Darm_thumb=0
191 ifeq ($(armthumb), on)
192 GYPFLAGS += -Darm_thumb=1
195 # arm_test_noprobe=on
196 # With this flag set, by default v8 will only use features implied
197 # by the compiler (no probe). This is done by modifying the default
198 # values of enable_armv7, enable_vfp3, enable_32dregs and enable_neon.
199 # Modifying these flags when launching v8 will enable the probing for
200 # the specified values.
201 ifeq ($(arm_test_noprobe), on)
202 GYPFLAGS += -Darm_test_noprobe=on
205 # ----------------- available targets: --------------------
206 # - "builddeps": pulls in external dependencies for building
207 # - "dependencies": pulls in all external dependencies
208 # - "grokdump": rebuilds heap constants lists used by grokdump
209 # - any arch listed in ARCHES (see below)
210 # - any mode listed in MODES
211 # - every combination <arch>.<mode>, e.g. "ia32.release"
212 # - "native": current host's architecture, release mode
213 # - any of the above with .check appended, e.g. "ia32.release.check"
214 # - "android": cross-compile for Android/ARM
215 # - "nacl" : cross-compile for Native Client (ia32 and x64)
216 # - default (no target specified): build all DEFAULT_ARCHES and MODES
217 # - "check": build all targets and run all tests
218 # - "<arch>.clean" for any <arch> in ARCHES
219 # - "clean": clean all ARCHES
221 # ----------------- internal stuff ------------------------
223 # Architectures and modes to be compiled. Consider these to be internal
224 # variables, don't override them (use the targets instead).
225 ARCHES = ia32 x64 x32 arm arm64 mips mipsel mips64el x87
226 DEFAULT_ARCHES = ia32 x64 arm
227 MODES = release debug optdebug
228 DEFAULT_MODES = release debug
229 ANDROID_ARCHES = android_ia32 android_arm android_arm64 android_mipsel android_x87
230 NACL_ARCHES = nacl_ia32 nacl_x64
232 # List of files that trigger Makefile regeneration:
235 deps/cares/cares.gyp \
236 deps/http_parser/http_parser.gyp \
237 deps/openssl/openssl.gyp \
239 deps/v8/tools/gyp/v8.gyp \
243 # If vtunejit=on, the v8vtune.gyp will be appended.
244 ifeq ($(vtunejit), on)
245 GYPFILES += src/third_party/vtune/v8vtune.gyp
247 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
248 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
249 ANDROID_BUILDS = $(foreach mode,$(MODES), \
250 $(addsuffix .$(mode),$(ANDROID_ARCHES)))
251 NACL_BUILDS = $(foreach mode,$(MODES), \
252 $(addsuffix .$(mode),$(NACL_ARCHES)))
253 # Generates corresponding test targets, e.g. "ia32.release.check".
254 CHECKS = $(addsuffix .check,$(BUILDS))
255 QUICKCHECKS = $(addsuffix .quickcheck,$(BUILDS))
256 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
257 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
258 # File where previously used GYPFLAGS are stored.
259 ENVFILE = $(OUTDIR)/environment
261 .PHONY: all check clean builddeps dependencies $(ENVFILE).new native \
262 qc quickcheck $(QUICKCHECKS) \
263 $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \
264 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
265 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
266 $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
267 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \
268 $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
269 must-set-NACL_SDK_ROOT
271 # Target definitions. "all" is the default.
272 all: $(DEFAULT_MODES)
274 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
275 # having been created before.
277 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
278 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
280 # Compile targets. MODES and ARCHES are convenience targets.
282 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
284 $(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
286 # Defines how to build a particular target (e.g. ia32.release).
287 $(BUILDS): $(OUTDIR)/Makefile.$$@
288 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
289 CXX="$(CXX)" LINK="$(LINK)" \
290 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
292 raw_input().replace('opt', '').capitalize()") \
293 builddir="$(shell pwd)/$(OUTDIR)/$@"
295 native: $(OUTDIR)/Makefile.native
296 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
297 CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
298 builddir="$(shell pwd)/$(OUTDIR)/$@"
300 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
302 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \
303 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN Makefile.android
304 @$(MAKE) -f Makefile.android $@ \
305 ARCH="$(basename $@)" \
306 MODE="$(subst .,,$(suffix $@))" \
308 GYPFLAGS="$(GYPFLAGS)"
310 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
312 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
313 Makefile.nacl must-set-NACL_SDK_ROOT
314 @$(MAKE) -f Makefile.nacl $@ \
315 ARCH="$(basename $@)" \
316 MODE="$(subst .,,$(suffix $@))" \
318 GYPFLAGS="$(GYPFLAGS)"
322 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
323 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
326 $(addsuffix .check,$(MODES)): $$(basename $$@)
327 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
328 --mode=$(basename $@) $(TESTFLAGS)
330 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
331 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
332 --arch=$(basename $@) $(TESTFLAGS)
334 $(CHECKS): $$(basename $$@)
335 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
336 --arch-and-mode=$(basename $@) $(TESTFLAGS)
338 $(addsuffix .quickcheck,$(MODES)): $$(basename $$@)
339 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
340 --mode=$(basename $@) $(TESTFLAGS) --quickcheck
342 $(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@)
343 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
344 --arch=$(basename $@) $(TESTFLAGS) --quickcheck
346 $(QUICKCHECKS): $$(basename $$@)
347 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
348 --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck
350 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
351 @tools/android-sync.sh $(basename $@) $(OUTDIR) \
352 $(shell pwd) $(ANDROID_V8)
354 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
355 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
356 --arch-and-mode=$(basename $@) \
358 --command-prefix="tools/android-run.py" $(TESTFLAGS)
360 $(addsuffix .check, $(ANDROID_ARCHES)): \
361 $(addprefix $$(basename $$@).,$(MODES)).check
363 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
364 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
365 --arch-and-mode=$(basename $@) \
366 --timeout=600 --nopresubmit --noi18n \
367 --command-prefix="tools/nacl-run.py"
369 $(addsuffix .check, $(NACL_ARCHES)): \
370 $(addprefix $$(basename $$@).,$(MODES)).check
373 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
374 --arch-and-mode=. $(TESTFLAGS)
376 SUPERFASTTESTMODES = ia32.release
377 FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release
378 FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug
382 SPACE = $(EMPTY) $(EMPTY)
383 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
384 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
385 --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \
386 --download-data mozilla webkit
387 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
388 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
391 # Clean targets. You can clean each architecture individually, or everything.
392 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
393 rm -f $(OUTDIR)/Makefile.$(basename $@)*
394 rm -rf $(OUTDIR)/$(basename $@).release
395 rm -rf $(OUTDIR)/$(basename $@).debug
396 rm -rf $(OUTDIR)/$(basename $@).optdebug
397 find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
400 rm -f $(OUTDIR)/Makefile.native
401 rm -rf $(OUTDIR)/native
402 find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
404 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean gtags.clean
406 # GYP file generation targets.
407 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
408 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
409 $(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
410 cut -f 2 -d " " | cut -f 1 -d "-" ))
411 $(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
412 $(eval V8_TARGET_ARCH:=$(subst .,,$(suffix $(basename $@))))
413 GYP_GENERATORS=make \
414 tools/gyp/gyp --generator-output="$(OUTDIR)" node.gyp \
415 -Icommon.gypi --depth=. \
416 -Dtarget_arch=$(V8_TARGET_ARCH) \
417 -Dv8_target_arch=$(V8_TARGET_ARCH) \
418 $(if $(findstring $(CXX_TARGET_ARCH),$(V8_TARGET_ARCH)), \
419 -Dtarget_arch=$(V8_TARGET_ARCH),) \
420 $(if $(findstring optdebug,$@),-Dv8_optimized_debug=2,) \
421 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
423 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
424 GYP_GENERATORS=make \
425 tools/gyp/gyp --generator-output="$(OUTDIR)" node.gyp \
426 -Icommon.gypi --depth=. -S.native $(GYPFLAGS)
428 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
429 ifndef ANDROID_NDK_ROOT
430 ifndef ANDROID_TOOLCHAIN
431 $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
435 # Note that NACL_SDK_ROOT must be set to point to an appropriate
436 # Native Client SDK before using this makefile. You can download
438 # https://developers.google.com/native-client/sdk/download
439 # The path indicated by NACL_SDK_ROOT will typically end with
440 # a folder for a pepper version such as "pepper_25" that should
441 # have "tools" and "toolchain" subdirectories.
442 must-set-NACL_SDK_ROOT:
444 $(error NACL_SDK_ROOT must be set)
447 # Replaces the old with the new environment file if they're different, which
448 # will trigger GYP to regenerate Makefiles.
449 $(ENVFILE): $(ENVFILE).new
450 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
451 then rm $(ENVFILE).new; \
452 else mv $(ENVFILE).new $(ENVFILE); fi
454 # Stores current GYPFLAGS in a file.
456 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
457 echo "CXX=$(CXX)" >> $(ENVFILE).new
459 # Heap constants for grokdump.
460 DUMP_FILE = tools/v8heapconst.py
461 grokdump: ia32.release
462 @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
463 @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
465 # Support for the GNU GLOBAL Source Code Tag System.
466 gtags.files: $(GYPFILES) $(ENVFILE)
467 @find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@
469 # We need to manually set the stack limit here, to work around bugs in
470 # gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
471 GPATH GRTAGS GSYMS GTAGS: gtags.files $(shell cat gtags.files 2> /dev/null)
472 @bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
475 rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
477 # Dependencies. "builddeps" are dependencies required solely for building,
478 # "dependencies" includes also dependencies required for development.
479 # Remember to keep these in sync with the DEPS file.
481 svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \
483 if svn info third_party/icu 2>&1 | grep -q icu46 ; then \
485 https://src.chromium.org/chrome/trunk/deps/third_party/icu52 \
486 third_party/icu --revision 277999 ; \
488 svn checkout --force \
489 https://src.chromium.org/chrome/trunk/deps/third_party/icu52 \
490 third_party/icu --revision 277999 ; \
492 svn checkout --force http://googletest.googlecode.com/svn/trunk \
493 testing/gtest --revision 692
494 svn checkout --force http://googlemock.googlecode.com/svn/trunk \
495 testing/gmock --revision 485
497 dependencies: builddeps
498 # The spec is a copy of the hooks in v8's DEPS file.
499 gclient sync -r fb782d4369d5ae04f17a2fceef7de5a63e50f07b --spec="solutions = [{u'managed': False, u'name': u'buildtools', u'url': u'https://chromium.googlesource.com/chromium/buildtools.git', u'custom_deps': {}, u'custom_hooks': [{u'name': u'clang_format_win',u'pattern': u'.',u'action': [u'download_from_google_storage',u'--no_resume',u'--platform=win32',u'--no_auth',u'--bucket',u'chromium-clang-format',u'-s',u'buildtools/win/clang-format.exe.sha1']},{u'name': u'clang_format_mac',u'pattern': u'.',u'action': [u'download_from_google_storage',u'--no_resume',u'--platform=darwin',u'--no_auth',u'--bucket',u'chromium-clang-format',u'-s',u'buildtools/mac/clang-format.sha1']},{u'name': u'clang_format_linux',u'pattern': u'.',u'action': [u'download_from_google_storage',u'--no_resume',u'--platform=linux*',u'--no_auth',u'--bucket',u'chromium-clang-format',u'-s',u'buildtools/linux64/clang-format.sha1']}],u'deps_file': u'.DEPS.git', u'safesync_url': u''}]"