-
Notifications
You must be signed in to change notification settings - Fork 14
/
build.sh
executable file
·61 lines (50 loc) · 1.86 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/env bash
#
# Author: Larissa Reames CIWRO/NOAA/NSSL/FRDD
#set -eux
target=${1:-"NULL"}
compiler=${2:-"intel"}
debug=${3:-"false"}
# If target is not set
if [[ "$target" == "NULL" ]]; then
source ./machine-setup.sh
fi
echo "target=$target, compiler=$compiler"
# Check for platform/compiler configuration file
if [[ ! -f modulefiles/build.$target && ! -f modulefiles/build.$target.$compiler.lua && ! -f modulefiles/build.$target.$compiler ]]; then
echo "Platform ${target} configuration file not found in ./modulefiles, neither build.$target nor build.$target.$compiler.lua"
exit 1
fi
if [[ "$target" == "vecna" || "$compiler" == "gnu" ]]; then
echo "Use platform configuration file: build.$target.$compiler"
source ./modulefiles/build.$target.$compiler > /dev/null
elif [[ "$target" == "linux.*" || "$target" == "macosx.*" ]]; then
unset -f module
echo "Use platform configuration file: build.$target"
source ./modulefiles/build.$target > /dev/null
else
echo "Use platform configuration file: build.$target.$compiler.lua"
module use ./modulefiles
module load build.$target.$compiler.lua
module list
fi
CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=../ -DEMC_EXEC_DIR=ON -DBUILD_TESTING=OFF"
if [[ "$compiler" == "intel" ]]; then
CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_Fortran_COMPILER=ifort"
elif [[ "$compiler" == "gnu" ]]; then
CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_Fortran_COMPILER=gfortran"
fi
export debug=true
if [[ "${debug}" == "true" ]]; then
CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_BUILD_TYPE=Debug"
else
CMAKE_FLAGS="${CMAKE_FLAGS} -DCMAKE_BUILD_TYPE=Release"
fi
# for a clean build folder
rm -fr ./build
mkdir ./build && cd ./build || exit 0
# do the building
cmake .. ${CMAKE_FLAGS}
make -j 8 VERBOSE=1
make install
exit 0