-
Notifications
You must be signed in to change notification settings - Fork 30
/
build_glm.sh
executable file
·277 lines (255 loc) · 5.78 KB
/
build_glm.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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/bin/sh
if [ "$GLM_CONFIGURED" != "true" ] ; then
. ./GLM_CONFIG
fi
case `uname` in
"Darwin"|"Linux"|"FreeBSD")
export OSTYPE=`uname -s`
;;
MINGW*)
export OSTYPE="Msys"
;;
esac
if [ "$OSTYPE" = "FreeBSD" ] ; then
export FC=flang
export CC=clang
export MAKE=gmake
else
export FC=gfortran
export CC=gcc
export MAKE=make
fi
ARGS=""
while [ $# -gt 0 ] ; do
ARGS="$ARGS $1"
case $1 in
--debug)
export DEBUG=true
;;
--mdebug)
export MDEBUG=true
;;
--fence)
export FENCE=true
;;
--fabm)
export FABM=true
;;
--gfort)
export FC=gfortran
;;
--ifort)
export FC=ifort
;;
--flang)
export FC=flang
;;
--no-gui)
export WITH_PLOTS=false
export WITH_XPLOTS=false
;;
*)
;;
esac
shift
done
if [ "$OSTYPE" = "Darwin" ] ; then
if [ "$HOMEBREW" = "" ] ; then
brew -v > /dev/null 2>&1
if [ $? != 0 ] ; then
which port > /dev/null 2>&1
if [ $? != 0 ] ; then
echo no ports and no brew
else
export MACPORTS=true
fi
else
export HOMEBREW=true
fi
fi
start_sh="$(ps -p "$$" -o command= | awk '{print $1}')"
if [ "$start_sh" = "/bin/sh" ] ; then
echo Restart using bash because MacOS cant use /bin/sh
/bin/bash $0 $ARGS
exit $?
fi
fi
# see if FC is defined, if not look for gfortran at least v8
if [ "$FC" = "" ] ; then
gfortran -v > /dev/null 2>&1
if [ $? != 0 ] ; then
export FC=ifort
else
VERS=`gfortran -dumpversion | cut -d\. -f1`
if [ $VERS -ge 8 ] ; then
export FC=gfortran
else
gfortran-8 -v > /dev/null 2>&1
if [ $? != 0 ] ; then
export FC=ifort
else
export gfortran-8
fi
fi
fi
fi
if [ "$FC" = "ifort" ] ; then
if [ "$OSTYPE" = "Linux" ] ; then
start_sh="$(ps -p "$$" -o command= | awk '{print $1}')"
# ifort config scripts wont work with /bin/sh
# so we restart using bash
if [ "$start_sh" = "/bin/sh" ] ; then
echo Restart using bash because ifort cant use /bin/sh
/bin/bash $0 $ARGS
exit $?
fi
fi
if [ -x /opt/intel/setvars.sh ] ; then
. /opt/intel/setvars.sh
elif [ -d /opt/intel/oneapi ] ; then
. /opt/intel/oneapi/setvars.sh
elif [ -d /opt/intel/bin ] ; then
. /opt/intel/bin/compilervars.sh intel64
fi
which ifort > /dev/null 2>&1
if [ $? != 0 ] ; then
echo ifort compiler requested, but not found
exit 1
fi
fi
export F77=$FC
export F90=$FC
export F95=$FC
export MPI=OPENMPI
if [ "$AED2DIR" = "" ] ; then
export AED2DIR=../libaed2
fi
if [ "$PLOTDIR" = "" ] ; then
export PLOTDIR=../libplot
fi
if [ "$UTILDIR" = "" ] ; then
export UTILDIR=../libutil
fi
if [ "$FABM" = "true" ] ; then
if [ ! -d $FABMDIR ] ; then
echo "FABM directory not found"
export FABM=false
else
which cmake > /dev/null 2>&1
if [ $? != 0 ] ; then
echo "cmake not found - FABM cannot be built"
export FABM=false
fi
fi
if [ "$FABM" = "false" ] ; then
echo build with FABM requested but FABM cannot be built
exit 1
fi
export FABMHOST=glm
cd ${FABMDIR}
if [ ! -d build ] ; then
mkdir build
fi
cd build
export FFLAGS+=-fPIC
if [ "${USE_DL}" = "true" ] ; then
cmake ${FABMDIR}/src -DBUILD_SHARED_LIBS=1 || exit 1
else
cmake ${FABMDIR}/src || exit 1
fi
${MAKE} || exit 1
fi
if [ "${AED2}" = "true" ] ; then
cd "${AED2DIR}"
${MAKE} || exit 1
cd ..
if [ "${AED2PLS}" != "" ] ; then
if [ -d "${AED2PLS}" ] ; then
cd "${AED2PLS}"
${MAKE} || exit 1
cd ..
fi
fi
fi
if [ "${AED}" = "true" ] ; then
echo "build libaed-water"
cd "${CURDIR}/../libaed-water"
${MAKE} || exit 1
DAEDWATDIR=`pwd`
if [ -d "${CURDIR}/../libaed-benthic" ] ; then
echo build libaed-benthic
cd "${CURDIR}/../libaed-benthic"
${MAKE} || exit 1
DAEDBENDIR=`pwd`
fi
if [ -d "${CURDIR}/../libaed-demo" ] ; then
echo build libaed-demo
cd "${CURDIR}/../libaed-demo"
${MAKE} || exit 1
DAEDDMODIR=`pwd`
fi
if [ -d "${CURDIR}/../libaed-riparian" ] ; then
echo build libaed-riparian
cd "${CURDIR}/../libaed-riparian"
${MAKE} || exit 1
DAEDRIPDIR=`pwd`
fi
if [ -d "${CURDIR}/../libaed-light" ] ; then
echo build libaed-light
cd "${CURDIR}/../libaed-light"
${MAKE} || exit 1
DAEDLGTDIR=`pwd`
fi
if [ -d "${CURDIR}/../libaed-dev" ] ; then
if [ -d "${CURDIR}/../phreeqcrm" ] ; then
PHREEQDIR="${CURDIR}/../phreeqcrm"
fi
echo build libaed-dev
cd "${CURDIR}/../libaed-dev"
${MAKE} PHREEQDIR=$PHREEQDIR || exit 1
DAEDDEVDIR=`pwd`
fi
fi
if [ -d "${UTILDIR}" ] ; then
echo "making libutil"
cd "${UTILDIR}"
${MAKE} || exit 1
cd "${CURDIR}/.."
fi
if [ "$OSTYPE" = "FreeBSD" ] ; then
echo not making flang extras
# cd ancillary/freebsd
# ./fetch.sh
# ${MAKE} || exit 1
elif [ "$OSTYPE" = "Msys" ] ; then
if [ ! -d ancillary/windows/msys ] ; then
echo making windows ancillary extras
cd ancillary/windows/Sources
./build_all.sh || exit 1
fi
fi
if [ "$WITH_PLOTS" = "true" ] ; then
echo "making libplot"
cd "${PLOTDIR}"
${MAKE} || exit 1
fi
cd "${CURDIR}"
if [ -f obj/aed_external.o ] ; then
/bin/rm obj/aed_external.o
fi
# Update versions in resource files
VERSION=`grep GLM_VERSION src/glm.h | cut -f2 -d\"`
cd "${CURDIR}/win"
${CURDIR}/vers.sh $VERSION
#cd ${CURDIR}/win-dll
#${CURDIR}/vers.sh $VERSION
cd "${CURDIR}"
${MAKE} AEDBENDIR=$DAEDBENDIR AEDDMODIR=$DAEDDMODIR || exit 1
if [ "${DAEDDEVDIR}" != "" ] ; then
if [ -d "${DAEDDEVDIR}" ] ; then
echo now build plus version
/bin/rm obj/aed_external.o
${MAKE} glm+ AEDBENDIR=$DAEDBENDIR AEDDMODIR=$DAEDDMODIR AEDRIPDIR=$DAEDRIPDIR AEDLGTDIR=$DAEDLGTDIR AEDDEVDIR=$DAEDDEVDIR PHREEQDIR=$PHREEQDIR || exit 1
fi
fi
exit 0