diff Makefile @ 1:f0ceb0ad20e7 version-1

Add manpage
author Guido Berhoerster <guido+sencrypt@berhoerster.name>
date Thu, 30 Jan 2014 00:00:13 +0100
parents 73af139d1a94
children 112d55c825b4
line wrap: on
line diff
--- a/Makefile	Tue Jan 28 19:23:16 2014 +0100
+++ b/Makefile	Thu Jan 30 00:00:13 2014 +0100
@@ -41,15 +41,36 @@
 PAX :=		pax
 GZIP :=		gzip
 SED :=		sed
+XSLTPROC :=	xsltproc
+DOCBOOK5_MANPAGES_STYLESHEET =	http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
+
+define generate-manpage-rule =
+%.$(1): %.$(1).xml
+	$$(XSLTPROC) \
+	    --xinclude \
+	    --stringparam package $$(PACKAGE) \
+	    --stringparam version $$(VERSION)\
+	    docbook-update-source-data.xsl $$< | \
+	    $$(XSLTPROC) \
+	    --xinclude \
+	    $$(DOCBOOK5_MANPAGES_FLAGS) \
+	    --output $$@ \
+	    $$(DOCBOOK5_MANPAGES_STYLESHEET) \
+	    -
+endef
 
 DESTDIR ?=
 prefix ?=	/usr/local
 bindir ?=	$(prefix)/bin
 datadir ?=	$(prefix)/share
+mandir ?=	$(datadir)/man
 
 HAVE_ERR_H ?=	1
 
 OBJS =		sencrypt.o
+MANPAGES =	$(PACKAGE).1 $(DECRYPT_ALIAS).1
+DOCBOOK5_MANPAGES_FLAGS =	--stringparam man.authors.section.enabled 0 \
+				--stringparam man.copyright.section.enabled 0
 
 ifeq ($(HAVE_ERR_H),0)
   OBJS +=	err.o
@@ -59,7 +80,7 @@
 
 .PHONY: all clean clobber dist install
 
-all: $(PACKAGE)
+all: $(PACKAGE) $(MANPAGES)
 
 $(PACKAGE): XCPPFLAGS :=	-DOPENSSL_LOAD_CONF
 ifeq ($(HAVE_ERR_H),1)
@@ -71,6 +92,8 @@
 $(PACKAGE): $(OBJS)
 	$(LINK.o) $^ $(LDLIBS) -o $@
 
+$(foreach section,1 2 3 4 5 6 7 8 9,$(eval $(call generate-manpage-rule,$(section))))
+
 %.o: %.c
 	$(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
 	$(COMPILE.c) -o $@ $<
@@ -78,9 +101,13 @@
 install:
 	$(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##*/}"; \
+	done
 
 clean:
-	rm -f $(PACKAGE) $(OBJS)
+	rm -f $(PACKAGE) $(OBJS) $(MANPAGES)
 
 clobber: clean
 	rm -f $(patsubst %.o,%.d,$(OBJS))