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