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