debian/copyright: update formatting (DEP5) and years of packaging
[debian/cdck.git] / debian / patches / libtool.patch
1 Author: gregor herrmann <gregoa@debian.org>
2 Description: update ltmain.sh and aclocal.m4
3 Bugs-Debian: #375634
4
5 --- a/ltmain.sh
6 +++ b/ltmain.sh
7 @@ -1,7 +1,7 @@
8  # ltmain.sh - Provide generalized library-building support services.
9  # NOTE: Changing this file will not affect anything until you rerun configure.
10  #
11 -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
12 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
13  # Free Software Foundation, Inc.
14  # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
15  #
16 @@ -17,13 +17,41 @@
17  #
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.
21 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22  #
23  # As a special exception to the GNU General Public License, if you
24  # distribute this file as part of a program that contains a
25  # configuration script generated by Autoconf, you may include it under
26  # the same distribution terms that you use for the rest of that program.
27  
28 +basename="s,^.*/,,g"
29 +
30 +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
31 +# is ksh but when the shell is invoked as "sh" and the current value of
32 +# the _XPG environment variable is not equal to 1 (one), the special
33 +# positional parameter $0, within a function call, is the name of the
34 +# function.
35 +progpath="$0"
36 +
37 +# The name of this program:
38 +progname=`echo "$progpath" | $SED $basename`
39 +modename="$progname"
40 +
41 +# Global variables:
42 +EXIT_SUCCESS=0
43 +EXIT_FAILURE=1
44 +
45 +PROGRAM=ltmain.sh
46 +PACKAGE=libtool
47 +VERSION="1.5.22 Debian 1.5.22-4"
48 +TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
49 +
50 +# See if we are running on zsh, and set the options which allow our
51 +# commands through without removal of \ escapes.
52 +if test -n "${ZSH_VERSION+set}" ; then
53 +  setopt NO_GLOB_SUBST
54 +fi
55 +
56  # Check that we have a working $echo.
57  if test "X$1" = X--no-reexec; then
58    # Discard the --no-reexec flag, and continue.
59 @@ -36,7 +64,7 @@
60    :
61  else
62    # Restart under the correct shell, and then maybe $echo will work.
63 -  exec $SHELL "$0" --no-reexec ${1+"$@"}
64 +  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
65  fi
66  
67  if test "X$1" = X--fallback-echo; then
68 @@ -45,19 +73,9 @@
69    cat <<EOF
70  $*
71  EOF
72 -  exit 0
73 +  exit $EXIT_SUCCESS
74  fi
75  
76 -# The name of this program.
77 -progname=`$echo "$0" | sed 's%^.*/%%'`
78 -modename="$progname"
79 -
80 -# Constants.
81 -PROGRAM=ltmain.sh
82 -PACKAGE=libtool
83 -VERSION=1.4.2
84 -TIMESTAMP=" (1.922.2.53 2001/09/11 03:18:52)"
85 -
86  default_mode=
87  help="Try \`$progname --help' for more information."
88  magic="%%%MAGIC variable%%%"
89 @@ -67,10 +85,20 @@
90  
91  # Sed substitution that helps us do robust quoting.  It backslashifies
92  # metacharacters that are still active within double-quoted strings.
93 -Xsed='sed -e 1s/^X//'
94 +Xsed="${SED}"' -e 1s/^X//'
95  sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
96 -SP2NL='tr \040 \012'
97 -NL2SP='tr \015\012 \040\040'
98 +# test EBCDIC or ASCII
99 +case `echo X|tr X '\101'` in
100 + A) # ASCII based system
101 +    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
102 +  SP2NL='tr \040 \012'
103 +  NL2SP='tr \015\012 \040\040'
104 +  ;;
105 + *) # EBCDIC based system
106 +  SP2NL='tr \100 \n'
107 +  NL2SP='tr \r\n \100\100'
108 +  ;;
109 +esac
110  
111  # NLS nuisances.
112  # Only set LANG and LC_ALL to C if already set.
113 @@ -85,12 +113,14 @@
114  fi
115  
116  # Make sure IFS has a sensible default
117 -: ${IFS="      "}
118 +lt_nl='
119 +'
120 +IFS="  $lt_nl"
121  
122  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
123 -  echo "$modename: not configured to build any kind of library" 1>&2
124 -  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
125 -  exit 1
126 +  $echo "$modename: not configured to build any kind of library" 1>&2
127 +  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
128 +  exit $EXIT_FAILURE
129  fi
130  
131  # Global variables.
132 @@ -102,11 +132,268 @@
133  show="$echo"
134  show_help=
135  execute_dlfiles=
136 +duplicate_deps=no
137 +preserve_args=
138  lo2o="s/\\.lo\$/.${objext}/"
139  o2lo="s/\\.${objext}\$/.lo/"
140  
141 +#####################################
142 +# Shell function definitions:
143 +# This seems to be the best place for them
144 +
145 +# func_mktempdir [string]
146 +# Make a temporary directory that won't clash with other running
147 +# libtool processes, and avoids race conditions if possible.  If
148 +# given, STRING is the basename for that directory.
149 +func_mktempdir ()
150 +{
151 +    my_template="${TMPDIR-/tmp}/${1-$progname}"
152 +
153 +    if test "$run" = ":"; then
154 +      # Return a directory name, but don't create it in dry-run mode
155 +      my_tmpdir="${my_template}-$$"
156 +    else
157 +
158 +      # If mktemp works, use that first and foremost
159 +      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
160 +
161 +      if test ! -d "$my_tmpdir"; then
162 +       # Failing that, at least try and use $RANDOM to avoid a race
163 +       my_tmpdir="${my_template}-${RANDOM-0}$$"
164 +
165 +       save_mktempdir_umask=`umask`
166 +       umask 0077
167 +       $mkdir "$my_tmpdir"
168 +       umask $save_mktempdir_umask
169 +      fi
170 +
171 +      # If we're not in dry-run mode, bomb out on failure
172 +      test -d "$my_tmpdir" || {
173 +        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
174 +       exit $EXIT_FAILURE
175 +      }
176 +    fi
177 +
178 +    $echo "X$my_tmpdir" | $Xsed
179 +}
180 +
181 +
182 +# func_win32_libid arg
183 +# return the library type of file 'arg'
184 +#
185 +# Need a lot of goo to handle *both* DLLs and import libs
186 +# Has to be a shell function in order to 'eat' the argument
187 +# that is supplied when $file_magic_command is called.
188 +func_win32_libid ()
189 +{
190 +  win32_libid_type="unknown"
191 +  win32_fileres=`file -L $1 2>/dev/null`
192 +  case $win32_fileres in
193 +  *ar\ archive\ import\ library*) # definitely import
194 +    win32_libid_type="x86 archive import"
195 +    ;;
196 +  *ar\ archive*) # could be an import, or static
197 +    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
198 +      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
199 +      win32_nmres=`eval $NM -f posix -A $1 | \
200 +       $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
201 +      case $win32_nmres in
202 +      import*)  win32_libid_type="x86 archive import";;
203 +      *)        win32_libid_type="x86 archive static";;
204 +      esac
205 +    fi
206 +    ;;
207 +  *DLL*)
208 +    win32_libid_type="x86 DLL"
209 +    ;;
210 +  *executable*) # but shell scripts are "executable" too...
211 +    case $win32_fileres in
212 +    *MS\ Windows\ PE\ Intel*)
213 +      win32_libid_type="x86 DLL"
214 +      ;;
215 +    esac
216 +    ;;
217 +  esac
218 +  $echo $win32_libid_type
219 +}
220 +
221 +
222 +# func_infer_tag arg
223 +# Infer tagged configuration to use if any are available and
224 +# if one wasn't chosen via the "--tag" command line option.
225 +# Only attempt this if the compiler in the base compile
226 +# command doesn't match the default compiler.
227 +# arg is usually of the form 'gcc ...'
228 +func_infer_tag ()
229 +{
230 +    if test -n "$available_tags" && test -z "$tagname"; then
231 +      CC_quoted=
232 +      for arg in $CC; do
233 +       case $arg in
234 +         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
235 +         arg="\"$arg\""
236 +         ;;
237 +       esac
238 +       CC_quoted="$CC_quoted $arg"
239 +      done
240 +      case $@ in
241 +      # Blanks in the command may have been stripped by the calling shell,
242 +      # but not from the CC environment variable when configure was run.
243 +      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
244 +      # Blanks at the start of $base_compile will cause this to fail
245 +      # if we don't check for them as well.
246 +      *)
247 +       for z in $available_tags; do
248 +         if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
249 +           # Evaluate the configuration.
250 +           eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
251 +           CC_quoted=
252 +           for arg in $CC; do
253 +           # Double-quote args containing other shell metacharacters.
254 +           case $arg in
255 +             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
256 +             arg="\"$arg\""
257 +             ;;
258 +           esac
259 +           CC_quoted="$CC_quoted $arg"
260 +         done
261 +           case "$@ " in
262 +             " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
263 +             # The compiler in the base compile command matches
264 +             # the one in the tagged configuration.
265 +             # Assume this is the tagged configuration we want.
266 +             tagname=$z
267 +             break
268 +             ;;
269 +           esac
270 +         fi
271 +       done
272 +       # If $tagname still isn't set, then no tagged configuration
273 +       # was found and let the user know that the "--tag" command
274 +       # line option must be used.
275 +       if test -z "$tagname"; then
276 +         $echo "$modename: unable to infer tagged configuration"
277 +         $echo "$modename: specify a tag with \`--tag'" 1>&2
278 +         exit $EXIT_FAILURE
279 +#        else
280 +#          $echo "$modename: using $tagname tagged configuration"
281 +       fi
282 +       ;;
283 +      esac
284 +    fi
285 +}
286 +
287 +
288 +# func_extract_an_archive dir oldlib
289 +func_extract_an_archive ()
290 +{
291 +    f_ex_an_ar_dir="$1"; shift
292 +    f_ex_an_ar_oldlib="$1"
293 +
294 +    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
295 +    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
296 +    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
297 +     :
298 +    else
299 +      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
300 +      exit $EXIT_FAILURE
301 +    fi
302 +}
303 +
304 +# func_extract_archives gentop oldlib ...
305 +func_extract_archives ()
306 +{
307 +    my_gentop="$1"; shift
308 +    my_oldlibs=${1+"$@"}
309 +    my_oldobjs=""
310 +    my_xlib=""
311 +    my_xabs=""
312 +    my_xdir=""
313 +    my_status=""
314 +
315 +    $show "${rm}r $my_gentop"
316 +    $run ${rm}r "$my_gentop"
317 +    $show "$mkdir $my_gentop"
318 +    $run $mkdir "$my_gentop"
319 +    my_status=$?
320 +    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
321 +      exit $my_status
322 +    fi
323 +
324 +    for my_xlib in $my_oldlibs; do
325 +      # Extract the objects.
326 +      case $my_xlib in
327 +       [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
328 +       *) my_xabs=`pwd`"/$my_xlib" ;;
329 +      esac
330 +      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
331 +      my_xdir="$my_gentop/$my_xlib"
332 +
333 +      $show "${rm}r $my_xdir"
334 +      $run ${rm}r "$my_xdir"
335 +      $show "$mkdir $my_xdir"
336 +      $run $mkdir "$my_xdir"
337 +      exit_status=$?
338 +      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
339 +       exit $exit_status
340 +      fi
341 +      case $host in
342 +      *-darwin*)
343 +       $show "Extracting $my_xabs"
344 +       # Do not bother doing anything if just a dry run
345 +       if test -z "$run"; then
346 +         darwin_orig_dir=`pwd`
347 +         cd $my_xdir || exit $?
348 +         darwin_archive=$my_xabs
349 +         darwin_curdir=`pwd`
350 +         darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
351 +         darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
352 +         if test -n "$darwin_arches"; then
353 +           darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
354 +           darwin_arch=
355 +           $show "$darwin_base_archive has multiple architectures $darwin_arches"
356 +           for darwin_arch in  $darwin_arches ; do
357 +             mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
358 +             lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
359 +             cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
360 +             func_extract_an_archive "`pwd`" "${darwin_base_archive}"
361 +             cd "$darwin_curdir"
362 +             $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
363 +           done # $darwin_arches
364 +      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
365 +           darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
366 +           darwin_file=
367 +           darwin_files=
368 +           for darwin_file in $darwin_filelist; do
369 +             darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
370 +             lipo -create -output "$darwin_file" $darwin_files
371 +           done # $darwin_filelist
372 +           ${rm}r unfat-$$
373 +           cd "$darwin_orig_dir"
374 +         else
375 +           cd "$darwin_orig_dir"
376 +           func_extract_an_archive "$my_xdir" "$my_xabs"
377 +         fi # $darwin_arches
378 +       fi # $run
379 +       ;;
380 +      *)
381 +        func_extract_an_archive "$my_xdir" "$my_xabs"
382 +        ;;
383 +      esac
384 +      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
385 +    done
386 +    func_extract_archives_result="$my_oldobjs"
387 +}
388 +# End of Shell function definitions
389 +#####################################
390 +
391 +# Darwin sucks
392 +eval std_shrext=\"$shrext_cmds\"
393 +
394 +disable_libs=no
395 +
396  # Parse our command line options once, thoroughly.
397 -while test $# -gt 0
398 +while test "$#" -gt 0
399  do
400    arg="$1"
401    shift
402 @@ -122,6 +409,34 @@
403      execute_dlfiles)
404        execute_dlfiles="$execute_dlfiles $arg"
405        ;;
406 +    tag)
407 +      tagname="$arg"
408 +      preserve_args="${preserve_args}=$arg"
409 +
410 +      # Check whether tagname contains only valid characters
411 +      case $tagname in
412 +      *[!-_A-Za-z0-9,/]*)
413 +       $echo "$progname: invalid tag name: $tagname" 1>&2
414 +       exit $EXIT_FAILURE
415 +       ;;
416 +      esac
417 +
418 +      case $tagname in
419 +      CC)
420 +       # Don't test for the "default" C tag, as we know, it's there, but
421 +       # not specially marked.
422 +       ;;
423 +      *)
424 +       if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
425 +         taglist="$taglist $tagname"
426 +         # Evaluate the configuration.
427 +         eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
428 +       else
429 +         $echo "$progname: ignoring unknown tag $tagname" 1>&2
430 +       fi
431 +       ;;
432 +      esac
433 +      ;;
434      *)
435        eval "$prev=\$arg"
436        ;;
437 @@ -139,18 +454,27 @@
438      ;;
439  
440    --version)
441 -    echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
442 -    exit 0
443 +    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
444 +    $echo
445 +    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
446 +    $echo "This is free software; see the source for copying conditions.  There is NO"
447 +    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
448 +    exit $?
449      ;;
450  
451    --config)
452 -    sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0
453 -    exit 0
454 +    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
455 +    # Now print the configurations for the tags.
456 +    for tagname in $taglist; do
457 +      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
458 +    done
459 +    exit $?
460      ;;
461  
462    --debug)
463 -    echo "$progname: enabling shell trace mode"
464 +    $echo "$progname: enabling shell trace mode"
465      set -x
466 +    preserve_args="$preserve_args $arg"
467      ;;
468  
469    --dry-run | -n)
470 @@ -158,18 +482,18 @@
471      ;;
472  
473    --features)
474 -    echo "host: $host"
475 +    $echo "host: $host"
476      if test "$build_libtool_libs" = yes; then
477 -      echo "enable shared libraries"
478 +      $echo "enable shared libraries"
479      else
480 -      echo "disable shared libraries"
481 +      $echo "disable shared libraries"
482      fi
483      if test "$build_old_libs" = yes; then
484 -      echo "enable static libraries"
485 +      $echo "enable static libraries"
486      else
487 -      echo "disable static libraries"
488 +      $echo "disable static libraries"
489      fi
490 -    exit 0
491 +    exit $?
492      ;;
493  
494    --finish) mode="finish" ;;
495 @@ -177,8 +501,23 @@
496    --mode) prevopt="--mode" prev=mode ;;
497    --mode=*) mode="$optarg" ;;
498  
499 +  --preserve-dup-deps) duplicate_deps="yes" ;;
500 +
501    --quiet | --silent)
502      show=:
503 +    preserve_args="$preserve_args $arg"
504 +    ;;
505 +
506 +  --tag)
507 +    prevopt="--tag"
508 +    prev=tag
509 +    preserve_args="$preserve_args --tag"
510 +    ;;
511 +  --tag=*)
512 +    set tag "$optarg" ${1+"$@"}
513 +    shift
514 +    prev=tag
515 +    preserve_args="$preserve_args --tag"
516      ;;
517  
518    -dlopen)
519 @@ -189,7 +528,7 @@
520    -*)
521      $echo "$modename: unrecognized option \`$arg'" 1>&2
522      $echo "$help" 1>&2
523 -    exit 1
524 +    exit $EXIT_FAILURE
525      ;;
526  
527    *)
528 @@ -202,9 +541,21 @@
529  if test -n "$prevopt"; then
530    $echo "$modename: option \`$prevopt' requires an argument" 1>&2
531    $echo "$help" 1>&2
532 -  exit 1
533 +  exit $EXIT_FAILURE
534  fi
535  
536 +case $disable_libs in
537 +no)
538 +  ;;
539 +shared)
540 +  build_libtool_libs=no
541 +  build_old_libs=yes
542 +  ;;
543 +static)
544 +  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
545 +  ;;
546 +esac
547 +
548  # If this variable is set in any of the actions, the command in it
549  # will be execed at the end.  This prevents here-documents from being
550  # left over by shells.
551 @@ -214,8 +565,10 @@
552  
553    # Infer the operation mode.
554    if test -z "$mode"; then
555 +    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
556 +    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
557      case $nonopt in
558 -    *cc | *++ | gcc* | *-gcc*)
559 +    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
560        mode=link
561        for arg
562        do
563 @@ -256,7 +609,7 @@
564    if test -n "$execute_dlfiles" && test "$mode" != execute; then
565      $echo "$modename: unrecognized option \`-dlopen'" 1>&2
566      $echo "$help" 1>&2
567 -    exit 1
568 +    exit $EXIT_FAILURE
569    fi
570  
571    # Change the help message to a mode-specific one.
572 @@ -270,158 +623,127 @@
573      modename="$modename: compile"
574      # Get the compilation command and the source file.
575      base_compile=
576 -    prev=
577 -    lastarg=
578 -    srcfile="$nonopt"
579 +    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
580 +    suppress_opt=yes
581      suppress_output=
582 +    arg_mode=normal
583 +    libobj=
584 +    later=
585  
586 -    user_target=no
587      for arg
588      do
589 -      case $prev in
590 -      "") ;;
591 -      xcompiler)
592 -       # Aesthetically quote the previous argument.
593 -       prev=
594 -       lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
595 -
596 -       case $arg in
597 -       # Double-quote args containing other shell metacharacters.
598 -       # Many Bourne shells cannot handle close brackets correctly
599 -       # in scan sets, so we specify it separately.
600 -       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
601 -         arg="\"$arg\""
602 -         ;;
603 -       esac
604 -
605 -       # Add the previous argument to base_compile.
606 -       if test -z "$base_compile"; then
607 -         base_compile="$lastarg"
608 -       else
609 -         base_compile="$base_compile $lastarg"
610 -       fi
611 -       continue
612 -       ;;
613 -      esac
614 -
615 -      # Accept any command-line options.
616 -      case $arg in
617 -      -o)
618 -       if test "$user_target" != "no"; then
619 -         $echo "$modename: you cannot specify \`-o' more than once" 1>&2
620 -         exit 1
621 -       fi
622 -       user_target=next
623 +      case $arg_mode in
624 +      arg  )
625 +       # do not "continue".  Instead, add this to base_compile
626 +       lastarg="$arg"
627 +       arg_mode=normal
628         ;;
629  
630 -      -static)
631 -       build_old_libs=yes
632 +      target )
633 +       libobj="$arg"
634 +       arg_mode=normal
635         continue
636         ;;
637  
638 -      -prefer-pic)
639 -       pic_mode=yes
640 -       continue
641 -       ;;
642 +      normal )
643 +       # Accept any command-line options.
644 +       case $arg in
645 +       -o)
646 +         if test -n "$libobj" ; then
647 +           $echo "$modename: you cannot specify \`-o' more than once" 1>&2
648 +           exit $EXIT_FAILURE
649 +         fi
650 +         arg_mode=target
651 +         continue
652 +         ;;
653  
654 -      -prefer-non-pic)
655 -       pic_mode=no
656 -       continue
657 -       ;;
658 +       -static | -prefer-pic | -prefer-non-pic)
659 +         later="$later $arg"
660 +         continue
661 +         ;;
662  
663 -      -Xcompiler)
664 -       prev=xcompiler
665 -       continue
666 -       ;;
667 +       -no-suppress)
668 +         suppress_opt=no
669 +         continue
670 +         ;;
671  
672 -      -Wc,*)
673 -       args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
674 -       lastarg=
675 -       save_ifs="$IFS"; IFS=','
676 -       for arg in $args; do
677 -         IFS="$save_ifs"
678 +       -Xcompiler)
679 +         arg_mode=arg  #  the next one goes into the "base_compile" arg list
680 +         continue      #  The current "srcfile" will either be retained or
681 +         ;;            #  replaced later.  I would guess that would be a bug.
682 +
683 +       -Wc,*)
684 +         args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
685 +         lastarg=
686 +         save_ifs="$IFS"; IFS=','
687 +         for arg in $args; do
688 +           IFS="$save_ifs"
689  
690 -         # Double-quote args containing other shell metacharacters.
691 -         # Many Bourne shells cannot handle close brackets correctly
692 -         # in scan sets, so we specify it separately.
693 -         case $arg in
694 -           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
695 -           arg="\"$arg\""
696 -           ;;
697 -         esac
698 -         lastarg="$lastarg $arg"
699 -       done
700 -       IFS="$save_ifs"
701 -       lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
702 +           # Double-quote args containing other shell metacharacters.
703 +           # Many Bourne shells cannot handle close brackets correctly
704 +           # in scan sets, so we specify it separately.
705 +           case $arg in
706 +             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
707 +             arg="\"$arg\""
708 +             ;;
709 +           esac
710 +           lastarg="$lastarg $arg"
711 +         done
712 +         IFS="$save_ifs"
713 +         lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
714  
715 -       # Add the arguments to base_compile.
716 -       if test -z "$base_compile"; then
717 -         base_compile="$lastarg"
718 -       else
719 +         # Add the arguments to base_compile.
720           base_compile="$base_compile $lastarg"
721 -       fi
722 -       continue
723 -       ;;
724 -      esac
725 +         continue
726 +         ;;
727  
728 -      case $user_target in
729 -      next)
730 -       # The next one is the -o target name
731 -       user_target=yes
732 -       continue
733 -       ;;
734 -      yes)
735 -       # We got the output file
736 -       user_target=set
737 -       libobj="$arg"
738 -       continue
739 +       * )
740 +         # Accept the current argument as the source file.
741 +         # The previous "srcfile" becomes the current argument.
742 +         #
743 +         lastarg="$srcfile"
744 +         srcfile="$arg"
745 +         ;;
746 +       esac  #  case $arg
747         ;;
748 -      esac
749 -
750 -      # Accept the current argument as the source file.
751 -      lastarg="$srcfile"
752 -      srcfile="$arg"
753 +      esac    #  case $arg_mode
754  
755        # Aesthetically quote the previous argument.
756 -
757 -      # Backslashify any backslashes, double quotes, and dollar signs.
758 -      # These are the only characters that are still specially
759 -      # interpreted inside of double-quoted scrings.
760        lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
761  
762 +      case $lastarg in
763        # Double-quote args containing other shell metacharacters.
764        # Many Bourne shells cannot handle close brackets correctly
765 -      # in scan sets, so we specify it separately.
766 -      case $lastarg in
767 +      # in scan sets, and some SunOS ksh mistreat backslash-escaping
768 +      # in scan sets (worked around with variable expansion),
769 +      # and furthermore cannot handle '|' '&' '(' ')' in scan sets
770 +      # at all, so we specify them separately.
771        *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
772         lastarg="\"$lastarg\""
773         ;;
774        esac
775  
776 -      # Add the previous argument to base_compile.
777 -      if test -z "$base_compile"; then
778 -       base_compile="$lastarg"
779 -      else
780 -       base_compile="$base_compile $lastarg"
781 -      fi
782 -    done
783 +      base_compile="$base_compile $lastarg"
784 +    done # for arg
785  
786 -    case $user_target in
787 -    set)
788 +    case $arg_mode in
789 +    arg)
790 +      $echo "$modename: you must specify an argument for -Xcompile"
791 +      exit $EXIT_FAILURE
792        ;;
793 -    no)
794 -      # Get the name of the library object.
795 -      libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
796 +    target)
797 +      $echo "$modename: you must specify a target with \`-o'" 1>&2
798 +      exit $EXIT_FAILURE
799        ;;
800      *)
801 -      $echo "$modename: you must specify a target with \`-o'" 1>&2
802 -      exit 1
803 +      # Get the name of the library object.
804 +      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
805        ;;
806      esac
807  
808      # Recognize several different file suffixes.
809      # If the user specifies -o file.o, it is replaced with file.lo
810 -    xform='[cCFSfmso]'
811 +    xform='[cCFSifmso]'
812      case $libobj in
813      *.ada) xform=ada ;;
814      *.adb) xform=adb ;;
815 @@ -429,10 +751,13 @@
816      *.asm) xform=asm ;;
817      *.c++) xform=c++ ;;
818      *.cc) xform=cc ;;
819 +    *.ii) xform=ii ;;
820 +    *.class) xform=class ;;
821      *.cpp) xform=cpp ;;
822      *.cxx) xform=cxx ;;
823      *.f90) xform=f90 ;;
824      *.for) xform=for ;;
825 +    *.java) xform=java ;;
826      esac
827  
828      libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
829 @@ -441,25 +766,63 @@
830      *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
831      *)
832        $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
833 -      exit 1
834 +      exit $EXIT_FAILURE
835        ;;
836      esac
837  
838 +    func_infer_tag $base_compile
839 +
840 +    for arg in $later; do
841 +      case $arg in
842 +      -static)
843 +       build_old_libs=yes
844 +       continue
845 +       ;;
846 +
847 +      -prefer-pic)
848 +       pic_mode=yes
849 +       continue
850 +       ;;
851 +
852 +      -prefer-non-pic)
853 +       pic_mode=no
854 +       continue
855 +       ;;
856 +      esac
857 +    done
858 +
859 +    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
860 +    case $qlibobj in
861 +      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
862 +       qlibobj="\"$qlibobj\"" ;;
863 +    esac
864 +    test "X$libobj" != "X$qlibobj" \
865 +       && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"'  &()|`$[]' \
866 +       && $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
867 +    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
868 +    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
869 +    if test "X$xdir" = "X$obj"; then
870 +      xdir=
871 +    else
872 +      xdir=$xdir/
873 +    fi
874 +    lobj=${xdir}$objdir/$objname
875 +
876      if test -z "$base_compile"; then
877        $echo "$modename: you must specify a compilation command" 1>&2
878        $echo "$help" 1>&2
879 -      exit 1
880 +      exit $EXIT_FAILURE
881      fi
882  
883      # Delete any leftover library objects.
884      if test "$build_old_libs" = yes; then
885 -      removelist="$obj $libobj"
886 +      removelist="$obj $lobj $libobj ${libobj}T"
887      else
888 -      removelist="$libobj"
889 +      removelist="$lobj $libobj ${libobj}T"
890      fi
891  
892      $run $rm $removelist
893 -    trap "$run $rm $removelist; exit 1" 1 2 15
894 +    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
895  
896      # On Cygwin there's no "real" PIC flag so we must build both object types
897      case $host_os in
898 @@ -467,7 +830,7 @@
899        pic_mode=default
900        ;;
901      esac
902 -    if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then
903 +    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
904        # non-PIC code in shared libraries is not supported
905        pic_mode=default
906      fi
907 @@ -478,8 +841,9 @@
908        output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
909        lockfile="$output_obj.lock"
910        removelist="$removelist $output_obj $lockfile"
911 -      trap "$run $rm $removelist; exit 1" 1 2 15
912 +      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
913      else
914 +      output_obj=
915        need_locks=no
916        lockfile=
917      fi
918 @@ -487,13 +851,13 @@
919      # Lock this critical section if it is needed
920      # We use this script file to make the link, it avoids creating a new file
921      if test "$need_locks" = yes; then
922 -      until $run ln "$0" "$lockfile" 2>/dev/null; do
923 +      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
924         $show "Waiting for $lockfile to be removed"
925         sleep 2
926        done
927      elif test "$need_locks" = warn; then
928        if test -f "$lockfile"; then
929 -       echo "\
930 +       $echo "\
931  *** ERROR, $lockfile exists and contains:
932  `cat $lockfile 2>/dev/null`
933  
934 @@ -505,14 +869,33 @@
935  compiler."
936  
937         $run $rm $removelist
938 -       exit 1
939 +       exit $EXIT_FAILURE
940        fi
941 -      echo $srcfile > "$lockfile"
942 +      $echo "$srcfile" > "$lockfile"
943      fi
944  
945      if test -n "$fix_srcfile_path"; then
946        eval srcfile=\"$fix_srcfile_path\"
947      fi
948 +    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
949 +    case $qsrcfile in
950 +      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
951 +      qsrcfile="\"$qsrcfile\"" ;;
952 +    esac
953 +
954 +    $run $rm "$libobj" "${libobj}T"
955 +
956 +    # Create a libtool object file (analogous to a ".la" file),
957 +    # but don't create it if we're doing a dry run.
958 +    test -z "$run" && cat > ${libobj}T <<EOF
959 +# $libobj - a libtool object file
960 +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
961 +#
962 +# Please DO NOT delete this file!
963 +# It is necessary for linking the library.
964 +
965 +# Name of the PIC object.
966 +EOF
967  
968      # Only build a PIC object if we are building libtool libraries.
969      if test "$build_libtool_libs" = yes; then
970 @@ -520,53 +903,38 @@
971        fbsd_hideous_sh_bug=$base_compile
972  
973        if test "$pic_mode" != no; then
974 -       # All platforms use -DPIC, to notify preprocessed assembler code.
975 -       command="$base_compile $srcfile $pic_flag -DPIC"
976 +       command="$base_compile $qsrcfile $pic_flag"
977        else
978         # Don't build PIC code
979 -       command="$base_compile $srcfile"
980 +       command="$base_compile $qsrcfile"
981        fi
982 -      if test "$build_old_libs" = yes; then
983 -       lo_libobj="$libobj"
984 -       dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
985 -       if test "X$dir" = "X$libobj"; then
986 -         dir="$objdir"
987 -       else
988 -         dir="$dir/$objdir"
989 -       fi
990 -       libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
991  
992 -       if test -d "$dir"; then
993 -         $show "$rm $libobj"
994 -         $run $rm $libobj
995 -       else
996 -         $show "$mkdir $dir"
997 -         $run $mkdir $dir
998 -         status=$?
999 -         if test $status -ne 0 && test ! -d $dir; then
1000 -           exit $status
1001 -         fi
1002 +      if test ! -d "${xdir}$objdir"; then
1003 +       $show "$mkdir ${xdir}$objdir"
1004 +       $run $mkdir ${xdir}$objdir
1005 +       exit_status=$?
1006 +       if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
1007 +         exit $exit_status
1008         fi
1009        fi
1010 -      if test "$compiler_o_lo" = yes; then
1011 -       output_obj="$libobj"
1012 -       command="$command -o $output_obj"
1013 -      elif test "$compiler_c_o" = yes; then
1014 -       output_obj="$obj"
1015 -       command="$command -o $output_obj"
1016 +
1017 +      if test -z "$output_obj"; then
1018 +       # Place PIC objects in $objdir
1019 +       command="$command -o $lobj"
1020        fi
1021  
1022 -      $run $rm "$output_obj"
1023 +      $run $rm "$lobj" "$output_obj"
1024 +
1025        $show "$command"
1026        if $run eval "$command"; then :
1027        else
1028         test -n "$output_obj" && $run $rm $removelist
1029 -       exit 1
1030 +       exit $EXIT_FAILURE
1031        fi
1032  
1033        if test "$need_locks" = warn &&
1034 -        test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
1035 -       echo "\
1036 +        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1037 +       $echo "\
1038  *** ERROR, $lockfile contains:
1039  `cat $lockfile 2>/dev/null`
1040  
1041 @@ -581,13 +949,13 @@
1042  compiler."
1043  
1044         $run $rm $removelist
1045 -       exit 1
1046 +       exit $EXIT_FAILURE
1047        fi
1048  
1049        # Just move the object if needed, then go on to compile the next one
1050 -      if test x"$output_obj" != x"$libobj"; then
1051 -       $show "$mv $output_obj $libobj"
1052 -       if $run $mv $output_obj $libobj; then :
1053 +      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1054 +       $show "$mv $output_obj $lobj"
1055 +       if $run $mv $output_obj $lobj; then :
1056         else
1057           error=$?
1058           $run $rm $removelist
1059 @@ -595,77 +963,50 @@
1060         fi
1061        fi
1062  
1063 -      # If we have no pic_flag, then copy the object into place and finish.
1064 -      if (test -z "$pic_flag" || test "$pic_mode" != default) &&
1065 -        test "$build_old_libs" = yes; then
1066 -       # Rename the .lo from within objdir to obj
1067 -       if test -f $obj; then
1068 -         $show $rm $obj
1069 -         $run $rm $obj
1070 -       fi
1071 +      # Append the name of the PIC object to the libtool object file.
1072 +      test -z "$run" && cat >> ${libobj}T <<EOF
1073 +pic_object='$objdir/$objname'
1074  
1075 -       $show "$mv $libobj $obj"
1076 -       if $run $mv $libobj $obj; then :
1077 -       else
1078 -         error=$?
1079 -         $run $rm $removelist
1080 -         exit $error
1081 -       fi
1082 +EOF
1083  
1084 -       xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
1085 -       if test "X$xdir" = "X$obj"; then
1086 -         xdir="."
1087 -       else
1088 -         xdir="$xdir"
1089 -       fi
1090 -       baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"`
1091 -       libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
1092 -       # Now arrange that obj and lo_libobj become the same file
1093 -       $show "(cd $xdir && $LN_S $baseobj $libobj)"
1094 -       if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then
1095 -         # Unlock the critical section if it was locked
1096 -         if test "$need_locks" != no; then
1097 -           $run $rm "$lockfile"
1098 -         fi
1099 -         exit 0
1100 -       else
1101 -         error=$?
1102 -         $run $rm $removelist
1103 -         exit $error
1104 -       fi
1105 +      # Allow error messages only from the first compilation.
1106 +      if test "$suppress_opt" = yes; then
1107 +        suppress_output=' >/dev/null 2>&1'
1108        fi
1109 +    else
1110 +      # No PIC object so indicate it doesn't exist in the libtool
1111 +      # object file.
1112 +      test -z "$run" && cat >> ${libobj}T <<EOF
1113 +pic_object=none
1114  
1115 -      # Allow error messages only from the first compilation.
1116 -      suppress_output=' >/dev/null 2>&1'
1117 +EOF
1118      fi
1119  
1120      # Only build a position-dependent object if we build old libraries.
1121      if test "$build_old_libs" = yes; then
1122        if test "$pic_mode" != yes; then
1123         # Don't build PIC code
1124 -       command="$base_compile $srcfile"
1125 +       command="$base_compile $qsrcfile"
1126        else
1127 -       # All platforms use -DPIC, to notify preprocessed assembler code.
1128 -       command="$base_compile $srcfile $pic_flag -DPIC"
1129 +       command="$base_compile $qsrcfile $pic_flag"
1130        fi
1131        if test "$compiler_c_o" = yes; then
1132         command="$command -o $obj"
1133 -       output_obj="$obj"
1134        fi
1135  
1136        # Suppress compiler output if we already did a PIC compilation.
1137        command="$command$suppress_output"
1138 -      $run $rm "$output_obj"
1139 +      $run $rm "$obj" "$output_obj"
1140        $show "$command"
1141        if $run eval "$command"; then :
1142        else
1143         $run $rm $removelist
1144 -       exit 1
1145 +       exit $EXIT_FAILURE
1146        fi
1147  
1148        if test "$need_locks" = warn &&
1149 -        test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
1150 -       echo "\
1151 +        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1152 +       $echo "\
1153  *** ERROR, $lockfile contains:
1154  `cat $lockfile 2>/dev/null`
1155  
1156 @@ -680,11 +1021,11 @@
1157  compiler."
1158  
1159         $run $rm $removelist
1160 -       exit 1
1161 +       exit $EXIT_FAILURE
1162        fi
1163  
1164        # Just move the object if needed
1165 -      if test x"$output_obj" != x"$obj"; then
1166 +      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1167         $show "$mv $output_obj $obj"
1168         if $run $mv $output_obj $obj; then :
1169         else
1170 @@ -694,29 +1035,31 @@
1171         fi
1172        fi
1173  
1174 -      # Create an invalid libtool object if no PIC, so that we do not
1175 -      # accidentally link it into a program.
1176 -      if test "$build_libtool_libs" != yes; then
1177 -       $show "echo timestamp > $libobj"
1178 -       $run eval "echo timestamp > \$libobj" || exit $?
1179 -      else
1180 -       # Move the .lo from within objdir
1181 -       $show "$mv $libobj $lo_libobj"
1182 -       if $run $mv $libobj $lo_libobj; then :
1183 -       else
1184 -         error=$?
1185 -         $run $rm $removelist
1186 -         exit $error
1187 -       fi
1188 -      fi
1189 +      # Append the name of the non-PIC object the libtool object file.
1190 +      # Only append if the libtool object file exists.
1191 +      test -z "$run" && cat >> ${libobj}T <<EOF
1192 +# Name of the non-PIC object.
1193 +non_pic_object='$objname'
1194 +
1195 +EOF
1196 +    else
1197 +      # Append the name of the non-PIC object the libtool object file.
1198 +      # Only append if the libtool object file exists.
1199 +      test -z "$run" && cat >> ${libobj}T <<EOF
1200 +# Name of the non-PIC object.
1201 +non_pic_object=none
1202 +
1203 +EOF
1204      fi
1205  
1206 +    $run $mv "${libobj}T" "${libobj}"
1207 +
1208      # Unlock the critical section if it was locked
1209      if test "$need_locks" != no; then
1210        $run $rm "$lockfile"
1211      fi
1212  
1213 -    exit 0
1214 +    exit $EXIT_SUCCESS
1215      ;;
1216  
1217    # libtool link mode
1218 @@ -727,7 +1070,7 @@
1219        # It is impossible to link a dll without this setting, and
1220        # we shouldn't force the makefile maintainer to figure out
1221        # which system we are compiling for in order to pass an extra
1222 -      # flag for every libtool invokation.
1223 +      # flag for every libtool invocation.
1224        # allow_undefined=no
1225  
1226        # FIXME: Unfortunately, there are problems with the above when trying
1227 @@ -742,6 +1085,7 @@
1228        ;;
1229      esac
1230      libtool_args="$nonopt"
1231 +    base_compile="$nonopt $@"
1232      compile_command="$nonopt"
1233      finalize_command="$nonopt"
1234  
1235 @@ -757,6 +1101,7 @@
1236      linker_flags=
1237      dllsearchpath=
1238      lib_search_path=`pwd`
1239 +    inst_prefix_dir=
1240  
1241      avoid_version=no
1242      dlfiles=
1243 @@ -771,6 +1116,9 @@
1244      module=no
1245      no_install=no
1246      objs=
1247 +    non_pic_objects=
1248 +    notinst_path= # paths that contain not-installed libtool libraries
1249 +    precious_files_regex=
1250      prefer_static_libs=no
1251      preload=no
1252      prev=
1253 @@ -782,6 +1130,9 @@
1254      temp_rpath=
1255      thread_safe=no
1256      vinfo=
1257 +    vinfo_number=no
1258 +
1259 +    func_infer_tag $base_compile
1260  
1261      # We need to know -static, to get the right output filenames.
1262      for arg
1263 @@ -795,14 +1146,15 @@
1264           if test -n "$link_static_flag"; then
1265             dlopen_self=$dlopen_self_static
1266           fi
1267 +         prefer_static_libs=yes
1268         else
1269           if test -z "$pic_flag" && test -n "$link_static_flag"; then
1270             dlopen_self=$dlopen_self_static
1271           fi
1272 +         prefer_static_libs=built
1273         fi
1274         build_libtool_libs=no
1275         build_old_libs=yes
1276 -       prefer_static_libs=yes
1277         break
1278         ;;
1279        esac
1280 @@ -812,7 +1164,7 @@
1281      test -n "$old_archive_from_new_cmds" && build_old_libs=yes
1282  
1283      # Go through the arguments, transforming them on the way.
1284 -    while test $# -gt 0; do
1285 +    while test "$#" -gt 0; do
1286        arg="$1"
1287        shift
1288        case $arg in
1289 @@ -877,7 +1229,7 @@
1290           export_symbols="$arg"
1291           if test ! -f "$arg"; then
1292             $echo "$modename: symbol file \`$arg' does not exist"
1293 -           exit 1
1294 +           exit $EXIT_FAILURE
1295           fi
1296           prev=
1297           continue
1298 @@ -887,18 +1239,140 @@
1299           prev=
1300           continue
1301           ;;
1302 +       inst_prefix)
1303 +         inst_prefix_dir="$arg"
1304 +         prev=
1305 +         continue
1306 +         ;;
1307 +       precious_regex)
1308 +         precious_files_regex="$arg"
1309 +         prev=
1310 +         continue
1311 +         ;;
1312         release)
1313           release="-$arg"
1314           prev=
1315           continue
1316           ;;
1317 +       objectlist)
1318 +         if test -f "$arg"; then
1319 +           save_arg=$arg
1320 +           moreargs=
1321 +           for fil in `cat $save_arg`
1322 +           do
1323 +#            moreargs="$moreargs $fil"
1324 +             arg=$fil
1325 +             # A libtool-controlled object.
1326 +
1327 +             # Check to see that this really is a libtool object.
1328 +             if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1329 +               pic_object=
1330 +               non_pic_object=
1331 +
1332 +               # Read the .lo file
1333 +               # If there is no directory component, then add one.
1334 +               case $arg in
1335 +               */* | *\\*) . $arg ;;
1336 +               *) . ./$arg ;;
1337 +               esac
1338 +
1339 +               if test -z "$pic_object" || \
1340 +                  test -z "$non_pic_object" ||
1341 +                  test "$pic_object" = none && \
1342 +                  test "$non_pic_object" = none; then
1343 +                 $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1344 +                 exit $EXIT_FAILURE
1345 +               fi
1346 +
1347 +               # Extract subdirectory from the argument.
1348 +               xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1349 +               if test "X$xdir" = "X$arg"; then
1350 +                 xdir=
1351 +               else
1352 +                 xdir="$xdir/"
1353 +               fi
1354 +
1355 +               if test "$pic_object" != none; then
1356 +                 # Prepend the subdirectory the object is found in.
1357 +                 pic_object="$xdir$pic_object"
1358 +
1359 +                 if test "$prev" = dlfiles; then
1360 +                   if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1361 +                     dlfiles="$dlfiles $pic_object"
1362 +                     prev=
1363 +                     continue
1364 +                   else
1365 +                     # If libtool objects are unsupported, then we need to preload.
1366 +                     prev=dlprefiles
1367 +                   fi
1368 +                 fi
1369 +
1370 +                 # CHECK ME:  I think I busted this.  -Ossama
1371 +                 if test "$prev" = dlprefiles; then
1372 +                   # Preload the old-style object.
1373 +                   dlprefiles="$dlprefiles $pic_object"
1374 +                   prev=
1375 +                 fi
1376 +
1377 +                 # A PIC object.
1378 +                 libobjs="$libobjs $pic_object"
1379 +                 arg="$pic_object"
1380 +               fi
1381 +
1382 +               # Non-PIC object.
1383 +               if test "$non_pic_object" != none; then
1384 +                 # Prepend the subdirectory the object is found in.
1385 +                 non_pic_object="$xdir$non_pic_object"
1386 +
1387 +                 # A standard non-PIC object
1388 +                 non_pic_objects="$non_pic_objects $non_pic_object"
1389 +                 if test -z "$pic_object" || test "$pic_object" = none ; then
1390 +                   arg="$non_pic_object"
1391 +                 fi
1392 +               else
1393 +                 # If the PIC object exists, use it instead.
1394 +                 # $xdir was prepended to $pic_object above.
1395 +                 non_pic_object="$pic_object"
1396 +                 non_pic_objects="$non_pic_objects $non_pic_object"
1397 +               fi
1398 +             else
1399 +               # Only an error if not doing a dry-run.
1400 +               if test -z "$run"; then
1401 +                 $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1402 +                 exit $EXIT_FAILURE
1403 +               else
1404 +                 # Dry-run case.
1405 +
1406 +                 # Extract subdirectory from the argument.
1407 +                 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1408 +                 if test "X$xdir" = "X$arg"; then
1409 +                   xdir=
1410 +                 else
1411 +                   xdir="$xdir/"
1412 +                 fi
1413 +
1414 +                 pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1415 +                 non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1416 +                 libobjs="$libobjs $pic_object"
1417 +                 non_pic_objects="$non_pic_objects $non_pic_object"
1418 +               fi
1419 +             fi
1420 +           done
1421 +         else
1422 +           $echo "$modename: link input file \`$save_arg' does not exist"
1423 +           exit $EXIT_FAILURE
1424 +         fi
1425 +         arg=$save_arg
1426 +         prev=
1427 +         continue
1428 +         ;;
1429         rpath | xrpath)
1430           # We need an absolute path.
1431           case $arg in
1432           [\\/]* | [A-Za-z]:[\\/]*) ;;
1433           *)
1434             $echo "$modename: only absolute run-paths are allowed" 1>&2
1435 -           exit 1
1436 +           exit $EXIT_FAILURE
1437             ;;
1438           esac
1439           if test "$prev" = rpath; then
1440 @@ -930,13 +1404,33 @@
1441           finalize_command="$finalize_command $wl$qarg"
1442           continue
1443           ;;
1444 +       xcclinker)
1445 +         linker_flags="$linker_flags $qarg"
1446 +         compiler_flags="$compiler_flags $qarg"
1447 +         prev=
1448 +         compile_command="$compile_command $qarg"
1449 +         finalize_command="$finalize_command $qarg"
1450 +         continue
1451 +         ;;
1452 +       shrext)
1453 +         shrext_cmds="$arg"
1454 +         prev=
1455 +         continue
1456 +         ;;
1457 +       darwin_framework|darwin_framework_skip)
1458 +         test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
1459 +         compile_command="$compile_command $arg"
1460 +         finalize_command="$finalize_command $arg"
1461 +         prev=
1462 +         continue
1463 +         ;;
1464         *)
1465           eval "$prev=\"\$arg\""
1466           prev=
1467           continue
1468           ;;
1469         esac
1470 -      fi # test -n $prev
1471 +      fi # test -n "$prev"
1472  
1473        prevarg="$arg"
1474  
1475 @@ -978,7 +1472,7 @@
1476        -export-symbols | -export-symbols-regex)
1477         if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1478           $echo "$modename: more than one -exported-symbols argument is not allowed"
1479 -         exit 1
1480 +         exit $EXIT_FAILURE
1481         fi
1482         if test "X$arg" = "X-export-symbols"; then
1483           prev=expsyms
1484 @@ -988,11 +1482,28 @@
1485         continue
1486         ;;
1487  
1488 +      -framework|-arch|-isysroot)
1489 +       case " $CC " in
1490 +         *" ${arg} ${1} "* | *" ${arg} ${1} "*)
1491 +               prev=darwin_framework_skip ;;
1492 +         *) compiler_flags="$compiler_flags $arg"
1493 +            prev=darwin_framework ;;
1494 +       esac
1495 +       compile_command="$compile_command $arg"
1496 +       finalize_command="$finalize_command $arg"
1497 +       continue
1498 +       ;;
1499 +
1500 +      -inst-prefix-dir)
1501 +       prev=inst_prefix
1502 +       continue
1503 +       ;;
1504 +
1505        # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1506        # so, if we see these flags be careful not to treat them like -L
1507        -L[A-Z][A-Z]*:*)
1508         case $with_gcc/$host in
1509 -       no/*-*-irix*)
1510 +       no/*-*-irix* | /*-*-irix*)
1511           compile_command="$compile_command $arg"
1512           finalize_command="$finalize_command $arg"
1513           ;;
1514 @@ -1009,7 +1520,8 @@
1515           absdir=`cd "$dir" && pwd`
1516           if test -z "$absdir"; then
1517             $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1518 -           exit 1
1519 +           absdir="$dir"
1520 +           notinst_path="$notinst_path $dir"
1521           fi
1522           dir="$absdir"
1523           ;;
1524 @@ -1023,10 +1535,15 @@
1525         esac
1526         case $host in
1527         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1528 +         testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
1529           case :$dllsearchpath: in
1530           *":$dir:"*) ;;
1531           *) dllsearchpath="$dllsearchpath:$dir";;
1532           esac
1533 +         case :$dllsearchpath: in
1534 +         *":$testbindir:"*) ;;
1535 +         *) dllsearchpath="$dllsearchpath:$testbindir";;
1536 +         esac
1537           ;;
1538         esac
1539         continue
1540 @@ -1035,36 +1552,98 @@
1541        -l*)
1542         if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1543           case $host in
1544 -         *-*-cygwin* | *-*-pw32* | *-*-beos*)
1545 +         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
1546             # These systems don't actually have a C or math library (as such)
1547             continue
1548             ;;
1549 -         *-*-mingw* | *-*-os2*)
1550 +         *-*-os2*)
1551             # These systems don't actually have a C library (as such)
1552             test "X$arg" = "X-lc" && continue
1553             ;;
1554 -         *-*-openbsd*)
1555 +         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1556             # Do not include libc due to us having libc/libc_r.
1557             test "X$arg" = "X-lc" && continue
1558             ;;
1559 -         esac
1560 -        elif test "X$arg" = "X-lc_r"; then
1561 -         case $host in
1562 -         *-*-openbsd*)
1563 -           # Do not include libc_r directly, use -pthread flag.
1564 +         *-*-rhapsody* | *-*-darwin1.[012])
1565 +           # Rhapsody C and math libraries are in the System framework
1566 +           deplibs="$deplibs -framework System"
1567             continue
1568             ;;
1569 +         *-*-sco3.2v5* | *-*-sco5v6*)
1570 +           # Causes problems with __ctype
1571 +           test "X$arg" = "X-lc" && continue
1572 +           ;;
1573 +         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1574 +           # Compiler inserts libc in the correct place for threads to work
1575 +           test "X$arg" = "X-lc" && continue
1576 +           ;;
1577           esac
1578 +       elif test "X$arg" = "X-lc_r"; then
1579 +        case $host in
1580 +        *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1581 +          # Do not include libc_r directly, use -pthread flag.
1582 +          continue
1583 +          ;;
1584 +        esac
1585         fi
1586         deplibs="$deplibs $arg"
1587         continue
1588         ;;
1589  
1590 +      # Tru64 UNIX uses -model [arg] to determine the layout of C++
1591 +      # classes, name mangling, and exception handling.
1592 +      -model)
1593 +       compile_command="$compile_command $arg"
1594 +       compiler_flags="$compiler_flags $arg"
1595 +       finalize_command="$finalize_command $arg"
1596 +       prev=xcompiler
1597 +       continue
1598 +       ;;
1599 +
1600 +     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1601 +       compiler_flags="$compiler_flags $arg"
1602 +       compile_command="$compile_command $arg"
1603 +       finalize_command="$finalize_command $arg"
1604 +       continue
1605 +       ;;
1606 +
1607        -module)
1608         module=yes
1609         continue
1610         ;;
1611  
1612 +      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1613 +      # -r[0-9][0-9]* specifies the processor on the SGI compiler
1614 +      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1615 +      # +DA*, +DD* enable 64-bit mode on the HP compiler
1616 +      # -q* pass through compiler args for the IBM compiler
1617 +      # -m* pass through architecture-specific compiler args for GCC
1618 +      # -m*, -t[45]*, -txscale* pass through architecture-specific
1619 +      # compiler args for GCC
1620 +      # -pg pass through profiling flag for GCC
1621 +      # @file GCC response files
1622 +      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
1623 +      -t[45]*|-txscale*|@*)
1624 +
1625 +       # Unknown arguments in both finalize_command and compile_command need
1626 +       # to be aesthetically quoted because they are evaled later.
1627 +       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1628 +       case $arg in
1629 +       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
1630 +         arg="\"$arg\""
1631 +         ;;
1632 +       esac
1633 +        compile_command="$compile_command $arg"
1634 +        finalize_command="$finalize_command $arg"
1635 +        compiler_flags="$compiler_flags $arg"
1636 +        continue
1637 +        ;;
1638 +
1639 +      -shrext)
1640 +       prev=shrext
1641 +       continue
1642 +       ;;
1643 +
1644        -no-fast-install)
1645         fast_install=no
1646         continue
1647 @@ -1089,8 +1668,18 @@
1648         continue
1649         ;;
1650  
1651 +      -objectlist)
1652 +       prev=objectlist
1653 +       continue
1654 +       ;;
1655 +
1656        -o) prev=output ;;
1657  
1658 +      -precious-files-regex)
1659 +       prev=precious_regex
1660 +       continue
1661 +       ;;
1662 +
1663        -release)
1664         prev=release
1665         continue
1666 @@ -1113,7 +1702,7 @@
1667         [\\/]* | [A-Za-z]:[\\/]*) ;;
1668         *)
1669           $echo "$modename: only absolute run-paths are allowed" 1>&2
1670 -         exit 1
1671 +         exit $EXIT_FAILURE
1672           ;;
1673         esac
1674         case "$xrpath " in
1675 @@ -1141,6 +1730,11 @@
1676         prev=vinfo
1677         continue
1678         ;;
1679 +      -version-number)
1680 +       prev=vinfo
1681 +       vinfo_number=yes
1682 +       continue
1683 +       ;;
1684  
1685        -Wc,*)
1686         args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1687 @@ -1189,6 +1783,11 @@
1688         continue
1689         ;;
1690  
1691 +      -XCClinker)
1692 +       prev=xcclinker
1693 +       continue
1694 +       ;;
1695 +
1696        # Some other compiler flag.
1697        -* | +*)
1698         # Unknown arguments in both finalize_command and compile_command need
1699 @@ -1201,29 +1800,106 @@
1700         esac
1701         ;;
1702  
1703 -      *.lo | *.$objext)
1704 -       # A library or standard object.
1705 -       if test "$prev" = dlfiles; then
1706 -         # This file was specified with -dlopen.
1707 -         if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1708 -           dlfiles="$dlfiles $arg"
1709 -           prev=
1710 -           continue
1711 -         else
1712 -           # If libtool objects are unsupported, then we need to preload.
1713 -           prev=dlprefiles
1714 -         fi
1715 -       fi
1716 +      *.$objext)
1717 +       # A standard object.
1718 +       objs="$objs $arg"
1719 +       ;;
1720  
1721 -       if test "$prev" = dlprefiles; then
1722 -         # Preload the old-style object.
1723 -         dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
1724 -         prev=
1725 -       else
1726 +      *.lo)
1727 +       # A libtool-controlled object.
1728 +
1729 +       # Check to see that this really is a libtool object.
1730 +       if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1731 +         pic_object=
1732 +         non_pic_object=
1733 +
1734 +         # Read the .lo file
1735 +         # If there is no directory component, then add one.
1736           case $arg in
1737 -         *.lo) libobjs="$libobjs $arg" ;;
1738 -         *) objs="$objs $arg" ;;
1739 +         */* | *\\*) . $arg ;;
1740 +         *) . ./$arg ;;
1741           esac
1742 +
1743 +         if test -z "$pic_object" || \
1744 +            test -z "$non_pic_object" ||
1745 +            test "$pic_object" = none && \
1746 +            test "$non_pic_object" = none; then
1747 +           $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1748 +           exit $EXIT_FAILURE
1749 +         fi
1750 +
1751 +         # Extract subdirectory from the argument.
1752 +         xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1753 +         if test "X$xdir" = "X$arg"; then
1754 +           xdir=
1755 +         else
1756 +           xdir="$xdir/"
1757 +         fi
1758 +
1759 +         if test "$pic_object" != none; then
1760 +           # Prepend the subdirectory the object is found in.
1761 +           pic_object="$xdir$pic_object"
1762 +
1763 +           if test "$prev" = dlfiles; then
1764 +             if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1765 +               dlfiles="$dlfiles $pic_object"
1766 +               prev=
1767 +               continue
1768 +             else
1769 +               # If libtool objects are unsupported, then we need to preload.
1770 +               prev=dlprefiles
1771 +             fi
1772 +           fi
1773 +
1774 +           # CHECK ME:  I think I busted this.  -Ossama
1775 +           if test "$prev" = dlprefiles; then
1776 +             # Preload the old-style object.
1777 +             dlprefiles="$dlprefiles $pic_object"
1778 +             prev=
1779 +           fi
1780 +
1781 +           # A PIC object.
1782 +           libobjs="$libobjs $pic_object"
1783 +           arg="$pic_object"
1784 +         fi
1785 +
1786 +         # Non-PIC object.
1787 +         if test "$non_pic_object" != none; then
1788 +           # Prepend the subdirectory the object is found in.
1789 +           non_pic_object="$xdir$non_pic_object"
1790 +
1791 +           # A standard non-PIC object
1792 +           non_pic_objects="$non_pic_objects $non_pic_object"
1793 +           if test -z "$pic_object" || test "$pic_object" = none ; then
1794 +             arg="$non_pic_object"
1795 +           fi
1796 +         else
1797 +           # If the PIC object exists, use it instead.
1798 +           # $xdir was prepended to $pic_object above.
1799 +           non_pic_object="$pic_object"
1800 +           non_pic_objects="$non_pic_objects $non_pic_object"
1801 +         fi
1802 +       else
1803 +         # Only an error if not doing a dry-run.
1804 +         if test -z "$run"; then
1805 +           $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1806 +           exit $EXIT_FAILURE
1807 +         else
1808 +           # Dry-run case.
1809 +
1810 +           # Extract subdirectory from the argument.
1811 +           xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1812 +           if test "X$xdir" = "X$arg"; then
1813 +             xdir=
1814 +           else
1815 +             xdir="$xdir/"
1816 +           fi
1817 +
1818 +           pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1819 +           non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1820 +           libobjs="$libobjs $pic_object"
1821 +           non_pic_objects="$non_pic_objects $non_pic_object"
1822 +         fi
1823         fi
1824         ;;
1825  
1826 @@ -1274,7 +1950,7 @@
1827      if test -n "$prev"; then
1828        $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
1829        $echo "$help" 1>&2
1830 -      exit 1
1831 +      exit $EXIT_FAILURE
1832      fi
1833  
1834      if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
1835 @@ -1283,6 +1959,7 @@
1836        finalize_command="$finalize_command $arg"
1837      fi
1838  
1839 +    oldlibs=
1840      # calculate the name of the file, without its directory
1841      outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
1842      libobjs_save="$libobjs"
1843 @@ -1303,12 +1980,12 @@
1844        output_objdir="$output_objdir/$objdir"
1845      fi
1846      # Create the object directory.
1847 -    if test ! -d $output_objdir; then
1848 +    if test ! -d "$output_objdir"; then
1849        $show "$mkdir $output_objdir"
1850        $run $mkdir $output_objdir
1851 -      status=$?
1852 -      if test $status -ne 0 && test ! -d $output_objdir; then
1853 -       exit $status
1854 +      exit_status=$?
1855 +      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
1856 +       exit $exit_status
1857        fi
1858      fi
1859  
1860 @@ -1317,7 +1994,7 @@
1861      "")
1862        $echo "$modename: you must specify an output file" 1>&2
1863        $echo "$help" 1>&2
1864 -      exit 1
1865 +      exit $EXIT_FAILURE
1866        ;;
1867      *.$libext) linkmode=oldlib ;;
1868      *.lo | *.$objext) linkmode=obj ;;
1869 @@ -1325,22 +2002,52 @@
1870      *) linkmode=prog ;; # Anything else should be a program.
1871      esac
1872  
1873 +    case $host in
1874 +    *cygwin* | *mingw* | *pw32*)
1875 +      # don't eliminate duplications in $postdeps and $predeps
1876 +      duplicate_compiler_generated_deps=yes
1877 +      ;;
1878 +    *)
1879 +      duplicate_compiler_generated_deps=$duplicate_deps
1880 +      ;;
1881 +    esac
1882      specialdeplibs=
1883 +
1884      libs=
1885      # Find all interdependent deplibs by searching for libraries
1886      # that are linked more than once (e.g. -la -lb -la)
1887      for deplib in $deplibs; do
1888 -      case "$libs " in
1889 -      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
1890 -      esac
1891 +      if test "X$duplicate_deps" = "Xyes" ; then
1892 +       case "$libs " in
1893 +       *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
1894 +       esac
1895 +      fi
1896        libs="$libs $deplib"
1897      done
1898 +
1899 +    if test "$linkmode" = lib; then
1900 +      libs="$predeps $libs $compiler_lib_search_path $postdeps"
1901 +
1902 +      # Compute libraries that are listed more than once in $predeps
1903 +      # $postdeps and mark them as special (i.e., whose duplicates are
1904 +      # not to be eliminated).
1905 +      pre_post_deps=
1906 +      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
1907 +       for pre_post_dep in $predeps $postdeps; do
1908 +         case "$pre_post_deps " in
1909 +         *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
1910 +         esac
1911 +         pre_post_deps="$pre_post_deps $pre_post_dep"
1912 +       done
1913 +      fi
1914 +      pre_post_deps=
1915 +    fi
1916 +
1917      deplibs=
1918      newdependency_libs=
1919      newlib_search_path=
1920      need_relink=no # whether we're linking any uninstalled libtool libraries
1921      notinst_deplibs= # not-installed libtool libraries
1922 -    notinst_path= # paths that contain not-installed libtool libraries
1923      case $linkmode in
1924      lib)
1925         passes="conv link"
1926 @@ -1349,7 +2056,7 @@
1927           *.la) ;;
1928           *)
1929             $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
1930 -           exit 1
1931 +           exit $EXIT_FAILURE
1932             ;;
1933           esac
1934         done
1935 @@ -1366,39 +2073,58 @@
1936         ;;
1937      esac
1938      for pass in $passes; do
1939 -      if test $linkmode = prog; then
1940 -       # Determine which files to process
1941 +      if test "$linkmode,$pass" = "lib,link" ||
1942 +        test "$linkmode,$pass" = "prog,scan"; then
1943 +       libs="$deplibs"
1944 +       deplibs=
1945 +      fi
1946 +      if test "$linkmode" = prog; then
1947         case $pass in
1948 -       dlopen)
1949 -         libs="$dlfiles"
1950 -         save_deplibs="$deplibs" # Collect dlpreopened libraries
1951 -         deplibs=
1952 -         ;;
1953 +       dlopen) libs="$dlfiles" ;;
1954         dlpreopen) libs="$dlprefiles" ;;
1955 -       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
1956 +       link)
1957 +         libs="$deplibs %DEPLIBS%"
1958 +         test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
1959 +         ;;
1960         esac
1961        fi
1962 +      if test "$pass" = dlopen; then
1963 +       # Collect dlpreopened libraries
1964 +       save_deplibs="$deplibs"
1965 +       deplibs=
1966 +      fi
1967        for deplib in $libs; do
1968         lib=
1969         found=no
1970         case $deplib in
1971 -       -l*)
1972 -         if test $linkmode = oldlib && test $linkmode = obj; then
1973 -           $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2
1974 -           continue
1975 +       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1976 +         if test "$linkmode,$pass" = "prog,link"; then
1977 +           compile_deplibs="$deplib $compile_deplibs"
1978 +           finalize_deplibs="$deplib $finalize_deplibs"
1979 +         else
1980 +           compiler_flags="$compiler_flags $deplib"
1981           fi
1982 -         if test $pass = conv; then
1983 -           deplibs="$deplib $deplibs"
1984 +         continue
1985 +         ;;
1986 +       -l*)
1987 +         if test "$linkmode" != lib && test "$linkmode" != prog; then
1988 +           $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
1989             continue
1990           fi
1991           name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
1992           for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
1993 -           # Search the libtool library
1994 -           lib="$searchdir/lib${name}.la"
1995 -           if test -f "$lib"; then
1996 -             found=yes
1997 -             break
1998 -           fi
1999 +           for search_ext in .la $std_shrext .so .a; do
2000 +             # Search the libtool library
2001 +             lib="$searchdir/lib${name}${search_ext}"
2002 +             if test -f "$lib"; then
2003 +               if test "$search_ext" = ".la"; then
2004 +                 found=yes
2005 +               else
2006 +                 found=no
2007 +               fi
2008 +               break 2
2009 +             fi
2010 +           done
2011           done
2012           if test "$found" != yes; then
2013             # deplib doesn't seem to be a libtool library
2014 @@ -1407,40 +2133,76 @@
2015               finalize_deplibs="$deplib $finalize_deplibs"
2016             else
2017               deplibs="$deplib $deplibs"
2018 -             test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs"
2019 +             test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2020             fi
2021             continue
2022 +         else # deplib is a libtool library
2023 +           # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2024 +           # We need to do some special things here, and not later.
2025 +           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2026 +             case " $predeps $postdeps " in
2027 +             *" $deplib "*)
2028 +               if (${SED} -e '2q' $lib |
2029 +                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2030 +                 library_names=
2031 +                 old_library=
2032 +                 case $lib in
2033 +                 */* | *\\*) . $lib ;;
2034 +                 *) . ./$lib ;;
2035 +                 esac
2036 +                 for l in $old_library $library_names; do
2037 +                   ll="$l"
2038 +                 done
2039 +                 if test "X$ll" = "X$old_library" ; then # only static version available
2040 +                   found=no
2041 +                   ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2042 +                   test "X$ladir" = "X$lib" && ladir="."
2043 +                   lib=$ladir/$old_library
2044 +                   if test "$linkmode,$pass" = "prog,link"; then
2045 +                     compile_deplibs="$deplib $compile_deplibs"
2046 +                     finalize_deplibs="$deplib $finalize_deplibs"
2047 +                   else
2048 +                     deplibs="$deplib $deplibs"
2049 +                     test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2050 +                   fi
2051 +                   continue
2052 +                 fi
2053 +               fi
2054 +               ;;
2055 +             *) ;;
2056 +             esac
2057 +           fi
2058           fi
2059           ;; # -l
2060         -L*)
2061           case $linkmode in
2062           lib)
2063             deplibs="$deplib $deplibs"
2064 -           test $pass = conv && continue
2065 +           test "$pass" = conv && continue
2066             newdependency_libs="$deplib $newdependency_libs"
2067             newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2068             ;;
2069           prog)
2070 -           if test $pass = conv; then
2071 +           if test "$pass" = conv; then
2072               deplibs="$deplib $deplibs"
2073               continue
2074             fi
2075 -           if test $pass = scan; then
2076 +           if test "$pass" = scan; then
2077               deplibs="$deplib $deplibs"
2078 -             newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2079             else
2080               compile_deplibs="$deplib $compile_deplibs"
2081               finalize_deplibs="$deplib $finalize_deplibs"
2082             fi
2083 +           newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2084             ;;
2085           *)
2086 -           $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2
2087 +           $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2088             ;;
2089           esac # linkmode
2090           continue
2091           ;; # -L
2092         -R*)
2093 -         if test $pass = link; then
2094 +         if test "$pass" = link; then
2095             dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2096             # Make sure the xrpath contains only unique directories.
2097             case "$xrpath " in
2098 @@ -1453,28 +2215,45 @@
2099           ;;
2100         *.la) lib="$deplib" ;;
2101         *.$libext)
2102 -         if test $pass = conv; then
2103 +         if test "$pass" = conv; then
2104             deplibs="$deplib $deplibs"
2105             continue
2106           fi
2107           case $linkmode in
2108           lib)
2109 -           if test "$deplibs_check_method" != pass_all; then
2110 -             echo
2111 -             echo "*** Warning: This library needs some functionality provided by $deplib."
2112 -             echo "*** I have the capability to make that library automatically link in when"
2113 -             echo "*** you link to this library.  But I can only do this if you have a"
2114 -             echo "*** shared version of the library, which you do not appear to have."
2115 +           valid_a_lib=no
2116 +           case $deplibs_check_method in
2117 +             match_pattern*)
2118 +               set dummy $deplibs_check_method
2119 +               match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2120 +               if eval $echo \"$deplib\" 2>/dev/null \
2121 +                   | $SED 10q \
2122 +                   | $EGREP "$match_pattern_regex" > /dev/null; then
2123 +                 valid_a_lib=yes
2124 +               fi
2125 +               ;;
2126 +             pass_all)
2127 +               valid_a_lib=yes
2128 +               ;;
2129 +            esac
2130 +           if test "$valid_a_lib" != yes; then
2131 +             $echo
2132 +             $echo "*** Warning: Trying to link with static lib archive $deplib."
2133 +             $echo "*** I have the capability to make that library automatically link in when"
2134 +             $echo "*** you link to this library.  But I can only do this if you have a"
2135 +             $echo "*** shared version of the library, which you do not appear to have"
2136 +             $echo "*** because the file extensions .$libext of this argument makes me believe"
2137 +             $echo "*** that it is just a static archive that I should not used here."
2138             else
2139 -             echo
2140 -             echo "*** Warning: Linking the shared library $output against the"
2141 -             echo "*** static library $deplib is not portable!"
2142 +             $echo
2143 +             $echo "*** Warning: Linking the shared library $output against the"
2144 +             $echo "*** static library $deplib is not portable!"
2145               deplibs="$deplib $deplibs"
2146             fi
2147             continue
2148             ;;
2149           prog)
2150 -           if test $pass != link; then
2151 +           if test "$pass" != link; then
2152               deplibs="$deplib $deplibs"
2153             else
2154               compile_deplibs="$deplib $compile_deplibs"
2155 @@ -1485,14 +2264,18 @@
2156           esac # linkmode
2157           ;; # *.$libext
2158         *.lo | *.$objext)
2159 -         if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2160 -           # If there is no dlopen support or we're linking statically,
2161 -           # we need to preload.
2162 -           newdlprefiles="$newdlprefiles $deplib"
2163 -           compile_deplibs="$deplib $compile_deplibs"
2164 -           finalize_deplibs="$deplib $finalize_deplibs"
2165 -         else
2166 -           newdlfiles="$newdlfiles $deplib"
2167 +         if test "$pass" = conv; then
2168 +           deplibs="$deplib $deplibs"
2169 +         elif test "$linkmode" = prog; then
2170 +           if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2171 +             # If there is no dlopen support or we're linking statically,
2172 +             # we need to preload.
2173 +             newdlprefiles="$newdlprefiles $deplib"
2174 +             compile_deplibs="$deplib $compile_deplibs"
2175 +             finalize_deplibs="$deplib $finalize_deplibs"
2176 +           else
2177 +             newdlfiles="$newdlfiles $deplib"
2178 +           fi
2179           fi
2180           continue
2181           ;;
2182 @@ -1501,17 +2284,17 @@
2183           continue
2184           ;;
2185         esac # case $deplib
2186 -       if test $found = yes || test -f "$lib"; then :
2187 +       if test "$found" = yes || test -f "$lib"; then :
2188         else
2189 -         $echo "$modename: cannot find the library \`$lib'" 1>&2
2190 -         exit 1
2191 +         $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
2192 +         exit $EXIT_FAILURE
2193         fi
2194  
2195         # Check to see that this really is a libtool archive.
2196 -       if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2197 +       if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2198         else
2199           $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2200 -         exit 1
2201 +         exit $EXIT_FAILURE
2202         fi
2203  
2204         ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2205 @@ -1524,8 +2307,11 @@
2206         library_names=
2207         old_library=
2208         # If the library was installed with an old release of libtool,
2209 -       # it will not redefine variable installed.
2210 +       # it will not redefine variables installed, or shouldnotlink
2211         installed=yes
2212 +       shouldnotlink=no
2213 +       avoidtemprpath=
2214 +
2215  
2216         # Read the .la file
2217         case $lib in
2218 @@ -1535,19 +2321,18 @@
2219  
2220         if test "$linkmode,$pass" = "lib,link" ||
2221            test "$linkmode,$pass" = "prog,scan" ||
2222 -          { test $linkmode = oldlib && test $linkmode = obj; }; then
2223 -          # Add dl[pre]opened files of deplib
2224 +          { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2225           test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2226           test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2227         fi
2228  
2229 -       if test $pass = conv; then
2230 +       if test "$pass" = conv; then
2231           # Only check for convenience libraries
2232           deplibs="$lib $deplibs"
2233           if test -z "$libdir"; then
2234             if test -z "$old_library"; then
2235               $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2236 -             exit 1
2237 +             exit $EXIT_FAILURE
2238             fi
2239             # It is a libtool convenience library, so add in its objects.
2240             convenience="$convenience $ladir/$objdir/$old_library"
2241 @@ -1555,18 +2340,21 @@
2242             tmp_libs=
2243             for deplib in $dependency_libs; do
2244               deplibs="$deplib $deplibs"
2245 -             case "$tmp_libs " in
2246 -             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2247 -             esac
2248 +              if test "X$duplicate_deps" = "Xyes" ; then
2249 +               case "$tmp_libs " in
2250 +               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2251 +               esac
2252 +              fi
2253               tmp_libs="$tmp_libs $deplib"
2254             done
2255 -         elif test $linkmode != prog && test $linkmode != lib; then
2256 +         elif test "$linkmode" != prog && test "$linkmode" != lib; then
2257             $echo "$modename: \`$lib' is not a convenience library" 1>&2
2258 -           exit 1
2259 +           exit $EXIT_FAILURE
2260           fi
2261           continue
2262         fi # $pass = conv
2263  
2264 +
2265         # Get the name of the library we link against.
2266         linklib=
2267         for l in $old_library $library_names; do
2268 @@ -1574,19 +2362,23 @@
2269         done
2270         if test -z "$linklib"; then
2271           $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2272 -         exit 1
2273 +         exit $EXIT_FAILURE
2274         fi
2275  
2276         # This library was specified with -dlopen.
2277 -       if test $pass = dlopen; then
2278 +       if test "$pass" = dlopen; then
2279           if test -z "$libdir"; then
2280             $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2281 -           exit 1
2282 +           exit $EXIT_FAILURE
2283           fi
2284 -         if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2285 +         if test -z "$dlname" ||
2286 +            test "$dlopen_support" != yes ||
2287 +            test "$build_libtool_libs" = no; then
2288             # If there is no dlname, no dlopen support or we're linking
2289 -           # statically, we need to preload.
2290 -           dlprefiles="$dlprefiles $lib"
2291 +           # statically, we need to preload.  We also need to preload any
2292 +           # dependent libraries so libltdl's deplib preloader doesn't
2293 +           # bomb out in the load deplibs phase.
2294 +           dlprefiles="$dlprefiles $lib $dependency_libs"
2295           else
2296             newdlfiles="$newdlfiles $lib"
2297           fi
2298 @@ -1618,19 +2410,27 @@
2299             dir="$libdir"
2300             absdir="$libdir"
2301           fi
2302 +         test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2303         else
2304 -         dir="$ladir/$objdir"
2305 -         absdir="$abs_ladir/$objdir"
2306 -         # Remove this search path later
2307 -         notinst_path="$notinst_path $abs_ladir"
2308 +         if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2309 +           dir="$ladir"
2310 +           absdir="$abs_ladir"
2311 +           # Remove this search path later
2312 +           notinst_path="$notinst_path $abs_ladir"
2313 +         else
2314 +           dir="$ladir/$objdir"
2315 +           absdir="$abs_ladir/$objdir"
2316 +           # Remove this search path later
2317 +           notinst_path="$notinst_path $abs_ladir"
2318 +         fi
2319         fi # $installed = yes
2320         name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2321  
2322         # This library was specified with -dlpreopen.
2323 -       if test $pass = dlpreopen; then
2324 +       if test "$pass" = dlpreopen; then
2325           if test -z "$libdir"; then
2326             $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2327 -           exit 1
2328 +           exit $EXIT_FAILURE
2329           fi
2330           # Prefer using a static library (so that no silly _DYNAMIC symbols
2331           # are required to link).
2332 @@ -1646,18 +2446,19 @@
2333  
2334         if test -z "$libdir"; then
2335           # Link the convenience library
2336 -         if test $linkmode = lib; then
2337 +         if test "$linkmode" = lib; then
2338             deplibs="$dir/$old_library $deplibs"
2339           elif test "$linkmode,$pass" = "prog,link"; then
2340             compile_deplibs="$dir/$old_library $compile_deplibs"
2341             finalize_deplibs="$dir/$old_library $finalize_deplibs"
2342           else
2343 -           deplibs="$lib $deplibs"
2344 +           deplibs="$lib $deplibs" # used for prog,scan pass
2345           fi
2346           continue
2347         fi
2348  
2349 -       if test $linkmode = prog && test $pass != link; then
2350 +
2351 +       if test "$linkmode" = prog && test "$pass" != link; then
2352           newlib_search_path="$newlib_search_path $ladir"
2353           deplibs="$lib $deplibs"
2354  
2355 @@ -1673,28 +2474,36 @@
2356             -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2357             esac
2358             # Need to link against all dependency_libs?
2359 -           if test $linkalldeplibs = yes; then
2360 +           if test "$linkalldeplibs" = yes; then
2361               deplibs="$deplib $deplibs"
2362             else
2363               # Need to hardcode shared library paths
2364               # or/and link against static libraries
2365               newdependency_libs="$deplib $newdependency_libs"
2366             fi
2367 -           case "$tmp_libs " in
2368 -           *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2369 -           esac
2370 +           if test "X$duplicate_deps" = "Xyes" ; then
2371 +             case "$tmp_libs " in
2372 +             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2373 +             esac
2374 +           fi
2375             tmp_libs="$tmp_libs $deplib"
2376           done # for deplib
2377           continue
2378         fi # $linkmode = prog...
2379  
2380 -       link_static=no # Whether the deplib will be linked statically
2381 -       if test -n "$library_names" &&
2382 -          { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2383 -         # Link against this shared library
2384 +       if test "$linkmode,$pass" = "prog,link"; then
2385 +         if test -n "$library_names" &&
2386 +            { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2387 +           # We need to hardcode the library path
2388 +           if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2389 +             # Make sure the rpath contains only unique directories.
2390 +             case "$temp_rpath " in
2391 +             *" $dir "*) ;;
2392 +             *" $absdir "*) ;;
2393 +             *) temp_rpath="$temp_rpath $absdir" ;;
2394 +             esac
2395 +           fi
2396  
2397 -         if test "$linkmode,$pass" = "prog,link" ||
2398 -          { test $linkmode = lib && test $hardcode_into_libs = yes; }; then
2399             # Hardcode the library path.
2400             # Skip directories that are in the system default run-time
2401             # search path.
2402 @@ -1716,17 +2525,6 @@
2403               esac
2404               ;;
2405             esac
2406 -           if test $linkmode = prog; then
2407 -             # We need to hardcode the library path
2408 -             if test -n "$shlibpath_var"; then
2409 -               # Make sure the rpath contains only unique directories.
2410 -               case "$temp_rpath " in
2411 -               *" $dir "*) ;;
2412 -               *" $absdir "*) ;;
2413 -               *) temp_rpath="$temp_rpath $dir" ;;
2414 -               esac
2415 -             fi
2416 -           fi
2417           fi # $linkmode,$pass = prog,link...
2418  
2419           if test "$alldeplibs" = yes &&
2420 @@ -1736,11 +2534,56 @@
2421             # We only need to search for static libraries
2422             continue
2423           fi
2424 +       fi
2425  
2426 +       link_static=no # Whether the deplib will be linked statically
2427 +       use_static_libs=$prefer_static_libs
2428 +       if test "$use_static_libs" = built && test "$installed" = yes ; then
2429 +         use_static_libs=no
2430 +       fi
2431 +       if test -n "$library_names" &&
2432 +          { test "$use_static_libs" = no || test -z "$old_library"; }; then
2433           if test "$installed" = no; then
2434             notinst_deplibs="$notinst_deplibs $lib"
2435             need_relink=yes
2436           fi
2437 +         # This is a shared library
2438 +
2439 +         # Warn about portability, can't link against -module's on
2440 +         # some systems (darwin)
2441 +         if test "$shouldnotlink" = yes && test "$pass" = link ; then
2442 +           $echo
2443 +           if test "$linkmode" = prog; then
2444 +             $echo "*** Warning: Linking the executable $output against the loadable module"
2445 +           else
2446 +             $echo "*** Warning: Linking the shared library $output against the loadable module"
2447 +           fi
2448 +           $echo "*** $linklib is not portable!"
2449 +         fi
2450 +         if test "$linkmode" = lib &&
2451 +            test "$hardcode_into_libs" = yes; then
2452 +           # Hardcode the library path.
2453 +           # Skip directories that are in the system default run-time
2454 +           # search path.
2455 +           case " $sys_lib_dlsearch_path " in
2456 +           *" $absdir "*) ;;
2457 +           *)
2458 +             case "$compile_rpath " in
2459 +             *" $absdir "*) ;;
2460 +             *) compile_rpath="$compile_rpath $absdir"
2461 +             esac
2462 +             ;;
2463 +           esac
2464 +           case " $sys_lib_dlsearch_path " in
2465 +           *" $libdir "*) ;;
2466 +           *)
2467 +             case "$finalize_rpath " in
2468 +             *" $libdir "*) ;;
2469 +             *) finalize_rpath="$finalize_rpath $libdir"
2470 +             esac
2471 +             ;;
2472 +           esac
2473 +         fi
2474  
2475           if test -n "$old_archive_from_expsyms_cmds"; then
2476             # figure out the soname
2477 @@ -1754,7 +2597,7 @@
2478             elif test -n "$soname_spec"; then
2479               # bleh windows
2480               case $host in
2481 -             *cygwin*)
2482 +             *cygwin* | mingw*)
2483                 major=`expr $current - $age`
2484                 versuffix="-$major"
2485                 ;;
2486 @@ -1766,17 +2609,18 @@
2487  
2488             # Make a new name for the extract_expsyms_cmds to use
2489             soroot="$soname"
2490 -           soname=`echo $soroot | sed -e 's/^.*\///'`
2491 -           newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a"
2492 +           soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2493 +           newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
2494  
2495             # If the library has no export list, then create one now
2496             if test -f "$output_objdir/$soname-def"; then :
2497             else
2498               $show "extracting exported symbol list from \`$soname'"
2499               save_ifs="$IFS"; IFS='~'
2500 -             eval cmds=\"$extract_expsyms_cmds\"
2501 +             cmds=$extract_expsyms_cmds
2502               for cmd in $cmds; do
2503                 IFS="$save_ifs"
2504 +               eval cmd=\"$cmd\"
2505                 $show "$cmd"
2506                 $run eval "$cmd" || exit $?
2507               done
2508 @@ -1787,9 +2631,10 @@
2509             if test -f "$output_objdir/$newlib"; then :; else
2510               $show "generating import library for \`$soname'"
2511               save_ifs="$IFS"; IFS='~'
2512 -             eval cmds=\"$old_archive_from_expsyms_cmds\"
2513 +             cmds=$old_archive_from_expsyms_cmds
2514               for cmd in $cmds; do
2515                 IFS="$save_ifs"
2516 +               eval cmd=\"$cmd\"
2517                 $show "$cmd"
2518                 $run eval "$cmd" || exit $?
2519               done
2520 @@ -1798,9 +2643,9 @@
2521             # make sure the library variables are pointing to the new library
2522             dir=$output_objdir
2523             linklib=$newlib
2524 -         fi # test -n $old_archive_from_expsyms_cmds
2525 +         fi # test -n "$old_archive_from_expsyms_cmds"
2526  
2527 -         if test $linkmode = prog || test "$mode" != relink; then
2528 +         if test "$linkmode" = prog || test "$mode" != relink; then
2529             add_shlibpath=
2530             add_dir=
2531             add=
2532 @@ -1809,6 +2654,26 @@
2533             immediate | unsupported)
2534               if test "$hardcode_direct" = no; then
2535                 add="$dir/$linklib"
2536 +               case $host in
2537 +                 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2538 +                 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
2539 +                 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2540 +                   *-*-unixware7*) add_dir="-L$dir" ;;
2541 +                 *-*-darwin* )
2542 +                   # if the lib is a module then we can not link against
2543 +                   # it, someone is ignoring the new warnings I added
2544 +                   if /usr/bin/file -L $add 2> /dev/null |
2545 +                      $EGREP ": [^:]* bundle" >/dev/null ; then
2546 +                     $echo "** Warning, lib $linklib is a module, not a shared library"
2547 +                     if test -z "$old_library" ; then
2548 +                       $echo
2549 +                       $echo "** And there doesn't seem to be a static archive available"
2550 +                       $echo "** The link will probably fail, sorry"
2551 +                     else
2552 +                       add="$dir/$old_library"
2553 +                     fi
2554 +                   fi
2555 +               esac
2556               elif test "$hardcode_minus_L" = no; then
2557                 case $host in
2558                 *-*-sunos*) add_shlibpath="$dir" ;;
2559 @@ -1827,6 +2692,14 @@
2560                 add="$dir/$linklib"
2561               elif test "$hardcode_minus_L" = yes; then
2562                 add_dir="-L$dir"
2563 +               # Try looking first in the location we're being installed to.
2564 +               if test -n "$inst_prefix_dir"; then
2565 +                 case $libdir in
2566 +                   [\\/]*)
2567 +                     add_dir="$add_dir -L$inst_prefix_dir$libdir"
2568 +                     ;;
2569 +                 esac
2570 +               fi
2571                 add="-l$name"
2572               elif test "$hardcode_shlibpath_var" = yes; then
2573                 add_shlibpath="$dir"
2574 @@ -1840,7 +2713,7 @@
2575  
2576             if test "$lib_linked" != yes; then
2577               $echo "$modename: configuration error: unsupported hardcode properties"
2578 -             exit 1
2579 +             exit $EXIT_FAILURE
2580             fi
2581  
2582             if test -n "$add_shlibpath"; then
2583 @@ -1849,7 +2722,7 @@
2584               *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2585               esac
2586             fi
2587 -           if test $linkmode = prog; then
2588 +           if test "$linkmode" = prog; then
2589               test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2590               test -n "$add" && compile_deplibs="$add $compile_deplibs"
2591             else
2592 @@ -1866,7 +2739,7 @@
2593             fi
2594           fi
2595  
2596 -         if test $linkmode = prog || test "$mode" = relink; then
2597 +         if test "$linkmode" = prog || test "$mode" = relink; then
2598             add_shlibpath=
2599             add_dir=
2600             add=
2601 @@ -1882,13 +2755,28 @@
2602               *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2603               esac
2604               add="-l$name"
2605 +           elif test "$hardcode_automatic" = yes; then
2606 +             if test -n "$inst_prefix_dir" &&
2607 +                test -f "$inst_prefix_dir$libdir/$linklib" ; then
2608 +               add="$inst_prefix_dir$libdir/$linklib"
2609 +             else
2610 +               add="$libdir/$linklib"
2611 +             fi
2612             else
2613               # We cannot seem to hardcode it, guess we'll fake it.
2614               add_dir="-L$libdir"
2615 +             # Try looking first in the location we're being installed to.
2616 +             if test -n "$inst_prefix_dir"; then
2617 +               case $libdir in
2618 +                 [\\/]*)
2619 +                   add_dir="$add_dir -L$inst_prefix_dir$libdir"
2620 +                   ;;
2621 +               esac
2622 +             fi
2623               add="-l$name"
2624             fi
2625  
2626 -           if test $linkmode = prog; then
2627 +           if test "$linkmode" = prog; then
2628               test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2629               test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2630             else
2631 @@ -1896,16 +2784,7 @@
2632               test -n "$add" && deplibs="$add $deplibs"
2633             fi
2634           fi
2635 -       elif test $linkmode = prog; then
2636 -         if test "$alldeplibs" = yes &&
2637 -            { test "$deplibs_check_method" = pass_all ||
2638 -              { test "$build_libtool_libs" = yes &&
2639 -                test -n "$library_names"; }; }; then
2640 -           # We only need to search for static libraries
2641 -           continue
2642 -         fi
2643 -
2644 -         # Try to link the static library
2645 +       elif test "$linkmode" = prog; then
2646           # Here we assume that one of hardcode_direct or hardcode_minus_L
2647           # is not unsupported.  This is valid on all known static and
2648           # shared platforms.
2649 @@ -1925,20 +2804,21 @@
2650  
2651             # Just print a warning and add the library to dependency_libs so
2652             # that the program can be linked against the static library.
2653 -           echo
2654 -           echo "*** Warning: This library needs some functionality provided by $lib."
2655 -           echo "*** I have the capability to make that library automatically link in when"
2656 -           echo "*** you link to this library.  But I can only do this if you have a"
2657 -           echo "*** shared version of the library, which you do not appear to have."
2658 +           $echo
2659 +           $echo "*** Warning: This system can not link to static lib archive $lib."
2660 +           $echo "*** I have the capability to make that library automatically link in when"
2661 +           $echo "*** you link to this library.  But I can only do this if you have a"
2662 +           $echo "*** shared version of the library, which you do not appear to have."
2663             if test "$module" = yes; then
2664 -             echo "*** Therefore, libtool will create a static module, that should work "
2665 -             echo "*** as long as the dlopening application is linked with the -dlopen flag."
2666 +             $echo "*** But as you try to build a module library, libtool will still create "
2667 +             $echo "*** a static module, that should work as long as the dlopening application"
2668 +             $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2669               if test -z "$global_symbol_pipe"; then
2670 -               echo
2671 -               echo "*** However, this would only work if libtool was able to extract symbol"
2672 -               echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2673 -               echo "*** not find such a program.  So, this module is probably useless."
2674 -               echo "*** \`nm' from GNU binutils and a full rebuild may help."
2675 +               $echo
2676 +               $echo "*** However, this would only work if libtool was able to extract symbol"
2677 +               $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2678 +               $echo "*** not find such a program.  So, this module is probably useless."
2679 +               $echo "*** \`nm' from GNU binutils and a full rebuild may help."
2680               fi
2681               if test "$build_old_libs" = no; then
2682                 build_libtool_libs=module
2683 @@ -1948,17 +2828,16 @@
2684               fi
2685             fi
2686           else
2687 -           convenience="$convenience $dir/$old_library"
2688 -           old_convenience="$old_convenience $dir/$old_library"
2689             deplibs="$dir/$old_library $deplibs"
2690             link_static=yes
2691           fi
2692         fi # link shared/static library?
2693  
2694 -       if test $linkmode = lib; then
2695 +       if test "$linkmode" = lib; then
2696           if test -n "$dependency_libs" &&
2697 -            { test $hardcode_into_libs != yes || test $build_old_libs = yes ||
2698 -              test $link_static = yes; }; then
2699 +            { test "$hardcode_into_libs" != yes ||
2700 +              test "$build_old_libs" = yes ||
2701 +              test "$link_static" = yes; }; then
2702             # Extract -R from dependency_libs
2703             temp_deplibs=
2704             for libdir in $dependency_libs; do
2705 @@ -1981,13 +2860,15 @@
2706           tmp_libs=
2707           for deplib in $dependency_libs; do
2708             newdependency_libs="$deplib $newdependency_libs"
2709 -           case "$tmp_libs " in
2710 -           *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2711 -           esac
2712 +           if test "X$duplicate_deps" = "Xyes" ; then
2713 +             case "$tmp_libs " in
2714 +             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2715 +             esac
2716 +           fi
2717             tmp_libs="$tmp_libs $deplib"
2718           done
2719  
2720 -         if test $link_all_deplibs != no; then
2721 +         if test "$link_all_deplibs" != no; then
2722             # Add the search paths of all dependency libraries
2723             for deplib in $dependency_libs; do
2724               case $deplib in
2725 @@ -2007,38 +2888,83 @@
2726                   ;;
2727                 esac
2728                 if grep "^installed=no" $deplib > /dev/null; then
2729 -                 path="-L$absdir/$objdir"
2730 +                 path="$absdir/$objdir"
2731                 else
2732 -                 eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2733 +                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2734                   if test -z "$libdir"; then
2735                     $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2736 -                   exit 1
2737 +                   exit $EXIT_FAILURE
2738                   fi
2739                   if test "$absdir" != "$libdir"; then
2740                     $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2741                   fi
2742 -                 path="-L$absdir"
2743 +                 path="$absdir"
2744                 fi
2745 +               depdepl=
2746 +               case $host in
2747 +               *-*-darwin*)
2748 +                 # we do not want to link against static libs,
2749 +                 # but need to link against shared
2750 +                 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2751 +                 if test -n "$deplibrary_names" ; then
2752 +                   for tmp in $deplibrary_names ; do
2753 +                     depdepl=$tmp
2754 +                   done
2755 +                   if test -f "$path/$depdepl" ; then
2756 +                     depdepl="$path/$depdepl"
2757 +                   fi
2758 +                   # do not add paths which are already there
2759 +                   case " $newlib_search_path " in
2760 +                   *" $path "*) ;;
2761 +                   *) newlib_search_path="$newlib_search_path $path";;
2762 +                   esac
2763 +                 fi
2764 +                 path=""
2765 +                 ;;
2766 +               *)
2767 +                 path="-L$path"
2768 +                 ;;
2769 +               esac
2770 +               ;;
2771 +             -l*)
2772 +               case $host in
2773 +               *-*-darwin*)
2774 +                 # Again, we only want to link against shared libraries
2775 +                 eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2776 +                 for tmp in $newlib_search_path ; do
2777 +                   if test -f "$tmp/lib$tmp_libs.dylib" ; then
2778 +                     eval depdepl="$tmp/lib$tmp_libs.dylib"
2779 +                     break
2780 +                   fi
2781 +                 done
2782 +                 path=""
2783 +                 ;;
2784 +               *) continue ;;
2785 +               esac
2786                 ;;
2787               *) continue ;;
2788               esac
2789               case " $deplibs " in
2790               *" $path "*) ;;
2791 -             *) deplibs="$deplibs $path" ;;
2792 +             *) deplibs="$path $deplibs" ;;
2793 +             esac
2794 +             case " $deplibs " in
2795 +             *" $depdepl "*) ;;
2796 +             *) deplibs="$depdepl $deplibs" ;;
2797               esac
2798             done
2799           fi # link_all_deplibs != no
2800         fi # linkmode = lib
2801        done # for deplib in $libs
2802 -      if test $pass = dlpreopen; then
2803 +      dependency_libs="$newdependency_libs"
2804 +      if test "$pass" = dlpreopen; then
2805         # Link the dlpreopened libraries before other libraries
2806         for deplib in $save_deplibs; do
2807           deplibs="$deplib $deplibs"
2808         done
2809        fi
2810 -      if test $pass != dlopen; then
2811 -       test $pass != scan && dependency_libs="$newdependency_libs"
2812 -       if test $pass != conv; then
2813 +      if test "$pass" != dlopen; then
2814 +       if test "$pass" != conv; then
2815           # Make sure lib_search_path contains only unique directories.
2816           lib_search_path=
2817           for dir in $newlib_search_path; do
2818 @@ -2060,9 +2986,30 @@
2819           eval tmp_libs=\"\$$var\"
2820           new_libs=
2821           for deplib in $tmp_libs; do
2822 +           # FIXME: Pedantically, this is the right thing to do, so
2823 +           #        that some nasty dependency loop isn't accidentally
2824 +           #        broken:
2825 +           #new_libs="$deplib $new_libs"
2826 +           # Pragmatically, this seems to cause very few problems in
2827 +           # practice:
2828             case $deplib in
2829             -L*) new_libs="$deplib $new_libs" ;;
2830 +           -R*) ;;
2831             *)
2832 +             # And here is the reason: when a library appears more
2833 +             # than once as an explicit dependence of a library, or
2834 +             # is implicitly linked in more than once by the
2835 +             # compiler, it is considered special, and multiple
2836 +             # occurrences thereof are not removed.  Compare this
2837 +             # with having the same library being listed as a
2838 +             # dependency of multiple other libraries: in this case,
2839 +             # we know (pedantically, we assume) the library does not
2840 +             # need to be listed more than once, so we keep only the
2841 +             # last copy.  This is not always right, but it is rare
2842 +             # enough that we require users that really mean to play
2843 +             # such unportable linking tricks to link the library
2844 +             # using -Wl,-lname, so that libtool does not consider it
2845 +             # for duplicate removal.
2846               case " $specialdeplibs " in
2847               *" $deplib "*) new_libs="$deplib $new_libs" ;;
2848               *)
2849 @@ -2090,19 +3037,32 @@
2850           eval $var=\"$tmp_libs\"
2851         done # for var
2852        fi
2853 -      if test "$pass" = "conv" &&
2854 -       { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then
2855 -       libs="$deplibs" # reset libs
2856 -       deplibs=
2857 -      fi
2858 +      # Last step: remove runtime libs from dependency_libs
2859 +      # (they stay in deplibs)
2860 +      tmp_libs=
2861 +      for i in $dependency_libs ; do
2862 +       case " $predeps $postdeps $compiler_lib_search_path " in
2863 +       *" $i "*)
2864 +         i=""
2865 +         ;;
2866 +       esac
2867 +       if test -n "$i" ; then
2868 +         tmp_libs="$tmp_libs $i"
2869 +       fi
2870 +      done
2871 +      dependency_libs=$tmp_libs
2872      done # for pass
2873 -    if test $linkmode = prog; then
2874 +    if test "$linkmode" = prog; then
2875        dlfiles="$newdlfiles"
2876        dlprefiles="$newdlprefiles"
2877      fi
2878  
2879      case $linkmode in
2880      oldlib)
2881 +      if test -n "$deplibs"; then
2882 +       $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
2883 +      fi
2884 +
2885        if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2886         $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
2887        fi
2888 @@ -2116,7 +3076,7 @@
2889        fi
2890  
2891        if test -n "$vinfo"; then
2892 -       $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
2893 +       $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
2894        fi
2895  
2896        if test -n "$release"; then
2897 @@ -2138,17 +3098,19 @@
2898        case $outputname in
2899        lib*)
2900         name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2901 +       eval shared_ext=\"$shrext_cmds\"
2902         eval libname=\"$libname_spec\"
2903         ;;
2904        *)
2905         if test "$module" = no; then
2906           $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
2907           $echo "$help" 1>&2
2908 -         exit 1
2909 +         exit $EXIT_FAILURE
2910         fi
2911         if test "$need_lib_prefix" != no; then
2912           # Add the "lib" prefix for modules if required
2913           name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
2914 +         eval shared_ext=\"$shrext_cmds\"
2915           eval libname=\"$libname_spec\"
2916         else
2917           libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
2918 @@ -2159,11 +3121,11 @@
2919        if test -n "$objs"; then
2920         if test "$deplibs_check_method" != pass_all; then
2921           $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
2922 -         exit 1
2923 +         exit $EXIT_FAILURE
2924         else
2925 -         echo
2926 -         echo "*** Warning: Linking the shared library $output against the non-libtool"
2927 -         echo "*** objects $objs is not portable!"
2928 +         $echo
2929 +         $echo "*** Warning: Linking the shared library $output against the non-libtool"
2930 +         $echo "*** objects $objs is not portable!"
2931           libobjs="$libobjs $objs"
2932         fi
2933        fi
2934 @@ -2173,7 +3135,7 @@
2935        fi
2936  
2937        set dummy $rpath
2938 -      if test $# -gt 2; then
2939 +      if test "$#" -gt 2; then
2940         $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
2941        fi
2942        install_libdir="$2"
2943 @@ -2182,14 +3144,16 @@
2944        if test -z "$rpath"; then
2945         if test "$build_libtool_libs" = yes; then
2946           # Building a libtool convenience library.
2947 -         libext=al
2948 +         # Some compilers have problems with a `.al' extension so
2949 +         # convenience libraries should have the same extension an
2950 +         # archive normally would.
2951           oldlibs="$output_objdir/$libname.$libext $oldlibs"
2952           build_libtool_libs=convenience
2953           build_old_libs=yes
2954         fi
2955  
2956         if test -n "$vinfo"; then
2957 -         $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
2958 +         $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
2959         fi
2960  
2961         if test -n "$release"; then
2962 @@ -2205,45 +3169,87 @@
2963         if test -n "$8"; then
2964           $echo "$modename: too many parameters to \`-version-info'" 1>&2
2965           $echo "$help" 1>&2
2966 -         exit 1
2967 +         exit $EXIT_FAILURE
2968         fi
2969  
2970 -       current="$2"
2971 -       revision="$3"
2972 -       age="$4"
2973 +       # convert absolute version numbers to libtool ages
2974 +       # this retains compatibility with .la files and attempts
2975 +       # to make the code below a bit more comprehensible
2976 +
2977 +       case $vinfo_number in
2978 +       yes)
2979 +         number_major="$2"
2980 +         number_minor="$3"
2981 +         number_revision="$4"
2982 +         #
2983 +         # There are really only two kinds -- those that
2984 +         # use the current revision as the major version
2985 +         # and those that subtract age and use age as
2986 +         # a minor version.  But, then there is irix
2987 +         # which has an extra 1 added just for fun
2988 +         #
2989 +         case $version_type in
2990 +         darwin|linux|osf|windows)
2991 +           current=`expr $number_major + $number_minor`
2992 +           age="$number_minor"
2993 +           revision="$number_revision"
2994 +           ;;
2995 +         freebsd-aout|freebsd-elf|sunos)
2996 +           current="$number_major"
2997 +           revision="$number_minor"
2998 +           age="0"
2999 +           ;;
3000 +         irix|nonstopux)
3001 +           current=`expr $number_major + $number_minor - 1`
3002 +           age="$number_minor"
3003 +           revision="$number_minor"
3004 +           ;;
3005 +         *)
3006 +           $echo "$modename: unknown library version type \`$version_type'" 1>&2
3007 +           $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3008 +           exit $EXIT_FAILURE
3009 +           ;;
3010 +         esac
3011 +         ;;
3012 +       no)
3013 +         current="$2"
3014 +         revision="$3"
3015 +         age="$4"
3016 +         ;;
3017 +       esac
3018  
3019         # Check that each of the things are valid numbers.
3020         case $current in
3021 -       0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3022 +       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
3023         *)
3024 -         $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
3025 +         $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
3026           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3027 -         exit 1
3028 +         exit $EXIT_FAILURE
3029           ;;
3030         esac
3031  
3032         case $revision in
3033 -       0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3034 +       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
3035         *)
3036 -         $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
3037 +         $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
3038           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3039 -         exit 1
3040 +         exit $EXIT_FAILURE
3041           ;;
3042         esac
3043  
3044         case $age in
3045 -       0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3046 +       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
3047         *)
3048 -         $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
3049 +         $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
3050           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3051 -         exit 1
3052 +         exit $EXIT_FAILURE
3053           ;;
3054         esac
3055  
3056 -       if test $age -gt $current; then
3057 +       if test "$age" -gt "$current"; then
3058           $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3059           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3060 -         exit 1
3061 +         exit $EXIT_FAILURE
3062         fi
3063  
3064         # Calculate the version variables.
3065 @@ -2260,7 +3266,7 @@
3066           versuffix="$major.$age.$revision"
3067           # Darwin ld doesn't like 0 for these options...
3068           minor_current=`expr $current + 1`
3069 -         verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
3070 +         verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
3071           ;;
3072  
3073         freebsd-aout)
3074 @@ -2273,16 +3279,21 @@
3075           versuffix=".$current";
3076           ;;
3077  
3078 -       irix)
3079 +       irix | nonstopux)
3080           major=`expr $current - $age + 1`
3081 -         verstring="sgi$major.$revision"
3082 +
3083 +         case $version_type in
3084 +           nonstopux) verstring_prefix=nonstopux ;;
3085 +           *)         verstring_prefix=sgi ;;
3086 +         esac
3087 +         verstring="$verstring_prefix$major.$revision"
3088  
3089           # Add in all the interfaces that we are compatible with.
3090           loop=$revision
3091 -         while test $loop != 0; do
3092 +         while test "$loop" -ne 0; do
3093             iface=`expr $revision - $loop`
3094             loop=`expr $loop - 1`
3095 -           verstring="sgi$major.$iface:$verstring"
3096 +           verstring="$verstring_prefix$major.$iface:$verstring"
3097           done
3098  
3099           # Before this point, $major must not contain `.'.
3100 @@ -2296,13 +3307,13 @@
3101           ;;
3102  
3103         osf)
3104 -         major=`expr $current - $age`
3105 +         major=.`expr $current - $age`
3106           versuffix=".$current.$age.$revision"
3107           verstring="$current.$age.$revision"
3108  
3109           # Add in all the interfaces that we are compatible with.
3110           loop=$age
3111 -         while test $loop != 0; do
3112 +         while test "$loop" -ne 0; do
3113             iface=`expr $current - $loop`
3114             loop=`expr $loop - 1`
3115             verstring="$verstring:${iface}.0"
3116 @@ -2326,20 +3337,19 @@
3117  
3118         *)
3119           $echo "$modename: unknown library version type \`$version_type'" 1>&2
3120 -         echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3121 -         exit 1
3122 +         $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3123 +         exit $EXIT_FAILURE
3124           ;;
3125         esac
3126  
3127         # Clear the version info if we defaulted, and they specified a release.
3128         if test -z "$vinfo" && test -n "$release"; then
3129           major=
3130 -         verstring="0.0"
3131           case $version_type in
3132           darwin)
3133             # we can't check for "0.0" in archive_cmds due to quoting
3134             # problems, so we reset it completely
3135 -           verstring=""
3136 +           verstring=
3137             ;;
3138           *)
3139             verstring="0.0"
3140 @@ -2373,9 +3383,30 @@
3141        fi
3142  
3143        if test "$mode" != relink; then
3144 -       # Remove our outputs.
3145 -       $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
3146 -       $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
3147 +       # Remove our outputs, but don't remove object files since they
3148 +       # may have been created when compiling PIC objects.
3149 +       removelist=
3150 +       tempremovelist=`$echo "$output_objdir/*"`
3151 +       for p in $tempremovelist; do
3152 +         case $p in
3153 +           *.$objext)
3154 +              ;;
3155 +           $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3156 +              if test "X$precious_files_regex" != "X"; then
3157 +                if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3158 +                then
3159 +                  continue
3160 +                fi
3161 +              fi
3162 +              removelist="$removelist $p"
3163 +              ;;
3164 +           *) ;;
3165 +         esac
3166 +       done
3167 +       if test -n "$removelist"; then
3168 +         $show "${rm}r $removelist"
3169 +         $run ${rm}r $removelist
3170 +       fi
3171        fi
3172  
3173        # Now set the variables for building old libraries.
3174 @@ -2388,9 +3419,9 @@
3175  
3176        # Eliminate all temporary directories.
3177        for path in $notinst_path; do
3178 -       lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'`
3179 -       deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'`
3180 -       dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'`
3181 +       lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
3182 +       deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
3183 +       dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
3184        done
3185  
3186        if test -n "$xrpath"; then
3187 @@ -2403,7 +3434,7 @@
3188           *) finalize_rpath="$finalize_rpath $libdir" ;;
3189           esac
3190         done
3191 -       if test $hardcode_into_libs != yes || test $build_old_libs = yes; then
3192 +       if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3193           dependency_libs="$temp_xrpath $dependency_libs"
3194         fi
3195        fi
3196 @@ -2441,12 +3472,18 @@
3197           *-*-netbsd*)
3198             # Don't link with libc until the a.out ld.so is fixed.
3199             ;;
3200 -         *-*-openbsd*)
3201 +         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
3202             # Do not include libc due to us having libc/libc_r.
3203             ;;
3204 -         *)
3205 +         *-*-sco3.2v5* | *-*-sco5v6*)
3206 +           # Causes problems with __ctype
3207 +           ;;
3208 +         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
3209 +           # Compiler inserts libc in the correct place for threads to work
3210 +           ;;
3211 +         *)
3212             # Add libc to deplibs on all other systems if necessary.
3213 -           if test $build_libtool_need_lc = "yes"; then
3214 +           if test "$build_libtool_need_lc" = "yes"; then
3215               deplibs="$deplibs -lc"
3216             fi
3217             ;;
3218 @@ -2473,7 +3510,7 @@
3219           # This might be a little naive.  We might want to check
3220           # whether the library exists or not.  But this is on
3221           # osf3 & osf4 and I'm not really sure... Just
3222 -         # implementing what was already the behaviour.
3223 +         # implementing what was already the behavior.
3224           newdeplibs=$deplibs
3225           ;;
3226         test_compile)
3227 @@ -2486,64 +3523,88 @@
3228           int main() { return 0; }
3229  EOF
3230           $rm conftest
3231 -         $CC -o conftest conftest.c $deplibs
3232 -         if test $? -eq 0 ; then
3233 +         $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
3234 +         if test "$?" -eq 0 ; then
3235             ldd_output=`ldd conftest`
3236             for i in $deplibs; do
3237 -             name="`expr $i : '-l\(.*\)'`"
3238 +             name=`expr $i : '-l\(.*\)'`
3239               # If $name is empty we are operating on a -L argument.
3240 -             if test -n "$name" && test "$name" != "0"; then
3241 -               libname=`eval \\$echo \"$libname_spec\"`
3242 -               deplib_matches=`eval \\$echo \"$library_names_spec\"`
3243 -               set dummy $deplib_matches
3244 -               deplib_match=$2
3245 -               if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3246 -                 newdeplibs="$newdeplibs $i"
3247 -               else
3248 -                 droppeddeps=yes
3249 -                 echo
3250 -                 echo "*** Warning: This library needs some functionality provided by $i."
3251 -                 echo "*** I have the capability to make that library automatically link in when"
3252 -                 echo "*** you link to this library.  But I can only do this if you have a"
3253 -                 echo "*** shared version of the library, which you do not appear to have."
3254 +              if test "$name" != "" && test "$name" -ne "0"; then
3255 +               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3256 +                 case " $predeps $postdeps " in
3257 +                 *" $i "*)
3258 +                   newdeplibs="$newdeplibs $i"
3259 +                   i=""
3260 +                   ;;
3261 +                 esac
3262 +               fi
3263 +               if test -n "$i" ; then
3264 +                 libname=`eval \\$echo \"$libname_spec\"`
3265 +                 deplib_matches=`eval \\$echo \"$library_names_spec\"`
3266 +                 set dummy $deplib_matches
3267 +                 deplib_match=$2
3268 +                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3269 +                   newdeplibs="$newdeplibs $i"
3270 +                 else
3271 +                   droppeddeps=yes
3272 +                   $echo
3273 +                   $echo "*** Warning: dynamic linker does not accept needed library $i."
3274 +                   $echo "*** I have the capability to make that library automatically link in when"
3275 +                   $echo "*** you link to this library.  But I can only do this if you have a"
3276 +                   $echo "*** shared version of the library, which I believe you do not have"
3277 +                   $echo "*** because a test_compile did reveal that the linker did not use it for"
3278 +                   $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3279 +                 fi
3280                 fi
3281               else
3282                 newdeplibs="$newdeplibs $i"
3283               fi
3284             done
3285           else
3286 -           # Error occured in the first compile.  Let's try to salvage the situation:
3287 -           # Compile a seperate program for each library.
3288 +           # Error occurred in the first compile.  Let's try to salvage
3289 +           # the situation: Compile a separate program for each library.
3290             for i in $deplibs; do
3291 -             name="`expr $i : '-l\(.*\)'`"
3292 -            # If $name is empty we are operating on a -L argument.
3293 -             if test -n "$name" && test "$name" != "0"; then
3294 +             name=`expr $i : '-l\(.*\)'`
3295 +             # If $name is empty we are operating on a -L argument.
3296 +              if test "$name" != "" && test "$name" != "0"; then
3297                 $rm conftest
3298 -               $CC -o conftest conftest.c $i
3299 +               $LTCC $LTCFLAGS -o conftest conftest.c $i
3300                 # Did it work?
3301 -               if test $? -eq 0 ; then
3302 +               if test "$?" -eq 0 ; then
3303                   ldd_output=`ldd conftest`
3304 -                 libname=`eval \\$echo \"$libname_spec\"`
3305 -                 deplib_matches=`eval \\$echo \"$library_names_spec\"`
3306 -                 set dummy $deplib_matches
3307 -                 deplib_match=$2
3308 -                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3309 -                   newdeplibs="$newdeplibs $i"
3310 -                 else
3311 -                   droppeddeps=yes
3312 -                   echo
3313 -                   echo "*** Warning: This library needs some functionality provided by $i."
3314 -                   echo "*** I have the capability to make that library automatically link in when"
3315 -                   echo "*** you link to this library.  But I can only do this if you have a"
3316 -                   echo "*** shared version of the library, which you do not appear to have."
3317 +                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3318 +                   case " $predeps $postdeps " in
3319 +                   *" $i "*)
3320 +                     newdeplibs="$newdeplibs $i"
3321 +                     i=""
3322 +                     ;;
3323 +                   esac
3324 +                 fi
3325 +                 if test -n "$i" ; then
3326 +                   libname=`eval \\$echo \"$libname_spec\"`
3327 +                   deplib_matches=`eval \\$echo \"$library_names_spec\"`
3328 +                   set dummy $deplib_matches
3329 +                   deplib_match=$2
3330 +                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3331 +                     newdeplibs="$newdeplibs $i"
3332 +                   else
3333 +                     droppeddeps=yes
3334 +                     $echo
3335 +                     $echo "*** Warning: dynamic linker does not accept needed library $i."
3336 +                     $echo "*** I have the capability to make that library automatically link in when"
3337 +                     $echo "*** you link to this library.  But I can only do this if you have a"
3338 +                     $echo "*** shared version of the library, which you do not appear to have"
3339 +                     $echo "*** because a test_compile did reveal that the linker did not use this one"
3340 +                     $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3341 +                   fi
3342                   fi
3343                 else
3344                   droppeddeps=yes
3345 -                 echo
3346 -                 echo "*** Warning!  Library $i is needed by this library but I was not able to"
3347 -                 echo "***  make it link in!  You will probably need to install it or some"
3348 -                 echo "*** library that it depends on before this library will be fully"
3349 -                 echo "*** functional.  Installing it before continuing would be even better."
3350 +                 $echo
3351 +                 $echo "*** Warning!  Library $i is needed by this library but I was not able to"
3352 +                 $echo "***  make it link in!  You will probably need to install it or some"
3353 +                 $echo "*** library that it depends on before this library will be fully"
3354 +                 $echo "*** functional.  Installing it before continuing would be even better."
3355                 fi
3356               else
3357                 newdeplibs="$newdeplibs $i"
3358 @@ -2555,13 +3616,22 @@
3359           set dummy $deplibs_check_method
3360           file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3361           for a_deplib in $deplibs; do
3362 -           name="`expr $a_deplib : '-l\(.*\)'`"
3363 +           name=`expr $a_deplib : '-l\(.*\)'`
3364             # If $name is empty we are operating on a -L argument.
3365 -           if test -n "$name" && test "$name" != "0"; then
3366 -             libname=`eval \\$echo \"$libname_spec\"`
3367 -             for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3368 -                   potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3369 -                   for potent_lib in $potential_libs; do
3370 +            if test "$name" != "" && test  "$name" != "0"; then
3371 +             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3372 +               case " $predeps $postdeps " in
3373 +               *" $a_deplib "*)
3374 +                 newdeplibs="$newdeplibs $a_deplib"
3375 +                 a_deplib=""
3376 +                 ;;
3377 +               esac
3378 +             fi
3379 +             if test -n "$a_deplib" ; then
3380 +               libname=`eval \\$echo \"$libname_spec\"`
3381 +               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3382 +                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3383 +                 for potent_lib in $potential_libs; do
3384                       # Follow soft links.
3385                       if ls -lLd "$potent_lib" 2>/dev/null \
3386                          | grep " -> " >/dev/null; then
3387 @@ -2574,28 +3644,36 @@
3388                       # but so what?
3389                       potlib="$potent_lib"
3390                       while test -h "$potlib" 2>/dev/null; do
3391 -                       potliblink=`ls -ld $potlib | sed 's/.* -> //'`
3392 +                       potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
3393                         case $potliblink in
3394                         [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
3395                         *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
3396                         esac
3397                       done
3398                       if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
3399 -                        | sed 10q \
3400 -                        | egrep "$file_magic_regex" > /dev/null; then
3401 +                        | ${SED} 10q \
3402 +                        | $EGREP "$file_magic_regex" > /dev/null; then
3403                         newdeplibs="$newdeplibs $a_deplib"
3404                         a_deplib=""
3405                         break 2
3406                       fi
3407 -                   done
3408 -             done
3409 +                 done
3410 +               done
3411 +             fi
3412               if test -n "$a_deplib" ; then
3413                 droppeddeps=yes
3414 -               echo
3415 -               echo "*** Warning: This library needs some functionality provided by $a_deplib."
3416 -               echo "*** I have the capability to make that library automatically link in when"
3417 -               echo "*** you link to this library.  But I can only do this if you have a"
3418 -               echo "*** shared version of the library, which you do not appear to have."
3419 +               $echo
3420 +               $echo "*** Warning: linker path does not have real file for library $a_deplib."
3421 +               $echo "*** I have the capability to make that library automatically link in when"
3422 +               $echo "*** you link to this library.  But I can only do this if you have a"
3423 +               $echo "*** shared version of the library, which you do not appear to have"
3424 +               $echo "*** because I did check the linker path looking for a file starting"
3425 +               if test -z "$potlib" ; then
3426 +                 $echo "*** with $libname but no candidates were found. (...for file magic test)"
3427 +               else
3428 +                 $echo "*** with $libname and none of the candidates passed a file format test"
3429 +                 $echo "*** using a file magic. Last file checked: $potlib"
3430 +               fi
3431               fi
3432             else
3433               # Add a -L argument.
3434 @@ -2607,29 +3685,47 @@
3435           set dummy $deplibs_check_method
3436           match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3437           for a_deplib in $deplibs; do
3438 -           name="`expr $a_deplib : '-l\(.*\)'`"
3439 +           name=`expr $a_deplib : '-l\(.*\)'`
3440             # If $name is empty we are operating on a -L argument.
3441             if test -n "$name" && test "$name" != "0"; then
3442 -             libname=`eval \\$echo \"$libname_spec\"`
3443 -             for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3444 -               potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3445 -               for potent_lib in $potential_libs; do
3446 -                 if eval echo \"$potent_lib\" 2>/dev/null \
3447 -                     | sed 10q \
3448 -                     | egrep "$match_pattern_regex" > /dev/null; then
3449 -                   newdeplibs="$newdeplibs $a_deplib"
3450 -                   a_deplib=""
3451 -                   break 2
3452 -                 fi
3453 +             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3454 +               case " $predeps $postdeps " in
3455 +               *" $a_deplib "*)
3456 +                 newdeplibs="$newdeplibs $a_deplib"
3457 +                 a_deplib=""
3458 +                 ;;
3459 +               esac
3460 +             fi
3461 +             if test -n "$a_deplib" ; then
3462 +               libname=`eval \\$echo \"$libname_spec\"`
3463 +               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3464 +                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3465 +                 for potent_lib in $potential_libs; do
3466 +                   potlib="$potent_lib" # see symlink-check above in file_magic test
3467 +                   if eval $echo \"$potent_lib\" 2>/dev/null \
3468 +                       | ${SED} 10q \
3469 +                       | $EGREP "$match_pattern_regex" > /dev/null; then
3470 +                     newdeplibs="$newdeplibs $a_deplib"
3471 +                     a_deplib=""
3472 +                     break 2
3473 +                   fi
3474 +                 done
3475                 done
3476 -             done
3477 +             fi
3478               if test -n "$a_deplib" ; then
3479                 droppeddeps=yes
3480 -               echo
3481 -               echo "*** Warning: This library needs some functionality provided by $a_deplib."
3482 -               echo "*** I have the capability to make that library automatically link in when"
3483 -               echo "*** you link to this library.  But I can only do this if you have a"
3484 -               echo "*** shared version of the library, which you do not appear to have."
3485 +               $echo
3486 +               $echo "*** Warning: linker path does not have real file for library $a_deplib."
3487 +               $echo "*** I have the capability to make that library automatically link in when"
3488 +               $echo "*** you link to this library.  But I can only do this if you have a"
3489 +               $echo "*** shared version of the library, which you do not appear to have"
3490 +               $echo "*** because I did check the linker path looking for a file starting"
3491 +               if test -z "$potlib" ; then
3492 +                 $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
3493 +               else
3494 +                 $echo "*** with $libname and none of the candidates passed a file format test"
3495 +                 $echo "*** using a regex pattern. Last file checked: $potlib"
3496 +               fi
3497               fi
3498             else
3499               # Add a -L argument.
3500 @@ -2639,16 +3735,23 @@
3501           ;;
3502         none | unknown | *)
3503           newdeplibs=""
3504 -         if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3505 -              -e 's/ -[LR][^ ]*//g' -e 's/[    ]//g' |
3506 -            grep . >/dev/null; then
3507 -           echo
3508 +         tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3509 +           -e 's/ -[LR][^ ]*//g'`
3510 +         if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3511 +           for i in $predeps $postdeps ; do
3512 +             # can't use Xsed below, because $i might contain '/'
3513 +             tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
3514 +           done
3515 +         fi
3516 +         if $echo "X $tmp_deplibs" | $Xsed -e 's/[     ]//g' \
3517 +           | grep . >/dev/null; then
3518 +           $echo
3519             if test "X$deplibs_check_method" = "Xnone"; then
3520 -             echo "*** Warning: inter-library dependencies are not supported in this platform."
3521 +             $echo "*** Warning: inter-library dependencies are not supported in this platform."
3522             else
3523 -             echo "*** Warning: inter-library dependencies are not known to be supported."
3524 +             $echo "*** Warning: inter-library dependencies are not known to be supported."
3525             fi
3526 -           echo "*** All declared inter-library dependencies are being dropped."
3527 +           $echo "*** All declared inter-library dependencies are being dropped."
3528             droppeddeps=yes
3529           fi
3530           ;;
3531 @@ -2668,17 +3771,17 @@
3532  
3533         if test "$droppeddeps" = yes; then
3534           if test "$module" = yes; then
3535 -           echo
3536 -           echo "*** Warning: libtool could not satisfy all declared inter-library"
3537 -           echo "*** dependencies of module $libname.  Therefore, libtool will create"
3538 -           echo "*** a static module, that should work as long as the dlopening"
3539 -           echo "*** application is linked with the -dlopen flag."
3540 +           $echo
3541 +           $echo "*** Warning: libtool could not satisfy all declared inter-library"
3542 +           $echo "*** dependencies of module $libname.  Therefore, libtool will create"
3543 +           $echo "*** a static module, that should work as long as the dlopening"
3544 +           $echo "*** application is linked with the -dlopen flag."
3545             if test -z "$global_symbol_pipe"; then
3546 -             echo
3547 -             echo "*** However, this would only work if libtool was able to extract symbol"
3548 -             echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3549 -             echo "*** not find such a program.  So, this module is probably useless."
3550 -             echo "*** \`nm' from GNU binutils and a full rebuild may help."
3551 +             $echo
3552 +             $echo "*** However, this would only work if libtool was able to extract symbol"
3553 +             $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3554 +             $echo "*** not find such a program.  So, this module is probably useless."
3555 +             $echo "*** \`nm' from GNU binutils and a full rebuild may help."
3556             fi
3557             if test "$build_old_libs" = no; then
3558               oldlibs="$output_objdir/$libname.$libext"
3559 @@ -2688,16 +3791,16 @@
3560               build_libtool_libs=no
3561             fi
3562           else
3563 -           echo "*** The inter-library dependencies that have been dropped here will be"
3564 -           echo "*** automatically added whenever a program is linked with this library"
3565 -           echo "*** or is declared to -dlopen it."
3566 -
3567 -           if test $allow_undefined = no; then
3568 -             echo
3569 -             echo "*** Since this library must not contain undefined symbols,"
3570 -             echo "*** because either the platform does not support them or"
3571 -             echo "*** it was explicitly requested with -no-undefined,"
3572 -             echo "*** libtool will only create a static version of it."
3573 +           $echo "*** The inter-library dependencies that have been dropped here will be"
3574 +           $echo "*** automatically added whenever a program is linked with this library"
3575 +           $echo "*** or is declared to -dlopen it."
3576 +
3577 +           if test "$allow_undefined" = no; then
3578 +             $echo
3579 +             $echo "*** Since this library must not contain undefined symbols,"
3580 +             $echo "*** because either the platform does not support them or"
3581 +             $echo "*** it was explicitly requested with -no-undefined,"
3582 +             $echo "*** libtool will only create a static version of it."
3583               if test "$build_old_libs" = no; then
3584                 oldlibs="$output_objdir/$libname.$libext"
3585                 build_libtool_libs=module
3586 @@ -2712,6 +3815,35 @@
3587         deplibs=$newdeplibs
3588        fi
3589  
3590 +
3591 +      # move library search paths that coincide with paths to not yet
3592 +      # installed libraries to the beginning of the library search list
3593 +      new_libs=
3594 +      for path in $notinst_path; do
3595 +       case " $new_libs " in
3596 +       *" -L$path/$objdir "*) ;;
3597 +       *)
3598 +         case " $deplibs " in
3599 +         *" -L$path/$objdir "*)
3600 +           new_libs="$new_libs -L$path/$objdir" ;;
3601 +         esac
3602 +         ;;
3603 +       esac
3604 +      done
3605 +      for deplib in $deplibs; do
3606 +       case $deplib in
3607 +       -L*)
3608 +         case " $new_libs " in
3609 +         *" $deplib "*) ;;
3610 +         *) new_libs="$new_libs $deplib" ;;
3611 +         esac
3612 +         ;;
3613 +       *) new_libs="$new_libs $deplib" ;;
3614 +       esac
3615 +      done
3616 +      deplibs="$new_libs"
3617 +
3618 +
3619        # All the library-specific variables (install_libdir is set above).
3620        library_names=
3621        old_library=
3622 @@ -2719,7 +3851,7 @@
3623  
3624        # Test again, we may have decided not to build it any more
3625        if test "$build_libtool_libs" = yes; then
3626 -       if test $hardcode_into_libs = yes; then
3627 +       if test "$hardcode_into_libs" = yes; then
3628           # Hardcode the library paths
3629           hardcode_libdirs=
3630           dep_rpath=
3631 @@ -2755,7 +3887,11 @@
3632           if test -n "$hardcode_libdir_separator" &&
3633              test -n "$hardcode_libdirs"; then
3634             libdir="$hardcode_libdirs"
3635 -           eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3636 +           if test -n "$hardcode_libdir_flag_spec_ld"; then
3637 +             eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
3638 +           else
3639 +             eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3640 +           fi
3641           fi
3642           if test -n "$runpath_var" && test -n "$perm_rpath"; then
3643             # We should set the runpath_var.
3644 @@ -2775,6 +3911,7 @@
3645         fi
3646  
3647         # Get the real and link names of the library.
3648 +       eval shared_ext=\"$shrext_cmds\"
3649         eval library_names=\"$library_names_spec\"
3650         set dummy $library_names
3651         realname="$2"
3652 @@ -2785,31 +3922,17 @@
3653         else
3654           soname="$realname"
3655         fi
3656 -       test -z "$dlname" && dlname=$soname
3657 +       if test -z "$dlname"; then
3658 +         dlname=$soname
3659 +       fi
3660  
3661         lib="$output_objdir/$realname"
3662 +       linknames=
3663         for link
3664         do
3665           linknames="$linknames $link"
3666         done
3667  
3668 -       # Ensure that we have .o objects for linkers which dislike .lo
3669 -       # (e.g. aix) in case we are running --disable-static
3670 -       for obj in $libobjs; do
3671 -         xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
3672 -         if test "X$xdir" = "X$obj"; then
3673 -           xdir="."
3674 -         else
3675 -           xdir="$xdir"
3676 -         fi
3677 -         baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
3678 -         oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
3679 -         if test ! -f $xdir/$oldobj; then
3680 -           $show "(cd $xdir && ${LN_S} $baseobj $oldobj)"
3681 -           $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $?
3682 -         fi
3683 -       done
3684 -
3685         # Use standard objects if they are pic
3686         test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
3687  
3688 @@ -2819,17 +3942,29 @@
3689             $show "generating symbol list for \`$libname.la'"
3690             export_symbols="$output_objdir/$libname.exp"
3691             $run $rm $export_symbols
3692 -           eval cmds=\"$export_symbols_cmds\"
3693 +           cmds=$export_symbols_cmds
3694             save_ifs="$IFS"; IFS='~'
3695             for cmd in $cmds; do
3696               IFS="$save_ifs"
3697 -             $show "$cmd"
3698 -             $run eval "$cmd" || exit $?
3699 +             eval cmd=\"$cmd\"
3700 +             if len=`expr "X$cmd" : ".*"` &&
3701 +              test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
3702 +               $show "$cmd"
3703 +               $run eval "$cmd" || exit $?
3704 +               skipped_export=false
3705 +             else
3706 +               # The command line is too long to execute in one step.
3707 +               $show "using reloadable object file for export list..."
3708 +               skipped_export=:
3709 +               # Break out early, otherwise skipped_export may be
3710 +               # set to false by a later but shorter cmd.
3711 +               break
3712 +             fi
3713             done
3714             IFS="$save_ifs"
3715             if test -n "$export_symbols_regex"; then
3716 -             $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
3717 -             $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
3718 +             $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
3719 +             $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
3720               $show "$mv \"${export_symbols}T\" \"$export_symbols\""
3721               $run eval '$mv "${export_symbols}T" "$export_symbols"'
3722             fi
3723 @@ -2840,46 +3975,30 @@
3724           $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
3725         fi
3726  
3727 +       tmp_deplibs=
3728 +       for test_deplib in $deplibs; do
3729 +               case " $convenience " in
3730 +               *" $test_deplib "*) ;;
3731 +               *)
3732 +                       tmp_deplibs="$tmp_deplibs $test_deplib"
3733 +                       ;;
3734 +               esac
3735 +       done
3736 +       deplibs="$tmp_deplibs"
3737 +
3738         if test -n "$convenience"; then
3739           if test -n "$whole_archive_flag_spec"; then
3740 +           save_libobjs=$libobjs
3741             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3742           else
3743             gentop="$output_objdir/${outputname}x"
3744 -           $show "${rm}r $gentop"
3745 -           $run ${rm}r "$gentop"
3746 -           $show "mkdir $gentop"
3747 -           $run mkdir "$gentop"
3748 -           status=$?
3749 -           if test $status -ne 0 && test ! -d "$gentop"; then
3750 -             exit $status
3751 -           fi
3752             generated="$generated $gentop"
3753  
3754 -           for xlib in $convenience; do
3755 -             # Extract the objects.
3756 -             case $xlib in
3757 -             [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3758 -             *) xabs=`pwd`"/$xlib" ;;
3759 -             esac
3760 -             xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3761 -             xdir="$gentop/$xlib"
3762 -
3763 -             $show "${rm}r $xdir"
3764 -             $run ${rm}r "$xdir"
3765 -             $show "mkdir $xdir"
3766 -             $run mkdir "$xdir"
3767 -             status=$?
3768 -             if test $status -ne 0 && test ! -d "$xdir"; then
3769 -               exit $status
3770 -             fi
3771 -             $show "(cd $xdir && $AR x $xabs)"
3772 -             $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
3773 -
3774 -             libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
3775 -           done
3776 +           func_extract_archives $gentop $convenience
3777 +           libobjs="$libobjs $func_extract_archives_result"
3778           fi
3779         fi
3780 -
3781 +
3782         if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3783           eval flag=\"$thread_safe_flag_spec\"
3784           linker_flags="$linker_flags $flag"
3785 @@ -2891,23 +4010,175 @@
3786         fi
3787  
3788         # Do each of the archive commands.
3789 +       if test "$module" = yes && test -n "$module_cmds" ; then
3790 +         if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
3791 +           eval test_cmds=\"$module_expsym_cmds\"
3792 +           cmds=$module_expsym_cmds
3793 +         else
3794 +           eval test_cmds=\"$module_cmds\"
3795 +           cmds=$module_cmds
3796 +         fi
3797 +       else
3798         if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
3799 -         eval cmds=\"$archive_expsym_cmds\"
3800 +         eval test_cmds=\"$archive_expsym_cmds\"
3801 +         cmds=$archive_expsym_cmds
3802 +       else
3803 +         eval test_cmds=\"$archive_cmds\"
3804 +         cmds=$archive_cmds
3805 +         fi
3806 +       fi
3807 +
3808 +       if test "X$skipped_export" != "X:" &&
3809 +          len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
3810 +          test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
3811 +         :
3812         else
3813 -         eval cmds=\"$archive_cmds\"
3814 +         # The command line is too long to link in one step, link piecewise.
3815 +         $echo "creating reloadable object files..."
3816 +
3817 +         # Save the value of $output and $libobjs because we want to
3818 +         # use them later.  If we have whole_archive_flag_spec, we
3819 +         # want to use save_libobjs as it was before
3820 +         # whole_archive_flag_spec was expanded, because we can't
3821 +         # assume the linker understands whole_archive_flag_spec.
3822 +         # This may have to be revisited, in case too many
3823 +         # convenience libraries get linked in and end up exceeding
3824 +         # the spec.
3825 +         if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
3826 +           save_libobjs=$libobjs
3827 +         fi
3828 +         save_output=$output
3829 +         output_la=`$echo "X$output" | $Xsed -e "$basename"`
3830 +
3831 +         # Clear the reloadable object creation command queue and
3832 +         # initialize k to one.
3833 +         test_cmds=
3834 +         concat_cmds=
3835 +         objlist=
3836 +         delfiles=
3837 +         last_robj=
3838 +         k=1
3839 +         output=$output_objdir/$output_la-${k}.$objext
3840 +         # Loop over the list of objects to be linked.
3841 +         for obj in $save_libobjs
3842 +         do
3843 +           eval test_cmds=\"$reload_cmds $objlist $last_robj\"
3844 +           if test "X$objlist" = X ||
3845 +              { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
3846 +                test "$len" -le "$max_cmd_len"; }; then
3847 +             objlist="$objlist $obj"
3848 +           else
3849 +             # The command $test_cmds is almost too long, add a
3850 +             # command to the queue.
3851 +             if test "$k" -eq 1 ; then
3852 +               # The first file doesn't have a previous command to add.
3853 +               eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
3854 +             else
3855 +               # All subsequent reloadable object files will link in
3856 +               # the last one created.
3857 +               eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
3858 +             fi
3859 +             last_robj=$output_objdir/$output_la-${k}.$objext
3860 +             k=`expr $k + 1`
3861 +             output=$output_objdir/$output_la-${k}.$objext
3862 +             objlist=$obj
3863 +             len=1
3864 +           fi
3865 +         done
3866 +         # Handle the remaining objects by creating one last
3867 +         # reloadable object file.  All subsequent reloadable object
3868 +         # files will link in the last one created.
3869 +         test -z "$concat_cmds" || concat_cmds=$concat_cmds~
3870 +         eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
3871 +
3872 +         if ${skipped_export-false}; then
3873 +           $show "generating symbol list for \`$libname.la'"
3874 +           export_symbols="$output_objdir/$libname.exp"
3875 +           $run $rm $export_symbols
3876 +           libobjs=$output
3877 +           # Append the command to create the export file.
3878 +           eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
3879 +          fi
3880 +
3881 +         # Set up a command to remove the reloadable object files
3882 +         # after they are used.
3883 +         i=0
3884 +         while test "$i" -lt "$k"
3885 +         do
3886 +           i=`expr $i + 1`
3887 +           delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
3888 +         done
3889 +
3890 +         $echo "creating a temporary reloadable object file: $output"
3891 +
3892 +         # Loop through the commands generated above and execute them.
3893 +         save_ifs="$IFS"; IFS='~'
3894 +         for cmd in $concat_cmds; do
3895 +           IFS="$save_ifs"
3896 +           $show "$cmd"
3897 +           $run eval "$cmd" || exit $?
3898 +         done
3899 +         IFS="$save_ifs"
3900 +
3901 +         libobjs=$output
3902 +         # Restore the value of output.
3903 +         output=$save_output
3904 +
3905 +         if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
3906 +           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3907 +         fi
3908 +         # Expand the library linking commands again to reset the
3909 +         # value of $libobjs for piecewise linking.
3910 +
3911 +         # Do each of the archive commands.
3912 +         if test "$module" = yes && test -n "$module_cmds" ; then
3913 +           if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
3914 +             cmds=$module_expsym_cmds
3915 +           else
3916 +             cmds=$module_cmds
3917 +           fi
3918 +         else
3919 +         if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
3920 +           cmds=$archive_expsym_cmds
3921 +         else
3922 +           cmds=$archive_cmds
3923 +           fi
3924 +         fi
3925 +
3926 +         # Append the command to remove the reloadable object files
3927 +         # to the just-reset $cmds.
3928 +         eval cmds=\"\$cmds~\$rm $delfiles\"
3929         fi
3930         save_ifs="$IFS"; IFS='~'
3931         for cmd in $cmds; do
3932           IFS="$save_ifs"
3933 +         eval cmd=\"$cmd\"
3934           $show "$cmd"
3935 -         $run eval "$cmd" || exit $?
3936 +         $run eval "$cmd" || {
3937 +           lt_exit=$?