configure.ac 12.5 KB
Newer Older
Uwe Schulzweida's avatar
Uwe Schulzweida committed
1
# Process this file with autoconf to produce a configure script.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
2
3
4
5
#
#  automake 1.14
#  autoconf 2.68
#  libtool  2.4.2
Uwe Schulzweida's avatar
Uwe Schulzweida committed
6

7
AC_PREREQ([2.68])
8
AC_INIT([cdo], [1.9.9rc3], [https://mpimet.mpg.de/cdo])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
9

Uwe Schulzweida's avatar
Uwe Schulzweida committed
10
11
AC_DEFINE_UNQUOTED(CDO, ["$PACKAGE_VERSION"], [CDO version])

Uwe Schulzweida's avatar
Uwe Schulzweida committed
12
13
CONFIG_ABORT=yes
AC_CONFIG_AUX_DIR(config)
14
AC_CONFIG_MACRO_DIR([m4])
15
AC_CONFIG_MACRO_DIR([libcdi/m4])
16
17
AC_CANONICAL_HOST
AC_CANONICAL_BUILD
Uwe Schulzweida's avatar
Uwe Schulzweida committed
18

Uwe Schulzweida's avatar
Uwe Schulzweida committed
19
# AM_INIT_AUTOMAKE([foreign -Wall -Werror])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
20
AM_INIT_AUTOMAKE([subdir-objects foreign -Wall])
21
AC_CONFIG_HEADERS([src/config.h])
22
AM_MAINTAINER_MODE([disable])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
23

24
# Set up libtool.
25
26
AM_PROG_AR
#
27
28
AC_MSG_NOTICE([setting up libtool])
LT_INIT
29

Uwe Schulzweida's avatar
Uwe Schulzweida committed
30
31
32
# bash
AC_PATH_TOOL([BASH],[bash],[:])

33
34
# Check building environment
AC_CHECK_TOOL([CC],[gcc],[:])
35
AC_CHECK_TOOL([CXX],[g++],[:])
36
AC_PROG_CC_C99
37
AM_PROG_CC_C_O
38
AC_PROG_CXX
Uwe Schulzweida's avatar
Uwe Schulzweida committed
39
AC_PROG_F77
40
AC_C_RESTRICT
41
AX_CXX_COMPILE_STDCXX_11
42
AC_OPENMP
43
44
45
46
47
48
49
50
51
52
AC_CHECK_TOOL([AR],[ar],[:])
AC_CHECK_TOOL([CPP],[cpp],[:])
AC_CHECK_TOOL([LD],[ld],[:])
AC_CHECK_TOOL([NM],[nm],[:])
AC_CHECK_TOOL([AR],[ar],[:])
AC_CHECK_TOOL([AS],[as],[:])
AC_CHECK_TOOL([DLLTOOL],[dlltool],[:])
AC_CHECK_TOOL([OBJDUMP],[objdump],[:])
AC_CHECK_TOOL([STRIP],[strip],[:])
AC_CHECK_TOOL([RANLIB],[ranlib],[:])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
53
AC_PROG_INSTALL
Uwe Schulzweida's avatar
Uwe Schulzweida committed
54
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
55
56
57
FC=no
export FC
#
58
#  ----------------------------------------------------------------------
59
# Check large file support on 32 bit system
Uwe Schulzweida's avatar
Uwe Schulzweida committed
60
AC_SYS_LARGEFILE
61
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
62
63
# Checks for library functions.
AC_FUNC_MMAP
64
#  ----------------------------------------------------------------------
65
66
# Checks for structures.
AC_CHECK_MEMBERS([struct stat.st_blksize])
67
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
68
69
70
# Checks for header files
AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_HEADERS(sys/times.h)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
71
AC_CHECK_HEADERS(malloc.h)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
72
AC_CHECK_HEADERS(glob.h)
73
AC_CHECK_HEADERS(fnmatch.h)
74
AC_CHECK_HEADERS(wordexp.h)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
75
AC_CHECK_HEADERS(execinfo.h)
76
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
77
78
# Checks for the availability of functions
AC_CHECK_FUNCS(mallinfo)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
79
AC_CHECK_FUNCS(backtrace)
80
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
81
# Checks for the availability of ANSI-C99 functions
Uwe Schulzweida's avatar
Uwe Schulzweida committed
82
AC_CHECK_FUNCS(getrlimit)
83

Uwe Schulzweida's avatar
Uwe Schulzweida committed
84
# Check compiler version
Uwe Schulzweida's avatar
Uwe Schulzweida committed
85
case "$CXX" in
86
  pgc*)   CXX_VERSION=`$CXX -V | head -2 | tail -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
87
88
89
  *gcc*)  CXX_VERSION=`$CXX --version | head -n 1`;;
  g++*)   CXX_VERSION=`$CXX --version | head -n 1`;;
  clang*) CXX_VERSION=`$CXX --version | head -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
90
  icpc*)  CXX_VERSION=`$CXX --version | head -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
91
92
93
  sxc*)   CXX_VERSION=`$CXX -V 2>&1   | tail -n 1`;;
  xlc*)   CXX_VERSION=`$CXX -qversion 2>&1   | head -n 1`;;
  *)      CXX_VERSION=`$CXX -V 2>&1   | head -n 1 | grep -v error`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
94
esac
95

Uwe Schulzweida's avatar
Uwe Schulzweida committed
96
case "$CC" in
97
  pgc*)   C_VERSION=`$CC -V | head -2 | tail -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
