tests: expose automake bug#14560
[platform/upstream/automake.git] / t / ar-lib5b.sh
1 #! /bin/sh
2 # Copyright (C) 2011-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 # Test if AM_PROG_AR triggers the use of the ar-lib script.
18 # This test does not require Microsoft lib.
19 # Keep this test in sync with sister test 'ar-lib5a.sh'.
20
21 . test-init.sh
22
23 cat > configure.ac << END
24 AC_INIT([$me], [1.0])
25 AC_CONFIG_AUX_DIR([auxdir])
26 AM_INIT_AUTOMAKE
27 AC_CONFIG_FILES([Makefile])
28 AC_PROG_CC
29 AM_PROG_AR
30 AC_PROG_RANLIB
31 # We want to test the content of am_cv_ar_interface in the Makefile.
32 AC_SUBST([am_cv_ar_interface])
33 AC_OUTPUT
34 END
35
36 cat > Makefile.am << 'END'
37 lib_LIBRARIES = libwish.a
38 libwish_a_SOURCES = wish.c
39
40 check-local:
41         test x'$(am_cv_ar_interface)' = x'lib'
42         test -f ar-lib-worked
43 MOSTLYCLEANFILES = ar-lib-worked
44 END
45
46 cat > wish.c << 'END'
47 int wish(void) { return 0; }
48 END
49
50 mkdir auxdir
51 cat > auxdir/ar-lib << 'END'
52 #! /bin/sh
53 :> ar-lib-worked
54 END
55 chmod +x auxdir/ar-lib
56
57 # Let's fake microsoft lib.
58 mkdir bin
59 cat > bin/lib << 'END'
60 #! /bin/sh
61 echo lib command line: $* >&2 # For debugging.
62 case " $* " in
63   # The '-OUT:' option is used by tests in configure.  So don't create
64   # the 'ar-lib-worked' file here, as that might cause spurious passes
65   # of this test; but don't fail either, as that would confuse said
66   # configure tests.
67   *' -OUT:'*) exit 0;;
68   # This means that $* looks like a command-line for 'ar'.  We have to
69   # exit with failure here, to accommodate the two following ortoghonal
70   # scenarios:
71   #  1. when 'lib' is tested by configure, this will tell that it does
72   #     not use the ar(1) interface, so that the 'ar-lib' script will
73   #     get involved;
74   #  2. when 'lib' is called by the Makefile, an ar-style command line
75   #     passed to it would mean that the 'ar-lib' script has failed to
76   #     properly munge the command line, or hasn't been invoked to do so.
77   *\ c*) exit 1;;
78   # Assume everything else is OK.
79   *) : > ar-lib-worked;;
80 esac
81 END
82 chmod +x bin/lib
83 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH; export PATH
84
85 $ACLOCAL
86 $AUTOCONF
87 $AUTOMAKE --add-missing
88
89 # Sanity check: test that it is ok to use 'am_cv_ar_interface' as we do.
90 $FGREP 'am_cv_ar_interface=' configure
91
92 ./configure AR=lib RANLIB=:
93
94 $MAKE check
95 $MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="AR=lib RANLIB=:"
96
97 :