Makefile 17.3 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 30
# 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.
OUTDIR ?= out
31
TESTJOBS ?=
32
GYPFLAGS ?=
33
TESTFLAGS ?=
34
ANDROID_NDK_HOST_ARCH ?=
35
ANDROID_V8 ?= /data/local/tmp/v8
36

Yang Guo's avatar
Yang Guo committed
37 38 39 40 41
$(warning Make (gyp) is deprecated. Please use GN instead.)
$(warning See https://github.com/v8/v8/wiki/Building-with-GN)
$(warning Or contact yangguo@chromium.org.)
$(error Expect the Makefile to be removed soon)

42 43 44 45 46 47 48 49 50 51 52 53 54
# 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
# disassembler=on
ifeq ($(disassembler), on)
  GYPFLAGS += -Dv8_enable_disassembler=1
endif
55 56 57 58
# objectprint=on
ifeq ($(objectprint), on)
  GYPFLAGS += -Dv8_object_print=1
endif
59 60 61 62
# verifycsa=on
ifeq ($(verifycsa), on)
  GYPFLAGS += -Dv8_enable_verify_csa=1
endif
63 64 65 66
# verifyheap=on
ifeq ($(verifyheap), on)
  GYPFLAGS += -Dv8_enable_verify_heap=1
endif
67 68 69 70
# tracemaps=on
ifeq ($(tracemaps), on)
  GYPFLAGS += -Dv8_trace_maps=1
endif
71 72 73 74
# concurrentmarking=on
ifeq ($(concurrentmarking), on)
  GYPFLAGS += -Dv8_enable_concurrent_marking=1
endif
75 76 77 78 79 80
# backtrace=off
ifeq ($(backtrace), off)
  GYPFLAGS += -Dv8_enable_backtrace=0
else
  GYPFLAGS += -Dv8_enable_backtrace=1
endif
81 82 83 84
# verifypredictable=on
ifeq ($(verifypredictable), on)
  GYPFLAGS += -Dv8_enable_verify_predictable=1
endif
85 86 87 88
# snapshot=off
ifeq ($(snapshot), off)
  GYPFLAGS += -Dv8_use_snapshot='false'
endif
89 90 91
ifeq ($(snapshot), external)
  GYPFLAGS += -Dv8_use_external_startup_data=1
endif
92 93
# extrachecks=on/off
ifeq ($(extrachecks), on)
jochen's avatar
jochen committed
94
  GYPFLAGS += -Ddcheck_always_on=1 -Dv8_enable_handle_zapping=1
95 96
endif
ifeq ($(extrachecks), off)
jochen's avatar
jochen committed
97
  GYPFLAGS += -Ddcheck_always_on=0 -Dv8_enable_handle_zapping=0
98
endif
99 100 101 102 103 104 105
# slowdchecks=on/off
ifeq ($(slowdchecks), on)
  GYPFLAGS += -Dv8_enable_slow_dchecks=1
endif
ifeq ($(slowdchecks), off)
  GYPFLAGS += -Dv8_enable_slow_dchecks=0
endif
106 107 108 109
# debugsymbols=on
ifeq ($(debugsymbols), on)
  GYPFLAGS += -Drelease_extra_cflags=-ggdb3
endif
110
# gdbjit=on/off
111 112 113
ifeq ($(gdbjit), on)
  GYPFLAGS += -Dv8_enable_gdbjit=1
endif
114 115 116
ifeq ($(gdbjit), off)
  GYPFLAGS += -Dv8_enable_gdbjit=0
endif
117 118 119 120
# vtunejit=on
ifeq ($(vtunejit), on)
  GYPFLAGS += -Dv8_enable_vtunejit=1
endif
121 122 123 124
# unalignedaccess=on
ifeq ($(unalignedaccess), on)
  GYPFLAGS += -Dv8_can_use_unaligned_accesses=true
endif
125 126 127 128
# randomseed=12345, disable random seed via randomseed=0
ifdef randomseed
  GYPFLAGS += -Dv8_random_seed=$(randomseed)
endif
129 130 131 132
# soname_version=1.2.3
ifdef soname_version
  GYPFLAGS += -Dsoname_version=$(soname_version)
endif
133 134 135 136
# werror=no
ifeq ($(werror), no)
  GYPFLAGS += -Dwerror=''
endif
137 138 139 140
# strictaliasing=off (workaround for GCC-4.5)
ifeq ($(strictaliasing), off)
  GYPFLAGS += -Dv8_no_strict_aliasing=1
endif
141 142 143 144
# regexp=interpreted
ifeq ($(regexp), interpreted)
  GYPFLAGS += -Dv8_interpreted_regexp=1
endif
145 146 147 148
# i18nsupport=off
ifeq ($(i18nsupport), off)
  GYPFLAGS += -Dv8_enable_i18n_support=0
  TESTFLAGS += --noi18n
149
endif
150
# deprecationwarnings=on
151 152
ifeq ($(deprecationwarnings), on)
  GYPFLAGS += -Dv8_deprecation_warnings=1
153
endif
154 155 156 157
# vectorstores=on
ifeq ($(vectorstores), on)
  GYPFLAGS += -Dv8_vector_stores=1
endif
158 159 160 161
# imminentdeprecationwarnings=on
ifeq ($(imminentdeprecationwarnings), on)
  GYPFLAGS += -Dv8_imminent_deprecation_warnings=1
endif
162 163 164
# asan=on
ifeq ($(asan), on)
  GYPFLAGS += -Dasan=1 -Dclang=1
165 166 167 168
  TESTFLAGS += --asan
  ifeq ($(lsan), on)
    GYPFLAGS += -Dlsan=1
  endif
169
endif
170 171 172
ifdef embedscript
  GYPFLAGS += -Dembed_script=$(embedscript)
endif
173 174 175
ifdef warmupscript
  GYPFLAGS += -Dwarmup_script=$(warmupscript)
endif
176 177 178
ifeq ($(goma), on)
  GYPFLAGS += -Duse_goma=1
endif
179 180 181 182 183 184 185 186
# v8_os_page_size=0, when 0 or not specified use build OS page size
ifdef v8_os_page_size
  ifneq ($(v8_os_page_size), 0)
    ifneq ($(snapshot), off)
      GYPFLAGS += -Dv8_os_page_size=$(v8_os_page_size)
    endif
  endif
endif
187
# arm specific flags.
188 189 190 191 192
# arm_version=<number | "default">
ifneq ($(strip $(arm_version)),)
  GYPFLAGS += -Darm_version=$(arm_version)
else
# Deprecated (use arm_version instead): armv7=false/true
193
ifeq ($(armv7), false)
194
  GYPFLAGS += -Darm_version=6
195 196
else
ifeq ($(armv7), true)
197 198
  GYPFLAGS += -Darm_version=7
endif
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
endif
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
# fpu: armfpu=xxx
# xxx: vfp, vfpv3-d16, vfpv3, neon.
ifeq ($(armfpu),)
  GYPFLAGS += -Darm_fpu=default
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
232
# arm_test_noprobe=on
233 234
# With this flag set, by default v8 will only use features implied
# by the compiler (no probe). This is done by modifying the default
235
# values of enable_armv7, enable_vfp3, enable_32dregs and enable_neon.
236 237
# Modifying these flags when launching v8 will enable the probing for
# the specified values.
238 239
ifeq ($(arm_test_noprobe), on)
  GYPFLAGS += -Darm_test_noprobe=on
240
endif
241 242 243 244
# Do not omit the frame pointer, needed for profiling with perf
ifeq ($(no_omit_framepointer), on)
  GYPFLAGS += -Drelease_extra_cflags=-fno-omit-frame-pointer
endif
245

246 247 248 249 250
ifdef android_ndk_root
  GYPFLAGS += -Dandroid_ndk_root=$(android_ndk_root)
  export ANDROID_NDK_ROOT = $(android_ndk_root)
endif

251 252 253 254
# ----------------- available targets: --------------------
# - any arch listed in ARCHES (see below)
# - any mode listed in MODES
# - every combination <arch>.<mode>, e.g. "ia32.release"
255
# - "native": current host's architecture, release mode
256
# - any of the above with .check appended, e.g. "ia32.release.check"
257
# - "android": cross-compile for Android/ARM
258
# - default (no target specified): build all DEFAULT_ARCHES and MODES
259 260 261 262 263 264 265 266
# - "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).
Jakob Kummerow's avatar
Jakob Kummerow committed
267 268
ARCHES = ia32 x64 arm arm64 mips mipsel mips64 mips64el ppc ppc64 s390 s390x
ARCHES32 = ia32 arm mips mipsel ppc s390
269
DEFAULT_ARCHES = ia32 x64 arm
270 271
MODES = release debug optdebug
DEFAULT_MODES = release debug
272
ANDROID_ARCHES = android_ia32 android_x64 android_arm android_arm64 \
Jakob Kummerow's avatar
Jakob Kummerow committed
273
		 android_mipsel
274 275

# List of files that trigger Makefile regeneration:
276
GYPFILES = third_party/icu/icu.gypi third_party/icu/icu.gyp \
277 278 279
	   gypfiles/shim_headers.gypi gypfiles/features.gypi \
           gypfiles/standalone.gypi \
	   gypfiles/toolchain.gypi gypfiles/all.gyp gypfiles/mac/asan.gyp \
280
	   test/cctest/cctest.gyp test/fuzzer/fuzzer.gyp \
281
	   test/unittests/unittests.gyp gypfiles/v8.gyp \
282
	   tools/parser-shell.gyp testing/gmock.gyp testing/gtest.gyp \
283
	   gypfiles/samples.gyp gypfiles/v8vtune.gyp gypfiles/d8.gyp
284 285 286

# Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
287 288
ANDROID_BUILDS = $(foreach mode,$(MODES), \
                   $(addsuffix .$(mode),$(ANDROID_ARCHES)))
289
# Generates corresponding test targets, e.g. "ia32.release.check".
290
CHECKS = $(addsuffix .check,$(BUILDS))
291
QUICKCHECKS = $(addsuffix .quickcheck,$(BUILDS))
292
ANDROID_CHECKS = $(addsuffix .check,$(ANDROID_BUILDS))
293 294
# File where previously used GYPFLAGS are stored.
ENVFILE = $(OUTDIR)/environment
295

296
.PHONY: all check clean builddeps dependencies $(ENVFILE).new native \
297
        qc quickcheck $(QUICKCHECKS) turbocheck \
298
        $(addsuffix .quickcheck,$(MODES)) $(addsuffix .quickcheck,$(ARCHES)) \
299
        $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
300
        $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
yangguo's avatar
yangguo committed
301
        $(ANDROID_ARCHES) $(ANDROID_BUILDS) $(ANDROID_CHECKS)
302

303
# Target definitions. "all" is the default.
304
all: $(DEFAULT_MODES)
305

306 307
# Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
# having been created before.
308
buildbot:
309 310 311
	$(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
	        builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"

312 313
# Compile targets. MODES and ARCHES are convenience targets.
.SECONDEXPANSION:
314
$(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
315

316
$(ARCHES): $(addprefix $$@.,$(DEFAULT_MODES))
317

318
# Defines how to build a particular target (e.g. ia32.release).
319
$(BUILDS): $(OUTDIR)/Makefile.$$@
320
	@$(MAKE) -C "$(OUTDIR)" -f Makefile.$@ \
321
	         BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
322 323
	                     python -c "print \
	                     raw_input().replace('opt', '').capitalize()") \
324 325
	         builddir="$(shell pwd)/$(OUTDIR)/$@"

326
native: $(OUTDIR)/Makefile.native
327
	@$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
328
	         BUILDTYPE=Release \
329 330
	         builddir="$(shell pwd)/$(OUTDIR)/$@"

331
$(ANDROID_ARCHES): $(addprefix $$@.,$(MODES))
332

333
$(ANDROID_BUILDS): $(GYPFILES) $(ENVFILE) Makefile.android
334 335 336 337 338
	@$(MAKE) -f Makefile.android $@ \
	        ARCH="$(basename $@)" \
	        MODE="$(subst .,,$(suffix $@))" \
	        OUTDIR="$(OUTDIR)" \
	        GYPFLAGS="$(GYPFLAGS)"
339

340 341
# Test targets.
check: all
342
	@gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
343
	    --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
344
	    $(TESTFLAGS)
345

346
$(addsuffix .check,$(MODES)): $$(basename $$@)
347
	@gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
348
	    --mode=$(basename $@) $(TESTFLAGS)
349 350

$(addsuffix .check,$(ARCHES)): $$(basename $$@)
351
	@gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
352
	    --arch=$(basename $@) $(TESTFLAGS)
353 354

$(CHECKS): $$(basename $$@)
355
	@gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
356
	    --arch-and-mode=$(basename $@) $(TESTFLAGS)
357

358
$(addsuffix .quickcheck,$(MODES)): $$(basename $$@)
359
	@gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
360 361 362
	    --mode=$(basename $@) $(TESTFLAGS) --quickcheck

$(addsuffix .quickcheck,$(ARCHES)): $$(basename $$@)
363
	@gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
364 365 366
	    --arch=$(basename $@) $(TESTFLAGS) --quickcheck

$(QUICKCHECKS): $$(basename $$@)
367
	@gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
368 369
	    --arch-and-mode=$(basename $@) $(TESTFLAGS) --quickcheck

370
$(addsuffix .sync, $(ANDROID_BUILDS)): $$(basename $$@)
371 372 373
	@tools/android-sync.sh $(basename $@) $(OUTDIR) \
	                       $(shell pwd) $(ANDROID_V8)

374
$(addsuffix .check, $(ANDROID_BUILDS)): $$(basename $$@).sync
375
	@gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
376
	     --arch-and-mode=$(basename $@) \
377
	     --timeout=600 \
378
	     --command-prefix="tools/android-run.py" $(TESTFLAGS)
379

380 381
$(addsuffix .check, $(ANDROID_ARCHES)): \
                $(addprefix $$(basename $$@).,$(MODES)).check
382

383
native.check: native
384
	@gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
385
	    --arch-and-mode=. $(TESTFLAGS)
386

387
SUPERFASTTESTMODES = ia32.release
388 389
FASTTESTMODES = $(SUPERFASTTESTMODES),x64.release,ia32.optdebug,x64.optdebug,arm.optdebug,arm64.release
FASTCOMPILEMODES = $(FASTTESTMODES),arm64.optdebug
390

391 392 393
COMMA = ,
EMPTY =
SPACE = $(EMPTY) $(EMPTY)
394
quickcheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
395
	gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
396 397
	    --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) --quickcheck \
	    --download-data mozilla webkit
398
	gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
399
	    --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) --quickcheck
