-
Notifications
You must be signed in to change notification settings - Fork 32
/
configure.ac
413 lines (376 loc) · 12.4 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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
dnl
dnl Process this file with autoconf to produce a configure script.
dnl AC_PREREQ([2.71])
AC_INIT([cmor],[3.9.0],[[email protected]])
GIT_TAG=`cd $srcdir ; ./get_git_version.sh`
AC_CANONICAL_TARGET
echo "TARGET: "${target_os}
RTAG="none"
case ${target_os} in
linux-*)
RTAG="-Wl,-rpath="
FTAG="-Wl,-rpath="
;;
darwin*)
RTAG="-Wl,-rpath,"
FTAG="-Wl,-rpath,"
;;
esac
CMOR_VERSION=${PACKAGE_VERSION}" (commit: ${GIT_TAG})"
AC_PREFIX_DEFAULT([/usr/local/cmor])
AC_CONFIG_FILES([Makefile setup.py compile_line.txt include/cmor_locale.h])
INCFILES="include/cmor.h include/cmor_func_def.h include/cmor_md5.h `cd $srcdir ; ls include/cdTime/*.h include/cdTime/cdunifpp/*.h | tr \"\n\" \" \" `"
AC_SUBST(RTAG)
AC_SUBST(FTAG)
AC_SUBST(PATH)
AC_SUBST(NCCFLAGS)
AC_SUBST(NCLDFLAGS)
AC_SUBST(ZFLAGS)
AC_SUBST(ZLDFLAGS)
AC_SUBST(UDUNITS2FLAGS)
AC_SUBST(UDUNITS2LDFLAGS)
AC_SUBST(UUIDFLAGS)
AC_SUBST(UUIDLDFLAGS)
AC_SUBST(JSONCFLAGS)
AC_SUBST(JSONCLDFLAGS)
AC_SUBST(LIBSOURCES)
AC_SUBST(LIBSOURCESCV)
AC_SUBST(LIBFSOURCES)
AC_SUBST(FC)
AC_SUBST(FFLAGS)
AC_SUBST(FCFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(CFLAGS)
AC_SUBST(USERCFLAGS)
AC_SUBST(USERFFLAGS)
AC_SUBST(USERLDFLAGS)
AC_SUBST(INCFILES)
AC_SUBST(TEST_FORTRAN)
AC_SUBST(LIBFILES)
AC_SUBST(VERB)
AC_SUBST(MODFILES)
AC_SUBST(MACROS)
AC_SUBST(DEBUG)
AC_SUBST(OK_COLOR)
AC_SUBST(NO_COLOR)
MACROS=""
DEBUG=""
OK_COLOR=""
NO_COLOR=""
AC_ARG_ENABLE([verbose-test],[AS_HELP_STRING([--enable-verbose-test],[enable verbose testing (default off)])])
if test "-"${enable_verbose_test} == "-yes" ; then
VERB=""
else
VERB=">/dev/null 2>/dev/null"
fi
if test "-"${enable_verbose_test} == "-yes" ; then
VERB=""
else
VERB=">/dev/null 2>/dev/null"
fi
AC_ARG_ENABLE([color],[AS_HELP_STRING([--enable-color],[enable colored output (default on)])],[
if test "x${enableval}" == "xyes" ; then
MACROS=${MACROS}" -DCOLOREDOUTPUT"
NO_COLOR="NO_COLOR2"
OK_COLOR="OK_COLOR2"
fi
],[
MACROS=${MACROS}" -DCOLOREDOUTPUT"
NO_COLOR="NO_COLOR2"
OK_COLOR="OK_COLOR2"
])
AC_ARG_ENABLE([debug],[AS_HELP_STRING([--enable-debug],[enable debug flag while commpiling (default on)])],[enable_debug=yes],[enable_debug=yes])
if test ${enable_debug} == "yes" ; then
DEBUG="-g"
fi
LIBFILES="cmor.o cmor_axes.o cmor_CV.o cmor_variables.o cmor_tables.o cdTimeConv.o cdUtil.o timeConv.o timeArith.o cmor_grids.o cmor_md5.o"
LIBFFILES="cmor_cfortran_interface.o cmor_fortran_interface.o"
dnl ##########################################################
dnl Turn on/off fortran
dnl ##########################################################
AC_ARG_ENABLE([fortran],[AS_HELP_STRING([--enable-fortran],[enable fortran api (default will try)])])
enable_fortran="-"${enable_fortran}
TEST_FORTRAN="test_fortran"
if test ${enable_fortran} == "-no" ; then
FC=""
F77=""
FFLAGS=""
FCFLAGS=""
TEST_FORTRAN=" "
MODFILES=" "
else
LIBFILES=${LIBFILES}" "${LIBFFILES}
MODFILES="cmor_users_functions.*"
fi
CDATPREFIX="--prefix=${prefix}"
MAKETESTPYTHON=" "
dnl turn on/off python
AC_ARG_WITH([cdat],[AS_HELP_STRING([--with-cdat],[enable support for cdat put path root (w/o bin/cdat)])],[],[with_cdat="no"])
with_cdatb="-"${with_cdat}
if [ test ${with_cdatb} != "-yes" ] ; then
if [ test ${with_cdatb} != "-no" ] ; then
PYTHONEXEC=${with_cdat}/bin/cdat
MAKEDEPPYTHON="python"
MAKETESTPYTHON="test_python"
CDATPREFIX="--prefix="${with_cdat}
else
PYTHONEXEC=" "
MAKEDEPPYTHON=" "
fi
else
PYTHONEXEC="cdat"
MAKEDEPPYTHON="python"
MAKETESTPYTHON="test_python"
fi
AC_ARG_WITH([python],[AS_HELP_STRING([--with-python],[enable support for python put path root (w/o bin/python)])],[],[with_python="no"])
with_pythonb="-"${with_python}
if [ test ${with_pythonb} != "-yes" ] ; then
if [ test ${with_pythonb} != "-no" ] ; then
PYTHONEXEC=${with_python}/bin/python
MAKEDEPPYTHON="python"
fi
else
PYTHONEXEC="python"
MAKEDEPPYTHON="python"
fi
AC_SUBST(CDATPREFIX)
AC_SUBST(PYTHONEXEC)
AC_SUBST(MAKEDEPPYTHON)
AC_SUBST(MAKETESTPYTHON)
dnl basic test
AC_PROG_CC
AC_PROG_CPP
AC_PROG_LN_S
AC_PROG_SED
AC_PROG_MKDIR_P
AC_PROG_RANLIB
if test ${enable_fortran} != "-no" ; then
AC_PROG_FC
AC_FC_LIBRARY_LDFLAGS
fi
LDFLAGS=${LDFLAGS}" -lm "
AC_ARG_WITH([json-c],[AS_HELP_STRING([--with-json-c],[enable support for json-c in none standard location])],[],[with_json_c="no"])
if [ test x${with_json_c} != xyes ] ; then
if [ test x${with_json_c} != xno ] ; then
JSONCFLAGS=" -I${with_json_c}/include"
if [ test ${RTAG} != "none" ] ; then
JSONCLDFLAGS=" -L${with_json_c}/lib ${RTAG}${with_json_c}/lib -ljson-c"
else
JSONCLDFLAGS=" -L${with_json_c}/lib -ljson-c"
fi
else
JSONCLDFLAGS="-ljson-c"
JSONCFLAGS=""
fi
else
JSONCLDFLAGS="-ljson-c"
JSONCFLAGS=""
fi
AC_CHECK_LIB([json-c],[json_object_new_object],[],[AC_MSG_ERROR(Could not get a working json-c)],[ ${JSONCFLAGS} ${JSONCLDFLAGS} ])
AC_ARG_WITH([uuid],[AS_HELP_STRING([--with-uuid],[enable support for uuid in none standard location])],[],[with_uuid="no"])
if [ test x${with_uuid} != xyes ] ; then
if [ test x${with_uuid} != xno ] ; then
UUIDFLAGS=" -I${with_uuid}/include"
if [ test ${RTAG} != "none" ] ; then
UUIDLDFLAGS=" -L${with_uuid}/lib ${RTAG}${with_uuid}/lib -luuid"
else
UUIDLDFLAGS=" -L${with_uuid}/lib -luuid"
fi
else
UUIDLDFLAGS="-luuid"
UUIDFLAGS=""
fi
else
UUIDLDFLAGS="-luuid"
UUIDFLAGS=""
fi
AC_CHECK_LIB([uuid],[uuid_generate],[],[AC_MSG_ERROR(Could not get a working uuid)],[ ${UUIDFLAGS} ${UUIDLDFLAGS} ])
LIBS=""
AC_ARG_WITH([udunits2],[AS_HELP_STRING([--with-udunits2],[enable support for udunits2 in none standard location])],[],[with_udunits2="no"])
if [ test x${with_udunits2} != xyes ] ; then
if [ test x${with_udunits2} != xno ] ; then
AS_IF([test -f "${with_udunits2}/include/udunits2/udunits2.h"],
[UDUNITS2FLAGS=" -I${with_udunits2}/include/udunits2"],
[UDUNITS2FLAGS=" -I${with_udunits2}/include"])
if [ test ${RTAG} != "none" ] ; then
UDUNITS2LDFLAGS=" -L${with_udunits2}/lib ${RTAG}${with_udunits2}/lib -ludunits2"
else
UDUNITS2LDFLAGS=" -L${with_udunits2}/lib -ludunits2"
fi
else
UDUNITS2FLAGS="-ludunits2"
UDUNITS2LDFLAGS=""
fi
else
UDUNITS2FLAGS="-ludunits2"
UDUNITS2LDFLAGS=""
fi
AC_CHECK_LIB([udunits2],[ut_parse],[],[AC_MSG_ERROR(Could not get a working udunits2)],[ ${UDUNITS2FLAGS} ${UDUNITS2LDFLAGS} -lm ])
LIBS=""
AC_ARG_WITH([netcdf],[AS_HELP_STRING([--with-netcdf],[enable support for NetCDF in none standard location])],[],[with_netcdf="no"])
if [ test x${with_netcdf} != xyes ]; then
if [ test x${with_netcdf} != xno ] ; then
AS_IF([test -f "${with_netcdf}/bin/nc-config"],[HAS_NCCONFIG=yes],[HAS_NCCONFIG=no])
if [ test ${HAS_NCCONFIG} == "yes" ] ; then
NCCFLAGS=`${with_netcdf}/bin/nc-config --cflags`
NCLDFLAGS=`${with_netcdf}/bin/nc-config --libs`
else
NCCFLAGS=" -I${with_netcdf}/include"
if [ test ${RTAG} != "none" ] ; then
NCLDFLAGS=" -L${with_netcdf}/lib ${RTAG}${with_netcdf}/lib -lnetcdf"
else
NCLDFLAGS=" -L${with_netcdf}/lib -lnetcdf"
fi
fi
else
NCCFLAGS="-lnetcdf"
NCLDFLAGS=""
fi
else
AC_PATH_PROG(NCCONFIG,nc-config,"no")
if [ test NCCONFIG != "no" ] ; then
NCCFLAGS=`${NCCONFIG} --cflags`
NCLDFLAGS=`${NCCONFIG} --libs`
else
NCCFLAGS="-lnetcdf"
NCLDFLAGS=""
fi
fi
LIBS=""
USERCFLAGS=${CFLAGS}
USERFFLAGS=${FFLAGS}
USERLDFLAGS=${LDFLAGS}
SV_LDFLAGS=${LDFLAGS}
SV_CFLAGS=${CFLAGS}
CFLAGS=${NCCFLAGS}
LDFLAGS=${NCLDFLAGS}
dnl ok that this point we need to see if it is NC3 or NC4
AC_CHECK_LIB([netcdf],[nc_inq_var_deflate],[HAS_NC4="yes"],[HAS_NC4="no"],[${NCFLAGS} ${NCLDFLAGS} ])
BUILD_NC3="no"
HAS_NC3="no"
OLIBS=${LIBS}
LIBS="-lnetcdf "${NCCFLAGS}" "${NCLDFLAGS}
if [ test ${HAS_NC4} == "no" ] ; then
dnl ok couldn't get nc4, lets see if that is a nc3
AC_CHECK_LIB([netcdf],[nc_open],[HAS_NC="yes"],[HAS_NC="no"],[${NCFLAGS} ${NCLDFLAGS} ])
if [ test ${HAS_NCCONFIG} == "yes" ] ; then
HAS_NC3="yes"
else
dnl need to test if it is version 3.6.3
AC_MSG_CHECKING([if you have netcdf 3.6.3)])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netcdf.h>
],
[ [
char version[50];
int major,minor,patch;
strncpy(version,nc_inq_libvers(),50);
sscanf(version,"%*c%1d%*c%1d%*c%1d%*s",&major,&minor,&patch);
if ((major!=3) && (minor!=6) && (patch!=3)) return 1;
return 0;
]])],[BUILD_NC3="no"],[BUILD_NC3="yes"])
if [test ${BUILD_NC3} == "yes" ] ; then
AC_MSG_RESULT(["no"])
AC_MSG_ERROR(Could not get a working NetCDF)
else
AC_MSG_RESULT(["yes"])
fi
HAS_NC3="yes"
fi
fi
LIBS=${OLIBS}
CPPFLAGS=" -I${srcdir}/include -I${srcdir}/include/cdTime ${CPPFLAGS}"
LDFLAGS=${SV_LDFLAGS}
MAINDIR=`pwd`
# Library sources
#LIBSOURCES="Src/cmor.c Src/cmor_variables.c Src/cmor_axes.c Src/cmor_tables.c Src/cmor_grids.c Src/cdTime/cdTimeConv.c Src/cdTime/cdUtil.c Src/cdTime/timeConv.c Src/cdTime/timeArith.c Src/cmor_cfortran_interface.c Src/cmor_md5.c"
#LIBSOURCES=`ls -x --width=10000 Src/*.c Src/cdTime/*.c`
LIBSOURCES=`cd $srcdir ; ls Src/*.c Src/cdTime/*.c | tr "\n" " " | sed 's#Src/_controlvocabulary.c##'`
LIBSOURCESCV=`cd $srcdir ; ls Src/*.c Src/cdTime/*.c | tr "\n" " " | sed 's#Src/_cmormodule.c##'`
LIBFSOURCES="Src/cmor_fortran_interface.f90"
AC_OUTPUT
AC_MSG_NOTICE([])
AC_MSG_NOTICE([************************************************************************])
AC_MSG_NOTICE([ SUMMARY])
AC_MSG_NOTICE([ VERSION: ${CMOR_VERSION}])
AC_MSG_NOTICE([************************************************************************])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([........................................................................])
AC_MSG_NOTICE([... COMPILERS])
AC_MSG_NOTICE([........................................................................])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ FORTRAN])
if test ${enable_fortran} == "-no" ; then
AC_MSG_NOTICE([ DISABLED])
else
AC_MSG_NOTICE([ FC=${FC}])
AC_MSG_NOTICE([ F77=${F77}])
AC_MSG_NOTICE([ FFLAGS=${FFLAGS}])
AC_MSG_NOTICE([ FCFLAGS=${FCFLAGS}])
fi
AC_MSG_NOTICE([........................................................................])
AC_MSG_NOTICE([... EXTERNALS ...])
AC_MSG_NOTICE([........................................................................])
if [test ${SZLIBFLAGS}!="nosz" ]; then
AC_MSG_NOTICE([])
AC_MSG_NOTICE([SZLIB])
AC_MSG_NOTICE([ CFLAGS : ${SZLIBFLAGS}])
AC_MSG_NOTICE([ LDFLAGS : ${SZLIBLDFLAGS}])
fi
AC_MSG_NOTICE([])
AC_MSG_NOTICE([JSONC])
AC_MSG_NOTICE([ CFLAGS : ${JSONCFLAGS}])
AC_MSG_NOTICE([ LDFLAGS : ${JSONCLDFLAGS}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([UUID])
AC_MSG_NOTICE([ CFLAGS : ${UUIDFLAGS}])
AC_MSG_NOTICE([ LDFLAGS : ${UUIDLDFLAGS}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([UDUNITS2])
AC_MSG_NOTICE([ CFLAGS : ${UDUNITS2FLAGS}])
AC_MSG_NOTICE([ LDFLAGS : ${UDUNITS2LDFLAGS}])
AC_MSG_NOTICE([])
if [test ${BUILD_NC3} == "no" ] ; then
if [test ${HAS_NC4} == "yes" ] ; then
AC_MSG_NOTICE([NetCDF4])
AC_MSG_NOTICE([ CFLAGS : ${NCCFLAGS}])
AC_MSG_NOTICE([ LDFLAGS : ${NCLDFLAGS}])
else
AC_MSG_NOTICE([NetCDF3.6.3])
AC_MSG_NOTICE([ CFLAGS : ${NCCFLAGS}])
AC_MSG_NOTICE([ LDFLAGS : ${NCLDFLAGS}])
fi
else
AC_MSG_NOTICE([No valid NetCDF found will build NetCDF3.6.3 for you])
fi
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ PYTHON])
if test "-"${PYTHONEXEC} == "-" ; then
AC_MSG_NOTICE([ Not built, not used it tests])
else
AC_MSG_NOTICE([ Built using python: ${PYTHONEXEC}])
fi
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Type "make" to build cmor])
AC_MSG_NOTICE([Type "make install" to build and install cmor to ${prefix}])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([Type "make test" to build and test cmor code only])
AC_MSG_NOTICE([Type "make test_C" to build cmor and test C only])
if test "-"${MAKETESTPYTHON} != "-" ; then
AC_MSG_NOTICE([Will also test for python since your are using CDAT])
AC_MSG_NOTICE([Type "make test_python" to build and test cmor python only])
fi
if test ${enable_fortran} != "-no" ; then
AC_MSG_NOTICE([Type "make test_fortran" to build cmor and test fortran only])
else
AC_MSG_NOTICE([will also test for fortran])
fi
AC_MSG_NOTICE([])
AC_MSG_NOTICE([You can compile C or FORTRAN code using the compilation lines shown in file: compile_line.txt and printed bellow:])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([])
cat compile_line.txt