[PATCH] Let the default compiler be configurable

Jeremy Huddleston jeremyhu at macports.org
Thu Jun 9 14:07:26 PDT 2011


I assumed that this was already possible and was amazed that it wasn't... with this patch, one can set "compiler" in $prefix/etc/macports.conf to choose a default compiler.

Thoughts?


Index: src/port1.0/portconfigure.tcl
===================================================================
--- src/port1.0/portconfigure.tcl	(revision 76925)
+++ src/port1.0/portconfigure.tcl	(working copy)
@@ -182,7 +182,7 @@
 default configure.f90           {[portconfigure::configure_get_compiler f90]}
 default configure.fc            {[portconfigure::configure_get_compiler fc]}
 default configure.javac         {[portconfigure::configure_get_compiler javac]}
-default configure.compiler      {[portconfigure::configure_get_default_compiler]}
+default configure.compiler      {${compiler}}
 
 set_ui_prefix
 
@@ -349,18 +349,6 @@
     }
 }
 
-# internal function to determine the default compiler
-proc portconfigure::configure_get_default_compiler {args} {
-    global macosx_deployment_target
-    switch -exact ${macosx_deployment_target} {
-        "10.4"      -
-        "10.5"      { return gcc-4.0 }
-        "10.6"      { return gcc-4.2 }
-        "10.7"      { return llvm-gcc-4.2 }
-        default     { return gcc }
-    }
-}
-
 # internal function to find correct compilers
 proc portconfigure::configure_get_compiler {type} {
     global configure.compiler prefix developer_dir
Index: src/macports1.0/macports.tcl
===================================================================
--- src/macports1.0/macports.tcl	(revision 76925)
+++ src/macports1.0/macports.tcl	(working copy)
@@ -44,7 +44,7 @@
         portinstalltype portarchivemode portarchivepath portarchivetype portautoclean \
         porttrace portverbose keeplogs destroot_umask variants_conf rsync_server rsync_options \
         rsync_dir startupitem_type place_worksymlink xcodeversion xcodebuildcmd \
-        mp_remote_url mp_remote_submit_url configureccache ccache_dir ccache_size configuredistcc configurepipe buildnicevalue buildmakejobs \
+        mp_remote_url mp_remote_submit_url configureccache ccache_dir ccache_size compiler configuredistcc configurepipe buildnicevalue buildmakejobs \
         applications_dir frameworks_dir developer_dir universal_archs build_arch macosx_deployment_target \
         macportsuser proxy_override_env proxy_http proxy_https proxy_ftp proxy_rsync proxy_skip \
         master_site_local patch_site_local archive_site_local"
@@ -54,7 +54,7 @@
         registry.path registry.format registry.installtype portarchivemode portarchivepath \
         portarchivetype archivefetch_pubkeys portautoclean porttrace keeplogs portverbose destroot_umask \
         rsync_server rsync_options rsync_dir startupitem_type place_worksymlink macportsuser \
-        mp_remote_url mp_remote_submit_url configureccache ccache_dir ccache_size configuredistcc configurepipe buildnicevalue buildmakejobs \
+        mp_remote_url mp_remote_submit_url configureccache ccache_dir ccache_size compiler configuredistcc configurepipe buildnicevalue buildmakejobs \
         applications_dir current_phase frameworks_dir developer_dir universal_archs build_arch \
         os_arch os_endian os_version os_major os_platform macosx_version macosx_deployment_target $user_options"
 
@@ -460,6 +460,7 @@
     global macports::configureccache
     global macports::ccache_dir
     global macports::ccache_size
+    global macports::compiler
     global macports::configuredistcc
     global macports::configurepipe
     global macports::buildnicevalue
@@ -792,6 +793,14 @@
     if {![info exists macports::ccache_size]} {
         set macports::ccache_size "2G"
     }
+    if {![info exists macports::compiler]} {
+        switch -glob -- $::macports::macosx_version {
+            10.[45]     { set macports::compiler "gcc-4.0" }
+            10.6        { set macports::compiler "gcc-4.2" }
+            10.7        { set macports::compiler "llvm-gcc-4.2" }
+            default     { set macports::compiler "gcc" }
+        }
+    }
     if {![info exists macports::configuredistcc]} {
         set macports::configuredistcc no
     }



More information about the macports-dev mailing list