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 ($(debuggersupport), off)
101 GYPFLAGS += -Dv8_enable_debugger_support=0
104 ifeq ($(unalignedaccess), on)
105 GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
107 # randomseed=12345, disable random seed via randomseed=0
109 GYPFLAGS += -Dv8_random_seed=$(randomseed)
111 # soname_version=1.2.3
113 GYPFLAGS += -Dsoname_version=$(soname_version)
117 GYPFLAGS += -Dwerror=''
120 ifeq ($(presubmit), no)
121 TESTFLAGS += --no-presubmit
123 # strictaliasing=off (workaround for GCC-4.5)
124 ifeq ($(strictaliasing), off)
125 GYPFLAGS += -Dv8_no_strict_aliasing=1
128 ifeq ($(regexp), interpreted)
129 GYPFLAGS += -Dv8_interpreted_regexp=1
132 ifeq ($(i18nsupport), off)
133 GYPFLAGS += -Dv8_enable_i18n_support=0
134 TESTFLAGS += --noi18n
136 # deprecation_warnings=on
137 ifeq ($(deprecationwarnings), on)
138 GYPFLAGS += -Dv8_deprecation_warnings=1
140 # arm specific flags.
141 # arm_version=<number | "default">
142 ifneq ($(strip $(arm_version)),)
143 GYPFLAGS += -Darm_version=$(arm_version)
145 # Deprecated (use arm_version instead): armv7=false/true
146 ifeq ($(armv7), false)
147 GYPFLAGS += -Darm_version=6
149 ifeq ($(armv7), true)
150 GYPFLAGS += -Darm_version=7
154 # vfp2=off. Deprecated, use armfpu=
155 # vfp3=off. Deprecated, use armfpu=
157 GYPFLAGS += -Darm_fpu=vfp
159 # hardfp=on/off. Deprecated, use armfloatabi
161 GYPFLAGS += -Darm_float_abi=hard
164 GYPFLAGS += -Darm_float_abi=softfp
168 ifeq ($(armneon), on)
169 GYPFLAGS += -Darm_neon=1
172 # xxx: vfp, vfpv3-d16, vfpv3, neon.
175 GYPFLAGS += -Darm_fpu=default
178 GYPFLAGS += -Darm_fpu=$(armfpu)
180 # float abi: armfloatabi=softfp/hard
181 ifeq ($(armfloatabi),)
183 GYPFLAGS += -Darm_float_abi=default
186 GYPFLAGS += -Darm_float_abi=$(armfloatabi)
189 ifeq ($(armthumb), off)
190 GYPFLAGS += -Darm_thumb=0
192 ifeq ($(armthumb), on)
193 GYPFLAGS += -Darm_thumb=1
197 # With this flag set, by default v8 will only use features implied
198 # by the compiler (no probe). This is done by modifying the default
199 # values of enable_armv7, enable_vfp2, enable_vfp3 and enable_32dregs.
200 # Modifying these flags when launching v8 will enable the probing for
201 # the specified values.
202 # When using the simulator, this flag is implied.
203 ifeq ($(armtest), on)
204 GYPFLAGS += -Darm_test=on
207 # ----------------- available targets: --------------------
208 # - "dependencies": pulls in external dependencies (currently: GYP)
209 # - "grokdump": rebuilds heap constants lists used by grokdump
210 # - any arch listed in ARCHES (see below)
211 # - any mode listed in MODES
212 # - every combination <arch>.<mode>, e.g. "ia32.release"
213 # - "native": current host's architecture, release mode
214 # - any of the above with .check appended, e.g. "ia32.release.check"
215 # - "android": cross-compile for Android/ARM
216 # - "nacl" : cross-compile for Native Client (ia32 and x64)
217 # - default (no target specified): build all DEFAULT_ARCHES and MODES
218 # - "check": build all targets and run all tests
219 # - "<arch>.clean" for any <arch> in ARCHES
220 # - "clean": clean all ARCHES
222 # ----------------- internal stuff ------------------------
224 # Architectures and modes to be compiled. Consider these to be internal
225 # variables, don't override them (use the targets instead).
226 ARCHES = ia32 x64 arm mipsel
227 DEFAULT_ARCHES = ia32 x64 arm
228 MODES = release debug optdebug
229 DEFAULT_MODES = release debug
230 ANDROID_ARCHES = android_ia32 android_arm android_mipsel
231 NACL_ARCHES = nacl_ia32 nacl_x64
233 # List of files that trigger Makefile regeneration:
234 GYPFILES = build/all.gyp build/features.gypi build/standalone.gypi \
235 build/toolchain.gypi samples/samples.gyp src/d8.gyp \
236 test/cctest/cctest.gyp tools/gyp/v8.gyp
238 # If vtunejit=on, the v8vtune.gyp will be appended.
239 ifeq ($(vtunejit), on)
240 GYPFILES += src/third_party/vtune/v8vtune.gyp
242 # Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
243 BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
244 ANDROID_BUILDS = $(foreach mode,$(MODES), \
245 $(addsuffix .$(mode),$(ANDROID_ARCHES)))
246 NACL_BUILDS = $(foreach mode,$(MODES), \
247 $(addsuffix .$(mode),$(NACL_ARCHES)))
248 # Generates corresponding test targets, e.g. "ia32.release.check".
249 CHECKS = $(addsuffix .check,$(BUILDS))
250 ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
251 NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
252 # File where previously used GYPFLAGS are stored.
253 ENVFILE = $(OUTDIR)/environment
255 .PHONY: all check clean dependencies $(ENVFILE).new native \
257 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
258 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
259 $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
260 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \
261 $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
262 must-set-NACL_SDK_ROOT
264 # Target definitions. "all" is the default.
265 all: $(DEFAULT_MODES)
267 # Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
268 # having been created before.
270 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
271 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
273 mips mips.release mips.debug:
274 @echo "V8 does not support big-endian MIPS builds at the moment," \
275 "please use little-endian builds (mipsel)."
277 # Compile targets. MODES and ARCHES are convenience targets.
279 $(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
281 $(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
283 # Defines how to build a particular target (e.g. ia32.release).
284 $(BUILDS): $(OUTDIR)/Makefile.$$@
285 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
286 CXX="$(CXX)" LINK="$(LINK)" \
287 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
289 raw_input().replace('opt', '').capitalize()") \
290 builddir="$(shell pwd)/$(OUTDIR)/$@"
292 native: $(OUTDIR)/Makefile.native
293 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
294 CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
295 builddir="$(shell pwd)/$(OUTDIR)/$@"
297 $(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
299 $(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \
300 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN Makefile.android
301 @$(MAKE) -f Makefile.android $@ \
302 ARCH="$(basename $@)" \
303 MODE="$(subst .,,$(suffix $@))" \
305 GYPFLAGS="$(GYPFLAGS)"
307 $(NACL_ARCHES): $(addprefix $$@.,$(MODES))
309 $(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
310 Makefile.nacl must-set-NACL_SDK_ROOT
311 @$(MAKE) -f Makefile.nacl $@ \
312 ARCH="$(basename $@)" \
313 MODE="$(subst .,,$(suffix $@))" \
315 GYPFLAGS="$(GYPFLAGS)"
319 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
320 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
323 $(addsuffix .check,$(MODES)): $$(basename $$@)
324 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
325 --mode=$(basename $@) $(TESTFLAGS)
327 $(addsuffix .check,$(ARCHES)): $$(basename $$@)
328 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
329 --arch=$(basename $@) $(TESTFLAGS)
331 $(CHECKS): $$(basename $$@)
332 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
333 --arch-and-mode=$(basename $@) $(TESTFLAGS)
335 $(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
336 @tools/android-sync.sh $(basename $@) $(OUTDIR) \
337 $(shell pwd) $(ANDROID_V8)
339 $(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
340 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
341 --arch-and-mode=$(basename $@) \
343 --command-prefix="tools/android-run.py" $(TESTFLAGS)
345 $(addsuffix .check, $(ANDROID_ARCHES)): \
346 $(addprefix $$(basename $$@).,$(MODES)).check
348 $(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
349 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
350 --arch-and-mode=$(basename $@) \
351 --timeout=600 --nopresubmit --noi18n \
352 --command-prefix="tools/nacl-run.py"
354 $(addsuffix .check, $(NACL_ARCHES)): \
355 $(addprefix $$(basename $$@).,$(MODES)).check
358 @tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
359 --arch-and-mode=. $(TESTFLAGS)
361 FASTTESTMODES = ia32.release,x64.release,ia32.optdebug,x64.optdebug,arm.optdebug
365 SPACE = $(EMPTY) $(EMPTY)
366 quickcheck: $(subst $(COMMA),$(SPACE),$(FASTTESTMODES))
367 tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
368 --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
371 # Clean targets. You can clean each architecture individually, or everything.
372 $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
373 rm -f $(OUTDIR)/Makefile.$(basename $@)*
374 rm -rf $(OUTDIR)/$(basename $@).release
375 rm -rf $(OUTDIR)/$(basename $@).debug
376 rm -rf $(OUTDIR)/$(basename $@).optdebug
377 find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
380 rm -f $(OUTDIR)/Makefile.native
381 rm -rf $(OUTDIR)/native
382 find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
384 clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean
386 # GYP file generation targets.
387 OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
388 $(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
389 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
390 GYP_GENERATORS=make \
391 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
392 -Ibuild/standalone.gypi --depth=. \
393 -Dv8_target_arch=$(subst .,,$(suffix $(basename $@))) \
394 -Dv8_optimized_debug=$(if $(findstring optdebug,$@),2,0) \
395 -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
397 $(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
398 PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(PYTHONPATH)" \
399 GYP_GENERATORS=make \
400 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
401 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
403 must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
404 ifndef ANDROID_NDK_ROOT
405 ifndef ANDROID_TOOLCHAIN
406 $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
410 # Note that NACL_SDK_ROOT must be set to point to an appropriate
411 # Native Client SDK before using this makefile. You can download
413 # https://developers.google.com/native-client/sdk/download
414 # The path indicated by NACL_SDK_ROOT will typically end with
415 # a folder for a pepper version such as "pepper_25" that should
416 # have "tools" and "toolchain" subdirectories.
417 must-set-NACL_SDK_ROOT:
419 $(error NACL_SDK_ROOT must be set)
422 # Replaces the old with the new environment file if they're different, which
423 # will trigger GYP to regenerate Makefiles.
424 $(ENVFILE): $(ENVFILE).new
425 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
426 then rm $(ENVFILE).new; \
427 else mv $(ENVFILE).new $(ENVFILE); fi
429 # Stores current GYPFLAGS in a file.
431 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
432 echo "CXX=$(CXX)" >> $(ENVFILE).new
434 # Heap constants for grokdump.
435 DUMP_FILE = tools/v8heapconst.py
436 grokdump: ia32.release
437 @cat $(DUMP_FILE).tmpl > $(DUMP_FILE)
438 @$(OUTDIR)/ia32.release/d8 --dump-heap-constants >> $(DUMP_FILE)
441 # Remember to keep these in sync with the DEPS file.
443 svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \
445 svn checkout --force \
446 https://src.chromium.org/chrome/trunk/deps/third_party/icu46 \
447 third_party/icu --revision 239289