OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2009 Google Inc. All rights reserved. | 3 # Copyright (c) 2009 Google Inc. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Notes: | 7 # Notes: |
8 # | 8 # |
9 # This is all roughly based on the Makefile system used by the Linux | 9 # This is all roughly based on the Makefile system used by the Linux |
10 # kernel, but is a non-recursive make -- we put the entire dependency | 10 # kernel, but is a non-recursive make -- we put the entire dependency |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 obj := $(builddir)/obj | 93 obj := $(builddir)/obj |
94 abs_obj := $(abspath $(obj)) | 94 abs_obj := $(abspath $(obj)) |
95 | 95 |
96 # We build up a list of every single one of the targets so we can slurp in the | 96 # We build up a list of every single one of the targets so we can slurp in the |
97 # generated dependency rule Makefiles in one pass. | 97 # generated dependency rule Makefiles in one pass. |
98 all_deps := | 98 all_deps := |
99 | 99 |
100 # C++ apps need to be linked with g++. Not sure what's appropriate. | 100 # C++ apps need to be linked with g++. Not sure what's appropriate. |
101 LINK ?= $(CXX) | 101 LINK ?= $(CXX) |
102 | 102 |
| 103 # We want to use GNU ar's T option if available because it's much faster. |
| 104 # We try to archive and link a file to see ar and ld support this feature. |
| 105 define detect_arflags |
| 106 $(shell \ |
| 107 mkdir -p $(obj).$(1)/arflags; |
| 108 if echo 'int main(){}' > $(obj).$(1)/arflags/artest.c && |
| 109 $(CXX.$(1)) -c $(obj).$(1)/arflags/artest.c -o $(obj).$(1)/arflags/artest
.o> /dev/null 2>&1 && |
| 110 $(AR.$(1)) crT $(obj).$(1)/arflags/artest.a $(obj).$(1)/arflags/artest.o
> /dev/null 2>&1 && |
| 111 $(LINK.$(1)) $(obj).$(1)/arflags/artest.a -o $(obj).$(1)/arflags/artest >
/dev/null 2>&1 ; then |
| 112 arflags=crT; |
| 113 else |
| 114 arflags=cr; |
| 115 fi; |
| 116 echo ARFLAGS.$(1) := $$arflags > $(obj).$(1)/arflags/arflags.mk; |
| 117 echo $$arflags; |
| 118 ) |
| 119 endef |
| 120 |
103 CC.target ?= $(CC) | 121 CC.target ?= $(CC) |
104 CFLAGS.target ?= $(CFLAGS) | 122 CFLAGS.target ?= $(CFLAGS) |
105 CXX.target ?= $(CXX) | 123 CXX.target ?= $(CXX) |
106 CXXFLAGS.target ?= $(CXXFLAGS) | 124 CXXFLAGS.target ?= $(CXXFLAGS) |
107 LINK.target ?= $(LINK) | 125 LINK.target ?= $(LINK) |
108 LDFLAGS.target ?= $(LDFLAGS) | 126 LDFLAGS.target ?= $(LDFLAGS) |
109 AR.target ?= $(AR) | 127 AR.target ?= $(AR) |
| 128 # We don't want to run the detection multiple times. So, we |
| 129 # - use $(obj).target/arflags/arflags.target.mk as the cache of the detection, |
| 130 # - use := to avoid the right hand side multiple times, and |
| 131 # - use ifeq instead of ?= because ?= is like ifeq and =, not ifeq and := . |
| 132 -include $(obj).target/arflags/arflags.mk |
| 133 ifeq ($(ARFLAGS.target),) |
| 134 ARFLAGS.target := $(call detect_arflags,target) |
| 135 endif |
110 RANLIB.target ?= ranlib | 136 RANLIB.target ?= ranlib |
111 | 137 |
112 CC.host ?= gcc | 138 CC.host ?= gcc |
113 CFLAGS.host ?= | 139 CFLAGS.host ?= |
114 CXX.host ?= g++ | 140 CXX.host ?= g++ |
115 CXXFLAGS.host ?= | 141 CXXFLAGS.host ?= |
116 LINK.host ?= g++ | 142 LINK.host ?= g++ |
117 LDFLAGS.host ?= | 143 LDFLAGS.host ?= |
118 AR.host ?= ar | 144 AR.host ?= ar |
| 145 # See the description for ARFLAGS.target. |
| 146 -include $(obj).host/arflags/arflags.mk |
| 147 ifeq ($(ARFLAGS.host),) |
| 148 ARFLAGS.host := $(call detect_arflags,host) |
| 149 endif |
119 RANLIB.host ?= ranlib | 150 RANLIB.host ?= ranlib |
120 | 151 |
121 # Flags to make gcc output dependency info. Note that you need to be | 152 # Flags to make gcc output dependency info. Note that you need to be |
122 # careful here to use the flags that ccache and distcc can understand. | 153 # careful here to use the flags that ccache and distcc can understand. |
123 # We write to a dep file on the side first and then rename at the end | 154 # We write to a dep file on the side first and then rename at the end |
124 # so we can't end up with a broken dep file. | 155 # so we can't end up with a broken dep file. |
125 depfile = $(depsdir)/$@.d | 156 depfile = $(depsdir)/$@.d |
126 DEPFLAGS = -MMD -MF $(depfile).raw | 157 DEPFLAGS = -MMD -MF $(depfile).raw |
127 | 158 |
128 # We have to fixup the deps output in a few ways. | 159 # We have to fixup the deps output in a few ways. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 # - cmd_foo is the actual command to run; | 194 # - cmd_foo is the actual command to run; |
164 # - quiet_cmd_foo is the brief-output summary of the command. | 195 # - quiet_cmd_foo is the brief-output summary of the command. |
165 | 196 |
166 quiet_cmd_cc = CC($(TOOLSET)) $@ | 197 quiet_cmd_cc = CC($(TOOLSET)) $@ |
167 cmd_cc = $(CC.$(TOOLSET)) $(CFLAGS.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) -c -o $
@ $< | 198 cmd_cc = $(CC.$(TOOLSET)) $(CFLAGS.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) -c -o $
@ $< |
168 | 199 |
169 quiet_cmd_cxx = CXX($(TOOLSET)) $@ | 200 quiet_cmd_cxx = CXX($(TOOLSET)) $@ |
170 cmd_cxx = $(CXX.$(TOOLSET)) $(CXXFLAGS.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) -
c -o $@ $< | 201 cmd_cxx = $(CXX.$(TOOLSET)) $(CXXFLAGS.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) -
c -o $@ $< |
171 | 202 |
172 quiet_cmd_alink = AR+RANLIB($(TOOLSET)) $@ | 203 quiet_cmd_alink = AR+RANLIB($(TOOLSET)) $@ |
173 cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) rc $@ $(filter %.o,$^) && $(RANLIB.$(TO
OLSET)) $@ | 204 cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) $(ARFLAGS.$(TOOLSET)) $@ $(filter %.o,$
^) && $(RANLIB.$(TOOLSET)) $@ |
174 | 205 |
175 quiet_cmd_touch = TOUCH $@ | 206 quiet_cmd_touch = TOUCH $@ |
176 cmd_touch = touch $@ | 207 cmd_touch = touch $@ |
177 | 208 |
178 quiet_cmd_copy = COPY $@ | 209 quiet_cmd_copy = COPY $@ |
179 # send stderr to /dev/null to ignore messages when linking directories. | 210 # send stderr to /dev/null to ignore messages when linking directories. |
180 cmd_copy = ln -f $< $@ 2>/dev/null || cp -af $< $@ | 211 cmd_copy = ln -f $< $@ 2>/dev/null || cp -af $< $@ |
181 | 212 |
182 # Due to circular dependencies between libraries :(, we wrap the | 213 # Due to circular dependencies between libraries :(, we wrap the |
183 # special "figure out circular dependencies" flags around the entire | 214 # special "figure out circular dependencies" flags around the entire |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 makefile_name, | 1308 makefile_name, |
1278 ' '.join(map(Sourceify, build_files)), | 1309 ' '.join(map(Sourceify, build_files)), |
1279 gyp.common.EncodePOSIXShellList( | 1310 gyp.common.EncodePOSIXShellList( |
1280 [gyp_binary, '-fmake'] + | 1311 [gyp_binary, '-fmake'] + |
1281 gyp.RegenerateFlags(options) + | 1312 gyp.RegenerateFlags(options) + |
1282 build_files_args))) | 1313 build_files_args))) |
1283 | 1314 |
1284 root_makefile.write(SHARED_FOOTER) | 1315 root_makefile.write(SHARED_FOOTER) |
1285 | 1316 |
1286 root_makefile.close() | 1317 root_makefile.close() |
OLD | NEW |