AC_INIT(gdl, 0.9.4 CVS)
AC_CONFIG_MACRO_DIR([m4])

dnl == Configuration (of the configure script)  ============
dnl ========================================================

dnl default: build standalone version on GDL
PYTHON_MODULE="no"

dnl optional-packages defaults:
dnl  - yes = require by default
dnl  - no  = needs explicit enabling
if test "x$with_readlinedir" = "x"; then with_readlinedir=yes; fi
if test "x$with_wxWidgets"   = "x"; then with_wxWidgets=yes;   fi
if test "x$with_udunits"     = "x"; then with_udunits=no;      fi
if test "x$with_grib"        = "x"; then with_grib=no;         fi
if test "x$with_Magick"      = "x"; then with_Magick=yes;      fi
if test "x$with_GraphicsMagick" = "x"; then with_GraphicsMagick=no;      fi
if test "x$with_eigen3"       = "x"; then with_eigen3=auto;      fi
if test "x$with_netcdf"      = "x"; then with_netcdf=yes;      fi
if test "x$with_hdf"         = "x"; then with_hdf=yes;         fi
if test "x$with_hdf5"        = "x"; then with_hdf5=yes;        fi
if test "x$with_fftw"        = "x"; then with_fftw=auto;       fi
if test "x$with_libproj4"    = "x"; then with_libproj4=no;     fi
if test "x$with_mpich"       = "x"; then with_mpich=no;        fi
if test "x$with_python"      = "x"; then with_python=yes;      fi
if test "x$with_gshhs"       = "x"; then with_gshhs=no;        fi
if test "x$with_pslib"       = "x"; then with_pslib=yes;       fi

dnl default DATADIR subdirectory 
datasubdir="gnudatalanguage"

dnl == some basics =========================================
dnl ======================================================== 

AM_CONFIG_HEADER(config.h)

AM_INIT_AUTOMAKE

AC_LANG(C++)
AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_LIBTOOL

dnl == Checking for 64-bit OS ==============================                                 
dnl ========================================================

AC_LANG_SAVE
AC_LANG_C
AC_MSG_CHECKING(for 64-bit OS)
AC_TRY_RUN([ int main () {
    if (sizeof(long) == 8) { return 0; } return 1; } ],
        result="yes", result="no", result="maybe" )
AC_MSG_RESULT($result)
if test "$result" = "yes"; then
    AC_DEFINE([HAVE_64BIT_OS], [1], [Define if 64-bit OS])
fi
AC_SUBST(HAVE_64BIT_OS)
AC_LANG_RESTORE

AC_SEARCH_LIBS([dlopen], [dl])
if test x"$ac_cv_search_dlopen" = x-ldl; then
LIBS="$LIBS -ldl"
fi

dnl == Python module (calling GDL from Python) =============
dnl ========================================================

dnl check if we build GDL standalone or the python module
AC_ARG_ENABLE(python_module,	
 	[  --enable-python_module  make GDL python module (default: standalone version)],
	[ PYTHON_MODULE="$enableval"
	])

if test "x$PYTHON_MODULE" = "xyes"; then
	AC_DEFINE([PYTHON_MODULE], [1], 
	[Define if you want to build the GDL python module])
fi
AM_CONDITIONAL(BUILDASLIBRARY, test "x$PYTHON_MODULE" = "xyes")

dnl == Checking presence of various headers/libs  ==========
dnl ========================================================

dnl related to portability of MEMORY() 
AC_CHECK_FUNCS([malloc_zone_statistics sbrk mallinfo])
AC_CHECK_HEADERS([malloc.h malloc/malloc.h])

dnl related to portability of LOCALE_GET()
AC_CHECK_HEADERS([locale.h])

dnl used in histogram
AC_CHECK_FUNCS([nexttoward])

dnl used by SPAWN, UNIT=
AC_CHECK_HEADERS([ext/stdio_filebuf.h])

dnl == ncurses =============================================
dnl ========================================================

AC_ARG_WITH(ncursesdir,
 	[  --with-ncursesdir=DIR   specify the ncurses (or curses) directory tree ],
	[ LIBS="$LIBS -L$withval/lib"
         INCLUDES="$INCLUDES -I$withval/include"
       ])

AC_CHECK_LIB(ncurses, initscr, [AC_DEFINE([HAVE_LIBNCURSES],[1],
  [Define to 1 if you have the ncurses library (-lncurses).])
  LIBS="-lncurses $LIBS"],AC_CHECK_LIB(curses, initscr))

dnl == readline ============================================
dnl ========================================================

dnl readline (we need *GNU* readline)
AC_ARG_WITH(readlinedir,
 	[  --with-readlinedir=DIR  specify the GNU readline directory tree ],
	[ with_readlinedir="$withval"])

if test "x$with_readlinedir" != "xno"; then

  if test "x$with_readlinedir" != "xyes"; then
dnl make sure this directory get in the path first 
dnl as OS X provides another readline library
    LIBS="-L$with_readlinedir/lib -L$with_readlinedir $LIBS -lreadline"
    INCLUDES="$INCLUDES -I$with_readlinedir/include -I$with_readlinedir"
  else
    LIBS="$LIBS -lreadline"
  fi

  AC_CHECK_LIB(readline, stifle_history,
  	[ AC_DEFINE( [HAVE_LIBREADLINE], [1], [GNU readline library])],
        [
	echo ""
	echo "Error! GNU readline was not found."
	echo "       Use --with-readlinedir=no to expicitely disable it"
	echo "       Check the README or use configure --help for other libraries needed"
        echo ""
        echo "       (suitable Debian/Ubuntu package: libreadline5-dev)"
        echo "       (suitable Fedora package: readline-devel)"
	exit -1
	])

  AC_CHECK_LIB(readline, rl_get_screen_size,[
       AC_DEFINE([RL_GET_SCREEN_SIZE], [1], [GNU readline with rl_get_screen_size])],
        [
	echo ""
	echo "Warning! Older GNU readline without 'rl_get_screen_size' was found."
	echo "         For resized terminals the size might not be updated correctly"
	echo "         If this is a problem please install a recent version of readline"
	])
fi

dnl == zlib ================================================
dnl ========================================================

AC_ARG_WITH(zlibdir,	
	[  --with-zlibdir=DIR      specify the Zlib directory tree ],
	[with_zlib="$withval" ])

if test "x$with_zlib" = "x"; then
  with_zlib=yes
fi

if test "x$with_zlib" = "xno"; then
	echo ""	
	echo "Error! ZLIB library is obligatory."
        exit -1
fi

if test "x$with_zlib" != "xyes"; then
    LIBS="$LIBS -L$with_zlib/lib -lz"
    INCLUDES="$INCLUDES -I$with_zlib/include"
