configure.sh 2.56 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 37 38 39 40 41 42 43
    #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
44
then
45
   if [[ $1 =~ .*pull.* ]] || [[ $2 =~ .*pull.* ]] || [[ $3 =~ .*pull.* ]] 
46 47
   then
       cd $DIR 
48
       git pull
49
       cd -
50
       exit
51 52 53 54 55 56 57 58 59 60
   fi
fi


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

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

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

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

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

93

94
echo "Configuration finished"
95
echo "If no errors occured you should change into directory $buildname "
96
echo "run 'make' or 'make -j4'"