Makefile 12.9 KB
Newer Older
1
# Copyright 2012 the V8 project authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above
#       copyright notice, this list of conditions and the following
#       disclaimer in the documentation and/or other materials provided
#       with the distribution.
#     * Neither the name of Google Inc. nor the names of its
#       contributors may be used to endorse or promote products derived
#       from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


# Variable default definitions. Override them by exporting them in your shell.
30 31
CXX ?= g++
LINK ?= g++
32
OUTDIR ?= out
33
TESTJOBS ?=
34
GYPFLAGS ?=
35
TESTFLAGS ?=
36
ANDROID_NDK_ROOT ?=
37
ANDROID_TOOLCHAIN ?=
38
ANDROID_V8 ?= /data/local/v8
39
NACL_SDK_ROOT ?=
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

# Special build flags. Use them like this: "make library=shared"

# library=shared || component=shared_library
ifeq ($(library), shared)
  GYPFLAGS += -Dcomponent=shared_library
endif
ifdef component
  GYPFLAGS += -Dcomponent=$(component)
endif
# console=readline
ifdef console
  GYPFLAGS += -Dconsole=$(console)
endif
# disassembler=on
ifeq ($(disassembler), on)
  GYPFLAGS += -Dv8_enable_disassembler=1
endif
58 59 60 61
# objectprint=on
ifeq ($(objectprint), on)
  GYPFLAGS += -Dv8_object_print=1
endif
62 63 64 65
# verifyheap=on
ifeq ($(verifyheap), on)
  GYPFLAGS += -Dv8_enable_verify_heap=1
endif
66 67 68 69 70 71
# backtrace=off
ifeq ($(backtrace), off)
  GYPFLAGS += -Dv8_enable_backtrace=0
else
  GYPFLAGS += -Dv8_enable_backtrace=1
endif
72 73 74 75
# snapshot=off
ifeq ($(snapshot), off)
  GYPFLAGS += -Dv8_use_snapshot='false'
endif
76 77 78 79 80 81 82
# extrachecks=on/off
ifeq ($(extrachecks), on)
  GYPFLAGS += -Dv8_enable_extra_checks=1
endif
ifeq ($(extrachecks), off)
  GYPFLAGS += -Dv8_enable_extra_checks=0
endif
83 84 85 86
# gdbjit=on
ifeq ($(gdbjit), on)
  GYPFLAGS += -Dv8_enable_gdbjit=1
endif
87 88 89 90
# vtunejit=on
ifeq ($(vtunejit), on)
  GYPFLAGS += -Dv8_enable_vtunejit=1
endif
91 92 93 94
# debuggersupport=off
ifeq ($(debuggersupport), off)
  GYPFLAGS += -Dv8_enable_debugger_support=0
endif
95 96 97 98
# unalignedaccess=on
ifeq ($(unalignedaccess), on)
  GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
endif
99 100 101 102
# soname_version=1.2.3
ifdef soname_version
  GYPFLAGS += -Dsoname_version=$(soname_version)
endif
103 104 105 106 107 108 109 110
# werror=no
ifeq ($(werror), no)
  GYPFLAGS += -Dwerror=''
endif
# presubmit=no
ifeq ($(presubmit), no)
  TESTFLAGS += --no-presubmit
endif
111 112 113 114
# strictaliasing=off (workaround for GCC-4.5)
ifeq ($(strictaliasing), off)
  GYPFLAGS += -Dv8_no_strict_aliasing=1
endif
115 116 117 118
# regexp=interpreted
ifeq ($(regexp), interpreted)
  GYPFLAGS += -Dv8_interpreted_regexp=1
endif
119 120
# arm specific flags.
# armv7=false/true
121 122
ifeq ($(armv7), false)
  GYPFLAGS += -Darmv7=0
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
else
ifeq ($(armv7), true)
  GYPFLAGS += -Darmv7=1
endif
endif
# vfp2=off. Deprecated, use armfpu=
# vfp3=off. Deprecated, use armfpu=
ifeq ($(vfp3), off)
  GYPFLAGS += -Darm_fpu=vfp
endif
# hardfp=on/off. Deprecated, use armfloatabi
ifeq ($(hardfp),on)
  GYPFLAGS += -Darm_float_abi=hard
else
ifeq ($(hardfp),off)
  GYPFLAGS += -Darm_float_abi=softfp
endif
endif
# armneon=on/off
ifeq ($(armneon), on)
  GYPFLAGS += -Darm_neon=1
endif
# fpu: armfpu=xxx
# xxx: vfp, vfpv3-d16, vfpv3, neon.
ifeq ($(armfpu),)
ifneq ($(vfp3), off)
  GYPFLAGS += -Darm_fpu=default
endif
else
  GYPFLAGS += -Darm_fpu=$(armfpu)
endif
# float abi: armfloatabi=softfp/hard
ifeq ($(armfloatabi),)
ifeq ($(hardfp),)
  GYPFLAGS += -Darm_float_abi=default
