X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=blobdiff_plain;f=ltmain.sh;h=474423aaf10e0f6db7c07e92998189547d242c8d;hp=daaf6bb5e9ecf65a80155bc1cc83e512ecb91dc1;hb=f39bebdba144115c82f60bfb9cead2243f7861fa;hpb=46b021de99dc2e4a8d95a59ae3c279f9ca4a91fc diff --git a/ltmain.sh b/ltmain.sh index daaf6bb5e9e..474423aaf10 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -17,7 +17,7 @@ # # 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. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -55,8 +55,8 @@ modename="$progname" # Constants. PROGRAM=ltmain.sh PACKAGE=libtool -VERSION=1.4a -TIMESTAMP=" (1.641.2.228 2001/04/20 08:53:18)" +VERSION=1.4a-GCC3.0 +TIMESTAMP=" (1.641.2.256 2001/05/28 20:09:07 with GCC-local changes)" default_mode= help="Try \`$progname --help' for more information." @@ -107,6 +107,7 @@ show_help= execute_dlfiles= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" +taglist= # Parse our command line options once, thoroughly. while test $# -gt 0 @@ -140,6 +141,7 @@ do CC) # Don't test for the "default" C tag, as we know, it's there, but # not specially marked. + taglist="$taglist $tagname" ;; *) if grep "^### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then @@ -246,6 +248,11 @@ if test -n "$prevopt"; then exit 1 fi +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + if test -z "$show_help"; then # Infer the operation mode. @@ -822,6 +829,7 @@ EOF linker_flags= dllsearchpath= lib_search_path=`pwd` + inst_prefix_dir= avoid_version=no dlfiles= @@ -954,6 +962,11 @@ EOF prev= continue ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; release) release="-$arg" prev= @@ -1034,6 +1047,11 @@ EOF if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. @@ -1104,13 +1122,26 @@ EOF finalize_command="$finalize_command $wl$qarg" continue ;; + framework) + case $host in + *-*-darwin*) + case "$deplibs " in + *" $qarg.framework "*) ;; + *) deplibs="$deplibs $qarg.framework" # this is fixed later + ;; + esac + ;; + esac + prev= + continue + ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac - fi + fi # test -n $prev prevarg="$arg" @@ -1151,7 +1182,7 @@ EOF -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then - $echo "$modename: not more than one -exported-symbols argument allowed" + $echo "$modename: more than one -exported-symbols argument is not allowed" exit 1 fi if test "X$arg" = "X-export-symbols"; then @@ -1162,6 +1193,11 @@ EOF continue ;; + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) @@ -1173,7 +1209,7 @@ EOF esac continue ;; - + -L*) dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` # We need an absolute path. @@ -1207,28 +1243,15 @@ EOF ;; -l*) - if test "$arg" = "-lc"; then - case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) - # These systems don't actually have c library (as such) - continue - ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody C library is in the System framework - deplibs="$deplibs -framework System" - continue - ;; - esac - elif test "$arg" = "-lm"; then + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-pw32* | *-*-beos*) - # These systems don't actually have math library (as such) + # These systems don't actually have a C or math library (as such) continue ;; - *-*-rhapsody* | *-*-darwin1.[012]) - # Rhapsody math library is in the System framework - deplibs="$deplibs -framework System" - continue + *-*-mingw* | *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue ;; esac fi @@ -1255,9 +1278,7 @@ EOF $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 fast_install=no ;; - *) - no_install=yes - ;; + *) no_install=yes ;; esac continue ;; @@ -1307,7 +1328,7 @@ EOF ;; -static) - # The effects of -static are defined in a previous loop. + # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least @@ -1371,6 +1392,10 @@ EOF prev=xlinker continue ;; + -framework) + prev=framework + continue + ;; # Some other compiler flag. -* | +*) @@ -1457,6 +1482,11 @@ EOF if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi + else + # If the PIC object exists, use it instead. + # $xdir was prepended to $pic_object above. + non_pic_object="$pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" fi else # Only an error if not doing a dry-run. @@ -1517,14 +1547,14 @@ EOF ;; esac ;; - esac + esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi - done + done # argument parsing loop if test -n "$prev"; then $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 @@ -1582,7 +1612,6 @@ EOF finalize_command="$finalize_command $arg" fi - oldlibs= # calculate the name of the file, without its directory outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` libobjs_save="$libobjs" @@ -1656,8 +1685,8 @@ EOF newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries - uninst_deplibs= # uninstalled libtool libraries - uninst_path= # paths that contain uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv link" @@ -1679,34 +1708,29 @@ EOF newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; - *) passes="conv" + *) passes="conv" ;; esac for pass in $passes; do - if test "$linkmode,$pass" = "lib,link" || - test "$linkmode,$pass" = "prog,scan"; then - libs="$deplibs" - deplibs= - fi if test $linkmode = prog; then + # Determine which files to process case $pass in - dlopen) libs="$dlfiles" ;; + dlopen) + libs="$dlfiles" + save_deplibs="$deplibs" # Collect dlpreopened libraries + deplibs= + ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi - if test $pass = dlopen; then - # Collect dlpreopened libraries - save_deplibs="$deplibs" - deplibs= - fi for deplib in $libs; do lib= found=no case $deplib in -l*) - if test $linkmode != lib && test $linkmode != prog; then - $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 + if test $linkmode = oldlib && test $linkmode = obj; then + $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2 continue fi if test $pass = conv; then @@ -1723,6 +1747,7 @@ EOF fi done if test "$found" != yes; then + # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" @@ -1732,7 +1757,7 @@ EOF fi continue fi - ;; + ;; # -l -L*) case $linkmode in lib) @@ -1755,11 +1780,11 @@ EOF fi ;; *) - $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 + $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2 ;; - esac + esac # linkmode continue - ;; + ;; # -L -R*) if test $pass = link; then dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` @@ -1803,21 +1828,17 @@ EOF fi continue ;; - esac - ;; + esac # linkmode + ;; # *.$libext *.lo | *.$objext) - if test $pass = conv; then - deplibs="$deplib $deplibs" - elif test $linkmode = prog; then - if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles="$newdlprefiles $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles="$newdlfiles $deplib" - fi + if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" fi continue ;; @@ -1825,7 +1846,7 @@ EOF alldeplibs=yes continue ;; - esac + esac # case $deplib if test $found = yes || test -f "$lib"; then : else $echo "$modename: cannot find the library \`$lib'" 1>&2 @@ -1858,15 +1879,23 @@ EOF *) . ./$lib ;; esac + case $host in + *-*-darwin*) + # Convert "-framework foo" to "foo.framework" in dependency_libs + test -n "$dependency_libs" && dependency_libs=`$echo "X$dependency_libs" | $Xsed -e 's/-framework \([^ $]*\)/\1.framework/g'` + ;; + esac + if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || - { test $linkmode != prog && test $linkmode != lib; }; then + { test $linkmode = oldlib && test $linkmode = obj; }; then + # Add dl[pre]opened files of deplib test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test $pass = conv; then - # only check for convenience libraries + # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then @@ -1889,7 +1918,7 @@ EOF exit 1 fi continue - fi + fi # $pass = conv # Get the name of the library we link against. linklib= @@ -1909,15 +1938,13 @@ EOF fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. We also need to preload any - # dependent libraries so libltdl's deplib preloader doesn't - # bomb out in the load deplibs phase. - dlprefiles="$dlprefiles $lib $dependency_libs" + # statically, we need to preload. + dlprefiles="$dlprefiles $lib" else newdlfiles="$newdlfiles $lib" fi continue - fi + fi # $pass = dlopen # We need an absolute path. case $ladir in @@ -1948,8 +1975,8 @@ EOF dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later - uninst_path="$uninst_path $abs_ladir" - fi + notinst_path="$notinst_path $abs_ladir" + fi # $installed = yes name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` # This library was specified with -dlpreopen. @@ -1968,17 +1995,17 @@ EOF else newdlprefiles="$newdlprefiles $dir/$linklib" fi - fi + fi # $pass = dlpreopen if test -z "$libdir"; then - # link the convenience library + # Link the convenience library if test $linkmode = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else - deplibs="$lib $deplibs" # used for prog,scan pass + deplibs="$lib $deplibs" fi continue fi @@ -2010,23 +2037,17 @@ EOF *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac tmp_libs="$tmp_libs $deplib" - done + done # for deplib continue - fi + fi # $linkmode = prog... - if test "$linkmode,$pass" = "prog,link"; then - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - # We need to hardcode the library path - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *" $absdir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi + link_static=no # Whether the deplib will be linked statically + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + # Link against this shared library + if test "$linkmode,$pass" = "prog,link" || + { test $linkmode = lib && test $hardcode_into_libs = yes; }; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. @@ -2039,7 +2060,6 @@ EOF esac ;; esac - case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) @@ -2049,7 +2069,18 @@ EOF esac ;; esac - fi + if test $linkmode = prog; then + # We need to hardcode the library path + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + fi + fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || @@ -2058,40 +2089,11 @@ EOF # We only need to search for static libraries continue fi - fi - link_static=no # Whether the deplib will be linked statically - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then if test "$installed" = no; then - uninst_deplibs="$uninst_deplibs $lib" + notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi - # This is a shared library - if test $linkmode = lib && - test $hardcode_into_libs = yes; then - # Hardcode the library path. - # Skip directories that are in the system default run-time - # search path. - case " $sys_lib_dlsearch_path " in - *" $absdir "*) ;; - *) - case "$compile_rpath " in - *" $absdir "*) ;; - *) compile_rpath="$compile_rpath $absdir" - esac - ;; - esac - case " $sys_lib_dlsearch_path " in - *" $libdir "*) ;; - *) - case "$finalize_rpath " in - *" $libdir "*) ;; - *) finalize_rpath="$finalize_rpath $libdir" - esac - ;; - esac - fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname @@ -2125,9 +2127,10 @@ EOF else $show "extracting exported symbol list from \`$soname'" IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' - eval cmds=\"$extract_expsyms_cmds\" + cmds=$extract_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -2138,9 +2141,10 @@ EOF if test -f "$output_objdir/$newlib"; then :; else $show "generating import library for \`$soname'" IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' - eval cmds=\"$old_archive_from_expsyms_cmds\" + cmds=$old_archive_from_expsyms_cmds for cmd in $cmds; do IFS="$save_ifs" + eval cmd=\"$cmd\" $show "$cmd" $run eval "$cmd" || exit $? done @@ -2149,7 +2153,7 @@ EOF # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib - fi + fi # test -n $old_archive_from_expsyms_cmds if test $linkmode = prog || test "$mode" != relink; then add_shlibpath= @@ -2178,6 +2182,14 @@ EOF add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" @@ -2236,6 +2248,14 @@ EOF else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi add="-l$name" fi @@ -2248,6 +2268,15 @@ EOF fi fi elif test $linkmode = prog; then + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + + # Try to link the static library # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. @@ -2264,6 +2293,7 @@ EOF if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. + # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo @@ -2271,13 +2301,30 @@ EOF echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + echo "*** Therefore, libtool will create a static module, that should work " + echo "*** as long as the dlopening application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi else convenience="$convenience $dir/$old_library" old_convenience="$old_convenience $dir/$old_library" deplibs="$dir/$old_library $deplibs" link_static=yes fi - fi + fi # link shared/static library? if test $linkmode = lib; then if test -n "$dependency_libs" && @@ -2351,10 +2398,9 @@ EOF *) deplibs="$path $deplibs" ;; esac done - fi - fi - done - dependency_libs="$newdependency_libs" + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs if test $pass = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do @@ -2362,6 +2408,7 @@ EOF done fi if test $pass != dlopen; then + test $pass != scan && dependency_libs="$newdependency_libs" if test $pass != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= @@ -2384,40 +2431,20 @@ EOF eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do - # FIXME: Pedantically, this is the right thing to do, so - # that some nasty dependency loop isn't accidentally - # broken: - #new_libs="$deplib $new_libs" - # Pragmatically, this seems to cause very few problems in - # practice: case $deplib in - -L*) new_libs="$deplib $new_libs" ;; - *) - # And here is the reason: when a library appears more - # than once as an explicit dependence of a library, or - # is implicitly linked in more than once by the - # compiler, it is considered special, and multiple - # occurrences thereof are not removed. Compare this - # with having the same library being listed as a - # dependency of multiple other libraries: in this case, - # we know (pedantically, we assume) the library does not - # need to be listed more than once, so we keep only the - # last copy. This is not always right, but it is rare - # enough that we require users that really mean to play - # such unportable linking tricks to link the library - # using -Wl,-lname, so that libtool does not consider it - # for duplicate removal. - case " $specialdeplibs " in - *" $deplib "*) new_libs="$deplib $new_libs" ;; - *) - case " $new_libs " in - *" $deplib "*) ;; - *) new_libs="$deplib $new_libs" ;; - esac - ;; - esac - ;; - esac + -L*) new_libs="$deplib $new_libs" ;; + *) + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac done tmp_libs= for deplib in $new_libs; do @@ -2432,9 +2459,14 @@ EOF esac done eval $var=\"$tmp_libs\" - done + done # for var fi - done + if test "$pass" = "conv" && + { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then + libs="$deplibs" # reset libs + deplibs= + fi + done # for pass if test $linkmode = prog; then dlfiles="$newdlfiles" dlprefiles="$newdlprefiles" @@ -2442,10 +2474,6 @@ EOF case $linkmode in oldlib) - if test -n "$deplibs"; then - $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 - fi - if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 fi @@ -2481,6 +2509,7 @@ EOF case $outputname in lib*) name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval shared_ext=\"$shrext\" eval libname=\"$libname_spec\" ;; *) @@ -2492,6 +2521,7 @@ EOF if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval shared_ext=\"$shrext\" eval libname=\"$libname_spec\" else libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` @@ -2641,7 +2671,7 @@ EOF ;; osf) - major=`expr $current - $age` + major=.`expr $current - $age` versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" @@ -2679,7 +2709,16 @@ EOF # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= - verstring="0.0" + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac if test "$need_version" = no; then versuffix= else @@ -2737,7 +2776,7 @@ EOF fi # Eliminate all temporary directories. - for path in $uninst_path; do + for path in $notinst_path; do lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'` deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'` dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'` @@ -2788,11 +2827,14 @@ EOF # Rhapsody C library is in the System framework deplibs="$deplibs -framework System" ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; *) - # Add libc to deplibs on all other systems if necessary. - if test $build_libtool_need_lc = "yes"; then - deplibs="$deplibs -lc" - fi + # Add libc to deplibs on all other systems if necessary. + if test $build_libtool_need_lc = "yes"; then + deplibs="$deplibs -lc" + fi ;; esac fi @@ -2836,7 +2878,7 @@ EOF for i in $deplibs; do name="`expr $i : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. - if test "$name" != "" -a "$name" != "0"; then + if test -n "$name" && test "$name" != "0"; then libname=`eval \\$echo \"$libname_spec\"` deplib_matches=`eval \\$echo \"$library_names_spec\"` set dummy $deplib_matches @@ -2861,7 +2903,7 @@ EOF for i in $deplibs; do name="`expr $i : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. - if test "$name" != "" -a "$name" != "0"; then + if test -n "$name" && test "$name" != "0"; then $rm conftest $LTCC -o conftest conftest.c $i # Did it work? @@ -2901,7 +2943,7 @@ EOF for a_deplib in $deplibs; do name="`expr $a_deplib : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. - if test "$name" != "" -a "$name" != "0"; then + if test -n "$name" && test "$name" != "0"; then libname=`eval \\$echo \"$libname_spec\"` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` @@ -2953,7 +2995,7 @@ EOF for a_deplib in $deplibs; do name="`expr $a_deplib : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. - if test "$name" != "" -a "$name" != "0"; then + if test -n "$name" && test "$name" != "0"; then libname=`eval \\$echo \"$libname_spec\"` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` @@ -3003,6 +3045,13 @@ EOF libname=$libname_save name=$name_save + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + if test "$droppeddeps" = yes; then if test "$module" = yes; then echo @@ -3045,6 +3094,14 @@ EOF fi fi fi + # Time to change all our "foo.framework" stuff back to "-framework foo" + case $host in + *-*-darwin*) + newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'` + dependency_libs=`$echo "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'` + ;; + esac + # Done checking deplibs! # Done checking deplibs! deplibs=$newdeplibs fi @@ -3113,6 +3170,7 @@ EOF # Get the real and link names of the library. eval library_names=\"$library_names_spec\" + eval shared_ext=\"$shrext\" set dummy $library_names realname="$2" shift; shift @@ -3122,9 +3180,7 @@ EOF else soname="$realname" fi - if test x$dlname = x; then - dlname=$soname - fi + test -z "$dlname" && dlname=$soname lib="$output_objdir/$realname" for link @@ -3232,16 +3288,17 @@ EOF # Do each of the archive commands. if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval cmds=\"$archive_expsym_cmds\" + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds else - eval cmds=\"$archive_cmds\" + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds fi - if len=`expr "X$cmds" : ".*"` && + if len=`expr "X$test_cmds" : ".*"` && test $len -le $max_cmd_len; then : else # The command line is too long to link in one step, link piecewise. - $echo "creating reloadable object files..." # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we @@ -3255,6 +3312,7 @@ EOF save_libobjs=$libobjs fi save_output=$output + output_la=`$echo "X$output" | $Xsed -e "s,^.*/,,"` # Clear the reloadable object creation command queue and # initialize k to one. @@ -3264,62 +3322,87 @@ EOF delfiles= last_robj= k=1 - output=$output_objdir/$save_output-${k}.$objext - # Loop over the list of objects to be linked. - for obj in $save_libobjs - do - eval test_cmds=\"$reload_cmds $objlist $last_robj\" - if test "X$objlist" = X || - { len=`expr "X$test_cmds" : ".*"` && - test $len -le $max_cmd_len; }; then - objlist="$objlist $obj" - else - # The command $test_cmds is almost too long, add a - # command to the queue. - if test $k -eq 1 ; then - # The first file doesn't have a previous command to add. - eval concat_cmds=\"$reload_cmds $objlist $last_robj\" - else - # All subsequent reloadable object files will link in - # the last one created. - eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" - fi - last_robj=$output_objdir/$save_output-${k}.$objext - k=`expr $k + 1` - output=$output_objdir/$save_output-${k}.$objext - objlist=$obj - len=1 - fi - done - # Handle the remaining objects by creating one last - # reloadable object file. All subsequent reloadable object - # files will link in the last one created. - test -z "$concat_cmds" || concat_cmds=$concat_cmds~ - eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" - - # Set up a command to remove the reloadale object files - # after they are used. - i=0 - while test $i -lt $k - do - i=`expr $i + 1` - delfiles="$delfiles $output_objdir/$save_output-${i}.$objext" - done - $echo "creating a temporary reloadable object file: $output" + if test "$with_gnu_ld" = yes; then + output=${output_objdir}/${output_la}.lnkscript + $echo "creating GNU ld script: $output" + $echo 'INPUT (' > $output + for obj in $save_libobjs + do + $echo \""$obj"\" >> $output + done + $echo ')' >> $output + delfiles="$delfiles $output" + elif test "X$file_list_spec" != X; then + output=${output_objdir}/${output_la}.lnk + $echo "creating linker input file list: $output" + : > $output + for obj in $save_libobjs + do + $echo "$obj" >> $output + done + delfiles="$delfiles $output" + output=\"$file_list_spec$output\" + else + $echo "creating reloadable object files..." + output=$output_objdir/$save_output-${k}.$objext + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + eval test_cmds=\"$reload_cmds $objlist $last_robj\" + if test "X$objlist" = X || + { len=`expr "X$test_cmds" : ".*"` && + test $len -le $max_cmd_len; }; then + objlist="$objlist $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test $k -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" + fi + last_robj=$output_objdir/$save_output-${k}.$objext + k=`expr $k + 1` + output=$output_objdir/$save_output-${k}.$objext + objlist=$obj + len=1 + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + + # Set up a command to remove the reloadale object files + # after they are used. + i=0 + while test $i -lt $k + do + i=`expr $i + 1` + delfiles="$delfiles $output_objdir/$save_output-${i}.$objext" + done + + $echo "creating a temporary reloadable object file: $output" - # Loop through the commands generated above and execute them. - IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' - for cmd in $concat_cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" + # Loop through the commands generated above and execute them. + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi - libobjs=$output + libobjs=$output # Restore the value of output. - output=$save_output + output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" @@ -3329,22 +3412,23 @@ EOF # Do each of the archive commands. if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then - eval cmds=\"$archive_expsym_cmds\" - else - eval cmds=\"$archive_cmds\" - fi + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi # Append the command to remove the reloadable object files # to the just-reset $cmds. - eval cmds=\"\$cmds~$rm $delfiles\" - fi - IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' - for cmd in $cmds; do - IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? - done - IFS="$save_ifs" + eval cmds=\"\$cmds~$rm $delfiles\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" # Restore the uninstalled library and exit if test "$mode" = relink; then @@ -3535,7 +3619,7 @@ EOF prog) case $host in - *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;; + *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;; esac if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 @@ -3552,6 +3636,27 @@ EOF fi fi + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + case $host in + *-*-darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + if test "$tagname" = CXX ; then + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + fi + # Time to change all our "foo.framework" stuff back to "-framework foo" + compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'` + finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).framework% -framework \1%g'` + ;; + esac + compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" @@ -4014,7 +4119,7 @@ relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variable: - uninst_deplibs='$uninst_deplibs' + notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$echo are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then @@ -4082,8 +4187,9 @@ else # relink executable if necessary if test -n \"\$relink_command\"; then - if (eval \$relink_command); then : + if relink_command_output=\`eval \$relink_command 2>&1\`; then : else + $echo \"\$relink_command_output\" >&2 $rm \"\$progdir/\$file\" exit 1 fi @@ -4252,6 +4358,63 @@ fi\ # fi # done + # POSIX demands no paths to be encoded in archives. We have + # to avoid creating archives with duplicate basenames if we + # might have to extract them afterwards, e.g., when creating a + # static archive out of a convenience library, or when linking + # the entirety of a libtool archive into another (currently + # not supported by libtool). + if (for obj in $oldobjs + do + $echo "X$obj" | $Xsed -e 's%^.*/%%' + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "copying selected object files to avoid basename conflicts..." + + if test -z "$gentop"; then + gentop="$output_objdir/${outputname}x" + + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + fi + + save_oldobjs=$oldobjs + oldobjs= + counter=1 + for obj in $save_oldobjs + do + objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + case " $oldobjs " in + " ") oldobjs=$obj ;; + *[\ /]"$objbase "*) + while :; do + # Make sure we don't pick an alternate name that also + # overlaps. + newobj=lt$counter-$objbase + counter=`expr $counter + 1` + case " $oldobjs " in + *[\ /]"$newobj "*) ;; + *) if test ! -f "$gentop/$newobj"; then break; fi ;; + esac + done + $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + $run ln "$obj" "$gentop/$newobj" || + $run cp "$obj" "$gentop/$newobj" + oldobjs="$oldobjs $gentop/$newobj" + ;; + *) oldobjs="$oldobjs $obj" ;; + esac + done + fi + eval cmds=\"$old_archive_cmds\" if len=`expr "X$cmds" : ".*"` && @@ -4265,6 +4428,7 @@ fi\ objlist= concat_cmds= save_oldobjs=$oldobjs + for obj in $save_oldobjs do oldobjs="$objlist $obj" @@ -4319,7 +4483,11 @@ fi\ fi done # Quote the link command for shipping. - relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args" + tagopts= + for tag in $taglist; do + tagopts="$tagopts --tag $tag" + done + relink_command="(cd `pwd`; $SHELL $0$tagopts --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` # Only create the output if not a dry run. @@ -4620,12 +4788,33 @@ relink_command=\"$relink_command\"" dir="$dir$objdir" if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$echo "$destdir" | sed "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + if test "$inst_prefix_dir" = "$destdir"; then + $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 + exit 1 + fi + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$echo "$relink_command" | sed "s%@inst_prefix_dir@%%"` + fi + $echo "$modename: warning: relinking \`$file'" 1>&2 $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - continue + exit 1 fi fi @@ -4735,7 +4924,7 @@ relink_command=\"$relink_command\"" # Do a test to see if this is really a libtool program. if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - uninst_deplibs= + notinst_deplibs= relink_command= # If there is no directory component, then add one. @@ -4745,13 +4934,13 @@ relink_command=\"$relink_command\"" esac # Check the variables that should have been set. - if test -z "$uninst_deplibs"; then + if test -z "$notinst_deplibs"; then $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 exit 1 fi finalize=yes - for lib in $uninst_deplibs; do + for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then @@ -4866,11 +5055,10 @@ relink_command=\"$relink_command\"" if test -n "$current_libdirs"; then # Maybe just do a dry run. test -n "$run" && current_libdirs=" -n$current_libdirs" - exec $SHELL $0 --finish$current_libdirs - exit 1 + exec_cmd='$SHELL $0 --finish$current_libdirs' + else + exit 0 fi - - exit 0 ;; # libtool finish mode @@ -4908,7 +5096,7 @@ relink_command=\"$relink_command\"" fi # Exit here if they wanted silent mode. - test "$show" = : && exit 0 + test "$show" = ":" && exit 0 echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" @@ -5073,11 +5261,8 @@ relink_command=\"$relink_command\"" LANG="$save_LANG"; export LANG fi - # Now actually exec the command. - eval "exec \$cmd$args" - - $echo "$modename: cannot exec \$cmd$args" - exit 1 + # Now prepare to actually exec the command. + exec_cmd='"$cmd"$args' else # Display what would be done. if test -n "$shlibpath_var"; then @@ -5131,14 +5316,16 @@ relink_command=\"$relink_command\"" # Remember objdir for removal later, being careful to avoid duplicates if test $mode = clean; then - case " $rmdirs " in + case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; esac fi - + # Don't error if the file doesn't exist and rm -f was used. - if test -L "$file" >/dev/null 2>&1 || test -f "$file"; then + if (test -L "$file") >/dev/null 2>&1 \ + || (test -h "$file") >/dev/null 2>&1 \ + || test -f "$file"; then : elif test -d "$file"; then exit_status=1 @@ -5239,8 +5426,8 @@ relink_command=\"$relink_command\"" # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then - $show "rmdir $dir" - $run rmdir $dir >/dev/null 2>&1 + $show "rmdir $dir" + $run rmdir $dir >/dev/null 2>&1 fi done @@ -5254,11 +5441,18 @@ relink_command=\"$relink_command\"" ;; esac - $echo "$modename: invalid operation mode \`$mode'" 1>&2 - $echo "$generic_help" 1>&2 - exit 1 + if test -z "$exec_cmd"; then + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + fi fi # test -z "$show_help" +if test -n "$exec_cmd"; then + eval exec $exec_cmd + exit 1 +fi + # We need to display help for each of the modes. case $mode in "") $echo \ @@ -5316,6 +5510,8 @@ Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only -static always build a \`.o' file suitable for static linking COMPILE-COMMAND is a command to be used in creating a \`standard' object file