diff options
author | Jim Meyering <meyering@fb.com> | 2022-10-16 19:50:41 -0700 |
---|---|---|
committer | Jim Meyering <meyering@fb.com> | 2022-10-16 22:13:11 -0700 |
commit | d1d7eeafe4a561c0b165085bc7bceb3220c66ac4 (patch) | |
tree | f762295ce86f2ee48a5103e034e35a3220f08be8 | |
parent | 0fe201e7f47ed9404cbf7a7a8ee142621c707e52 (diff) | |
download | sed-d1d7eeafe4a561c0b165085bc7bceb3220c66ac4.tar.gz |
build: work when perl is installed but not in /usr/bin/perl
Also support building on systems without perl and when cross-compiling.
* configure.ac (AC_ARG_ENABLE [bold-man-page-references]): New
configure-time option, using code copied from coreutils.
(BUILD_MAN_PAGE, BUILD_DUMMY_MAN_PAGE): Remove definitions.
(HAVE_PERL): Remove bogus conditional.
* doc/dummy-man: New file, from coreutils, with slight adapation.
* build-aux/help2man: Update from coreutils.
* doc/local.mk (EXTRA_DIST): Distribute dummy-man.
(run_help2man): New variable.
(doc/sed.1): Use it rather than simply invoking help2man.
Simplify to use only one copy of this rule, now that run_help2man
works both with and without perl and when cross-compiling.
Move the --name=... string argument into...
* doc/sed.x: ... here. Also make the "Synopsis" appear in generated file.
In https://lists.gnu.org/r/sed-devel/2022-10/msg00005.html,
Bruno Haible reported build failure with perl in a different
location and (in another report) another failure with no perl at all.
-rwxr-xr-x | build-aux/help2man | 38 | ||||
-rw-r--r-- | configure.ac | 38 | ||||
-rwxr-xr-x | doc/dummy-man | 73 | ||||
-rw-r--r-- | doc/local.mk | 36 | ||||
-rw-r--r-- | doc/sed.x | 6 |
5 files changed, 138 insertions, 53 deletions
diff --git a/build-aux/help2man b/build-aux/help2man index 67452e2..581f69d 100755 --- a/build-aux/help2man +++ b/build-aux/help2man @@ -1,7 +1,9 @@ #!/usr/bin/perl -w # Generate a short man page from --help and --version output. -# Copyright (C) 1997-2022 Free Software Foundation, Inc. +# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009, +# 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021 Free Software +# Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -27,7 +29,7 @@ use Text::Tabs qw(expand); use POSIX qw(strftime setlocale LC_ALL); my $this_program = 'help2man'; -my $this_version = '1.47.3'; +my $this_version = '1.48.5'; sub _ { $_[0] } sub configure_locale @@ -51,8 +53,9 @@ sub fix_italic_spacing; my $version_info = enc_user sprintf _(<<'EOT'), $this_program, $this_version; GNU %s %s -Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009, 2010, -2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc. +Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009, +2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021 Free Software +Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -75,6 +78,7 @@ Usage: %s [OPTION]... EXECUTABLE -p, --info-page=TEXT name of Texinfo manual -N, --no-info suppress pointer to Texinfo manual -l, --libtool exclude the `lt-' from the program name + -b, --bold-refs apply bold style to references --help print this help, then exit --version print version number, then exit @@ -96,7 +100,7 @@ my $help_option = '--help'; my $version_option = '--version'; my $discard_stderr = 1; my ($opt_name, @opt_include, $opt_output, $opt_info, $opt_no_info, $opt_libtool, - $version_text); + $opt_bold_refs, $version_text); my %opt_def = ( 'n|name=s' => \$opt_name, @@ -110,6 +114,7 @@ my %opt_def = ( 'p|info-page=s' => \$opt_info, 'N|no-info' => \$opt_no_info, 'l|libtool' => \$opt_libtool, + 'b|bold-refs' => \$opt_bold_refs, 'help' => sub { print $help_info; exit }, 'version' => sub { print $version_info; exit }, 'h|help-option=s' => \$help_option, @@ -247,7 +252,7 @@ my $help_text = get_option_value $ARGV[0], $help_option; $version_text ||= get_option_value $ARGV[0], $version_option; # By default the generated manual pages will include the current date. This may -# however be overriden by setting the environment variable $SOURCE_DATE_EPOCH +# however be overridden by setting the environment variable $SOURCE_DATE_EPOCH # to an integer value of the seconds since the UNIX epoch. This is primarily # intended to support reproducible builds (wiki.debian.org/ReproducibleBuilds) # and will additionally ensure that the output date string is UTC. @@ -282,21 +287,23 @@ if ($opt_output) # <version> # <program> <version> # {GNU,Free} <program> <version> -# <program> ({GNU,Free} <package>) <version> -# <program> - {GNU,Free} <package> <version> +# <program> ({GNU,Free,} <package>) <version> +# <program> - {GNU,Free,} <package> <version> +# <program> - {GNU,Free,} <package> - <version> # # and separated from any copyright/author details by a blank line. ($_, $version_text) = ((split /\n+/, $version_text, 2), ''); -if (/^(\S+) +\(((?:GNU|Free) +[^)]+)\) +(.*)/ or - /^(\S+) +- *((?:GNU|Free) +\S+) +(.*)/) +if (/^(\S+) +\(((?:(?:GNU|Free) +)?[^)]+)\) +(\S.*)$/ or + /^(\S+) +- +((?:(?:GNU|Free) +)?\S.*) +- +(\S.*)$/ or + /^(\S+) +- +((?:(?:GNU|Free) +)?\S+) +(\S.*)$/) { $program = program_basename $1; $package = $2; $version = $3; } -elsif (/^((?:GNU|Free) +)?(\S+) +(.*)/) +elsif (/^((?:GNU|Free) +)?(\S+) +(\S.*)$/) { $program = program_basename $2; $package = $1 ? "$1$program" : $program; @@ -336,7 +343,7 @@ for ($replace{_('NAME')} || ($include{_('NAME')} ||= '')) my $PROGRAM = uc $program; # Set default page head/footers -$source ||= "$program $version"; +$source ||= "$package $version"; unless ($manual) { for ($section) @@ -709,6 +716,13 @@ for my $sect (@pre, (grep !$filter{$_}, @sections), @post) for ($include{$sect}) { + # Add bold style around referenced pages. + if ($opt_bold_refs) + { + # This will ignore entries already marked up (with \) + s/(^|\s|,)([\[\w\x83]+)\(([1-9][[:lower:]]?)\)/$1\\fB$2\\fP($3)/g; + } + # Replace leading dot, apostrophe, backslash and hyphen # tokens. s/\x80/\\&./g; diff --git a/configure.ac b/configure.ac index 62aad18..1f6ff5c 100644 --- a/configure.ac +++ b/configure.ac @@ -36,11 +36,7 @@ gl_DISABLE_THREADS AC_DEFINE([GNULIB_NO_VLA], [1], [Define to 1 to disable use of VLAs]) # The test suite needs to know if we have a working perl. -# FIXME: this is suboptimal. Ideally, we would be able to call gl_PERL -# with an ACTION-IF-NOT-FOUND argument ... -cu_have_perl=yes -case $PERL in *"/missing "*) cu_have_perl=no;; esac -AM_CONDITIONAL([HAVE_PERL], [test $cu_have_perl = yes]) +AM_CONDITIONAL([HAVE_PERL], [test "$gl_cv_prog_perl" != no]) # gl_GCC_VERSION_IFELSE([major], [minor], [run-if-found], [run-if-not-found]) # ------------------------------------------------ @@ -289,29 +285,25 @@ if test "$gl_gcc_warnings" = yes; then AC_SUBST([GNULIB_TEST_WARN_CFLAGS]) fi +AC_ARG_ENABLE([bold-man-page-references], + [AS_HELP_STRING([--disable-bold-man-page-references], + [When generating man pages, do not apply bold style around any + references like name(1) etc.])], + [gl_bold_manpages=yes ; + case $enableval in + no|yes) gl_bold_manpages=$enableval ;; + *) AC_MSG_ERROR([bad value $enableval for bold-man-page-references. + Options are: yes, no.]) ;; + esac], + [gl_bold_manpages=yes] +) +AM_CONDITIONAL([BOLD_MAN_REFS], [test "$gl_bold_manpages" != no]) + AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes]) # Perl is needed for help2man AC_PATH_PROG([PERL], [perl]) -# Can the man page be built? -# Perl needed for help2man, executing sed needed for 'sed --help' -can_rebuild_man_page=no -test -n "$PERL" && \ - test "$cross_compiling" != yes && \ - can_rebuild_man_page=yes - -# Build the man page when -# building from git and rebuilding is possible. -AM_CONDITIONAL([BUILD_MAN_PAGE], - [test "$can_rebuild_man_page" = yes]) - -# Create a stub man page instead of failing when -# building from git and rebuilding is not possible. -AM_CONDITIONAL([BUILD_DUMMY_MAN_PAGE], - [test "$can_rebuild_man_page" = no]) - - # This is needed when building outside the source dir # with --disable-dependency-tracking, see https://bugs.gnu.org/25371 AS_MKDIR_P([lib]) diff --git a/doc/dummy-man b/doc/dummy-man new file mode 100755 index 0000000..25bde40 --- /dev/null +++ b/doc/dummy-man @@ -0,0 +1,73 @@ +#!/bin/sh +# 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 + +fatal_ () +{ + printf '%s: %s\n' "$0" "$*" >&2 + exit 1 +} + +basename_ () +{ + printf '%s\n' "$1" | sed 's,.*/,,' +} + +output= +source="GNU sed" +while test $# -gt 0; do + case $1 in + # 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. + --info-page=*);; + -*) fatal_ "invalid or unrecognized help2man option '$1'";; + --) shift; break;; + *) break;; + esac + shift +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 +Did not generate or find default '$baseout' man page. +Creating a stub man page instead. +END + +progname=`basename_ "$1"` +bs='\' + +cat >"$output" <<END +.TH "$progname" 1 "$source" "User Commands" +.SH NAME +$progname $bs- stream editor for filtering and transforming text +.SH DESCRIPTION +.B OOPS! +We were unable to create a proper manual page for +.B $progname. +For concise option descriptions, run +.IP +.B env $progname --help +.PP +The full documentation for +.B $progname +is maintained as a Texinfo manual, which should be accessible +on your system via the command +.IP +.B info sed invoking +END diff --git a/doc/local.mk b/doc/local.mk index 8433003..7b6f397 100644 --- a/doc/local.mk +++ b/doc/local.mk @@ -19,26 +19,32 @@ dist_man_MANS = doc/sed.1 dist_noinst_DATA = doc/sed.x doc/sed-dummy.1 HELP2MAN = $(top_srcdir)/build-aux/help2man SEDBIN = sed/sed +EXTRA_DIST += doc/dummy-man AM_MAKEINFOHTMLFLAGS = --no-split -if BUILD_MAN_PAGE +## Use the distributed man pages if cross compiling or lack perl +if CROSS_COMPILING +run_help2man = $(SHELL) $(srcdir)/doc/dummy-man +else +## Graceful degradation for systems lacking perl. +if HAVE_PERL +if BOLD_MAN_REFS +help2man_OPTS=--bold-refs +endif +run_help2man = $(PERL) -- $(HELP2MAN) $(help2man_OPTS) +else +run_help2man = $(SHELL) $(srcdir)/doc/dummy-man +endif +endif + doc/sed.1: sed/sed$(EXEEXT) .version $(srcdir)/doc/sed.x $(AM_V_GEN)$(MKDIR_P) doc $(AM_V_at)rm -rf $@ $@-t - $(AM_V_at)$(HELP2MAN) \ - --name 'stream editor for filtering and transforming text' \ - -p sed --include $(srcdir)/doc/sed.x \ - -o $@-t $(SEDBIN) \ + $(AM_V_at)$(run_help2man) \ + --info-page=sed \ + --include $(srcdir)/doc/sed.x \ + --output=$@-t \ + $(SEDBIN) \ && chmod a-w $@-t \ && mv $@-t $@ -else !BUILD_MAN_PAGE - -if BUILD_DUMMY_MAN_PAGE -doc/sed.1: doc/sed-dummy.1 - $(AM_V_at)$(SED) 's/VERSION/$(PACKAGE_VERSION)/' $< > $@-t \ - && chmod a-w $@-t \ - && mv $@-t $@ -endif BUILD_DUMMY_MAN_PAGE - -endif !BUILD_MAN_PAGE @@ -1,6 +1,6 @@ -.SH NAME -sed \- a Stream EDitor -.SH SYNOPSIS +[NAME] +sed \- stream editor for filtering and transforming text +[SYNOPSIS] .nf sed [-V] [--version] [--help] [-n] [--quiet] [--silent] [-l N] [--line-length=N] [-u] [--unbuffered] |