[53217] trunk/base
jmr at macports.org
jmr at macports.org
Wed Jul 1 01:47:27 PDT 2009
Revision: 53217
http://trac.macports.org/changeset/53217
Author: jmr at macports.org
Date: 2009-07-01 01:47:26 -0700 (Wed, 01 Jul 2009)
Log Message:
-----------
add build_arch config option for choosing target CPU arch
Modified Paths:
--------------
trunk/base/doc/macports.conf.in
trunk/base/src/macports1.0/macports.tcl
trunk/base/src/port1.0/portconfigure.tcl
Modified: trunk/base/doc/macports.conf.in
===================================================================
--- trunk/base/doc/macports.conf.in 2009-07-01 08:36:18 UTC (rev 53216)
+++ trunk/base/doc/macports.conf.in 2009-07-01 08:47:26 UTC (rev 53217)
@@ -53,6 +53,11 @@
# Supported types: tgz (default), tar, tbz, tbz2, tlz, txz, xar, zip, cpgz, cpio
portarchivetype tgz
+# CPU architecture to compile for. Defaults to i386 or ppc on Mac OS X 10.5
+# and earlier, depending on the CPU type detected at runtime. On Mac OS X 10.6
+# the default is x86_64 if the CPU supports it, i386 otherwise.
+#build_arch i386
+
# Use ccache (C/C++ compiler cache) - see http://ccache.samba.org/
configureccache no
Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl 2009-07-01 08:36:18 UTC (rev 53216)
+++ trunk/base/src/macports1.0/macports.tcl 2009-07-01 08:47:26 UTC (rev 53217)
@@ -45,7 +45,7 @@
porttrace portverbose destroot_umask variants_conf rsync_server rsync_options \
rsync_dir startupitem_type place_worksymlink xcodeversion xcodebuildcmd \
mp_remote_url mp_remote_submit_url configureccache configuredistcc configurepipe buildnicevalue buildmakejobs \
- applications_dir frameworks_dir developer_dir universal_archs \
+ applications_dir frameworks_dir developer_dir universal_archs build_arch \
macportsuser proxy_override_env proxy_http proxy_https proxy_ftp proxy_rsync proxy_skip"
variable user_options "submitter_name submitter_email submitter_key"
variable portinterp_options "\
@@ -54,7 +54,7 @@
portarchivetype portautoclean porttrace portverbose destroot_umask rsync_server \
rsync_options rsync_dir startupitem_type place_worksymlink \
mp_remote_url mp_remote_submit_url configureccache configuredistcc configurepipe buildnicevalue buildmakejobs \
- applications_dir frameworks_dir developer_dir universal_archs $user_options"
+ applications_dir frameworks_dir developer_dir universal_archs build_arch $user_options"
# deferred options are only computed when needed.
# they are not exported to the trace thread.
@@ -351,6 +351,7 @@
global macports::buildnicevalue
global macports::buildmakejobs
global macports::universal_archs
+ global macports::build_arch
# Set the system encoding to utf-8
encoding system utf-8
@@ -656,6 +657,23 @@
set macports::universal_archs {i386 ppc}
}
}
+
+ # Default arch to build for
+ if {![info exists macports::build_arch] && $tcl_platform(os) == "Darwin"} {
+ if {[lindex [split $tcl_platform(osVersion) .] 0] >= 10} {
+ if {[sysctl hw.cpu64bit_capable] == 1} {
+ set macports::build_arch x86_64
+ } else {
+ set macports::build_arch i386
+ }
+ } else {
+ if {$tcl_platform(machine) == "Power Macintosh"} {
+ set macports::build_arch ppc
+ } else {
+ set macports::build_arch i386
+ }
+ }
+ }
# ENV cleanup.
set keepenvkeys {
Modified: trunk/base/src/port1.0/portconfigure.tcl
===================================================================
--- trunk/base/src/port1.0/portconfigure.tcl 2009-07-01 08:36:18 UTC (rev 53216)
+++ trunk/base/src/port1.0/portconfigure.tcl 2009-07-01 08:47:26 UTC (rev 53217)
@@ -100,24 +100,28 @@
# internal function to return the system value for CFLAGS/CXXFLAGS/etc
proc portconfigure::configure_get_cflags {args} {
- global configure.optflags
- global configure.m32 configure.m64 configure.march configure.mtune
+ global configure.optflags configure.archflags
+ global configure.march configure.mtune
global configure.universal_cflags
+
set flags "${configure.optflags}"
- if {[tbool configure.m64]} {
- set flags "-m64 ${flags}"
- } elseif {[tbool configure.m32]} {
- set flags "-m32 ${flags}"
+ if {[variant_isset universal]} {
+ if {${configure.universal_cflags} != ""} {
+ append flags " ${configure.universal_cflags}"
+ }
+ # stop here since the rest doesn't make much sense for universal
+ return $flags
}
+
+ if {${configure.archflags} != ""} {
+ append flags " ${configure.archflags}"
+ }
if {[info exists configure.march] && ${configure.march} != {}} {
append flags " -march=${configure.march}"
}
if {[info exists configure.mtune] && ${configure.mtune} != {}} {
append flags " -mtune=${configure.mtune}"
}
- if {[variant_isset universal] && ${configure.universal_cflags} != ""} {
- append flags " ${configure.universal_cflags}"
- }
return $flags
}
@@ -131,10 +135,12 @@
}
proc portconfigure::configure_get_ldflags {args} {
- global prefix configure.universal_ldflags
+ global prefix configure.universal_ldflags configure.archflags
set flags "-L${prefix}/lib"
if {[variant_isset universal] && ${configure.universal_ldflags} != ""} {
append flags " ${configure.universal_ldflags}"
+ } elseif {${configure.archflags} != ""} {
+ append flags " ${configure.archflags}"
}
return $flags
}
@@ -150,6 +156,10 @@
default configure.pkg_config {}
default configure.pkg_config_path {}
+options configure.build_arch configure.archflags
+default configure.build_arch {${build_arch}}
+default configure.archflags {[portconfigure::configure_get_archflags]}
+
options configure.universal_archs configure.universal_args configure.universal_cflags configure.universal_cppflags configure.universal_cxxflags configure.universal_ldflags
default configure.universal_archs {${universal_archs}}
default configure.universal_args {--disable-dependency-tracking}
@@ -213,6 +223,26 @@
return $result
}
+# internal function to determine the compiler flags to select an arch
+proc portconfigure::configure_get_archflags {args} {
+ global configure.build_arch configure.m32 configure.m64
+ set flags ""
+ if {[tbool configure.m64]} {
+ set flags "-m64"
+ } elseif {[tbool configure.m32]} {
+ set flags "-m32"
+ } elseif {${configure.build_arch} != ""} {
+ if {[arch_flag_supported]} {
+ set flags "-arch ${configure.build_arch}"
+ } elseif {${configure.build_arch} == "x86_64" || ${configure.build_arch} == "ppc64"} {
+ set flags "-m64"
+ } else {
+ set flags "-m32"
+ }
+ }
+ return $flags
+}
+
# internal function to determine the "-arch xy" flags for the compiler
proc portconfigure::configure_get_universal_archflags {args} {
global configure.universal_archs
@@ -260,6 +290,24 @@
return $flags
}
+# internal proc to determine if the compiler supports -arch
+proc portconfigure::arch_flag_supported {args} {
+ global configure.compiler
+ switch -exact ${configure.compiler} {
+ gcc-4.0 -
+ gcc-4.2 -
+ llvm-gcc-4.2 -
+ clang -
+ apple-gcc-4.0 -
+ apple-gcc-4.2 {
+ return yes
+ }
+ default {
+ return no
+ }
+ }
+}
+
# internal function to determine the default compiler
proc portconfigure::configure_get_default_compiler {args} {
global os.platform os.major
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090701/e781f977/attachment.html>
More information about the macports-changes
mailing list