[76869] trunk/dports/python/py27-numpy
vince at macports.org
vince at macports.org
Fri Mar 11 08:42:54 PST 2011
Revision: 76869
http://trac.macports.org/changeset/76869
Author: vince at macports.org
Date: 2011-03-11 08:42:54 -0800 (Fri, 11 Mar 2011)
Log Message:
-----------
Allow a two-way universal build based on Atlas (+universal +atlas).
This should solve #28346 #27773 #28118 and #28454
Modified Paths:
--------------
trunk/dports/python/py27-numpy/Portfile
Added Paths:
-----------
trunk/dports/python/py27-numpy/files/wrapper-template
Modified: trunk/dports/python/py27-numpy/Portfile
===================================================================
--- trunk/dports/python/py27-numpy/Portfile 2011-03-11 16:41:31 UTC (rev 76868)
+++ trunk/dports/python/py27-numpy/Portfile 2011-03-11 16:42:54 UTC (rev 76869)
@@ -54,20 +54,25 @@
# the +atlas variant) ...
set gcc_version ""
if {[variant_isset atlas]} {
- universal_variant no
# see if the user has set -gcc4X to disable using MacPorts'
# compiler; if not, either use what the user set (as +gcc4X) or
# default to gcc44.
variant gcc43 conflicts gcc44 gcc45 \
- description {Use the gcc43 compiler (enables fortran linking)} {}
+ description {Use the gcc43 compiler (enables fortran linking)} {
+ configure.compiler macports-gcc-4.3
+ }
variant gcc44 conflicts gcc43 gcc45 \
- description {Use the gcc44 compiler (enables fortran linking)} {}
+ description {Use the gcc44 compiler (enables fortran linking)} {
+ configure.compiler macports-gcc-4.4
+ }
variant gcc45 conflicts gcc43 gcc44 \
- description {Use the gcc45 compiler (enables fortran linking)} {}
+ description {Use the gcc45 compiler (enables fortran linking)} {
+ configure.compiler macports-gcc-4.5
+ }
if {![variant_isset gcc43] && ![variant_isset gcc45]} {
default_variants +gcc44
@@ -115,14 +120,52 @@
reinplace "s|@@MPORTS_PYTHON@@|${python.bin}|" \
${worksrcpath}/numpy/f2py/setup.py
- # disallow searching for any fortran executable except what is
- # specified in this Portfile; NOTE: this change only works when
- # setting the GCC version; if this flag is not set (meaning no
- # +gcc4X variant is set), then F2PY may or not work.
- if {${gcc_version} != ""} {
- # set which fortran to use in the f2py Python scripts
- reinplace "/possible_executables/s|\\\[.*\\\]|\['gfortran-mp-${gcc_version}'\]|g" ${worksrcpath}/numpy/distutils/fcompiler/gnu.py
- }
+ if {[variant_isset universal] && [variant_isset atlas]} {
+ # Prepare wrappers
+ file copy -force ${filespath}/wrapper-template \
+ ${worksrcpath}/c-wrapper
+ file copy -force ${filespath}/wrapper-template \
+ ${worksrcpath}/f-wrapper
+ file copy -force ${filespath}/wrapper-template \
+ ${worksrcpath}/cxx-wrapper
+
+ if {[variant_isset gcc43]} {
+ set CC "${prefix}/bin/gcc-mp-4.3"
+ set CXX "${prefix}/bin/g++-mp-4.3"
+ set F90 "${prefix}/bin/gfortran-mp-4.3"
+ } elseif {[variant_isset gcc44]} {
+ set CC "${prefix}/bin/gcc-mp-4.4"
+ set CXX "${prefix}/bin/g++-mp-4.4"
+ set F90 "${prefix}/bin/gfortran-mp-4.4"
+ } elseif {[variant_isset gcc45]} {
+ set CC "${prefix}/bin/gcc-mp-4.5"
+ set CXX "${prefix}/bin/g++-mp-4.5"
+ set F90 "${prefix}/bin/gfortran-mp-4.5"
+ }
+
+ reinplace "s|@@@|${CC}|" ${worksrcpath}/c-wrapper
+ reinplace "s|---|\\\\.c|" ${worksrcpath}/c-wrapper
+ reinplace "s|&&&|${prefix}|" ${worksrcpath}/c-wrapper
+
+ reinplace "s|@@@|${CXX}|" ${worksrcpath}/cxx-wrapper
+ reinplace "s#---#(\\\\.C|\\\\.cpp|\\\\.cc)#" \
+ ${worksrcpath}/cxx-wrapper
+ reinplace "s|&&&|${prefix}|" ${worksrcpath}/cxx-wrapper
+
+ reinplace "s|@@@|${F90}|" ${worksrcpath}/f-wrapper
+ reinplace "s|---|\\\\.f|" ${worksrcpath}/f-wrapper
+ reinplace "s|&&&|${prefix}|" ${worksrcpath}/f-wrapper
+
+ build.env-append CC="${worksrcpath}/c-wrapper" \
+ CXX="${worksrcpath}/cxx-wrapper" \
+ F77="${worksrcpath}/f-wrapper" \
+ F90="${worksrcpath}/f-wrapper"
+
+ destroot.env-append CC="${worksrcpath}/c-wrapper" \
+ CXX="${worksrcpath}/cxx-wrapper" \
+ F77="${worksrcpath}/f-wrapper" \
+ F90="${worksrcpath}/f-wrapper"
+ }
}
livecheck.type regex
Added: trunk/dports/python/py27-numpy/files/wrapper-template
===================================================================
--- trunk/dports/python/py27-numpy/files/wrapper-template (rev 0)
+++ trunk/dports/python/py27-numpy/files/wrapper-template 2011-03-11 16:42:54 UTC (rev 76869)
@@ -0,0 +1,143 @@
+#!/bin/sh
+COMPILER='@@@'
+SUFFIX='---'
+PREFIX='&&&'
+OUTPUT_O='NO'
+OUTPUT=''
+NAMED_OUTPUT=''
+LASTFILE=''
+INTEL='NO'
+SIZE32='NO'
+SIZE64='NO'
+NEWARGS=''
+
+SKIP='NO'
+
+for arg in $@
+do
+ if [ $SKIP = 'ARCH' ]; then
+ # intercept -arch option and set SIZEXX
+ SKIP='NO'
+ if [ $arg = 'x86_64' ] || [ $arg = 'ppc64' ]; then
+ SIZE64='YES'
+ else
+ SIZE32='YES'
+ fi
+
+ # which architecture are we compiling for?
+ if [ $arg = 'x86_64' ] || [ $arg = 'i386' ]; then
+ INTEL='YES'
+ fi
+
+ elif [ $arg = '-arch' ]; then
+ SKIP='ARCH'
+
+ elif [ $arg = '--version' ]; then
+ ${COMPILER} --version
+ exit 0
+
+ else
+ NEWARGS+="$arg "
+
+ # if the -c option is given, the output is .o
+ if [ $arg = '-c' ]; then
+ OUTPUT_O='YES'
+ fi
+
+ # if the output file is given by a -o option, record it
+ if [ $SKIP = 'O' ]; then
+ SKIP='NO'
+ NAMED_OUTPUT=$arg
+ fi
+
+ if [ $arg = '-o' ]; then
+ SKIP='O'
+ fi
+
+ # Note each file ending by ${SUFFIX} and remember the last one
+ # Transform them in .o
+ if `echo $arg | grep -q "${SUFFIX}$"`; then
+ LASTFILE=$arg
+ OUTPUT+=`echo $arg | sed "s/${SUFFIX}/\.o/"`
+ OUTPUT+=' '
+ fi
+ fi
+done
+
+# What is the output?
+
+if [ ${NAMED_OUTPUT}"X" != "X" ]; then
+ OUTPUT=$NAMED_OUTPUT
+
+elif [ $OUTPUT_O = 'NO' ]; then
+ # It is an executable whose is name is the LASTFILE without suffix
+ OUTPUT=`echo ${LASTFILE} | sed "s/${SUFFIX}//"`
+fi
+
+# Othewise, the output is just the ${OUTPUT} variable as computed before
+
+# For some reason, -dynamiclib and -lpython2.6 are missing when linking
+# .so files. Add them, except if -bundle is set (incompatible switches)
+if [ `echo $OUTPUT | sed -E 's|.*\.||'` = "so" ] && \
+ ! `echo $NEWARGS | grep -q bundle`; then
+ NEWARGS="${NEWARGS} ${PREFIX}/lib/libpython2.6.dylib -dynamiclib"
+fi
+
+# Now, compile
+
+if [ $SIZE32 = 'NO' ] && [ $SIZE64 = 'NO' ]; then
+ # No size indication given, just proceed with default
+ if `${COMPILER} $NEWARGS`; then
+ exit 0
+ else
+ exit 1
+ fi
+
+elif [ $SIZE32 = 'YES' ] && [ $SIZE64 = 'NO' ]; then
+ # 32-bit
+ if `${COMPILER} -m32 $NEWARGS`; then
+ exit 0
+ else
+ exit 1
+ fi
+
+elif [ $SIZE32 = 'NO' ] && [ $SIZE64 = 'YES' ]; then
+ # 64-bit
+ if `${COMPILER} -m64 $NEWARGS`; then
+ exit 0
+ else
+ exit 1
+ fi
+
+else
+ # Universal case
+ if `${COMPILER} -m32 $NEWARGS`; then
+ for filename in ${OUTPUT}
+ do
+ mv ${filename} ${filename}.32
+ done
+
+ if `${COMPILER} -m64 $NEWARGS`; then
+ for filename in ${OUTPUT}
+ do
+ mv ${filename} ${filename}.64
+ if [ $INTEL = 'YES' ]; then
+ lipo -create -arch x86_64 ${filename}.64 \
+ -arch i386 ${filename}.32 \
+ -output ${filename}
+ else
+ lipo -create -arch ppc64 ${filename}.64 \
+ -arch ppc ${filename}.32 \
+ -output ${filename}
+ fi
+
+ rm -f ${filename}.32 ${filename}.64
+ done
+ else
+ exit 1
+ fi
+ else
+ exit 1
+ fi
+fi
+exit 0
Property changes on: trunk/dports/python/py27-numpy/files/wrapper-template
___________________________________________________________________
Added: svn:executable
+ *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110311/63f15611/attachment.html>
More information about the macports-changes
mailing list