changeset 13:5a992d873084

Use a symlink for the manpage alias instead of a soelim stub
author Guido Berhoerster <guido+sencrypt@berhoerster.name>
date Tue, 13 Sep 2016 19:50:38 +0200
parents 14e58decdf87
children a779ed022a87
files Makefile
diffstat 1 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Sep 13 18:37:25 2016 +0200
+++ b/Makefile	Tue Sep 13 19:50:38 2016 +0200
@@ -37,28 +37,35 @@
 #MAKEDEPEND.c =	makedepend -f- -Y -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) --
 LINK.c =	$(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH)
 LINK.o =	$(CC) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH)
+CP :=		cp
 INSTALL :=	install
 INSTALL.exec :=	$(INSTALL) -D -m 0755
 INSTALL.data :=	$(INSTALL) -D -m 0644
+INSTALL.link :=	$(CP) -f -P
 PAX :=		pax
 GZIP :=		gzip
 SED :=		sed
 XSLTPROC :=	xsltproc
 DOCBOOK5_MANPAGES_STYLESHEET =	http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
+DOCBOOK5_MANPAGES_FLAGS =	--stringparam man.authors.section.enabled 0 \
+				--stringparam man.copyright.section.enabled 0
 
 define generate-manpage-rule =
-%.$(1): %.$(1).xml
+$(addsuffix .%,$(basename $1)): $(addsuffix .%.xml,$(basename $(firstword $1))) docbook-update-source-data.xsl
 	$$(XSLTPROC) \
 	    --xinclude \
 	    --stringparam package $$(PACKAGE) \
-	    --stringparam version $$(VERSION)\
+	    --stringparam version $$(VERSION) \
 	    docbook-update-source-data.xsl $$< | \
 	    $$(XSLTPROC) \
 	    --xinclude \
+	    --output $(firstword $1) \
 	    $$(DOCBOOK5_MANPAGES_FLAGS) \
-	    --output $$@ \
 	    $$(DOCBOOK5_MANPAGES_STYLESHEET) \
 	    -
+	for alias in $(wordlist 2,$(words $1),$1); do \
+	    ln -sf $(notdir $(firstword $1)) $$$$alias; \
+	done
 endef
 
 DESTDIR ?=
@@ -81,9 +88,8 @@
 endif
 
 OBJS =		sencrypt.o
+
 MANPAGES =	$(PACKAGE).1 $(DECRYPT_ALIAS).1
-DOCBOOK5_MANPAGES_FLAGS =	--stringparam man.authors.section.enabled 0 \
-				--stringparam man.copyright.section.enabled 0
 
 .DEFAULT_TARGET = all
 
@@ -103,7 +109,7 @@
 $(PACKAGE): $(OBJS)
 	$(LINK.o) $^ $(LDLIBS) -o $@
 
-$(foreach section,1 2 3 4 5 6 7 8 9,$(eval $(call generate-manpage-rule,$(section))))
+$(eval $(call generate-manpage-rule,$(MANPAGES)))
 
 %.o: %.c
 	$(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
@@ -113,8 +119,13 @@
 	$(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)"
 	ln -f $(PACKAGE) "$(DESTDIR)$(bindir)/$(DECRYPT_ALIAS)"
 	for manpage in $(MANPAGES); do \
-	    $(INSTALL.data) $${manpage} \
-	        "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
+	    if [ -L $${manpage} ]; then \
+	        $(INSTALL.link) $${manpage} \
+	            "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
+	    else \
+	        $(INSTALL.data) $${manpage} \
+	            "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
+	    fi \
 	done
 
 clean: