r103: Check for the right symbols in nbd.h by compiling, rather than guessing on
authoryoe <yoe>
Wed, 16 Feb 2005 08:38:00 +0000 (08:38 +0000)
committeryoe <yoe>
Wed, 16 Feb 2005 08:38:00 +0000 (08:38 +0000)
whether they'll be there on the basis of other, unrelated, symbols. Also, make
the error message that appears if we don't find what we need a bit more
helpful, and warn the user if a bad nbd.h is found locally but a good one is
provided system-wide.

configure.ac

index 5965ad3..80f6181 100644 (file)
@@ -74,22 +74,31 @@ dnl We need to check for NBD_CMD_DISC, but that's part of an enum, it is not
 dnl #define'd. Therefore, we check for something which is differently #define'd
 dnl in the old or new versions, even if we don't really care about that.
 dnl This might break at some time, but it should work for now, so...
-AC_TRY_CPP([#include "nbd.h"
-#ifdef LOCAL_END_REQUEST
-#error not here
-#endif
-], 
-  [AC_DEFINE(NBD_H_LOCAL, 1, Set to 1 if a (recent enough) nbd.h can be found in the current directory)
-    NBD_H='"nbd.h"'],
-  AC_TRY_CPP([#include <linux/nbd.h>
-#ifdef LOCAL_END_REQUEST
-#error not here
-#endif
+AC_TRY_COMPILE([#include <stdio.h>
+#define MY_NAME "conftest"
+#define NBD_H_LOCAL
+#include "cliserv.h"
 ],
-    [AC_DEFINE(NBD_H_LINUX, 1, Set to 1 if a (recent enough) nbd.h can be found in the linux directory in the search path) NBD_H='<linux/nbd.h>'],
-    AC_MSG_ERROR(Could not find a (recent enough) nbd.h)
+[int foo=NBD_CMD_DISC], 
+  [AC_DEFINE(NBD_H_LOCAL, 1, Set to 1 if a (2.6) nbd.h can be found in the current directory)
+    NBD_H='"nbd.h"'],
+  AC_TRY_COMPILE([#include <stdio.h>
+#define MY_NAME "conftest"
+#define NBD_H_LINUX
+#include "cliserv.h"
+  ],
+[int foo=NBD_CMD_DISC],
+    [AC_DEFINE(NBD_H_LINUX, 1, Set to 1 if a (2.6) nbd.h can be found in the linux directory in the search path) NBD_H='<linux/nbd.h>'],
+    AC_MSG_ERROR(Could not find an nbd.h from 2.6 or above.)
   )
 )
+if test -f nbd.h
+then
+  if test $NBD_H='<linux/nbd.h>'
+  then
+    AC_MSG_WARN([there is a local nbd.h, but it is from the 2.4-series of kernels. Using the system-provided, working, nbd.h])
+  fi
+fi
 AC_MSG_RESULT($NBD_H)
 AC_CHECK_HEADERS([sys/mount.h],,,
 [[#include <sys/param.h>