endif
else
  GYPFLAGS += -Darm_float_abi=$(armfloatabi)
endif
# armthumb=on/off
ifeq ($(armthumb), off)
  GYPFLAGS += -Darm_thumb=0
else
ifeq ($(armthumb), on)
  GYPFLAGS += -Darm_thumb=1
endif
endif
# armtest=on
# With this flag set, by default v8 will only use features implied
# by the compiler (no probe). This is done by modifying the default
# values of enable_armv7, enable_vfp2, enable_vfp3 and enable_32dregs.
# Modifying these flags when launching v8 will enable the probing for
# the specified values.
# When using the simulator, this flag is implied.
ifeq ($(armtest), on)
  GYPFLAGS += -Darm_test=on
179
endif
180 181

# ----------------- available targets: --------------------
182
# - "dependencies": pulls in external dependencies (currently: GYP)
183 184 185
# - any arch listed in ARCHES (see below)
# - any mode listed in MODES
# - every combination <arch>.<mode>, e.g. "ia32.release"
186
# - "native": current host's architecture, release mode
187
# - any of the above with .check appended, e.g. "ia32.release.check"
188
# - "android": cross-compile for Android/ARM
189
# - "nacl" : cross-compile for Native Client (ia32 and x64)
190
# - default (no target specified): build all DEFAULT_ARCHES and MODES
191 192 193 194 195 196 197 198
# - "check": build all targets and run all tests
# - "<arch>.clean" for any <arch> in ARCHES
# - "clean": clean all ARCHES

# ----------------- internal stuff ------------------------

# Architectures and modes to be compiled. Consider these to be internal
# variables, don't override them (use the targets instead).
199
ARCHES = ia32 x64 arm mipsel
200
DEFAULT_ARCHES = ia32 x64 arm
201
MODES = release debug
202
ANDROID_ARCHES = android_ia32 android_arm android_mipsel
203
NACL_ARCHES = nacl_ia32 nacl_x64
204 205

# List of files that trigger Makefile regeneration:
206
GYPFILES = build/all.gyp build/common.gypi build/standalone.gypi \
207 208 209
           preparser/preparser.gyp samples/samples.gyp src/d8.gyp \
           test/cctest/cctest.gyp tools/gyp/v8.gyp

210 211 212 213
# If vtunejit=on, the v8vtune.gyp will be appended.
ifeq ($(vtunejit), on)
  GYPFILES += src/third_party/vtune/v8vtune.gyp
endif
214 215
# Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
216 217
ANDROID_BUILDS = $(foreach mode,$(MODES), \
                   $(addsuffix .$(mode),$(ANDROID_ARCHES)))
218 219
NACL_BUILDS = $(foreach mode,$(MODES), \
                   $(addsuffix .$(mode),$(NACL_ARCHES)))
220
# Generates corresponding test targets, e.g. "ia32.release.check".
221
CHECKS = $(addsuffix .check,$(BUILDS))
222
ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
223
NACL_CHECKS = $(addsuffix .check,$(NACL_BUILDS))
224 225
# File where previously used GYPFLAGS are stored.
ENVFILE = $(OUTDIR)/environment
226

227
.PHONY: all check clean dependencies $(ENVFILE).new native \
228
        $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
229
        $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
230
        $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS) \
231 232 233
        must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN \
        $(NACL_ARCHES) $(NACL_BUILDS) $(NACL_CHECKS) \
        must-set-NACL_SDK_ROOT
234

235 236
# Target definitions. "all" is the default.
all: $(MODES)
237

