-
Notifications
You must be signed in to change notification settings - Fork 19
/
configure.ac
294 lines (271 loc) · 10.7 KB
/
configure.ac
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# -----------------------------------------------------------------------
# Copyright (c) 2011-2024 Remko Scharroo
# See LICENSE.TXT file for copying and redistribution conditions.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program 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 Lesser General Public License for more details.
# -----------------------------------------------------------------------
#
# Run GNU autoconf to produce a configure script from this input.
# -----------------------------------------------------------------
# -----------------------------------------------------------------
# Define and show package version
# -----------------------------------------------------------------
AC_INIT([RADS],[4.7.0],[[email protected]])
AC_PREREQ([2.72])
AC_MSG_NOTICE([AC_PACKAGE_NAME, version AC_PACKAGE_VERSION])
# -----------------------------------------------------------------
# Check for this file before proceeding
# -----------------------------------------------------------------
AC_CONFIG_SRCDIR(src/rads.f90)
# -----------------------------------------------------------------
# Set some defaults
# -----------------------------------------------------------------
AC_PREFIX_DEFAULT(`pwd`)
AC_CANONICAL_TARGET
# -----------------------------------------------------------------
# Specify user options
# -----------------------------------------------------------------
AC_ARG_WITH([nf-config], [ --with-nf-config=fullpath Full path to nf-config (or nc-config) [[auto]]], nf_config=$withval)
AC_ARG_WITH([netcdf-inc], [ --with-netcdf-inc=dir Specify location of the NetCDF include file [[auto]]])
AC_ARG_WITH([netcdf-lib], [ --with-netcdf-lib=dir:dir Specify location of the NetCDF library. Use colon-separator if Fortran library is in separate directory [[auto]]])
AC_ARG_ENABLE([debug], [ --enable-debug Compile with debugging options [[off]]])
AC_ARG_ENABLE([devel], [ --enable-devel Compile developer tools [[off]]])
# -----------------------------------------------------------------
# Process user options
# -----------------------------------------------------------------
AC_MSG_NOTICE([checking user options])
configure_options="`AS_ECHO(["$ac_configure_args"]) | sed "s/^ //; s/\'//g"`" #'
AC_SUBST(CONFIGURE_OPTIONS, $configure_options)
# -----------------------------------------------------------------
# Switch for debugging
# -----------------------------------------------------------------
AC_MSG_CHECKING([whether debugging is desired])
if ! test "x$enable_debug" = "xyes" ; then
enable_debug=no
ac_cv_prog_cc_g=no
ac_cv_prog_fc_g=no
fi
AC_MSG_RESULT([$enable_debug])
# -----------------------------------------------------------------
# Switch for developers only
# -----------------------------------------------------------------
AC_MSG_CHECKING([whether developer tools are desired])
if ! test "x$enable_devel" = "xyes" ; then
enable_devel=no
fi
AC_MSG_RESULT([$enable_devel])
# -----------------------------------------------------------------
# Default settings come from nf-config
# -----------------------------------------------------------------
AC_PATH_PROGS([nf_config], [nf-config] [nc-config], [$with_nf_config])
# -----------------------------------------------------------------
# Find Fortran 90 compilers.
# -----------------------------------------------------------------
# If F90 is set, and FC isn't, then set FC to whatever F90 was set to.
# Otherwise set it to what NetCDF was compiled with
AC_MSG_CHECKING([for Fortran 90 compiler])
if test "${F90+set}" = "set"; then
F90=$F90
elif test "${FC+set}" = "set"; then
F90=$FC
elif ! test "x$nf_config" = "x"; then
F90=`$nf_config --fc`
F90=`basename $F90`
fi
AC_MSG_RESULT([$F90])
# On solaris, f95 comes before gfortran.
case "$host" in
*solaris*) F90G="f95 f90 gfortran" ;;
*) F90G="gfortran f95 f90" ;;
esac
F90S="xlf90 fort xlf95 ifort ifc efc pgf95 lf95 $F90G xlf90 pgf90 epcf90"
# Find a fortran 90 compiler, if requested.
AC_MSG_NOTICE([finding Fortran 90 compiler])
AC_PROG_FC($F90 $F90S)
F90=$FC
if test "${FC+set}" = set && test "x$FC" = x; then
AC_MSG_ERROR([Cannot find F90 compiler. Cannot continue.])
fi
# -----------------------------------------------------------------
# Learn more about the Fortran 90 compiler
# -----------------------------------------------------------------
AC_MSG_NOTICE([setting up Fortran 90])
# Find out various additions needed to FCFLAGS to make the compiler
# run with .f90, free-form, 132-byte length, or module inclusion.
AC_LANG_PUSH(Fortran)
AC_FC_SRCEXT(f90)
AC_FC_FREEFORM
AC_FC_LINE_LENGTH(132)
AC_FC_MODULE_FLAG
AC_FC_FUNC("FC_name",FC_name)
AC_LANG_POP(Fortran)
AC_SUBST(MOD_FLAG, ${ac_cv_fc_module_flag})
AC_SUBST(FC_name)
# Check if the fortran 90 compiler can compile a simple test file.
AC_MSG_CHECKING([if $FC can handle Fortran 90])
cat <<EOF >conftest.f90
program foo
real, parameter :: pi = 3.141592654
end program
EOF
doit='$FC $FCFLAGS conftest.f90 -o conftest.exe'
if AC_TRY_EVAL(doit); then
AC_MSG_RESULT([yes])
else
AC_MSG_ERROR([Cannot use $F90 to compile Fortran 90 code. Cannot continue.])
fi
rm -rf conftest.*
# -----------------------------------------------------------------
# Additional flags for GNU compilers (for developers only)
# -----------------------------------------------------------------
AC_MSG_CHECKING([for additional compiler flags (for developers)])
opt=
if test "x$enable_devel" = "xyes"; then
if test "x$ac_cv_f77_compiler_gnu" = "xyes" ; then
opt=" -Wall -Wimplicit"
fi
# Version 4.* uses -Wtabs, Version 5.* (and later?) uses -Wno-tabs
case "$FC" in
gfortran*) $FC --version | grep -q " 4."
if test $? == 1 ; then
opt=" -Wall -Wno-tabs -fimplicit-none"
else
opt=" -Wall -Wtabs -fimplicit-none"
fi ;;
ifort*) opt=" -warn" ;;
esac
fi
FCFLAGS=$FCFLAGS$opt
AC_MSG_RESULT([$opt])
if test "x$enable_devel" = "xno"; then
ALTIM=
DEVEL_DIRS=
DEVEL_OBJS=
DEVEL_FLAGS=
INSTALL_C=
else
DEVEL_DIRS="devel"
DEVEL_OBJS='${ALTIM}/src/rssubs/tpj_subs.o ${ALTIM}/src/rssubs/solar_subs.o'
DEVEL_FLAGS=" -I../devel $MOD_FLAG"'${ALTIM}/include'
INSTALL_C=" -C"
fi
AC_SUBST(ALTIM)
AC_SUBST(DEVEL_DIRS)
AC_SUBST(DEVEL_OBJS)
AC_SUBST(DEVEL_FLAGS)
# -----------------------------------------------------------------
# Allow user to set --with-netcdf-inc and/or --with-netcdf-lib
# -----------------------------------------------------------------
AC_MSG_CHECKING([for NetCDF includes])
if ! test "x$with_netcdf_inc" = "x" ; then
NETCDF_INC=$MOD_FLAG$with_netcdf_inc
elif test -x "$nf_config" ; then
NETCDF_INC=$MOD_FLAG`$nf_config --includedir`
else
NETCDF_INC=$MOD_FLAG/usr/local/inc
fi
AC_MSG_RESULT([$NETCDF_INC])
AC_SUBST(NETCDF_INC)
AC_MSG_CHECKING([for NetCDF libraries])
if ! test "x$with_netcdf_lib" = "x" ; then
NETCDF_LIB="-L"`echo $with_netcdf_lib | sed "s=:= -L="`" -lnetcdf"
doit="find "`echo $with_netcdf_lib | sed "s=:= ="`" -name libnetcdff*"
if test `$doit|wc -l` -ne 0; then
NETCDF_LIB="${NETCDF_LIB}f -lnetcdf"
fi
elif test -x "$nf_config" ; then
NETCDF_LIB=`$nf_config --flibs`
else
NETCDF_LIB=-L/usr/local/lib -lnetcdf -lnetcdff
fi
AC_MSG_RESULT([$NETCDF_LIB])
AC_SUBST(NETCDF_LIB)
# -----------------------------------------------------------------
# Try to compile simple program with NetCDF
# -----------------------------------------------------------------
AC_MSG_CHECKING([if $FC can compile a simple NetCDF program])
cat <<EOF > conftest.f90
program foo
use typesizes
use netcdf
integer :: i = 0, j
write (*,"(a)") nf90_inq_libvers()
if (i == 1) j = nf90_def_var_deflate (0, 0, 0, 0, 0)
end program
EOF
doit="$FC $FCFLAGS conftest.f90 -o conftest.exe $NETCDF_INC $NETCDF_LIB"
if AC_TRY_EVAL(doit); then
AC_MSG_RESULT([yes])
NETCDF_VERS=`./conftest.exe`
AC_MSG_RESULT([Succeeded to compile Fortran 90 code with NetCDF version $NETCDF_VERS])
rm -f ./conftest.exe
else
AC_MSG_WARN([no])
echo $doit
echo "========================================================"
echo "Could not compile simple Fortran 90 program with NetCDF."
echo "One or more of the next problems occurred:"
echo "- The directory/directories containing libnetcdf/libnetcdff"
echo " library/libraries were not/wrongly identified. Use the"
echo " --with-netcdf-lib=DIR[:DIR] option to specify the proper"
echo " directory/directories."
echo "- The directory containing netcdf.mod was not/wrongly"
echo " identified. Use the --with-netcdf-inc=DIR option to"
echo " specify the proper directory."
echo "- The NetCDF library pointed to was not compiled with"
echo " Fortran 90 support. Recompile the NetCDF library with the"
echo " configuration flag --enable-f90"
echo "- Your compiler $FC does not properly compile Fortran 90 code."
echo " Find another compiler and specify it on the command line"
echo " using FC=<compilername>."
echo "- Your NetCDF Fortran library is too old. Use version 4.3"
echo " or later."
echo "========================================================"
exit 1
fi
# -----------------------------------------------------------------
# Allow user to set --with-lapack-lib
# -----------------------------------------------------------------
AC_MSG_CHECKING([for lapack options (for developers)])
LAPACK_LIB=
if test "x$with_devel" = "xyes" ; then
case $build_os in
*darwin*) LAPACK_LIB="-Wl,-framework,Accelerate" ;;
*) LAPACK_LIB="-llapack -lblas" ;;
esac
fi
AC_MSG_RESULT([$LAPACK_LIB])
AC_SUBST(LAPACK_LIB)
# -----------------------------------------------------------------
# Do we have big or little endian
# -----------------------------------------------------------------
AC_C_BIGENDIAN(LITTLE_ENDIAN="false",LITTLE_ENDIAN="true",LITTLE_ENDIAN="true",LITTLE_ENDIAN="true")
AC_SUBST(LITTLE_ENDIAN)
# -----------------------------------------------------------------
# Find other utilities
# -----------------------------------------------------------------
AC_MSG_NOTICE([finding other utilities])
AC_PROG_LN_S
AC_PROG_RANLIB
AC_PROG_INSTALL
# -----------------------------------------------------------------
# Add -C option to install (developers only)
# -----------------------------------------------------------------
INSTALL_DATA="${INSTALL_DATA}${INSTALL_C}"
INSTALL_PROGRAM="${INSTALL_PROGRAM}${INSTALL_C}"
INSTALL_SCRIPT="${INSTALL_SCRIPT}${INSTALL_C}"
INSTALL_DIR='${INSTALL} -d'
AC_SUBST(INSTALL_DIR)
# -----------------------------------------------------------------
# Substitute in .in files
# -----------------------------------------------------------------
AC_CONFIG_FILES([config.mk src/rads-config doc/manuals/rads_config.tex])
AC_OUTPUT