new version of the patch for fc4 and libsx-2.05

Patrice Dumas pertusus at FREE.FR
Wed Aug 17 09:24:41 EDT 2005


Hi,

I use libsx-2.05 to link against grads. There are some differences with regard
with the libsx version used in the main grads. Indeed GetFile is now in the
main library, not only in freq, but has the prototype changed. So I added a
macro that test for the version I have and conditionnalized code. It might
not be a definitive solution as if the old libsx is used the tests detecting
the new will be positive: the prototype of GetFile should be tested too.

I attach the patch with all the changes.

acinclude.m4
* add the fifth argument to AC_CHECK_LIB in GA_CHECK_LIB
* properly quote GA_CHECK_LIB
* add forgotten $
* new macro GA_CHECK_NEW_GUI to check for the new libsx
configure.in
* use GA_CHECK_NEW_GUI. If used define USEFREQ to 0
* use AC_CHECK_NC_DODS to find more versions of opendap
config.h.in (automatically done by autoheader)
* add USEFREQ
gagui.c
* define SimpleGeteFile conditionnaly on USEFREQ
gagui.c and gsgui.c
* conditionnaly include freq.h
gauser.c
* add the prototype of gxhpng
gxdxwd.c
* include stdlib.h and remove calloc prototype
--> this should be conditionnalized at least with AC_HEADER_STDC and maybe
    use gnulib calloc
gxhpng.c
* copy and paste gdCompareInt

I also reattach the libdap.m4 and libnc-dap.m4 needed to define
AC_CHECK_NC_DODS.

My compiler is gcc4.

For those interested by fedora core, I have submitted grads:

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=165955

--
Pat
-------------- next part --------------
diff -u --recursive --exclude aclocal.m4 --exclude configure --exclude Makefile.in --exclude bootstrap grads-1.9b4-orig/acinclude.m4 grads-1.9b4/acinclude.m4
--- grads-1.9b4-orig/acinclude.m4       2003-10-02 16:01:15.000000000 +0200
+++ grads-1.9b4/acinclude.m4    2005-08-16 12:08:41.000000000 +0200
@@ -165,10 +165,10 @@
 dnl               enabled, just calls AC_CHECK_LIB. If not, checks for the presence
 dnl               of a file "libname.a" in the supplibs directory.
 dnl  args:        library-name, extra-libs, action-if-found, action-if-not-found
