From aa9a2796703fc487bb8a44f6a7fe6e7b85a3af3c Mon Sep 17 00:00:00 2001 From: Ossama Othman Date: Tue, 8 Feb 2000 18:47:30 +0000 Subject: [PATCH] * ltcf-cxx.sh (predeps, postdeps, predep_objects, postdep_objects): Split {pre,post}deps into a variable that hold library dependencies and another that holds objects needed during shared library generation. This was needed so that the objects needed for shared library generation do not get analyzed by the ILD mechanism. The objects are only used during the initial creation of the shared library, not during subsequent links to that library. (archive_cmds, archive_expsym_cmds): Added $predep_objects before all objects and libraries, and $postdep_objects after them. This is necessary when linking C++ shared libraries. (output_verbose_link_cmds): Added shared library generation compiler flag. The objects and libraries the compiler links when creating shared libraries may be different than those used when linking programs, particulary for object files. * ltconfig.in (predep_objects, postdep_objects): Include these variables in the generated libtool script. * ltmain.in: Quote regular expression used for automatic tagged configuration selection. Also improved the regular expression used for matching. Updated clean mode to work properly with the new `.lo' files. (libs): Only add $predeps and $postdeps to the list of dependency libraries when linking a library. * tagdemo/Makefile.am (noinst_LTLIBRARIES): Added another test library that depends on the existing test library. It was added to exercise the ILD mechanism when using tagged configurations. (tagdemo_LDADD): The tagdemo program now depends on the new test library. Since the new test library depends on the previous one, the previous library should be linked to the program as well. * Makefile.in: Regenerated from updated Makefile.am. * tagdemo/baz.cpp, tagdemo/baz.h: Added these sources. They are new test library sources. * tagdemo/main.cpp (main): Added call to method in new test library. --- ChangeLog | 37 +++++++ ltcf-cxx.sh | 241 ++++++++++++++++++++++++-------------------- ltconfig.in | 18 +++- ltmain.in | 40 ++++++-- tagdemo/Makefile.am | 10 +- tagdemo/Makefile.in | 22 ++-- tagdemo/baz.cpp | 35 +++++++ tagdemo/baz.h | 43 ++++++++ tagdemo/main.cpp | 15 +++ 9 files changed, 331 insertions(+), 130 deletions(-) create mode 100644 tagdemo/baz.cpp create mode 100644 tagdemo/baz.h diff --git a/ChangeLog b/ChangeLog index 7af264664..06ba690c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2000-02-08 Ossama Othman + + * ltcf-cxx.sh (predeps, postdeps, predep_objects, + postdep_objects): Split {pre,post}deps into a variable that hold + library dependencies and another that holds objects needed during + shared library generation. This was needed so that the objects + needed for shared library generation do not get analyzed by the + ILD mechanism. The objects are only used during the initial + creation of the shared library, not during subsequent links to + that library. + (archive_cmds, archive_expsym_cmds): Added $predep_objects before + all objects and libraries, and $postdep_objects after them. This + is necessary when linking C++ shared libraries. + (output_verbose_link_cmds): Added shared library generation + compiler flag. The objects and libraries the compiler links when + creating shared libraries may be different than those used when + linking programs, particulary for object files. + * ltconfig.in (predep_objects, postdep_objects): Include these + variables in the generated libtool script. + * ltmain.in: Quote regular expression used for automatic tagged + configuration selection. Also improved the regular expression + used for matching. + Updated clean mode to work properly with the new `.lo' files. + (libs): Only add $predeps and $postdeps to the list of dependency + libraries when linking a library. + * tagdemo/Makefile.am (noinst_LTLIBRARIES): Added another test + library that depends on the existing test library. It was added + to exercise the ILD mechanism when using tagged configurations. + (tagdemo_LDADD): The tagdemo program now depends on the new test + library. Since the new test library depends on the previous one, + the previous library should be linked to the program as well. + * Makefile.in: Regenerated from updated Makefile.am. + * tagdemo/baz.cpp, tagdemo/baz.h: Added these sources. They are + new test library sources. + * tagdemo/main.cpp (main): Added call to method in new test + library. + 2000-02-05 Ossama Othman * ltmain.in: The "-R*" case in the loop that iterates through diff --git a/ltcf-cxx.sh b/ltcf-cxx.sh index 9f06f0a70..44e2c2175 100644 --- a/ltcf-cxx.sh +++ b/ltcf-cxx.sh @@ -131,8 +131,8 @@ case "$host_os" in ;; aCC) case "$host_os" in - hpux9*) archive_cmds='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; - *) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; + hpux9*) archive_cmds='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; + *) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' ;; esac hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: @@ -143,13 +143,13 @@ case "$host_os" in # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when - # linking. + # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmds='templist=`($CC $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' + 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' ;; *) # FIXME: insert proper C++ library support @@ -161,13 +161,13 @@ case "$host_os" in case "$CXX" in CC) # SGI C++ - archive_cmds='$CC -shared -all -multigot $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + 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' ;; *) if test "$with_gcc" = yes; then - archive_cmds='$CC -shared $libobjs $deplibs $linker_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -update_registry ${objdir}/so_locations -o $lib' + archive_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -update_registry ${objdir}/so_locations -o $lib' else - archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -o $lib' + archive_cmds='$LD -shared $predep_objects $libobjs $deplibs $postdep_objects $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -o $lib' fi hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: @@ -184,8 +184,8 @@ case "$host_os" in ;; cxx) # Compaq C++ - archive_cmds='$CC -shared $libobjs $deplibs $linker_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared $libobjs $deplibs $linker_flags ${wl}-retain-symbols-file $wl$export_symbols' + archive_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='-rpath $libdir' @@ -193,19 +193,19 @@ case "$host_os" in # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when - # linking. + # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmds='templist=`$CC $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' + 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' ;; *) # GNU C++ compiler if test "$with_gcc" = yes; then - archive_cmds='$CC -shared -nostdlib $predeps $libobjs $deplibs $postdeps $compiler_flags ${wl}-soname $wl$soname -o $lib' - archive_expsym_cmds='$CC -shared -nostdlib $predeps $libobjs $deplibs $postdeps $compiler_flags ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + archive_cmds='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file $wl$export_symbols -o $lib' runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' @@ -222,8 +222,8 @@ case "$host_os" in # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when - # linking. - output_verbose_link_cmds='$CC $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"' + # linking a shared library. + output_verbose_link_cmds='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"' fi ;; esac @@ -255,15 +255,15 @@ case "$host_os" in osf3*) if test "$with_gcc" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared -nostdlib ${allow_undefined_flag} $predeps $libobjs $deplibs $postdeps $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + 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' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when - # linking. - output_verbose_link_cmds='$CC $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"' + # linking a shared library. + output_verbose_link_cmds='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"' fi case "$CXX" in @@ -279,20 +279,20 @@ case "$host_os" in ;; cxx) allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $predeps $libobjs $deplibs $postdeps $linker_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + archive_cmds='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when - # linking. + # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmds='templist=`$CC $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' + 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' ;; *) # FIXME: insert proper C++ library support @@ -303,15 +303,15 @@ case "$host_os" in osf4* | osf5*) if test "$with_gcc" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared -nostdlib ${allow_undefined_flag} $predeps $libobjs $deplibs $postdeps $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' + 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' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when - # linking. - output_verbose_link_cmds='$CC $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"' + # linking a shared library. + output_verbose_link_cmds='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep "\-L"' fi case "$CXX" in @@ -327,20 +327,20 @@ case "$host_os" in ;; cxx) allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' - archive_cmds='$CC -shared${allow_undefined_flag} $predeps $libobjs $deplibs $postdeps $linker_flags ${wl}-msym ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + archive_cmds='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-msym ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when - # linking. + # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmds='templist=`$CC $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' + 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' ;; *) # FIXME: insert proper C++ library support @@ -387,9 +387,9 @@ case "$host_os" in CC) # Sun C++ 4.2, 5.x and Centerline C++ no_undefined_flag=' -ztext' - archive_cmds='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predeps $libobjs $deplibs $postdeps $linker_flags' + archive_cmds='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predeps $libobjs $deplibs $postdeps $linker_flags~$rm $lib.exp' + $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags~$rm $lib.exp' hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no @@ -407,13 +407,13 @@ case "$host_os" in # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when - # linking. + # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmds='templist=`$CC $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' + 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' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is @@ -423,7 +423,7 @@ case "$host_os" in ;; gcx) # Green Hills C++ Compiler - archive_cmds='$CC -shared $libobjs $deplibs $linker_flags ${wl}-h $wl$soname -o $lib' + archive_cmds='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $linker_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. old_archive_cmds='$CC $LDFLAGS -archive -o $oldlib $oldobjs' @@ -432,23 +432,28 @@ case "$host_os" in # GNU C++ compiler if test "$with_gcc" = yes; then if $CXX --version | egrep -v '^2\.7' > /dev/null; then - archive_cmds='$LD -shared -nostdlib $LDFLAGS $predeps $libobjs $deplibs $postdeps $linkopts ${wl}-h $wl$soname -o $lib' + archive_cmds='$LD -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $linkopts ${wl}-h $wl$soname -o $lib' archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predeps $libobjs $deplibs $postdeps $linkopts~$rm $lib.exp' + $LD -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linkopts~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmds="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | egrep \"\-L\"" else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. - archive_cmds='$LD -G -nostdlib $LDFLAGS $predeps $libobjs $deplibs $postdeps $linkopts ${wl}-h $wl$soname -o $lib' + archive_cmds='$LD -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $linkopts ${wl}-h $wl$soname -o $lib' archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ - $LD -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predeps $libobjs $postdeps $deplibs $linkopts~$rm $lib.exp' + $LD -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linkopts~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmds="$CC -G $CFLAGS -v conftest.$objext 2>&1 | egrep \"\-L\"" fi hardcode_libdir_flag_spec='${wl}-R $wl$libdir' - - # Commands to make compiler produce verbose output that lists - # what "hidden" libraries, object files and flags are used when - # linking. - output_verbose_link_cmds="$CC $CFLAGS -v conftest.$objext 2>&1 | egrep \"\-L\"" fi ;; esac @@ -480,72 +485,6 @@ case "$host_os" in ;; esac -# Figure out "hidden" C++ library dependencies from verbose -# compiler output -cat > conftest.$ac_ext <&5; then - # Parse the compiler output and extract the necessary - # object, libraries and library flags. - - # Sentinel used to keep track of whether or not we are before - # the conftest object file. - pre_object_deps_done=no - - for p in `eval $output_verbose_link_cmds`; do - case $p in - *.$objext | -L* | -R* | -l*) - # Some compilers place space between "-{L,R}" and the path. - # Remove the space. - if test $p = "-L" \ - || test $p = "-R"; then - prev=$p - continue - else - prev= - fi - - # This assumes that the test object file only shows up - # once in the compiler output. - if test "$p" != "conftest.$objext"; then - if test "$pre_object_deps_done" = no; then - predeps="${predeps} ${prev}${p}" - else - postdeps="${postdeps} ${prev}${p}" - fi - else - pre_object_deps_done=yes - fi - ;; - *) ;; # Ignore the rest. - esac - done - - # Clean up. - rm -f a.out -else - echo "ltcf-cxx.sh: error: problem compiling test program" -fi - -$rm -f confest.$objext - - ## Compiler Characteristics: PIC flags, static flags, etc @@ -769,3 +708,91 @@ else ;; esac fi + + +# Figure out "hidden" C++ library dependencies from verbose +# compiler output whening linking a shared library. +cat > conftest.$ac_ext <&5; then + # Parse the compiler output and extract the necessary + # object, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval $output_verbose_link_cmds`; do + + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" \ + || test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$predeps"; then + predeps="${prev}${p}" + else + predeps="${predeps} ${prev}${p}" + fi + else + if test -z "$postdeps"; then + postdeps="${prev}${p}" + else + postdeps="${postdeps} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$predep_objects"; then + predep_objects="$p" + else + predep_objects="$predep_objects $p" + fi + else + if test -z "$postdep_objects"; then + postdep_objects="$p" + else + postdep_objects="$postdep_objects $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out +else + echo "ltcf-cxx.sh: error: problem compiling test program" +fi + +$rm -f confest.$objext diff --git a/ltconfig.in b/ltconfig.in index a6d24eb7f..c9ff43935 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -218,6 +218,8 @@ cache_file= ld_shlibs=yes ## Dependencies to place before and after the object being linked: +predep_objects= +postdep_objects= predeps= postdeps= @@ -1915,7 +1917,7 @@ case "$ltmain" in RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ - predeps postdeps \ + predep_objects postdep_objects predeps postdeps \ old_striplib striplib file_magic_cmd export_symbols_cmds \ deplibs_check_method allow_undefined_flag no_undefined_flag \ finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ @@ -2179,10 +2181,20 @@ postuninstall_cmds=$postuninstall_cmds old_striplib=$old_striplib striplib=$striplib -# Dependencies to place before the object being linked. +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$predep_objects + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$postdep_objects + +# Dependencies to place before the objects being linked to create a +# shared library. predeps=$predeps -# Dependencies to place after the object being linked. +# Dependencies to place after the objects being linked to create a +# shared library. postdeps=$postdeps # Method to check whether dependent libraries are shared objects. diff --git a/ltmain.in b/ltmain.in index b31bdce7d..44e263cea 100644 --- a/ltmain.in +++ b/ltmain.in @@ -427,12 +427,12 @@ if test -z "$show_help"; then # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. - if test -n "$available_tags" && test -z "$tagname" && echo $base_compile | grep -v $CC > /dev/null; then + if test -n "$available_tags" && test -z "$tagname" && echo $base_compile | grep -v "^[ ]*[^ ]*$CC" > /dev/null; then for z in $available_tags; do if grep "^### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then # Evaluate the configuration. eval "`sed -n -e '/^### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`" - if echo $base_compile | grep $CC > /dev/null; then + if echo $base_compile | grep "^[ ]*[^ ]*$CC" > /dev/null; then # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. @@ -760,8 +760,6 @@ EOF finalize_shlibpath= convenience= old_convenience= - test -n "$predeps" || predeps= - test -n "$postdeps" || postdeps= deplibs= old_deplibs= compiler_flags= @@ -1344,12 +1342,12 @@ EOF # command doesn't match the default compiler. if test -n "$available_tags" \ && test -z "$tagname" \ - && echo $compile_command | grep -v $CC > /dev/null; then + && echo $compile_command | grep -v "^[ ]*[^ ]*$CC" > /dev/null; then for z in $available_tags; do if grep "^### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then # Evaluate the configuration. eval "`sed -n -e '/^### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`" - if echo $compile_command | grep $CC > /dev/null; then + if echo $compile_command | grep "^[ ]*[^ ]*$CC" > /dev/null; then # The compiler in $compile_command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. @@ -1423,7 +1421,12 @@ EOF linkmode=prog ;; esac - libs="$deplibs" + if test $linkmode = lib; then + libs="$predeps $deplibs $postdeps" + else + libs="$deplibs" + fi + deplibs= newdependency_libs= uninst_path= # paths that contain uninstalled libtool libraries @@ -1460,7 +1463,8 @@ EOF link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi - for deplib in $predeps $postdeps $libs; do + + for deplib in $libs; do lib= found=no case "$deplib" in @@ -4377,9 +4381,23 @@ relink_command=\"$relink_command\"" ;; *.lo) - if test "$build_old_libs" = yes; then - oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` - rmfiles="$rmfiles $dir/$oldobj" + # Possibly a libtool object, so verify it. + if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + + # Read the .lo file + . ./$file + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" \ + && test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" \ + && test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi fi ;; diff --git a/tagdemo/Makefile.am b/tagdemo/Makefile.am index cbfad4506..9a5283dad 100644 --- a/tagdemo/Makefile.am +++ b/tagdemo/Makefile.am @@ -6,17 +6,21 @@ AUTOMAKE_OPTIONS = no-dependencies foreign EXTRA_DIST = acinclude.m4 -noinst_LTLIBRARIES = libfoo.la +noinst_LTLIBRARIES = libfoo.la libbaz.la libfoo_la_SOURCES = foo.cpp libfoo_la_LIBADD = $(LIBM) -noinst_HEADERS = foo.h +# Test some of the ILD support when using tagged configurations. +libbaz_la_SOURCES = baz.cpp +libbaz_la_LIBADD = libfoo.la + +noinst_HEADERS = foo.h baz.h bin_PROGRAMS = tagdemo tagdemo_SOURCES = main.cpp -tagdemo_LDADD = libfoo.la +tagdemo_LDADD = libbaz.la $(OBJECTS): libtool libtool: $(LIBTOOL_DEPS) diff --git a/tagdemo/Makefile.in b/tagdemo/Makefile.in index 56e17deeb..3add7703e 100644 --- a/tagdemo/Makefile.in +++ b/tagdemo/Makefile.in @@ -85,17 +85,21 @@ AUTOMAKE_OPTIONS = no-dependencies foreign EXTRA_DIST = acinclude.m4 -noinst_LTLIBRARIES = libfoo.la +noinst_LTLIBRARIES = libfoo.la libbaz.la libfoo_la_SOURCES = foo.cpp libfoo_la_LIBADD = $(LIBM) -noinst_HEADERS = foo.h +# Test some of the ILD support when using tagged configurations. +libbaz_la_SOURCES = baz.cpp +libbaz_la_LIBADD = libfoo.la + +noinst_HEADERS = foo.h baz.h bin_PROGRAMS = tagdemo tagdemo_SOURCES = main.cpp -tagdemo_LDADD = libfoo.la +tagdemo_LDADD = libbaz.la ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs CONFIG_CLEAN_FILES = @@ -109,11 +113,14 @@ LIBS = @LIBS@ libfoo_la_LDFLAGS = libfoo_la_DEPENDENCIES = libfoo_la_OBJECTS = foo.lo +libbaz_la_LDFLAGS = +libbaz_la_DEPENDENCIES = libfoo.la +libbaz_la_OBJECTS = baz.lo bin_PROGRAMS = tagdemo$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) tagdemo_OBJECTS = main.$(OBJEXT) -tagdemo_DEPENDENCIES = libfoo.la +tagdemo_DEPENDENCIES = libbaz.la tagdemo_LDFLAGS = CXXFLAGS = @CXXFLAGS@ CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) @@ -130,8 +137,8 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = tar GZIP_ENV = --best -SOURCES = $(libfoo_la_SOURCES) $(tagdemo_SOURCES) -OBJECTS = $(libfoo_la_OBJECTS) $(tagdemo_OBJECTS) +SOURCES = $(libfoo_la_SOURCES) $(libbaz_la_SOURCES) $(tagdemo_SOURCES) +OBJECTS = $(libfoo_la_OBJECTS) $(libbaz_la_OBJECTS) $(tagdemo_OBJECTS) all: all-redirect .SUFFIXES: @@ -207,6 +214,9 @@ maintainer-clean-libtool: libfoo.la: $(libfoo_la_OBJECTS) $(libfoo_la_DEPENDENCIES) $(CXXLINK) $(libfoo_la_LDFLAGS) $(libfoo_la_OBJECTS) $(libfoo_la_LIBADD) $(LIBS) +libbaz.la: $(libbaz_la_OBJECTS) $(libbaz_la_DEPENDENCIES) + $(CXXLINK) $(libbaz_la_LDFLAGS) $(libbaz_la_OBJECTS) $(libbaz_la_LIBADD) $(LIBS) + mostlyclean-binPROGRAMS: clean-binPROGRAMS: diff --git a/tagdemo/baz.cpp b/tagdemo/baz.cpp new file mode 100644 index 000000000..51a56347a --- /dev/null +++ b/tagdemo/baz.cpp @@ -0,0 +1,35 @@ +// -*- C++ -*- +// baz.cpp -- a slightly more complicated test library +// Copyright (C) 1998-2000 Free Software Foundation, Inc. +// Originally by Thomas Tanner +// This file is part of GNU Libtool. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. + +#include "foo.h" +#include "baz.h" + +// -------------------------------------------------------------------- +// Our C++ derived class methods. + + +int +barbaz_derived::baz(void) +{ + foobar_derived FB; + + return FB.foo(); +} diff --git a/tagdemo/baz.h b/tagdemo/baz.h new file mode 100644 index 000000000..1c1be2b4e --- /dev/null +++ b/tagdemo/baz.h @@ -0,0 +1,43 @@ +// -*- C++ -*- +// baz.h -- interface to the libfoo* libraries +// Copyright (C) 1998-1999 Free Software Foundation, Inc. +// Originally by Thomas Tanner +// This file is part of GNU Libtool. + +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. + +// Only include this header file once. +#ifndef _BAZ_H_ +#define _BAZ_H_ 1 + +// Our test C++ base class. +class barbaz +{ +public: + virtual int baz(void) = 0; + // Some dummy pure virtual functions. +}; + + +// Our test C++ derived class. +class barbaz_derived : public barbaz +{ +public: + virtual int baz(void); + // Override the base class' pure virtual functions. +}; + +#endif /* !_FOO_H_ */ diff --git a/tagdemo/main.cpp b/tagdemo/main.cpp index 84be36238..6f1e16dda 100644 --- a/tagdemo/main.cpp +++ b/tagdemo/main.cpp @@ -21,6 +21,7 @@ #include "foo.h" +#include "baz.h" #include @@ -44,5 +45,19 @@ main (int, char *[]) if (fb->foo() == FOO_RET) printf("foobar::foo is ok!\n"); + // -------------- + + barbaz_derived BB; + // Instantiate the derived class. + + barbaz *bb = &BB; + // Have some fun with polymorphism. + + + // barbaz_derived::baz() should return FOO_RET since it calls + // foobar_derived::foo(), which in turn calls ::foo(). + if (bb->baz() == FOO_RET) + printf("barbaz::baz is ok!\n"); + return 0; } -- 2.47.3