am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / txinfo-no-clutter.sh
1 #! /bin/sh
2 # Copyright (C) 2012-2013 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 # The info, html, pdf, ps and dvi targets shouldn't let clutter in the
18 # build directory.  Related to automake bug#11146.
19
20 required='makeinfo tex texi2dvi dvips'
21 . test-init.sh
22
23 cat >> configure.ac <<'END'
24 AC_CONFIG_FILES([sub/Makefile])
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am << 'END'
29 all-local: ps pdf dvi html # For "make distcheck".
30 info_TEXINFOS = foo.texi doc/bar.texi baz.texi
31 SUBDIRS = sub
32 END
33
34 mkdir sub doc
35
36 cat > sub/Makefile.am << 'END'
37 all-local: ps pdf dvi html # For "make distcheck".
38 info_TEXINFOS = baz.texi
39 END
40
41 cat > foo.texi << 'END'
42 \input texinfo
43 @setfilename foo.info
44 @settitle foo
45 @node Top
46 Hello walls.
47 @include version.texi
48 @bye
49 END
50
51 cat > doc/bar.texi << 'END'
52 \input texinfo
53 @setfilename bar.info
54 @settitle bar
55 @node Top
56 Hello walls.
57 @include version2.texi
58 @bye
59 END
60
61 cat > baz.texi << 'END'
62 \input texinfo
63 @setfilename baz.info
64 @settitle baz
65 @defindex au
66 @defindex sa
67 @defindex sb
68 @synindex sa sb
69 @node Top
70 Hello walls.
71 @cindex foo
72 foo
73 @pindex bar
74 bar
75 @auindex baz
76 baz
77 @saindex sa
78 sa
79 @sbindex sb
80 sb
81 @bye
82 END
83
84 cp baz.texi sub
85
86 $ACLOCAL
87 $AUTOMAKE --add-missing
88 $AUTOCONF
89
90 ./configure
91
92 # Try one by one, to ensure later targets don't involuntarily
93 # clean up potential cruft left by earlier ones.
94 for fmt in info pdf ps dvi html all; do
95   $MAKE $fmt
96   # For debugging.
97   ls -l . doc sub
98   # Sanity check.
99   case $fmt in
100     html)
101       test -e foo.html
102       test -e doc/bar.html
103       test -e baz.html
104       test -e sub/baz.html
105       ;;
106     all)
107       for x in info pdf ps dvi; do
108         test -f foo.$x
109         test -f doc/bar.$x
110         test -f baz.$x
111         test -f sub/baz.$x
112       done
113       test -e foo.html
114       test -e doc/bar.html
115       test -e baz.html
116       test -e sub/baz.html
117       ;;
118     *)
119       test -f foo.$fmt
120       test -f doc/bar.$fmt
121       test -f baz.$fmt
122       test -f sub/baz.$fmt
123       ;;
124   esac
125   # Real test.
126   ls -d foo* baz* sub/baz* doc/bar* > lst
127   basename_rx='(foo|doc/bar|baz|sub/baz)'
128   case $fmt in
129     pdf) extension_rx="(texi|pdf|t2p)";;
130     dvi) extension_rx="(texi|dvi|t2d)";;
131      ps) extension_rx="(texi|ps|dvi|t2d)";;
132    info) extension_rx="(texi|info)";;
133    html) extension_rx="(texi|html)";;
134     all) extension_rx="(texi|html|info|pdf|ps|dvi|t2[pd])";;
135       *) fatal_ "unreachable code reached";;
136   esac
137   $EGREP -v "^$basename_rx\.$extension_rx$" lst && exit 1
138   # Cleanup for checks on the next format.
139   case $fmt in
140     info) rm -f *.info doc/*.info sub/*.info;;
141        *) $MAKE clean;;
142   esac
143 done
144
145 $MAKE distcheck
146
147 :