ar-lib: new 'AM_PROG_AR' macro, triggering the 'ar-lib' script
[automake.git] / tests / multlib.test
blob1072a574549ce9b71b33221c82f2ff63ac52dedb
1 #! /bin/sh
2 # Copyright (C) 2003, 2004, 2007, 2010 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 # Check multilib support.
18 # Based on a test case from Ralf Corsepius.
20 required='gcc GNUmake'
21 . ./defs || Exit 1
23 set -e
25 cat >configure.in <<'END'
26 AC_INIT([multlib], [1.0])
27 AC_CONFIG_SRCDIR(libfoo/foo.c)
28 AC_CONFIG_AUX_DIR(.)
29 AM_INIT_AUTOMAKE
30 AC_CONFIG_FILES([Makefile])
31 AC_CONFIG_SUBDIRS(libfoo)
32 AC_CONFIG_SUBDIRS(libbar)
33 AC_OUTPUT
34 END
36 cat >mycc <<'END'
37 #! /bin/sh
38 case ${1+"$@"} in
39 *-print-multi-lib*)
40 echo ".;"
41 echo "debug;@g"
42 exit 0 ;;
43 esac
44 gcc ${1+"$@"}
45 END
47 chmod +x mycc
48 PATH=`pwd`$PATH_SEPARATOR$PATH
50 cat >Makefile.am <<'EOF'
51 SUBDIRS = @subdirs@
52 EXTRA_DIST = config-ml.in symlink-tree
53 EOF
55 # libfoo tests multilib supports when there are no subdirectories
56 # libbar tests multilib supports when there are subdirectories
58 mkdir libfoo
60 cat >libfoo/configure.in <<'END'
61 AC_PREREQ(2.57)
62 AC_INIT(libfoo, 0.1, nobody@localhost)
63 AC_CONFIG_SRCDIR(foo.c)
64 # Apparently it doesn't work to have auxdir=.. when
65 # multilib uses symlinked trees.
66 AC_CONFIG_AUX_DIR(.)
67 AM_INIT_AUTOMAKE
68 AC_PROG_CC
69 AM_PROG_AR
70 AC_PROG_RANLIB
71 AM_ENABLE_MULTILIB(Makefile,[..])
72 AC_CONFIG_FILES([Makefile])
73 AC_OUTPUT
74 END
76 cat >libfoo/Makefile.am <<'END'
77 noinst_LIBRARIES = libfoo.a
78 libfoo_a_SOURCES = foo.c
79 END
81 : > libfoo/foo.c
83 mkdir libbar
85 cat >libbar/configure.in <<'END'
86 AC_PREREQ(2.57)
87 AC_INIT(libbar, 0.1, nobody@localhost)
88 # Apparently it doesn't work to have auxdir=.. when
89 # multilib uses symlinked trees.
90 AC_CONFIG_AUX_DIR(.)
91 AM_INIT_AUTOMAKE
92 AC_PROG_CC
93 AM_PROG_AR
94 AC_PROG_RANLIB
95 AM_ENABLE_MULTILIB(Makefile,[..])
96 AC_CONFIG_FILES([Makefile sub/Makefile])
97 AC_OUTPUT
98 END
100 cat >libbar/Makefile.am <<'END'
101 SUBDIRS = sub
102 noinst_LIBRARIES = libbar.a
103 libbar_a_SOURCES = bar.c
106 mkdir libbar/sub
108 : >libbar/sub/Makefile.am
110 : > libbar/bar.c
112 cp "$testsrcdir/../lib/config-ml.in" .
113 cp "$testsrcdir/../lib/symlink-tree" .
115 $ACLOCAL
116 $AUTOCONF
117 $AUTOMAKE --add-missing
118 cd libfoo
119 $ACLOCAL
120 $AUTOCONF
121 $AUTOMAKE --add-missing
122 cd ../libbar
123 $ACLOCAL
124 $AUTOCONF
125 $AUTOMAKE --add-missing
126 cd ..
129 # Check VPATH builds
130 mkdir build
131 cd build
132 ../configure --enable-multilib CC=mycc
133 $MAKE
134 $MAKE install
135 $MAKE distcleancheck
137 # Check standard builds.
138 cd ..
139 # Why to I have to specify --with-target-subdir?
140 ./configure --enable-multilib --with-target-subdir=. CC=mycc
141 $MAKE