forked from oorb/oorb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·252 lines (216 loc) · 7.96 KB
/
configure
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
#!/bin/bash
#
#====================================================================#
# #
# Copyright 2002,2003,2004,2005,2006,2007,2008,2009 #
# Mikael Granvik, Jenni Virtanen, Karri Muinonen, Teemu Laakso, #
# Dagmara Oszkiewicz #
# #
# This file is part of OpenOrb. #
# #
# OpenOrb is free software: you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# OpenOrb is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
# General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with OpenOrb. If not, see <http://www.gnu.org/licenses/>. #
# #
#====================================================================#
#
# Script for selecting the compiler and setting general options.
#
# Author: MG
# Version: 2009-11-13
#
# Extract command-line options
option_to_varname()
{
# takes an option such as --with-foo as an argument
# and returns the corresponding variable name (FOO)
key="${1%=*}"
key="${key#--}"
key="${key#with-}"
echo "$key" | awk '{print toupper($0)}'
}
PREFIX='/usr/local'
PYOORB=0
PYTHON=python
F2PY="f2py"
PYTEST="py.test"
ADDLIBS="-llapack"
ADDOPTS=
COVERAGE=
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case "$key" in
# Simple options with an argument
--prefix=*|--with-python=*|--with-f2py=*|--with-pytest=*)
eval "$(option_to_varname $key)='${key#*=}'"
shift;
;;
--with-pyoorb)
eval "$(option_to_varname $key)=1"
shift;
;;
--coverage)
COVERAGE=on
ADDLIBS="$ADDLIBS -lgcov"
ADDOPTS="$ADDOPTS -coverage"
shift;
;;
--with-compiler-options=*)
ADDOPTS="$ADDOPTS ${key#*=}"
shift;
;;
*)
POSITIONAL+=("$1")
shift;
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
# --coverage only works with gfortran; verify gfortran is being used
if [[ ! -z $COVERAGE && $1 != gfortran ]]; then
echo "Error: --coverage option only works with the gfortran compiler".
exit -1
fi
# Make sure $PREFIX is an absolute path
if [[ $PREFIX != /* ]]; then
echo "Argument to --prefix must be an absolute path beginning with a '/'"
exit -1
fi
# Store install prefix into a fortran variable PREFIX
# Fold the path to fit into FORTRAN's line length limit
prefix_h="prefix.h"
rm -f "$prefix_h"
echo '!!!!! GENERATED BY configure SCRIPT; DO NOT EDIT !!!!!' >> "$prefix_h"
echo 'CHARACTER(len=FNAME_LEN) :: PREFIX = "" &' >> "$prefix_h"
echo "$PREFIX" | fold -b -w 60 | sed 's|.*| \& // "&" \&|' >> "$prefix_h"
echo ' & // ""' >> "$prefix_h"
include_file=Makefile.include
rm -f $include_file
if [[ $1 == absoft ]] ; then
echo 'FC = $(FC_ABSOFT)' > $include_file
if [[ $2 == opt ]] ; then
echo 'FCOPTIONS = $(FCOPTIONS_OPT_ABSOFT)' >> $include_file
else
echo 'FCOPTIONS = $(FCOPTIONS_DEB_ABSOFT)' >> $include_file
fi
echo 'FC_INC = $(FC_INC_ABSOFT)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_ABSOFT)' >> $include_file
elif [[ $1 == compaq ]] ; then
echo 'FC = $(FC_COMPAQ)' > $include_file
if [[ $2 == opt ]] ; then
echo 'FCOPTIONS = $(FCOPTIONS_OPT_COMPAQ)' >> $include_file
else
echo 'FCOPTIONS = $(FCOPTIONS_DEB_COMPAQ)' >> $include_file
fi
echo 'FC_INC = $(FC_INC_COMPAQ)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_COMPAQ)' >> $include_file
elif [[ $1 == ibm ]] ; then
if [[ $2 == opt ]] ; then
echo 'FC = $(FC_SER_IBM)' > $include_file
echo 'FCOPTIONS = $(FCOPTIONS_OPT_IBM)' >> $include_file
elif [[ $2 == par ]] ; then
echo 'FC = $(FC_PAR_IBM)' > $include_file
echo 'FCOPTIONS = $(FCOPTIONS_PAR_IBM)' >> $include_file
else
echo 'FC = $(FC_SER_IBM)' > $include_file
echo 'FCOPTIONS = $(FCOPTIONS_DEB_IBM)' >> $include_file
fi
echo 'FC_INC = $(FC_INC_IBM)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_IBM)' >> $include_file
elif [[ $1 == intel ]] ; then
echo 'FC = $(FC_INTEL)' > $include_file
if [[ $2 == opt ]] ; then
echo 'FCOPTIONS = $(FCOPTIONS_OPT_INTEL)' >> $include_file
else
echo 'FCOPTIONS = $(FCOPTIONS_DEB_INTEL)' >> $include_file
fi
echo 'FC_INC = $(FC_INC_INTEL)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_INTEL)' >> $include_file
echo 'F2PY_FCOMPILER = $(F2PY_FCOMPILER_INTEL)' >> $include_file
elif [[ $1 == lahey ]] ; then
echo 'FC = $(FC_LAHEY)' > $include_file
if [[ $2 == opt ]] ; then
echo 'FCOPTIONS = $(FCOPTIONS_OPT_LAHEY)' >> $include_file
else
echo 'FCOPTIONS = $(FCOPTIONS_DEB_LAHEY)' >> $include_file
fi
echo 'FC_INC = $(FC_INC_LAHEY)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_LAHEY)' >> $include_file
elif [[ $1 == sun ]] ; then
echo 'FC = $(FC_SUN)' > $include_file
if [[ $2 == opt ]] ; then
echo 'FCOPTIONS = $(FCOPTIONS_OPT_SUN)' >> $include_file
elif [[ $2 == par ]] ; then
echo 'FCOPTIONS = $(FCOPTIONS_PAR_SUN)' >> $include_file
else
echo 'FCOPTIONS = $(FCOPTIONS_DEB_SUN)' >> $include_file
fi
echo 'FC_INC = $(FC_INC_SUN)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_SUN)' >> $include_file
elif [[ $1 == g95 ]] ; then
echo 'FC = $(FC_G95)' > $include_file
if [[ $2 == opt ]] ; then
echo 'FCOPTIONS = $(FCOPTIONS_OPT_G95)' >> $include_file
else
echo 'FCOPTIONS = $(FCOPTIONS_DEB_G95)' >> $include_file
fi
echo 'FC_INC = $(FC_INC_G95)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_G95)' >> $include_file
elif [[ $1 == gfortran ]] ; then
echo 'FC = $(FC_GFORTRAN)' > $include_file
if [[ $2 == opt ]] ; then
echo 'FCOPTIONS = $(FCOPTIONS_OPT_GFORTRAN)'"$ADDOPTS" >> $include_file
else
echo 'FCOPTIONS = $(FCOPTIONS_DEB_GFORTRAN)'"$ADDOPTS" >> $include_file
fi
echo 'FC_INC = $(FC_INC_GFORTRAN)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_GFORTRAN)' >> $include_file
echo 'F2PY_FCOMPILER = $(F2PY_FCOMPILER_GFORTRAN)' >> $include_file
elif [[ $1 == conda ]] ; then
echo "FC = ${FC}" > $include_file
echo "FCOPTIONS = $FFLAGS $LDFLAGS -cpp ""$ADDOPTS" >> $include_file
echo 'FC_INC = $(FC_INC_GFORTRAN)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_GFORTRAN)' >> $include_file
echo 'F2PY_FCOMPILER = $(F2PY_FCOMPILER_GFORTRAN)' >> $include_file
elif [[ $1 == flang ]] ; then
echo 'FC = $(FC_FLANG)' > $include_file
if [[ $2 == opt ]] ; then
echo 'FCOPTIONS = $(FCOPTIONS_OPT_FLANG)'"$ADDOPTS" >> $include_file
else
echo 'FCOPTIONS = $(FCOPTIONS_DEB_FLANG)'"$ADDOPTS" >> $include_file
fi
echo 'FC_INC = $(FC_INC_FLANG)' >> $include_file
echo 'FC_SHARED = $(FC_SHARED_FLANG)' >> $include_file
echo 'F2PY_FCOMPILER = $(F2PY_FCOMPILER_FLANG)' >> $include_file
else
echo Erroneous compiler: $1
rm -f $include_file
fi
# Options for liboorb and Python wrappers.
SYSTEM=`uname -s`
if [[ ${SYSTEM} == "Linux" ]] ; then
echo 'LIBEXT = so' >> $include_file
elif [[ ${SYSTEM} == "Darwin" ]] ; then
echo 'LIBEXT = dylib' >> $include_file
else
echo 'LIBEXT = so' >> $include_file
fi
# Store PREFIX for use by 'make install'
echo "PREFIX=$PREFIX" >> "$include_file"
# Store the name of the python and f2py executables
echo "PYOORB=$PYOORB" >> "$include_file"
echo "PYTHON=$PYTHON" >> "$include_file"
echo "F2PY=$F2PY" >> "$include_file"
echo "PYTEST=$PYTEST" >> "$include_file"
echo "ADDLIBS=$ADDLIBS" >> "$include_file"