configure.sh 2.59 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
        'configure.sh AUTO'
18 19 20 21 22 23 24 25 26

  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:
        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'"
27
echo "
28 29 30
   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."
31
fi
Daniel Wortmann's avatar
Daniel Wortmann committed
32

33 34
#Check if we are using the git version and update if pull was used as an argument
if test -d $DIR/.git 
35 36 37 38 39 40 41 42
    #Check if hook is installed and install it if needed
    if test -h $DIR/.git/hooks/pre-commit
    then
        echo "Git version found"
    else
        ln -s $DIR/tests/git-hooks/pre-commit $DIR/.git/hooks
        echo "Git version found, hook installed"
    fi
43
then
44
   if [[ $1 =~ .*pull.* ]] || [[ $2 =~ .*pull.* ]] || [[ $3 =~ .*pull.* ]] 
45 46
   then
       cd $DIR 
47
       git pull
48
       cd -
49
       exit
50 51 52 53 54 55 56 57 58 59
   fi
fi


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

60 61 62 63 64 65 66 67 68
#Name of the build directory
label=$2
if [ -n "$label" ]
then
    buildname="build.$label"
else
    buildname="build"
fi

69
#check if there is a build directory
70
if test -d $buildname
71 72
then
    echo "OLD build directory found, saved in build.$$"
73
    mv $buildname $buildname.$$
74
fi
75 76
mkdir $buildname
cd $buildname
Daniel Wortmann's avatar
Daniel Wortmann committed
77 78 79

#Now check the machine and set some defaults 
machine=$1
Daniel Wortmann's avatar
Daniel Wortmann committed
80
if [[ $machine =~ FLEUR_CONFIG_MACHINE ]]
81
then
Daniel Wortmann's avatar
Daniel Wortmann committed
82
    machine=$FLEUR_CONFIG_MACHINE
83
fi
84
echo "Machine config:$machine"
Daniel Wortmann's avatar
Daniel Wortmann committed
85 86
configure_machine

87
#run cmake
88
if [[ $buildname =~ .*debug.* ]]
89 90 91 92 93 94
then
   echo "Debug version will be build"
   BUILD=Debug
else
   BUILD=Release
fi
95
cmake -DCMAKE_BUILD_TYPE=$BUILD $DIR
96

97

98
echo "Configuration finished"
99
echo "If no errors occured you should change into directory $buildname "
100
echo "run 'make' or 'make -j4'"