ltmain.in: Use func_warning for all warnings
[libtool.git] / tests / convenience.at
blobbf45cddab3197be0e25429a7858e95034497073a
1 # convenience.at -- testing C convenience archives            -*- Autotest -*-
3 #   Copyright (C) 2005, 2007-2019, 2021-2024 Free Software Foundation,
4 #   Inc.
5 #   Written by Ralf Wildenhues, 2005
7 #   This file is part of GNU Libtool.
9 # GNU Libtool is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation; either version 2 of
12 # the License, or (at your option) any later version.
14 # GNU Libtool is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with GNU Libtool; see the file COPYING.  If not, a copy
21 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
22 # or obtained by writing to the Free Software Foundation, Inc.,
23 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 ####
26 # Test that convenience archives work.
27 # for each TAG, test:
28 # - adding one or multiple convenience archives
29 # - with or without additional objects on the cmdline
31 AT_SETUP([C convenience archives])
32 AT_KEYWORDS([libtool])
34 cat >main1.c <<EOF
35 extern int a1(void);
36 int main(void) { return a1() != 1; }
37 EOF
38 cat >main2.c <<EOF
39 extern int a1(void), a2(void);
40 int main(void) { return a1() + a2() != 3; }
41 EOF
42 cat >main3.c <<EOF
43 extern int a1(void), a2(void), a3(void);
44 int main(void) { return a1() + a2() + a3() != 6; }
45 EOF
46 for i in 1 2 3; do
47   echo "int a$i(void) { return $i; }" > a$i.c
48   $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c main$i.c
49   $LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a$i.c
50   $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba$i.la a$i.lo
51 done
52 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba12.la liba1.la liba2.la -rpath /notexist],
53          [0],[ignore],[ignore])
54 AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba123.la a3.lo liba1.la liba2.la -rpath /notexist],
55          [0],[ignore],[ignore])
57 conv=
58 for i in 1 2 3; do
59   conv=$conv$i
60   AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -static -o main_static$EXEEXT main$i.lo liba$conv.la],
61            [0],[ignore],[ignore])
62   AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main$EXEEXT main$i.lo liba$conv.la],
63            [0],[ignore],[ignore])
64   LT_AT_EXEC_CHECK([./main_static])
65   LT_AT_EXEC_CHECK([./main])
66 done
67 AT_CLEANUP
70 AT_SETUP([C++ convenience archives])
71 LT_AT_TAG([CXX])
72 AT_KEYWORDS([libtool])
74 cat >main1.cpp <<EOF
75 extern int a1(void);
76 int main(void) { return a1() != 1; }
77 EOF
78 cat >main2.cpp <<EOF
79 extern int a1(void), a2(void);
80 int main(void) { return a1() + a2() != 3; }
81 EOF
82 cat >main3.cpp <<EOF
83 extern int a1(void), a2(void), a3(void);
84 int main(void) { return a1() + a2() + a3() != 6; }
85 EOF
86 for i in 1 2 3; do
87   echo "int a$i(void) { return $i; }" > a$i.cpp
88   $LIBTOOL --tag=CXX --mode=compile $CXX $CXXFLAGS -c main$i.cpp
89   $LIBTOOL --tag=CXX --mode=compile $CXX $CXXFLAGS -c a$i.cpp
90   $LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS -o liba$i.la a$i.lo
91 done
92 AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS -o liba12.la liba1.la liba2.la -rpath /notexist],
93          [0],[ignore],[ignore])
94 AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS -o liba123.la a3.lo liba1.la liba2.la -rpath /notexist],
95          [0],[ignore],[ignore])
97 conv=
98 for i in 1 2 3; do
99   conv=$conv$i
100   AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS -static -o main_static$EXEEXT main$i.lo liba$conv.la],
101            [0],[ignore],[ignore])
102   AT_CHECK([$LIBTOOL --tag=CXX --mode=link $CXX $CXXFLAGS $LDFLAGS -o main$EXEEXT main$i.lo liba$conv.la],
103            [0],[ignore],[ignore])
104   LT_AT_EXEC_CHECK([./main_static])
105   LT_AT_EXEC_CHECK([./main])
106 done
107 AT_CLEANUP
110 AT_SETUP([F77 convenience archives])
111 LT_AT_TAG([F77])
112 AT_KEYWORDS([libtool])
114 cat >main1.f <<EOF
115       program main
116       implicit none
117       integer*4 res
118       call a1(res)
119       end
121 cat >main2.f <<EOF
122       program main
123       implicit none
124       integer*4 res
125       call a1(res)
126       call a2(res)
127       end
129 cat >main3.f <<EOF
130       program main
131       implicit none
132       integer*4 res
133       call a1(res)
134       call a2(res)
135       call a3(res)
136       end
139 for i in 1 2 3; do
140   cat >a$i.f <<EOF
141       subroutine a$i(res)
142       implicit none
143       integer*4 res
144       res=$i
145       return
146       end
148   $LIBTOOL --tag=F77 --mode=compile $F77 $FFLAGS -c main$i.f
149   $LIBTOOL --tag=F77 --mode=compile $F77 $FFLAGS -c a$i.f
150   $LIBTOOL --tag=F77 --mode=link $F77 $FFLAGS $LDFLAGS -o liba$i.la a$i.lo
151 done
152 AT_CHECK([$LIBTOOL --tag=F77 --mode=link $F77 $FFLAGS $LDFLAGS -o liba12.la liba1.la liba2.la -rpath /notexist],
153          [0],[ignore],[ignore])
154 AT_CHECK([$LIBTOOL --tag=F77 --mode=link $F77 $FFLAGS $LDFLAGS -o liba123.la a3.lo liba1.la liba2.la -rpath /notexist],
155          [0],[ignore],[ignore])
157 conv=
158 for i in 1 2 3; do
159   conv=$conv$i
160   AT_CHECK([$LIBTOOL --tag=F77 --mode=link $F77 $FFLAGS $LDFLAGS -static -o main_static$EXEEXT main$i.lo liba$conv.la],
161            [0],[ignore],[ignore])
162   AT_CHECK([$LIBTOOL --tag=F77 --mode=link $F77 $FFLAGS $LDFLAGS -o main$EXEEXT main$i.lo liba$conv.la],
163            [0],[ignore],[ignore])
164   LT_AT_EXEC_CHECK([./main_static])
165   LT_AT_EXEC_CHECK([./main])
166 done
167 AT_CLEANUP
170 AT_SETUP([FC convenience archives])
171 LT_AT_TAG([FC])
172 AT_KEYWORDS([libtool])
174 cat >main1.f <<EOF
175       program main
176       implicit none
177       integer*4 res
178       call a1(res)
179       end
181 cat >main2.f <<EOF
182       program main
183       implicit none
184       integer*4 res
185       call a1(res)
186       call a2(res)
187       end
189 cat >main3.f <<EOF
190       program main
191       implicit none
192       integer*4 res
193       call a1(res)
194       call a2(res)
195       call a3(res)
196       end
199 for i in 1 2 3; do
200   cat >a$i.f <<EOF
201       subroutine a$i(res)
202       implicit none
203       integer*4 res
204       res=$i
205       return
206       end
208   $LIBTOOL --tag=FC --mode=compile $FC $FCFLAGS -c main$i.f
209   $LIBTOOL --tag=FC --mode=compile $FC $FCFLAGS -c a$i.f
210   $LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -o liba$i.la a$i.lo
211 done
212 AT_CHECK([$LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -o liba12.la liba1.la liba2.la -rpath /notexist],
213          [0],[ignore],[ignore])
214 AT_CHECK([$LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -o liba123.la a3.lo liba1.la liba2.la -rpath /notexist],
215          [0],[ignore],[ignore])
217 conv=
218 for i in 1 2 3; do
219   conv=$conv$i
220   AT_CHECK([$LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -static -o main_static$EXEEXT main$i.lo liba$conv.la],
221            [0],[ignore],[ignore])
222   AT_CHECK([$LIBTOOL --tag=FC --mode=link $FC $FCFLAGS $LDFLAGS -o main$EXEEXT main$i.lo liba$conv.la],
223            [0],[ignore],[ignore])
224   LT_AT_EXEC_CHECK([./main_static])
225   LT_AT_EXEC_CHECK([./main])
226 done
227 AT_CLEANUP
230 AT_SETUP([Java convenience archives])
231 LT_AT_EXEC_TAG([GCJ])
232 AT_KEYWORDS([libtool])
234 cat >foo1.java <<EOF
235 public class foo1 {
236   public static void main(String[[]] argv) {
237     A1 a1 = new A1();
238   }
241 cat >foo2.java <<EOF
242 public class foo2 {
243   public static void main(String[[]] argv) {
244     A1 a1 = new A1(); A2 a2 = new A2();
245   }
248 cat >foo3.java <<EOF
249 public class foo3 {
250   public static void main(String[[]] argv) {
251     A1 a1 = new A1(); A2 a2 = new A2(); A3 a3 = new A3();
252   }
255 for i in 1 2 3; do
256   cat >A$i.java <<EOF
257 public class A$i {
258   private int a;
259   public A$i () { a = 0; }
263   # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42143
264   # Some 4.3.x and 4.4.x releases of gcj insert a spurious dummy symbol
265   # into every object file when compiling directly from .java to .o, so
266   # we have to make .class files first, and then compile those to native
267   # objects:
268   $GCJ $GCJFLAGS -C foo$i.java
269   $GCJ $GCJFLAGS -C A$i.java
271   $LIBTOOL --tag=GCJ --mode=compile $GCJ $GCJFLAGS -c foo$i.class
272   $LIBTOOL --tag=GCJ --mode=compile $GCJ $GCJFLAGS -c A$i.class
273   $LIBTOOL --tag=GCJ --mode=link $GCJ $GCJFLAGS $LDFLAGS -o liba$i.la A$i.lo
274 done
275 AT_CHECK([$LIBTOOL --tag=GCJ --mode=link $GCJ $GCJFLAGS $LDFLAGS -o liba12.la liba1.la liba2.la -rpath /notexist],
276          [0],[ignore],[ignore])
277 AT_CHECK([$LIBTOOL --tag=GCJ --mode=link $GCJ $GCJFLAGS $LDFLAGS -o liba123.la A3.lo liba1.la liba2.la -rpath /notexist],
278          [0],[ignore],[ignore])
280 conv=
281 for i in 1 2 3; do
282   conv=$conv$i
283   AT_CHECK([$LIBTOOL --tag=GCJ --mode=link $GCJ $GCJFLAGS $LDFLAGS -static --main=foo$i -o main_static$EXEEXT foo$i.lo liba$conv.la],
284            [0],[ignore],[ignore])
285   AT_CHECK([$LIBTOOL --tag=GCJ --mode=link $GCJ $GCJFLAGS $LDFLAGS --main=foo$i -o main$EXEEXT foo$i.lo liba$conv.la],
286            [0],[ignore],[ignore])
287   LT_AT_EXEC_CHECK([./main_static])
288   LT_AT_EXEC_CHECK([./main])
289 done
290 AT_CLEANUP