-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild_elcom.sh
More file actions
executable file
·242 lines (208 loc) · 6 KB
/
Copy pathbuild_elcom.sh
File metadata and controls
executable file
·242 lines (208 loc) · 6 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
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
#!/bin/sh
# CURDIR should be the directory of the project we are building
export CURDIR=`pwd`/ELCOM
# CWD should be the tools directory in which CURDIR lives
export CWD=`dirname ${CURDIR}`
if [ ! -d ELCOM ] ; then
echo "no ELCOM directory"
exit 1
fi
export DEBUG=false
export FC=gfortran
export CC=gcc
export MAKE=make
export WITH_AED=true
export WITH_AED_PLUS=false
if [ -d ${CWD}/libaed-dev ] ; then
export WITH_AED_PLUS=true
fi
ARGS=""
while [ $# -gt 0 ] ; do
ARGS="$ARGS $1"
case $1 in
--check)
export WITH_CHECKS=true
;;
--debug)
export DEBUG=true
;;
--fence)
export FENCE=true
;;
--with-aed)
export WITH_AED=true
;;
--without-aed)
export WITH_AED=false
;;
--with-aed-plus)
export WITH_AED=true
export WITH_AED_PLUS=true
;;
--without-aed-plus)
export WITH_AED=false
export WITH_AED_PLUS=false
;;
--ifx)
export FC=ifx
;;
--ifort)
export FC=ifort
;;
--gfort)
export FC=gfortran
;;
--clang)
export CC=clang
;;
--flang)
export FC=flang
;;
--auto-prereq)
export AUTO_PREQ=true
;;
--help)
echo "build_elcom accepts the following flags:"
echo " --debug : build with debugging symbols"
echo " --gfort : use the gfortran compiler"
echo " --ifort : use the older intel fortran compiler"
echo " --ifx : use the newer intel fortran compiler"
echo " --clang : use the clang C/C++ compiler"
echo " --flang : use the flang fortran compiler"
echo
echo " --with-aed : build with aed enabled"
echo " --without-aed : build without aed enabled"
echo " --with-aed-plus : build with aed and aed-plus enabled"
echo " --without-aed-plus : build without aed and aed-plus enabled"
echo
echo " --auto-prereq : if needed, also build ancillary pre-requirments"
echo
exit 0
;;
*)
echo unknown arg \"$1\" ignored
;;
esac
shift
done
export F77=$FC
export F90=$FC
export F95=$FC
. ${CWD}/build_env.inc
export HDF5LIB=$NETCDFHOME/lib
#export HDF5LIBNAME="-lhdf5"
export NETCDFINC=$NETCDFHOME/include
export NETCDFINCL=${NETCDFINC}
export NETCDFLIBDIR=$NETCDFHOME/lib
export NETCDFLIB=${NETCDFLIBDIR}
if [ "$OSTYPE" = "Darwin" ] ; then
if [ "${HOMEBREW}" = "true" ] ; then
export NETCDFLIBNAME="-lnetcdff -L/opt/homebrew/lib -lnetcdf"
else
export NETCDFLIBNAME="-lnetcdff -L/opt/local/lib -lnetcdf"
fi
else
# force the link to use the static version of the netcdff library to avoid
# runtime confusion with gfortran version
export NETCDFLIBNAME="-Xlinker -l:libnetcdff.a -lnetcdf"
fi
#===============================================================================
if [ "$WITH_AED" = "true" ] ; then
. ${CWD}/build_aedlibs.inc
fi
#===============================================================================
export LIB_PRE=lib
if [ "$OSTYPE" = "Msys" ] ; then
export LIB_EXT=a
else
export LIB_EXT=so
fi
export INCLUDES="-I${NETCDFINCL}"
export BUILDDATE=`date -u +%Y%m%d-%H%MUTC`
PARAMS=""
echo build elcom_aed
cd ${CURDIR}/elcom_aed
if [ "$WITH_AED_PLUS" = "true" ] ; then
${MAKE} -f Makefile WITH_AED_PLUS=1 AEDWATDIR=$DAEDWATDIR \
AEDBENDIR=$DAEDBENDIR AEDDMODIR=$DAEDDMODIR \
AEDRIPDIR=$DAEDRIPDIR AEDLGTDIR=$DAEDLGTDIR \
AEDDEVDIR=$DAEDDEVDIR PHREEQDIR=$PHREEQDIR \
AEDAPIDIR=$DAEDAPIDIR || exit 1
else
${MAKE} -f Makefile WITH_AED_PLUS=0 AEDWATDIR=$DAEDWATDIR \
AEDBENDIR=$DAEDBENDIR AEDDMODIR=$DAEDDMODIR \
AEDAPIDIR=$DAEDAPIDIR || exit 1
fi
DELCAEDDIR=`pwd`
PARAMS="${PARAMS} ELCAEDDIR=${DELCAEDDIR}"
echo build cwr_utils
cd ${CURDIR}/cwr_utils
${MAKE} -f Makefile || exit 1
DCWRUTLSDIR=`pwd`
PARAMS="${PARAMS} CWRUTLSDIR=${DCWRUTLSDIR}"
echo build libcwrcommon
cd ${CURDIR}/libcwrcommon
${MAKE} -f Makefile || exit 1
DCWRCMMNDIR=`pwd`
PARAMS="${PARAMS} CWRCMMNDIR=${DCWRCMMNDIR}"
echo build caedym_utils
cd ${CURDIR}/caedym_utils
${MAKE} -f Makefile || exit 1
DCAEDYMUDIR=`pwd`
PARAMS="${PARAMS} CAEDYMUDIR=${DCAEDYMUDIR}"
echo build elcom_sed
cd ${CURDIR}/elcom_sed
${MAKE} -f Makefile || exit 1
if [ -x ${CURDIR}/external/FoX-4.1.2/FoX-config ] ; then
echo FoX already built
else
echo build FoX
cd ${CURDIR}/external/FoX-4.1.2
./configure
${MAKE} -f Makefile || exit 1
fi
echo build elcom_utils
cd ${CURDIR}/elcom_utils
${MAKE} -f Makefile || exit 1
DECLUTLDIR=`pwd`
PARAMS="${PARAMS} ECLUTLDIR=${ECLUTLDIR}"
echo build elcom_src_v3
cd ${CURDIR}/elcom_src_v3
${MAKE} -f Makefile || exit 1
echo build pre_elcom
cd ${CURDIR}/utilities/pre_elcom
${MAKE} -f Makefile || exit 1
#============================ Linux ===================================
if [ "$OSTYPE" = "Linux" ] ; then
if [ $(lsb_release -is) = Ubuntu ] ; then
BINPATH=../binaries/ubuntu/$(lsb_release -rs)
else
BINPATH=../binaries/RedHat/$(lsb_release -rs)
fi
fi
#============================ MacOS ===================================
if [ "$OSTYPE" = "Darwin" ] ; then
MOSLINE=`grep 'SOFTWARE LICENSE AGREEMENT FOR ' '/System/Library/CoreServices/Setup Assistant.app/Contents/Resources/en.lproj/OSXSoftwareLicense.rtf'`
MOSNAME=`echo ${MOSLINE} | awk -F 'macOS ' '{print $NF}' | tr -d '\\' | tr ' ' '_'`
BINPATH="../binaries/macos/${MOSNAME}"
fi
#============================ Msys ===================================
if [ "$OSTYPE" = "Msys" ] ; then
BINPATH="../binaries/windows"
fi
#============================= All ====================================
ISODATE=`date +%Y%m%d`
EXTN="_$ISODATE"
cd ${CURDIR}
echo Installing in ${BINPATH}
if [ ! -d ${BINPATH} ] ; then
mkdir -p ${BINPATH}
fi
cp elcom_src_v3/elcom ${BINPATH}/elcom${EXTN}
cp utilities/pre_elcom/pre_elcom ${BINPATH}/pre_elcom${EXTN}
if [ "$DEBUG" = "true" ] ; then
ln -fs elcom${EXTN} ${BINPATH}/elcom_latest_d
else
ln -fs elcom${EXTN} ${BINPATH}/elcom_latest
fi
exit 0