[libXi PATCH] Be smarter about generating man pages

Dan Nicholson dbn.lists at gmail.com
Tue Dec 16 16:45:16 PST 2008


With the current rules, the man pages will be generated repeatedly if you
have xmlto installed. This is because make always thinks they are out of
date with respect to their prerequisite, do_xmlto_stage. They are changed
here to handle the multiple output files as described in the automake
manual.

distcheck has been confirmed to still work such that building from the
tarball does not require xmlto. On the other hand, if the user wants to
rebuild the man pages, they'll have to explicitly touch XI.xml.

It may be better to split the xml into per-page files so that xmlto only
generates one output at a time. A toplevel XI.xml can still pull together
all the pieces with XInclude.
---
 man/.gitignore  |    2 +
 man/Makefile.am |  143 +++++++++++++++++++++++++++++--------------------------
 2 files changed, 77 insertions(+), 68 deletions(-)

diff --git a/man/.gitignore b/man/.gitignore
index 2d0f344..727ea33 100644
--- a/man/.gitignore
+++ b/man/.gitignore
@@ -1,3 +1,5 @@
 Makefile
 Makefile.in
 *.3*
+xi.stamp
+xi.tmp
diff --git a/man/Makefile.am b/man/Makefile.am
index f0829b7..68aac3b 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -30,64 +30,60 @@ LIB_MAN_DIR_SUFFIX = $(LIB_MAN_DIR:@mandir@/man%=%)
 
 libman_xml = XI.xml
 
-if HAVE_XMLTO
-XI_manpages = \
-	      XAllowDeviceEvents \
-	      XChangeKeyboardDevice \
-	      XChangePointerDevice \
-	      XDeviceBell \
-	      XQueryDeviceState \
-	      XSendExtensionEvent \
-	      XSetDeviceMode \
-	      XSetDeviceValuators \
-	      XChangeDeviceDontPropagateList \
-	      XGetDeviceDontPropagateList \
-	      XChangeDeviceHierarchy \
-	      XDefineDeviceCursor \
-	      XUndefineDeviceCursor \
-	      XExtendedGrabDevice \
-	      XGetDeviceControl \
-	      XChangeDeviceControl \
-	      XGetDeviceKeyMapping \
-	      XChangeDeviceKeyMapping \
-	      XGetDeviceModifierMapping \
-	      XSetDeviceModifierMapping \
-	      XGetDeviceMotionEvents \
-	      XDeviceTimeCoord \
-	      XGetFeedbackControl \
-	      XChangeFeedbackControl \
-	      XGrabDeviceButton \
-	      XUngrabDeviceButton \
-	      XGrabDeviceKey \
-	      XUngrabDeviceKey \
-	      XGrabDevice \
-	      XUngrabDevice \
-	      XiSelectEvent \
-	      XListInputDevices \
-	      XFreeDeviceList \
-	      XOpenDevice \
-	      XCloseDevice \
-	      XQueryDevicePointer \
-	      XQueryInputVersion \
-	      XGetExtensionVersion \
-	      XSelectExtensionEvent \
-	      XGetSelectedExtensionEvents \
-	      XSetClientPointer \
-	      XGetClientPointer \
-	      XSetDeviceButtonMapping \
-	      XGetDeviceButtonMapping \
-	      XSetDeviceFocus \
-	      XGetDeviceFocus \
-	      XWarpDevicePointer \
-	      XListDeviceProperties \
-	      XGetDeviceProperty \
-	      XChangeDeviceProperty \
-	      XDeleteDeviceProperty
-endif # HAVE_XMLTO
-
-libman_PRE = $(XI_manpages:%=%.man)
-
-EXTRA_DIST = $(libman_PRE) $(libman_xml)
+libman_PRE = \
+	      XAllowDeviceEvents.man \
+	      XChangeKeyboardDevice.man \
+	      XChangePointerDevice.man \
+	      XDeviceBell.man \
+	      XQueryDeviceState.man \
+	      XSendExtensionEvent.man \
+	      XSetDeviceMode.man \
+	      XSetDeviceValuators.man \
+	      XChangeDeviceDontPropagateList.man \
+	      XGetDeviceDontPropagateList.man \
+	      XChangeDeviceHierarchy.man \
+	      XDefineDeviceCursor.man \
+	      XUndefineDeviceCursor.man \
+	      XExtendedGrabDevice.man \
+	      XGetDeviceControl.man \
+	      XChangeDeviceControl.man \
+	      XGetDeviceKeyMapping.man \
+	      XChangeDeviceKeyMapping.man \
+	      XGetDeviceModifierMapping.man \
+	      XSetDeviceModifierMapping.man \
+	      XGetDeviceMotionEvents.man \
+	      XDeviceTimeCoord.man \
+	      XGetFeedbackControl.man \
+	      XChangeFeedbackControl.man \
+	      XGrabDeviceButton.man \
+	      XUngrabDeviceButton.man \
+	      XGrabDeviceKey.man \
+	      XUngrabDeviceKey.man \
+	      XGrabDevice.man \
+	      XUngrabDevice.man \
+	      XiSelectEvent.man \
+	      XListInputDevices.man \
+	      XFreeDeviceList.man \
+	      XOpenDevice.man \
+	      XCloseDevice.man \
+	      XQueryDevicePointer.man \
+	      XQueryInputVersion.man \
+	      XGetExtensionVersion.man \
+	      XSelectExtensionEvent.man \
+	      XGetSelectedExtensionEvents.man \
+	      XSetClientPointer.man \
+	      XGetClientPointer.man \
+	      XSetDeviceButtonMapping.man \
+	      XGetDeviceButtonMapping.man \
+	      XSetDeviceFocus.man \
+	      XGetDeviceFocus.man \
+	      XWarpDevicePointer.man \
+	      XListDeviceProperties.man \
+	      XGetDeviceProperty.man \
+	      XChangeDeviceProperty.man \
+	      XDeleteDeviceProperty.man
+
+EXTRA_DIST = $(libman_PRE) $(libman_xml) xi.stamp
 
 CLEANFILES = $(libman_DATA) $(BUILT_SOURCES)
 
