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