configure.ac 9.98 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_INIT([cdo], [1.9.0], [http://mpimet.mpg.de/cdo])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
8

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

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

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

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

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

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

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
107
108
109
110
111
  *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

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])
112

113
# Checks for username, hostname and system type
Uwe Schulzweida's avatar
Uwe Schulzweida committed
114
115
116
USERNAME=$LOGNAME
if test -z "$USERNAME" ; then USERNAME=$USER; fi;
if test -z "$USERNAME" ; then USERNAME="unknown"; fi;
117
118
119
120
121
122
123
124
125
126
127
128
129
AC_DEFINE_UNQUOTED([USER_NAME],["$USERNAME"], [User name])
AC_SUBST([USER_NAME],["$USERNAME"])

AS_IF([test -z "$HOST"],
      [HOST=unknown
       AS_IF([test -x /bin/hostname],[HOST=$(hostname)],
             [AS_IF([test -x /bin/uname],
                    [HOST=$(uname -n)])])])
AC_DEFINE_UNQUOTED([HOST_NAME],["$HOST"],[Host name])
AC_SUBST([HOST_NAME],["$HOST"])

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
137
# Checks for the availability of ANSI-C99 math functions
AC_CHECK_DECLS([isnan],,,[AC_INCLUDES_DEFAULT
@%:@include <math.h>])
AC_CHECK_FUNCS(sqrtl)
138
139
140
AC_CHECK_FUNCS(feenableexcept)
#
AC_CHECK_MEMBERS([fenv_t.__control, fenv_t.__mxcsr],,,[[#include <fenv.h>]])
141
#  ----------------------------------------------------------------------
142
#  Enable NEARPT3 support
143
144
145
146
147
148
149
150
# AC_MSG_CHECKING([for nearpt3 support])
# AC_ARG_ENABLE([nearpt3], AS_HELP_STRING([--enable-nearpt3],[nearpt3 support [default=no]]))
# AS_IF([test "x$enable_nearpt3" = "xyes"], [
#   AC_DEFINE(ENABLE_NEARPT3, [1], [Define to 1 for nearpt3 support])
# ])
# AC_MSG_RESULT([$enable_nearpt3])
# AC_SUBST([ENABLE_NEARPT3],[$enable_nearpt3])
# AM_CONDITIONAL([ENABLE_NEARPT3],[test x$enable_nearpt3 = 'xyes'])
151
#  ----------------------------------------------------------------------
152
#  Enable DATA support
153
AC_MSG_CHECKING([for DATA support])
154
155
156
157
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])
])
158
159
160
AC_MSG_RESULT([$enable_data])
AC_SUBST([ENABLE_DATA],[$enable_data])
#  ----------------------------------------------------------------------
161
CFLAGS="$CFLAGS ${OPENMP_CFLAGS}"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
162
CXXFLAGS="$CXXFLAGS ${OPENMP_CFLAGS}"
163
164
#  ----------------------------------------------------------------------

165
# Add configure options
166
ACX_OPTIONS
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

#  ----------------------------------------------------------------------

# 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
242
#  ----------------------------------------------------------------------
243
AC_SUBST([CXXFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
244
AC_SUBST([CPPFLAGS])
245
246
247
AC_SUBST([FCFLAGS])
AC_SUBST([CLDFLAGS])
AC_SUBST([CLIBS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
248
249
#AC_SUBST([INCLUDES])
AC_SUBST([AM_CPPFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
250
251
AC_SUBST([AR])

Uwe Schulzweida's avatar
Uwe Schulzweida committed
252
# Checks for compiler
Uwe Schulzweida's avatar
Uwe Schulzweida committed
253
254
255
256
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])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
257

Uwe Schulzweida's avatar
Uwe Schulzweida committed
258
259
260
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_PROG_AWK

Uwe Schulzweida's avatar
Uwe Schulzweida committed
261
AC_CONFIG_FILES([test/File.test test/Read_grib.test test/Read_netcdf.test test/Copy_netcdf.test],[chmod a+x "$ac_file"])
262
AC_CONFIG_FILES([test/Comp.test test/Compc.test],[chmod a+x "$ac_file"])
263
AC_CONFIG_FILES([test/Cat.test test/Gridarea.test test/Genweights.test test/Remap.test test/Remap2.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
264
AC_CONFIG_FILES([test/EOF.test test/Select.test test/Spectral.test test/Vertint.test],[chmod a+x "$ac_file"])
265
AC_CONFIG_FILES([test/Timstat.test test/Timselstat.test test/Seasstat.test test/Runstat.test test/Multiyearstat.test test/Ydrunstat.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
266
AC_CONFIG_FILES([test/Gridboxstat.test test/Vertstat.test test/Fldstat.test test/Fldpctl.test test/Ensstat.test test/Enspctl.test],[chmod a+x "$ac_file"])
267
AC_CONFIG_FILES([test/Merstat.test test/Zonstat.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
268
AC_CONFIG_FILES([test/Afterburner.test test/Detrend.test test/Arithc.test test/Arith.test test/Expr.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
269
AC_CONFIG_FILES([test/Gradsdes.test test/Collgrid.test test/threads.test test/tsformat.test test/wildcard.test],[chmod a+x "$ac_file"])
Ralf Mueller's avatar
Ralf Mueller committed
270
AC_CONFIG_FILES([test/MapReduce.test test/Ninfo.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
271
272
AC_CONFIG_FILES([Makefile src/Makefile contrib/Makefile test/Makefile test/data/Makefile cdo.spec cdo.settings])
AC_OUTPUT
Uwe Schulzweida's avatar
Uwe Schulzweida committed
273

274
275
276
277
#  ----------------------------------------------------------------------
#  Show configuration
AC_MSG_NOTICE([CDO is configured with the following options:])
cat cdo.settings
278

279
280
AS_IF([test "$ac_cv_prog_cc_c99" = "no"],
      [AC_MSG_NOTICE([
281

282
283
  Warning: The C compiler does not accept ANSI C99 source code!
])])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
284
285
286
287
288
289
AC_MSG_NOTICE([

  Configuration completed.

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