Add configure checking for presence of libsmbclient-dev
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 3 Sep 2010 22:46:21 +0000 (08:46 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Fri, 3 Sep 2010 22:46:21 +0000 (08:46 +1000)
and build without SMB support if not available.

Add pritning of which optional backends are available int he build
at the end of the configure script

For now : support for raw scsi through the linux sg interface  and smb
support are optional.

Makefile.in
config.h.in
configure.in
dbench.c
linux_scsi.c

index 466a45d9ea223482e7815c92197aec2926bef3d6..b0c0af6f6f1cee4b11ef8017ccd2d3170a0d6cff 100644 (file)
@@ -11,7 +11,7 @@ datadir=@datadir@
 docdir=@datadir@/doc/dbench
 XSLTPROC = /usr/bin/xsltproc
 INSTALLCMD=@INSTALL@
-LIBS=@LIBS@ -lpopt -lz -lsmbclient
+LIBS=@LIBS@ -lpopt -lz @LIBSMBCLIENT@
 DESTDIR=/
 CC=@CC@
 CFLAGS=@CFLAGS@ -I. -DVERSION=\"$(VERSION)\" -DDATADIR=\"$(datadir)\"
@@ -19,7 +19,7 @@ EXEEXT=@EXEEXT@
 
 LIBNFS_OBJ = libnfs.o mount_client.o nfs_client.o mount_xdr.o nfs_xdr.o
 
-DB_OBJS = fileio.o util.o dbench.o child.o system.o snprintf.o sockio.o nfsio.o libnfs.a socklib.o linux_scsi.o iscsi.o smb.o
+DB_OBJS = fileio.o util.o dbench.o child.o system.o snprintf.o sockio.o nfsio.o libnfs.a socklib.o @LINUXSCSI@ iscsi.o @SMBO@
 SRV_OBJS = util.o tbench_srv.o socklib.o
 
 all: dbench doc
index c5a824c19b437fb89d3f714d065aae88798c918f..2e09a7473903c03020cf50ac85cc51710e5c8c1f 100644 (file)
 /* Define to 1 if you have the `lgetxattr' function. */
 #undef HAVE_LGETXATTR
 
+/* Whether we have LIBSMBCLIENT support */
+#undef HAVE_LIBSMBCLIENT
+
 /* Define if Linux SCSI Generic is enabled */
 #undef HAVE_LINUX_SCSI_SG
 
index e64e24e9e0cee0464e6c93b5d6aebe564687e360..869924f232c81d0019f31e6ff9039e2256d00de9 100644 (file)
@@ -111,6 +111,48 @@ else
   exit
 fi
 
+#
+# Check that libsmbclient is available
+#
+AC_MSG_CHECKING(whether libsmbclient is available)
+ac_save_CFLAGS="$CFLAGS"
+ac_save_LIBS="$LIBS"
+CFLAGS="$CFLAGS $GLIB_CFLAGS"
+LIBS="$GLIB_LIBS $LIBS -lsmbclient"
+AC_TRY_RUN([
+#include <stdio.h>
+#include <libsmbclient.h>
+
+int main(int argc, char *argv[])
+{
+       SMBCCTX *ctx;
+
+       ctx = smbc_new_context();
+       if (ctx == NULL) {
+               fprintf(stderr, "Could not allocate SMB Context\n");
+               return 1;
+       }
+
+       smbc_free_context(ctx, 1);
+
+       return 0;
+}
+], ac_cv_have_libsmbclient=yes, ac_cv_have_libsmbclient=no,
+   [echo $ac_n "compile with LIBSMBCLIENT. Assuming OK... $ac_c"
+    ac_cv_have_libsmbclient=yes])
+CFLAGS="$ac_save_CFLAGS"
+LIBS="$ac_save_LIBS"
+if test "$ac_cv_have_libsmbclient" = yes ; then
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(HAVE_LIBSMBCLIENT, 1, [Whether we have LIBSMBCLIENT support])
+  LIBSMBCLIENT="-lsmbclient"
+  SMBO="smb.o"
+else
+  AC_MSG_RESULT(no)
+  AC_MSG_NOTICE(Libsmbclient-dev not available. Building DBENCH without SMB support)
+  LIBSMBCLIENT=""
+  SMBO=""
+fi
 
 #
 # Check whether we have access to Linux SCSI Generic ioctl()
@@ -154,14 +196,33 @@ LIBS="$ac_save_LIBS"
 if test "$ac_cv_linux_scsi_sg" = yes ; then
   AC_MSG_RESULT(yes)
   have_linux_scsi_sg=yes
+  LINUXSCSI="linux_scsi.o"
 else
   AC_MSG_RESULT(no)
   have_linux_scsi_sg=no
+  LINUXSCSI=""
 fi
 if test x$have_linux_scsi_sg = xyes
 then
   AC_DEFINE(HAVE_LINUX_SCSI_SG, 1, [Define if Linux SCSI Generic is enabled])
 fi
 
+AC_SUBST(LIBSMBCLIENT)
+AC_SUBST(SMBO)
+AC_SUBST(LINUXSCSI)
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
+
+
+
+AC_MSG_NOTICE(============================================)
+if test "$ac_cv_have_libsmbclient" = yes ; then
+  AC_MSG_NOTICE(SMB support .......................... [YES])
+else
+  AC_MSG_NOTICE(SMB support .......................... [NO])
+fi
+if test "$ac_cv_linux_scsi_sg" = yes ; then
+  AC_MSG_NOTICE(LINUX SCSI SG support ................ [YES])
+else
+  AC_MSG_NOTICE(LINUX SCSI SG support ................ [NO])
+fi
index 03456f4798610b96a90c9ad16d97e556e8bb2c40..ffbba3ce97346e3a40016652c124f24d27088f0b 100644 (file)
--- a/dbench.c
+++ b/dbench.c
@@ -381,7 +381,7 @@ static void process_opts(int argc, const char **argv)
        struct poptOption popt_options[] = {
                POPT_AUTOHELP
                { "backend", 'B', POPT_ARG_STRING, &options.backend, 0, 
-                 "dbench backend (fileio, sockio, nfs, scsi, iscsi)", "string" },
+                 "dbench backend (fileio, sockio, nfs, scsi, iscsi, smb)", "string" },
                { "timelimit", 't', POPT_ARG_INT, &options.timelimit, 0, 
                  "timelimit", "integer" },
                { "loadfile",  'c', POPT_ARG_STRING, &options.loadfile, 0, 
@@ -440,10 +440,12 @@ static void process_opts(int argc, const char **argv)
                  "How many seconds of warmup to run", NULL },
                { "machine-readable", 0, POPT_ARG_NONE, &options.machine_readable, 0,
                  "Print data in more machine-readable friendly format", NULL},
+#ifdef HAVE_LIBSMBCLIENT
                { "smb-share",  0, POPT_ARG_STRING, &options.smb_share, 0, 
                  "//SERVER/SHARE to use", NULL },
                { "smb-user",  0, POPT_ARG_STRING, &options.smb_user, 0, 
                  "User to authenticate as : [<domain>/]<user>%<password>", NULL },
+#endif
                POPT_TABLEEND
        };
        poptContext pc;
@@ -534,9 +536,11 @@ static void process_opts(int argc, const char **argv)
        } else if (strcmp(options.backend, "iscsi") == 0) {
                extern struct nb_operations iscsi_ops;
                nb_ops = &iscsi_ops;
+#ifdef HAVE_LIBSMBCLIENT
        } else if (strcmp(options.backend, "smb") == 0) {
                extern struct nb_operations smb_ops;
                nb_ops = &smb_ops;
+#endif
        } else {
                printf("Unknown backend '%s'\n", options.backend);
                exit(1);
index 0594f551555417af0ed351316b8106bc54bb8d6f..4eecac8ca2ac8e90cbc6f177246fddafd3e231f0 100644 (file)
@@ -20,8 +20,6 @@
 #include <stdio.h>
 #undef _GNU_SOURCE
 
-#ifdef HAVE_LINUX_SCSI_SG
-
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <scsi/sg.h>
@@ -428,4 +426,3 @@ struct nb_operations scsi_ops = {
        .ops          = ops
 };
 
-#endif /* HAVE_LINUX_SCSI_SG */