3 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 # This program creates a program's manual from the .x skeleton and its --help
22 # Usage: x-to-1 [OPTIONS] PERL HELP2MAN EXECUTABLE PROGRAM.x PROGRAM.1
25 # PERL The file name of the perl program.
26 # HELP2MAN Either the file name of the help2man perl script, or a complete
27 # command such as "$PERL -w -- help2man".
28 # EXECUTABLE The file name of the program to invoke with --help.
29 # PROGRAM The name of the program.
30 # PROGRAM.x The .x skeleton is a file containing manual page text that is
31 # not part of the --help output. It is passed to help2man via
32 # its --include option. Its format is described in the help2man
34 # PROGRAM.1 The output file, a manual page in mandoc format.
37 # --update Don't overwrite the output if nothing would change.
43 --update) update
=yes; shift;;
49 echo "Usage: x-to-1 [OPTIONS] PERL HELP2MAN executable program.x program.1" 1>&2
58 # Accommodate both possible forms of the HELP2MAN argument.
61 *) HELP2MAN
="$PERL $HELP2MAN" ;;
64 progname
=`basename $aux .x`
65 # configure determined whether perl exists.
71 # Determine whether all the perl modules that help2man needs are installed.
72 if $HELP2MAN --help >/dev
/null
2>/dev
/null
; then
79 if test @CROSS_COMPILING@
= no
&& test -f $executable && test $perlok = yes; then
80 echo "Updating man page $output"
81 echo "$HELP2MAN --include=$aux $executable > $output"
83 $HELP2MAN --include=$aux $executable > t-
$progname.1 ||
exit 1
84 if test -n "$update"; then
85 # In --update mode, don't overwrite the output if nothing would change.
86 if cmp t-
$progname.1 $output >/dev
/null
2>&1; then
89 mv t-
$progname.1 $output
92 mv t-
$progname.1 $output
95 echo "WARNING: The man page $output cannot be updated yet."