Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / man4.test
1 #! /bin/sh
2 # Copyright (C) 2008, 2010 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Ensure `make dist' fails when help2man replacement man pages are created.
18 #
19 # The assumption here is the following: if the developer uses help2man to
20 # generate man pages from --help output, then these man pages may not be
21 # stored in VCS.  However, they should be distributed, so that the end user
22 # that receives the tarball doesn't have to install help2man.  If they are
23 # not distributed, then the developer should make help2man a prerequisite
24 # to building the package from a tarball, e.g., with a configure check for
25 # help2man that errors out if it is unavailable.  In both cases it is
26 # sufficient to check only distributed man pages.
27 #
28 # Idea of this whole shenanigan is to allow somebody to check out sources from
29 # a VCS and build and install them without needing help2man installed.  The
30 # installed man pages will be bogus in this case.  Typically, this happens
31 # when developers ask users to try out a fix from VCS; the developers themselves
32 # will usually have help2man installed (or should install it).
33
34 . ./defs || Exit 1
35
36 set -e
37
38 cat > Makefile.am << 'END'
39 dist_man_MANS = $(srcdir)/foo.1 bar.1
40 dist_bin_SCRIPTS = foo bar
41 $(srcdir)/foo.1:
42         $(HELP2MAN) --output=$@ $(srcdir)/foo
43 bar.1:
44         $(HELP2MAN) --output=$(srcdir)/bar.1 $(srcdir)/bar
45
46 ## It is a bug that we need to list $(srcdir)/bar.1 explicitly here.
47 MAINTAINERCLEANFILES = $(dist_man_MANS) $(srcdir)/bar.1
48 END
49
50 cat >>configure.in <<'END'
51 AM_MISSING_PROG([HELP2MAN], [help2man])
52 AC_OUTPUT
53 END
54
55 cat > foo <<'END'
56 #! /bin/sh
57 while test $# -gt 0; do
58   case $1 in
59     -h | --help) echo "usage: $0 [OPTIONS]..."; exit 0;;
60     -v | --version) echo "$0 1.0"; exit 0;;
61   esac
62   shift
63 done
64 END
65
66 cp foo bar
67
68 cat > help2man <<'END'
69 #! /bin/sh
70 # fake help2man script that lets `missing' think it is not installed
71 exit 127
72 END
73
74 chmod +x foo bar help2man
75 save_PATH=$PATH
76 PATH=`pwd`$PATH_SEPARATOR$PATH
77
78 $ACLOCAL
79 $AUTOMAKE
80 $AUTOCONF
81 ./configure
82 $MAKE
83 $MAKE dist && Exit 1
84 $MAKE distcheck && Exit 1
85 $MAKE distclean
86
87 mkdir build
88 cd build
89 ../configure
90 $MAKE
91 $MAKE dist 2>stderr && { cat stderr >&2; Exit 1; }
92 cat stderr >&2
93 grep 'install help2man' stderr
94 $MAKE distcheck 2>stderr && { cat stderr >&2; Exit 1; }
95 cat stderr >&2
96 grep 'install help2man' stderr
97
98 rm -f ../help2man
99 PATH=$save_PATH
100 export PATH
101
102 # If help2man is installed, then ensure that the recommendation works.
103 if (help2man --version) >/dev/null 2>&1; then
104   $MAKE maintainer-clean
105   ../configure
106   $MAKE
107   $MAKE distcheck
108 fi
109 :