...
 
Commits (3)
#! /bin/bash
# configure script
# note: has nothing to do with GNU autoconf
exec 2> ${LOGFILE:-/dev/null} 3>&1
eval ${LOGFILE:+set -x}
if [[ -z $LOGFILE ]]; then
exec 2> /dev/null 3>&1
else
exec 3> >(while read TEXT ; do echo $TEXT ; echo $(date +"%d.%m.%Y %H:%M:%S") $TEXT >> $LOGFILE; done)
exec 2>> $LOGFILE
fi
shopt -s nullglob
......@@ -89,7 +92,7 @@ CONF_LD=$LD
CONF_MODDIR=$FPATH
if [ "$CONF_OS" -eq "Darwin" ]; then
if [ "$CONF_OS" == "Darwin" ]; then
CONF_PREFIX=/usr/local/
else
CONF_PREFIX=/usr/
......@@ -125,7 +128,7 @@ for arg in "$@" ; do
--coverage)
COVERAGE=true ;;
--ci)
echo "Running in CI configuration. Will not perform speed tests!"
echo "Running in CI configuration. Will not perform speed tests!" 1>&3
HAVE_MCC=true
HAVE_GINAC=true
DEBUG=true
......@@ -185,6 +188,7 @@ findprog() {
var="$2"
set -- ${!var:+"${!var}"} "${@:3}"
for prog in "$@" ; do
echo "Checking option $prog in path" 1>&2
full="`type -P "$prog"`" && {
echo "$full" 1>&3
printf -v "CONF_$var" "%q" "$full"
......@@ -201,14 +205,17 @@ findlib() {
case "$flag" in
-L* )
libfolder=${flag/-L/}
echo "Checking folder $libfolder" 1>&2
if [ -f "$libfolder/lib$1.so" ] ; then
path=`readlink -f -- "$libfolder/lib$1.so"`
echo "Found SO in folder $libfolder" 1>&2
echo $path 1>&3
printf -v "CONF_$2" "%q" "$path"
return 0
fi
if [ -f "$libfolder/lib$1.a" ] ; then
path=`readlinf -f -- "$libfolder/lib$1.a"`
echo "Found A in folder $libfolder" 1>&2
echo $path 1>&3
printf -v "CONF_$2" "%q" "$path"
return 0
......@@ -259,7 +266,7 @@ case "$1,$2,$3" in
$NATIVE && eval addflag FFLAGS -march=native -mtune=native
fi
if $COVERAGE ; then
echo "Coverage analytics is currently only supported for gcc"
echo "Coverage analytics is currently only supported for gcc" 1>&3
exit 1
fi
;;
......@@ -303,7 +310,7 @@ case "$1,$2,$3" in
HAVE_MCC=false
fi
if $COVERAGE ; then
echo "Coverage analytics is currently only supported for gcc"
echo "Coverage analytics is currently only supported for gcc" 1>&3
exit 1
fi
;;
......@@ -317,6 +324,7 @@ echo -n "extracting the Fortran libraries... " 1>&3
rm -fr $test*
echo "Trying the following program as $test.f90" 1>&2
tee $test.f90 << _EOF_ 1>&2
program test
integer i
......@@ -325,7 +333,10 @@ tee $test.f90 << _EOF_ 1>&2
end
_EOF_
echo "Executing $CONF_FC -v -o $test $test.f90" 1>&2
while read line ; do
echo "Parsing line $line" 1>&2
set -- ${line//[:,()]/ }
[[ "$1" =~ (/collect2|/ld|^ld)$ ]] && while test $# -gt 1 ; do
shift
......@@ -333,12 +344,16 @@ while read line ; do
*.o | -lc*)
;;
-l* | -L* | *.a)
echo "Found linker flag $1" 1>&2
FLDFLAGS+=" $1" ;;
-Bstatic | -Bdynamic | *.ld)
echo "Found linker flag $1" 1>&2
FLDFLAGS+=" -Wl,$1" ;;
/*)
echo "Found linker flag $1" 1>&2
FLDFLAGS+=" -L$1" ;;
-rpath*)
echo "Found linker flag $1" 1>&2
FLDFLAGS+=" -Wl,$1,$2"
shift ;;
-dynamic-linker)
......@@ -352,6 +367,7 @@ while read line ; do
shift
case "$1" in
-fintrinsic-modules-path )
echo "Found module path $1" 1>&2
CONF_MODPATH=$2
;;
esac
......@@ -400,16 +416,23 @@ if ( $HAVE_GINAC || $HAVE_MCC ); then
echo -n "does $CONF_FC append underscores... " 1>&3
echo "Trying the following program as $test-c.c" 1>&2
tee $test-c.c << _EOF_ 1>&2
int uscore_ = 95;
int uscore = 59;
_EOF_
for CONF_BITS in ${CONF_BITS:--m64 -m32} ; do
echo "Executing $CONF_CC $CONF_CFLAGS $CONF_BITS -c $test-c.c" 1>&2
eval $CONF_CC $CONF_CFLAGS $CONF_BITS -c $test-c.c 1>&2 || continue
echo "Executing $CONF_FC -o $test $test.f90 $test-c.o" 1>&2
eval $CONF_FC -o $test $test.f90 $test-c.o 1>&2 && break
done
if [[ ! -x "$test" ]]; then
echo "error: linking failed. Please check logfile $LOGFILE." 1>&3
fi
./$test
case $? in
95)
......@@ -424,10 +447,10 @@ _EOF_
esac
else
$CONF_CC=
$CONF_CXX=
$CONF_CFLAGS=
$CONF_NOUNDERSCORE=
CONF_CC=
CONF_CXX=
CONF_CFLAGS=
CONF_NOUNDERSCORE=
fi
......@@ -439,12 +462,15 @@ if $HAVE_MCC ; then
echo -n "what is $CONF_MATH SystemID... " 1>&3
echo "Trying the following program as $test.m" 1>&2
tee $test.m << _EOF_ 1>&2
Print["SYSID "<>ToString[\$SystemID]];
Print["INSTDIR "<>ToString[\$InstallationDirectory]];
Print["USERDIR "<>ToString[\$UserBaseDirectory]];
_EOF_
$CONF_MATH < $test.m > $test.log
echo "Mathematica returned" 1>&2
cat $test.log 1>&2
CONF_MATH_SYS=`cat $test.log | grep "SYSID" | sed 's/.*SYSID //'`
CONF_MATH_DIR=`cat $test.log | grep "INSTDIR" | sed 's/.*INSTDIR //'`
CONF_MATH_USR=`cat $test.log | grep "USERDIR" | sed 's/.*USERDIR //'`
......@@ -458,7 +484,9 @@ _EOF_
PATH=$CONF_COMPAD:$PATH findprog mcc MCC mcc
echo -n "looking for MLDK directory... " 1>&3
echo "Running $CONF_MCC --internals" 1>&2
$CONF_MCC --internals > $test.int
cat $test.int 1>&2
CONF_MLDK=`cat $test.int | grep "MLDK Directory" | cut -f2 -d":"`
echo $CONF_MLDK 1>&3
......@@ -466,7 +494,6 @@ _EOF_
CONF_MCC_CFLAGS=`cat $test.int | grep "Compile Flags$arch:" | cut -f2 -d":"`
CONF_MCC_LFLAGS=`cat $test.int | grep "Linker Libraries" | cut -f2 -d":"`
CONF_MCC_LFLAGS="$CONF_LFLAGS $CONF_MCC_LFLAGS"
cat $test.int | grep "Linker Libraries" | cut -f2 -d":"
if [ ! -z $CONF_BITS ]; then
if [ "$CONF_BITS" -ne "$MCC_BITS" ]; then
echo "mcc wants $MCC_BITS ($arch), $CONF_BITS selected." 1>&3
......@@ -493,6 +520,7 @@ _EOF_
## can we do MathLink compilations
echo -n "do we have working MathLink... " 1>&3
echo "Trying the following program as $test.tm" 1>&2
tee $test.tm << _EOF_ 1>&2
:Begin:
:Function: test
......@@ -512,17 +540,20 @@ int main(int argc, char **argv) {
return MLMain(argc, argv);
}
_EOF_
echo "Executing $CONF_MPREP $test.tm" 1>&2
$CONF_MPREP $test.tm > $test.tm.c
echo "Executing $CONF_CC $CONF_MCC_CFLAGS $CONF_CFLAGS -c $test.tm.c" 1>&2
$CONF_CC $CONF_MCC_CFLAGS $CONF_CFLAGS -c $test.tm.c
echo "Executing $CONF_CC -o $test.math $test.tm.o $CONF_MCC_LFLAGS" 1>&2
$CONF_CC -o $test.math $test.tm.o $CONF_MCC_LFLAGS
test -x $test.math && {
if [[ -x "$test.math" ]] ; then
echo "yes" 1>&3
CONF_ML=1
} || {
else
echo "no" 1>&3
CONF_ML=0
exit 1;
}
fi
fi
......@@ -535,6 +566,7 @@ CONF_LD=${LD:-$CONF_FC}
if $CONF_QUAD ; then
echo -n "does $CONF_FC support quad-precision... " 1>&3
rm -fr $test*
echo "Trying the following program as $test.f90" 1>&2
tee $test.f90 << _EOF_ 1>&2
program test
real(selected_real_kind(30,32)) a, b
......@@ -543,12 +575,16 @@ if $CONF_QUAD ; then
if( a .eq. b ) stop 1
end
_EOF_
echo "Running $CONF_FC $CONF_FFLAGS -o $test $test.f90" 1>&2
$CONF_FC $CONF_FFLAGS -o $test $test.f90 1>&2
if [[ ! -x "$test" ]]; then
echo "no. Compilation failed."
fi
./$test 1>&2 && {
echo "yes" 1>&3
eval addflag FFLAGS -DKINDREAL=16 -DKINDINT=8
} || {
echo "no" 1>&3
echo "no. Running failed" 1>&3
exit 1
}
$HAVE_MCC && eval addflag CFLAGS -DHAVE_QUAD
......@@ -583,6 +619,7 @@ if $HAVE_GINAC ; then
if $FOUND_GINAC; then
CONF_LD=${LD:-$CONF_CXX}
echo -n "Checking if GiNaC works... " 1>&3
echo "Trying the following program as $test.ginac.cpp" 1>&2
tee $test.ginac.cpp << _EOF_ 1>&2
#include <ginac/ginac.h>
#include <iostream>
......@@ -630,14 +667,19 @@ int main() {
complex_t cans = geval_(&x[0],&n);
float del = (2.2982889094420660-cans.r)*(2.2982889094420660-cans.r) + (0.98869296399417417-cans.i)*(0.98869296399417417-cans.i);
if ( (ans<1e-15) && (del<1e-15) )
return 0;
else
return 1;
if (ans>1e-15) return 1;
if (del>1e-15) return 2;
return 0;
}
_EOF_
echo "Running $CONF_CXX $CONF_CXXFLAGS $CONF_BITS -c $test.ginac.cpp" 1>&2
$CONF_CXX $CONF_CXXFLAGS $CONF_BITS -c $test.ginac.cpp
echo "Running $CONF_LD -o $test.ginac $test.ginac.o $CONF_LFLAGS" 1>&2
$CONF_LD -o $test.ginac $test.ginac.o $CONF_LFLAGS
if [[ ! -x "$test" ]]; then
echo "error compiling GiNaC" 1>&3
exit 1
fi
./$test.ginac
case $? in
0)
......@@ -646,6 +688,9 @@ _EOF_
1)
echo "no" 1>&3
exit 1 ;;
2)
echo "no. Try updating your GiNaC version" 1>&3
exit 1 ;;
*)
echo "error running GiNaC" 1>&3
exit 1 ;;
......@@ -923,4 +968,4 @@ distclean:
EOF
echo "Configuration of handyG $VERSION done. Now type \"make\"."
echo "Configuration of handyG $VERSION done. Now type \"make\"." 1>&3