test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / libobj-basic.sh
1 #! /bin/sh
2 # Copyright (C) 2010-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 # Make sure AC_LIBSOURCE and AC_LIBSOURCES work.
18
19 required=cc
20 . test-init.sh
21
22 mv configure.ac configure.proto
23 cat >> configure.proto << 'END'
24 AC_PROG_CC
25 AM_PROG_AR
26 AC_PROG_RANLIB
27 AC_OUTPUT
28 END
29
30 cat > Makefile.am << 'END'
31 noinst_LIBRARIES = libtu.a
32 libtu_a_SOURCES = foo.c
33 libtu_a_LIBADD = $(LIBOBJS)
34
35 include extra-checks.am
36 .PHONY: $(extra_checks) pre-test
37
38 pre-test: distdir
39         ls -l $(srcdir) $(builddir) $(distdir)
40         $(AR) tv libtu.a
41 $(extra_checks): pre-test
42 check-local: $(extra_checks)
43
44 maude-src:
45         grep dummy_maude $(srcdir)/maude.c
46 maude-dist:
47         grep dummy_maude $(distdir)/maude.c
48 liver-src:
49         grep dummy_liver $(srcdir)/liver.c
50 liver-dist:
51         grep dummy_liver $(distdir)/liver.c
52 liver-not-dist:
53         test -d $(distdir)
54         test ! -r $(distdir)/liver.c
55 maude-not-dist:
56         test -d $(distdir)
57         test ! -r $(distdir)/maude.c
58 END
59
60 cat > foo.c << 'END'
61 extern int dummy_foo;
62 END
63
64 cat > maude.c << 'END'
65 extern int dummy_maude;
66 END
67
68 cat > liver.c << 'END'
69 extern int dummy_liver;
70 END
71
72 # AC_LIBSOURCE should work also if called after AC_OUTPUT.
73 cat configure.proto - > configure.ac <<END
74 AC_LIBSOURCE([maude.c])
75 END
76
77 cat > extra-checks.am << 'END'
78 extra_checks = maude-src maude-dist liver-not-dist
79 END
80
81 cp "$am_scriptdir/ar-lib" . || fatal_ "fetching auxiliary script 'ar-lib'"
82
83 $ACLOCAL
84 $AUTOCONF
85 $AUTOMAKE
86 ./configure
87
88 $MAKE check
89 $MAKE distcheck
90
91 $MAKE distclean
92 # Avoid timestamp-related differences.
93 rm -rf autom4te*.cache
94
95 cat > extra-checks.am << 'END'
96 extra_checks = maude-src maude-dist liver-src liver-dist
97 END
98
99 # AC_LIBSOURCES should work also if called after AC_OUTPUT.
100 cat configure.proto - > configure.ac <<END
101 AC_LIBSOURCES([maude.c, liver.c])
102 END
103
104 $ACLOCAL
105 $AUTOCONF
106 $AUTOMAKE
107 ./configure
108
109 $MAKE check
110 $MAKE distcheck
111
112 :