else
    LIBS="$LIBS -lz"
fi

AC_CHECK_LIB(z, gzopen, [AC_DEFINE([HAVE_LIBZ], [1], [Zlib library])], 
 	[
 	echo ""
 	echo "Error! zlib library is required but was not found"
 	echo "       Use --with-zlibdir=DIR to specify the zlib directory tree"
        echo ""
        echo "       (suitable Debian/Ubuntu package: zlib1g-dev)"
        echo "       (suitable Fedora package: zlib-devel)"
 	exit -1
 	])

dnl == OpenMP ==============================================
dnl ========================================================

dnl AC_OPENMP
dnl AC_PREREQ([2.63])
dnl if test "x$OPENMP_CXXFLAGS" != "x"; then
dnl   dnl this is just to force recompilation when OpenMP setting is changed
dnl   AC_DEFINE([HAVE_OPENMP], [1], [Use OpenMP])
dnl   CPPFLAGS="$CPPFLAGS $OPENMP_CXXFLAGS"
dnl   LDFLAGS="$LDFLAGS $OPENMP_CXXFLAGS"
dnl fi

AC_ARG_WITH(openmp,	
	[  --with-openmp=no        disable OpenMP utilization ],
	[with_openmp="$withval" ])

dnl default yes if omp.h found
openmp_autodetected=no
if test "x$with_openmp" = "x"; then
   AC_CHECK_HEADERS("omp.h", [
     with_openmp=yes
     openmp_autodetected=yes
     echo ""
     echo "OpenMP enabled (omp.h file was found)."
     echo "Try --with-openmp=no if your compiler does not support it (e.g. GCC < 4.2)"
     echo ""
   ], [
     with_openmp=no
     echo ""
     echo "OpenMP disabled (omp.h file was not found)."
     echo "Try --with-openmp=yes if your compiler does support it (e.g. GCC >= 4.2)"
     echo ""
   ])
fi

if test "x$with_openmp" != "xno"; then
	CPPFLAGS="$CPPFLAGS -fopenmp"
	LDFLAGS="$LDFLAGS -fopenmp"
fi


dnl == GSL =================================================
dnl ========================================================

AC_ARG_WITH(gsldir,	
	[  --with-gsldir=DIR       specify the GSL directory tree ],
	[with_gsl="$withval" ])

if test "x$with_gsl" = "x"; then
  with_gsl=yes
fi

if test "x$with_gsl" = "xno"; then	
	echo ""	
	echo "Error! Gnu Scientific Library (1.7 or higher) is mandatory"
        exit -1
fi

if test "x$with_gsl" != "xyes"; then
    LIBS="$LIBS -L$with_gsl/lib -lgsl -lgslcblas"
    INCLUDES="$INCLUDES -I$with_gsl/include"
else
    LIBS="$LIBS -lgsl -lgslcblas"
fi

AC_CHECK_LIB(gsl, gsl_ran_binomial_knuth, [], [
	echo ""
	echo "Error! Gnu Scientific Library (1.7 or higher) is mandatory"
        echo ""
        echo "       (suitable Debian/Ubuntu package: libgsl0-dev)"
        echo "       (suitable Fedora package: gsl-dev)"
	echo "       (suitable Gentoo package: sci-libs/gsl)"
        exit -1
	])
AC_CHECK_LIB(gslcblas, cblas_drot, [], [
	echo ""
	echo "Error! libgslcblas (part of GSL) is mandatory"
        exit -1
	])

dnl == PLPlot ==============================================
dnl ========================================================

AC_ARG_WITH(plplotdir,	
	[  --with-plplotdir=DIR    specify the plplot directory tree ],
	[with_plplot="$withval" ])

if test "x$with_plplot" = "x"; then
  with_plplot=yes
fi

if test "x$with_plplot" = "xno"; then	
	echo ""	
	echo "Error! PLPLOT library is mandatory."
        exit -1
fi

OLDPLPLOT="no"
AC_ARG_ENABLE(oldplplot,	
 	[  --enable-oldplplot      use plplot version prior to 5.9.0],
	[ OLDPLPLOT="$enableval"
	])

if test "x$OLDPLPLOT" = "xyes"; then
	AC_DEFINE([HAVE_OLDPLPLOT], [1], 
	[Define if you have a plplot version prior to 5.9.0])
fi

if test "x$with_plplot" != "xyes"; then
    LIBS="$LIBS -L$with_plplot/lib -lplplotd -lplplotcxxd"
    INCLUDES="$INCLUDES -I$with_plplot/include"
else
    LIBS="$LIBS -lplplotd -lplplotcxxd"
fi

dnl LIBS="$LIBS /usr/local/lib/libplplotd.a /usr/local/lib/libplplotcxxd.a"

AC_CHECK_LIB(plplotcxxd, plsexit, [AC_DEFINE([HAVE_LIBPLPLOTCXXD], [1], [plplot library])], 
	[
	echo ""
	echo "Error! plplot library is required but was not found"
	echo "       Use --with-plplotdir=DIR to specify the plplot directory tree"
        echo ""
        echo "       (suitable Debian/Ubuntu packages: libplplot-dev, [plplot9-driver-xwin])"
        echo "       (suitable Fedora package: plplot-devel)"
        echo "       (suitable Gentoo package: sci-libs/plplot)"
	exit -1
	])

dnl recent plplot (5.9.9-4) in Debian unstable version have hidden symbols

AC_CHECK_LIB(plplotcxxd,  c_plslabelfunc,
     	[AC_DEFINE([HAVE_PLPLOT_SLABELFUNC], [1], [plplot slabel library])],
	[
	echo ""
	echo "Warning, due to old plplot library, [XYZ]TICKFORMAT option for plot axis will not be supported."
	echo "you should upgrade to plplot version > 5.9.6"
	echo ""
	])

AC_CHECK_LIB(plplotcxxd,  plstrl,
     	[AC_DEFINE([PLPLOT_PRIVATE_NOT_HIDDEN], [1], [plplot private pb. library])],
	[
	echo ""
	echo "Using a plplot library without private functions - workarounds will be used."
	echo ""
	])

AC_CHECK_LIB(plplotcxxd, c_pllegend,
     	[AC_DEFINE([PLPLOT_HAS_LEGEND], [1], [plplot private pb. library])],
	[
	echo ""
	echo "Your plplot lib is too old for some gdl functions, please upgrade."
	echo ""
	])

