Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / search-path.at
1 # search-path.at -- test sys_lib_search_path_spec             -*- Autotest -*-
2 #
3 #   Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc.
4 #
5 #   This file is part of GNU Libtool.
6 #
7 # GNU Libtool is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of
10 # the License, or (at your option) any later version.
11 #
12 # GNU Libtool is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Libtool; see the file COPYING.  If not, a copy
19 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
20 # or obtained by writing to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 ####
23
24 AT_SETUP([sys_lib_search_path])
25 AT_KEYWORDS([libtool])
26 LDFLAGS="$LDFLAGS -no-undefined"
27
28 AT_DATA([main.c],
29 [[extern
30 #ifdef __cplusplus
31 "C"
32 #endif
33 int inflate ();
34 int main()
35 {
36   return inflate ();
37 }
38 ]])
39
40 $CC $CPPFLAGS $CFLAGS -c main.c
41 eval `$LIBTOOL --config | $EGREP '^(sys_lib_search_path_spec)='`
42 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
43 no_libz=:
44 for path in $sys_lib_search_path; do
45   if $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT -L$path -lz
46   then
47     AT_CHECK([$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o main$EXEEXT main.$OBJEXT -lz],
48              [], [ignore], [ignore])
49     no_libz=false
50     break
51   fi
52 done
53
54 # If -lz doesn't exist (hello, cross compiler!), we need a dummy test.
55 if $no_libz; then
56   AT_CHECK([exit 77])
57 fi
58
59 AT_CLEANUP
60
61
62 AT_SETUP([sys_lib_search_path on w32])
63 AT_KEYWORDS([libtool])
64
65 # Check if libtool knows the path to system libraries.  Using
66 # a w32 system library since the test is designed to check if
67 # the libtool handling of the sys_lib_search_path variable is
68 # correct for MSVC.
69
70 LDFLAGS="$LDFLAGS -no-undefined"
71
72 AT_DATA([gc.c],
73 [[#include <windows.h>
74 HCURSOR get_cursor (void)
75 {
76   return GetCursor ();
77 }
78 ]])
79
80 eval "`$LIBTOOL --config | grep '^build_libtool_libs='`"
81 AT_CHECK([test "$build_libtool_libs" = yes || exit 77])
82
83 AT_CHECK([$LIBTOOL --mode=compile --tag=CC \
84           $CC $CPPFLAGS $CFLAGS -o gc.lo -c gc.c || exit 77],
85          [], [ignore], [ignore])
86
87 # Ok, compile was fine, then it should be possible to link too.
88
89 AT_CHECK([$LIBTOOL --mode=link --tag=CC --tag=disable-static \
90           $CC $CFLAGS $LDFLAGS -o libgc.la gc.lo -rpath /nowhere -luser32],
91          [], [ignore], [ignore])
92
93 # If -luser32 was found, then libtool will build a shared library,
94 # otherwise libtool will fall back to creating a static library.
95 AT_CHECK([grep old_library=\'\' libgc.la], [], [ignore])
96
97 AT_CLEANUP