1# Generated from ltmain.m4sh.
2
3# ltmain.sh (GNU libtool) 2.2.6b
4# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5
6# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
7# This is free software; see the source for copying conditions.  There is NO
8# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
10# GNU Libtool is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# As a special exception to the GNU General Public License,
16# if you distribute this file as part of a program or library that
17# is built using GNU Libtool, you may include this file under the
18# same distribution terms that you use for the rest of that program.
19#
20# GNU Libtool is distributed in the hope that it will be useful, but
21# WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23# General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with GNU Libtool; see the file COPYING.  If not, a copy
27# can be downloaded from http://www.gnu.org/licenses/gpl.html,
28# or obtained by writing to the Free Software Foundation, Inc.,
29# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
31# Usage: $progname [OPTION]... [MODE-ARG]...
32#
33# Provide generalized library-building support services.
34#
35#     --config             show all configuration variables
36#     --debug              enable verbose shell tracing
37# -n, --dry-run            display commands without modifying any files
38#     --features           display basic configuration information and exit
39#     --mode=MODE          use operation mode MODE
40#     --preserve-dup-deps  don't remove duplicate dependency libraries
41#     --quiet, --silent    don't print informational messages
42#     --tag=TAG            use configuration variables from tag TAG
43# -v, --verbose            print informational messages (default)
44#     --version            print version information
45# -h, --help               print short or long help message
46#
47# MODE must be one of the following:
48#
49#       clean              remove files from the build directory
50#       compile            compile a source file into a libtool object
51#       execute            automatically set library path, then run a program
52#       finish             complete the installation of libtool libraries
53#       install            install libraries or executables
54#       link               create a library or an executable
55#       uninstall          remove libraries from an installed directory
56#
57# MODE-ARGS vary depending on the MODE.
58# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
59#
60# When reporting a bug, please describe a test case to reproduce it and
61# include the following information:
62#
63#       host-triplet:	$host
64#       shell:		$SHELL
65#       compiler:		$LTCC
66#       compiler flags:		$LTCFLAGS
67#       linker:		$LD (gnu? $with_gnu_ld)
68#       $progname:		(GNU libtool) 2.2.6b
69#       automake:		$automake_version
70#       autoconf:		$autoconf_version
71#
72# Report bugs to <bug-libtool@gnu.org>.
73
74PROGRAM=ltmain.sh
75PACKAGE=libtool
76VERSION=2.2.6b
77TIMESTAMP=""
78package_revision=1.3017
79
80# Be Bourne compatible
81if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
82  emulate sh
83  NULLCMD=:
84  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
85  # is contrary to our usage.  Disable this feature.
86  alias -g '${1+"$@"}'='"$@"'
87  setopt NO_GLOB_SUBST
88else
89  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
90fi
91BIN_SH=xpg4; export BIN_SH # for Tru64
92DUALCASE=1; export DUALCASE # for MKS sh
93
94# NLS nuisances: We save the old values to restore during execute mode.
95# Only set LANG and LC_ALL to C if already set.
96# These must not be set unconditionally because not all systems understand
97# e.g. LANG=C (notably SCO).
98lt_user_locale=
99lt_safe_locale=
100for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
101do
102  eval "if test \"\${$lt_var+set}\" = set; then
103          save_$lt_var=\$$lt_var
104          $lt_var=C
105	  export $lt_var
106	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
107	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
108	fi"
109done
110
111$lt_unset CDPATH
112
113
114
115
116
117: ${CP="cp -f"}
118: ${ECHO="echo"}
119: ${EGREP="/bin/grep -E"}
120: ${FGREP="/bin/grep -F"}
121: ${GREP="/bin/grep"}
122: ${LN_S="ln -s"}
123: ${MAKE="make"}
124: ${MKDIR="mkdir"}
125: ${MV="mv -f"}
126: ${RM="rm -f"}
127: ${SED="/bin/sed"}
128: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
129: ${Xsed="$SED -e 1s/^X//"}
130
131# Global variables:
132EXIT_SUCCESS=0
133EXIT_FAILURE=1
134EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
135EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
136
137exit_status=$EXIT_SUCCESS
138
139# Make sure IFS has a sensible default
140lt_nl='
141'
142IFS=" 	$lt_nl"
143
144dirname="s,/[^/]*$,,"
145basename="s,^.*/,,"
146
147# func_dirname_and_basename file append nondir_replacement
148# perform func_basename and func_dirname in a single function
149# call:
150#   dirname:  Compute the dirname of FILE.  If nonempty,
151#             add APPEND to the result, otherwise set result
152#             to NONDIR_REPLACEMENT.
153#             value returned in "$func_dirname_result"
154#   basename: Compute filename of FILE.
155#             value retuned in "$func_basename_result"
156# Implementation must be kept synchronized with func_dirname
157# and func_basename. For efficiency, we do not delegate to
158# those functions but instead duplicate the functionality here.
159func_dirname_and_basename ()
160{
161  # Extract subdirectory from the argument.
162  func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
163  if test "X$func_dirname_result" = "X${1}"; then
164    func_dirname_result="${3}"
165  else
166    func_dirname_result="$func_dirname_result${2}"
167  fi
168  func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
169}
170
171# Generated shell functions inserted here.
172
173# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
174# is ksh but when the shell is invoked as "sh" and the current value of
175# the _XPG environment variable is not equal to 1 (one), the special
176# positional parameter $0, within a function call, is the name of the
177# function.
178progpath="$0"
179
180# The name of this program:
181# In the unlikely event $progname began with a '-', it would play havoc with
182# func_echo (imagine progname=-n), so we prepend ./ in that case:
183func_dirname_and_basename "$progpath"
184progname=$func_basename_result
185case $progname in
186  -*) progname=./$progname ;;
187esac
188
189# Make sure we have an absolute path for reexecution:
190case $progpath in
191  [\\/]*|[A-Za-z]:\\*) ;;
192  *[\\/]*)
193     progdir=$func_dirname_result
194     progdir=`cd "$progdir" && pwd`
195     progpath="$progdir/$progname"
196     ;;
197  *)
198     save_IFS="$IFS"
199     IFS=:
200     for progdir in $PATH; do
201       IFS="$save_IFS"
202       test -x "$progdir/$progname" && break
203     done
204     IFS="$save_IFS"
205     test -n "$progdir" || progdir=`pwd`
206     progpath="$progdir/$progname"
207     ;;
208esac
209
210# Sed substitution that helps us do robust quoting.  It backslashifies
211# metacharacters that are still active within double-quoted strings.
212Xsed="${SED}"' -e 1s/^X//'
213sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
214
215# Same as above, but do not quote variable references.
216double_quote_subst='s/\(["`\\]\)/\\\1/g'
217
218# Re-`\' parameter expansions in output of double_quote_subst that were
219# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
220# in input to double_quote_subst, that '$' was protected from expansion.
221# Since each input `\' is now two `\'s, look for any number of runs of
222# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
223bs='\\'
224bs2='\\\\'
225bs4='\\\\\\\\'
226dollar='\$'
227sed_double_backslash="\
228  s/$bs4/&\\
229/g
230  s/^$bs2$dollar/$bs&/
231  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
232  s/\n//g"
233
234# Standard options:
235opt_dry_run=false
236opt_help=false
237opt_quiet=false
238opt_verbose=false
239opt_warning=:
240
241# func_echo arg...
242# Echo program name prefixed message, along with the current mode
243# name if it has been set yet.
244func_echo ()
245{
246    $ECHO "$progname${mode+: }$mode: $*"
247}
248
249# func_verbose arg...
250# Echo program name prefixed message in verbose mode only.
251func_verbose ()
252{
253    $opt_verbose && func_echo ${1+"$@"}
254
255    # A bug in bash halts the script if the last line of a function
256    # fails when set -e is in force, so we need another command to
257    # work around that:
258    :
259}
260
261# func_error arg...
262# Echo program name prefixed message to standard error.
263func_error ()
264{
265    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
266}
267
268# func_warning arg...
269# Echo program name prefixed warning message to standard error.
270func_warning ()
271{
272    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
273
274    # bash bug again:
275    :
276}
277
278# func_fatal_error arg...
279# Echo program name prefixed message to standard error, and exit.
280func_fatal_error ()
281{
282    func_error ${1+"$@"}
283    exit $EXIT_FAILURE
284}
285
286# func_fatal_help arg...
287# Echo program name prefixed message to standard error, followed by
288# a help hint, and exit.
289func_fatal_help ()
290{
291    func_error ${1+"$@"}
292    func_fatal_error "$help"
293}
294help="Try \`$progname --help' for more information."  ## default
295
296
297# func_grep expression filename
298# Check whether EXPRESSION matches any line of FILENAME, without output.
299func_grep ()
300{
301    $GREP "$1" "$2" >/dev/null 2>&1
302}
303
304
305# func_mkdir_p directory-path
306# Make sure the entire path to DIRECTORY-PATH is available.
307func_mkdir_p ()
308{
309    my_directory_path="$1"
310    my_dir_list=
311
312    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
313
314      # Protect directory names starting with `-'
315      case $my_directory_path in
316        -*) my_directory_path="./$my_directory_path" ;;
317      esac
318
319      # While some portion of DIR does not yet exist...
320      while test ! -d "$my_directory_path"; do
321        # ...make a list in topmost first order.  Use a colon delimited
322	# list incase some portion of path contains whitespace.
323        my_dir_list="$my_directory_path:$my_dir_list"
324
325        # If the last portion added has no slash in it, the list is done
326        case $my_directory_path in */*) ;; *) break ;; esac
327
328        # ...otherwise throw away the child directory and loop
329        my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
330      done
331      my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
332
333      save_mkdir_p_IFS="$IFS"; IFS=':'
334      for my_dir in $my_dir_list; do
335	IFS="$save_mkdir_p_IFS"
336        # mkdir can fail with a `File exist' error if two processes
337        # try to create one of the directories concurrently.  Don't
338        # stop in that case!
339        $MKDIR "$my_dir" 2>/dev/null || :
340      done
341      IFS="$save_mkdir_p_IFS"
342
343      # Bail out if we (or some other process) failed to create a directory.
344      test -d "$my_directory_path" || \
345        func_fatal_error "Failed to create \`$1'"
346    fi
347}
348
349
350# func_mktempdir [string]
351# Make a temporary directory that won't clash with other running
352# libtool processes, and avoids race conditions if possible.  If
353# given, STRING is the basename for that directory.
354func_mktempdir ()
355{
356    my_template="${TMPDIR-/tmp}/${1-$progname}"
357
358    if test "$opt_dry_run" = ":"; then
359      # Return a directory name, but don't create it in dry-run mode
360      my_tmpdir="${my_template}-$$"
361    else
362
363      # If mktemp works, use that first and foremost
364      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
365
366      if test ! -d "$my_tmpdir"; then
367        # Failing that, at least try and use $RANDOM to avoid a race
368        my_tmpdir="${my_template}-${RANDOM-0}$$"
369
370        save_mktempdir_umask=`umask`
371        umask 0077
372        $MKDIR "$my_tmpdir"
373        umask $save_mktempdir_umask
374      fi
375
376      # If we're not in dry-run mode, bomb out on failure
377      test -d "$my_tmpdir" || \
378        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
379    fi
380
381    $ECHO "X$my_tmpdir" | $Xsed
382}
383
384
385# func_quote_for_eval arg
386# Aesthetically quote ARG to be evaled later.
387# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
388# is double-quoted, suitable for a subsequent eval, whereas
389# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
390# which are still active within double quotes backslashified.
391func_quote_for_eval ()
392{
393    case $1 in
394      *[\\\`\"\$]*)
395	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
396      *)
397        func_quote_for_eval_unquoted_result="$1" ;;
398    esac
399
400    case $func_quote_for_eval_unquoted_result in
401      # Double-quote args containing shell metacharacters to delay
402      # word splitting, command substitution and and variable
403      # expansion for a subsequent eval.
404      # Many Bourne shells cannot handle close brackets correctly
405      # in scan sets, so we specify it separately.
406      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
407        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
408        ;;
409      *)
410        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
411    esac
412}
413
414
415# func_quote_for_expand arg
416# Aesthetically quote ARG to be evaled later; same as above,
417# but do not quote variable references.
418func_quote_for_expand ()
419{
420    case $1 in
421      *[\\\`\"]*)
422	my_arg=`$ECHO "X$1" | $Xsed \
423	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
424      *)
425        my_arg="$1" ;;
426    esac
427
428    case $my_arg in
429      # Double-quote args containing shell metacharacters to delay
430      # word splitting and command substitution for a subsequent eval.
431      # Many Bourne shells cannot handle close brackets correctly
432      # in scan sets, so we specify it separately.
433      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
434        my_arg="\"$my_arg\""
435        ;;
436    esac
437
438    func_quote_for_expand_result="$my_arg"
439}
440
441
442# func_show_eval cmd [fail_exp]
443# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
444# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
445# is given, then evaluate it.
446func_show_eval ()
447{
448    my_cmd="$1"
449    my_fail_exp="${2-:}"
450
451    ${opt_silent-false} || {
452      func_quote_for_expand "$my_cmd"
453      eval "func_echo $func_quote_for_expand_result"
454    }
455
456    if ${opt_dry_run-false}; then :; else
457      eval "$my_cmd"
458      my_status=$?
459      if test "$my_status" -eq 0; then :; else
460	eval "(exit $my_status); $my_fail_exp"
461      fi
462    fi
463}
464
465
466# func_show_eval_locale cmd [fail_exp]
467# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
468# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
469# is given, then evaluate it.  Use the saved locale for evaluation.
470func_show_eval_locale ()
471{
472    my_cmd="$1"
473    my_fail_exp="${2-:}"
474
475    ${opt_silent-false} || {
476      func_quote_for_expand "$my_cmd"
477      eval "func_echo $func_quote_for_expand_result"
478    }
479
480    if ${opt_dry_run-false}; then :; else
481      eval "$lt_user_locale
482	    $my_cmd"
483      my_status=$?
484      eval "$lt_safe_locale"
485      if test "$my_status" -eq 0; then :; else
486	eval "(exit $my_status); $my_fail_exp"
487      fi
488    fi
489}
490
491
492
493
494
495# func_version
496# Echo version message to standard output and exit.
497func_version ()
498{
499    $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
500        s/^# //
501	s/^# *$//
502        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
503        p
504     }' < "$progpath"
505     exit $?
506}
507
508# func_usage
509# Echo short help message to standard output and exit.
510func_usage ()
511{
512    $SED -n '/^# Usage:/,/# -h/ {
513        s/^# //
514	s/^# *$//
515	s/\$progname/'$progname'/
516	p
517    }' < "$progpath"
518    $ECHO
519    $ECHO "run \`$progname --help | more' for full usage"
520    exit $?
521}
522
523# func_help
524# Echo long help message to standard output and exit.
525func_help ()
526{
527    $SED -n '/^# Usage:/,/# Report bugs to/ {
528        s/^# //
529	s/^# *$//
530	s*\$progname*'$progname'*
531	s*\$host*'"$host"'*
532	s*\$SHELL*'"$SHELL"'*
533	s*\$LTCC*'"$LTCC"'*
534	s*\$LTCFLAGS*'"$LTCFLAGS"'*
535	s*\$LD*'"$LD"'*
536	s/\$with_gnu_ld/'"$with_gnu_ld"'/
537	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
538	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
539	p
540     }' < "$progpath"
541    exit $?
542}
543
544# func_missing_arg argname
545# Echo program name prefixed message to standard error and set global
546# exit_cmd.
547func_missing_arg ()
548{
549    func_error "missing argument for $1"
550    exit_cmd=exit
551}
552
553exit_cmd=:
554
555
556
557
558
559# Check that we have a working $ECHO.
560if test "X$1" = X--no-reexec; then
561  # Discard the --no-reexec flag, and continue.
562  shift
563elif test "X$1" = X--fallback-echo; then
564  # Avoid inline document here, it may be left over
565  :
566elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
567  # Yippee, $ECHO works!
568  :
569else
570  # Restart under the correct shell, and then maybe $ECHO will work.
571  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
572fi
573
574if test "X$1" = X--fallback-echo; then
575  # used as fallback echo
576  shift
577  cat <<EOF
578$*
579EOF
580  exit $EXIT_SUCCESS
581fi
582
583magic="%%%MAGIC variable%%%"
584magic_exe="%%%MAGIC EXE variable%%%"
585
586# Global variables.
587# $mode is unset
588nonopt=
589execute_dlfiles=
590preserve_args=
591lo2o="s/\\.lo\$/.${objext}/"
592o2lo="s/\\.${objext}\$/.lo/"
593extracted_archives=
594extracted_serial=0
595
596opt_dry_run=false
597opt_duplicate_deps=false
598opt_silent=false
599opt_debug=:
600
601# If this variable is set in any of the actions, the command in it
602# will be execed at the end.  This prevents here-documents from being
603# left over by shells.
604exec_cmd=
605
606# func_fatal_configuration arg...
607# Echo program name prefixed message to standard error, followed by
608# a configuration failure hint, and exit.
609func_fatal_configuration ()
610{
611    func_error ${1+"$@"}
612    func_error "See the $PACKAGE documentation for more information."
613    func_fatal_error "Fatal configuration error."
614}
615
616
617# func_config
618# Display the configuration for all the tags in this script.
619func_config ()
620{
621    re_begincf='^# ### BEGIN LIBTOOL'
622    re_endcf='^# ### END LIBTOOL'
623
624    # Default configuration.
625    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
626
627    # Now print the configurations for the tags.
628    for tagname in $taglist; do
629      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
630    done
631
632    exit $?
633}
634
635# func_features
636# Display the features supported by this script.
637func_features ()
638{
639    $ECHO "host: $host"
640    if test "$build_libtool_libs" = yes; then
641      $ECHO "enable shared libraries"
642    else
643      $ECHO "disable shared libraries"
644    fi
645    if test "$build_old_libs" = yes; then
646      $ECHO "enable static libraries"
647    else
648      $ECHO "disable static libraries"
649    fi
650
651    exit $?
652}
653
654# func_enable_tag tagname
655# Verify that TAGNAME is valid, and either flag an error and exit, or
656# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
657# variable here.
658func_enable_tag ()
659{
660  # Global variable:
661  tagname="$1"
662
663  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
664  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
665  sed_extractcf="/$re_begincf/,/$re_endcf/p"
666
667  # Validate tagname.
668  case $tagname in
669    *[!-_A-Za-z0-9,/]*)
670      func_fatal_error "invalid tag name: $tagname"
671      ;;
672  esac
673
674  # Don't test for the "default" C tag, as we know it's
675  # there but not specially marked.
676  case $tagname in
677    CC) ;;
678    *)
679      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
680	taglist="$taglist $tagname"
681
682	# Evaluate the configuration.  Be careful to quote the path
683	# and the sed script, to avoid splitting on whitespace, but
684	# also don't use non-portable quotes within backquotes within
685	# quotes we have to do it in 2 steps:
686	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
687	eval "$extractedcf"
688      else
689	func_error "ignoring unknown tag $tagname"
690      fi
691      ;;
692  esac
693}
694
695# Parse options once, thoroughly.  This comes as soon as possible in
696# the script to make things like `libtool --version' happen quickly.
697{
698
699  # Shorthand for --mode=foo, only valid as the first argument
700  case $1 in
701  clean|clea|cle|cl)
702    shift; set dummy --mode clean ${1+"$@"}; shift
703    ;;
704  compile|compil|compi|comp|com|co|c)
705    shift; set dummy --mode compile ${1+"$@"}; shift
706    ;;
707  execute|execut|execu|exec|exe|ex|e)
708    shift; set dummy --mode execute ${1+"$@"}; shift
709    ;;
710  finish|finis|fini|fin|fi|f)
711    shift; set dummy --mode finish ${1+"$@"}; shift
712    ;;
713  install|instal|insta|inst|ins|in|i)
714    shift; set dummy --mode install ${1+"$@"}; shift
715    ;;
716  link|lin|li|l)
717    shift; set dummy --mode link ${1+"$@"}; shift
718    ;;
719  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
720    shift; set dummy --mode uninstall ${1+"$@"}; shift
721    ;;
722  esac
723
724  # Parse non-mode specific arguments:
725  while test "$#" -gt 0; do
726    opt="$1"
727    shift
728
729    case $opt in
730      --config)		func_config					;;
731
732      --debug)		preserve_args="$preserve_args $opt"
733			func_echo "enabling shell trace mode"
734			opt_debug='set -x'
735			$opt_debug
736			;;
737
738      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
739			execute_dlfiles="$execute_dlfiles $1"
740			shift
741			;;
742
743      --dry-run | -n)	opt_dry_run=:					;;
744      --features)       func_features					;;
745      --finish)		mode="finish"					;;
746
747      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
748			case $1 in
749			  # Valid mode arguments:
750			  clean)	;;
751			  compile)	;;
752			  execute)	;;
753			  finish)	;;
754			  install)	;;
755			  link)		;;
756			  relink)	;;
757			  uninstall)	;;
758
759			  # Catch anything else as an error
760			  *) func_error "invalid argument for $opt"
761			     exit_cmd=exit
762			     break
763			     ;;
764		        esac
765
766			mode="$1"
767			shift
768			;;
769
770      --preserve-dup-deps)
771			opt_duplicate_deps=:				;;
772
773      --quiet|--silent)	preserve_args="$preserve_args $opt"
774			opt_silent=:
775			;;
776
777      --verbose| -v)	preserve_args="$preserve_args $opt"
778			opt_silent=false
779			;;
780
781      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
782			preserve_args="$preserve_args $opt $1"
783			func_enable_tag "$1"	# tagname is set here
784			shift
785			;;
786
787      # Separate optargs to long options:
788      -dlopen=*|--mode=*|--tag=*)
789			func_opt_split "$opt"
790			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
791			shift
792			;;
793
794      -\?|-h)		func_usage					;;
795      --help)		opt_help=:					;;
796      --version)	func_version					;;
797
798      -*)		func_fatal_help "unrecognized option \`$opt'"	;;
799
800      *)		nonopt="$opt"
801			break
802			;;
803    esac
804  done
805
806
807  case $host in
808    *cygwin* | *mingw* | *pw32* | *cegcc*)
809      # don't eliminate duplications in $postdeps and $predeps
810      opt_duplicate_compiler_generated_deps=:
811      ;;
812    *)
813      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
814      ;;
815  esac
816
817  # Having warned about all mis-specified options, bail out if
818  # anything was wrong.
819  $exit_cmd $EXIT_FAILURE
820}
821
822# func_check_version_match
823# Ensure that we are using m4 macros, and libtool script from the same
824# release of libtool.
825func_check_version_match ()
826{
827  if test "$package_revision" != "$macro_revision"; then
828    if test "$VERSION" != "$macro_version"; then
829      if test -z "$macro_version"; then
830        cat >&2 <<_LT_EOF
831$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
832$progname: definition of this LT_INIT comes from an older release.
833$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
834$progname: and run autoconf again.
835_LT_EOF
836      else
837        cat >&2 <<_LT_EOF
838$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
839$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
840$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
841$progname: and run autoconf again.
842_LT_EOF
843      fi
844    else
845      cat >&2 <<_LT_EOF
846$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
847$progname: but the definition of this LT_INIT comes from revision $macro_revision.
848$progname: You should recreate aclocal.m4 with macros from revision $package_revision
849$progname: of $PACKAGE $VERSION and run autoconf again.
850_LT_EOF
851    fi
852
853    exit $EXIT_MISMATCH
854  fi
855}
856
857
858## ----------- ##
859##    Main.    ##
860## ----------- ##
861
862$opt_help || {
863  # Sanity checks first:
864  func_check_version_match
865
866  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
867    func_fatal_configuration "not configured to build any kind of library"
868  fi
869
870  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
871
872
873  # Darwin sucks
874  eval std_shrext=\"$shrext_cmds\"
875
876
877  # Only execute mode is allowed to have -dlopen flags.
878  if test -n "$execute_dlfiles" && test "$mode" != execute; then
879    func_error "unrecognized option \`-dlopen'"
880    $ECHO "$help" 1>&2
881    exit $EXIT_FAILURE
882  fi
883
884  # Change the help message to a mode-specific one.
885  generic_help="$help"
886  help="Try \`$progname --help --mode=$mode' for more information."
887}
888
889
890# func_lalib_p file
891# True iff FILE is a libtool `.la' library or `.lo' object file.
892# This function is only a basic sanity check; it will hardly flush out
893# determined imposters.
894func_lalib_p ()
895{
896    test -f "$1" &&
897      $SED -e 4q "$1" 2>/dev/null \
898        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
899}
900
901# func_lalib_unsafe_p file
902# True iff FILE is a libtool `.la' library or `.lo' object file.
903# This function implements the same check as func_lalib_p without
904# resorting to external programs.  To this end, it redirects stdin and
905# closes it afterwards, without saving the original file descriptor.
906# As a safety measure, use it only where a negative result would be
907# fatal anyway.  Works if `file' does not exist.
908func_lalib_unsafe_p ()
909{
910    lalib_p=no
911    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
912	for lalib_p_l in 1 2 3 4
913	do
914	    read lalib_p_line
915	    case "$lalib_p_line" in
916		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
917	    esac
918	done
919	exec 0<&5 5<&-
920    fi
921    test "$lalib_p" = yes
922}
923
924# func_ltwrapper_script_p file
925# True iff FILE is a libtool wrapper script
926# This function is only a basic sanity check; it will hardly flush out
927# determined imposters.
928func_ltwrapper_script_p ()
929{
930    func_lalib_p "$1"
931}
932
933# func_ltwrapper_executable_p file
934# True iff FILE is a libtool wrapper executable
935# This function is only a basic sanity check; it will hardly flush out
936# determined imposters.
937func_ltwrapper_executable_p ()
938{
939    func_ltwrapper_exec_suffix=
940    case $1 in
941    *.exe) ;;
942    *) func_ltwrapper_exec_suffix=.exe ;;
943    esac
944    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
945}
946
947# func_ltwrapper_scriptname file
948# Assumes file is an ltwrapper_executable
949# uses $file to determine the appropriate filename for a
950# temporary ltwrapper_script.
951func_ltwrapper_scriptname ()
952{
953    func_ltwrapper_scriptname_result=""
954    if func_ltwrapper_executable_p "$1"; then
955	func_dirname_and_basename "$1" "" "."
956	func_stripname '' '.exe' "$func_basename_result"
957	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
958    fi
959}
960
961# func_ltwrapper_p file
962# True iff FILE is a libtool wrapper script or wrapper executable
963# This function is only a basic sanity check; it will hardly flush out
964# determined imposters.
965func_ltwrapper_p ()
966{
967    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
968}
969
970
971# func_execute_cmds commands fail_cmd
972# Execute tilde-delimited COMMANDS.
973# If FAIL_CMD is given, eval that upon failure.
974# FAIL_CMD may read-access the current command in variable CMD!
975func_execute_cmds ()
976{
977    $opt_debug
978    save_ifs=$IFS; IFS='~'
979    for cmd in $1; do
980      IFS=$save_ifs
981      eval cmd=\"$cmd\"
982      func_show_eval "$cmd" "${2-:}"
983    done
984    IFS=$save_ifs
985}
986
987
988# func_source file
989# Source FILE, adding directory component if necessary.
990# Note that it is not necessary on cygwin/mingw to append a dot to
991# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
992# behavior happens only for exec(3), not for open(2)!  Also, sourcing
993# `FILE.' does not work on cygwin managed mounts.
994func_source ()
995{
996    $opt_debug
997    case $1 in
998    */* | *\\*)	. "$1" ;;
999    *)		. "./$1" ;;
1000    esac
1001}
1002
1003
1004# func_infer_tag arg
1005# Infer tagged configuration to use if any are available and
1006# if one wasn't chosen via the "--tag" command line option.
1007# Only attempt this if the compiler in the base compile
1008# command doesn't match the default compiler.
1009# arg is usually of the form 'gcc ...'
1010func_infer_tag ()
1011{
1012    $opt_debug
1013
1014    # FreeBSD-specific: where we install compilers with non-standard names
1015    tag_compilers_CC="*cc cc* *gcc gcc*"
1016    tag_compilers_CXX="*c++ c++* *g++ g++*"
1017    base_compiler=`set -- "$@"; echo $1`
1018
1019    # If $tagname isn't set, then try to infer if the default "CC" tag applies
1020    if test -z "$tagname"; then
1021      for zp in $tag_compilers_CC; do
1022        case $base_compiler in
1023	 $zp) tagname="CC"; break;;
1024	esac
1025      done
1026    fi
1027
1028    if test -n "$available_tags" && test -z "$tagname"; then
1029      CC_quoted=
1030      for arg in $CC; do
1031        func_quote_for_eval "$arg"
1032	CC_quoted="$CC_quoted $func_quote_for_eval_result"
1033      done
1034      case $@ in
1035      # Blanks in the command may have been stripped by the calling shell,
1036      # but not from the CC environment variable when configure was run.
1037      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1038      # Blanks at the start of $base_compile will cause this to fail
1039      # if we don't check for them as well.
1040      *)
1041	for z in $available_tags; do
1042	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1043	    # Evaluate the configuration.
1044	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1045	    CC_quoted=
1046	    for arg in $CC; do
1047	      # Double-quote args containing other shell metacharacters.
1048	      func_quote_for_eval "$arg"
1049	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
1050	    done
1051	    case "$@ " in
1052	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1053	      # The compiler in the base compile command matches
1054	      # the one in the tagged configuration.
1055	      # Assume this is the tagged configuration we want.
1056	      tagname=$z
1057	      break
1058	      ;;
1059	    esac
1060
1061	    # FreeBSD-specific: try compilers based on inferred tag
1062	    if test -z "$tagname"; then
1063	      eval "tag_compilers=\$tag_compilers_${z}"
1064	      if test -n "$tag_compilers"; then
1065		for zp in $tag_compilers; do
1066		  case $base_compiler in
1067		    $zp) tagname=$z; break;;
1068		  esac
1069		done
1070		if test -n "$tagname"; then
1071		  break
1072		fi
1073	      fi
1074            fi
1075          fi
1076	done
1077	# If $tagname still isn't set, then no tagged configuration
1078	# was found and let the user know that the "--tag" command
1079	# line option must be used.
1080	if test -z "$tagname"; then
1081	  func_echo "unable to infer tagged configuration"
1082	  func_fatal_error "specify a tag with \`--tag'"
1083#	else
1084#	  func_verbose "using $tagname tagged configuration"
1085	fi
1086	;;
1087      esac
1088    fi
1089}
1090
1091
1092
1093# func_write_libtool_object output_name pic_name nonpic_name
1094# Create a libtool object file (analogous to a ".la" file),
1095# but don't create it if we're doing a dry run.
1096func_write_libtool_object ()
1097{
1098    write_libobj=${1}
1099    if test "$build_libtool_libs" = yes; then
1100      write_lobj=\'${2}\'
1101    else
1102      write_lobj=none
1103    fi
1104
1105    if test "$build_old_libs" = yes; then
1106      write_oldobj=\'${3}\'
1107    else
1108      write_oldobj=none
1109    fi
1110
1111    $opt_dry_run || {
1112      cat >${write_libobj}T <<EOF
1113# $write_libobj - a libtool object file
1114# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1115#
1116# Please DO NOT delete this file!
1117# It is necessary for linking the library.
1118
1119# Name of the PIC object.
1120pic_object=$write_lobj
1121
1122# Name of the non-PIC object
1123non_pic_object=$write_oldobj
1124
1125EOF
1126      $MV "${write_libobj}T" "${write_libobj}"
1127    }
1128}
1129
1130# func_mode_compile arg...
1131func_mode_compile ()
1132{
1133    $opt_debug
1134    # Get the compilation command and the source file.
1135    base_compile=
1136    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1137    suppress_opt=yes
1138    suppress_output=
1139    arg_mode=normal
1140    libobj=
1141    later=
1142    pie_flag=
1143
1144    for arg
1145    do
1146      case $arg_mode in
1147      arg  )
1148	# do not "continue".  Instead, add this to base_compile
1149	lastarg="$arg"
1150	arg_mode=normal
1151	;;
1152
1153      target )
1154	libobj="$arg"
1155	arg_mode=normal
1156	continue
1157	;;
1158
1159      normal )
1160	# Accept any command-line options.
1161	case $arg in
1162	-o)
1163	  test -n "$libobj" && \
1164	    func_fatal_error "you cannot specify \`-o' more than once"
1165	  arg_mode=target
1166	  continue
1167	  ;;
1168
1169	-pie | -fpie | -fPIE)
1170          pie_flag="$pie_flag $arg"
1171	  continue
1172	  ;;
1173
1174	-shared | -static | -prefer-pic | -prefer-non-pic)
1175	  later="$later $arg"
1176	  continue
1177	  ;;
1178
1179	-no-suppress)
1180	  suppress_opt=no
1181	  continue
1182	  ;;
1183
1184	-Xcompiler)
1185	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
1186	  continue      #  The current "srcfile" will either be retained or
1187	  ;;            #  replaced later.  I would guess that would be a bug.
1188
1189	-Wc,*)
1190	  func_stripname '-Wc,' '' "$arg"
1191	  args=$func_stripname_result
1192	  lastarg=
1193	  save_ifs="$IFS"; IFS=','
1194	  for arg in $args; do
1195	    IFS="$save_ifs"
1196	    func_quote_for_eval "$arg"
1197	    lastarg="$lastarg $func_quote_for_eval_result"
1198	  done
1199	  IFS="$save_ifs"
1200	  func_stripname ' ' '' "$lastarg"
1201	  lastarg=$func_stripname_result
1202
1203	  # Add the arguments to base_compile.
1204	  base_compile="$base_compile $lastarg"
1205	  continue
1206	  ;;
1207
1208	*)
1209	  # Accept the current argument as the source file.
1210	  # The previous "srcfile" becomes the current argument.
1211	  #
1212	  lastarg="$srcfile"
1213	  srcfile="$arg"
1214	  ;;
1215	esac  #  case $arg
1216	;;
1217      esac    #  case $arg_mode
1218
1219      # Aesthetically quote the previous argument.
1220      func_quote_for_eval "$lastarg"
1221      base_compile="$base_compile $func_quote_for_eval_result"
1222    done # for arg
1223
1224    case $arg_mode in
1225    arg)
1226      func_fatal_error "you must specify an argument for -Xcompile"
1227      ;;
1228    target)
1229      func_fatal_error "you must specify a target with \`-o'"
1230      ;;
1231    *)
1232      # Get the name of the library object.
1233      test -z "$libobj" && {
1234	func_basename "$srcfile"
1235	libobj="$func_basename_result"
1236      }
1237      ;;
1238    esac
1239
1240    # Recognize several different file suffixes.
1241    # If the user specifies -o file.o, it is replaced with file.lo
1242    case $libobj in
1243    *.[cCFSifmso] | \
1244    *.ada | *.adb | *.ads | *.asm | \
1245    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1246    *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1247      func_xform "$libobj"
1248      libobj=$func_xform_result
1249      ;;
1250    esac
1251
1252    case $libobj in
1253    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1254    *)
1255      func_fatal_error "cannot determine name of library object from \`$libobj'"
1256      ;;
1257    esac
1258
1259    func_infer_tag $base_compile
1260
1261    for arg in $later; do
1262      case $arg in
1263      -shared)
1264	test "$build_libtool_libs" != yes && \
1265	  func_fatal_configuration "can not build a shared library"
1266	build_old_libs=no
1267	continue
1268	;;
1269
1270      -static)
1271	build_libtool_libs=no
1272	build_old_libs=yes
1273	continue
1274	;;
1275
1276      -prefer-pic)
1277	pic_mode=yes
1278	continue
1279	;;
1280
1281      -prefer-non-pic)
1282	pic_mode=no
1283	continue
1284	;;
1285      esac
1286    done
1287
1288    func_quote_for_eval "$libobj"
1289    test "X$libobj" != "X$func_quote_for_eval_result" \
1290      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
1291      && func_warning "libobj name \`$libobj' may not contain shell special characters."
1292    func_dirname_and_basename "$obj" "/" ""
1293    objname="$func_basename_result"
1294    xdir="$func_dirname_result"
1295    lobj=${xdir}$objdir/$objname
1296
1297    test -z "$base_compile" && \
1298      func_fatal_help "you must specify a compilation command"
1299
1300    # Delete any leftover library objects.
1301    if test "$build_old_libs" = yes; then
1302      removelist="$obj $lobj $libobj ${libobj}T"
1303    else
1304      removelist="$lobj $libobj ${libobj}T"
1305    fi
1306
1307    # On Cygwin there's no "real" PIC flag so we must build both object types
1308    case $host_os in
1309    cygwin* | mingw* | pw32* | os2* | cegcc*)
1310      pic_mode=default
1311      ;;
1312    esac
1313    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1314      # non-PIC code in shared libraries is not supported
1315      pic_mode=default
1316    fi
1317
1318    # Calculate the filename of the output object if compiler does
1319    # not support -o with -c
1320    if test "$compiler_c_o" = no; then
1321      output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1322      lockfile="$output_obj.lock"
1323    else
1324      output_obj=
1325      need_locks=no
1326      lockfile=
1327    fi
1328
1329    # Lock this critical section if it is needed
1330    # We use this script file to make the link, it avoids creating a new file
1331    if test "$need_locks" = yes; then
1332      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1333	func_echo "Waiting for $lockfile to be removed"
1334	sleep 2
1335      done
1336    elif test "$need_locks" = warn; then
1337      if test -f "$lockfile"; then
1338	$ECHO "\
1339*** ERROR, $lockfile exists and contains:
1340`cat $lockfile 2>/dev/null`
1341
1342This indicates that another process is trying to use the same
1343temporary object file, and libtool could not work around it because
1344your compiler does not support \`-c' and \`-o' together.  If you
1345repeat this compilation, it may succeed, by chance, but you had better
1346avoid parallel builds (make -j) in this platform, or get a better
1347compiler."
1348
1349	$opt_dry_run || $RM $removelist
1350	exit $EXIT_FAILURE
1351      fi
1352      removelist="$removelist $output_obj"
1353      $ECHO "$srcfile" > "$lockfile"
1354    fi
1355
1356    $opt_dry_run || $RM $removelist
1357    removelist="$removelist $lockfile"
1358    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1359
1360    if test -n "$fix_srcfile_path"; then
1361      eval srcfile=\"$fix_srcfile_path\"
1362    fi
1363    func_quote_for_eval "$srcfile"
1364    qsrcfile=$func_quote_for_eval_result
1365
1366    # Only build a PIC object if we are building libtool libraries.
1367    if test "$build_libtool_libs" = yes; then
1368      # Without this assignment, base_compile gets emptied.
1369      fbsd_hideous_sh_bug=$base_compile
1370
1371      if test "$pic_mode" != no; then
1372	command="$base_compile $qsrcfile $pic_flag"
1373      else
1374	# Don't build PIC code
1375	command="$base_compile $qsrcfile"
1376      fi
1377
1378      func_mkdir_p "$xdir$objdir"
1379
1380      if test -z "$output_obj"; then
1381	# Place PIC objects in $objdir
1382	command="$command -o $lobj"
1383      fi
1384
1385      func_show_eval_locale "$command"	\
1386          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1387
1388      if test "$need_locks" = warn &&
1389	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1390	$ECHO "\
1391*** ERROR, $lockfile contains:
1392`cat $lockfile 2>/dev/null`
1393
1394but it should contain:
1395$srcfile
1396
1397This indicates that another process is trying to use the same
1398temporary object file, and libtool could not work around it because
1399your compiler does not support \`-c' and \`-o' together.  If you
1400repeat this compilation, it may succeed, by chance, but you had better
1401avoid parallel builds (make -j) in this platform, or get a better
1402compiler."
1403
1404	$opt_dry_run || $RM $removelist
1405	exit $EXIT_FAILURE
1406      fi
1407
1408      # Just move the object if needed, then go on to compile the next one
1409      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1410	func_show_eval '$MV "$output_obj" "$lobj"' \
1411	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1412      fi
1413
1414      # Allow error messages only from the first compilation.
1415      if test "$suppress_opt" = yes; then
1416	suppress_output=' >/dev/null 2>&1'
1417      fi
1418    fi
1419
1420    # Only build a position-dependent object if we build old libraries.
1421    if test "$build_old_libs" = yes; then
1422      if test "$pic_mode" != yes; then
1423	# Don't build PIC code
1424	command="$base_compile $qsrcfile$pie_flag"
1425      else
1426	command="$base_compile $qsrcfile $pic_flag"
1427      fi
1428      if test "$compiler_c_o" = yes; then
1429	command="$command -o $obj"
1430      fi
1431
1432      # Suppress compiler output if we already did a PIC compilation.
1433      command="$command$suppress_output"
1434      func_show_eval_locale "$command" \
1435        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1436
1437      if test "$need_locks" = warn &&
1438	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1439	$ECHO "\
1440*** ERROR, $lockfile contains:
1441`cat $lockfile 2>/dev/null`
1442
1443but it should contain:
1444$srcfile
1445
1446This indicates that another process is trying to use the same
1447temporary object file, and libtool could not work around it because
1448your compiler does not support \`-c' and \`-o' together.  If you
1449repeat this compilation, it may succeed, by chance, but you had better
1450avoid parallel builds (make -j) in this platform, or get a better
1451compiler."
1452
1453	$opt_dry_run || $RM $removelist
1454	exit $EXIT_FAILURE
1455      fi
1456
1457      # Just move the object if needed
1458      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1459	func_show_eval '$MV "$output_obj" "$obj"' \
1460	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1461      fi
1462    fi
1463
1464    $opt_dry_run || {
1465      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1466
1467      # Unlock the critical section if it was locked
1468      if test "$need_locks" != no; then
1469	removelist=$lockfile
1470        $RM "$lockfile"
1471      fi
1472    }
1473
1474    exit $EXIT_SUCCESS
1475}
1476
1477$opt_help || {
1478test "$mode" = compile && func_mode_compile ${1+"$@"}
1479}
1480
1481func_mode_help ()
1482{
1483    # We need to display help for each of the modes.
1484    case $mode in
1485      "")
1486        # Generic help is extracted from the usage comments
1487        # at the start of this file.
1488        func_help
1489        ;;
1490
1491      clean)
1492        $ECHO \
1493"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1494
1495Remove files from the build directory.
1496
1497RM is the name of the program to use to delete files associated with each FILE
1498(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1499to RM.
1500
1501If FILE is a libtool library, object or program, all the files associated
1502with it are deleted. Otherwise, only FILE itself is deleted using RM."
1503        ;;
1504
1505      compile)
1506      $ECHO \
1507"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1508
1509Compile a source file into a libtool library object.
1510
1511This mode accepts the following additional options:
1512
1513  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
1514  -no-suppress      do not suppress compiler output for multiple passes
1515  -prefer-pic       try to building PIC objects only
1516  -prefer-non-pic   try to building non-PIC objects only
1517  -shared           do not build a \`.o' file suitable for static linking
1518  -static           only build a \`.o' file suitable for static linking
1519
1520COMPILE-COMMAND is a command to be used in creating a \`standard' object file
1521from the given SOURCEFILE.
1522
1523The output file name is determined by removing the directory component from
1524SOURCEFILE, then substituting the C source code suffix \`.c' with the
1525library object suffix, \`.lo'."
1526        ;;
1527
1528      execute)
1529        $ECHO \
1530"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1531
1532Automatically set library path, then run a program.
1533
1534This mode accepts the following additional options:
1535
1536  -dlopen FILE      add the directory containing FILE to the library path
1537
1538This mode sets the library path environment variable according to \`-dlopen'
1539flags.
1540
1541If any of the ARGS are libtool executable wrappers, then they are translated
1542into their corresponding uninstalled binary, and any of their required library
1543directories are added to the library path.
1544
1545Then, COMMAND is executed, with ARGS as arguments."
1546        ;;
1547
1548      finish)
1549        $ECHO \
1550"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1551
1552Complete the installation of libtool libraries.
1553
1554Each LIBDIR is a directory that contains libtool libraries.
1555
1556The commands that this mode executes may require superuser privileges.  Use
1557the \`--dry-run' option if you just want to see what would be executed."
1558        ;;
1559
1560      install)
1561        $ECHO \
1562"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1563
1564Install executables or libraries.
1565
1566INSTALL-COMMAND is the installation command.  The first component should be
1567either the \`install' or \`cp' program.
1568
1569The following components of INSTALL-COMMAND are treated specially:
1570
1571  -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
1572
1573The rest of the components are interpreted as arguments to that command (only
1574BSD-compatible install options are recognized)."
1575        ;;
1576
1577      link)
1578        $ECHO \
1579"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1580
1581Link object files or libraries together to form another library, or to
1582create an executable program.
1583
1584LINK-COMMAND is a command using the C compiler that you would use to create
1585a program from several object files.
1586
1587The following components of LINK-COMMAND are treated specially:
1588
1589  -all-static       do not do any dynamic linking at all
1590  -avoid-version    do not add a version suffix if possible
1591  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
1592  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
1593  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1594  -export-symbols SYMFILE
1595                    try to export only the symbols listed in SYMFILE
1596  -export-symbols-regex REGEX
1597                    try to export only the symbols matching REGEX
1598  -LLIBDIR          search LIBDIR for required installed libraries
1599  -lNAME            OUTPUT-FILE requires the installed library libNAME
1600  -module           build a library that can dlopened
1601  -no-fast-install  disable the fast-install mode
1602  -no-install       link a not-installable executable
1603  -no-undefined     declare that a library does not refer to external symbols
1604  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
1605  -objectlist FILE  Use a list of object files found in FILE to specify objects
1606  -precious-files-regex REGEX
1607                    don't remove output files matching REGEX
1608  -release RELEASE  specify package release information
1609  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
1610  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
1611  -shared           only do dynamic linking of libtool libraries
1612  -shrext SUFFIX    override the standard shared library file extension
1613  -static           do not do any dynamic linking of uninstalled libtool libraries
1614  -static-libtool-libs
1615                    do not do any dynamic linking of libtool libraries
1616  -version-info CURRENT[:REVISION[:AGE]]
1617                    specify library version info [each variable defaults to 0]
1618  -weak LIBNAME     declare that the target provides the LIBNAME interface
1619
1620All other options (arguments beginning with \`-') are ignored.
1621
1622Every other argument is treated as a filename.  Files ending in \`.la' are
1623treated as uninstalled libtool libraries, other files are standard or library
1624object files.
1625
1626If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1627only library objects (\`.lo' files) may be specified, and \`-rpath' is
1628required, except when creating a convenience library.
1629
1630If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1631using \`ar' and \`ranlib', or on Windows using \`lib'.
1632
1633If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1634is created, otherwise an executable program is created."
1635        ;;
1636
1637      uninstall)
1638        $ECHO \
1639"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1640
1641Remove libraries from an installation directory.
1642
1643RM is the name of the program to use to delete files associated with each FILE
1644(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1645to RM.
1646
1647If FILE is a libtool library, all the files associated with it are deleted.
1648Otherwise, only FILE itself is deleted using RM."
1649        ;;
1650
1651      *)
1652        func_fatal_help "invalid operation mode \`$mode'"
1653        ;;
1654    esac
1655
1656    $ECHO
1657    $ECHO "Try \`$progname --help' for more information about other modes."
1658
1659    exit $?
1660}
1661
1662  # Now that we've collected a possible --mode arg, show help if necessary
1663  $opt_help && func_mode_help
1664
1665
1666# func_mode_execute arg...
1667func_mode_execute ()
1668{
1669    $opt_debug
1670    # The first argument is the command name.
1671    cmd="$nonopt"
1672    test -z "$cmd" && \
1673      func_fatal_help "you must specify a COMMAND"
1674
1675    # Handle -dlopen flags immediately.
1676    for file in $execute_dlfiles; do
1677      test -f "$file" \
1678	|| func_fatal_help "\`$file' is not a file"
1679
1680      dir=
1681      case $file in
1682      *.la)
1683	# Check to see that this really is a libtool archive.
1684	func_lalib_unsafe_p "$file" \
1685	  || func_fatal_help "\`$lib' is not a valid libtool archive"
1686
1687	# Read the libtool library.
1688	dlname=
1689	library_names=
1690	func_source "$file"
1691
1692	# Skip this library if it cannot be dlopened.
1693	if test -z "$dlname"; then
1694	  # Warn if it was a shared library.
1695	  test -n "$library_names" && \
1696	    func_warning "\`$file' was not linked with \`-export-dynamic'"
1697	  continue
1698	fi
1699
1700	func_dirname "$file" "" "."
1701	dir="$func_dirname_result"
1702
1703	if test -f "$dir/$objdir/$dlname"; then
1704	  dir="$dir/$objdir"
1705	else
1706	  if test ! -f "$dir/$dlname"; then
1707	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1708	  fi
1709	fi
1710	;;
1711
1712      *.lo)
1713	# Just add the directory containing the .lo file.
1714	func_dirname "$file" "" "."
1715	dir="$func_dirname_result"
1716	;;
1717
1718      *)
1719	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1720	continue
1721	;;
1722      esac
1723
1724      # Get the absolute pathname.
1725      absdir=`cd "$dir" && pwd`
1726      test -n "$absdir" && dir="$absdir"
1727
1728      # Now add the directory to shlibpath_var.
1729      if eval "test -z \"\$$shlibpath_var\""; then
1730	eval "$shlibpath_var=\"\$dir\""
1731      else
1732	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1733      fi
1734    done
1735
1736    # This variable tells wrapper scripts just to set shlibpath_var
1737    # rather than running their programs.
1738    libtool_execute_magic="$magic"
1739
1740    # Check if any of the arguments is a wrapper script.
1741    args=
1742    for file
1743    do
1744      case $file in
1745      -*) ;;
1746      *)
1747	# Do a test to see if this is really a libtool program.
1748	if func_ltwrapper_script_p "$file"; then
1749	  func_source "$file"
1750	  # Transform arg to wrapped name.
1751	  file="$progdir/$program"
1752	elif func_ltwrapper_executable_p "$file"; then
1753	  func_ltwrapper_scriptname "$file"
1754	  func_source "$func_ltwrapper_scriptname_result"
1755	  # Transform arg to wrapped name.
1756	  file="$progdir/$program"
1757	fi
1758	;;
1759      esac
1760      # Quote arguments (to preserve shell metacharacters).
1761      func_quote_for_eval "$file"
1762      args="$args $func_quote_for_eval_result"
1763    done
1764
1765    if test "X$opt_dry_run" = Xfalse; then
1766      if test -n "$shlibpath_var"; then
1767	# Export the shlibpath_var.
1768	eval "export $shlibpath_var"
1769      fi
1770
1771      # Restore saved environment variables
1772      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1773      do
1774	eval "if test \"\${save_$lt_var+set}\" = set; then
1775                $lt_var=\$save_$lt_var; export $lt_var
1776	      else
1777		$lt_unset $lt_var
1778	      fi"
1779      done
1780
1781      # Now prepare to actually exec the command.
1782      exec_cmd="\$cmd$args"
1783    else
1784      # Display what would be done.
1785      if test -n "$shlibpath_var"; then
1786	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1787	$ECHO "export $shlibpath_var"
1788      fi
1789      $ECHO "$cmd$args"
1790      exit $EXIT_SUCCESS
1791    fi
1792}
1793
1794test "$mode" = execute && func_mode_execute ${1+"$@"}
1795
1796
1797# func_mode_finish arg...
1798func_mode_finish ()
1799{
1800    $opt_debug
1801    libdirs="$nonopt"
1802    admincmds=
1803
1804    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1805      for dir
1806      do
1807	libdirs="$libdirs $dir"
1808      done
1809
1810      for libdir in $libdirs; do
1811	if test -n "$finish_cmds"; then
1812	  # Do each command in the finish commands.
1813	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1814'"$cmd"'"'
1815	fi
1816	if test -n "$finish_eval"; then
1817	  # Do the single finish_eval.
1818	  eval cmds=\"$finish_eval\"
1819	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1820       $cmds"
1821	fi
1822      done
1823    fi
1824
1825    # Exit here if they wanted silent mode.
1826    $opt_silent && exit $EXIT_SUCCESS
1827
1828    $ECHO "X----------------------------------------------------------------------" | $Xsed
1829    $ECHO "Libraries have been installed in:"
1830    for libdir in $libdirs; do
1831      $ECHO "   $libdir"
1832    done
1833    $ECHO
1834    $ECHO "If you ever happen to want to link against installed libraries"
1835    $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1836    $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1837    $ECHO "flag during linking and do at least one of the following:"
1838    if test -n "$shlibpath_var"; then
1839      $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
1840      $ECHO "     during execution"
1841    fi
1842    if test -n "$runpath_var"; then
1843      $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
1844      $ECHO "     during linking"
1845    fi
1846    if test -n "$hardcode_libdir_flag_spec"; then
1847      libdir=LIBDIR
1848      eval flag=\"$hardcode_libdir_flag_spec\"
1849
1850      $ECHO "   - use the \`$flag' linker flag"
1851    fi
1852    if test -n "$admincmds"; then
1853      $ECHO "   - have your system administrator run these commands:$admincmds"
1854    fi
1855    if test -f /etc/ld.so.conf; then
1856      $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1857    fi
1858    $ECHO
1859
1860    $ECHO "See any operating system documentation about shared libraries for"
1861    case $host in
1862      solaris2.[6789]|solaris2.1[0-9])
1863        $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1864	$ECHO "pages."
1865	;;
1866      *)
1867        $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1868        ;;
1869    esac
1870    $ECHO "X----------------------------------------------------------------------" | $Xsed
1871    exit $EXIT_SUCCESS
1872}
1873
1874test "$mode" = finish && func_mode_finish ${1+"$@"}
1875
1876
1877# func_mode_install arg...
1878func_mode_install ()
1879{
1880    $opt_debug
1881    # There may be an optional sh(1) argument at the beginning of
1882    # install_prog (especially on Windows NT).
1883    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1884       # Allow the use of GNU shtool's install command.
1885       $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1886      # Aesthetically quote it.
1887      func_quote_for_eval "$nonopt"
1888      install_prog="$func_quote_for_eval_result "
1889      arg=$1
1890      shift
1891    else
1892      install_prog=
1893      arg=$nonopt
1894    fi
1895
1896    # The real first argument should be the name of the installation program.
1897    # Aesthetically quote it.
1898    func_quote_for_eval "$arg"
1899    install_prog="$install_prog$func_quote_for_eval_result"
1900
1901    # We need to accept at least all the BSD install flags.
1902    dest=
1903    files=
1904    opts=
1905    prev=
1906    install_type=
1907    isdir=no
1908    stripme=
1909    for arg
1910    do
1911      if test -n "$dest"; then
1912	files="$files $dest"
1913	dest=$arg
1914	continue
1915      fi
1916
1917      case $arg in
1918      -d) isdir=yes ;;
1919      -f)
1920	case " $install_prog " in
1921	*[\\\ /]cp\ *) ;;
1922	*) prev=$arg ;;
1923	esac
1924	;;
1925      -g | -m | -o)
1926	prev=$arg
1927	;;
1928      -s)
1929	stripme=" -s"
1930	continue
1931	;;
1932      -*)
1933	;;
1934      *)
1935	# If the previous option needed an argument, then skip it.
1936	if test -n "$prev"; then
1937	  prev=
1938	else
1939	  dest=$arg
1940	  continue
1941	fi
1942	;;
1943      esac
1944
1945      # Aesthetically quote the argument.
1946      func_quote_for_eval "$arg"
1947      install_prog="$install_prog $func_quote_for_eval_result"
1948    done
1949
1950    test -z "$install_prog" && \
1951      func_fatal_help "you must specify an install program"
1952
1953    test -n "$prev" && \
1954      func_fatal_help "the \`$prev' option requires an argument"
1955
1956    if test -z "$files"; then
1957      if test -z "$dest"; then
1958	func_fatal_help "no file or destination specified"
1959      else
1960	func_fatal_help "you must specify a destination"
1961      fi
1962    fi
1963
1964    # Strip any trailing slash from the destination.
1965    func_stripname '' '/' "$dest"
1966    dest=$func_stripname_result
1967
1968    # Check to see that the destination is a directory.
1969    test -d "$dest" && isdir=yes
1970    if test "$isdir" = yes; then
1971      destdir="$dest"
1972      destname=
1973    else
1974      func_dirname_and_basename "$dest" "" "."
1975      destdir="$func_dirname_result"
1976      destname="$func_basename_result"
1977
1978      # Not a directory, so check to see that there is only one file specified.
1979      set dummy $files; shift
1980      test "$#" -gt 1 && \
1981	func_fatal_help "\`$dest' is not a directory"
1982    fi
1983    case $destdir in
1984    [\\/]* | [A-Za-z]:[\\/]*) ;;
1985    *)
1986      for file in $files; do
1987	case $file in
1988	*.lo) ;;
1989	*)
1990	  func_fatal_help "\`$destdir' must be an absolute directory name"
1991	  ;;
1992	esac
1993      done
1994      ;;
1995    esac
1996
1997    # This variable tells wrapper scripts just to set variables rather
1998    # than running their programs.
1999    libtool_install_magic="$magic"
2000
2001    staticlibs=
2002    future_libdirs=
2003    current_libdirs=
2004    for file in $files; do
2005
2006      # Do each installation.
2007      case $file in
2008      *.$libext)
2009	# Do the static libraries later.
2010	staticlibs="$staticlibs $file"
2011	;;
2012
2013      *.la)
2014	# Check to see that this really is a libtool archive.
2015	func_lalib_unsafe_p "$file" \
2016	  || func_fatal_help "\`$file' is not a valid libtool archive"
2017
2018	library_names=
2019	old_library=
2020	relink_command=
2021	func_source "$file"
2022
2023	# Add the libdir to current_libdirs if it is the destination.
2024	if test "X$destdir" = "X$libdir"; then
2025	  case "$current_libdirs " in
2026	  *" $libdir "*) ;;
2027	  *) current_libdirs="$current_libdirs $libdir" ;;
2028	  esac
2029	else
2030	  # Note the libdir as a future libdir.
2031	  case "$future_libdirs " in
2032	  *" $libdir "*) ;;
2033	  *) future_libdirs="$future_libdirs $libdir" ;;
2034	  esac
2035	fi
2036
2037	func_dirname "$file" "/" ""
2038	dir="$func_dirname_result"
2039	dir="$dir$objdir"
2040
2041	if test -n "$relink_command"; then
2042	  # Determine the prefix the user has applied to our future dir.
2043	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2044
2045	  # Don't allow the user to place us outside of our expected
2046	  # location b/c this prevents finding dependent libraries that
2047	  # are installed to the same prefix.
2048	  # At present, this check doesn't affect windows .dll's that
2049	  # are installed into $libdir/../bin (currently, that works fine)
2050	  # but it's something to keep an eye on.
2051	  test "$inst_prefix_dir" = "$destdir" && \
2052	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2053
2054	  if test -n "$inst_prefix_dir"; then
2055	    # Stick the inst_prefix_dir data into the link command.
2056	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2057	  else
2058	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2059	  fi
2060
2061	  func_warning "relinking \`$file'"
2062	  func_show_eval "$relink_command" \
2063	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2064	fi
2065
2066	# See the names of the shared library.
2067	set dummy $library_names; shift
2068	if test -n "$1"; then
2069	  realname="$1"
2070	  shift
2071
2072	  srcname="$realname"
2073	  test -n "$relink_command" && srcname="$realname"T
2074
2075	  # Install the shared library and build the symlinks.
2076	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2077	      'exit $?'
2078	  tstripme="$stripme"
2079	  case $host_os in
2080	  cygwin* | mingw* | pw32* | cegcc*)
2081	    case $realname in
2082	    *.dll.a)
2083	      tstripme=""
2084	      ;;
2085	    esac
2086	    ;;
2087	  esac
2088	  if test -n "$tstripme" && test -n "$striplib"; then
2089	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
2090	  fi
2091
2092	  if test "$#" -gt 0; then
2093	    # Delete the old symlinks, and create new ones.
2094	    # Try `ln -sf' first, because the `ln' binary might depend on
2095	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
2096	    # so we also need to try rm && ln -s.
2097	    for linkname
2098	    do
2099	      test "$linkname" != "$realname" \
2100		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2101	    done
2102	  fi
2103
2104	  # Do each command in the postinstall commands.
2105	  lib="$destdir/$realname"
2106	  func_execute_cmds "$postinstall_cmds" 'exit $?'
2107	fi
2108
2109	# Install the pseudo-library for information purposes.
2110	func_basename "$file"
2111	name="$func_basename_result"
2112	instname="$dir/$name"i
2113	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2114
2115	# Maybe install the static library, too.
2116	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2117	;;
2118
2119      *.lo)
2120	# Install (i.e. copy) a libtool object.
2121
2122	# Figure out destination file name, if it wasn't already specified.
2123	if test -n "$destname"; then
2124	  destfile="$destdir/$destname"
2125	else
2126	  func_basename "$file"
2127	  destfile="$func_basename_result"
2128	  destfile="$destdir/$destfile"
2129	fi
2130
2131	# Deduce the name of the destination old-style object file.
2132	case $destfile in
2133	*.lo)
2134	  func_lo2o "$destfile"
2135	  staticdest=$func_lo2o_result
2136	  ;;
2137	*.$objext)
2138	  staticdest="$destfile"
2139	  destfile=
2140	  ;;
2141	*)
2142	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
2143	  ;;
2144	esac
2145
2146	# Install the libtool object if requested.
2147	test -n "$destfile" && \
2148	  func_show_eval "$install_prog $file $destfile" 'exit $?'
2149
2150	# Install the old object if enabled.
2151	if test "$build_old_libs" = yes; then
2152	  # Deduce the name of the old-style object file.
2153	  func_lo2o "$file"
2154	  staticobj=$func_lo2o_result
2155	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2156	fi
2157	exit $EXIT_SUCCESS
2158	;;
2159
2160      *)
2161	# Figure out destination file name, if it wasn't already specified.
2162	if test -n "$destname"; then
2163	  destfile="$destdir/$destname"
2164	else
2165	  func_basename "$file"
2166	  destfile="$func_basename_result"
2167	  destfile="$destdir/$destfile"
2168	fi
2169
2170	# If the file is missing, and there is a .exe on the end, strip it
2171	# because it is most likely a libtool script we actually want to
2172	# install
2173	stripped_ext=""
2174	case $file in
2175	  *.exe)
2176	    if test ! -f "$file"; then
2177	      func_stripname '' '.exe' "$file"
2178	      file=$func_stripname_result
2179	      stripped_ext=".exe"
2180	    fi
2181	    ;;
2182	esac
2183
2184	# Do a test to see if this is really a libtool program.
2185	case $host in
2186	*cygwin* | *mingw*)
2187	    if func_ltwrapper_executable_p "$file"; then
2188	      func_ltwrapper_scriptname "$file"
2189	      wrapper=$func_ltwrapper_scriptname_result
2190	    else
2191	      func_stripname '' '.exe' "$file"
2192	      wrapper=$func_stripname_result
2193	    fi
2194	    ;;
2195	*)
2196	    wrapper=$file
2197	    ;;
2198	esac
2199	if func_ltwrapper_script_p "$wrapper"; then
2200	  notinst_deplibs=
2201	  relink_command=
2202
2203	  func_source "$wrapper"
2204
2205	  # Check the variables that should have been set.
2206	  test -z "$generated_by_libtool_version" && \
2207	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2208
2209	  finalize=yes
2210	  for lib in $notinst_deplibs; do
2211	    # Check to see that each library is installed.
2212	    libdir=
2213	    if test -f "$lib"; then
2214	      func_source "$lib"
2215	    fi
2216	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2217	    if test -n "$libdir" && test ! -f "$libfile"; then
2218	      func_warning "\`$lib' has not been installed in \`$libdir'"
2219	      finalize=no
2220	    fi
2221	  done
2222
2223	  relink_command=
2224	  func_source "$wrapper"
2225
2226	  outputname=
2227	  if test "$fast_install" = no && test -n "$relink_command"; then
2228	    $opt_dry_run || {
2229	      if test "$finalize" = yes; then
2230	        tmpdir=`func_mktempdir`
2231		func_basename "$file$stripped_ext"
2232		file="$func_basename_result"
2233	        outputname="$tmpdir/$file"
2234	        # Replace the output file specification.
2235	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2236
2237	        $opt_silent || {
2238	          func_quote_for_expand "$relink_command"
2239		  eval "func_echo $func_quote_for_expand_result"
2240	        }
2241	        if eval "$relink_command"; then :
2242	          else
2243		  func_error "error: relink \`$file' with the above command before installing it"
2244		  $opt_dry_run || ${RM}r "$tmpdir"
2245		  continue
2246	        fi
2247	        file="$outputname"
2248	      else
2249	        func_warning "cannot relink \`$file'"
2250	      fi
2251	    }
2252	  else
2253	    # Install the binary that we compiled earlier.
2254	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2255	  fi
2256	fi
2257
2258	# remove .exe since cygwin /usr/bin/install will append another
2259	# one anyway
2260	case $install_prog,$host in
2261	*/usr/bin/install*,*cygwin*)
2262	  case $file:$destfile in
2263	  *.exe:*.exe)
2264	    # this is ok
2265	    ;;
2266	  *.exe:*)
2267	    destfile=$destfile.exe
2268	    ;;
2269	  *:*.exe)
2270	    func_stripname '' '.exe' "$destfile"
2271	    destfile=$func_stripname_result
2272	    ;;
2273	  esac
2274	  ;;
2275	esac
2276	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2277	$opt_dry_run || if test -n "$outputname"; then
2278	  ${RM}r "$tmpdir"
2279	fi
2280	;;
2281      esac
2282    done
2283
2284    for file in $staticlibs; do
2285      func_basename "$file"
2286      name="$func_basename_result"
2287
2288      # Set up the ranlib parameters.
2289      oldlib="$destdir/$name"
2290
2291      func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2292
2293      if test -n "$stripme" && test -n "$old_striplib"; then
2294	func_show_eval "$old_striplib $oldlib" 'exit $?'
2295      fi
2296
2297      # Do each command in the postinstall commands.
2298      func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2299    done
2300
2301    test -n "$future_libdirs" && \
2302      func_warning "remember to run \`$progname --finish$future_libdirs'"
2303
2304    if test -n "$current_libdirs"; then
2305      # Maybe just do a dry run.
2306      $opt_dry_run && current_libdirs=" -n$current_libdirs"
2307      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2308    else
2309      exit $EXIT_SUCCESS
2310    fi
2311}
2312
2313test "$mode" = install && func_mode_install ${1+"$@"}
2314
2315
2316# func_generate_dlsyms outputname originator pic_p
2317# Extract symbols from dlprefiles and create ${outputname}S.o with
2318# a dlpreopen symbol table.
2319func_generate_dlsyms ()
2320{
2321    $opt_debug
2322    my_outputname="$1"
2323    my_originator="$2"
2324    my_pic_p="${3-no}"
2325    my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2326    my_dlsyms=
2327
2328    if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2329      if test -n "$NM" && test -n "$global_symbol_pipe"; then
2330	my_dlsyms="${my_outputname}S.c"
2331      else
2332	func_error "not configured to extract global symbols from dlpreopened files"
2333      fi
2334    fi
2335
2336    if test -n "$my_dlsyms"; then
2337      case $my_dlsyms in
2338      "") ;;
2339      *.c)
2340	# Discover the nlist of each of the dlfiles.
2341	nlist="$output_objdir/${my_outputname}.nm"
2342
2343	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2344
2345	# Parse the name list into a source file.
2346	func_verbose "creating $output_objdir/$my_dlsyms"
2347
2348	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2349/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2350/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2351
2352#ifdef __cplusplus
2353extern \"C\" {
2354#endif
2355
2356/* External symbol declarations for the compiler. */\
2357"
2358
2359	if test "$dlself" = yes; then
2360	  func_verbose "generating symbol list for \`$output'"
2361
2362	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2363
2364	  # Add our own program objects to the symbol list.
2365	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2366	  for progfile in $progfiles; do
2367	    func_verbose "extracting global C symbols from \`$progfile'"
2368	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2369	  done
2370
2371	  if test -n "$exclude_expsyms"; then
2372	    $opt_dry_run || {
2373	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2374	      eval '$MV "$nlist"T "$nlist"'
2375	    }
2376	  fi
2377
2378	  if test -n "$export_symbols_regex"; then
2379	    $opt_dry_run || {
2380	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2381	      eval '$MV "$nlist"T "$nlist"'
2382	    }
2383	  fi
2384
2385	  # Prepare the list of exported symbols
2386	  if test -z "$export_symbols"; then
2387	    export_symbols="$output_objdir/$outputname.exp"
2388	    $opt_dry_run || {
2389	      $RM $export_symbols
2390	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2391	      case $host in
2392	      *cygwin* | *mingw* | *cegcc* )
2393                eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2394                eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2395	        ;;
2396	      esac
2397	    }
2398	  else
2399	    $opt_dry_run || {
2400	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2401	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2402	      eval '$MV "$nlist"T "$nlist"'
2403	      case $host in
2404	        *cygwin | *mingw* | *cegcc* )
2405	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2406	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2407	          ;;
2408	      esac
2409	    }
2410	  fi
2411	fi
2412
2413	for dlprefile in $dlprefiles; do
2414	  func_verbose "extracting global C symbols from \`$dlprefile'"
2415	  func_basename "$dlprefile"
2416	  name="$func_basename_result"
2417	  $opt_dry_run || {
2418	    eval '$ECHO ": $name " >> "$nlist"'
2419	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2420	  }
2421	done
2422
2423	$opt_dry_run || {
2424	  # Make sure we have at least an empty file.
2425	  test -f "$nlist" || : > "$nlist"
2426
2427	  if test -n "$exclude_expsyms"; then
2428	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2429	    $MV "$nlist"T "$nlist"
2430	  fi
2431
2432	  # Try sorting and uniquifying the output.
2433	  if $GREP -v "^: " < "$nlist" |
2434	      if sort -k 3 </dev/null >/dev/null 2>&1; then
2435		sort -k 3
2436	      else
2437		sort +2
2438	      fi |
2439	      uniq > "$nlist"S; then
2440	    :
2441	  else
2442	    $GREP -v "^: " < "$nlist" > "$nlist"S
2443	  fi
2444
2445	  if test -f "$nlist"S; then
2446	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2447	  else
2448	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2449	  fi
2450
2451	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2452
2453/* The mapping between symbol names and symbols.  */
2454typedef struct {
2455  const char *name;
2456  void *address;
2457} lt_dlsymlist;
2458"
2459	  case $host in
2460	  *cygwin* | *mingw* | *cegcc* )
2461	    $ECHO >> "$output_objdir/$my_dlsyms" "\
2462/* DATA imports from DLLs on WIN32 con't be const, because
2463   runtime relocations are performed -- see ld's documentation
2464   on pseudo-relocs.  */"
2465	    lt_dlsym_const= ;;
2466	  *osf5*)
2467	    echo >> "$output_objdir/$my_dlsyms" "\
2468/* This system does not cope well with relocations in const data */"
2469	    lt_dlsym_const= ;;
2470	  *)
2471	    lt_dlsym_const=const ;;
2472	  esac
2473
2474	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2475extern $lt_dlsym_const lt_dlsymlist
2476lt_${my_prefix}_LTX_preloaded_symbols[];
2477$lt_dlsym_const lt_dlsymlist
2478lt_${my_prefix}_LTX_preloaded_symbols[] =
2479{\
2480  { \"$my_originator\", (void *) 0 },"
2481
2482	  case $need_lib_prefix in
2483	  no)
2484	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2485	    ;;
2486	  *)
2487	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2488	    ;;
2489	  esac
2490	  $ECHO >> "$output_objdir/$my_dlsyms" "\
2491  {0, (void *) 0}
2492};
2493
2494/* This works around a problem in FreeBSD linker */
2495#ifdef FREEBSD_WORKAROUND
2496static const void *lt_preloaded_setup() {
2497  return lt_${my_prefix}_LTX_preloaded_symbols;
2498}
2499#endif
2500
2501#ifdef __cplusplus
2502}
2503#endif\
2504"
2505	} # !$opt_dry_run
2506
2507	pic_flag_for_symtable=
2508	case "$compile_command " in
2509	*" -static "*) ;;
2510	*)
2511	  case $host in
2512	  # compiling the symbol table file with pic_flag works around
2513	  # a FreeBSD bug that causes programs to crash when -lm is
2514	  # linked before any other PIC object.  But we must not use
2515	  # pic_flag when linking with -static.  The problem exists in
2516	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2517	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2518	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2519	  *-*-hpux*)
2520	    pic_flag_for_symtable=" $pic_flag"  ;;
2521	  *)
2522	    if test "X$my_pic_p" != Xno; then
2523	      pic_flag_for_symtable=" $pic_flag"
2524	    fi
2525	    ;;
2526	  esac
2527	  ;;
2528	esac
2529	symtab_cflags=
2530	for arg in $LTCFLAGS; do
2531	  case $arg in
2532	  -pie | -fpie | -fPIE) ;;
2533	  *) symtab_cflags="$symtab_cflags $arg" ;;
2534	  esac
2535	done
2536
2537	# Now compile the dynamic symbol file.
2538	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2539
2540	# Clean up the generated files.
2541	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2542
2543	# Transform the symbol file into the correct name.
2544	symfileobj="$output_objdir/${my_outputname}S.$objext"
2545	case $host in
2546	*cygwin* | *mingw* | *cegcc* )
2547	  if test -f "$output_objdir/$my_outputname.def"; then
2548	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2549	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2550	  else
2551	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2552	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2553	  fi
2554	  ;;
2555	*)
2556	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2557	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2558	  ;;
2559	esac
2560	;;
2561      *-*-freebsd*)
2562	# FreeBSD doesn't need this...
2563	;;
2564      *)
2565	func_fatal_error "unknown suffix for \`$my_dlsyms'"
2566	;;
2567      esac
2568    else
2569      # We keep going just in case the user didn't refer to
2570      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
2571      # really was required.
2572
2573      # Nullify the symbol file.
2574      compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2575      finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2576    fi
2577}
2578
2579# func_win32_libid arg
2580# return the library type of file 'arg'
2581#
2582# Need a lot of goo to handle *both* DLLs and import libs
2583# Has to be a shell function in order to 'eat' the argument
2584# that is supplied when $file_magic_command is called.
2585func_win32_libid ()
2586{
2587  $opt_debug
2588  win32_libid_type="unknown"
2589  win32_fileres=`file -L $1 2>/dev/null`
2590  case $win32_fileres in
2591  *ar\ archive\ import\ library*) # definitely import
2592    win32_libid_type="x86 archive import"
2593    ;;
2594  *ar\ archive*) # could be an import, or static
2595    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2596       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2597      win32_nmres=`eval $NM -f posix -A $1 |
2598	$SED -n -e '
2599	    1,100{
2600		/ I /{
2601		    s,.*,import,
2602		    p
2603		    q
2604		}
2605	    }'`
2606      case $win32_nmres in
2607      import*)  win32_libid_type="x86 archive import";;
2608      *)        win32_libid_type="x86 archive static";;
2609      esac
2610    fi
2611    ;;
2612  *DLL*)
2613    win32_libid_type="x86 DLL"
2614    ;;
2615  *executable*) # but shell scripts are "executable" too...
2616    case $win32_fileres in
2617    *MS\ Windows\ PE\ Intel*)
2618      win32_libid_type="x86 DLL"
2619      ;;
2620    esac
2621    ;;
2622  esac
2623  $ECHO "$win32_libid_type"
2624}
2625
2626
2627
2628# func_extract_an_archive dir oldlib
2629func_extract_an_archive ()
2630{
2631    $opt_debug
2632    f_ex_an_ar_dir="$1"; shift
2633    f_ex_an_ar_oldlib="$1"
2634    func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2635    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2636     :
2637    else
2638      func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2639    fi
2640}
2641
2642
2643# func_extract_archives gentop oldlib ...
2644func_extract_archives ()
2645{
2646    $opt_debug
2647    my_gentop="$1"; shift
2648    my_oldlibs=${1+"$@"}
2649    my_oldobjs=""
2650    my_xlib=""
2651    my_xabs=""
2652    my_xdir=""
2653
2654    for my_xlib in $my_oldlibs; do
2655      # Extract the objects.
2656      case $my_xlib in
2657	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2658	*) my_xabs=`pwd`"/$my_xlib" ;;
2659      esac
2660      func_basename "$my_xlib"
2661      my_xlib="$func_basename_result"
2662      my_xlib_u=$my_xlib
2663      while :; do
2664        case " $extracted_archives " in
2665	*" $my_xlib_u "*)
2666	  func_arith $extracted_serial + 1
2667	  extracted_serial=$func_arith_result
2668	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
2669	*) break ;;
2670	esac
2671      done
2672      extracted_archives="$extracted_archives $my_xlib_u"
2673      my_xdir="$my_gentop/$my_xlib_u"
2674
2675      func_mkdir_p "$my_xdir"
2676
2677      case $host in
2678      *-darwin*)
2679	func_verbose "Extracting $my_xabs"
2680	# Do not bother doing anything if just a dry run
2681	$opt_dry_run || {
2682	  darwin_orig_dir=`pwd`
2683	  cd $my_xdir || exit $?
2684	  darwin_archive=$my_xabs
2685	  darwin_curdir=`pwd`
2686	  darwin_base_archive=`basename "$darwin_archive"`
2687	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2688	  if test -n "$darwin_arches"; then
2689	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2690	    darwin_arch=
2691	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2692	    for darwin_arch in  $darwin_arches ; do
2693	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2694	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2695	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2696	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2697	      cd "$darwin_curdir"
2698	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2699	    done # $darwin_arches
2700            ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2701	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2702	    darwin_file=
2703	    darwin_files=
2704	    for darwin_file in $darwin_filelist; do
2705	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2706	      $LIPO -create -output "$darwin_file" $darwin_files
2707	    done # $darwin_filelist
2708	    $RM -rf unfat-$$
2709	    cd "$darwin_orig_dir"
2710	  else
2711	    cd $darwin_orig_dir
2712	    func_extract_an_archive "$my_xdir" "$my_xabs"
2713	  fi # $darwin_arches
2714	} # !$opt_dry_run
2715	;;
2716      *)
2717        func_extract_an_archive "$my_xdir" "$my_xabs"
2718	;;
2719      esac
2720      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2721    done
2722
2723    func_extract_archives_result="$my_oldobjs"
2724}
2725
2726
2727
2728# func_emit_wrapper_part1 [arg=no]
2729#
2730# Emit the first part of a libtool wrapper script on stdout.
2731# For more information, see the description associated with
2732# func_emit_wrapper(), below.
2733func_emit_wrapper_part1 ()
2734{
2735	func_emit_wrapper_part1_arg1=no
2736	if test -n "$1" ; then
2737	  func_emit_wrapper_part1_arg1=$1
2738	fi
2739
2740	$ECHO "\
2741#! $SHELL
2742
2743# $output - temporary wrapper script for $objdir/$outputname
2744# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2745#
2746# The $output program cannot be directly executed until all the libtool
2747# libraries that it depends on are installed.
2748#
2749# This wrapper script should never be moved out of the build directory.
2750# If it is, it will not operate correctly.
2751
2752# Sed substitution that helps us do robust quoting.  It backslashifies
2753# metacharacters that are still active within double-quoted strings.
2754Xsed='${SED} -e 1s/^X//'
2755sed_quote_subst='$sed_quote_subst'
2756
2757# Be Bourne compatible
2758if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2759  emulate sh
2760  NULLCMD=:
2761  # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2762  # is contrary to our usage.  Disable this feature.
2763  alias -g '\${1+\"\$@\"}'='\"\$@\"'
2764  setopt NO_GLOB_SUBST
2765else
2766  case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2767fi
2768BIN_SH=xpg4; export BIN_SH # for Tru64
2769DUALCASE=1; export DUALCASE # for MKS sh
2770
2771# The HP-UX ksh and POSIX shell print the target directory to stdout
2772# if CDPATH is set.
2773(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2774
2775relink_command=\"$relink_command\"
2776
2777# This environment variable determines our operation mode.
2778if test \"\$libtool_install_magic\" = \"$magic\"; then
2779  # install mode needs the following variables:
2780  generated_by_libtool_version='$macro_version'
2781  notinst_deplibs='$notinst_deplibs'
2782else
2783  # When we are sourced in execute mode, \$file and \$ECHO are already set.
2784  if test \"\$libtool_execute_magic\" != \"$magic\"; then
2785    ECHO=\"$qecho\"
2786    file=\"\$0\"
2787    # Make sure echo works.
2788    if test \"X\$1\" = X--no-reexec; then
2789      # Discard the --no-reexec flag, and continue.
2790      shift
2791    elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2792      # Yippee, \$ECHO works!
2793      :
2794    else
2795      # Restart under the correct shell, and then maybe \$ECHO will work.
2796      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2797    fi
2798  fi\
2799"
2800	$ECHO "\
2801
2802  # Find the directory that this script lives in.
2803  thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2804  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2805
2806  # Follow symbolic links until we get to the real thisdir.
2807  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2808  while test -n \"\$file\"; do
2809    destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2810
2811    # If there was a directory component, then change thisdir.
2812    if test \"x\$destdir\" != \"x\$file\"; then
2813      case \"\$destdir\" in
2814      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2815      *) thisdir=\"\$thisdir/\$destdir\" ;;
2816      esac
2817    fi
2818
2819    file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2820    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2821  done
2822"
2823}
2824# end: func_emit_wrapper_part1
2825
2826# func_emit_wrapper_part2 [arg=no]
2827#
2828# Emit the second part of a libtool wrapper script on stdout.
2829# For more information, see the description associated with
2830# func_emit_wrapper(), below.
2831func_emit_wrapper_part2 ()
2832{
2833	func_emit_wrapper_part2_arg1=no
2834	if test -n "$1" ; then
2835	  func_emit_wrapper_part2_arg1=$1
2836	fi
2837
2838	$ECHO "\
2839
2840  # Usually 'no', except on cygwin/mingw when embedded into
2841  # the cwrapper.
2842  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
2843  if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2844    # special case for '.'
2845    if test \"\$thisdir\" = \".\"; then
2846      thisdir=\`pwd\`
2847    fi
2848    # remove .libs from thisdir
2849    case \"\$thisdir\" in
2850    *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2851    $objdir )   thisdir=. ;;
2852    esac
2853  fi
2854
2855  # Try to get the absolute directory name.
2856  absdir=\`cd \"\$thisdir\" && pwd\`
2857  test -n \"\$absdir\" && thisdir=\"\$absdir\"
2858"
2859
2860	if test "$fast_install" = yes; then
2861	  $ECHO "\
2862  program=lt-'$outputname'$exeext
2863  progdir=\"\$thisdir/$objdir\"
2864
2865  if test ! -f \"\$progdir/\$program\" ||
2866     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2867       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2868
2869    file=\"\$\$-\$program\"
2870
2871    if test ! -d \"\$progdir\"; then
2872      $MKDIR \"\$progdir\"
2873    else
2874      $RM \"\$progdir/\$file\"
2875    fi"
2876
2877	  $ECHO "\
2878
2879    # relink executable if necessary
2880    if test -n \"\$relink_command\"; then
2881      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2882      else
2883	$ECHO \"\$relink_command_output\" >&2
2884	$RM \"\$progdir/\$file\"
2885	exit 1
2886      fi
2887    fi
2888
2889    $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2890    { $RM \"\$progdir/\$program\";
2891      $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2892    $RM \"\$progdir/\$file\"
2893  fi"
2894	else
2895	  $ECHO "\
2896  program='$outputname'
2897  progdir=\"\$thisdir/$objdir\"
2898"
2899	fi
2900
2901	$ECHO "\
2902
2903  if test -f \"\$progdir/\$program\"; then"
2904
2905	# Export our shlibpath_var if we have one.
2906	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2907	  $ECHO "\
2908    # Add our own library path to $shlibpath_var
2909    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2910
2911    # Some systems cannot cope with colon-terminated $shlibpath_var
2912    # The second colon is a workaround for a bug in BeOS R4 sed
2913    $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2914
2915    export $shlibpath_var
2916"
2917	fi
2918
2919	# fixup the dll searchpath if we need to.
2920	if test -n "$dllsearchpath"; then
2921	  $ECHO "\
2922    # Add the dll search path components to the executable PATH
2923    PATH=$dllsearchpath:\$PATH
2924"
2925	fi
2926
2927	$ECHO "\
2928    if test \"\$libtool_execute_magic\" != \"$magic\"; then
2929      # Run the actual program with our arguments.
2930"
2931	case $host in
2932	# Backslashes separate directories on plain windows
2933	*-*-mingw | *-*-os2* | *-cegcc*)
2934	  $ECHO "\
2935      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2936"
2937	  ;;
2938
2939	*)
2940	  $ECHO "\
2941      exec \"\$progdir/\$program\" \${1+\"\$@\"}
2942"
2943	  ;;
2944	esac
2945	$ECHO "\
2946      \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2947      exit 1
2948    fi
2949  else
2950    # The program doesn't exist.
2951    \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2952    \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2953    $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2954    exit 1
2955  fi
2956fi\
2957"
2958}
2959# end: func_emit_wrapper_part2
2960
2961
2962# func_emit_wrapper [arg=no]
2963#
2964# Emit a libtool wrapper script on stdout.
2965# Don't directly open a file because we may want to
2966# incorporate the script contents within a cygwin/mingw
2967# wrapper executable.  Must ONLY be called from within
2968# func_mode_link because it depends on a number of variables
2969# set therein.
2970#
2971# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2972# variable will take.  If 'yes', then the emitted script
2973# will assume that the directory in which it is stored is
2974# the $objdir directory.  This is a cygwin/mingw-specific
2975# behavior.
2976func_emit_wrapper ()
2977{
2978	func_emit_wrapper_arg1=no
2979	if test -n "$1" ; then
2980	  func_emit_wrapper_arg1=$1
2981	fi
2982
2983	# split this up so that func_emit_cwrapperexe_src
2984	# can call each part independently.
2985	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
2986	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
2987}
2988
2989
2990# func_to_host_path arg
2991#
2992# Convert paths to host format when used with build tools.
2993# Intended for use with "native" mingw (where libtool itself
2994# is running under the msys shell), or in the following cross-
2995# build environments:
2996#    $build          $host
2997#    mingw (msys)    mingw  [e.g. native]
2998#    cygwin          mingw
2999#    *nix + wine     mingw
3000# where wine is equipped with the `winepath' executable.
3001# In the native mingw case, the (msys) shell automatically
3002# converts paths for any non-msys applications it launches,
3003# but that facility isn't available from inside the cwrapper.
3004# Similar accommodations are necessary for $host mingw and
3005# $build cygwin.  Calling this function does no harm for other
3006# $host/$build combinations not listed above.
3007#
3008# ARG is the path (on $build) that should be converted to
3009# the proper representation for $host. The result is stored
3010# in $func_to_host_path_result.
3011func_to_host_path ()
3012{
3013  func_to_host_path_result="$1"
3014  if test -n "$1" ; then
3015    case $host in
3016      *mingw* )
3017        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3018        case $build in
3019          *mingw* ) # actually, msys
3020            # awkward: cmd appends spaces to result
3021            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3022            func_to_host_path_tmp1=`( cmd //c echo "$1" |\
3023              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3024            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3025              $SED -e "$lt_sed_naive_backslashify"`
3026            ;;
3027          *cygwin* )
3028            func_to_host_path_tmp1=`cygpath -w "$1"`
3029            func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3030              $SED -e "$lt_sed_naive_backslashify"`
3031            ;;
3032          * )
3033            # Unfortunately, winepath does not exit with a non-zero
3034            # error code, so we are forced to check the contents of
3035            # stdout. On the other hand, if the command is not
3036            # found, the shell will set an exit code of 127 and print
3037            # *an error message* to stdout. So we must check for both
3038            # error code of zero AND non-empty stdout, which explains
3039            # the odd construction:
3040            func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3041            if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3042              func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3043                $SED -e "$lt_sed_naive_backslashify"`
3044            else
3045              # Allow warning below.
3046              func_to_host_path_result=""
3047            fi
3048            ;;
3049        esac
3050        if test -z "$func_to_host_path_result" ; then
3051          func_error "Could not determine host path corresponding to"
3052          func_error "  '$1'"
3053          func_error "Continuing, but uninstalled executables may not work."
3054          # Fallback:
3055          func_to_host_path_result="$1"
3056        fi
3057        ;;
3058    esac
3059  fi
3060}
3061# end: func_to_host_path
3062
3063# func_to_host_pathlist arg
3064#
3065# Convert pathlists to host format when used with build tools.
3066# See func_to_host_path(), above. This function supports the
3067# following $build/$host combinations (but does no harm for
3068# combinations not listed here):
3069#    $build          $host
3070#    mingw (msys)    mingw  [e.g. native]
3071#    cygwin          mingw
3072#    *nix + wine     mingw
3073#
3074# Path separators are also converted from $build format to
3075# $host format. If ARG begins or ends with a path separator
3076# character, it is preserved (but converted to $host format)
3077# on output.
3078#
3079# ARG is a pathlist (on $build) that should be converted to
3080# the proper representation on $host. The result is stored
3081# in $func_to_host_pathlist_result.
3082func_to_host_pathlist ()
3083{
3084  func_to_host_pathlist_result="$1"
3085  if test -n "$1" ; then
3086    case $host in
3087      *mingw* )
3088        lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3089        # Remove leading and trailing path separator characters from
3090        # ARG. msys behavior is inconsistent here, cygpath turns them
3091        # into '.;' and ';.', and winepath ignores them completely.
3092        func_to_host_pathlist_tmp2="$1"
3093        # Once set for this call, this variable should not be
3094        # reassigned. It is used in tha fallback case.
3095        func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
3096          $SED -e 's|^:*||' -e 's|:*$||'`
3097        case $build in
3098          *mingw* ) # Actually, msys.
3099            # Awkward: cmd appends spaces to result.
3100            lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3101            func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
3102              $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3103            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3104              $SED -e "$lt_sed_naive_backslashify"`
3105            ;;
3106          *cygwin* )
3107            func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
3108            func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3109              $SED -e "$lt_sed_naive_backslashify"`
3110            ;;
3111          * )
3112            # unfortunately, winepath doesn't convert pathlists
3113            func_to_host_pathlist_result=""
3114            func_to_host_pathlist_oldIFS=$IFS
3115            IFS=:
3116            for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3117              IFS=$func_to_host_pathlist_oldIFS
3118              if test -n "$func_to_host_pathlist_f" ; then
3119                func_to_host_path "$func_to_host_pathlist_f"
3120                if test -n "$func_to_host_path_result" ; then
3121                  if test -z "$func_to_host_pathlist_result" ; then
3122                    func_to_host_pathlist_result="$func_to_host_path_result"
3123                  else
3124                    func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
3125                  fi
3126                fi
3127              fi
3128              IFS=:
3129            done
3130            IFS=$func_to_host_pathlist_oldIFS
3131            ;;
3132        esac
3133        if test -z "$func_to_host_pathlist_result" ; then
3134          func_error "Could not determine the host path(s) corresponding to"
3135          func_error "  '$1'"
3136          func_error "Continuing, but uninstalled executables may not work."
3137          # Fallback. This may break if $1 contains DOS-style drive
3138          # specifications. The fix is not to complicate the expression
3139          # below, but for the user to provide a working wine installation
3140          # with winepath so that path translation in the cross-to-mingw
3141          # case works properly.
3142          lt_replace_pathsep_nix_to_dos="s|:|;|g"
3143          func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3144            $SED -e "$lt_replace_pathsep_nix_to_dos"`
3145        fi
3146        # Now, add the leading and trailing path separators back
3147        case "$1" in
3148          :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3149            ;;
3150        esac
3151        case "$1" in
3152          *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
3153            ;;
3154        esac
3155        ;;
3156    esac
3157  fi
3158}
3159# end: func_to_host_pathlist
3160
3161# func_emit_cwrapperexe_src
3162# emit the source code for a wrapper executable on stdout
3163# Must ONLY be called from within func_mode_link because
3164# it depends on a number of variable set therein.
3165func_emit_cwrapperexe_src ()
3166{
3167	cat <<EOF
3168
3169/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3170   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3171
3172   The $output program cannot be directly executed until all the libtool
3173   libraries that it depends on are installed.
3174
3175   This wrapper executable should never be moved out of the build directory.
3176   If it is, it will not operate correctly.
3177
3178   Currently, it simply execs the wrapper *script* "$SHELL $output",
3179   but could eventually absorb all of the scripts functionality and
3180   exec $objdir/$outputname directly.
3181*/
3182EOF
3183	    cat <<"EOF"
3184#include <stdio.h>
3185#include <stdlib.h>
3186#ifdef _MSC_VER
3187# include <direct.h>
3188# include <process.h>
3189# include <io.h>
3190# define setmode _setmode
3191#else
3192# include <unistd.h>
3193# include <stdint.h>
3194# ifdef __CYGWIN__
3195#  include <io.h>
3196#  define HAVE_SETENV
3197#  ifdef __STRICT_ANSI__
3198char *realpath (const char *, char *);
3199int putenv (char *);
3200int setenv (const char *, const char *, int);
3201#  endif
3202# endif
3203#endif
3204#include <malloc.h>
3205#include <stdarg.h>
3206#include <assert.h>
3207#include <string.h>
3208#include <ctype.h>
3209#include <errno.h>
3210#include <fcntl.h>
3211#include <sys/stat.h>
3212
3213#if defined(PATH_MAX)
3214# define LT_PATHMAX PATH_MAX
3215#elif defined(MAXPATHLEN)
3216# define LT_PATHMAX MAXPATHLEN
3217#else
3218# define LT_PATHMAX 1024
3219#endif
3220
3221#ifndef S_IXOTH
3222# define S_IXOTH 0
3223#endif
3224#ifndef S_IXGRP
3225# define S_IXGRP 0
3226#endif
3227
3228#ifdef _MSC_VER
3229# define S_IXUSR _S_IEXEC
3230# define stat _stat
3231# ifndef _INTPTR_T_DEFINED
3232#  define intptr_t int
3233# endif
3234#endif
3235
3236#ifndef DIR_SEPARATOR
3237# define DIR_SEPARATOR '/'
3238# define PATH_SEPARATOR ':'
3239#endif
3240
3241#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3242  defined (__OS2__)
3243# define HAVE_DOS_BASED_FILE_SYSTEM
3244# define FOPEN_WB "wb"
3245# ifndef DIR_SEPARATOR_2
3246#  define DIR_SEPARATOR_2 '\\'
3247# endif
3248# ifndef PATH_SEPARATOR_2
3249#  define PATH_SEPARATOR_2 ';'
3250# endif
3251#endif
3252
3253#ifndef DIR_SEPARATOR_2
3254# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3255#else /* DIR_SEPARATOR_2 */
3256# define IS_DIR_SEPARATOR(ch) \
3257	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3258#endif /* DIR_SEPARATOR_2 */
3259
3260#ifndef PATH_SEPARATOR_2
3261# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3262#else /* PATH_SEPARATOR_2 */
3263# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3264#endif /* PATH_SEPARATOR_2 */
3265
3266#ifdef __CYGWIN__
3267# define FOPEN_WB "wb"
3268#endif
3269
3270#ifndef FOPEN_WB
3271# define FOPEN_WB "w"
3272#endif
3273#ifndef _O_BINARY
3274# define _O_BINARY 0
3275#endif
3276
3277#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
3278#define XFREE(stale) do { \
3279  if (stale) { free ((void *) stale); stale = 0; } \
3280} while (0)
3281
3282#undef LTWRAPPER_DEBUGPRINTF
3283#if defined DEBUGWRAPPER
3284# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3285static void
3286ltwrapper_debugprintf (const char *fmt, ...)
3287{
3288    va_list args;
3289    va_start (args, fmt);
3290    (void) vfprintf (stderr, fmt, args);
3291    va_end (args);
3292}
3293#else
3294# define LTWRAPPER_DEBUGPRINTF(args)
3295#endif
3296
3297const char *program_name = NULL;
3298
3299void *xmalloc (size_t num);
3300char *xstrdup (const char *string);
3301const char *base_name (const char *name);
3302char *find_executable (const char *wrapper);
3303char *chase_symlinks (const char *pathspec);
3304int make_executable (const char *path);
3305int check_executable (const char *path);
3306char *strendzap (char *str, const char *pat);
3307void lt_fatal (const char *message, ...);
3308void lt_setenv (const char *name, const char *value);
3309char *lt_extend_str (const char *orig_value, const char *add, int to_end);
3310void lt_opt_process_env_set (const char *arg);
3311void lt_opt_process_env_prepend (const char *arg);
3312void lt_opt_process_env_append (const char *arg);
3313int lt_split_name_value (const char *arg, char** name, char** value);
3314void lt_update_exe_path (const char *name, const char *value);
3315void lt_update_lib_path (const char *name, const char *value);
3316
3317static const char *script_text_part1 =
3318EOF
3319
3320	    func_emit_wrapper_part1 yes |
3321	        $SED -e 's/\([\\"]\)/\\\1/g' \
3322	             -e 's/^/  "/' -e 's/$/\\n"/'
3323	    echo ";"
3324	    cat <<EOF
3325
3326static const char *script_text_part2 =
3327EOF
3328	    func_emit_wrapper_part2 yes |
3329	        $SED -e 's/\([\\"]\)/\\\1/g' \
3330	             -e 's/^/  "/' -e 's/$/\\n"/'
3331	    echo ";"
3332
3333	    cat <<EOF
3334const char * MAGIC_EXE = "$magic_exe";
3335const char * LIB_PATH_VARNAME = "$shlibpath_var";
3336EOF
3337
3338	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3339              func_to_host_pathlist "$temp_rpath"
3340	      cat <<EOF
3341const char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
3342EOF
3343	    else
3344	      cat <<"EOF"
3345const char * LIB_PATH_VALUE   = "";
3346EOF
3347	    fi
3348
3349	    if test -n "$dllsearchpath"; then
3350              func_to_host_pathlist "$dllsearchpath:"
3351	      cat <<EOF
3352const char * EXE_PATH_VARNAME = "PATH";
3353const char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
3354EOF
3355	    else
3356	      cat <<"EOF"
3357const char * EXE_PATH_VARNAME = "";
3358const char * EXE_PATH_VALUE   = "";
3359EOF
3360	    fi
3361
3362	    if test "$fast_install" = yes; then
3363	      cat <<EOF
3364const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3365EOF
3366	    else
3367	      cat <<EOF
3368const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3369EOF
3370	    fi
3371
3372
3373	    cat <<"EOF"
3374
3375#define LTWRAPPER_OPTION_PREFIX         "--lt-"
3376#define LTWRAPPER_OPTION_PREFIX_LENGTH  5
3377
3378static const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
3379static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3380
3381static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
3382
3383static const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
3384static const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
3385  /* argument is putenv-style "foo=bar", value of foo is set to bar */
3386
3387static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
3388static const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
3389  /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
3390
3391static const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
3392static const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
3393  /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
3394
3395int
3396main (int argc, char *argv[])
3397{
3398  char **newargz;
3399  int  newargc;
3400  char *tmp_pathspec;
3401  char *actual_cwrapper_path;
3402  char *actual_cwrapper_name;
3403  char *target_name;
3404  char *lt_argv_zero;
3405  intptr_t rval = 127;
3406
3407  int i;
3408
3409  program_name = (char *) xstrdup (base_name (argv[0]));
3410  LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
3411  LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3412
3413  /* very simple arg parsing; don't want to rely on getopt */
3414  for (i = 1; i < argc; i++)
3415    {
3416      if (strcmp (argv[i], dumpscript_opt) == 0)
3417	{
3418EOF
3419	    case "$host" in
3420	      *mingw* | *cygwin* )
3421		# make stdout use "unix" line endings
3422		echo "          setmode(1,_O_BINARY);"
3423		;;
3424	      esac
3425
3426	    cat <<"EOF"
3427	  printf ("%s", script_text_part1);
3428	  printf ("%s", script_text_part2);
3429	  return 0;
3430	}
3431    }
3432
3433  newargz = XMALLOC (char *, argc + 1);
3434  tmp_pathspec = find_executable (argv[0]);
3435  if (tmp_pathspec == NULL)
3436    lt_fatal ("Couldn't find %s", argv[0]);
3437  LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3438			  tmp_pathspec));
3439
3440  actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3441  LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3442			  actual_cwrapper_path));
3443  XFREE (tmp_pathspec);
3444
3445  actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3446  strendzap (actual_cwrapper_path, actual_cwrapper_name);
3447
3448  /* wrapper name transforms */
3449  strendzap (actual_cwrapper_name, ".exe");
3450  tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3451  XFREE (actual_cwrapper_name);
3452  actual_cwrapper_name = tmp_pathspec;
3453  tmp_pathspec = 0;
3454
3455  /* target_name transforms -- use actual target program name; might have lt- prefix */
3456  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3457  strendzap (target_name, ".exe");
3458  tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3459  XFREE (target_name);
3460  target_name = tmp_pathspec;
3461  tmp_pathspec = 0;
3462
3463  LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3464			  target_name));
3465EOF
3466
3467	    cat <<EOF
3468  newargz[0] =
3469    XMALLOC (char, (strlen (actual_cwrapper_path) +
3470		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3471  strcpy (newargz[0], actual_cwrapper_path);
3472  strcat (newargz[0], "$objdir");
3473  strcat (newargz[0], "/");
3474EOF
3475
3476	    cat <<"EOF"
3477  /* stop here, and copy so we don't have to do this twice */
3478  tmp_pathspec = xstrdup (newargz[0]);
3479
3480  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3481  strcat (newargz[0], actual_cwrapper_name);
3482
3483  /* DO want the lt- prefix here if it exists, so use target_name */
3484  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3485  XFREE (tmp_pathspec);
3486  tmp_pathspec = NULL;
3487EOF
3488
3489	    case $host_os in
3490	      mingw*)
3491	    cat <<"EOF"
3492  {
3493    char* p;
3494    while ((p = strchr (newargz[0], '\\')) != NULL)
3495      {
3496	*p = '/';
3497      }
3498    while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3499      {
3500	*p = '/';
3501      }
3502  }
3503EOF
3504	    ;;
3505	    esac
3506
3507	    cat <<"EOF"
3508  XFREE (target_name);
3509  XFREE (actual_cwrapper_path);
3510  XFREE (actual_cwrapper_name);
3511
3512  lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3513  lt_setenv ("DUALCASE", "1");  /* for MSK sh */
3514  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3515  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3516
3517  newargc=0;
3518  for (i = 1; i < argc; i++)
3519    {
3520      if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
3521        {
3522          if (argv[i][env_set_opt_len] == '=')
3523            {
3524              const char *p = argv[i] + env_set_opt_len + 1;
3525              lt_opt_process_env_set (p);
3526            }
3527          else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
3528            {
3529              lt_opt_process_env_set (argv[++i]); /* don't copy */
3530            }
3531          else
3532            lt_fatal ("%s missing required argument", env_set_opt);
3533          continue;
3534        }
3535      if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
3536        {
3537          if (argv[i][env_prepend_opt_len] == '=')
3538            {
3539              const char *p = argv[i] + env_prepend_opt_len + 1;
3540              lt_opt_process_env_prepend (p);
3541            }
3542          else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
3543            {
3544              lt_opt_process_env_prepend (argv[++i]); /* don't copy */
3545            }
3546          else
3547            lt_fatal ("%s missing required argument", env_prepend_opt);
3548          continue;
3549        }
3550      if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
3551        {
3552          if (argv[i][env_append_opt_len] == '=')
3553            {
3554              const char *p = argv[i] + env_append_opt_len + 1;
3555              lt_opt_process_env_append (p);
3556            }
3557          else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
3558            {
3559              lt_opt_process_env_append (argv[++i]); /* don't copy */
3560            }
3561          else
3562            lt_fatal ("%s missing required argument", env_append_opt);
3563          continue;
3564        }
3565      if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3566        {
3567          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3568             namespace, but it is not one of the ones we know about and
3569             have already dealt with, above (inluding dump-script), then
3570             report an error. Otherwise, targets might begin to believe
3571             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3572             namespace. The first time any user complains about this, we'll
3573             need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3574             or a configure.ac-settable value.
3575           */
3576          lt_fatal ("Unrecognized option in %s namespace: '%s'",
3577                    ltwrapper_option_prefix, argv[i]);
3578        }
3579      /* otherwise ... */
3580      newargz[++newargc] = xstrdup (argv[i]);
3581    }
3582  newargz[++newargc] = NULL;
3583
3584  LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3585  for (i = 0; i < newargc; i++)
3586    {
3587      LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3588    }
3589
3590EOF
3591
3592	    case $host_os in
3593	      mingw*)
3594		cat <<"EOF"
3595  /* execv doesn't actually work on mingw as expected on unix */
3596  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3597  if (rval == -1)
3598    {
3599      /* failed to start process */
3600      LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3601      return 127;
3602    }
3603  return rval;
3604EOF
3605		;;
3606	      *)
3607		cat <<"EOF"
3608  execv (lt_argv_zero, newargz);
3609  return rval; /* =127, but avoids unused variable warning */
3610EOF
3611		;;
3612	    esac
3613
3614	    cat <<"EOF"
3615}
3616
3617void *
3618xmalloc (size_t num)
3619{
3620  void *p = (void *) malloc (num);
3621  if (!p)
3622    lt_fatal ("Memory exhausted");
3623
3624  return p;
3625}
3626
3627char *
3628xstrdup (const char *string)
3629{
3630  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3631			  string) : NULL;
3632}
3633
3634const char *
3635base_name (const char *name)
3636{
3637  const char *base;
3638
3639#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3640  /* Skip over the disk name in MSDOS pathnames. */
3641  if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3642    name += 2;
3643#endif
3644
3645  for (base = name; *name; name++)
3646    if (IS_DIR_SEPARATOR (*name))
3647      base = name + 1;
3648  return base;
3649}
3650
3651int
3652check_executable (const char *path)
3653{
3654  struct stat st;
3655
3656  LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
3657			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3658  if ((!path) || (!*path))
3659    return 0;
3660
3661  if ((stat (path, &st) >= 0)
3662      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3663    return 1;
3664  else
3665    return 0;
3666}
3667
3668int
3669make_executable (const char *path)
3670{
3671  int rval = 0;
3672  struct stat st;
3673
3674  LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
3675			  path ? (*path ? path : "EMPTY!") : "NULL!"));
3676  if ((!path) || (!*path))
3677    return 0;
3678
3679  if (stat (path, &st) >= 0)
3680    {
3681      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3682    }
3683  return rval;
3684}
3685
3686/* Searches for the full path of the wrapper.  Returns
3687   newly allocated full path name if found, NULL otherwise
3688   Does not chase symlinks, even on platforms that support them.
3689*/
3690char *
3691find_executable (const char *wrapper)
3692{
3693  int has_slash = 0;
3694  const char *p;
3695  const char *p_next;
3696  /* static buffer for getcwd */
3697  char tmp[LT_PATHMAX + 1];
3698  int tmp_len;
3699  char *concat_name;
3700
3701  LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
3702			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3703
3704  if ((wrapper == NULL) || (*wrapper == '\0'))
3705    return NULL;
3706
3707  /* Absolute path? */
3708#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3709  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3710    {
3711      concat_name = xstrdup (wrapper);
3712      if (check_executable (concat_name))
3713	return concat_name;
3714      XFREE (concat_name);
3715    }
3716  else
3717    {
3718#endif
3719      if (IS_DIR_SEPARATOR (wrapper[0]))
3720	{
3721	  concat_name = xstrdup (wrapper);
3722	  if (check_executable (concat_name))
3723	    return concat_name;
3724	  XFREE (concat_name);
3725	}
3726#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3727    }
3728#endif
3729
3730  for (p = wrapper; *p; p++)
3731    if (*p == '/')
3732      {
3733	has_slash = 1;
3734	break;
3735      }
3736  if (!has_slash)
3737    {
3738      /* no slashes; search PATH */
3739      const char *path = getenv ("PATH");
3740      if (path != NULL)
3741	{
3742	  for (p = path; *p; p = p_next)
3743	    {
3744	      const char *q;
3745	      size_t p_len;
3746	      for (q = p; *q; q++)
3747		if (IS_PATH_SEPARATOR (*q))
3748		  break;
3749	      p_len = q - p;
3750	      p_next = (*q == '\0' ? q : q + 1);
3751	      if (p_len == 0)
3752		{
3753		  /* empty path: current directory */
3754		  if (getcwd (tmp, LT_PATHMAX) == NULL)
3755		    lt_fatal ("getcwd failed");
3756		  tmp_len = strlen (tmp);
3757		  concat_name =
3758		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3759		  memcpy (concat_name, tmp, tmp_len);
3760		  concat_name[tmp_len] = '/';
3761		  strcpy (concat_name + tmp_len + 1, wrapper);
3762		}
3763	      else
3764		{
3765		  concat_name =
3766		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3767		  memcpy (concat_name, p, p_len);
3768		  concat_name[p_len] = '/';
3769		  strcpy (concat_name + p_len + 1, wrapper);
3770		}
3771	      if (check_executable (concat_name))
3772		return concat_name;
3773	      XFREE (concat_name);
3774	    }
3775	}
3776      /* not found in PATH; assume curdir */
3777    }
3778  /* Relative path | not found in path: prepend cwd */
3779  if (getcwd (tmp, LT_PATHMAX) == NULL)
3780    lt_fatal ("getcwd failed");
3781  tmp_len = strlen (tmp);
3782  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3783  memcpy (concat_name, tmp, tmp_len);
3784  concat_name[tmp_len] = '/';
3785  strcpy (concat_name + tmp_len + 1, wrapper);
3786
3787  if (check_executable (concat_name))
3788    return concat_name;
3789  XFREE (concat_name);
3790  return NULL;
3791}
3792
3793char *
3794chase_symlinks (const char *pathspec)
3795{
3796#ifndef S_ISLNK
3797  return xstrdup (pathspec);
3798#else
3799  char buf[LT_PATHMAX];
3800  struct stat s;
3801  char *tmp_pathspec = xstrdup (pathspec);
3802  char *p;
3803  int has_symlinks = 0;
3804  while (strlen (tmp_pathspec) && !has_symlinks)
3805    {
3806      LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3807			      tmp_pathspec));
3808      if (lstat (tmp_pathspec, &s) == 0)
3809	{
3810	  if (S_ISLNK (s.st_mode) != 0)
3811	    {
3812	      has_symlinks = 1;
3813	      break;
3814	    }
3815
3816	  /* search backwards for last DIR_SEPARATOR */
3817	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3818	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3819	    p--;
3820	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3821	    {
3822	      /* no more DIR_SEPARATORS left */
3823	      break;
3824	    }
3825	  *p = '\0';
3826	}
3827      else
3828	{
3829	  char *errstr = strerror (errno);
3830	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3831	}
3832    }
3833  XFREE (tmp_pathspec);
3834
3835  if (!has_symlinks)
3836    {
3837      return xstrdup (pathspec);
3838    }
3839
3840  tmp_pathspec = realpath (pathspec, buf);
3841  if (tmp_pathspec == 0)
3842    {
3843      lt_fatal ("Could not follow symlinks for %s", pathspec);
3844    }
3845  return xstrdup (tmp_pathspec);
3846#endif
3847}
3848
3849char *
3850strendzap (char *str, const char *pat)
3851{
3852  size_t len, patlen;
3853
3854  assert (str != NULL);
3855  assert (pat != NULL);
3856
3857  len = strlen (str);
3858  patlen = strlen (pat);
3859
3860  if (patlen <= len)
3861    {
3862      str += len - patlen;
3863      if (strcmp (str, pat) == 0)
3864	*str = '\0';
3865    }
3866  return str;
3867}
3868
3869static void
3870lt_error_core (int exit_status, const char *mode,
3871	       const char *message, va_list ap)
3872{
3873  fprintf (stderr, "%s: %s: ", program_name, mode);
3874  vfprintf (stderr, message, ap);
3875  fprintf (stderr, ".\n");
3876
3877  if (exit_status >= 0)
3878    exit (exit_status);
3879}
3880
3881void
3882lt_fatal (const char *message, ...)
3883{
3884  va_list ap;
3885  va_start (ap, message);
3886  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3887  va_end (ap);
3888}
3889
3890void
3891lt_setenv (const char *name, const char *value)
3892{
3893  LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
3894                          (name ? name : "<NULL>"),
3895                          (value ? value : "<NULL>")));
3896  {
3897#ifdef HAVE_SETENV
3898    /* always make a copy, for consistency with !HAVE_SETENV */
3899    char *str = xstrdup (value);
3900    setenv (name, str, 1);
3901#else
3902    int len = strlen (name) + 1 + strlen (value) + 1;
3903    char *str = XMALLOC (char, len);
3904    sprintf (str, "%s=%s", name, value);
3905    if (putenv (str) != EXIT_SUCCESS)
3906      {
3907        XFREE (str);
3908      }
3909#endif
3910  }
3911}
3912
3913char *
3914lt_extend_str (const char *orig_value, const char *add, int to_end)
3915{
3916  char *new_value;
3917  if (orig_value && *orig_value)
3918    {
3919      int orig_value_len = strlen (orig_value);
3920      int add_len = strlen (add);
3921      new_value = XMALLOC (char, add_len + orig_value_len + 1);
3922      if (to_end)
3923        {
3924          strcpy (new_value, orig_value);
3925          strcpy (new_value + orig_value_len, add);
3926        }
3927      else
3928        {
3929          strcpy (new_value, add);
3930          strcpy (new_value + add_len, orig_value);
3931        }
3932    }
3933  else
3934    {
3935      new_value = xstrdup (add);
3936    }
3937  return new_value;
3938}
3939
3940int
3941lt_split_name_value (const char *arg, char** name, char** value)
3942{
3943  const char *p;
3944  int len;
3945  if (!arg || !*arg)
3946    return 1;
3947
3948  p = strchr (arg, (int)'=');
3949
3950  if (!p)
3951    return 1;
3952
3953  *value = xstrdup (++p);
3954
3955  len = strlen (arg) - strlen (*value);
3956  *name = XMALLOC (char, len);
3957  strncpy (*name, arg, len-1);
3958  (*name)[len - 1] = '\0';
3959
3960  return 0;
3961}
3962
3963void
3964lt_opt_process_env_set (const char *arg)
3965{
3966  char *name = NULL;
3967  char *value = NULL;
3968
3969  if (lt_split_name_value (arg, &name, &value) != 0)
3970    {
3971      XFREE (name);
3972      XFREE (value);
3973      lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
3974    }
3975
3976  lt_setenv (name, value);
3977  XFREE (name);
3978  XFREE (value);
3979}
3980
3981void
3982lt_opt_process_env_prepend (const char *arg)
3983{
3984  char *name = NULL;
3985  char *value = NULL;
3986  char *new_value = NULL;
3987
3988  if (lt_split_name_value (arg, &name, &value) != 0)
3989    {
3990      XFREE (name);
3991      XFREE (value);
3992      lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
3993    }
3994
3995  new_value = lt_extend_str (getenv (name), value, 0);
3996  lt_setenv (name, new_value);
3997  XFREE (new_value);
3998  XFREE (name);
3999  XFREE (value);
4000}
4001
4002void
4003lt_opt_process_env_append (const char *arg)
4004{
4005  char *name = NULL;
4006  char *value = NULL;
4007  char *new_value = NULL;
4008
4009  if (lt_split_name_value (arg, &name, &value) != 0)
4010    {
4011      XFREE (name);
4012      XFREE (value);
4013      lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
4014    }
4015
4016  new_value = lt_extend_str (getenv (name), value, 1);
4017  lt_setenv (name, new_value);
4018  XFREE (new_value);
4019  XFREE (name);
4020  XFREE (value);
4021}
4022
4023void
4024lt_update_exe_path (const char *name, const char *value)
4025{
4026  LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
4027                          (name ? name : "<NULL>"),
4028                          (value ? value : "<NULL>")));
4029
4030  if (name && *name && value && *value)
4031    {
4032      char *new_value = lt_extend_str (getenv (name), value, 0);
4033      /* some systems can't cope with a ':'-terminated path #' */
4034      int len = strlen (new_value);
4035      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4036        {
4037          new_value[len-1] = '\0';
4038        }
4039      lt_setenv (name, new_value);
4040      XFREE (new_value);
4041    }
4042}
4043
4044void
4045lt_update_lib_path (const char *name, const char *value)
4046{
4047  LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4048                          (name ? name : "<NULL>"),
4049                          (value ? value : "<NULL>")));
4050
4051  if (name && *name && value && *value)
4052    {
4053      char *new_value = lt_extend_str (getenv (name), value, 0);
4054      lt_setenv (name, new_value);
4055      XFREE (new_value);
4056    }
4057}
4058
4059
4060EOF
4061}
4062# end: func_emit_cwrapperexe_src
4063
4064# func_mode_link arg...
4065func_mode_link ()
4066{
4067    $opt_debug
4068    case $host in
4069    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4070      # It is impossible to link a dll without this setting, and
4071      # we shouldn't force the makefile maintainer to figure out
4072      # which system we are compiling for in order to pass an extra
4073      # flag for every libtool invocation.
4074      # allow_undefined=no
4075
4076      # FIXME: Unfortunately, there are problems with the above when trying
4077      # to make a dll which has undefined symbols, in which case not
4078      # even a static library is built.  For now, we need to specify
4079      # -no-undefined on the libtool link line when we can be certain
4080      # that all symbols are satisfied, otherwise we get a static library.
4081      allow_undefined=yes
4082      ;;
4083    *)
4084      allow_undefined=yes
4085      ;;
4086    esac
4087    libtool_args=$nonopt
4088    base_compile="$nonopt $@"
4089    compile_command=$nonopt
4090    finalize_command=$nonopt
4091
4092    compile_rpath=
4093    finalize_rpath=
4094    compile_shlibpath=
4095    finalize_shlibpath=
4096    convenience=
4097    old_convenience=
4098    deplibs=
4099    old_deplibs=
4100    compiler_flags=
4101    linker_flags=
4102    dllsearchpath=
4103    lib_search_path=`pwd`
4104    inst_prefix_dir=
4105    new_inherited_linker_flags=
4106
4107    avoid_version=no
4108    dlfiles=
4109    dlprefiles=
4110    dlself=no
4111    export_dynamic=no
4112    export_symbols=
4113    export_symbols_regex=
4114    generated=
4115    libobjs=
4116    ltlibs=
4117    module=no
4118    no_install=no
4119    objs=
4120    non_pic_objects=
4121    precious_files_regex=
4122    prefer_static_libs=no
4123    preload=no
4124    prev=
4125    prevarg=
4126    release=
4127    rpath=
4128    xrpath=
4129    perm_rpath=
4130    temp_rpath=
4131    thread_safe=no
4132    vinfo=
4133    vinfo_number=no
4134    weak_libs=
4135    single_module="${wl}-single_module"
4136    func_infer_tag $base_compile
4137
4138    # We need to know -static, to get the right output filenames.
4139    for arg
4140    do
4141      case $arg in
4142      -shared)
4143	test "$build_libtool_libs" != yes && \
4144	  func_fatal_configuration "can not build a shared library"
4145	build_old_libs=no
4146	break
4147	;;
4148      -all-static | -static | -static-libtool-libs)
4149	case $arg in
4150	-all-static)
4151	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4152	    func_warning "complete static linking is impossible in this configuration"
4153	  fi
4154	  if test -n "$link_static_flag"; then
4155	    dlopen_self=$dlopen_self_static
4156	  fi
4157	  prefer_static_libs=yes
4158	  ;;
4159	-static)
4160	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4161	    dlopen_self=$dlopen_self_static
4162	  fi
4163	  prefer_static_libs=built
4164	  ;;
4165	-static-libtool-libs)
4166	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
4167	    dlopen_self=$dlopen_self_static
4168	  fi
4169	  prefer_static_libs=yes
4170	  ;;
4171	esac
4172	build_libtool_libs=no
4173	build_old_libs=yes
4174	break
4175	;;
4176      esac
4177    done
4178
4179    # See if our shared archives depend on static archives.
4180    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4181
4182    # Go through the arguments, transforming them on the way.
4183    while test "$#" -gt 0; do
4184      arg="$1"
4185      shift
4186      func_quote_for_eval "$arg"
4187      qarg=$func_quote_for_eval_unquoted_result
4188      func_append libtool_args " $func_quote_for_eval_result"
4189
4190      # If the previous option needs an argument, assign it.
4191      if test -n "$prev"; then
4192	case $prev in
4193	output)
4194	  func_append compile_command " @OUTPUT@"
4195	  func_append finalize_command " @OUTPUT@"
4196	  ;;
4197	esac
4198
4199	case $prev in
4200	dlfiles|dlprefiles)
4201	  if test "$preload" = no; then
4202	    # Add the symbol object into the linking commands.
4203	    func_append compile_command " @SYMFILE@"
4204	    func_append finalize_command " @SYMFILE@"
4205	    preload=yes
4206	  fi
4207	  case $arg in
4208	  *.la | *.lo) ;;  # We handle these cases below.
4209	  force)
4210	    if test "$dlself" = no; then
4211	      dlself=needless
4212	      export_dynamic=yes
4213	    fi
4214	    prev=
4215	    continue
4216	    ;;
4217	  self)
4218	    if test "$prev" = dlprefiles; then
4219	      dlself=yes
4220	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4221	      dlself=yes
4222	    else
4223	      dlself=needless
4224	      export_dynamic=yes
4225	    fi
4226	    prev=
4227	    continue
4228	    ;;
4229	  *)
4230	    if test "$prev" = dlfiles; then
4231	      dlfiles="$dlfiles $arg"
4232	    else
4233	      dlprefiles="$dlprefiles $arg"
4234	    fi
4235	    prev=
4236	    continue
4237	    ;;
4238	  esac
4239	  ;;
4240	expsyms)
4241	  export_symbols="$arg"
4242	  test -f "$arg" \
4243	    || func_fatal_error "symbol file \`$arg' does not exist"
4244	  prev=
4245	  continue
4246	  ;;
4247	expsyms_regex)
4248	  export_symbols_regex="$arg"
4249	  prev=
4250	  continue
4251	  ;;
4252	framework)
4253	  case $host in
4254	    *-*-darwin*)
4255	      case "$deplibs " in
4256		*" $qarg.ltframework "*) ;;
4257		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4258		   ;;
4259	      esac
4260	      ;;
4261	  esac
4262	  prev=
4263	  continue
4264	  ;;
4265	inst_prefix)
4266	  inst_prefix_dir="$arg"
4267	  prev=
4268	  continue
4269	  ;;
4270	objectlist)
4271	  if test -f "$arg"; then
4272	    save_arg=$arg
4273	    moreargs=
4274	    for fil in `cat "$save_arg"`
4275	    do
4276#	      moreargs="$moreargs $fil"
4277	      arg=$fil
4278	      # A libtool-controlled object.
4279
4280	      # Check to see that this really is a libtool object.
4281	      if func_lalib_unsafe_p "$arg"; then
4282		pic_object=
4283		non_pic_object=
4284
4285		# Read the .lo file
4286		func_source "$arg"
4287
4288		if test -z "$pic_object" ||
4289		   test -z "$non_pic_object" ||
4290		   test "$pic_object" = none &&
4291		   test "$non_pic_object" = none; then
4292		  func_fatal_error "cannot find name of object for \`$arg'"
4293		fi
4294
4295		# Extract subdirectory from the argument.
4296		func_dirname "$arg" "/" ""
4297		xdir="$func_dirname_result"
4298
4299		if test "$pic_object" != none; then
4300		  # Prepend the subdirectory the object is found in.
4301		  pic_object="$xdir$pic_object"
4302
4303		  if test "$prev" = dlfiles; then
4304		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4305		      dlfiles="$dlfiles $pic_object"
4306		      prev=
4307		      continue
4308		    else
4309		      # If libtool objects are unsupported, then we need to preload.
4310		      prev=dlprefiles
4311		    fi
4312		  fi
4313
4314		  # CHECK ME:  I think I busted this.  -Ossama
4315		  if test "$prev" = dlprefiles; then
4316		    # Preload the old-style object.
4317		    dlprefiles="$dlprefiles $pic_object"
4318		    prev=
4319		  fi
4320
4321		  # A PIC object.
4322		  func_append libobjs " $pic_object"
4323		  arg="$pic_object"
4324		fi
4325
4326		# Non-PIC object.
4327		if test "$non_pic_object" != none; then
4328		  # Prepend the subdirectory the object is found in.
4329		  non_pic_object="$xdir$non_pic_object"
4330
4331		  # A standard non-PIC object
4332		  func_append non_pic_objects " $non_pic_object"
4333		  if test -z "$pic_object" || test "$pic_object" = none ; then
4334		    arg="$non_pic_object"
4335		  fi
4336		else
4337		  # If the PIC object exists, use it instead.
4338		  # $xdir was prepended to $pic_object above.
4339		  non_pic_object="$pic_object"
4340		  func_append non_pic_objects " $non_pic_object"
4341		fi
4342	      else
4343		# Only an error if not doing a dry-run.
4344		if $opt_dry_run; then
4345		  # Extract subdirectory from the argument.
4346		  func_dirname "$arg" "/" ""
4347		  xdir="$func_dirname_result"
4348
4349		  func_lo2o "$arg"
4350		  pic_object=$xdir$objdir/$func_lo2o_result
4351		  non_pic_object=$xdir$func_lo2o_result
4352		  func_append libobjs " $pic_object"
4353		  func_append non_pic_objects " $non_pic_object"
4354	        else
4355		  func_fatal_error "\`$arg' is not a valid libtool object"
4356		fi
4357	      fi
4358	    done
4359	  else
4360	    func_fatal_error "link input file \`$arg' does not exist"
4361	  fi
4362	  arg=$save_arg
4363	  prev=
4364	  continue
4365	  ;;
4366	precious_regex)
4367	  precious_files_regex="$arg"
4368	  prev=
4369	  continue
4370	  ;;
4371	release)
4372	  release="-$arg"
4373	  prev=
4374	  continue
4375	  ;;
4376	rpath | xrpath)
4377	  # We need an absolute path.
4378	  case $arg in
4379	  [\\/]* | [A-Za-z]:[\\/]*) ;;
4380	  *)
4381	    func_fatal_error "only absolute run-paths are allowed"
4382	    ;;
4383	  esac
4384	  if test "$prev" = rpath; then
4385	    case "$rpath " in
4386	    *" $arg "*) ;;
4387	    *) rpath="$rpath $arg" ;;
4388	    esac
4389	  else
4390	    case "$xrpath " in
4391	    *" $arg "*) ;;
4392	    *) xrpath="$xrpath $arg" ;;
4393	    esac
4394	  fi
4395	  prev=
4396	  continue
4397	  ;;
4398	shrext)
4399	  shrext_cmds="$arg"
4400	  prev=
4401	  continue
4402	  ;;
4403	weak)
4404	  weak_libs="$weak_libs $arg"
4405	  prev=
4406	  continue
4407	  ;;
4408	xcclinker)
4409	  linker_flags="$linker_flags $qarg"
4410	  compiler_flags="$compiler_flags $qarg"
4411	  prev=
4412	  func_append compile_command " $qarg"
4413	  func_append finalize_command " $qarg"
4414	  continue
4415	  ;;
4416	xcompiler)
4417	  compiler_flags="$compiler_flags $qarg"
4418	  prev=
4419	  func_append compile_command " $qarg"
4420	  func_append finalize_command " $qarg"
4421	  continue
4422	  ;;
4423	xlinker)
4424	  linker_flags="$linker_flags $qarg"
4425	  compiler_flags="$compiler_flags $wl$qarg"
4426	  prev=
4427	  func_append compile_command " $wl$qarg"
4428	  func_append finalize_command " $wl$qarg"
4429	  continue
4430	  ;;
4431	*)
4432	  eval "$prev=\"\$arg\""
4433	  prev=
4434	  continue
4435	  ;;
4436	esac
4437      fi # test -n "$prev"
4438
4439      prevarg="$arg"
4440
4441      case $arg in
4442      -all-static)
4443	if test -n "$link_static_flag"; then
4444	  # See comment for -static flag below, for more details.
4445	  func_append compile_command " $link_static_flag"
4446	  func_append finalize_command " $link_static_flag"
4447	fi
4448	continue
4449	;;
4450
4451      -allow-undefined)
4452	# FIXME: remove this flag sometime in the future.
4453	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4454	;;
4455
4456      -avoid-version)
4457	avoid_version=yes
4458	continue
4459	;;
4460
4461      -dlopen)
4462	prev=dlfiles
4463	continue
4464	;;
4465
4466      -dlpreopen)
4467	prev=dlprefiles
4468	continue
4469	;;
4470
4471      -export-dynamic)
4472	export_dynamic=yes
4473	continue
4474	;;
4475
4476      -export-symbols | -export-symbols-regex)
4477	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4478	  func_fatal_error "more than one -exported-symbols argument is not allowed"
4479	fi
4480	if test "X$arg" = "X-export-symbols"; then
4481	  prev=expsyms
4482	else
4483	  prev=expsyms_regex
4484	fi
4485	continue
4486	;;
4487
4488      -framework)
4489	prev=framework
4490	continue
4491	;;
4492
4493      -inst-prefix-dir)
4494	prev=inst_prefix
4495	continue
4496	;;
4497
4498      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4499      # so, if we see these flags be careful not to treat them like -L
4500      -L[A-Z][A-Z]*:*)
4501	case $with_gcc/$host in
4502	no/*-*-irix* | /*-*-irix*)
4503	  func_append compile_command " $arg"
4504	  func_append finalize_command " $arg"
4505	  ;;
4506	esac
4507	continue
4508	;;
4509
4510      -L*)
4511	func_stripname '-L' '' "$arg"
4512	dir=$func_stripname_result
4513	if test -z "$dir"; then
4514	  if test "$#" -gt 0; then
4515	    func_fatal_error "require no space between \`-L' and \`$1'"
4516	  else
4517	    func_fatal_error "need path for \`-L' option"
4518	  fi
4519	fi
4520	# We need an absolute path.
4521	case $dir in
4522	[\\/]* | [A-Za-z]:[\\/]*) ;;
4523	*)
4524	  absdir=`cd "$dir" && pwd`
4525	  test -z "$absdir" && \
4526	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
4527	  dir="$absdir"
4528	  ;;
4529	esac
4530	case "$deplibs " in
4531	*" -L$dir "*) ;;
4532	*)
4533	  deplibs="$deplibs -L$dir"
4534	  lib_search_path="$lib_search_path $dir"
4535	  ;;
4536	esac
4537	case $host in
4538	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4539	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
4540	  case :$dllsearchpath: in
4541	  *":$dir:"*) ;;
4542	  ::) dllsearchpath=$dir;;
4543	  *) dllsearchpath="$dllsearchpath:$dir";;
4544	  esac
4545	  case :$dllsearchpath: in
4546	  *":$testbindir:"*) ;;
4547	  ::) dllsearchpath=$testbindir;;
4548	  *) dllsearchpath="$dllsearchpath:$testbindir";;
4549	  esac
4550	  ;;
4551	esac
4552	continue
4553	;;
4554
4555      -l*)
4556	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4557	  case $host in
4558	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
4559	    # These systems don't actually have a C or math library (as such)
4560	    continue
4561	    ;;
4562	  *-*-os2*)
4563	    # These systems don't actually have a C library (as such)
4564	    test "X$arg" = "X-lc" && continue
4565	    ;;
4566	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4567	    # Do not include libc due to us having libc/libc_r.
4568	    test "X$arg" = "X-lc" && continue
4569	    ;;
4570	  *-*-rhapsody* | *-*-darwin1.[012])
4571	    # Rhapsody C and math libraries are in the System framework
4572	    deplibs="$deplibs System.ltframework"
4573	    continue
4574	    ;;
4575	  *-*-sco3.2v5* | *-*-sco5v6*)
4576	    # Causes problems with __ctype
4577	    test "X$arg" = "X-lc" && continue
4578	    ;;
4579	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4580	    # Compiler inserts libc in the correct place for threads to work
4581	    test "X$arg" = "X-lc" && continue
4582	    ;;
4583	  esac
4584	elif test "X$arg" = "X-lc_r"; then
4585	 case $host in
4586	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4587	   # Do not include libc_r directly, use -pthread flag.
4588	   continue
4589	   ;;
4590	 esac
4591	fi
4592	deplibs="$deplibs $arg"
4593	continue
4594	;;
4595
4596      -module)
4597	module=yes
4598	continue
4599	;;
4600
4601      # Tru64 UNIX uses -model [arg] to determine the layout of C++
4602      # classes, name mangling, and exception handling.
4603      # Darwin uses the -arch flag to determine output architecture.
4604      -model|-arch|-isysroot)
4605	compiler_flags="$compiler_flags $arg"
4606	func_append compile_command " $arg"
4607	func_append finalize_command " $arg"
4608	prev=xcompiler
4609	continue
4610	;;
4611
4612      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4613	compiler_flags="$compiler_flags $arg"
4614	func_append compile_command " $arg"
4615	func_append finalize_command " $arg"
4616	case "$new_inherited_linker_flags " in
4617	    *" $arg "*) ;;
4618	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4619	esac
4620	deplibs="$deplibs $arg"
4621	continue
4622	;;
4623
4624      -multi_module)
4625	single_module="${wl}-multi_module"
4626	continue
4627	;;
4628
4629      -no-fast-install)
4630	fast_install=no
4631	continue
4632	;;
4633
4634      -no-install)
4635	case $host in
4636	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4637	  # The PATH hackery in wrapper scripts is required on Windows
4638	  # and Darwin in order for the loader to find any dlls it needs.
4639	  func_warning "\`-no-install' is ignored for $host"
4640	  func_warning "assuming \`-no-fast-install' instead"
4641	  fast_install=no
4642	  ;;
4643	*) no_install=yes ;;
4644	esac
4645	continue
4646	;;
4647
4648      -no-undefined)
4649	allow_undefined=no
4650	continue
4651	;;
4652
4653      -objectlist)
4654	prev=objectlist
4655	continue
4656	;;
4657
4658      -o) prev=output ;;
4659
4660      -precious-files-regex)
4661	prev=precious_regex
4662	continue
4663	;;
4664
4665      -release)
4666	prev=release
4667	continue
4668	;;
4669
4670      -rpath)
4671	prev=rpath
4672	continue
4673	;;
4674
4675      -R)
4676	prev=xrpath
4677	continue
4678	;;
4679
4680      -R*)
4681	func_stripname '-R' '' "$arg"
4682	dir=$func_stripname_result
4683	# We need an absolute path.
4684	case $dir in
4685	[\\/]* | [A-Za-z]:[\\/]*) ;;
4686	*)
4687	  func_fatal_error "only absolute run-paths are allowed"
4688	  ;;
4689	esac
4690	case "$xrpath " in
4691	*" $dir "*) ;;
4692	*) xrpath="$xrpath $dir" ;;
4693	esac
4694	continue
4695	;;
4696
4697      -shared)
4698	# The effects of -shared are defined in a previous loop.
4699	continue
4700	;;
4701
4702      -shrext)
4703	prev=shrext
4704	continue
4705	;;
4706
4707      -static | -static-libtool-libs)
4708	# The effects of -static are defined in a previous loop.
4709	# We used to do the same as -all-static on platforms that
4710	# didn't have a PIC flag, but the assumption that the effects
4711	# would be equivalent was wrong.  It would break on at least
4712	# Digital Unix and AIX.
4713	continue
4714	;;
4715
4716      -thread-safe)
4717	thread_safe=yes
4718	continue
4719	;;
4720
4721      -version-info)
4722	prev=vinfo
4723	continue
4724	;;
4725
4726      -version-number)
4727	prev=vinfo
4728	vinfo_number=yes
4729	continue
4730	;;
4731
4732      -weak)
4733        prev=weak
4734	continue
4735	;;
4736
4737      -Wc,*)
4738	func_stripname '-Wc,' '' "$arg"
4739	args=$func_stripname_result
4740	arg=
4741	save_ifs="$IFS"; IFS=','
4742	for flag in $args; do
4743	  IFS="$save_ifs"
4744          func_quote_for_eval "$flag"
4745	  arg="$arg $wl$func_quote_for_eval_result"
4746	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
4747	done
4748	IFS="$save_ifs"
4749	func_stripname ' ' '' "$arg"
4750	arg=$func_stripname_result
4751	;;
4752
4753      -Wl,*)
4754	func_stripname '-Wl,' '' "$arg"
4755	args=$func_stripname_result
4756	arg=
4757	save_ifs="$IFS"; IFS=','
4758	for flag in $args; do
4759	  IFS="$save_ifs"
4760          func_quote_for_eval "$flag"
4761	  arg="$arg $wl$func_quote_for_eval_result"
4762	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4763	  linker_flags="$linker_flags $func_quote_for_eval_result"
4764	done
4765	IFS="$save_ifs"
4766	func_stripname ' ' '' "$arg"
4767	arg=$func_stripname_result
4768	;;
4769
4770      -Xcompiler)
4771	prev=xcompiler
4772	continue
4773	;;
4774
4775      -Xlinker)
4776	prev=xlinker
4777	continue
4778	;;
4779
4780      -XCClinker)
4781	prev=xcclinker
4782	continue
4783	;;
4784
4785      # -msg_* for osf cc
4786      -msg_*)
4787	func_quote_for_eval "$arg"
4788	arg="$func_quote_for_eval_result"
4789	;;
4790
4791      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4792      # -r[0-9][0-9]* specifies the processor on the SGI compiler
4793      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4794      # +DA*, +DD* enable 64-bit mode on the HP compiler
4795      # -q* pass through compiler args for the IBM compiler
4796      # -m*, -t[45]*, -txscale* pass through architecture-specific
4797      # compiler args for GCC
4798      # -F/path gives path to uninstalled frameworks, gcc on darwin
4799      # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4800      # @file GCC response files
4801      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4802      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4803        func_quote_for_eval "$arg"
4804	arg="$func_quote_for_eval_result"
4805        func_append compile_command " $arg"
4806        func_append finalize_command " $arg"
4807        compiler_flags="$compiler_flags $arg"
4808        continue
4809        ;;
4810
4811      # Some other compiler flag.
4812      -* | +*)
4813        func_quote_for_eval "$arg"
4814	arg="$func_quote_for_eval_result"
4815	;;
4816
4817      *.$objext)
4818	# A standard object.
4819	objs="$objs $arg"
4820	;;
4821
4822      *.lo)
4823	# A libtool-controlled object.
4824
4825	# Check to see that this really is a libtool object.
4826	if func_lalib_unsafe_p "$arg"; then
4827	  pic_object=
4828	  non_pic_object=
4829
4830	  # Read the .lo file
4831	  func_source "$arg"
4832
4833	  if test -z "$pic_object" ||
4834	     test -z "$non_pic_object" ||
4835	     test "$pic_object" = none &&
4836	     test "$non_pic_object" = none; then
4837	    func_fatal_error "cannot find name of object for \`$arg'"
4838	  fi
4839
4840	  # Extract subdirectory from the argument.
4841	  func_dirname "$arg" "/" ""
4842	  xdir="$func_dirname_result"
4843
4844	  if test "$pic_object" != none; then
4845	    # Prepend the subdirectory the object is found in.
4846	    pic_object="$xdir$pic_object"
4847
4848	    if test "$prev" = dlfiles; then
4849	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4850		dlfiles="$dlfiles $pic_object"
4851		prev=
4852		continue
4853	      else
4854		# If libtool objects are unsupported, then we need to preload.
4855		prev=dlprefiles
4856	      fi
4857	    fi
4858
4859	    # CHECK ME:  I think I busted this.  -Ossama
4860	    if test "$prev" = dlprefiles; then
4861	      # Preload the old-style object.
4862	      dlprefiles="$dlprefiles $pic_object"
4863	      prev=
4864	    fi
4865
4866	    # A PIC object.
4867	    func_append libobjs " $pic_object"
4868	    arg="$pic_object"
4869	  fi
4870
4871	  # Non-PIC object.
4872	  if test "$non_pic_object" != none; then
4873	    # Prepend the subdirectory the object is found in.
4874	    non_pic_object="$xdir$non_pic_object"
4875
4876	    # A standard non-PIC object
4877	    func_append non_pic_objects " $non_pic_object"
4878	    if test -z "$pic_object" || test "$pic_object" = none ; then
4879	      arg="$non_pic_object"
4880	    fi
4881	  else
4882	    # If the PIC object exists, use it instead.
4883	    # $xdir was prepended to $pic_object above.
4884	    non_pic_object="$pic_object"
4885	    func_append non_pic_objects " $non_pic_object"
4886	  fi
4887	else
4888	  # Only an error if not doing a dry-run.
4889	  if $opt_dry_run; then
4890	    # Extract subdirectory from the argument.
4891	    func_dirname "$arg" "/" ""
4892	    xdir="$func_dirname_result"
4893
4894	    func_lo2o "$arg"
4895	    pic_object=$xdir$objdir/$func_lo2o_result
4896	    non_pic_object=$xdir$func_lo2o_result
4897	    func_append libobjs " $pic_object"
4898	    func_append non_pic_objects " $non_pic_object"
4899	  else
4900	    func_fatal_error "\`$arg' is not a valid libtool object"
4901	  fi
4902	fi
4903	;;
4904
4905      *.$libext)
4906	# An archive.
4907	deplibs="$deplibs $arg"
4908	old_deplibs="$old_deplibs $arg"
4909	continue
4910	;;
4911
4912      *.la)
4913	# A libtool-controlled library.
4914
4915	if test "$prev" = dlfiles; then
4916	  # This library was specified with -dlopen.
4917	  dlfiles="$dlfiles $arg"
4918	  prev=
4919	elif test "$prev" = dlprefiles; then
4920	  # The library was specified with -dlpreopen.
4921	  dlprefiles="$dlprefiles $arg"
4922	  prev=
4923	else
4924	  deplibs="$deplibs $arg"
4925	fi
4926	continue
4927	;;
4928
4929      # Some other compiler argument.
4930      *)
4931	# Unknown arguments in both finalize_command and compile_command need
4932	# to be aesthetically quoted because they are evaled later.
4933	func_quote_for_eval "$arg"
4934	arg="$func_quote_for_eval_result"
4935	;;
4936      esac # arg
4937
4938      # Now actually substitute the argument into the commands.
4939      if test -n "$arg"; then
4940	func_append compile_command " $arg"
4941	func_append finalize_command " $arg"
4942      fi
4943    done # argument parsing loop
4944
4945    test -n "$prev" && \
4946      func_fatal_help "the \`$prevarg' option requires an argument"
4947
4948    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4949      eval arg=\"$export_dynamic_flag_spec\"
4950      func_append compile_command " $arg"
4951      func_append finalize_command " $arg"
4952    fi
4953
4954    oldlibs=
4955    # calculate the name of the file, without its directory
4956    func_basename "$output"
4957    outputname="$func_basename_result"
4958    libobjs_save="$libobjs"
4959
4960    if test -n "$shlibpath_var"; then
4961      # get the directories listed in $shlibpath_var
4962      eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
4963    else
4964      shlib_search_path=
4965    fi
4966    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4967    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4968
4969    func_dirname "$output" "/" ""
4970    output_objdir="$func_dirname_result$objdir"
4971    # Create the object directory.
4972    func_mkdir_p "$output_objdir"
4973
4974    # Determine the type of output
4975    case $output in
4976    "")
4977      func_fatal_help "you must specify an output file"
4978      ;;
4979    *.$libext) linkmode=oldlib ;;
4980    *.lo | *.$objext) linkmode=obj ;;
4981    *.la) linkmode=lib ;;
4982    *) linkmode=prog ;; # Anything else should be a program.
4983    esac
4984
4985    specialdeplibs=
4986
4987    libs=
4988    # Find all interdependent deplibs by searching for libraries
4989    # that are linked more than once (e.g. -la -lb -la)
4990    for deplib in $deplibs; do
4991      if $opt_duplicate_deps ; then
4992	case "$libs " in
4993	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4994	esac
4995      fi
4996      libs="$libs $deplib"
4997    done
4998
4999    if test "$linkmode" = lib; then
5000      libs="$predeps $libs $compiler_lib_search_path $postdeps"
5001
5002      # Compute libraries that are listed more than once in $predeps
5003      # $postdeps and mark them as special (i.e., whose duplicates are
5004      # not to be eliminated).
5005      pre_post_deps=
5006      if $opt_duplicate_compiler_generated_deps; then
5007	for pre_post_dep in $predeps $postdeps; do
5008	  case "$pre_post_deps " in
5009	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
5010	  esac
5011	  pre_post_deps="$pre_post_deps $pre_post_dep"
5012	done
5013      fi
5014      pre_post_deps=
5015    fi
5016
5017    deplibs=
5018    newdependency_libs=
5019    newlib_search_path=
5020    need_relink=no # whether we're linking any uninstalled libtool libraries
5021    notinst_deplibs= # not-installed libtool libraries
5022    notinst_path= # paths that contain not-installed libtool libraries
5023
5024    case $linkmode in
5025    lib)
5026	passes="conv dlpreopen link"
5027	for file in $dlfiles $dlprefiles; do
5028	  case $file in
5029	  *.la) ;;
5030	  *)
5031	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
5032	    ;;
5033	  esac
5034	done
5035	;;
5036    prog)
5037	compile_deplibs=
5038	finalize_deplibs=
5039	alldeplibs=no
5040	newdlfiles=
5041	newdlprefiles=
5042	passes="conv scan dlopen dlpreopen link"
5043	;;
5044    *)  passes="conv"
5045	;;
5046    esac
5047
5048    for pass in $passes; do
5049      # The preopen pass in lib mode reverses $deplibs; put it back here
5050      # so that -L comes before libs that need it for instance...
5051      if test "$linkmode,$pass" = "lib,link"; then
5052	## FIXME: Find the place where the list is rebuilt in the wrong
5053	##        order, and fix it there properly
5054        tmp_deplibs=
5055	for deplib in $deplibs; do
5056	  tmp_deplibs="$deplib $tmp_deplibs"
5057	done
5058	deplibs="$tmp_deplibs"
5059      fi
5060
5061      if test "$linkmode,$pass" = "lib,link" ||
5062	 test "$linkmode,$pass" = "prog,scan"; then
5063	libs="$deplibs"
5064	deplibs=
5065      fi
5066      if test "$linkmode" = prog; then
5067	case $pass in
5068	dlopen) libs="$dlfiles" ;;
5069	dlpreopen) libs="$dlprefiles" ;;
5070	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
5071	esac
5072      fi
5073      if test "$linkmode,$pass" = "lib,dlpreopen"; then
5074	# Collect and forward deplibs of preopened libtool libs
5075	for lib in $dlprefiles; do
5076	  # Ignore non-libtool-libs
5077	  dependency_libs=
5078	  case $lib in
5079	  *.la)	func_source "$lib" ;;
5080	  esac
5081
5082	  # Collect preopened libtool deplibs, except any this library
5083	  # has declared as weak libs
5084	  for deplib in $dependency_libs; do
5085            deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
5086	    case " $weak_libs " in
5087	    *" $deplib_base "*) ;;
5088	    *) deplibs="$deplibs $deplib" ;;
5089	    esac
5090	  done
5091	done
5092	libs="$dlprefiles"
5093      fi
5094      if test "$pass" = dlopen; then
5095	# Collect dlpreopened libraries
5096	save_deplibs="$deplibs"
5097	deplibs=
5098      fi
5099
5100      for deplib in $libs; do
5101	lib=
5102	found=no
5103	case $deplib in
5104	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5105	  if test "$linkmode,$pass" = "prog,link"; then
5106	    compile_deplibs="$deplib $compile_deplibs"
5107	    finalize_deplibs="$deplib $finalize_deplibs"
5108	  else
5109	    compiler_flags="$compiler_flags $deplib"
5110	  fi
5111
5112	  case $linkmode in
5113	  lib)
5114	    deplibs="$deplib $deplibs"
5115	    test "$pass" = conv && continue
5116	    newdependency_libs="$deplib $newdependency_libs"
5117	    ;;
5118	  prog)
5119	    if test "$pass" = conv; then
5120	      deplibs="$deplib $deplibs"
5121	      continue
5122	    fi
5123	    if test "$pass" = scan; then
5124	      deplibs="$deplib $deplibs"
5125	    else
5126	      compile_deplibs="$deplib $compile_deplibs"
5127	      finalize_deplibs="$deplib $finalize_deplibs"
5128	    fi
5129	    ;;
5130	  *)
5131	    ;;
5132	  esac # linkmode
5133
5134	  continue
5135	  ;;
5136	-l*)
5137	  if test "$linkmode" != lib && test "$linkmode" != prog; then
5138	    func_warning "\`-l' is ignored for archives/objects"
5139	    continue
5140	  fi
5141	  func_stripname '-l' '' "$deplib"
5142	  name=$func_stripname_result
5143	  if test "$linkmode" = lib; then
5144	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5145	  else
5146	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5147	  fi
5148	  for searchdir in $searchdirs; do
5149	    for search_ext in .la $std_shrext .so .a; do
5150	      # Search the libtool library
5151	      lib="$searchdir/lib${name}${search_ext}"
5152	      if test -f "$lib"; then
5153		if test "$search_ext" = ".la"; then
5154		  found=yes
5155		else
5156		  found=no
5157		fi
5158		break 2
5159	      fi
5160	    done
5161	  done
5162	  if test "$found" != yes; then
5163	    # deplib doesn't seem to be a libtool library
5164	    if test "$linkmode,$pass" = "prog,link"; then
5165	      compile_deplibs="$deplib $compile_deplibs"
5166	      finalize_deplibs="$deplib $finalize_deplibs"
5167	    else
5168	      deplibs="$deplib $deplibs"
5169	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5170	    fi
5171	    continue
5172	  else # deplib is a libtool library
5173	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5174	    # We need to do some special things here, and not later.
5175	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5176	      case " $predeps $postdeps " in
5177	      *" $deplib "*)
5178		if func_lalib_p "$lib"; then
5179		  library_names=
5180		  old_library=
5181		  func_source "$lib"
5182		  for l in $old_library $library_names; do
5183		    ll="$l"
5184		  done
5185		  if test "X$ll" = "X$old_library" ; then # only static version available
5186		    found=no
5187		    func_dirname "$lib" "" "."
5188		    ladir="$func_dirname_result"
5189		    lib=$ladir/$old_library
5190		    if test "$linkmode,$pass" = "prog,link"; then
5191		      compile_deplibs="$deplib $compile_deplibs"
5192		      finalize_deplibs="$deplib $finalize_deplibs"
5193		    else
5194		      deplibs="$deplib $deplibs"
5195		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5196		    fi
5197		    continue
5198		  fi
5199		fi
5200		;;
5201	      *) ;;
5202	      esac
5203	    fi
5204	  fi
5205	  ;; # -l
5206	*.ltframework)
5207	  if test "$linkmode,$pass" = "prog,link"; then
5208	    compile_deplibs="$deplib $compile_deplibs"
5209	    finalize_deplibs="$deplib $finalize_deplibs"
5210	  else
5211	    deplibs="$deplib $deplibs"
5212	    if test "$linkmode" = lib ; then
5213		case "$new_inherited_linker_flags " in
5214		    *" $deplib "*) ;;
5215		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5216		esac
5217	    fi
5218	  fi
5219	  continue
5220	  ;;
5221	-L*)
5222	  case $linkmode in
5223	  lib)
5224	    deplibs="$deplib $deplibs"
5225	    test "$pass" = conv && continue
5226	    newdependency_libs="$deplib $newdependency_libs"
5227	    func_stripname '-L' '' "$deplib"
5228	    newlib_search_path="$newlib_search_path $func_stripname_result"
5229	    ;;
5230	  prog)
5231	    if test "$pass" = conv; then
5232	      deplibs="$deplib $deplibs"
5233	      continue
5234	    fi
5235	    if test "$pass" = scan; then
5236	      deplibs="$deplib $deplibs"
5237	    else
5238	      compile_deplibs="$deplib $compile_deplibs"
5239	      finalize_deplibs="$deplib $finalize_deplibs"
5240	    fi
5241	    func_stripname '-L' '' "$deplib"
5242	    newlib_search_path="$newlib_search_path $func_stripname_result"
5243	    ;;
5244	  *)
5245	    func_warning "\`-L' is ignored for archives/objects"
5246	    ;;
5247	  esac # linkmode
5248	  continue
5249	  ;; # -L
5250	-R*)
5251	  if test "$pass" = link; then
5252	    func_stripname '-R' '' "$deplib"
5253	    dir=$func_stripname_result
5254	    # Make sure the xrpath contains only unique directories.
5255	    case "$xrpath " in
5256	    *" $dir "*) ;;
5257	    *) xrpath="$xrpath $dir" ;;
5258	    esac
5259	  fi
5260	  deplibs="$deplib $deplibs"
5261	  continue
5262	  ;;
5263	*.la) lib="$deplib" ;;
5264	*.$libext)
5265	  if test "$pass" = conv; then
5266	    deplibs="$deplib $deplibs"
5267	    continue
5268	  fi
5269	  case $linkmode in
5270	  lib)
5271	    # Linking convenience modules into shared libraries is allowed,
5272	    # but linking other static libraries is non-portable.
5273	    case " $dlpreconveniencelibs " in
5274	    *" $deplib "*) ;;
5275	    *)
5276	      valid_a_lib=no
5277	      case $deplibs_check_method in
5278		match_pattern*)
5279		  set dummy $deplibs_check_method; shift
5280		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5281		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
5282		    | $EGREP "$match_pattern_regex" > /dev/null; then
5283		    valid_a_lib=yes
5284		  fi
5285		;;
5286		pass_all)
5287		  valid_a_lib=yes
5288		;;
5289	      esac
5290	      if test "$valid_a_lib" != yes; then
5291		$ECHO
5292		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
5293		$ECHO "*** I have the capability to make that library automatically link in when"
5294		$ECHO "*** you link to this library.  But I can only do this if you have a"
5295		$ECHO "*** shared version of the library, which you do not appear to have"
5296		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
5297		$ECHO "*** that it is just a static archive that I should not use here."
5298	      else
5299		$ECHO
5300		$ECHO "*** Warning: Linking the shared library $output against the"
5301		$ECHO "*** static library $deplib is not portable!"
5302		deplibs="$deplib $deplibs"
5303	      fi
5304	      ;;
5305	    esac
5306	    continue
5307	    ;;
5308	  prog)
5309	    if test "$pass" != link; then
5310	      deplibs="$deplib $deplibs"
5311	    else
5312	      compile_deplibs="$deplib $compile_deplibs"
5313	      finalize_deplibs="$deplib $finalize_deplibs"
5314	    fi
5315	    continue
5316	    ;;
5317	  esac # linkmode
5318	  ;; # *.$libext
5319	*.lo | *.$objext)
5320	  if test "$pass" = conv; then
5321	    deplibs="$deplib $deplibs"
5322	  elif test "$linkmode" = prog; then
5323	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5324	      # If there is no dlopen support or we're linking statically,
5325	      # we need to preload.
5326	      newdlprefiles="$newdlprefiles $deplib"
5327	      compile_deplibs="$deplib $compile_deplibs"
5328	      finalize_deplibs="$deplib $finalize_deplibs"
5329	    else
5330	      newdlfiles="$newdlfiles $deplib"
5331	    fi
5332	  fi
5333	  continue
5334	  ;;
5335	%DEPLIBS%)
5336	  alldeplibs=yes
5337	  continue
5338	  ;;
5339	esac # case $deplib
5340
5341	if test "$found" = yes || test -f "$lib"; then :
5342	else
5343	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5344	fi
5345
5346	# Check to see that this really is a libtool archive.
5347	func_lalib_unsafe_p "$lib" \
5348	  || func_fatal_error "\`$lib' is not a valid libtool archive"
5349
5350	func_dirname "$lib" "" "."
5351	ladir="$func_dirname_result"
5352
5353	dlname=
5354	dlopen=
5355	dlpreopen=
5356	libdir=
5357	library_names=
5358	old_library=
5359	inherited_linker_flags=
5360	# If the library was installed with an old release of libtool,
5361	# it will not redefine variables installed, or shouldnotlink
5362	installed=yes
5363	shouldnotlink=no
5364	avoidtemprpath=
5365
5366
5367	# Read the .la file
5368	func_source "$lib"
5369
5370	# Convert "-framework foo" to "foo.ltframework"
5371	if test -n "$inherited_linker_flags"; then
5372	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
5373	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5374	    case " $new_inherited_linker_flags " in
5375	      *" $tmp_inherited_linker_flag "*) ;;
5376	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5377	    esac
5378	  done
5379	fi
5380	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5381	if test "$linkmode,$pass" = "lib,link" ||
5382	   test "$linkmode,$pass" = "prog,scan" ||
5383	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5384	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5385	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5386	fi
5387
5388	if test "$pass" = conv; then
5389	  # Only check for convenience libraries
5390	  deplibs="$lib $deplibs"
5391	  if test -z "$libdir"; then
5392	    if test -z "$old_library"; then
5393	      func_fatal_error "cannot find name of link library for \`$lib'"
5394	    fi
5395	    # It is a libtool convenience library, so add in its objects.
5396	    convenience="$convenience $ladir/$objdir/$old_library"
5397	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
5398	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
5399	    func_fatal_error "\`$lib' is not a convenience library"
5400	  fi
5401	  tmp_libs=
5402	  for deplib in $dependency_libs; do
5403	    deplibs="$deplib $deplibs"
5404	    if $opt_duplicate_deps ; then
5405	      case "$tmp_libs " in
5406	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5407	      esac
5408	    fi
5409	    tmp_libs="$tmp_libs $deplib"
5410	  done
5411	  continue
5412	fi # $pass = conv
5413
5414
5415	# Get the name of the library we link against.
5416	linklib=
5417	for l in $old_library $library_names; do
5418	  linklib="$l"
5419	done
5420	if test -z "$linklib"; then
5421	  func_fatal_error "cannot find name of link library for \`$lib'"
5422	fi
5423
5424	# This library was specified with -dlopen.
5425	if test "$pass" = dlopen; then
5426	  if test -z "$libdir"; then
5427	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5428	  fi
5429	  if test -z "$dlname" ||
5430	     test "$dlopen_support" != yes ||
5431	     test "$build_libtool_libs" = no; then
5432	    # If there is no dlname, no dlopen support or we're linking
5433	    # statically, we need to preload.  We also need to preload any
5434	    # dependent libraries so libltdl's deplib preloader doesn't
5435	    # bomb out in the load deplibs phase.
5436	    dlprefiles="$dlprefiles $lib $dependency_libs"
5437	  else
5438	    newdlfiles="$newdlfiles $lib"
5439	  fi
5440	  continue
5441	fi # $pass = dlopen
5442
5443	# We need an absolute path.
5444	case $ladir in
5445	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5446	*)
5447	  abs_ladir=`cd "$ladir" && pwd`
5448	  if test -z "$abs_ladir"; then
5449	    func_warning "cannot determine absolute directory name of \`$ladir'"
5450	    func_warning "passing it literally to the linker, although it might fail"
5451	    abs_ladir="$ladir"
5452	  fi
5453	  ;;
5454	esac
5455	func_basename "$lib"
5456	laname="$func_basename_result"
5457
5458	# Find the relevant object directory and library name.
5459	if test "X$installed" = Xyes; then
5460	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5461	    func_warning "library \`$lib' was moved."
5462	    dir="$ladir"
5463	    absdir="$abs_ladir"
5464	    libdir="$abs_ladir"
5465	  else
5466	    dir="$libdir"
5467	    absdir="$libdir"
5468	  fi
5469	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5470	else
5471	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5472	    dir="$ladir"
5473	    absdir="$abs_ladir"
5474	    # Remove this search path later
5475	    notinst_path="$notinst_path $abs_ladir"
5476	  else
5477	    dir="$ladir/$objdir"
5478	    absdir="$abs_ladir/$objdir"
5479	    # Remove this search path later
5480	    notinst_path="$notinst_path $abs_ladir"
5481	  fi
5482	fi # $installed = yes
5483	func_stripname 'lib' '.la' "$laname"
5484	name=$func_stripname_result
5485
5486	# This library was specified with -dlpreopen.
5487	if test "$pass" = dlpreopen; then
5488	  if test -z "$libdir" && test "$linkmode" = prog; then
5489	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5490	  fi
5491	  # Prefer using a static library (so that no silly _DYNAMIC symbols
5492	  # are required to link).
5493	  if test -n "$old_library"; then
5494	    newdlprefiles="$newdlprefiles $dir/$old_library"
5495	    # Keep a list of preopened convenience libraries to check
5496	    # that they are being used correctly in the link pass.
5497	    test -z "$libdir" && \
5498		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5499	  # Otherwise, use the dlname, so that lt_dlopen finds it.
5500	  elif test -n "$dlname"; then
5501	    newdlprefiles="$newdlprefiles $dir/$dlname"
5502	  else
5503	    newdlprefiles="$newdlprefiles $dir/$linklib"
5504	  fi
5505	fi # $pass = dlpreopen
5506
5507	if test -z "$libdir"; then
5508	  # Link the convenience library
5509	  if test "$linkmode" = lib; then
5510	    deplibs="$dir/$old_library $deplibs"
5511	  elif test "$linkmode,$pass" = "prog,link"; then
5512	    compile_deplibs="$dir/$old_library $compile_deplibs"
5513	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
5514	  else
5515	    deplibs="$lib $deplibs" # used for prog,scan pass
5516	  fi
5517	  continue
5518	fi
5519
5520
5521	if test "$linkmode" = prog && test "$pass" != link; then
5522	  newlib_search_path="$newlib_search_path $ladir"
5523	  deplibs="$lib $deplibs"
5524
5525	  linkalldeplibs=no
5526	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
5527	     test "$build_libtool_libs" = no; then
5528	    linkalldeplibs=yes
5529	  fi
5530
5531	  tmp_libs=
5532	  for deplib in $dependency_libs; do
5533	    case $deplib in
5534	    -L*) func_stripname '-L' '' "$deplib"
5535	         newlib_search_path="$newlib_search_path $func_stripname_result"
5536		 ;;
5537	    esac
5538	    # Need to link against all dependency_libs?
5539	    if test "$linkalldeplibs" = yes; then
5540	      deplibs="$deplib $deplibs"
5541	    else
5542	      # Need to hardcode shared library paths
5543	      # or/and link against static libraries
5544	      newdependency_libs="$deplib $newdependency_libs"
5545	    fi
5546	    if $opt_duplicate_deps ; then
5547	      case "$tmp_libs " in
5548	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5549	      esac
5550	    fi
5551	    tmp_libs="$tmp_libs $deplib"
5552	  done # for deplib
5553	  continue
5554	fi # $linkmode = prog...
5555
5556	if test "$linkmode,$pass" = "prog,link"; then
5557	  if test -n "$library_names" &&
5558	     { { test "$prefer_static_libs" = no ||
5559	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
5560	       test -z "$old_library"; }; then
5561	    # We need to hardcode the library path
5562	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5563	      # Make sure the rpath contains only unique directories.
5564	      case "$temp_rpath:" in
5565	      *"$absdir:"*) ;;
5566	      *) temp_rpath="$temp_rpath$absdir:" ;;
5567	      esac
5568	    fi
5569
5570	    # Hardcode the library path.
5571	    # Skip directories that are in the system default run-time
5572	    # search path.
5573	    case " $sys_lib_dlsearch_path " in
5574	    *" $absdir "*) ;;
5575	    *)
5576	      case "$compile_rpath " in
5577	      *" $absdir "*) ;;
5578	      *) compile_rpath="$compile_rpath $absdir"
5579	      esac
5580	      ;;
5581	    esac
5582	    case " $sys_lib_dlsearch_path " in
5583	    *" $libdir "*) ;;
5584	    *)
5585	      case "$finalize_rpath " in
5586	      *" $libdir "*) ;;
5587	      *) finalize_rpath="$finalize_rpath $libdir"
5588	      esac
5589	      ;;
5590	    esac
5591	  fi # $linkmode,$pass = prog,link...
5592
5593	  if test "$alldeplibs" = yes &&
5594	     { test "$deplibs_check_method" = pass_all ||
5595	       { test "$build_libtool_libs" = yes &&
5596		 test -n "$library_names"; }; }; then
5597	    # We only need to search for static libraries
5598	    continue
5599	  fi
5600	fi
5601
5602	link_static=no # Whether the deplib will be linked statically
5603	use_static_libs=$prefer_static_libs
5604	if test "$use_static_libs" = built && test "$installed" = yes; then
5605	  use_static_libs=no
5606	fi
5607	if test -n "$library_names" &&
5608	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
5609	  case $host in
5610	  *cygwin* | *mingw* | *cegcc*)
5611	      # No point in relinking DLLs because paths are not encoded
5612	      notinst_deplibs="$notinst_deplibs $lib"
5613	      need_relink=no
5614	    ;;
5615	  *)
5616	    if test "$installed" = no; then
5617	      notinst_deplibs="$notinst_deplibs $lib"
5618	      need_relink=yes
5619	    fi
5620	    ;;
5621	  esac
5622	  # This is a shared library
5623
5624	  # Warn about portability, can't link against -module's on some
5625	  # systems (darwin).  Don't bleat about dlopened modules though!
5626	  dlopenmodule=""
5627	  for dlpremoduletest in $dlprefiles; do
5628	    if test "X$dlpremoduletest" = "X$lib"; then
5629	      dlopenmodule="$dlpremoduletest"
5630	      break
5631	    fi
5632	  done
5633	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5634	    $ECHO
5635	    if test "$linkmode" = prog; then
5636	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
5637	    else
5638	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5639	    fi
5640	    $ECHO "*** $linklib is not portable!"
5641	  fi
5642	  if test "$linkmode" = lib &&
5643	     test "$hardcode_into_libs" = yes; then
5644	    # Hardcode the library path.
5645	    # Skip directories that are in the system default run-time
5646	    # search path.
5647	    case " $sys_lib_dlsearch_path " in
5648	    *" $absdir "*) ;;
5649	    *)
5650	      case "$compile_rpath " in
5651	      *" $absdir "*) ;;
5652	      *) compile_rpath="$compile_rpath $absdir"
5653	      esac
5654	      ;;
5655	    esac
5656	    case " $sys_lib_dlsearch_path " in
5657	    *" $libdir "*) ;;
5658	    *)
5659	      case "$finalize_rpath " in
5660	      *" $libdir "*) ;;
5661	      *) finalize_rpath="$finalize_rpath $libdir"
5662	      esac
5663	      ;;
5664	    esac
5665	  fi
5666
5667	  if test -n "$old_archive_from_expsyms_cmds"; then
5668	    # figure out the soname
5669	    set dummy $library_names
5670	    shift
5671	    realname="$1"
5672	    shift
5673	    libname=`eval "\\$ECHO \"$libname_spec\""`
5674	    # use dlname if we got it. it's perfectly good, no?
5675	    if test -n "$dlname"; then
5676	      soname="$dlname"
5677	    elif test -n "$soname_spec"; then
5678	      # bleh windows
5679	      case $host in
5680	      *cygwin* | mingw* | *cegcc*)
5681	        func_arith $current - $age
5682		major=$func_arith_result
5683		versuffix="-$major"
5684		;;
5685	      esac
5686	      eval soname=\"$soname_spec\"
5687	    else
5688	      soname="$realname"
5689	    fi
5690
5691	    # Make a new name for the extract_expsyms_cmds to use
5692	    soroot="$soname"
5693	    func_basename "$soroot"
5694	    soname="$func_basename_result"
5695	    func_stripname 'lib' '.dll' "$soname"
5696	    newlib=libimp-$func_stripname_result.a
5697
5698	    # If the library has no export list, then create one now
5699	    if test -f "$output_objdir/$soname-def"; then :
5700	    else
5701	      func_verbose "extracting exported symbol list from \`$soname'"
5702	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5703	    fi
5704
5705	    # Create $newlib
5706	    if test -f "$output_objdir/$newlib"; then :; else
5707	      func_verbose "generating import library for \`$soname'"
5708	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5709	    fi
5710	    # make sure the library variables are pointing to the new library
5711	    dir=$output_objdir
5712	    linklib=$newlib
5713	  fi # test -n "$old_archive_from_expsyms_cmds"
5714
5715	  if test "$linkmode" = prog || test "$mode" != relink; then
5716	    add_shlibpath=
5717	    add_dir=
5718	    add=
5719	    lib_linked=yes
5720	    case $hardcode_action in
5721	    immediate | unsupported)
5722	      if test "$hardcode_direct" = no; then
5723		add="$dir/$linklib"
5724		case $host in
5725		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5726		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5727		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5728		    *-*-unixware7*) add_dir="-L$dir" ;;
5729		  *-*-darwin* )
5730		    # if the lib is a (non-dlopened) module then we can not
5731		    # link against it, someone is ignoring the earlier warnings
5732		    if /usr/bin/file -L $add 2> /dev/null |
5733			 $GREP ": [^:]* bundle" >/dev/null ; then
5734		      if test "X$dlopenmodule" != "X$lib"; then
5735			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
5736			if test -z "$old_library" ; then
5737			  $ECHO
5738			  $ECHO "*** And there doesn't seem to be a static archive available"
5739			  $ECHO "*** The link will probably fail, sorry"
5740			else
5741			  add="$dir/$old_library"
5742			fi
5743		      elif test -n "$old_library"; then
5744			add="$dir/$old_library"
5745		      fi
5746		    fi
5747		esac
5748	      elif test "$hardcode_minus_L" = no; then
5749		case $host in
5750		*-*-sunos*) add_shlibpath="$dir" ;;
5751		esac
5752		add_dir="-L$dir"
5753		add="-l$name"
5754	      elif test "$hardcode_shlibpath_var" = no; then
5755		add_shlibpath="$dir"
5756		add="-l$name"
5757	      else
5758		lib_linked=no
5759	      fi
5760	      ;;
5761	    relink)
5762	      if test "$hardcode_direct" = yes &&
5763	         test "$hardcode_direct_absolute" = no; then
5764		add="$dir/$linklib"
5765	      elif test "$hardcode_minus_L" = yes; then
5766		add_dir="-L$dir"
5767		# Try looking first in the location we're being installed to.
5768		if test -n "$inst_prefix_dir"; then
5769		  case $libdir in
5770		    [\\/]*)
5771		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
5772		      ;;
5773		  esac
5774		fi
5775		add="-l$name"
5776	      elif test "$hardcode_shlibpath_var" = yes; then
5777		add_shlibpath="$dir"
5778		add="-l$name"
5779	      else
5780		lib_linked=no
5781	      fi
5782	      ;;
5783	    *) lib_linked=no ;;
5784	    esac
5785
5786	    if test "$lib_linked" != yes; then
5787	      func_fatal_configuration "unsupported hardcode properties"
5788	    fi
5789
5790	    if test -n "$add_shlibpath"; then
5791	      case :$compile_shlibpath: in
5792	      *":$add_shlibpath:"*) ;;
5793	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5794	      esac
5795	    fi
5796	    if test "$linkmode" = prog; then
5797	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5798	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
5799	    else
5800	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5801	      test -n "$add" && deplibs="$add $deplibs"
5802	      if test "$hardcode_direct" != yes &&
5803		 test "$hardcode_minus_L" != yes &&
5804		 test "$hardcode_shlibpath_var" = yes; then
5805		case :$finalize_shlibpath: in
5806		*":$libdir:"*) ;;
5807		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5808		esac
5809	      fi
5810	    fi
5811	  fi
5812
5813	  if test "$linkmode" = prog || test "$mode" = relink; then
5814	    add_shlibpath=
5815	    add_dir=
5816	    add=
5817	    # Finalize command for both is simple: just hardcode it.
5818	    if test "$hardcode_direct" = yes &&
5819	       test "$hardcode_direct_absolute" = no; then
5820	      add="$libdir/$linklib"
5821	    elif test "$hardcode_minus_L" = yes; then
5822	      add_dir="-L$libdir"
5823	      add="-l$name"
5824	    elif test "$hardcode_shlibpath_var" = yes; then
5825	      case :$finalize_shlibpath: in
5826	      *":$libdir:"*) ;;
5827	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5828	      esac
5829	      add="-l$name"
5830	    elif test "$hardcode_automatic" = yes; then
5831	      if test -n "$inst_prefix_dir" &&
5832		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
5833		add="$inst_prefix_dir$libdir/$linklib"
5834	      else
5835		add="$libdir/$linklib"
5836	      fi
5837	    else
5838	      # We cannot seem to hardcode it, guess we'll fake it.
5839	      add_dir="-L$libdir"
5840	      # Try looking first in the location we're being installed to.
5841	      if test -n "$inst_prefix_dir"; then
5842		case $libdir in
5843		  [\\/]*)
5844		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
5845		    ;;
5846		esac
5847	      fi
5848	      add="-l$name"
5849	    fi
5850
5851	    if test "$linkmode" = prog; then
5852	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5853	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5854	    else
5855	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
5856	      test -n "$add" && deplibs="$add $deplibs"
5857	    fi
5858	  fi
5859	elif test "$linkmode" = prog; then
5860	  # Here we assume that one of hardcode_direct or hardcode_minus_L
5861	  # is not unsupported.  This is valid on all known static and
5862	  # shared platforms.
5863	  if test "$hardcode_direct" != unsupported; then
5864	    test -n "$old_library" && linklib="$old_library"
5865	    compile_deplibs="$dir/$linklib $compile_deplibs"
5866	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
5867	  else
5868	    compile_deplibs="-l$name -L$dir $compile_deplibs"
5869	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5870	  fi
5871	elif test "$build_libtool_libs" = yes; then
5872	  # Not a shared library
5873	  if test "$deplibs_check_method" != pass_all; then
5874	    # We're trying link a shared library against a static one
5875	    # but the system doesn't support it.
5876
5877	    # Just print a warning and add the library to dependency_libs so
5878	    # that the program can be linked against the static library.
5879	    $ECHO
5880	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
5881	    $ECHO "*** I have the capability to make that library automatically link in when"
5882	    $ECHO "*** you link to this library.  But I can only do this if you have a"
5883	    $ECHO "*** shared version of the library, which you do not appear to have."
5884	    if test "$module" = yes; then
5885	      $ECHO "*** But as you try to build a module library, libtool will still create "
5886	      $ECHO "*** a static module, that should work as long as the dlopening application"
5887	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
5888	      if test -z "$global_symbol_pipe"; then
5889		$ECHO
5890		$ECHO "*** However, this would only work if libtool was able to extract symbol"
5891		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5892		$ECHO "*** not find such a program.  So, this module is probably useless."
5893		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
5894	      fi
5895	      if test "$build_old_libs" = no; then
5896		build_libtool_libs=module
5897		build_old_libs=yes
5898	      else
5899		build_libtool_libs=no
5900	      fi
5901	    fi
5902	  else
5903	    deplibs="$dir/$old_library $deplibs"
5904	    link_static=yes
5905	  fi
5906	fi # link shared/static library?
5907
5908	if test "$linkmode" = lib; then
5909	  if test -n "$dependency_libs" &&
5910	     { test "$hardcode_into_libs" != yes ||
5911	       test "$build_old_libs" = yes ||
5912	       test "$link_static" = yes; }; then
5913	    # Extract -R from dependency_libs
5914	    temp_deplibs=
5915	    for libdir in $dependency_libs; do
5916	      case $libdir in
5917	      -R*) func_stripname '-R' '' "$libdir"
5918	           temp_xrpath=$func_stripname_result
5919		   case " $xrpath " in
5920		   *" $temp_xrpath "*) ;;
5921		   *) xrpath="$xrpath $temp_xrpath";;
5922		   esac;;
5923	      *) temp_deplibs="$temp_deplibs $libdir";;
5924	      esac
5925	    done
5926	    dependency_libs="$temp_deplibs"
5927	  fi
5928
5929	  newlib_search_path="$newlib_search_path $absdir"
5930	  # Link against this library
5931	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5932	  # ... and its dependency_libs
5933	  tmp_libs=
5934	  for deplib in $dependency_libs; do
5935	    newdependency_libs="$deplib $newdependency_libs"
5936	    if $opt_duplicate_deps ; then
5937	      case "$tmp_libs " in
5938	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5939	      esac
5940	    fi
5941	    tmp_libs="$tmp_libs $deplib"
5942	  done
5943
5944	  if test "$link_all_deplibs" != no; then
5945	    # Add the search paths of all dependency libraries
5946	    for deplib in $dependency_libs; do
5947	      case $deplib in
5948	      -L*) path="$deplib" ;;
5949	      *.la)
5950	        func_dirname "$deplib" "" "."
5951		dir="$func_dirname_result"
5952		# We need an absolute path.
5953		case $dir in
5954		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5955		*)
5956		  absdir=`cd "$dir" && pwd`
5957		  if test -z "$absdir"; then
5958		    func_warning "cannot determine absolute directory name of \`$dir'"
5959		    absdir="$dir"
5960		  fi
5961		  ;;
5962		esac
5963		if $GREP "^installed=no" $deplib > /dev/null; then
5964		case $host in
5965		*-*-darwin*)
5966		  depdepl=
5967		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5968		  if test -n "$deplibrary_names" ; then
5969		    for tmp in $deplibrary_names ; do
5970		      depdepl=$tmp
5971		    done
5972		    if test -f "$absdir/$objdir/$depdepl" ; then
5973		      depdepl="$absdir/$objdir/$depdepl"
5974		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5975                      if test -z "$darwin_install_name"; then
5976                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
5977                      fi
5978		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5979		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5980		      path=
5981		    fi
5982		  fi
5983		  ;;
5984		*)
5985		  path="-L$absdir/$objdir"
5986		  ;;
5987		esac
5988		else
5989		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5990		  test -z "$libdir" && \
5991		    func_fatal_error "\`$deplib' is not a valid libtool archive"
5992		  test "$absdir" != "$libdir" && \
5993		    func_warning "\`$deplib' seems to be moved"
5994
5995		  path="-L$absdir"
5996		fi
5997		;;
5998	      esac
5999	      case " $deplibs " in
6000	      *" $path "*) ;;
6001	      *) deplibs="$path $deplibs" ;;
6002	      esac
6003	    done
6004	  fi # link_all_deplibs != no
6005	fi # linkmode = lib
6006      done # for deplib in $libs
6007      if test "$pass" = link; then
6008	if test "$linkmode" = "prog"; then
6009	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
6010	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
6011	else
6012	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6013	fi
6014      fi
6015      dependency_libs="$newdependency_libs"
6016      if test "$pass" = dlpreopen; then
6017	# Link the dlpreopened libraries before other libraries
6018	for deplib in $save_deplibs; do
6019	  deplibs="$deplib $deplibs"
6020	done
6021      fi
6022      if test "$pass" != dlopen; then
6023	if test "$pass" != conv; then
6024	  # Make sure lib_search_path contains only unique directories.
6025	  lib_search_path=
6026	  for dir in $newlib_search_path; do
6027	    case "$lib_search_path " in
6028	    *" $dir "*) ;;
6029	    *) lib_search_path="$lib_search_path $dir" ;;
6030	    esac
6031	  done
6032	  newlib_search_path=
6033	fi
6034
6035	if test "$linkmode,$pass" != "prog,link"; then
6036	  vars="deplibs"
6037	else
6038	  vars="compile_deplibs finalize_deplibs"
6039	fi
6040	for var in $vars dependency_libs; do
6041	  # Add libraries to $var in reverse order
6042	  eval tmp_libs=\"\$$var\"
6043	  new_libs=
6044	  for deplib in $tmp_libs; do
6045	    # FIXME: Pedantically, this is the right thing to do, so
6046	    #        that some nasty dependency loop isn't accidentally
6047	    #        broken:
6048	    #new_libs="$deplib $new_libs"
6049	    # Pragmatically, this seems to cause very few problems in
6050	    # practice:
6051	    case $deplib in
6052	    -L*) new_libs="$deplib $new_libs" ;;
6053	    -R*) ;;
6054	    *)
6055	      # And here is the reason: when a library appears more
6056	      # than once as an explicit dependence of a library, or
6057	      # is implicitly linked in more than once by the
6058	      # compiler, it is considered special, and multiple
6059	      # occurrences thereof are not removed.  Compare this
6060	      # with having the same library being listed as a
6061	      # dependency of multiple other libraries: in this case,
6062	      # we know (pedantically, we assume) the library does not
6063	      # need to be listed more than once, so we keep only the
6064	      # last copy.  This is not always right, but it is rare
6065	      # enough that we require users that really mean to play
6066	      # such unportable linking tricks to link the library
6067	      # using -Wl,-lname, so that libtool does not consider it
6068	      # for duplicate removal.
6069	      case " $specialdeplibs " in
6070	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
6071	      *)
6072		case " $new_libs " in
6073		*" $deplib "*) ;;
6074		*) new_libs="$deplib $new_libs" ;;
6075		esac
6076		;;
6077	      esac
6078	      ;;
6079	    esac
6080	  done
6081	  tmp_libs=
6082	  for deplib in $new_libs; do
6083	    case $deplib in
6084	    -L*)
6085	      case " $tmp_libs " in
6086	      *" $deplib "*) ;;
6087	      *) tmp_libs="$tmp_libs $deplib" ;;
6088	      esac
6089	      ;;
6090	    *) tmp_libs="$tmp_libs $deplib" ;;
6091	    esac
6092	  done
6093	  eval $var=\"$tmp_libs\"
6094	done # for var
6095      fi
6096      # Last step: remove runtime libs from dependency_libs
6097      # (they stay in deplibs)
6098      tmp_libs=
6099      for i in $dependency_libs ; do
6100	case " $predeps $postdeps $compiler_lib_search_path " in
6101	*" $i "*)
6102	  i=""
6103	  ;;
6104	esac
6105	if test -n "$i" ; then
6106	  tmp_libs="$tmp_libs $i"
6107	fi
6108      done
6109      dependency_libs=$tmp_libs
6110    done # for pass
6111    if test "$linkmode" = prog; then
6112      dlfiles="$newdlfiles"
6113    fi
6114    if test "$linkmode" = prog || test "$linkmode" = lib; then
6115      dlprefiles="$newdlprefiles"
6116    fi
6117
6118    case $linkmode in
6119    oldlib)
6120      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6121	func_warning "\`-dlopen' is ignored for archives"
6122      fi
6123
6124      case " $deplibs" in
6125      *\ -l* | *\ -L*)
6126	func_warning "\`-l' and \`-L' are ignored for archives" ;;
6127      esac
6128
6129      test -n "$rpath" && \
6130	func_warning "\`-rpath' is ignored for archives"
6131
6132      test -n "$xrpath" && \
6133	func_warning "\`-R' is ignored for archives"
6134
6135      test -n "$vinfo" && \
6136	func_warning "\`-version-info/-version-number' is ignored for archives"
6137
6138      test -n "$release" && \
6139	func_warning "\`-release' is ignored for archives"
6140
6141      test -n "$export_symbols$export_symbols_regex" && \
6142	func_warning "\`-export-symbols' is ignored for archives"
6143
6144      # Now set the variables for building old libraries.
6145      build_libtool_libs=no
6146      oldlibs="$output"
6147      objs="$objs$old_deplibs"
6148      ;;
6149
6150    lib)
6151      # Make sure we only generate libraries of the form `libNAME.la'.
6152      case $outputname in
6153      lib*)
6154	func_stripname 'lib' '.la' "$outputname"
6155	name=$func_stripname_result
6156	eval shared_ext=\"$shrext_cmds\"
6157	eval libname=\"$libname_spec\"
6158	;;
6159      *)
6160	test "$module" = no && \
6161	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
6162
6163	if test "$need_lib_prefix" != no; then
6164	  # Add the "lib" prefix for modules if required
6165	  func_stripname '' '.la' "$outputname"
6166	  name=$func_stripname_result
6167	  eval shared_ext=\"$shrext_cmds\"
6168	  eval libname=\"$libname_spec\"
6169	else
6170	  func_stripname '' '.la' "$outputname"
6171	  libname=$func_stripname_result
6172	fi
6173	;;
6174      esac
6175
6176      if test -n "$objs"; then
6177	if test "$deplibs_check_method" != pass_all; then
6178	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6179	else
6180	  $ECHO
6181	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6182	  $ECHO "*** objects $objs is not portable!"
6183	  libobjs="$libobjs $objs"
6184	fi
6185      fi
6186
6187      test "$dlself" != no && \
6188	func_warning "\`-dlopen self' is ignored for libtool libraries"
6189
6190      set dummy $rpath
6191      shift
6192      test "$#" -gt 1 && \
6193	func_warning "ignoring multiple \`-rpath's for a libtool library"
6194
6195      install_libdir="$1"
6196
6197      oldlibs=
6198      if test -z "$rpath"; then
6199	if test "$build_libtool_libs" = yes; then
6200	  # Building a libtool convenience library.
6201	  # Some compilers have problems with a `.al' extension so
6202	  # convenience libraries should have the same extension an
6203	  # archive normally would.
6204	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
6205	  build_libtool_libs=convenience
6206	  build_old_libs=yes
6207	fi
6208
6209	test -n "$vinfo" && \
6210	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6211
6212	test -n "$release" && \
6213	  func_warning "\`-release' is ignored for convenience libraries"
6214      else
6215
6216	# Parse the version information argument.
6217	save_ifs="$IFS"; IFS=':'
6218	set dummy $vinfo 0 0 0
6219	shift
6220	IFS="$save_ifs"
6221
6222	test -n "$7" && \
6223	  func_fatal_help "too many parameters to \`-version-info'"
6224
6225	# convert absolute version numbers to libtool ages
6226	# this retains compatibility with .la files and attempts
6227	# to make the code below a bit more comprehensible
6228
6229	case $vinfo_number in
6230	yes)
6231	  number_major="$1"
6232	  number_minor="$2"
6233	  number_revision="$3"
6234	  #
6235	  # There are really only two kinds -- those that
6236	  # use the current revision as the major version
6237	  # and those that subtract age and use age as
6238	  # a minor version.  But, then there is irix
6239	  # which has an extra 1 added just for fun
6240	  #
6241	  case $version_type in
6242	  darwin|linux|osf|windows|none)
6243	    func_arith $number_major + $number_minor
6244	    current=$func_arith_result
6245	    age="$number_minor"
6246	    revision="$number_revision"
6247	    ;;
6248	  freebsd-aout|freebsd-elf|sunos)
6249	    current="$number_major"
6250	    revision="$number_minor"
6251	    age="0"
6252	    ;;
6253	  irix|nonstopux)
6254	    func_arith $number_major + $number_minor
6255	    current=$func_arith_result
6256	    age="$number_minor"
6257	    revision="$number_minor"
6258	    lt_irix_increment=no
6259	    ;;
6260	  esac
6261	  ;;
6262	no)
6263	  current="$1"
6264	  revision="$2"
6265	  age="$3"
6266	  ;;
6267	esac
6268
6269	# Check that each of the things are valid numbers.
6270	case $current in
6271	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]) ;;
6272	*)
6273	  func_error "CURRENT \`$current' must be a nonnegative integer"
6274	  func_fatal_error "\`$vinfo' is not valid version information"
6275	  ;;
6276	esac
6277
6278	case $revision in
6279	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]) ;;
6280	*)
6281	  func_error "REVISION \`$revision' must be a nonnegative integer"
6282	  func_fatal_error "\`$vinfo' is not valid version information"
6283	  ;;
6284	esac
6285
6286	case $age in
6287	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]) ;;
6288	*)
6289	  func_error "AGE \`$age' must be a nonnegative integer"
6290	  func_fatal_error "\`$vinfo' is not valid version information"
6291	  ;;
6292	esac
6293
6294	if test "$age" -gt "$current"; then
6295	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
6296	  func_fatal_error "\`$vinfo' is not valid version information"
6297	fi
6298
6299	# Calculate the version variables.
6300	major=
6301	versuffix=
6302	verstring=
6303	case $version_type in
6304	none) ;;
6305
6306	darwin)
6307	  # Like Linux, but with the current version available in
6308	  # verstring for coding it into the library header
6309	  func_arith $current - $age
6310	  major=.$func_arith_result
6311	  versuffix="$major.$age.$revision"
6312	  # Darwin ld doesn't like 0 for these options...
6313	  func_arith $current + 1
6314	  minor_current=$func_arith_result
6315	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6316	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6317	  ;;
6318
6319	freebsd-aout)
6320	  major=".$current"
6321	  versuffix=".$current.$revision";
6322	  ;;
6323
6324	freebsd-elf)
6325	  major=".$current"
6326	  versuffix=".$current"
6327	  ;;
6328
6329	irix | nonstopux)
6330	  if test "X$lt_irix_increment" = "Xno"; then
6331	    func_arith $current - $age
6332	  else
6333	    func_arith $current - $age + 1
6334	  fi
6335	  major=$func_arith_result
6336
6337	  case $version_type in
6338	    nonstopux) verstring_prefix=nonstopux ;;
6339	    *)         verstring_prefix=sgi ;;
6340	  esac
6341	  verstring="$verstring_prefix$major.$revision"
6342
6343	  # Add in all the interfaces that we are compatible with.
6344	  loop=$revision
6345	  while test "$loop" -ne 0; do
6346	    func_arith $revision - $loop
6347	    iface=$func_arith_result
6348	    func_arith $loop - 1
6349	    loop=$func_arith_result
6350	    verstring="$verstring_prefix$major.$iface:$verstring"
6351	  done
6352
6353	  # Before this point, $major must not contain `.'.
6354	  major=.$major
6355	  versuffix="$major.$revision"
6356	  ;;
6357
6358	linux)
6359	  func_arith $current - $age
6360	  major=.$func_arith_result
6361	  versuffix="$major.$age.$revision"
6362	  ;;
6363
6364	osf)
6365	  func_arith $current - $age
6366	  major=.$func_arith_result
6367	  versuffix=".$current.$age.$revision"
6368	  verstring="$current.$age.$revision"
6369
6370	  # Add in all the interfaces that we are compatible with.
6371	  loop=$age
6372	  while test "$loop" -ne 0; do
6373	    func_arith $current - $loop
6374	    iface=$func_arith_result
6375	    func_arith $loop - 1
6376	    loop=$func_arith_result
6377	    verstring="$verstring:${iface}.0"
6378	  done
6379
6380	  # Make executables depend on our current version.
6381	  verstring="$verstring:${current}.0"
6382	  ;;
6383
6384	qnx)
6385	  major=".$current"
6386	  versuffix=".$current"
6387	  ;;
6388
6389	sunos)
6390	  major=".$current"
6391	  versuffix=".$current.$revision"
6392	  ;;
6393
6394	windows)
6395	  # Use '-' rather than '.', since we only want one
6396	  # extension on DOS 8.3 filesystems.
6397	  func_arith $current - $age
6398	  major=$func_arith_result
6399	  versuffix="-$major"
6400	  ;;
6401
6402	*)
6403	  func_fatal_configuration "unknown library version type \`$version_type'"
6404	  ;;
6405	esac
6406
6407	# Clear the version info if we defaulted, and they specified a release.
6408	if test -z "$vinfo" && test -n "$release"; then
6409	  major=
6410	  case $version_type in
6411	  darwin)
6412	    # we can't check for "0.0" in archive_cmds due to quoting
6413	    # problems, so we reset it completely
6414	    verstring=
6415	    ;;
6416	  *)
6417	    verstring="0.0"
6418	    ;;
6419	  esac
6420	  if test "$need_version" = no; then
6421	    versuffix=
6422	  else
6423	    versuffix=".0.0"
6424	  fi
6425	fi
6426
6427	# Remove version info from name if versioning should be avoided
6428	if test "$avoid_version" = yes && test "$need_version" = no; then
6429	  major=
6430	  versuffix=
6431	  verstring=""
6432	fi
6433
6434	# Check to see if the archive will have undefined symbols.
6435	if test "$allow_undefined" = yes; then
6436	  if test "$allow_undefined_flag" = unsupported; then
6437	    func_warning "undefined symbols not allowed in $host shared libraries"
6438	    build_libtool_libs=no
6439	    build_old_libs=yes
6440	  fi
6441	else
6442	  # Don't allow undefined symbols.
6443	  allow_undefined_flag="$no_undefined_flag"
6444	fi
6445
6446      fi
6447
6448      func_generate_dlsyms "$libname" "$libname" "yes"
6449      libobjs="$libobjs $symfileobj"
6450      test "X$libobjs" = "X " && libobjs=
6451
6452      if test "$mode" != relink; then
6453	# Remove our outputs, but don't remove object files since they
6454	# may have been created when compiling PIC objects.
6455	removelist=
6456	tempremovelist=`$ECHO "$output_objdir/*"`
6457	for p in $tempremovelist; do
6458	  case $p in
6459	    *.$objext | *.gcno)
6460	       ;;
6461	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6462	       if test "X$precious_files_regex" != "X"; then
6463		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6464		 then
6465		   continue
6466		 fi
6467	       fi
6468	       removelist="$removelist $p"
6469	       ;;
6470	    *) ;;
6471	  esac
6472	done
6473	test -n "$removelist" && \
6474	  func_show_eval "${RM}r \$removelist"
6475      fi
6476
6477      # Now set the variables for building old libraries.
6478      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6479	oldlibs="$oldlibs $output_objdir/$libname.$libext"
6480
6481	# Transform .lo files to .o files.
6482	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
6483      fi
6484
6485      # Eliminate all temporary directories.
6486      #for path in $notinst_path; do
6487      #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
6488      #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
6489      #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
6490      #done
6491
6492      if test -n "$xrpath"; then
6493	# If the user specified any rpath flags, then add them.
6494	temp_xrpath=
6495	for libdir in $xrpath; do
6496	  temp_xrpath="$temp_xrpath -R$libdir"
6497	  case "$finalize_rpath " in
6498	  *" $libdir "*) ;;
6499	  *) finalize_rpath="$finalize_rpath $libdir" ;;
6500	  esac
6501	done
6502	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6503	  dependency_libs="$temp_xrpath $dependency_libs"
6504	fi
6505      fi
6506
6507      # Make sure dlfiles contains only unique files that won't be dlpreopened
6508      old_dlfiles="$dlfiles"
6509      dlfiles=
6510      for lib in $old_dlfiles; do
6511	case " $dlprefiles $dlfiles " in
6512	*" $lib "*) ;;
6513	*) dlfiles="$dlfiles $lib" ;;
6514	esac
6515      done
6516
6517      # Make sure dlprefiles contains only unique files
6518      old_dlprefiles="$dlprefiles"
6519      dlprefiles=
6520      for lib in $old_dlprefiles; do
6521	case "$dlprefiles " in
6522	*" $lib "*) ;;
6523	*) dlprefiles="$dlprefiles $lib" ;;
6524	esac
6525      done
6526
6527      if test "$build_libtool_libs" = yes; then
6528	if test -n "$rpath"; then
6529	  case $host in
6530	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
6531	    # these systems don't actually have a c library (as such)!
6532	    ;;
6533	  *-*-rhapsody* | *-*-darwin1.[012])
6534	    # Rhapsody C library is in the System framework
6535	    deplibs="$deplibs System.ltframework"
6536	    ;;
6537	  *-*-netbsd*)
6538	    # Don't link with libc until the a.out ld.so is fixed.
6539	    ;;
6540	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6541	    # Do not include libc due to us having libc/libc_r.
6542	    ;;
6543	  *-*-sco3.2v5* | *-*-sco5v6*)
6544	    # Causes problems with __ctype
6545	    ;;
6546	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6547	    # Compiler inserts libc in the correct place for threads to work
6548	    ;;
6549	  *)
6550	    # Add libc to deplibs on all other systems if necessary.
6551	    if test "$build_libtool_need_lc" = "yes"; then
6552	      deplibs="$deplibs -lc"
6553	    fi
6554	    ;;
6555	  esac
6556	fi
6557
6558	# Transform deplibs into only deplibs that can be linked in shared.
6559	name_save=$name
6560	libname_save=$libname
6561	release_save=$release
6562	versuffix_save=$versuffix
6563	major_save=$major
6564	# I'm not sure if I'm treating the release correctly.  I think
6565	# release should show up in the -l (ie -lgmp5) so we don't want to
6566	# add it in twice.  Is that correct?
6567	release=""
6568	versuffix=""
6569	major=""
6570	newdeplibs=
6571	droppeddeps=no
6572	case $deplibs_check_method in
6573	pass_all)
6574	  # Don't check for shared/static.  Everything works.
6575	  # This might be a little naive.  We might want to check
6576	  # whether the library exists or not.  But this is on
6577	  # osf3 & osf4 and I'm not really sure... Just
6578	  # implementing what was already the behavior.
6579	  newdeplibs=$deplibs
6580	  ;;
6581	test_compile)
6582	  # This code stresses the "libraries are programs" paradigm to its
6583	  # limits. Maybe even breaks it.  We compile a program, linking it
6584	  # against the deplibs as a proxy for the library.  Then we can check
6585	  # whether they linked in statically or dynamically with ldd.
6586	  $opt_dry_run || $RM conftest.c
6587	  cat > conftest.c <<EOF
6588	  int main() { return 0; }
6589EOF
6590	  $opt_dry_run || $RM conftest
6591	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6592	    ldd_output=`ldd conftest`
6593	    for i in $deplibs; do
6594	      case $i in
6595	      -l*)
6596		func_stripname -l '' "$i"
6597		name=$func_stripname_result
6598		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6599		  case " $predeps $postdeps " in
6600		  *" $i "*)
6601		    newdeplibs="$newdeplibs $i"
6602		    i=""
6603		    ;;
6604		  esac
6605		fi
6606		if test -n "$i" ; then
6607		  libname=`eval "\\$ECHO \"$libname_spec\""`
6608		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6609		  set dummy $deplib_matches; shift
6610		  deplib_match=$1
6611		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6612		    newdeplibs="$newdeplibs $i"
6613		  else
6614		    droppeddeps=yes
6615		    $ECHO
6616		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6617		    $ECHO "*** I have the capability to make that library automatically link in when"
6618		    $ECHO "*** you link to this library.  But I can only do this if you have a"
6619		    $ECHO "*** shared version of the library, which I believe you do not have"
6620		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6621		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
6622		  fi
6623		fi
6624		;;
6625	      *)
6626		newdeplibs="$newdeplibs $i"
6627		;;
6628	      esac
6629	    done
6630	  else
6631	    # Error occurred in the first compile.  Let's try to salvage
6632	    # the situation: Compile a separate program for each library.
6633	    for i in $deplibs; do
6634	      case $i in
6635	      -l*)
6636		func_stripname -l '' "$i"
6637		name=$func_stripname_result
6638		$opt_dry_run || $RM conftest
6639		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6640		  ldd_output=`ldd conftest`
6641		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6642		    case " $predeps $postdeps " in
6643		    *" $i "*)
6644		      newdeplibs="$newdeplibs $i"
6645		      i=""
6646		      ;;
6647		    esac
6648		  fi
6649		  if test -n "$i" ; then
6650		    libname=`eval "\\$ECHO \"$libname_spec\""`
6651		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6652		    set dummy $deplib_matches; shift
6653		    deplib_match=$1
6654		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6655		      newdeplibs="$newdeplibs $i"
6656		    else
6657		      droppeddeps=yes
6658		      $ECHO
6659		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6660		      $ECHO "*** I have the capability to make that library automatically link in when"
6661		      $ECHO "*** you link to this library.  But I can only do this if you have a"
6662		      $ECHO "*** shared version of the library, which you do not appear to have"
6663		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6664		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
6665		    fi
6666		  fi
6667		else
6668		  droppeddeps=yes
6669		  $ECHO
6670		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
6671		  $ECHO "*** make it link in!  You will probably need to install it or some"
6672		  $ECHO "*** library that it depends on before this library will be fully"
6673		  $ECHO "*** functional.  Installing it before continuing would be even better."
6674		fi
6675		;;
6676	      *)
6677		newdeplibs="$newdeplibs $i"
6678		;;
6679	      esac
6680	    done
6681	  fi
6682	  ;;
6683	file_magic*)
6684	  set dummy $deplibs_check_method; shift
6685	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6686	  for a_deplib in $deplibs; do
6687	    case $a_deplib in
6688	    -l*)
6689	      func_stripname -l '' "$a_deplib"
6690	      name=$func_stripname_result
6691	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6692		case " $predeps $postdeps " in
6693		*" $a_deplib "*)
6694		  newdeplibs="$newdeplibs $a_deplib"
6695		  a_deplib=""
6696		  ;;
6697		esac
6698	      fi
6699	      if test -n "$a_deplib" ; then
6700		libname=`eval "\\$ECHO \"$libname_spec\""`
6701		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6702		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6703		  for potent_lib in $potential_libs; do
6704		      # Follow soft links.
6705		      if ls -lLd "$potent_lib" 2>/dev/null |
6706			 $GREP " -> " >/dev/null; then
6707			continue
6708		      fi
6709		      # The statement above tries to avoid entering an
6710		      # endless loop below, in case of cyclic links.
6711		      # We might still enter an endless loop, since a link
6712		      # loop can be closed while we follow links,
6713		      # but so what?
6714		      potlib="$potent_lib"
6715		      while test -h "$potlib" 2>/dev/null; do
6716			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6717			case $potliblink in
6718			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6719			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
6720			esac
6721		      done
6722		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6723			 $SED -e 10q |
6724			 $EGREP "$file_magic_regex" > /dev/null; then
6725			newdeplibs="$newdeplibs $a_deplib"
6726			a_deplib=""
6727			break 2
6728		      fi
6729		  done
6730		done
6731	      fi
6732	      if test -n "$a_deplib" ; then
6733		droppeddeps=yes
6734		$ECHO
6735		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6736		$ECHO "*** I have the capability to make that library automatically link in when"
6737		$ECHO "*** you link to this library.  But I can only do this if you have a"
6738		$ECHO "*** shared version of the library, which you do not appear to have"
6739		$ECHO "*** because I did check the linker path looking for a file starting"
6740		if test -z "$potlib" ; then
6741		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6742		else
6743		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6744		  $ECHO "*** using a file magic. Last file checked: $potlib"
6745		fi
6746	      fi
6747	      ;;
6748	    *)
6749	      # Add a -L argument.
6750	      newdeplibs="$newdeplibs $a_deplib"
6751	      ;;
6752	    esac
6753	  done # Gone through all deplibs.
6754	  ;;
6755	match_pattern*)
6756	  set dummy $deplibs_check_method; shift
6757	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6758	  for a_deplib in $deplibs; do
6759	    case $a_deplib in
6760	    -l*)
6761	      func_stripname -l '' "$a_deplib"
6762	      name=$func_stripname_result
6763	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6764		case " $predeps $postdeps " in
6765		*" $a_deplib "*)
6766		  newdeplibs="$newdeplibs $a_deplib"
6767		  a_deplib=""
6768		  ;;
6769		esac
6770	      fi
6771	      if test -n "$a_deplib" ; then
6772		libname=`eval "\\$ECHO \"$libname_spec\""`
6773		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6774		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6775		  for potent_lib in $potential_libs; do
6776		    potlib="$potent_lib" # see symlink-check above in file_magic test
6777		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6778		       $EGREP "$match_pattern_regex" > /dev/null; then
6779		      newdeplibs="$newdeplibs $a_deplib"
6780		      a_deplib=""
6781		      break 2
6782		    fi
6783		  done
6784		done
6785	      fi
6786	      if test -n "$a_deplib" ; then
6787		droppeddeps=yes
6788		$ECHO
6789		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6790		$ECHO "*** I have the capability to make that library automatically link in when"
6791		$ECHO "*** you link to this library.  But I can only do this if you have a"
6792		$ECHO "*** shared version of the library, which you do not appear to have"
6793		$ECHO "*** because I did check the linker path looking for a file starting"
6794		if test -z "$potlib" ; then
6795		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6796		else
6797		  $ECHO "*** with $libname and none of the candidates passed a file format test"
6798		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
6799		fi
6800	      fi
6801	      ;;
6802	    *)
6803	      # Add a -L argument.
6804	      newdeplibs="$newdeplibs $a_deplib"
6805	      ;;
6806	    esac
6807	  done # Gone through all deplibs.
6808	  ;;
6809	none | unknown | *)
6810	  newdeplibs=""
6811	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6812	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
6813	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6814	    for i in $predeps $postdeps ; do
6815	      # can't use Xsed below, because $i might contain '/'
6816	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
6817	    done
6818	  fi
6819	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
6820	     $GREP . >/dev/null; then
6821	    $ECHO
6822	    if test "X$deplibs_check_method" = "Xnone"; then
6823	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
6824	    else
6825	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
6826	    fi
6827	    $ECHO "*** All declared inter-library dependencies are being dropped."
6828	    droppeddeps=yes
6829	  fi
6830	  ;;
6831	esac
6832	versuffix=$versuffix_save
6833	major=$major_save
6834	release=$release_save
6835	libname=$libname_save
6836	name=$name_save
6837
6838	case $host in
6839	*-*-rhapsody* | *-*-darwin1.[012])
6840	  # On Rhapsody replace the C library with the System framework
6841	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6842	  ;;
6843	esac
6844
6845	if test "$droppeddeps" = yes; then
6846	  if test "$module" = yes; then
6847	    $ECHO
6848	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6849	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
6850	    $ECHO "*** a static module, that should work as long as the dlopening"
6851	    $ECHO "*** application is linked with the -dlopen flag."
6852	    if test -z "$global_symbol_pipe"; then
6853	      $ECHO
6854	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
6855	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6856	      $ECHO "*** not find such a program.  So, this module is probably useless."
6857	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
6858	    fi
6859	    if test "$build_old_libs" = no; then
6860	      oldlibs="$output_objdir/$libname.$libext"
6861	      build_libtool_libs=module
6862	      build_old_libs=yes
6863	    else
6864	      build_libtool_libs=no
6865	    fi
6866	  else
6867	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
6868	    $ECHO "*** automatically added whenever a program is linked with this library"
6869	    $ECHO "*** or is declared to -dlopen it."
6870
6871	    if test "$allow_undefined" = no; then
6872	      $ECHO
6873	      $ECHO "*** Since this library must not contain undefined symbols,"
6874	      $ECHO "*** because either the platform does not support them or"
6875	      $ECHO "*** it was explicitly requested with -no-undefined,"
6876	      $ECHO "*** libtool will only create a static version of it."
6877	      if test "$build_old_libs" = no; then
6878		oldlibs="$output_objdir/$libname.$libext"
6879		build_libtool_libs=module
6880		build_old_libs=yes
6881	      else
6882		build_libtool_libs=no
6883	      fi
6884	    fi
6885	  fi
6886	fi
6887	# Done checking deplibs!
6888	deplibs=$newdeplibs
6889      fi
6890      # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6891      case $host in
6892	*-*-darwin*)
6893	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6894	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6895	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6896	  ;;
6897      esac
6898
6899      # move library search paths that coincide with paths to not yet
6900      # installed libraries to the beginning of the library search list
6901      new_libs=
6902      for path in $notinst_path; do
6903	case " $new_libs " in
6904	*" -L$path/$objdir "*) ;;
6905	*)
6906	  case " $deplibs " in
6907	  *" -L$path/$objdir "*)
6908	    new_libs="$new_libs -L$path/$objdir" ;;
6909	  esac
6910	  ;;
6911	esac
6912      done
6913      for deplib in $deplibs; do
6914	case $deplib in
6915	-L*)
6916	  case " $new_libs " in
6917	  *" $deplib "*) ;;
6918	  *) new_libs="$new_libs $deplib" ;;
6919	  esac
6920	  ;;
6921	*) new_libs="$new_libs $deplib" ;;
6922	esac
6923      done
6924      deplibs="$new_libs"
6925
6926      # All the library-specific variables (install_libdir is set above).
6927      library_names=
6928      old_library=
6929      dlname=
6930
6931      # Test again, we may have decided not to build it any more
6932      if test "$build_libtool_libs" = yes; then
6933	if test "$hardcode_into_libs" = yes; then
6934	  # Hardcode the library paths
6935	  hardcode_libdirs=
6936	  dep_rpath=
6937	  rpath="$finalize_rpath"
6938	  test "$mode" != relink && rpath="$compile_rpath$rpath"
6939	  for libdir in $rpath; do
6940	    if test -n "$hardcode_libdir_flag_spec"; then
6941	      if test -n "$hardcode_libdir_separator"; then
6942		if test -z "$hardcode_libdirs"; then
6943		  hardcode_libdirs="$libdir"
6944		else
6945		  # Just accumulate the unique libdirs.
6946		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6947		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6948		    ;;
6949		  *)
6950		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6951		    ;;
6952		  esac
6953		fi
6954	      else
6955		eval flag=\"$hardcode_libdir_flag_spec\"
6956		dep_rpath="$dep_rpath $flag"
6957	      fi
6958	    elif test -n "$runpath_var"; then
6959	      case "$perm_rpath " in
6960	      *" $libdir "*) ;;
6961	      *) perm_rpath="$perm_rpath $libdir" ;;
6962	      esac
6963	    fi
6964	  done
6965	  # Substitute the hardcoded libdirs into the rpath.
6966	  if test -n "$hardcode_libdir_separator" &&
6967	     test -n "$hardcode_libdirs"; then
6968	    libdir="$hardcode_libdirs"
6969	    if test -n "$hardcode_libdir_flag_spec_ld"; then
6970	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6971	    else
6972	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6973	    fi
6974	  fi
6975	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
6976	    # We should set the runpath_var.
6977	    rpath=
6978	    for dir in $perm_rpath; do
6979	      rpath="$rpath$dir:"
6980	    done
6981	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6982	  fi
6983	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6984	fi
6985
6986	shlibpath="$finalize_shlibpath"
6987	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6988	if test -n "$shlibpath"; then
6989	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6990	fi
6991
6992	# Get the real and link names of the library.
6993	eval shared_ext=\"$shrext_cmds\"
6994	eval library_names=\"$library_names_spec\"
6995	set dummy $library_names
6996	shift
6997	realname="$1"
6998	shift
6999
7000	if test -n "$soname_spec"; then
7001	  eval soname=\"$soname_spec\"
7002	else
7003	  soname="$realname"
7004	fi
7005	if test -z "$dlname"; then
7006	  dlname=$soname
7007	fi
7008
7009	lib="$output_objdir/$realname"
7010	linknames=
7011	for link
7012	do
7013	  linknames="$linknames $link"
7014	done
7015
7016	# Use standard objects if they are pic
7017	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7018	test "X$libobjs" = "X " && libobjs=
7019
7020	delfiles=
7021	if test -n "$export_symbols" && test -n "$include_expsyms"; then
7022	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
7023	  export_symbols="$output_objdir/$libname.uexp"
7024	  delfiles="$delfiles $export_symbols"
7025	fi
7026
7027	orig_export_symbols=
7028	case $host_os in
7029	cygwin* | mingw* | cegcc*)
7030	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
7031	    # exporting using user supplied symfile
7032	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
7033	      # and it's NOT already a .def file. Must figure out
7034	      # which of the given symbols are data symbols and tag
7035	      # them as such. So, trigger use of export_symbols_cmds.
7036	      # export_symbols gets reassigned inside the "prepare
7037	      # the list of exported symbols" if statement, so the
7038	      # include_expsyms logic still works.
7039	      orig_export_symbols="$export_symbols"
7040	      export_symbols=
7041	      always_export_symbols=yes
7042	    fi
7043	  fi
7044	  ;;
7045	esac
7046
7047	# Prepare the list of exported symbols
7048	if test -z "$export_symbols"; then
7049	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
7050	    func_verbose "generating symbol list for \`$libname.la'"
7051	    export_symbols="$output_objdir/$libname.exp"
7052	    $opt_dry_run || $RM $export_symbols
7053	    cmds=$export_symbols_cmds
7054	    save_ifs="$IFS"; IFS='~'
7055	    for cmd in $cmds; do
7056	      IFS="$save_ifs"
7057	      eval cmd=\"$cmd\"
7058	      func_len " $cmd"
7059	      len=$func_len_result
7060	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7061		func_show_eval "$cmd" 'exit $?'
7062		skipped_export=false
7063	      else
7064		# The command line is too long to execute in one step.
7065		func_verbose "using reloadable object file for export list..."
7066		skipped_export=:
7067		# Break out early, otherwise skipped_export may be
7068		# set to false by a later but shorter cmd.
7069		break
7070	      fi
7071	    done
7072	    IFS="$save_ifs"
7073	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7074	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7075	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7076	    fi
7077	  fi
7078	fi
7079
7080	if test -n "$export_symbols" && test -n "$include_expsyms"; then
7081	  tmp_export_symbols="$export_symbols"
7082	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7083	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7084	fi
7085
7086	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7087	  # The given exports_symbols file has to be filtered, so filter it.
7088	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7089	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
7090	  # 's' commands which not all seds can handle. GNU sed should be fine
7091	  # though. Also, the filter scales superlinearly with the number of
7092	  # global variables. join(1) would be nice here, but unfortunately
7093	  # isn't a blessed tool.
7094	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7095	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7096	  export_symbols=$output_objdir/$libname.def
7097	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7098	fi
7099
7100	tmp_deplibs=
7101	for test_deplib in $deplibs; do
7102	  case " $convenience " in
7103	  *" $test_deplib "*) ;;
7104	  *)
7105	    tmp_deplibs="$tmp_deplibs $test_deplib"
7106	    ;;
7107	  esac
7108	done
7109	deplibs="$tmp_deplibs"
7110
7111	if test -n "$convenience"; then
7112	  if test -n "$whole_archive_flag_spec" &&
7113	    test "$compiler_needs_object" = yes &&
7114	    test -z "$libobjs"; then
7115	    # extract the archives, so we have objects to list.
7116	    # TODO: could optimize this to just extract one archive.
7117	    whole_archive_flag_spec=
7118	  fi
7119	  if test -n "$whole_archive_flag_spec"; then
7120	    save_libobjs=$libobjs
7121	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7122	    test "X$libobjs" = "X " && libobjs=
7123	  else
7124	    gentop="$output_objdir/${outputname}x"
7125	    generated="$generated $gentop"
7126
7127	    func_extract_archives $gentop $convenience
7128	    libobjs="$libobjs $func_extract_archives_result"
7129	    test "X$libobjs" = "X " && libobjs=
7130	  fi
7131	fi
7132
7133	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7134	  eval flag=\"$thread_safe_flag_spec\"
7135	  linker_flags="$linker_flags $flag"
7136	fi
7137
7138	# Make a backup of the uninstalled library when relinking
7139	if test "$mode" = relink; then
7140	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
7141	fi
7142
7143	# Do each of the archive commands.
7144	if test "$module" = yes && test -n "$module_cmds" ; then
7145	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7146	    eval test_cmds=\"$module_expsym_cmds\"
7147	    cmds=$module_expsym_cmds
7148	  else
7149	    eval test_cmds=\"$module_cmds\"
7150	    cmds=$module_cmds
7151	  fi
7152	else
7153	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7154	    eval test_cmds=\"$archive_expsym_cmds\"
7155	    cmds=$archive_expsym_cmds
7156	  else
7157	    eval test_cmds=\"$archive_cmds\"
7158	    cmds=$archive_cmds
7159	  fi
7160	fi
7161
7162	if test "X$skipped_export" != "X:" &&
7163	   func_len " $test_cmds" &&
7164	   len=$func_len_result &&
7165	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7166	  :
7167	else
7168	  # The command line is too long to link in one step, link piecewise
7169	  # or, if using GNU ld and skipped_export is not :, use a linker
7170	  # script.
7171
7172	  # Save the value of $output and $libobjs because we want to
7173	  # use them later.  If we have whole_archive_flag_spec, we
7174	  # want to use save_libobjs as it was before
7175	  # whole_archive_flag_spec was expanded, because we can't
7176	  # assume the linker understands whole_archive_flag_spec.
7177	  # This may have to be revisited, in case too many
7178	  # convenience libraries get linked in and end up exceeding
7179	  # the spec.
7180	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7181	    save_libobjs=$libobjs
7182	  fi
7183	  save_output=$output
7184	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
7185
7186	  # Clear the reloadable object creation command queue and
7187	  # initialize k to one.
7188	  test_cmds=
7189	  concat_cmds=
7190	  objlist=
7191	  last_robj=
7192	  k=1
7193
7194	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7195	    output=${output_objdir}/${output_la}.lnkscript
7196	    func_verbose "creating GNU ld script: $output"
7197	    $ECHO 'INPUT (' > $output
7198	    for obj in $save_libobjs
7199	    do
7200	      $ECHO "$obj" >> $output
7201	    done
7202	    $ECHO ')' >> $output
7203	    delfiles="$delfiles $output"
7204	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7205	    output=${output_objdir}/${output_la}.lnk
7206	    func_verbose "creating linker input file list: $output"
7207	    : > $output
7208	    set x $save_libobjs
7209	    shift
7210	    firstobj=
7211	    if test "$compiler_needs_object" = yes; then
7212	      firstobj="$1 "
7213	      shift
7214	    fi
7215	    for obj
7216	    do
7217	      $ECHO "$obj" >> $output
7218	    done
7219	    delfiles="$delfiles $output"
7220	    output=$firstobj\"$file_list_spec$output\"
7221	  else
7222	    if test -n "$save_libobjs"; then
7223	      func_verbose "creating reloadable object files..."
7224	      output=$output_objdir/$output_la-${k}.$objext
7225	      eval test_cmds=\"$reload_cmds\"
7226	      func_len " $test_cmds"
7227	      len0=$func_len_result
7228	      len=$len0
7229
7230	      # Loop over the list of objects to be linked.
7231	      for obj in $save_libobjs
7232	      do
7233		func_len " $obj"
7234		func_arith $len + $func_len_result
7235		len=$func_arith_result
7236		if test "X$objlist" = X ||
7237		   test "$len" -lt "$max_cmd_len"; then
7238		  func_append objlist " $obj"
7239		else
7240		  # The command $test_cmds is almost too long, add a
7241		  # command to the queue.
7242		  if test "$k" -eq 1 ; then
7243		    # The first file doesn't have a previous command to add.
7244		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
7245		  else
7246		    # All subsequent reloadable object files will link in
7247		    # the last one created.
7248		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
7249		  fi
7250		  last_robj=$output_objdir/$output_la-${k}.$objext
7251		  func_arith $k + 1
7252		  k=$func_arith_result
7253		  output=$output_objdir/$output_la-${k}.$objext
7254		  objlist=$obj
7255		  func_len " $last_robj"
7256		  func_arith $len0 + $func_len_result
7257		  len=$func_arith_result
7258		fi
7259	      done
7260	      # Handle the remaining objects by creating one last
7261	      # reloadable object file.  All subsequent reloadable object
7262	      # files will link in the last one created.
7263	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7264	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
7265	      if test -n "$last_robj"; then
7266	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
7267	      fi
7268	      delfiles="$delfiles $output"
7269
7270	    else
7271	      output=
7272	    fi
7273
7274	    if ${skipped_export-false}; then
7275	      func_verbose "generating symbol list for \`$libname.la'"
7276	      export_symbols="$output_objdir/$libname.exp"
7277	      $opt_dry_run || $RM $export_symbols
7278	      libobjs=$output
7279	      # Append the command to create the export file.
7280	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7281	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
7282	      if test -n "$last_robj"; then
7283		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
7284	      fi
7285	    fi
7286
7287	    test -n "$save_libobjs" &&
7288	      func_verbose "creating a temporary reloadable object file: $output"
7289
7290	    # Loop through the commands generated above and execute them.
7291	    save_ifs="$IFS"; IFS='~'
7292	    for cmd in $concat_cmds; do
7293	      IFS="$save_ifs"
7294	      $opt_silent || {
7295		  func_quote_for_expand "$cmd"
7296		  eval "func_echo $func_quote_for_expand_result"
7297	      }
7298	      $opt_dry_run || eval "$cmd" || {
7299		lt_exit=$?
7300
7301		# Restore the uninstalled library and exit
7302		if test "$mode" = relink; then
7303		  ( cd "$output_objdir" && \
7304		    $RM "${realname}T" && \
7305		    $MV "${realname}U" "$realname" )
7306		fi
7307
7308		exit $lt_exit
7309	      }
7310	    done
7311	    IFS="$save_ifs"
7312
7313	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7314	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7315	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7316	    fi
7317	  fi
7318
7319          if ${skipped_export-false}; then
7320	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
7321	      tmp_export_symbols="$export_symbols"
7322	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7323	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7324	    fi
7325
7326	    if test -n "$orig_export_symbols"; then
7327	      # The given exports_symbols file has to be filtered, so filter it.
7328	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7329	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
7330	      # 's' commands which not all seds can handle. GNU sed should be fine
7331	      # though. Also, the filter scales superlinearly with the number of
7332	      # global variables. join(1) would be nice here, but unfortunately
7333	      # isn't a blessed tool.
7334	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7335	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7336	      export_symbols=$output_objdir/$libname.def
7337	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7338	    fi
7339	  fi
7340
7341	  libobjs=$output
7342	  # Restore the value of output.
7343	  output=$save_output
7344
7345	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7346	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7347	    test "X$libobjs" = "X " && libobjs=
7348	  fi
7349	  # Expand the library linking commands again to reset the
7350	  # value of $libobjs for piecewise linking.
7351
7352	  # Do each of the archive commands.
7353	  if test "$module" = yes && test -n "$module_cmds" ; then
7354	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7355	      cmds=$module_expsym_cmds
7356	    else
7357	      cmds=$module_cmds
7358	    fi
7359	  else
7360	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7361	      cmds=$archive_expsym_cmds
7362	    else
7363	      cmds=$archive_cmds
7364	    fi
7365	  fi
7366	fi
7367
7368	if test -n "$delfiles"; then
7369	  # Append the command to remove temporary files to $cmds.
7370	  eval cmds=\"\$cmds~\$RM $delfiles\"
7371	fi
7372
7373	# Add any objects from preloaded convenience libraries
7374	if test -n "$dlprefiles"; then
7375	  gentop="$output_objdir/${outputname}x"
7376	  generated="$generated $gentop"
7377
7378	  func_extract_archives $gentop $dlprefiles
7379	  libobjs="$libobjs $func_extract_archives_result"
7380	  test "X$libobjs" = "X " && libobjs=
7381	fi
7382
7383	save_ifs="$IFS"; IFS='~'
7384	for cmd in $cmds; do
7385	  IFS="$save_ifs"
7386	  eval cmd=\"$cmd\"
7387	  $opt_silent || {
7388	    func_quote_for_expand "$cmd"
7389	    eval "func_echo $func_quote_for_expand_result"
7390	  }
7391	  $opt_dry_run || eval "$cmd" || {
7392	    lt_exit=$?
7393
7394	    # Restore the uninstalled library and exit
7395	    if test "$mode" = relink; then
7396	      ( cd "$output_objdir" && \
7397	        $RM "${realname}T" && \
7398		$MV "${realname}U" "$realname" )
7399	    fi
7400
7401	    exit $lt_exit
7402	  }
7403	done
7404	IFS="$save_ifs"
7405
7406	# Restore the uninstalled library and exit
7407	if test "$mode" = relink; then
7408	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
7409
7410	  if test -n "$convenience"; then
7411	    if test -z "$whole_archive_flag_spec"; then
7412	      func_show_eval '${RM}r "$gentop"'
7413	    fi
7414	  fi
7415
7416	  exit $EXIT_SUCCESS
7417	fi
7418
7419	# Create links to the real library.
7420	for linkname in $linknames; do
7421	  if test "$realname" != "$linkname"; then
7422	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7423	  fi
7424	done
7425
7426	# If -module or -export-dynamic was specified, set the dlname.
7427	if test "$module" = yes || test "$export_dynamic" = yes; then
7428	  # On all known operating systems, these are identical.
7429	  dlname="$soname"
7430	fi
7431      fi
7432      ;;
7433
7434    obj)
7435      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7436	func_warning "\`-dlopen' is ignored for objects"
7437      fi
7438
7439      case " $deplibs" in
7440      *\ -l* | *\ -L*)
7441	func_warning "\`-l' and \`-L' are ignored for objects" ;;
7442      esac
7443
7444      test -n "$rpath" && \
7445	func_warning "\`-rpath' is ignored for objects"
7446
7447      test -n "$xrpath" && \
7448	func_warning "\`-R' is ignored for objects"
7449
7450      test -n "$vinfo" && \
7451	func_warning "\`-version-info' is ignored for objects"
7452
7453      test -n "$release" && \
7454	func_warning "\`-release' is ignored for objects"
7455
7456      case $output in
7457      *.lo)
7458	test -n "$objs$old_deplibs" && \
7459	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7460
7461	libobj=$output
7462	func_lo2o "$libobj"
7463	obj=$func_lo2o_result
7464	;;
7465      *)
7466	libobj=
7467	obj="$output"
7468	;;
7469      esac
7470
7471      # Delete the old objects.
7472      $opt_dry_run || $RM $obj $libobj
7473
7474      # Objects from convenience libraries.  This assumes
7475      # single-version convenience libraries.  Whenever we create
7476      # different ones for PIC/non-PIC, this we'll have to duplicate
7477      # the extraction.
7478      reload_conv_objs=
7479      gentop=
7480      # reload_cmds runs $LD directly, so let us get rid of
7481      # -Wl from whole_archive_flag_spec and hope we can get by with
7482      # turning comma into space..
7483      wl=
7484
7485      if test -n "$convenience"; then
7486	if test -n "$whole_archive_flag_spec"; then
7487	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
7488	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
7489	else
7490	  gentop="$output_objdir/${obj}x"
7491	  generated="$generated $gentop"
7492
7493	  func_extract_archives $gentop $convenience
7494	  reload_conv_objs="$reload_objs $func_extract_archives_result"
7495	fi
7496      fi
7497
7498      # Create the old-style object.
7499      reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
7500
7501      output="$obj"
7502      func_execute_cmds "$reload_cmds" 'exit $?'
7503
7504      # Exit if we aren't doing a library object file.
7505      if test -z "$libobj"; then
7506	if test -n "$gentop"; then
7507	  func_show_eval '${RM}r "$gentop"'
7508	fi
7509
7510	exit $EXIT_SUCCESS
7511      fi
7512
7513      if test "$build_libtool_libs" != yes; then
7514	if test -n "$gentop"; then
7515	  func_show_eval '${RM}r "$gentop"'
7516	fi
7517
7518	# Create an invalid libtool object if no PIC, so that we don't
7519	# accidentally link it into a program.
7520	# $show "echo timestamp > $libobj"
7521	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
7522	exit $EXIT_SUCCESS
7523      fi
7524
7525      if test -n "$pic_flag" || test "$pic_mode" != default; then
7526	# Only do commands if we really have different PIC objects.
7527	reload_objs="$libobjs $reload_conv_objs"
7528	output="$libobj"
7529	func_execute_cmds "$reload_cmds" 'exit $?'
7530      fi
7531
7532      if test -n "$gentop"; then
7533	func_show_eval '${RM}r "$gentop"'
7534      fi
7535
7536      exit $EXIT_SUCCESS
7537      ;;
7538
7539    prog)
7540      case $host in
7541	*cygwin*) func_stripname '' '.exe' "$output"
7542	          output=$func_stripname_result.exe;;
7543      esac
7544      test -n "$vinfo" && \
7545	func_warning "\`-version-info' is ignored for programs"
7546
7547      test -n "$release" && \
7548	func_warning "\`-release' is ignored for programs"
7549
7550      test "$preload" = yes \
7551        && test "$dlopen_support" = unknown \
7552	&& test "$dlopen_self" = unknown \
7553	&& test "$dlopen_self_static" = unknown && \
7554	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7555
7556      case $host in
7557      *-*-rhapsody* | *-*-darwin1.[012])
7558	# On Rhapsody replace the C library is the System framework
7559	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7560	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7561	;;
7562      esac
7563
7564      case $host in
7565      *-*-darwin*)
7566	# Don't allow lazy linking, it breaks C++ global constructors
7567	# But is supposedly fixed on 10.4 or later (yay!).
7568	if test "$tagname" = CXX ; then
7569	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7570	    10.[0123])
7571	      compile_command="$compile_command ${wl}-bind_at_load"
7572	      finalize_command="$finalize_command ${wl}-bind_at_load"
7573	    ;;
7574	  esac
7575	fi
7576	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
7577	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7578	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7579	;;
7580      esac
7581
7582
7583      # move library search paths that coincide with paths to not yet
7584      # installed libraries to the beginning of the library search list
7585      new_libs=
7586      for path in $notinst_path; do
7587	case " $new_libs " in
7588	*" -L$path/$objdir "*) ;;
7589	*)
7590	  case " $compile_deplibs " in
7591	  *" -L$path/$objdir "*)
7592	    new_libs="$new_libs -L$path/$objdir" ;;
7593	  esac
7594	  ;;
7595	esac
7596      done
7597      for deplib in $compile_deplibs; do
7598	case $deplib in
7599	-L*)
7600	  case " $new_libs " in
7601	  *" $deplib "*) ;;
7602	  *) new_libs="$new_libs $deplib" ;;
7603	  esac
7604	  ;;
7605	*) new_libs="$new_libs $deplib" ;;
7606	esac
7607      done
7608      compile_deplibs="$new_libs"
7609
7610
7611      compile_command="$compile_command $compile_deplibs"
7612      finalize_command="$finalize_command $finalize_deplibs"
7613
7614      if test -n "$rpath$xrpath"; then
7615	# If the user specified any rpath flags, then add them.
7616	for libdir in $rpath $xrpath; do
7617	  # This is the magic to use -rpath.
7618	  case "$finalize_rpath " in
7619	  *" $libdir "*) ;;
7620	  *) finalize_rpath="$finalize_rpath $libdir" ;;
7621	  esac
7622	done
7623      fi
7624
7625      # Now hardcode the library paths
7626      rpath=
7627      hardcode_libdirs=
7628      for libdir in $compile_rpath $finalize_rpath; do
7629	if test -n "$hardcode_libdir_flag_spec"; then
7630	  if test -n "$hardcode_libdir_separator"; then
7631	    if test -z "$hardcode_libdirs"; then
7632	      hardcode_libdirs="$libdir"
7633	    else
7634	      # Just accumulate the unique libdirs.
7635	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7636	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7637		;;
7638	      *)
7639		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7640		;;
7641	      esac
7642	    fi
7643	  else
7644	    eval flag=\"$hardcode_libdir_flag_spec\"
7645	    rpath="$rpath $flag"
7646	  fi
7647	elif test -n "$runpath_var"; then
7648	  case "$perm_rpath " in
7649	  *" $libdir "*) ;;
7650	  *) perm_rpath="$perm_rpath $libdir" ;;
7651	  esac
7652	fi
7653	case $host in
7654	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7655	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7656	  case :$dllsearchpath: in
7657	  *":$libdir:"*) ;;
7658	  ::) dllsearchpath=$libdir;;
7659	  *) dllsearchpath="$dllsearchpath:$libdir";;
7660	  esac
7661	  case :$dllsearchpath: in
7662	  *":$testbindir:"*) ;;
7663	  ::) dllsearchpath=$testbindir;;
7664	  *) dllsearchpath="$dllsearchpath:$testbindir";;
7665	  esac
7666	  ;;
7667	esac
7668      done
7669      # Substitute the hardcoded libdirs into the rpath.
7670      if test -n "$hardcode_libdir_separator" &&
7671	 test -n "$hardcode_libdirs"; then
7672	libdir="$hardcode_libdirs"
7673	eval rpath=\" $hardcode_libdir_flag_spec\"
7674      fi
7675      compile_rpath="$rpath"
7676
7677      rpath=
7678      hardcode_libdirs=
7679      for libdir in $finalize_rpath; do
7680	if test -n "$hardcode_libdir_flag_spec"; then
7681	  if test -n "$hardcode_libdir_separator"; then
7682	    if test -z "$hardcode_libdirs"; then
7683	      hardcode_libdirs="$libdir"
7684	    else
7685	      # Just accumulate the unique libdirs.
7686	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7687	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7688		;;
7689	      *)
7690		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7691		;;
7692	      esac
7693	    fi
7694	  else
7695	    eval flag=\"$hardcode_libdir_flag_spec\"
7696	    rpath="$rpath $flag"
7697	  fi
7698	elif test -n "$runpath_var"; then
7699	  case "$finalize_perm_rpath " in
7700	  *" $libdir "*) ;;
7701	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7702	  esac
7703	fi
7704      done
7705      # Substitute the hardcoded libdirs into the rpath.
7706      if test -n "$hardcode_libdir_separator" &&
7707	 test -n "$hardcode_libdirs"; then
7708	libdir="$hardcode_libdirs"
7709	eval rpath=\" $hardcode_libdir_flag_spec\"
7710      fi
7711      finalize_rpath="$rpath"
7712
7713      if test -n "$libobjs" && test "$build_old_libs" = yes; then
7714	# Transform all the library objects into standard objects.
7715	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7716	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7717      fi
7718
7719      func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7720
7721      # template prelinking step
7722      if test -n "$prelink_cmds"; then
7723	func_execute_cmds "$prelink_cmds" 'exit $?'
7724      fi
7725
7726      wrappers_required=yes
7727      case $host in
7728      *cygwin* | *mingw* )
7729        if test "$build_libtool_libs" != yes; then
7730          wrappers_required=no
7731        fi
7732        ;;
7733      *cegcc)
7734        # Disable wrappers for cegcc, we are cross compiling anyway.
7735        wrappers_required=no
7736        ;;
7737      *)
7738        if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7739          wrappers_required=no
7740        fi
7741        ;;
7742      esac
7743      if test "$wrappers_required" = no; then
7744	# Replace the output file specification.
7745	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7746	link_command="$compile_command$compile_rpath"
7747
7748	# We have no uninstalled library dependencies, so finalize right now.
7749	exit_status=0
7750	func_show_eval "$link_command" 'exit_status=$?'
7751
7752	# Delete the generated files.
7753	if test -f "$output_objdir/${outputname}S.${objext}"; then
7754	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
7755	fi
7756
7757	exit $exit_status
7758      fi
7759
7760      if test -n "$compile_shlibpath$finalize_shlibpath"; then
7761	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7762      fi
7763      if test -n "$finalize_shlibpath"; then
7764	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7765      fi
7766
7767      compile_var=
7768      finalize_var=
7769      if test -n "$runpath_var"; then
7770	if test -n "$perm_rpath"; then
7771	  # We should set the runpath_var.
7772	  rpath=
7773	  for dir in $perm_rpath; do
7774	    rpath="$rpath$dir:"
7775	  done
7776	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7777	fi
7778	if test -n "$finalize_perm_rpath"; then
7779	  # We should set the runpath_var.
7780	  rpath=
7781	  for dir in $finalize_perm_rpath; do
7782	    rpath="$rpath$dir:"
7783	  done
7784	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7785	fi
7786      fi
7787
7788      if test "$no_install" = yes; then
7789	# We don't need to create a wrapper script.
7790	link_command="$compile_var$compile_command$compile_rpath"
7791	# Replace the output file specification.
7792	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7793	# Delete the old output file.
7794	$opt_dry_run || $RM $output
7795	# Link the executable and exit
7796	func_show_eval "$link_command" 'exit $?'
7797	exit $EXIT_SUCCESS
7798      fi
7799
7800      if test "$hardcode_action" = relink; then
7801	# Fast installation is not supported
7802	link_command="$compile_var$compile_command$compile_rpath"
7803	relink_command="$finalize_var$finalize_command$finalize_rpath"
7804
7805	func_warning "this platform does not like uninstalled shared libraries"
7806	func_warning "\`$output' will be relinked during installation"
7807      else
7808	if test "$fast_install" != no; then
7809	  link_command="$finalize_var$compile_command$finalize_rpath"
7810	  if test "$fast_install" = yes; then
7811	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
7812	  else
7813	    # fast_install is set to needless
7814	    relink_command=
7815	  fi
7816	else
7817	  link_command="$compile_var$compile_command$compile_rpath"
7818	  relink_command="$finalize_var$finalize_command$finalize_rpath"
7819	fi
7820      fi
7821
7822      # Replace the output file specification.
7823      link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
7824
7825      # Delete the old output files.
7826      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
7827
7828      func_show_eval "$link_command" 'exit $?'
7829
7830      # Now create the wrapper script.
7831      func_verbose "creating $output"
7832
7833      # Quote the relink command for shipping.
7834      if test -n "$relink_command"; then
7835	# Preserve any variables that may affect compiler behavior
7836	for var in $variables_saved_for_relink; do
7837	  if eval test -z \"\${$var+set}\"; then
7838	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7839	  elif eval var_value=\$$var; test -z "$var_value"; then
7840	    relink_command="$var=; export $var; $relink_command"
7841	  else
7842	    func_quote_for_eval "$var_value"
7843	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
7844	  fi
7845	done
7846	relink_command="(cd `pwd`; $relink_command)"
7847	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7848      fi
7849
7850      # Quote $ECHO for shipping.
7851      if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7852	case $progpath in
7853	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7854	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7855	esac
7856	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7857      else
7858	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
7859      fi
7860
7861      # Only actually do things if not in dry run mode.
7862      $opt_dry_run || {
7863	# win32 will think the script is a binary if it has
7864	# a .exe suffix, so we strip it off here.
7865	case $output in
7866	  *.exe) func_stripname '' '.exe' "$output"
7867	         output=$func_stripname_result ;;
7868	esac
7869	# test for cygwin because mv fails w/o .exe extensions
7870	case $host in
7871	  *cygwin*)
7872	    exeext=.exe
7873	    func_stripname '' '.exe' "$outputname"
7874	    outputname=$func_stripname_result ;;
7875	  *) exeext= ;;
7876	esac
7877	case $host in
7878	  *cygwin* | *mingw* )
7879	    func_dirname_and_basename "$output" "" "."
7880	    output_name=$func_basename_result
7881	    output_path=$func_dirname_result
7882	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
7883	    cwrapper="$output_path/$output_name.exe"
7884	    $RM $cwrappersource $cwrapper
7885	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
7886
7887	    func_emit_cwrapperexe_src > $cwrappersource
7888
7889	    # The wrapper executable is built using the $host compiler,
7890	    # because it contains $host paths and files. If cross-
7891	    # compiling, it, like the target executable, must be
7892	    # executed on the $host or under an emulation environment.
7893	    $opt_dry_run || {
7894	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7895	      $STRIP $cwrapper
7896	    }
7897
7898	    # Now, create the wrapper script for func_source use:
7899	    func_ltwrapper_scriptname $cwrapper
7900	    $RM $func_ltwrapper_scriptname_result
7901	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7902	    $opt_dry_run || {
7903	      # note: this script will not be executed, so do not chmod.
7904	      if test "x$build" = "x$host" ; then
7905		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7906	      else
7907		func_emit_wrapper no > $func_ltwrapper_scriptname_result
7908	      fi
7909	    }
7910	  ;;
7911	  * )
7912	    $RM $output
7913	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
7914
7915	    func_emit_wrapper no > $output
7916	    chmod +x $output
7917	  ;;
7918	esac
7919      }
7920      exit $EXIT_SUCCESS
7921      ;;
7922    esac
7923
7924    # See if we need to build an old-fashioned archive.
7925    for oldlib in $oldlibs; do
7926
7927      if test "$build_libtool_libs" = convenience; then
7928	oldobjs="$libobjs_save $symfileobj"
7929	addlibs="$convenience"
7930	build_libtool_libs=no
7931      else
7932	if test "$build_libtool_libs" = module; then
7933	  oldobjs="$libobjs_save"
7934	  build_libtool_libs=no
7935	else
7936	  oldobjs="$old_deplibs $non_pic_objects"
7937	  if test "$preload" = yes && test -f "$symfileobj"; then
7938	    oldobjs="$oldobjs $symfileobj"
7939	  fi
7940	fi
7941	addlibs="$old_convenience"
7942      fi
7943
7944      if test -n "$addlibs"; then
7945	gentop="$output_objdir/${outputname}x"
7946	generated="$generated $gentop"
7947
7948	func_extract_archives $gentop $addlibs
7949	oldobjs="$oldobjs $func_extract_archives_result"
7950      fi
7951
7952      # Do each command in the archive commands.
7953      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
7954	cmds=$old_archive_from_new_cmds
7955      else
7956
7957	# Add any objects from preloaded convenience libraries
7958	if test -n "$dlprefiles"; then
7959	  gentop="$output_objdir/${outputname}x"
7960	  generated="$generated $gentop"
7961
7962	  func_extract_archives $gentop $dlprefiles
7963	  oldobjs="$oldobjs $func_extract_archives_result"
7964	fi
7965
7966	# POSIX demands no paths to be encoded in archives.  We have
7967	# to avoid creating archives with duplicate basenames if we
7968	# might have to extract them afterwards, e.g., when creating a
7969	# static archive out of a convenience library, or when linking
7970	# the entirety of a libtool archive into another (currently
7971	# not supported by libtool).
7972	if (for obj in $oldobjs
7973	    do
7974	      func_basename "$obj"
7975	      $ECHO "$func_basename_result"
7976	    done | sort | sort -uc >/dev/null 2>&1); then
7977	  :
7978	else
7979	  $ECHO "copying selected object files to avoid basename conflicts..."
7980	  gentop="$output_objdir/${outputname}x"
7981	  generated="$generated $gentop"
7982	  func_mkdir_p "$gentop"
7983	  save_oldobjs=$oldobjs
7984	  oldobjs=
7985	  counter=1
7986	  for obj in $save_oldobjs
7987	  do
7988	    func_basename "$obj"
7989	    objbase="$func_basename_result"
7990	    case " $oldobjs " in
7991	    " ") oldobjs=$obj ;;
7992	    *[\ /]"$objbase "*)
7993	      while :; do
7994		# Make sure we don't pick an alternate name that also
7995		# overlaps.
7996		newobj=lt$counter-$objbase
7997		func_arith $counter + 1
7998		counter=$func_arith_result
7999		case " $oldobjs " in
8000		*[\ /]"$newobj "*) ;;
8001		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
8002		esac
8003	      done
8004	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
8005	      oldobjs="$oldobjs $gentop/$newobj"
8006	      ;;
8007	    *) oldobjs="$oldobjs $obj" ;;
8008	    esac
8009	  done
8010	fi
8011	eval cmds=\"$old_archive_cmds\"
8012
8013	func_len " $cmds"
8014	len=$func_len_result
8015	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
8016	  cmds=$old_archive_cmds
8017	else
8018	  # the command line is too long to link in one step, link in parts
8019	  func_verbose "using piecewise archive linking..."
8020	  save_RANLIB=$RANLIB
8021	  RANLIB=:
8022	  objlist=
8023	  concat_cmds=
8024	  save_oldobjs=$oldobjs
8025	  oldobjs=
8026	  # Is there a better way of finding the last object in the list?
8027	  for obj in $save_oldobjs
8028	  do
8029	    last_oldobj=$obj
8030	  done
8031	  eval test_cmds=\"$old_archive_cmds\"
8032	  func_len " $test_cmds"
8033	  len0=$func_len_result
8034	  len=$len0
8035	  for obj in $save_oldobjs
8036	  do
8037	    func_len " $obj"
8038	    func_arith $len + $func_len_result
8039	    len=$func_arith_result
8040	    func_append objlist " $obj"
8041	    if test "$len" -lt "$max_cmd_len"; then
8042	      :
8043	    else
8044	      # the above command should be used before it gets too long
8045	      oldobjs=$objlist
8046	      if test "$obj" = "$last_oldobj" ; then
8047		RANLIB=$save_RANLIB
8048	      fi
8049	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8050	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
8051	      objlist=
8052	      len=$len0
8053	    fi
8054	  done
8055	  RANLIB=$save_RANLIB
8056	  oldobjs=$objlist
8057	  if test "X$oldobjs" = "X" ; then
8058	    eval cmds=\"\$concat_cmds\"
8059	  else
8060	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
8061	  fi
8062	fi
8063      fi
8064      func_execute_cmds "$cmds" 'exit $?'
8065    done
8066
8067    test -n "$generated" && \
8068      func_show_eval "${RM}r$generated"
8069
8070    # Now create the libtool archive.
8071    case $output in
8072    *.la)
8073      old_library=
8074      test "$build_old_libs" = yes && old_library="$libname.$libext"
8075      func_verbose "creating $output"
8076
8077      # Preserve any variables that may affect compiler behavior
8078      for var in $variables_saved_for_relink; do
8079	if eval test -z \"\${$var+set}\"; then
8080	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8081	elif eval var_value=\$$var; test -z "$var_value"; then
8082	  relink_command="$var=; export $var; $relink_command"
8083	else
8084	  func_quote_for_eval "$var_value"
8085	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8086	fi
8087      done
8088      # Quote the link command for shipping.
8089      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8090      relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
8091      if test "$hardcode_automatic" = yes ; then
8092	relink_command=
8093      fi
8094
8095      # Only create the output if not a dry run.
8096      $opt_dry_run || {
8097	for installed in no yes; do
8098	  if test "$installed" = yes; then
8099	    if test -z "$install_libdir"; then
8100	      break
8101	    fi
8102	    output="$output_objdir/$outputname"i
8103	    # Replace all uninstalled libtool libraries with the installed ones
8104	    newdependency_libs=
8105	    for deplib in $dependency_libs; do
8106	      case $deplib in
8107	      *.la)
8108		func_basename "$deplib"
8109		name="$func_basename_result"
8110		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8111		test -z "$libdir" && \
8112		  func_fatal_error "\`$deplib' is not a valid libtool archive"
8113		newdependency_libs="$newdependency_libs $libdir/$name"
8114		;;
8115	      *) newdependency_libs="$newdependency_libs $deplib" ;;
8116	      esac
8117	    done
8118	    dependency_libs="$newdependency_libs"
8119	    newdlfiles=
8120
8121	    for lib in $dlfiles; do
8122	      case $lib in
8123	      *.la)
8124	        func_basename "$lib"
8125		name="$func_basename_result"
8126		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8127		test -z "$libdir" && \
8128		  func_fatal_error "\`$lib' is not a valid libtool archive"
8129		newdlfiles="$newdlfiles $libdir/$name"
8130		;;
8131	      *) newdlfiles="$newdlfiles $lib" ;;
8132	      esac
8133	    done
8134	    dlfiles="$newdlfiles"
8135	    newdlprefiles=
8136	    for lib in $dlprefiles; do
8137	      case $lib in
8138	      *.la)
8139		# Only pass preopened files to the pseudo-archive (for
8140		# eventual linking with the app. that links it) if we
8141		# didn't already link the preopened objects directly into
8142		# the library:
8143		func_basename "$lib"
8144		name="$func_basename_result"
8145		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8146		test -z "$libdir" && \
8147		  func_fatal_error "\`$lib' is not a valid libtool archive"
8148		newdlprefiles="$newdlprefiles $libdir/$name"
8149		;;
8150	      esac
8151	    done
8152	    dlprefiles="$newdlprefiles"
8153	  else
8154	    newdlfiles=
8155	    for lib in $dlfiles; do
8156	      case $lib in
8157		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8158		*) abs=`pwd`"/$lib" ;;
8159	      esac
8160	      newdlfiles="$newdlfiles $abs"
8161	    done
8162	    dlfiles="$newdlfiles"
8163	    newdlprefiles=
8164	    for lib in $dlprefiles; do
8165	      case $lib in
8166		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8167		*) abs=`pwd`"/$lib" ;;
8168	      esac
8169	      newdlprefiles="$newdlprefiles $abs"
8170	    done
8171	    dlprefiles="$newdlprefiles"
8172	  fi
8173	  $RM $output
8174	  # place dlname in correct position for cygwin
8175	  tdlname=$dlname
8176	  case $host,$output,$installed,$module,$dlname in
8177	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
8178	  esac
8179	  $ECHO > $output "\
8180# $outputname - a libtool library file
8181# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8182#
8183# Please DO NOT delete this file!
8184# It is necessary for linking the library.
8185
8186# The name that we can dlopen(3).
8187dlname='$tdlname'
8188
8189# Names of this library.
8190library_names='$library_names'
8191
8192# The name of the static archive.
8193old_library='$old_library'
8194
8195# Linker flags that can not go in dependency_libs.
8196inherited_linker_flags='$new_inherited_linker_flags'
8197
8198# Libraries that this one depends upon.
8199dependency_libs='$dependency_libs'
8200
8201# Names of additional weak libraries provided by this library
8202weak_library_names='$weak_libs'
8203
8204# Version information for $libname.
8205current=$current
8206age=$age
8207revision=$revision
8208
8209# Is this an already installed library?
8210installed=$installed
8211
8212# Should we warn about portability when linking against -modules?
8213shouldnotlink=$module
8214
8215# Files to dlopen/dlpreopen
8216dlopen='$dlfiles'
8217dlpreopen='$dlprefiles'
8218
8219# Directory that this library needs to be installed in:
8220libdir='$install_libdir'"
8221	  if test "$installed" = no && test "$need_relink" = yes; then
8222	    $ECHO >> $output "\
8223relink_command=\"$relink_command\""
8224	  fi
8225	done
8226      }
8227
8228      # Do a symbolic link so that the libtool archive can be found in
8229      # LD_LIBRARY_PATH before the program is installed.
8230      func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8231      ;;
8232    esac
8233    exit $EXIT_SUCCESS
8234}
8235
8236{ test "$mode" = link || test "$mode" = relink; } &&
8237    func_mode_link ${1+"$@"}
8238
8239
8240# func_mode_uninstall arg...
8241func_mode_uninstall ()
8242{
8243    $opt_debug
8244    RM="$nonopt"
8245    files=
8246    rmforce=
8247    exit_status=0
8248
8249    # This variable tells wrapper scripts just to set variables rather
8250    # than running their programs.
8251    libtool_install_magic="$magic"
8252
8253    for arg
8254    do
8255      case $arg in
8256      -f) RM="$RM $arg"; rmforce=yes ;;
8257      -*) RM="$RM $arg" ;;
8258      *) files="$files $arg" ;;
8259      esac
8260    done
8261
8262    test -z "$RM" && \
8263      func_fatal_help "you must specify an RM program"
8264
8265    rmdirs=
8266
8267    origobjdir="$objdir"
8268    for file in $files; do
8269      func_dirname "$file" "" "."
8270      dir="$func_dirname_result"
8271      if test "X$dir" = X.; then
8272	objdir="$origobjdir"
8273      else
8274	objdir="$dir/$origobjdir"
8275      fi
8276      func_basename "$file"
8277      name="$func_basename_result"
8278      test "$mode" = uninstall && objdir="$dir"
8279
8280      # Remember objdir for removal later, being careful to avoid duplicates
8281      if test "$mode" = clean; then
8282	case " $rmdirs " in
8283	  *" $objdir "*) ;;
8284	  *) rmdirs="$rmdirs $objdir" ;;
8285	esac
8286      fi
8287
8288      # Don't error if the file doesn't exist and rm -f was used.
8289      if { test -L "$file"; } >/dev/null 2>&1 ||
8290	 { test -h "$file"; } >/dev/null 2>&1 ||
8291	 test -f "$file"; then
8292	:
8293      elif test -d "$file"; then
8294	exit_status=1
8295	continue
8296      elif test "$rmforce" = yes; then
8297	continue
8298      fi
8299
8300      rmfiles="$file"
8301
8302      case $name in
8303      *.la)
8304	# Possibly a libtool archive, so verify it.
8305	if func_lalib_p "$file"; then
8306	  func_source $dir/$name
8307
8308	  # Delete the libtool libraries and symlinks.
8309	  for n in $library_names; do
8310	    rmfiles="$rmfiles $objdir/$n"
8311	  done
8312	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
8313
8314	  case "$mode" in
8315	  clean)
8316	    case "  $library_names " in
8317	    # "  " in the beginning catches empty $dlname
8318	    *" $dlname "*) ;;
8319	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
8320	    esac
8321	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
8322	    ;;
8323	  uninstall)
8324	    if test -n "$library_names"; then
8325	      # Do each command in the postuninstall commands.
8326	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8327	    fi
8328
8329	    if test -n "$old_library"; then
8330	      # Do each command in the old_postuninstall commands.
8331	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8332	    fi
8333	    # FIXME: should reinstall the best remaining shared library.
8334	    ;;
8335	  esac
8336	fi
8337	;;
8338
8339      *.lo)
8340	# Possibly a libtool object, so verify it.
8341	if func_lalib_p "$file"; then
8342
8343	  # Read the .lo file
8344	  func_source $dir/$name
8345
8346	  # Add PIC object to the list of files to remove.
8347	  if test -n "$pic_object" &&
8348	     test "$pic_object" != none; then
8349	    rmfiles="$rmfiles $dir/$pic_object"
8350	  fi
8351
8352	  # Add non-PIC object to the list of files to remove.
8353	  if test -n "$non_pic_object" &&
8354	     test "$non_pic_object" != none; then
8355	    rmfiles="$rmfiles $dir/$non_pic_object"
8356	  fi
8357	fi
8358	;;
8359
8360      *)
8361	if test "$mode" = clean ; then
8362	  noexename=$name
8363	  case $file in
8364	  *.exe)
8365	    func_stripname '' '.exe' "$file"
8366	    file=$func_stripname_result
8367	    func_stripname '' '.exe' "$name"
8368	    noexename=$func_stripname_result
8369	    # $file with .exe has already been added to rmfiles,
8370	    # add $file without .exe
8371	    rmfiles="$rmfiles $file"
8372	    ;;
8373	  esac
8374	  # Do a test to see if this is a libtool program.
8375	  if func_ltwrapper_p "$file"; then
8376	    if func_ltwrapper_executable_p "$file"; then
8377	      func_ltwrapper_scriptname "$file"
8378	      relink_command=
8379	      func_source $func_ltwrapper_scriptname_result
8380	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8381	    else
8382	      relink_command=
8383	      func_source $dir/$noexename
8384	    fi
8385
8386	    # note $name still contains .exe if it was in $file originally
8387	    # as does the version of $file that was added into $rmfiles
8388	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
8389	    if test "$fast_install" = yes && test -n "$relink_command"; then
8390	      rmfiles="$rmfiles $objdir/lt-$name"
8391	    fi
8392	    if test "X$noexename" != "X$name" ; then
8393	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
8394	    fi
8395	  fi
8396	fi
8397	;;
8398      esac
8399      func_show_eval "$RM $rmfiles" 'exit_status=1'
8400    done
8401    objdir="$origobjdir"
8402
8403    # Try to remove the ${objdir}s in the directories where we deleted files
8404    for dir in $rmdirs; do
8405      if test -d "$dir"; then
8406	func_show_eval "rmdir $dir >/dev/null 2>&1"
8407      fi
8408    done
8409
8410    exit $exit_status
8411}
8412
8413{ test "$mode" = uninstall || test "$mode" = clean; } &&
8414    func_mode_uninstall ${1+"$@"}
8415
8416test -z "$mode" && {
8417  help="$generic_help"
8418  func_fatal_help "you must specify a MODE"
8419}
8420
8421test -z "$exec_cmd" && \
8422  func_fatal_help "invalid operation mode \`$mode'"
8423
8424if test -n "$exec_cmd"; then
8425  eval exec "$exec_cmd"
8426  exit $EXIT_FAILURE
8427fi
8428
8429exit $exit_status
8430
8431
8432# The TAGs below are defined such that we never get into a situation
8433# in which we disable both kinds of libraries.  Given conflicting
8434# choices, we go for a static library, that is the most portable,
8435# since we can't tell whether shared libraries were disabled because
8436# the user asked for that or because the platform doesn't support
8437# them.  This is particularly important on AIX, because we don't
8438# support having both static and shared libraries enabled at the same
8439# time on that platform, so we default to a shared-only configuration.
8440# If a disable-shared tag is given, we'll fallback to a static-only
8441# configuration.  But we'll never go from static-only to shared-only.
8442
8443# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8444build_libtool_libs=no
8445build_old_libs=yes
8446# ### END LIBTOOL TAG CONFIG: disable-shared
8447
8448# ### BEGIN LIBTOOL TAG CONFIG: disable-static
8449build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
8450# ### END LIBTOOL TAG CONFIG: disable-static
8451
8452# Local Variables:
8453# mode:shell-script
8454# sh-indentation:2
8455# End:
8456# vi:sw=2
8457
8458