$NetBSD: patch-ag,v 1.1 2002/10/02 21:38:02 dillo Exp $

--- configure.orig	Wed Oct  2 23:34:47 2002
+++ configure
@@ -1455,66 +1453,58 @@ done
 
 
 
-echo $ac_n "checking for netcdf library""... $ac_c" 1>&6
-echo "configure:1460: checking for netcdf library" >&5
+echo $ac_n "checking for ncvarid in -lnetcdf""... $ac_c" 1>&6
+echo "configure:1458: checking for ncvarid in -lnetcdf" >&5
+ac_lib_var=`echo netcdf'_'ncvarid | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-lnetcdf  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1466 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+char ncvarid();
 
-    if test -d /opt/netcdf/include ; then
-	#
-	# Solaris often has it here
-	CXXFLAGS="$CXXFLAGS -I/opt/netcdf/include"
-        LIBS="$LIBS -L/opt/netcdf/lib -lnetcdf"
-	if test $gri_cv_is_sun = yes ; then
-	    LIBS="$LIBS -lnsl"
-	fi
-	cat >> confdefs.h <<\EOF
-#define HAVE_LIBNETCDF 1
+int main() {
+ncvarid()
+; return 0; }
 EOF
+if { (eval echo configure:1480: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
 
-        echo "yes (in /opt/netcdf/include/netcdf.h and /opt/netcdf/lib/libnetcdf.a)"
-    else
-	if test -f /usr/local/include/netcdf.h ; then
-	    CXXFLAGS="$CPPFLAGS -I/usr/local/include"
-	    LIBS="$LIBS -L/usr/local/lib -lnetcdf"
-            if test $gri_cv_is_sun = yes ; then
-		LIBS="$LIBS -lnsl"
-	    fi
-	    cat >> confdefs.h <<\EOF
-#define HAVE_LIBNETCDF 1
-EOF
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  HAVE_LIBNETCDF="YES"
+else
+  echo "$ac_t""no" 1>&6
+HAVE_LIBNETCDF=""
+fi
 
-            echo "yes (in /usr/local/include/netcdf.h and /usr/local/lib/libnetcdf.a)"
-	else
-	    #
-	    # Linux/debian often has it here.
-	    if test -f /usr/include/netcdf.h ; then
-                CXXFLAGS="$CPPFLAGS -I/usr/include/netcdf"
-                LIBS="$LIBS -L/usr/lib/netcdf -lnetcdf"
-                if test $gri_cv_is_sun = yes ; then
-                    LIBS="$LIBS -lnsl"
-                fi
-                cat >> confdefs.h <<\EOF
-#define HAVE_LIBNETCDF 1
-EOF
 
-                echo "yes (in /usr/include/netcdf.h and /usr/lib/libnetcdf.a)"
-            else
-		if test -f /boot/home/lib/netcdf ; then
-		    CXXFLAGS="$CPPFLAGS -I/boot/home/include/netcdf"
-		    LIBS="$LIBS -L/boot/home/lib/netcdf -lnetcdf"
-                    if test $gri_cv_is_sun = yes ; then
-			LIBS="$LIBS -lnsl"
-		    fi
-                    echo "yes (in /boot/home/netcdf)"
-		    cat >> confdefs.h <<\EOF
+if test -n "$HAVE_LIBNETCDF" ; then
+    cat >> confdefs.h <<\EOF
 #define HAVE_LIBNETCDF 1
 EOF
-
-		else
-	            echo "no"
-		fi
-            fi
-        fi
-    fi
+ 
+   LIBS="-lnetcdf $LIBS"
+fi
 
 
 echo $ac_n "checking for sin in -lm""... $ac_c" 1>&6
