configure.ac 6.79 KB
Newer Older
1
#  Process this file with autoconf to produce a configure script.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
2

3
AC_INIT(cdi, 1.3.1, Uwe.Schulzweida@zmaw.de)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
4

Uwe Schulzweida's avatar
Uwe Schulzweida committed
5
6
echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"

Uwe Schulzweida's avatar
Uwe Schulzweida committed
7
8
9
10
11
12
13
14
15
16
17
CONFIG_ABORT=yes

AC_ARG_VAR(CFINT,  [C/Fortran interface preprocessor flag, e.g. -Df2cFortran]) 
AC_ARG_VAR(AR,     [AR archive command]) 

AC_CONFIG_AUX_DIR(config)
AC_CANONICAL_TARGET

AM_CONFIG_HEADER(src/config.h)
AM_INIT_AUTOMAKE

18
#  Checks for programs.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
19
20
21
22
23
24
AC_PROG_CC
AC_PROG_F77
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_CHECK_PROGS(AR, ar, [ar])

25
#  Check large file support on 32 bit systems
Uwe Schulzweida's avatar
Uwe Schulzweida committed
26
27
AC_SYS_LARGEFILE

28
#  Checks for library functions.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
29
30
AC_FUNC_MMAP

31
#  Checks for library malloc.
Uwe Schulzweida's avatar
Uwe Schulzweida committed
32
33
AC_CHECK_LIB(malloc, mallinfo)

34
35
36
# Checks for structures.
AC_CHECK_MEMBERS([struct stat.st_blksize])

37
38
39
# Checks for the availability of ANSI-C99 functions
AC_CHECK_FUNCS(isnan)

Uwe Schulzweida's avatar
Uwe Schulzweida committed
40
41
42
43
#  ----------------------------------------------------------------------
#  Compile interface with internal GRIB library
#
AC_ARG_WITH([grib],
44
45
            [AC_HELP_STRING([--with-grib], [Use the internal GRIB library [default=yes]])],,
             with_grib="yes")
Uwe Schulzweida's avatar
Uwe Schulzweida committed
46

47
48
49
if test "${with_grib}" = "yes" ; then
  AC_DEFINE(HAVE_LIBGRIB, [1], [Define to 1 for GRIB interface])
fi
Uwe Schulzweida's avatar
Uwe Schulzweida committed
50
51
52
53
54
55
56
57
58
59

AC_MSG_CHECKING([for GRIB support])
AC_MSG_RESULT($with_grib)

#  ----------------------------------------------------------------------
#  Compile interface with internal SERVICE library
#
AC_ARG_WITH([service],
            [AC_HELP_STRING([--with-service],
                            [Use the internal SERVICE library [default=yes]])],,
60
             with_service="yes")
Uwe Schulzweida's avatar
Uwe Schulzweida committed
61

62
63
64
if test "${with_service}" = "yes" ; then
  AC_DEFINE(HAVE_LIBSERVICE, [1], [Define to 1 for SERVICE interface])
fi
Uwe Schulzweida's avatar
Uwe Schulzweida committed
65
66
67
68
69
70
71
72
73
74

AC_MSG_CHECKING([for SERVICE support])
AC_MSG_RESULT($with_service)

#  ----------------------------------------------------------------------
#  Compile interface with internal EXTRA library
#
AC_ARG_WITH([extra],
            [AC_HELP_STRING([--with-extra],
                            [Use the internal EXTRA library [default=yes]])],,
75
             with_extra="yes")
Uwe Schulzweida's avatar
Uwe Schulzweida committed
76

77
78
79
if test "${with_extra}" = "yes" ; then
  AC_DEFINE(HAVE_LIBEXTRA, [1], [Define to 1 for EXTRA interface])
fi
Uwe Schulzweida's avatar
Uwe Schulzweida committed
80
81
82
83
84
85
86
87
88
89

AC_MSG_CHECKING([for EXTRA support])
AC_MSG_RESULT($with_extra)

#  ----------------------------------------------------------------------
#  Compile interface with internal IEG library
#
AC_ARG_WITH([ieg],
            [AC_HELP_STRING([--with-ieg],
                            [Use the internal IEG library [default=yes]])],,
90
             with_ieg="yes")
Uwe Schulzweida's avatar
Uwe Schulzweida committed
91

92
93
94
if test "${with_ieg}" = "yes" ; then
  AC_DEFINE(HAVE_LIBIEG, [1], [Define to 1 for IEG interface])
fi
Uwe Schulzweida's avatar
Uwe Schulzweida committed
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122

AC_MSG_CHECKING([for IEG support])
AC_MSG_RESULT($with_ieg)

#  ----------------------------------------------------------------------
# Begin DAP (aka DODS) support
# Store pre-DAP LIBS value to restore from later
LIBS_no_DAP="${LIBS}"

AC_ARG_ENABLE(dap,AS_HELP_STRING([--enable-dap],[Build OPeNDAP/DODS-enabled clients if possible [[default=no]]]),enable_dap=${enableval},enable_dap=no)

