OSDN Git Service

merge from gcc
[pf3gnuchains/pf3gnuchains4x.git] / ltcf-cxx.sh
1 #### This script is meant to be sourced by ltconfig.
2
3 # ltcf-cxx.sh - Create a C++ compiler specific configuration
4 #
5 # Copyright (C) 1996-1999, 2000, 2001 Free Software Foundation, Inc.
6 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7 #
8 # Original C++ support by:Gary V. Vaughan <gvv@techie.com>
9 #    Alexandre Oliva <oliva@lsd.ic.unicamp.br>
10 #    Ossama Othman <ossama@debian.org>
11 #    Thomas Thanner <tanner@gmx.de>
12 #
13 # This file is free software; you can redistribute it and/or modify it
14 # under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 # General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 #
27 # As a special exception to the GNU General Public License, if you
28 # distribute this file as part of a program that contains a
29 # configuration script generated by Autoconf, you may include it under
30 # the same distribution terms that you use for the rest of that program.
31
32
33 # Source file extension for C++ test sources.
34 ac_ext=cc
35
36 # Object file extension for compiled C++ test sources.
37 objext=o
38
39 # Code to be used in simple compile tests
40 lt_simple_compile_test_code="int some_variable = 0;"
41
42 # Code to be used in simple link tests
43 lt_simple_link_test_code='int main(int, char *[]) { return (0); }'
44
45 # C++ compiler
46 CXX=${CXX-c++}
47
48 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
49 CC=${CC-"$CXX"}
50 CFLAGS=${CFLAGS-"$CXXFLAGS"}
51
52 # Allow CC to be a program name with arguments.
53 set dummy $CC
54 compiler=$2
55 cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'`
56
57 # Check if we are using GNU gcc  (taken/adapted from configure script)
58 # We need to check here since "--with-gcc" is set at configure time,
59 # not ltconfig time!
60 cat > conftest.$ac_ext <<EOF
61 #ifdef __GNUC__
62   yes;
63 #endif
64 EOF
65 if { ac_try='${CC-c++} -E conftest.$ac_ext'; { (eval echo \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
66   with_gcc=yes
67
68   # Set up default GNU C++ configuration
69
70   # Check if GNU C++ uses GNU ld as the underlying linker, since the
71   # archiving commands below assume that GNU ld is being used.
72   if eval "`$CC -print-prog-name=ld` --version 2>&1" | \
73       egrep 'GNU ld' > /dev/null; then
74     with_gnu_ld=yes
75
76     archive_cmds='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
77     archive_expsym_cmds='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
78
79     hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
80     export_dynamic_flag_spec='${wl}--export-dynamic'
81
82     # If archive_cmds runs LD, not CC, wlarc should be empty
83     # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
84     #     investigate it a little bit more. (MM)
85     wlarc='${wl}'
86
87     # ancient GNU ld didn't support --whole-archive et. al.
88     if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
89         egrep 'no-whole-archive' > /dev/null; then
90       whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
91     else
92       whole_archive_flag_spec=
93     fi
94   else
95     with_gnu_ld=no
96     wlarc=
97
98     # A generic and very simple default shared library creation
99     # command for GNU C++ for the case where it uses the native
100     # linker, instead of GNU ld.  If possible, this setting should
101     # overridden to take advantage of the native linker features on
102     # the platform it is being used on.
103     archive_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
104   fi
105
106   # Commands to make compiler produce verbose output that lists
107   # what "hidden" libraries, object files and flags are used when
108   # linking a shared library.
109   output_verbose_link_cmds='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"'
110
111 else
112   with_gcc=no
113   with_gnu_ld=no
114   wlarc=
115 fi
116
117 # In general, the C++ compiler should always link C++ objects.
118 case $target in
119 *aix3* | *aix4*)
120   # AIX just has to be different, doesn't it? :-\
121   LD=makeC++SharedLib_r
122   LDFLAGS="$LDFLAGS -p 0"
123   ;;
124 *)
125   LD="$CC"
126   LDFLAGS="$LDFLAGS"
127   ;;
128 esac
129
130
131 # PORTME: fill in a description of your system's C++ link characteristics
132 case "$host_os" in
133   aix3*)
134     # FIXME: insert proper C++ library support
135     ld_shlibs=no
136
137     # We don't want to build shared libraries on unknown CPU types.
138     case $host_cpu in
139     powerpc | rs6000) ;;
140     *) ld_shlibs=no ;;
141     esac
142     ;;
143   aix4*)
144     archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
145     # -bexpall does not export symbols beginning with underscore (_)
146     always_export_symbols=yes
147     # Exported symbols can be pulled into shared objects from archives
148     whole_archive_flag_spec=' '
149     build_libtool_need_lc=yes
150     ;;
151   chorus*)
152     case "$cc_basename" in
153       *)
154         # FIXME: insert proper C++ library support
155         ld_shlibs=no
156         ;;
157     esac 
158     ;;
159   dgux*)
160     case "$cc_basename" in
161       ec++)
162         # FIXME: insert proper C++ library support
163         ld_shlibs=no
164         ;;
165       ghcx)
166         # Green Hills C++ Compiler
167         # FIXME: insert proper C++ library support
168         ld_shlibs=no
169         ;;
170       *)
171         # FIXME: insert proper C++ library support
172         ld_shlibs=no
173         ;;
174     esac
175     ;;
176   freebsd*)
177     # FreeBSD uses GNU C++ and GNU ld
178     # FIXME: insert proper C++ library support
179     ld_shlibs=no
180     ;;
181   hpux*)
182     case "$cc_basename" in
183       CC)
184         # FIXME: insert proper C++ library support
185         ld_shlibs=no
186         ;;
187       aCC)
188         case "$host_os" in
189         hpux9*) archive_cmds='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;;
190         *) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;;
191         esac
192         hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
193         hardcode_libdir_separator=:
194         hardcode_direct=yes
195         hardcode_minus_L=yes # Not in the search PATH, but as the default
196                              # location of the library.
197         export_dynamic_flag_spec='${wl}-E'
198
199         # Commands to make compiler produce verbose output that lists
200         # what "hidden" libraries, object files and flags are used when
201         # linking a shared library.
202         #
203         # There doesn't appear to be a way to prevent this compiler from
204         # explicitly linking system object files so we need to strip them
205         # from the output so that they don't get included in the library
206         # dependencies.
207         output_verbose_link_cmds='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | egrep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
208         ;;
209       *)
210         # FIXME: insert proper C++ library support
211         ld_shlibs=no
212         ;;
213     esac
214     ;;
215   irix5* | irix6*)
216     case "$cc_basename" in
217       CC)
218         # SGI C++
219         archive_cmds='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
220
221         # Archives containing C++ object files must be created using
222         # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
223         # necessary to make sure instantiated templates are included
224         # in the archive.
225         old_archive_cmds='$CC -ar -WR,-u -o $oldlib $oldobjs'
226         ;;
227       *)
228         if test "$with_gcc" = yes; then
229           if test "$with_gnu_ld" = no; then
230             archive_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
231           else
232             archive_cmds='$LD -shared $predep_objects $libobjs $deplibs $postdep_objects $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -o $lib'
233           fi
234         fi
235         hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
236         hardcode_libdir_separator=:
237         link_all_deplibs=yes
238         ;;
239     esac
240     ;;
241   linux*)
242     case "$cc_basename" in
243       KCC)
244         # Kuck and Associates, Inc. (KAI) C++ Compiler
245
246         # KCC will only create a shared library if the output file
247         # ends with ".so" (or ".sl" for HP-UX), so rename the library
248         # to its proper name (with version) after linking.
249         archive_cmds='templib=`echo $lib | sed -e "s/\.so\..*/\.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
250         archive_expsym_cmds='templib=`echo $lib | sed -e "s/\.so\..*/\.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
251
252         # Commands to make compiler produce verbose output that lists
253         # what "hidden" libraries, object files and flags are used when
254         # linking a shared library.
255         #
256         # There doesn't appear to be a way to prevent this compiler from
257         # explicitly linking system object files so we need to strip them
258         # from the output so that they don't get included in the library
259         # dependencies.
260         output_verbose_link_cmds='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest.so 2>&1 | egrep "ld"`; rm -f libconftest.so; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
261
262         hardcode_libdir_flag_spec='${wl}--rpath,$libdir'
263         export_dynamic_flag_spec='${wl}--export-dynamic'
264
265         # Archives containing C++ object files must be created using
266         # "CC -Bstatic", where "CC" is the KAI C++ compiler.
267         old_archive_cmds='$CC -Bstatic -o $oldlib $oldobjs'
268         ;;
269       cxx)
270         # Compaq C++
271         archive_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
272         archive_expsym_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
273
274         runpath_var=LD_RUN_PATH
275         hardcode_libdir_flag_spec='-rpath $libdir'
276         hardcode_libdir_separator=:
277
278         # Commands to make compiler produce verbose output that lists
279         # what "hidden" libraries, object files and flags are used when
280         # linking a shared library.
281         #
282         # There doesn't appear to be a way to prevent this compiler from
283         # explicitly linking system object files so we need to strip them
284         # from the output so that they don't get included in the library
285         # dependencies.
286         output_verbose_link_cmds='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | sed "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
287         ;;
288     esac
289     ;;
290   lynxos*)
291     # FIXME: insert proper C++ library support
292     ld_shlibs=no
293     ;;
294   m88k*)
295     # FIXME: insert proper C++ library support
296     ld_shlibs=no
297     ;;
298   mvs*)
299     case "$cc_basename" in
300       cxx)
301         # FIXME: insert proper C++ library support
302         ld_shlibs=no
303         ;;
304       *)
305         # FIXME: insert proper C++ library support
306         ld_shlibs=no
307         ;;
308     esac   
309     ;;
310   netbsd*)
311     # NetBSD uses g++ - do we need to do anything?
312     ;;
313   osf3*)
314     if test "$with_gcc" = yes && test "$with_gnu_ld" = no; then
315       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
316       archive_cmds='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
317
318       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
319       hardcode_libdir_separator=:
320
321       # Commands to make compiler produce verbose output that lists
322       # what "hidden" libraries, object files and flags are used when
323       # linking a shared library.
324       output_verbose_link_cmds='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"'
325     fi
326
327     case "$cc_basename" in
328       KCC)
329         # Kuck and Associates, Inc. (KAI) C++ Compiler
330
331         # KCC will only create a shared library if the output file
332         # ends with ".so" (or ".sl" for HP-UX), so rename the library
333         # to its proper name (with version) after linking.
334         archive_cmds='templib=`echo $lib | sed -e "s/\.so\..*/\.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
335
336         hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
337         hardcode_libdir_separator=:
338
339         # Archives containing C++ object files must be created using
340         # "CC -Bstatic", where "CC" is the KAI C++ compiler.
341         old_archive_cmds='$CC -Bstatic -o $oldlib $oldobjs'
342
343         ;;
344       RCC)
345         # Rational C++ 2.4.1
346         # FIXME: insert proper C++ library support
347         ld_shlibs=no
348         ;;
349       cxx)
350         allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
351         archive_cmds='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
352
353         hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
354         hardcode_libdir_separator=:
355
356         # Commands to make compiler produce verbose output that lists
357         # what "hidden" libraries, object files and flags are used when
358         # linking a shared library.
359         #
360         # There doesn't appear to be a way to prevent this compiler from
361         # explicitly linking system object files so we need to strip them
362         # from the output so that they don't get included in the library
363         # dependencies.
364         output_verbose_link_cmds='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | sed "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
365         ;;
366       *)
367         # FIXME: insert proper C++ library support
368         ld_shlibs=no
369         ;;
370     esac
371     ;;
372   osf4* | osf5*)
373     if test "$with_gcc" = yes && test "$with_gnu_ld" = no; then
374       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
375       archive_cmds='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
376
377       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
378       hardcode_libdir_separator=:
379
380       # Commands to make compiler produce verbose output that lists
381       # what "hidden" libraries, object files and flags are used when
382       # linking a shared library.
383       output_verbose_link_cmds='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"'
384     fi
385
386     case "$cc_basename" in
387       KCC)
388         # Kuck and Associates, Inc. (KAI) C++ Compiler
389
390         # KCC will only create a shared library if the output file
391         # ends with ".so" (or ".sl" for HP-UX), so rename the library
392         # to its proper name (with version) after linking.
393         archive_cmds='templib=`echo $lib | sed -e "s/\.so\..*/\.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
394
395         hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
396         hardcode_libdir_separator=:
397
398         # Archives containing C++ object files must be created using
399         # the KAI C++ compiler.
400         old_archive_cmds='$CC -o $oldlib $oldobjs'
401         ;;
402       RCC)
403         # Rational C++ 2.4.1
404         # FIXME: insert proper C++ library support
405         ld_shlibs=no
406         ;;
407       cxx)
408         allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
409         archive_cmds='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
410         
411         hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
412         hardcode_libdir_separator=:
413
414         # Commands to make compiler produce verbose output that lists
415         # what "hidden" libraries, object files and flags are used when
416         # linking a shared library.
417         #
418         # There doesn't appear to be a way to prevent this compiler from
419         # explicitly linking system object files so we need to strip them
420         # from the output so that they don't get included in the library
421         # dependencies.
422         output_verbose_link_cmds='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | sed "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
423         ;;
424       *)
425         # FIXME: insert proper C++ library support
426         ld_shlibs=no
427         ;;
428     esac
429     ;;
430   psos*)
431     # FIXME: insert proper C++ library support
432     ld_shlibs=no
433     ;;
434   sco*)
435     case "$cc_basename" in
436       CC)
437         # FIXME: insert proper C++ library support
438         ld_shlibs=no
439         ;;
440       *)
441         # FIXME: insert proper C++ library support
442         ld_shlibs=no
443         ;;
444     esac
445     ;;
446   sunos4*)
447     case "$cc_basename" in
448       CC)
449         # Sun C++ 4.x
450         # FIXME: insert proper C++ library support
451         ld_shlibs=no
452         ;;
453       lcc)
454         # Lucid
455         # FIXME: insert proper C++ library support
456         ld_shlibs=no
457         ;;
458       *)
459         # FIXME: insert proper C++ library support
460         ld_shlibs=no
461         ;;
462     esac
463     ;;
464   solaris*)
465     case "$cc_basename" in
466       CC)
467         # Sun C++ 4.2, 5.x and Centerline C++
468         no_undefined_flag=' -ztext'
469         archive_cmds='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
470         archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
471         $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
472
473         hardcode_libdir_flag_spec='-R$libdir'
474         hardcode_shlibpath_var=no
475         case "$host_os" in
476           solaris2.[0-5] | solaris2.[0-5].*) ;;
477           *)
478             # The C++ compiler is used as linker so we must use $wl
479             # flag to pass the commands to the underlying system
480             # linker.
481             # Supported since Solaris 2.6 (maybe 2.5.1?)
482             whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
483             ;;
484         esac
485         link_all_deplibs=yes
486
487         # Commands to make compiler produce verbose output that lists
488         # what "hidden" libraries, object files and flags are used when
489         # linking a shared library.
490         #
491         # There doesn't appear to be a way to prevent this compiler from
492         # explicitly linking system object files so we need to strip them
493         # from the output so that they don't get included in the library
494         # dependencies.
495         output_verbose_link_cmds='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | egrep "\-R|\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
496
497         # Archives containing C++ object files must be created using
498         # "CC -xar", where "CC" is the Sun C++ compiler.  This is
499         # necessary to make sure instantiated templates are included
500         # in the archive.
501         old_archive_cmds='$CC -xar -o $oldlib $oldobjs'
502         ;;
503       gcx)
504         # Green Hills C++ Compiler
505         archive_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
506
507         # The C++ compiler must be used to create the archive.
508         old_archive_cmds='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
509         ;;
510       *)
511         # GNU C++ compiler with Solaris linker
512         if test "$with_gcc" = yes && test "$with_gnu_ld" = no; then
513           if $CC --version | egrep -v '^2\.7' > /dev/null; then
514             archive_cmds='$LD -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-h $wl$soname -o $lib'
515             archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
516                 $LD -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags~$rm $lib.exp'
517
518             # Commands to make compiler produce verbose output that lists
519             # what "hidden" libraries, object files and flags are used when
520             # linking a shared library.
521             output_verbose_link_cmds="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep \"\-L\""
522           else
523             # g++ 2.7 appears to require `-G' NOT `-shared' on this
524             # platform.
525             archive_cmds='$LD -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-h $wl$soname -o $lib'
526             archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
527                 $LD -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags~$rm $lib.exp'
528
529             # Commands to make compiler produce verbose output that lists
530             # what "hidden" libraries, object files and flags are used when
531             # linking a shared library.
532             output_verbose_link_cmds="$CC -G $CFLAGS -v conftest.$objext 2>&1 | egrep \"\-L\""
533           fi
534
535           hardcode_libdir_flag_spec='${wl}-R $wl$libdir'
536         fi
537         ;;
538     esac   
539     ;;
540   tandem*)
541     case "$cc_basename" in
542       NCC)
543         # NonStop-UX NCC 3.20
544         # FIXME: insert proper C++ library support
545         ld_shlibs=no
546         ;;
547       *)
548         # FIXME: insert proper C++ library support
549         ld_shlibs=no
550         ;;
551     esac   
552     ;;
553   unixware*)
554     # FIXME: insert proper C++ library support
555     ld_shlibs=no
556     ;;
557   vxworks*)
558     # FIXME: insert proper C++ library support
559     ld_shlibs=no
560     ;;
561   *)
562     # FIXME: insert proper C++ library support
563     ld_shlibs=no
564     ;;
565 esac
566
567
568 ## Compiler Characteristics: PIC flags, static flags, etc
569
570 # We don't use cached values here since only the C compiler
571 # characteristics should be cached.
572 ac_cv_prog_cc_pic=
573 ac_cv_prog_cc_shlib=
574 ac_cv_prog_cc_wl=
575 ac_cv_prog_cc_static=
576 ac_cv_prog_cc_no_builtin=
577 ac_cv_prog_cc_can_build_shared=$can_build_shared
578
579 ac_cv_prog_cc_pic_works=
580 ac_cv_prog_cc_static_works=
581
582 if test "$with_gcc" = yes; then
583   ac_cv_prog_cc_wl='-Wl,'
584   ac_cv_prog_cc_static='-static'
585
586   case "$host_os" in
587   beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
588     # PIC is the default for these OSes.
589     ;;
590   aix*)
591     # Below there is a dirty hack to force normal static linking with -ldl
592     # The problem is because libdl dynamically linked with both libc and
593     # libC (AIX C++ library), which obviously doesn't included in libraries
594     # list by gcc. This cause undefined symbols with -static flags.
595     # This hack allows C programs to be linked with "-static -ldl", but
596     # we not sure about C++ programs.
597     ac_cv_prog_cc_static="$ac_cv_prog_cc_static ${ac_cv_prog_cc_wl}-lC"
598     ;;
599   cygwin* | mingw* | os2*)
600     # This hack is so that the source file can tell whether it is being
601     # built for inclusion in a dll (and should export symbols for example).
602     ac_cv_prog_cc_pic='-DDLL_EXPORT'
603     ;;
604   amigaos*)
605     # FIXME: we need at least 68020 code to build shared libraries, but
606     # adding the `-m68020' flag to GCC prevents building anything better,
607     # like `-m68040'.
608     ac_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4'
609     ;;
610   sysv4*MP*)
611     if test -d /usr/nec; then
612       ac_cv_prog_cc_pic=-Kconform_pic
613     fi
614     ;;
615   *)
616     ac_cv_prog_cc_pic='-fPIC'
617     ;;
618   esac
619 else
620   case "$host_os" in
621     aix4*)
622       # All AIX code is PIC.
623       ;;
624     chorus*)
625       case "$cc_basename" in
626       cxch68)
627         # Green Hills C++ Compiler
628         # ac_cv_prog_cc_static="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
629         ;;
630       esac 
631       ;;
632     dgux*)
633       case "$cc_basename" in
634         ec++)
635           ac_cv_prog_cc_pic='-KPIC'
636           ;;
637         ghcx)
638           # Green Hills C++ Compiler
639           ac_cv_prog_cc_pic='-pic'
640           ;;
641         *)
642           ;;
643       esac
644       ;;
645     freebsd*)
646       # FreeBSD uses GNU C++
647       ;;
648     hpux9* | hpux10* | hpux11*)
649       case "$cc_basename" in
650         CC)
651           ac_cv_prog_cc_wl='-Wl,'
652           ac_cv_prog_cc_static="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
653           ac_cv_prog_cc_pic='+Z'
654           ;;
655         aCC)
656           ac_cv_prog_cc_wl='-Wl,'
657           ac_cv_prog_cc_static="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
658           ac_cv_prog_cc_pic='+Z'
659           ;;
660         *)
661           ;;
662       esac
663       ;;
664     irix5* | irix6*)
665       case "$cc_basename" in
666         CC)
667           ac_cv_prog_cc_wl='-Wl,'
668           ac_cv_prog_cc_static='-non_shared'
669           ac_cv_prog_cc_pic='-KPIC'
670           ;;
671         *)
672           ;;
673       esac
674       ;;
675     linux*)
676       case "$cc_basename" in
677         KCC)
678           # KAI C++ Compiler
679           ac_cv_prog_cc_wl='--backend -Wl,'
680           ac_cv_prog_cc_pic='-fPIC'
681           ;;
682         cxx)
683           # Compaq C++
684           # Make sure the PIC flag is empty.  It appears that all Alpha
685           # Linux and Compaq Tru64 Unix objects are PIC.
686           ac_cv_prog_cc_pic=
687           ac_cv_prog_cc_static='-non_shared'
688           ;;
689         *)
690           ;;
691       esac
692       ;;
693     lynxos*)
694       ;;
695     m88k*)
696       ;;
697     mvs*)
698       case "$cc_basename" in
699         cxx)
700           ac_cv_prog_cc_pic='-W c,exportall'
701           ;;
702         *)
703           ;;
704       esac   
705       ;;
706     netbsd*)
707       ;;
708     osf3* | osf4* | osf5*)
709       case "$cc_basename" in
710         KCC)
711           ac_cv_prog_cc_wl='--backend -Wl,'
712           ;;
713         RCC)
714           # Rational C++ 2.4.1
715           ac_cv_prog_cc_pic='-pic'
716           ;;
717         cxx)
718           # Digital/Compaq C++
719           ac_cv_prog_cc_wl='-Wl,'
720           # Make sure the PIC flag is empty.  It appears that all Alpha
721           # Linux and Compaq Tru64 Unix objects are PIC.
722           ac_cv_prog_cc_pic=
723           ac_cv_prog_cc_static='-non_shared'
724           ;;
725         *)
726           ;;
727       esac
728       ;;
729     psos*)
730       ;;
731     sco*)
732       case "$cc_basename" in
733         CC)
734           ac_cv_prog_cc_pic='-fPIC'
735           ;;
736         *)
737           ;;
738       esac
739       ;;
740     solaris*)
741       case "$cc_basename" in
742         CC)
743           # Sun C++ 4.2, 5.x and Centerline C++
744           ac_cv_prog_cc_pic='-KPIC'
745           ac_cv_prog_cc_static='-Bstatic'
746           ac_cv_prog_cc_wl='-Qoption ld '
747           ;;
748         gcx)
749           # Green Hills C++ Compiler
750           ac_cv_prog_cc_pic='-PIC'
751           ;;
752         *)
753           ;;
754       esac   
755       ;;
756     sunos4*)
757       case "$cc_basename" in
758         CC)
759           # Sun C++ 4.x
760           ac_cv_prog_cc_pic='-pic'
761           ac_cv_prog_cc_static='-Bstatic'
762           ;;
763         lcc)
764           # Lucid
765           ac_cv_prog_cc_pic='-pic'
766           ;;
767         *)
768           ;;
769       esac
770       ;;
771     tandem*)
772       case "$cc_basename" in
773         NCC)
774           # NonStop-UX NCC 3.20
775           ac_cv_prog_cc_pic='-KPIC'
776           ;;
777         *)
778           ;;
779       esac   
780       ;;
781     unixware*)
782       ;;
783     vxworks*)
784       ;;
785     *)
786       ac_cv_prog_cc_can_build_shared=no
787       ;;
788   esac
789 fi
790 ac_cv_prog_cc_pic="$ac_cv_prog_cc_pic -DPIC"
791
792
793 # Figure out "hidden" C++ library dependencies from verbose
794 # compiler output whening linking a shared library.
795 cat > conftest.$ac_ext <<EOF
796 class Foo
797 {
798 public:
799   Foo (void) { a = 0; }
800 private:
801   int a;
802 };
803 EOF
804
805
806 if (eval $ac_compile) 2>&5; then
807   # Parse the compiler output and extract the necessary
808   # objects, libraries and library flags.
809
810   # Sentinel used to keep track of whether or not we are before
811   # the conftest object file.
812   pre_test_object_deps_done=no
813
814   for p in `eval $output_verbose_link_cmds`; do
815
816     case $p in
817
818     -L* | -R* | -l*)
819        # Some compilers place space between "-{L,R}" and the path.
820        # Remove the space.
821        if test $p = "-L" \
822           || test $p = "-R"; then
823          prev=$p
824          continue
825        else
826          prev=
827        fi
828
829        if test "$pre_test_object_deps_done" = no; then
830          case $p in
831          -L* | -R*)
832            # Internal compiler library paths should come after those
833            # provided the user.  The postdeps already come after the
834            # user supplied libs so there is no need to process them.
835            if test -z "$compiler_lib_search_path"; then
836              compiler_lib_search_path="${prev}${p}"
837            else
838              compiler_lib_search_path="${compiler_lib_search_path} ${prev}${p}"
839            fi
840            ;;
841          # The "-l" case would never come before the object being
842          # linked, so don't bother handling this case.
843          esac
844        else
845          if test -z "$postdeps"; then
846            postdeps="${prev}${p}"
847          else
848            postdeps="${postdeps} ${prev}${p}"
849          fi
850        fi
851        ;;
852
853     *.$objext)
854        # This assumes that the test object file only shows up
855        # once in the compiler output.
856        if test "$p" = "conftest.$objext"; then
857          pre_test_object_deps_done=yes
858          continue
859        fi
860
861        if test "$pre_test_object_deps_done" = no; then
862          if test -z "$predep_objects"; then
863            predep_objects="$p"
864          else
865            predep_objects="$predep_objects $p"
866          fi
867        else
868          if test -z "$postdep_objects"; then
869            postdep_objects="$p"
870          else
871            postdep_objects="$postdep_objects $p"
872          fi
873        fi
874        ;;
875
876     *) ;; # Ignore the rest.
877
878     esac
879   done
880
881   # Clean up.
882   rm -f a.out
883 else
884   echo "ltcf-cxx.sh: error: problem compiling test program"
885 fi
886
887 $rm -f confest.$objext
888
889 case " $postdeps " in
890 *" -lc "*) need_lc=no ;;
891 *) need_lc=yes ;;
892 esac