Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / demo-noinst-link.test
1 #! /bin/sh
2 # demo-noinst-link.test - make sure we do not link with an installed
3 #                         library when an uninstalled one is to be used
4 #
5 #   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
6 #   Written by Gary V. Vaughan, 2003
7 #
8 #   This file is part of GNU Libtool.
9 #
10 # GNU Libtool is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation; either version 2 of
13 # the License, or (at your option) any later version.
14 #
15 # GNU Libtool is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with GNU Libtool; see the file COPYING.  If not, a copy
22 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
23 # or obtained by writing to the Free Software Foundation, Inc.,
24 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 ####
26
27 . tests/defs || exit 1
28
29 func_restore_files ()
30 {
31     mv -f "$objdir"/temp/libs/* "$objdir"
32     mv -f "$objdir/temp/libhello.la" "$objdir/temp/hell$EXEEXT" .
33     rm -rf "$objdir/temp"
34 }
35
36 func_save_files ()
37 {
38     func_mkdir_p "$objdir/temp/libs"
39     cp -f libhello.la "hell$EXEEXT" "$objdir/temp"
40     cp -f "$objdir"/* "$objdir"/temp/libs
41     trap "func_restore_files" 0 1 2 13 15
42 }
43
44 func_require "demo-inst" "$prefix/lib/libhello.la"
45
46 func_mkprefixdir
47 func_cd "tests/demo"
48 func_save_files
49
50 func_msg "removing \`libhello.la' and \`hell' from demo"
51 rm -f libhello.la "hell$EXEEXT"
52
53 status=$EXIT_SUCCESS
54 func_msg "linking \`hell' with a broken \`demo/libhello.la'"
55 if $MAKE "hell$EXEEXT" libhello_la_OBJECTS=hello.lo; then
56   func_msg "Succeeded: this means the installed library was used, which is wrong"
57   status=$EXIT_FAILURE
58 fi
59
60 exit $status