configure.ac 9.88 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.9rc6], [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`;;
Uwe Schulzweida's avatar
Uwe Schulzweida committed
112
  f77*)      F77_VERSION=`$F77 --version | head -n 1`;;
113 114
  *)         F77_VERSION=`$F77 -V 2>&1   | head -n 1 | grep -v error`;;
esac
Uwe Schulzweida's avatar
Uwe Schulzweida committed
115
fi
116

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

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

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

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

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

Uwe Schulzweida's avatar
Uwe Schulzweida committed
192 193
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_PROG_AWK
194 195 196 197 198 199 200 201
#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
202
                test/Change.test
203 204 205 206 207 208
                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
209
                test/EOFcoeff.test
210 211 212 213 214 215 216 217 218 219 220 221
                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
222
                test/Isosurface.test
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
                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
251
                test/Wind.test
Uwe Schulzweida's avatar
Uwe Schulzweida committed
252
                test/Yeararith.test
253 254 255 256 257 258
                test/Ydrunstat.test
                test/Yearmonstat.test
                test/Ymonarith.test
                test/Zonstat.test
                test/threads.test
                test/tsformat.test
259
                test/userInput.test
260
                test/wildcard.test]
261 262
            ,[chmod a+x "$ac_file"])
#tests which only execute operators and dont check about correctness
263
AC_CONFIG_FILES([test/executeOnly/Splitsel.test], [chmod a+x "$ac_file"])
264 265 266 267 268 269 270

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

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

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

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

  Configuration completed.

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