blob: ebf68312b56830fc091faa551b71f75bf70c58c4 [file] [log] [blame]
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +00001# Copyright 2011 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++" # For distcc: export CXX="distcc g++"
31LINK ?= "g++"
32OUTDIR ?= out
33TESTJOBS ?= -j16
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000034GYPFLAGS ?=
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +000035
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000036# Special build flags. Use them like this: "make library=shared"
37
38# library=shared || component=shared_library
39ifeq ($(library), shared)
40 GYPFLAGS += -Dcomponent=shared_library
41endif
42ifdef component
43 GYPFLAGS += -Dcomponent=$(component)
44endif
45# console=readline
46ifdef console
47 GYPFLAGS += -Dconsole=$(console)
48endif
49# disassembler=on
50ifeq ($(disassembler), on)
51 GYPFLAGS += -Dv8_enable_disassembler=1
52endif
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000053# objectprint=on
54ifeq ($(objectprint), on)
55 GYPFLAGS += -Dv8_object_print=1
56endif
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000057# snapshot=off
58ifeq ($(snapshot), off)
59 GYPFLAGS += -Dv8_use_snapshot='false'
60endif
61# gdbjit=on
62ifeq ($(gdbjit), on)
63 GYPFLAGS += -Dv8_enable_gdbjit=1
64endif
65# liveobjectlist=on
66ifeq ($(liveobjectlist), on)
67 GYPFLAGS += -Dv8_use_liveobjectlist=true
68endif
69# vfp3=off
70ifeq ($(vfp3), off)
71 GYPFLAGS += -Dv8_can_use_vfp_instructions=false
72else
73 GYPFLAGS += -Dv8_can_use_vfp_instructions=true
74endif
ricow@chromium.org55ee8072011-09-08 16:33:10 +000075# soname_version=1.2.3
76ifdef soname_version
77 GYPFLAGS += -Dsoname_version=$(soname_version)
78endif
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000079
80# ----------------- available targets: --------------------
ricow@chromium.org55ee8072011-09-08 16:33:10 +000081# - "dependencies": pulls in external dependencies (currently: GYP)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000082# - any arch listed in ARCHES (see below)
83# - any mode listed in MODES
84# - every combination <arch>.<mode>, e.g. "ia32.release"
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +000085# - "native": current host's architecture, release mode
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000086# - any of the above with .check appended, e.g. "ia32.release.check"
87# - default (no target specified): build all ARCHES and MODES
88# - "check": build all targets and run all tests
89# - "<arch>.clean" for any <arch> in ARCHES
90# - "clean": clean all ARCHES
91
92# ----------------- internal stuff ------------------------
93
94# Architectures and modes to be compiled. Consider these to be internal
95# variables, don't override them (use the targets instead).
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +000096ARCHES = ia32 x64 arm
97MODES = release debug
98
99# List of files that trigger Makefile regeneration:
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000100GYPFILES = build/all.gyp build/common.gypi build/standalone.gypi \
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000101 preparser/preparser.gyp samples/samples.gyp src/d8.gyp \
102 test/cctest/cctest.gyp tools/gyp/v8.gyp
103
104# Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
105BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000106# Generates corresponding test targets, e.g. "ia32.release.check".
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000107CHECKS = $(addsuffix .check,$(BUILDS))
108# File where previously used GYPFLAGS are stored.
109ENVFILE = $(OUTDIR)/environment
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000110
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000111.PHONY: all check clean dependencies $(ENVFILE).new native \
fschneider@chromium.org1805e212011-09-05 10:49:12 +0000112 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
113 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES))
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000114
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000115# Target definitions. "all" is the default.
116all: $(MODES)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000117
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000118# Compile targets. MODES and ARCHES are convenience targets.
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000119.SECONDEXPANSION:
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000120$(MODES): $(addsuffix .$$@,$(ARCHES))
121
122$(ARCHES): $(addprefix $$@.,$(MODES))
123
124# Defines how to build a particular target (e.g. ia32.release).
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000125$(BUILDS): $(OUTDIR)/Makefile-$$(basename $$@)
126 @$(MAKE) -C "$(OUTDIR)" -f Makefile-$(basename $@) \
127 CXX="$(CXX)" LINK="$(LINK)" \
128 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
129 python -c "print raw_input().capitalize()") \
130 builddir="$(shell pwd)/$(OUTDIR)/$@"
131
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000132native: $(OUTDIR)/Makefile-native
133 @$(MAKE) -C "$(OUTDIR)" -f Makefile-native \
134 CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \
135 builddir="$(shell pwd)/$(OUTDIR)/$@"
136
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000137# Test targets.
138check: all
139 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR)
140
141$(addsuffix .check,$(MODES)): $$(basename $$@)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000142 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
143 --mode=$(basename $@)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000144
145$(addsuffix .check,$(ARCHES)): $$(basename $$@)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000146 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
147 --arch=$(basename $@)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000148
149$(CHECKS): $$(basename $$@)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000150 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
151 --arch-and-mode=$(basename $@)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000152
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000153native.check: native
154 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR)/native \
155 --arch-and-mode=.
156
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000157# Clean targets. You can clean each architecture individually, or everything.
158$(addsuffix .clean,$(ARCHES)):
159 rm -f $(OUTDIR)/Makefile-$(basename $@)
160 rm -rf $(OUTDIR)/$(basename $@).release
161 rm -rf $(OUTDIR)/$(basename $@).debug
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000162 find $(OUTDIR) -regex '.*\(host\|target\)-$(basename $@)\.mk' -delete
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000163
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000164native.clean:
165 rm -f $(OUTDIR)/Makefile-native
166 rm -rf $(OUTDIR)/native
167 find $(OUTDIR) -regex '.*\(host\|target\)-native\.mk' -delete
168
169clean: $(addsuffix .clean,$(ARCHES)) native.clean
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000170
171# GYP file generation targets.
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000172$(OUTDIR)/Makefile-ia32: $(GYPFILES) $(ENVFILE)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000173 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000174 -Ibuild/standalone.gypi --depth=. -Dtarget_arch=ia32 \
175 -S-ia32 $(GYPFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000176
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000177$(OUTDIR)/Makefile-x64: $(GYPFILES) $(ENVFILE)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000178 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000179 -Ibuild/standalone.gypi --depth=. -Dtarget_arch=x64 \
180 -S-x64 $(GYPFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000181
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000182$(OUTDIR)/Makefile-arm: $(GYPFILES) $(ENVFILE)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000183 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000184 -Ibuild/standalone.gypi --depth=. -Ibuild/armu.gypi \
185 -S-arm $(GYPFLAGS)
186
erik.corry@gmail.comc3b670f2011-10-05 21:44:48 +0000187$(OUTDIR)/Makefile-native: $(GYPFILES) $(ENVFILE)
188 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
189 -Ibuild/standalone.gypi --depth=. -S-native $(GYPFLAGS)
190
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000191# Replaces the old with the new environment file if they're different, which
192# will trigger GYP to regenerate Makefiles.
193$(ENVFILE): $(ENVFILE).new
194 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) >/dev/null; \
195 then rm $(ENVFILE).new; \
196 else mv $(ENVFILE).new $(ENVFILE); fi
197
198# Stores current GYPFLAGS in a file.
199$(ENVFILE).new:
200 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new;
ricow@chromium.org55ee8072011-09-08 16:33:10 +0000201
202# Dependencies.
203dependencies:
204 svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \
205 --revision 1026