-AC_DEFUN(GA_CHECK_LIB,
+AC_DEFUN([GA_CHECK_LIB],
 [
   if test "${ga_dyn_supplibs}" = "yes" ; then
-     AC_CHECK_LIB($1, $2, $3, $4)
+     AC_CHECK_LIB([$1], [$2], [$3], [$4], [$5])
   else
      AC_MSG_CHECKING([for lib$1.a in supplibs])
      if test -f "${ga_supplib_dir}/lib/lib$1.a" ; then
@@ -249,7 +249,39 @@
   GA_UNSET_FLAGS
 ])

+dnl GA_CHECK_NEW_GUI : Checks whether GrADS can be built with GUI features
+dnl                    enabled. Check libsx without freq.
+dnl  args :            action-if-yes, action-if-no
+AC_DEFUN([GA_CHECK_NEW_GUI],
+[
+  # Check libs and headers for GUI widgets
+  GA_SET_FLAGS([$X_CFLAGS], [$X_LIBS])

+  ga_check_new_gui="no"
+  AC_CHECK_HEADER([libsx.h],
+  [ AC_CHECK_LIB([Xt],[main],
+    [ AC_CHECK_LIB([Xaw],[main],
+      [ AC_CHECK_LIB([Xmu],[main],
+         [ GA_CHECK_LIB([sx],[GetFile],
+           [ ga_check_new_gui="yes"
+            ],
+           [ ga_check_new_gui="no"
+            ],
+            [-lXaw -lXmu -lXt])
+        ])
+      ])
+    ])
+  ])
+  if test $ga_check_new_gui = "yes" ; then
+    $1
+    true #dummy command
+  else
+    $2
+    true #dummy command
+  fi
+
+  GA_UNSET_FLAGS
+])

 dnl GA_CHECK_GD : Checks whether GrADS can be built with printim command
 dnl                    enabled.
@@ -324,7 +356,7 @@
 AC_DEFUN(GA_CHECK_NC,
 [
   # Check libs and headers for netCDF support
-  GA_SET_FLAGS([-I{ga_supplib_dir}/include/nc])
+  GA_SET_FLAGS([-I${ga_supplib_dir}/include/nc])

   ga_check_nc="no"
   AC_CHECK_HEADER(udunits.h,
@@ -356,7 +388,7 @@
 AC_DEFUN(GA_CHECK_HDF,
 [
   # Check libs and headers for HDF support
-  GA_SET_FLAGS([-I{ga_supplib_dir}/include/hdf])
+  GA_SET_FLAGS([-I${ga_supplib_dir}/include/hdf])

   ga_check_hdf="no"
   AC_CHECK_HEADER(udunits.h,
@@ -394,7 +426,7 @@
 AC_DEFUN(GA_CHECK_DODS,
 [
   # Check libs and headers for DODS support
-  GA_SET_FLAGS([-I{ga_supplib_dir}/include/dods])
+  GA_SET_FLAGS([-I${ga_supplib_dir}/include/dods])

   ga_check_dods="no"
   AC_CHECK_HEADER(udunits.h,
Seulement dans grads-1.9b4: autom4te.cache
Seulement dans grads-1.9b4: autoscan.log
Seulement dans grads-1.9b4: config.h.in
Seulement dans grads-1.9b4: config.log
Seulement dans grads-1.9b4: config.status
diff -u --recursive --exclude aclocal.m4 --exclude configure --exclude Makefile.in --exclude bootstrap grads-1.9b4-orig/configure.in grads-1.9b4/configure.in
--- grads-1.9b4-orig/configure.in       2005-05-23 17:04:40.000000000 +0200
+++ grads-1.9b4/configure.in    2005-08-16 12:05:01.000000000 +0200
@@ -274,14 +274,24 @@


 use_gui=no
+use_new_gui=no
 if test "$with_gui" != "no" ; then
    echo "Check GrADS GUI support..."
    GA_CHECK_GUI([use_gui=yes])
+   if test $use_gui = no; then
+      GA_CHECK_NEW_GUI([use_new_gui=yes; 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])
+  if test $use_new_gui = no; then
+    GA_SET_LIB_VAR(gui_libs, [sx freq])
+    AC_DEFINE(USEFREQ, 1, [Use GetFile from freq])
+  else
+    GA_SET_LIB_VAR([gui_libs], [sx])
+    AC_DEFINE(USEFREQ, 0, [Use GetFile from freq])
+  fi
   gui_libs="$gui_libs -lXaw -lXmu -lXt $guilibadd"
   AC_SUBST(gui_libs)
 else
@@ -383,15 +393,25 @@


 use_dods=no
+dods_ncdap=no
 if test "$with_dods" != "no" ; then
   GA_CHECK_DODS([use_dods=yes])
+  if test "z$use_dods" = "zno" -a "${ga_dyn_supplibs}" = "yes" ; then
+  AC_CHECK_HEADER([udunits.h],
+  [ AC_CHECK_HEADER([netcdf.h],
+    [ GA_CHECK_LIB([udunits], [utInit],
+       [AC_CHECK_NC_DODS([dods_ncdap=yes; 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 "z$dods_ncdap" = "zno" ; 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
@@ -404,7 +424,11 @@
        echo "+ gradsdods (OPeNDAP/netCDF) build enabled - gridded interface only"
     fi

-    dods_libs="$dods_rep_libs $dods_rep_libs $dods_libs"
+    if test "z$dods_ncdap" = "zyes" ; then
+       dods_libs="$NC_DAP_LIBS -ludunits"
+    else
+       dods_libs="$dods_rep_libs $dods_rep_libs $dods_libs"
+    fi
     AC_SUBST(dods_libs)
     AC_SUBST(gadods_def)
 else
Seulement dans grads-1.9b4: configure.scan
Seulement dans grads-1.9b4: grads-1.9b4.tar.gz
Seulement dans grads-1.9b4: grads.spec
Seulement dans grads-1.9b4: libdap.m4
Seulement dans grads-1.9b4: libnc-dap.m4
Seulement dans grads-1.9b4: Makefile
Seulement dans grads-1.9b4/src: bufrscan
Seulement dans grads-1.9b4/src: bufrscan.o
Seulement dans grads-1.9b4/src: bufrstn.o
Seulement dans grads-1.9b4/src: buildinfo.h
Seulement dans grads-1.9b4/src: config.h
diff -u --recursive --exclude aclocal.m4 --exclude configure --exclude Makefile.in --exclude bootstrap grads-1.9b4-orig/src/config.h.in grads-1.9b4/src/config.h.in
--- grads-1.9b4-orig/src/config.h.in    2004-12-15 22:00:03.000000000 +0100
+++ grads-1.9b4/src/config.h.in 2005-08-16 12:05:39.000000000 +0200
@@ -88,6 +88,9 @@
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS

+/* Use GetFile from freq */
+#undef USEFREQ
+
 /* Enable GUI widgets */
 #undef USEGUI

Seulement dans grads-1.9b4/src: config.h.in~
Seulement dans grads-1.9b4/src: fgbds.o
Seulement dans grads-1.9b4/src: fgutil.o
Seulement dans grads-1.9b4/src: gabufr.o
Seulement dans grads-1.9b4/src: gabufrtbl.o
Seulement dans grads-1.9b4/src: gacfg-c.o
Seulement dans grads-1.9b4/src: gacfg-dods.o
Seulement dans grads-1.9b4/src: gacfg-hdf.o
Seulement dans grads-1.9b4/src: gacfg-nc.o
Seulement dans grads-1.9b4/src: gaddes-c.o
Seulement dans grads-1.9b4/src: gaddes-dods.o
Seulement dans grads-1.9b4/src: gaddes-hdf.o
Seulement dans grads-1.9b4/src: gaddes-nc.o
Seulement dans grads-1.9b4/src: gaddes.sa.o
Seulement dans grads-1.9b4/src: gaexpr.o
Seulement dans grads-1.9b4/src: gafunc.o
Seulement dans grads-1.9b4/src: gagmap.o
diff -u --recursive --exclude aclocal.m4 --exclude configure --exclude Makefile.in --exclude bootstrap grads-1.9b4-orig/src/gagui.c grads-1.9b4/src/gagui.c
--- grads-1.9b4-orig/src/gagui.c        2002-10-28 20:08:33.000000000 +0100
+++ grads-1.9b4/src/gagui.c     2005-08-16 12:15:04.000000000 +0200
@@ -38,7 +38,9 @@
 #include <time.h>

 #include "libsx.h"
-#include "freq.h"
+#if USEFREQ == 1
+#include "freq.h"
+#endif
 #include "grads.h"
 #include "gx.h"

@@ -341,8 +343,20 @@
 }

 /*
+ * define SimpleGetFile, it is not part of libsx.
+ */
+char *SimpleGetFile(char *path)
+{
+#if USEFREQ == 0
+   return GetFile("Simple file requestor", path, NULL, NULL);
+#else
+   return GetFile(path);
+#endif
+}
+
+/*
  * CB_Load() - Callback function for the load button.  This just calls
- *          GetFile() to get a file name. In case of "open" or "sdfopen",
+ *          SimpleGetFile() to get a file name. In case of "open" or "sdfopen",
  *          the file becomes the default and the user is asked to select a
  *          variable from this file.
  */
@@ -356,7 +370,7 @@
   else if(strstr(data,"exec"))    last_path = last_path_exec;
   else if(strstr(data,"run"))     last_path = last_path_run;
   else                            last_path = NULL;
-  fname = GetFile(last_path);
+  fname = SimpleGetFile(last_path);

   if(fname)
     {
@@ -979,7 +993,7 @@
   WinInfo *wi=(WinInfo *)arg;
   char *fname;

-  fname = GetFile(wi->cur_path);
+  fname = SimpleGetFile(wi->cur_path);
   if (fname)
    {
      SetTextWidgetText(wi->text_widget, fname, TRUE);
@@ -1126,7 +1140,7 @@


   fname = (char *) data;
-  if ( !strcmp(fname,"NULL") ) fname = GetFile(NULL);
+  if ( !strcmp(fname,"NULL") ) fname = SimpleGetFile(NULL);
   if ( !fname ) return;

   this = MakeWindow("GrADS Text Viewer", SAME_DISPLAY, NONEXCLUSIVE_WINDOW);
@@ -1151,7 +1165,7 @@
   WinInfo *wi;

   fname = (char *)data;
-  if ( !strcmp(fname,"NULL") ) fname = GetFile(NULL);
+  if ( !strcmp(fname,"NULL") ) fname = SimpleGetFile(NULL);
   if ( !fname ) return;

   this = MakeWindow("GrADS Text Editor", SAME_DISPLAY, NONEXCLUSIVE_WINDOW);
Seulement dans grads-1.9b4/src: gagui.o
Seulement dans grads-1.9b4/src: gagx.o
Seulement dans grads-1.9b4/src: gaio-c.o
Seulement dans grads-1.9b4/src: gaio-dods.o
Seulement dans grads-1.9b4/src: gaio-hdf.o
Seulement dans grads-1.9b4/src: gaio-nc.o
Seulement dans grads-1.9b4/src: galats.o
Seulement dans grads-1.9b4/src: gamach.o
Seulement dans grads-1.9b4/src: gasdf-dods.o
Seulement dans grads-1.9b4/src: gasdf-hdf.o
Seulement dans grads-1.9b4/src: gasdf-nc.o
diff -u --recursive --exclude aclocal.m4 --exclude configure --exclude Makefile.in --exclude bootstrap grads-1.9b4-orig/src/gauser.c grads-1.9b4/src/gauser.c
--- grads-1.9b4-orig/src/gauser.c       2005-05-18 20:51:01.000000000 +0200
+++ grads-1.9b4/src/gauser.c    2005-08-16 11:33:49.000000000 +0200
@@ -42,6 +42,7 @@
 #endif

 /* int gxhpng (char *, int, int, int, int); */
+int gxhpng (char *, int, int, int, int, char *, char *, int) ;

 /*mf 971022 --- expose Mike Fiorino's global struct to these routines for warning level setting mf*/
 extern struct gamfcmn mfcmn;
Seulement dans grads-1.9b4/src: gauser-c.o
Seulement dans grads-1.9b4/src: gauser-dods.o
Seulement dans grads-1.9b4/src: gauser-hdf.o
Seulement dans grads-1.9b4/src: gauser-nc.o
Seulement dans grads-1.9b4/src: gautil.o
Seulement dans grads-1.9b4/src: gautil.sa.o
Seulement dans grads-1.9b4/src: gd13gif.o
Seulement dans grads-1.9b4/src: gradsc
Seulement dans grads-1.9b4/src: gradsdods
Seulement dans grads-1.9b4/src: gradshdf
Seulement dans grads-1.9b4/src: gradsnc
Seulement dans grads-1.9b4/src: grads.o
Seulement dans grads-1.9b4/src: gribmap
Seulement dans grads-1.9b4/src: gribmap.o
Seulement dans grads-1.9b4/src: gribscan
Seulement dans grads-1.9b4/src: gribscan.o
Seulement dans grads-1.9b4/src: gscrpt.o
diff -u --recursive --exclude aclocal.m4 --exclude configure --exclude Makefile.in --exclude bootstrap grads-1.9b4-orig/src/gsgui.c grads-1.9b4/src/gsgui.c
--- grads-1.9b4-orig/src/gsgui.c        2002-10-28 20:08:33.000000000 +0100
+++ grads-1.9b4/src/gsgui.c     2005-08-16 12:15:42.000000000 +0200
@@ -29,7 +29,9 @@
 #include <stdlib.h>

 #include "libsx.h"
+#if USEFREQ == 1
 #include "freq.h"
+#endif
 #include "gagui.h"

 /* Supported widget types */
Seulement dans grads-1.9b4/src: gsgui.o
Seulement dans grads-1.9b4/src: gxchpl.o
Seulement dans grads-1.9b4/src: gxcntr.o
diff -u --recursive --exclude aclocal.m4 --exclude configure --exclude Makefile.in --exclude bootstrap grads-1.9b4-orig/src/gxdxwd.c grads-1.9b4/src/gxdxwd.c
--- grads-1.9b4-orig/src/gxdxwd.c       2002-10-28 20:08:33.000000000 +0100
+++ grads-1.9b4/src/gxdxwd.c    2005-08-16 11:33:49.000000000 +0200
@@ -6,6 +6,7 @@
 #include <config.h>
 #endif

+#include <stdlib.h>
 #include <stdio.h>
 #include <errno.h>

@@ -22,7 +23,7 @@
  *              writting.
  */

-char *calloc();
+/* char *calloc(); */

 #include "X11/XWDFile.h"

Seulement dans grads-1.9b4/src: gxdxwd.o
Seulement dans grads-1.9b4/src: gxeps
Seulement dans grads-1.9b4/src: gxeps.o
diff -u --recursive --exclude aclocal.m4 --exclude configure --exclude Makefile.in --exclude bootstrap grads-1.9b4-orig/src/gxhpng.c grads-1.9b4/src/gxhpng.c
--- grads-1.9b4-orig/src/gxhpng.c       2004-03-12 17:14:04.000000000 +0100
+++ grads-1.9b4/src/gxhpng.c    2005-08-16 11:33:49.000000000 +0200
@@ -379,6 +379,11 @@

 int gdCompareInt(const void *a, const void *b);

+int gdCompareInt(const void *a, const void *b)
+{
+       return (*(const int *)a) - (*(const int *)b);
+}
+
 /* Version of gdImageFilledPolygon to invoke my local
    version of gdImageLne.  Nothing else changed... B.Doty 5/31/01 */

Seulement dans grads-1.9b4/src: gxmeta.o
Seulement dans grads-1.9b4/src: gxmeta.sa.o
Seulement dans grads-1.9b4/src: gxps
Seulement dans grads-1.9b4/src: gxps.o
Seulement dans grads-1.9b4/src: gxshad.o
Seulement dans grads-1.9b4/src: gxstrm.o
Seulement dans grads-1.9b4/src: gxsubs.o
Seulement dans grads-1.9b4/src: gxtran
Seulement dans grads-1.9b4/src: gxtran.o
Seulement dans grads-1.9b4/src: gxwmap.o
Seulement dans grads-1.9b4/src: gxX.o
Seulement dans grads-1.9b4/src: latsgribmap.o
Seulement dans grads-1.9b4/src: latsgrib.o
Seulement dans grads-1.9b4/src: latsint.o
Seulement dans grads-1.9b4/src: latsnc-nc.o
Seulement dans grads-1.9b4/src: latsnc.o
Seulement dans grads-1.9b4/src: lats.o
Seulement dans grads-1.9b4/src: latsstat.o
Seulement dans grads-1.9b4/src: latstime.o
Seulement dans grads-1.9b4/src: Makefile
Seulement dans grads-1.9b4/src: stamp-h
Seulement dans grads-1.9b4/src: stamp-h1
Seulement dans grads-1.9b4/src: stnmap
Seulement dans grads-1.9b4/src: stnmap.o
Seulement dans grads-1.9b4/src: wgrib
Seulement dans grads-1.9b4/src: wgrib.o
-------------- next part --------------
# Configure macros for Libdap
# Patrice Dumas 2005 based on freetype2.m4 from Marcelo Magallon 2001-10-26,
# based on gtk.m4 by Owen Taylor
# AC_CHECK_DODS is also based on code from gdal configure.in

# AC_CHECK_LIBDAP([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
# Test for Libdap and define DAP_CFLAGS and DAP_LIBS.
# Check that the version is above MINIMUM-VERSION
# use when linking with a c++ aware linker, with a c linker you may also
# need -lstdc++

AC_DEFUN([AC_CHECK_LIBDAP],
[
  AC_PATH_PROG([DAP_CONFIG], [dap-config], [no])
  dap_min_version=m4_if([$1], [], [3.5.0], [$1])
  AC_MSG_CHECKING([for libdap version >= $dap_min_version])
  dap_no=""
  if test "$DAP_CONFIG" = "no" ; then
     dap_no=yes
  else
     dap_config_major_version=`$DAP_CONFIG --version | sed 's/^libdap \([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$/\1/'`
     dap_config_minor_version=`$DAP_CONFIG --version | sed 's/^libdap \([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$/\2/'`
     dap_config_micro_version=`$DAP_CONFIG --version | sed 's/^libdap \([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$/\2/'`
     dap_min_major_version=`echo $dap_min_version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
     dap_min_minor_version=`echo $dap_min_version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
     dap_min_micro_version=`echo $dap_min_version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`

     dap_config_is_lt=""
     if test $dap_config_major_version -lt $dap_min_major_version ; then
       dap_config_is_lt=yes
     else
       if test $dap_config_major_version -eq $dap_min_major_version ; then
         if test $dap_config_minor_version -lt $dap_min_minor_version ; then
           dap_config_is_lt=yes
         else
           if test $dap_config_minor_version -eq $dap_min_minor_version ; then
             if test $dap_config_micro_version -lt $dap_min_micro_version ; then
               dap_config_is_lt=yes
             fi
           fi
         fi
       fi
     fi
     if test x$dap_config_is_lt = xyes ; then
       dap_no=yes
     else
       DAP_LIBS="`$DAP_CONFIG --libs`"
       DAP_CFLAGS="`$DAP_CONFIG --cflags`"
     fi
   fi
   if test x$dap_no = x ; then
     AC_MSG_RESULT([yes])
     m4_if([$2], [], [:], [$2])
   else
     AC_MSG_RESULT([no])
     if test "$DAP_CONFIG" = "no" ; then
     AC_MSG_NOTICE([The dap-config script could not be found.])
     else
       if test x$dap_config_is_lt = xyes ; then
         AC_MSG_NOTICE([the installed libdap library is too old.])
       fi
     fi
     DAP_LIBS=""
     DAP_CFLAGS=""
     m4_if([$3], [], [:], [$3])
   fi
   AC_SUBST([DAP_CFLAGS])
   AC_SUBST([DAP_LIBS])
])

# AC_CHECK_DODS([ ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
# Test for Libdap or older versions. Define DAP_CFLAGS and DAP_LIBS and
# optionnaly DAP_ROOT

AC_DEFUN([AC_CHECK_DODS],
[
  AC_ARG_WITH(dods_root,
    [  --with-dods-root[=ARG] DODS root fallback ],
    ,,)

  ac_dods_ok='no'
  AC_CHECK_LIBDAP([],[ac_dods_ok='yes'],[ac_dods_ok='no'])
  if test "z$ac_dods_ok" = "zno" ; then
     AC_PATH_PROG([OPENDAP_CONFIG], [opendap-config], [no])
     AC_MSG_CHECKING([for libdap with opendap-config])
     if test "$OPENDAP_CONFIG" = "no" ; then
       ac_dods_ok='no'
        AC_MSG_RESULT([no])
     else
       DAP_LIBS="`$OPENDAP_CONFIG --libs`"
       DAP_CFLAGS="`$OPENDAP_CONFIG --cflags`"
       ac_dods_ok='yes'
        AC_MSG_RESULT([yes])
     fi
  fi
  DAP_ROOT=
  if test "z$ac_dods_ok" = "zno" ; then
    AC_MSG_CHECKING(DODS specific root)
    if test -z "$with_dods_root" -o "$with_dods_root" = "no"; then
      AC_MSG_RESULT(disabled)
    else
      AC_MSG_RESULT([$with_dods_root])
      DODS_ROOT=$with_dods_root
      DODS_LIB=$with_dods_root/lib
      DODS_INC=$with_dods_root/include
      DODS_BIN=$with_dods_root/bin

      dnl Add the DODS libraries to LIBS
      if test -x $DODS_BIN/opendap-config ; then
        dnl OPeNDAP 3.4 and earlier lack opendap-config, but use it if avail.
        DAP_LIBS="`$DODS_BIN/opendap-config --libs`"
        DAP_CFLAGS="`$DODS_BIN/opendap-config --cflags`"
        ac_dods_ok='yes'
      else
        dnl Otherwise try to put things together in a more primitive way.
        DAP_LIBS="-L$DODS_LIB -ldap++ -lpthread"
        DAP_CFLAGS="-I$DODS_INC"

        ac_dods_curl='yes'
        dnl Add curl to LIBS; it might be local to DODS or generally installed
        AC_MSG_CHECKING([For curl and libxml2])
        if test -x $DODS_BIN/curl-config; then
            DAP_LIBS="$DAP_LIBS  `$DODS_BIN/curl-config --libs`"
        elif which curl-config > /dev/null 2>&1; then
            DAP_LIBS="$DAP_LIBS  `curl-config --libs`"
        else
            AC_MSG_WARN([You gave a dods root, but I can't find curl!])
            ac_dods_curl='no'
        fi

        ac_dods_xml2='yes'
        if test -x $DODS_BIN/xml2-config; then
            DAP_LIBS="$DAP_LIBS `$DODS_BIN/xml2-config --libs`"
        elif which xml2-config > /dev/null 2>&1; then
            DAP_LIBS="$DAP_LIBS  `xml2-config --libs`"
        else
            AC_MSG_WARN([You gave a dods root, but I can't find xml2!])
            ac_dods_xml2='no'
        fi
        AC_LANG_PUSH([C++])
        if test $ac_dods_xml2 = 'yes' -a $ac_dods_curl = 'yes'; then
          AC_MSG_RESULT([yes])
          dnl We check that linking is succesfull
          ac_save_LIBS="$LIBS"
          ac_save_CFLAGS="$CFLAGS"
          LIBS="$LIBS $DAP_LIBS"
          CFLAGS="$CFLAGS $DAP_CFLAGS"
          AC_MSG_NOTICE([Checking for DODS with curl and libxml2])
          AC_CHECK_LIB([dap++],[main],[ac_dods_ok='yes'],[ac_dods_ok='no'])
          LIBS=$ac_save_LIBS
          CFLAGS=$ac_save_CFLAGS
          if test "z$ac_dods_ok" = "zno"; then
            DAP_LIBS="$DAP_LIBS -lrx"
            ac_save_LIBS="$LIBS"
            ac_save_CFLAGS="$CFLAGS"
            LIBS="$LIBS $DAP_LIBS"
            CFLAGS="$CFLAGS $DAP_CFLAGS"
            AC_MSG_NOTICE([Checking for DODS with curl, libxml2 and librx])
            AC_CHECK_LIB([dap++],[main],[ac_dods_ok='yes'],[ac_dods_ok='no'])
            LIBS=$ac_save_LIBS
            CFLAGS=$ac_save_CFLAGS
          fi
        else
           AC_MSG_RESULT([no])
        fi
        if test $ac_dods_ok = 'no'; then
           dnl assume it is an old version of DODS
           AC_MSG_NOTICE([Checking for DODS with libwww and librx])
           DAP_LIBS="-L$DODS_LIB -lwww -ldap++ -lpthread -lrx"
           DAP_CFLAGS="-I$DODS_INC"
           ac_save_LIBS="$LIBS"
           ac_save_CFLAGS="$CFLAGS"
           LIBS="$LIBS $DAP_LIBS"
           CFLAGS="$CFLAGS $DAP_CFLAGS"
           AC_CHECK_LIB([dap++],[main],[ac_dods_ok='yes'],[ac_dods_ok='no'])
           LIBS=$ac_save_LIBS
           CFLAGS=$ac_save_CFLAGS
        fi
        AC_LANG_POP
      fi

      AC_MSG_CHECKING([for DODS in a specific root])
      if test "z$ac_dods_ok" = "zyes"; then
        AC_MSG_RESULT([yes])
        AC_MSG_NOTICE([setting DAP_ROOT directory to $DODS_ROOT])
        DAP_ROOT="$DODS_ROOT"
      else
        AC_MSG_RESULT([no])
      fi
    fi
  fi
  if test "x$ac_dods_ok" = "xyes" ; then
     m4_if([$1], [], [:], [$1])
  else
     DAP_LIBS=""
     DAP_CFLAGS=""
     m4_if([$2], [], [:], [$2])
  fi
  AC_SUBST([DAP_CFLAGS])
  AC_SUBST([DAP_LIBS])
  AC_SUBST([DAP_ROOT])
])
-------------- next part --------------
# Configure macro for Libnc-dap
# Patrice Dumas 2005 based on freetype2.m4 from Marcelo Magallon 2001-10-26,
# based on gtk.m4 by Owen Taylor

# AC_CHECK_LIBNC_DAP([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
# Test for Libnc-dap and define NC_DAP_CFLAGS and NC_DAP_LIBS.
# Check that the version is above MINIMUM-VERSION

AC_DEFUN([AC_CHECK_LIBNC_DAP],
[
  AC_PATH_PROG([NC_DAP_CONFIG], [ncdap-config], [no])
  ncdap_min_version=m4_if([$1], [], [3.5.0], [$1])
  AC_MSG_CHECKING([for libnc-dap version >= $ncdap_min_version])
  ncdap_no=""
  if test "$NC_DAP_CONFIG" = "no" ; then
     ncdap_no=yes
  else
     ncdap_config_major_version=`$NC_DAP_CONFIG --version | sed 's/^libnc-dap \([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$/\1/'`
     ncdap_config_minor_version=`$NC_DAP_CONFIG --version | sed 's/^libnc-dap \([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$/\2/'`
     ncdap_config_micro_version=`$NC_DAP_CONFIG --version | sed 's/^libnc-dap \([[0-9]]\)*\.\([[0-9]]*\)\.\([[0-9]]*\)$/\2/'`
     ncdap_min_major_version=`echo $ncdap_min_version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
     ncdap_min_minor_version=`echo $ncdap_min_version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
     ncdap_min_micro_version=`echo $ncdap_min_version | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`

     ncdap_config_is_lt=""
     if test $ncdap_config_major_version -lt $ncdap_min_major_version ; then
       ncdap_config_is_lt=yes
     else
       if test $ncdap_config_major_version -eq $ncdap_min_major_version ; then
         if test $ncdap_config_minor_version -lt $ncdap_min_minor_version ; then
           ncdap_config_is_lt=yes
         else
           if test $ncdap_config_minor_version -eq $ncdap_min_minor_version ; then
             if test $ncdap_config_micro_version -lt $ncdap_min_micro_version ; then
               ncdap_config_is_lt=yes
             fi
           fi
         fi
       fi
     fi
     if test x$ncdap_config_is_lt = xyes ; then
       ncdap_no=yes
     else
       NC_DAP_LIBS="`$NC_DAP_CONFIG --libs`"
       NC_DAP_CFLAGS="`$NC_DAP_CONFIG --cflags`"
     fi
   fi
   if test x$ncdap_no = x ; then
     AC_MSG_RESULT([yes])
     m4_if([$2], [], [:], [$2])
   else
     AC_MSG_RESULT([no])
     if test "$NC_DAP_CONFIG" = "no" ; then
     AC_MSG_NOTICE([The ncdap-config script could not be found.])
     else
       if test x$ncdap_config_is_lt = xyes ; then
         AC_MSG_NOTICE([the installed libnc-dap library is too old.])
       fi
     fi
     NC_DAP_LIBS=""
     NC_DAP_CFLAGS=""
     m4_if([$3], [], [:], [$3])

   fi
   AC_SUBST([NC_DAP_CFLAGS])
   AC_SUBST([NC_DAP_LIBS])
])


# AC_FC_CHECK_LIBNC_DAP([MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
# Test for Libnc-dap and define NC_DAP_FFLAGS and NC_DAP_FLIBS with flags
# for fortran.
# Check that the version is above MINIMUM-VERSION

AC_DEFUN([AC_FC_CHECK_LIBNC_DAP],
[
  libnc_fc_dap_ok="no"
  AC_CHECK_LIBNC_DAP([$1],[libnc_fc_dap_ok="yes"],[libnc_fc_dap_ok="no"])
  if test $libnc_fc_dap_ok = "yes"; then
     NC_DAP_FLIBS="`$NC_DAP_CONFIG --flibs`"
     NC_DAP_FFLAGS="$NC_DAP_CFLAGS"
     m4_if([$2], [], [:], [$2])
  else
     m4_if([$3], [], [:], [$3])
     NC_DAP_FLIBS=""
     NC_DAP_FFLAGS=""
  fi
  AC_SUBST([NC_DAP_FFLAGS])
  AC_SUBST([NC_DAP_FLIBS])
])


# AC_CHECK_NC_DODS([ ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
# Test for Libnc-dap or older versions. Define NC_DAP_CFLAGS and NC_DAP_LIBS.
# use AC_CHECK_DODS if the flags cannot be found easily

AC_DEFUN([AC_CHECK_NC_DODS],
[
  ac_ncdods_ok='no'
  AC_CHECK_LIBNC_DAP([],[ac_ncdods_ok='yes'],[ac_ncdods_ok='no'])
  if test "z$ac_ncdods_ok" = "zno" ; then
     AC_PATH_PROG([OPENNC_DAP_CONFIG], [opendap-config], [no])
     AC_MSG_CHECKING([for libnc-dap with opendap-config])
     if test "$OPENNC_DAP_CONFIG" = "no" ; then
       ac_ncdods_ok='no'
       AC_MSG_RESULT([no])
     else
       NC_DAP_LIBS="`$OPENNC_DAP_CONFIG --libs-nc`"
       NC_DAP_CFLAGS="`$OPENNC_DAP_CONFIG --cflags`"
       ac_ncdods_ok='yes'
       AC_MSG_RESULT([yes])
     fi
  fi
  if test "z$ac_ncdods_ok" = "zno" ; then
     ac_ncdods_dap_ok='no'
     AC_CHECK_DODS([ac_ncdods_dap_ok='yes'],[ac_ncdods_dap_ok='no'])
     if test "z$ac_ncdods_dap_ok" = 'zyes'; then
        NC_DAP_LIBS="$DAP_LIBS -lnc-dods -ldap++"
        NC_DAP_CFLAGS="$DAP_CFLAGS"
        AC_LANG_PUSH([C++])
        dnl We check that linking is succesfull
        ac_save_LIBS="$LIBS"
        ac_save_CFLAGS="$CFLAGS"
        LIBS="$LIBS $NC_DAP_LIBS"
        CFLAGS="$CFLAGS $NC_DAP_CFLAGS"
        AC_CHECK_FUNC([nc_open],[ac_ncdods_ok='yes'],[ac_ncdods_ok='no'])
        LIBS=$ac_save_LIBS
        CFLAGS=$ac_save_CFLAGS
        AC_LANG_POP
     fi
  fi
  if test "x$ac_ncdods_ok" = "xyes" ; then
     m4_if([$1], [], [:], [$1])
  else
     NC_DAP_LIBS=""
     NC_DAP_CFLAGS=""
     m4_if([$2], [], [:], [$2])
  fi
  AC_SUBST([NC_DAP_CFLAGS])
  AC_SUBST([NC_DAP_LIBS])
])


More information about the gradsusr mailing list