Merge branch 'maint'
[platform/upstream/automake.git] / t / vtexi4.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2012 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 # Check that the version.texi file is automatically created and distributed
18 # if @included into a texi source.  Also check that is correctly defined
19 # @values definitions it is advertised to.
20 # See also the related test 'vtexi3.test', which does similar checks, but
21 # for more vers*.texi files, and does not require makeinfo, tex and
22 # texi2dvi.
23
24 required='makeinfo tex texi2dvi'
25 . ./defs || Exit 1
26
27 test $(LC_ALL=C date '+%u') -gt 0 && test $(LC_ALL=C date '+%u') -lt 8 \
28   && day=$(LC_ALL=C date '+%d')   && test -n "$day" \
29   && month=$(LC_ALL=C date '+%B') && test -n "$month" \
30   && year=$(LC_ALL=C date '+%Y')  && test -n "$year" \
31   || skip_ "'date' is not POSIX-compliant enough"
32 day=$(echo "$day" | sed 's/^0//')
33
34 (echo '\ex\a' | grep x) \
35   || skip_ "grep doesn't work on input that is not pure text"
36
37 cat > configure.ac << END
38 AC_INIT([$me], [123.456])
39 AM_INIT_AUTOMAKE
40 AC_CONFIG_FILES([Makefile])
41 AC_OUTPUT
42 END
43
44 cat > defs.am <<END
45 my_date_rx = $day $month $year
46 my_month_rx = $month $year
47 my_version_rx = 123\.456
48 END
49
50 cat > Makefile.am << 'END'
51 include defs.am
52 info_TEXINFOS = foo.texi
53 test-grepinfo:
54 ## Not useless uses of cat: we only tested that grep worked on
55 ## non-text input when that's given from a pipe.
56         cat $(srcdir)/foo.info | grep 'GREPVERSION=$(my_version_rx)='
57         cat $(srcdir)/foo.info | grep 'GREPEDITION=$(my_version_rx)='
58         cat $(srcdir)/foo.info | grep 'GREPDATE=$(my_date_rx)='
59         cat $(srcdir)/foo.info | grep 'GREPMONTH=$(my_month_rx)='
60 test-distfiles:
61         @echo DISTFILES = $(DISTFILES)
62         echo ' ' $(DISTFILES) ' ' | grep '[ /]version.texi '
63 test-distdir: distdir
64         ls -l $(distdir)
65         diff $(srcdir)/version.texi $(distdir)/version.texi
66 .PHONY: test-grepinfo test-distfiles test-distdir
67 check-local: test-grepinfo test-distfiles test-distdir
68 END
69
70 cat > foo.texi << 'END'
71 \input texinfo
72 @c %**start of header
73 @setfilename foo.info
74 @settitle Zardoz
75 @c %**end of header
76
77 @node Top
78 @include version.texi
79
80 GREPVERSION=@value{VERSION}=
81
82 GREPEDITION=@value{EDITION}=
83
84 GREPDATE=@value{UPDATED}=
85
86 GREPMONTH=@value{UPDATED-MONTH}=
87
88 @bye
89 END
90
91 $ACLOCAL
92 $AUTOCONF
93 $AUTOMAKE -a
94
95 ./configure
96 $MAKE all dvi
97
98 # Debugging & sanity checks.
99 ls -l
100 cat version.texi
101 cat foo.info
102 test -f foo.dvi
103
104 $MAKE test-grepinfo
105 $MAKE test-distfiles
106 $MAKE test-distdir
107 $MAKE distcheck
108
109 :