if test "${enable_dap}" = "yes"; then
   if which ncdap-config > /dev/null; then
      CPPFLAGS="${CPPFLAGS} `ncdap-config --cflags`"
      nc_dap_ver=`ncdap-config --version`
      LIBS="`ncdap-config --libs` ${LIBS}"	
   else
      AC_MSG_ERROR(couldn't find ncdap-config)     
   fi
fi

#  ----------------------------------------------------------------------
#  Is the netcdf present? It has a header file `netcdf.h' and a library
#  `-lnetcdf' and their locations might be specified with the `--with-netcdf'
#  command-line switch. The value is an include path and/or a library path.
#  If the library path is specified then it must be preceded by a comma.
#
AC_ARG_WITH([netcdf],
123
124
            [AC_HELP_STRING([--with-netcdf=<directory>],
                            [Specify location of netCDF library. Configure will expect to find subdirs include and lib.])],,
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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
            withval=no)

case $withval in
  yes)
    HAVE_NETCDF="yes"
    AC_CHECK_HEADERS(netcdf.h)
    AC_CHECK_LIB(netcdf, nc_open,, unset HAVE_NETCDF)

    if test -z "$HAVE_NETCDF" -a -n "$CONFIG_ABORT"; then
      AC_MSG_ERROR(couldn't find netCDF library)
    fi
    ;;
  no)
    HAVE_NETCDF="no"
    AC_MSG_CHECKING(for netCDF library)
    AC_MSG_RESULT(suppressed)
    ;;
  *)
    HAVE_NETCDF="yes"
    case "$withval" in
      *,*)
        netcdf_inc="`echo $withval |cut -f1 -d,`"
        netcdf_lib="`echo $withval |cut -f2 -d, -s`"
        ;;
      *)
        if test -n "$withval"; then
          netcdf_inc="$withval/include"
          netcdf_lib="$withval/lib"
        fi
        ;;
    esac

#   Trying to include -I/usr/include and -L/usr/lib is redundant and
#   can mess some compilers up.
    if test "X$netcdf_inc" = "X/usr/include"; then
      netcdf_inc=""
    fi
    if test "X$netcdf_lib" = "X/usr/lib"; then
      netcdf_lib=""
    fi

#   Trying to include -I/usr/local/include and -L/usr/local/lib is redundant and
#   can mess some compilers up.
    if test "X$netcdf_inc" = "X/usr/local/include"; then
      netcdf_inc=""
    fi
    if test "X$netcdf_lib" = "X/usr/local/lib"; then
      netcdf_lib=""
    fi

    saved_CPPFLAGS="$CPPFLAGS"
    saved_LDFLAGS="$LDFLAGS"

    if test -n "$netcdf_inc"; then
      CPPFLAGS="$CPPFLAGS -I$netcdf_inc"
    fi

    AC_CHECK_HEADERS(netcdf.h,, CPPFLAGS="$saved_CPPFLAGS")

    if test -n "$netcdf_lib"; then
      LDFLAGS="$LDFLAGS -L$netcdf_lib"
    fi

    if test "${enable_dap}" = "yes"; then
      AC_CHECK_LIB(nc-dap, nc_open,, LDFLAGS="$saved_LDFLAGS"; unset HAVE_NETCDF)
if test $ac_cv_lib_nc_dap_nc_open = yes; then
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBNETCDF 1
_ACEOF
fi
    else
      AC_CHECK_LIB(netcdf, nc_open,, LDFLAGS="$saved_LDFLAGS"; unset HAVE_NETCDF)
    fi

    if test -z "$HAVE_NETCDF" -a -n "$CONFIG_ABORT"; then
      AC_MSG_ERROR(couldn't find netCDF library)
    fi
    ;;
esac

205
206
207
208
209
210
211
212
#  ----------------------------------------------------------------------
#  Compile interface with SZLIB library
#
AC_MSG_CHECKING([whether a location for the SZLIB library was specified])
AC_ARG_WITH([szlib],
            [AS_HELP_STRING([--with-szlib=<directory>],
                            [Specify location of SZLIB library. Configure will expect to find subdirs include and lib.])],
            [SZLIBDIR=$with_szlib])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
213
214
215
216
217
218
219
220
221
if test -z "$SZLIBDIR" ; then
  AC_MSG_RESULT([no])
else
  AC_MSG_RESULT([$SZLIBDIR])
  LDFLAGS="$LDFLAGS -L$SZLIBDIR/lib"
  CPPFLAGS="$CPPFLAGS -I$SZLIBDIR/include"
  AC_CHECK_LIB(sz, SZ_BufftoBuffCompress, , LDFLAGS="$LDFLAGS")
# AC_SUBST([SZLIBDIR], [$SZLIBDIR])
fi
222
223

#  Check C / Fortran interface
Uwe Schulzweida's avatar
Uwe Schulzweida committed
224
225
226
227
UD_CHECK_CFINT([$srcdir/src/cfortran.h])

AC_SUBST([FC],$F77)
AC_SUBST([CFINT])
228
AC_SUBST([CPPFLAGS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
229
230
AC_SUBST([AR])

Uwe Schulzweida's avatar
Uwe Schulzweida committed
231
AC_OUTPUT(Makefile src/Makefile app/Makefile tests/Makefile examples/Makefile)
Uwe Schulzweida's avatar
Uwe Schulzweida committed
232
233
234
235
236
237
238

AC_MSG_NOTICE([

  Configuration completed.

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