configure.ac 9.57 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.8.0rc5], [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

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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
80
81
# Check compiler version
case "$CC" in
82
  pgcc*)  COMP_VERSION=`$CC -V | head -2 | tail -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
83
  *gcc*)  COMP_VERSION=`$CC --version | head -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
84
  g++*)   COMP_VERSION=`$CC --version | head -n 1`;;
85
  clang*) COMP_VERSION=`$CC --version | head -n 1`;;
86
  icc*)   COMP_VERSION=`$CC --version | head -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
87
  sxc*)   COMP_VERSION=`$CC -V 2>&1   | tail -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
88
  xlc*)   COMP_VERSION=`$CC -qversion 2>&1   | head -n 1`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
89
  *)      COMP_VERSION=`$CC -V 2>&1   | head -n 1 | grep -v error`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
90
esac
91
92
93
94

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

95
# Checks for username, hostname and system type
Uwe Schulzweida's avatar
Uwe Schulzweida committed
96
97
98
USERNAME=$LOGNAME
if test -z "$USERNAME" ; then USERNAME=$USER; fi;
if test -z "$USERNAME" ; then USERNAME="unknown"; fi;
99
100
101
102
103
104
105
106
107
108
109
110
111
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
112
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
113
#  Check for math library
114
AC_CHECK_LIB([m],[floor])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
115
#  ----------------------------------------------------------------------
116
117
118
119
# Checks for the availability of ANSI-C99 math functions
AC_CHECK_DECLS([isnan],,,[AC_INCLUDES_DEFAULT
@%:@include <math.h>])
AC_CHECK_FUNCS(sqrtl)
120
121
122
AC_CHECK_FUNCS(feenableexcept)
#
AC_CHECK_MEMBERS([fenv_t.__control, fenv_t.__mxcsr],,,[[#include <fenv.h>]])
123
#  ----------------------------------------------------------------------
124
#  Enable NEARPT3 support
125
126
127
128
129
130
131
132
# 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'])
133
#  ----------------------------------------------------------------------
134
#  Enable DATA support
135
AC_MSG_CHECKING([for DATA support])
136
137
138
139
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])
])
140
141
142
AC_MSG_RESULT([$enable_data])
AC_SUBST([ENABLE_DATA],[$enable_data])
#  ----------------------------------------------------------------------
143
144
145
CFLAGS="$CFLAGS ${OPENMP_CFLAGS}"
#  ----------------------------------------------------------------------

146
# Add configure options
147
ACX_OPTIONS
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

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

# 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)

223
224
225
226
227
228
229
230
231
232
AC_ARG_ENABLE([cxx],
              [AS_HELP_STRING([--enable-cxx],[Use CXX as default compiler [default=no]])],
              [AS_IF([test "x$enable_cxx" != 'xno'],
                     [CC=$CXX
                      CXXFLAGS=$CFLAGS
                      enable_cxx=yes],
              [enable_cxx=no])],
              [enable_cxx=no])
AC_MSG_RESULT([$enable_cxx])
AC_SUBST([ENABLE_CXX],[$enable_cxx])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
233
#  ----------------------------------------------------------------------
234
AC_SUBST([CXXFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
235
AC_SUBST([CPPFLAGS])
236
237
238
AC_SUBST([FCFLAGS])
AC_SUBST([CLDFLAGS])
AC_SUBST([CLIBS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
239
240
#AC_SUBST([INCLUDES])
AC_SUBST([AM_CPPFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
241
242
AC_SUBST([AR])

Uwe Schulzweida's avatar
Uwe Schulzweida committed
243
244
245
246
# Checks for compiler
COMPILER="$CC $CFLAGS"
AC_DEFINE_UNQUOTED(COMPILER, ["$COMPILER"], [Compiler])

Uwe Schulzweida's avatar
Uwe Schulzweida committed
247
248
249
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_PROG_AWK

Uwe Schulzweida's avatar
Uwe Schulzweida committed
250
AC_CONFIG_FILES([test/File.test test/Read_grib.test test/Read_netcdf.test test/Copy_netcdf.test],[chmod a+x "$ac_file"])
251
AC_CONFIG_FILES([test/Comp.test test/Compc.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
252
AC_CONFIG_FILES([test/Cat.test test/Gridarea.test test/Genweights.test test/Remap.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
253
AC_CONFIG_FILES([test/Select.test test/Spectral.test test/Vertint.test],[chmod a+x "$ac_file"])
254
AC_CONFIG_FILES([test/Timstat.test test/Timselstat.test test/Seasstat.test test/Runstat.test test/Multiyearstat.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
255
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"])
256
AC_CONFIG_FILES([test/Merstat.test test/Zonstat.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
257
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
258
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
259
AC_CONFIG_FILES([test/MapReduce.test test/Ninfo.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
260
261
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
262

263
264
265
266
#  ----------------------------------------------------------------------
#  Show configuration
AC_MSG_NOTICE([CDO is configured with the following options:])
cat cdo.settings
267

268
269
AS_IF([test "$ac_cv_prog_cc_c99" = "no"],
      [AC_MSG_NOTICE([
270

271
272
  Warning: The C compiler does not accept ANSI C99 source code!
])])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
273
274
275
276
277
278
AC_MSG_NOTICE([

  Configuration completed.

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