• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4# met:
5#
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.
15#
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.
27
28
29# Variable default definitions. Override them by exporting them in your shell.
30CXX ?= g++
31LINK ?= g++
32OUTDIR ?= out
33TESTJOBS ?=
34GYPFLAGS ?=
35TESTFLAGS ?=
36ANDROID_NDK_ROOT ?=
37ANDROID_NDK_HOST_ARCH ?=
38ANDROID_TOOLCHAIN ?=
39ANDROID_V8 ?= /data/local/tmp/v8
40NACL_SDK_ROOT ?=
41
42# Special build flags. Use them like this: "make library=shared"
43
44# library=shared || component=shared_library
45ifeq ($(library), shared)
46  GYPFLAGS += -Dcomponent=shared_library
47endif
48ifdef component
49  GYPFLAGS += -Dcomponent=$(component)
50endif
51# console=readline
52ifdef console
53  GYPFLAGS += -Dconsole=$(console)
54endif
55# disassembler=on
56ifeq ($(disassembler), on)
57  GYPFLAGS += -Dv8_enable_disassembler=1
58endif
59# objectprint=on
60ifeq ($(objectprint), on)
61  GYPFLAGS += -Dv8_object_print=1
62endif
63# verifyheap=on
64ifeq ($(verifyheap), on)
65  GYPFLAGS += -Dv8_enable_verify_heap=1
66endif
67# backtrace=off
68ifeq ($(backtrace), off)
69  GYPFLAGS += -Dv8_enable_backtrace=0
70else
71  GYPFLAGS += -Dv8_enable_backtrace=1
72endif
73# snapshot=off
74ifeq ($(snapshot), off)
75  GYPFLAGS += -Dv8_use_snapshot='false'
76endif
77# extrachecks=on/off
78ifeq ($(extrachecks), on)
79  GYPFLAGS += -Dv8_enable_extra_checks=1 -Dv8_enable_handle_zapping=1
80endif
81ifeq ($(extrachecks), off)
82  GYPFLAGS += -Dv8_enable_extra_checks=0 -Dv8_enable_handle_zapping=0
83endif
84# gdbjit=on/off
85ifeq ($(gdbjit), on)
86  GYPFLAGS += -Dv8_enable_gdbjit=1
87endif
88ifeq ($(gdbjit), off)
89  GYPFLAGS += -Dv8_enable_gdbjit=0
90endif
91# vtunejit=on
92ifeq ($(vtunejit), on)
93  GYPFLAGS += -Dv8_enable_vtunejit=1
94endif
95# optdebug=on
96ifeq ($(optdebug), on)
97  GYPFLAGS += -Dv8_optimized_debug=2
98endif
99# unalignedaccess=on
100ifeq ($(unalignedaccess), on)
101  GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
102endif
103# randomseed=12345, disable random seed via randomseed=0
104ifdef randomseed
105  GYPFLAGS += -Dv8_random_seed=$(randomseed)
106endif
107# soname_version=1.2.3
108ifdef soname_version
109  GYPFLAGS += -Dsoname_version=$(soname_version)
110endif
111# werror=no
112ifeq ($(werror), no)
113  GYPFLAGS += -Dwerror=''
114endif
115# presubmit=no
116ifeq ($(presubmit), no)
117  TESTFLAGS += --no-presubmit
118endif
119# strictaliasing=off (workaround for GCC-4.5)
120ifeq ($(strictaliasing), off)
121  GYPFLAGS += -Dv8_no_strict_aliasing=1
122endif
123# regexp=interpreted
124ifeq ($(regexp), interpreted)
125  GYPFLAGS += -Dv8_interpreted_regexp=1
126endif
127# i18nsupport=off
128ifeq ($(i18nsupport), off)
129  GYPFLAGS += -Dv8_enable_i18n_support=0
130  TESTFLAGS += --noi18n
131endif
132# deprecation_warnings=on
133ifeq ($(deprecationwarnings), on)
134  GYPFLAGS += -Dv8_deprecation_warnings=1
135endif
136# asan=/path/to/clang++
137ifneq ($(strip $(asan)),)
138  GYPFLAGS += -Dasan=1
139  export CXX=$(asan)
140  export CXX_host=$(asan)
141  export LINK=$(asan)
142  export ASAN_SYMBOLIZER_PATH="$(dir $(asan))llvm-symbolizer"
143endif
144
145# arm specific flags.
146# arm_version=<number | "default">
147ifneq ($(strip $(arm_version)),)
148  GYPFLAGS += -Darm_version=$(arm_version)
149else
150# Deprecated (use arm_version instead): armv7=false/true
151ifeq ($(armv7), false)
152  GYPFLAGS += -Darm_version=6
153else
154ifeq ($(armv7), true)
155  GYPFLAGS += -Darm_version=7
156endif
157endif
158endif
159# hardfp=on/off. Deprecated, use armfloatabi
160ifeq ($(hardfp),on)
161  GYPFLAGS += -Darm_float_abi=hard
162else
163ifeq ($(hardfp),off)
164  GYPFLAGS += -Darm_float_abi=softfp
165endif
166endif
167# fpu: armfpu=xxx
168# xxx: vfp, vfpv3-d16, vfpv3, neon.
169ifeq ($(armfpu),)
170  GYPFLAGS += -Darm_fpu=default
171else
172  GYPFLAGS += -Darm_fpu=$(armfpu)
173endif
174# float abi: armfloatabi=softfp/hard
175ifeq ($(armfloatabi),)
176ifeq ($(hardfp),)
177  GYPFLAGS += -Darm_float_abi=default
178endif
179else
180  GYPFLAGS += -Darm_float_abi=$(armfloatabi)
181endif
182# armthumb=on/off
183ifeq ($(armthumb), off)
184  GYPFLAGS += -Darm_thumb=0
185else
186ifeq ($(armthumb), on)
187  GYPFLAGS += -Darm_thumb=1
188endif
189endif
190# armtest=on
191# With this flag set, by default v8 will only use features implied
192# by the compiler (no probe). This is done by modifying the default
193# values of enable_armv7, enable_vfp3, enable_32dregs and enable_neon.
194# Modifying these flags when launching v8 will enable the probing for
195# the specified values.
196# When using the simulator, this flag is implied.
197ifeq ($(armtest), on)
198  GYPFLAGS += -Darm_test=on
199endif
200
201# ----------------- available targets: --------------------
202# - "dependencies": pulls in external dependencies (currently: GYP)
203# - "grokdump": rebuilds heap constants lists used by grokdump
204# - any arch listed in ARCHES (see below)
205# - any mode listed in MODES
206# - every combination <arch>.<mode>, e.g. "ia32.release"
207# - "native": current host's architecture, release mode
208# - any of the above with .check appended, e.g. "ia32.release.check"
209# - "android": cross-compile for Android/ARM
210# - "nacl" : cross-compile for Native Client (ia32 and x64)
211# - default (no target specified): build all DEFAULT_ARCHES and MODES
212# - "check": build all targets and run all tests
213# - "<arch>.clean" for any <arch> in ARCHES
214# - "clean": clean all ARCHES
215
216# ----------------- internal stuff ------------------------
217
218# Architectures and modes to be compiled. Consider these to be internal
219# variables, don't override them (use the targets instead).
220ARCHES = ia32 x64 arm arm64 mips mipsel x87
221DEFAULT_ARCHES = ia32 x64 arm
222MODES = release debug optdebug
223DEFAULT_MODES = release debug
224ANDROID_ARCHES = android_ia32 android_arm android_arm64 android_mipsel android_x87
225NACL_ARCHES = nacl_ia32 nacl_x64
226
227# List of files that trigger Makefile regeneration:
228GYPFILES = build/all.gyp build/features.gypi build/standalone.gypi \
229           build/toolchain.gypi samples/samples.gyp src/d8.gyp \
230           test/cctest/cctest.gyp tools/gyp/v8.gyp
231
232# If vtunejit=on, the v8vtune.gyp will be appended.
233ifeq ($(vtunejit), on)
234  GYPFILES += src/third_party/vtune/v8vtune.gyp
235endif
236# Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
237BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
238ANDROID_BUILDS = $(foreach mode,$(MODES), \
239                   $(addsuffix .$(mode),$(ANDROID_ARCHES)))
240NACL_BUILDS = $(foreach mode,$(MODES), \
241                   $(addsuffix .$(mode),$(NACL_ARCHES)))
242# Generates corresponding test targets, e.g. "ia32.release.check".
243CHECKS = $(addsuffix .check,$(BUILDS))
244QUICKCHECKS = $(addsuffix .quickcheck,$(BUILDS))
245ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
246NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
247# File where previously used GYPFLAGS are stored.
248ENVFILE = $(OUTDIR)/environment
249
250.PHONY: all check clean dependencies $(ENVFILE).new native \
251        qc quickcheck $(QUICKCHECKS) \
252        $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \
253        $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
254        $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
255        $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
256        must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \
257        $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
258        must-set-NACL_SDK_ROOT
259
260# Target definitions. "all" is the default.
261all: $(DEFAULT_MODES)
262
263# Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
264# having been created before.
265buildbot:
266	$(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
267	        builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
268
269# Compile targets. MODES and ARCHES are convenience targets.
270.SECONDEXPANSION:
271$(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
272
273$(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
274
275# Defines how to build a particular target (e.g. ia32.release).
276$(BUILDS): $(OUTDIR)/Makefile.$$@
277	@$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
278	         CXX="$(CXX)" LINK="$(LINK)" \
279	         BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
280	                     python -c "print \
281	                     raw_input().replace('opt', '').capitalize()") \
282	         builddir="$(shell pwd)/$(OUTDIR)/$@"
283
284native: $(OUTDIR)/Makefile.native
285	@$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
286	         CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
287	         builddir="$(shell pwd)/$(OUTDIR)/$@"
288
289$(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
290
291$(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \
292                   must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN Makefile.android
293	@$(MAKE) -f Makefile.android $@ \
294	        ARCH="$(basename $@)" \
295	        MODE="$(subst .,,$(suffix $@))" \
296	        OUTDIR="$(OUTDIR)" \
297	        GYPFLAGS="$(GYPFLAGS)"
298
299$(NACL_ARCHES): $(addprefix $$@.,$(MODES))
300
301$(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
302		   Makefile.nacl must-set-NACL_SDK_ROOT
303	@$(MAKE) -f Makefile.nacl $@ \
304	        ARCH="$(basename $@)" \
305	        MODE="$(subst .,,$(suffix $@))" \
306	        OUTDIR="$(OUTDIR)" \
307	        GYPFLAGS="$(GYPFLAGS)"
308
309# Test targets.
310check: all
311	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
312	    --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
313	    $(TESTFLAGS)
314
315$(addsuffix .check,$(MODES)): $$(basename $$@)
316	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
317	    --mode=$(basename $@) $(TESTFLAGS)
318
319$(addsuffix .check,$(ARCHES)): $$(basename $$@)
320	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
321	    --arch=$(basename $@) $(TESTFLAGS)
322
323$(CHECKS): $$(basename $$@)
324	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
325	    --arch-and-mode=$(basename $@) $(TESTFLAGS)
326
327$(addsuffix .quickcheck,$(MODES)): $$(basename $$@)
328	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
329	    --mode=$(basename $@) $(TESTFLAGS) --quickcheck
330
331$(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@)
332	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
333	    --arch=$(basename $@) $(TESTFLAGS) --quickcheck
334
335$(QUICKCHECKS): $$(basename $$@)
336	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
337	    --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck
338
339$(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
340	@tools/android-sync.sh $(basename $@) $(OUTDIR) \
341	                       $(shell pwd) $(ANDROID_V8)
342
343$(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
344	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
345	     --arch-and-mode=$(basename $@) \
346	     --timeout=600 \
347	     --command-prefix="tools/android-run.py" $(TESTFLAGS)
348
349$(addsuffix .check, $(ANDROID_ARCHES)): \
350                $(addprefix $$(basename $$@).,$(MODES)).check
351
352$(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
353	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
354	     --arch-and-mode=$(basename $@) \
355	     --timeout=600 --nopresubmit --noi18n \
356	     --command-prefix="tools/nacl-run.py"
357
358$(addsuffix .check, $(NACL_ARCHES)): \
359                $(addprefix $$(basename $$@).,$(MODES)).check
360
361native.check: native
362	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
363	    --arch-and-mode=. $(TESTFLAGS)
364
365SUPERFASTTESTMODES = ia32.release
366FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release
367FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug
368
369COMMA = ,
370EMPTY =
371SPACE = $(EMPTY) $(EMPTY)
372quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
373	tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
374	    --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \
375	    --download-data mozilla webkit
376	tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
377	    --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
378qc: quickcheck
379
380# Clean targets. You can clean each architecture individually, or everything.
381$(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
382	rm -f $(OUTDIR)/Makefile.$(basename $@)*
383	rm -rf $(OUTDIR)/$(basename $@).release
384	rm -rf $(OUTDIR)/$(basename $@).debug
385	rm -rf $(OUTDIR)/$(basename $@).optdebug
386	find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
387
388native.clean:
389	rm -f $(OUTDIR)/Makefile.native
390	rm -rf $(OUTDIR)/native
391	find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
392
393clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean gtags.clean
394
395# GYP file generation targets.
396OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
397$(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
398	PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
399	PYTHONPATH="$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
400	GYP_GENERATORS=make \
401	build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
402	              -Ibuild/standalone.gypi --depth=. \
403	              -Dv8_target_arch=$(subst .,,$(suffix $(basename $@))) \
404	              $(if $(findstring optdebug,$@),-Dv8_optimized_debug=2,) \
405	              -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
406
407$(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
408	PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
409	PYTHONPATH="$(shell pwd)/build/gyp/pylib:$(PYTHONPATH)" \
410	GYP_GENERATORS=make \
411	build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
412	              -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
413
414must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
415ifndef ANDROID_NDK_ROOT
416ifndef ANDROID_TOOLCHAIN
417	  $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
418endif
419endif
420
421# Note that NACL_SDK_ROOT must be set to point to an appropriate
422# Native Client SDK before using this makefile. You can download
423# an SDK here:
424#   https://developers.google.com/native-client/sdk/download
425# The path indicated by NACL_SDK_ROOT will typically end with
426# a folder for a pepper version such as "pepper_25" that should
427# have "tools" and "toolchain" subdirectories.
428must-set-NACL_SDK_ROOT:
429ifndef NACL_SDK_ROOT
430	  $(error NACL_SDK_ROOT must be set)
431endif
432
433# Replaces the old with the new environment file if they're different, which
434# will trigger GYP to regenerate Makefiles.
435$(ENVFILE): $(ENVFILE).new
436	@if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
437	    then rm $(ENVFILE).new; \
438	    else mv $(ENVFILE).new $(ENVFILE); fi
439
440# Stores current GYPFLAGS in a file.
441$(ENVFILE).new:
442	@mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
443	    echo "CXX=$(CXX)" >> $(ENVFILE).new
444
445# Heap constants for grokdump.
446DUMP_FILE = tools/v8heapconst.py
447grokdump: ia32.release
448	@cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
449	@$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
450
451# Support for the GNU GLOBAL Source Code Tag System.
452gtags.files: $(GYPFILES) $(ENVFILE)
453	@find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@
454
455# We need to manually set the stack limit here, to work around bugs in
456# gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
457GPATH GRTAGS GSYMS GTAGS: gtags.files $(shell cat gtags.files 2> /dev/null)
458	@bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
459
460gtags.clean:
461	rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
462
463# Dependencies.
464# Remember to keep these in sync with the DEPS file.
465dependencies:
466	svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \
467	    --revision 1831
468	svn checkout --force \
469	    https://src.chromium.org/chrome/trunk/deps/third_party/icu46 \
470	    third_party/icu --revision 258359
471	( test -d buildtools || \
472	  git clone https://chromium.googlesource.com/chromium/buildtools.git; \
473	  cd buildtools; \
474	  git fetch origin; \
475	  git checkout 5d89977ce55240995d1596fe420b818468f5ec37 )
476