@@ -114,14 +110,25 @@ SUFFIXES = .$(LIB_MAN_SUFFIX) .man
 .man.$(LIB_MAN_SUFFIX):
 	sed $(MAN_SUBSTS) < $< > $@
 
-dist-hook: $(libman_PRE)
-
-.PHONY: do_xmlto_stage
-
-$(libman_PRE): do_xmlto_stage
-
-do_xmlto_stage: $(libman_xml)
-	$(XMLTO) man $?
-	for m in $(XI_manpages); do \
-	  mv -f $$m.__libmansuffix__ $$m.man ; \
+# This is ugly, but handling of tools with multiple outputs in make is a
+# huge PITA. The commands below are taken from the automake manual:
+# http://www.gnu.org/software/automake/manual/automake.html#Multiple-Outputs
+if HAVE_XMLTO
+xi.stamp: $(libman_xml)
+	@rm -f xi.tmp
+	@touch xi.tmp
+	$(XMLTO) man $^
+	@for man in $(libman_PRE); do \
+	  out=`echo $$man | sed 's/\.man/.__libmansuffix__/'`; \
+	  echo mv -f $$out $$man; \
+	  mv -f $$out $$man || exit 1; \
 	done
+	@mv -f xi.tmp $@
+$(libman_PRE): xi.stamp
+	@if test -f $@; then :; else \
+	  rm -f $<; \
+	  $(MAKE) $(AM_MAKEFLAGS) $<; \
+	fi
+CLEANFILES += xi.tmp
+MAINTAINERCLEANFILES += xi.stamp
+endif # HAVE_XMLTO
-- 
1.5.6.5




More information about the xorg mailing list