tests: never source test-defs.sh directly, source test-lib.sh instead
[automake.git] / t / canon7.sh
blob8ffeffbf85db1e70b6249d88d83f9dc49ef71d75
1 #! /bin/sh
2 # Copyright (C) 2010-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Stress test on canonicalization.
19 required='cc libtool libtoolize'
20 . ./defs || exit 1
22 cat >> configure.ac << 'END'
23 AC_PROG_CC
24 AM_PROG_AR
25 AC_PROG_RANLIB dnl: for static libraries
26 AC_PROG_LIBTOOL dnl: for libtool libraries
27 AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
28 AC_OUTPUT
29 END
31 if touch ,foo-bar libb.az+baz lib~zardoz,,; then
32 rm -f ,foo-bar libb.az+baz lib~zardoz,,
33 else
34 skip_ "cannot create regular files with \"tricky\" names"
37 cat > Makefile.am << 'END'
38 noinst_PROGRAMS = dummy_static dummy_dynamic ,foo-bar
39 noinst_LIBRARIES = libb.az+baz.a
40 noinst_LTLIBRARIES = lib~zardoz,,.la
42 dummy_static_SOURCES = dummy.c lib.h
43 dummy_dynamic_SOURCES = $(dummy_static_SOURCES)
45 dummy_static_LDADD = $(noinst_LIBRARIES)
46 dummy_dynamic_LDADD = $(noinst_LTLIBRARIES)
48 _foo_bar_SOURCES = foobar.c
49 libb_az_baz_a_SOURCES = libs.c
50 lib_zardoz___la_SOURCES = libd.c
52 check-local:
53 ls -l
54 if CROSS_COMPILING
55 test -f ./,foo-bar$(EXEEXT)
56 test -f ./dummy_static$(EXEEXT)
57 test -f ./dummy_dynamic$(EXEEXT)
58 else !CROSS_COMPILING
59 ./,foo-bar
60 ./dummy_static
61 ./dummy_dynamic
62 ./,foo-bar | grep 'Hello, FooBar!'
63 ./dummy_static | grep 'Hello from Static!'
64 ./dummy_dynamic | grep 'Hello from Dynamic!'
65 endif !CROSS_COMPILING
66 END
68 cat > foobar.c << 'END'
69 #include <stdio.h>
70 int main(void)
72 printf("Hello, FooBar!\n");
73 return 0;
75 END
77 cat > dummy.c << 'END'
78 #include <stdio.h>
79 #include "lib.h"
80 int main(void)
82 printf("Hello from %s!\n", dummy_func());
83 return 0;
85 END
87 echo 'const char *dummy_func(void);' > lib.h
88 echo 'const char *dummy_func(void) { return "Dynamic"; }' > libd.c
89 echo 'const char *dummy_func(void) { return "Static"; }' > libs.c
91 libtoolize
92 $ACLOCAL
93 $AUTOCONF
94 $AUTOMAKE -a
96 ./configure
98 $MAKE check
99 $MAKE distcheck