blob: 0d825c079508b439f35a4301ab7c4476d5962d27 [file] [log] [blame]
ulan@chromium.org2efb9002012-01-19 15:36:35 +00001# Copyright 2012 the V8 project authors. All rights reserved.
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +00002# 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.
danno@chromium.orgc612e022011-11-10 11:38:15 +000030CXX ?= g++
31LINK ?= g++
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +000032OUTDIR ?= out
33TESTJOBS ?= -j16
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000034GYPFLAGS ?=
svenpanne@chromium.orga8bb4d92011-10-10 13:20:40 +000035TESTFLAGS ?=
ulan@chromium.org2efb9002012-01-19 15:36:35 +000036ANDROID_NDK_ROOT ?=
37ANDROID_TOOL_PREFIX = $(ANDROID_NDK_ROOT)/toolchain/bin/arm-linux-androideabi
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +000038
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000039# Special build flags. Use them like this: "make library=shared"
40
41# library=shared || component=shared_library
42ifeq ($(library), shared)
43 GYPFLAGS += -Dcomponent=shared_library
44endif
45ifdef component
46 GYPFLAGS += -Dcomponent=$(component)
47endif
48# console=readline
49ifdef console
50 GYPFLAGS += -Dconsole=$(console)
51endif
52# disassembler=on
53ifeq ($(disassembler), on)
54 GYPFLAGS += -Dv8_enable_disassembler=1
55endif
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000056# objectprint=on
57ifeq ($(objectprint), on)
58 GYPFLAGS += -Dv8_object_print=1
59endif
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000060# snapshot=off
61ifeq ($(snapshot), off)
62 GYPFLAGS += -Dv8_use_snapshot='false'
63endif
64# gdbjit=on
65ifeq ($(gdbjit), on)
66 GYPFLAGS += -Dv8_enable_gdbjit=1
67endif
68# liveobjectlist=on
69ifeq ($(liveobjectlist), on)
70 GYPFLAGS += -Dv8_use_liveobjectlist=true
71endif
72# vfp3=off
73ifeq ($(vfp3), off)
74 GYPFLAGS += -Dv8_can_use_vfp_instructions=false
75else
76 GYPFLAGS += -Dv8_can_use_vfp_instructions=true
77endif
erik.corry@gmail.combbceb572012-03-09 10:52:05 +000078# debuggersupport=off
79ifeq ($(debuggersupport), off)
80 GYPFLAGS += -Dv8_enable_debugger_support=0
81endif
ricow@chromium.org55ee8072011-09-08 16:33:10 +000082# soname_version=1.2.3
83ifdef soname_version
84 GYPFLAGS += -Dsoname_version=$(soname_version)
85endif
svenpanne@chromium.orga8bb4d92011-10-10 13:20:40 +000086# werror=no
87ifeq ($(werror), no)
88 GYPFLAGS += -Dwerror=''
89endif
90# presubmit=no
91ifeq ($(presubmit), no)
92 TESTFLAGS += --no-presubmit
93endif
ulan@chromium.org2efb9002012-01-19 15:36:35 +000094# strictaliasing=off (workaround for GCC-4.5)
95ifeq ($(strictaliasing), off)
96 GYPFLAGS += -Dv8_no_strict_aliasing=1
97endif
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000098
99# ----------------- available targets: --------------------
ricow@chromium.org55ee8072011-09-08 16:33:10 +0000100# - "dependencies": pulls in external dependencies (currently: GYP)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000101# - any arch listed in ARCHES (see below)
102# - any mode listed in MODES
103# - every combination <arch>.<mode>, e.g. "ia32.release"
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000104# - "native": current host's architecture, release mode
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000105# - any of the above with .check appended, e.g. "ia32.release.check"
ulan@chromium.org2efb9002012-01-19 15:36:35 +0000106# - "android": cross-compile for Android/ARM (release mode)
danno@chromium.orgc612e022011-11-10 11:38:15 +0000107# - default (no target specified): build all DEFAULT_ARCHES and MODES
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000108# - "check": build all targets and run all tests
109# - "<arch>.clean" for any <arch> in ARCHES
110# - "clean": clean all ARCHES
111
112# ----------------- internal stuff ------------------------
113
114# Architectures and modes to be compiled. Consider these to be internal
115# variables, don't override them (use the targets instead).
danno@chromium.orgc612e022011-11-10 11:38:15 +0000116ARCHES = ia32 x64 arm mips
117DEFAULT_ARCHES = ia32 x64 arm
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000118MODES = release debug
119
120# List of files that trigger Makefile regeneration:
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000121GYPFILES = build/all.gyp build/common.gypi build/standalone.gypi \
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000122 preparser/preparser.gyp samples/samples.gyp src/d8.gyp \
123 test/cctest/cctest.gyp tools/gyp/v8.gyp
124
125# Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
126BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000127# Generates corresponding test targets, e.g. "ia32.release.check".
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000128CHECKS = $(addsuffix .check,$(BUILDS))
129# File where previously used GYPFLAGS are stored.
130ENVFILE = $(OUTDIR)/environment
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000131
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000132.PHONY: all check clean dependencies $(ENVFILE).new native \
fschneider@chromium.org1805e212011-09-05 10:49:12 +0000133 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
ulan@chromium.org2efb9002012-01-19 15:36:35 +0000134 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) \
135 must-set-ANDROID_NDK_ROOT
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000136
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000137# Target definitions. "all" is the default.
138all: $(MODES)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000139
jkummerow@chromium.org212d9642012-05-11 15:02:09 +0000140# Special target for the buildbots to use. Depends on $(OUTDIR)/Makefile
141# having been created before.
142buildbot:
143 $(MAKE) -C "$(OUTDIR)" BUILDTYPE=$(BUILDTYPE) \
144 builddir="$(abspath $(OUTDIR))/$(BUILDTYPE)"
145
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000146# Compile targets. MODES and ARCHES are convenience targets.
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000147.SECONDEXPANSION:
danno@chromium.orgc612e022011-11-10 11:38:15 +0000148$(MODES): $(addsuffix .$$@,$(DEFAULT_ARCHES))
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000149
150$(ARCHES): $(addprefix $$@.,$(MODES))
151
152# Defines how to build a particular target (e.g. ia32.release).
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000153$(BUILDS): $(OUTDIR)/Makefile.$$(basename $$@)
154 @$(MAKE) -C "$(OUTDIR)" -f Makefile.$(basename $@) \
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000155 CXX="$(CXX)" LINK="$(LINK)" \
156 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
157 python -c "print raw_input().capitalize()") \
158 builddir="$(shell pwd)/$(OUTDIR)/$@"
159
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000160native: $(OUTDIR)/Makefile.native
161 @$(MAKE) -C "$(OUTDIR)" -f Makefile.native \
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000162 CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
163 builddir="$(shell pwd)/$(OUTDIR)/$@"
164
ulan@chromium.org2efb9002012-01-19 15:36:35 +0000165# TODO(jkummerow): add "android.debug" when we need it.
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000166android android.release: $(OUTDIR)/Makefile.android
167 @$(MAKE) -C "$(OUTDIR)" -f Makefile.android \
ulan@chromium.org2efb9002012-01-19 15:36:35 +0000168 CXX="$(ANDROID_TOOL_PREFIX)-g++" \
169 AR="$(ANDROID_TOOL_PREFIX)-ar" \
170 RANLIB="$(ANDROID_TOOL_PREFIX)-ranlib" \
171 CC="$(ANDROID_TOOL_PREFIX)-gcc" \
172 LD="$(ANDROID_TOOL_PREFIX)-ld" \
173 LINK="$(ANDROID_TOOL_PREFIX)-g++" \
174 BUILDTYPE=Release \
175 builddir="$(shell pwd)/$(OUTDIR)/android.release"
176
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000177# Test targets.
178check: all
svenpanne@chromium.orga8bb4d92011-10-10 13:20:40 +0000179 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
danno@chromium.orgc612e022011-11-10 11:38:15 +0000180 --arch=$(shell echo $(DEFAULT_ARCHES) | sed -e 's/ /,/g') \
svenpanne@chromium.orga8bb4d92011-10-10 13:20:40 +0000181 $(TESTFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000182
183$(addsuffix .check,$(MODES)): $$(basename $$@)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000184 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
svenpanne@chromium.orga8bb4d92011-10-10 13:20:40 +0000185 --mode=$(basename $@) $(TESTFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000186
187$(addsuffix .check,$(ARCHES)): $$(basename $$@)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000188 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
svenpanne@chromium.orga8bb4d92011-10-10 13:20:40 +0000189 --arch=$(basename $@) $(TESTFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000190
191$(CHECKS): $$(basename $$@)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000192 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
svenpanne@chromium.orga8bb4d92011-10-10 13:20:40 +0000193 --arch-and-mode=$(basename $@) $(TESTFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000194
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000195native.check: native
196 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
svenpanne@chromium.orga8bb4d92011-10-10 13:20:40 +0000197 --arch-and-mode=. $(TESTFLAGS)
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000198
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000199# Clean targets. You can clean each architecture individually, or everything.
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000200$(addsuffix .clean,$(ARCHES)) android.clean:
201 rm -f $(OUTDIR)/Makefile.$(basename $@)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000202 rm -rf $(OUTDIR)/$(basename $@).release
203 rm -rf $(OUTDIR)/$(basename $@).debug
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000204 find $(OUTDIR) -regex '.*\(host\|target\).$(basename $@)\.mk' -delete
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000205
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000206native.clean:
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000207 rm -f $(OUTDIR)/Makefile.native
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000208 rm -rf $(OUTDIR)/native
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000209 find $(OUTDIR) -regex '.*\(host\|target\).native\.mk' -delete
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000210
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000211clean: $(addsuffix .clean,$(ARCHES)) native.clean android.clean
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000212
213# GYP file generation targets.
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000214MAKEFILES = $(addprefix $(OUTDIR)/Makefile.,$(ARCHES))
215$(MAKEFILES): $(GYPFILES) $(ENVFILE)
jkummerow@chromium.org1456e702012-03-30 08:38:13 +0000216 GYP_GENERATORS=make \
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000217 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000218 -Ibuild/standalone.gypi --depth=. \
219 -Dv8_target_arch=$(subst .,,$(suffix $@)) \
220 -S.$(subst .,,$(suffix $@)) $(GYPFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000221
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000222$(OUTDIR)/Makefile.native: $(GYPFILES) $(ENVFILE)
jkummerow@chromium.org1456e702012-03-30 08:38:13 +0000223 GYP_GENERATORS=make \
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000224 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000225 -Ibuild/standalone.gypi --depth=. -S.native $(GYPFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000226
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000227$(OUTDIR)/Makefile.android: $(GYPFILES) $(ENVFILE) build/android.gypi \
ulan@chromium.org2efb9002012-01-19 15:36:35 +0000228 must-set-ANDROID_NDK_ROOT
jkummerow@chromium.org1456e702012-03-30 08:38:13 +0000229 GYP_GENERATORS=make \
ulan@chromium.org2efb9002012-01-19 15:36:35 +0000230 CC="${ANDROID_TOOL_PREFIX}-gcc" \
ulan@chromium.org0e3f88b2012-05-22 09:16:05 +0000231 CXX="${ANDROID_TOOL_PREFIX}-g++" \
ulan@chromium.org2efb9002012-01-19 15:36:35 +0000232 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
233 -Ibuild/standalone.gypi --depth=. -Ibuild/android.gypi \
danno@chromium.org2c26cb12012-05-03 09:06:43 +0000234 -S.android $(GYPFLAGS)
ulan@chromium.org2efb9002012-01-19 15:36:35 +0000235
236must-set-ANDROID_NDK_ROOT:
237ifndef ANDROID_NDK_ROOT
238 $(error ANDROID_NDK_ROOT is not set)
239endif
240
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000241# Replaces the old with the new environment file if they're different, which
242# will trigger GYP to regenerate Makefiles.
243$(ENVFILE): $(ENVFILE).new
244 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) >/dev/null; \
245 then rm $(ENVFILE).new; \
246 else mv $(ENVFILE).new $(ENVFILE); fi
247
248# Stores current GYPFLAGS in a file.
249$(ENVFILE).new:
jkummerow@chromium.org28faa982012-04-13 09:58:30 +0000250 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; \
251 echo "CXX=$(CXX)" >> $(ENVFILE).new
ricow@chromium.org55ee8072011-09-08 16:33:10 +0000252
253# Dependencies.
254dependencies:
255 svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \
fschneider@chromium.org7d10be52012-04-10 12:30:14 +0000256 --revision 1282