configure.sh 2.3 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 [label]"
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
echo "
29 30 31
   By specifying a label which contains 'debug' in addition to your 
   machine configuration you will build a debugging version. Otherwise
   the label will be added to the build directory name."
32
fi
Daniel Wortmann's avatar
Daniel Wortmann committed
33

34 35
#Check if we are using the git version and update if pull was used as an argument
if test -d $DIR/.git 
36
then
37
   if [[ $1 =~ .*pull.* ]] || [[ $2 =~ .*pull.* ]] || [[ $3 =~ .*pull.* ]] 
38 39
   then
       cd $DIR 
40
       git pull
41
       cd -
42
       exit
43 44 45 46 47 48 49 50 51 52
   fi
fi


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

53 54 55 56 57 58 59 60 61
#Name of the build directory
label=$2
if [ -n "$label" ]
then
    buildname="build.$label"
else
    buildname="build"
fi

62
#check if there is a build directory
63
if test -d $buildname
64 65
then
    echo "OLD build directory found, saved in build.$$"
66
    mv $buildname $buildname.$$
67
fi
68 69
mkdir $buildname
cd $buildname
Daniel Wortmann's avatar
Daniel Wortmann committed
70 71 72 73 74

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

75
#run cmake
76
if [[ $buildname =~ .*debug.* ]]
77 78 79 80 81 82
then
   echo "Debug version will be build"
   BUILD=Debug
else
   BUILD=Release
fi
83
cmake -DCMAKE_BUILD_TYPE=$BUILD $DIR
84

85

86
echo "Configuration finished"
87
echo "If no errors occured you should change into directory $buildname "
88
echo "run 'make' or 'make -j4'"