1#! /bin/sh
2# build-relink.test - check to see whether shlibpath overrides runpath
3
4# Test script header.
5need_prefix=yes
6if test -z "$srcdir"; then
7  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
8  test "$srcdir" = "$0" && srcdir=.
9  test "${VERBOSE+set}" != "set" && VERBOSE=yes
10fi
11. $srcdir/defs || exit 1
12
13# Check that things are built.
14if test -f $prefix/lib/libhello.la && cd ../demo && test -f libhello.la; then :
15else
16  echo "You must run demo-inst.test before $0" 1>&2
17  exit 77
18fi
19
20# Check to make sure we have a dynamic library.
21library_names=NONE
22eval `grep '^library_names=' ./libhello.la 2>/dev/null`
23
24if test "$library_names" = NONE; then
25  echo "library_names not set in ../demo/libhello.la" 1>&2
26  exit 1
27elif test -z "$library_names"; then
28  echo "= Exiting: ../demo/libhello.la is not a shared library"
29  exit 77
30fi
31
32# Unfortunately, we need access to libtool internals for this test.
33objdir=NONE
34eval `grep '^objdir=' ./libtool 2>/dev/null`
35if test "$objdir" = NONE; then
36  echo "objdir not set in ../demo/libtool" 1>&2
37  exit 1
38fi
39
40shlibpath_overrides_runpath=NONE
41eval `grep '^shlibpath_overrides_runpath=' ./libtool 2>/dev/null`
42if test "$shlibpath_overrides_runpath" = NONE; then
43  echo "shlibpath_overrides_runpath not set in ../demo/libtool" 1>&2
44  exit 1
45fi
46
47hardcode_action=NONE
48eval `grep '^hardcode_action=' ./libtool 2>/dev/null`
49if test "$hardcode_action" = NONE; then
50  echo "hardcode_action not set in ../demo/libtool" 1>&2
51  exit 1
52fi
53
54hardcode_direct=NONE
55eval `grep '^hardcode_direct=' ./libtool 2>/dev/null`
56if test "$hardcode_direct" = NONE; then
57  echo "hardcode_direct not set in ../demo/libtool" 1>&2
58  exit 1
59fi
60
61hardcode_into_libs=NONE
62eval `grep '^hardcode_into_libs=' ./libtool 2>/dev/null`
63if test "$hardcode_into_libs" = NONE; then
64  echo "hardcode_into_libs not set in ../demo/libtool" 1>&2
65  exit 1
66fi
67
68./hell # so that it links on-demand if needed
69
70echo "removing libhello.la from ../demo"
71rm -f libhello.la $objdir/libhello.*
72
73echo "running ../demo/hell"
74if ./hell; then
75  :
76elif test "x,$hardcode_action,$hardcode_direct" = x,relink,yes; then
77  echo "Ok, uninstalled programs fail after uninstalled libraries are removed"
78  echo "This works in other configurations, but not in this particular one"
79else
80  echo "= Exiting: ../demo/hell does not run, maybe libhello was not installed"
81  exit 1
82fi
83
84echo "linking a broken ../demo/libhello.la"
85if $make libhello.la libhello_la_OBJECTS=hello.lo; then
86  :
87else
88  echo "= Exiting: cannot link broken libhello.la"
89  exit 1
90fi
91rm -f libhello.la
92
93echo "running ../demo/hell with broken libhello.la"
94if (./hell) 2>&1; then
95  echo "= Exiting: ../demo/hell runs even though libhello.la is incomplete"
96  echo "shlibpath_overrides_runpath should be set to no"
97  exit 1
98else
99  echo "Failed, as expected"
100fi
101
102if test "x$hardcode_action" = xrelink; then
103  echo "= Exiting: install-time relinking is required"
104  exit 0
105fi
106
107if test "$shlibpath_overrides_runpath" != yes; then
108  rm -f $objdir/lt-hell$EXEEXT || exit 1
109  cp $objdir/hell$EXEEXT $objdir/lt-hell$EXEEXT || exit 1
110  echo "running ../demo/hell with installed libhello.la"
111  if ./hell; then
112    echo "Worked, as expected"
113  else
114    echo "shlibpath_overrides_runpath should be set to yes"
115    status=1
116  fi
117  rm -f $objdir/lt-hell$EXEEXT
118fi
119
120exit $status
121