autoconf other macro for hdf

Patrice Dumas pertusus at FREE.FR
Sun Oct 2 14:18:20 EDT 2005


Hi,

Here is a slightly modified hdf autoconf macro and the corresponding
patch for configure.ac. I merged with what James Gallagher did for
hdf4_handler (based on my netcdf.m4...). The hdf4.m4 corresponding
file is also attached, it obsoletes the previous hdf.m4 file I sent.

--
Pat
-------------- next part --------------
--- grads-1.9b4-orig/configure.in       2005-05-23 17:04:40.000000000 +0200
+++ grads-1.9b4/configure.in    2005-10-02 17:47:13.000000000 +0200
@@ -66,6 +66,8 @@
     [Use pre-1.9 non-canonical names for supplib directories]),
     [old_supplibs="yes"])

+ga_dyn_supplibs=no
+
 AC_ARG_ENABLE(dyn-supplibs, AC_HELP_STRING([--enable-dyn-supplibs],
     [Use dynamic (shared object) system libraries, if present, for optional features. This will produce smaller, but possibly less portable, binaries. By default, only static libraries from a GrADS supplibs distribution will be used for optional feature support to maximize binary portability.]),
     [ GA_ENABLE_DYNAMIC() ])
@@ -258,11 +260,21 @@
 use_readline=no
 if test "$with_readline" != "no" ; then
   echo "Check GrADS command line editing support..."
-  GA_CHECK_READLINE([use_readline=yes])
+  if test "$ga_dyn_supplibs" = "yes" ; then
+  # GA_LIB_READLINE adds the required -l to LIBS
+    GA_LIB_READLINE([
+      use_readline=yes
+      readline_libs=""
+    ])
+  else
+    GA_CHECK_READLINE([use_readline=yes])
+  fi
 fi
 if test $use_readline = "yes" ; then
   echo "+ Command line editing enabled"
-  GA_SET_LIB_VAR(readline_libs, readline)
+  if test "$ga_dyn_supplibs" = "no" ; then
+    GA_SET_LIB_VAR(readline_libs, readline)
+  fi
   AC_SUBST(readline_libs)
   AC_DEFINE(READLINE, 1, [Enable command line editing])
   AC_DEFINE(MM_READLINE,,[Enhanced readline with history])
@@ -274,15 +286,29 @@


 use_gui=no
+use_freq=yes
 if test "$with_gui" != "no" ; then
    echo "Check GrADS GUI support..."
-   GA_CHECK_GUI([use_gui=yes])
+   if test "$ga_dyn_supplibs" = "yes" ; then
+     GA_CHECK_LIBSX([use_gui=yes;use_freq=yes],[use_gui=yes;use_freq=no])
+   else
+     GA_CHECK_GUI([use_gui=yes])
+   fi
 fi
 if test $use_gui = "yes" ; then
   AC_DEFINE(USEGUI, 1, [Enable GUI widgets])
   echo "+ GUI enabled"
-  GA_SET_LIB_VAR(gui_libs, [sx freq])
-  gui_libs="$gui_libs -lXaw -lXmu -lXt $guilibadd"
+  if test "$ga_dyn_supplibs" = "yes" ; then
+    gui_libs="$GA_LIBSX_LIBS $guilibadd"
+  else
+    GA_SET_LIB_VAR(gui_libs, [sx freq])
+    gui_libs="$gui_libs -lXaw -lXmu -lXt $guilibadd"
+  fi
+  if test $use_freq = yes; then
+     AC_DEFINE(USEFREQ, 1, [Use GetFile from freq])
+  else
+     AC_DEFINE(USEFREQ, 0, [Use GetFile from freq])
+  fi
   AC_SUBST(gui_libs)
 else
   AC_DEFINE(USEGUI, 0, [Enable GUI widgets])
@@ -294,13 +320,24 @@
 use_printim=no
 if test "$with_printim" != "no" ; then
   echo "Check GrADS printim support..."
