]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
build: use AC_CONFIG_FILES only to generate Makefiles
authorVincent Bernat <vincent@bernat.im>
Sun, 5 Oct 2014 13:07:42 +0000 (15:07 +0200)
committerVincent Bernat <vincent@bernat.im>
Sun, 5 Oct 2014 13:07:42 +0000 (15:07 +0200)
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.

configure.ac
edit.am [new file with mode: 0644]
osx/Makefile.am
src/client/Makefile.am
src/daemon/Makefile.am
src/lib/Makefile.am

index 34fe40eab0f647010bafe649de629d004533edfc..bb1b64868a777a8d9ee590e8de2b712d994383cb 100644 (file)
@@ -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 (file)
index 0000000..adb51c2
--- /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 $@
index 5e2b8fe7333366a0eeb372e821be4c620edc1a4f..081369465022e3423516b4e6f2166dc608d058eb 100644 (file)
@@ -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
index 34578797feced3e53e9f7c5fec2ebb152e7132a4..454bdeb5208d8faecdcce0ad634883dba7de9f22 100644 (file)
@@ -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
index e234f246fe360f7c49c62599a01bf89d23ba66d2..0883ac72569c365137e82524b097adcc37cff353 100644 (file)
@@ -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
index f13e0f43f90c719d3445bab3edca55b626db8bd5..2d2bce941d9a0cd233096d3503574bc95908c08e 100644 (file)
@@ -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