400 401
qc: quickcheck

402
turbocheck: $(subst $(COMMA),$(SPACE),$(FASTCOMPILEMODES))
403
	gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
404 405
	    --arch-and-mode=$(SUPERFASTTESTMODES) $(TESTFLAGS) \
	    --quickcheck --variants=turbofan --download-data mozilla webkit
406
	gypfiles/run-tests-legacy.py $(TESTJOBS) --outdir=$(OUTDIR) \
407 408 409 410
	    --arch-and-mode=$(FASTTESTMODES) $(TESTFLAGS) \
	    --quickcheck --variants=turbofan
tc: turbocheck

411
# Clean targets. You can clean each architecture individually, or everything.
yangguo's avatar
yangguo committed
412
$(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES)):
413
	rm -f $(OUTDIR)/Makefile.$(basename $@)*
414 415
	rm -rf $(OUTDIR)/$(basename $@).release
	rm -rf $(OUTDIR)/$(basename $@).debug
416
	rm -rf $(OUTDIR)/$(basename $@).optdebug
417
	find $(OUTDIR) -regex '.*\(host\|target\)\.$(basename $@).*\.mk' -delete
418

419
native.clean:
420
	rm -f $(OUTDIR)/Makefile.native
421
	rm -rf $(OUTDIR)/native