-  GA_CHECK_GD([use_printim=yes], [])
+  if test "$ga_dyn_supplibs" = "yes" ; then
+    GA_SUPP_CHECK_GD([
+      use_printim=yes
+      printim_libs="$GA_GD_LIBS"
+      LDFLAGS="$LDFLAGS $GA_GD_LDFLAGS"
+      CPPFLAGS="$CPPFLAGS $GA_GD_CPPFLAGS"
+    ])
+  else
+    GA_CHECK_GD([use_printim=yes], [])
+  fi
 fi

 if test $use_printim = "yes" ; then
   AC_DEFINE(GXPNG, 1, [Enable printim using GD library \
                        (http://www.boutell.com/gd) for PNG/GIF images])
-  GA_SET_LIB_VAR(printim_libs, [gd png z])
+  if test "$ga_dyn_supplibs" = "no" ; then
+    GA_SET_LIB_VAR(printim_libs, [gd png z])
+  fi
   AC_SUBST(printim_libs)
   extra_utils="$extra_utils gxtran"
   echo "+ printim enabled"
@@ -354,10 +391,23 @@

 use_nc=no
 if test "$with_nc" != "no" ; then
-     GA_CHECK_NC([use_nc=yes])
+  if test "$ga_dyn_supplibs" = "yes" ; then
+    GA_CHECK_UDUNITS([
+      AC_CHECK_NETCDF([
+        LDFLAGS="$LDFLAGS $NC_LDFLAGS"
+        CPPFLAGS="$CPPFLAGS $NC_CPPFLAGS"
+        use_nc=yes
+        nc_libs="$NC_LIBS $GA_UDUNITS_LIBS"
+      ])
+    ])
+  else
+    GA_CHECK_NC([use_nc=yes])
+  fi
 fi
 if test $use_nc = "yes" ; then
-  GA_SET_LIB_VAR(nc_libs, [netcdf udunits])
+  if test "$ga_dyn_supplibs" = "no" ; then
+    GA_SET_LIB_VAR(nc_libs, [netcdf udunits])
+  fi
   AC_SUBST(nc_libs)
   extra_bins="$extra_bins gradsnc"
   echo "+ gradsnc (plain netCDF) build enabled"
@@ -369,13 +419,26 @@

 use_hdf=no
 if test "$with_hdf" != "no" ; then
-  GA_CHECK_HDF([use_hdf=yes])
+  if test "$ga_dyn_supplibs" = "yes" ; then
+    GA_CHECK_UDUNITS([
+      AC_CHECK_HDF4_NETCDF([
+        LDFLAGS="$LDFLAGS $HDF4_LDFLAGS"
+        CPPFLAGS="$CPPFLAGS $HDF4_CPPFLAGS"
+        use_hdf=yes
+        hdf_libs="$HDF4_LIBS $GA_UDUNITS_LIBS"
+      ])
+    ])
+  else
+    GA_CHECK_HDF([use_hdf=yes])
+  fi
 fi
 if test $use_hdf = "yes" ; then
+  if test "$ga_dyn_supplibs" = "no" ; then
     GA_SET_LIB_VAR(hdf_libs, [mfhdf df jpeg udunits z])
-    AC_SUBST(hdf_libs)
-    extra_bins="$extra_bins gradshdf"
-    echo "+ gradshdf (HDF-SDS/netCDF) build enabled"
+  fi
+  AC_SUBST(hdf_libs)
+  extra_bins="$extra_bins gradshdf"
+  echo "+ gradshdf (HDF-SDS/netCDF) build enabled"
 else
   echo "- gradshdf (HDF-SDS/netCDF) build disabled"
 fi
@@ -384,22 +447,38 @@

 use_dods=no
 if test "$with_dods" != "no" ; then
-  GA_CHECK_DODS([use_dods=yes])
+  if test "$ga_dyn_supplibs" = "yes" ; then
+    GA_CHECK_UDUNITS([
+      AC_CHECK_NC_DODS([
+        CPPFLAGS="$CPPFLAGS $NC_DAP_CFLAGS"
+        dods_libs="$GA_UDUNITS_LIBS $NC_DAP_LIBS"
+        use_dods=yes
+      ])
+    ])
+  else
+    GA_CHECK_DODS([use_dods=yes])
+  fi
 fi

 if test $use_dods = "yes" ; then
-
     extra_bins="$extra_bins gradsdods"
-    GA_SET_LIB_VAR(dods_libs, [udunits www rx z])
-
+    if test "$ga_dyn_supplibs" = "no" ; then
+      GA_SET_LIB_VAR(dods_libs, [udunits www rx z])
+    fi

     GA_CHECK_LIB(gadods, main, [use_gadods=yes], [use_gadods=no])
     if test $use_gadods = "yes" ; then
-       dods_rep_libs="-lgadods -lnc-dods -ldap++"
+       if test "$ga_dyn_supplibs" = "no" ; then
+         dods_rep_libs="-lgadods -lnc-dods -ldap++"
+       else
+         dods_rep_libs="-lgadods"
+       fi
        gadods_def="-DUSEGADODS=1"
        echo "+ gradsdods (OPeNDAP/netCDF) build enabled - gridded and station interfaces"
     else
-       dods_rep_libs="-lnc-dods -ldap++"
+       if test "$ga_dyn_supplibs" = "no" ; then
+         dods_rep_libs="-lnc-dods -ldap++"
+       fi
        gadods_def="-DUSEGADODS=0"
        echo "+ gradsdods (OPeNDAP/netCDF) build enabled - gridded interface only"
     fi
-------------- next part --------------
dnl AC_CHECK_HDF : Check for hdf4
dnl args :             action-if-yes, action-if-no

AC_DEFUN([AC_CHECK_HDF4],
[
  AC_ARG_WITH([hdf4],
            [AS_HELP_STRING([--with-hdf4=ARG],[hdf4 directory])],
            [HDF4_PATH=$withval],
            [HDF4_PATH=""])

  AC_ARG_WITH([hdf4_include],
            [AS_HELP_STRING([--with-hdf4-include=ARG],[hdf 4 include directory])],
            [HDF4_PATH_INC=$withval],
            [HDF4_PATH_INC=""])

  AC_ARG_WITH([hdf4_libdir],
            [AS_HELP_STRING([--with-hdf4-libdir=ARG],[hdf 4 library directory])],
            [HDF4_PATH_LIBDIR=$withval],
            [HDF4_PATH_LIBDIR=""])

  AS_IF([test "z$HDF4_PATH" != "z"],
  [
    AS_IF([test "z$HDF4_PATH_LIBDIR" = "z"],
      [HDF4_PATH_LIBDIR="$HDF4_PATH/lib"])
    AS_IF([test "z$HDF4_PATH_INC" = "z"],
      [HDF4_PATH_INC="$HDF4_PATH/include"])
  ])

  HDF4_LDFLAGS=
  AS_IF([test "z$HDF4_PATH_LIBDIR" != "z"],
    [HDF4_LDFLAGS="-L$HDF4_PATH_LIBDIR"])

  HDF4_LIBS=
  ac_hdf4_save_LDFLAGS=$LDFLAGS
  ac_hdf4_save_LIBS=$LIBS
  LDFLAGS="$LDFLAGS $HDF4_LDFLAGS"
  AC_CHECK_LIB([sz], [SZ_BufftoBuffCompress],
  [
      LIBS="$LIBS -lsz"
      HDF4_LIBS='-lsz'
  ])

dnl -lsz is not required because due to licencing it may not be present
dnl nor required everywhere
  ac_hdf4_lib='no'
  AC_CHECK_LIB([z],[deflate],
  [ AC_CHECK_LIB([jpeg],[jpeg_start_compress],
    [ AC_CHECK_LIB([df],[Hopen],
      [ AC_CHECK_LIB([mfhdf],[SDstart],
        [ ac_hdf4_lib="yes"
          HDF4_LIBS="-lmfhdf -ldf -ljpeg -lz $HDF4_LIBS"
        ],[],[-ldf -ljpeg -lz])
      ],[],[-ljpeg -lz])
    ])
  ])
  LDFLAGS=$ac_hdf4_save_LDFLAGS
  LIBS=$ac_hdf4_save_LIBS

  HDF4_CPPFLAGS=
  AS_IF([test "z$HDF4_PATH_INC" != "z"],
    [HDF4_CPPFLAGS="-I$HDF4_PATH_INC"])

  ac_hdf4_h='no'
  ac_hdf4_save_CPPFLAGS=$CPPFLAGS
  CPPFLAGS="$CPPFLAGS $HDF4_CPPFLAGS"
  AC_CHECK_HEADER([mfhdf.h],[ac_hdf4_h='yes'])
  CPPFLAGS=$ac_hdf4_save_CPPFLAGS

  AS_IF([test "$ac_hdf4_h" = 'yes' -a "$ac_hdf4_lib" = 'yes'],
  [m4_if([$1], [], [:], [$1])],
  [m4_if([$2], [], [:], [$2])])

  AC_SUBST([HDF4_LIBS])
  AC_SUBST([HDF4_CPPFLAGS])
  AC_SUBST([HDF4_LDFLAGS])
])

dnl check for the netcdf 2 interface provided by hdf
AC_DEFUN([AC_CHECK_HDF4_NETCDF],
[
  ac_hdf4_netcdf_lib='no'
  ac_hdf4_netcdf_h='no'
  AC_CHECK_HDF4([
    ac_hdf4_netcdf_save_LDFLAGS=$LDFLAGS
    ac_hdf4_netcdf_save_LIBS=$LIBS
    LIBS="$LIBS $HDF4_LIBS"
    LDFLAGS="$LDFLAGS $HDF4_LDFLAGS"
    AC_MSG_CHECKING([for ncopen with hdf link flags])
    AC_LINK_IFELSE([AC_LANG_CALL([],[ncopen])],
      [
        AC_MSG_RESULT([yes])
        ac_hdf4_netcdf_lib='yes'
      ],
      [
        AC_MSG_RESULT([no])
        ac_hdf4_netcdf_lib='no'
      ])
    LDFLAGS=$ac_hdf4_netcdf_save_LDFLAGS
    LIBS=$ac_hdf4_netcdf_save_LIBS

    ac_hdf4_netcdf_save_CPPFLAGS=$CPPFLAGS
    CPPFLAGS="$CPPFLAGS $HDF4_CPPFLAGS"
    AC_CHECK_NETCDF_HEADER([],[ac_hdf4_netcdf_h='yes'])
    CPPFLAGS=$ac_hdf4_netcdf_save_CPPFLAGS
  ])

  AS_IF([test $ac_hdf4_netcdf_lib = 'yes' -a $ac_hdf4_netcdf_h = 'yes'],
  [m4_if([$1], [], [:], [$1])],
  [m4_if([$2], [], [:], [$2])])

])


More information about the gradsusr mailing list