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