From: Vincent Bernat Date: Sun, 5 Oct 2014 13:07:42 +0000 (+0200) Subject: build: use AC_CONFIG_FILES only to generate Makefiles X-Git-Tag: 0.7.11~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=95493844623c46e803d31302ac7758ce01580be7;p=thirdparty%2Flldpd.git build: use AC_CONFIG_FILES only to generate Makefiles Other kind of files may get partially expanded variables. For example, `@sbindir@` is expanded to `${exec_prefix}/sbin` which won't work in a regular configuration file. While this could be done easily with GNU Make, using automake doesn't allow us to use pattern rules or stuff like that. Therefore, there are a lot of repetitions to declare the files we need to transform. --- diff --git a/configure.ac b/configure.ac index 34fe40ea..bb1b6486 100644 --- a/configure.ac +++ b/configure.ac @@ -15,14 +15,14 @@ AC_INIT([lldpd], AC_CONFIG_SRCDIR([src/log.c]) AC_CONFIG_HEADER([config.h]) -AC_CONFIG_FILES([Makefile src/Makefile src/compat/Makefile src/daemon/Makefile - src/lib/Makefile src/lib/lldpctl.pc src/client/Makefile - tests/Makefile]) -AC_CONFIG_FILES([osx/Makefile osx/distribution.xml osx/im.bernat.lldpd.plist]) -AC_CONFIG_FILES([osx/scripts/preinstall], [chmod +x osx/scripts/preinstall]) -AC_CONFIG_FILES([osx/scripts/postinstall], [chmod +x osx/scripts/postinstall]) -AC_CONFIG_FILES([src/daemon/lldpd.service src/daemon/lldpd.sysusers.conf]) -AC_CONFIG_FILES([src/daemon/lldpd.8 src/client/lldpcli.8]) +AC_CONFIG_FILES([Makefile + src/Makefile + src/compat/Makefile + src/daemon/Makefile + src/lib/Makefile + src/client/Makefile + tests/Makefile + osx/Makefile]) AC_CONFIG_MACRO_DIR([m4]) AC_SUBST([CONFIGURE_ARGS], [$ac_configure_args]) diff --git a/edit.am b/edit.am new file mode 100644 index 00000000..adb51c26 --- /dev/null +++ b/edit.am @@ -0,0 +1,19 @@ +edit = $(SED) \ + -e 's|@bindir[@]|$(bindir)|g' \ + -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \ + -e 's|@libdir[@]|$(libdir)|g' \ + -e 's|@includedir[@]|$(includedir)|g' \ + -e 's|@exec_prefix[@]|$(exec_prefix)|g' \ + -e 's|@prefix[@]|$(prefix)|g' \ + -e 's|@VERSION[@]|$(VERSION)|g' \ + -e 's|@PACKAGE[@]|$(PACKAGE)|g' \ + -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ + -e 's|@PACKAGE_URL[@]|$(PACKAGE_URL)|g' \ + -e 's|@PRIVSEP_USER[@]|$(PRIVSEP_USER)|g' \ + -e 's|@PRIVSEP_GROUP[@]|$(PRIVSEP_GROUP)|g' \ + -e 's|@PRIVSEP_CHROOT[@]|$(PRIVSEP_CHROOT)|g' \ + -e 's|@LLDPD_CTL_SOCKET[@]|$(LLDPD_CTL_SOCKET)|g' + +$(TEMPLATES): Makefile + $(edit) $(srcdir)/$@.in > $@.tmp + mv $@.tmp $@ diff --git a/osx/Makefile.am b/osx/Makefile.am index 5e2b8fe7..08136946 100644 --- a/osx/Makefile.am +++ b/osx/Makefile.am @@ -61,6 +61,17 @@ if HAVE_LAUNCHDDAEMONSDIR launchddaemons_DATA = im.bernat.lldpd.plist endif +TEMPLATES = distribution.xml im.bernat.lldpd.plist scripts/postinstall scripts/preinstall +EXTRA_DIST += distribution.xml.in im.bernat.lldpd.plist.in scripts/postinstall.in scripts/preinstall.in +CLEANFILES = $(TEMPLATES) +distribution.xml: distribution.xml.in +im.bernat.lldpd.plist: im.bernat.lldpd.plist.in +scripts/postinstall: scripts/postinstall.in + chmod +x $@ +scripts/preinstall: scripts/preinstall.in + chmod +x $@ +include $(top_srcdir)/edit.am + .PHONY: pkg requirements endif diff --git a/src/client/Makefile.am b/src/client/Makefile.am index 34578797..454bdeb5 100644 --- a/src/client/Makefile.am +++ b/src/client/Makefile.am @@ -49,3 +49,9 @@ dist_zshcompletion_DATA = _lldpcli # Default configuration lldpdconfdir = $(sysconfdir)/lldpd.d dist_lldpdconf_DATA = README.conf + +TEMPLATES = lldpcli.8 +EXTRA_DIST = lldpcli.8.in +CLEANFILES = $(TEMPLATES) +lldpcli.8: lldpcli.8.in +include $(top_srcdir)/edit.am diff --git a/src/daemon/Makefile.am b/src/daemon/Makefile.am index e234f246..0883ac72 100644 --- a/src/daemon/Makefile.am +++ b/src/daemon/Makefile.am @@ -148,3 +148,11 @@ endif if HAVE_SYSUSERSDIR sysusers_DATA = lldpd.sysusers.conf endif + +TEMPLATES = lldpd.8 lldpd.service lldpd.sysusers.conf +EXTRA_DIST += lldpd.8.in lldpd.service.in lldpd.sysusers.conf.in +CLEANFILES += $(TEMPLATES) +lldpd.8: lldpd.8.in +lldpd.service: lldpd.service.in +lldpd.sysusers.conf: lldpd.sysusers.conf.in +include $(top_srcdir)/edit.am diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index f13e0f43..2d2bce94 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -15,3 +15,9 @@ liblldpctl_la_LDFLAGS = -export-symbols-regex '^lldpctl_' -version-info 7:0:3 pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = lldpctl.pc + +TEMPLATES = lldpctl.pc +EXTRA_DIST = lldpctl.pc.in +CLEANFILES = $(TEMPLATES) +lldpctl.pc: lldpctl.pc.in +include $(top_srcdir)/edit.am