diff mbox series

[ndctl] ndctl: Introduce ndctl/config.h

Message ID 154752443528.1624297.9852799229397528506.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit 7a71522e0751cf877ed970f6d9521d6699fb2b46
Headers show
Series [ndctl] ndctl: Introduce ndctl/config.h | expand

Commit Message

Dan Williams Jan. 15, 2019, 3:53 a.m. UTC
The AC_DEFINE_QUOTED scheme falls over if the autoconf variable requires
expansion. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=385769.

Define a config.h file autogenerated by the build system and let 'make'
do the variable expansion.

Cc: Qi Fuli <qi.fuli@jp.fujitsu.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 .gitignore        |    1 +
 configure.ac      |    2 --
 ndctl/Makefile.am |    7 +++++++
 ndctl/monitor.c   |    1 +
 4 files changed, 9 insertions(+), 2 deletions(-)

Comments

Verma, Vishal L Jan. 16, 2019, 9:07 p.m. UTC | #1
On Mon, 2019-01-14 at 19:53 -0800, Dan Williams wrote:
> The AC_DEFINE_QUOTED scheme falls over if the autoconf variable
> requires
> expansion. See 
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=385769.
> 
> Define a config.h file autogenerated by the build system and let
> 'make'
> do the variable expansion.
> 
> Cc: Qi Fuli <qi.fuli@jp.fujitsu.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  .gitignore        |    1 +
>  configure.ac      |    2 --
>  ndctl/Makefile.am |    7 +++++++
>  ndctl/monitor.c   |    1 +
>  4 files changed, 9 insertions(+), 2 deletions(-)

Thanks, applied.
diff mbox series

Patch

diff --git a/.gitignore b/.gitignore
index 0baace4b457e..5a3d8e4507e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@  daxctl/lib/libdaxctl.la
 daxctl/lib/libdaxctl.lo
 daxctl/lib/libdaxctl.pc
 *.a
+ndctl/config.h
 ndctl/lib/libndctl.pc
 ndctl/ndctl
 rhel/
diff --git a/configure.ac b/configure.ac
index aa07ec7bc870..a02a2d80e1d5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -158,8 +158,6 @@  ndctl_monitorconfdir=${sysconfdir}/ndctl
 ndctl_monitorconf=monitor.conf
 AC_SUBST([ndctl_monitorconfdir])
 AC_SUBST([ndctl_monitorconf])
-AC_DEFINE_UNQUOTED(NDCTL_CONF_FILE, ["$ndctl_monitorconfdir/$ndctl_monitorconf"],
-	[default ndctl monitor conf path])
 
 my_CFLAGS="\
 -Wall \
diff --git a/ndctl/Makefile.am b/ndctl/Makefile.am
index ff01e0688afd..f96f08974aa6 100644
--- a/ndctl/Makefile.am
+++ b/ndctl/Makefile.am
@@ -2,6 +2,13 @@  include $(top_srcdir)/Makefile.am.in
 
 bin_PROGRAMS = ndctl
 
+DISTCLEANFILES = config.h
+BUILT_SOURCES = config.h
+config.h: Makefile
+	$(AM_V_GEN) echo "/* Autogenerated by ndctl/Makefile.am */" >$@
+	$(AM_V_GEN) echo '#define NDCTL_CONF_FILE \
+		"$(ndctl_monitorconfdir)/$(ndctl_monitorconf)"' >>$@
+
 ndctl_SOURCES = ndctl.c \
 		bus.c \
 		create-nfit.c \
diff --git a/ndctl/monitor.c b/ndctl/monitor.c
index 233f2bbd9b55..0daba0e96306 100644
--- a/ndctl/monitor.c
+++ b/ndctl/monitor.c
@@ -10,6 +10,7 @@ 
 #include <util/util.h>
 #include <util/parse-options.h>
 #include <util/strbuf.h>
+#include <ndctl/config.h>
 #include <ndctl/ndctl.h>
 #include <ndctl/libndctl.h>
 #include <sys/epoll.h>