From 11d59de600e4af093db642279945d79efa5d1f33 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 17 Jun 2019 13:41:05 +0200 Subject: [PATCH] build/autotools: generate "config-extra.h" via makefile "config-extra.h.mk" When the code that generates "config-extra.h" changes, we want to regenerate the file. Move that code to a separate makefile so we can add a dependency. Otherwise, we'd had to depend on "Makefile", which itself is generated by Makefile.am. Also, depend on "config.h" to regenerate it when ./configure runs and touches that header. This may not cover all cases where ./configure's configuration changes and a regeneration would be due. But such is life. Also, most components depend on this header, so let various .dirstamp files depend on it, so we are sure to build this first. That because, autotools generates dependencies for header files automatically, but that requires that the header file exist. Such automatic dependencies don't work out-of-the-box for generated headers. Co-authored-by: Thomas Haller --- Makefile.am | 38 ++++++++++---------------------------- config-extra.h.mk | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 config-extra.h.mk diff --git a/Makefile.am b/Makefile.am index 750176536..e6d491fd3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -103,37 +103,19 @@ dflt_cppflags = -std=gnu11 ############################################################################### -# with autotools, it is not easily possible to generate these defines -# from configure.ac. -# -# See https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html -# -# With meson-only, they could just be set via config.h.meson -config-extra.h: config.h - $(AM_V_GEN) \ - echo "/* Generated by Makefile.am */" >$@ && \ - echo "#define BINDIR \"$(bindir)\"" >>$@ && \ - echo "#define DATADIR \"$(datadir)\"" >>$@ && \ - echo "#define LIBEXECDIR \"$(libexecdir)\"" >>$@ && \ - echo "#define LOCALSTATEDIR \"$(localstatedir)\"" >>$@ && \ - echo "#define NMCONFDIR \"$(nmconfdir)\"" >>$@ && \ - echo "#define NMLIBDIR \"$(nmlibdir)\"" >>$@ && \ - echo "#define NMLOCALEDIR \"$(nmlocaledir)\"" >>$@ && \ - echo "#define NMPLUGINDIR \"$(plugindir)\"" >>$@ && \ - echo "#define NMRUNDIR \"$(nmrundir)\"" >>$@ && \ - echo "#define NMSTATEDIR \"$(nmstatedir)\"" >>$@ && \ - echo "#define NMVPNDIR \"$(pkglibdir)\"" >>$@ && \ - echo "#define NM_BUILD_BUILDDIR \"$(abs_builddir)\"" >>$@ && \ - echo "#define NM_BUILD_SRCDIR \"$(abs_srcdir)\"" >>$@ && \ - echo "#define PPPD_PLUGIN_DIR \"$(PPPD_PLUGIN_DIR)\"" >>$@ && \ - echo "#define PREFIX \"$(prefix)\"" >>$@ && \ - echo "#define RUNSTATEDIR \"$(runstatedir)\"" >>$@ && \ - echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@ && \ - true +include config-extra.h.mk DISTCLEANFILES += config-extra.h -libnm-core/.dirstamp: config-extra.h +$(libnm_core_lib_h_pub_mkenums): config-extra.h +libnm-core/.dirstamp: config-extra.h +shared/.dirstamp: config-extra.h +shared/nm-glib-aux/.dirstamp: config-extra.h +shared/nm-std-aux/.dirstamp: config-extra.h +shared/nm-udev-aux/.dirstamp: config-extra.h +shared/systemd/.dirstamp: config-extra.h +shared/systemd/src/basic/.dirstamp: config-extra.h +src/dhcp/.dirstamp: config-extra.h ############################################################################### diff --git a/config-extra.h.mk b/config-extra.h.mk new file mode 100644 index 000000000..b1d3814ff --- /dev/null +++ b/config-extra.h.mk @@ -0,0 +1,27 @@ +# With autotools, it is not easily possible to generate these defines +# from configure.ac. +# +# See https://www.gnu.org/software/autoconf/manual/autoconf-2.63/html_node/Installation-Directory-Variables.html +# +# With meson-only, they could just be set via config.h.meson +config-extra.h: config-extra.h.mk config.h + $(AM_V_GEN) \ + echo "/* Generated by Makefile.am */" >$@ && \ + echo "#define BINDIR \"$(bindir)\"" >>$@ && \ + echo "#define DATADIR \"$(datadir)\"" >>$@ && \ + echo "#define LIBEXECDIR \"$(libexecdir)\"" >>$@ && \ + echo "#define LOCALSTATEDIR \"$(localstatedir)\"" >>$@ && \ + echo "#define NMCONFDIR \"$(nmconfdir)\"" >>$@ && \ + echo "#define NMLIBDIR \"$(nmlibdir)\"" >>$@ && \ + echo "#define NMLOCALEDIR \"$(nmlocaledir)\"" >>$@ && \ + echo "#define NMPLUGINDIR \"$(plugindir)\"" >>$@ && \ + echo "#define NMRUNDIR \"$(nmrundir)\"" >>$@ && \ + echo "#define NMSTATEDIR \"$(nmstatedir)\"" >>$@ && \ + echo "#define NMVPNDIR \"$(pkglibdir)\"" >>$@ && \ + echo "#define NM_BUILD_BUILDDIR \"$(abs_builddir)\"" >>$@ && \ + echo "#define NM_BUILD_SRCDIR \"$(abs_srcdir)\"" >>$@ && \ + echo "#define PPPD_PLUGIN_DIR \"$(PPPD_PLUGIN_DIR)\"" >>$@ && \ + echo "#define PREFIX \"$(prefix)\"" >>$@ && \ + echo "#define RUNSTATEDIR \"$(runstatedir)\"" >>$@ && \ + echo "#define SYSCONFDIR \"$(sysconfdir)\"" >>$@ && \ + true