.
[gnulib.git] / config / 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-2002 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 # All known linkers require a `.a' archive for static linking (except M$VC,
38 # which needs '.lib').
39 libext=a
40 shlibext=
41
42 host="$1"
43 host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
44 host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
45 host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
46
47 wl=
48 if test "$GCC" = yes; then
49   wl='-Wl,'
50 else
51   case "$host_os" in
52     aix3* | aix4* | aix5*)
53       if test "$host_cpu" = ia64; then
54         wl='-Wl,'
55       fi
56       ;;
57     hpux9* | hpux10* | hpux11*)
58       wl='-Wl,'
59       ;;
60     irix5* | irix6*)
61       wl='-Wl,'
62       ;;
63     linux*)
64       echo '__INTEL_COMPILER' > conftest.$ac_ext
65       if $CC -E conftest.$ac_ext >/dev/null | grep __INTEL_COMPILER >/dev/null
66       then
67         :
68       else
69         # Intel icc
70         wl='-Qoption,ld,'
71       fi
72       ;;
73     osf3* | osf4* | osf5*)
74       wl='-Wl,'
75       ;;
76     solaris*)
77       wl='-Wl,'
78       ;;
79     sunos4*)
80       wl='-Qoption ld '
81       ;;
82     sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
83       if test "x$host_vendor" = xsni; then
84         wl='-LD'
85       else
86         wl='-Wl,'
87       fi
88       ;;
89   esac
90 fi
91
92 hardcode_libdir_flag_spec=
93 hardcode_libdir_separator=
94 hardcode_direct=no
95 hardcode_minus_L=no
96
97 case "$host_os" in
98   cygwin* | mingw* | pw32* )
99     # FIXME: the MSVC++ port hasn't been tested in a loooong time
100     # When not using gcc, we currently assume that we are using
101     # Microsoft Visual C++.
102     if test "$GCC" != yes; then
103       with_gnu_ld=no
104     fi
105     ;;
106 esac
107
108 ld_shlibs=yes
109 if test "$with_gnu_ld" = yes; then
110   case "$host_os" in
111     aix3* | aix4* | aix5*)
112       # On AIX, the GNU linker is very broken
113       ld_shlibs=no
114       ;;
115     amigaos*)
116       hardcode_libdir_flag_spec='-L$libdir'
117       hardcode_minus_L=yes
118       # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
119       # that the semantics of dynamic libraries on AmigaOS, at least up
120       # to version 4, is to share data among multiple programs linked
121       # with the same dynamic library.  Since this doesn't match the
122       # behavior of shared libraries on other platforms, we can use
123       # them.
124       ld_shlibs=no
125       ;;
126     beos*)
127       if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
128         :
129       else
130         ld_shlibs=no
131       fi
132       ;;
133     cygwin* | mingw* | pw32*)
134       # hardcode_libdir_flag_spec is actually meaningless, as there is
135       # no search path for DLLs.
136       hardcode_libdir_flag_spec='-L$libdir'
137       ;;
138     solaris* | sysv5*)
139       if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
140         ld_shlibs=no
141       elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
142         :
143       else
144         ld_shlibs=no
145       fi
146       ;;
147     sunos4*)
148       hardcode_direct=yes
149       ;;
150     *)
151       if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
152         :
153       else
154         ld_shlibs=no
155       fi
156       ;;
157   esac
158   if test "$ld_shlibs" = yes; then
159     hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
160   fi
161 else
162   case "$host_os" in
163     aix3*)
164       # Note: this linker hardcodes the directories in LIBPATH if there
165       # are no directories specified by -L.
166       hardcode_minus_L=yes
167       if test "$GCC" = yes; then
168         # Neither direct hardcoding nor static linking is supported with a
169         # broken collect2.
170         hardcode_direct=unsupported
171       fi
172       ;;
173     aix4* | aix5*)
174       hardcode_libdir_separator=':'
175       if test "$GCC" = yes; then
176         collect2name=`${CC} -print-prog-name=collect2`
177         if test -f "$collect2name" && \
178           strings "$collect2name" | grep resolve_lib_name >/dev/null
179         then
180           # We have reworked collect2
181           hardcode_direct=yes
182         else
183           # We have old collect2
184           hardcode_direct=unsupported
185           hardcode_minus_L=yes
186           hardcode_libdir_flag_spec='-L$libdir'
187           hardcode_libdir_separator=
188         fi
189       else
190         hardcode_direct=yes
191       fi
192       if test "$host_cpu" = ia64; then
193         # On IA64, the linker does run time linking by default, so we don't
194         # have to do anything special.
195         aix_use_runtimelinking=no
196       else
197         # Test if we are trying to use run time linking, or normal AIX style linking.
198         # If -brtl is somewhere in LDFLAGS, we need to do run time linking.
199         aix_use_runtimelinking=no
200         for ld_flag in $LDFLAGS; do
201           if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl" ); then
202             aix_use_runtimelinking=yes
203             break
204           fi
205         done
206       fi
207       if test "$aix_use_runtimelinking" = yes; then
208         hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib'
209       else
210         if test "$host_cpu" = ia64; then
211           hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
212         else
213           hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib'
214         fi
215       fi
216       ;;
217     amigaos*)
218       hardcode_libdir_flag_spec='-L$libdir'
219       hardcode_minus_L=yes
220       # see comment about different semantics on the GNU ld section
221       ld_shlibs=no
222       ;;
223     cygwin* | mingw* | pw32*)
224       # When not using gcc, we currently assume that we are using
225       # Microsoft Visual C++.
226       # hardcode_libdir_flag_spec is actually meaningless, as there is
227       # no search path for DLLs.
228       hardcode_libdir_flag_spec=' '
229       libext=lib
230       ;;
231     darwin* | rhapsody*)
232       hardcode_direct=yes
233       ;;
234     freebsd1*)
235       ld_shlibs=no
236       ;;
237     freebsd2.2*)
238       hardcode_libdir_flag_spec='-R$libdir'
239       hardcode_direct=yes
240       ;;
241     freebsd2*)
242       hardcode_direct=yes
243       hardcode_minus_L=yes
244       ;;
245     freebsd*)
246       hardcode_libdir_flag_spec='-R$libdir'
247       hardcode_direct=yes
248       ;;
249     hpux9* | hpux10* | hpux11*)
250       hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
251       hardcode_libdir_separator=:
252       hardcode_direct=yes
253       hardcode_minus_L=yes # Not in the search PATH, but as the default
254                            # location of the library.
255       ;;
256     irix5* | irix6*)
257       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
258       hardcode_libdir_separator=:
259       ;;
260     netbsd*)
261       hardcode_libdir_flag_spec='-R$libdir'
262       hardcode_direct=yes
263       ;;
264     newsos6)
265       hardcode_direct=yes
266       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
267       hardcode_libdir_separator=:
268       ;;
269     openbsd*)
270       hardcode_libdir_flag_spec='-R$libdir'
271       hardcode_direct=yes
272       ;;
273     os2*)
274       hardcode_libdir_flag_spec='-L$libdir'
275       hardcode_minus_L=yes
276       ;;
277     osf3*)
278       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
279       hardcode_libdir_separator=:
280       ;;
281     osf4* | osf5*)
282       if test "$GCC" = yes; then
283         hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
284       else
285         # Both cc and cxx compiler support -rpath directly
286         hardcode_libdir_flag_spec='-rpath $libdir'
287       fi
288       hardcode_libdir_separator=:
289       ;;
290     sco3.2v5*)
291       ;;
292     solaris*)
293       hardcode_libdir_flag_spec='-R$libdir'
294       ;;
295     sunos4*)
296       hardcode_libdir_flag_spec='-L$libdir'
297       hardcode_direct=yes
298       hardcode_minus_L=yes
299       ;;
300     sysv4)
301       if test "x$host_vendor" = xsno; then
302         hardcode_direct=yes # is this really true???
303       else
304         hardcode_direct=no # Motorola manual says yes, but my tests say they lie
305       fi
306       ;;
307     sysv4.3*)
308       ;;
309     sysv5*)
310       hardcode_libdir_flag_spec=
311       ;;
312     uts4*)
313       hardcode_libdir_flag_spec='-L$libdir'
314       ;;
315     dgux*)
316       hardcode_libdir_flag_spec='-L$libdir'
317       ;;
318     sysv4*MP*)
319       if test -d /usr/nec; then
320         ld_shlibs=yes
321       fi
322       ;;
323     sysv4.2uw2*)
324       hardcode_direct=yes
325       hardcode_minus_L=no
326       ;;
327     sysv5uw7* | unixware7*)
328       ;;
329     *)
330       ld_shlibs=no
331       ;;
332   esac
333 fi
334
335 # Check dynamic linker characteristics
336 libname_spec='lib$name'
337 sys_lib_dlsearch_path_spec="/lib /usr/lib"
338 sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
339 case "$host_os" in
340   aix3*)
341     shlibext=so
342     ;;
343   aix4* | aix5*)
344     shlibext=so
345     ;;
346   amigaos*)
347     shlibext=ixlibrary
348     ;;
349   beos*)
350     shlibext=so
351     ;;
352   bsdi4*)
353     shlibext=so
354     sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
355     sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
356     ;;
357   cygwin* | mingw* | pw32*)
358     case $GCC,$host_os in
359       yes,cygwin*)
360         shlibext=dll.a
361         ;;
362       yes,mingw*)
363         shlibext=dll
364         sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"`
365         ;;
366       yes,pw32*)
367         shlibext=dll
368         ;;
369       *)
370         shlibext=dll
371         ;;
372     esac
373     ;;
374   darwin* | rhapsody*)
375     shlibext=dylib
376     ;;
377   freebsd1*)
378     ;;
379   freebsd*)
380     shlibext=so
381     ;;
382   gnu*)
383     shlibext=so
384     ;;
385   hpux9* | hpux10* | hpux11*)
386     shlibext=sl
387     ;;
388   irix5* | irix6*)
389     shlibext=so
390     case "$host_os" in
391       irix5*)
392         libsuff= shlibsuff=
393         ;;
394       *)
395         case $LD in
396           *-32|*"-32 ") libsuff= shlibsuff= ;;
397           *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 ;;
398           *-64|*"-64 ") libsuff=64 shlibsuff=64 ;;
399           *) libsuff= shlibsuff= ;;
400         esac
401         ;;
402     esac
403     sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
404     sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
405     ;;
406   linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*)
407     ;;
408   linux-gnu*)
409     shlibext=so
410     ;;
411   netbsd*)
412     shlibext=so
413     ;;
414   newsos6)
415     shlibext=so
416     ;;
417   openbsd*)
418     shlibext=so
419     ;;
420   os2*)
421     libname_spec='$name'
422     shlibext=dll
423     ;;
424   osf3* | osf4* | osf5*)
425     shlibext=so
426     sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
427     sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
428     ;;
429   sco3.2v5*)
430     shlibext=so
431     ;;
432   solaris*)
433     shlibext=so
434     ;;
435   sunos4*)
436     shlibext=so
437     ;;
438   sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
439     shlibext=so
440     case "$host_vendor" in
441       motorola)
442         sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
443         ;;
444     esac
445     ;;
446   uts4*)
447     shlibext=so
448     ;;
449   dgux*)
450     shlibext=so
451     ;;
452   sysv4*MP*)
453     if test -d /usr/nec; then
454       shlibext=so
455     fi
456     ;;
457 esac
458
459 sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
460 escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
461 escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
462 escaped_sys_lib_search_path_spec=`echo "X$sys_lib_search_path_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
463 escaped_sys_lib_dlsearch_path_spec=`echo "X$sys_lib_dlsearch_path_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
464
465 sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
466
467 # How to pass a linker flag through the compiler.
468 wl="$escaped_wl"
469
470 # Static library suffix (normally "a").
471 libext="$libext"
472
473 # Shared library suffix (normally "so").
474 shlibext="$shlibext"
475
476 # Flag to hardcode \$libdir into a binary during linking.
477 # This must work even if \$libdir does not exist.
478 hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
479
480 # Whether we need a single -rpath flag with a separated argument.
481 hardcode_libdir_separator="$hardcode_libdir_separator"
482
483 # Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
484 # resulting binary.
485 hardcode_direct="$hardcode_direct"
486
487 # Set to yes if using the -LDIR flag during linking hardcodes DIR into the
488 # resulting binary.
489 hardcode_minus_L="$hardcode_minus_L"
490
491 # Compile-time system search path for libraries
492 sys_lib_search_path_spec="$escaped_sys_lib_search_path_spec"
493
494 # Run-time system search path for libraries
495 sys_lib_dlsearch_path_spec="$escaped_sys_lib_dlsearch_path_spec"
496
497 EOF