From 434c34a564600cc6408aec6c21d0a99728c562c0 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Tue, 25 Aug 2009 11:47:24 +0200
Subject: [PATCH] Simplify manpage building

This eliminates one temporary directory in the process.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 Makefile.am               | 12 ++----------
 autotools/docbook-wrapper |  7 ++++---
 2 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index aa7f25483..fd4456029 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -287,19 +287,11 @@ doc/%.png: doc/%.dot
 
 man/%.7.in man/%.8.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
 	@test -n "$(DOCBOOK2MAN)" || { echo 'docbook2man' not found during configure; exit 1; }
-	TMPDIR=`mktemp -d` && { \
-	$(DOCBOOK_WRAPPER) "$(DOCBOOK2MAN)" $< $$TMPDIR/$(patsubst man/%.in,%,$@) ; \
-	mv $$TMPDIR/$(patsubst man/%.in,%,$@) $@ ; \
-	rm -rf "$$TMPDIR" ; \
-	}
+	$(DOCBOOK_WRAPPER) "$(DOCBOOK2MAN)" $< $(notdir $(@:.in=)) $@
 
 man/%.html.in: man/%.sgml man/footer.sgml $(DOCBOOK_WRAPPER)
 	@test -n "$(DOCBOOK2HTML)" || { echo 'docbook2html' not found during configure; exit 1; }
-	TMPDIR=`mktemp -d` && { \
-	$(DOCBOOK_WRAPPER) "$(DOCBOOK2HTML) --nochunks" $< $$TMPDIR/$(patsubst man/%.in,%,$@) ; \
-	mv $$TMPDIR/$(patsubst man/%.in,%,$@) $@ ; \
-	rm -rf "$$TMPDIR" ; \
-	}
+	$(DOCBOOK_WRAPPER) "$(DOCBOOK2HTML) --nochunks" $< $(notdir $(@:.in=)) $@
 
 man/%.7: man/%.7.in stamp-directories $(REPLACE_VARS_SED)
 	sed -f $(REPLACE_VARS_SED) < $< > $@
diff --git a/autotools/docbook-wrapper b/autotools/docbook-wrapper
index f525f16a1..681d9c1d1 100755
--- a/autotools/docbook-wrapper
+++ b/autotools/docbook-wrapper
@@ -2,7 +2,7 @@
 
 set -e
 
-if test "$#" != 3
+if test "$#" != 4
 then
   echo "Wrong number of arguments." >&2
   exit 1
@@ -10,7 +10,8 @@ fi
 
 cmd="${1}"
 input="${2}"
-output="${3}"
+cmdoutputfile="${3}"
+output="${4}"
 
 # docbook2man inserts a date formatted using the current locale into its
 # output. Using the "C" locale makes sure it's always in the default format.
@@ -26,7 +27,7 @@ then
   exit 1
 fi
 
-mv "${tmpdir}/`basename "${output}"`" "${output}"
+mv "${tmpdir}/${cmdoutputfile}" "${output}"
 
 # Needed for make to recognize output file
 touch "${output}"
-- 
GitLab