1# ltmain.sh - Provide generalized library-building support services.
2# NOTE: Changing this file will not affect anything until you rerun configure.
3#
4# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
5# Free Software Foundation, Inc.
6# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful, but
14# WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16# General Public License for more details.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21#
22# As a special exception to the GNU General Public License, if you
23# distribute this file as part of a program that contains a
24# configuration script generated by Autoconf, you may include it under
25# the same distribution terms that you use for the rest of that program.
26
27basename="s,^.*/,,g"
28
29# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30# is ksh but when the shell is invoked as "sh" and the current value of
31# the _XPG environment variable is not equal to 1 (one), the special
32# positional parameter $0, within a function call, is the name of the
33# function.
34progpath="$0"
35
36# define SED for historic ltconfig's generated by Libtool 1.3
37test -z "$SED" && SED=sed
38
39# The name of this program:
40progname=`echo "$progpath" | $SED $basename`
41modename="$progname"
42
43# Global variables:
44EXIT_SUCCESS=0
45EXIT_FAILURE=1
46
47PROGRAM=ltmain.sh
48PACKAGE=libtool
49VERSION=1.5.22
50TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
51
52# See if we are running on zsh, and set the options which allow our
53# commands through without removal of \ escapes.
54if test -n "${ZSH_VERSION+set}" ; then
55  setopt NO_GLOB_SUBST
56fi
57# Same for EGREP, and just to be sure, do LTCC as well
58if test "X$EGREP" = X ; then
59    EGREP=egrep
60fi
61if test "X$LTCC" = X ; then
62    LTCC=${CC-gcc}
63fi
64
65# Check that we have a working $echo.
66if test "X$1" = X--no-reexec; then
67  # Discard the --no-reexec flag, and continue.
68  shift
69elif test "X$1" = X--fallback-echo; then
70  # Avoid inline document here, it may be left over
71  :
72elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
73  # Yippee, $echo works!
74  :
75else
76  # Restart under the correct shell, and then maybe $echo will work.
77  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
78fi
79
80if test "X$1" = X--fallback-echo; then
81  # used as fallback echo
82  shift
83  cat <<EOF
84$*
85EOF
86  exit $EXIT_SUCCESS
87fi
88
89default_mode=
90help="Try \`$progname --help' for more information."
91magic="%%%MAGIC variable%%%"
92mkdir="mkdir"
93mv="mv -f"
94rm="rm -f"
95
96# Sed substitution that helps us do robust quoting.  It backslashifies
97# metacharacters that are still active within double-quoted strings.
98Xsed="${SED}"' -e 1s/^X//'
99sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
100# test EBCDIC or ASCII
101case `echo X|tr X '\101'` in
102 A) # ASCII based system
103    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
104  SP2NL='tr \040 \012'
105  NL2SP='tr \015\012 \040\040'
106  ;;
107 *) # EBCDIC based system
108  SP2NL='tr \100 \n'
109  NL2SP='tr \r\n \100\100'
110  ;;
111esac
112
113# NLS nuisances.
114# Only set LANG and LC_ALL to C if already set.
115# These must not be set unconditionally because not all systems understand
116# e.g. LANG=C (notably SCO).
117# We save the old values to restore during execute mode.
118if test "${LC_ALL+set}" = set; then
119  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
120fi
121if test "${LANG+set}" = set; then
122  save_LANG="$LANG"; LANG=C; export LANG
123fi
124
125# Make sure IFS has a sensible default
126lt_nl='
127'
128IFS=" 	$lt_nl"
129
130if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
131  $echo "$modename: not configured to build any kind of library" 1>&2
132  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
133  exit $EXIT_FAILURE
134fi
135
136# Global variables.
137mode=$default_mode
138nonopt=
139prev=
140prevopt=
141run=
142show="$echo"
143show_help=
144execute_dlfiles=
145duplicate_deps=no
146preserve_args=
147lo2o="s/\\.lo\$/.${objext}/"
148o2lo="s/\\.${objext}\$/.lo/"
149
150if test -z "$max_cmd_len"; then
151  i=0
152  testring="ABCD"
153  new_result=
154
155  # If test is not a shell built-in, we'll probably end up computing a
156  # maximum length that is only half of the actual maximum length, but
157  # we can't tell.
158  while (test "X"`$SHELL $0 --fallback-echo "X$testring" 2>/dev/null` \
159             = "XX$testring") >/dev/null 2>&1 &&
160          new_result=`expr "X$testring" : ".*" 2>&1` &&
161          max_cmd_len="$new_result" &&
162          test "$i" != 17 # 1/2 MB should be enough
163  do
164    i=`expr $i + 1`
165    testring="$testring$testring"
166  done
167  testring=
168  # Add a significant safety factor because C++ compilers can tack on massive
169  # amounts of additional arguments before passing them to the linker.
170  # It appears as though 1/2 is a usable value.
171  max_cmd_len=`expr $max_cmd_len \/ 2`
172fi
173
174#####################################
175# Shell function definitions:
176# This seems to be the best place for them
177
178# func_mktempdir [string]
179# Make a temporary directory that won't clash with other running
180# libtool processes, and avoids race conditions if possible.  If
181# given, STRING is the basename for that directory.
182func_mktempdir ()
183{
184    my_template="${TMPDIR-/tmp}/${1-$progname}"
185
186    if test "$run" = ":"; then
187      # Return a directory name, but don't create it in dry-run mode
188      my_tmpdir="${my_template}-$$"
189    else
190
191      # If mktemp works, use that first and foremost
192      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
193
194      if test ! -d "$my_tmpdir"; then
195	# Failing that, at least try and use $RANDOM to avoid a race
196	my_tmpdir="${my_template}-${RANDOM-0}$$"
197
198	save_mktempdir_umask=`umask`
199	umask 0077
200	$mkdir "$my_tmpdir"
201	umask $save_mktempdir_umask
202      fi
203
204      # If we're not in dry-run mode, bomb out on failure
205      test -d "$my_tmpdir" || {
206        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
207	exit $EXIT_FAILURE
208      }
209    fi
210
211    $echo "X$my_tmpdir" | $Xsed
212}
213
214
215# func_win32_libid arg
216# return the library type of file 'arg'
217#
218# Need a lot of goo to handle *both* DLLs and import libs
219# Has to be a shell function in order to 'eat' the argument
220# that is supplied when $file_magic_command is called.
221func_win32_libid ()
222{
223  win32_libid_type="unknown"
224  win32_fileres=`file -L $1 2>/dev/null`
225  case $win32_fileres in
226  *ar\ archive\ import\ library*) # definitely import
227    win32_libid_type="x86 archive import"
228    ;;
229  *ar\ archive*) # could be an import, or static
230    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
231      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
232      win32_nmres=`eval $NM -f posix -A $1 | \
233	$SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
234      case $win32_nmres in
235      import*)  win32_libid_type="x86 archive import";;
236      *)        win32_libid_type="x86 archive static";;
237      esac
238    fi
239    ;;
240  *DLL*)
241    win32_libid_type="x86 DLL"
242    ;;
243  *executable*) # but shell scripts are "executable" too...
244    case $win32_fileres in
245    *MS\ Windows\ PE\ Intel*)
246      win32_libid_type="x86 DLL"
247      ;;
248    esac
249    ;;
250  esac
251  $echo $win32_libid_type
252}
253
254
255# func_infer_tag arg
256# Infer tagged configuration to use if any are available and
257# if one wasn't chosen via the "--tag" command line option.
258# Only attempt this if the compiler in the base compile
259# command doesn't match the default compiler.
260# arg is usually of the form 'gcc ...'
261func_infer_tag ()
262{
263    if test -n "$available_tags" && test -z "$tagname"; then
264      CC_quoted=
265      for arg in $CC; do
266	case $arg in
267	  *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
268	  arg="\"$arg\""
269	  ;;
270	esac
271	CC_quoted="$CC_quoted $arg"
272      done
273      case $@ in
274      # Blanks in the command may have been stripped by the calling shell,
275      # but not from the CC environment variable when configure was run.
276      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
277      # Blanks at the start of $base_compile will cause this to fail
278      # if we don't check for them as well.
279      *)
280	for z in $available_tags; do
281	  if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
282	    # Evaluate the configuration.
283	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
284	    CC_quoted=
285	    for arg in $CC; do
286	    # Double-quote args containing other shell metacharacters.
287	    case $arg in
288	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
289	      arg="\"$arg\""
290	      ;;
291	    esac
292	    CC_quoted="$CC_quoted $arg"
293	  done
294	    # user sometimes does CC=<HOST>-gcc so we need to match that to 'gcc'
295	    trimedcc=`echo ${CC} | $SED -e "s/${host}-//g"`
296	    # and sometimes libtool has CC=<HOST>-gcc but user does CC=gcc
297	    extendcc=${host}-${CC}
298	    # and sometimes libtool has CC=<OLDHOST>-gcc but user has CC=<NEWHOST>-gcc
299	    # (Gentoo-specific hack because we always export $CHOST)
300	    mungedcc=${CHOST-${host}}-${trimedcc}
301	    case "$@ " in
302	      "cc "* | " cc "* | "${host}-cc "* | " ${host}-cc "*|\
303	      "gcc "* | " gcc "* | "${host}-gcc "* | " ${host}-gcc "*)
304	      tagname=CC
305	      break ;;
306	      "$trimedcc "* | " $trimedcc "* | "`$echo $trimedcc` "* | " `$echo $trimedcc` "*|\
307	      "$extendcc "* | " $extendcc "* | "`$echo $extendcc` "* | " `$echo $extendcc` "*|\
308	      "$mungedcc "* | " $mungedcc "* | "`$echo $mungedcc` "* | " `$echo $mungedcc` "*|\
309	      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
310	      # The compiler in the base compile command matches
311	      # the one in the tagged configuration.
312	      # Assume this is the tagged configuration we want.
313	      tagname=$z
314	      break
315	      ;;
316	    esac
317	  fi
318	done
319	# If $tagname still isn't set, then no tagged configuration
320	# was found and let the user know that the "--tag" command
321	# line option must be used.
322	if test -z "$tagname"; then
323	  $echo "$modename: unable to infer tagged configuration"
324	  $echo "$modename: specify a tag with \`--tag'" 1>&2
325	  exit $EXIT_FAILURE
326#        else
327#          $echo "$modename: using $tagname tagged configuration"
328	fi
329	;;
330      esac
331    fi
332}
333
334
335# func_extract_an_archive dir oldlib
336func_extract_an_archive ()
337{
338    f_ex_an_ar_dir="$1"; shift
339    f_ex_an_ar_oldlib="$1"
340
341    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
342    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
343    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
344     :
345    else
346      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
347      exit $EXIT_FAILURE
348    fi
349}
350
351# func_extract_archives gentop oldlib ...
352func_extract_archives ()
353{
354    my_gentop="$1"; shift
355    my_oldlibs=${1+"$@"}
356    my_oldobjs=""
357    my_xlib=""
358    my_xabs=""
359    my_xdir=""
360    my_status=""
361
362    $show "${rm}r $my_gentop"
363    $run ${rm}r "$my_gentop"
364    $show "$mkdir $my_gentop"
365    $run $mkdir "$my_gentop"
366    my_status=$?
367    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
368      exit $my_status
369    fi
370
371    for my_xlib in $my_oldlibs; do
372      # Extract the objects.
373      case $my_xlib in
374	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
375	*) my_xabs=`pwd`"/$my_xlib" ;;
376      esac
377      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
378      my_xdir="$my_gentop/$my_xlib"
379
380      $show "${rm}r $my_xdir"
381      $run ${rm}r "$my_xdir"
382      $show "$mkdir $my_xdir"
383      $run $mkdir "$my_xdir"
384      exit_status=$?
385      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
386	exit $exit_status
387      fi
388      case $host in
389      *-darwin*)
390	$show "Extracting $my_xabs"
391	# Do not bother doing anything if just a dry run
392	if test -z "$run"; then
393	  darwin_orig_dir=`pwd`
394	  cd $my_xdir || exit $?
395	  darwin_archive=$my_xabs
396	  darwin_curdir=`pwd`
397	  darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
398	  darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
399	  if test -n "$darwin_arches"; then
400	    darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
401	    darwin_arch=
402	    $show "$darwin_base_archive has multiple architectures $darwin_arches"
403	    for darwin_arch in  $darwin_arches ; do
404	      mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
405	      lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
406	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
407	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
408	      cd "$darwin_curdir"
409	      $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
410	    done # $darwin_arches
411      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
412	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
413	    darwin_file=
414	    darwin_files=
415	    for darwin_file in $darwin_filelist; do
416	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
417	      lipo -create -output "$darwin_file" $darwin_files
418	    done # $darwin_filelist
419	    ${rm}r unfat-$$
420	    cd "$darwin_orig_dir"
421	  else
422	    cd "$darwin_orig_dir"
423 	    func_extract_an_archive "$my_xdir" "$my_xabs"
424	  fi # $darwin_arches
425	fi # $run
426	;;
427      *)
428        func_extract_an_archive "$my_xdir" "$my_xabs"
429        ;;
430      esac
431      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
432    done
433    func_extract_archives_result="$my_oldobjs"
434}
435# End of Shell function definitions
436#####################################
437
438# Darwin sucks
439eval std_shrext=\"$shrext_cmds\"
440
441disable_libs=no
442
443# Parse our command line options once, thoroughly.
444while test "$#" -gt 0
445do
446  arg="$1"
447  shift
448
449  case $arg in
450  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
451  *) optarg= ;;
452  esac
453
454  # If the previous option needs an argument, assign it.
455  if test -n "$prev"; then
456    case $prev in
457    execute_dlfiles)
458      execute_dlfiles="$execute_dlfiles $arg"
459      ;;
460    tag)
461      tagname="$arg"
462      preserve_args="${preserve_args}=$arg"
463
464      # Check whether tagname contains only valid characters
465      case $tagname in
466      *[!-_A-Za-z0-9,/]*)
467	$echo "$progname: invalid tag name: $tagname" 1>&2
468	exit $EXIT_FAILURE
469	;;
470      esac
471
472      case $tagname in
473      CC)
474	# Don't test for the "default" C tag, as we know, it's there, but
475	# not specially marked.
476	;;
477      *)
478	if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
479	  taglist="$taglist $tagname"
480	  # Evaluate the configuration.
481	  eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
482	else
483	  $echo "$progname: ignoring unknown tag $tagname" 1>&2
484	fi
485	;;
486      esac
487      ;;
488    *)
489      eval "$prev=\$arg"
490      ;;
491    esac
492
493    prev=
494    prevopt=
495    continue
496  fi
497
498  # Have we seen a non-optional argument yet?
499  case $arg in
500  --help)
501    show_help=yes
502    ;;
503
504  --version)
505    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
506    $echo
507    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
508    $echo "This is free software; see the source for copying conditions.  There is NO"
509    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
510    exit $?
511    ;;
512
513  --config)
514    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
515    # Now print the configurations for the tags.
516    for tagname in $taglist; do
517      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
518    done
519    exit $?
520    ;;
521
522  --debug)
523    $echo "$progname: enabling shell trace mode"
524    set -x
525    preserve_args="$preserve_args $arg"
526    ;;
527
528  --dry-run | -n)
529    run=:
530    ;;
531
532  --features)
533    $echo "host: $host"
534    if test "$build_libtool_libs" = yes; then
535      $echo "enable shared libraries"
536    else
537      $echo "disable shared libraries"
538    fi
539    if test "$build_old_libs" = yes; then
540      $echo "enable static libraries"
541    else
542      $echo "disable static libraries"
543    fi
544    exit $?
545    ;;
546
547  --finish) mode="finish" ;;
548
549  --mode) prevopt="--mode" prev=mode ;;
550  --mode=*) mode="$optarg" ;;
551
552  --preserve-dup-deps) duplicate_deps="yes" ;;
553
554  --quiet | --silent)
555    show=:
556    preserve_args="$preserve_args $arg"
557    ;;
558
559  --tag)
560    prevopt="--tag"
561    prev=tag
562    preserve_args="$preserve_args --tag"
563    ;;
564  --tag=*)
565    set tag "$optarg" ${1+"$@"}
566    shift
567    prev=tag
568    preserve_args="$preserve_args --tag"
569    ;;
570
571  -dlopen)
572    prevopt="-dlopen"
573    prev=execute_dlfiles
574    ;;
575
576  -*)
577    $echo "$modename: unrecognized option \`$arg'" 1>&2
578    $echo "$help" 1>&2
579    exit $EXIT_FAILURE
580    ;;
581
582  *)
583    nonopt="$arg"
584    break
585    ;;
586  esac
587done
588
589if test -n "$prevopt"; then
590  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
591  $echo "$help" 1>&2
592  exit $EXIT_FAILURE
593fi
594
595case $disable_libs in
596no)
597  ;;
598shared)
599  build_libtool_libs=no
600  build_old_libs=yes
601  ;;
602static)
603  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
604  ;;
605esac
606
607# If this variable is set in any of the actions, the command in it
608# will be execed at the end.  This prevents here-documents from being
609# left over by shells.
610exec_cmd=
611
612if test -z "$show_help"; then
613
614  # Infer the operation mode.
615  if test -z "$mode"; then
616    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
617    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
618    case $nonopt in
619    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
620      mode=link
621      for arg
622      do
623	case $arg in
624	-c)
625	   mode=compile
626	   break
627	   ;;
628	esac
629      done
630      ;;
631    *db | *dbx | *strace | *truss)
632      mode=execute
633      ;;
634    *install*|cp|mv)
635      mode=install
636      ;;
637    *rm)
638      mode=uninstall
639      ;;
640    *)
641      # If we have no mode, but dlfiles were specified, then do execute mode.
642      test -n "$execute_dlfiles" && mode=execute
643
644      # Just use the default operation mode.
645      if test -z "$mode"; then
646	if test -n "$nonopt"; then
647	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
648	else
649	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
650	fi
651      fi
652      ;;
653    esac
654  fi
655
656  # Only execute mode is allowed to have -dlopen flags.
657  if test -n "$execute_dlfiles" && test "$mode" != execute; then
658    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
659    $echo "$help" 1>&2
660    exit $EXIT_FAILURE
661  fi
662
663  # Change the help message to a mode-specific one.
664  generic_help="$help"
665  help="Try \`$modename --help --mode=$mode' for more information."
666
667  # These modes are in order of execution frequency so that they run quickly.
668  case $mode in
669  # libtool compile mode
670  compile)
671    modename="$modename: compile"
672    # Get the compilation command and the source file.
673    base_compile=
674    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
675    suppress_opt=yes
676    suppress_output=
677    arg_mode=normal
678    libobj=
679    later=
680
681    for arg
682    do
683      case $arg_mode in
684      arg  )
685	# do not "continue".  Instead, add this to base_compile
686	lastarg="$arg"
687	arg_mode=normal
688	;;
689
690      target )
691	libobj="$arg"
692	arg_mode=normal
693	continue
694	;;
695
696      normal )
697	# Accept any command-line options.
698	case $arg in
699	-o)
700	  if test -n "$libobj" ; then
701	    $echo "$modename: you cannot specify \`-o' more than once" 1>&2
702	    exit $EXIT_FAILURE
703	  fi
704	  arg_mode=target
705	  continue
706	  ;;
707
708	-static | -prefer-pic | -prefer-non-pic)
709	  later="$later $arg"
710	  continue
711	  ;;
712
713	-no-suppress)
714	  suppress_opt=no
715	  continue
716	  ;;
717
718	-Xcompiler)
719	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
720	  continue      #  The current "srcfile" will either be retained or
721	  ;;            #  replaced later.  I would guess that would be a bug.
722
723	-Wc,*)
724	  args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
725	  lastarg=
726	  save_ifs="$IFS"; IFS=','
727 	  for arg in $args; do
728	    IFS="$save_ifs"
729
730	    # Double-quote args containing other shell metacharacters.
731	    # Many Bourne shells cannot handle close brackets correctly
732	    # in scan sets, so we specify it separately.
733	    case $arg in
734	      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
735	      arg="\"$arg\""
736	      ;;
737	    esac
738	    lastarg="$lastarg $arg"
739	  done
740	  IFS="$save_ifs"
741	  lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
742
743	  # Add the arguments to base_compile.
744	  base_compile="$base_compile $lastarg"
745	  continue
746	  ;;
747
748	* )
749	  # Accept the current argument as the source file.
750	  # The previous "srcfile" becomes the current argument.
751	  #
752	  lastarg="$srcfile"
753	  srcfile="$arg"
754	  ;;
755	esac  #  case $arg
756	;;
757      esac    #  case $arg_mode
758
759      # Aesthetically quote the previous argument.
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, and some SunOS ksh mistreat backslash-escaping
766      # in scan sets (worked around with variable expansion),
767      # and furthermore cannot handle '|' '&' '(' ')' in scan sets
768      # at all, so we specify them separately.
769      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
770	lastarg="\"$lastarg\""
771	;;
772      esac
773
774      base_compile="$base_compile $lastarg"
775    done # for arg
776
777    case $arg_mode in
778    arg)
779      $echo "$modename: you must specify an argument for -Xcompile"
780      exit $EXIT_FAILURE
781      ;;
782    target)
783      $echo "$modename: you must specify a target with \`-o'" 1>&2
784      exit $EXIT_FAILURE
785      ;;
786    *)
787      # Get the name of the library object.
788      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
789      ;;
790    esac
791
792    # Recognize several different file suffixes.
793    # If the user specifies -o file.o, it is replaced with file.lo
794    xform='[cCFSifmso]'
795    case $libobj in
796    *.ada) xform=ada ;;
797    *.adb) xform=adb ;;
798    *.ads) xform=ads ;;
799    *.asm) xform=asm ;;
800    *.c++) xform=c++ ;;
801    *.cc) xform=cc ;;
802    *.ii) xform=ii ;;
803    *.class) xform=class ;;
804    *.cpp) xform=cpp ;;
805    *.cxx) xform=cxx ;;
806    *.f90) xform=f90 ;;
807    *.for) xform=for ;;
808    *.java) xform=java ;;
809    esac
810
811    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
812
813    case $libobj in
814    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
815    *)
816      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
817      exit $EXIT_FAILURE
818      ;;
819    esac
820
821    func_infer_tag $base_compile
822
823    for arg in $later; do
824      case $arg in
825      -static)
826	build_old_libs=yes
827	continue
828	;;
829
830      -prefer-pic)
831	pic_mode=yes
832	continue
833	;;
834
835      -prefer-non-pic)
836	pic_mode=no
837	continue
838	;;
839      esac
840    done
841
842    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
843    case $qlibobj in
844      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
845	qlibobj="\"$qlibobj\"" ;;
846    esac
847    test "X$libobj" != "X$qlibobj" \
848	&& $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' 	&()|`$[]' \
849	&& $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
850    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
851    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
852    if test "X$xdir" = "X$obj"; then
853      xdir=
854    else
855      xdir=$xdir/
856    fi
857    lobj=${xdir}$objdir/$objname
858
859    if test -z "$base_compile"; then
860      $echo "$modename: you must specify a compilation command" 1>&2
861      $echo "$help" 1>&2
862      exit $EXIT_FAILURE
863    fi
864
865    # Delete any leftover library objects.
866    if test "$build_old_libs" = yes; then
867      removelist="$obj $lobj $libobj ${libobj}T"
868    else
869      removelist="$lobj $libobj ${libobj}T"
870    fi
871
872    $run $rm $removelist
873    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
874
875    # On Cygwin there's no "real" PIC flag so we must build both object types
876    case $host_os in
877    cygwin* | mingw* | pw32* | os2*)
878      pic_mode=default
879      ;;
880    esac
881    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
882      # non-PIC code in shared libraries is not supported
883      pic_mode=default
884    fi
885
886    # Calculate the filename of the output object if compiler does
887    # not support -o with -c
888    if test "$compiler_c_o" = no; then
889      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
890      lockfile="$output_obj.lock"
891      removelist="$removelist $output_obj $lockfile"
892      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
893    else
894      output_obj=
895      need_locks=no
896      lockfile=
897    fi
898
899    # Lock this critical section if it is needed
900    # We use this script file to make the link, it avoids creating a new file
901    if test "$need_locks" = yes; then
902      until $run ln "$srcfile" "$lockfile" 2>/dev/null; do
903	$show "Waiting for $lockfile to be removed"
904	sleep 2
905      done
906    elif test "$need_locks" = warn; then
907      if test -f "$lockfile"; then
908	$echo "\
909*** ERROR, $lockfile exists and contains:
910`cat $lockfile 2>/dev/null`
911
912This indicates that another process is trying to use the same
913temporary object file, and libtool could not work around it because
914your compiler does not support \`-c' and \`-o' together.  If you
915repeat this compilation, it may succeed, by chance, but you had better
916avoid parallel builds (make -j) in this platform, or get a better
917compiler."
918
919	$run $rm $removelist
920	exit $EXIT_FAILURE
921      fi
922      $echo "$srcfile" > "$lockfile"
923    fi
924
925    if test -n "$fix_srcfile_path"; then
926      eval srcfile=\"$fix_srcfile_path\"
927    fi
928    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
929    case $qsrcfile in
930      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
931      qsrcfile="\"$qsrcfile\"" ;;
932    esac
933
934    $run $rm "$libobj" "${libobj}T"
935
936    # Create a libtool object file (analogous to a ".la" file),
937    # but don't create it if we're doing a dry run.
938    test -z "$run" && cat > ${libobj}T <<EOF
939# $libobj - a libtool object file
940# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
941#
942# Please DO NOT delete this file!
943# It is necessary for linking the library.
944
945# Name of the PIC object.
946EOF
947
948    # Only build a PIC object if we are building libtool libraries.
949    if test "$build_libtool_libs" = yes; then
950      # Without this assignment, base_compile gets emptied.
951      fbsd_hideous_sh_bug=$base_compile
952
953      if test "$pic_mode" != no; then
954	command="$base_compile $qsrcfile $pic_flag"
955      else
956	# Don't build PIC code
957	command="$base_compile $qsrcfile"
958      fi
959
960      if test ! -d "${xdir}$objdir"; then
961	$show "$mkdir ${xdir}$objdir"
962	$run $mkdir ${xdir}$objdir
963	exit_status=$?
964	if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
965	  exit $exit_status
966	fi
967      fi
968
969      if test -z "$output_obj"; then
970	# Place PIC objects in $objdir
971	command="$command -o $lobj"
972      fi
973
974      $run $rm "$lobj" "$output_obj"
975
976      $show "$command"
977      if $run eval "$command"; then :
978      else
979	test -n "$output_obj" && $run $rm $removelist
980	exit $EXIT_FAILURE
981      fi
982
983      if test "$need_locks" = warn &&
984	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
985	$echo "\
986*** ERROR, $lockfile contains:
987`cat $lockfile 2>/dev/null`
988
989but it should contain:
990$srcfile
991
992This indicates that another process is trying to use the same
993temporary object file, and libtool could not work around it because
994your compiler does not support \`-c' and \`-o' together.  If you
995repeat this compilation, it may succeed, by chance, but you had better
996avoid parallel builds (make -j) in this platform, or get a better
997compiler."
998
999	$run $rm $removelist
1000	exit $EXIT_FAILURE
1001      fi
1002
1003      # Just move the object if needed, then go on to compile the next one
1004      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1005	$show "$mv $output_obj $lobj"
1006	if $run $mv $output_obj $lobj; then :
1007	else
1008	  error=$?
1009	  $run $rm $removelist
1010	  exit $error
1011	fi
1012      fi
1013
1014      # Append the name of the PIC object to the libtool object file.
1015      test -z "$run" && cat >> ${libobj}T <<EOF
1016pic_object='$objdir/$objname'
1017
1018EOF
1019
1020      # Allow error messages only from the first compilation.
1021      if test "$suppress_opt" = yes; then
1022        suppress_output=' >/dev/null 2>&1'
1023      fi
1024    else
1025      # No PIC object so indicate it doesn't exist in the libtool
1026      # object file.
1027      test -z "$run" && cat >> ${libobj}T <<EOF
1028pic_object=none
1029
1030EOF
1031    fi
1032
1033    # Only build a position-dependent object if we build old libraries.
1034    if test "$build_old_libs" = yes; then
1035      if test "$pic_mode" != yes; then
1036	# Don't build PIC code
1037	command="$base_compile $qsrcfile"
1038      else
1039	command="$base_compile $qsrcfile $pic_flag"
1040      fi
1041      if test "$compiler_c_o" = yes; then
1042	command="$command -o $obj"
1043      fi
1044
1045      # Suppress compiler output if we already did a PIC compilation.
1046      command="$command$suppress_output"
1047      $run $rm "$obj" "$output_obj"
1048      $show "$command"
1049      if $run eval "$command"; then :
1050      else
1051	$run $rm $removelist
1052	exit $EXIT_FAILURE
1053      fi
1054
1055      if test "$need_locks" = warn &&
1056	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1057	$echo "\
1058*** ERROR, $lockfile contains:
1059`cat $lockfile 2>/dev/null`
1060
1061but it should contain:
1062$srcfile
1063
1064This indicates that another process is trying to use the same
1065temporary object file, and libtool could not work around it because
1066your compiler does not support \`-c' and \`-o' together.  If you
1067repeat this compilation, it may succeed, by chance, but you had better
1068avoid parallel builds (make -j) in this platform, or get a better
1069compiler."
1070
1071	$run $rm $removelist
1072	exit $EXIT_FAILURE
1073      fi
1074
1075      # Just move the object if needed
1076      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1077	$show "$mv $output_obj $obj"
1078	if $run $mv $output_obj $obj; then :
1079	else
1080	  error=$?
1081	  $run $rm $removelist
1082	  exit $error
1083	fi
1084      fi
1085
1086      # Append the name of the non-PIC object the libtool object file.
1087      # Only append if the libtool object file exists.
1088      test -z "$run" && cat >> ${libobj}T <<EOF
1089# Name of the non-PIC object.
1090non_pic_object='$objname'
1091
1092EOF
1093    else
1094      # Append the name of the non-PIC object the libtool object file.
1095      # Only append if the libtool object file exists.
1096      test -z "$run" && cat >> ${libobj}T <<EOF
1097# Name of the non-PIC object.
1098non_pic_object=none
1099
1100EOF
1101    fi
1102
1103    $run $mv "${libobj}T" "${libobj}"
1104
1105    # Unlock the critical section if it was locked
1106    if test "$need_locks" != no; then
1107      $run $rm "$lockfile"
1108    fi
1109
1110    exit $EXIT_SUCCESS
1111    ;;
1112
1113  # libtool link mode
1114  link | relink)
1115    modename="$modename: link"
1116    case $host in
1117    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1118      # It is impossible to link a dll without this setting, and
1119      # we shouldn't force the makefile maintainer to figure out
1120      # which system we are compiling for in order to pass an extra
1121      # flag for every libtool invocation.
1122      # allow_undefined=no
1123
1124      # FIXME: Unfortunately, there are problems with the above when trying
1125      # to make a dll which has undefined symbols, in which case not
1126      # even a static library is built.  For now, we need to specify
1127      # -no-undefined on the libtool link line when we can be certain
1128      # that all symbols are satisfied, otherwise we get a static library.
1129      allow_undefined=yes
1130      ;;
1131    *)
1132      allow_undefined=yes
1133      ;;
1134    esac
1135    libtool_args="$nonopt"
1136    base_compile="$nonopt $@"
1137    compile_command="$nonopt"
1138    finalize_command="$nonopt"
1139
1140    compile_rpath=
1141    finalize_rpath=
1142    compile_shlibpath=
1143    finalize_shlibpath=
1144    convenience=
1145    old_convenience=
1146    deplibs=
1147    old_deplibs=
1148    compiler_flags=
1149    linker_flags=
1150    dllsearchpath=
1151    lib_search_path=`pwd`
1152    inst_prefix_dir=
1153
1154    avoid_version=no
1155    dlfiles=
1156    dlprefiles=
1157    dlself=no
1158    export_dynamic=no
1159    export_symbols=
1160    export_symbols_regex=
1161    generated=
1162    libobjs=
1163    ltlibs=
1164    module=no
1165    no_install=no
1166    objs=
1167    non_pic_objects=
1168    notinst_path= # paths that contain not-installed libtool libraries
1169    precious_files_regex=
1170    prefer_static_libs=no
1171    preload=no
1172    prev=
1173    prevarg=
1174    release=
1175    rpath=
1176    xrpath=
1177    perm_rpath=
1178    temp_rpath=
1179    thread_safe=no
1180    vinfo=
1181    vinfo_number=no
1182
1183    func_infer_tag $base_compile
1184
1185    # We need to know -static, to get the right output filenames.
1186    for arg
1187    do
1188      case $arg in
1189      -all-static | -static)
1190	if test "X$arg" = "X-all-static"; then
1191	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1192	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1193	  fi
1194	  if test -n "$link_static_flag"; then
1195	    dlopen_self=$dlopen_self_static
1196	  fi
1197	  prefer_static_libs=yes
1198	else
1199	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
1200	    dlopen_self=$dlopen_self_static
1201	  fi
1202	  prefer_static_libs=built
1203	fi
1204	build_libtool_libs=no
1205	build_old_libs=yes
1206	break
1207	;;
1208      esac
1209    done
1210
1211    # See if our shared archives depend on static archives.
1212    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
1213
1214    # Go through the arguments, transforming them on the way.
1215    while test "$#" -gt 0; do
1216      arg="$1"
1217      shift
1218      case $arg in
1219      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1220	qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1221	;;
1222      *) qarg=$arg ;;
1223      esac
1224      libtool_args="$libtool_args $qarg"
1225
1226      # If the previous option needs an argument, assign it.
1227      if test -n "$prev"; then
1228	case $prev in
1229	output)
1230	  compile_command="$compile_command @OUTPUT@"
1231	  finalize_command="$finalize_command @OUTPUT@"
1232	  ;;
1233	esac
1234
1235	case $prev in
1236	dlfiles|dlprefiles)
1237	  if test "$preload" = no; then
1238	    # Add the symbol object into the linking commands.
1239	    compile_command="$compile_command @SYMFILE@"
1240	    finalize_command="$finalize_command @SYMFILE@"
1241	    preload=yes
1242	  fi
1243	  case $arg in
1244	  *.la | *.lo) ;;  # We handle these cases below.
1245	  force)
1246	    if test "$dlself" = no; then
1247	      dlself=needless
1248	      export_dynamic=yes
1249	    fi
1250	    prev=
1251	    continue
1252	    ;;
1253	  self)
1254	    if test "$prev" = dlprefiles; then
1255	      dlself=yes
1256	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1257	      dlself=yes
1258	    else
1259	      dlself=needless
1260	      export_dynamic=yes
1261	    fi
1262	    prev=
1263	    continue
1264	    ;;
1265	  *)
1266	    if test "$prev" = dlfiles; then
1267	      dlfiles="$dlfiles $arg"
1268	    else
1269	      dlprefiles="$dlprefiles $arg"
1270	    fi
1271	    prev=
1272	    continue
1273	    ;;
1274	  esac
1275	  ;;
1276	expsyms)
1277	  export_symbols="$arg"
1278	  if test ! -f "$arg"; then
1279	    $echo "$modename: symbol file \`$arg' does not exist"
1280	    exit $EXIT_FAILURE
1281	  fi
1282	  prev=
1283	  continue
1284	  ;;
1285	expsyms_regex)
1286	  export_symbols_regex="$arg"
1287	  prev=
1288	  continue
1289	  ;;
1290	inst_prefix)
1291	  inst_prefix_dir="$arg"
1292	  prev=
1293	  continue
1294	  ;;
1295	precious_regex)
1296	  precious_files_regex="$arg"
1297	  prev=
1298	  continue
1299	  ;;
1300	release)
1301	  release="-$arg"
1302	  prev=
1303	  continue
1304	  ;;
1305	objectlist)
1306	  if test -f "$arg"; then
1307	    save_arg=$arg
1308	    moreargs=
1309	    for fil in `cat $save_arg`
1310	    do
1311#	      moreargs="$moreargs $fil"
1312	      arg=$fil
1313	      # A libtool-controlled object.
1314
1315	      # Check to see that this really is a libtool object.
1316	      if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1317		pic_object=
1318		non_pic_object=
1319
1320		# Read the .lo file
1321		# If there is no directory component, then add one.
1322		case $arg in
1323		*/* | *\\*) . $arg ;;
1324		*) . ./$arg ;;
1325		esac
1326
1327		if test -z "$pic_object" || \
1328		   test -z "$non_pic_object" ||
1329		   test "$pic_object" = none && \
1330		   test "$non_pic_object" = none; then
1331		  $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1332		  exit $EXIT_FAILURE
1333		fi
1334
1335		# Extract subdirectory from the argument.
1336		xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1337		if test "X$xdir" = "X$arg"; then
1338		  xdir=
1339		else
1340		  xdir="$xdir/"
1341		fi
1342
1343		if test "$pic_object" != none; then
1344		  # Prepend the subdirectory the object is found in.
1345		  pic_object="$xdir$pic_object"
1346
1347		  if test "$prev" = dlfiles; then
1348		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1349		      dlfiles="$dlfiles $pic_object"
1350		      prev=
1351		      continue
1352		    else
1353		      # If libtool objects are unsupported, then we need to preload.
1354		      prev=dlprefiles
1355		    fi
1356		  fi
1357
1358		  # CHECK ME:  I think I busted this.  -Ossama
1359		  if test "$prev" = dlprefiles; then
1360		    # Preload the old-style object.
1361		    dlprefiles="$dlprefiles $pic_object"
1362		    prev=
1363		  fi
1364
1365		  # A PIC object.
1366		  libobjs="$libobjs $pic_object"
1367		  arg="$pic_object"
1368		fi
1369
1370		# Non-PIC object.
1371		if test "$non_pic_object" != none; then
1372		  # Prepend the subdirectory the object is found in.
1373		  non_pic_object="$xdir$non_pic_object"
1374
1375		  # A standard non-PIC object
1376		  non_pic_objects="$non_pic_objects $non_pic_object"
1377		  if test -z "$pic_object" || test "$pic_object" = none ; then
1378		    arg="$non_pic_object"
1379		  fi
1380		else
1381		  # If the PIC object exists, use it instead.
1382		  # $xdir was prepended to $pic_object above.
1383		  non_pic_object="$pic_object"
1384		  non_pic_objects="$non_pic_objects $non_pic_object"
1385		fi
1386	      else
1387		# Only an error if not doing a dry-run.
1388		if test -z "$run"; then
1389		  $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1390		  exit $EXIT_FAILURE
1391		else
1392		  # Dry-run case.
1393
1394		  # Extract subdirectory from the argument.
1395		  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1396		  if test "X$xdir" = "X$arg"; then
1397		    xdir=
1398		  else
1399		    xdir="$xdir/"
1400		  fi
1401
1402		  pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1403		  non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1404		  libobjs="$libobjs $pic_object"
1405		  non_pic_objects="$non_pic_objects $non_pic_object"
1406		fi
1407	      fi
1408	    done
1409	  else
1410	    $echo "$modename: link input file \`$save_arg' does not exist"
1411	    exit $EXIT_FAILURE
1412	  fi
1413	  arg=$save_arg
1414	  prev=
1415	  continue
1416	  ;;
1417	rpath | xrpath)
1418	  # We need an absolute path.
1419	  case $arg in
1420	  [\\/]* | [A-Za-z]:[\\/]*) ;;
1421	  *)
1422	    $echo "$modename: only absolute run-paths are allowed" 1>&2
1423	    exit $EXIT_FAILURE
1424	    ;;
1425	  esac
1426	  if test "$prev" = rpath; then
1427	    case "$rpath " in
1428	    *" $arg "*) ;;
1429	    *) rpath="$rpath $arg" ;;
1430	    esac
1431	  else
1432	    case "$xrpath " in
1433	    *" $arg "*) ;;
1434	    *) xrpath="$xrpath $arg" ;;
1435	    esac
1436	  fi
1437	  prev=
1438	  continue
1439	  ;;
1440	xcompiler)
1441	  compiler_flags="$compiler_flags $qarg"
1442	  prev=
1443	  compile_command="$compile_command $qarg"
1444	  finalize_command="$finalize_command $qarg"
1445	  continue
1446	  ;;
1447	xlinker)
1448	  linker_flags="$linker_flags $qarg"
1449	  compiler_flags="$compiler_flags $wl$qarg"
1450	  prev=
1451	  compile_command="$compile_command $wl$qarg"
1452	  finalize_command="$finalize_command $wl$qarg"
1453	  continue
1454	  ;;
1455	xcclinker)
1456	  linker_flags="$linker_flags $qarg"
1457	  compiler_flags="$compiler_flags $qarg"
1458	  prev=
1459	  compile_command="$compile_command $qarg"
1460	  finalize_command="$finalize_command $qarg"
1461	  continue
1462	  ;;
1463	shrext)
1464  	  shrext_cmds="$arg"
1465	  prev=
1466	  continue
1467	  ;;
1468	darwin_framework|darwin_framework_skip)
1469	  test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
1470	  compile_command="$compile_command $arg"
1471	  finalize_command="$finalize_command $arg"
1472	  prev=
1473	  continue
1474	  ;;
1475	*)
1476	  eval "$prev=\"\$arg\""
1477	  prev=
1478	  continue
1479	  ;;
1480	esac
1481      fi # test -n "$prev"
1482
1483      prevarg="$arg"
1484
1485      case $arg in
1486      -all-static)
1487	if test -n "$link_static_flag"; then
1488	  compile_command="$compile_command $link_static_flag"
1489	  finalize_command="$finalize_command $link_static_flag"
1490	fi
1491	continue
1492	;;
1493
1494      -allow-undefined)
1495	# FIXME: remove this flag sometime in the future.
1496	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1497	continue
1498	;;
1499
1500      -avoid-version)
1501	avoid_version=yes
1502	continue
1503	;;
1504
1505      -dlopen)
1506	prev=dlfiles
1507	continue
1508	;;
1509
1510      -dlpreopen)
1511	prev=dlprefiles
1512	continue
1513	;;
1514
1515      -export-dynamic)
1516	export_dynamic=yes
1517	continue
1518	;;
1519
1520      -export-symbols | -export-symbols-regex)
1521	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1522	  $echo "$modename: more than one -exported-symbols argument is not allowed"
1523	  exit $EXIT_FAILURE
1524	fi
1525	if test "X$arg" = "X-export-symbols"; then
1526	  prev=expsyms
1527	else
1528	  prev=expsyms_regex
1529	fi
1530	continue
1531	;;
1532
1533      -framework|-arch|-isysroot)
1534	case " $CC " in
1535	  *" ${arg} ${1} "* | *" ${arg}	${1} "*)
1536		prev=darwin_framework_skip ;;
1537	  *) compiler_flags="$compiler_flags $arg"
1538	     prev=darwin_framework ;;
1539	esac
1540	compile_command="$compile_command $arg"
1541	finalize_command="$finalize_command $arg"
1542	continue
1543	;;
1544
1545      -inst-prefix-dir)
1546	prev=inst_prefix
1547	continue
1548	;;
1549
1550      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1551      # so, if we see these flags be careful not to treat them like -L
1552      -L[A-Z][A-Z]*:*)
1553	case $with_gcc/$host in
1554	no/*-*-irix* | /*-*-irix*)
1555	  compile_command="$compile_command $arg"
1556	  finalize_command="$finalize_command $arg"
1557	  ;;
1558	esac
1559	continue
1560	;;
1561
1562      -L*)
1563	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1564	# We need an absolute path.
1565	case $dir in
1566	[\\/]* | [A-Za-z]:[\\/]*) ;;
1567	*)
1568	  absdir=`cd "$dir" && pwd`
1569	  if test -z "$absdir"; then
1570	    $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1571	    absdir="$dir"
1572	    notinst_path="$notinst_path $dir"
1573	  fi
1574	  dir="$absdir"
1575	  ;;
1576	esac
1577	case "$deplibs " in
1578	*" -L$dir "*) ;;
1579	*)
1580	  deplibs="$deplibs -L$dir"
1581	  lib_search_path="$lib_search_path $dir"
1582	  ;;
1583	esac
1584	case $host in
1585	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1586	  testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
1587	  case :$dllsearchpath: in
1588	  *":$dir:"*) ;;
1589	  *) dllsearchpath="$dllsearchpath:$dir";;
1590	  esac
1591	  case :$dllsearchpath: in
1592	  *":$testbindir:"*) ;;
1593	  *) dllsearchpath="$dllsearchpath:$testbindir";;
1594	  esac
1595	  ;;
1596	esac
1597	continue
1598	;;
1599
1600      -l*)
1601	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1602	  case $host in
1603	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
1604	    # These systems don't actually have a C or math library (as such)
1605	    continue
1606	    ;;
1607	  *-*-os2*)
1608	    # These systems don't actually have a C library (as such)
1609	    test "X$arg" = "X-lc" && continue
1610	    ;;
1611	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1612	    # Do not include libc due to us having libc/libc_r.
1613	    test "X$arg" = "X-lc" && continue
1614	    ;;
1615	  *-*-rhapsody* | *-*-darwin1.[012])
1616	    # Rhapsody C and math libraries are in the System framework
1617	    deplibs="$deplibs -framework System"
1618	    continue
1619	    ;;
1620	  *-*-sco3.2v5* | *-*-sco5v6*)
1621	    # Causes problems with __ctype
1622	    test "X$arg" = "X-lc" && continue
1623	    ;;
1624	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
1625	    # Compiler inserts libc in the correct place for threads to work
1626	    test "X$arg" = "X-lc" && continue
1627	    ;;
1628	  esac
1629	elif test "X$arg" = "X-lc_r"; then
1630	 case $host in
1631	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
1632	   # Do not include libc_r directly, use -pthread flag.
1633	   continue
1634	   ;;
1635	 esac
1636	fi
1637	deplibs="$deplibs $arg"
1638	continue
1639	;;
1640
1641      # Tru64 UNIX uses -model [arg] to determine the layout of C++
1642      # classes, name mangling, and exception handling.
1643      -model)
1644	compile_command="$compile_command $arg"
1645	compiler_flags="$compiler_flags $arg"
1646	finalize_command="$finalize_command $arg"
1647	prev=xcompiler
1648	continue
1649	;;
1650
1651     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1652	compiler_flags="$compiler_flags $arg"
1653	compile_command="$compile_command $arg"
1654	finalize_command="$finalize_command $arg"
1655	continue
1656	;;
1657
1658      -module)
1659	module=yes
1660	continue
1661	;;
1662
1663      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1664      # -r[0-9][0-9]* specifies the processor on the SGI compiler
1665      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1666      # +DA*, +DD* enable 64-bit mode on the HP compiler
1667      # -q* pass through compiler args for the IBM compiler
1668      # -m* pass through architecture-specific compiler args for GCC
1669      # -m*, -t[45]*, -txscale* pass through architecture-specific
1670      # compiler args for GCC
1671      # -pg pass through profiling flag for GCC
1672      # @file GCC response files
1673      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
1674      -t[45]*|-txscale*|@*)
1675
1676	# Unknown arguments in both finalize_command and compile_command need
1677	# to be aesthetically quoted because they are evaled later.
1678	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1679	case $arg in
1680	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1681	  arg="\"$arg\""
1682	  ;;
1683	esac
1684        compile_command="$compile_command $arg"
1685        finalize_command="$finalize_command $arg"
1686        compiler_flags="$compiler_flags $arg"
1687        continue
1688        ;;
1689
1690      -shrext)
1691	prev=shrext
1692	continue
1693	;;
1694
1695      -no-fast-install)
1696	fast_install=no
1697	continue
1698	;;
1699
1700      -no-install)
1701	case $host in
1702	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1703	  # The PATH hackery in wrapper scripts is required on Windows
1704	  # in order for the loader to find any dlls it needs.
1705	  $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
1706	  $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
1707	  fast_install=no
1708	  ;;
1709	*) no_install=yes ;;
1710	esac
1711	continue
1712	;;
1713
1714      -no-undefined)
1715	allow_undefined=no
1716	continue
1717	;;
1718
1719      -objectlist)
1720	prev=objectlist
1721	continue
1722	;;
1723
1724      -o) prev=output ;;
1725
1726      -precious-files-regex)
1727	prev=precious_regex
1728	continue
1729	;;
1730
1731      -release)
1732	prev=release
1733	continue
1734	;;
1735
1736      -rpath)
1737	prev=rpath
1738	continue
1739	;;
1740
1741      -R)
1742	prev=xrpath
1743	continue
1744	;;
1745
1746      -R*)
1747	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1748	# We need an absolute path.
1749	case $dir in
1750	[\\/]* | [A-Za-z]:[\\/]*) ;;
1751	*)
1752	  $echo "$modename: only absolute run-paths are allowed" 1>&2
1753	  exit $EXIT_FAILURE
1754	  ;;
1755	esac
1756	case "$xrpath " in
1757	*" $dir "*) ;;
1758	*) xrpath="$xrpath $dir" ;;
1759	esac
1760	continue
1761	;;
1762
1763      -static)
1764	# The effects of -static are defined in a previous loop.
1765	# We used to do the same as -all-static on platforms that
1766	# didn't have a PIC flag, but the assumption that the effects
1767	# would be equivalent was wrong.  It would break on at least
1768	# Digital Unix and AIX.
1769	continue
1770	;;
1771
1772      -thread-safe)
1773	thread_safe=yes
1774	continue
1775	;;
1776
1777      -version-info)
1778	prev=vinfo
1779	continue
1780	;;
1781      -version-number)
1782	prev=vinfo
1783	vinfo_number=yes
1784	continue
1785	;;
1786
1787      -Wc,*)
1788	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1789	arg=
1790	save_ifs="$IFS"; IFS=','
1791	for flag in $args; do
1792	  IFS="$save_ifs"
1793	  case $flag in
1794	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1795	    flag="\"$flag\""
1796	    ;;
1797	  esac
1798	  arg="$arg $wl$flag"
1799	  compiler_flags="$compiler_flags $flag"
1800	done
1801	IFS="$save_ifs"
1802	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1803	;;
1804
1805      -Wl,*)
1806	args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
1807	arg=
1808	save_ifs="$IFS"; IFS=','
1809	for flag in $args; do
1810	  IFS="$save_ifs"
1811	  case $flag in
1812	    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1813	    flag="\"$flag\""
1814	    ;;
1815	  esac
1816	  arg="$arg $wl$flag"
1817	  compiler_flags="$compiler_flags $wl$flag"
1818	  linker_flags="$linker_flags $flag"
1819	done
1820	IFS="$save_ifs"
1821	arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1822	;;
1823
1824      -Xcompiler)
1825	prev=xcompiler
1826	continue
1827	;;
1828
1829      -Xlinker)
1830	prev=xlinker
1831	continue
1832	;;
1833
1834      -XCClinker)
1835	prev=xcclinker
1836	continue
1837	;;
1838
1839      # Some other compiler flag.
1840      -* | +*)
1841	# Unknown arguments in both finalize_command and compile_command need
1842	# to be aesthetically quoted because they are evaled later.
1843	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1844	case $arg in
1845	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1846	  arg="\"$arg\""
1847	  ;;
1848	esac
1849	;;
1850
1851      *.$objext)
1852	# A standard object.
1853	objs="$objs $arg"
1854	;;
1855
1856      *.lo)
1857	# A libtool-controlled object.
1858
1859	# Check to see that this really is a libtool object.
1860	if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1861	  pic_object=
1862	  non_pic_object=
1863
1864	  # Read the .lo file
1865	  # If there is no directory component, then add one.
1866	  case $arg in
1867	  */* | *\\*) . $arg ;;
1868	  *) . ./$arg ;;
1869	  esac
1870
1871	  if test -z "$pic_object" || \
1872	     test -z "$non_pic_object" ||
1873	     test "$pic_object" = none && \
1874	     test "$non_pic_object" = none; then
1875	    $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1876	    exit $EXIT_FAILURE
1877	  fi
1878
1879	  # Extract subdirectory from the argument.
1880	  xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1881	  if test "X$xdir" = "X$arg"; then
1882	    xdir=
1883 	  else
1884	    xdir="$xdir/"
1885	  fi
1886
1887	  if test "$pic_object" != none; then
1888	    # Prepend the subdirectory the object is found in.
1889	    pic_object="$xdir$pic_object"
1890
1891	    if test "$prev" = dlfiles; then
1892	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1893		dlfiles="$dlfiles $pic_object"
1894		prev=
1895		continue
1896	      else
1897		# If libtool objects are unsupported, then we need to preload.
1898		prev=dlprefiles
1899	      fi
1900	    fi
1901
1902	    # CHECK ME:  I think I busted this.  -Ossama
1903	    if test "$prev" = dlprefiles; then
1904	      # Preload the old-style object.
1905	      dlprefiles="$dlprefiles $pic_object"
1906	      prev=
1907	    fi
1908
1909	    # A PIC object.
1910	    libobjs="$libobjs $pic_object"
1911	    arg="$pic_object"
1912	  fi
1913
1914	  # Non-PIC object.
1915	  if test "$non_pic_object" != none; then
1916	    # Prepend the subdirectory the object is found in.
1917	    non_pic_object="$xdir$non_pic_object"
1918
1919	    # A standard non-PIC object
1920	    non_pic_objects="$non_pic_objects $non_pic_object"
1921	    if test -z "$pic_object" || test "$pic_object" = none ; then
1922	      arg="$non_pic_object"
1923	    fi
1924	  else
1925	    # If the PIC object exists, use it instead.
1926	    # $xdir was prepended to $pic_object above.
1927	    non_pic_object="$pic_object"
1928	    non_pic_objects="$non_pic_objects $non_pic_object"
1929	  fi
1930	else
1931	  # Only an error if not doing a dry-run.
1932	  if test -z "$run"; then
1933	    $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1934	    exit $EXIT_FAILURE
1935	  else
1936	    # Dry-run case.
1937
1938	    # Extract subdirectory from the argument.
1939	    xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1940	    if test "X$xdir" = "X$arg"; then
1941	      xdir=
1942	    else
1943	      xdir="$xdir/"
1944	    fi
1945
1946	    pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1947	    non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1948	    libobjs="$libobjs $pic_object"
1949	    non_pic_objects="$non_pic_objects $non_pic_object"
1950	  fi
1951	fi
1952	;;
1953
1954      *.$libext)
1955	# An archive.
1956	deplibs="$deplibs $arg"
1957	old_deplibs="$old_deplibs $arg"
1958	continue
1959	;;
1960
1961      *.la)
1962	# A libtool-controlled library.
1963
1964	if test "$prev" = dlfiles; then
1965	  # This library was specified with -dlopen.
1966	  dlfiles="$dlfiles $arg"
1967	  prev=
1968	elif test "$prev" = dlprefiles; then
1969	  # The library was specified with -dlpreopen.
1970	  dlprefiles="$dlprefiles $arg"
1971	  prev=
1972	else
1973	  deplibs="$deplibs $arg"
1974	fi
1975	continue
1976	;;
1977
1978      # Some other compiler argument.
1979      *)
1980	# Unknown arguments in both finalize_command and compile_command need
1981	# to be aesthetically quoted because they are evaled later.
1982	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1983	case $arg in
1984	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
1985	  arg="\"$arg\""
1986	  ;;
1987	esac
1988	;;
1989      esac # arg
1990
1991      # Now actually substitute the argument into the commands.
1992      if test -n "$arg"; then
1993	compile_command="$compile_command $arg"
1994	finalize_command="$finalize_command $arg"
1995      fi
1996    done # argument parsing loop
1997
1998    if test -n "$prev"; then
1999      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
2000      $echo "$help" 1>&2
2001      exit $EXIT_FAILURE
2002    fi
2003
2004    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
2005      eval arg=\"$export_dynamic_flag_spec\"
2006      compile_command="$compile_command $arg"
2007      finalize_command="$finalize_command $arg"
2008    fi
2009
2010    oldlibs=
2011    # calculate the name of the file, without its directory
2012    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
2013    libobjs_save="$libobjs"
2014
2015    if test -n "$shlibpath_var"; then
2016      # get the directories listed in $shlibpath_var
2017      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
2018    else
2019      shlib_search_path=
2020    fi
2021    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
2022    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
2023
2024    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
2025    if test "X$output_objdir" = "X$output"; then
2026      output_objdir="$objdir"
2027    else
2028      output_objdir="$output_objdir/$objdir"
2029    fi
2030    # Create the object directory.
2031    if test ! -d "$output_objdir"; then
2032      $show "$mkdir $output_objdir"
2033      $run $mkdir $output_objdir
2034      exit_status=$?
2035      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
2036	exit $exit_status
2037      fi
2038    fi
2039
2040    # Determine the type of output
2041    case $output in
2042    "")
2043      $echo "$modename: you must specify an output file" 1>&2
2044      $echo "$help" 1>&2
2045      exit $EXIT_FAILURE
2046      ;;
2047    *.$libext) linkmode=oldlib ;;
2048    *.lo | *.$objext) linkmode=obj ;;
2049    *.la) linkmode=lib ;;
2050    *) linkmode=prog ;; # Anything else should be a program.
2051    esac
2052
2053    case $host in
2054    *cygwin* | *mingw* | *pw32*)
2055      # don't eliminate duplications in $postdeps and $predeps
2056      duplicate_compiler_generated_deps=yes
2057      ;;
2058    *)
2059      duplicate_compiler_generated_deps=$duplicate_deps
2060      ;;
2061    esac
2062    specialdeplibs=
2063
2064    libs=
2065    # Find all interdependent deplibs by searching for libraries
2066    # that are linked more than once (e.g. -la -lb -la)
2067    for deplib in $deplibs; do
2068      if test "X$duplicate_deps" = "Xyes" ; then
2069	case "$libs " in
2070	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2071	esac
2072      fi
2073      libs="$libs $deplib"
2074    done
2075
2076    if test "$linkmode" = lib; then
2077      libs="$predeps $libs $compiler_lib_search_path $postdeps"
2078
2079      # Compute libraries that are listed more than once in $predeps
2080      # $postdeps and mark them as special (i.e., whose duplicates are
2081      # not to be eliminated).
2082      pre_post_deps=
2083      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
2084	for pre_post_dep in $predeps $postdeps; do
2085	  case "$pre_post_deps " in
2086	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
2087	  esac
2088	  pre_post_deps="$pre_post_deps $pre_post_dep"
2089	done
2090      fi
2091      pre_post_deps=
2092    fi
2093
2094    deplibs=
2095    newdependency_libs=
2096    newlib_search_path=
2097    need_relink=no # whether we're linking any uninstalled libtool libraries
2098    notinst_deplibs= # not-installed libtool libraries
2099    case $linkmode in
2100    lib)
2101	passes="conv link"
2102	for file in $dlfiles $dlprefiles; do
2103	  case $file in
2104	  *.la) ;;
2105	  *)
2106	    $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
2107	    exit $EXIT_FAILURE
2108	    ;;
2109	  esac
2110	done
2111	;;
2112    prog)
2113	compile_deplibs=
2114	finalize_deplibs=
2115	alldeplibs=no
2116	newdlfiles=
2117	newdlprefiles=
2118	passes="conv scan dlopen dlpreopen link"
2119	;;
2120    *)  passes="conv"
2121	;;
2122    esac
2123    for pass in $passes; do
2124      if test "$linkmode,$pass" = "lib,link" ||
2125	 test "$linkmode,$pass" = "prog,scan"; then
2126	libs="$deplibs"
2127	deplibs=
2128      fi
2129      if test "$linkmode" = prog; then
2130	case $pass in
2131	dlopen) libs="$dlfiles" ;;
2132	dlpreopen) libs="$dlprefiles" ;;
2133	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
2134	esac
2135      fi
2136      if test "$pass" = dlopen; then
2137	# Collect dlpreopened libraries
2138	save_deplibs="$deplibs"
2139	deplibs=
2140      fi
2141      for deplib in $libs; do
2142	lib=
2143	found=no
2144	case $deplib in
2145	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
2146	  if test "$linkmode,$pass" = "prog,link"; then
2147	    compile_deplibs="$deplib $compile_deplibs"
2148	    finalize_deplibs="$deplib $finalize_deplibs"
2149	  else
2150	    compiler_flags="$compiler_flags $deplib"
2151	  fi
2152	  continue
2153	  ;;
2154	-l*)
2155	  if test "$linkmode" != lib && test "$linkmode" != prog; then
2156	    $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
2157	    continue
2158	  fi
2159	  name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
2160	  for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
2161	    for search_ext in .la $std_shrext .so .a; do
2162	      # Search the libtool library
2163	      lib="$searchdir/lib${name}${search_ext}"
2164	      if test -f "$lib"; then
2165		if test "$search_ext" = ".la"; then
2166		  found=yes
2167		else
2168		  found=no
2169		fi
2170		break 2
2171	      fi
2172	    done
2173	  done
2174	  if test "$found" != yes; then
2175	    # deplib doesn't seem to be a libtool library
2176	    if test "$linkmode,$pass" = "prog,link"; then
2177	      compile_deplibs="$deplib $compile_deplibs"
2178	      finalize_deplibs="$deplib $finalize_deplibs"
2179	    else
2180	      deplibs="$deplib $deplibs"
2181	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2182	    fi
2183	    continue
2184	  else # deplib is a libtool library
2185	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2186	    # We need to do some special things here, and not later.
2187	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2188	      case " $predeps $postdeps " in
2189	      *" $deplib "*)
2190		if (${SED} -e '2q' $lib |
2191                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2192		  library_names=
2193		  old_library=
2194		  case $lib in
2195		  */* | *\\*) . $lib ;;
2196		  *) . ./$lib ;;
2197		  esac
2198		  for l in $old_library $library_names; do
2199		    ll="$l"
2200		  done
2201		  if test "X$ll" = "X$old_library" ; then # only static version available
2202		    found=no
2203		    ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2204		    test "X$ladir" = "X$lib" && ladir="."
2205		    lib=$ladir/$old_library
2206		    if test "$linkmode,$pass" = "prog,link"; then
2207		      compile_deplibs="$deplib $compile_deplibs"
2208		      finalize_deplibs="$deplib $finalize_deplibs"
2209		    else
2210		      deplibs="$deplib $deplibs"
2211		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2212		    fi
2213		    continue
2214		  fi
2215		fi
2216	        ;;
2217	      *) ;;
2218	      esac
2219	    fi
2220	  fi
2221	  ;; # -l
2222	-L*)
2223	  case $linkmode in
2224	  lib)
2225	    deplibs="$deplib $deplibs"
2226	    test "$pass" = conv && continue
2227	    newdependency_libs="$deplib $newdependency_libs"
2228	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2229	    ;;
2230	  prog)
2231	    if test "$pass" = conv; then
2232	      deplibs="$deplib $deplibs"
2233	      continue
2234	    fi
2235	    if test "$pass" = scan; then
2236	      deplibs="$deplib $deplibs"
2237	    else
2238	      compile_deplibs="$deplib $compile_deplibs"
2239	      finalize_deplibs="$deplib $finalize_deplibs"
2240	    fi
2241	    newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2242	    ;;
2243	  *)
2244	    $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2245	    ;;
2246	  esac # linkmode
2247	  continue
2248	  ;; # -L
2249	-R*)
2250	  if test "$pass" = link; then
2251	    dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2252	    # Make sure the xrpath contains only unique directories.
2253	    case "$xrpath " in
2254	    *" $dir "*) ;;
2255	    *) xrpath="$xrpath $dir" ;;
2256	    esac
2257	  fi
2258	  deplibs="$deplib $deplibs"
2259	  continue
2260	  ;;
2261	*.la) lib="$deplib" ;;
2262	*.$libext)
2263	  if test "$pass" = conv; then
2264	    deplibs="$deplib $deplibs"
2265	    continue
2266	  fi
2267	  case $linkmode in
2268	  lib)
2269	    valid_a_lib=no
2270	    case $deplibs_check_method in
2271	      match_pattern*)
2272		set dummy $deplibs_check_method
2273	        match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2274		if eval $echo \"$deplib\" 2>/dev/null \
2275		    | $SED 10q \
2276		    | $EGREP "$match_pattern_regex" > /dev/null; then
2277		  valid_a_lib=yes
2278		fi
2279		;;
2280	      pass_all)
2281		valid_a_lib=yes
2282		;;
2283            esac
2284	    if test "$valid_a_lib" != yes; then
2285	      $echo
2286	      $echo "*** Warning: Trying to link with static lib archive $deplib."
2287	      $echo "*** I have the capability to make that library automatically link in when"
2288	      $echo "*** you link to this library.  But I can only do this if you have a"
2289	      $echo "*** shared version of the library, which you do not appear to have"
2290	      $echo "*** because the file extensions .$libext of this argument makes me believe"
2291	      $echo "*** that it is just a static archive that I should not used here."
2292	    else
2293	      $echo
2294	      $echo "*** Warning: Linking the shared library $output against the"
2295	      $echo "*** static library $deplib is not portable!"
2296	      deplibs="$deplib $deplibs"
2297	    fi
2298	    continue
2299	    ;;
2300	  prog)
2301	    if test "$pass" != link; then
2302	      deplibs="$deplib $deplibs"
2303	    else
2304	      compile_deplibs="$deplib $compile_deplibs"
2305	      finalize_deplibs="$deplib $finalize_deplibs"
2306	    fi
2307	    continue
2308	    ;;
2309	  esac # linkmode
2310	  ;; # *.$libext
2311	*.lo | *.$objext)
2312	  if test "$pass" = conv; then
2313	    deplibs="$deplib $deplibs"
2314	  elif test "$linkmode" = prog; then
2315	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2316	      # If there is no dlopen support or we're linking statically,
2317	      # we need to preload.
2318	      newdlprefiles="$newdlprefiles $deplib"
2319	      compile_deplibs="$deplib $compile_deplibs"
2320	      finalize_deplibs="$deplib $finalize_deplibs"
2321	    else
2322	      newdlfiles="$newdlfiles $deplib"
2323	    fi
2324	  fi
2325	  continue
2326	  ;;
2327	%DEPLIBS%)
2328	  alldeplibs=yes
2329	  continue
2330	  ;;
2331	esac # case $deplib
2332	if test "$found" = yes || test -f "$lib"; then :
2333	else
2334	  $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
2335	  exit $EXIT_FAILURE
2336	fi
2337
2338	# Check to see that this really is a libtool archive.
2339	if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2340	else
2341	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2342	  exit $EXIT_FAILURE
2343	fi
2344
2345	ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2346	test "X$ladir" = "X$lib" && ladir="."
2347
2348	dlname=
2349	dlopen=
2350	dlpreopen=
2351	libdir=
2352	library_names=
2353	old_library=
2354	# If the library was installed with an old release of libtool,
2355	# it will not redefine variables installed, or shouldnotlink
2356	installed=yes
2357	shouldnotlink=no
2358	avoidtemprpath=
2359
2360
2361	# Read the .la file
2362	case $lib in
2363	*/* | *\\*) . $lib ;;
2364	*) . ./$lib ;;
2365	esac
2366
2367	if test "$linkmode,$pass" = "lib,link" ||
2368	   test "$linkmode,$pass" = "prog,scan" ||
2369	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2370	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2371	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2372	fi
2373
2374	if test "$pass" = conv; then
2375	  # Only check for convenience libraries
2376	  deplibs="$lib $deplibs"
2377	  if test -z "$libdir"; then
2378	    if test -z "$old_library"; then
2379	      $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2380	      exit $EXIT_FAILURE
2381	    fi
2382	    # It is a libtool convenience library, so add in its objects.
2383	    convenience="$convenience $ladir/$objdir/$old_library"
2384	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
2385	    tmp_libs=
2386	    for deplib in $dependency_libs; do
2387	      deplibs="$deplib $deplibs"
2388              if test "X$duplicate_deps" = "Xyes" ; then
2389	        case "$tmp_libs " in
2390	        *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2391	        esac
2392              fi
2393	      tmp_libs="$tmp_libs $deplib"
2394	    done
2395	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
2396	    $echo "$modename: \`$lib' is not a convenience library" 1>&2
2397	    exit $EXIT_FAILURE
2398	  fi
2399	  continue
2400	fi # $pass = conv
2401
2402
2403	# Get the name of the library we link against.
2404	linklib=
2405	for l in $old_library $library_names; do
2406	  linklib="$l"
2407	done
2408	if test -z "$linklib"; then
2409	  $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2410	  exit $EXIT_FAILURE
2411	fi
2412
2413	# This library was specified with -dlopen.
2414	if test "$pass" = dlopen; then
2415	  if test -z "$libdir"; then
2416	    $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2417	    exit $EXIT_FAILURE
2418	  fi
2419	  if test -z "$dlname" ||
2420	     test "$dlopen_support" != yes ||
2421	     test "$build_libtool_libs" = no; then
2422	    # If there is no dlname, no dlopen support or we're linking
2423	    # statically, we need to preload.  We also need to preload any
2424	    # dependent libraries so libltdl's deplib preloader doesn't
2425	    # bomb out in the load deplibs phase.
2426	    dlprefiles="$dlprefiles $lib $dependency_libs"
2427	  else
2428	    newdlfiles="$newdlfiles $lib"
2429	  fi
2430	  continue
2431	fi # $pass = dlopen
2432
2433	# We need an absolute path.
2434	case $ladir in
2435	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
2436	*)
2437	  abs_ladir=`cd "$ladir" && pwd`
2438	  if test -z "$abs_ladir"; then
2439	    $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
2440	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
2441	    abs_ladir="$ladir"
2442	  fi
2443	  ;;
2444	esac
2445	laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
2446
2447	# Find the relevant object directory and library name.
2448	if test "X$installed" = Xyes; then
2449	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2450	    $echo "$modename: warning: library \`$lib' was moved." 1>&2
2451	    dir="$ladir"
2452	    absdir="$abs_ladir"
2453	    libdir="$abs_ladir"
2454	  else
2455	    dir="$libdir"
2456	    absdir="$libdir"
2457	  fi
2458	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2459	else
2460	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2461	    dir="$ladir"
2462	    absdir="$abs_ladir"
2463	    # Remove this search path later
2464	    notinst_path="$notinst_path $abs_ladir"
2465	  else
2466	    dir="$ladir/$objdir"
2467	    absdir="$abs_ladir/$objdir"
2468	    # Remove this search path later
2469	    notinst_path="$notinst_path $abs_ladir"
2470	  fi
2471	fi # $installed = yes
2472	name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2473
2474	# This library was specified with -dlpreopen.
2475	if test "$pass" = dlpreopen; then
2476	  if test -z "$libdir"; then
2477	    $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2478	    exit $EXIT_FAILURE
2479	  fi
2480	  # Prefer using a static library (so that no silly _DYNAMIC symbols
2481	  # are required to link).
2482	  if test -n "$old_library"; then
2483	    newdlprefiles="$newdlprefiles $dir/$old_library"
2484	  # Otherwise, use the dlname, so that lt_dlopen finds it.
2485	  elif test -n "$dlname"; then
2486	    newdlprefiles="$newdlprefiles $dir/$dlname"
2487	  else
2488	    newdlprefiles="$newdlprefiles $dir/$linklib"
2489	  fi
2490	fi # $pass = dlpreopen
2491
2492	if test -z "$libdir"; then
2493	  # Link the convenience library
2494	  if test "$linkmode" = lib; then
2495	    deplibs="$dir/$old_library $deplibs"
2496	  elif test "$linkmode,$pass" = "prog,link"; then
2497	    compile_deplibs="$dir/$old_library $compile_deplibs"
2498	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
2499	  else
2500	    deplibs="$lib $deplibs" # used for prog,scan pass
2501	  fi
2502	  continue
2503	fi
2504
2505
2506	if test "$linkmode" = prog && test "$pass" != link; then
2507	  newlib_search_path="$newlib_search_path $ladir"
2508	  deplibs="$lib $deplibs"
2509
2510	  linkalldeplibs=no
2511	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
2512	     test "$build_libtool_libs" = no; then
2513	    linkalldeplibs=yes
2514	  fi
2515
2516	  tmp_libs=
2517	  for deplib in $dependency_libs; do
2518	    case $deplib in
2519	    -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2520	    esac
2521	    # Need to link against all dependency_libs?
2522	    if test "$linkalldeplibs" = yes; then
2523	      deplibs="$deplib $deplibs"
2524	    else
2525	      # Need to hardcode shared library paths
2526	      # or/and link against static libraries
2527	      newdependency_libs="$deplib $newdependency_libs"
2528	    fi
2529	    if test "X$duplicate_deps" = "Xyes" ; then
2530	      case "$tmp_libs " in
2531	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2532	      esac
2533	    fi
2534	    tmp_libs="$tmp_libs $deplib"
2535	  done # for deplib
2536	  continue
2537	fi # $linkmode = prog...
2538
2539	if test "$linkmode,$pass" = "prog,link"; then
2540	  if test -n "$library_names" &&
2541	     { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2542	    # We need to hardcode the library path
2543	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
2544	      # Make sure the rpath contains only unique directories.
2545	      case "$temp_rpath " in
2546	      *" $dir "*) ;;
2547	      *" $absdir "*) ;;
2548	      *) temp_rpath="$temp_rpath $absdir" ;;
2549	      esac
2550	    fi
2551
2552	    # Hardcode the library path.
2553	    # Skip directories that are in the system default run-time
2554	    # search path.
2555	    case " $sys_lib_dlsearch_path " in
2556	    *" $absdir "*) ;;
2557	    *)
2558	      case "$compile_rpath " in
2559	      *" $absdir "*) ;;
2560	      *) compile_rpath="$compile_rpath $absdir"
2561	      esac
2562	      ;;
2563	    esac
2564	    case " $sys_lib_dlsearch_path " in
2565	    *" $libdir "*) ;;
2566	    *)
2567	      case "$finalize_rpath " in
2568	      *" $libdir "*) ;;
2569	      *) finalize_rpath="$finalize_rpath $libdir"
2570	      esac
2571	      ;;
2572	    esac
2573	  fi # $linkmode,$pass = prog,link...
2574
2575	  if test "$alldeplibs" = yes &&
2576	     { test "$deplibs_check_method" = pass_all ||
2577	       { test "$build_libtool_libs" = yes &&
2578		 test -n "$library_names"; }; }; then
2579	    # We only need to search for static libraries
2580	    continue
2581	  fi
2582	fi
2583
2584	link_static=no # Whether the deplib will be linked statically
2585	use_static_libs=$prefer_static_libs
2586	if test "$use_static_libs" = built && test "$installed" = yes ; then
2587	  use_static_libs=no
2588	fi
2589	if test -n "$library_names" &&
2590	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
2591	  if test "$installed" = no; then
2592	    notinst_deplibs="$notinst_deplibs $lib"
2593	    need_relink=yes
2594	  fi
2595	  # This is a shared library
2596
2597	  # Warn about portability, can't link against -module's on
2598	  # some systems (darwin)
2599	  if test "$shouldnotlink" = yes && test "$pass" = link ; then
2600	    $echo
2601	    if test "$linkmode" = prog; then
2602	      $echo "*** Warning: Linking the executable $output against the loadable module"
2603	    else
2604	      $echo "*** Warning: Linking the shared library $output against the loadable module"
2605	    fi
2606	    $echo "*** $linklib is not portable!"
2607	  fi
2608	  if test "$linkmode" = lib &&
2609	     test "$hardcode_into_libs" = yes; then
2610	    # Hardcode the library path.
2611	    # Skip directories that are in the system default run-time
2612	    # search path.
2613	    case " $sys_lib_dlsearch_path " in
2614	    *" $absdir "*) ;;
2615	    *)
2616	      case "$compile_rpath " in
2617	      *" $absdir "*) ;;
2618	      *) compile_rpath="$compile_rpath $absdir"
2619	      esac
2620	      ;;
2621	    esac
2622	    case " $sys_lib_dlsearch_path " in
2623	    *" $libdir "*) ;;
2624	    *)
2625	      case "$finalize_rpath " in
2626	      *" $libdir "*) ;;
2627	      *) finalize_rpath="$finalize_rpath $libdir"
2628	      esac
2629	      ;;
2630	    esac
2631	  fi
2632
2633	  if test -n "$old_archive_from_expsyms_cmds"; then
2634	    # figure out the soname
2635	    set dummy $library_names
2636	    realname="$2"
2637	    shift; shift
2638	    libname=`eval \\$echo \"$libname_spec\"`
2639	    # use dlname if we got it. it's perfectly good, no?
2640	    if test -n "$dlname"; then
2641	      soname="$dlname"
2642	    elif test -n "$soname_spec"; then
2643	      # bleh windows
2644	      case $host in
2645	      *cygwin* | mingw*)
2646		major=`expr $current - $age`
2647		versuffix="-$major"
2648		;;
2649	      esac
2650	      eval soname=\"$soname_spec\"
2651	    else
2652	      soname="$realname"
2653	    fi
2654
2655	    # Make a new name for the extract_expsyms_cmds to use
2656	    soroot="$soname"
2657	    soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2658	    newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
2659
2660	    # If the library has no export list, then create one now
2661	    if test -f "$output_objdir/$soname-def"; then :
2662	    else
2663	      $show "extracting exported symbol list from \`$soname'"
2664	      save_ifs="$IFS"; IFS='~'
2665	      cmds=$extract_expsyms_cmds
2666	      for cmd in $cmds; do
2667		IFS="$save_ifs"
2668		eval cmd=\"$cmd\"
2669		$show "$cmd"
2670		$run eval "$cmd" || exit $?
2671	      done
2672	      IFS="$save_ifs"
2673	    fi
2674
2675	    # Create $newlib
2676	    if test -f "$output_objdir/$newlib"; then :; else
2677	      $show "generating import library for \`$soname'"
2678	      save_ifs="$IFS"; IFS='~'
2679	      cmds=$old_archive_from_expsyms_cmds
2680	      for cmd in $cmds; do
2681		IFS="$save_ifs"
2682		eval cmd=\"$cmd\"
2683		$show "$cmd"
2684		$run eval "$cmd" || exit $?
2685	      done
2686	      IFS="$save_ifs"
2687	    fi
2688	    # make sure the library variables are pointing to the new library
2689	    dir=$output_objdir
2690	    linklib=$newlib
2691	  fi # test -n "$old_archive_from_expsyms_cmds"
2692
2693	  if test "$linkmode" = prog || test "$mode" != relink; then
2694	    add_shlibpath=
2695	    add_dir=
2696	    add=
2697	    lib_linked=yes
2698	    case $hardcode_action in
2699	    immediate | unsupported)
2700	      if test "$hardcode_direct" = no; then
2701		add="$dir/$linklib"
2702		case $host in
2703		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
2704		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
2705		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
2706		    *-*-unixware7*) add_dir="-L$dir" ;;
2707		  *-*-darwin* )
2708		    # if the lib is a module then we can not link against
2709		    # it, someone is ignoring the new warnings I added
2710		    if /usr/bin/file -L $add 2> /dev/null |
2711                      $EGREP ": [^:]* bundle" >/dev/null ; then
2712		      $echo "** Warning, lib $linklib is a module, not a shared library"
2713		      if test -z "$old_library" ; then
2714		        $echo
2715		        $echo "** And there doesn't seem to be a static archive available"
2716		        $echo "** The link will probably fail, sorry"
2717		      else
2718		        add="$dir/$old_library"
2719		      fi
2720		    fi
2721		esac
2722	      elif test "$hardcode_minus_L" = no; then
2723		case $host in
2724		*-*-sunos*) add_shlibpath="$dir" ;;
2725		esac
2726		add_dir="-L$dir"
2727		add="-l$name"
2728	      elif test "$hardcode_shlibpath_var" = no; then
2729		add_shlibpath="$dir"
2730		add="-l$name"
2731	      else
2732		lib_linked=no
2733	      fi
2734	      ;;
2735	    relink)
2736	      if test "$hardcode_direct" = yes; then
2737		add="$dir/$linklib"
2738	      elif test "$hardcode_minus_L" = yes; then
2739		add_dir="-L$dir"
2740		# Try looking first in the location we're being installed to.
2741		if test -n "$inst_prefix_dir"; then
2742		  case $libdir in
2743		    [\\/]*)
2744		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
2745		      ;;
2746		  esac
2747		fi
2748		add="-l$name"
2749	      elif test "$hardcode_shlibpath_var" = yes; then
2750		add_shlibpath="$dir"
2751		add="-l$name"
2752	      else
2753		lib_linked=no
2754	      fi
2755	      ;;
2756	    *) lib_linked=no ;;
2757	    esac
2758
2759	    if test "$lib_linked" != yes; then
2760	      $echo "$modename: configuration error: unsupported hardcode properties"
2761	      exit $EXIT_FAILURE
2762	    fi
2763
2764	    if test -n "$add_shlibpath"; then
2765	      case :$compile_shlibpath: in
2766	      *":$add_shlibpath:"*) ;;
2767	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2768	      esac
2769	    fi
2770	    if test "$linkmode" = prog; then
2771	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2772	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
2773	    else
2774	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2775	      test -n "$add" && deplibs="$add $deplibs"
2776	      if test "$hardcode_direct" != yes && \
2777		 test "$hardcode_minus_L" != yes && \
2778		 test "$hardcode_shlibpath_var" = yes; then
2779		case :$finalize_shlibpath: in
2780		*":$libdir:"*) ;;
2781		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2782		esac
2783	      fi
2784	    fi
2785	  fi
2786
2787	  if test "$linkmode" = prog || test "$mode" = relink; then
2788	    add_shlibpath=
2789	    add_dir=
2790	    add=
2791	    # Finalize command for both is simple: just hardcode it.
2792	    if test "$hardcode_direct" = yes; then
2793	      add="$libdir/$linklib"
2794	    elif test "$hardcode_minus_L" = yes; then
2795	      add_dir="-L$libdir"
2796	      add="-l$name"
2797	    elif test "$hardcode_shlibpath_var" = yes; then
2798	      case :$finalize_shlibpath: in
2799	      *":$libdir:"*) ;;
2800	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2801	      esac
2802	      add="-l$name"
2803	    elif test "$hardcode_automatic" = yes; then
2804	      if test -n "$inst_prefix_dir" &&
2805		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
2806	        add="$inst_prefix_dir$libdir/$linklib"
2807	      else
2808	        add="$libdir/$linklib"
2809	      fi
2810	    else
2811	      # We cannot seem to hardcode it, guess we'll fake it.
2812	      add_dir="-L$libdir"
2813	      # Try looking first in the location we're being installed to.
2814	      if test -n "$inst_prefix_dir"; then
2815		case $libdir in
2816		  [\\/]*)
2817		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
2818		    ;;
2819		esac
2820	      fi
2821	      add="-l$name"
2822	    fi
2823
2824	    if test "$linkmode" = prog; then
2825	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2826	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2827	    else
2828	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
2829	      test -n "$add" && deplibs="$add $deplibs"
2830	    fi
2831	  fi
2832	elif test "$linkmode" = prog; then
2833	  # Here we assume that one of hardcode_direct or hardcode_minus_L
2834	  # is not unsupported.  This is valid on all known static and
2835	  # shared platforms.
2836	  if test "$hardcode_direct" != unsupported; then
2837	    test -n "$old_library" && linklib="$old_library"
2838	    compile_deplibs="$dir/$linklib $compile_deplibs"
2839	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
2840	  else
2841	    compile_deplibs="-l$name -L$dir $compile_deplibs"
2842	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
2843	  fi
2844	elif test "$build_libtool_libs" = yes; then
2845	  # Not a shared library
2846	  if test "$deplibs_check_method" != pass_all; then
2847	    # We're trying link a shared library against a static one
2848	    # but the system doesn't support it.
2849
2850