if test "x$with_Magick" != "xno"; then
  # https://sourceforge.net/tracker/index.php?func=detail&aid=2974380&group_id=97659&atid=618683
  AC_CHECK_LIB(plplotd, plGetDrvDir, [
    echo ""
    echo "Warning! Dynamic drivers have to be disabled in plplot"
    echo "         to make plplot work with ImageMagic:"
    echo "         - use the -DENABLE_DYNDRIVERS=OFF cmake option when" 
    echo "           compiling plplot to disable dynamic drivers in plplot, or"
    echo "         - use --with-Magick=no here to not use ImageMagick in GDL."
    echo ""
  ])
fi


dnl == wxWidgets ===========================================
dnl ========================================================

AC_ARG_WITH(wxWidgets,	
  [  --with-wxWidgets=DIR    use wxWidgets (with optional path DIR) ],
  [with_wxWidgets="$withval" ])

if test "x$with_wxWidgets" != "xno"; then

  if test "x$with_wxWidgets" = "xyes"; then
    AC_PATH_PROG(wxConfig, wx-config, no) 
  else
    AC_PATH_PROG(wxConfig, wx-config, no, "$with_wxWidgets/bin")
  fi

  if test "x$wxConfig" = "xno"; then
    echo ""
    echo "Error! wxWidgets version 2.8 or later is required but was not found (wx-config program not found)"
    echo "       Use --with-wxWidgets=DIR to specify the wxWidgets directory tree"
    echo "       Use --with-wxWidgets=no  to not use it"
    echo "       Check the README or use configure --help for other libraries needed"
    echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
    echo ""
    echo "       (suitable Debian/Ubuntu package: libwxgtk2.8-dev)"
    echo "       (suitable Fedora package: wxGTK-devel)"
    echo "       (suitable Gentoo package: x11-libs/wxGTK)"
    exit -1
  else
    LIBS="$LIBS `wx-config --libs`"
    INCLUDES="$INCLUDES `wx-config --cxxflags`"
    dnl SA: this is needed to compile on Leopard
    dnl (see e.g. the "OpenGL bug section" in http://wiki.finkproject.org/index.php/Fink:Packaging:Preparing_for_10.5#OpenGL_Bug)
    dnl LDFLAGS="$LDFLAGS -Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib"
  fi

  AC_DEFINE([HAVE_LIBWXWIDGETS], [1], [wxWidgets library])

  # SA: the code below worked for me on Ubuntu and Macports... but it does not work e.g. on Fedora
  #
  #tmp="`wx-config --basename`-`wx-config --release`"
  #AC_CHECK_LIB($tmp, wxFatalSignalHandler, 
  #  [AC_DEFINE([HAVE_LIBWXWIDGETS], [1], [wxWidgets library])], [
  #    dnl SA: handling the multi-port wxWidgets installation case	 
  #    tmp="`wx-config --basename --toolkit=base`-`wx-config --release`"	 
  #    AC_CHECK_LIB($tmp, wxInteger_compare, [AC_DEFINE([HAVE_LIBWXWIDGETS], [1])], [
  #      echo ""
  #      echo "Error! wxWidgets version 2.8 or later is required but was not found"
  #      echo "       Use --with-wxWidgets=DIR to specify the wxWidgets directory tree"
  #      echo "       Use --with-wxWidgets=no  to not use it"
  #      echo "       Check the README or use configure --help for other libraries needed"
  #      echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
  #      exit -1
  #    ])
  #])
fi

dnl == ImageMagick =========================================
dnl ========================================================
 
AC_ARG_WITH(Magick,	
	[  --with-Magick[=DIR]       use ImageMagick package (with optional path DIR) ],
	[with_Magick="$withval" ])

if test "x$with_Magick" != "xno"; then
  if test "x$with_Magick" = "xyes"; then
    AC_PATH_PROG(MagickConfig, Magick++-config, no)
  else
    AC_PATH_PROG(MagickConfig, Magick++-config, no, "$with_Magick/bin")
  fi

  if test "x$MagickConfig" = "xno"; then
    AC_MSG_ERROR(ImageMagick is required but was not found (Magick++-config program not found)
      Use --with-Magick=DIR to specify the ImageMagick directory tree
      Use --with-Magick=no  to not use it
    
      (suitable Debian/Ubuntu package: libmagick++-dev)
      (suitable Fedora package: ImageMagick-c++-devel)
    )
  else
    LIBS="$LIBS `$MagickConfig --libs`"
    INCLUDES="$INCLUDES `$MagickConfig --cppflags`"
    LDFLAGS="$LDFLAGS `$MagickConfig --ldflags`"
  fi

  AC_CHECK_LIB(
    Magick++, 
    GetMagickVersion, 
    [AC_DEFINE([USE_MAGICK], [1], [Define if you want to use ImageMagick])], [
      AC_MSG_CHECKING(if adding X library path helps)
      AC_MSG_RESULT(?)
      AC_PATH_X
      LDFLAGS="$LDFLAGS -L$x_libraries"
      AC_CHECK_LIB(Magick++, GetMagickReleaseDate, AC_DEFINE([USE_MAGICK], [1]), [
        echo ""
        echo "Error! ImageMagick version 5.5.7 or later is required but was not found"
        echo "       Use --with-Magick=DIR to specify the ImageMagick directory tree"
        echo "       Use --with-Magick=no  to not use it"
        echo "       Check the README or use configure --help for other libraries needed"
        echo "       (--with-xxxdir = mandatory, --with-xxx = optional (--with-xxx=no to disable))"
        echo ""
        echo "       (suitable Debian/Ubuntu package: libmagick++-dev)"
        echo "       (suitable Fedora package: ImageMagick-c++-devel)"
        echo "       (suitable Fedora package: media-gfx/imagemagick)"
        exit -1
      ])
    ]
  )
fi
dnl == GraphicsMagick ======================================
dnl ========================================================
 
AC_ARG_WITH(GraphicsMagick,	
	[  --with-GraphicsMagick[=DIR]  use GraphicsMagick package (with optional path DIR) ],
	[with_GraphicsMagick="$withval" ])

if test "x$with_GraphicsMagick" != "xno"; then
  if test "x$with_GraphicsMagick" = "xyes"; then
    AC_PATH_PROG(GraphicsMagickConfig, GraphicsMagick++-config, no)
  else
    AC_PATH_PROG(GraphicsMagickConfig, GraphicsMagick++-config, no, "$with_GraphicsMagick/bin")
  fi

  if test "x$GraphicsMagickConfig" = "xno"; then
    AC_MSG_ERROR(GraphicsMagick is required but was not found (GraphicsMagick++-config program not found)
      Use --with-GraphicsMagick=DIR to specify the GraphicsMagick directory tree
      Use --with-GraphicsMagick=no  to not use it
    
      (suitable Debian/Ubuntu package: libmagick++-dev)
      (suitable Fedora package: GraphicsMagick-c++-devel)
    )
  else
    LIBS="$LIBS `$GraphicsMagickConfig --libs`"
    INCLUDES="$INCLUDES `$GraphicsMagickConfig --cppflags`"
    LDFLAGS="$LDFLAGS `$GraphicsMagickConfig --ldflags`"
  fi

  AC_CHECK_LIB(
    GraphicsMagick++, 
    GetMagickVersion, 
    [AC_DEFINE([USE_MAGICK], [1], [Define if you want to use GraphicsMagick])], [
      AC_MSG_CHECKING(if adding X library path helps)
      AC_MSG_RESULT(?)
      AC_PATH_X
      LDFLAGS="$LDFLAGS -L$x_libraries"
      AC_CHECK_LIB(GraphicsMagick++, GetMagickReleaseDate, AC_DEFINE([USE_MAGICK], [1]), [
        echo ""
        echo "Error! GraphicsMagick version 1.3 or later is required but was not found"
        echo "       Use --with-GraphicsMagick=DIR to specify the GraphicsMagick directory tree"
        echo "       Use --with-GraphicsMagick=no  to not use it"
        echo "       Check the README or use configure --help for other libraries needed"
        echo "       (--with-xxxdir = mandatory, --with-xxx = optional (--with-xxx=no to disable))"
        echo ""
        echo "       (suitable Debian/Ubuntu package: libgraphicsmagick++-dev)"
        echo "       (suitable Fedora package: graphicsMagick-c++-devel)"
        echo "       (suitable Fedora package: media-gfx/igraphicsmagick)"
        exit -1
      ])
    ]
  )
fi

dnl == Eigen3 =================================================
dnl ========================================================

if test "x$with_eigen3" = "xauto"; then
   AC_CHECK_FILE("/usr/include/eigen3/signature_of_eigen3_matrix_library",
   	[with_eigen3=yes], [with_eigen3=no])
   if test "x$with_eigen3" = "xyes"; then
     AC_DEFINE([USE_EIGEN], [1], [Define if you want to use Eigen lib.])
     INCLUDES="$INCLUDES -I/usr/include/eigen3/"
   fi
else
  AC_ARG_WITH(eigen3,	
 	[  --with-eigen3=DIR       specify the Eigen3 package ((with optional path DIR) ],
 	[with_eigen3="$withval" ])

  if test "x$with_eigen3" != "xno"; then
    AC_DEFINE([USE_EIGEN], [1], [Define if you want to use Eigen lib.])
    	 INCLUDES="$INCLUDES -I$with_eigen3"
  fi
fi
dnl == netCDF ==============================================
dnl ========================================================

AC_ARG_WITH(netcdf,	
	[  --with-netcdf[=DIR]       use netCDF package (with optional path DIR) ],
	[with_netcdf="$withval" ])

if test "x$with_netcdf" != "xno"; then

  if test "x$with_netcdf" = "xyes"; then
    AC_PATH_PROG(nc_config, nc-config, no) 
  else
    AC_PATH_PROG(nc_config, nc-config, no, "$with_netcdf/bin")
  fi  

  if test "x$nc_config" != "xno"; then
    LIBS="$LIBS `$nc_config --libs`"
    INCLUDES="$INCLUDES `$nc_config --cflags`"
    ncdfincdir="`$nc_config --prefix`/include" 
  else
    if test "x$with_netcdf" != "xyes"; then
	LIBS="$LIBS -L$with_netcdf/lib -lnetcdf"
	ncdfincdir="$with_netcdf/include"
    else
	LIBS="$LIBS -L/usr/lib/netcdf-3 -lnetcdf"
        ncdfincdir="/usr/include/netcdf-3"
    fi
    INCLUDES="$INCLUDES -I$ncdfincdir"
  fi

  AC_CHECK_LIB(netcdf, nc_open, [AC_DEFINE([USE_NETCDF], [1], [Define if you want to use netCDF])], [
    echo ""
    echo "Error! netCDF version 3.5.1 or later is required but was not found"
    echo "       Use --with-netcdf=DIR to specify the netcdf directory tree"
    echo "       Use --with-netcdf=no  to not use it"
    echo "       Check the README or use configure --help for other libraries needed"
    echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
    echo ""
    echo "       (suitable Debian/Ubuntu package: libnetcdf-dev)"
    echo "       (suitable Fedora package: netcdf-devel)"
    echo "       (suitable Fedora package: sci-libs/netcdf-cxx )"
    exit -1
    ])

  AC_CHECK_HEADERS("netcdf.h", [], [
    AC_CHECK_HEADERS("$ncdfincdir/netcdf.h", [], [
      echo ""
      echo "Error! netCDF installation seems not to be usable"
      echo "       This suggests a conflicting netCDF-HDF4 installation, e.g."
      echo "       - uninstalling HDF4 after installation of netCDF"
      echo "       - installing netCDF before HDF4" 
      exit -1
    ])
  ])

fi

dnl == HDF (version 4) =====================================
dnl ========================================================

AC_ARG_WITH(hdf,	
	[  --with-hdf[=DIR]          use HDF package (with optional path DIR) ],
	[with_hdf="$withval" ])

if test "x$with_hdf" != "xno"; then

  # on Debian the no-netcdf flavour of HDF4 libraries has an alt-suffixed naming
  _LIBS=$LIBS
  _INCLUDES=$INCLUDES
  for sfx in "dfalt" "df"; do

    if test "x$with_hdf" != "xyes"; then
      LIBS="$_LIBS -L$with_hdf/lib -L$with_hdf/lib/hdf -lmfh$sfx -l$sfx -ljpeg -lz"
      INCLUDES="$_INCLUDES -I$with_hdf/include -I$with_hdf/include/hdf"
    else
      LIBS="$_LIBS -L/usr/lib/hdf -lmfh$sfx -l$sfx -ljpeg -lz"
      INCLUDES="$_INCLUDES -I/usr/include/hdf"
    fi

    AC_CHECK_LIB($sfx, Hopen, [AC_DEFINE([USE_HDF], [1], [Define if you want to use HDF])], 
      AC_MSG_CHECKING([if linking with SZIP helps])
      echo ""
      AC_CHECK_LIB($sfx, Hclose, [
        LIBS="$LIBS -lsz"
        AC_DEFINE([USE_HDF], [1], [Define if you want to use HDF])
      ], [ 
        if test $sfx != "dfalt"; then
          echo ""
          echo "Error! HDF4 libraries were not found"
          echo "       Use --with-hdf=DIR to specify the HDF directory tree"
          echo "       Use --with-hdf=no  to not use it"
          echo "       Check the README or use configure --help for other libraries needed"
          echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
          echo ""
          echo "       (suitable Debian/Ubuntu package: libhdf4-alt-dev)"
          exit -1
        else
          continue # switchng to non-alt-suffixed naming
        fi
      ], [-lsz])
    )

    AC_CHECK_LIB(mfh$sfx, SDstart, [AC_DEFINE([USE_HDF], [1], [Define if you want to use HDF])], [ 
      echo ""
      echo "Error! HDF4 libraries were not found"
      echo "       Use --with-hdf=DIR to specify the HDF directory tree"
      echo "       Use --with-hdf=no  to not use it"
      echo "       Check the README or use configure --help for other libraries needed"
      echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
      echo ""
      echo "       (suitable Debian/Ubuntu package: libhdf4-alt-dev)"
      exit -1
    ])

    # checking if HDF4 was compiled with the '--disable-netcdf' option
    if test "x$with_netcdf" != "xno"; then
      AC_CHECK_LIB(mfh$sfx, sd_nccreate, [], [
        echo ""
        echo "Error! HDF4 needs to be configured with the --disable-netcdf option"
        echo "       in order to be used with the original netCDF library"
        echo "       (-alt suffixed HDF4 packages in case of Debian)"
        echo "       Check the INSTALL file of the HDF4 package for details"
        echo ""
        echo "       (suitable Debian/Ubuntu package: libhdf4-alt-dev)"
        echo "                                                ^^^"
        exit -1
      ])
    fi

    # all went OK with the alt-suffixed naming -> skipping tests for the non-alt-suffixed naming
    if test $sfx == "dfalt"; then break; fi

  done
fi

dnl == HDF5 ================================================
dnl ========================================================

AC_ARG_WITH(hdf5,	
	[  --with-hdf5[=DIR]         use HDF5 package (with optional path DIR) ],
	[with_hdf5="$withval" ])

if test "x$with_hdf5" != "xno"; then
  if test "x$with_hdf5" != "xyes"; then
    LIBS="$LIBS -L$with_hdf5/lib -L$with_hdf5/lib/hdf -L$with_hdf5/lib/hdf5 -lhdf5"
    INCLUDES="$INCLUDES -I$with_hdf5/include -I$with_hdf5/include/hdf -I$with_hdf5/include/hdf5"
  else
    INCLUDES="$INCLUDES -I/usr/include/hdf -I/usr/include/hdf5"
    LIBS="$LIBS -L/usr/lib/hdf -L/usr/lib/hdf5 -lhdf5"
  fi

  AC_CHECK_LIB(hdf5, H5Fopen, [AC_DEFINE([USE_HDF5], [1], [Define if you want to use HDF5])], 
    AC_MSG_CHECKING([if linking with SZIP helps])
    echo ""
    AC_CHECK_LIB(hdf5, H5Fclose, [
      LIBS="$LIBS -lsz"
      AC_DEFINE([USE_HDF5], [1], [Define if you want to use HDF5])
    ], [
    echo ""
    echo "Error! HDF version 5 is required but was not found"
    echo "       Use --with-hdf5=DIR to specify the HDF5 directory tree"
    echo "       Use --with-hdf5=no  to not use it"
    echo "       Check the README or use configure --help for other libraries needed"
    echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
    echo ""
    echo "       (suitable Debian/Ubuntu package: libhdf5-serial-dev)"
    echo "       (suitable Fedora package: hdf-devel)"
    exit -1
    ], [-lsz]))
fi

dnl == FFTW ================================================
dnl ========================================================

if test "x$with_fftw" = "xauto"; then 
  AC_CHECK_LIB(fftw3, fftw_malloc, [
    AC_CHECK_LIB(fftw3f, fftwf_malloc, [with_fftw=yes], [with_fftw=no])
  ], [with_fftw=no])
fi

AC_ARG_WITH(fftw,	
	[  --with-fftw[=DIR]         use FFTW package (with optional path DIR) ],
	[with_fftw="$withval" ])

if test "x$with_fftw" != "xno"; then
  if test "x$with_fftw" != "xyes"; then
    LIBS="$LIBS -L$with_fftw/lib -lfftw3"
    INCLUDES="$INCLUDES -I$with_fftw/include"
  else
    INCLUDES="$INCLUDES -I/usr/include"
    LIBS="$LIBS -lfftw3"
  fi

  AC_CHECK_LIB(fftw3, fftw_malloc, [AC_DEFINE([USE_FFTW], [1], [Define if you want to use FFTW])], [
    echo ""
    echo "Error! FFTW3 version 3 is required but was not found"
    echo "       Use --with-fftw=DIR to specify the FFTW directory tree"
    echo "       Use --with-fftw=no  to not use it"
    echo "       Check the README or use configure --help for other libraries needed"
    echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
    echo ""
    echo "       (suitable Debian/Ubuntu package: libfftw3-dev)"
    echo "       (suitable Fedora package: fftw-devel)"
    exit -1
    ])
fi

if test "x$with_fftw" != "xno"; then
  if test "x$with_fftw" != "xyes"; then
    LIBS="$LIBS -L$with_fftw/lib -lfftw3f"
    INCLUDES="$INCLUDES -I$with_fftw/include"
  else
    INCLUDES="$INCLUDES -I/usr/include"
    LIBS="$LIBS -lfftw3f"
  fi

  AC_CHECK_LIB(fftw3f, fftwf_malloc, [AC_DEFINE([USE_FFTW], [1], [Define if you want to use FFTW])], [
    echo ""
    echo "Error! FFTW3F version 3 is required but was not found"
    echo "       Use --with-fftw=DIR to specify the FFTW directory tree"
    echo "       Use --with-fftw=no  to not use it"
    echo "       Check the README or use configure --help for other libraries needed"
    echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
    exit -1
    ])
fi

dnl == LIBPROJ4 ============================================
dnl ========================================================

AC_ARG_WITH(libproj4,	
	[  --with-libproj4[=DIR]     use LIBPROJ4 package (with optional path DIR) ],
	[with_libproj4="$withval" ])

if test "x$with_libproj4" != "xno"; then
  if test "x$with_libproj4" != "xyes"; then
    LIBS="$LIBS -L$with_libproj4/lib -lproj4"
    INCLUDES="$INCLUDES -I$with_libproj4/include"
  else
    INCLUDES="$INCLUDES -I/usr/include"
    LIBS="$LIBS -lproj4"
  fi

  AC_CHECK_LIB(proj4, proj_init, [AC_DEFINE([USE_LIBPROJ], [1], 
  [Define if you want to use LIBPROJ4])], [])

  AC_CHECK_LIB(proj4, proj_init, [AC_DEFINE([USE_LIBPROJ_NEW], [1], 
  [Define if you want to use new LIBPROJ4])], [

     AC_CHECK_LIB(proj4, pj_init, [AC_DEFINE([USE_LIBPROJ], [1], 
     [Define if you want to use LIBPROJ4])], [
       echo ""
       echo "Error! LIBPROJ4 is required but was not found"
       echo "       Use --with-libproj4=DIR to specify the LIBPROJ4 directory tree"
       echo "       Use --with-libproj4=no  to not use it"
       echo "       Check the README or use configure --help for other libraries needed"
       echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
       exit -1
       ])
  ])
fi

dnl == MPICH ===============================================
dnl ========================================================

AC_ARG_WITH(mpich,	
	[  --with-mpich[=DIR]        use MPICH (experimental) (with optional path DIR) ],
	[with_mpich="$withval" ])

if test "x$with_mpich" != "xno"; then
  if test "x$with_mpich" != "xyes"; then
    LIBS="$LIBS -L$with_mpich/lib -lmpich"
    INCLUDES="$INCLUDES -I$with_mpich/include"
  else
    INCLUDES="$INCLUDES -I/usr/include"
    LIBS="$LIBS -lmpich"
  fi

  AC_CHECK_LIB(mpich, MPI_Init, [AC_DEFINE([USE_MPI], [1], [Define if you want to use MPI])], [
    echo ""
    echo "Error! MPICH is required but was not found"
    echo "       Use --with-mpich=DIR to specify the MPICH directory tree"
    echo "       Use --with-mpich=no  to not use it"
    echo "       Check the README or use configure --help for other libraries needed"
    echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
    exit -1
    ])
fi

dnl == Python (calling Python from GDL) ====================
dnl ========================================================

AC_ARG_WITH(python,
	[  --with-python[=DIR]       use Python package (with optional path DIR) ],
	[with_python="$withval" ])

if test "x$with_python" != "xno"; then
  AM_PATH_PYTHON
  AC_ARG_ENABLE(python_version,	
 	[  --enable-python_version set explicit python version to use (eg. 2.6)],
	[ PYTHON_VERSION="$enableval"
	])

  if test "x$PYTHON_VERSION" = "x"; then
    AC_MSG_CHECKING([for Python version])
    queryfile=$ac_confdir/query_version.py
    echo "# tmp file auto (re)generated by GDL configure. Please delete" > $queryfile
    echo import sys >> $queryfile
    echo print \'%s.%s\' % sys.version_info[\[0:2\]] >> $queryfile
dnl   echo print sys.version.split\(\'.\'\)[\[0\]]+\".\"+sys.version.split\(\'.\'\)[\[1\]] >> $queryfile
    PYTHON_VERSION=`python $queryfile`
    rm $queryfile
    AC_MSG_RESULT([$PYTHON_VERSION])
  fi

  if test "x$with_python" != "xyes"; then
    LIBS="$LIBS -L$with_python/lib" 
    LIBS="$LIBS -L$with_python/lib/python$PYTHON_VERSION/config -lpython$PYTHON_VERSION"
    PYTHON_INCLUDES="$with_python/include/python$PYTHON_VERSION"
  else
    LIBS="$LIBS -lpython$PYTHON_VERSION"
    PYTHON_INCLUDES="/usr/include/python$PYTHON_VERSION"
  fi

  AC_CHECK_LIB(python$PYTHON_VERSION, Py_Initialize, 
  [AC_DEFINE([USE_PYTHON],[1],[Define if you want to use python])], 
  [ 
    echo ""
    echo "Error! Python version $PYTHON_VERSION is required but was not found"
    echo "       Use --with-python=DIR to specify the python directory tree"
    echo "       Use --with-python=no  to not use it"
    echo ""
    echo "       (suitable Debian/Ubuntu package: python$PYTHON_VERSION-dev)"
    echo "       (suitable Fedora package: python-devel)"
    exit -1
    ])

  AC_CHECK_HEADER($PYTHON_INCLUDES/Python.h, [], [
    echo ""
    echo "Error! Python header file not found (missing '-devel' package?)"
    echo "  Use --with-python=no to disable Python support"
    exit -1
  ])

  OLDCPPFLAGS=$CPPFLAGS
  AC_MSG_CHECKING([for Numpy include directory])
  pinc=`echo "import numpy; print numpy.get_include()" | $PYTHON - 2>/dev/null`
  AC_MSG_RESULT([${pinc:-unknown}])
  test -n "$pinc" && PYTHON_INCLUDES="$PYTHON_INCLUDES -I$pinc"
  CPPFLAGS="$CPPFLAGS -I$PYTHON_INCLUDES"
  AC_CHECK_HEADER([numpy/arrayobject.h], [], [
    echo ""
    echo "Error! Python numpy package was not found"
    echo "  Use --with-python=no to disable Python support"
    echo ""
    echo "  (suitable Debian/Ubuntu package: python-numpy)"
    exit -1
  ], [#include <Python.h>])
  CPPFLAGS=$OLDCPPFLAGS
  unset OLDCPPFLAGS
  INCLUDES="$INCLUDES -I$PYTHON_INCLUDES"
fi

dnl == UDUNITS-2 ===========================================
dnl ========================================================

AC_ARG_WITH(udunits,
         [  --with-udunits[=DIR]      use UDUNITS-2 package (with optional path DIR) ],
         [with_udunits="$withval" ])
 
if test "x$with_udunits" != "xno"; then
  if test "x$with_udunits" != "xyes"; then
    LIBS="$LIBS -L$with_udunits/lib -ludunits2"
    INCLUDES="$INCLUDES -I$with_udunits/include"
  else
    INCLUDES="$INCLUDES -I/usr/include"
    LIBS="$LIBS -ludunits2"
  fi

  AC_CHECK_LIB(udunits2, ut_get_unit_by_name, [AC_DEFINE([USE_UDUNITS], [1], [Define if you want to use UDUNITS-2])], [
    echo ""
    echo "Error! UDUNITS-2 is required but was not found"
    echo "       Use --with-udunits=DIR to specify the UDUNITS-2 directory tree"
    echo "       Use --with-udunits=no  to not use it"
    echo "       Check the README or use configure --help for other libraries needed"
    echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
    echo ""
    echo "       (suitable Debian/Ubuntu package: libudunits2-dev)"
    echo "       (suitable Fedora package: udunits2-devel)"
    exit -1
    ])
  AC_CHECK_HEADERS(udunits2/udunits2.h)
fi

dnl == GRIB ================================================
dnl ========================================================

AC_ARG_WITH(grib,
         [  --with-grib[=DIR]         use GRIB package (with optional path DIR) ],
         [with_grib="$withval" ])
  
if test "x$with_grib" != "xno"; then
  if test "x$with_grib" != "xyes"; then
    LIBS="$LIBS -L$with_grib/lib -lgrib_api"
    INCLUDES="$INCLUDES -I$with_grib/include"
  else
    INCLUDES="$INCLUDES -I/usr/include"
    LIBS="$LIBS -lgrib_api"
  fi

  AC_CHECK_LIB(grib_api, grib_handle_new_from_file, [
      AC_DEFINE([USE_GRIB], [1], [Define if you want to use GRIB])
    ], [ 
      AC_MSG_CHECKING([if linking with Jasper helps])
      echo ""
      AC_CHECK_LIB(grib_api, grib_handle_clone, [
        LIBS="$LIBS -ljasper"
        AC_DEFINE([USE_GRIB], [1], [Define if you want to use GRIB])
      ], [ 
        AC_MSG_CHECKING([if linking with Jasper and OpenJPEG helps])
        echo ""
        AC_CHECK_LIB(grib_api, grib_handle_delete, [
          LIBS="$LIBS -ljasper -lopenjpeg"
          AC_DEFINE([USE_GRIB], [1], [Define if you want to use GRIB])
        ], [
          AC_MSG_CHECKING([if linking with Jasper and OpenJPEG and PNG helps])
          echo ""
          AC_CHECK_LIB(grib_api, grib_handle_new_from_message, [
            LIBS="$LIBS -ljasper -lopenjpeg -lpng"
            AC_DEFINE([USE_GRIB], [1], [Define if you want to use GRIB])
          ], [
            echo ""
            echo "Error! GRIB is required but was not found"
            echo "       Use --with-grib=DIR to specify the GRIB directory tree"
            echo "       Use --with-grib=no  to not use it"
            echo "       Check the README or use configure --help for other libraries needed"
            echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
            echo ""
            echo "       (suitable Debian/Ubuntu package: libgrib-api-dev)"
            echo "       (suitable Fedora package: grib_api-devel)"
            exit -1
          ], [-ljasper -lopenjpeg -lpng])
        ], [-ljasper -lopenjpeg])
      ], [-ljasper])
    ]
  )

fi

dnl == GSHHS ===============================================
dnl ========================================================

AC_ARG_WITH(gshhs,
         [  --with-gshhs[=DIR]        use GSHHS package (with optional path DIR) ],
         [with_gshhs="$withval" ])
  
if test "x$with_gshhs" != "xno"; then
  if test "x$with_gshhs" != "xyes"; then
    INCLUDES="$INCLUDES -I$with_gshhs/include"
  fi

  AC_CHECK_HEADERS(gshhs.h, [
    AC_DEFINE([USE_GSHHS], [1], [Define if you want to use GSHHS])
  ], [
    echo ""
    echo "Error! GSHHS is required but gshhs.h was not found"
    echo "       Use --with-gshhs=DIR to specify the GSHHS directory tree"
    echo "       Use --with-gshhs=no  to not use it"
    echo "       Check the README or use configure --help for other libraries needed"
    echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
    exit -1
  ])

fi

dnl == Xlib ================================================
dnl ========================================================

AC_PATH_X
if test "x$no_x" = "xyes"; then
  echo ""
  echo "Warning! X Window System not detected, building with Xlib calls disabled"
  echo "         Use --x-includes=DIR and --x-libraries=DIR to pass any needed paths"
  echo ""
else
  AC_DEFINE([HAVE_X], [1], [Define if you want to enable calls to Xlib])
fi

dnl == pslib ===============================================
dnl ========================================================

AC_ARG_WITH(pslib,
         [  --with-pslib[=DIR]        use pslib package (with optional path DIR) ],
         [with_pslib="$withval" ])
  
if test "x$with_pslib" != "xno"; then
  if test "x$with_pslib" != "xyes"; then
    LIBS="$LIBS -L$with_pslib/lib -lps"
    INCLUDES="$INCLUDES -I$with_pslib/include"
  else
    INCLUDES="$INCLUDES -I/usr/include"
    LIBS="$LIBS -lps"
  fi

  AC_CHECK_LIB(ps, PS_new, [AC_DEFINE([USE_PSLIB], [1], [Define if you want to use pslib])], [
    echo ""
    echo "Error! pslib is required but it was not found"
    echo "       Use --with-pslib=DIR to specify the pslib directory tree"
    echo "       Use --with-pslib=no  to not use it"
    echo "       Check the README or use configure --help for other libraries needed"
    echo "       (--with-xxxdir = obligatory, --with-xxx = optional (--with-xxx=no to disable))"
    echo ""
    echo "       (suitable Debian/Ubuntu package: pslib-dev)"
    echo "       (suitable Fedora package: pslib-devel)"
    exit -1
  ])

fi


dnl == installation paths ==================================
dnl ========================================================

AC_DEFUN([AC_DEFINE_DIR], [
  prefix_NONE=
  exec_prefix_NONE=
  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
dnl refers to ${prefix}.  Thus we have to use `eval' twice.
  eval ac_define_dir="\"[$]$2\""
  eval ac_define_dir="\"$ac_define_dir\""
  AC_SUBST($1, "$ac_define_dir")
  AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
  test "$prefix_NONE" && prefix=NONE
  test "$exec_prefix_NONE" && exec_prefix=NONE
])

AC_DEFINE_DIR([EXEC_PREFIX], [exec_prefix], [--exec-prefix or default])
#AC_DEFINE([EXEC_PREFIX],[\"`echo ${exec_prefix}`\"],[GDL installation directory])
AC_DEFINE_DIR([GDLDATADIR], [datadir/$datasubdir], [$datadir/gnudatalanguage])

dnl == OS-/architecture-dependant options ==================
dnl ========================================================

DARWIN="no"
case "${host}" in
  *darwin*)
    DARWIN="yes"
esac

dnl check for specific architecture
case "${host}" in
  powerpc-*-darwin* )
    dnl PowerPC Darwin based distributions (including Mac OS X)
    LDFLAGS="$LDFLAGS -bind_at_load"
    ;;

  powerpc*-*-linux* )
    LDFLAGS="$LDFLAGS -rdynamic"
    ;;

  *linux*)
    dnl Linux
    dnl LINKIMAGE support
    dnl (-ltermcap was reported to solve problems with readline)
    dnl LDFLAGS="$LDFLAGS -ltermcap -rdynamic -z muldefs"
    LDFLAGS="$LDFLAGS -rdynamic -Wl,-z,muldefs"
    ;;

  *solaris* )
    LIBS="$LIBS -lsocket -lnsl"
    ;;

  *cygwin* )
    LIBS="$LIBS -lrpc"
    ;;

dnl  *)
dnl    AC_MSG_ERROR(unknown system type ${host}.)
dnl    ;;
esac

dnl check if old darwin (needs some workarounds) 
case "${host}" in

  *darwin6*)
    dnl Jaguar
    AC_DEFINE([OLD_DARWIN], [1], [Pre-10.5 version of OS X])
    ;;
  *darwin7*)
    dnl Panther
    AC_DEFINE([OLD_DARWIN], [1], [Pre-10.5 version of OS X])
    ;;
  *darwin8.8*)
    dnl newer Tiger
    ;;
  *darwin8.9*)
    dnl newer Tiger
    ;;
  *darwin8.10*)
    dnl newer Tiger
    ;;
  *darwin8.11*)
    dnl newer Tiger
    ;;
  *darwin8.12*)
    dnl newer Tiger
    ;;
  *darwin8.13*)
    dnl newer Tiger
    ;;
  *darwin8.14*)
    dnl newer Tiger
    ;;
  *darwin8.15*)
    dnl newer Tiger
    ;;
  *darwin9*)
    dnl Leopard
    ;;
  *darwin8*)
    dnl Tiger
    AC_DEFINE([OLD_DARWIN], [1], [Pre-10.4.8 version of OS X])
    ;;
esac

dnl for src/Makefile.am: OS X linker does not know -z
AM_CONDITIONAL(DARWIN, test "x$DARWIN" = "xyes")

dnl == some final instructions =============================
dnl ========================================================

EXT_LIBS="$EXT_LIBS $LIBS"
EXT_INCLUDES="$EXT_INCLUDES $INCLUDES"
AC_SUBST(EXT_LIBS)
AC_SUBST(EXT_INCLUDES)

dnl some stuff copied from wxWindows

dnl install checks
dnl   defines INSTALL with the appropriate command
AC_PROG_INSTALL

dnl   make install path absolute (if not already);
dnl   will fail with (some) MSDOS paths
case ${INSTALL} in
  /* ) # Absolute
     ;;
  ?:* ) # Drive letter, considered as absolute.
     ;;
  *)
     INSTALL=`pwd`/${INSTALL} ;;
esac

case "${host}" in

    dnl The other BSD's should probably go in here too, since this is
    dnl to workaround a strange static lib BSDism.
    dnl Mac OS X install seems to ignore -p option...
    *-*-darwin* )
        INSTALL_PROGRAM="cp -fp"
        INSTALL_DATA="cp -fp"
        ;;
    *)
        ;;
esac

dnl echo LIBS $LIBS
dnl echo INCLUDES $INCLUDES

dnl Checks for header files.
dnl AC_HEADER_STDC

dnl Checks for typedefs, structures, and compiler characteristics.
dnl AC_C_CONST

dnl Checks for library functions.
dnl AC_CHECK_FUNCS(strdup strtod strtol abs)

dnl perform program name transformation
dnl AC_ARG_PROGRAM

AC_CONFIG_FILES(Makefile src/Makefile src/antlr/Makefile src/pro/Makefile src/pro/dicom/Makefile src/pro/envi/Makefile testsuite/Makefile doc/Makefile)
AC_OUTPUT

dnl == summary table =======================================
dnl ========================================================

echo "
                  GDL - GNU Data Language
  ----- compilation options: ---------------------------
  System:              $host
  Installation prefix: $prefix
  C++ compiler:        $CXX $CXXFLAGS
  OpenMP support:      `if test "x$with_openmp" = "xno";
    then echo 'no'; else echo 'yes'; fi`
  Build type:          `if test "x$PYTHON_MODULE" = "xyes";
    then echo 'library (Python module)'; else echo 'standalone (other: Python module)'; fi`
  ----- optional libraries (consult README/INSTALL): ---
  wxWidgets:           `if test no = $with_wxWidgets;
    then echo 'no'; else echo yes; fi`
  Magick:              `if test no = $with_Magick;
    then echo 'no'; else echo yes; fi`
  GraphicsMagick:      `if test no = $with_GraphicsMagick;
    then echo 'no'; else echo yes; fi`
  Eigen:               `if test no = $with_eigen;
    then echo 'no'; else echo yes; fi`
  NetCDF:              `if test no = $with_netcdf;
    then echo 'no'; else echo yes; fi`
  HDF4:                `if test no = $with_hdf;
    then echo 'no'; else echo yes; fi`
  HDF5:                `if test no = $with_hdf5;
    then echo 'no'; else echo yes; fi`
  FFTW:                `if test no = $with_fftw; 
    then echo 'no  (GSL version used)'; else echo yes; fi`
  libproject:          `if test no = $with_libproj4;
    then echo 'no  (see also MAP_INSTALL)'; else echo yes; fi`
  MPICH:               `if test no = $with_mpich;
    then echo 'no  (needs explicit enabling)'; else echo yes; fi`
  Python:              `if test no = $with_python;
    then echo 'no  (see also PYTHON.txt)'; else echo \"yes ($PYTHON_VERSION)\"; fi`
  UDUNITS-2:           `if test no = $with_udunits;
    then echo 'no  (needs explicit enabling)'; else echo yes; fi`
  GRIB:                `if test no = $with_grib;
    then echo 'no  (needs explicit enabling)'; else echo yes; fi`
  GSHHS:               `if test no = $with_gshhs;
    then echo 'no  (see also MAP_INSTALL)'; else echo yes; fi`
  Xlib:                `if test xyes = x$no_x;
    then echo 'no'; else echo yes; fi`
  pslib:               `if test no = $with_pslib;
    then echo 'no'; else echo yes; fi`
  ----- notes on auxiliary files: ----------------------
  - consult MAP_INSTALL for details concerning auxiliary
    files needed for mapping support
  - SAVE and RESTORE procedures require *.pro files from 
    the CMSVLIB package (see README for details)
  ------------------------------------------------------
`if test yes = $openmp_autodetected; then
  echo '  ----- note on OpenMP support -------------------------'
  echo '   OpenMP was autodetected, use --with-openmp=no if your'
  echo '   compiler does not support it (e.g. GCC < 4.2)'
  echo '  ------------------------------------------------------'; fi`
  use 'make' to build and 'make install' to install GDL
  (optional 'make check' tests the build - experimental)
"
echo "
*********************** WARNING ******************************
We plan to drop support for Autotools-based configuration
(i.e. the configure script) and switch to CMake. If possible,
please try to compile GDL with CMake (e.g. by typing \"cmake .\"
instead of \"./configure\") and please do report any problems.
Consult INSTALL.CMake for help on passing options to CMake.
**************************************************************
"

dnl == EOF =================================================
