Index: /trunk/dports/science/xraylib/Portfile
===================================================================
--- /trunk/dports/science/xraylib/Portfile	(revision 97980)
+++ /trunk/dports/science/xraylib/Portfile	(revision 97981)
@@ -6,4 +6,5 @@
 name                xraylib
 version             2.16.0
+revision            1
 categories          science
 platforms           darwin
@@ -26,4 +27,11 @@
                     sha256 91ccbd25338c00027d58ee13239375926a0e106d9b883d1c927e846e035e276c 
 
+patchfiles          patch-configure.diff \
+                    patch-m4-m4-ax_python_devel.m4.diff \
+                    patch-python-Makefile.am.diff \
+                    patch-python-Makefile.in.diff
+
+patch.pre_args      -p1
+
 configure.args      --disable-idl \
                     --disable-fortran2003 \
@@ -43,8 +51,30 @@
 }
 
-variant python description {Python bindings} {
-    configure.args-append --enable-python --enable-python-integration
+variant python26 description {Python2.6 bindings} conflicts python27 python31 python32 {
+    configure.args-append --enable-python --enable-python-integration PYTHON=${prefix}/bin/python2.6
     configure.args-delete --disable-python
     depends_build-append port:swig-python
+    depends_lib-append port:python26
+}
+
+variant python27 description {Python2.7 bindings} conflicts python26 python31 python32 {
+    configure.args-append --enable-python --enable-python-integration PYTHON=${prefix}/bin/python2.7
+    configure.args-delete --disable-python
+    depends_build-append port:swig-python
+    depends_lib-append port:python27
+}
+
+variant python31 description {Python3.1 bindings} conflicts python27 python26 python32 {
+    configure.args-append --enable-python --enable-python-integration PYTHON=${prefix}/bin/python3.1
+    configure.args-delete --disable-python
+    depends_build-append port:swig-python
+    depends_lib-append port:python31
+}
+
+variant python32 description {Python3.2 bindings} conflicts python27 python31 python26 {
+    configure.args-append --enable-python --enable-python-integration PYTHON=${prefix}/bin/python3.2
+    configure.args-delete --disable-python
+    depends_build-append port:swig-python
+    depends_lib-append port:python32
 }
 
@@ -97,3 +127,6 @@
 }
 
