acx_options.m4 34.3 KB
Newer Older
1 2 3
AC_DEFUN([ACX_OPTIONS],
[
#  ----------------------------------------------------------------------
4
#  Checks for multithreaded compiling + linking
Uwe Schulzweida's avatar
Uwe Schulzweida committed
5
ENABLE_THREADS=no
6
AC_ARG_WITH([threads],
7
            [AC_HELP_STRING([--with-threads=<yes/no/directory>],
8
                            [Compile + link for multithreading [default=yes]])],
9 10
            [],
            [with_threads=yes])
11 12
THREADS_INCLUDE=''
THREADS_LIBS=''
13
AS_CASE([$with_threads],
14
        [no],[AC_MSG_CHECKING([multithreading])
15
              AC_MSG_RESULT([suppressed])],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
16 17
        [yes],[AX_PTHREAD([AC_DEFINE([HAVE_LIBPTHREAD],[1],[Define 1 for multithread support])
                           ENABLE_THREADS=yes],[AC_MSG_ERROR([multithreaded settings NOT found])])
18 19
               LIBS="$PTHREAD_LIBS $LIBS"
               CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
20
               CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
21
               CC="$PTHREAD_CC"
22
               AS_ECHO(["CC:$CC CFLAGS:$CFLAGS LIBS:$LIBS"])],
23
        [*],[THREADS_ROOT=$with_threads
24 25
             LDFLAGS="-L$THREADS_ROOT/lib $LDFLAGS"
             CPPFLAGS="-I$THREADS_ROOT/include $CPPFLAGS "
26 27
             AC_CHECK_HEADERS(pthread.h)
             AC_CHECK_LIB([pthread],[pthread_create])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
28
             ENABLE_THREADS=yes
29 30
             THREADS_LIBS=" -L$THREADS_ROOT/lib -lpthread"
             THREADS_INCLUDE=" -I$THREADS_ROOT/include"])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
31
AC_SUBST([ENABLE_THREADS])
32 33
AC_SUBST([THREADS_INCLUDE])
AC_SUBST([THREADS_LIBS])
34
#  ----------------------------------------------------------------------
35
#  Compile application with SZLIB library, needed for GRIB1 linking
36 37
SZLIB_INCLUDE=''
SZLIB_LIBS=''
38
AC_ARG_WITH([szlib],
39
            [AS_HELP_STRING([--with-szlib=<yes|no|directory> (default=no)],[location of szlib library, optional for GRIB1 compression])],
40 41 42 43 44 45 46 47
            [AS_CASE(["$with_szlib"],
                     [no],[AC_MSG_CHECKING([for szlib library])
                           AC_MSG_RESULT([suppressed])],
                     [yes],[AC_CHECK_HEADERS(szlib.h)
                            AC_SEARCH_LIBS([SZ_BufftoBuffCompress],
                                           [sz],
                                           [AC_DEFINE([HAVE_LIBSZ],[1],[Define to 1 for SZIP support])],
                                           [AC_MSG_ERROR([Could not link to szlib])])
48
                            SZLIB_LIBS=" -lsz"],
49 50
                     [*],[SZLIB_ROOT=$with_szlib
                          AS_IF([test -d "$SZLIB_ROOT"],
Ralf Müller's avatar
Ralf Müller committed
51
                                [LDFLAGS="-L$SZLIB_ROOT/lib $LDFLAGS"
52
                                 CPPFLAGS="-I$SZLIB_ROOT/include $CPPFLAGS"
53 54 55 56 57
                                 AC_CHECK_HEADERS(szlib.h)
                                 AC_SEARCH_LIBS([SZ_BufftoBuffCompress],
                                                [sz],
                                                [AC_DEFINE([HAVE_LIBSZ],[1],[Define to 1 for SZIP support])],
                                                [AC_MSG_ERROR([Could not link to szlib])])
58 59
                                 SZLIB_LIBS=" -L$SZLIB_ROOT/lib -lsz"
                                 SZLIB_INCLUDE=" -I$SZLIB_ROOT/include"],
60 61 62
                                [AC_MSG_NOTICE([$SZLIB_ROOT is not a directory! SZLIB suppressed])])])],
            [AC_MSG_CHECKING([for szlib library])
             AC_MSG_RESULT([suppressed])])
63 64
AC_SUBST([SZLIB_INCLUDE])
AC_SUBST([SZLIB_LIBS])
65 66
#  ----------------------------------------------------------------------
#  Link application with HDF5 library, required for netcdf4
67 68 69
HDF5_ROOT=''
HDF5_INCLUDE=''
HDF5_LIBS=''
70
AC_ARG_WITH([hdf5],
71
            [AS_HELP_STRING([--with-hdf5=<yes|no|directory> (default=no)],[location of HDF5 library])],
72 73 74 75 76 77 78
            [AS_CASE(["$with_hdf5"],
                     [no],[AC_MSG_CHECKING([for hdf5 library])
                           AC_MSG_RESULT([suppressed])],
                     [yes],[AC_CHECK_HEADERS([hdf5.h])
                            AC_SEARCH_LIBS([H5Fopen],
                                           [hdf5],
                                           [AC_DEFINE([HAVE_LIBHDF5],[1],[Define to 1 for HDF5 support])],
79
                                           [AC_MSG_ERROR([Cannot link to hdf5 library!])])
80 81 82
                            AC_SEARCH_LIBS([H5DSis_scale],
                                           [hdf5_hl],
                                           [have_hdf5_hl=yes],
83
                                           [AC_MSG_NOTICE([Cannot find hdf5 high level interface!])
84
                                            have_hdf5_hl=no])
85 86 87 88 89 90 91
                            AS_IF([test "x$have_libhdf5_hl" = xyes],
                                  [HDF5_LIBS=" -lhdf5_hl -lhdf5"],
                                  [HDF5_LIBS=" -lhdf5"])
                            ],
                     [*],[AS_IF([test -d "$with_hdf5"],
                                [HDF5_ROOT="$with_hdf5"
                                 LDFLAGS="-L$HDF5_ROOT/lib $LDFLAGS"
92
                                 CPPFLAGS="-I$HDF5_ROOT/include $CPPFLAGS"
93 94 95 96
                                 AC_CHECK_HEADERS([hdf5.h])
                                 AC_SEARCH_LIBS([H5Fopen],
                                                [hdf5],
                                                [AC_DEFINE([HAVE_LIBHDF5],[1],[Define to 1 for HDF5 support])],
97
                                                [AC_MSG_ERROR([Cannot link to hdf5!])])
98 99 100
                                 AC_SEARCH_LIBS([H5DSis_scale],
                                                [hdf5_hl],
                                                [have_hdf5_hl=yes],
101
                                                [AC_MSG_NOTICE([Cannot link to hdf5 high level interface!])
102 103
                                                have_hdf5_hl=no])
                                 AS_IF([test "x$have_libhdf5_hl" = 'xyes'],
104 105 106 107
                                       [HDF5_LIBS=" -L$HDF5_ROOT/lib -lhdf5_hl -lhdf5"],
                                       [HDF5_LIBS=" -L$HDF5_ROOT/lib -lhdf5"])
                                 HDF5_INCLUDE=" -I$HDF5_ROOT/include"],
                                [AC_MSG_NOTICE([$with_hdf5 is not a directory! HDF5 suppressed])])])],
108 109
            [AC_MSG_CHECKING([for hdf5 library])
             AC_MSG_RESULT([suppressed])])
110 111 112
AC_SUBST([HDF5_ROOT])
AC_SUBST([HDF5_INCLUDE])
AC_SUBST([HDF5_LIBS])
113 114
#  ----------------------------------------------------------------------
#  Compile application with netcdf
115 116 117
NETCDF_ROOT=''
NETCDF_INCLUDE=''
NETCDF_LIBS=''
Uwe Schulzweida's avatar
Uwe Schulzweida committed
118 119 120
ENABLE_NETCDF=no
ENABLE_NC2=no
ENABLE_NC4=no
121
ENABLE_NC4HDF5=no
122
AC_ARG_WITH([netcdf],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
123
            [AS_HELP_STRING([--with-netcdf=<yes|no|directory> (default=no)],[location of NetCDF library (lib and include subdirs)])],
124
            [AS_CASE(["$with_netcdf"],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
125
                     [no],[AC_MSG_CHECKING([for NetCDF library])
126 127 128 129
                           AC_MSG_RESULT([suppressed])],
                     [yes],[AC_CHECK_HEADERS([netcdf.h])
                            AC_SEARCH_LIBS([nc_open],
                                           [netcdf],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
130
                                           [AC_DEFINE([HAVE_LIBNETCDF],[1],[Define to 1 for NetCDF support])
131
                                            ENABLE_NETCDF=yes],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
132
                                           [AC_MSG_ERROR([Could not link to NetCDF library])])
133 134 135
                            NETCDF_LIBS=" -lnetcdf"
                            AC_CHECK_PROG(NC_CONFIG,nc-config,nc-config)
                            AS_IF([test "x$NC_CONFIG" != "x"],
136 137 138 139
                                  [AC_MSG_CHECKING([netcdf's OpenDAP support])
                                   AS_IF([test "x$($NC_CONFIG --has-dap)" = "xyes"],
                                         [AC_DEFINE([HAVE_LIBNC_DAP],[1],[Define to 1 for NetCDF OpenDAP])
                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])]
140 141
                                  [AC_MSG_CHECKING([netcdf's nc2 support])
                                   AS_IF([test "x$($NC_CONFIG --has-nc2)" = "xyes"],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
142
                                         [AC_DEFINE([HAVE_NETCDF2],[1],[Define to 1 for NetCDF2 support])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
143
                                          ENABLE_NC2=yes
144 145 146
                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
                                   AC_MSG_CHECKING([netcdf's nc4 support])
                                   AS_IF([test "x$($NC_CONFIG --has-nc4)" = "xyes"],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
147
                                         [AC_DEFINE([HAVE_NETCDF4],[1],[Define to 1 for NetCDF4 support])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
148
                                          ENABLE_NC4=yes
149 150 151
                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
			           AC_MSG_CHECKING([netcdf's nc4/hdf5 support])
                                   AS_IF([test "x$($NC_CONFIG --has-hdf5)" = "xyes"],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
152
                                         [AC_DEFINE([HAVE_NC4HDF5],[1],[Define to 1 for NetCDF4/HDF5 support])
153 154
                                          ENABLE_NC4HDF5=yes
                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])]) ],
155 156 157 158
                                  [AS_ECHO([Could not find nc-config! go on with default configuration])])],
                     [*],[AS_IF([test -d "$with_netcdf"],
                                [NETCDF_ROOT=$with_netcdf
                                 LDFLAGS="-L$NETCDF_ROOT/lib $LDFLAGS"
159
                                 CPPFLAGS="-I$NETCDF_ROOT/include $CPPFLAGS"
160 161 162
                                 AC_CHECK_HEADERS([netcdf.h])
                                 AC_SEARCH_LIBS([nc_open],
                                                [netcdf],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
163
                                                [AC_DEFINE([HAVE_LIBNETCDF],[1],[Define to 1 for NetCDF support])
164
                                                 ENABLE_NETCDF=yes],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
165
                                                [AC_MSG_ERROR([Could not link to NetCDF library])])
166 167 168 169 170 171 172
                                 NETCDF_LIBS=" -L$NETCDF_ROOT/lib -lnetcdf"
                                 NETCDF_INCLUDE=" -I$NETCDF_ROOT/include"
                                 AC_MSG_CHECKING([nc-config script])
                                 AC_CHECK_PROG(NC_CONFIG,nc-config,[$NETCDF_ROOT/bin/nc-config],,["$NETCDF_ROOT/bin"])
                                 AS_IF([test "x$NC_CONFIG" != "x"],
                                   [AC_MSG_CHECKING([netcdf's OpenDAP support])
                                   AS_IF([test "x$($NC_CONFIG --has-dap)" = "xyes"],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
173
                                         [AC_DEFINE([HAVE_LIBNC_DAP],[1],[Define to 1 for NetCDF OpenDAP])
174 175 176
                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])]
                                   [AC_MSG_CHECKING([netcdf's nc2 support])
                                   AS_IF([test "x$($NC_CONFIG --has-nc2)" = "xyes"],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
177
                                         [AC_DEFINE([HAVE_NETCDF2],[1],[Define to 1 for NetCDF2 support])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
178
                                          ENABLE_NC2=yes
179 180 181
                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
                                   AC_MSG_CHECKING([netcdf's nc4 support])
                                   AS_IF([test "x$($NC_CONFIG --has-nc4)" = "xyes"],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
182
                                         [AC_DEFINE([HAVE_NETCDF4],[1],[Define to 1 for NetCDF4 support])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
183
                                          ENABLE_NC4=yes
184 185 186
                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
			           AC_MSG_CHECKING([netcdf's nc4/hdf5 support])
                                   AS_IF([test "x$($NC_CONFIG --has-hdf5)" = "xyes"],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
187
                                         [AC_DEFINE([HAVE_NC4HDF5],[1],[Define to 1 for NetCDF4/HDF5 support])
188 189
                                          ENABLE_NC4HDF5=yes
                                          AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])]) ],
190
                                   [AC_MSG_RESULT([Could not find nc-config! go on with default configuration])])],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
191 192
                                [AC_MSG_NOTICE([$with_netcdf is not a directory! NetCDF suppressed])])])],
            [AC_MSG_CHECKING([for NetCDF library])
193
             AC_MSG_RESULT([suppressed])])
194 195 196

AS_IF([test "x$ENABLE_NC4HDF5" = "xyes"],
      [AC_SEARCH_LIBS([H5TS_mutex_lock], [netcdf],
197
               [AC_DEFINE([HAVE_NC4HDF5_THREADSAFE],[1],[Define to 1 for NetCDF4/HDF5 threadsafe support])],,[-lhdf5])])
198

199
AC_SUBST([ENABLE_NETCDF])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
200 201
AC_SUBST([ENABLE_NC2])
AC_SUBST([ENABLE_NC4])
202
AC_SUBST([ENABLE_NC4HDF5])
203 204 205
AC_SUBST([NETCDF_ROOT])
AC_SUBST([NETCDF_INCLUDE])
AC_SUBST([NETCDF_LIBS])
206
#  ----------------------------------------------------------------------
Uwe Schulzweida's avatar
Uwe Schulzweida committed
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
#  Link application with UDUNITS2 library
AC_ARG_WITH([udunits2],
            [AS_HELP_STRING([--with-udunits2=<directory>],
                            [Specify location of UDUNITS2 library.])],
            [AS_CASE(["$with_udunits2"],
                     [no],[AC_MSG_CHECKING([for udunits2 library])
                           AC_MSG_RESULT([suppressed])],
                     [yes],[AC_CHECK_HEADERS([udunits2.h])
                            AC_SEARCH_LIBS([ut_parse],
                                           [udunits2],
                                           [AC_DEFINE([HAVE_LIBUDUNITS2],[1],[Define to 1 for UDUNITS2 support])],
                                           [AC_MSG_ERROR([Could not link to udunits2 library!])])
                            AC_SUBST([UDUNITS_LDFLAGS],[" -ludunits2"])
                            AC_SUBST([UDUNITS_INCLUDE],[""])],
                     [*],[UDUNITS_ROOT=$with_udunits2
                          AS_IF([test -d "$UDUNITS_ROOT"],
                                [LDFLAGS="$LDFLAGS -L$UDUNITS_ROOT/lib"
224
                                 CPPFLAGS="$CPPFLAGS -I$UDUNITS_ROOT/include -I$UDUNITS_ROOT/include/udunits2"
Uwe Schulzweida's avatar
Uwe Schulzweida committed
225 226 227 228 229 230 231 232 233 234 235 236
                                 AC_CHECK_HEADERS([udunits2.h])
                                 AC_CHECK_HEADERS([udunits2/udunits2.h])
                                 AC_SEARCH_LIBS([ut_parse],
                                                [udunits2],
                                                [AC_DEFINE([HAVE_LIBUDUNITS2],[1],[Define to 1 for UDUNITS2 support])],
                                                [AC_MSG_ERROR([Could not link to udunits2 library!])])
                                 AC_SUBST([UDUNITS_LDFLAGS],[" -L$UDUNITS_ROOT/lib -ludunits2"])
                                 AC_SUBST([UDUNITS_INCLUDE],[" -I$UDUNITS_ROOT/include"])],
                                [AC_MSG_ERROR([$UDUNITS_ROOT is not a directory! UDUNITS2 suppressed])])])],
            [AC_MSG_CHECKING([for the UDUNITS2 library])
             AC_MSG_RESULT([suppressed])])
#  ----------------------------------------------------------------------
237 238 239
#  Link application with CMOR library
CMOR_LIBS=''
AC_ARG_WITH([cmor],
240
            [AS_HELP_STRING([--with-cmor=<directory>],[Specify location of CMOR library.])],
241 242 243 244 245 246 247 248 249 250
            [AS_CASE(["$with_cmor"],
                     [no],[AC_MSG_CHECKING([for cmor library])
                           AC_MSG_RESULT([suppressed])],
                     [yes],[AC_CHECK_HEADERS([cmor.h])
                            AC_SEARCH_LIBS([cmor_load_table],[cmor],[AC_DEFINE([HAVE_LIBCMOR],[1],[Define to 1 for CMOR support])],
                                           [AC_MSG_ERROR([Could not link to cmor library!])])
                            AC_SUBST([CMOR_LIBS],[" -lcmor"])],
                     [*],[CMOR_ROOT=$with_cmor
                          AS_IF([test -d "$CMOR_ROOT"],
                                [LDFLAGS="$LDFLAGS -L$CMOR_ROOT/lib"
Thomas Jahns's avatar
Thomas Jahns committed
251 252 253
                                 LIBS_saved=$LIBS
                                 LIBS="${LIBS+${LIBS} }$UUID_C_LIB"
                                 CPPFLAGS="$CPPFLAGS -I$CMOR_ROOT/include -I$CMOR_ROOT/include/cdTime -I$CMOR_ROOT/include/json-c"
254 255 256 257
                                 AC_SEARCH_LIBS([cmor_load_table],
                                                [cmor],
                                                [AC_DEFINE([HAVE_LIBCMOR],[1],[Define to 1 for CMOR support])],
                                                [AC_MSG_ERROR([Could not link to cmor library!])])
258 259
                                 LIBS="${LIBS_saved} -lcmor"
                                 CMOR_LIBS=" -L$CMOR_ROOT/lib -lcmor"],
260 261 262 263 264
                                [AC_MSG_ERROR([$CMOR_ROOT is not a directory! CMOR suppressed])])])],
            [AC_MSG_CHECKING([for the CMOR library])
             AC_MSG_RESULT([suppressed])])
AC_SUBST([CMOR_LIBS])
#  ----------------------------------------------------------------------
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
#  Compile application with ECCODES library (for GRIB2 support)
ECCODES_INCLUDE=''
ECCODES_LIBS=''
ENABLE_GRIBAPI=no
AC_ARG_WITH([eccodes],
            [AS_HELP_STRING([--with-eccodes=<yes|no|directory> (default=no)],[location of ECCODES library (lib and include subdirs)])],
            [AS_CASE(["$with_eccodes"],
                     [no],[AC_MSG_CHECKING([for ECCODES library])
                           AC_MSG_RESULT([suppressed])],
                     [yes],[AC_CHECK_HEADERS([grib_api.h])
                            AC_SEARCH_LIBS([grib_get_message],
                                           [eccodes],
                                           [AC_DEFINE([HAVE_LIBGRIB_API],[1],[ECCODES library is present if defined to 1])
                                            ENABLE_GRIBAPI=yes],
                                           [AC_MSG_ERROR([Could not link to eccodes library])])],
                     [*],[ECCODES_ROOT=$with_eccodes
                          AS_IF([test -d "$ECCODES_ROOT"],
                                [LDFLAGS="-L$ECCODES_ROOT/lib $LDFLAGS"
                                 CPPFLAGS="-I$ECCODES_ROOT/include $CPPFLAGS"
                                 AC_CHECK_HEADERS([grib_api.h])
                                 AC_SEARCH_LIBS([grib_get_message],
                                                [eccodes],
                                                [AC_DEFINE([HAVE_LIBGRIB_API],[1],[ECCODES library is present if defined to 1])
                                                 ENABLE_GRIBAPI=yes],
                                                [AC_MSG_ERROR([Could not link to eccodes library])])
                                 ECCODES_LIBS=" -L$ECCODES_ROOT/lib -leccodes"
                                 ECCODES_INCLUDE=" -I$ECCODES_ROOT/include"],
                                [AC_MSG_ERROR([$ECCODES_ROOT is not a directory! ECCODES suppressed])])])],
            [AC_MSG_CHECKING([for the ECCODES library])
             AC_MSG_RESULT([suppressed])])
AC_SUBST([ECCODES_INCLUDE])
AC_SUBST([ECCODES_LIBS])
#AC_SUBST([ENABLE_GRIBAPI])
#  ----------------------------------------------------------------------
299
#  Compile application with GRIB_API library (for GRIB2 support)
300 301
GRIB_API_INCLUDE=''
GRIB_API_LIBS=''
302
#ENABLE_GRIBAPI=no
303
AC_ARG_WITH([grib_api],
304
            [AS_HELP_STRING([--with-grib_api=<yes|no|directory> (default=no)],[location of GRIB_API library (lib and include subdirs)])],
305 306 307 308 309 310
            [AS_CASE(["$with_grib_api"],
                     [no],[AC_MSG_CHECKING([for GRIB_API library])
                           AC_MSG_RESULT([suppressed])],
                     [yes],[AC_CHECK_HEADERS([grib_api.h])
                            AC_SEARCH_LIBS([grib_get_message],
                                           [grib_api],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
311 312
                                           [AC_DEFINE([HAVE_LIBGRIB_API],[1],[GRIB_API library is present if defined to 1])
                                            ENABLE_GRIBAPI=yes],
313 314 315
                                           [AC_MSG_ERROR([Could not link to grib_api library])])],
                     [*],[GRIB_API_ROOT=$with_grib_api
                          AS_IF([test -d "$GRIB_API_ROOT"],
316
                                [LDFLAGS="-L$GRIB_API_ROOT/lib $LDFLAGS"
317
                                 CPPFLAGS="-I$GRIB_API_ROOT/include $CPPFLAGS"
318 319 320
                                 AC_CHECK_HEADERS([grib_api.h])
                                 AC_SEARCH_LIBS([grib_get_message],
                                                [grib_api],
Uwe Schulzweida's avatar
Uwe Schulzweida committed
321 322
                                                [AC_DEFINE([HAVE_LIBGRIB_API],[1],[GRIB_API library is present if defined to 1])
                                                 ENABLE_GRIBAPI=yes],
323
                                                [AC_MSG_ERROR([Could not link to grib_api library])])
324 325
                                 GRIB_API_LIBS=" -L$GRIB_API_ROOT/lib -lgrib_api"
                                 GRIB_API_INCLUDE=" -I$GRIB_API_ROOT/include"],
326 327 328
                                [AC_MSG_ERROR([$GRIB_API_ROOT is not a directory! GRIB_API suppressed])])])],
            [AC_MSG_CHECKING([for the GRIB_API library])
             AC_MSG_RESULT([suppressed])])
329 330
AC_SUBST([GRIB_API_INCLUDE])
AC_SUBST([GRIB_API_LIBS])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
331
AC_SUBST([ENABLE_GRIBAPI])
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391
#  ----------------------------------------------------------------------
#  Enable GRIB support
AC_MSG_CHECKING([for GRIB support])
AC_ARG_ENABLE([grib],
              [AS_HELP_STRING([--enable-grib],[GRIB support [default=yes]])],
              [AS_IF([test "x$enable_grib" != 'xno'],
                     [AC_DEFINE(HAVE_LIBGRIB, [1], [Define to 1 for GRIB support])
                      enable_grib=yes])],
              [AC_DEFINE(HAVE_LIBGRIB, [1], [Define to 1 for GRIB support])
               enable_grib=yes])
AC_MSG_RESULT([$enable_grib])
AC_SUBST([ENABLE_GRIB],[$enable_grib])
#  ----------------------------------------------------------------------
#  Compile interface with internal CGRIBEX library
AC_MSG_CHECKING([for CGRIBEX support])
AC_ARG_ENABLE([cgribex],
              [AC_HELP_STRING([--enable-cgribex],[Use the CGRIBEX library [default=yes]])],
              [AS_IF([test "x$enable_cgribex" != 'xno'],
                     [AC_DEFINE(HAVE_LIBCGRIBEX,[1],[Define to 1 for GRIB1 decoding/encoding with cgribex])
                      enable_cgribex=yes])],
              [AC_DEFINE(HAVE_LIBCGRIBEX,[1],[Define to 1 for GRIB1 decoding/encoding with cgribex])
               enable_cgribex=yes])
AC_MSG_RESULT([$enable_cgribex])
AC_SUBST([ENABLE_CGRIBEX],[$enable_cgribex])
#  ----------------------------------------------------------------------
#  Compile interface with internal SERVICE library
AC_MSG_CHECKING([for SERVICE support])
AC_ARG_ENABLE([service],
              [AC_HELP_STRING([--enable-service],[Use the service library [default=yes]])],
              [AS_IF([test "x$enable_service" != 'xno'],
                     [AC_DEFINE(HAVE_LIBSERVICE,[1],[Define to 1 for SERVICE interface])
                      enable_service=yes])],
              [AC_DEFINE(HAVE_LIBSERVICE,[1],[Define to 1 for SERVICE interface])
               enable_service=yes])
AC_MSG_RESULT([$enable_service])
AC_SUBST([ENABLE_SERVICE],[$enable_service])
#  ----------------------------------------------------------------------
#  Compile interface with internal EXTRA library
AC_MSG_CHECKING([for EXTRA support])
AC_ARG_ENABLE([extra],
              [AC_HELP_STRING([--enable-extra],[Use the extra library [default=yes]])],
              [AS_IF([test "x$enable_extra" != 'xno'],
                     [AC_DEFINE(HAVE_LIBEXTRA,[1],[Define to 1 for EXTRA interface])
                      enable_extra=yes])],
              [AC_DEFINE(HAVE_LIBEXTRA,[1],[Define to 1 for EXTRA interface])
               enable_extra=yes])
AC_MSG_RESULT([$enable_extra])
AC_SUBST([ENABLE_EXTRA],[$enable_extra])
#  ----------------------------------------------------------------------
#  Compile interface with internal IEG library
AC_MSG_CHECKING([for IEG support])
AC_ARG_ENABLE([ieg],
              [AC_HELP_STRING([--enable-ieg],[Use the ieg library [default=yes]])],
              [AS_IF([test "x$enable_ieg" != 'xno'],
                     [AC_DEFINE(HAVE_LIBIEG,[1],[Define to 1 for IEG interface])
                      enable_ieg=yes])],
              [AC_DEFINE(HAVE_LIBIEG,[1],[Define to 1 for IEG interface])
               enable_ieg=yes])
AC_MSG_RESULT([$enable_ieg])
AC_SUBST([ENABLE_IEG],[$enable_ieg])
Ralf Müller's avatar
6*8=42  
Ralf Müller committed
392 393 394 395
#  ----------------------------------------------------------------------
#  Compile with fftw support
AC_MSG_CHECKING([for FFTW3 support])
AC_ARG_WITH([fftw3],
396 397
    [AS_HELP_STRING([--with-fftw3],
      [enable support for fftw3])],
Ralf Müller's avatar
6*8=42  
Ralf Müller committed
398
    [],
399
    [with_fftw3=no])
Ralf Müller's avatar
6*8=42  
Ralf Müller committed
400 401 402 403 404 405 406

  AS_IF([test "x$with_fftw3" != xno],
      [AC_CHECK_HEADERS([fftw3.h])
    AC_SEARCH_LIBS([fftw_cleanup],[fftw3],
      [AC_DEFINE([HAVE_LIBFFTW3],[1],[FFTW3 library is present if defined to 1])],
      [AC_MSG_RESULT([Could not link to fftw3 library])])])

407 408 409 410 411 412 413 414
#  ----------------------------------------------------------------------
#  Checks for PROJ.4 library
AC_ARG_WITH([proj],
            [AS_HELP_STRING([--with-proj=<directory>],
                            [Specify location of PROJ library for cartographic projections.])],
            [AS_CASE(["$with_proj"],
                     [no],[AC_MSG_CHECKING([for proj library])
                           AC_MSG_RESULT([suppressed])],
415
                     [yes],[AC_CHECK_HEADERS([proj_api.h])
416 417 418 419 420 421
                            AC_SEARCH_LIBS([pj_init],[proj],[AC_DEFINE([HAVE_LIBPROJ],[1],[Define to 1 for PROJ support])],
                                           [AC_MSG_ERROR([Could not link to PROJ library!])])
                            AC_SUBST([PROJ_LDFLAGS],[" -lproj"])
                            AC_SUBST([PROJ_INCLUDE],[""])],
                     [*],[PROJ_ROOT=$with_proj
                          AS_IF([test -d "$PROJ_ROOT"],
Ralf Müller's avatar
Ralf Müller committed
422
                                [LDFLAGS="-L$PROJ_ROOT/lib $LDFLAGS"
423
                                 CPPFLAGS="-I$PROJ_ROOT/include $CPPFLAGS"
424
                                 AC_CHECK_HEADERS([proj_api.h])
425 426 427 428 429 430 431 432 433 434
                                 AC_SEARCH_LIBS([pj_init],
                                                [proj],
                                                [AC_DEFINE([HAVE_LIBPROJ],[1],[Define to 1 for PROJ support])],
                                                [AC_MSG_ERROR([Could not link to PROJ library!])])
                                 AC_SUBST([PROJ_LDFLAGS],[" -L$PROJ_ROOT/lib -lproj"])
                                 AC_SUBST([PROJ_INCLUDE],[" -I$PROJ_ROOT/include"])],
                                [AC_MSG_ERROR([$PROJ_ROOT is not a directory! PROJ suppressed])])])],
            [AC_MSG_CHECKING([for the PROJ library])
             AC_MSG_RESULT([suppressed])])
#  ----------------------------------------------------------------------
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461
#  Checks for CURL library
AC_ARG_WITH([curl],
            [AS_HELP_STRING([--with-curl=<directory>],
                            [Specify location of CURL library.])],
            [AS_CASE(["$with_curl"],
                     [no],[AC_MSG_CHECKING([for curl library])
                           AC_MSG_RESULT([suppressed])],
                     [yes],[AC_CHECK_HEADERS([curl/curl.h])
                            AC_SEARCH_LIBS([curl_global_init],[curl],[AC_DEFINE([HAVE_LIBCURL],[1],[Define to 1 for CURL support])],
                                           [AC_MSG_ERROR([Could not link to CURL library!])])
                            AC_SUBST([CURL_LDFLAGS],[" -lcurl"])
                            AC_SUBST([CURL_INCLUDE],[""])],
                     [*],[CURL_ROOT=$with_curl
                          AS_IF([test -d "$CURL_ROOT"],
                                [LDFLAGS="-L$CURL_ROOT/lib $LDFLAGS"
                                 CPPFLAGS="-I$CURL_ROOT/include $CPPFLAGS"
                                 AC_CHECK_HEADERS([curl/curl.h])
                                 AC_SEARCH_LIBS([curl_global_init],
                                                [curl],
                                                [AC_DEFINE([HAVE_LIBCURL],[1],[Define to 1 for CURL support])],
                                                [AC_MSG_ERROR([Could not link to CURL library!])])
                                 AC_SUBST([CURL_LDFLAGS],[" -L$CURL_ROOT/lib -lcurl"])
                                 AC_SUBST([CURL_INCLUDE],[" -I$CURL_ROOT/include"])],
                                [AC_MSG_ERROR([$CURL_ROOT is not a directory! CURL suppressed])])])],
            [AC_MSG_CHECKING([for the CURL library])
             AC_MSG_RESULT([suppressed])])
#  ----------------------------------------------------------------------
462
#  Compile application with MAGICS (xml required)
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493
MAGICS_ROOT=''
MAGICS_INCLUDE=''
MAGICS_LIBS=''
AC_ARG_WITH([magics],
            [AS_HELP_STRING([--with-magics=<yes|no|directory>],[location of magics library (lib and include subdirs)])],
            [AS_CASE(["$with_magics"],
                     [no],[AC_MSG_CHECKING([for magics library])
                           AC_MSG_RESULT([suppressed])],
                     [yes],[AC_CHECK_HEADERS([magics_api.h])
                            AC_SEARCH_LIBS([mag_open],
                                           [MagPlus],
                                           [AC_DEFINE([HAVE_LIBMAGICS],[1],[Define to 1 for MAGICS support])],
                                           [AC_MSG_ERROR([Could not link to magics library])])
                            AC_SUBST([MAGICS_LIBS],[" -lMagPlus"])],
                     [*],[AS_IF([test -d "$with_magics"],
                                [MAGICS_ROOT=$with_magics
                                 LDFLAGS="-L$MAGICS_ROOT/lib $LDFLAGS"
                                 CPPFLAGS="-I$MAGICS_ROOT/include/magics $CPPFLAGS"
                                 AC_CHECK_HEADERS([magics_api.h])
                                 AC_SEARCH_LIBS([mag_open],
                                                [MagPlus],
                                                [AC_DEFINE([HAVE_LIBMAGICS],[1],[Define to 1 for MAGICS support])],
                                                [AC_MSG_ERROR([Could not link to magics library])])
                                 MAGICS_LIBS=" -L$MAGICS_ROOT/lib -lMagPlus"
                                 MAGICS_INCLUDE=" -I$MAGICS_ROOT/include/magics"],
                                [AC_MSG_NOTICE([$with_magics is not a directory! MAGICS suppressed])])])],
            [AC_MSG_CHECKING([for MAGICS library])
             AC_MSG_RESULT([suppressed])])
AC_SUBST([MAGICS_ROOT])
AC_SUBST([MAGICS_INCLUDE])
AC_SUBST([MAGICS_LIBS])
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
AC_ARG_WITH([libxml2],
            [AS_HELP_STRING([--with-libxml2=<yes|no|directory>],[location of libxml2 library (lib and include subdirs)])],
            [AS_CASE(["$with_libxml2"],
                     [no],[AC_MSG_CHECKING([for libxml2 library])
                           AC_MSG_RESULT([suppressed])],
                     [yes],[CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2"
                            AC_CHECK_HEADERS([libxml/parser.h])
                            AC_CHECK_HEADERS([libxml/tree.h])
                            AC_SEARCH_LIBS([xmlInitMemory],
                                           [xml2],
                                           [AC_DEFINE([HAVE_LIBXML2],[1],[Define to 1 for XML2 support])],
                                           [AC_MSG_ERROR([Could not link to libxml2 library])])
                            AC_SUBST([XML2_LIBS],[" -lxml2"])],
                     [*],[AS_IF([test -d "$with_libxml2"],
                                [XML2_ROOT=$with_libxml2
                                 LDFLAGS="-L$XML2_ROOT/lib $LDFLAGS"
                                 CPPFLAGS="-I$XML2_ROOT/include/libxml2 $CPPFLAGS"
511 512
                                 AC_CHECK_HEADERS([libxml/parser.h])
                                 AC_CHECK_HEADERS([libxml/tree.h])
513 514 515 516 517 518 519 520 521 522
                                 AC_SEARCH_LIBS([xmlInitMemory],
                                                [xml2],
                                                [AC_DEFINE([HAVE_LIBXML2],[1],[Define to 1 for XML2 support])],
                                                [AC_MSG_ERROR([Could not link to libxml2 library])])
                                 XML2_LIBS=" -L$XML2_ROOT/lib -lxml2"
                                 XML2_INCLUDE=" -I$XML2_ROOT/include/libxml2"],
                                [AC_MSG_NOTICE([$with_libxml2 is not a directory! XML2 suppressed])])])],
            [AC_MSG_CHECKING([for XML2 library])
             AC_MSG_RESULT([suppressed])])
AM_CONDITIONAL([ENABLE_MAGICS],[test ! x$with_magics = 'x' -a ! x$with_libxml2 = 'x'])
523
#  ----------------------------------------------------------------------
524
#  How to build CDI into CDO? 
525
INTERNAL_CDI_DIR=libcdi
526
# At the moment, there are two possible CDI bindings
527 528
# (default)          linking directly to CDI's object files, i.e. a libtool
#                    convenience library
529
# (--enable-cdi-lib) build and link to a shared CDI library
530
AC_MSG_CHECKING([for build a separate CDI library and link CDO to it])
531
AC_ARG_ENABLE([cdi-lib],
532
              [AS_HELP_STRING([--enable-cdi-lib],[build, install and link to a CDI library [default=no]])],
533 534
              [AS_IF([test "x$enable_cdi_lib" != "xno"],
                     [enable_cdi_lib=yes],
535 536 537 538 539 540
                     [enable_cdi_lib=no
                      CDO_DISABLE_CDILIB=1
                      export CDO_DISABLE_CDILIB])],
              [enable_cdi_lib=no
               CDO_DISABLE_CDILIB=1
               export CDO_DISABLE_CDILIB])
541 542 543 544 545
AC_MSG_RESULT([$enable_cdi_lib])
# save CDI binding mode for later automake use
AM_CONDITIONAL([ENABLE_CDI_LIB],[test x$enable_cdi_lib = 'xyes'])
# create shell variables for the representation of configure results
AS_IF([test x$enable_cdi_lib = 'xno'],[AC_SUBST([ENABLE_CDI_LIB],[false])],[AC_SUBST([ENABLE_CDI_LIB],[true])])
Ralf Müller's avatar
Ralf Müller committed
546
# scan for CDI as a subproject
547
AC_CONFIG_SUBDIRS([libcdi])
548 549 550 551 552 553 554 555 556 557 558
#  ----------------------------------------------------------------------
#  Build a static CDO
AC_MSG_CHECKING([for building an additional static CDO binary])
AC_ARG_ENABLE([all-static],
              [AS_HELP_STRING([--enable-all-static],[build a completely statically linked CDO binary [default=no]])],
              [AS_IF([test "x$enable_all_static" != "xno"],
                     [enable_all_static=yes],
                     [enable_all_static=no])],
              [enable_all_static=no])
AC_MSG_RESULT([$enable_all_static])
AM_CONDITIONAL([ENABLE_ALL_STATIC],[test x$enable_all_static = 'xyes'])
559 560 561 562 563 564 565 566 567 568 569 570 571
#  ----------------------------------------------------------------------
#  Build CDO with HIRLAM extensions
AC_MSG_CHECKING([for HIRLAM extensions])
AC_ARG_ENABLE([hirlam-extensions],
              [AS_HELP_STRING([--enable-hirlam-extensions],[HIRLAM extensions [default=no]])],
              [AS_IF([test "x$enable_hirlam_extensions" != "xno"],
                    [AC_DEFINE(HIRLAM_EXTENSIONS,[1],[Define to 1 for HIRLAM extensions])
                     enable_hirlam_extensions=yes],
                    [enable_hirlam_extensions=no])],
              [enable_hirlam_extensions=no])
AC_MSG_RESULT([$enable_hirlam_extensions])
AM_CONDITIONAL([ENABLE_HIRLAM_EXTENSIONS],[test x$enable_hirlam_extensions = 'xyes'])
#
572
])
Uwe Schulzweida's avatar
Uwe Schulzweida committed
573 574 575 576
dnl
dnl Local Variables:
dnl mode: autoconf
dnl End: