1 | # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4 |
---|
2 | # portconfigure.tcl |
---|
3 | # $Id: portconfigure.tcl 80130 2011-07-05 03:56:34Z jmr@macports.org $ |
---|
4 | # |
---|
5 | # Copyright (c) 2007 - 2011 The MacPorts Project |
---|
6 | # Copyright (c) 2007 Markus W. Weissmann <mww@macports.org> |
---|
7 | # Copyright (c) 2002 - 2003 Apple Inc. |
---|
8 | # All rights reserved. |
---|
9 | # |
---|
10 | # Redistribution and use in source and binary forms, with or without |
---|
11 | # modification, are permitted provided that the following conditions |
---|
12 | # are met: |
---|
13 | # 1. Redistributions of source code must retain the above copyright |
---|
14 | # notice, this list of conditions and the following disclaimer. |
---|
15 | # 2. Redistributions in binary form must reproduce the above copyright |
---|
16 | # notice, this list of conditions and the following disclaimer in the |
---|
17 | # documentation and/or other materials provided with the distribution. |
---|
18 | # 3. Neither the name of Apple Inc. nor the names of its contributors |
---|
19 | # may be used to endorse or promote products derived from this software |
---|
20 | # without specific prior written permission. |
---|
21 | # |
---|
22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
23 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
24 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
25 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
---|
26 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
27 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
28 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
29 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
30 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
31 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
32 | # POSSIBILITY OF SUCH DAMAGE. |
---|
33 | # |
---|
34 | |
---|
35 | package provide portconfigure 1.0 |
---|
36 | package require portutil 1.0 |
---|
37 | |
---|
38 | set org.macports.configure [target_new org.macports.configure portconfigure::configure_main] |
---|
39 | target_provides ${org.macports.configure} configure |
---|
40 | target_requires ${org.macports.configure} main fetch checksum extract patch |
---|
41 | target_prerun ${org.macports.configure} portconfigure::configure_start |
---|
42 | |
---|
43 | namespace eval portconfigure { |
---|
44 | } |
---|
45 | |
---|
46 | # define options |
---|
47 | commands configure autoreconf automake autoconf xmkmf |
---|
48 | # defaults |
---|
49 | default configure.env "" |
---|
50 | default configure.pre_args {--prefix=${prefix}} |
---|
51 | default configure.cmd ./configure |
---|
52 | default configure.nice {${buildnicevalue}} |
---|
53 | default configure.dir {${worksrcpath}} |
---|
54 | default autoreconf.dir {${worksrcpath}} |
---|
55 | default autoreconf.pre_args {--install} |
---|
56 | default autoconf.dir {${worksrcpath}} |
---|
57 | default automake.dir {${worksrcpath}} |
---|
58 | default xmkmf.cmd xmkmf |
---|
59 | default xmkmf.dir {${worksrcpath}} |
---|
60 | default use_configure yes |
---|
61 | |
---|
62 | option_proc use_autoreconf portconfigure::set_configure_type |
---|
63 | option_proc use_automake portconfigure::set_configure_type |
---|
64 | option_proc use_autoconf portconfigure::set_configure_type |
---|
65 | option_proc use_xmkmf portconfigure::set_configure_type |
---|
66 | |
---|
67 | option_proc autoreconf.cmd portconfigure::set_configure_type |
---|
68 | option_proc automake.cmd portconfigure::set_configure_type |
---|
69 | option_proc autoconf.cmd portconfigure::set_configure_type |
---|
70 | option_proc xmkmf.cmd portconfigure::set_configure_type |
---|
71 | |
---|
72 | ## |
---|
73 | # Local helper proc |
---|
74 | proc portconfigure::add_build_dep { type dep } { |
---|
75 | global ${type}.cmd option_defaults |
---|
76 | |
---|
77 | if {![info exists ${type}.cmd] || ( |
---|
78 | ([info exists option_defaults(${type}.cmd)] && [set ${type}.cmd] == $option_defaults(${type}.cmd)) || |
---|
79 | (![info exists option_defaults(${type}.cmd)] && [set ${type}.cmd] == "${type}") |
---|
80 | )} { |
---|
81 | eval depends_build-append $dep |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | ## |
---|
86 | # Adds dependencies for the binaries which will be called, but only if it is |
---|
87 | # the default. If .cmd was overwritten the port has to care for deps itself. |
---|
88 | proc portconfigure::set_configure_type {option action args} { |
---|
89 | global autoreconf.cmd automake.cmd autoconf.cmd xmkmf.cmd |
---|
90 | |
---|
91 | array set configure_map { |
---|
92 | autoconf {port:autoconf port:automake port:libtool} |
---|
93 | xmkmf port:imake |
---|
94 | } |
---|
95 | |
---|
96 | if {[string equal ${action} "set"]} { |
---|
97 | switch $option { |
---|
98 | autoreconf.cmd - |
---|
99 | automake.cmd - |
---|
100 | autoconf.cmd { |
---|
101 | eval depends_build-delete $configure_map(autoconf) |
---|
102 | } |
---|
103 | xmkmf.cmd { |
---|
104 | depends_build-delete $configure_map(xmkmf) |
---|
105 | } |
---|
106 | use_xmkmf { |
---|
107 | if {[tbool args]} { |
---|
108 | depends_build-append $configure_map(xmkmf) |
---|
109 | } |
---|
110 | } |
---|
111 | default { |
---|
112 | # strip "use_" |
---|
113 | set type [string range $option 4 end] |
---|
114 | if {[tbool args]} { |
---|
115 | add_build_dep $type $configure_map(autoconf) |
---|
116 | } |
---|
117 | } |
---|
118 | } |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | options configure.asroot |
---|
123 | default configure.asroot no |
---|
124 | |
---|
125 | # Configure special environment variables. |
---|
126 | # We could have m32/m64/march/mtune be global configurable at some point. |
---|
127 | options configure.m32 configure.m64 configure.march configure.mtune |
---|
128 | default configure.march {} |
---|
129 | default configure.mtune {} |
---|
130 | # We could have debug/optimizations be global configurable at some point. |
---|
131 | options configure.optflags configure.cflags configure.cppflags configure.cxxflags configure.objcflags configure.ldflags configure.libs configure.fflags configure.f90flags configure.fcflags configure.classpath |
---|
132 | default configure.optflags {-O2} |
---|
133 | # compiler flags section |
---|
134 | default configure.cflags {${configure.optflags}} |
---|
135 | default configure.cppflags {-I${prefix}/include} |
---|
136 | default configure.cxxflags {${configure.optflags}} |
---|
137 | default configure.objcflags {${configure.optflags}} |
---|
138 | default configure.ldflags {-L${prefix}/lib} |
---|
139 | default configure.libs {} |
---|
140 | default configure.fflags {${configure.optflags}} |
---|
141 | default configure.f90flags {${configure.optflags}} |
---|
142 | default configure.fcflags {${configure.optflags}} |
---|
143 | default configure.classpath {} |
---|
144 | |
---|
145 | # tools section |
---|
146 | options configure.perl configure.python configure.ruby configure.install configure.awk configure.bison configure.pkg_config configure.pkg_config_path |
---|
147 | default configure.perl {} |
---|
148 | default configure.python {} |
---|
149 | default configure.ruby {} |
---|
150 | default configure.install {${portutil::autoconf::install_command}} |
---|
151 | default configure.awk {} |
---|
152 | default configure.bison {} |
---|
153 | default configure.pkg_config {} |
---|
154 | default configure.pkg_config_path {} |
---|
155 | |
---|
156 | options configure.build_arch configure.ld_archflags configure.sdkroot |
---|
157 | default configure.build_arch {[portconfigure::choose_supported_archs ${build_arch}]} |
---|
158 | default configure.ld_archflags {[portconfigure::configure_get_ld_archflags]} |
---|
159 | default configure.sdkroot {[portconfigure::configure_get_sdkroot]} |
---|
160 | foreach tool {cc cxx objc f77 f90 fc} { |
---|
161 | options configure.${tool}_archflags |
---|
162 | default configure.${tool}_archflags "\[portconfigure::configure_get_archflags $tool\]" |
---|
163 | } |
---|
164 | |
---|
165 | options configure.universal_archs configure.universal_args configure.universal_cflags configure.universal_cppflags configure.universal_cxxflags configure.universal_ldflags |
---|
166 | default configure.universal_archs {[portconfigure::choose_supported_archs ${universal_archs}]} |
---|
167 | default configure.universal_args {--disable-dependency-tracking} |
---|
168 | default configure.universal_cflags {[portconfigure::configure_get_universal_cflags]} |
---|
169 | default configure.universal_cppflags {} |
---|
170 | default configure.universal_cxxflags {[portconfigure::configure_get_universal_cflags]} |
---|
171 | default configure.universal_ldflags {[portconfigure::configure_get_universal_ldflags]} |
---|
172 | |
---|
173 | # Select a distinct compiler (C, C preprocessor, C++) |
---|
174 | options configure.ccache configure.distcc configure.pipe configure.cc configure.cxx configure.cpp configure.objc configure.f77 configure.f90 configure.fc configure.javac configure.compiler |
---|
175 | default configure.ccache {${configureccache}} |
---|
176 | default configure.distcc {${configuredistcc}} |
---|
177 | default configure.pipe {${configurepipe}} |
---|
178 | default configure.cc {[portconfigure::configure_get_compiler cc]} |
---|
179 | default configure.cxx {[portconfigure::configure_get_compiler cxx]} |
---|
180 | default configure.cpp {[portconfigure::configure_get_compiler cpp]} |
---|
181 | default configure.objc {[portconfigure::configure_get_compiler objc]} |
---|
182 | default configure.f77 {[portconfigure::configure_get_compiler f77]} |
---|
183 | default configure.f90 {[portconfigure::configure_get_compiler f90]} |
---|
184 | default configure.fc {[portconfigure::configure_get_compiler fc]} |
---|
185 | default configure.javac {[portconfigure::configure_get_compiler javac]} |
---|
186 | default configure.compiler {[portconfigure::configure_get_default_compiler]} |
---|
187 | |
---|
188 | set_ui_prefix |
---|
189 | |
---|
190 | proc portconfigure::configure_start {args} { |
---|
191 | global UI_PREFIX configure.compiler |
---|
192 | |
---|
193 | ui_notice "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option subport]]" |
---|
194 | |
---|
195 | set name "" |
---|
196 | switch -exact ${configure.compiler} { |
---|
197 | gcc { set name "System gcc" } |
---|
198 | gcc-3.3 { set name "Mac OS X gcc 3.3" } |
---|
199 | gcc-4.0 { set name "Mac OS X gcc 4.0" } |
---|
200 | gcc-4.2 { set name "Mac OS X gcc 4.2" } |
---|
201 | llvm-gcc-4.2 { set name "Mac OS X llvm-gcc 4.2" } |
---|
202 | clang { set name "Mac OS X clang" } |
---|
203 | apple-gcc-3.3 { set name "MacPorts Apple gcc 3.3" } |
---|
204 | apple-gcc-4.0 { set name "MacPorts Apple gcc 4.0" } |
---|
205 | apple-gcc-4.2 { set name "MacPorts Apple gcc 4.2" } |
---|
206 | macports-gcc-4.0 { set name "MacPorts gcc 4.0" } |
---|
207 | macports-gcc-4.1 { set name "MacPorts gcc 4.1" } |
---|
208 | macports-gcc-4.2 { set name "MacPorts gcc 4.2" } |
---|
209 | macports-gcc-4.3 { set name "MacPorts gcc 4.3" } |
---|
210 | macports-gcc-4.4 { set name "MacPorts gcc 4.4" } |
---|
211 | macports-gcc-4.5 { set name "MacPorts gcc 4.5" } |
---|
212 | macports-gcc-4.6 { set name "MacPorts gcc 4.6" } |
---|
213 | macports-llvm-gcc-4.2 { set name "MacPorts llvm-gcc 4.2" } |
---|
214 | macports-clang { set name "MacPorts clang" } |
---|
215 | default { return -code error "Invalid value for configure.compiler" } |
---|
216 | } |
---|
217 | ui_debug "Using compiler '$name'" |
---|
218 | |
---|
219 | # Additional ccache directory setup |
---|
220 | global configureccache ccache_dir ccache_size macportsuser |
---|
221 | if {${configureccache}} { |
---|
222 | elevateToRoot "configure ccache" |
---|
223 | if [catch { |
---|
224 | file mkdir ${ccache_dir} |
---|
225 | file attributes ${ccache_dir} -owner ${macportsuser} -permissions 0755 |
---|
226 | exec ccache -M ${ccache_size} >/dev/null |
---|
227 | } result] { |
---|
228 | ui_warn "ccache_dir ${ccache_dir} could not be initialized; disabling ccache: $result" |
---|
229 | set configureccache no |
---|
230 | } |
---|
231 | dropPrivileges |
---|
232 | } |
---|
233 | } |
---|
234 | |
---|
235 | # internal function to choose the default configure.build_arch and |
---|
236 | # configure.universal_archs based on supported_archs and build_arch or |
---|
237 | # universal_archs |
---|
238 | proc portconfigure::choose_supported_archs {archs} { |
---|
239 | global supported_archs |
---|
240 | if {$supported_archs == ""} { |
---|
241 | return $archs |
---|
242 | } |
---|
243 | set ret {} |
---|
244 | foreach arch $archs { |
---|
245 | if {[lsearch -exact $supported_archs $arch] != -1} { |
---|
246 | set add_arch $arch |
---|
247 | } elseif {$arch == "x86_64" && [lsearch -exact $supported_archs "i386"] != -1} { |
---|
248 | set add_arch "i386" |
---|
249 | } elseif {$arch == "ppc64" && [lsearch -exact $supported_archs "ppc"] != -1} { |
---|
250 | set add_arch "ppc" |
---|
251 | } else { |
---|
252 | continue |
---|
253 | } |
---|
254 | if {[lsearch -exact $ret $add_arch] == -1} { |
---|
255 | lappend ret $add_arch |
---|
256 | } |
---|
257 | } |
---|
258 | return $ret |
---|
259 | } |
---|
260 | |
---|
261 | # internal function to determine the compiler flags to select an arch |
---|
262 | proc portconfigure::configure_get_archflags {tool} { |
---|
263 | global configure.build_arch configure.m32 configure.m64 configure.compiler |
---|
264 | set flags "" |
---|
265 | if {[tbool configure.m64]} { |
---|
266 | set flags "-m64" |
---|
267 | } elseif {[tbool configure.m32]} { |
---|
268 | set flags "-m32" |
---|
269 | } elseif {${configure.build_arch} != ""} { |
---|
270 | if {[arch_flag_supported] && ($tool == "cc" || $tool == "cxx" || $tool == "objc")} { |
---|
271 | set flags "-arch ${configure.build_arch}" |
---|
272 | } elseif {${configure.build_arch} == "x86_64" || ${configure.build_arch} == "ppc64"} { |
---|
273 | set flags "-m64" |
---|
274 | } elseif {${configure.compiler} != "gcc-3.3"} { |
---|
275 | set flags "-m32" |
---|
276 | } |
---|
277 | } |
---|
278 | return $flags |
---|
279 | } |
---|
280 | |
---|
281 | # internal function to determine the ld flags to select an arch |
---|
282 | # Unfortunately there's no consistent way to do this when the compiler |
---|
283 | # doesn't support -arch, because it could be used to link rather than using |
---|
284 | # ld directly. So we punt and let portfiles deal with that case. |
---|
285 | proc portconfigure::configure_get_ld_archflags {args} { |
---|
286 | global configure.build_arch |
---|
287 | if {${configure.build_arch} != "" && [arch_flag_supported]} { |
---|
288 | return "-arch ${configure.build_arch}" |
---|
289 | } else { |
---|
290 | return "" |
---|
291 | } |
---|
292 | } |
---|
293 | |
---|
294 | proc portconfigure::configure_get_sdkroot {} { |
---|
295 | global developer_dir macosx_deployment_target macosx_version os.arch os.platform |
---|
296 | if {${os.platform} == "darwin" && ($macosx_deployment_target != $macosx_version |
---|
297 | || (${os.arch} == "powerpc" && $macosx_version == "10.4" && [variant_exists universal] && [variant_isset universal]))} { |
---|
298 | if {$macosx_deployment_target == "10.4"} { |
---|
299 | set sdk "${developer_dir}/SDKs/MacOSX10.4u.sdk" |
---|
300 | } else { |
---|
301 | set sdk "${developer_dir}/SDKs/MacOSX${macosx_deployment_target}.sdk" |
---|
302 | } |
---|
303 | if {[file exists $sdk]} { |
---|
304 | return $sdk |
---|
305 | } |
---|
306 | } |
---|
307 | return "" |
---|
308 | } |
---|
309 | |
---|
310 | # internal function to determine the "-arch xy" flags for the compiler |
---|
311 | proc portconfigure::configure_get_universal_archflags {args} { |
---|
312 | global configure.universal_archs |
---|
313 | set flags "" |
---|
314 | foreach arch ${configure.universal_archs} { |
---|
315 | if {$flags == ""} { |
---|
316 | set flags "-arch $arch" |
---|
317 | } else { |
---|
318 | append flags " -arch $arch" |
---|
319 | } |
---|
320 | } |
---|
321 | return $flags |
---|
322 | } |
---|
323 | |
---|
324 | # internal function to determine the CFLAGS for the compiler |
---|
325 | proc portconfigure::configure_get_universal_cflags {args} { |
---|
326 | return [configure_get_universal_archflags] |
---|
327 | } |
---|
328 | |
---|
329 | # internal function to determine the LDFLAGS for the compiler |
---|
330 | proc portconfigure::configure_get_universal_ldflags {args} { |
---|
331 | return [configure_get_universal_archflags] |
---|
332 | } |
---|
333 | |
---|
334 | # internal proc to determine if the compiler supports -arch |
---|
335 | proc portconfigure::arch_flag_supported {args} { |
---|
336 | global configure.compiler |
---|
337 | switch -exact ${configure.compiler} { |
---|
338 | gcc-4.0 - |
---|
339 | gcc-4.2 - |
---|
340 | llvm-gcc-4.2 - |
---|
341 | clang - |
---|
342 | apple-gcc-4.0 - |
---|
343 | apple-gcc-4.2 - |
---|
344 | macports-clang { |
---|
345 | return yes |
---|
346 | } |
---|
347 | default { |
---|
348 | return no |
---|
349 | } |
---|
350 | } |
---|
351 | } |
---|
352 | |
---|
353 | # internal function to determine the default compiler |
---|
354 | proc portconfigure::configure_get_default_compiler {args} { |
---|
355 | global xcodeversion macosx_deployment_target |
---|
356 | if {$xcodeversion == "none" || $xcodeversion == ""} { |
---|
357 | return gcc |
---|
358 | } elseif {[rpm-vercomp $xcodeversion 4.0] >= 0} { |
---|
359 | return llvm-gcc-4.2 |
---|
360 | } elseif {[rpm-vercomp $xcodeversion 3.2] >= 0 && $macosx_deployment_target != "10.4"} { |
---|
361 | return gcc-4.2 |
---|
362 | } else { |
---|
363 | return gcc-4.0 |
---|
364 | } |
---|
365 | } |
---|
366 | |
---|
367 | # internal function to find correct compilers |
---|
368 | proc portconfigure::configure_get_compiler {type} { |
---|
369 | global configure.compiler prefix developer_dir |
---|
370 | set ret "" |
---|
371 | switch -exact ${configure.compiler} { |
---|
372 | gcc { |
---|
373 | switch -exact ${type} { |
---|
374 | cc { set ret /usr/bin/gcc } |
---|
375 | objc { set ret /usr/bin/gcc } |
---|
376 | cxx { set ret /usr/bin/g++ } |
---|
377 | cpp { set ret /usr/bin/cpp } |
---|
378 | } |
---|
379 | } |
---|
380 | gcc-3.3 { |
---|
381 | switch -exact ${type} { |
---|
382 | cc { set ret /usr/bin/gcc-3.3 } |
---|
383 | objc { set ret /usr/bin/gcc-3.3 } |
---|
384 | cxx { set ret /usr/bin/g++-3.3 } |
---|
385 | cpp { set ret /usr/bin/cpp-3.3 } |
---|
386 | } |
---|
387 | } |
---|
388 | gcc-4.0 { |
---|
389 | switch -exact ${type} { |
---|
390 | cc { set ret /usr/bin/gcc-4.0 } |
---|
391 | objc { set ret /usr/bin/gcc-4.0 } |
---|
392 | cxx { set ret /usr/bin/g++-4.0 } |
---|
393 | cpp { set ret /usr/bin/cpp-4.0 } |
---|
394 | } |
---|
395 | } |
---|
396 | gcc-4.2 { |
---|
397 | switch -exact ${type} { |
---|
398 | cc { set ret /usr/bin/gcc-4.2 } |
---|
399 | objc { set ret /usr/bin/gcc-4.2 } |
---|
400 | cxx { set ret /usr/bin/g++-4.2 } |
---|
401 | cpp { set ret /usr/bin/cpp-4.2 } |
---|
402 | } |
---|
403 | } |
---|
404 | llvm-gcc-4.2 { |
---|
405 | switch -exact ${type} { |
---|
406 | cc { set ret ${developer_dir}/usr/bin/llvm-gcc-4.2 } |
---|
407 | objc { set ret ${developer_dir}/usr/bin/llvm-gcc-4.2 } |
---|
408 | cxx { set ret ${developer_dir}/usr/bin/llvm-g++-4.2 } |
---|
409 | cpp { set ret ${developer_dir}/usr/bin/llvm-cpp-4.2 } |
---|
410 | } |
---|
411 | } |
---|
412 | clang { |
---|
413 | switch -exact ${type} { |
---|
414 | cc { set ret ${developer_dir}/usr/bin/clang } |
---|
415 | objc { set ret ${developer_dir}/usr/bin/clang } |
---|
416 | cxx { |
---|
417 | if {[file executable ${developer_dir}/usr/bin/clang++]} { |
---|
418 | set ret ${developer_dir}/usr/bin/clang++ |
---|
419 | } else { |
---|
420 | set ret ${developer_dir}/usr/bin/llvm-g++-4.2 |
---|
421 | } |
---|
422 | } |
---|
423 | } |
---|
424 | } |
---|
425 | apple-gcc-3.3 { |
---|
426 | switch -exact ${type} { |
---|
427 | cc { set ret ${prefix}/bin/gcc-apple-3.3 } |
---|
428 | cpp { set ret ${prefix}/bin/cpp-apple-3.3 } |
---|
429 | } |
---|
430 | } |
---|
431 | apple-gcc-4.0 { |
---|
432 | switch -exact ${type} { |
---|
433 | cc { set ret ${prefix}/bin/gcc-apple-4.0 } |
---|
434 | objc { set ret ${prefix}/bin/gcc-apple-4.0 } |
---|
435 | cpp { set ret ${prefix}/bin/cpp-apple-4.0 } |
---|
436 | } |
---|
437 | } |
---|
438 | apple-gcc-4.2 { |
---|
439 | switch -exact ${type} { |
---|
440 | cc { set ret ${prefix}/bin/gcc-apple-4.2 } |
---|
441 | objc { set ret ${prefix}/bin/gcc-apple-4.2 } |
---|
442 | cpp { set ret ${prefix}/bin/cpp-apple-4.2 } |
---|
443 | } |
---|
444 | } |
---|
445 | macports-gcc-4.0 { |
---|
446 | switch -exact ${type} { |
---|
447 | cc { set ret ${prefix}/bin/gcc-mp-4.0 } |
---|
448 | objc { set ret ${prefix}/bin/gcc-mp-4.0 } |
---|
449 | cxx { set ret ${prefix}/bin/g++-mp-4.0 } |
---|
450 | cpp { set ret ${prefix}/bin/cpp-mp-4.0 } |
---|
451 | fc { set ret ${prefix}/bin/gfortran-mp-4.0 } |
---|
452 | f77 { set ret ${prefix}/bin/gfortran-mp-4.0 } |
---|
453 | f90 { set ret ${prefix}/bin/gfortran-mp-4.0 } |
---|
454 | } |
---|
455 | } |
---|
456 | macports-gcc-4.1 { |
---|
457 | switch -exact ${type} { |
---|
458 | cc { set ret ${prefix}/bin/gcc-mp-4.1 } |
---|
459 | objc { set ret ${prefix}/bin/gcc-mp-4.1 } |
---|
460 | cxx { set ret ${prefix}/bin/g++-mp-4.1 } |
---|
461 | cpp { set ret ${prefix}/bin/cpp-mp-4.1 } |
---|
462 | fc { set ret ${prefix}/bin/gfortran-mp-4.1 } |
---|
463 | f77 { set ret ${prefix}/bin/gfortran-mp-4.1 } |
---|
464 | f90 { set ret ${prefix}/bin/gfortran-mp-4.1 } |
---|
465 | } |
---|
466 | } |
---|
467 | macports-gcc-4.2 { |
---|
468 | switch -exact ${type} { |
---|
469 | cc { set ret ${prefix}/bin/gcc-mp-4.2 } |
---|
470 | objc { set ret ${prefix}/bin/gcc-mp-4.2 } |
---|
471 | cxx { set ret ${prefix}/bin/g++-mp-4.2 } |
---|
472 | cpp { set ret ${prefix}/bin/cpp-mp-4.2 } |
---|
473 | fc { set ret ${prefix}/bin/gfortran-mp-4.2 } |
---|
474 | f77 { set ret ${prefix}/bin/gfortran-mp-4.2 } |
---|
475 | f90 { set ret ${prefix}/bin/gfortran-mp-4.2 } |
---|
476 | } |
---|
477 | } |
---|
478 | macports-gcc-4.3 { |
---|
479 | switch -exact ${type} { |
---|
480 | cc { set ret ${prefix}/bin/gcc-mp-4.3 } |
---|
481 | objc { set ret ${prefix}/bin/gcc-mp-4.3 } |
---|
482 | cxx { set ret ${prefix}/bin/g++-mp-4.3 } |
---|
483 | cpp { set ret ${prefix}/bin/cpp-mp-4.3 } |
---|
484 | fc { set ret ${prefix}/bin/gfortran-mp-4.3 } |
---|
485 | f77 { set ret ${prefix}/bin/gfortran-mp-4.3 } |
---|
486 | f90 { set ret ${prefix}/bin/gfortran-mp-4.3 } |
---|
487 | } |
---|
488 | } |
---|
489 | macports-gcc-4.4 { |
---|
490 | switch -exact ${type} { |
---|
491 | cc { set ret ${prefix}/bin/gcc-mp-4.4 } |
---|
492 | objc { set ret ${prefix}/bin/gcc-mp-4.4 } |
---|
493 | cxx { set ret ${prefix}/bin/g++-mp-4.4 } |
---|
494 | cpp { set ret ${prefix}/bin/cpp-mp-4.4 } |
---|
495 | fc { set ret ${prefix}/bin/gfortran-mp-4.4 } |
---|
496 | f77 { set ret ${prefix}/bin/gfortran-mp-4.4 } |
---|
497 | f90 { set ret ${prefix}/bin/gfortran-mp-4.4 } |
---|
498 | } |
---|
499 | } |
---|
500 | macports-gcc-4.5 { |
---|
501 | switch -exact ${type} { |
---|
502 | cc { set ret ${prefix}/bin/gcc-mp-4.5 } |
---|
503 | objc { set ret ${prefix}/bin/gcc-mp-4.5 } |
---|
504 | cxx { set ret ${prefix}/bin/g++-mp-4.5 } |
---|
505 | cpp { set ret ${prefix}/bin/cpp-mp-4.5 } |
---|
506 | fc { set ret ${prefix}/bin/gfortran-mp-4.5 } |
---|
507 | f77 { set ret ${prefix}/bin/gfortran-mp-4.5 } |
---|
508 | f90 { set ret ${prefix}/bin/gfortran-mp-4.5 } |
---|
509 | } |
---|
510 | } |
---|
511 | macports-gcc-4.6 { |
---|
512 | switch -exact ${type} { |
---|
513 | cc { set ret ${prefix}/bin/gcc-mp-4.6 } |
---|
514 | objc { set ret ${prefix}/bin/gcc-mp-4.6 } |
---|
515 | cxx { set ret ${prefix}/bin/g++-mp-4.6 } |
---|
516 | cpp { set ret ${prefix}/bin/cpp-mp-4.6 } |
---|
517 | fc { set ret ${prefix}/bin/gfortran-mp-4.6 } |
---|
518 | f77 { set ret ${prefix}/bin/gfortran-mp-4.6 } |
---|
519 | f90 { set ret ${prefix}/bin/gfortran-mp-4.6 } |
---|
520 | } |
---|
521 | } |
---|
522 | macports-llvm-gcc-4.2 { |
---|
523 | switch -exact ${type} { |
---|
524 | cc { set ret ${prefix}/bin/llvm-gcc-4.2 } |
---|
525 | objc { set ret ${prefix}/bin/llvm-gcc-4.2 } |
---|
526 | cxx { set ret ${prefix}/bin/llvm-g++-4.2 } |
---|
527 | cpp { set ret ${prefix}/bin/llvm-cpp-4.2 } |
---|
528 | fc { set ret ${prefix}/bin/llvm-gfortran-4.2 } |
---|
529 | f77 { set ret ${prefix}/bin/llvm-gfortran-4.2 } |
---|
530 | f90 { set ret ${prefix}/bin/llvm-gfortran-4.2 } |
---|
531 | } |
---|
532 | } |
---|
533 | macports-clang { |
---|
534 | switch -exact ${type} { |
---|
535 | cc { set ret ${prefix}/bin/clang } |
---|
536 | objc { set ret ${prefix}/bin/clang } |
---|
537 | cxx { set ret ${prefix}/bin/clang++ } |
---|
538 | } |
---|
539 | } |
---|
540 | } |
---|
541 | return $ret |
---|
542 | } |
---|
543 | |
---|
544 | proc portconfigure::configure_main {args} { |
---|
545 | global [info globals] |
---|
546 | global worksrcpath use_configure use_autoreconf use_autoconf use_automake use_xmkmf |
---|
547 | global configure.env configure.pipe configure.libs configure.classpath configure.universal_args |
---|
548 | global configure.perl configure.python configure.ruby configure.install configure.awk configure.bison configure.pkg_config configure.pkg_config_path |
---|
549 | global configure.ccache configure.distcc configure.cpp configure.javac configure.march configure.mtune configure.sdkroot |
---|
550 | foreach tool {cc cxx objc f77 f90 fc ld} { |
---|
551 | global configure.${tool} configure.${tool}_archflags |
---|
552 | } |
---|
553 | foreach flags {cflags cppflags cxxflags objcflags ldflags fflags f90flags fcflags} { |
---|
554 | global configure.${flags} configure.universal_${flags} |
---|
555 | } |
---|
556 | |
---|
557 | if {[tbool use_autoreconf]} { |
---|
558 | if {[catch {command_exec autoreconf} result]} { |
---|
559 | return -code error "[format [msgcat::mc "%s failure: %s"] autoreconf $result]" |
---|
560 | } |
---|
561 | } |
---|
562 | |
---|
563 | if {[tbool use_automake]} { |
---|
564 | if {[catch {command_exec automake} result]} { |
---|
565 | return -code error "[format [msgcat::mc "%s failure: %s"] automake $result]" |
---|
566 | } |
---|
567 | } |
---|
568 | |
---|
569 | if {[tbool use_autoconf]} { |
---|
570 | if {[catch {command_exec autoconf} result]} { |
---|
571 | return -code error "[format [msgcat::mc "%s failure: %s"] autoconf $result]" |
---|
572 | } |
---|
573 | } |
---|
574 | |
---|
575 | if {[tbool use_xmkmf]} { |
---|
576 | if {[catch {command_exec xmkmf} result]} { |
---|
577 | return -code error "[format [msgcat::mc "%s failure: %s"] xmkmf $result]" |
---|
578 | } else { |
---|
579 | # XXX should probably use make command abstraction but we know that |
---|
580 | # X11 will already set things up so that "make Makefiles" always works. |
---|
581 | system "cd ${worksrcpath} && make Makefiles" |
---|
582 | } |
---|
583 | } elseif {[tbool use_configure]} { |
---|
584 | # Merge (ld|c|cpp|cxx)flags into the environment variable. |
---|
585 | parse_environment configure |
---|
586 | |
---|
587 | # Set pre-compiler filter to use (ccache/distcc), if any. |
---|
588 | if {[tbool configure.ccache] && [tbool configure.distcc]} { |
---|
589 | set filter "ccache " |
---|
590 | append_list_to_environment_value configure "CCACHE_PREFIX" "distcc" |
---|
591 | } elseif {[tbool configure.ccache]} { |
---|
592 | set filter "ccache " |
---|
593 | } elseif {[tbool configure.distcc]} { |
---|
594 | set filter "distcc " |
---|
595 | } else { |
---|
596 | set filter "" |
---|
597 | } |
---|
598 | |
---|
599 | # Set flags controlling the kind of compiler output. |
---|
600 | if {[tbool configure.pipe]} { |
---|
601 | set output "-pipe " |
---|
602 | } else { |
---|
603 | set output "" |
---|
604 | } |
---|
605 | |
---|
606 | # Append configure flags. |
---|
607 | append_list_to_environment_value configure "CC" ${filter}${configure.cc} |
---|
608 | append_list_to_environment_value configure "CXX" ${filter}${configure.cxx} |
---|
609 | append_list_to_environment_value configure "OBJC" ${filter}${configure.objc} |
---|
610 | append_list_to_environment_value configure "FC" ${configure.fc} |
---|
611 | append_list_to_environment_value configure "F77" ${configure.f77} |
---|
612 | append_list_to_environment_value configure "F90" ${configure.f90} |
---|
613 | append_list_to_environment_value configure "JAVAC" ${configure.javac} |
---|
614 | append_list_to_environment_value configure "CFLAGS" ${output}${configure.cflags} |
---|
615 | append_list_to_environment_value configure "CPPFLAGS" ${configure.cppflags} |
---|
616 | append_list_to_environment_value configure "CXXFLAGS" ${output}${configure.cxxflags} |
---|
617 | append_list_to_environment_value configure "OBJCFLAGS" ${output}${configure.objcflags} |
---|
618 | append_list_to_environment_value configure "LDFLAGS" ${configure.ldflags} |
---|
619 | append_list_to_environment_value configure "LIBS" ${configure.libs} |
---|
620 | append_list_to_environment_value configure "FFLAGS" ${output}${configure.fflags} |
---|
621 | append_list_to_environment_value configure "F90FLAGS" ${output}${configure.f90flags} |
---|
622 | append_list_to_environment_value configure "FCFLAGS" ${output}${configure.fcflags} |
---|
623 | append_list_to_environment_value configure "CLASSPATH" ${configure.classpath} |
---|
624 | append_list_to_environment_value configure "PERL" ${configure.perl} |
---|
625 | append_list_to_environment_value configure "PYTHON" ${configure.python} |
---|
626 | append_list_to_environment_value configure "RUBY" ${configure.ruby} |
---|
627 | append_list_to_environment_value configure "INSTALL" ${configure.install} |
---|
628 | append_list_to_environment_value configure "AWK" ${configure.awk} |
---|
629 | append_list_to_environment_value configure "BISON" ${configure.bison} |
---|
630 | append_list_to_environment_value configure "PKG_CONFIG" ${configure.pkg_config} |
---|
631 | append_list_to_environment_value configure "PKG_CONFIG_PATH" ${configure.pkg_config_path} |
---|
632 | |
---|
633 | # add SDK flags if cross-compiling (or universal on ppc tiger) |
---|
634 | if {${configure.sdkroot} != ""} { |
---|
635 | foreach flags {CPPFLAGS CFLAGS CXXFLAGS OBJCFLAGS} { |
---|
636 | append_list_to_environment_value configure $flags "-isysroot ${configure.sdkroot}" |
---|
637 | } |
---|
638 | append_list_to_environment_value configure "LDFLAGS" "-Wl,-syslibroot,${configure.sdkroot}" |
---|
639 | } |
---|
640 | |
---|
641 | # add extra flags that are conditional on whether we're building universal |
---|
642 | if {[variant_exists universal] && [variant_isset universal]} { |
---|
643 | foreach flags {CFLAGS OBJCFLAGS} { |
---|
644 | append_list_to_environment_value configure $flags ${configure.universal_cflags} |
---|
645 | } |
---|
646 | append_list_to_environment_value configure "CXXFLAGS" ${configure.universal_cxxflags} |
---|
647 | append_list_to_environment_value configure "CPPFLAGS" ${configure.universal_cppflags} |
---|
648 | append_list_to_environment_value configure "LDFLAGS" ${configure.universal_ldflags} |
---|
649 | eval configure.pre_args-append ${configure.universal_args} |
---|
650 | } else { |
---|
651 | foreach {tool flags} {cc CFLAGS cxx CXXFLAGS objc OBJCFLAGS f77 FFLAGS f90 F90FLAGS fc FCFLAGS ld LDFLAGS} { |
---|
652 | append_list_to_environment_value configure $flags [set configure.${tool}_archflags] |
---|
653 | if {${configure.march} != {}} { |
---|
654 | append_list_to_environment_value configure $flags "-march=${configure.march}" |
---|
655 | } |
---|
656 | if {${configure.mtune} != {}} { |
---|
657 | append_list_to_environment_value configure $flags "-mtune=${configure.mtune}" |
---|
658 | } |
---|
659 | } |
---|
660 | } |
---|
661 | |
---|
662 | # Execute the command (with the new environment). |
---|
663 | if {[catch {command_exec configure} result]} { |
---|
664 | return -code error "[format [msgcat::mc "%s failure: %s"] configure $result]" |
---|
665 | } |
---|
666 | } |
---|
667 | return 0 |
---|
668 | } |
---|