1#! /bin/sh
2# Output a system dependent set of variables, describing how to set the
3# run time search path of shared libraries in an executable.
4#
5#   Copyright 1996-2003 Free Software Foundation, Inc.
6#   Taken from GNU libtool, 2001
7#   Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8#
9#   This program is free software; you can redistribute it and/or modify
10#   it under the terms of the GNU General Public License as published by
11#   the Free Software Foundation; either version 2 of the License, or
12#   (at your option) any later version.
13#
14#   This program is distributed in the hope that it will be useful, but
15#   WITHOUT ANY WARRANTY; without even the implied warranty of
16#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17#   General Public License for more details.
18#
19#   You should have received a copy of the GNU General Public License
20#   along with this program; if not, write to the Free Software
21#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22#
23#   As a special exception to the GNU General Public License, if you
24#   distribute this file as part of a program that contains a
25#   configuration script generated by Autoconf, you may include it under
26#   the same distribution terms that you use for the rest of that program.
27#
28# The first argument passed to this file is the canonical host specification,
29#    CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
30# or
31#    CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
32# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
33# should be set by the caller.
34#
35# The set of defined variables is at the end of this script.
36
37# Known limitations:
38# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
39#   than 256 bytes, otherwise the compiler driver will dump core. The only
40#   known workaround is to choose shorter directory names for the build
41#   directory and/or the installation directory.
42
43# All known linkers require a `.a' archive for static linking (except M$VC,
44# which needs '.lib').
45libext=a
46shrext=.so
47
48host="$1"
49host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
50host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
51host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
52
53# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
54
55wl=
56if test "$GCC" = yes; then
57  wl='-Wl,'
58else
59  case "$host_os" in
60    aix*)
61      wl='-Wl,'
62      ;;
63    mingw* | pw32* | os2*)
64      ;;
65    hpux9* | hpux10* | hpux11*)
66      wl='-Wl,'
67      ;;
68    irix5* | irix6* | nonstopux*)
69      wl='-Wl,'
70      ;;
71    newsos6)
72      ;;
73    linux*)
74      case $CC in
75        icc|ecc)
76          wl='-Wl,'
77          ;;
78        ccc)
79          wl='-Wl,'
80          ;;
81      esac
82      ;;
83    osf3* | osf4* | osf5*)
84      wl='-Wl,'
85      ;;
86    sco3.2v5*)
87      ;;
88    solaris*)
89      wl='-Wl,'
90      ;;
91    sunos4*)
92      wl='-Qoption ld '
93      ;;
94    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
95      wl='-Wl,'
96      ;;
97    sysv4*MP*)
98      ;;
99    uts4*)
100      ;;
101  esac
102fi
103
104# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
105
106hardcode_libdir_flag_spec=
107hardcode_libdir_separator=
108hardcode_direct=no
109hardcode_minus_L=no
110
111case "$host_os" in
112  cygwin* | mingw* | pw32*)
113    # FIXME: the MSVC++ port hasn't been tested in a loooong time
114    # When not using gcc, we currently assume that we are using
115    # Microsoft Visual C++.
116    if test "$GCC" != yes; then
117      with_gnu_ld=no
118    fi
119    ;;
120  openbsd*)
121    with_gnu_ld=no
122    ;;
123esac
124
125ld_shlibs=yes
126if test "$with_gnu_ld" = yes; then
127  case "$host_os" in
128    aix[3-9]*)
129      # On AIX/PPC, the GNU linker is very broken
130      if test "$host_cpu" != ia64; then
131        ld_shlibs=no
132      fi
133      ;;
134    amigaos*)
135      hardcode_libdir_flag_spec='-L$libdir'
136      hardcode_minus_L=yes
137      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
138      # that the semantics of dynamic libraries on AmigaOS, at least up
139      # to version 4, is to share data among multiple programs linked
140      # with the same dynamic library.  Since this doesn't match the
141      # behavior of shared libraries on other platforms, we can use
142      # them.
143      ld_shlibs=no
144      ;;
145    beos*)
146      if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
147        :
148      else
149        ld_shlibs=no
150      fi
151      ;;
152    cygwin* | mingw* | pw32*)
153      # hardcode_libdir_flag_spec is actually meaningless, as there is
154      # no search path for DLLs.
155      hardcode_libdir_flag_spec='-L$libdir'
156      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
157        :
158      else
159        ld_shlibs=no
160      fi
161      ;;
162    netbsd*)
163      ;;
164    haiku*)
165      ;;
166    solaris* | sysv5*)
167      if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
168        ld_shlibs=no
169      elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
170        :
171      else
172        ld_shlibs=no
173      fi
174      ;;
175    sunos4*)
176      hardcode_direct=yes
177      ;;
178    *)
179      if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
180        :
181      else
182        ld_shlibs=no
183      fi
184      ;;
185  esac
186  if test "$ld_shlibs" = yes; then
187    # Unlike libtool, we use -rpath here, not --rpath, since the documented
188    # option of GNU ld is called -rpath, not --rpath.
189    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
190  fi
191else
192  case "$host_os" in
193    aix3*)
194      # Note: this linker hardcodes the directories in LIBPATH if there
195      # are no directories specified by -L.
196      hardcode_minus_L=yes
197      if test "$GCC" = yes; then
198        # Neither direct hardcoding nor static linking is supported with a
199        # broken collect2.
200        hardcode_direct=unsupported
201      fi
202      ;;
203    aix[4-9]*)
204      if test "$host_cpu" = ia64; then
205        # On IA64, the linker does run time linking by default, so we don't
206        # have to do anything special.
207        aix_use_runtimelinking=no
208      else
209        aix_use_runtimelinking=no
210        # Test if we are trying to use run time linking or normal
211        # AIX style linking. If -brtl is somewhere in LDFLAGS, we
212        # need to do runtime linking.
213        case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
214          for ld_flag in $LDFLAGS; do
215            if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
216              aix_use_runtimelinking=yes
217              break
218            fi
219          done
220        esac
221      fi
222      hardcode_direct=yes
223      hardcode_libdir_separator=':'
224      if test "$GCC" = yes; then
225        case $host_os in aix4.[012]|aix4.[012].*)
226          collect2name=`${CC} -print-prog-name=collect2`
227          if test -f "$collect2name" && \
228            strings "$collect2name" | grep resolve_lib_name >/dev/null
229          then
230            # We have reworked collect2
231            hardcode_direct=yes
232          else
233            # We have old collect2
234            hardcode_direct=unsupported
235            hardcode_minus_L=yes
236            hardcode_libdir_flag_spec='-L$libdir'
237            hardcode_libdir_separator=
238          fi
239        esac
240      fi
241      # Begin _LT_AC_SYS_LIBPATH_AIX.
242      echo 'int main () { return 0; }' > conftest.c
243      ${CC} ${LDFLAGS} conftest.c -o conftest
244      aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
245}'`
246      if test -z "$aix_libpath"; then
247        aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
248}'`
249      fi
250      if test -z "$aix_libpath"; then
251        aix_libpath="/usr/lib:/lib"
252      fi
253      rm -f conftest.c conftest
254      # End _LT_AC_SYS_LIBPATH_AIX.
255      if test "$aix_use_runtimelinking" = yes; then
256        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
257      else
258        if test "$host_cpu" = ia64; then
259          hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
260        else
261          hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
262        fi
263      fi
264      ;;
265    amigaos*)
266      hardcode_libdir_flag_spec='-L$libdir'
267      hardcode_minus_L=yes
268      # see comment about different semantics on the GNU ld section
269      ld_shlibs=no
270      ;;
271    bsdi4*)
272      ;;
273    cygwin* | mingw* | pw32*)
274      # When not using gcc, we currently assume that we are using
275      # Microsoft Visual C++.
276      # hardcode_libdir_flag_spec is actually meaningless, as there is
277      # no search path for DLLs.
278      hardcode_libdir_flag_spec=' '
279      libext=lib
280      ;;
281    darwin* | rhapsody*)
282      if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then
283        hardcode_direct=no
284      fi
285      ;;
286    dgux*)
287      hardcode_libdir_flag_spec='-L$libdir'
288      ;;
289    freebsd2.2*)
290      hardcode_libdir_flag_spec='-R$libdir'
291      hardcode_direct=yes
292      ;;
293    freebsd2*)
294      hardcode_direct=yes
295      hardcode_minus_L=yes
296      ;;
297    freebsd*)
298      hardcode_libdir_flag_spec='-R$libdir'
299      hardcode_direct=yes
300      ;;
301    hpux9*)
302      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
303      hardcode_libdir_separator=:
304      hardcode_direct=yes
305      # hardcode_minus_L: Not really in the search PATH,
306      # but as the default location of the library.
307      hardcode_minus_L=yes
308      ;;
309    hpux10* | hpux11*)
310      if test "$with_gnu_ld" = no; then
311        case "$host_cpu" in
312          hppa*64*)
313            hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
314            hardcode_libdir_separator=:
315            hardcode_direct=no
316            ;;
317          ia64*)
318            hardcode_libdir_flag_spec='-L$libdir'
319            hardcode_direct=no
320            # hardcode_minus_L: Not really in the search PATH,
321            # but as the default location of the library.
322            hardcode_minus_L=yes
323            ;;
324          *)
325            hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
326            hardcode_libdir_separator=:
327            hardcode_direct=yes
328            # hardcode_minus_L: Not really in the search PATH,
329            # but as the default location of the library.
330            hardcode_minus_L=yes
331            ;;
332        esac
333      fi
334      ;;
335    irix5* | irix6* | nonstopux*)
336      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
337      hardcode_libdir_separator=:
338      ;;
339    netbsd*)
340      hardcode_libdir_flag_spec='-R$libdir'
341      hardcode_direct=yes
342      ;;
343    newsos6)
344      hardcode_direct=yes
345      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
346      hardcode_libdir_separator=:
347      ;;
348    openbsd*)
349      hardcode_direct=yes
350      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
351        hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
352      else
353        case "$host_os" in
354          openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
355            hardcode_libdir_flag_spec='-R$libdir'
356            ;;
357          *)
358            hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
359            ;;
360        esac
361      fi
362      ;;
363    os2*)
364      hardcode_libdir_flag_spec='-L$libdir'
365      hardcode_minus_L=yes
366      ;;
367    osf3*)
368      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
369      hardcode_libdir_separator=:
370      ;;
371    osf4* | osf5*)
372      if test "$GCC" = yes; then
373        hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
374      else
375        # Both cc and cxx compiler support -rpath directly
376        hardcode_libdir_flag_spec='-rpath $libdir'
377      fi
378      hardcode_libdir_separator=:
379      ;;
380    sco3.2v5*)
381      ;;
382    solaris*)
383      hardcode_libdir_flag_spec='-R$libdir'
384      ;;
385    sunos4*)
386      hardcode_libdir_flag_spec='-L$libdir'
387      hardcode_direct=yes
388      hardcode_minus_L=yes
389      ;;
390    sysv4)
391      case $host_vendor in
392        sni)
393          hardcode_direct=yes # is this really true???
394          ;;
395        siemens)
396          hardcode_direct=no
397          ;;
398        motorola)
399          hardcode_direct=no #Motorola manual says yes, but my tests say they lie
400          ;;
401      esac
402      ;;
403    sysv4.3*)
404      ;;
405    sysv4*MP*)
406      if test -d /usr/nec; then
407        ld_shlibs=yes
408      fi
409      ;;
410    sysv4.2uw2*)
411      hardcode_direct=yes
412      hardcode_minus_L=no
413      ;;
414    sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[78]* | unixware7*)
415      ;;
416    sysv5*)
417      hardcode_libdir_flag_spec=
418      ;;
419    uts4*)
420      hardcode_libdir_flag_spec='-L$libdir'
421      ;;
422    *)
423      ld_shlibs=no
424      ;;
425  esac
426fi
427
428# Check dynamic linker characteristics
429# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
430libname_spec='lib$name'
431case "$host_os" in
432  aix3*)
433    ;;
434  aix[4-9]*)
435    ;;
436  amigaos*)
437    ;;
438  beos*)
439    ;;
440  bsdi4*)
441    ;;
442  cygwin* | mingw* | pw32*)
443    shrext=.dll
444    ;;
445  darwin* | rhapsody*)
446    shrext=.dylib
447    ;;
448  dgux*)
449    ;;
450  freebsd*)
451    ;;
452  gnu*)
453    ;;
454  hpux9* | hpux10* | hpux11*)
455    case "$host_cpu" in
456      ia64*)
457        shrext=.so
458        ;;
459      hppa*64*)
460        shrext=.sl
461        ;;
462      *)
463        shrext=.sl
464        ;;
465    esac
466    ;;
467  irix5* | irix6* | nonstopux*)
468    case "$host_os" in
469      irix5* | nonstopux*)
470        libsuff= shlibsuff=
471        ;;
472      *)
473        case $LD in
474          *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
475          *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
476          *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
477          *) libsuff= shlibsuff= ;;
478        esac
479        ;;
480    esac
481    ;;
482  linux*oldld* | linux*aout* | linux*coff*)
483    ;;
484  linux*)
485    ;;
486  netbsd*)
487    ;;
488  newsos6)
489    ;;
490  nto-qnx)
491    ;;
492  openbsd*)
493    ;;
494  os2*)
495    libname_spec='$name'
496    shrext=.dll
497    ;;
498  osf3* | osf4* | osf5*)
499    ;;
500  sco3.2v5*)
501    ;;
502  solaris*)
503    ;;
504  sunos4*)
505    ;;
506  sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
507    ;;
508  sysv4*MP*)
509    ;;
510  uts4*)
511    ;;
512esac
513
514sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
515escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
516shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
517escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
518
519sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
520
521# How to pass a linker flag through the compiler.
522wl="$escaped_wl"
523
524# Static library suffix (normally "a").
525libext="$libext"
526
527# Shared library suffix (normally "so").
528shlibext="$shlibext"
529
530# Flag to hardcode \$libdir into a binary during linking.
531# This must work even if \$libdir does not exist.
532hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
533
534# Whether we need a single -rpath flag with a separated argument.
535hardcode_libdir_separator="$hardcode_libdir_separator"
536
537# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
538# resulting binary.
539hardcode_direct="$hardcode_direct"
540
541# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
542# resulting binary.
543hardcode_minus_L="$hardcode_minus_L"
544
545EOF
546