Merge branch 'maint'
[platform/upstream/automake.git] / tests / multlib.test
1 #! /bin/sh
2 # Copyright (C) 2003, 2004, 2007, 2010, 2011, 2012 Free Software
3 # Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 # Check multilib support.
19 # Based on a test case from Ralf Corsepius.
20
21 required='gcc GNUmake'
22 . ./defs || Exit 1
23
24 # Multilib support has been deprecated in the Automake core.
25
26 cat >>configure.in <<'END'
27 AM_ENABLE_MULTILIB([Makefile], [.])
28 END
29
30 $ACLOCAL
31 $AUTOCONF -Wall -Werror 2>stderr && { cat stderr >&2; Exit 1; }
32 cat stderr >&2
33 grep '^configure\.in:4:.*AM_ENABLE_MULTILIB.* removed.* soon' stderr
34 grep '"multilib".*feature' stderr
35 grep 'contrib.* in the Automake distribution' stderr
36
37 rm -rf autom4te*.cache aclocal.m4 configure
38
39 # Functional tests now.
40
41 cat >configure.in <<'END'
42 AC_INIT([multlib], [1.0])
43 AC_CONFIG_SRCDIR(libfoo/foo.c)
44 AC_CONFIG_AUX_DIR(.)
45 AM_INIT_AUTOMAKE
46 AC_CONFIG_FILES([Makefile])
47 AC_CONFIG_SUBDIRS(libfoo)
48 AC_CONFIG_SUBDIRS(libbar)
49 AC_OUTPUT
50 END
51
52 cat >mycc <<'END'
53 #! /bin/sh
54 case ${1+"$@"} in
55  *-print-multi-lib*)
56   echo ".;"
57   echo "debug;@g"
58   exit 0 ;;
59 esac
60 gcc ${1+"$@"}
61 END
62
63 chmod +x mycc
64 PATH=`pwd`$PATH_SEPARATOR$PATH
65
66 cat >Makefile.am <<'EOF'
67 SUBDIRS = @subdirs@
68 EXTRA_DIST = config-ml.in symlink-tree
69 EOF
70
71 # libfoo tests multilib supports when there are no subdirectories
72 # libbar tests multilib supports when there are subdirectories
73
74 mkdir libfoo
75
76 cat >libfoo/configure.in <<'END'
77 AC_PREREQ(2.57)
78 AC_INIT(libfoo, 0.1, nobody@localhost)
79 AC_CONFIG_SRCDIR(foo.c)
80 # Apparently it doesn't work to have auxdir=.. when
81 # multilib uses symlinked trees.
82 AC_CONFIG_AUX_DIR(.)
83 AM_INIT_AUTOMAKE
84 AC_PROG_CC
85 AM_PROG_AR
86 AC_PROG_RANLIB
87 AM_ENABLE_MULTILIB(Makefile,[..])
88 AC_CONFIG_FILES([Makefile])
89 AC_OUTPUT
90 END
91
92 cat >libfoo/Makefile.am <<'END'
93 noinst_LIBRARIES = libfoo.a
94 libfoo_a_SOURCES = foo.c
95 END
96
97 : > libfoo/foo.c
98
99 mkdir libbar
100
101 cat >libbar/configure.in <<'END'
102 AC_PREREQ(2.57)
103 AC_INIT(libbar, 0.1, nobody@localhost)
104 # Apparently it doesn't work to have auxdir=.. when
105 # multilib uses symlinked trees.
106 AC_CONFIG_AUX_DIR(.)
107 AM_INIT_AUTOMAKE
108 AC_PROG_CC
109 AM_PROG_AR
110 AC_PROG_RANLIB
111 AM_ENABLE_MULTILIB(Makefile,[..])
112 AC_CONFIG_FILES([Makefile sub/Makefile])
113 AC_OUTPUT
114 END
115
116 cat >libbar/Makefile.am <<'END'
117 SUBDIRS = sub
118 noinst_LIBRARIES = libbar.a
119 libbar_a_SOURCES = bar.c
120 END
121
122 mkdir libbar/sub
123
124 : >libbar/sub/Makefile.am
125
126 : > libbar/bar.c
127
128 cp "$am_scriptdir"/config-ml.in "$am_scriptdir"/symlink-tree .
129
130 $ACLOCAL -Wno-obsolete
131 $AUTOCONF -Werror -Wall -Wno-obsolete
132 $AUTOMAKE --add-missing
133 cd libfoo
134 $ACLOCAL
135 $AUTOCONF -Werror -Wall -Wno-obsolete
136 $AUTOMAKE --add-missing
137 cd ../libbar
138 $ACLOCAL
139 $AUTOCONF -Werror -Wall -Wno-obsolete
140 $AUTOMAKE --add-missing
141 cd ..
142
143
144 # Check VPATH builds
145 mkdir build
146 cd build
147 ../configure --enable-multilib CC=mycc
148 $MAKE
149 $MAKE install
150 $MAKE distcleancheck
151
152 # Check standard builds.
153 cd ..
154 # Why to I have to specify --with-target-subdir?
155 ./configure --enable-multilib --with-target-subdir=. CC=mycc
156 $MAKE