Commit 09697f6f authored by Daniel Brown's avatar Daniel Brown
Browse files

Merge branch 'develop' of git.ligo.org:finesse/finesse into develop

parents 86c0c3c4 4c9bce39
......@@ -58,102 +58,85 @@ BRANCH_STABLE=2
failure()
{
echo "************************************"
echo "Error detected! Stopping build!"
echo "`date`" | tee -a $LOGFILE
if [ -f "$LOGFILE" ]; then
echo "------------------------------------"
echo "Please check logfile: `basename $LOGFILE`"
#echo "These are the final 20 lines:"
echo "------------------------------------"
#tail -n 14 $LOGFILE | head -n 20
fi
echo "************************************"
exit 1
echo "************************************"
echo "Error detected! Stopping build!"
echo "`date`" | tee -a $LOGFILE
if [ -f "$LOGFILE" ]; then
echo "------------------------------------"
echo "Please check logfile: `basename $LOGFILE`"
#echo "These are the final 20 lines:"
echo "------------------------------------"
#tail -n 14 $LOGFILE | head -n 20
fi
echo "************************************"
exit 1
}
clean()
{
cd $ROOT || failure
echo "Cleaning Finesse files..." | tee -a $LOGFILE
make realclean
rm kat || failure
cd $ROOT || failure
echo "Cleaning Finesse files..." | tee -a $LOGFILE
make realclean
rm kat || failure
}
### functions (features) #############################################################
check_GSL_architecture()
{
lib1=$gsl_libpath/libgsl.dylib
lib2=$gsl_libpath/libgsl.a
lib4=$gsl_libpath/libgslcblas.a
lib3=$gsl_libpath/libgslcblas.dylib
if [ -f $lib2 ]
then
echo "Found libgsl.a, use static linking"
export GSL_LIBS="$lib2 $lib4"
echo $CPUARCH
if [[ $platform == "mac" && -z $CPUARCH ]]
then
libinfo=`file $lib2`
if [[ "$libinfo" != *i386* && "$libinfo" != *i686* ]]
then
echo "Trying ar -x ..."
testfile=version.o
ar -x $lib2 $testfile
libinfo=`file $testfile`
echo $libinfo
rm $testfile
fi
if [[ "$libinfo" == *x86_64* ]]
then
CPUARCH="x86_64"
elif [[ "$libinfo" == *i386* || "$libinfo" == *i686* ]]
then
CPUARCH="i686"
else
echo " ** Could not determne architecture from GSL libraries"
exit 1
fi
echo " - setting architecture based on GSL to $CPUARCH " | tee -a $LOGFILE
fi
elif [ -f $lib1 ]
then
echo "Found libgsl.dylib, use dynamic linking"
export GSL_LIBS="$lib1 $lib3"
if [[ $platform == "mac" && -z $CPUARCH ]]
then
libinfo=`file -L $lib1`
if [[ "$libinfo" == *x86_64* ]]
then
CPUARCH="x86_64"
elif [[ "$libinfo" == *i386* || "$libinfo" == *i686* ]]
then
CPUARCH="i686"
fi
echo " - setting architecture based on GSL to $CPUARCH " | tee -a $LOGFILE
fi
else
echo" - Could not determine architecture (x86_64 or i686) of GSL library" | tee -a $LOGFILE
return 1
lib1=$gsl_libpath/libgsl.dylib
lib2=$gsl_libpath/libgsl.a
lib4=$gsl_libpath/libgslcblas.a
lib3=$gsl_libpath/libgslcblas.dylib
if [ -f $lib2 ]; then
echo "Found libgsl.a, use static linking"
export GSL_LIBS="$lib2 $lib4"
#echo $CPUARCH
if [[ $platform == "mac" && -z $CPUARCH ]]; then
libinfo=`file $lib2`
if [[ "$libinfo" != *i386* && "$libinfo" != *i686* ]]; then
echo "Trying ar -x ..."
testfile=version.o
ar -x $lib2 $testfile
libinfo=`file $testfile`
echo $libinfo
rm $testfile
fi
if [[ "$libinfo" == *x86_64* ]]; then
CPUARCH="x86_64"
elif [[ "$libinfo" == *i386* || "$libinfo" == *i686* ]]; then
CPUARCH="i686"
else
echo " ** Could not determne architecture from GSL libraries"
exit 1
fi
echo " - setting architecture based on GSL to $CPUARCH " | tee -a $LOGFILE
fi
elif [ -f $lib1 ]; then
echo "Found libgsl.dylib, use dynamic linking"
export GSL_LIBS="$lib1 $lib3"
if [[ $platform == "mac" && -z $CPUARCH ]]; then
libinfo=`file -L $lib1`
if [[ "$libinfo" == *x86_64* ]]; then
CPUARCH="x86_64"
elif [[ "$libinfo" == *i386* || "$libinfo" == *i686* ]]; then
CPUARCH="i686"
fi
echo " - setting architecture based on GSL to $CPUARCH " | tee -a $LOGFILE
fi
else
echo " - Could not determine architecture (x86_64 or i686) of GSL library" | tee -a $LOGFILE
return 1
fi
}
check_prerequisites()
{
# setting default compiler
export CC
# setting default compiler
export CC
# check if the src and lib directories are here
echo "Required source and library folders exist?"
if [ ! -d "src" ]; then
......@@ -170,184 +153,164 @@ check_prerequisites()
echo " - Library folder exists" | tee -a $LOGFILE
fi
echo "Checking prerequisites..." | tee -a $LOGFILE
echo "Checking prerequisites..." | tee -a $LOGFILE
# required toolchain
if [[ $target_arch == "win" ]]; then
if [[ $platform == "win" ]]; then
TOOLS="make gcc ar ranlib"
# required toolchain
if [[ $target_arch == "win" ]]; then
if [[ $platform == "win" ]]; then
TOOLS="make gcc ar ranlib"
else
echo " - Compiling windows version on non-windows machine"
TOOLS="i586-mingw32msvc-gcc i586-mingw32msvc-ar i586-mingw32msvc-ranlib"
fi
else
echo " - Compiling windows version on non-windows machine"
TOOLS="i586-mingw32msvc-gcc i586-mingw32msvc-ar i586-mingw32msvc-ranlib"
fi
else
TOOLS="gcc ar ranlib"
fi
TOOLS="gcc ar ranlib"
fi
for tool in $TOOLS; do
for tool in $TOOLS; do
if which ls &> /dev/null; then
echo " - Found \"$tool\"..." | tee -a $LOGFILE
else
echo " - Missing \"$tool\" which is required tool!" | tee -a $LOGFILE
return 1
return 1
fi
done
done
if [[ "$platform" == 'win32' ]]; then
echo " - GSL found!" | tee -a $LOGFILE
elif [[ "$platform" == 'win64' ]]; then
echo " - GSL found!" | tee -a $LOGFILE
if [[ "$platform" == 'win32' ]]; then
echo " - GSL found!" | tee -a $LOGFILE
elif [[ "$platform" == 'win64' ]]; then
echo " - GSL found!" | tee -a $LOGFILE
elif ! (which gsl-config &> /dev/null); then
echo " - Missing GSL which is a required library" | tee -a $LOGFILE
return 1
echo " - Missing GSL which is a required library" | tee -a $LOGFILE
return 1
else
if [[ "$platform" == 'win' ]];
then
echo " - GSL found!" | tee -a $LOGFILE
else
gsl_libpath=`gsl-config --libs | cut -d " " -f1`
gsl_libpath=${gsl_libpath#-L}
gsl_libpath=${gsl_libpath#-l}
echo " - GSL found! ($gsl_libpath)" | tee -a $LOGFILE
check_GSL_architecture
fi
if [[ "$platform" == 'win' ]]; then
echo " - GSL found!" | tee -a $LOGFILE
else
gsl_libpath=`gsl-config --libs | cut -d " " -f1`
gsl_libpath=${gsl_libpath#-L}
gsl_libpath=${gsl_libpath#-l}
echo " - GSL found! ($gsl_libpath)" | tee -a $LOGFILE
check_GSL_architecture
fi
fi
echo " - Required toolchain found!" | tee -a $LOGFILE
echo " - Required toolchain found!" | tee -a $LOGFILE
return 0
}
build()
{
pwdbefore=`pwd`
if [[ $platform != "win32" && $platform != "win64" ]] ; then
echo "Configuring CUBA" | tee -a $LOGFILE
# configure cuba if needed
if [ ! -f "./lib/Cuba-3.2/config.h" ] && [ ! -f "./lib/Cuba-3.2/makefile" ] ; then
cd ./lib/Cuba-3.2
chmod 700 ./configure
if [[ $platform == "mac" ]]
then
echo "Configuring Cuba with extra flags (CPUARCH=$CPUARCH)"
./configure -q CFLAGS="-O3 -fomit-frame-pointer -ffast-math -Wall -Wextra -arch $CPUARCH"
else
./configure -q CFLAGS="-O3 -fomit-frame-pointer -ffast-math -Wall -Wextra"
fi
rm libcuba.a # removing this to trigger rebuild
# These CFLAGS are those generated by the configure script on a clean system
# We set them here explicitly in order to overwrite the previously exported
# CFLAGS for the rest of the build (because they cause Cuba to crash with a
# segmentation fault).
cd $pwdbefore
else
echo " - Cuba is already configured"
fi
fi
#------------ don't know why this is here ---------------------
#gsl_libpath=`gsl-config --libs | cut -d " " -f1`
#gsl_libpath=${gsl_libpath#-L}
#gsl_libpath=${gsl_libpath#-l}
# Setting GSL_LIBS flags to allow static linking
#export GSL_LIBS="$gsl_libpath/libgslcblas.a $gsl_libpath/libgsl.a"
echo "Calling make file, see make.log for more details..."
echo ""
if [ $verbose == 1 ]
then
make ARCH=$target_arch BUILD=$platform config 2>&1 | tee make.log || failure
make ARCH=$target_arch BUILD=$platform kat 2>&1 | tee make.log || failure
pwdbefore=`pwd`
if [[ $platform != "win32" && $platform != "win64" ]]; then
echo "Configuring CUBA" | tee -a $LOGFILE
# configure cuba if needed
if [ ! -f "./lib/Cuba-3.2/config.h" ] && [ ! -f "./lib/Cuba-3.2/makefile" ]; then
cd ./lib/Cuba-3.2
chmod 700 ./configure
if [[ $platform == "mac" ]]; then
echo "Configuring Cuba with extra flags (CPUARCH=$CPUARCH)"
./configure -q CFLAGS="-O3 -fomit-frame-pointer -ffast-math -Wall -Wextra -arch $CPUARCH"
else
./configure -q CFLAGS="-O3 -fomit-frame-pointer -ffast-math -Wall -Wextra"
fi
rm libcuba.a # removing this to trigger rebuild
# These CFLAGS are those generated by the configure script on a clean system
# We set them here explicitly in order to overwrite the previously exported
# CFLAGS for the rest of the build (because they cause Cuba to crash with a
# segmentation fault).
cd $pwdbefore
else
make ARCH=$target_arch BUILD=$platform config 2>&1 1>make.log || failure
make ARCH=$target_arch BUILD=$platform kat 2>&1 1>make.log || failure
echo " - Cuba is already configured"
fi
fi
if grep " Error " make.log 1>/dev/null 2>&1
then
#cat make.err > $LOGFILE
failure
else
return 0;
fi
echo "Calling make file, see make.log for more details..."
echo ""
if [ $verbose == 1 ]; then
make ARCH=$target_arch BUILD=$platform config 2>&1 | tee make.log || failure
make ARCH=$target_arch BUILD=$platform kat 2>&1 | tee make.log || failure
else
make ARCH=$target_arch BUILD=$platform config 2>&1 1>make.log || failure
make ARCH=$target_arch BUILD=$platform kat 2>&1 1>make.log || failure
fi
if grep " Error " make.log 1>/dev/null 2>&1; then
#cat make.err > $LOGFILE
failure
else
return 0;
fi
}
make-win-package()
{
python getWinDLLs.py
sys=`eval uname --machine`
ver=`eval git describe --abbrev=0`
echo "Making Windows $sys package..." | tee -a $LOGFILE
rm -rf .windlls
python getWinDLLs.py
dir=FINESSE_"$ver"_WIN_"$sys"
sys=`eval uname --machine`
ver=`eval git describe --abbrev=0`
echo "Making Windows $sys package..." | tee -a $LOGFILE
rm -rf .windlls
python getWinDLLs.py
dir=FINESSE_"$ver"_WIN_"$sys"
rm -rf $dir
rm -rf $dir
mkdir $dir
cd $dir
cp ../.windlls/*.dll .
cp ../kat.exe .
cp ../kat.ini .
cp ../kat.ini .
cp ../CHANGES .
cp ../LICENSES .
cp ../README .
cp ../INSTALL .
cp ../test.kat .
cp ../test_plot.kat .
cp ../install.bat .
cp ../findGnuplot.bat .
cp ../test_plot.kat .
cp ../install.bat .
cp ../findGnuplot.bat .
a=`which cygpath`
cp $a .
echo "Created Windows distribution $dir" | tee -a $LOGFILE
a=`which cygpath`
cp $a .
echo "Created Windows distribution $dir" | tee -a $LOGFILE
cd ..
}
print_usage()
{
cd $ROOT
echo "******************************************************************************"
echo "Usage: `basename $0` <option> <--checkout: option>"
echo
echo "Run with the checkout command first, this fetches the latest stable"
echo "version of Finesse source. You can then build it by using the system"
echo "specific build argument to get the required version."
echo
echo "Available Arguments:"
echo " --build"
echo " Builds Finesse executable that is native to the system you are running"
echo ""
echo " --build-linux"
echo " --build-linux32"
echo " --build-mac"
echo " --build-mac32"
echo " --build-win32"
echo " --build-win64"
echo " Choose the system which you would like to build an executable for."
echo ""
echo " --clean"
echo " This cleans up all the build files. Should be used if you have"
echo " swapped branches."
echo ""
echo " --make-win-package"
echo " This creates the binary distribution for win32. Only runs on Cygwin"
echo " capable Windows machines."
echo "******************************************************************************"
cd $ROOT
echo "******************************************************************************"
echo "Usage: `basename $0` <option> <--checkout: option>"
echo
echo "Run with the checkout command first, this fetches the latest stable"
echo "version of Finesse source. You can then build it by using the system"
echo "specific build argument to get the required version."
echo
echo "Available Arguments:"
echo " --build"
echo " Builds Finesse executable that is native to the system you are running"
echo ""
echo " --build-linux"
echo " --build-linux32"
echo " --build-mac"
echo " --build-mac32"
echo " --build-win32"
echo " --build-win64"
echo " Choose the system which you would like to build an executable for."
echo ""
echo " --clean"
echo " This cleans up all the build files. Should be used if you have"
echo " swapped branches."
echo ""
echo " --make-win-package"
echo " This creates the binary distribution for win32. Only runs on Cygwin"
echo " capable Windows machines."
echo "******************************************************************************"
echo "Wrong usage. Stopping!" >> $LOGFILE
echo "Wrong usage. Stopping!" >> $LOGFILE
return 0
return 0
}
### main control ##########################################################
......@@ -376,17 +339,17 @@ if [[ "$unamestr" == 'Linux' ]]; then
elif [[ "$unamestr" == 'Darwin' ]]; then
platform='mac'
elif [[ "$unamestr" == *CYGWIN* ]]; then
if [[ "$unamem" == 'i686' ]]; then
platform='cygwin32'
else
platform='cygwin64'
fi
if [[ "$unamem" == 'i686' ]]; then
platform='cygwin32'
else
platform='cygwin64'
fi
elif [[ "$unamestr" == *MINGW* ]]; then
if [[ "$unamem" == 'i686' ]]; then
platform='win32'
else
platform='win64'
fi
if [[ "$unamem" == 'i686' ]]; then
platform='win32'
else
platform='win64'
fi
else
echo "Platform could not be determined ($unamestr)" | tee -a $LOGFILE
failure
......@@ -395,270 +358,254 @@ fi
echo 'Running on "'$platform'"'
case "$1" in
"--build")
NATIVE="-march=native"
CPUARCH=""
target_arch=$platform
if [[ "$platform" == 'linux' ]]; then
TARGET=$TARGET_LINUX
elif [[ "$platform" == 'mac' ]]; then
TARGET=$TARGET_MAC
elif [[ "$platform" == 'cygwin32' ]]; then
TARGET=$TARGET_WIN32
CPUARCH=
target_arch=win32
elif [[ "$platform" == 'cygwin64' ]]; then
TARGET=$TARGET_WIN64
CPUARCH=
target_arch=win64
elif [[ "$platform" == 'win32' ]]; then
TARGET=$TARGET_WIN32
CPUARCH=
target_arch=win64
elif [[ "$platform" == 'win64' ]]; then
TARGET=$TARGET_WIN64
CPUARCH=
target_arch=win64
else
echo "Platform Target could not be determined" | tee -a $LOGFILE
failure
fi
"--build")
NATIVE="-march=native"
CPUARCH=""
target_arch=$platform
if [[ "$platform" == 'linux' ]]; then
TARGET=$TARGET_LINUX
elif [[ "$platform" == 'mac' ]]; then
TARGET=$TARGET_MAC
elif [[ "$platform" == 'cygwin32' ]]; then
TARGET=$TARGET_WIN32
CPUARCH=
target_arch=win32
elif [[ "$platform" == 'cygwin64' ]]; then
TARGET=$TARGET_WIN64
CPUARCH=
target_arch=win64
elif [[ "$platform" == 'win32' ]]; then
TARGET=$TARGET_WIN32
CPUARCH=
target_arch=win64
elif [[ "$platform" == 'win64' ]]; then
TARGET=$TARGET_WIN64
CPUARCH=
target_arch=win64
else
echo "Platform Target could not be determined" | tee -a $LOGFILE
failure
fi
echo "Building native Finesse version:" | tee -a $LOGFILE
;;
"--build-linux")
NATIVE=""
TARGET=$TARGET_LINUX
="-m64"
target_arch="linux"
echo "Building Linux version :" | tee -a $LOGFILE
;;
"--build-linux32")
NATIVE=""
TARGET=$TARGET_LINUX
CPUARCH="-m32"
target_arch="linux"
echo "Building Linux 32bit version:" | tee -a $LOGFILE
;;
"--build-mac32")
NATIVE=""
TARGET=$TARGET_MAC
CPUARCH="i386"
target_arch="mac"
echo "Building Mac (Intel) 32bit version:" | tee -a $LOGFILE
;;
"--build-mac")
NATIVE=""
TARGET=$TARGET_MAC
CPUARCH=""
target_arch="mac"
echo "Building Mac (Intel) version:" | tee -a $LOGFILE
;;
"--build-win32")
NATIVE=""
TARGET=$TARGET_WIN32
CPUARCH="i686"
target_arch="win32"
echo "Building Win32 version:" | tee -a $LOGFILE
;;
"--build-win64")
NATIVE=""
TARGET=$TARGET_WIN64
CPUARCH="x86_64"
target_arch="win64"
echo "Building Win64 version:" | tee -a $LOGFILE
;;
"--checkout")
echo ""
echo "ERROR: --checkout is no longer used, use 'git checkout [branch name]' instead." | tee -a $LOGFILE
echo ""
;;
"--remove")
echo "--remove is no longer used." | tee -a $LOGFILE
;;
"--clean")
TARGET=$TARGET_CLEAN
;;
"--make-win-package")
make-win-package
exit 0
;;
*)
print_usage
exit 1
;;
echo "Building native Finesse version:" | tee -a $LOGFILE
;;
"--build-linux")
NATIVE=""
TARGET=$TARGET_LINUX
CPUARCH="-m64"
target_arch="linux"
echo "Building Linux version :" | tee -a $LOGFILE
;;
"--build-linux32")
NATIVE=""
TARGET=$TARGET_LINUX
CPUARCH="-m32"