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