On 23/09/17 20:18, Peter Bohning wrote:
> Cross compiling for aarch64 from amd64
>  
> Is there no way to disable the man pages in configure options?  Thanks.
>  
> https://lists.gnu.org/archive/html/coreutils/2014-11/msg00000.html

I've seen this issue in various places now (CC'd).

We should probably reinstate distribution of man pages
since these generated pages are so similar on various systems.
Also given the amount of old ChangeLogs removed recently
I don't think the addition of 273K (uncompressed) is prohibitive.

The attached was tested in these modes:
 git repo build
 tarball build with/without help2man
 tarball vpath build with/without help2man
 make distcheck
 make install  (and ensure only enabled program man pages installed)

I've not applied this yet, but hope to soon after a bit more testing.

cheers,
Pádraig
From d05e91c7b6c84b22cab3f30abdf3490b7c83910b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Sat, 30 Sep 2017 17:08:02 -0700
Subject: [PATCH] build: reinstate distribution of man pages

man pages change little between systems,
so falling back to distributed pages make sense
when cross compiling or lacking perl.

* man/local.mk: Add all man pages to EXTRA_DIST
so that they're distributed in the generated tarball.
Use the dummy-man page generator if cross compiling.
Set TZ to avoid a distcheck failure where man pages
used a diffent month than those rebuilt (with a .timestamp).
* man/dummy-man: Only fall back to generating a stub
if copying an existing man page fails.
* NEWS: Mention the build-related change.
---
 NEWS          |  5 +++++
 man/dummy-man | 23 ++++++++++++-----------
 man/local.mk  | 16 +++++++++++-----
 3 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/NEWS b/NEWS
index 5d57c72..2878b70 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,11 @@ GNU coreutils NEWS                                    -*- outline -*-
   to attempt to hide the original length of the file name.
   [bug introduced in coreutils-8.28]
 
+** Build-related
+
+  Default man pages are now distributed which are used if perl is
+  not available on the build system, or when cross compiling.
+
 
 * Noteworthy changes in release 8.28 (2017-09-01) [stable]
 
diff --git a/man/dummy-man b/man/dummy-man
index f05ce2a..e298295 100755
--- a/man/dummy-man
+++ b/man/dummy-man
@@ -1,8 +1,7 @@
 #!/bin/sh
-# Poor man's placeholder for help2man invocation on systems lacking perl;
-# it generates a dummy man page stating that a proper one could not be
-# generated, and redirecting the user back to either the info
-# documentation or the '--help' output.
+# Poor man's placeholder for help2man invocation on systems lacking perl,
+# or when cross compiling.
+# It just copies the distributed man pages.
 
 set -e; set -u
 
@@ -24,12 +23,12 @@ while test $# -gt 0; do
     # Help2man options we recognize and handle.
     --output=*) output=`expr x"$1" : x'--output=\(.*\)'`;;
     --output) shift; output=$1;;
+    --include=*) include=`expr x"$1" : x'--include=\(.*\)'`;;
+    --include) shift; include=$1;;
     --source=*) source=`expr x"$1" : x'--source=\(.*\)'`;;
     --source) shift; source=$1;;
     # Recognize (as no-op) other help2man options that might be used
     # in the makefile.
-    --include=*);;
-    --include) shift;;
     --info-page=*);;
     -*) fatal_ "invalid or unrecognized help2man option '$1'";;
     --) shift; break;;
@@ -41,10 +40,13 @@ done
 test $# -gt 0 || fatal_ "missing argument"
 test $# -le 1 || fatal_ "too many non-option arguments"
 
+dist_man=$(printf '%s\n' "$include" | sed 's/\.x$/.1/')
+test -f "$dist_man" && cp "$dist_man" "$output" && exit || :
+
 baseout=`basename_ "$output"`
 sed 's/^/WARNING: /' >&2 <<END
-Cannot create proper '$baseout' man page, since perl is missing or
-inadequate on this system.  Creating a stub man page instead.
+Did not generate or find default '$baseout' man page.
+Creating a stub man page instead.
 END
 
 progname=`basename_ "$1"`
@@ -55,9 +57,8 @@ cat >"$output" <<END
 .SH NAME
 $progname $bs- a $source program
 .SH DESCRIPTION
-.B OOOPS!
-Due to the lack of perl on the build system, we were
-unable to create a proper manual page for
+.B OOPS!
+We were unable to create a proper manual page for
 .B $progname.
 For concise option descriptions, run
 .IP
diff --git a/man/local.mk b/man/local.mk
index b8a1b23..623ade1 100644
--- a/man/local.mk
+++ b/man/local.mk
@@ -18,22 +18,27 @@
 
 EXTRA_DIST += man/help2man man/dummy-man
 
+## Use the distributed man pages if cross compiling or lack perl
+if CROSS_COMPILING
+run_help2man = $(SHELL) $(srcdir)/man/dummy-man
+else
 ## Graceful degradation for systems lacking perl.
 if HAVE_PERL
 run_help2man = $(PERL) -- $(srcdir)/man/help2man
 else
 run_help2man = $(SHELL) $(srcdir)/man/dummy-man
 endif
+endif
 
 man1_MANS = @man1_MANS@
-EXTRA_DIST += $(man1_MANS:.1=.x)
+EXTRA_DIST += $(man1_MANS) $(man1_MANS:.1=.x)
 
 EXTRA_MANS = @EXTRA_MANS@
-EXTRA_DIST += $(EXTRA_MANS:.1=.x)
+EXTRA_DIST += $(EXTRA_MANS) $(EXTRA_MANS:.1=.x)
 
 ALL_MANS = $(man1_MANS) $(EXTRA_MANS)
 
-CLEANFILES += $(ALL_MANS)
+MAINTAINERCLEANFILES += $(ALL_MANS)
 
 # This is a kludge to remove generated 'man/*.1' from a non-srcdir build.
 # Without this, "make distcheck" might fail.
@@ -179,13 +184,14 @@ endif
 ## Note the use of $$t/$*, rather than just '$*' as in other packages.
 ## That is necessary to avoid failures for programs that are also shell
 ## built-in functions like echo, false, printf, pwd.
-	rm -f $@ $@-t							\
+	rm -f $@-t							\
 	  && t=$*.td							\
 	  && rm -rf $$t							\
 	  && $(MKDIR_P) $$t						\
 	  && (cd $$t && $(LN_S) '$(abs_top_builddir)/src/'$$prog$(EXEEXT) \
 				$$argv$(EXEEXT))			\
 	&& : $${SOURCE_DATE_EPOCH=`cat $(srcdir)/.timestamp 2>/dev/null || :`} \
+	&& : $${TZ=UTC} && export TZ					\
 	&& export SOURCE_DATE_EPOCH && $(run_help2man)			\
 		     --source='$(PACKAGE_STRING)'			\
 		     --include=$(srcdir)/man/$$name.x			\
@@ -198,4 +204,4 @@ endif
 	       $$t/$$name.1 > $@-t			\
 	  && rm -rf $$t							\
 	  && chmod a-w $@-t						\
-	  && mv $@-t $@
+	  && rm -f $@ && mv $@-t $@
-- 
2.9.3

Reply via email to