configure.ac 9.97 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.9], [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
CONFIG_ABORT=yes
13
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_SRCDIR([src/cdo.cc])
22
AC_CONFIG_HEADERS([src/config.h])
23
AM_MAINTAINER_MODE([disable])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
24

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

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

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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
85
# Check compiler version
Uwe Schulzweida's avatar
Uwe Schulzweida committed
86
case "$CXX" in
87 88 89 90 91 92 93 94
  *pgc*)   CXX_VERSION=`$CXX -V | head -2 | tail -n 1`;;
  *gcc*)   CXX_VERSION=`$CXX --version | head -n 1`;;
  *g++*)   CXX_VERSION=`$CXX --version | head -n 1`;;
  *clang*) CXX_VERSION=`$CXX --version | head -n 1`;;
  *icpc*)  CXX_VERSION=`$CXX --version | head -n 1`;;
  *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
95
esac
96

Uwe Schulzweida's avatar
Uwe Schulzweida committed
97
case "$CC" in
98 99 100 101 102 103 104 105
  *pgc*)   C_VERSION=`$CC -V | head -2 | tail -n 1`;;
  *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`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
106 107
esac

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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
118 119 120 121 122
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])
123

Uwe Schulzweida's avatar
Uwe Schulzweida committed
124
if test -n "$F77" ; then
125 126
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
127
fi
128

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

137
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
138
#  Create the Interface to Fortran77 routines via cfortran.h
139 140 141 142 143 144 145 146 147 148
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
149
AS_IF([test -n "$F77" -a X"$F77" != Xno],
150 151 152 153 154 155 156 157 158 159 160 161 162 163
  [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
164 165
AS_IF([test x$enable_fortran = 'xno'],[AC_SUBST([ENABLE_FORTRAN],[false])],[AC_SUBST([ENABLE_FORTRAN],[true])])
#
Uwe Schulzweida's avatar
Uwe Schulzweida committed
166
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
167
AS_IF([test x$acx_cv_cfortran_works = 'xno'],[AC_SUBST([FORTRAN_WORKS],[no])],[AC_SUBST([FORTRAN_WORKS],[yes])])
168
#  ----------------------------------------------------------------------
169 170
CFLAGS="$CFLAGS ${OPENMP_CFLAGS}"
CXXFLAGS="$CXXFLAGS ${OPENMP_CFLAGS}"
171
  ----------------------------------------------------------------------
172
# Add configure options
173 174
ACX_CDO_OPTIONS
ACX_CDI_OPTIONS
Uwe Schulzweida's avatar
Uwe Schulzweida committed
175
#  ----------------------------------------------------------------------
176
AC_SUBST([CXXFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
177
AC_SUBST([CPPFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
178
AC_SUBST([FFLAGS])
179 180
AC_SUBST([CLDFLAGS])
AC_SUBST([CLIBS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
181 182
#AC_SUBST([INCLUDES])
AC_SUBST([AM_CPPFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
183 184
AC_SUBST([AR])

Uwe Schulzweida's avatar
Uwe Schulzweida committed
185
# Checks for compiler
Uwe Schulzweida's avatar
Uwe Schulzweida committed
186 187 188 189
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])
190 191
F77_COMPILER="$F77 $FFLAGS"
AC_DEFINE_UNQUOTED(F77_COMPILER, ["$F77_COMPILER"], [F77 Compiler])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
192

Uwe Schulzweida's avatar
Uwe Schulzweida committed
193 194
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_PROG_AWK
195 196 197 198 199 200 201 202
#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
203
                test/Change.test
204 205 206 207 208 209
                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
210
                test/EOFcoeff.test
211 212 213 214 215 216 217 218 219 220 221 222
                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
223
                test/Isosurface.test
224 225 226 227 228 229 230 231 232 233 234 235 236
                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
Uwe Schulzweida's avatar
Uwe Schulzweida committed
237
                test/Remapstat.test
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
                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
253
                test/Wind.test
Uwe Schulzweida's avatar
Uwe Schulzweida committed
254
                test/Yeararith.test
255 256 257 258 259 260
                test/Ydrunstat.test
                test/Yearmonstat.test
                test/Ymonarith.test
                test/Zonstat.test
                test/threads.test
                test/tsformat.test
261
                test/userInput.test
262
                test/wildcard.test]
263 264
            ,[chmod a+x "$ac_file"])
#tests which only execute operators and dont check about correctness
265
AC_CONFIG_FILES([test/executeOnly/Splitsel.test], [chmod a+x "$ac_file"])
266 267 268 269 270 271 272

#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
273
AC_OUTPUT
Uwe Schulzweida's avatar
Uwe Schulzweida committed
274

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

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

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

  Configuration completed.

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