]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
Make systemd-devel optional
authorKeith Busch <kbusch@kernel.org>
Mon, 10 Feb 2020 23:29:10 +0000 (15:29 -0800)
committerKeith Busch <kbusch@kernel.org>
Mon, 10 Feb 2020 23:29:10 +0000 (15:29 -0800)
There's only one libnvme feature that uses this package. Let's make this
feature optional and return error ENOTSUP if the package is not available.

Signed-off-by: Keith Busch <kbusch@kernel.org>
configure
src/Makefile
src/nvme/fabrics.c

index 63d26a50c9b8bad4517fc959157941f44acb12fb..88663d6bc534c9ff21f5f1f152929bf7ec2c8010 100755 (executable)
--- a/configure
+++ b/configure
@@ -138,6 +138,18 @@ compile_prog() {
   do_cc $CFLAGS $local_cflags -o $TMPE $TMPC $LDFLAGS $local_ldflags
 }
 
+feature_not_found() {
+  feature=$1
+  packages=$2
+
+  echo ""
+  echo "ERROR: $feature package requirements not met"
+  if test ! -z "$packages" ; then
+    echo "ERROR: needs $packages installed"
+  fi
+  fatal ""
+}
+
 has() {
   type "$1" >/dev/null 2>&1
 }
@@ -167,25 +179,25 @@ print_and_output_mak "datadir" "$datadir"
 libuuid="no"
 ${ld} -o /dev/null -luuid >/dev/null 2>&1
 if [ $? -eq 0 ]; then
-       libuuid="yes"
+  libuuid="yes"
 fi
 print_config "libuuid" "${libuuid}"
 
 ##########################################
 # check for SystemD
-havesystemd="no"
-pkg-config --exists systemd  --atleast-version=232
+systemd="no"
+pkg-config --exists systemd --atleast-version=232
 if [ $? -eq 0 ]; then
-       havesystemd="yes"
+  systemd="yes"
 fi
-print_config "havesystemd" "${havesystemd}"
+print_config "systemd" "${systemd}"
 
 if test "$libuuid" = "yes"; then
-  output_sym "LIBUUID"
+  output_sym "CONFIG_LIBUUID"
   echo "override LDFLAGS += -luuid" >> $config_host_mak
   echo "override LIB_DEPENDS += uuid" >> $config_host_mak 
 fi
-if test "$havesystemd" = "yes"; then
-  output_sym "HAVE_SYSTEMD"
+if test "$systemd" = "yes"; then
+  output_sym "CONFIG_SYSTEMD"
   echo "override LDFLAGS += -lsystemd" >> $config_host_mak
 fi
index 5f42219cb891140f55ae424e863b7e7b240fcc97..03e5abc5504a3e60844d98651b27801a1d2f7f62 100644 (file)
@@ -8,7 +8,7 @@ libdir ?= $(prefix)/lib
 
 CCANDIR=ccan/
 
-CFLAGS ?= -g -fomit-frame-pointer -O2 -I/usr/include -Invme/ -I$(CCANDIR)
+CFLAGS ?= -g -fomit-frame-pointer -O2 -I/usr/include -Invme/ -I$(CCANDIR) -include ../config-host.h
 override CFLAGS += -Wall -fPIC
 SO_CFLAGS=-shared $(CFLAGS)
 L_CFLAGS=$(CFLAGS)
index 795a060adf51c60724a8677c96126b1c35e0e9cc..1eeeac355b2b93676fe5f6509fd43d77ecaa731b 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#ifdef CONFIG_SYSTEMD
 #include <systemd/sd-id128.h>
+#define NVME_HOSTNQN_ID SD_ID128_MAKE(c7,f4,61,81,12,be,49,32,8c,83,10,6f,9d,dd,d8,6b)
+#endif
 
 #include <ccan/array_size/array_size.h>
 
@@ -22,7 +25,6 @@
 #include "util.h"
 
 #define NVMF_HOSTID_SIZE       36
-#define NVME_HOSTNQN_ID SD_ID128_MAKE(c7,f4,61,81,12,be,49,32,8c,83,10,6f,9d,dd,d8,6b)
 
 const char *nvmf_dev = "/dev/nvme-fabrics";
 const char *nvmf_hostnqn_file = "/etc/nvme/hostnqn";
@@ -336,6 +338,7 @@ out_free_log:
        return ret;
 }
 
+#ifdef CONFIG_SYSTEMD
 char *nvmf_hostnqn_generate()
 {
        char *ret = NULL;
@@ -351,6 +354,13 @@ char *nvmf_hostnqn_generate()
 
        return ret;
 }
+#else
+char *nvmf_hostnqn_generate()
+{
+       errno = ENOTSUP;
+       return NULL;
+}
+#endif
 
 static char *nvmf_read_file(const char *f, int len)
 {