source: trunk/third/gettext2/autoconf-lib-link/tests/rpathcfg.sh @ 22167

Revision 22167, 6.4 KB checked in by ghudson, 19 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r22166, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1#!/bin/sh
2# Prints information for maintaining config.rpath.
3
4# The caller should set the environment variables
5# top_srcdir, srcdir, CONFIG_SHELL, CC, GCC, LDFLAGS, LD, with_gnu_ld, host.
6
7echo "=============== rpathcfg for $host ==============="
8echo
9echo "--------------- config.rpath output ---------------"
10${CONFIG_SHELL-/bin/sh} $srcdir/../config.rpath "$host" | sed -e 's/^acl_cv_//'
11echo "--------------- experimentally determined ---------------"
12builddir=`pwd`
13global_top_auxdir=`cd "$top_srcdir"/config && pwd`
14export global_top_auxdir
15
16test -d tstdir || mkdir tstdir
17
18rm -rf tstprefix tstdir/build tstlib
19
20eval `${CONFIG_SHELL-/bin/sh} $srcdir/../config.rpath "$host" | grep '^acl_cv_wl='`
21wl="$acl_cv_wl"
22
23# Static library suffix (normally "a").
24mkdir tstprefix
25mkdir tstdir/build
26(cd $srcdir/rpathx && tar cf - *) | (cd tstdir/build && tar xf -)
27(cd tstdir/build
28 ${CONFIG_SHELL-/bin/sh} ./configure --disable-shared --prefix=$builddir/tstprefix > configure.log 2>&1
29 make > make.log 2>&1
30 make install > install.log 2>&1
31)
32rm -rf tstdir/build
33libext=
34cd tstprefix/lib
35for f in *; do
36  case $f in
37    *.la) ;;
38    *[0-9]) ;;
39    *) libext=`echo $f | sed -e 's/^.*\.//'`;;
40  esac
41  if test -n "$libext"; then
42    break
43  fi
44done
45cd ../..
46rm -rf tstprefix
47
48# Shared library suffix (normally "so").
49mkdir tstprefix
50mkdir tstdir/build
51(cd $srcdir/rpathx && tar cf - *) | (cd tstdir/build && tar xf -)
52(cd tstdir/build
53 ${CONFIG_SHELL-/bin/sh} ./configure --disable-static --prefix=$builddir/tstprefix > configure.log 2>&1
54 make > make.log 2>&1
55 make install > install.log 2>&1
56)
57rm -rf tstdir/build
58shlibext=
59cd tstprefix/lib || exit 1
60for f in *; do
61  case $f in
62    *.la) ;;
63    *[0-9]) ;;
64    *) shlibext=`echo $f | sed -e 's/^.*\.//'`;;
65  esac
66  if test -n "$shlibext"; then
67    break
68  fi
69done
70cd ../..
71rm -rf tstprefix
72
73# Prepare hardcoding tests.
74mkdir tstprefix
75mkdir tstdir/build
76(cd $srcdir/rpathx && tar cf - *) | (cd tstdir/build && tar xf -)
77(cd tstdir/build
78 ${CONFIG_SHELL-/bin/sh} ./configure --disable-static --prefix=$builddir/tstprefix > configure.log 2>&1
79 make > make.log 2>&1
80 make install > install.log 2>&1
81)
82rm -rf tstdir/build
83
84# Flag to hardcode \$libdir into a binary during linking.
85# This must work even if \$libdir does not exist.
86hardcode_libdir_flag_spec=
87for spec in \
88    '-L$libdir' \
89    '-R$libdir' \
90    '-rpath $libdir' '${wl}-rpath ${wl}$libdir' \
91    '${wl}+b ${wl}$libdir' \
92    '${wl}-R $libdir:/usr/lib:/lib' \
93    '${wl}-blibpath:$libdir:/usr/lib:/lib' \
94    '${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' \
95  ; do
96  mv tstprefix/lib tstlib
97  libdir=`pwd`/tstprefix/lib
98  eval flag=\"$spec\"
99  echo 1>&2
100  echo "$CC $LDFLAGS $srcdir/rpathlx/usex.c tstlib/librpathx.$shlibext $flag -o a.out" 1>&2
101  $CC $LDFLAGS $srcdir/rpathlx/usex.c tstlib/librpathx.$shlibext $flag -o a.out
102  if test $? = 0; then
103    mv tstlib tstprefix/lib
104    echo "ok, running created a.out." 1>&2
105    if ./a.out; then
106      hardcode_libdir_flag_spec="$hardcode_libdir_flag_spec$spec
107"
108    fi
109  else
110    mv tstlib tstprefix/lib
111  fi
112  rm -f a.out
113done
114
115# Whether we need a single -rpath flag with a separated argument.
116hardcode_libdir_separator=
117if test -n "$hardcode_libdir_flag_spec"; then
118  spec=`echo "$hardcode_libdir_flag_spec" | sed -e '2,$d'`
119  # Try with multiple -rpath flags.
120  mv tstprefix/lib tstlib
121  libdir=`pwd`/tstprefix/lib
122  eval flag1=\"$spec\"
123  libdir=/tmp
124  eval flag2=\"$spec\"
125  echo 1>&2
126  echo "$CC $LDFLAGS $srcdir/rpathlx/usex.c tstlib/librpathx.$shlibext $flag1 $flag2 -o a.out" 1>&2
127  $CC $LDFLAGS $srcdir/rpathlx/usex.c tstlib/librpathx.$shlibext $flag1 $flag2 -o a.out
128  if test $? = 0; then
129    mv tstlib tstprefix/lib
130    echo "ok, running created a.out." 1>&2
131    if ./a.out; then
132      hardcode_libdir_separator=NONE
133    fi
134  else
135    mv tstlib tstprefix/lib
136  fi
137  rm -f a.out
138  if test -z "$hardcode_libdir_separator"; then
139    # Try with a single -rpath flag.
140    mv tstprefix/lib tstlib
141    libdir=`pwd`/tstprefix/lib:/tmp
142    eval flag=\"$spec\"
143    echo 1>&2
144    echo "$CC $LDFLAGS $srcdir/rpathlx/usex.c tstlib/librpathx.$shlibext $flag -o a.out" 1>&2
145    $CC $LDFLAGS $srcdir/rpathlx/usex.c tstlib/librpathx.$shlibext $flag -o a.out
146    if test $? = 0; then
147      mv tstlib tstprefix/lib
148      echo "ok, running created a.out." 1>&2
149      if ./a.out; then
150        hardcode_libdir_separator=:
151      fi
152    else
153      mv tstlib tstprefix/lib
154    fi
155    rm -f a.out
156  fi
157  if test -z "$hardcode_libdir_separator"; then
158    echo "hardcode_libdir_separator test failed!" 1>&2
159  else
160    if test "$hardcode_libdir_separator" = NONE; then
161      hardcode_libdir_separator=
162    fi
163  fi
164fi
165
166# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
167# resulting binary.
168hardcode_direct=no
169echo 1>&2
170echo "$CC $LDFLAGS $srcdir/rpathlx/usex.c tstprefix/lib/librpathx.$shlibext -o a.out" 1>&2
171$CC $LDFLAGS $srcdir/rpathlx/usex.c tstprefix/lib/librpathx.$shlibext -o a.out
172if test $? = 0; then
173  echo "ok, running created a.out." 1>&2
174  if ./a.out; then
175    hardcode_direct=yes
176  fi
177fi
178rm -f a.out
179
180# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
181# resulting binary.
182hardcode_minus_L=no
183echo 1>&2
184echo "$CC $LDFLAGS $srcdir/rpathlx/usex.c -Ltstprefix/lib -lrpathx -o a.out" 1>&2
185$CC $LDFLAGS $srcdir/rpathlx/usex.c -Ltstprefix/lib -lrpathx -o a.out
186if test $? = 0; then
187  echo "ok, running created a.out." 1>&2
188  if ./a.out; then
189    hardcode_minus_L=yes
190  fi
191fi
192rm -f a.out
193
194# Clean up.
195rm -rf tstprefix tstdir
196
197sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
198escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
199escaped_sys_lib_search_path_spec=`echo "X$sys_lib_search_path_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
200escaped_sys_lib_dlsearch_path_spec=`echo "X$sys_lib_dlsearch_path_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
201
202cat <<EOF
203
204# Static library suffix (normally "a").
205libext="$libext"
206
207# Shared library suffix (normally "so").
208shlibext="$shlibext"
209
210# Flag to hardcode \$libdir into a binary during linking.
211# This must work even if \$libdir does not exist.
212hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
213
214# Whether we need a single -rpath flag with a separated argument.
215hardcode_libdir_separator="$hardcode_libdir_separator"
216
217# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
218# resulting binary.
219hardcode_direct="$hardcode_direct"
220
221# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
222# resulting binary.
223hardcode_minus_L="$hardcode_minus_L"
224
225EOF
Note: See TracBrowser for help on using the repository browser.