Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / multlib.test
1 #! /bin/sh
2 # Copyright (C) 2003, 2004, 2007, 2010, 2012 Free Software Foundation,
3 # 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 set -e
25
26 # Multilib support has been deprecated in the Automake core.
27
28 cat >>configure.in <<'END'
29 AM_ENABLE_MULTILIB([Makefile], [.])
30 END
31
32 $ACLOCAL
33 $AUTOCONF -Wall -Werror 2>stderr && { cat stderr >&2; Exit 1; }
34 cat stderr >&2
35 grep '^configure\.in:4:.*AM_ENABLE_MULTILIB.* removed.* soon' stderr
36 grep '"multilib".*feature' stderr
37 grep 'contrib.* in the Automake distribution' stderr
38
39 rm -rf autom4te*.cache aclocal.m4 configure
40
41 # Functional tests now.
42
43 cat >configure.in <<'END'
44 AC_INIT([multlib], [1.0])
45 AC_CONFIG_SRCDIR(libfoo/foo.c)
46 AC_CONFIG_AUX_DIR(.)
47 AM_INIT_AUTOMAKE
48 AC_CONFIG_FILES([Makefile])
49 AC_CONFIG_SUBDIRS(libfoo)
50 AC_CONFIG_SUBDIRS(libbar)
51 AC_OUTPUT
52 END
53
54 cat >mycc <<'END'
55 #! /bin/sh
56 case ${1+"$@"} in
57  *-print-multi-lib*)
58   echo ".;"
59   echo "debug;@g"
60   exit 0 ;;
61 esac
62 gcc ${1+"$@"}
63 END
64
65 chmod +x mycc
66 PATH=`pwd`$PATH_SEPARATOR$PATH
67
68 cat >Makefile.am <<'EOF'
69 SUBDIRS = @subdirs@
70 EXTRA_DIST = config-ml.in symlink-tree
71 EOF
72
73 # libfoo tests multilib supports when there are no subdirectories
74 # libbar tests multilib supports when there are subdirectories
75
76 mkdir libfoo
77
78 cat >libfoo/configure.in <<'END'
79 AC_PREREQ(2.57)
80 AC_INIT(libfoo, 0.1, nobody@localhost)
81 AC_CONFIG_SRCDIR(foo.c)
82 # Apparently it doesn't work to have auxdir=.. when
83 # multilib uses symlinked trees.
84 AC_CONFIG_AUX_DIR(.)
85 AM_INIT_AUTOMAKE
86 AC_PROG_CC
87 AM_PROG_AR
88 AC_PROG_RANLIB
89 AM_ENABLE_MULTILIB(Makefile,[..])
90 AC_CONFIG_FILES([Makefile])
91 AC_OUTPUT
92 END
93
94 cat >libfoo/Makefile.am <<'END'
95 noinst_LIBRARIES = libfoo.a
96 libfoo_a_SOURCES = foo.c
97 END
98
99 : > libfoo/foo.c
100
101 mkdir libbar
102
103 cat >libbar/configure.in <<'END'
104 AC_PREREQ(2.57)
105 AC_INIT(libbar, 0.1, nobody@localhost)
106 # Apparently it doesn't work to have auxdir=.. when
107 # multilib uses symlinked trees.
108 AC_CONFIG_AUX_DIR(.)
109 AM_INIT_AUTOMAKE
110 AC_PROG_CC
111 AM_PROG_AR
112 AC_PROG_RANLIB
113 AM_ENABLE_MULTILIB(Makefile,[..])
114 AC_CONFIG_FILES([Makefile sub/Makefile])
115 AC_OUTPUT
116 END
117
118 cat >libbar/Makefile.am <<'END'
119 SUBDIRS = sub
120 noinst_LIBRARIES = libbar.a
121 libbar_a_SOURCES = bar.c
122 END
123
124 mkdir libbar/sub
125
126 : >libbar/sub/Makefile.am
127
128 : > libbar/bar.c
129
130 cp "$testsrcdir/../lib/config-ml.in" .
131 cp "$testsrcdir/../lib/symlink-tree" .
132
133 $ACLOCAL -Wno-obsolete
134 $AUTOCONF -Werror -Wall -Wno-obsolete
135 $AUTOMAKE --add-missing
136 cd libfoo
137 $ACLOCAL
138 $AUTOCONF -Werror -Wall -Wno-obsolete
139 $AUTOMAKE --add-missing
140 cd ../libbar
141 $ACLOCAL
142 $AUTOCONF -Werror -Wall -Wno-obsolete
143 $AUTOMAKE --add-missing
144 cd ..
145
146
147 # Check VPATH builds
148 mkdir build
149 cd build
150 ../configure --enable-multilib CC=mycc
151 $MAKE
152 $MAKE install
153 $MAKE distcleancheck
154
155 # Check standard builds.
156 cd ..
157 # Why to I have to specify --with-target-subdir?
158 ./configure --enable-multilib --with-target-subdir=. CC=mycc
159 $MAKE