configure.sh 2.12 KB
Newer Older
1
#!/usr/bin/env bash
2
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3
echo "------------ Welcome to the FLEUR configuration script -------------"
4
. $DIR/cmake/machines.sh
5 6 7
#check if -h or  --help was given as argument
if [ "$1" = "" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]
then
8
   echo "USAGE: configure.sh MACHINE [debug]"
9 10 11 12 13 14 15 16
   echo "
  To help the script finding a proper configuration you should
  provide the name of a specific machine to compile on.
  Currently known machine configurations are:
  " 
   echo "   $known_machines"
   echo " 
  If you do not find a proper choice you might try
17
        'configuration.sh AUTO'
18 19 20 21 22 23 24 25 26 27

  You might also want to add your configuration to the file 
  cmake/machines.sh in this case :-)
  
  In addition you can modify some environment variables:
        FLEUR_NO_SERIAL     -- if defined no serial executables will be build
        FC                  -- name of Fortran compiler
        CC                  -- name of C compiler
        FLEUR_LIBRARIES     -- list of linker arguments i.e. '-L/lib;-lbla'
        CMAKE_Fortran_FLAGS -- list of compiler options i.e. '-r8'"
28 29
echo "
   By specifying 'debug' in addition to your machine configuration you will build a debugging version"
30 31
fi
#Check if we are using the git version and ask if we want to update
32
if test -d $DIR/.git
33 34 35 36 37
then
   #We are using the git version so ask the user (for 10sec)
   echo "Shall we try to update to the newest git version? (y/n)"
   read -n 1 -t 10 x
   if test "$x" == "y"
38 39
   then
       cd $DIR 
40
       git pull
41
       cd -
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
   fi
fi


#Now check the machine and set some defaults 
machine=$1
configure_machine

#include a configfile if present
if test -r config.sh
then
 . config.sh
fi

#check if there is a build directory
if test -d build
then
    echo "OLD build directory found, saved in build.$$"
    mv build build.$$
fi
mkdir build
cd build
#run cmake
65 66 67 68 69 70 71
if test "debug" == "$2"
then
   echo "Debug version will be build"
   BUILD=Debug
else
   BUILD=Release
fi
72
cmake -DCMAKE_BUILD_TYPE=$BUILD $DIR
73

74

75 76 77
echo "Configuration finished"
echo "If no errors occured you should change into directory 'build' "
echo "run 'make' or 'make -j4'"