summarylogtreecommitdiffstats
path: root/netcdf-build-fix.diff
blob: 71c9e0e76dd3531c6fe98cb0c39e36d4c08052f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Description: Update NETCDF macro in autotools
Author: Ionut Georgescu
Index: grace-5.1.24-patch/ac-tools/configure.in
===================================================================
--- grace-5.1.24-patch.orig/ac-tools/configure.in
+++ grace-5.1.24-patch/ac-tools/configure.in
@@ -548,8 +548,17 @@ fi
 
 if test $netcdf = true
 then
-  ACX_CHECK_NETCDF(3.0, AC_DEFINE(HAVE_NETCDF),
-                   AC_MSG_RESULT(--> support for netCDF is disabled))
+  AC_CHECK_HEADERS(netcdf.h,
+  [
+	AC_CHECK_LIB(netcdf, nc_open,
+	[
+		NETCDF_LIBS="-lnetcdf"
+		AC_DEFINE(HAVE_NETCDF)
+	],
+	[AC_MSG_RESULT([--> support for netCDF is disabled])]
+	)
+   ],
+   [AC_MSG_RESULT([--> support for netCDF is disabled])])
 fi
 
 if test $fftw = true
Index: grace-5.1.24-patch/configure
===================================================================
--- grace-5.1.24-patch.orig/configure
+++ grace-5.1.24-patch/configure
@@ -747,7 +747,6 @@ with_helpviewer
 with_printcmd
 enable_debug
 enable_maintainer
-with_netcdf_libraries
 with_zlib_library
 with_jpeg_library
 with_png_library
@@ -1410,7 +1409,6 @@ Optional Packages:
   --with-editor=COMMAND        define editor ["xterm -e vi"]
   --with-helpviewer=COMMAND    define help viewer command ["mozilla %s"]
   --with-printcmd=PROG         use PROG for printing
-  --with-netcdf-libraries=OBJ  use OBJ as netCDF libraries [-lnetcdf]
   --with-zlib-library=OBJ      use OBJ as ZLIB library [-lz]
   --with-jpeg-library=OBJ      use OBJ as JPEG library [-ljpeg]
   --with-png-library=OBJ       use OBJ as PNG library [-lpng]
@@ -8138,86 +8136,69 @@ fi
 
 if test $netcdf = true
 then
+  for ac_header in netcdf.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "netcdf.h" "ac_cv_header_netcdf_h" "$ac_includes_default"
+if test "x$ac_cv_header_netcdf_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_NETCDF_H 1
+_ACEOF
 
-
-# Check whether --with-netcdf_libraries was given.
-if test "${with_netcdf_libraries+set}" = set; then :
-  withval=$with_netcdf_libraries; netcdf_libraries="$withval"
-fi
-
-  if test "x$netcdf_libraries" = "x"
-  then
-    netcdf_libraries=-lnetcdf
-  fi
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for netCDF API version >= 3.0" >&5
-$as_echo_n "checking for netCDF API version >= 3.0... " >&6; }
-if ${acx_cv_netcdf+:} false; then :
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nc_open in -lnetcdf" >&5
+$as_echo_n "checking for nc_open in -lnetcdf... " >&6; }
+if ${ac_cv_lib_netcdf_nc_open+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if ${acx_cv_netcdf_libraries+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  acx_cv_netcdf_libraries=$netcdf_libraries
-fi
-
-
-    save_CFLAGS=$CFLAGS
-    save_CPPFLAGS=$CPPFLAGS
-    save_LDFLAGS=$LDFLAGS
-    save_LIBS=$LIBS
-
-    LIBS="$acx_cv_netcdf_libraries $LIBS"
-
-
-    if test "$cross_compiling" = yes; then :
-  acx_cv_netcdf="no"
-
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnetcdf  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-#include <stdio.h>
-#include <netcdf.h>
-      int main(void) {
-        char *vlib;
-        vlib = nc_inq_libvers();
-        if (strcmp(vlib, "3.0") < 0) {
-          exit(1);
-        }
-        exit(0);
-      }
-
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char nc_open ();
+int
+main ()
+{
+return nc_open ();
+  ;
+  return 0;
+}
 _ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  acx_cv_netcdf="yes"
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_netcdf_nc_open=yes
 else
-  acx_cv_netcdf="no"
+  ac_cv_lib_netcdf_nc_open=no
 fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_netcdf_nc_open" >&5
+$as_echo "$ac_cv_lib_netcdf_nc_open" >&6; }
+if test "x$ac_cv_lib_netcdf_nc_open" = xyes; then :
 
+		NETCDF_LIBS="-lnetcdf"
+		$as_echo "#define HAVE_NETCDF 1" >>confdefs.h
 
-    CFLAGS=$save_CFLAGS
-    CPPFLAGS=$save_CPPFLAGS
-    LDFLAGS=$save_LDFLAGS
-    LIBS=$save_LIBS
 
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: --> support for netCDF is disabled" >&5
+$as_echo "--> support for netCDF is disabled" >&6; }
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_netcdf" >&5
-$as_echo "$acx_cv_netcdf" >&6; }
-  if test "$acx_cv_netcdf" = "yes"
-  then
-    NETCDF_LIBS="$acx_cv_netcdf_libraries"
-    $as_echo "#define HAVE_NETCDF 1" >>confdefs.h
 
-  else
-    NETCDF_LIBS=
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: --> support for netCDF is disabled" >&5
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: --> support for netCDF is disabled" >&5
 $as_echo "--> support for netCDF is disabled" >&6; }
-  fi
+fi
+
+done
 
 fi