-default_variants    +python
+if {![variant_isset python26] && ![variant_isset python27] && ![variant_isset python31] && ![variant_isset python32]} {
+    default_variants    +python27
+}
+
Index: /trunk/dports/science/xraylib/files/patch-configure.diff
===================================================================
--- /trunk/dports/science/xraylib/files/patch-configure.diff	(revision 97981)
+++ /trunk/dports/science/xraylib/files/patch-configure.diff	(revision 97981)
@@ -0,0 +1,73 @@
+--- xraylib-2.16.0-released/configure	2012-09-17 17:19:28.000000000 +0200
++++ xraylib-2.16.0/configure	2012-09-19 17:27:05.000000000 +0200
+@@ -17732,20 +17732,23 @@
+ 		# credits goes to momjian, I think. I'd like to put the right name
+ 		# in the credits, if someone can point me in the right direction... ?
+ 		#
+-		if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
+-			-a x"$ac_python_library" != x"$ac_python_soname"
+-		then
++		#echo "ac_python_libdir: x$ac_python_libdirx"
++		#echo "ac_python_library: x$ac_python_libraryx"
++		#echo "ac_python_soname: x$ac_python_sonamex"
++		#if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
++		#	-a x"$ac_python_library" != x"$ac_python_soname"
++		#then
+ 			# use the official shared library
+ 			ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
+-			PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library"
+-		else
+-			# old way: use libpython from python_configdir
+-			ac_python_libdir=`$PYTHON -c \
+-			  "from distutils.sysconfig import get_python_lib as f; \
+-			  import os; \
+-			  print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
+ 			PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
+-		fi
++		#else
++		#	# old way: use libpython from python_configdir
++		#	ac_python_libdir=`$PYTHON -c \
++		#	  "from distutils.sysconfig import get_python_lib as f; \
++		#	  import os; \
++		#	  print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
++		#	PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
++		#fi
+ 
+ 		if test -z "PYTHON_LDFLAGS"; then
+ 			{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
+@@ -17800,7 +17803,7 @@
+ 	if test -z "$PYTHON_EXTRA_LIBS"; then
+ 	   PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
+                 conf = distutils.sysconfig.get_config_var; \
+-                print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"`
++                print (conf('LOCALMODLIBS') + ' ' + conf('LDFLAGS') + ' ' + conf('LIBS'))"`
+ 	fi
+ 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON_EXTRA_LIBS" >&5
+ $as_echo "$PYTHON_EXTRA_LIBS" >&6; }
+@@ -18080,7 +18083,7 @@
+ JAVA_TEST=Test.java
+ CLASS_TEST=Test.class
+ cat << \EOF > $JAVA_TEST
+-/* #line 18083 "configure" */
++/* #line 18086 "configure" */
+ public class Test {
+ }
+ EOF
+@@ -18267,7 +18270,7 @@
+ if $UUDECODE Test.uue; then
+         ac_cv_prog_uudecode_base64=yes
+ else
+-        echo "configure: 18270: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
++        echo "configure: 18273: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
+         echo "configure: failed file was:" >&5
+         cat Test.uue >&5
+         ac_cv_prog_uudecode_base64=no
+@@ -18298,7 +18301,7 @@
+ CLASS_TEST=Test.class
+ TEST=Test
+ cat << \EOF > $JAVA_TEST
+-/* [#]line 18301 "configure" */
++/* [#]line 18304 "configure" */
+ public class Test {
+ public static void main (String args[]) {
+         System.exit (0);
Index: /trunk/dports/science/xraylib/files/patch-m4-m4-ax_python_devel.m4.diff
===================================================================
--- /trunk/dports/science/xraylib/files/patch-m4-m4-ax_python_devel.m4.diff	(revision 97981)
+++ /trunk/dports/science/xraylib/files/patch-m4-m4-ax_python_devel.m4.diff	(revision 97981)
@@ -0,0 +1,46 @@
+--- xraylib-2.16.0-released/m4/m4-ax_python_devel.m4	2012-09-17 17:19:18.000000000 +0200
++++ xraylib-2.16.0/m4/m4-ax_python_devel.m4	2012-09-19 17:26:55.000000000 +0200
+@@ -232,20 +232,23 @@
+ 		# credits goes to momjian, I think. I'd like to put the right name
+ 		# in the credits, if someone can point me in the right direction... ?
+ 		#
+-		if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
+-			-a x"$ac_python_library" != x"$ac_python_soname"
+-		then
++		#echo "ac_python_libdir: x$ac_python_libdirx"
++		#echo "ac_python_library: x$ac_python_libraryx"
++		#echo "ac_python_soname: x$ac_python_sonamex"
++		#if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
++		#	-a x"$ac_python_library" != x"$ac_python_soname"
++		#then
+ 			# use the official shared library
+ 			ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
+-			PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library"
+-		else
+-			# old way: use libpython from python_configdir
+-			ac_python_libdir=`$PYTHON -c \
+-			  "from distutils.sysconfig import get_python_lib as f; \
+-			  import os; \
+-			  print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
+ 			PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
+-		fi
++		#else
++		#	# old way: use libpython from python_configdir
++		#	ac_python_libdir=`$PYTHON -c \
++		#	  "from distutils.sysconfig import get_python_lib as f; \
++		#	  import os; \
++		#	  print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
++		#	PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
++		#fi
+ 
+ 		if test -z "PYTHON_LDFLAGS"; then
+ 			AC_MSG_WARN([
+@@ -290,7 +293,7 @@
+ 	if test -z "$PYTHON_EXTRA_LIBS"; then
+ 	   PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
+                 conf = distutils.sysconfig.get_config_var; \
+-                print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"`
++                print (conf('LOCALMODLIBS') + ' ' + conf('LDFLAGS') + ' ' + conf('LIBS'))"`
+ 	fi
+ 	AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
+ 	AC_SUBST(PYTHON_EXTRA_LIBS)
Index: /trunk/dports/science/xraylib/files/patch-python-Makefile.am.diff
===================================================================
--- /trunk/dports/science/xraylib/files/patch-python-Makefile.am.diff	(revision 97981)
+++ /trunk/dports/science/xraylib/files/patch-python-Makefile.am.diff	(revision 97981)
@@ -0,0 +1,11 @@
+--- xraylib-2.16.0-released/python/Makefile.am	2012-09-11 16:12:36.000000000 +0200
++++ xraylib-2.16.0/python/Makefile.am	2012-09-19 16:19:22.000000000 +0200
+@@ -27,7 +27,7 @@
+ 
+ pythonxrl: ${top_srcdir}/src/xraylib.i
+ 	$(SWIG) -I${top_srcdir}/include -includeall -o xraylib_wrap.c -python ${top_srcdir}/src/xraylib.i
+-	CC="$(CC)" CPPFLAGS="-I${top_srcdir}/include" CFLAGS="$(ARCHFLAGS)" $(PYTHON) xrlsetup.py build_ext --inplace
++	CC="$(CC)" CPPFLAGS="-I${top_srcdir}/include" LDFLAGS="$(PYTHON_LDFLAGS)" CFLAGS="$(ARCHFLAGS)" $(PYTHON) xrlsetup.py build_ext --inplace
+ 
+ 
+ 
Index: /trunk/dports/science/xraylib/files/patch-python-Makefile.in.diff
===================================================================
--- /trunk/dports/science/xraylib/files/patch-python-Makefile.in.diff	(revision 97981)
+++ /trunk/dports/science/xraylib/files/patch-python-Makefile.in.diff	(revision 97981)
@@ -0,0 +1,11 @@
+--- xraylib-2.16.0-released/python/Makefile.in	2012-09-17 17:19:29.000000000 +0200
++++ xraylib-2.16.0/python/Makefile.in	2012-09-19 17:27:07.000000000 +0200
+@@ -484,7 +484,7 @@
+ 
+ @ENABLE_PYTHON_TRUE@pythonxrl: ${top_srcdir}/src/xraylib.i
+ @ENABLE_PYTHON_TRUE@	$(SWIG) -I${top_srcdir}/include -includeall -o xraylib_wrap.c -python ${top_srcdir}/src/xraylib.i
+-@ENABLE_PYTHON_TRUE@	CC="$(CC)" CPPFLAGS="-I${top_srcdir}/include" CFLAGS="$(ARCHFLAGS)" $(PYTHON) xrlsetup.py build_ext --inplace
++@ENABLE_PYTHON_TRUE@	CC="$(CC)" CPPFLAGS="-I${top_srcdir}/include" LDFLAGS="$(PYTHON_LDFLAGS)" CFLAGS="$(ARCHFLAGS)" $(PYTHON) xrlsetup.py build_ext --inplace
+ 
+ #I like to use my own commands for the install: although xrlsetup.py can handle this, I want to do it myself. Libtool would also be a possibility as is detailed in the automake manual.
+ #MKDIR_P's are necessary for distcheck
