source: branches/gsoc08-privileges/base/src/port1.0/portconfigure.tcl @ 38277

Last change on this file since 38277 was 38277, checked in by pmagrath@…, 9 years ago

Merged revisions 38163,38230,38232,38252,38255,38271 via svnmerge from
https://svn.macosforge.org/repository/macports/trunk/base

........

r38163 | jmr@… | 2008-07-10 02:50:57 +0100 (Thu, 10 Jul 2008) | 2 lines


In fetch, gracefully handle failure to spawn ping processes. (#15906)

........

r38230 | raimue@… | 2008-07-13 11:06:54 +0100 (Sun, 13 Jul 2008) | 3 lines


port/port.tcl:
Exit gracefully if an invalid global option was given

........

r38232 | jmr@… | 2008-07-13 11:25:29 +0100 (Sun, 13 Jul 2008) | 2 lines


Mirror sites: add new transact SourceForge mirror

........

r38252 | raimue@… | 2008-07-13 22:40:06 +0100 (Sun, 13 Jul 2008) | 3 lines


doc/port.1:
Document 'port edit --editor'

........

r38255 | raimue@… | 2008-07-13 23:38:40 +0100 (Sun, 13 Jul 2008) | 4 lines


port/port.tcl:
Convert list to string to allow additional parameters,
for example port edit --editor 'vim -y'

........

r38271 | mww@… | 2008-07-14 15:29:47 +0100 (Mon, 14 Jul 2008) | 3 lines


add 'llvm-gcc-4.2' compiler suite (from XCode 3.1);
make a wild guess at default compiler choice for 10.6;

........

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 20.1 KB
Line 
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 38277 2008-07-14 19:03:37Z pmagrath@macports.org $
4#
5# Copyright (c) 2002 - 2003 Apple Computer, Inc.
6# Copyright (c) 2007 Markus W. Weissmann <mww@macports.org>
7# All rights reserved.
8#
9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions
11# are met:
12# 1. Redistributions of source code must retain the above copyright
13#    notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright
15#    notice, this list of conditions and the following disclaimer in the
16#    documentation and/or other materials provided with the distribution.
17# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
18#    may be used to endorse or promote products derived from this software
19#    without specific prior written permission.
20#
21# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31# POSSIBILITY OF SUCH DAMAGE.
32#
33
34package provide portconfigure 1.0
35package require portutil 1.0
36
37set org.macports.configure [target_new org.macports.configure configure_main]
38target_provides ${org.macports.configure} configure
39target_requires ${org.macports.configure} main fetch extract checksum patch
40target_prerun ${org.macports.configure} configure_start
41
42# define options
43commands configure automake autoconf xmkmf libtool
44# defaults
45default configure.env       ""
46default configure.pre_args  {--prefix=${prefix}}
47default configure.cmd       ./configure
48default configure.dir       {${worksrcpath}}
49default autoconf.dir        {${worksrcpath}}
50default automake.dir        {${worksrcpath}}
51default xmkmf.cmd           xmkmf
52default xmkmf.dir           {${worksrcpath}}
53default use_configure       yes
54
55# Configure special environment variables.
56# We could have m32/m64/march/mtune be global configurable at some point.
57options configure.m32 configure.m64 configure.march configure.mtune
58default configure.march     {}
59default configure.mtune     {}
60# We could have debug/optimizations be global configurable at some point.
61options configure.optflags configure.cflags configure.cppflags configure.cxxflags configure.objcflags configure.ldflags configure.libs configure.fflags configure.f90flags configure.fcflags configure.classpath
62default configure.optflags  {-O2}
63# compiler flags section
64default configure.cflags    {[configure_get_cflags]}
65default configure.cppflags  {"-I${prefix}/include"}
66default configure.cxxflags  {[configure_get_cflags]}
67default configure.objcflags {[configure_get_cflags]}
68default configure.ldflags   {"-L${prefix}/lib"}
69default configure.libs      {}
70default configure.fflags    {[configure_get_cflags]}
71default configure.f90flags  {[configure_get_cflags]}
72default configure.fcflags   {[configure_get_cflags]}
73default configure.classpath {}
74
75# internal function to return the system value for CFLAGS/CXXFLAGS/etc
76proc configure_get_cflags {args} {
77    global configure.optflags
78    global configure.m32 configure.m64 configure.march configure.mtune
79    set flags "${configure.optflags}"
80    if {[tbool configure.m64]} {
81        set flags "-m64 ${flags}"
82    } elseif {[tbool configure.m32]} {
83        set flags "-m32 ${flags}"
84    }
85    if {[info exists configure.march] && ${configure.march} != {}} {
86        set flags "${flags} -march=${configure.march}"
87    }
88    if {[info exists configure.mtune] && ${configure.mtune} != {}} {
89        set flags "${flags} -mtune=${configure.mtune}"
90    }
91    return $flags
92}
93
94# tools section
95options configure.perl configure.python configure.ruby configure.install configure.awk configure.bison configure.pkg_config configure.pkg_config_path
96default configure.perl              {}
97default configure.python            {}
98default configure.ruby              {}
99default configure.install           {${portutil::autoconf::install_command}}
100default configure.awk               {}
101default configure.bison             {}
102default configure.pkg_config        {}
103default configure.pkg_config_path   {}
104
105# backwards compatibility for hardcoded ports
106if {[file exists /Developer/SDKs/MacOSX10.5.sdk]} {
107    set sysroot "/Developer/SDKs/MacOSX10.5.sdk"
108} else {
109    set sysroot "/Developer/SDKs/MacOSX10.4u.sdk"
110}
111
112options configure.universal_target configure.universal_sysroot configure.universal_archs configure.universal_args configure.universal_cflags configure.universal_cppflags configure.universal_cxxflags configure.universal_ldflags
113default configure.universal_target      {${universal_target}}
114default configure.universal_sysroot     {${universal_sysroot}}
115default configure.universal_archs       {${universal_archs}}
116default configure.universal_args        {[configure_get_universal_args]}
117default configure.universal_cflags      {[configure_get_universal_cflags]}
118default configure.universal_cppflags    {[configure_get_universal_cppflags]}
119default configure.universal_cxxflags    {[configure_get_universal_cflags]}
120default configure.universal_ldflags     {[configure_get_universal_ldflags]}
121
122# Select a distinct compiler (C, C preprocessor, C++)
123options configure.ccache configure.distcc configure.pipe configure.cc configure.cxx configure.cpp configure.objc configure.f77 configure.f90 configure.fc configure.javac configure.compiler
124default configure.ccache        {${configureccache}}
125default configure.distcc        {${configuredistcc}}
126default configure.pipe          {${configurepipe}}
127default configure.cc            {}
128default configure.cxx           {}
129default configure.cpp           {}
130default configure.objc          {}
131default configure.f77           {}
132default configure.f90           {}
133default configure.fc            {}
134default configure.javac         {}
135default configure.compiler      {}
136
137set_ui_prefix
138
139proc configure_start {args} {
140    global UI_PREFIX
141   
142    ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option portname]]"
143}
144
145# internal function to determine canonical system name for configure
146proc configure_get_universal_system_name {args} {
147    global configure.universal_target configure.universal_archs
148    set arch "unknown"
149    switch -- ${configure.universal_archs} {
150        "ppc"  { set arch "powerpc" }
151        "i386"  { set arch "i686" }
152        "ppc64"  { set arch "powerpc" }
153        "x86_64"  { set arch "i686" }
154    }
155    switch -- ${configure.universal_target} {
156        "10.1"  { return "powerpc-apple-darwin5" }
157                # /Developer/SDKs/MacOSX10.1.5.sdk
158        "10.2"  { return "powerpc-apple-darwin6" }
159                # /Developer/SDKs/MacOSX10.2.8.sdk
160        "10.3"  { return "powerpc-apple-darwin7" }
161                # /Developer/SDKs/MacOSX10.3.9.sdk
162        "10.4"  { return "${arch}-apple-darwin8" }
163        "10.5"  { return "${arch}-apple-darwin9" }
164    }
165    return ""
166}
167
168# internal function to determine the universal args for configure.cmd
169proc configure_get_universal_args {args} {
170    global configure.universal_archs
171    set system [configure_get_universal_system_name]
172    set params "--disable-dependency-tracking"
173    if {[llength ${configure.universal_archs}] == 1 &&
174        [info exists system] && $system != ""} {
175        set params "$params --host=${system} --target=${system}"
176    }
177    return $params
178}
179
180# internal function to determine the "-arch xy" flags for the compiler
181proc configure_get_universal_archflags {args} {
182    global configure.universal_archs
183    set flags ""
184    foreach arch ${configure.universal_archs} {
185        set flags "$flags -arch $arch"
186    }
187    return $flags
188}
189
190# internal function to determine the CPPFLAGS for the compiler
191proc configure_get_universal_cppflags {args} {
192    global configure.universal_sysroot
193    set flags ""
194    # include sysroot in CPPFLAGS too (twice), for the benefit of autoconf
195    if {[info exists configure.universal_sysroot]} {
196        set flags "-isysroot ${configure.universal_sysroot}"
197    }
198    return $flags
199}
200
201# internal function to determine the CFLAGS for the compiler
202proc configure_get_universal_cflags {args} {
203    global configure.universal_sysroot configure.universal_target
204    global os.platform os.arch os.version os.major
205    set flags [configure_get_universal_archflags]
206    # these flags should be valid for C/C++ and similar compiler frontends
207    if {[info exists configure.universal_sysroot]} {
208        set flags "-isysroot ${configure.universal_sysroot} ${flags}"
209    }
210    # normally set in MACOSX_DEPLOYMENT_TARGET, add here too to make sure
211    if {${os.major} == "9"} {
212        set flags "${flags} -mmacosx-version-min=${configure.universal_target}"
213    }
214    return $flags
215}
216
217# internal function to determine the LDFLAGS for the compiler
218proc configure_get_universal_ldflags {args} {
219    global configure.universal_sysroot configure.universal_target
220    global os.platform os.arch os.version os.major
221    set flags [configure_get_universal_archflags]
222    # works around linking without using the CFLAGS, outside of automake
223    if {${os.arch} == "powerpc"} {
224        set flags "-Wl,-syslibroot,${configure.universal_sysroot} ${flags}"
225    }
226    # normally set in MACOSX_DEPLOYMENT_TARGET, add here too to make sure
227    if {${os.major} == "9"} {
228        set flags "${flags} -mmacosx-version-min=${configure.universal_target}"
229    }
230    return $flags
231}
232
233
234
235# internal function for setting compiler variables; use like "_set_compiler string var val var val .."
236# this function will NOT override explicitely set variables from the portfile
237proc select_compiler {info args} {
238    global configure.cc configure.cxx configure.cpp configure.objc configure.f77 configure.f90 configure.fc
239    ui_debug "Using compiler '$info'"
240    set i 0
241    foreach value $args {
242        if {0==$i} {
243            set comp $value
244            set i 1
245        } else {
246            switch -exact $comp {
247                cc  { if {""==${configure.cc}}  { set configure.cc $value } }
248                cxx { if {""==${configure.cxx}} { set configure.cxx $value } }
249                cpp { if {""==${configure.cpp}} { set configure.cpp $value } }
250                objc { if {""==${configure.objc}} { set configure.objc $value } }
251                fc  { if {""==${configure.fc}}  { set configure.fc $value } }
252                f77 { if {""==${configure.f77}} { set configure.f77 $value } }
253                f90 { if {""==${configure.f90}} { set configure.f90 $value } }
254            }
255            set i 0
256        }
257    }
258}
259
260proc configure_main {args} {
261    global [info globals]
262    global worksrcpath use_configure use_autoconf use_automake use_xmkmf
263    global configure.env configure.pipe configure.cflags configure.cppflags configure.cxxflags configure.objcflags configure.ldflags configure.libs configure.fflags configure.f90flags configure.fcflags configure.classpath
264    global configure.perl configure.python configure.ruby configure.install configure.awk configure.bison configure.pkg_config configure.pkg_config_path
265    global configure.ccache configure.distcc configure.cc configure.cxx configure.cpp configure.objc configure.f77 configure.f90 configure.fc configure.javac configure.compiler prefix
266    global os.platform os.major
267   
268    if {[tbool use_automake]} {
269        # XXX depend on automake
270        if {[catch {command_exec automake} result]} {
271            return -code error "[format [msgcat::mc "%s failure: %s"] automake $result]"
272        }
273    }
274   
275    if {[tbool use_autoconf]} {
276        # XXX depend on autoconf
277        if {[catch {command_exec autoconf} result]} {
278            return -code error "[format [msgcat::mc "%s failure: %s"] autoconf $result]"
279        }
280    }
281
282    # 1st chose a reasonable default compiler suite for each platform if none was chosen
283    if {""==${configure.compiler}} {
284        switch -exact "${os.platform} ${os.major}" {
285            "darwin 7" { set configure.compiler gcc-3.3 }
286            "darwin 8" { set configure.compiler gcc-4.0 }
287            "darwin 9" { set configure.compiler gcc-4.0 }
288            "darwin 10" { set configure.compiler llvm-gcc-4.2 }
289        }
290    }
291
292    # select a compiler collection
293    switch -exact ${configure.compiler} {
294        gcc-3.3 {
295            select_compiler "Mac OS X gcc 3.3" \
296                cc  /usr/bin/gcc-3.3 \
297                objc /usr/bin/gcc-3.3 \
298                cxx /usr/bin/g++-3.3 \
299                cpp /usr/bin/cpp-3.3 }
300        gcc-4.0 {
301            select_compiler "Mac OS X gcc 4.0" \
302                cc  /usr/bin/gcc-4.0 \
303                objc /usr/bin/gcc-4.0 \
304                cxx /usr/bin/g++-4.0 \
305                cpp /usr/bin/cpp-4.0 }
306        gcc-4.2 {
307            select_compiler "Mac OS X gcc 4.2" \
308                cc  /usr/bin/gcc-4.2 \
309                objc /usr/bin/gcc-4.2 \
310                cxx /usr/bin/g++-4.2 \
311                cpp /usr/bin/cpp-4.2 }
312        llvm-gcc-4.2 {
313            select_compiler "Mac OS X llvm-gcc 4.2" \
314                cc  /Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 \
315                objc /Developer/usr/llvm-gcc-4.2/bin/llvm-gcc-4.2 \
316                cxx /Developer/usr/llvm-gcc-4.2/bin/llvm-g++-4.2 \
317                cpp /Developer/usr/llvm-gcc-4.2/bin/llvm-cpp-4.2 }
318        apple-gcc-3.3 {
319            select_compiler "MacPorts Apple gcc 3.3" \
320                cc  ${prefix}/bin/gcc-apple-3.3 \
321                cpp ${prefix}/bin/cpp-apple-3.3 }
322        apple-gcc-4.0 {
323            select_compiler "MacPorts Apple gcc 4.0" \
324                cc  ${prefix}/bin/gcc-apple-4.0 \
325                objc ${prefix}/bin/gcc-apple-4.0 \
326                cpp ${prefix}/bin/cpp-apple-4.0 }
327        macports-gcc-3.3 {
328            select_compiler "MacPorts gcc 3.3" \
329                cc  ${prefix}/bin/gcc-mp-3.3 \
330                cxx ${prefix}/bin/g++-mp-3.3 \
331                cpp ${prefix}/bin/cpp-mp-3.3 }
332        macports-gcc-3.4 {
333            select_compiler "MacPorts gcc 3.4" \
334                cc  ${prefix}/bin/gcc-mp-3.4 \
335                cxx ${prefix}/bin/g++-mp-3.4 \
336                cpp ${prefix}/bin/cpp-mp-3.4 }
337        macports-gcc-4.0 {
338            select_compiler "MacPorts gcc 4.0" \
339                cc  ${prefix}/bin/gcc-mp-4.0 \
340                objc ${prefix}/bin/gcc-mp-4.0 \
341                cxx ${prefix}/bin/g++-mp-4.0 \
342                cpp ${prefix}/bin/cpp-mp-4.0 \
343                fc  ${prefix}/bin/gfortran-mp-4.0 \
344                f77 ${prefix}/bin/gfortran-mp-4.0 \
345                f90 ${prefix}/bin/gfortran-mp-4.0 }
346        macports-gcc-4.1 {
347            select_compiler "MacPorts gcc 4.1" \
348                cc  ${prefix}/bin/gcc-mp-4.1 \
349                objc ${prefix}/bin/gcc-mp-4.1 \
350                cxx ${prefix}/bin/g++-mp-4.1 \
351                cpp ${prefix}/bin/cpp-mp-4.1 \
352                fc  ${prefix}/bin/gfortran-mp-4.1 \
353                f77 ${prefix}/bin/gfortran-mp-4.1 \
354                f90 ${prefix}/bin/gfortran-mp-4.1 }
355        macports-gcc-4.2 {
356            select_compiler "MacPorts gcc 4.2" \
357                cc  ${prefix}/bin/gcc-mp-4.2 \
358                objc ${prefix}/bin/gcc-mp-4.2 \
359                cxx ${prefix}/bin/g++-mp-4.2 \
360                cpp ${prefix}/bin/cpp-mp-4.2 \
361                fc  ${prefix}/bin/gfortran-mp-4.2 \
362                f77 ${prefix}/bin/gfortran-mp-4.2 \
363                f90 ${prefix}/bin/gfortran-mp-4.2 }
364        macports-gcc-4.3 {
365            select_compiler "MacPorts gcc 4.3" \
366                cc  ${prefix}/bin/gcc-mp-4.3 \
367                objc ${prefix}/bin/gcc-mp-4.3 \
368                cxx ${prefix}/bin/g++-mp-4.3 \
369                cpp ${prefix}/bin/cpp-mp-4.3 \
370                fc  ${prefix}/bin/gfortran-mp-4.3 \
371                f77 ${prefix}/bin/gfortran-mp-4.3 \
372                f90 ${prefix}/bin/gfortran-mp-4.3 }
373        macports-gcc-4.4 {
374            select_compiler "MacPorts gcc 4.4" \
375                cc  ${prefix}/bin/gcc-mp-4.4 \
376                objc ${prefix}/bin/gcc-mp-4.4 \
377                cxx ${prefix}/bin/g++-mp-4.4 \
378                cpp ${prefix}/bin/cpp-mp-4.4 \
379                fc  ${prefix}/bin/gfortran-mp-4.4 \
380                f77 ${prefix}/bin/gfortran-mp-4.4 \
381                f90 ${prefix}/bin/gfortran-mp-4.4 }
382        default {
383            ui_debug "No compiler collection selected explicitly" }
384    }
385   
386    if {[tbool use_xmkmf]} {
387        # XXX depend on xmkmf
388        if {[catch {command_exec xmkmf} result]} {
389            return -code error "[format [msgcat::mc "%s failure: %s"] xmkmf $result]"
390        } else {
391            # XXX should probably use make command abstraction but we know that
392            # X11 will already set things up so that "make Makefiles" always works.
393            system "cd ${worksrcpath} && make Makefiles"
394        }
395    } elseif {[tbool use_configure]} {
396        # Merge (ld|c|cpp|cxx)flags into the environment variable.
397        parse_environment configure
398
399        # Set pre-compiler filter to use (ccache/distcc), if any.
400        if {[tbool configure.ccache] && [tbool configure.distcc]} {
401            set filter "ccache "
402            append_list_to_environment_value configure "CCACHE_PREFIX" "distcc"
403        } elseif {[tbool configure.ccache]} {
404            set filter "ccache "
405        } elseif {[tbool configure.distcc]} {
406            set filter "distcc "
407        } else {
408            set filter ""
409        }
410       
411        # Set flags controlling the kind of compiler output.
412        if {[tbool configure.pipe]} {
413            set output "-pipe "
414        } else {
415            set output ""
416        }
417
418        # Append configure flags.
419        append_list_to_environment_value configure "CC" ${filter}${configure.cc}
420        append_list_to_environment_value configure "CPP" ${filter}${configure.cpp}
421        append_list_to_environment_value configure "CXX" ${filter}${configure.cxx}
422        append_list_to_environment_value configure "OBJC" ${filter}${configure.objc}
423        append_list_to_environment_value configure "FC" ${configure.fc}
424        append_list_to_environment_value configure "F77" ${configure.f77}
425        append_list_to_environment_value configure "F90" ${configure.f90}
426        append_list_to_environment_value configure "JAVAC" ${configure.javac}
427        append_list_to_environment_value configure "CFLAGS" ${output}${configure.cflags}
428        append_list_to_environment_value configure "CPPFLAGS" ${configure.cppflags}
429        append_list_to_environment_value configure "CXXFLAGS" ${output}${configure.cxxflags}
430        append_list_to_environment_value configure "OBJCFLAGS" ${output}${configure.objcflags}
431        append_list_to_environment_value configure "LDFLAGS" ${configure.ldflags}
432        append_list_to_environment_value configure "LIBS" ${configure.libs}
433        append_list_to_environment_value configure "FFLAGS" ${output}${configure.fflags}
434        append_list_to_environment_value configure "F90FLAGS" ${output}${configure.f90flags}
435        append_list_to_environment_value configure "FCFLAGS" ${output}${configure.fcflags}
436        append_list_to_environment_value configure "CLASSPATH" ${configure.classpath}
437        append_list_to_environment_value configure "PERL" ${configure.perl}
438        append_list_to_environment_value configure "PYTHON" ${configure.python}
439        append_list_to_environment_value configure "RUBY" ${configure.ruby}
440        append_list_to_environment_value configure "INSTALL" ${configure.install}
441        append_list_to_environment_value configure "AWK" ${configure.awk}
442        append_list_to_environment_value configure "BISON" ${configure.bison}
443        append_list_to_environment_value configure "PKG_CONFIG" ${configure.pkg_config}
444        append_list_to_environment_value configure "PKG_CONFIG_PATH" ${configure.pkg_config_path}
445
446        # Execute the command (with the new environment).
447        if {[catch {command_exec configure} result]} {
448            return -code error "[format [msgcat::mc "%s failure: %s"] configure $result]"
449        }
450    }
451    return 0
452}
Note: See TracBrowser for help on using the repository browser.