--- dports/math/atlas/Portfile	2009-06-29 15:07:27.000000000 +0200
+++ dports.local/math/atlas/Portfile	2009-06-29 20:02:41.000000000 +0200
@@ -37,7 +37,6 @@
                     sha1    c75223fdef3258c461370af5d2b889d580d7f38a \
                     rmd160  e8fabba2fdd944afbc02a83599cf45a0d721030d
 
-
 # the following patch corrects extension conventions for osx's dynamic libs
 set make_patch      patch-build-Make.top.diff
 use_parallel_build  no
@@ -46,35 +45,58 @@
 
 destroot.dir        ${build.dir}
 destroot.destdir    DESTDIR=${destroot}${prefix}
-depends_lib         port:gcc43 \
-                    port:bzip2 \
+depends_lib         port:bzip2 \
                     port:gzip
 
-# Set fortran compiler flags
-set myf77           ${prefix}/bin/gfortran-mp-4.3
+variant gcc42 conflicts gcc43 gcc44 description "Use gcc-4.2 as compiler" {
+	  depends_lib-append    port:gcc42
+      configure.compiler 	macports-gcc-4.2
+}
 
-configure.args      -C xc ${prefix}/bin/gcc-mp-4.3 \
-                    -C gc ${prefix}/bin/gcc-mp-4.3 \
-                    -C if ${myf77} \
-                    -C ic ${prefix}/bin/gcc-mp-4.3 \
-                    -C dm ${prefix}/bin/gcc-mp-4.3 \
-                    -C sm ${prefix}/bin/gcc-mp-4.3 \
-                    -C dk ${prefix}/bin/gcc-mp-4.3 \
-                    -C sk ${prefix}/bin/gcc-mp-4.3 \
-                    --cc=${prefix}/bin/gcc-mp-4.3 \
-                    -b 32 \
-                    -Fa alg -fPIC 
-                    
-configure.compiler macports-gcc-4.3
+variant gcc43 conflicts gcc42 gcc44 description "Use gcc-4.3 as compiler" {
+	  depends_lib-append    port:gcc43
+      configure.compiler macports-gcc-4.3
+}
 
-        
+variant gcc44 conflicts gcc42 gcc43 description "Use gcc4.4 as compiler" {
+	  depends_lib-append    port:gcc44
+      configure.compiler macports-gcc-4.4
+}
 
+if { ![variant_isset gcc42] && ![variant_isset gcc43] && ![variant_isset gcc44] } {
+	  default_variants      +gcc43
+}
+
+if {[variant_isset gcc42]} {
+	set myf77 		${prefix}/bin/gfortran-mp-4.2
+	set mygcc 		${prefix}/bin/gcc-mp-4.2
+	set gcc_libdir 	gcc42
+} elseif {[variant_isset gcc43]} {
+	set myf77 		${prefix}/bin/gfortran-mp-4.3
+	set mygcc 		${prefix}/bin/gcc-mp-4.3
+	set gcc_libdir 	gcc43
+} elseif {[variant_isset gcc44]} {
+	set myf77 		${prefix}/bin/gfortran-mp-4.4
+	set mygcc 		${prefix}/bin/gcc-mp-4.4
+	set gcc_libdir 	gcc44
+} 
+ 
+configure.args      -C xc ${mygcc} \
+                    -C gc ${mygcc} \
+					-C if ${myf77} \
+					-C ic ${mygcc} \
+                    -C dm ${mygcc} \
+                    -C sm ${mygcc} \
+                    -C dk ${mygcc} \
+                    -C sk ${mygcc} \
+                    --cc=${mygcc} \
+                    -b 32 \
+                    -Fa alg -fPIC         
+      
 # we are configuring from the build directory
 configure.dir       ${workpath}/${name}-${version}/build
 configure.cmd       ../configure
 
-# change the default compilers to those of gcc43 and make into shared library
-
 extract {
     # extract atlas and move to a consistent working directory name
     system "cd ${workpath} && bunzip2 -dc ${distpath}/${atlasdist} | \
@@ -86,8 +108,6 @@
          gnutar --no-same-owner -xf -"
 }
 
-
-
 pre-configure {
     # Get some system specific variables for maximum optimization
     set cpufreq [expr {[exec sysctl -n hw.cpufrequency]/1000000}]
@@ -160,7 +180,7 @@
     }
   
   set ld "ld -arch ${myarch} -dynamic -dylib -single_module -dead_strip -x \
-          -all_load -L. -L${prefix}/lib/gcc43 -ldylib1.o -dylib_install_name"
+          -all_load -L. -L${prefix}/lib/${gcc_libdir} -ldylib1.o -dylib_install_name"
   
   system "cd ${workpath}/${name}-${version}/build/lib && \
           ${ld} ${prefix}/lib/libatlas.dylib libatlas.a -o libatlas.dylib \

