diff Makefile @ 4:f28486666a4f

Add manpages for relmon and relmon_watchlist
author Guido Berhoerster <guido+relmon@berhoerster.name>
date Fri, 24 Oct 2014 22:44:39 +0200
parents 6d87242c537e
children 4ecf1408f04f
line wrap: on
line diff
--- a/Makefile	Mon Oct 20 19:31:20 2014 +0200
+++ b/Makefile	Fri Oct 24 22:44:39 2014 +0200
@@ -31,32 +31,60 @@
 PAX :=		pax
 GZIP :=		gzip
 SED :=		sed
+XSLTPROC :=	xsltproc
+DOCBOOK5_MANPAGES_STYLESHEET =	http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
 TCLSH_PATH :=	/usr/bin/tclsh
 
+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
 
 SCRIPTS =	$(PACKAGE).tcl
+MANPAGES =	$(PACKAGE).1 $(PACKAGE)_watchlist.4
+DOCBOOK5_MANPAGES_FLAGS =	--stringparam man.authors.section.enabled 0 \
+				--stringparam man.copyright.section.enabled 0
 
 .DEFAULT_TARGET = all
 
 .PHONY: all clean clobber dist install
 
-all: $(PACKAGE)
+all: $(PACKAGE) $(MANPAGES)
 
 $(PACKAGE): $(SCRIPTS)
 	cp $< $@
 
+$(foreach section,1 2 3 4 5 6 7 8 9,$(eval $(call generate-manpage-rule,$(section))))
+
 %.tcl: %.tcl.in
 	$(SED) -e '1s,#!.*,#!$(TCLSH_PATH),' -e 's,@VERSION@,$(VERSION),' $< \
 	    > $@
 
 install:
 	$(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)"
+	for manpage in $(MANPAGES); do \
+	    $(INSTALL.data) $${manpage} \
+	        "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
+	done
 
 clean:
-	rm -f $(PACKAGE) $(SCRIPTS)
+	rm -f $(PACKAGE) $(SCRIPTS) $(MANPAGES)
 
 clobber: clean