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.
37 ANDROID_NDK_HOST_ARCH ?=
39 ANDROID_V8 ?= /data/local/tmp/v8
42 # Special build flags. Use them like this: "make library=shared"
44 # library=shared || component=shared_library
45 ifeq ($(library), shared)
46 GYPFLAGS += -Dcomponent=shared_library
49 GYPFLAGS += -Dcomponent=$(component)
53 GYPFLAGS += -Dconsole=$(console)
56 ifeq ($(disassembler), on)
57 GYPFLAGS += -Dv8_enable_disassembler=1
60 ifeq ($(objectprint), on)
61 GYPFLAGS += -Dv8_object_print=1
64 ifeq ($(verifyheap), on)
65 GYPFLAGS += -Dv8_enable_verify_heap=1
68 ifeq ($(backtrace), off)
69 GYPFLAGS += -Dv8_enable_backtrace=0
71 GYPFLAGS += -Dv8_enable_backtrace=1
74 ifeq ($(snapshot), off)
75 GYPFLAGS += -Dv8_use_snapshot='false'
78 ifeq ($(extrachecks), on)
79 GYPFLAGS += -Dv8_enable_extra_checks=1 -Dv8_enable_handle_zapping=1
81 ifeq ($(extrachecks), off)
82 GYPFLAGS += -Dv8_enable_extra_checks=0 -Dv8_enable_handle_zapping=0
86 GYPFLAGS += -Dv8_enable_gdbjit=1
89 GYPFLAGS += -Dv8_enable_gdbjit=0
92 ifeq ($(vtunejit), on)
93 GYPFLAGS += -Dv8_enable_vtunejit=1
96 ifeq ($(optdebug), on)
97 GYPFLAGS += -Dv8_optimized_debug=2
100 ifeq ($(unalignedaccess), on)
101 GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
103 # randomseed=12345, disable random seed via randomseed=0
105 GYPFLAGS += -Dv8_random_seed=$(randomseed)
107 # soname_version=1.2.3
109 GYPFLAGS += -Dsoname_version=$(soname_version)
113 GYPFLAGS += -Dwerror=''
116 ifeq ($(presubmit), no)
117 TESTFLAGS += --no-presubmit
119 # strictaliasing=off (workaround for GCC-4.5)
120 ifeq ($(strictaliasing), off)
121 GYPFLAGS += -Dv8_no_strict_aliasing=1
124 ifeq ($(regexp), interpreted)
125 GYPFLAGS += -Dv8_interpreted_regexp=1
128 ifeq ($(i18nsupport), off)
129 GYPFLAGS += -Dv8_enable_i18n_support=0
130 TESTFLAGS += --noi18n
132 # deprecation_warnings=on
133 ifeq ($(deprecationwarnings), on)
134 GYPFLAGS += -Dv8_deprecation_warnings=1
136 # asan=/path/to/clang++
137 ifneq ($(strip $(asan)),)
140 export CXX_host=$(asan)
142 export ASAN_SYMBOLIZER_PATH="$(dir $(asan))llvm-symbolizer"
145 # arm specific flags.
146 # arm_version=<number | "default">
147 ifneq ($(strip $(arm_version)),)
148 GYPFLAGS += -Darm_version=$(arm_version)
150 # Deprecated (use arm_version instead): armv7=false/true
151 ifeq ($(armv7), false)
152 GYPFLAGS += -Darm_version=6
154 ifeq ($(armv7), true)
155 GYPFLAGS += -Darm_version=7
159 # vfp2=off. Deprecated, use armfpu=
160 # vfp3=off. Deprecated, use armfpu=
162 GYPFLAGS += -Darm_fpu=vfp
164 # hardfp=on/off. Deprecated, use armfloatabi
166 GYPFLAGS += -Darm_float_abi=hard
169 GYPFLAGS += -Darm_float_abi=softfp
173 ifeq ($(armneon), on)
174 GYPFLAGS += -Darm_neon=1
177 # xxx: vfp, vfpv3-d16, vfpv3, neon.
180 GYPFLAGS += -Darm_fpu=default
183 GYPFLAGS += -Darm_fpu=$(armfpu)
185 # float abi: armfloatabi=softfp/hard
186 ifeq ($(armfloatabi),)
188 GYPFLAGS += -Darm_float_abi=default
191 GYPFLAGS += -Darm_float_abi=$(armfloatabi)
194 ifeq ($(armthumb), off)
195 GYPFLAGS += -Darm_thumb=0
197 ifeq ($(armthumb), on)
198 GYPFLAGS += -Darm_thumb=1
202 # With this flag set, by default v8 will only use features implied
203 # by the compiler (no probe). This is done by modifying the default
204 # values of enable_armv7, enable_vfp2, enable_vfp3 and enable_32dregs.
205 # Modifying these flags when launching v8 will enable the probing for
206 # the specified values.
207 # When using the simulator, this flag is implied.
208 ifeq ($(armtest), on)
209 GYPFLAGS += -Darm_test=on
212 # ----------------- available targets: --------------------
213 # - "dependencies": pulls in external dependencies (currently: GYP)
214 # - "grokdump": rebuilds heap constants lists used by grokdump
215 # - any arch listed in ARCHES (see below)
216 # - any mode listed in MODES
217 # - every combination <arch>.<mode>, e.g. "ia32.release"
218 # - "native": current host's architecture, release mode
219 # - any of the above with .check appended, e.g. "ia32.release.check"
220 # - "android": cross-compile for Android/ARM
221 # - "nacl" : cross-compile for Native Client (ia32 and x64)
222 # - default (no target specified): build all DEFAULT_ARCHES and MODES
223 # - "check": build all targets and run all tests
224 # - "<arch>.clean" for any <arch> in ARCHES
225 # - "clean": clean all ARCHES
227 # ----------------- internal stuff ------------------------
229 # Architectures and modes to be compiled. Consider these to be internal
230 # variables, don't override them (use the targets instead).
231 ARCHES = ia32 x64 arm arm64 mips mipsel
232 DEFAULT_ARCHES = ia32 x64 arm
233 MODES = release debug optdebug
234 DEFAULT_MODES = release debug
235 ANDROID_ARCHES = android_ia32 android_arm android_arm64 android_mipsel
236 NACL_ARCHES = nacl_ia32 nacl_x64
238 # List of files that trigger Makefile regeneration:
239 GYPFILES = build/all.gyp build/features.gypi build/standalone.gypi \
240 build/toolchain.gypi samples/samples.gyp src/d8.gyp \
241 test/cctest/cctest.gyp 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 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 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
410 PYTHONPATH="$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
411 GYP_GENERATORS=make \
412 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
413 -Ibuild/standalone.gypi --depth=. \
414 -Dv8_target_arch=$(subst .,,$(suffix $(basename $@))) \
415 $(if $(findstring optdebug,$@),-Dv8_optimized_debug=2,) \
416 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
418 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
419 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
420 PYTHONPATH="$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
421 GYP_GENERATORS=make \
422 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
423 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
425 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
426 ifndef ANDROID_NDK_ROOT
427 ifndef ANDROID_TOOLCHAIN
428 $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
432 # Note that NACL_SDK_ROOT must be set to point to an appropriate
433 # Native Client SDK before using this makefile. You can download
435 # https://developers.google.com/native-client/sdk/download
436 # The path indicated by NACL_SDK_ROOT will typically end with
437 # a folder for a pepper version such as "pepper_25" that should
438 # have "tools" and "toolchain" subdirectories.
439 must-set-NACL_SDK_ROOT:
441 $(error NACL_SDK_ROOT must be set)
444 # Replaces the old with the new environment file if they're different, which
445 # will trigger GYP to regenerate Makefiles.
446 $(ENVFILE): $(ENVFILE).new
447 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
448 then rm $(ENVFILE).new; \
449 else mv $(ENVFILE).new $(ENVFILE); fi
451 # Stores current GYPFLAGS in a file.
453 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
454 echo "CXX=$(CXX)" >> $(ENVFILE).new
456 # Heap constants for grokdump.
457 DUMP_FILE = tools/v8heapconst.py
458 grokdump: ia32.release
459 @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
460 @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
462 # Support for the GNU GLOBAL Source Code Tag System.
463 gtags.files: $(GYPFILES) $(ENVFILE)
464 @find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@
466 # We need to manually set the stack limit here, to work around bugs in
467 # gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
468 GPATH GRTAGS GSYMS GTAGS: gtags.files $(shell cat gtags.files 2> /dev/null)
469 @bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
472 rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
475 # Remember to keep these in sync with the DEPS file.
477 svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \
479 svn checkout --force \
480 https://src.chromium.org/chrome/trunk/deps/third_party/icu46 \
481 third_party/icu --revision 258359