422
	find $(OUTDIR) -regex '.*\(host\|target\)\.native\.mk' -delete
423

yangguo's avatar
yangguo committed
424
clean: $(addsuffix .clean, $(ARCHES) $(ANDROID_ARCHES)) native.clean gtags.clean tags.clean
425 426

# GYP file generation targets.
427
OUT_MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(BUILDS))
428
$(OUT_MAKEFILES): $(GYPFILES) $(ENVFILE)
429 430
	$(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
	        cut -f 2 -d " " | cut -f 1 -d "-" ))
431
	$(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
432
	$(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
433 434 435 436
	$(eval CXX_TARGET_ARCH:=$(subst s390x,s390,$(CXX_TARGET_ARCH)))
	$(eval CXX_TARGET_ARCH:=$(subst powerpc,ppc,$(CXX_TARGET_ARCH)))
	$(eval CXX_TARGET_ARCH:=$(subst ppc64,ppc,$(CXX_TARGET_ARCH)))
	$(eval CXX_TARGET_ARCH:=$(subst ppcle,ppc,$(CXX_TARGET_ARCH)))
437
	$(eval V8_TARGET_ARCH:=$(subst .,,$(suffix $(basename $@))))
438
	PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/gypfiles:$(PYTHONPATH):$(shell pwd)/tools/gyp/pylib:$(PYTHONPATH)" \
439
	GYP_GENERATORS=make \
440 441
	tools/gyp/gyp --generator-output="$(OUTDIR)" gypfiles/all.gyp \
	              -Igypfiles/standalone.gypi --depth=. \
442
	              -Dv8_target_arch=$(V8_TARGET_ARCH) \
443
	              $(if $(findstring $(CXX_TARGET_ARCH),$(V8_TARGET_ARCH)), \
444 445 446
	              -Dtarget_arch=$(V8_TARGET_ARCH), \
	                  $(if $(shell echo $(ARCHES32) | grep $(V8_TARGET_ARCH)), \
	                  -Dtarget_arch=ia32,)) \
447
	              $(if $(findstring optdebug,$@),-Dv8_optimized_debug=1,) \
448
	              -S$(suffix $(basename $@))$(suffix $@) $(GYPFLAGS)
449

450
$(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
451
	PYTHONPATH="$(shell pwd)/tools/generate_shim_headers:$(shell pwd)/gypfiles:$(PYTHONPATH):$(shell pwd)/tools/gyp/pylib:$(PYTHONPATH)" \
452
	GYP_GENERATORS=make \
453 454
	tools/gyp/gyp --generator-output="$(OUTDIR)" gypfiles/all.gyp \
	              -Igypfiles/standalone.gypi --depth=. -S.native $(GYPFLAGS)
455

456 457 458
# Replaces the old with the new environment file if they're different, which
# will trigger GYP to regenerate Makefiles.
$(ENVFILE): $(ENVFILE).new
459
	@if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) > /dev/null; \
460 461 462 463 464
	    then rm $(ENVFILE).new; \
	    else mv $(ENVFILE).new $(ENVFILE); fi

# Stores current GYPFLAGS in a file.
$(ENVFILE).new:
465 466 467
	$(eval CXX_TARGET_ARCH:=$(shell $(CXX) -v 2>&1 | grep ^Target: | \
	        cut -f 2 -d " " | cut -f 1 -d "-" ))
	$(eval CXX_TARGET_ARCH:=$(subst aarch64,arm64,$(CXX_TARGET_ARCH)))
468
	$(eval CXX_TARGET_ARCH:=$(subst x86_64,x64,$(CXX_TARGET_ARCH)))
469
	@mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS) -Dtarget_arch=$(CXX_TARGET_ARCH)" > $(ENVFILE).new;
470

471 472 473 474
# Support for the GNU GLOBAL Source Code Tag System.
gtags.files: $(GYPFILES) $(ENVFILE)
	@find include src test -name '*.h' -o -name '*.cc' -o -name '*.c' > $@

475 476
# We need to manually set the stack limit here, to work around bugs in
# gmake-3.81 and global-5.7.1 on recent 64-bit Linux systems.
477 478 479
# Using $(wildcard ...) gracefully ignores non-existing files, so that stale
# gtags.files after switching branches don't cause recipe failures.
GPATH GRTAGS GSYMS GTAGS: gtags.files $(wildcard $(shell cat gtags.files 2> /dev/null))
480
	@bash -c 'ulimit -s 10240 && GTAGSFORCECPP=yes gtags -i -q -f $<'
481 482

gtags.clean:
483
	rm -f gtags.files GPATH GRTAGS GSYMS GTAGS
484

485 486 487 488 489 490 491 492
tags: gtags.files $(wildcard $(shell cat gtags.files 2> /dev/null))
	@(ctags --version | grep 'Exuberant Ctags' >/dev/null) || \
		(echo "Please install Exuberant Ctags (check 'ctags --version')" >&2; false)
	ctags --fields=+l -L $<

tags.clean:
	rm -r tags

493 494
dependencies builddeps:
	$(error Use 'gclient sync' instead)