blob: 618bbef1d063956f2fcbc38535acc7778f5eb0e6 [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
53# snapshot=off
54ifeq ($(snapshot), off)
55 GYPFLAGS += -Dv8_use_snapshot='false'
56endif
57# gdbjit=on
58ifeq ($(gdbjit), on)
59 GYPFLAGS += -Dv8_enable_gdbjit=1
60endif
61# liveobjectlist=on
62ifeq ($(liveobjectlist), on)
63 GYPFLAGS += -Dv8_use_liveobjectlist=true
64endif
65# vfp3=off
66ifeq ($(vfp3), off)
67 GYPFLAGS += -Dv8_can_use_vfp_instructions=false
68else
69 GYPFLAGS += -Dv8_can_use_vfp_instructions=true
70endif
71
72# ----------------- available targets: --------------------
73# - any arch listed in ARCHES (see below)
74# - any mode listed in MODES
75# - every combination <arch>.<mode>, e.g. "ia32.release"
76# - any of the above with .check appended, e.g. "ia32.release.check"
77# - default (no target specified): build all ARCHES and MODES
78# - "check": build all targets and run all tests
79# - "<arch>.clean" for any <arch> in ARCHES
80# - "clean": clean all ARCHES
81
82# ----------------- internal stuff ------------------------
83
84# Architectures and modes to be compiled. Consider these to be internal
85# variables, don't override them (use the targets instead).
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +000086ARCHES = ia32 x64 arm
87MODES = release debug
88
89# List of files that trigger Makefile regeneration:
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000090GYPFILES = build/all.gyp build/common.gypi build/standalone.gypi \
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +000091 preparser/preparser.gyp samples/samples.gyp src/d8.gyp \
92 test/cctest/cctest.gyp tools/gyp/v8.gyp
93
94# Generates all combinations of ARCHES and MODES, e.g. "ia32.release".
95BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES)))
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +000096# Generates corresponding test targets, e.g. "ia32.release.check".
ricow@chromium.org4668a2c2011-08-29 10:41:00 +000097CHECKS = $(addsuffix .check,$(BUILDS))
98# File where previously used GYPFLAGS are stored.
99ENVFILE = $(OUTDIR)/environment
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000100
fschneider@chromium.org1805e212011-09-05 10:49:12 +0000101.PHONY: all check clean $(ENVFILE).new \
102 $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \
103 $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES))
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000104
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000105# Target definitions. "all" is the default.
106all: $(MODES)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000107
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000108# Compile targets. MODES and ARCHES are convenience targets.
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000109.SECONDEXPANSION:
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000110$(MODES): $(addsuffix .$$@,$(ARCHES))
111
112$(ARCHES): $(addprefix $$@.,$(MODES))
113
114# Defines how to build a particular target (e.g. ia32.release).
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000115$(BUILDS): $(OUTDIR)/Makefile-$$(basename $$@)
116 @$(MAKE) -C "$(OUTDIR)" -f Makefile-$(basename $@) \
117 CXX="$(CXX)" LINK="$(LINK)" \
118 BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \
119 python -c "print raw_input().capitalize()") \
120 builddir="$(shell pwd)/$(OUTDIR)/$@"
121
122# Test targets.
123check: all
124 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR)
125
126$(addsuffix .check,$(MODES)): $$(basename $$@)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000127 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
128 --mode=$(basename $@)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000129
130$(addsuffix .check,$(ARCHES)): $$(basename $$@)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000131 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
132 --arch=$(basename $@)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000133
134$(CHECKS): $$(basename $$@)
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000135 @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \
136 --arch-and-mode=$(basename $@)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000137
138# Clean targets. You can clean each architecture individually, or everything.
139$(addsuffix .clean,$(ARCHES)):
140 rm -f $(OUTDIR)/Makefile-$(basename $@)
141 rm -rf $(OUTDIR)/$(basename $@).release
142 rm -rf $(OUTDIR)/$(basename $@).debug
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000143 find $(OUTDIR) -regex '.*\(host\|target\)-$(basename $@)\.mk' -delete
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000144
145clean: $(addsuffix .clean,$(ARCHES))
146
147# GYP file generation targets.
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000148$(OUTDIR)/Makefile-ia32: $(GYPFILES) $(ENVFILE)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000149 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000150 -Ibuild/standalone.gypi --depth=. -Dtarget_arch=ia32 \
151 -S-ia32 $(GYPFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000152
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000153$(OUTDIR)/Makefile-x64: $(GYPFILES) $(ENVFILE)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000154 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000155 -Ibuild/standalone.gypi --depth=. -Dtarget_arch=x64 \
156 -S-x64 $(GYPFLAGS)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000157
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000158$(OUTDIR)/Makefile-arm: $(GYPFILES) $(ENVFILE)
kmillikin@chromium.org7c2628c2011-08-10 11:27:35 +0000159 build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \
ricow@chromium.org4668a2c2011-08-29 10:41:00 +0000160 -Ibuild/standalone.gypi --depth=. -Ibuild/armu.gypi \
161 -S-arm $(GYPFLAGS)
162
163# Replaces the old with the new environment file if they're different, which
164# will trigger GYP to regenerate Makefiles.
165$(ENVFILE): $(ENVFILE).new
166 @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) >/dev/null; \
167 then rm $(ENVFILE).new; \
168 else mv $(ENVFILE).new $(ENVFILE); fi
169
170# Stores current GYPFLAGS in a file.
171$(ENVFILE).new:
172 @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new;