]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Build without uuid
authorKeith Busch <keith.busch@intel.com>
Mon, 27 Feb 2017 15:25:53 +0000 (10:25 -0500)
committerKeith Busch <keith.busch@intel.com>
Mon, 27 Feb 2017 15:28:19 +0000 (10:28 -0500)
By popular demand, this introduces a compile time check for uuid and
callbacks accordingly.

https://github.com/linux-nvme/nvme-cli/issues/160

Signed-off-by: Keith Busch <keith.busch@intel.com>
Makefile
nvme.c

index e88add79343c97e291fdb6b0c51490171a00c7f6..2d25edc41af42bff5e8bd6544b733482e677d99a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 CFLAGS ?= -O2 -g -Wall -Werror
 CFLAGS += -std=gnu99
 CPPFLAGS += -D_GNU_SOURCE -D__CHECK_ENDIAN__
-LDFLAGS += -luuid
+LIBUUID = $(shell ld -o /dev/null -luuid >/dev/null 2>&1; echo $$?)
 NVME = nvme
 INSTALL ?= install
 DESTDIR =
@@ -10,6 +10,12 @@ SYSCONFDIR = /etc
 SBINDIR = $(PREFIX)/sbin
 LIB_DEPENDS =
 
+ifeq ($(LIBUUID),0)
+       override LDFLAGS += -luuid
+       override CFLAGS += -DLIBUUID
+       override LIB_DEPENDS += uuid
+endif
+
 RPMBUILD = rpmbuild
 TAR = tar
 RM = rm -f
diff --git a/nvme.c b/nvme.c
index 4fe908fe5d9d4a1bf21d40e2cbcbba79bffe973e..be5ec834f99013e56090ed426599b19c910092eb 100644 (file)
--- a/nvme.c
+++ b/nvme.c
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+
+#ifdef LIBUUID
 #include <uuid/uuid.h>
+#endif
 
 #include "nvme-print.h"
 #include "nvme-ioctl.h"
@@ -2676,6 +2679,7 @@ static int admin_passthru(int argc, char **argv, struct command *cmd, struct plu
        return passthru(argc, argv, NVME_IOCTL_ADMIN_CMD, desc, cmd);
 }
 
+#ifdef LIBUUID
 static int gen_hostnqn_cmd(int argc, char **argv, struct command *command, struct plugin *plugin)
 {
        uuid_t uuid;
@@ -2686,6 +2690,14 @@ static int gen_hostnqn_cmd(int argc, char **argv, struct command *command, struc
        printf("nqn.2014-08.org.nvmexpress:NVMf:uuid:%s\n", uuid_str);
        return 0;
 }
+#else
+static int gen_hostnqn_cmd(int argc, char **argv, struct command *command, struct plugin *plugin)
+{
+       fprintf(stderr, "\"%s\" not supported. Install lib uuid and rebuild.\n",
+               command->name);
+       return -ENOTSUP;
+}
+#endif
 
 static int discover_cmd(int argc, char **argv, struct command *command, struct plugin *plugin)
 {