238 239 240 241 242 243
# Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
# having been created before.
buildbot:
	$(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
	        builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"

244 245 246 247
mips mips.release mips.debug:
	@echo "V8 does not support big-endian MIPS builds at the moment," \
	      "please use little-endian builds (mipsel)."

248 249
# Compile targets. MODES and ARCHES are convenience targets.
.SECONDEXPANSION:
250
$(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
251

252
$(ARCHES): $(addprefix $$@.,$(MODES))
253

254
# Defines how to build a particular target (e.g. ia32.release).
255 256
$(BUILDS): $(OUTDIR)/Makefile.$$(basename $$@)
	@$(MAKE) -C "$(OUTDIR)" -f Makefile.$(basename $@) \
257 258 259 260 261
	         CXX="$(CXX)" LINK="$(LINK)" \
	         BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
	                     python -c "print raw_input().capitalize()") \
	         builddir="$(shell pwd)/$(OUTDIR)/$@"

262 263
native: $(OUTDIR)/Makefile.native
	@$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
264 265 266
	         CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
	         builddir="$(shell pwd)/$(OUTDIR)/$@"

267
$(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
268

269
$(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) build/android.gypi \
270
                   must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN Makefile.android
271 272 273 274 275
	@$(MAKE) -f Makefile.android $@ \
	        ARCH="$(basename $@)" \
	        MODE="$(subst .,,$(suffix $@))" \
	        OUTDIR="$(OUTDIR)" \
	        GYPFLAGS="$(GYPFLAGS)"
276

277 278 279 280 281 282 283 284 285 286
$(NACL_ARCHES): $(addprefix $$@.,$(MODES))

$(NACL_BUILDS): $(GYPFILES) $(ENVFILE) \
		   Makefile.nacl must-set-NACL_SDK_ROOT
	@$(MAKE) -f Makefile.nacl $@ \
	        ARCH="$(basename $@)" \
	        MODE="$(subst .,,$(suffix $@))" \
	        OUTDIR="$(OUTDIR)" \
	        GYPFLAGS="$(GYPFLAGS)"

287 288
# Test targets.
check: all
289
	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
290
	    --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
291
	    $(TESTFLAGS)
292

293
$(addsuffix .check,$(MODES)): $$(basename $$@)
294
	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
295
	    --mode=$(basename $@) $(TESTFLAGS)
296 297

$(addsuffix .check,$(ARCHES)): $$(basename $$@)
298
	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
299
	    --arch=$(basename $@) $(TESTFLAGS)
300 301

$(CHECKS): $$(basename $$@)
302
	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
303
	    --arch-and-mode=$(basename $@) $(TESTFLAGS)
304

305
$(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
306 307 308
	@tools/android-sync.sh $(basename $@) $(OUTDIR) \
	                       $(shell pwd) $(ANDROID_V8)

309
$(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
310
	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
311
	     --arch-and-mode=$(basename $@) \
312
	     --timeout=600 \
313
	     --command-prefix="tools/android-run.py"
314

315 316
$(addsuffix .check, $(ANDROID_ARCHES)): \
                $(addprefix $$(basename $$@).,$(MODES)).check
317

318 319 320 321 322 323 324 325 326
$(addsuffix .check, $(NACL_BUILDS)): $$(basename $$@)
	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR) \
	     --arch-and-mode=$(basename $@) \
	     --timeout=600 --nopresubmit \
	     --command-prefix="tools/nacl-run.py"

$(addsuffix .check, $(NACL_ARCHES)): \
                $(addprefix $$(basename $$@).,$(MODES)).check

327
native.check: native
328
	@tools/run-tests.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
329
	    --arch-and-mode=. $(TESTFLAGS)
330

331
# Clean targets. You can clean each architecture individually, or everything.
332
$(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)):
333
	rm -f $(OUTDIR)/Makefile.$(basename $@)
334 335
	rm -rf $(OUTDIR)/$(basename $@).release
	rm -rf $(OUTDIR)/$(basename $@).debug
336
	find $(OUTDIR) -regex '.*\(host\|target\).$(basename $@)\.mk' -delete
337

338
native.clean:
339
	rm -f $(OUTDIR)/Makefile.native
340
	rm -rf $(OUTDIR)/native
341
	find $(OUTDIR) -regex '.*\(host\|target\).native\.mk' -delete
342

343
clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES) $(NACL_ARCHES)) native.clean
344 345

# GYP file generation targets.
346 347
OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ARCHES))
$(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
348
	GYP_GENERATORS=make \
349
	build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
350 351 352
	              -Ibuild/standalone.gypi --depth=. \
	              -Dv8_target_arch=$(subst .,,$(suffix $@)) \
	              -S.$(subst .,,$(suffix $@)) $(GYPFLAGS)
353

354
$(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
355
	GYP_GENERATORS=make \
356
	build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
357
	              -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
358

359
must-set-ANDROID_NDK_ROOT_OR_TOOLCHAIN:
360
ifndef ANDROID_NDK_ROOT
361 362 363
ifndef ANDROID_TOOLCHAIN
	  $(error ANDROID_NDK_ROOT or ANDROID_TOOLCHAIN must be set))
endif
364 365
endif

366 367 368 369 370 371 372 373 374 375 376 377
# Note that NACL_SDK_ROOT must be set to point to an appropriate
# Native Client SDK before using this makefile. You can download
# an SDK here:
#   https://developers.google.com/native-client/sdk/download
# The path indicated by NACL_SDK_ROOT will typically end with
# a folder for a pepper version such as "pepper_25" that should
# have "tools" and "toolchain" subdirectories.
must-set-NACL_SDK_ROOT:
ifndef NACL_SDK_ROOT
	  $(error NACL_SDK_ROOT must be set)
endif

378 379 380 381 382 383 384 385 386
# Replaces the old with the new environment file if they're different, which
# will trigger GYP to regenerate Makefiles.
$(ENVFILE): $(ENVFILE).new
	@if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) >/dev/null; \
	    then rm $(ENVFILE).new; \
	    else mv $(ENVFILE).new $(ENVFILE); fi

# Stores current GYPFLAGS in a file.
$(ENVFILE).new:
387 388
	@mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
	    echo "CXX=$(CXX)" >> $(ENVFILE).new
389 390

# Dependencies.
391
# Remember to keep these in sync with the DEPS file.
392 393
dependencies:
	svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \
394
	    --revision 1501