diff Makefile @ 5:f0c7f45022c0

Add manpage
author Guido Berhoerster <guido+xwrited@berhoerster.name>
date Sun, 27 Apr 2014 23:12:06 +0200
parents 6e2d746b06ae
children 129f316b99aa
line wrap: on
line diff
--- a/Makefile	Sun Apr 27 23:12:06 2014 +0200
+++ b/Makefile	Sun Apr 27 23:12:06 2014 +0200
@@ -42,11 +42,29 @@
 MSGFMT :=	msgfmt
 INTLTOOL_UPDATE := intltool-update
 INTLTOOL_MERGE := intltool-merge
+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)\
+	    data/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
 localedir ?=	$(datadir)/locale
 sysconfdir ?=	/etc
 xdgautostartdir ?= $(sysconfdir)/xdg/autostart
@@ -82,7 +100,8 @@
 endif
 
 OBJS =		main.o xwrited-debug.o xwrited-unique.o $(OBJS_UTMP)
-AUTOSTART_FILE = $(PACKAGE).desktop
+MANPAGES =	data/$(PACKAGE).1
+AUTOSTART_FILE = data/$(PACKAGE).desktop
 MOFILES :=	$(patsubst %.po,%.mo,$(wildcard po/*.po))
 POTFILE =	po/$(PACKAGE).pot
 POSRCS :=	$(shell $(SED) -e 's/\#.*//' -e '/^[ \t]*$$/d' \
@@ -97,12 +116,14 @@
 		-DG_LOG_DOMAIN=\"$(PACKAGE)\"
 LDLIBS :=	$(EXTRA_LIBS) \
 		$(shell pkg-config --libs $(PKGCONFIG_LIBS))
+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) $(MOFILES) $(AUTOSTART_FILE)
+all: $(PACKAGE) $(MANPAGES) $(MOFILES) $(AUTOSTART_FILE)
 
 $(PACKAGE): $(OBJS)
 	$(LINK.o) $^ $(LDLIBS) -o $@
@@ -122,6 +143,8 @@
 	$(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
 	$(COMPILE.c) -o $@ $<
 
+$(foreach section,1 2 3 4 5 6 7 8 9,$(eval $(call generate-manpage-rule,$(section))))
+
 %.desktop: %.desktop.in $(MOFILES)
 	$(INTLTOOL_MERGE) --desktop-style --utf8 po $< $@
 
@@ -136,9 +159,11 @@
 	done
 	$(INSTALL.data) $(AUTOSTART_FILE) \
 	        "$(DESTDIR)$(xdgautostartdir)/$(notdir $(AUTOSTART_FILE))"
+	$(INSTALL.data) data/$(PACKAGE).1 \
+	        "$(DESTDIR)$(mandir)/man1/$(PACKAGE).1"
 
 clean:
-	rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(AUTOSTART_FILE)
+	rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(MANPAGES) $(AUTOSTART_FILE)
 
 clobber: clean
 	rm -f $(patsubst %.o,%.d,$(OBJS))