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