OSDN Git Service

update copyrights
[pf3gnuchains/gcc-fork.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 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   aix4*)
138     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'
139     # -bexpall does not export symbols beginning with underscore (_)
140     always_export_symbols=yes
141     # Exported symbols can be pulled into shared objects from archives
142     whole_archive_flag_spec=' '
143     build_libtool_need_lc=yes
144     ;;
145   chorus*)
146     case "$cc_basename" in
147       *)
148         # FIXME: insert proper C++ library support
149         ld_shlibs=no
150         ;;
151     esac 
152     ;;
153   dgux*)
154     case "$cc_basename" in
155       ec++)
156         # FIXME: insert proper C++ library support
157         ld_shlibs=no
158         ;;
159       ghcx)
160         # Green Hills C++ Compiler
161         # FIXME: insert proper C++ library support
162         ld_shlibs=no
163         ;;
164       *)
165         # FIXME: insert proper C++ library support
166         ld_shlibs=no
167         ;;
168     esac
169     ;;
170   freebsd[12]*)
171     # C++ shared libraries reported to be fairly broken before switch to ELF
172     ld_shlibs=no
173     ;;
174   freebsd*)
175     # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
176     # conventions
177     ld_shlibs=yes
178     ;;
179   hpux*)
180     case "$cc_basename" in
181       CC)
182         # FIXME: insert proper C++ library support
183         ld_shlibs=no
184         ;;
185       aCC)
186         case "$host_os" in
187         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' ;;
188         *) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;;
189         esac
190         hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
191         hardcode_libdir_separator=:
192         hardcode_direct=yes
193         hardcode_minus_L=yes # Not in the search PATH, but as the default
194                              # location of the library.
195         export_dynamic_flag_spec='${wl}-E'
196
197         # Commands to make compiler produce verbose output that lists
198         # what "hidden" libraries, object files and flags are used when
199         # linking a shared library.
200         #
201         # There doesn't appear to be a way to prevent this compiler from
202         # explicitly linking system object files so we need to strip them
203         # from the output so that they don't get included in the library
204         # dependencies.
205         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'
206         ;;
207       *)
208         # FIXME: insert proper C++ library support
209         ld_shlibs=no
210         ;;
211     esac
212     ;;
213   irix5* | irix6*)
214     case "$cc_basename" in
215       CC)
216         # SGI C++
217         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'
218
219         # Archives containing C++ object files must be created using
220         # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
221         # necessary to make sure instantiated templates are included
222         # in the archive.
223         old_archive_cmds='$CC -ar -WR,-u -o $oldlib $oldobjs'
224         ;;
225       *)
226         if test "$with_gcc" = yes; then
227           if test "$with_gnu_ld" = no; then
228             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'
229           else
230             archive_cmds='$LD -shared $predep_objects $libobjs $deplibs $postdep_objects $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -o $lib'
231           fi
232         fi
233         hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
234         hardcode_libdir_separator=:
235         link_all_deplibs=yes
236         ;;
237     esac
238     ;;
239   linux*)
240     case "$cc_basename" in
241       KCC)
242         # Kuck and Associates, Inc. (KAI) C++ Compiler
243
244         # KCC will only create a shared library if the output file
245         # ends with ".so" (or ".sl" for HP-UX), so rename the library
246         # to its proper name (with version) after linking.
247         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'
248         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'
249
250         # Commands to make compiler produce verbose output that lists
251         # what "hidden" libraries, object files and flags are used when
252         # linking a shared library.
253         #
254         # There doesn't appear to be a way to prevent this compiler from
255         # explicitly linking system object files so we need to strip them
256         # from the output so that they don't get included in the library
257         # dependencies.
258         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'
259
260         hardcode_libdir_flag_spec='${wl}--rpath,$libdir'
261         export_dynamic_flag_spec='${wl}--export-dynamic'
262
263         # Archives containing C++ object files must be created using
264         # "CC -Bstatic", where "CC" is the KAI C++ compiler.
265         old_archive_cmds='$CC -Bstatic -o $oldlib $oldobjs'
266         ;;
267       cxx)
268         # Compaq C++
269         archive_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
270         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'
271
272         runpath_var=LD_RUN_PATH
273         hardcode_libdir_flag_spec='-rpath $libdir'
274         hardcode_libdir_separator=:
275
276         # Commands to make compiler produce verbose output that lists
277         # what "hidden" libraries, object files and flags are used when
278         # linking a shared library.
279         #
280         # There doesn't appear to be a way to prevent this compiler from
281         # explicitly linking system object files so we need to strip them
282         # from the output so that they don't get included in the library
283         # dependencies.
284         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'
285         ;;
286     esac
287     ;;
288   lynxos*)
289     # FIXME: insert proper C++ library support
290     ld_shlibs=no
291     ;;
292   m88k*)
293     # FIXME: insert proper C++ library support
294     ld_shlibs=no
295     ;;
296   mvs*)
297     case "$cc_basename" in
298       cxx)
299         # FIXME: insert proper C++ library support
300         ld_shlibs=no
301         ;;
302       *)
303         # FIXME: insert proper C++ library support
304         ld_shlibs=no
305         ;;
306     esac   
307     ;;
308   netbsd*)
309     # NetBSD uses g++ - do we need to do anything?
310     ;;
311   osf3*)
312     if test "$with_gcc" = yes && test "$with_gnu_ld" = no; then
313       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
314       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'
315
316       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
317       hardcode_libdir_separator=:
318
319       # Commands to make compiler produce verbose output that lists
320       # what "hidden" libraries, object files and flags are used when
321       # linking a shared library.
322       output_verbose_link_cmds='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"'
323     fi
324
325     case "$cc_basename" in
326       KCC)
327         # Kuck and Associates, Inc. (KAI) C++ Compiler
328
329         # KCC will only create a shared library if the output file
330         # ends with ".so" (or ".sl" for HP-UX), so rename the library
331         # to its proper name (with version) after linking.
332         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'
333
334         hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
335         hardcode_libdir_separator=:
336
337         # Archives containing C++ object files must be created using
338         # "CC -Bstatic", where "CC" is the KAI C++ compiler.
339         old_archive_cmds='$CC -Bstatic -o $oldlib $oldobjs'
340
341         ;;
342       RCC)
343         # Rational C++ 2.4.1
344         # FIXME: insert proper C++ library support
345         ld_shlibs=no
346         ;;
347       cxx)
348         allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
349         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'
350
351         hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
352         hardcode_libdir_separator=:
353
354         # Commands to make compiler produce verbose output that lists
355         # what "hidden" libraries, object files and flags are used when
356         # linking a shared library.
357         #
358         # There doesn't appear to be a way to prevent this compiler from
359         # explicitly linking system object files so we need to strip them
360         # from the output so that they don't get included in the library
361         # dependencies.
362         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'
363         ;;
364       *)
365         # FIXME: insert proper C++ library support
366         ld_shlibs=no
367         ;;
368     esac
369     ;;
370   osf4* | osf5*)
371     if test "$with_gcc" = yes && test "$with_gnu_ld" = no; then
372       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
373       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'
374
375       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
376       hardcode_libdir_separator=:
377
378       # Commands to make compiler produce verbose output that lists
379       # what "hidden" libraries, object files and flags are used when
380       # linking a shared library.
381       output_verbose_link_cmds='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"'
382     fi
383
384     case "$cc_basename" in
385       KCC)
386         # Kuck and Associates, Inc. (KAI) C++ Compiler
387
388         # KCC will only create a shared library if the output file
389         # ends with ".so" (or ".sl" for HP-UX), so rename the library
390         # to its proper name (with version) after linking.
391         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'
392
393         hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
394         hardcode_libdir_separator=:
395
396         # Archives containing C++ object files must be created using
397         # the KAI C++ compiler.
398         old_archive_cmds='$CC -o $oldlib $oldobjs'
399         ;;
400       RCC)
401         # Rational C++ 2.4.1
402         # FIXME: insert proper C++ library support
403         ld_shlibs=no
404         ;;
405       cxx)
406         allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
407         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'
408         
409         hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
410         hardcode_libdir_separator=:
411
412         # Commands to make compiler produce verbose output that lists
413         # what "hidden" libraries, object files and flags are used when
414         # linking a shared library.
415         #
416         # There doesn't appear to be a way to prevent this compiler from
417         # explicitly linking system object files so we need to strip them
418         # from the output so that they don't get included in the library
419         # dependencies.
420         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'
421         ;;
422       *)
423         # FIXME: insert proper C++ library support
424         ld_shlibs=no
425         ;;
426     esac
427     ;;
428   psos*)
429     # FIXME: insert proper C++ library support
430     ld_shlibs=no
431     ;;
432   sco*)
433     case "$cc_basename" in
434       CC)
435         # FIXME: insert proper C++ library support
436         ld_shlibs=no
437         ;;
438       *)
439         # FIXME: insert proper C++ library support
440         ld_shlibs=no
441         ;;
442     esac
443     ;;
444   sunos4*)
445     case "$cc_basename" in
446       CC)
447         # Sun C++ 4.x
448         # FIXME: insert proper C++ library support
449         ld_shlibs=no
450         ;;
451       lcc)
452         # Lucid
453         # FIXME: insert proper C++ library support
454         ld_shlibs=no
455         ;;
456       *)
457         # FIXME: insert proper C++ library support
458         ld_shlibs=no
459         ;;
460     esac
461     ;;
462   solaris*)
463     case "$cc_basename" in
464       CC)
465         # Sun C++ 4.2, 5.x and Centerline C++
466         no_undefined_flag=' -ztext'
467         archive_cmds='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
468         archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
469         $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'
470
471         hardcode_libdir_flag_spec='-R$libdir'
472         hardcode_shlibpath_var=no
473         case "$host_os" in
474           solaris2.[0-5] | solaris2.[0-5].*) ;;
475           *)
476             # The C++ compiler is used as linker so we must use $wl
477             # flag to pass the commands to the underlying system
478             # linker.
479             # Supported since Solaris 2.6 (maybe 2.5.1?)
480             whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
481             ;;
482         esac
483         link_all_deplibs=yes
484
485         # Commands to make compiler produce verbose output that lists
486         # what "hidden" libraries, object files and flags are used when
487         # linking a shared library.
488         #
489         # There doesn't appear to be a way to prevent this compiler from
490         # explicitly linking system object files so we need to strip them
491         # from the output so that they don't get included in the library
492         # dependencies.
493         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'
494
495         # Archives containing C++ object files must be created using
496         # "CC -xar", where "CC" is the Sun C++ compiler.  This is
497         # necessary to make sure instantiated templates are included
498         # in the archive.
499         old_archive_cmds='$CC -xar -o $oldlib $oldobjs'
500         ;;
501       gcx)
502         # Green Hills C++ Compiler
503         archive_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
504
505         # The C++ compiler must be used to create the archive.
506         old_archive_cmds='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
507         ;;
508       *)
509         # GNU C++ compiler with Solaris linker
510         if test "$with_gcc" = yes && test "$with_gnu_ld" = no; then
511           if $CC --version | egrep -v '^2\.7' > /dev/null; then
512             archive_cmds='$LD -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-h $wl$soname -o $lib'
513             archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
514                 $LD -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags~$rm $lib.exp'
515
516             # Commands to make compiler produce verbose output that lists
517             # what "hidden" libraries, object files and flags are used when
518             # linking a shared library.
519             output_verbose_link_cmds="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep \"\-L\""
520           else
521             # g++ 2.7 appears to require `-G' NOT `-shared' on this
522             # platform.
523             archive_cmds='$LD -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-h $wl$soname -o $lib'
524             archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
525                 $LD -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags~$rm $lib.exp'
526
527             # Commands to make compiler produce verbose output that lists
528             # what "hidden" libraries, object files and flags are used when
529             # linking a shared library.
530             output_verbose_link_cmds="$CC -G $CFLAGS -v conftest.$objext 2>&1 | egrep \"\-L\""
531           fi
532
533           hardcode_libdir_flag_spec='${wl}-R $wl$libdir'
534         fi
535         ;;
536     esac   
537     ;;
538   tandem*)
539     case "$cc_basename" in
540       NCC)
541         # NonStop-UX NCC 3.20
542         # FIXME: insert proper C++ library support
543         ld_shlibs=no
544         ;;
545       *)
546         # FIXME: insert proper C++ library support
547         ld_shlibs=no
548         ;;
549     esac   
550     ;;
551   unixware*)
552     # FIXME: insert proper C++ library support
553     ld_shlibs=no
554     ;;
555   vxworks*)
556     # FIXME: insert proper C++ library support
557     ld_shlibs=no
558     ;;
559   *)
560     # FIXME: insert proper C++ library support
561     ld_shlibs=no
562     ;;
563 esac
564
565
566 ## Compiler Characteristics: PIC flags, static flags, etc
567
568 # We don't use cached values here since only the C compiler
569 # characteristics should be cached.
570 ac_cv_prog_cc_pic=
571 ac_cv_prog_cc_shlib=
572 ac_cv_prog_cc_wl=
573 ac_cv_prog_cc_static=
574 ac_cv_prog_cc_no_builtin=
575 ac_cv_prog_cc_can_build_shared=$can_build_shared
576
577 # It is not enough to reset these cached values, they must be unset.
578 unset ac_cv_prog_cc_pic_works
579 unset ac_cv_prog_cc_static_works
580
581 if test "$with_gcc" = yes; then
582   ac_cv_prog_cc_wl='-Wl,'
583   ac_cv_prog_cc_static='-static'
584
585   case "$host_os" in
586   beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
587     # PIC is the default for these OSes.
588     ;;
589   aix*)
590     # Below there is a dirty hack to force normal static linking with -ldl
591     # The problem is because libdl dynamically linked with both libc and
592     # libC (AIX C++ library), which obviously doesn't included in libraries
593     # list by gcc. This cause undefined symbols with -static flags.
594     # This hack allows C programs to be linked with "-static -ldl", but
595     # we not sure about C++ programs.
596     ac_cv_prog_cc_static="$ac_cv_prog_cc_static ${ac_cv_prog_cc_wl}-lC"
597     ;;
598   *djgpp*)
599     # DJGPP does not support shared libraries at all
600     ac_cv_prog_cc_pic=
601     ;;
602   cygwin* | mingw* | os2*)
603     # This hack is so that the source file can tell whether it is being
604     # built for inclusion in a dll (and should export symbols for example).
605     ac_cv_prog_cc_pic='-DDLL_EXPORT'
606     ;;
607   amigaos*)
608     # FIXME: we need at least 68020 code to build shared libraries, but
609     # adding the `-m68020' flag to GCC prevents building anything better,
610     # like `-m68040'.
611     ac_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4'
612     ;;
613   sysv4*MP*)
614     if test -d /usr/nec; then
615       ac_cv_prog_cc_pic=-Kconform_pic
616     fi
617     ;;
618   *)
619     ac_cv_prog_cc_pic='-fPIC'
620     ;;
621   esac
622 else
623   case "$host_os" in
624     aix4*)
625       # All AIX code is PIC.
626       ;;
627     chorus*)
628       case "$cc_basename" in
629       cxch68)
630         # Green Hills C++ Compiler
631         # 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"
632         ;;
633       esac 
634       ;;
635     dgux*)
636       case "$cc_basename" in
637         ec++)
638           ac_cv_prog_cc_pic='-KPIC'
639           ;;
640         ghcx)
641           # Green Hills C++ Compiler
642           ac_cv_prog_cc_pic='-pic'
643           ;;
644         *)
645           ;;
646       esac
647       ;;
648     freebsd*)
649       # FreeBSD uses GNU C++
650       ;;
651     hpux9* | hpux10* | hpux11*)
652       case "$cc_basename" in
653         CC)
654           ac_cv_prog_cc_wl='-Wl,'
655           ac_cv_prog_cc_static="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
656           ac_cv_prog_cc_pic='+Z'
657           ;;
658         aCC)
659           ac_cv_prog_cc_wl='-Wl,'
660           ac_cv_prog_cc_static="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
661           ac_cv_prog_cc_pic='+Z'
662           ;;
663         *)
664           ;;
665       esac
666       ;;
667     irix5* | irix6*)
668       case "$cc_basename" in
669         CC)
670           ac_cv_prog_cc_wl='-Wl,'
671           ac_cv_prog_cc_static='-non_shared'
672           ac_cv_prog_cc_pic='-KPIC'
673           ;;
674         *)
675           ;;
676       esac
677       ;;
678     linux*)
679       case "$cc_basename" in
680         KCC)
681           # KAI C++ Compiler
682           ac_cv_prog_cc_wl='--backend -Wl,'
683           ac_cv_prog_cc_pic='-fPIC'
684           ;;
685         cxx)
686           # Compaq C++
687           # Make sure the PIC flag is empty.  It appears that all Alpha
688           # Linux and Compaq Tru64 Unix objects are PIC.
689           ac_cv_prog_cc_pic=
690           ac_cv_prog_cc_static='-non_shared'
691           ;;
692         *)
693           ;;
694       esac
695       ;;
696     lynxos*)
697       ;;
698     m88k*)
699       ;;
700     mvs*)
701       case "$cc_basename" in
702         cxx)
703           ac_cv_prog_cc_pic='-W c,exportall'
704           ;;
705         *)
706           ;;
707       esac   
708       ;;
709     netbsd*)
710       ;;
711     osf3* | osf4* | osf5*)
712       case "$cc_basename" in
713         KCC)
714           ac_cv_prog_cc_wl='--backend -Wl,'
715           ;;
716         RCC)
717           # Rational C++ 2.4.1
718           ac_cv_prog_cc_pic='-pic'
719           ;;
720         cxx)
721           # Digital/Compaq C++
722           ac_cv_prog_cc_wl='-Wl,'
723           # Make sure the PIC flag is empty.  It appears that all Alpha
724           # Linux and Compaq Tru64 Unix objects are PIC.
725           ac_cv_prog_cc_pic=
726           ac_cv_prog_cc_static='-non_shared'
727           ;;
728         *)
729           ;;
730       esac
731       ;;
732     psos*)
733       ;;
734     sco*)
735       case "$cc_basename" in
736         CC)
737           ac_cv_prog_cc_pic='-fPIC'
738           ;;
739         *)
740           ;;
741       esac
742       ;;
743     solaris*)
744       case "$cc_basename" in
745         CC)
746           # Sun C++ 4.2, 5.x and Centerline C++
747           ac_cv_prog_cc_pic='-KPIC'
748           ac_cv_prog_cc_static='-Bstatic'
749           ac_cv_prog_cc_wl='-Qoption ld '
750           ;;
751         gcx)
752           # Green Hills C++ Compiler
753           ac_cv_prog_cc_pic='-PIC'
754           ;;
755         *)
756           ;;
757       esac   
758       ;;
759     sunos4*)
760       case "$cc_basename" in
761         CC)
762           # Sun C++ 4.x
763           ac_cv_prog_cc_pic='-pic'
764           ac_cv_prog_cc_static='-Bstatic'
765           ;;
766         lcc)
767           # Lucid
768           ac_cv_prog_cc_pic='-pic'
769           ;;
770         *)
771           ;;
772       esac
773       ;;
774     tandem*)
775       case "$cc_basename" in
776         NCC)
777           # NonStop-UX NCC 3.20
778           ac_cv_prog_cc_pic='-KPIC'
779           ;;
780         *)
781           ;;
782       esac   
783       ;;
784     unixware*)
785       ;;
786     vxworks*)
787       ;;
788     *)
789       ac_cv_prog_cc_can_build_shared=no
790       ;;
791   esac
792 fi
793
794 case "$host_os" in
795     # Platforms which do not suport PIC and -DPIC is meaningless
796     # on them:
797     *djgpp*)
798       ac_cv_prog_cc_pic=
799       ;;
800     *)
801       ac_cv_prog_cc_pic="$ac_cv_prog_cc_pic -DPIC"
802       ;;
803 esac
804
805
806 # Figure out "hidden" C++ library dependencies from verbose
807 # compiler output whening linking a shared library.
808 cat > conftest.$ac_ext <<EOF
809 class Foo
810 {
811 public:
812   Foo (void) { a = 0; }
813 private:
814   int a;
815 };
816 EOF
817
818
819 if eval $ac_compile 2>&5; then
820   # Parse the compiler output and extract the necessary
821   # objects, libraries and library flags.
822
823   # Sentinel used to keep track of whether or not we are before
824   # the conftest object file.
825   pre_test_object_deps_done=no
826
827   for p in `eval $output_verbose_link_cmds`; do
828
829     case $p in
830
831     -L* | -R* | -l*)
832        # Some compilers place space between "-{L,R}" and the path.
833        # Remove the space.
834        if test $p = "-L" \
835           || test $p = "-R"; then
836          prev=$p
837          continue
838        else
839          prev=
840        fi
841
842        if test "$pre_test_object_deps_done" = no; then
843          case $p in
844          -L* | -R*)
845            # Internal compiler library paths should come after those
846            # provided the user.  The postdeps already come after the
847            # user supplied libs so there is no need to process them.
848            if test -z "$compiler_lib_search_path"; then
849              compiler_lib_search_path="${prev}${p}"
850            else
851              compiler_lib_search_path="${compiler_lib_search_path} ${prev}${p}"
852            fi
853            ;;
854          # The "-l" case would never come before the object being
855          # linked, so don't bother handling this case.
856          esac
857        else
858          if test -z "$postdeps"; then
859            postdeps="${prev}${p}"
860          else
861            postdeps="${postdeps} ${prev}${p}"
862          fi
863        fi
864        ;;
865
866     *.$objext)
867        # This assumes that the test object file only shows up
868        # once in the compiler output.
869        if test "$p" = "conftest.$objext"; then
870          pre_test_object_deps_done=yes
871          continue
872        fi
873
874        if test "$pre_test_object_deps_done" = no; then
875          if test -z "$predep_objects"; then
876            predep_objects="$p"
877          else
878            predep_objects="$predep_objects $p"
879          fi
880        else
881          if test -z "$postdep_objects"; then
882            postdep_objects="$p"
883          else
884            postdep_objects="$postdep_objects $p"
885          fi
886        fi
887        ;;
888
889     *) ;; # Ignore the rest.
890
891     esac
892   done
893
894   # Clean up.
895   rm -f a.out
896 else
897   echo "ltcf-cxx.sh: error: problem compiling test program"
898 fi
899
900 $rm -f confest.$objext
901
902 case " $postdeps " in
903 *" -lc "*) need_lc=no ;;
904 *) need_lc=yes ;;
905 esac