-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·174 lines (174 loc) · 5.87 KB
/
build.sh
File metadata and controls
executable file
·174 lines (174 loc) · 5.87 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/bash
#
# Define how to build the libraries and executables:
BUILD_TYPE=Debug
Fortran_COMPILER=gfortran
GENERATOR="Unix Makefiles"
ENABLE_OPI_SUPPORT=ON
ENABLE_PFUNIT=ON
LIBSUFFIX="so"
GENERATOR_FLAGS=""
if [[ "$OSTYPE" == "linux-gnu" ]]; then
LIBSUFFIX="so"
elif [[ "$OSTYPE" == "darwin"* ]]; then
LIBSUFFIX="dylib"
elif [[ "$OSTYPE" == "CYGWIN"* ]]; then
LIBSUFFIX="dll"
elif [[ "$OSTYPE" == "MINGW"* ]]; then
LIBSUFFIX="dll"
elif [[ "$OSTYPE" == "msys"* ]]; then
LIBSUFFIX="dll"
GENERATOR_FLAGS="-G MSYS Makefiles"
fi
git submodule update --init --recursive
################################################################################
# #
# Build OPI #
# #
################################################################################
if [[ "$ENABLE_OPI_SUPPORT" == "ON" ]]; then
# Build OPI
cd OPI || exit
# Create the build directory if it does not exist
if [[ ! -d "build" ]]; then
mkdir build
else
rm -rf build/*
fi
cd build || exit
echo "Updating cmake"
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=../ -DCMAKE_Fortran_COMPILER=$Fortran_COMPILER -DENABLE_CXX11=ON -DENABLE_CL_SUPPORT=OFF -DENABLE_CUDA_SUPPORT=OFF -DENABLE_PYTHON=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5 "$GENERATOR_FLAGS" ../
echo "Building OPI"
cmake --build .
cmake --install .
if [[ $? -ne 0 ]]; then
echo "Could not build OPI. Exiting."
exit $?
fi
echo "Leaving OPI"
cd ../../
else
echo "ENABLE_OPI_SUPPORT is 'OFF'. Skipping. Set to 'ON' to add it."
fi
################################################################################
# #
# Build libslam #
# #
################################################################################
# Build libslam
cd libslam || exit
# Create the build directory if it does not exist
if [[ ! -d "build" ]]; then
mkdir build
else
rm -rf build/*
fi
cd build || exit
echo "Updating cmake"
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_Fortran_COMPILER=$Fortran_COMPILER -DENABLE_OpenMP_SUPPORT=OFF -DENABLE_POSTGRESQL_SUPPORT=OFF -DCMAKE_POLICY_VERSION_MINIMUM=3.5 "$GENERATOR_FLAGS" ../
echo "Building libslam"
cmake --build .
cmake --install .
if [[ $? -ne 0 ]]; then
echo "Could not build libslam. Exiting."
exit $?
fi
echo "Manually preparing 'lib' and 'include' directories"
cd ../
# Delete the include and lib folders when they exist,
# as linking on windows will create directories which
# leads to errors on the second run of the script
if [[ ! -d "include" ]]; then
rm -rf include
fi
if [[ ! -d "lib" ]]; then
rm -rf lib
fi
ln -sf build/include include
ln -sf build/lib lib
echo "Leaving libslam"
cd ../
################################################################################
# #
# Build pFUnit #
# #
################################################################################
if [[ "$ENABLE_PFUNIT" == "ON" ]]; then
cd pFUnit || exit
# Create the build directory if it does not exist
if [[ ! -d "build" ]]; then
mkdir build
else
rm -rf build/*
fi
cd build || exit
echo "Updating cmake"
export PFUNIT_DIR=..//pFUnit/build/installed
export FC=$Fortran_COMPILER
cmake -DSKIP_MPI=yes "$GENERATOR_FLAGS" -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ../
echo "Building pFUnit"
cmake --build .
cmake --install .
cd ../
echo "Leaving pFUnit"
cd ../
else
echo "ENABLE_PFUNIT is 'OFF'. Skipping. Set to 'ON' to add it."
fi
################################################################################
# #
# Build NEPTUNE #
# #
################################################################################
# Create the lib directory if it does not exist
if [[ ! -d "lib" ]]; then
mkdir lib
fi
# Create the links to libraries needed by NEPTUNE
cd lib || exit
ln -sf ../libslam/lib/libslam-Fortran.$LIBSUFFIX .
if [[ "$ENABLE_OPI_SUPPORT" == "ON" ]]; then
ln -sf ../OPI/lib/libOPI-Fortran.$LIBSUFFIX .
ln -sf ../OPI/lib/libOPI.$LIBSUFFIX .
fi
cd ..
# Create the include directory if it does not exist
if [[ ! -d "include" ]]; then
mkdir include
fi
# Create the links to includes needed by NEPTUNE
cd include || exit
ln -sf ../libslam/include/SLAM .
if [[ "$ENABLE_OPI_SUPPORT" == "ON" ]]; then
ln -sf ../OPI/include/OPI .
fi
cd ..
# Create the build directory if it does not exist
if [[ ! -d "build" ]]; then
mkdir build
else
rm -rf build/*
fi
cd build || exit
echo "Updating cmake"
cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_Fortran_COMPILER=$Fortran_COMPILER -DENABLE_OPI_SUPPORT=$ENABLE_OPI_SUPPORT -DSKIP_MSIS_2=ON -DENABLE_PFUNIT=$ENABLE_PFUNIT -DCMAKE_POLICY_VERSION_MINIMUM=3.5 "$GENERATOR_FLAGS" ../
echo "Building NEPTUNE"
cmake --build .
cmake --install .
if [[ $? -ne 0 ]]; then
echo "Could not build NEPTUNE. Exiting."
exit $?
fi
echo "Leaving NEPTUNE"
cd ../work || exit
if [[ "$OSTYPE" == "msys"* || "$OSTYPE" == "MINGW"* ]]; then
ln -sf ../bin/neptune-sa.exe . || exit
ln -sf ../bin/libneptune.dll . || exit
ln -sf ../lib/libneptune.dll.a . || exit
ln -sf ../libslam/lib/libslam-Fortran.dll . || exit
ln -sf ../libslam/lib/libslam-Fortran.dll.a . || exit
else
ln -sf ../bin/neptune-sa . || exit
fi
cd ..
echo "Done"