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

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

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

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

149
# Add configure options
150
ACX_OPTIONS
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

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

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

226
227
228
229
230
231
232
233
234
235
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
236
#  ----------------------------------------------------------------------
237
AC_SUBST([CXXFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
238
AC_SUBST([CPPFLAGS])
239
240
241
AC_SUBST([FCFLAGS])
AC_SUBST([CLDFLAGS])
AC_SUBST([CLIBS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
242
243
#AC_SUBST([INCLUDES])
AC_SUBST([AM_CPPFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
244
245
AC_SUBST([AR])

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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
250
251
252
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_PROG_AWK

Uwe Schulzweida's avatar
Uwe Schulzweida committed
253
AC_CONFIG_FILES([test/File.test test/Read_grib.test test/Read_netcdf.test test/Copy_netcdf.test],[chmod a+x "$ac_file"])
254
AC_CONFIG_FILES([test/Comp.test test/Compc.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
255
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
256
AC_CONFIG_FILES([test/EOF.test test/Select.test test/Spectral.test test/Vertint.test],[chmod a+x "$ac_file"])
257
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
258
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"])
259
AC_CONFIG_FILES([test/Merstat.test test/Zonstat.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
260
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
261
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
262
AC_CONFIG_FILES([test/MapReduce.test test/Ninfo.test],[chmod a+x "$ac_file"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
263
264
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
265

266
267
268
269
#  ----------------------------------------------------------------------
#  Show configuration
AC_MSG_NOTICE([CDO is configured with the following options:])
cat cdo.settings
270

271
272
AS_IF([test "$ac_cv_prog_cc_c99" = "no"],
      [AC_MSG_NOTICE([
273

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

  Configuration completed.

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