1 # ltmain.sh - Provide generalized library-building support services.
2 # NOTE: Changing this file will not affect anything until you rerun configure.
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
5 # Free Software Foundation, Inc.
6 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 # As a special exception to the GNU General Public License, if you
23 # distribute this file as part of a program that contains a
24 # configuration script generated by Autoconf, you may include it under
25 # the same distribution terms that you use for the rest of that program.
29 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30 # is ksh but when the shell is invoked as "sh" and the current value of
31 # the _XPG environment variable is not equal to 1 (one), the special
32 # positional parameter $0, within a function call, is the name of the
36 # The name of this program:
37 progname=`echo "$progpath" | $SED $basename`
47 TIMESTAMP=" (1.1220.2.118 2004/08/07 12:24:38)"
49 # See if we are running on zsh, and set the options which allow our
50 # commands through without removal of \ escapes.
51 if test -n "${ZSH_VERSION+set}" ; then
55 # Check that we have a working $echo.
56 if test "X$1" = X--no-reexec; then
57 # Discard the --no-reexec flag, and continue.
59 elif test "X$1" = X--fallback-echo; then
60 # Avoid inline document here, it may be left over
62 elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
63 # Yippee, $echo works!
66 # Restart under the correct shell, and then maybe $echo will work.
67 exec $SHELL "$progpath" --no-reexec ${1+"$@"}
70 if test "X$1" = X--fallback-echo; then
71 # used as fallback echo
80 help="Try \`$progname --help' for more information."
81 magic="%%%MAGIC variable%%%"
86 # Sed substitution that helps us do robust quoting. It backslashifies
87 # metacharacters that are still active within double-quoted strings.
88 Xsed="${SED}"' -e 1s/^X//'
89 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
90 # test EBCDIC or ASCII
91 case `echo A|tr A '\301'` in
92 A) # EBCDIC based system
93 SP2NL="tr '\100' '\n'"
94 NL2SP="tr '\r\n' '\100\100'"
96 *) # Assume ASCII based system
97 SP2NL="tr '\040' '\012'"
98 NL2SP="tr '\015\012' '\040\040'"
103 # Only set LANG and LC_ALL to C if already set.
104 # These must not be set unconditionally because not all systems understand
105 # e.g. LANG=C (notably SCO).
106 # We save the old values to restore during execute mode.
107 if test "${LC_ALL+set}" = set; then
108 save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
110 if test "${LANG+set}" = set; then
111 save_LANG="$LANG"; LANG=C; export LANG
114 # Make sure IFS has a sensible default
118 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
119 $echo "$modename: not configured to build any kind of library" 1>&2
120 $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
133 lo2o="s/\\.lo\$/.${objext}/"
134 o2lo="s/\\.${objext}\$/.lo/"
136 #####################################
137 # Shell function definitions:
138 # This seems to be the best place for them
140 # func_win32_libid arg
141 # return the library type of file 'arg'
143 # Need a lot of goo to handle *both* DLLs and import libs
144 # Has to be a shell function in order to 'eat' the argument
145 # that is supplied when $file_magic_command is called.
146 func_win32_libid () {
147 win32_libid_type="unknown"
148 win32_fileres=`file -L $1 2>/dev/null`
149 case $win32_fileres in
150 *ar\ archive\ import\ library*) # definitely import
151 win32_libid_type="x86 archive import"
153 *ar\ archive*) # could be an import, or static
154 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
155 $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
156 win32_nmres=`eval $NM -f posix -A $1 | \
157 sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
158 if test "X$win32_nmres" = "Ximport" ; then
159 win32_libid_type="x86 archive import"
161 win32_libid_type="x86 archive static"
166 win32_libid_type="x86 DLL"
168 *executable*) # but shell scripts are "executable" too...
169 case $win32_fileres in
170 *MS\ Windows\ PE\ Intel*)
171 win32_libid_type="x86 DLL"
176 $echo $win32_libid_type
181 # Infer tagged configuration to use if any are available and
182 # if one wasn't chosen via the "--tag" command line option.
183 # Only attempt this if the compiler in the base compile
184 # command doesn't match the default compiler.
185 # arg is usually of the form 'gcc ...'
187 if test -n "$available_tags" && test -z "$tagname"; then
191 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
195 CC_quoted="$CC_quoted $arg"
198 # Blanks in the command may have been stripped by the calling shell,
199 # but not from the CC environment variable when configure was run.
200 " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
201 # Blanks at the start of $base_compile will cause this to fail
202 # if we don't check for them as well.
204 for z in $available_tags; do
205 if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
206 # Evaluate the configuration.
207 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
210 # Double-quote args containing other shell metacharacters.
212 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
216 CC_quoted="$CC_quoted $arg"
219 " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
220 # The compiler in the base compile command matches
221 # the one in the tagged configuration.
222 # Assume this is the tagged configuration we want.
229 # If $tagname still isn't set, then no tagged configuration
230 # was found and let the user know that the "--tag" command
231 # line option must be used.
232 if test -z "$tagname"; then
233 $echo "$modename: unable to infer tagged configuration"
234 $echo "$modename: specify a tag with \`--tag'" 1>&2
237 # $echo "$modename: using $tagname tagged configuration"
245 # func_extract_archives gentop oldlib ...
246 func_extract_archives () {
247 my_gentop="$1"; shift
255 $show "${rm}r $my_gentop"
256 $run ${rm}r "$my_gentop"
257 $show "$mkdir $my_gentop"
258 $run $mkdir "$my_gentop"
260 if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
264 for my_xlib in $my_oldlibs; do
265 # Extract the objects.
267 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
268 *) my_xabs=`pwd`"/$my_xlib" ;;
270 my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
271 my_xdir="$my_gentop/$my_xlib"
273 $show "${rm}r $my_xdir"
274 $run ${rm}r "$my_xdir"
275 $show "$mkdir $my_xdir"
276 $run $mkdir "$my_xdir"
278 if test "$status" -ne 0 && test ! -d "$my_xdir"; then
283 $show "Extracting $my_xabs"
284 # Do not bother doing anything if just a dry run
285 if test -z "$run"; then
286 darwin_orig_dir=`pwd`
287 cd $my_xdir || exit $?
288 darwin_archive=$my_xabs
290 darwin_base_archive=`basename $darwin_archive`
291 darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
292 if test -n "$darwin_arches"; then
293 darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
295 $show "$darwin_base_archive has multiple architectures $darwin_arches"
296 for darwin_arch in $darwin_arches ; do
297 mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
298 lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
299 # Remove the table of contents from the thin files.
300 $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF 2>/dev/null || true
301 $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF\ SORTED 2>/dev/null || true
302 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
303 $AR -xo "${darwin_base_archive}"
304 rm "${darwin_base_archive}"
306 done # $darwin_arches
307 ## Okay now we have a bunch of thin objects, gotta fatten them up :)
308 darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP`
311 for darwin_file in $darwin_filelist; do
312 darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
313 lipo -create -output "$darwin_file" $darwin_files
314 done # $darwin_filelist
316 cd "$darwin_orig_dir"
319 (cd $my_xdir && $AR x $my_xabs) || exit $?
324 # We will extract separately just the conflicting names and we will
325 # no longer touch any unique names. It is faster to leave these
326 # extract automatically by $AR in one run.
327 $show "(cd $my_xdir && $AR x $my_xabs)"
328 $run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $?
329 if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then
332 $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
333 $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
334 $AR t "$my_xabs" | sort | uniq -cd | while read -r count name
337 while test "$i" -le "$count"
339 # Put our $i before any first dot (extension)
340 # Never overwrite any file
342 while test "X$name_to" = "X$name" || test -f "$my_xdir/$name_to"
344 name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
346 $show "(cd $my_xdir && $AR xN $i $my_xabs '$name' && $mv '$name' '$name_to')"
347 $run eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $mv '$name' '$name_to')" || exit $?
354 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
357 func_extract_archives_result="$my_oldobjs"
359 # End of Shell function definitions
360 #####################################
363 eval std_shrext=\"$shrext_cmds\"
365 # Parse our command line options once, thoroughly.
366 while test "$#" -gt 0
372 -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
376 # If the previous option needs an argument, assign it.
377 if test -n "$prev"; then
380 execute_dlfiles="$execute_dlfiles $arg"
384 preserve_args="${preserve_args}=$arg"
386 # Check whether tagname contains only valid characters
389 $echo "$progname: invalid tag name: $tagname" 1>&2
396 # Don't test for the "default" C tag, as we know, it's there, but
397 # not specially marked.
400 if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
401 taglist="$taglist $tagname"
402 # Evaluate the configuration.
403 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
405 $echo "$progname: ignoring unknown tag $tagname" 1>&2
420 # Have we seen a non-optional argument yet?
427 $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
429 $echo "Copyright (C) 2003 Free Software Foundation, Inc."
430 $echo "This is free software; see the source for copying conditions. There is NO"
431 $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
436 ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
437 # Now print the configurations for the tags.
438 for tagname in $taglist; do
439 ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
445 $echo "$progname: enabling shell trace mode"
447 preserve_args="$preserve_args $arg"
456 if test "$build_libtool_libs" = yes; then
457 $echo "enable shared libraries"
459 $echo "disable shared libraries"
461 if test "$build_old_libs" = yes; then
462 $echo "enable static libraries"
464 $echo "disable static libraries"
469 --finish) mode="finish" ;;
471 --mode) prevopt="--mode" prev=mode ;;
472 --mode=*) mode="$optarg" ;;
474 --preserve-dup-deps) duplicate_deps="yes" ;;
478 preserve_args="$preserve_args $arg"
481 --tag) prevopt="--tag" prev=tag ;;
483 set tag "$optarg" ${1+"$@"}
486 preserve_args="$preserve_args --tag"
495 $echo "$modename: unrecognized option \`$arg'" 1>&2
507 if test -n "$prevopt"; then
508 $echo "$modename: option \`$prevopt' requires an argument" 1>&2
513 # If this variable is set in any of the actions, the command in it
514 # will be execed at the end. This prevents here-documents from being
515 # left over by shells.
518 if test -z "$show_help"; then
520 # Infer the operation mode.
521 if test -z "$mode"; then
522 $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
523 $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
525 *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
537 *db | *dbx | *strace | *truss)
547 # If we have no mode, but dlfiles were specified, then do execute mode.
548 test -n "$execute_dlfiles" && mode=execute
550 # Just use the default operation mode.
551 if test -z "$mode"; then
552 if test -n "$nonopt"; then
553 $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
555 $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
562 # Only execute mode is allowed to have -dlopen flags.
563 if test -n "$execute_dlfiles" && test "$mode" != execute; then
564 $echo "$modename: unrecognized option \`-dlopen'" 1>&2
569 # Change the help message to a mode-specific one.
571 help="Try \`$modename --help --mode=$mode' for more information."
573 # These modes are in order of execution frequency so that they run quickly.
575 # libtool compile mode
577 modename="$modename: compile"
578 # Get the compilation command and the source file.
580 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
591 # do not "continue". Instead, add this to base_compile
603 # Accept any command-line options.
606 if test -n "$libobj" ; then
607 $echo "$modename: you cannot specify \`-o' more than once" 1>&2
614 -static | -prefer-pic | -prefer-non-pic)
625 arg_mode=arg # the next one goes into the "base_compile" arg list
626 continue # The current "srcfile" will either be retained or
627 ;; # replaced later. I would guess that would be a bug.
630 args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
632 save_ifs="$IFS"; IFS=','
636 # Double-quote args containing other shell metacharacters.
637 # Many Bourne shells cannot handle close brackets correctly
638 # in scan sets, so we specify it separately.
640 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
644 lastarg="$lastarg $arg"
647 lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
649 # Add the arguments to base_compile.
650 base_compile="$base_compile $lastarg"
655 # Accept the current argument as the source file.
656 # The previous "srcfile" becomes the current argument.
663 esac # case $arg_mode
665 # Aesthetically quote the previous argument.
666 lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
669 # Double-quote args containing other shell metacharacters.
670 # Many Bourne shells cannot handle close brackets correctly
671 # in scan sets, so we specify it separately.
672 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
673 lastarg="\"$lastarg\""
677 base_compile="$base_compile $lastarg"
682 $echo "$modename: you must specify an argument for -Xcompile"
686 $echo "$modename: you must specify a target with \`-o'" 1>&2
690 # Get the name of the library object.
691 [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
695 # Recognize several different file suffixes.
696 # If the user specifies -o file.o, it is replaced with file.lo
706 *.class) xform=class ;;
711 *.java) xform=java ;;
714 libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
717 *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
719 $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
724 func_infer_tag $base_compile
726 for arg in $later; do
745 objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
746 xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
747 if test "X$xdir" = "X$obj"; then
752 lobj=${xdir}$objdir/$objname
754 if test -z "$base_compile"; then
755 $echo "$modename: you must specify a compilation command" 1>&2
760 # Delete any leftover library objects.
761 if test "$build_old_libs" = yes; then
762 removelist="$obj $lobj $libobj ${libobj}T"
764 removelist="$lobj $libobj ${libobj}T"
768 trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
770 # On Cygwin there's no "real" PIC flag so we must build both object types
772 cygwin* | mingw* | pw32* | os2*)
776 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
777 # non-PIC code in shared libraries is not supported
781 # Calculate the filename of the output object if compiler does
782 # not support -o with -c
783 if test "$compiler_c_o" = no; then
784 output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
785 lockfile="$output_obj.lock"
786 removelist="$removelist $output_obj $lockfile"
787 trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
794 # Lock this critical section if it is needed
795 # We use this script file to make the link, it avoids creating a new file
796 if test "$need_locks" = yes; then
797 until $run ln "$progpath" "$lockfile" 2>/dev/null; do
798 $show "Waiting for $lockfile to be removed"
801 elif test "$need_locks" = warn; then
802 if test -f "$lockfile"; then
804 *** ERROR, $lockfile exists and contains:
805 `cat $lockfile 2>/dev/null`
807 This indicates that another process is trying to use the same
808 temporary object file, and libtool could not work around it because
809 your compiler does not support \`-c' and \`-o' together. If you
810 repeat this compilation, it may succeed, by chance, but you had better
811 avoid parallel builds (make -j) in this platform, or get a better
817 $echo $srcfile > "$lockfile"
820 if test -n "$fix_srcfile_path"; then
821 eval srcfile=\"$fix_srcfile_path\"
824 $run $rm "$libobj" "${libobj}T"
826 # Create a libtool object file (analogous to a ".la" file),
827 # but don't create it if we're doing a dry run.
828 test -z "$run" && cat > ${libobj}T <<EOF
829 # $libobj - a libtool object file
830 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
832 # Please DO NOT delete this file!
833 # It is necessary for linking the library.
835 # Name of the PIC object.
838 # Only build a PIC object if we are building libtool libraries.
839 if test "$build_libtool_libs" = yes; then
840 # Without this assignment, base_compile gets emptied.
841 fbsd_hideous_sh_bug=$base_compile
843 if test "$pic_mode" != no; then
844 command="$base_compile $srcfile $pic_flag"
846 # Don't build PIC code
847 command="$base_compile $srcfile"
850 if test ! -d "${xdir}$objdir"; then
851 $show "$mkdir ${xdir}$objdir"
852 $run $mkdir ${xdir}$objdir
854 if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
859 if test -z "$output_obj"; then
860 # Place PIC objects in $objdir
861 command="$command -o $lobj"
864 $run $rm "$lobj" "$output_obj"
867 if $run eval "$command"; then :
869 test -n "$output_obj" && $run $rm $removelist
873 if test "$need_locks" = warn &&
874 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
876 *** ERROR, $lockfile contains:
877 `cat $lockfile 2>/dev/null`
879 but it should contain:
882 This indicates that another process is trying to use the same
883 temporary object file, and libtool could not work around it because
884 your compiler does not support \`-c' and \`-o' together. If you
885 repeat this compilation, it may succeed, by chance, but you had better
886 avoid parallel builds (make -j) in this platform, or get a better
893 # Just move the object if needed, then go on to compile the next one
894 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
895 $show "$mv $output_obj $lobj"
896 if $run $mv $output_obj $lobj; then :
904 # Append the name of the PIC object to the libtool object file.
905 test -z "$run" && cat >> ${libobj}T <<EOF
906 pic_object='$objdir/$objname'
910 # Allow error messages only from the first compilation.
911 if test "$suppress_opt" = yes; then
912 suppress_output=' >/dev/null 2>&1'
915 # No PIC object so indicate it doesn't exist in the libtool
917 test -z "$run" && cat >> ${libobj}T <<EOF
923 # Only build a position-dependent object if we build old libraries.
924 if test "$build_old_libs" = yes; then
925 if test "$pic_mode" != yes; then
926 # Don't build PIC code
927 command="$base_compile $srcfile"
929 command="$base_compile $srcfile $pic_flag"
931 if test "$compiler_c_o" = yes; then
932 command="$command -o $obj"
935 # Suppress compiler output if we already did a PIC compilation.
936 command="$command$suppress_output"
937 $run $rm "$obj" "$output_obj"
939 if $run eval "$command"; then :
945 if test "$need_locks" = warn &&
946 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
948 *** ERROR, $lockfile contains:
949 `cat $lockfile 2>/dev/null`
951 but it should contain:
954 This indicates that another process is trying to use the same
955 temporary object file, and libtool could not work around it because
956 your compiler does not support \`-c' and \`-o' together. If you
957 repeat this compilation, it may succeed, by chance, but you had better
958 avoid parallel builds (make -j) in this platform, or get a better
965 # Just move the object if needed
966 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
967 $show "$mv $output_obj $obj"
968 if $run $mv $output_obj $obj; then :
976 # Append the name of the non-PIC object the libtool object file.
977 # Only append if the libtool object file exists.
978 test -z "$run" && cat >> ${libobj}T <<EOF
979 # Name of the non-PIC object.
980 non_pic_object='$objname'
984 # Append the name of the non-PIC object the libtool object file.
985 # Only append if the libtool object file exists.
986 test -z "$run" && cat >> ${libobj}T <<EOF
987 # Name of the non-PIC object.
993 $run $mv "${libobj}T" "${libobj}"
995 # Unlock the critical section if it was locked
996 if test "$need_locks" != no; then
1005 modename="$modename: link"
1007 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1008 # It is impossible to link a dll without this setting, and
1009 # we shouldn't force the makefile maintainer to figure out
1010 # which system we are compiling for in order to pass an extra
1011 # flag for every libtool invocation.
1012 # allow_undefined=no
1014 # FIXME: Unfortunately, there are problems with the above when trying
1015 # to make a dll which has undefined symbols, in which case not
1016 # even a static library is built. For now, we need to specify
1017 # -no-undefined on the libtool link line when we can be certain
1018 # that all symbols are satisfied, otherwise we get a static library.
1025 libtool_args="$nonopt"
1026 base_compile="$nonopt $@"
1027 compile_command="$nonopt"
1028 finalize_command="$nonopt"
1041 lib_search_path=`pwd`
1050 export_symbols_regex=
1058 precious_files_regex=
1059 prefer_static_libs=no
1072 func_infer_tag $base_compile
1074 # We need to know -static, to get the right output filenames.
1078 -all-static | -static)
1079 if test "X$arg" = "X-all-static"; then
1080 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1081 $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1083 if test -n "$link_static_flag"; then
1084 dlopen_self=$dlopen_self_static
1087 if test -z "$pic_flag" && test -n "$link_static_flag"; then
1088 dlopen_self=$dlopen_self_static
1091 build_libtool_libs=no
1093 prefer_static_libs=yes
1099 # See if our shared archives depend on static archives.
1100 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
1102 # Go through the arguments, transforming them on the way.
1103 while test "$#" -gt 0; do
1107 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1108 qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1112 libtool_args="$libtool_args $qarg"
1114 # If the previous option needs an argument, assign it.
1115 if test -n "$prev"; then
1118 compile_command="$compile_command @OUTPUT@"
1119 finalize_command="$finalize_command @OUTPUT@"
1125 if test "$preload" = no; then
1126 # Add the symbol object into the linking commands.
1127 compile_command="$compile_command @SYMFILE@"
1128 finalize_command="$finalize_command @SYMFILE@"
1132 *.la | *.lo) ;; # We handle these cases below.
1134 if test "$dlself" = no; then
1142 if test "$prev" = dlprefiles; then
1144 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1154 if test "$prev" = dlfiles; then
1155 dlfiles="$dlfiles $arg"
1157 dlprefiles="$dlprefiles $arg"
1165 export_symbols="$arg"
1166 if test ! -f "$arg"; then
1167 $echo "$modename: symbol file \`$arg' does not exist"
1174 export_symbols_regex="$arg"
1179 inst_prefix_dir="$arg"
1184 precious_files_regex="$arg"
1194 if test -f "$arg"; then
1197 for fil in `cat $save_arg`
1199 # moreargs="$moreargs $fil"
1201 # A libtool-controlled object.
1203 # Check to see that this really is a libtool object.
1204 if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1209 # If there is no directory component, then add one.
1211 */* | *\\*) . $arg ;;
1215 if test -z "$pic_object" || \
1216 test -z "$non_pic_object" ||
1217 test "$pic_object" = none && \
1218 test "$non_pic_object" = none; then
1219 $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1223 # Extract subdirectory from the argument.
1224 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1225 if test "X$xdir" = "X$arg"; then
1231 if test "$pic_object" != none; then
1232 # Prepend the subdirectory the object is found in.
1233 pic_object="$xdir$pic_object"
1235 if test "$prev" = dlfiles; then
1236 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1237 dlfiles="$dlfiles $pic_object"
1241 # If libtool objects are unsupported, then we need to preload.
1246 # CHECK ME: I think I busted this. -Ossama
1247 if test "$prev" = dlprefiles; then
1248 # Preload the old-style object.
1249 dlprefiles="$dlprefiles $pic_object"
1254 libobjs="$libobjs $pic_object"
1259 if test "$non_pic_object" != none; then
1260 # Prepend the subdirectory the object is found in.
1261 non_pic_object="$xdir$non_pic_object"
1263 # A standard non-PIC object
1264 non_pic_objects="$non_pic_objects $non_pic_object"
1265 if test -z "$pic_object" || test "$pic_object" = none ; then
1266 arg="$non_pic_object"
1270 # Only an error if not doing a dry-run.
1271 if test -z "$run"; then
1272 $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1277 # Extract subdirectory from the argument.
1278 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1279 if test "X$xdir" = "X$arg"; then
1285 pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1286 non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1287 libobjs="$libobjs $pic_object"
1288 non_pic_objects="$non_pic_objects $non_pic_object"
1293 $echo "$modename: link input file \`$save_arg' does not exist"
1301 # We need an absolute path.
1303 [\\/]* | [A-Za-z]:[\\/]*) ;;
1305 $echo "$modename: only absolute run-paths are allowed" 1>&2
1309 if test "$prev" = rpath; then
1312 *) rpath="$rpath $arg" ;;
1317 *) xrpath="$xrpath $arg" ;;
1324 compiler_flags="$compiler_flags $qarg"
1326 compile_command="$compile_command $qarg"
1327 finalize_command="$finalize_command $qarg"
1331 linker_flags="$linker_flags $qarg"
1332 compiler_flags="$compiler_flags $wl$qarg"
1334 compile_command="$compile_command $wl$qarg"
1335 finalize_command="$finalize_command $wl$qarg"
1339 linker_flags="$linker_flags $qarg"
1340 compiler_flags="$compiler_flags $qarg"
1342 compile_command="$compile_command $qarg"
1343 finalize_command="$finalize_command $qarg"
1352 eval "$prev=\"\$arg\""
1357 fi # test -n "$prev"
1363 if test -n "$link_static_flag"; then
1364 compile_command="$compile_command $link_static_flag"
1365 finalize_command="$finalize_command $link_static_flag"
1371 # FIXME: remove this flag sometime in the future.
1372 $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1396 -export-symbols | -export-symbols-regex)
1397 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1398 $echo "$modename: more than one -exported-symbols argument is not allowed"
1401 if test "X$arg" = "X-export-symbols"; then
1414 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1415 # so, if we see these flags be careful not to treat them like -L
1417 case $with_gcc/$host in
1418 no/*-*-irix* | /*-*-irix*)
1419 compile_command="$compile_command $arg"
1420 finalize_command="$finalize_command $arg"
1427 dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1428 # We need an absolute path.
1430 [\\/]* | [A-Za-z]:[\\/]*) ;;
1432 absdir=`cd "$dir" && pwd`
1433 if test -z "$absdir"; then
1434 $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1443 deplibs="$deplibs -L$dir"
1444 lib_search_path="$lib_search_path $dir"
1448 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1449 case :$dllsearchpath: in
1451 *) dllsearchpath="$dllsearchpath:$dir";;
1459 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1461 *-*-cygwin* | *-*-pw32* | *-*-beos*)
1462 # These systems don't actually have a C or math library (as such)
1465 *-*-mingw* | *-*-os2*)
1466 # These systems don't actually have a C library (as such)
1467 test "X$arg" = "X-lc" && continue
1469 *-*-openbsd* | *-*-freebsd*)
1470 # Do not include libc due to us having libc/libc_r.
1471 test "X$arg" = "X-lc" && continue
1473 *-*-rhapsody* | *-*-darwin1.[012])
1474 # Rhapsody C and math libraries are in the System framework
1475 deplibs="$deplibs -framework System"
1478 elif test "X$arg" = "X-lc_r"; then
1480 *-*-openbsd* | *-*-freebsd*)
1481 # Do not include libc_r directly, use -pthread flag.
1486 deplibs="$deplibs $arg"
1490 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1491 deplibs="$deplibs $arg"
1500 # gcc -m* arguments should be passed to the linker via $compiler_flags
1501 # in order to pass architecture information to the linker
1502 # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
1503 # but this is not reliable with gcc because gcc may use -mfoo to
1504 # select a different linker, different libraries, etc, while
1505 # -Wl,-mfoo simply passes -mfoo to the linker.
1507 # Unknown arguments in both finalize_command and compile_command need
1508 # to be aesthetically quoted because they are evaled later.
1509 arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1511 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1515 compile_command="$compile_command $arg"
1516 finalize_command="$finalize_command $arg"
1517 if test "$with_gcc" = "yes" ; then
1518 compiler_flags="$compiler_flags $arg"
1535 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1536 # The PATH hackery in wrapper scripts is required on Windows
1537 # in order for the loader to find any dlls it needs.
1538 $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
1539 $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
1542 *) no_install=yes ;;
1559 -precious-files-regex)
1580 dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1581 # We need an absolute path.
1583 [\\/]* | [A-Za-z]:[\\/]*) ;;
1585 $echo "$modename: only absolute run-paths are allowed" 1>&2
1591 *) xrpath="$xrpath $dir" ;;
1597 # The effects of -static are defined in a previous loop.
1598 # We used to do the same as -all-static on platforms that
1599 # didn't have a PIC flag, but the assumption that the effects
1600 # would be equivalent was wrong. It would break on at least
1601 # Digital Unix and AIX.
1621 args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1623 save_ifs="$IFS"; IFS=','
1624 for flag in $args; do
1627 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1632 compiler_flags="$compiler_flags $flag"
1635 arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1639 args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
1641 save_ifs="$IFS"; IFS=','
1642 for flag in $args; do
1645 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1650 compiler_flags="$compiler_flags $wl$flag"
1651 linker_flags="$linker_flags $flag"
1654 arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1672 # Some other compiler flag.
1674 # Unknown arguments in both finalize_command and compile_command need
1675 # to be aesthetically quoted because they are evaled later.
1676 arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1678 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1685 # A standard object.
1690 # A libtool-controlled object.
1692 # Check to see that this really is a libtool object.
1693 if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1698 # If there is no directory component, then add one.
1700 */* | *\\*) . $arg ;;
1704 if test -z "$pic_object" || \
1705 test -z "$non_pic_object" ||
1706 test "$pic_object" = none && \
1707 test "$non_pic_object" = none; then
1708 $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1712 # Extract subdirectory from the argument.
1713 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1714 if test "X$xdir" = "X$arg"; then
1720 if test "$pic_object" != none; then
1721 # Prepend the subdirectory the object is found in.
1722 pic_object="$xdir$pic_object"
1724 if test "$prev" = dlfiles; then
1725 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1726 dlfiles="$dlfiles $pic_object"
1730 # If libtool objects are unsupported, then we need to preload.
1735 # CHECK ME: I think I busted this. -Ossama
1736 if test "$prev" = dlprefiles; then
1737 # Preload the old-style object.
1738 dlprefiles="$dlprefiles $pic_object"
1743 libobjs="$libobjs $pic_object"
1748 if test "$non_pic_object" != none; then
1749 # Prepend the subdirectory the object is found in.
1750 non_pic_object="$xdir$non_pic_object"
1752 # A standard non-PIC object
1753 non_pic_objects="$non_pic_objects $non_pic_object"
1754 if test -z "$pic_object" || test "$pic_object" = none ; then
1755 arg="$non_pic_object"
1759 # Only an error if not doing a dry-run.
1760 if test -z "$run"; then
1761 $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1766 # Extract subdirectory from the argument.
1767 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1768 if test "X$xdir" = "X$arg"; then
1774 pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1775 non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1776 libobjs="$libobjs $pic_object"
1777 non_pic_objects="$non_pic_objects $non_pic_object"
1784 deplibs="$deplibs $arg"
1785 old_deplibs="$old_deplibs $arg"
1790 # A libtool-controlled library.
1792 if test "$prev" = dlfiles; then
1793 # This library was specified with -dlopen.
1794 dlfiles="$dlfiles $arg"
1796 elif test "$prev" = dlprefiles; then
1797 # The library was specified with -dlpreopen.
1798 dlprefiles="$dlprefiles $arg"
1801 deplibs="$deplibs $arg"
1806 # Some other compiler argument.
1808 # Unknown arguments in both finalize_command and compile_command need
1809 # to be aesthetically quoted because they are evaled later.
1810 arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1812 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1819 # Now actually substitute the argument into the commands.
1820 if test -n "$arg"; then
1821 compile_command="$compile_command $arg"
1822 finalize_command="$finalize_command $arg"
1824 done # argument parsing loop
1826 if test -n "$prev"; then
1827 $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
1832 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
1833 eval arg=\"$export_dynamic_flag_spec\"
1834 compile_command="$compile_command $arg"
1835 finalize_command="$finalize_command $arg"
1839 # calculate the name of the file, without its directory
1840 outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
1841 libobjs_save="$libobjs"
1843 if test -n "$shlibpath_var"; then
1844 # get the directories listed in $shlibpath_var
1845 eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
1849 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
1850 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
1852 output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
1853 if test "X$output_objdir" = "X$output"; then
1854 output_objdir="$objdir"
1856 output_objdir="$output_objdir/$objdir"
1858 # Create the object directory.
1859 if test ! -d "$output_objdir"; then
1860 $show "$mkdir $output_objdir"
1861 $run $mkdir $output_objdir
1863 if test "$status" -ne 0 && test ! -d "$output_objdir"; then
1868 # Determine the type of output
1871 $echo "$modename: you must specify an output file" 1>&2
1875 *.$libext) linkmode=oldlib ;;
1876 *.lo | *.$objext) linkmode=obj ;;
1877 *.la) linkmode=lib ;;
1878 *) linkmode=prog ;; # Anything else should be a program.
1882 *cygwin* | *mingw* | *pw32*)
1883 # don't eliminate duplications in $postdeps and $predeps
1884 duplicate_compiler_generated_deps=yes
1887 duplicate_compiler_generated_deps=$duplicate_deps
1893 # Find all interdependent deplibs by searching for libraries
1894 # that are linked more than once (e.g. -la -lb -la)
1895 for deplib in $deplibs; do
1896 if test "X$duplicate_deps" = "Xyes" ; then
1898 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
1901 libs="$libs $deplib"
1904 if test "$linkmode" = lib; then
1905 libs="$predeps $libs $compiler_lib_search_path $postdeps"
1907 # Compute libraries that are listed more than once in $predeps
1908 # $postdeps and mark them as special (i.e., whose duplicates are
1909 # not to be eliminated).
1911 if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
1912 for pre_post_dep in $predeps $postdeps; do
1913 case "$pre_post_deps " in
1914 *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
1916 pre_post_deps="$pre_post_deps $pre_post_dep"
1925 need_relink=no # whether we're linking any uninstalled libtool libraries
1926 notinst_deplibs= # not-installed libtool libraries
1927 notinst_path= # paths that contain not-installed libtool libraries
1931 for file in $dlfiles $dlprefiles; do
1935 $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
1947 passes="conv scan dlopen dlpreopen link"
1952 for pass in $passes; do
1953 if test "$linkmode,$pass" = "lib,link" ||
1954 test "$linkmode,$pass" = "prog,scan"; then
1958 if test "$linkmode" = prog; then
1960 dlopen) libs="$dlfiles" ;;
1961 dlpreopen) libs="$dlprefiles" ;;
1962 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
1965 if test "$pass" = dlopen; then
1966 # Collect dlpreopened libraries
1967 save_deplibs="$deplibs"
1970 for deplib in $libs; do
1974 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1975 if test "$linkmode,$pass" = "prog,link"; then
1976 compile_deplibs="$deplib $compile_deplibs"
1977 finalize_deplibs="$deplib $finalize_deplibs"
1979 deplibs="$deplib $deplibs"
1984 if test "$linkmode" != lib && test "$linkmode" != prog; then
1985 $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
1988 if test "$pass" = conv; then
1989 deplibs="$deplib $deplibs"
1992 name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
1993 for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
1994 for search_ext in .la $std_shrext .so .a; do
1995 # Search the libtool library
1996 lib="$searchdir/lib${name}${search_ext}"
1997 if test -f "$lib"; then
1998 if test "$search_ext" = ".la"; then
2007 if test "$found" != yes; then
2008 # deplib doesn't seem to be a libtool library
2009 if test "$linkmode,$pass" = "prog,link"; then
2010 compile_deplibs="$deplib $compile_deplibs"
2011 finalize_deplibs="$deplib $finalize_deplibs"
2013 deplibs="$deplib $deplibs"
2014 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2017 else # deplib is a libtool library
2018 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2019 # We need to do some special things here, and not later.
2020 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2021 case " $predeps $postdeps " in
2023 if (${SED} -e '2q' $lib |
2024 grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2028 */* | *\\*) . $lib ;;
2031 for l in $old_library $library_names; do
2034 if test "X$ll" = "X$old_library" ; then # only static version available
2036 ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2037 test "X$ladir" = "X$lib" && ladir="."
2038 lib=$ladir/$old_library
2039 if test "$linkmode,$pass" = "prog,link"; then
2040 compile_deplibs="$deplib $compile_deplibs"
2041 finalize_deplibs="$deplib $finalize_deplibs"
2043 deplibs="$deplib $deplibs"
2044 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2058 deplibs="$deplib $deplibs"
2059 test "$pass" = conv && continue
2060 newdependency_libs="$deplib $newdependency_libs"
2061 newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2064 if test "$pass" = conv; then
2065 deplibs="$deplib $deplibs"
2068 if test "$pass" = scan; then
2069 deplibs="$deplib $deplibs"
2071 compile_deplibs="$deplib $compile_deplibs"
2072 finalize_deplibs="$deplib $finalize_deplibs"
2074 newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2077 $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2083 if test "$pass" = link; then
2084 dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2085 # Make sure the xrpath contains only unique directories.
2088 *) xrpath="$xrpath $dir" ;;
2091 deplibs="$deplib $deplibs"
2094 *.la) lib="$deplib" ;;
2096 if test "$pass" = conv; then
2097 deplibs="$deplib $deplibs"
2103 case $deplibs_check_method in
2105 set dummy $deplibs_check_method
2106 match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2107 if eval $echo \"$deplib\" 2>/dev/null \
2109 | $EGREP "$match_pattern_regex" > /dev/null; then
2117 if test "$valid_a_lib" != yes; then
2119 $echo "*** Warning: Trying to link with static lib archive $deplib."
2120 $echo "*** I have the capability to make that library automatically link in when"
2121 $echo "*** you link to this library. But I can only do this if you have a"
2122 $echo "*** shared version of the library, which you do not appear to have"
2123 $echo "*** because the file extensions .$libext of this argument makes me believe"
2124 $echo "*** that it is just a static archive that I should not used here."
2127 $echo "*** Warning: Linking the shared library $output against the"
2128 $echo "*** static library $deplib is not portable!"
2129 deplibs="$deplib $deplibs"
2134 if test "$pass" != link; then
2135 deplibs="$deplib $deplibs"
2137 compile_deplibs="$deplib $compile_deplibs"
2138 finalize_deplibs="$deplib $finalize_deplibs"
2145 if test "$pass" = conv; then
2146 deplibs="$deplib $deplibs"
2147 elif test "$linkmode" = prog; then
2148 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2149 # If there is no dlopen support or we're linking statically,
2150 # we need to preload.
2151 newdlprefiles="$newdlprefiles $deplib"
2152 compile_deplibs="$deplib $compile_deplibs"
2153 finalize_deplibs="$deplib $finalize_deplibs"
2155 newdlfiles="$newdlfiles $deplib"
2165 if test "$found" = yes || test -f "$lib"; then :
2167 $echo "$modename: cannot find the library \`$lib'" 1>&2
2171 # Check to see that this really is a libtool archive.
2172 if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2174 $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2178 ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2179 test "X$ladir" = "X$lib" && ladir="."
2187 # If the library was installed with an old release of libtool,
2188 # it will not redefine variables installed, or shouldnotlink
2194 */* | *\\*) . $lib ;;
2198 if test "$linkmode,$pass" = "lib,link" ||
2199 test "$linkmode,$pass" = "prog,scan" ||
2200 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2201 test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2202 test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2205 if test "$pass" = conv; then
2206 # Only check for convenience libraries
2207 deplibs="$lib $deplibs"
2208 if test -z "$libdir"; then
2209 if test -z "$old_library"; then
2210 $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2213 # It is a libtool convenience library, so add in its objects.
2214 convenience="$convenience $ladir/$objdir/$old_library"
2215 old_convenience="$old_convenience $ladir/$objdir/$old_library"
2217 for deplib in $dependency_libs; do
2218 deplibs="$deplib $deplibs"
2219 if test "X$duplicate_deps" = "Xyes" ; then
2220 case "$tmp_libs " in
2221 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2224 tmp_libs="$tmp_libs $deplib"
2226 elif test "$linkmode" != prog && test "$linkmode" != lib; then
2227 $echo "$modename: \`$lib' is not a convenience library" 1>&2
2234 # Get the name of the library we link against.
2236 for l in $old_library $library_names; do
2239 if test -z "$linklib"; then
2240 $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2244 # This library was specified with -dlopen.
2245 if test "$pass" = dlopen; then
2246 if test -z "$libdir"; then
2247 $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2250 if test -z "$dlname" ||
2251 test "$dlopen_support" != yes ||
2252 test "$build_libtool_libs" = no; then
2253 # If there is no dlname, no dlopen support or we're linking
2254 # statically, we need to preload. We also need to preload any
2255 # dependent libraries so libltdl's deplib preloader doesn't
2256 # bomb out in the load deplibs phase.
2257 dlprefiles="$dlprefiles $lib $dependency_libs"
2259 newdlfiles="$newdlfiles $lib"
2264 # We need an absolute path.
2266 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
2268 abs_ladir=`cd "$ladir" && pwd`
2269 if test -z "$abs_ladir"; then
2270 $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
2271 $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
2276 laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
2278 # Find the relevant object directory and library name.
2279 if test "X$installed" = Xyes; then
2280 if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2281 $echo "$modename: warning: library \`$lib' was moved." 1>&2
2290 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2293 # Remove this search path later
2294 notinst_path="$notinst_path $abs_ladir"
2296 dir="$ladir/$objdir"
2297 absdir="$abs_ladir/$objdir"
2298 # Remove this search path later
2299 notinst_path="$notinst_path $abs_ladir"
2301 fi # $installed = yes
2302 name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2304 # This library was specified with -dlpreopen.
2305 if test "$pass" = dlpreopen; then
2306 if test -z "$libdir"; then
2307 $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2310 # Prefer using a static library (so that no silly _DYNAMIC symbols
2311 # are required to link).
2312 if test -n "$old_library"; then
2313 newdlprefiles="$newdlprefiles $dir/$old_library"
2314 # Otherwise, use the dlname, so that lt_dlopen finds it.
2315 elif test -n "$dlname"; then
2316 newdlprefiles="$newdlprefiles $dir/$dlname"
2318 newdlprefiles="$newdlprefiles $dir/$linklib"
2320 fi # $pass = dlpreopen
2322 if test -z "$libdir"; then
2323 # Link the convenience library
2324 if test "$linkmode" = lib; then
2325 deplibs="$dir/$old_library $deplibs"
2326 elif test "$linkmode,$pass" = "prog,link"; then
2327 compile_deplibs="$dir/$old_library $compile_deplibs"
2328 finalize_deplibs="$dir/$old_library $finalize_deplibs"
2330 deplibs="$lib $deplibs" # used for prog,scan pass
2336 if test "$linkmode" = prog && test "$pass" != link; then
2337 newlib_search_path="$newlib_search_path $ladir"
2338 deplibs="$lib $deplibs"
2341 if test "$link_all_deplibs" != no || test -z "$library_names" ||
2342 test "$build_libtool_libs" = no; then
2347 for deplib in $dependency_libs; do
2349 -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2351 # Need to link against all dependency_libs?
2352 if test "$linkalldeplibs" = yes; then
2353 deplibs="$deplib $deplibs"
2355 # Need to hardcode shared library paths
2356 # or/and link against static libraries
2357 newdependency_libs="$deplib $newdependency_libs"
2359 if test "X$duplicate_deps" = "Xyes" ; then
2360 case "$tmp_libs " in
2361 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2364 tmp_libs="$tmp_libs $deplib"
2367 fi # $linkmode = prog...
2369 if test "$linkmode,$pass" = "prog,link"; then
2370 if test -n "$library_names" &&
2371 { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2372 # We need to hardcode the library path
2373 if test -n "$shlibpath_var"; then
2374 # Make sure the rpath contains only unique directories.
2375 case "$temp_rpath " in
2378 *) temp_rpath="$temp_rpath $dir" ;;
2382 # Hardcode the library path.
2383 # Skip directories that are in the system default run-time
2385 case " $sys_lib_dlsearch_path " in
2388 case "$compile_rpath " in
2390 *) compile_rpath="$compile_rpath $absdir"
2394 case " $sys_lib_dlsearch_path " in
2397 case "$finalize_rpath " in
2399 *) finalize_rpath="$finalize_rpath $libdir"
2403 fi # $linkmode,$pass = prog,link...
2405 if test "$alldeplibs" = yes &&
2406 { test "$deplibs_check_method" = pass_all ||
2407 { test "$build_libtool_libs" = yes &&
2408 test -n "$library_names"; }; }; then
2409 # We only need to search for static libraries
2414 link_static=no # Whether the deplib will be linked statically
2415 if test -n "$library_names" &&
2416 { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2417 if test "$installed" = no; then
2418 notinst_deplibs="$notinst_deplibs $lib"
2421 # This is a shared library
2423 # Warn about portability, can't link against -module's on
2424 # some systems (darwin)
2425 if test "$shouldnotlink" = yes && test "$pass" = link ; then
2427 if test "$linkmode" = prog; then
2428 $echo "*** Warning: Linking the executable $output against the loadable module"
2430 $echo "*** Warning: Linking the shared library $output against the loadable module"
2432 $echo "*** $linklib is not portable!"
2434 if test "$linkmode" = lib &&
2435 test "$hardcode_into_libs" = yes; then
2436 # Hardcode the library path.
2437 # Skip directories that are in the system default run-time
2439 case " $sys_lib_dlsearch_path " in
2442 case "$compile_rpath " in
2444 *) compile_rpath="$compile_rpath $absdir"
2448 case " $sys_lib_dlsearch_path " in
2451 case "$finalize_rpath " in
2453 *) finalize_rpath="$finalize_rpath $libdir"
2459 if test -n "$old_archive_from_expsyms_cmds"; then
2460 # figure out the soname
2461 set dummy $library_names
2464 libname=`eval \\$echo \"$libname_spec\"`
2465 # use dlname if we got it. it's perfectly good, no?
2466 if test -n "$dlname"; then
2468 elif test -n "$soname_spec"; then
2472 major=`expr $current - $age`
2476 eval soname=\"$soname_spec\"
2481 # Make a new name for the extract_expsyms_cmds to use
2483 soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2484 newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
2486 # If the library has no export list, then create one now
2487 if test -f "$output_objdir/$soname-def"; then :
2489 $show "extracting exported symbol list from \`$soname'"
2490 save_ifs="$IFS"; IFS='~'
2491 cmds=$extract_expsyms_cmds
2492 for cmd in $cmds; do
2496 $run eval "$cmd" || exit $?
2502 if test -f "$output_objdir/$newlib"; then :; else
2503 $show "generating import library for \`$soname'"
2504 save_ifs="$IFS"; IFS='~'
2505 cmds=$old_archive_from_expsyms_cmds
2506 for cmd in $cmds; do
2510 $run eval "$cmd" || exit $?
2514 # make sure the library variables are pointing to the new library
2517 fi # test -n "$old_archive_from_expsyms_cmds"
2519 if test "$linkmode" = prog || test "$mode" != relink; then
2524 case $hardcode_action in
2525 immediate | unsupported)
2526 if test "$hardcode_direct" = no; then
2529 *-*-sco3.2v5* ) add_dir="-L$dir" ;;
2531 # if the lib is a module then we can not link against
2532 # it, someone is ignoring the new warnings I added
2533 if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2534 $echo "** Warning, lib $linklib is a module, not a shared library"
2535 if test -z "$old_library" ; then
2537 $echo "** And there doesn't seem to be a static archive available"
2538 $echo "** The link will probably fail, sorry"
2540 add="$dir/$old_library"
2544 elif test "$hardcode_minus_L" = no; then
2546 *-*-sunos*) add_shlibpath="$dir" ;;
2550 elif test "$hardcode_shlibpath_var" = no; then
2551 add_shlibpath="$dir"
2558 if test "$hardcode_direct" = yes; then
2560 elif test "$hardcode_minus_L" = yes; then
2562 # Try looking first in the location we're being installed to.
2563 if test -n "$inst_prefix_dir"; then
2566 add_dir="$add_dir -L$inst_prefix_dir$libdir"
2571 elif test "$hardcode_shlibpath_var" = yes; then
2572 add_shlibpath="$dir"
2581 if test "$lib_linked" != yes; then
2582 $echo "$modename: configuration error: unsupported hardcode properties"
2586 if test -n "$add_shlibpath"; then
2587 case :$compile_shlibpath: in
2588 *":$add_shlibpath:"*) ;;
2589 *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2592 if test "$linkmode" = prog; then
2593 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2594 test -n "$add" && compile_deplibs="$add $compile_deplibs"
2596 test -n "$add_dir" && deplibs="$add_dir $deplibs"
2597 test -n "$add" && deplibs="$add $deplibs"
2598 if test "$hardcode_direct" != yes && \
2599 test "$hardcode_minus_L" != yes && \
2600 test "$hardcode_shlibpath_var" = yes; then
2601 case :$finalize_shlibpath: in
2603 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2609 if test "$linkmode" = prog || test "$mode" = relink; then
2613 # Finalize command for both is simple: just hardcode it.
2614 if test "$hardcode_direct" = yes; then
2615 add="$libdir/$linklib"
2616 elif test "$hardcode_minus_L" = yes; then
2619 elif test "$hardcode_shlibpath_var" = yes; then
2620 case :$finalize_shlibpath: in
2622 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2625 elif test "$hardcode_automatic" = yes; then
2626 if test -n "$inst_prefix_dir" &&
2627 test -f "$inst_prefix_dir$libdir/$linklib" ; then
2628 add="$inst_prefix_dir$libdir/$linklib"
2630 add="$libdir/$linklib"
2633 # We cannot seem to hardcode it, guess we'll fake it.
2635 # Try looking first in the location we're being installed to.
2636 if test -n "$inst_prefix_dir"; then
2639 add_dir="$add_dir -L$inst_prefix_dir$libdir"
2646 if test "$linkmode" = prog; then
2647 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2648 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2650 test -n "$add_dir" && deplibs="$add_dir $deplibs"
2651 test -n "$add" && deplibs="$add $deplibs"
2654 elif test "$linkmode" = prog; then
2655 # Here we assume that one of hardcode_direct or hardcode_minus_L
2656 # is not unsupported. This is valid on all known static and
2658 if test "$hardcode_direct" != unsupported; then
2659 test -n "$old_library" && linklib="$old_library"
2660 compile_deplibs="$dir/$linklib $compile_deplibs"
2661 finalize_deplibs="$dir/$linklib $finalize_deplibs"
2663 compile_deplibs="-l$name -L$dir $compile_deplibs"
2664 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
2666 elif test "$build_libtool_libs" = yes; then
2667 # Not a shared library
2668 if test "$deplibs_check_method" != pass_all; then
2669 # We're trying link a shared library against a static one
2670 # but the system doesn't support it.
2672 # Just print a warning and add the library to dependency_libs so
2673 # that the program can be linked against the static library.
2675 $echo "*** Warning: This system can not link to static lib archive $lib."
2676 $echo "*** I have the capability to make that library automatically link in when"
2677 $echo "*** you link to this library. But I can only do this if you have a"
2678 $echo "*** shared version of the library, which you do not appear to have."
2679 if test "$module" = yes; then
2680 $echo "*** But as you try to build a module library, libtool will still create "
2681 $echo "*** a static module, that should work as long as the dlopening application"
2682 $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2683 if test -z "$global_symbol_pipe"; then
2685 $echo "*** However, this would only work if libtool was able to extract symbol"
2686 $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2687 $echo "*** not find such a program. So, this module is probably useless."
2688 $echo "*** \`nm' from GNU binutils and a full rebuild may help."
2690 if test "$build_old_libs" = no; then
2691 build_libtool_libs=module
2694 build_libtool_libs=no
2698 convenience="$convenience $dir/$old_library"
2699 old_convenience="$old_convenience $dir/$old_library"
2700 deplibs="$dir/$old_library $deplibs"
2703 fi # link shared/static library?
2705 if test "$linkmode" = lib; then
2706 if test -n "$dependency_libs" &&
2707 { test "$hardcode_into_libs" != yes ||
2708 test "$build_old_libs" = yes ||
2709 test "$link_static" = yes; }; then
2710 # Extract -R from dependency_libs
2712 for libdir in $dependency_libs; do
2714 -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
2716 *" $temp_xrpath "*) ;;
2717 *) xrpath="$xrpath $temp_xrpath";;
2719 *) temp_deplibs="$temp_deplibs $libdir";;
2722 dependency_libs="$temp_deplibs"
2725 newlib_search_path="$newlib_search_path $absdir"
2726 # Link against this library
2727 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
2728 # ... and its dependency_libs
2730 for deplib in $dependency_libs; do
2731 newdependency_libs="$deplib $newdependency_libs"
2732 if test "X$duplicate_deps" = "Xyes" ; then
2733 case "$tmp_libs " in
2734 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2737 tmp_libs="$tmp_libs $deplib"
2740 if test "$link_all_deplibs" != no; then
2741 # Add the search paths of all dependency libraries
2742 for deplib in $dependency_libs; do
2744 -L*) path="$deplib" ;;
2746 dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
2747 test "X$dir" = "X$deplib" && dir="."
2748 # We need an absolute path.
2750 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
2752 absdir=`cd "$dir" && pwd`
2753 if test -z "$absdir"; then
2754 $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
2759 if grep "^installed=no" $deplib > /dev/null; then
2760 path="$absdir/$objdir"
2762 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2763 if test -z "$libdir"; then
2764 $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2767 if test "$absdir" != "$libdir"; then
2768 $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2775 # we do not want to link against static libs,
2776 # but need to link against shared
2777 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2778 if test -n "$deplibrary_names" ; then
2779 for tmp in $deplibrary_names ; do
2782 if test -f "$path/$depdepl" ; then
2783 depdepl="$path/$depdepl"
2785 # do not add paths which are already there
2786 case " $newlib_search_path " in
2788 *) newlib_search_path="$newlib_search_path $path";;
2801 # Again, we only want to link against shared libraries
2802 eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2803 for tmp in $newlib_search_path ; do
2804 if test -f "$tmp/lib$tmp_libs.dylib" ; then
2805 eval depdepl="$tmp/lib$tmp_libs.dylib"
2816 case " $deplibs " in
2818 *) deplibs="$depdepl $deplibs" ;;
2820 case " $deplibs " in
2822 *) deplibs="$deplibs $path" ;;
2825 fi # link_all_deplibs != no
2827 done # for deplib in $libs
2828 dependency_libs="$newdependency_libs"
2829 if test "$pass" = dlpreopen; then
2830 # Link the dlpreopened libraries before other libraries
2831 for deplib in $save_deplibs; do
2832 deplibs="$deplib $deplibs"
2835 if test "$pass" != dlopen; then
2836 if test "$pass" != conv; then
2837 # Make sure lib_search_path contains only unique directories.
2839 for dir in $newlib_search_path; do
2840 case "$lib_search_path " in
2842 *) lib_search_path="$lib_search_path $dir" ;;
2848 if test "$linkmode,$pass" != "prog,link"; then
2851 vars="compile_deplibs finalize_deplibs"
2853 for var in $vars dependency_libs; do
2854 # Add libraries to $var in reverse order
2855 eval tmp_libs=\"\$$var\"
2857 for deplib in $tmp_libs; do
2858 # FIXME: Pedantically, this is the right thing to do, so
2859 # that some nasty dependency loop isn't accidentally
2861 #new_libs="$deplib $new_libs"
2862 # Pragmatically, this seems to cause very few problems in
2865 -L*) new_libs="$deplib $new_libs" ;;
2868 # And here is the reason: when a library appears more
2869 # than once as an explicit dependence of a library, or
2870 # is implicitly linked in more than once by the
2871 # compiler, it is considered special, and multiple
2872 # occurrences thereof are not removed. Compare this
2873 # with having the same library being listed as a
2874 # dependency of multiple other libraries: in this case,
2875 # we know (pedantically, we assume) the library does not
2876 # need to be listed more than once, so we keep only the
2877 # last copy. This is not always right, but it is rare
2878 # enough that we require users that really mean to play
2879 # such unportable linking tricks to link the library
2880 # using -Wl,-lname, so that libtool does not consider it
2881 # for duplicate removal.
2882 case " $specialdeplibs " in
2883 *" $deplib "*) new_libs="$deplib $new_libs" ;;
2885 case " $new_libs " in
2887 *) new_libs="$deplib $new_libs" ;;
2895 for deplib in $new_libs; do
2898 case " $tmp_libs " in
2900 *) tmp_libs="$tmp_libs $deplib" ;;
2903 *) tmp_libs="$tmp_libs $deplib" ;;
2906 eval $var=\"$tmp_libs\"
2909 # Last step: remove runtime libs from dependency_libs
2910 # (they stay in deplibs)
2912 for i in $dependency_libs ; do
2913 case " $predeps $postdeps $compiler_lib_search_path " in
2918 if test -n "$i" ; then
2919 tmp_libs="$tmp_libs $i"
2922 dependency_libs=$tmp_libs
2924 if test "$linkmode" = prog; then
2925 dlfiles="$newdlfiles"
2926 dlprefiles="$newdlprefiles"
2931 if test -n "$deplibs"; then
2932 $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
2935 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2936 $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
2939 if test -n "$rpath"; then
2940 $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
2943 if test -n "$xrpath"; then
2944 $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
2947 if test -n "$vinfo"; then
2948 $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
2951 if test -n "$release"; then
2952 $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
2955 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
2956 $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
2959 # Now set the variables for building old libraries.
2960 build_libtool_libs=no
2962 objs="$objs$old_deplibs"
2966 # Make sure we only generate libraries of the form `libNAME.la'.
2969 name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2970 eval shared_ext=\"$shrext_cmds\"
2971 eval libname=\"$libname_spec\"
2974 if test "$module" = no; then
2975 $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
2979 if test "$need_lib_prefix" != no; then
2980 # Add the "lib" prefix for modules if required
2981 name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
2982 eval shared_ext=\"$shrext_cmds\"
2983 eval libname=\"$libname_spec\"
2985 libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
2990 if test -n "$objs"; then
2991 if test "$deplibs_check_method" != pass_all; then
2992 $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
2996 $echo "*** Warning: Linking the shared library $output against the non-libtool"
2997 $echo "*** objects $objs is not portable!"
2998 libobjs="$libobjs $objs"
3002 if test "$dlself" != no; then
3003 $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
3007 if test "$#" -gt 2; then
3008 $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
3013 if test -z "$rpath"; then
3014 if test "$build_libtool_libs" = yes; then
3015 # Building a libtool convenience library.
3016 # Some compilers have problems with a `.al' extension so
3017 # convenience libraries should have the same extension an
3018 # archive normally would.
3019 oldlibs="$output_objdir/$libname.$libext $oldlibs"
3020 build_libtool_libs=convenience
3024 if test -n "$vinfo"; then
3025 $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
3028 if test -n "$release"; then
3029 $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
3033 # Parse the version information argument.
3034 save_ifs="$IFS"; IFS=':'
3035 set dummy $vinfo 0 0 0
3038 if test -n "$8"; then
3039 $echo "$modename: too many parameters to \`-version-info'" 1>&2
3044 # convert absolute version numbers to libtool ages
3045 # this retains compatibility with .la files and attempts
3046 # to make the code below a bit more comprehensible
3048 case $vinfo_number in
3052 number_revision="$4"
3054 # There are really only two kinds -- those that
3055 # use the current revision as the major version
3056 # and those that subtract age and use age as
3057 # a minor version. But, then there is irix
3058 # which has an extra 1 added just for fun
3060 case $version_type in
3061 darwin|linux|osf|windows)
3062 current=`expr $number_major + $number_minor`
3064 revision="$number_revision"
3066 freebsd-aout|freebsd-elf|sunos)
3067 current="$number_major"
3068 revision="$number_minor"
3072 current=`expr $number_major + $number_minor - 1`
3074 revision="$number_minor"
3085 # Check that each of the things are valid numbers.
3087 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3089 $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
3090 $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3096 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3098 $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
3099 $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3105 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3107 $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
3108 $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3113 if test "$age" -gt "$current"; then
3114 $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3115 $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3119 # Calculate the version variables.
3123 case $version_type in
3127 # Like Linux, but with the current version available in
3128 # verstring for coding it into the library header
3129 major=.`expr $current - $age`
3130 versuffix="$major.$age.$revision"
3131 # Darwin ld doesn't like 0 for these options...
3132 minor_current=`expr $current + 1`
3133 verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
3138 versuffix=".$current.$revision";
3143 versuffix=".$current";
3147 major=`expr $current - $age + 1`
3149 case $version_type in
3150 nonstopux) verstring_prefix=nonstopux ;;
3151 *) verstring_prefix=sgi ;;
3153 verstring="$verstring_prefix$major.$revision"
3155 # Add in all the interfaces that we are compatible with.
3157 while test "$loop" -ne 0; do
3158 iface=`expr $revision - $loop`
3159 loop=`expr $loop - 1`
3160 verstring="$verstring_prefix$major.$iface:$verstring"
3163 # Before this point, $major must not contain `.'.
3165 versuffix="$major.$revision"
3169 major=.`expr $current - $age`
3170 versuffix="$major.$age.$revision"
3174 major=.`expr $current - $age`
3175 versuffix=".$current.$age.$revision"
3176 verstring="$current.$age.$revision"
3178 # Add in all the interfaces that we are compatible with.
3180 while test "$loop" -ne 0; do
3181 iface=`expr $current - $loop`
3182 loop=`expr $loop - 1`
3183 verstring="$verstring:${iface}.0"
3186 # Make executables depend on our current version.
3187 verstring="$verstring:${current}.0"
3192 versuffix=".$current.$revision"
3196 # Use '-' rather than '.', since we only want one
3197 # extension on DOS 8.3 filesystems.
3198 major=`expr $current - $age`
3203 $echo "$modename: unknown library version type \`$version_type'" 1>&2
3204 $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
3209 # Clear the version info if we defaulted, and they specified a release.
3210 if test -z "$vinfo" && test -n "$release"; then
3212 case $version_type in
3214 # we can't check for "0.0" in archive_cmds due to quoting
3215 # problems, so we reset it completely
3222 if test "$need_version" = no; then
3229 # Remove version info from name if versioning should be avoided
3230 if test "$avoid_version" = yes && test "$need_version" = no; then
3236 # Check to see if the archive will have undefined symbols.
3237 if test "$allow_undefined" = yes; then
3238 if test "$allow_undefined_flag" = unsupported; then
3239 $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
3240 build_libtool_libs=no
3244 # Don't allow undefined symbols.
3245 allow_undefined_flag="$no_undefined_flag"
3249 if test "$mode" != relink; then
3250 # Remove our outputs, but don't remove object files since they
3251 # may have been created when compiling PIC objects.
3253 tempremovelist=`$echo "$output_objdir/*"`
3254 for p in $tempremovelist; do
3258 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3259 if test "X$precious_files_regex" != "X"; then
3260 if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3265 removelist="$removelist $p"
3270 if test -n "$removelist"; then
3271 $show "${rm}r $removelist"
3272 $run ${rm}r $removelist
3276 # Now set the variables for building old libraries.
3277 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
3278 oldlibs="$oldlibs $output_objdir/$libname.$libext"
3280 # Transform .lo files to .o files.
3281 oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
3284 # Eliminate all temporary directories.
3285 for path in $notinst_path; do
3286 lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
3287 deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
3288 dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
3291 if test -n "$xrpath"; then
3292 # If the user specified any rpath flags, then add them.
3294 for libdir in $xrpath; do
3295 temp_xrpath="$temp_xrpath -R$libdir"
3296 case "$finalize_rpath " in
3298 *) finalize_rpath="$finalize_rpath $libdir" ;;
3301 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3302 dependency_libs="$temp_xrpath $dependency_libs"
3306 # Make sure dlfiles contains only unique files that won't be dlpreopened
3307 old_dlfiles="$dlfiles"
3309 for lib in $old_dlfiles; do
3310 case " $dlprefiles $dlfiles " in
3312 *) dlfiles="$dlfiles $lib" ;;
3316 # Make sure dlprefiles contains only unique files
3317 old_dlprefiles="$dlprefiles"
3319 for lib in $old_dlprefiles; do
3320 case "$dlprefiles " in
3322 *) dlprefiles="$dlprefiles $lib" ;;
3326 if test "$build_libtool_libs" = yes; then
3327 if test -n "$rpath"; then
3329 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
3330 # these systems don't actually have a c library (as such)!
3332 *-*-rhapsody* | *-*-darwin1.[012])
3333 # Rhapsody C library is in the System framework
3334 deplibs="$deplibs -framework System"
3337 # Don't link with libc until the a.out ld.so is fixed.
3339 *-*-openbsd* | *-*-freebsd*)
3340 # Do not include libc due to us having libc/libc_r.
3341 test "X$arg" = "X-lc" && continue
3344 # Add libc to deplibs on all other systems if necessary.
3345 if test "$build_libtool_need_lc" = "yes"; then
3346 deplibs="$deplibs -lc"
3352 # Transform deplibs into only deplibs that can be linked in shared.
3354 libname_save=$libname
3355 release_save=$release
3356 versuffix_save=$versuffix
3358 # I'm not sure if I'm treating the release correctly. I think
3359 # release should show up in the -l (ie -lgmp5) so we don't want to
3360 # add it in twice. Is that correct?
3366 case $deplibs_check_method in
3368 # Don't check for shared/static. Everything works.
3369 # This might be a little naive. We might want to check
3370 # whether the library exists or not. But this is on
3371 # osf3 & osf4 and I'm not really sure... Just
3372 # implementing what was already the behavior.
3376 # This code stresses the "libraries are programs" paradigm to its
3377 # limits. Maybe even breaks it. We compile a program, linking it
3378 # against the deplibs as a proxy for the library. Then we can check
3379 # whether they linked in statically or dynamically with ldd.
3381 cat > conftest.c <<EOF
3382 int main() { return 0; }
3385 $LTCC -o conftest conftest.c $deplibs
3386 if test "$?" -eq 0 ; then
3387 ldd_output=`ldd conftest`
3388 for i in $deplibs; do
3389 name="`expr $i : '-l\(.*\)'`"
3390 # If $name is empty we are operating on a -L argument.
3391 if test "$name" != "" && test "$name" -ne "0"; then
3392 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3393 case " $predeps $postdeps " in
3395 newdeplibs="$newdeplibs $i"
3400 if test -n "$i" ; then
3401 libname=`eval \\$echo \"$libname_spec\"`
3402 deplib_matches=`eval \\$echo \"$library_names_spec\"`
3403 set dummy $deplib_matches
3405 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3406 newdeplibs="$newdeplibs $i"
3410 $echo "*** Warning: dynamic linker does not accept needed library $i."
3411 $echo "*** I have the capability to make that library automatically link in when"
3412 $echo "*** you link to this library. But I can only do this if you have a"
3413 $echo "*** shared version of the library, which I believe you do not have"
3414 $echo "*** because a test_compile did reveal that the linker did not use it for"
3415 $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3419 newdeplibs="$newdeplibs $i"
3423 # Error occurred in the first compile. Let's try to salvage
3424 # the situation: Compile a separate program for each library.
3425 for i in $deplibs; do
3426 name="`expr $i : '-l\(.*\)'`"
3427 # If $name is empty we are operating on a -L argument.
3428 if test "$name" != "" && test "$name" != "0"; then
3430 $LTCC -o conftest conftest.c $i
3432 if test "$?" -eq 0 ; then
3433 ldd_output=`ldd conftest`
3434 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3435 case " $predeps $postdeps " in
3437 newdeplibs="$newdeplibs $i"
3442 if test -n "$i" ; then
3443 libname=`eval \\$echo \"$libname_spec\"`
3444 deplib_matches=`eval \\$echo \"$library_names_spec\"`
3445 set dummy $deplib_matches
3447 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3448 newdeplibs="$newdeplibs $i"
3452 $echo "*** Warning: dynamic linker does not accept needed library $i."
3453 $echo "*** I have the capability to make that library automatically link in when"
3454 $echo "*** you link to this library. But I can only do this if you have a"
3455 $echo "*** shared version of the library, which you do not appear to have"
3456 $echo "*** because a test_compile did reveal that the linker did not use this one"
3457 $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3463 $echo "*** Warning! Library $i is needed by this library but I was not able to"
3464 $echo "*** make it link in! You will probably need to install it or some"
3465 $echo "*** library that it depends on before this library will be fully"
3466 $echo "*** functional. Installing it before continuing would be even better."
3469 newdeplibs="$newdeplibs $i"
3475 set dummy $deplibs_check_method
3476 file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3477 for a_deplib in $deplibs; do
3478 name="`expr $a_deplib : '-l\(.*\)'`"
3479 # If $name is empty we are operating on a -L argument.
3480 if test "$name" != "" && test "$name" != "0"; then
3481 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3482 case " $predeps $postdeps " in
3484 newdeplibs="$newdeplibs $a_deplib"