From: Keith Busch Date: Mon, 10 Feb 2020 23:29:10 +0000 (-0800) Subject: Make systemd-devel optional X-Git-Tag: v1.0-rc0~178 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=14f550e99ce9e493ed3d22b42f288ff68b65f82b;p=users%2Fsagi%2Flibnvme.git Make systemd-devel optional 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 --- diff --git a/configure b/configure index 63d26a50..88663d6b 100755 --- 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 diff --git a/src/Makefile b/src/Makefile index 5f42219c..03e5abc5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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) diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 795a060a..1eeeac35 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -13,7 +13,10 @@ #include #include +#ifdef CONFIG_SYSTEMD #include +#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 @@ -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) {