kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 1 | # 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. |
| 30 | CXX ?= "g++" # For distcc: export CXX="distcc g++" |
| 31 | LINK ?= "g++" |
| 32 | OUTDIR ?= out |
| 33 | TESTJOBS ?= -j16 |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 34 | GYPFLAGS ?= |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame^] | 35 | TESTFLAGS ?= |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 36 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 37 | # Special build flags. Use them like this: "make library=shared" |
| 38 | |
| 39 | # library=shared || component=shared_library |
| 40 | ifeq ($(library), shared) |
| 41 | GYPFLAGS += -Dcomponent=shared_library |
| 42 | endif |
| 43 | ifdef component |
| 44 | GYPFLAGS += -Dcomponent=$(component) |
| 45 | endif |
| 46 | # console=readline |
| 47 | ifdef console |
| 48 | GYPFLAGS += -Dconsole=$(console) |
| 49 | endif |
| 50 | # disassembler=on |
| 51 | ifeq ($(disassembler), on) |
| 52 | GYPFLAGS += -Dv8_enable_disassembler=1 |
| 53 | endif |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 54 | # objectprint=on |
| 55 | ifeq ($(objectprint), on) |
| 56 | GYPFLAGS += -Dv8_object_print=1 |
| 57 | endif |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 58 | # snapshot=off |
| 59 | ifeq ($(snapshot), off) |
| 60 | GYPFLAGS += -Dv8_use_snapshot='false' |
| 61 | endif |
| 62 | # gdbjit=on |
| 63 | ifeq ($(gdbjit), on) |
| 64 | GYPFLAGS += -Dv8_enable_gdbjit=1 |
| 65 | endif |
| 66 | # liveobjectlist=on |
| 67 | ifeq ($(liveobjectlist), on) |
| 68 | GYPFLAGS += -Dv8_use_liveobjectlist=true |
| 69 | endif |
| 70 | # vfp3=off |
| 71 | ifeq ($(vfp3), off) |
| 72 | GYPFLAGS += -Dv8_can_use_vfp_instructions=false |
| 73 | else |
| 74 | GYPFLAGS += -Dv8_can_use_vfp_instructions=true |
| 75 | endif |
ricow@chromium.org | 55ee807 | 2011-09-08 16:33:10 +0000 | [diff] [blame] | 76 | # soname_version=1.2.3 |
| 77 | ifdef soname_version |
| 78 | GYPFLAGS += -Dsoname_version=$(soname_version) |
| 79 | endif |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame^] | 80 | # werror=no |
| 81 | ifeq ($(werror), no) |
| 82 | GYPFLAGS += -Dwerror='' |
| 83 | endif |
| 84 | # presubmit=no |
| 85 | ifeq ($(presubmit), no) |
| 86 | TESTFLAGS += --no-presubmit |
| 87 | endif |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 88 | |
| 89 | # ----------------- available targets: -------------------- |
ricow@chromium.org | 55ee807 | 2011-09-08 16:33:10 +0000 | [diff] [blame] | 90 | # - "dependencies": pulls in external dependencies (currently: GYP) |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 91 | # - any arch listed in ARCHES (see below) |
| 92 | # - any mode listed in MODES |
| 93 | # - every combination <arch>.<mode>, e.g. "ia32.release" |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 94 | # - "native": current host's architecture, release mode |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 95 | # - any of the above with .check appended, e.g. "ia32.release.check" |
| 96 | # - default (no target specified): build all ARCHES and MODES |
| 97 | # - "check": build all targets and run all tests |
| 98 | # - "<arch>.clean" for any <arch> in ARCHES |
| 99 | # - "clean": clean all ARCHES |
| 100 | |
| 101 | # ----------------- internal stuff ------------------------ |
| 102 | |
| 103 | # Architectures and modes to be compiled. Consider these to be internal |
| 104 | # variables, don't override them (use the targets instead). |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 105 | ARCHES = ia32 x64 arm |
| 106 | MODES = release debug |
| 107 | |
| 108 | # List of files that trigger Makefile regeneration: |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 109 | GYPFILES = build/all.gyp build/common.gypi build/standalone.gypi \ |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 110 | preparser/preparser.gyp samples/samples.gyp src/d8.gyp \ |
| 111 | test/cctest/cctest.gyp tools/gyp/v8.gyp |
| 112 | |
| 113 | # Generates all combinations of ARCHES and MODES, e.g. "ia32.release". |
| 114 | BUILDS = $(foreach mode,$(MODES),$(addsuffix .$(mode),$(ARCHES))) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 115 | # Generates corresponding test targets, e.g. "ia32.release.check". |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 116 | CHECKS = $(addsuffix .check,$(BUILDS)) |
| 117 | # File where previously used GYPFLAGS are stored. |
| 118 | ENVFILE = $(OUTDIR)/environment |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 119 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 120 | .PHONY: all check clean dependencies $(ENVFILE).new native \ |
fschneider@chromium.org | 1805e21 | 2011-09-05 10:49:12 +0000 | [diff] [blame] | 121 | $(ARCHES) $(MODES) $(BUILDS) $(CHECKS) $(addsuffix .clean,$(ARCHES)) \ |
| 122 | $(addsuffix .check,$(MODES)) $(addsuffix .check,$(ARCHES)) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 123 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 124 | # Target definitions. "all" is the default. |
| 125 | all: $(MODES) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 126 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 127 | # Compile targets. MODES and ARCHES are convenience targets. |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 128 | .SECONDEXPANSION: |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 129 | $(MODES): $(addsuffix .$$@,$(ARCHES)) |
| 130 | |
| 131 | $(ARCHES): $(addprefix $$@.,$(MODES)) |
| 132 | |
| 133 | # Defines how to build a particular target (e.g. ia32.release). |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 134 | $(BUILDS): $(OUTDIR)/Makefile-$$(basename $$@) |
| 135 | @$(MAKE) -C "$(OUTDIR)" -f Makefile-$(basename $@) \ |
| 136 | CXX="$(CXX)" LINK="$(LINK)" \ |
| 137 | BUILDTYPE=$(shell echo $(subst .,,$(suffix $@)) | \ |
| 138 | python -c "print raw_input().capitalize()") \ |
| 139 | builddir="$(shell pwd)/$(OUTDIR)/$@" |
| 140 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 141 | native: $(OUTDIR)/Makefile-native |
| 142 | @$(MAKE) -C "$(OUTDIR)" -f Makefile-native \ |
| 143 | CXX="$(CXX)" LINK="$(LINK)" BUILDTYPE=Release \ |
| 144 | builddir="$(shell pwd)/$(OUTDIR)/$@" |
| 145 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 146 | # Test targets. |
| 147 | check: all |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame^] | 148 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \ |
| 149 | $(TESTFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 150 | |
| 151 | $(addsuffix .check,$(MODES)): $$(basename $$@) |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 152 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame^] | 153 | --mode=$(basename $@) $(TESTFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 154 | |
| 155 | $(addsuffix .check,$(ARCHES)): $$(basename $$@) |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 156 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame^] | 157 | --arch=$(basename $@) $(TESTFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 158 | |
| 159 | $(CHECKS): $$(basename $$@) |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 160 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR) \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame^] | 161 | --arch-and-mode=$(basename $@) $(TESTFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 162 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 163 | native.check: native |
| 164 | @tools/test-wrapper-gypbuild.py $(TESTJOBS) --outdir=$(OUTDIR)/native \ |
svenpanne@chromium.org | a8bb4d9 | 2011-10-10 13:20:40 +0000 | [diff] [blame^] | 165 | --arch-and-mode=. $(TESTFLAGS) |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 166 | |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 167 | # Clean targets. You can clean each architecture individually, or everything. |
| 168 | $(addsuffix .clean,$(ARCHES)): |
| 169 | rm -f $(OUTDIR)/Makefile-$(basename $@) |
| 170 | rm -rf $(OUTDIR)/$(basename $@).release |
| 171 | rm -rf $(OUTDIR)/$(basename $@).debug |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 172 | find $(OUTDIR) -regex '.*\(host\|target\)-$(basename $@)\.mk' -delete |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 173 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 174 | native.clean: |
| 175 | rm -f $(OUTDIR)/Makefile-native |
| 176 | rm -rf $(OUTDIR)/native |
| 177 | find $(OUTDIR) -regex '.*\(host\|target\)-native\.mk' -delete |
| 178 | |
| 179 | clean: $(addsuffix .clean,$(ARCHES)) native.clean |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 180 | |
| 181 | # GYP file generation targets. |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 182 | $(OUTDIR)/Makefile-ia32: $(GYPFILES) $(ENVFILE) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 183 | build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 184 | -Ibuild/standalone.gypi --depth=. -Dtarget_arch=ia32 \ |
| 185 | -S-ia32 $(GYPFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 186 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 187 | $(OUTDIR)/Makefile-x64: $(GYPFILES) $(ENVFILE) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 188 | build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 189 | -Ibuild/standalone.gypi --depth=. -Dtarget_arch=x64 \ |
| 190 | -S-x64 $(GYPFLAGS) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 191 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 192 | $(OUTDIR)/Makefile-arm: $(GYPFILES) $(ENVFILE) |
kmillikin@chromium.org | 7c2628c | 2011-08-10 11:27:35 +0000 | [diff] [blame] | 193 | build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 194 | -Ibuild/standalone.gypi --depth=. -Ibuild/armu.gypi \ |
| 195 | -S-arm $(GYPFLAGS) |
| 196 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 197 | $(OUTDIR)/Makefile-native: $(GYPFILES) $(ENVFILE) |
| 198 | build/gyp/gyp --generator-output="$(OUTDIR)" build/all.gyp \ |
| 199 | -Ibuild/standalone.gypi --depth=. -S-native $(GYPFLAGS) |
| 200 | |
ricow@chromium.org | 4668a2c | 2011-08-29 10:41:00 +0000 | [diff] [blame] | 201 | # Replaces the old with the new environment file if they're different, which |
| 202 | # will trigger GYP to regenerate Makefiles. |
| 203 | $(ENVFILE): $(ENVFILE).new |
| 204 | @if test -r $(ENVFILE) && cmp $(ENVFILE).new $(ENVFILE) >/dev/null; \ |
| 205 | then rm $(ENVFILE).new; \ |
| 206 | else mv $(ENVFILE).new $(ENVFILE); fi |
| 207 | |
| 208 | # Stores current GYPFLAGS in a file. |
| 209 | $(ENVFILE).new: |
| 210 | @mkdir -p $(OUTDIR); echo "GYPFLAGS=$(GYPFLAGS)" > $(ENVFILE).new; |
ricow@chromium.org | 55ee807 | 2011-09-08 16:33:10 +0000 | [diff] [blame] | 211 | |
| 212 | # Dependencies. |
| 213 | dependencies: |
| 214 | svn checkout --force http://gyp.googlecode.com/svn/trunk build/gyp \ |
| 215 | --revision 1026 |