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