98
99
100
101
102
103
104
105
106
  *gcc*)  C_VERSION=`$CC --version | head -n 1`;;
  g++*)   C_VERSION=`$CC --version | head -n 1`;;
  clang*) C_VERSION=`$CC --version | head -n 1`;;
  icc*)   C_VERSION=`$CC --version | head -n 1`;;
  sxc*)   C_VERSION=`$CC -V 2>&1   | tail -n 1`;;
  xlc*)   C_VERSION=`$CC -qversion 2>&1   | head -n 1`;;
  *)      C_VERSION=`$CC -V 2>&1   | head -n 1 | grep -v error`;;
esac

Uwe Schulzweida's avatar
Uwe Schulzweida committed
107
if test -n "$F77" ; then
108
109
110
case "$F77" in
  pgf*)      F77_VERSION=`$F77 -V | head -2 | tail -n 1`;;
  gfortran*) F77_VERSION=`$F77 --version | head -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
111
  ifort*)    F77_VERSION=`$F77 --version | head -n 1`;;
112
113
  *)         F77_VERSION=`$F77 -V 2>&1   | head -n 1 | grep -v error`;;
esac
Uwe Schulzweida's avatar
Uwe Schulzweida committed
114
fi
115

Uwe Schulzweida's avatar
Uwe Schulzweida committed
116
117
118
119
120
if test -z "$CXX_VERSION" ; then CXX_VERSION="unknown"; fi;
AC_DEFINE_UNQUOTED(CXX_VERSION, ["$CXX_VERSION"], [CXX Compiler version])

if test -z "$C_VERSION" ; then C_VERSION="unknown"; fi;
AC_DEFINE_UNQUOTED(C_VERSION, ["$C_VERSION"], [C Compiler version])
121

Uwe Schulzweida's avatar
Uwe Schulzweida committed
122
if test -n "$F77" ; then
123
124
if test -z "$F77_VERSION" ; then F77_VERSION="unknown"; fi;
AC_DEFINE_UNQUOTED(F77_VERSION, ["$F77_VERSION"], [F77 Compiler version])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125
fi
126

127
# Check for system type
128
129
AC_DEFINE_UNQUOTED([SYSTEM_TYPE],["$ac_cv_build"], [System type])
AC_SUBST([SYSTEM_TYPE],["$ac_cv_build"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
130
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
131
#  Check for math library
132
AC_CHECK_LIB([m],[floor])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
133
#  ----------------------------------------------------------------------
134
135
136
AC_CHECK_FUNCS(feenableexcept)
#
AC_CHECK_MEMBERS([fenv_t.__control, fenv_t.__mxcsr],,,[[#include <fenv.h>]])
137

138
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
139
#  Create the Interface to Fortran77 routines via cfortran.h
140
141
142
143
144
145
146
147
148
149
AC_ARG_ENABLE([fortran],
              [AS_HELP_STRING([--disable-fortran],
                              [Omit building of Fortran routines])],
              [enable_fortran=${enableval}],[enable_fortran=yes])
AS_IF([test "x${enable_fortran}" = "xyes"], [
dnl ######################################################################
dnl Test whether cfortran.h works correctly
dnl ######################################################################
ACX_FIND_CFORTRAN_DEF
ACX_XLF_QEXTNAME_ADD_APPENDUS
Uwe Schulzweida's avatar
Uwe Schulzweida committed
150
AS_IF([test -n "$F77" -a X"$F77" != Xno],
151
152
153
154
155
156
157
158
159
160
161
162
163
164
  [ACX_CHECK_CFORTRAN([$srcdir/src],
    [AC_DEFINE([HAVE_CF_INTERFACE],[1],
       [Defined to 1 if C / Fortran interface cfortran.h works])],
    [AS_CASE([x"$acx_cv_cfortran_works"],
       [x"error"],
       [AC_MSG_NOTICE([Linking/Running with C EXTERNAL built with cfortran.h does not work!])],
       [x"compiling with cfortran.h failed"],
       [AC_MSG_NOTICE([Compilation with cfortran.h is not working!])],
       [x"error compiling Fortran subroutine"],
       [AC_MSG_NOTICE([compilation of simple Fortran source failed!])],
       [AC_MSG_NOTICE([Unexpected error when linking C and Fortran via cfortran.h!])])
     AC_MSG_NOTICE([Disabling cfortran.h bindings generation])
     acx_cv_cfortran_works=no])])
])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
165
166
AS_IF([test x$enable_fortran = 'xno'],[AC_SUBST([ENABLE_FORTRAN],[false])],[AC_SUBST([ENABLE_FORTRAN],[true])])
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
167
AM_CONDITIONAL([USE_F77],[test -n "$F77" -a X"$F77" != Xno -a x"$acx_cv_cfortran_works" = xyes])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
168
AS_IF([test x$acx_cv_cfortran_works = 'xno'],[AC_SUBST([FORTRAN_WORKS],[no])],[AC_SUBST([FORTRAN_WORKS],[yes])])
169
#  ----------------------------------------------------------------------
170
171
172
173
174
175
176
177
178
179
180
181
182
#  Enable DATA support
AC_MSG_CHECKING([for DATA support])
AC_ARG_ENABLE([data], AS_HELP_STRING([--enable-data],[DATA support [default=yes]]))
AS_IF([test "x$enable_data" != 'xno'], [
  AC_DEFINE(ENABLE_DATA, [1], [Define to 1 for DATA support])
])
AC_MSG_RESULT([$enable_data])
AS_IF([test x$enable_data = 'xno'],[AC_SUBST([ENABLE_DATA],[false])],[AC_SUBST([ENABLE_DATA],[true])])
#  ----------------------------------------------------------------------
CFLAGS="$CFLAGS ${OPENMP_CFLAGS}"
CXXFLAGS="$CXXFLAGS ${OPENMP_CFLAGS}"
#  ----------------------------------------------------------------------
# Add configure options
183
184
ACX_CDO_OPTIONS
ACX_CDI_OPTIONS
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
# configure code from valgrind

# does the x86/amd64 assembler understand SSE 4.2 instructions?
# Note, this doesn't generate a C-level symbol.  It generates a
# automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
  do { long long int x; 
   __asm__ __volatile__(
      "crc32q %%r15,%%r15" : : : "r15" );
   __asm__ __volatile__(
      "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11"); 
   __asm__ __volatile__(
      "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
  while (0)
]])], [
ac_have_as_sse42=yes
AC_MSG_RESULT([yes])
], [
ac_have_as_sse42=no
AC_MSG_RESULT([no])
])

AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)


# does the x86/amd64 assembler understand AVX instructions?
# Note, this doesn't generate a C-level symbol.  It generates a
# automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
  do { long long int x; 
   __asm__ __volatile__(
      "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
   __asm__ __volatile__(
      "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
  while (0)
]])], [
ac_have_as_avx=yes
AC_MSG_RESULT([yes])
], [
ac_have_as_avx=no
AC_MSG_RESULT([no])
])

AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)


# does the x86/amd64 assembler understand AVX2 instructions?
# Note, this doesn't generate a C-level symbol.  It generates a
# automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
  do { long long int x; 
   __asm__ __volatile__(
      "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
   __asm__ __volatile__(
      "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
  while (0)
]])], [
ac_have_as_avx2=yes
AC_MSG_RESULT([yes])
], [
ac_have_as_avx2=no
AC_MSG_RESULT([no])
])

AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)

Uwe Schulzweida's avatar
Uwe Schulzweida committed
258
#  ----------------------------------------------------------------------
259
AC_SUBST([CXXFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
260
AC_SUBST([CPPFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
261
AC_SUBST([FFLAGS])
262
263
AC_SUBST([CLDFLAGS])
AC_SUBST([CLIBS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
264
265
#AC_SUBST([INCLUDES])
AC_SUBST([AM_CPPFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
266
267
AC_SUBST([AR])

Uwe Schulzweida's avatar
Uwe Schulzweida committed
268
# Checks for compiler
Uwe Schulzweida's avatar
Uwe Schulzweida committed
269
270
271
272
C_COMPILER="$CC $CFLAGS"
AC_DEFINE_UNQUOTED(C_COMPILER, ["$C_COMPILER"], [C Compiler])
CXX_COMPILER="$CXX $CXXFLAGS"
AC_DEFINE_UNQUOTED(CXX_COMPILER, ["$CXX_COMPILER"], [CXX Compiler])
273
274
F77_COMPILER="$F77 $FFLAGS"
AC_DEFINE_UNQUOTED(F77_COMPILER, ["$F77_COMPILER"], [F77 Compiler])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
275

Uwe Schulzweida's avatar
Uwe Schulzweida committed
276
277
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_PROG_AWK
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#test util
AC_CONFIG_FILES([test/cdoTestFunctions.test ],[chmod a+x "$ac_file"])
#general tests
AC_CONFIG_FILES([
                test/Afterburner.test
                test/Arith.test
                test/Arithc.test
                test/Cat.test
                test/Change.test ]
                test/Collgrid.test
                test/Comp.test
                test/Compc.test
                test/Copy_netcdf.test 
                test/Detrend.test
                test/EOF.test
Uwe Schulzweida's avatar
Uwe Schulzweida committed
293
                test/EOFcoeff.test
294
295
296
297
298
299
300
301
302
303
304
305
                test/Enspctl.test
                test/Ensstat.test
                test/Expr.test
                test/File.test
                test/Filter.test
                test/Fldpctl.test
                test/Fldstat.test
                test/Genweights.test
                test/Gradsdes.test
                test/Gridarea.test
                test/Gridboxstat.test
                test/Inttime.test
Uwe Schulzweida's avatar
Uwe Schulzweida committed
306
                test/Isosurface.test
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
                test/MapReduce.test
                test/Mergetime.test
                test/Merstat.test
                test/Monarith.test
                test/Multiyearstat.test
                test/Ninfo.test
                test/Read_grib.test
                test/Read_netcdf.test
                test/Remap.test
                test/Remap2.test
                test/Remap3.test
                test/Remapeta.test
                test/Remapgrid.test
                test/Runpctl.test
                test/Runstat.test
                test/Seasstat.test
                test/Select.test
                test/Setmiss.test
                test/Smooth.test
                test/Spectral.test
                test/Timpctl.test
                test/Timselstat.test
                test/Timselpctl.test
                test/Timstat.test
                test/Timstat2.test
                test/Varsstat.test
                test/Vertint.test
                test/Vertstat.test
Uwe Schulzweida's avatar
Uwe Schulzweida committed
335
                test/Wind.test
336
337
338
339
340
341
                test/Ydrunstat.test
                test/Yearmonstat.test
                test/Ymonarith.test
                test/Zonstat.test
                test/threads.test
                test/tsformat.test
342
                test/userInput.test
343
344
345
346
347
348
349
350
351
352
353
354
355
356
                test/wildcard.test
            ,[chmod a+x "$ac_file"])
#tests which only execute operators and dont check about correctness
AC_CONFIG_FILES([
                 test/executeOnly/Splitsel.test 
                 ],
            [chmod a+x "$ac_file"])

#Cdo Options
AC_CONFIG_FILES([contrib/Makefile  cdo.spec cdo.settings])
#Makefiles
AC_CONFIG_FILES([Makefile src/lib/ncl/Makefile src/lib/yac/Makefile src/lib/gradsdes/Makefile src/Makefile])
#Test Makefiles
AC_CONFIG_FILES([test/Makefile test/data/Makefile test/executeOnly/Makefile test/bandit_tests/Makefile])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
357
AC_OUTPUT
Uwe Schulzweida's avatar
Uwe Schulzweida committed
358

359
360
361
362
#  ----------------------------------------------------------------------
#  Show configuration
AC_MSG_NOTICE([CDO is configured with the following options:])
cat cdo.settings
363

364
365
AS_IF([test "$ac_cv_prog_cc_c99" = "no"],
      [AC_MSG_NOTICE([
366

367
368
  Warning: The C compiler does not accept ANSI C99 source code!
])])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
369
370
371
372
373
374
AC_MSG_NOTICE([

  Configuration completed.

    You can now say 'make' to compile the CDO package and 'make install' to install it afterwards.
])