[libvirt PATCH 05/32] build: generate configmake.h in root directory

Daniel P. Berrangé berrange at redhat.com
Thu Jan 23 11:42:58 UTC 2020


Currently we rely on gnulib creating configmake.h, but we
can easily create it ourselves instead.

Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
 Makefile.am              | 44 ++++++++++++++++++++++++++++++++++++++++
 configure.ac             | 12 +++++------
 tools/nss/libvirt_nss.c  |  7 +------
 tools/virt-login-shell.c |  6 +-----
 4 files changed, 51 insertions(+), 18 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 8a8eecb697..485b281a03 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -129,6 +129,9 @@ clean-cov:
 
 MAINTAINERCLEANFILES = .git-module-status
 
+BUILT_SOURCES = configmake.h
+CLEANFILES = configmake.h
+
 distclean-local: clean-GNUmakefile
 clean-GNUmakefile:
 	test '$(srcdir)' = . || rm -f $(top_builddir)/GNUmakefile
@@ -154,3 +157,44 @@ gen-AUTHORS:
 
 ci-%:
 	$(MAKE) -C $(srcdir)/ci/ $@
+
+# Listed in the same order as the GNU makefile conventions, and
+# provided by autoconf 2.59c+ or 2.70.
+# The Automake-defined pkg* macros are appended, in the order
+# listed in the Automake 1.10a+ documentation.
+configmake.h: Makefile
+	$(AM_V_GEN)rm -f $@-t && \
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+	  echo '#if HAVE_WINSOCK2_H'; \
+	  echo '# include <winsock2.h> /* avoid mingw pollution on DATADIR */'; \
+	  echo '#endif'; \
+	  echo '#define PREFIX "$(prefix)"'; \
+	  echo '#define EXEC_PREFIX "$(exec_prefix)"'; \
+	  echo '#define BINDIR "$(bindir)"'; \
+	  echo '#define SBINDIR "$(sbindir)"'; \
+	  echo '#define LIBEXECDIR "$(libexecdir)"'; \
+	  echo '#define DATAROOTDIR "$(datarootdir)"'; \
+	  echo '#define DATADIR "$(datadir)"'; \
+	  echo '#define SYSCONFDIR "$(sysconfdir)"'; \
+	  echo '#define SHAREDSTATEDIR "$(sharedstatedir)"'; \
+	  echo '#define LOCALSTATEDIR "$(localstatedir)"'; \
+	  echo '#define RUNSTATEDIR "$(runstatedir)"'; \
+	  echo '#define INCLUDEDIR "$(includedir)"'; \
+	  echo '#define OLDINCLUDEDIR "$(oldincludedir)"'; \
+	  echo '#define DOCDIR "$(docdir)"'; \
+	  echo '#define INFODIR "$(infodir)"'; \
+	  echo '#define HTMLDIR "$(htmldir)"'; \
+	  echo '#define DVIDIR "$(dvidir)"'; \
+	  echo '#define PDFDIR "$(pdfdir)"'; \
+	  echo '#define PSDIR "$(psdir)"'; \
+	  echo '#define LIBDIR "$(libdir)"'; \
+	  echo '#define LISPDIR "$(lispdir)"'; \
+	  echo '#define LOCALEDIR "$(localedir)"'; \
+	  echo '#define MANDIR "$(mandir)"'; \
+	  echo '#define MANEXT "$(manext)"'; \
+	  echo '#define PKGDATADIR "$(pkgdatadir)"'; \
+	  echo '#define PKGINCLUDEDIR "$(pkgincludedir)"'; \
+	  echo '#define PKGLIBDIR "$(pkglibdir)"'; \
+	  echo '#define PKGLIBEXECDIR "$(pkglibexecdir)"'; \
+	} | sed '/""/d' > $@-t && \
+	mv -f $@-t $@
diff --git a/configure.ac b/configure.ac
index 4bdf38ec15..f0d79b95d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -132,14 +132,12 @@ AC_PROG_CPP
 dnl autoconf 2.70 adds a --runstatedir option so that downstreams
 dnl can point to /run instead of the historic /var/run, but
 dnl autoconf hasn't had a release since 2012.
-dnl
-dnl gnulib sets configmake.h to include runstatedir, but sets
-dnl it to $localstatedir/run if $runstatedir env var is not set
-dnl which is useless for apps that need to use /run without
-dnl waiting for autoconf 2.70
-dnl
+if test "x$runstatedir" = x; then
+  AC_SUBST([runstatedir], ['${localstatedir}/run'])
+fi
+
 dnl we introduce --with-runstatedir and then overwrite the
-dnl value of $runstatedir so gnulib's configmake.h becomes useful
+dnl value of $runstatedir so configmake.h is more useful
 AC_ARG_WITH(
     [runstatedir],
     [AS_HELP_STRING(
diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c
index 6e332f7578..3b89f72742 100644
--- a/tools/nss/libvirt_nss.c
+++ b/tools/nss/libvirt_nss.c
@@ -41,12 +41,7 @@
 # include <nsswitch.h>
 #endif
 
-/*
- * This gnulib files is used for its macros only,
- * so doesn't introduce a link time dep, which we
- * must avoid
- */
-#include "gnulib/lib/configmake.h"
+#include "configmake.h"
 
 #include "libvirt_nss_leases.h"
 
diff --git a/tools/virt-login-shell.c b/tools/virt-login-shell.c
index cf4a249f0a..25449f972d 100644
--- a/tools/virt-login-shell.c
+++ b/tools/virt-login-shell.c
@@ -28,11 +28,7 @@
 #include <errno.h>
 #include <string.h>
 
-/*
- * These gnulib files are used for their macros only,
- * so don't introduce a link time dep, which we must avoid
- */
-#include "gnulib/lib/configmake.h"
+#include "configmake.h"
 
 #define VIR_INT64_STR_BUFLEN 21
 
-- 
2.24.1




More information about the libvir-list mailing list