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