*-map tests: Fix compilation error.
[gnulib.git] / build-aux / x-to-1.in
blob1b09d33db42daa9337ce9367ae4e583e8109481b
1 #! /bin/sh
3 # Copyright (C) 2001-2019 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
20 # output.
21 # The .x skeleton is a file containing manual page text that is not part of the
22 # --help output. It is passed to help2man via its --include option. Its format
23 # is described in the help2man documentation.
25 update=
26 while true; do
27 case "$1" in
28 --update) update=yes; shift;;
29 *) break;;
30 esac
31 done
33 if test $# != 5; then
34 echo "Usage: x-to-1 [OPTIONS] PERL HELP2MAN executable program.x program.1" 1>&2
35 exit 1
37 PERL="$1"
38 HELP2MAN="$2"
39 executable="$3"
40 aux="$4"
41 output="$5"
43 progname=`basename $aux .x`
44 case "$PERL" in *"/missing perl") perlok=no;; *) perlok=yes;; esac
45 if test @CROSS_COMPILING@ = no && test -f $executable && test $perlok = yes; then
46 echo "Updating man page $output"
47 echo "$PERL $HELP2MAN --include=$aux $executable > $output"
48 rm -f t-$progname.1
49 $PERL $HELP2MAN --include=$aux $executable > t-$progname.1 || exit 1
50 if test -n "$update"; then
51 # In --update mode, don't overwrite the output if nothing would change.
52 if cmp t-$progname.1 $output >/dev/null 2>&1; then
53 rm -f t-$progname.1
54 else
55 mv t-$progname.1 $output
57 else
58 mv t-$progname.1 $output
60 else
61 echo "WARNING: The man page $output cannot be updated yet."