msousa@353: # Generated from ltmain.m4sh.
msousa@353: 
msousa@353: # ltmain.sh (GNU libtool) 2.2.6b
msousa@353: # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
msousa@353: 
msousa@353: # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
msousa@353: # This is free software; see the source for copying conditions.  There is NO
msousa@353: # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
msousa@353: 
msousa@353: # GNU Libtool is free software; you can redistribute it and/or modify
msousa@353: # it under the terms of the GNU General Public License as published by
msousa@353: # the Free Software Foundation; either version 2 of the License, or
msousa@353: # (at your option) any later version.
msousa@353: #
msousa@353: # As a special exception to the GNU General Public License,
msousa@353: # if you distribute this file as part of a program or library that
msousa@353: # is built using GNU Libtool, you may include this file under the
msousa@353: # same distribution terms that you use for the rest of that program.
msousa@353: #
msousa@353: # GNU Libtool is distributed in the hope that it will be useful, but
msousa@353: # WITHOUT ANY WARRANTY; without even the implied warranty of
msousa@353: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
msousa@353: # General Public License for more details.
msousa@353: #
msousa@353: # You should have received a copy of the GNU General Public License
msousa@353: # along with GNU Libtool; see the file COPYING.  If not, a copy
msousa@353: # can be downloaded from http://www.gnu.org/licenses/gpl.html,
msousa@353: # or obtained by writing to the Free Software Foundation, Inc.,
msousa@353: # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
msousa@353: 
msousa@353: # Usage: $progname [OPTION]... [MODE-ARG]...
msousa@353: #
msousa@353: # Provide generalized library-building support services.
msousa@353: #
msousa@353: #     --config             show all configuration variables
msousa@353: #     --debug              enable verbose shell tracing
msousa@353: # -n, --dry-run            display commands without modifying any files
msousa@353: #     --features           display basic configuration information and exit
msousa@353: #     --mode=MODE          use operation mode MODE
msousa@353: #     --preserve-dup-deps  don't remove duplicate dependency libraries
msousa@353: #     --quiet, --silent    don't print informational messages
msousa@353: #     --tag=TAG            use configuration variables from tag TAG
msousa@353: # -v, --verbose            print informational messages (default)
msousa@353: #     --version            print version information
msousa@353: # -h, --help               print short or long help message
msousa@353: #
msousa@353: # MODE must be one of the following:
msousa@353: #
msousa@353: #       clean              remove files from the build directory
msousa@353: #       compile            compile a source file into a libtool object
msousa@353: #       execute            automatically set library path, then run a program
msousa@353: #       finish             complete the installation of libtool libraries
msousa@353: #       install            install libraries or executables
msousa@353: #       link               create a library or an executable
msousa@353: #       uninstall          remove libraries from an installed directory
msousa@353: #
msousa@353: # MODE-ARGS vary depending on the MODE.
msousa@353: # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
msousa@353: #
msousa@353: # When reporting a bug, please describe a test case to reproduce it and
msousa@353: # include the following information:
msousa@353: #
msousa@353: #       host-triplet:	$host
msousa@353: #       shell:		$SHELL
msousa@353: #       compiler:		$LTCC
msousa@353: #       compiler flags:		$LTCFLAGS
msousa@353: #       linker:		$LD (gnu? $with_gnu_ld)
msousa@353: #       $progname:		(GNU libtool) 2.2.6b Debian-2.2.6b-2ubuntu1
msousa@353: #       automake:		$automake_version
msousa@353: #       autoconf:		$autoconf_version
msousa@353: #
msousa@353: # Report bugs to <bug-libtool@gnu.org>.
msousa@353: 
msousa@353: PROGRAM=ltmain.sh
msousa@353: PACKAGE=libtool
msousa@353: VERSION="2.2.6b Debian-2.2.6b-2ubuntu1"
msousa@353: TIMESTAMP=""
msousa@353: package_revision=1.3017
msousa@353: 
msousa@353: # Be Bourne compatible
msousa@353: if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
msousa@353:   emulate sh
msousa@353:   NULLCMD=:
msousa@353:   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
msousa@353:   # is contrary to our usage.  Disable this feature.
msousa@353:   alias -g '${1+"$@"}'='"$@"'
msousa@353:   setopt NO_GLOB_SUBST
msousa@353: else
msousa@353:   case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
msousa@353: fi
msousa@353: BIN_SH=xpg4; export BIN_SH # for Tru64
msousa@353: DUALCASE=1; export DUALCASE # for MKS sh
msousa@353: 
msousa@353: # NLS nuisances: We save the old values to restore during execute mode.
msousa@353: # Only set LANG and LC_ALL to C if already set.
msousa@353: # These must not be set unconditionally because not all systems understand
msousa@353: # e.g. LANG=C (notably SCO).
msousa@353: lt_user_locale=
msousa@353: lt_safe_locale=
msousa@353: for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
msousa@353: do
msousa@353:   eval "if test \"\${$lt_var+set}\" = set; then
msousa@353:           save_$lt_var=\$$lt_var
msousa@353:           $lt_var=C
msousa@353: 	  export $lt_var
msousa@353: 	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
msousa@353: 	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
msousa@353: 	fi"
msousa@353: done
msousa@353: 
msousa@353: $lt_unset CDPATH
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: : ${CP="cp -f"}
msousa@353: : ${ECHO="echo"}
msousa@353: : ${EGREP="/bin/grep -E"}
msousa@353: : ${FGREP="/bin/grep -F"}
msousa@353: : ${GREP="/bin/grep"}
msousa@353: : ${LN_S="ln -s"}
msousa@353: : ${MAKE="make"}
msousa@353: : ${MKDIR="mkdir"}
msousa@353: : ${MV="mv -f"}
msousa@353: : ${RM="rm -f"}
msousa@353: : ${SED="/bin/sed"}
msousa@353: : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
msousa@353: : ${Xsed="$SED -e 1s/^X//"}
msousa@353: 
msousa@353: # Global variables:
msousa@353: EXIT_SUCCESS=0
msousa@353: EXIT_FAILURE=1
msousa@353: EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
msousa@353: EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
msousa@353: 
msousa@353: exit_status=$EXIT_SUCCESS
msousa@353: 
msousa@353: # Make sure IFS has a sensible default
msousa@353: lt_nl='
msousa@353: '
msousa@353: IFS=" 	$lt_nl"
msousa@353: 
msousa@353: dirname="s,/[^/]*$,,"
msousa@353: basename="s,^.*/,,"
msousa@353: 
msousa@353: # func_dirname_and_basename file append nondir_replacement
msousa@353: # perform func_basename and func_dirname in a single function
msousa@353: # call:
msousa@353: #   dirname:  Compute the dirname of FILE.  If nonempty,
msousa@353: #             add APPEND to the result, otherwise set result
msousa@353: #             to NONDIR_REPLACEMENT.
msousa@353: #             value returned in "$func_dirname_result"
msousa@353: #   basename: Compute filename of FILE.
msousa@353: #             value retuned in "$func_basename_result"
msousa@353: # Implementation must be kept synchronized with func_dirname
msousa@353: # and func_basename. For efficiency, we do not delegate to
msousa@353: # those functions but instead duplicate the functionality here.
msousa@353: func_dirname_and_basename ()
msousa@353: {
msousa@353:   # Extract subdirectory from the argument.
msousa@353:   func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
msousa@353:   if test "X$func_dirname_result" = "X${1}"; then
msousa@353:     func_dirname_result="${3}"
msousa@353:   else
msousa@353:     func_dirname_result="$func_dirname_result${2}"
msousa@353:   fi
msousa@353:   func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
msousa@353: }
msousa@353: 
msousa@353: # Generated shell functions inserted here.
msousa@353: 
msousa@353: # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
msousa@353: # is ksh but when the shell is invoked as "sh" and the current value of
msousa@353: # the _XPG environment variable is not equal to 1 (one), the special
msousa@353: # positional parameter $0, within a function call, is the name of the
msousa@353: # function.
msousa@353: progpath="$0"
msousa@353: 
msousa@353: # The name of this program:
msousa@353: # In the unlikely event $progname began with a '-', it would play havoc with
msousa@353: # func_echo (imagine progname=-n), so we prepend ./ in that case:
msousa@353: func_dirname_and_basename "$progpath"
msousa@353: progname=$func_basename_result
msousa@353: case $progname in
msousa@353:   -*) progname=./$progname ;;
msousa@353: esac
msousa@353: 
msousa@353: # Make sure we have an absolute path for reexecution:
msousa@353: case $progpath in
msousa@353:   [\\/]*|[A-Za-z]:\\*) ;;
msousa@353:   *[\\/]*)
msousa@353:      progdir=$func_dirname_result
msousa@353:      progdir=`cd "$progdir" && pwd`
msousa@353:      progpath="$progdir/$progname"
msousa@353:      ;;
msousa@353:   *)
msousa@353:      save_IFS="$IFS"
msousa@353:      IFS=:
msousa@353:      for progdir in $PATH; do
msousa@353:        IFS="$save_IFS"
msousa@353:        test -x "$progdir/$progname" && break
msousa@353:      done
msousa@353:      IFS="$save_IFS"
msousa@353:      test -n "$progdir" || progdir=`pwd`
msousa@353:      progpath="$progdir/$progname"
msousa@353:      ;;
msousa@353: esac
msousa@353: 
msousa@353: # Sed substitution that helps us do robust quoting.  It backslashifies
msousa@353: # metacharacters that are still active within double-quoted strings.
msousa@353: Xsed="${SED}"' -e 1s/^X//'
msousa@353: sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
msousa@353: 
msousa@353: # Same as above, but do not quote variable references.
msousa@353: double_quote_subst='s/\(["`\\]\)/\\\1/g'
msousa@353: 
msousa@353: # Re-`\' parameter expansions in output of double_quote_subst that were
msousa@353: # `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
msousa@353: # in input to double_quote_subst, that '$' was protected from expansion.
msousa@353: # Since each input `\' is now two `\'s, look for any number of runs of
msousa@353: # four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
msousa@353: bs='\\'
msousa@353: bs2='\\\\'
msousa@353: bs4='\\\\\\\\'
msousa@353: dollar='\$'
msousa@353: sed_double_backslash="\
msousa@353:   s/$bs4/&\\
msousa@353: /g
msousa@353:   s/^$bs2$dollar/$bs&/
msousa@353:   s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
msousa@353:   s/\n//g"
msousa@353: 
msousa@353: # Standard options:
msousa@353: opt_dry_run=false
msousa@353: opt_help=false
msousa@353: opt_quiet=false
msousa@353: opt_verbose=false
msousa@353: opt_warning=:
msousa@353: 
msousa@353: # func_echo arg...
msousa@353: # Echo program name prefixed message, along with the current mode
msousa@353: # name if it has been set yet.
msousa@353: func_echo ()
msousa@353: {
msousa@353:     $ECHO "$progname${mode+: }$mode: $*"
msousa@353: }
msousa@353: 
msousa@353: # func_verbose arg...
msousa@353: # Echo program name prefixed message in verbose mode only.
msousa@353: func_verbose ()
msousa@353: {
msousa@353:     $opt_verbose && func_echo ${1+"$@"}
msousa@353: 
msousa@353:     # A bug in bash halts the script if the last line of a function
msousa@353:     # fails when set -e is in force, so we need another command to
msousa@353:     # work around that:
msousa@353:     :
msousa@353: }
msousa@353: 
msousa@353: # func_error arg...
msousa@353: # Echo program name prefixed message to standard error.
msousa@353: func_error ()
msousa@353: {
msousa@353:     $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
msousa@353: }
msousa@353: 
msousa@353: # func_warning arg...
msousa@353: # Echo program name prefixed warning message to standard error.
msousa@353: func_warning ()
msousa@353: {
msousa@353:     $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
msousa@353: 
msousa@353:     # bash bug again:
msousa@353:     :
msousa@353: }
msousa@353: 
msousa@353: # func_fatal_error arg...
msousa@353: # Echo program name prefixed message to standard error, and exit.
msousa@353: func_fatal_error ()
msousa@353: {
msousa@353:     func_error ${1+"$@"}
msousa@353:     exit $EXIT_FAILURE
msousa@353: }
msousa@353: 
msousa@353: # func_fatal_help arg...
msousa@353: # Echo program name prefixed message to standard error, followed by
msousa@353: # a help hint, and exit.
msousa@353: func_fatal_help ()
msousa@353: {
msousa@353:     func_error ${1+"$@"}
msousa@353:     func_fatal_error "$help"
msousa@353: }
msousa@353: help="Try \`$progname --help' for more information."  ## default
msousa@353: 
msousa@353: 
msousa@353: # func_grep expression filename
msousa@353: # Check whether EXPRESSION matches any line of FILENAME, without output.
msousa@353: func_grep ()
msousa@353: {
msousa@353:     $GREP "$1" "$2" >/dev/null 2>&1
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_mkdir_p directory-path
msousa@353: # Make sure the entire path to DIRECTORY-PATH is available.
msousa@353: func_mkdir_p ()
msousa@353: {
msousa@353:     my_directory_path="$1"
msousa@353:     my_dir_list=
msousa@353: 
msousa@353:     if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
msousa@353: 
msousa@353:       # Protect directory names starting with `-'
msousa@353:       case $my_directory_path in
msousa@353:         -*) my_directory_path="./$my_directory_path" ;;
msousa@353:       esac
msousa@353: 
msousa@353:       # While some portion of DIR does not yet exist...
msousa@353:       while test ! -d "$my_directory_path"; do
msousa@353:         # ...make a list in topmost first order.  Use a colon delimited
msousa@353: 	# list incase some portion of path contains whitespace.
msousa@353:         my_dir_list="$my_directory_path:$my_dir_list"
msousa@353: 
msousa@353:         # If the last portion added has no slash in it, the list is done
msousa@353:         case $my_directory_path in */*) ;; *) break ;; esac
msousa@353: 
msousa@353:         # ...otherwise throw away the child directory and loop
msousa@353:         my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
msousa@353:       done
msousa@353:       my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
msousa@353: 
msousa@353:       save_mkdir_p_IFS="$IFS"; IFS=':'
msousa@353:       for my_dir in $my_dir_list; do
msousa@353: 	IFS="$save_mkdir_p_IFS"
msousa@353:         # mkdir can fail with a `File exist' error if two processes
msousa@353:         # try to create one of the directories concurrently.  Don't
msousa@353:         # stop in that case!
msousa@353:         $MKDIR "$my_dir" 2>/dev/null || :
msousa@353:       done
msousa@353:       IFS="$save_mkdir_p_IFS"
msousa@353: 
msousa@353:       # Bail out if we (or some other process) failed to create a directory.
msousa@353:       test -d "$my_directory_path" || \
msousa@353:         func_fatal_error "Failed to create \`$1'"
msousa@353:     fi
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_mktempdir [string]
msousa@353: # Make a temporary directory that won't clash with other running
msousa@353: # libtool processes, and avoids race conditions if possible.  If
msousa@353: # given, STRING is the basename for that directory.
msousa@353: func_mktempdir ()
msousa@353: {
msousa@353:     my_template="${TMPDIR-/tmp}/${1-$progname}"
msousa@353: 
msousa@353:     if test "$opt_dry_run" = ":"; then
msousa@353:       # Return a directory name, but don't create it in dry-run mode
msousa@353:       my_tmpdir="${my_template}-$$"
msousa@353:     else
msousa@353: 
msousa@353:       # If mktemp works, use that first and foremost
msousa@353:       my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
msousa@353: 
msousa@353:       if test ! -d "$my_tmpdir"; then
msousa@353:         # Failing that, at least try and use $RANDOM to avoid a race
msousa@353:         my_tmpdir="${my_template}-${RANDOM-0}$$"
msousa@353: 
msousa@353:         save_mktempdir_umask=`umask`
msousa@353:         umask 0077
msousa@353:         $MKDIR "$my_tmpdir"
msousa@353:         umask $save_mktempdir_umask
msousa@353:       fi
msousa@353: 
msousa@353:       # If we're not in dry-run mode, bomb out on failure
msousa@353:       test -d "$my_tmpdir" || \
msousa@353:         func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
msousa@353:     fi
msousa@353: 
msousa@353:     $ECHO "X$my_tmpdir" | $Xsed
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_quote_for_eval arg
msousa@353: # Aesthetically quote ARG to be evaled later.
msousa@353: # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
msousa@353: # is double-quoted, suitable for a subsequent eval, whereas
msousa@353: # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
msousa@353: # which are still active within double quotes backslashified.
msousa@353: func_quote_for_eval ()
msousa@353: {
msousa@353:     case $1 in
msousa@353:       *[\\\`\"\$]*)
msousa@353: 	func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
msousa@353:       *)
msousa@353:         func_quote_for_eval_unquoted_result="$1" ;;
msousa@353:     esac
msousa@353: 
msousa@353:     case $func_quote_for_eval_unquoted_result in
msousa@353:       # Double-quote args containing shell metacharacters to delay
msousa@353:       # word splitting, command substitution and and variable
msousa@353:       # expansion for a subsequent eval.
msousa@353:       # Many Bourne shells cannot handle close brackets correctly
msousa@353:       # in scan sets, so we specify it separately.
msousa@353:       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
msousa@353:         func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
msousa@353:         ;;
msousa@353:       *)
msousa@353:         func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
msousa@353:     esac
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_quote_for_expand arg
msousa@353: # Aesthetically quote ARG to be evaled later; same as above,
msousa@353: # but do not quote variable references.
msousa@353: func_quote_for_expand ()
msousa@353: {
msousa@353:     case $1 in
msousa@353:       *[\\\`\"]*)
msousa@353: 	my_arg=`$ECHO "X$1" | $Xsed \
msousa@353: 	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
msousa@353:       *)
msousa@353:         my_arg="$1" ;;
msousa@353:     esac
msousa@353: 
msousa@353:     case $my_arg in
msousa@353:       # Double-quote args containing shell metacharacters to delay
msousa@353:       # word splitting and command substitution for a subsequent eval.
msousa@353:       # Many Bourne shells cannot handle close brackets correctly
msousa@353:       # in scan sets, so we specify it separately.
msousa@353:       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
msousa@353:         my_arg="\"$my_arg\""
msousa@353:         ;;
msousa@353:     esac
msousa@353: 
msousa@353:     func_quote_for_expand_result="$my_arg"
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_show_eval cmd [fail_exp]
msousa@353: # Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
msousa@353: # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
msousa@353: # is given, then evaluate it.
msousa@353: func_show_eval ()
msousa@353: {
msousa@353:     my_cmd="$1"
msousa@353:     my_fail_exp="${2-:}"
msousa@353: 
msousa@353:     ${opt_silent-false} || {
msousa@353:       func_quote_for_expand "$my_cmd"
msousa@353:       eval "func_echo $func_quote_for_expand_result"
msousa@353:     }
msousa@353: 
msousa@353:     if ${opt_dry_run-false}; then :; else
msousa@353:       eval "$my_cmd"
msousa@353:       my_status=$?
msousa@353:       if test "$my_status" -eq 0; then :; else
msousa@353: 	eval "(exit $my_status); $my_fail_exp"
msousa@353:       fi
msousa@353:     fi
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_show_eval_locale cmd [fail_exp]
msousa@353: # Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
msousa@353: # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
msousa@353: # is given, then evaluate it.  Use the saved locale for evaluation.
msousa@353: func_show_eval_locale ()
msousa@353: {
msousa@353:     my_cmd="$1"
msousa@353:     my_fail_exp="${2-:}"
msousa@353: 
msousa@353:     ${opt_silent-false} || {
msousa@353:       func_quote_for_expand "$my_cmd"
msousa@353:       eval "func_echo $func_quote_for_expand_result"
msousa@353:     }
msousa@353: 
msousa@353:     if ${opt_dry_run-false}; then :; else
msousa@353:       eval "$lt_user_locale
msousa@353: 	    $my_cmd"
msousa@353:       my_status=$?
msousa@353:       eval "$lt_safe_locale"
msousa@353:       if test "$my_status" -eq 0; then :; else
msousa@353: 	eval "(exit $my_status); $my_fail_exp"
msousa@353:       fi
msousa@353:     fi
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: # func_version
msousa@353: # Echo version message to standard output and exit.
msousa@353: func_version ()
msousa@353: {
msousa@353:     $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
msousa@353:         s/^# //
msousa@353: 	s/^# *$//
msousa@353:         s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
msousa@353:         p
msousa@353:      }' < "$progpath"
msousa@353:      exit $?
msousa@353: }
msousa@353: 
msousa@353: # func_usage
msousa@353: # Echo short help message to standard output and exit.
msousa@353: func_usage ()
msousa@353: {
msousa@353:     $SED -n '/^# Usage:/,/# -h/ {
msousa@353:         s/^# //
msousa@353: 	s/^# *$//
msousa@353: 	s/\$progname/'$progname'/
msousa@353: 	p
msousa@353:     }' < "$progpath"
msousa@353:     $ECHO
msousa@353:     $ECHO "run \`$progname --help | more' for full usage"
msousa@353:     exit $?
msousa@353: }
msousa@353: 
msousa@353: # func_help
msousa@353: # Echo long help message to standard output and exit.
msousa@353: func_help ()
msousa@353: {
msousa@353:     $SED -n '/^# Usage:/,/# Report bugs to/ {
msousa@353:         s/^# //
msousa@353: 	s/^# *$//
msousa@353: 	s*\$progname*'$progname'*
msousa@353: 	s*\$host*'"$host"'*
msousa@353: 	s*\$SHELL*'"$SHELL"'*
msousa@353: 	s*\$LTCC*'"$LTCC"'*
msousa@353: 	s*\$LTCFLAGS*'"$LTCFLAGS"'*
msousa@353: 	s*\$LD*'"$LD"'*
msousa@353: 	s/\$with_gnu_ld/'"$with_gnu_ld"'/
msousa@353: 	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
msousa@353: 	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
msousa@353: 	p
msousa@353:      }' < "$progpath"
msousa@353:     exit $?
msousa@353: }
msousa@353: 
msousa@353: # func_missing_arg argname
msousa@353: # Echo program name prefixed message to standard error and set global
msousa@353: # exit_cmd.
msousa@353: func_missing_arg ()
msousa@353: {
msousa@353:     func_error "missing argument for $1"
msousa@353:     exit_cmd=exit
msousa@353: }
msousa@353: 
msousa@353: exit_cmd=:
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: # Check that we have a working $ECHO.
msousa@353: if test "X$1" = X--no-reexec; then
msousa@353:   # Discard the --no-reexec flag, and continue.
msousa@353:   shift
msousa@353: elif test "X$1" = X--fallback-echo; then
msousa@353:   # Avoid inline document here, it may be left over
msousa@353:   :
msousa@353: elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
msousa@353:   # Yippee, $ECHO works!
msousa@353:   :
msousa@353: else
msousa@353:   # Restart under the correct shell, and then maybe $ECHO will work.
msousa@353:   exec $SHELL "$progpath" --no-reexec ${1+"$@"}
msousa@353: fi
msousa@353: 
msousa@353: if test "X$1" = X--fallback-echo; then
msousa@353:   # used as fallback echo
msousa@353:   shift
msousa@353:   cat <<EOF
msousa@353: $*
msousa@353: EOF
msousa@353:   exit $EXIT_SUCCESS
msousa@353: fi
msousa@353: 
msousa@353: magic="%%%MAGIC variable%%%"
msousa@353: magic_exe="%%%MAGIC EXE variable%%%"
msousa@353: 
msousa@353: # Global variables.
msousa@353: # $mode is unset
msousa@353: nonopt=
msousa@353: execute_dlfiles=
msousa@353: preserve_args=
msousa@353: lo2o="s/\\.lo\$/.${objext}/"
msousa@353: o2lo="s/\\.${objext}\$/.lo/"
msousa@353: extracted_archives=
msousa@353: extracted_serial=0
msousa@353: 
msousa@353: opt_dry_run=false
msousa@353: opt_duplicate_deps=false
msousa@353: opt_silent=false
msousa@353: opt_debug=:
msousa@353: 
msousa@353: # If this variable is set in any of the actions, the command in it
msousa@353: # will be execed at the end.  This prevents here-documents from being
msousa@353: # left over by shells.
msousa@353: exec_cmd=
msousa@353: 
msousa@353: # func_fatal_configuration arg...
msousa@353: # Echo program name prefixed message to standard error, followed by
msousa@353: # a configuration failure hint, and exit.
msousa@353: func_fatal_configuration ()
msousa@353: {
msousa@353:     func_error ${1+"$@"}
msousa@353:     func_error "See the $PACKAGE documentation for more information."
msousa@353:     func_fatal_error "Fatal configuration error."
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_config
msousa@353: # Display the configuration for all the tags in this script.
msousa@353: func_config ()
msousa@353: {
msousa@353:     re_begincf='^# ### BEGIN LIBTOOL'
msousa@353:     re_endcf='^# ### END LIBTOOL'
msousa@353: 
msousa@353:     # Default configuration.
msousa@353:     $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
msousa@353: 
msousa@353:     # Now print the configurations for the tags.
msousa@353:     for tagname in $taglist; do
msousa@353:       $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
msousa@353:     done
msousa@353: 
msousa@353:     exit $?
msousa@353: }
msousa@353: 
msousa@353: # func_features
msousa@353: # Display the features supported by this script.
msousa@353: func_features ()
msousa@353: {
msousa@353:     $ECHO "host: $host"
msousa@353:     if test "$build_libtool_libs" = yes; then
msousa@353:       $ECHO "enable shared libraries"
msousa@353:     else
msousa@353:       $ECHO "disable shared libraries"
msousa@353:     fi
msousa@353:     if test "$build_old_libs" = yes; then
msousa@353:       $ECHO "enable static libraries"
msousa@353:     else
msousa@353:       $ECHO "disable static libraries"
msousa@353:     fi
msousa@353: 
msousa@353:     exit $?
msousa@353: }
msousa@353: 
msousa@353: # func_enable_tag tagname
msousa@353: # Verify that TAGNAME is valid, and either flag an error and exit, or
msousa@353: # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
msousa@353: # variable here.
msousa@353: func_enable_tag ()
msousa@353: {
msousa@353:   # Global variable:
msousa@353:   tagname="$1"
msousa@353: 
msousa@353:   re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
msousa@353:   re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
msousa@353:   sed_extractcf="/$re_begincf/,/$re_endcf/p"
msousa@353: 
msousa@353:   # Validate tagname.
msousa@353:   case $tagname in
msousa@353:     *[!-_A-Za-z0-9,/]*)
msousa@353:       func_fatal_error "invalid tag name: $tagname"
msousa@353:       ;;
msousa@353:   esac
msousa@353: 
msousa@353:   # Don't test for the "default" C tag, as we know it's
msousa@353:   # there but not specially marked.
msousa@353:   case $tagname in
msousa@353:     CC) ;;
msousa@353:     *)
msousa@353:       if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
msousa@353: 	taglist="$taglist $tagname"
msousa@353: 
msousa@353: 	# Evaluate the configuration.  Be careful to quote the path
msousa@353: 	# and the sed script, to avoid splitting on whitespace, but
msousa@353: 	# also don't use non-portable quotes within backquotes within
msousa@353: 	# quotes we have to do it in 2 steps:
msousa@353: 	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
msousa@353: 	eval "$extractedcf"
msousa@353:       else
msousa@353: 	func_error "ignoring unknown tag $tagname"
msousa@353:       fi
msousa@353:       ;;
msousa@353:   esac
msousa@353: }
msousa@353: 
msousa@353: # Parse options once, thoroughly.  This comes as soon as possible in
msousa@353: # the script to make things like `libtool --version' happen quickly.
msousa@353: {
msousa@353: 
msousa@353:   # Shorthand for --mode=foo, only valid as the first argument
msousa@353:   case $1 in
msousa@353:   clean|clea|cle|cl)
msousa@353:     shift; set dummy --mode clean ${1+"$@"}; shift
msousa@353:     ;;
msousa@353:   compile|compil|compi|comp|com|co|c)
msousa@353:     shift; set dummy --mode compile ${1+"$@"}; shift
msousa@353:     ;;
msousa@353:   execute|execut|execu|exec|exe|ex|e)
msousa@353:     shift; set dummy --mode execute ${1+"$@"}; shift
msousa@353:     ;;
msousa@353:   finish|finis|fini|fin|fi|f)
msousa@353:     shift; set dummy --mode finish ${1+"$@"}; shift
msousa@353:     ;;
msousa@353:   install|instal|insta|inst|ins|in|i)
msousa@353:     shift; set dummy --mode install ${1+"$@"}; shift
msousa@353:     ;;
msousa@353:   link|lin|li|l)
msousa@353:     shift; set dummy --mode link ${1+"$@"}; shift
msousa@353:     ;;
msousa@353:   uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
msousa@353:     shift; set dummy --mode uninstall ${1+"$@"}; shift
msousa@353:     ;;
msousa@353:   esac
msousa@353: 
msousa@353:   # Parse non-mode specific arguments:
msousa@353:   while test "$#" -gt 0; do
msousa@353:     opt="$1"
msousa@353:     shift
msousa@353: 
msousa@353:     case $opt in
msousa@353:       --config)		func_config					;;
msousa@353: 
msousa@353:       --debug)		preserve_args="$preserve_args $opt"
msousa@353: 			func_echo "enabling shell trace mode"
msousa@353: 			opt_debug='set -x'
msousa@353: 			$opt_debug
msousa@353: 			;;
msousa@353: 
msousa@353:       -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
msousa@353: 			execute_dlfiles="$execute_dlfiles $1"
msousa@353: 			shift
msousa@353: 			;;
msousa@353: 
msousa@353:       --dry-run | -n)	opt_dry_run=:					;;
msousa@353:       --features)       func_features					;;
msousa@353:       --finish)		mode="finish"					;;
msousa@353: 
msousa@353:       --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
msousa@353: 			case $1 in
msousa@353: 			  # Valid mode arguments:
msousa@353: 			  clean)	;;
msousa@353: 			  compile)	;;
msousa@353: 			  execute)	;;
msousa@353: 			  finish)	;;
msousa@353: 			  install)	;;
msousa@353: 			  link)		;;
msousa@353: 			  relink)	;;
msousa@353: 			  uninstall)	;;
msousa@353: 
msousa@353: 			  # Catch anything else as an error
msousa@353: 			  *) func_error "invalid argument for $opt"
msousa@353: 			     exit_cmd=exit
msousa@353: 			     break
msousa@353: 			     ;;
msousa@353: 		        esac
msousa@353: 
msousa@353: 			mode="$1"
msousa@353: 			shift
msousa@353: 			;;
msousa@353: 
msousa@353:       --preserve-dup-deps)
msousa@353: 			opt_duplicate_deps=:				;;
msousa@353: 
msousa@353:       --quiet|--silent)	preserve_args="$preserve_args $opt"
msousa@353: 			opt_silent=:
msousa@353: 			;;
msousa@353: 
msousa@353:       --verbose| -v)	preserve_args="$preserve_args $opt"
msousa@353: 			opt_silent=false
msousa@353: 			;;
msousa@353: 
msousa@353:       --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
msousa@353: 			preserve_args="$preserve_args $opt $1"
msousa@353: 			func_enable_tag "$1"	# tagname is set here
msousa@353: 			shift
msousa@353: 			;;
msousa@353: 
msousa@353:       # Separate optargs to long options:
msousa@353:       -dlopen=*|--mode=*|--tag=*)
msousa@353: 			func_opt_split "$opt"
msousa@353: 			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
msousa@353: 			shift
msousa@353: 			;;
msousa@353: 
msousa@353:       -\?|-h)		func_usage					;;
msousa@353:       --help)		opt_help=:					;;
msousa@353:       --version)	func_version					;;
msousa@353: 
msousa@353:       -*)		func_fatal_help "unrecognized option \`$opt'"	;;
msousa@353: 
msousa@353:       *)		nonopt="$opt"
msousa@353: 			break
msousa@353: 			;;
msousa@353:     esac
msousa@353:   done
msousa@353: 
msousa@353: 
msousa@353:   case $host in
msousa@353:     *cygwin* | *mingw* | *pw32* | *cegcc*)
msousa@353:       # don't eliminate duplications in $postdeps and $predeps
msousa@353:       opt_duplicate_compiler_generated_deps=:
msousa@353:       ;;
msousa@353:     *)
msousa@353:       opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
msousa@353:       ;;
msousa@353:   esac
msousa@353: 
msousa@353:   # Having warned about all mis-specified options, bail out if
msousa@353:   # anything was wrong.
msousa@353:   $exit_cmd $EXIT_FAILURE
msousa@353: }
msousa@353: 
msousa@353: # func_check_version_match
msousa@353: # Ensure that we are using m4 macros, and libtool script from the same
msousa@353: # release of libtool.
msousa@353: func_check_version_match ()
msousa@353: {
msousa@353:   if test "$package_revision" != "$macro_revision"; then
msousa@353:     if test "$VERSION" != "$macro_version"; then
msousa@353:       if test -z "$macro_version"; then
msousa@353:         cat >&2 <<_LT_EOF
msousa@353: $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
msousa@353: $progname: definition of this LT_INIT comes from an older release.
msousa@353: $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
msousa@353: $progname: and run autoconf again.
msousa@353: _LT_EOF
msousa@353:       else
msousa@353:         cat >&2 <<_LT_EOF
msousa@353: $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
msousa@353: $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
msousa@353: $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
msousa@353: $progname: and run autoconf again.
msousa@353: _LT_EOF
msousa@353:       fi
msousa@353:     else
msousa@353:       cat >&2 <<_LT_EOF
msousa@353: $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
msousa@353: $progname: but the definition of this LT_INIT comes from revision $macro_revision.
msousa@353: $progname: You should recreate aclocal.m4 with macros from revision $package_revision
msousa@353: $progname: of $PACKAGE $VERSION and run autoconf again.
msousa@353: _LT_EOF
msousa@353:     fi
msousa@353: 
msousa@353:     exit $EXIT_MISMATCH
msousa@353:   fi
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: ## ----------- ##
msousa@353: ##    Main.    ##
msousa@353: ## ----------- ##
msousa@353: 
msousa@353: $opt_help || {
msousa@353:   # Sanity checks first:
msousa@353:   func_check_version_match
msousa@353: 
msousa@353:   if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
msousa@353:     func_fatal_configuration "not configured to build any kind of library"
msousa@353:   fi
msousa@353: 
msousa@353:   test -z "$mode" && func_fatal_error "error: you must specify a MODE."
msousa@353: 
msousa@353: 
msousa@353:   # Darwin sucks
msousa@353:   eval std_shrext=\"$shrext_cmds\"
msousa@353: 
msousa@353: 
msousa@353:   # Only execute mode is allowed to have -dlopen flags.
msousa@353:   if test -n "$execute_dlfiles" && test "$mode" != execute; then
msousa@353:     func_error "unrecognized option \`-dlopen'"
msousa@353:     $ECHO "$help" 1>&2
msousa@353:     exit $EXIT_FAILURE
msousa@353:   fi
msousa@353: 
msousa@353:   # Change the help message to a mode-specific one.
msousa@353:   generic_help="$help"
msousa@353:   help="Try \`$progname --help --mode=$mode' for more information."
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_lalib_p file
msousa@353: # True iff FILE is a libtool `.la' library or `.lo' object file.
msousa@353: # This function is only a basic sanity check; it will hardly flush out
msousa@353: # determined imposters.
msousa@353: func_lalib_p ()
msousa@353: {
msousa@353:     test -f "$1" &&
msousa@353:       $SED -e 4q "$1" 2>/dev/null \
msousa@353:         | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
msousa@353: }
msousa@353: 
msousa@353: # func_lalib_unsafe_p file
msousa@353: # True iff FILE is a libtool `.la' library or `.lo' object file.
msousa@353: # This function implements the same check as func_lalib_p without
msousa@353: # resorting to external programs.  To this end, it redirects stdin and
msousa@353: # closes it afterwards, without saving the original file descriptor.
msousa@353: # As a safety measure, use it only where a negative result would be
msousa@353: # fatal anyway.  Works if `file' does not exist.
msousa@353: func_lalib_unsafe_p ()
msousa@353: {
msousa@353:     lalib_p=no
msousa@353:     if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
msousa@353: 	for lalib_p_l in 1 2 3 4
msousa@353: 	do
msousa@353: 	    read lalib_p_line
msousa@353: 	    case "$lalib_p_line" in
msousa@353: 		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
msousa@353: 	    esac
msousa@353: 	done
msousa@353: 	exec 0<&5 5<&-
msousa@353:     fi
msousa@353:     test "$lalib_p" = yes
msousa@353: }
msousa@353: 
msousa@353: # func_ltwrapper_script_p file
msousa@353: # True iff FILE is a libtool wrapper script
msousa@353: # This function is only a basic sanity check; it will hardly flush out
msousa@353: # determined imposters.
msousa@353: func_ltwrapper_script_p ()
msousa@353: {
msousa@353:     func_lalib_p "$1"
msousa@353: }
msousa@353: 
msousa@353: # func_ltwrapper_executable_p file
msousa@353: # True iff FILE is a libtool wrapper executable
msousa@353: # This function is only a basic sanity check; it will hardly flush out
msousa@353: # determined imposters.
msousa@353: func_ltwrapper_executable_p ()
msousa@353: {
msousa@353:     func_ltwrapper_exec_suffix=
msousa@353:     case $1 in
msousa@353:     *.exe) ;;
msousa@353:     *) func_ltwrapper_exec_suffix=.exe ;;
msousa@353:     esac
msousa@353:     $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
msousa@353: }
msousa@353: 
msousa@353: # func_ltwrapper_scriptname file
msousa@353: # Assumes file is an ltwrapper_executable
msousa@353: # uses $file to determine the appropriate filename for a
msousa@353: # temporary ltwrapper_script.
msousa@353: func_ltwrapper_scriptname ()
msousa@353: {
msousa@353:     func_ltwrapper_scriptname_result=""
msousa@353:     if func_ltwrapper_executable_p "$1"; then
msousa@353: 	func_dirname_and_basename "$1" "" "."
msousa@353: 	func_stripname '' '.exe' "$func_basename_result"
msousa@353: 	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
msousa@353:     fi
msousa@353: }
msousa@353: 
msousa@353: # func_ltwrapper_p file
msousa@353: # True iff FILE is a libtool wrapper script or wrapper executable
msousa@353: # This function is only a basic sanity check; it will hardly flush out
msousa@353: # determined imposters.
msousa@353: func_ltwrapper_p ()
msousa@353: {
msousa@353:     func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_execute_cmds commands fail_cmd
msousa@353: # Execute tilde-delimited COMMANDS.
msousa@353: # If FAIL_CMD is given, eval that upon failure.
msousa@353: # FAIL_CMD may read-access the current command in variable CMD!
msousa@353: func_execute_cmds ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     save_ifs=$IFS; IFS='~'
msousa@353:     for cmd in $1; do
msousa@353:       IFS=$save_ifs
msousa@353:       eval cmd=\"$cmd\"
msousa@353:       func_show_eval "$cmd" "${2-:}"
msousa@353:     done
msousa@353:     IFS=$save_ifs
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_source file
msousa@353: # Source FILE, adding directory component if necessary.
msousa@353: # Note that it is not necessary on cygwin/mingw to append a dot to
msousa@353: # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
msousa@353: # behavior happens only for exec(3), not for open(2)!  Also, sourcing
msousa@353: # `FILE.' does not work on cygwin managed mounts.
msousa@353: func_source ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     case $1 in
msousa@353:     */* | *\\*)	. "$1" ;;
msousa@353:     *)		. "./$1" ;;
msousa@353:     esac
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_infer_tag arg
msousa@353: # Infer tagged configuration to use if any are available and
msousa@353: # if one wasn't chosen via the "--tag" command line option.
msousa@353: # Only attempt this if the compiler in the base compile
msousa@353: # command doesn't match the default compiler.
msousa@353: # arg is usually of the form 'gcc ...'
msousa@353: func_infer_tag ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     if test -n "$available_tags" && test -z "$tagname"; then
msousa@353:       CC_quoted=
msousa@353:       for arg in $CC; do
msousa@353:         func_quote_for_eval "$arg"
msousa@353: 	CC_quoted="$CC_quoted $func_quote_for_eval_result"
msousa@353:       done
msousa@353:       case $@ in
msousa@353:       # Blanks in the command may have been stripped by the calling shell,
msousa@353:       # but not from the CC environment variable when configure was run.
msousa@353:       " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
msousa@353:       # Blanks at the start of $base_compile will cause this to fail
msousa@353:       # if we don't check for them as well.
msousa@353:       *)
msousa@353: 	for z in $available_tags; do
msousa@353: 	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
msousa@353: 	    # Evaluate the configuration.
msousa@353: 	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
msousa@353: 	    CC_quoted=
msousa@353: 	    for arg in $CC; do
msousa@353: 	      # Double-quote args containing other shell metacharacters.
msousa@353: 	      func_quote_for_eval "$arg"
msousa@353: 	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
msousa@353: 	    done
msousa@353: 	    case "$@ " in
msousa@353: 	      " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
msousa@353: 	      # The compiler in the base compile command matches
msousa@353: 	      # the one in the tagged configuration.
msousa@353: 	      # Assume this is the tagged configuration we want.
msousa@353: 	      tagname=$z
msousa@353: 	      break
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	  fi
msousa@353: 	done
msousa@353: 	# If $tagname still isn't set, then no tagged configuration
msousa@353: 	# was found and let the user know that the "--tag" command
msousa@353: 	# line option must be used.
msousa@353: 	if test -z "$tagname"; then
msousa@353: 	  func_echo "unable to infer tagged configuration"
msousa@353: 	  func_fatal_error "specify a tag with \`--tag'"
msousa@353: #	else
msousa@353: #	  func_verbose "using $tagname tagged configuration"
msousa@353: 	fi
msousa@353: 	;;
msousa@353:       esac
msousa@353:     fi
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: # func_write_libtool_object output_name pic_name nonpic_name
msousa@353: # Create a libtool object file (analogous to a ".la" file),
msousa@353: # but don't create it if we're doing a dry run.
msousa@353: func_write_libtool_object ()
msousa@353: {
msousa@353:     write_libobj=${1}
msousa@353:     if test "$build_libtool_libs" = yes; then
msousa@353:       write_lobj=\'${2}\'
msousa@353:     else
msousa@353:       write_lobj=none
msousa@353:     fi
msousa@353: 
msousa@353:     if test "$build_old_libs" = yes; then
msousa@353:       write_oldobj=\'${3}\'
msousa@353:     else
msousa@353:       write_oldobj=none
msousa@353:     fi
msousa@353: 
msousa@353:     $opt_dry_run || {
msousa@353:       cat >${write_libobj}T <<EOF
msousa@353: # $write_libobj - a libtool object file
msousa@353: # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
msousa@353: #
msousa@353: # Please DO NOT delete this file!
msousa@353: # It is necessary for linking the library.
msousa@353: 
msousa@353: # Name of the PIC object.
msousa@353: pic_object=$write_lobj
msousa@353: 
msousa@353: # Name of the non-PIC object
msousa@353: non_pic_object=$write_oldobj
msousa@353: 
msousa@353: EOF
msousa@353:       $MV "${write_libobj}T" "${write_libobj}"
msousa@353:     }
msousa@353: }
msousa@353: 
msousa@353: # func_mode_compile arg...
msousa@353: func_mode_compile ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     # Get the compilation command and the source file.
msousa@353:     base_compile=
msousa@353:     srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
msousa@353:     suppress_opt=yes
msousa@353:     suppress_output=
msousa@353:     arg_mode=normal
msousa@353:     libobj=
msousa@353:     later=
msousa@353:     pie_flag=
msousa@353: 
msousa@353:     for arg
msousa@353:     do
msousa@353:       case $arg_mode in
msousa@353:       arg  )
msousa@353: 	# do not "continue".  Instead, add this to base_compile
msousa@353: 	lastarg="$arg"
msousa@353: 	arg_mode=normal
msousa@353: 	;;
msousa@353: 
msousa@353:       target )
msousa@353: 	libobj="$arg"
msousa@353: 	arg_mode=normal
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       normal )
msousa@353: 	# Accept any command-line options.
msousa@353: 	case $arg in
msousa@353: 	-o)
msousa@353: 	  test -n "$libobj" && \
msousa@353: 	    func_fatal_error "you cannot specify \`-o' more than once"
msousa@353: 	  arg_mode=target
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	-pie | -fpie | -fPIE)
msousa@353:           pie_flag="$pie_flag $arg"
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	-shared | -static | -prefer-pic | -prefer-non-pic)
msousa@353: 	  later="$later $arg"
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	-no-suppress)
msousa@353: 	  suppress_opt=no
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	-Xcompiler)
msousa@353: 	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
msousa@353: 	  continue      #  The current "srcfile" will either be retained or
msousa@353: 	  ;;            #  replaced later.  I would guess that would be a bug.
msousa@353: 
msousa@353: 	-Wc,*)
msousa@353: 	  func_stripname '-Wc,' '' "$arg"
msousa@353: 	  args=$func_stripname_result
msousa@353: 	  lastarg=
msousa@353: 	  save_ifs="$IFS"; IFS=','
msousa@353: 	  for arg in $args; do
msousa@353: 	    IFS="$save_ifs"
msousa@353: 	    func_quote_for_eval "$arg"
msousa@353: 	    lastarg="$lastarg $func_quote_for_eval_result"
msousa@353: 	  done
msousa@353: 	  IFS="$save_ifs"
msousa@353: 	  func_stripname ' ' '' "$lastarg"
msousa@353: 	  lastarg=$func_stripname_result
msousa@353: 
msousa@353: 	  # Add the arguments to base_compile.
msousa@353: 	  base_compile="$base_compile $lastarg"
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	*)
msousa@353: 	  # Accept the current argument as the source file.
msousa@353: 	  # The previous "srcfile" becomes the current argument.
msousa@353: 	  #
msousa@353: 	  lastarg="$srcfile"
msousa@353: 	  srcfile="$arg"
msousa@353: 	  ;;
msousa@353: 	esac  #  case $arg
msousa@353: 	;;
msousa@353:       esac    #  case $arg_mode
msousa@353: 
msousa@353:       # Aesthetically quote the previous argument.
msousa@353:       func_quote_for_eval "$lastarg"
msousa@353:       base_compile="$base_compile $func_quote_for_eval_result"
msousa@353:     done # for arg
msousa@353: 
msousa@353:     case $arg_mode in
msousa@353:     arg)
msousa@353:       func_fatal_error "you must specify an argument for -Xcompile"
msousa@353:       ;;
msousa@353:     target)
msousa@353:       func_fatal_error "you must specify a target with \`-o'"
msousa@353:       ;;
msousa@353:     *)
msousa@353:       # Get the name of the library object.
msousa@353:       test -z "$libobj" && {
msousa@353: 	func_basename "$srcfile"
msousa@353: 	libobj="$func_basename_result"
msousa@353:       }
msousa@353:       ;;
msousa@353:     esac
msousa@353: 
msousa@353:     # Recognize several different file suffixes.
msousa@353:     # If the user specifies -o file.o, it is replaced with file.lo
msousa@353:     case $libobj in
msousa@353:     *.[cCFSifmso] | \
msousa@353:     *.ada | *.adb | *.ads | *.asm | \
msousa@353:     *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
msousa@353:     *.[fF][09]? | *.for | *.java | *.obj | *.sx)
msousa@353:       func_xform "$libobj"
msousa@353:       libobj=$func_xform_result
msousa@353:       ;;
msousa@353:     esac
msousa@353: 
msousa@353:     case $libobj in
msousa@353:     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
msousa@353:     *)
msousa@353:       func_fatal_error "cannot determine name of library object from \`$libobj'"
msousa@353:       ;;
msousa@353:     esac
msousa@353: 
msousa@353:     func_infer_tag $base_compile
msousa@353: 
msousa@353:     for arg in $later; do
msousa@353:       case $arg in
msousa@353:       -shared)
msousa@353: 	test "$build_libtool_libs" != yes && \
msousa@353: 	  func_fatal_configuration "can not build a shared library"
msousa@353: 	build_old_libs=no
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -static)
msousa@353: 	build_libtool_libs=no
msousa@353: 	build_old_libs=yes
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -prefer-pic)
msousa@353: 	pic_mode=yes
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -prefer-non-pic)
msousa@353: 	pic_mode=no
msousa@353: 	continue
msousa@353: 	;;
msousa@353:       esac
msousa@353:     done
msousa@353: 
msousa@353:     func_quote_for_eval "$libobj"
msousa@353:     test "X$libobj" != "X$func_quote_for_eval_result" \
msousa@353:       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
msousa@353:       && func_warning "libobj name \`$libobj' may not contain shell special characters."
msousa@353:     func_dirname_and_basename "$obj" "/" ""
msousa@353:     objname="$func_basename_result"
msousa@353:     xdir="$func_dirname_result"
msousa@353:     lobj=${xdir}$objdir/$objname
msousa@353: 
msousa@353:     test -z "$base_compile" && \
msousa@353:       func_fatal_help "you must specify a compilation command"
msousa@353: 
msousa@353:     # Delete any leftover library objects.
msousa@353:     if test "$build_old_libs" = yes; then
msousa@353:       removelist="$obj $lobj $libobj ${libobj}T"
msousa@353:     else
msousa@353:       removelist="$lobj $libobj ${libobj}T"
msousa@353:     fi
msousa@353: 
msousa@353:     # On Cygwin there's no "real" PIC flag so we must build both object types
msousa@353:     case $host_os in
msousa@353:     cygwin* | mingw* | pw32* | os2* | cegcc*)
msousa@353:       pic_mode=default
msousa@353:       ;;
msousa@353:     esac
msousa@353:     if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
msousa@353:       # non-PIC code in shared libraries is not supported
msousa@353:       pic_mode=default
msousa@353:     fi
msousa@353: 
msousa@353:     # Calculate the filename of the output object if compiler does
msousa@353:     # not support -o with -c
msousa@353:     if test "$compiler_c_o" = no; then
msousa@353:       output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
msousa@353:       lockfile="$output_obj.lock"
msousa@353:     else
msousa@353:       output_obj=
msousa@353:       need_locks=no
msousa@353:       lockfile=
msousa@353:     fi
msousa@353: 
msousa@353:     # Lock this critical section if it is needed
msousa@353:     # We use this script file to make the link, it avoids creating a new file
msousa@353:     if test "$need_locks" = yes; then
msousa@353:       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
msousa@353: 	func_echo "Waiting for $lockfile to be removed"
msousa@353: 	sleep 2
msousa@353:       done
msousa@353:     elif test "$need_locks" = warn; then
msousa@353:       if test -f "$lockfile"; then
msousa@353: 	$ECHO "\
msousa@353: *** ERROR, $lockfile exists and contains:
msousa@353: `cat $lockfile 2>/dev/null`
msousa@353: 
msousa@353: This indicates that another process is trying to use the same
msousa@353: temporary object file, and libtool could not work around it because
msousa@353: your compiler does not support \`-c' and \`-o' together.  If you
msousa@353: repeat this compilation, it may succeed, by chance, but you had better
msousa@353: avoid parallel builds (make -j) in this platform, or get a better
msousa@353: compiler."
msousa@353: 
msousa@353: 	$opt_dry_run || $RM $removelist
msousa@353: 	exit $EXIT_FAILURE
msousa@353:       fi
msousa@353:       removelist="$removelist $output_obj"
msousa@353:       $ECHO "$srcfile" > "$lockfile"
msousa@353:     fi
msousa@353: 
msousa@353:     $opt_dry_run || $RM $removelist
msousa@353:     removelist="$removelist $lockfile"
msousa@353:     trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
msousa@353: 
msousa@353:     if test -n "$fix_srcfile_path"; then
msousa@353:       eval srcfile=\"$fix_srcfile_path\"
msousa@353:     fi
msousa@353:     func_quote_for_eval "$srcfile"
msousa@353:     qsrcfile=$func_quote_for_eval_result
msousa@353: 
msousa@353:     # Only build a PIC object if we are building libtool libraries.
msousa@353:     if test "$build_libtool_libs" = yes; then
msousa@353:       # Without this assignment, base_compile gets emptied.
msousa@353:       fbsd_hideous_sh_bug=$base_compile
msousa@353: 
msousa@353:       if test "$pic_mode" != no; then
msousa@353: 	command="$base_compile $qsrcfile $pic_flag"
msousa@353:       else
msousa@353: 	# Don't build PIC code
msousa@353: 	command="$base_compile $qsrcfile"
msousa@353:       fi
msousa@353: 
msousa@353:       func_mkdir_p "$xdir$objdir"
msousa@353: 
msousa@353:       if test -z "$output_obj"; then
msousa@353: 	# Place PIC objects in $objdir
msousa@353: 	command="$command -o $lobj"
msousa@353:       fi
msousa@353: 
msousa@353:       func_show_eval_locale "$command"	\
msousa@353:           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
msousa@353: 
msousa@353:       if test "$need_locks" = warn &&
msousa@353: 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
msousa@353: 	$ECHO "\
msousa@353: *** ERROR, $lockfile contains:
msousa@353: `cat $lockfile 2>/dev/null`
msousa@353: 
msousa@353: but it should contain:
msousa@353: $srcfile
msousa@353: 
msousa@353: This indicates that another process is trying to use the same
msousa@353: temporary object file, and libtool could not work around it because
msousa@353: your compiler does not support \`-c' and \`-o' together.  If you
msousa@353: repeat this compilation, it may succeed, by chance, but you had better
msousa@353: avoid parallel builds (make -j) in this platform, or get a better
msousa@353: compiler."
msousa@353: 
msousa@353: 	$opt_dry_run || $RM $removelist
msousa@353: 	exit $EXIT_FAILURE
msousa@353:       fi
msousa@353: 
msousa@353:       # Just move the object if needed, then go on to compile the next one
msousa@353:       if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
msousa@353: 	func_show_eval '$MV "$output_obj" "$lobj"' \
msousa@353: 	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
msousa@353:       fi
msousa@353: 
msousa@353:       # Allow error messages only from the first compilation.
msousa@353:       if test "$suppress_opt" = yes; then
msousa@353: 	suppress_output=' >/dev/null 2>&1'
msousa@353:       fi
msousa@353:     fi
msousa@353: 
msousa@353:     # Only build a position-dependent object if we build old libraries.
msousa@353:     if test "$build_old_libs" = yes; then
msousa@353:       if test "$pic_mode" != yes; then
msousa@353: 	# Don't build PIC code
msousa@353: 	command="$base_compile $qsrcfile$pie_flag"
msousa@353:       else
msousa@353: 	command="$base_compile $qsrcfile $pic_flag"
msousa@353:       fi
msousa@353:       if test "$compiler_c_o" = yes; then
msousa@353: 	command="$command -o $obj"
msousa@353:       fi
msousa@353: 
msousa@353:       # Suppress compiler output if we already did a PIC compilation.
msousa@353:       command="$command$suppress_output"
msousa@353:       func_show_eval_locale "$command" \
msousa@353:         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
msousa@353: 
msousa@353:       if test "$need_locks" = warn &&
msousa@353: 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
msousa@353: 	$ECHO "\
msousa@353: *** ERROR, $lockfile contains:
msousa@353: `cat $lockfile 2>/dev/null`
msousa@353: 
msousa@353: but it should contain:
msousa@353: $srcfile
msousa@353: 
msousa@353: This indicates that another process is trying to use the same
msousa@353: temporary object file, and libtool could not work around it because
msousa@353: your compiler does not support \`-c' and \`-o' together.  If you
msousa@353: repeat this compilation, it may succeed, by chance, but you had better
msousa@353: avoid parallel builds (make -j) in this platform, or get a better
msousa@353: compiler."
msousa@353: 
msousa@353: 	$opt_dry_run || $RM $removelist
msousa@353: 	exit $EXIT_FAILURE
msousa@353:       fi
msousa@353: 
msousa@353:       # Just move the object if needed
msousa@353:       if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
msousa@353: 	func_show_eval '$MV "$output_obj" "$obj"' \
msousa@353: 	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
msousa@353:       fi
msousa@353:     fi
msousa@353: 
msousa@353:     $opt_dry_run || {
msousa@353:       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
msousa@353: 
msousa@353:       # Unlock the critical section if it was locked
msousa@353:       if test "$need_locks" != no; then
msousa@353: 	removelist=$lockfile
msousa@353:         $RM "$lockfile"
msousa@353:       fi
msousa@353:     }
msousa@353: 
msousa@353:     exit $EXIT_SUCCESS
msousa@353: }
msousa@353: 
msousa@353: $opt_help || {
msousa@353: test "$mode" = compile && func_mode_compile ${1+"$@"}
msousa@353: }
msousa@353: 
msousa@353: func_mode_help ()
msousa@353: {
msousa@353:     # We need to display help for each of the modes.
msousa@353:     case $mode in
msousa@353:       "")
msousa@353:         # Generic help is extracted from the usage comments
msousa@353:         # at the start of this file.
msousa@353:         func_help
msousa@353:         ;;
msousa@353: 
msousa@353:       clean)
msousa@353:         $ECHO \
msousa@353: "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
msousa@353: 
msousa@353: Remove files from the build directory.
msousa@353: 
msousa@353: RM is the name of the program to use to delete files associated with each FILE
msousa@353: (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
msousa@353: to RM.
msousa@353: 
msousa@353: If FILE is a libtool library, object or program, all the files associated
msousa@353: with it are deleted. Otherwise, only FILE itself is deleted using RM."
msousa@353:         ;;
msousa@353: 
msousa@353:       compile)
msousa@353:       $ECHO \
msousa@353: "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
msousa@353: 
msousa@353: Compile a source file into a libtool library object.
msousa@353: 
msousa@353: This mode accepts the following additional options:
msousa@353: 
msousa@353:   -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
msousa@353:   -no-suppress      do not suppress compiler output for multiple passes
msousa@353:   -prefer-pic       try to building PIC objects only
msousa@353:   -prefer-non-pic   try to building non-PIC objects only
msousa@353:   -shared           do not build a \`.o' file suitable for static linking
msousa@353:   -static           only build a \`.o' file suitable for static linking
msousa@353: 
msousa@353: COMPILE-COMMAND is a command to be used in creating a \`standard' object file
msousa@353: from the given SOURCEFILE.
msousa@353: 
msousa@353: The output file name is determined by removing the directory component from
msousa@353: SOURCEFILE, then substituting the C source code suffix \`.c' with the
msousa@353: library object suffix, \`.lo'."
msousa@353:         ;;
msousa@353: 
msousa@353:       execute)
msousa@353:         $ECHO \
msousa@353: "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
msousa@353: 
msousa@353: Automatically set library path, then run a program.
msousa@353: 
msousa@353: This mode accepts the following additional options:
msousa@353: 
msousa@353:   -dlopen FILE      add the directory containing FILE to the library path
msousa@353: 
msousa@353: This mode sets the library path environment variable according to \`-dlopen'
msousa@353: flags.
msousa@353: 
msousa@353: If any of the ARGS are libtool executable wrappers, then they are translated
msousa@353: into their corresponding uninstalled binary, and any of their required library
msousa@353: directories are added to the library path.
msousa@353: 
msousa@353: Then, COMMAND is executed, with ARGS as arguments."
msousa@353:         ;;
msousa@353: 
msousa@353:       finish)
msousa@353:         $ECHO \
msousa@353: "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
msousa@353: 
msousa@353: Complete the installation of libtool libraries.
msousa@353: 
msousa@353: Each LIBDIR is a directory that contains libtool libraries.
msousa@353: 
msousa@353: The commands that this mode executes may require superuser privileges.  Use
msousa@353: the \`--dry-run' option if you just want to see what would be executed."
msousa@353:         ;;
msousa@353: 
msousa@353:       install)
msousa@353:         $ECHO \
msousa@353: "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
msousa@353: 
msousa@353: Install executables or libraries.
msousa@353: 
msousa@353: INSTALL-COMMAND is the installation command.  The first component should be
msousa@353: either the \`install' or \`cp' program.
msousa@353: 
msousa@353: The following components of INSTALL-COMMAND are treated specially:
msousa@353: 
msousa@353:   -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
msousa@353: 
msousa@353: The rest of the components are interpreted as arguments to that command (only
msousa@353: BSD-compatible install options are recognized)."
msousa@353:         ;;
msousa@353: 
msousa@353:       link)
msousa@353:         $ECHO \
msousa@353: "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
msousa@353: 
msousa@353: Link object files or libraries together to form another library, or to
msousa@353: create an executable program.
msousa@353: 
msousa@353: LINK-COMMAND is a command using the C compiler that you would use to create
msousa@353: a program from several object files.
msousa@353: 
msousa@353: The following components of LINK-COMMAND are treated specially:
msousa@353: 
msousa@353:   -all-static       do not do any dynamic linking at all
msousa@353:   -avoid-version    do not add a version suffix if possible
msousa@353:   -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
msousa@353:   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
msousa@353:   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
msousa@353:   -export-symbols SYMFILE
msousa@353:                     try to export only the symbols listed in SYMFILE
msousa@353:   -export-symbols-regex REGEX
msousa@353:                     try to export only the symbols matching REGEX
msousa@353:   -LLIBDIR          search LIBDIR for required installed libraries
msousa@353:   -lNAME            OUTPUT-FILE requires the installed library libNAME
msousa@353:   -module           build a library that can dlopened
msousa@353:   -no-fast-install  disable the fast-install mode
msousa@353:   -no-install       link a not-installable executable
msousa@353:   -no-undefined     declare that a library does not refer to external symbols
msousa@353:   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
msousa@353:   -objectlist FILE  Use a list of object files found in FILE to specify objects
msousa@353:   -precious-files-regex REGEX
msousa@353:                     don't remove output files matching REGEX
msousa@353:   -release RELEASE  specify package release information
msousa@353:   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
msousa@353:   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
msousa@353:   -shared           only do dynamic linking of libtool libraries
msousa@353:   -shrext SUFFIX    override the standard shared library file extension
msousa@353:   -static           do not do any dynamic linking of uninstalled libtool libraries
msousa@353:   -static-libtool-libs
msousa@353:                     do not do any dynamic linking of libtool libraries
msousa@353:   -version-info CURRENT[:REVISION[:AGE]]
msousa@353:                     specify library version info [each variable defaults to 0]
msousa@353:   -weak LIBNAME     declare that the target provides the LIBNAME interface
msousa@353: 
msousa@353: All other options (arguments beginning with \`-') are ignored.
msousa@353: 
msousa@353: Every other argument is treated as a filename.  Files ending in \`.la' are
msousa@353: treated as uninstalled libtool libraries, other files are standard or library
msousa@353: object files.
msousa@353: 
msousa@353: If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
msousa@353: only library objects (\`.lo' files) may be specified, and \`-rpath' is
msousa@353: required, except when creating a convenience library.
msousa@353: 
msousa@353: If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
msousa@353: using \`ar' and \`ranlib', or on Windows using \`lib'.
msousa@353: 
msousa@353: If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
msousa@353: is created, otherwise an executable program is created."
msousa@353:         ;;
msousa@353: 
msousa@353:       uninstall)
msousa@353:         $ECHO \
msousa@353: "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
msousa@353: 
msousa@353: Remove libraries from an installation directory.
msousa@353: 
msousa@353: RM is the name of the program to use to delete files associated with each FILE
msousa@353: (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
msousa@353: to RM.
msousa@353: 
msousa@353: If FILE is a libtool library, all the files associated with it are deleted.
msousa@353: Otherwise, only FILE itself is deleted using RM."
msousa@353:         ;;
msousa@353: 
msousa@353:       *)
msousa@353:         func_fatal_help "invalid operation mode \`$mode'"
msousa@353:         ;;
msousa@353:     esac
msousa@353: 
msousa@353:     $ECHO
msousa@353:     $ECHO "Try \`$progname --help' for more information about other modes."
msousa@353: 
msousa@353:     exit $?
msousa@353: }
msousa@353: 
msousa@353:   # Now that we've collected a possible --mode arg, show help if necessary
msousa@353:   $opt_help && func_mode_help
msousa@353: 
msousa@353: 
msousa@353: # func_mode_execute arg...
msousa@353: func_mode_execute ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     # The first argument is the command name.
msousa@353:     cmd="$nonopt"
msousa@353:     test -z "$cmd" && \
msousa@353:       func_fatal_help "you must specify a COMMAND"
msousa@353: 
msousa@353:     # Handle -dlopen flags immediately.
msousa@353:     for file in $execute_dlfiles; do
msousa@353:       test -f "$file" \
msousa@353: 	|| func_fatal_help "\`$file' is not a file"
msousa@353: 
msousa@353:       dir=
msousa@353:       case $file in
msousa@353:       *.la)
msousa@353: 	# Check to see that this really is a libtool archive.
msousa@353: 	func_lalib_unsafe_p "$file" \
msousa@353: 	  || func_fatal_help "\`$lib' is not a valid libtool archive"
msousa@353: 
msousa@353: 	# Read the libtool library.
msousa@353: 	dlname=
msousa@353: 	library_names=
msousa@353: 	func_source "$file"
msousa@353: 
msousa@353: 	# Skip this library if it cannot be dlopened.
msousa@353: 	if test -z "$dlname"; then
msousa@353: 	  # Warn if it was a shared library.
msousa@353: 	  test -n "$library_names" && \
msousa@353: 	    func_warning "\`$file' was not linked with \`-export-dynamic'"
msousa@353: 	  continue
msousa@353: 	fi
msousa@353: 
msousa@353: 	func_dirname "$file" "" "."
msousa@353: 	dir="$func_dirname_result"
msousa@353: 
msousa@353: 	if test -f "$dir/$objdir/$dlname"; then
msousa@353: 	  dir="$dir/$objdir"
msousa@353: 	else
msousa@353: 	  if test ! -f "$dir/$dlname"; then
msousa@353: 	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 	;;
msousa@353: 
msousa@353:       *.lo)
msousa@353: 	# Just add the directory containing the .lo file.
msousa@353: 	func_dirname "$file" "" "."
msousa@353: 	dir="$func_dirname_result"
msousa@353: 	;;
msousa@353: 
msousa@353:       *)
msousa@353: 	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
msousa@353: 	continue
msousa@353: 	;;
msousa@353:       esac
msousa@353: 
msousa@353:       # Get the absolute pathname.
msousa@353:       absdir=`cd "$dir" && pwd`
msousa@353:       test -n "$absdir" && dir="$absdir"
msousa@353: 
msousa@353:       # Now add the directory to shlibpath_var.
msousa@353:       if eval "test -z \"\$$shlibpath_var\""; then
msousa@353: 	eval "$shlibpath_var=\"\$dir\""
msousa@353:       else
msousa@353: 	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
msousa@353:       fi
msousa@353:     done
msousa@353: 
msousa@353:     # This variable tells wrapper scripts just to set shlibpath_var
msousa@353:     # rather than running their programs.
msousa@353:     libtool_execute_magic="$magic"
msousa@353: 
msousa@353:     # Check if any of the arguments is a wrapper script.
msousa@353:     args=
msousa@353:     for file
msousa@353:     do
msousa@353:       case $file in
msousa@353:       -*) ;;
msousa@353:       *)
msousa@353: 	# Do a test to see if this is really a libtool program.
msousa@353: 	if func_ltwrapper_script_p "$file"; then
msousa@353: 	  func_source "$file"
msousa@353: 	  # Transform arg to wrapped name.
msousa@353: 	  file="$progdir/$program"
msousa@353: 	elif func_ltwrapper_executable_p "$file"; then
msousa@353: 	  func_ltwrapper_scriptname "$file"
msousa@353: 	  func_source "$func_ltwrapper_scriptname_result"
msousa@353: 	  # Transform arg to wrapped name.
msousa@353: 	  file="$progdir/$program"
msousa@353: 	fi
msousa@353: 	;;
msousa@353:       esac
msousa@353:       # Quote arguments (to preserve shell metacharacters).
msousa@353:       func_quote_for_eval "$file"
msousa@353:       args="$args $func_quote_for_eval_result"
msousa@353:     done
msousa@353: 
msousa@353:     if test "X$opt_dry_run" = Xfalse; then
msousa@353:       if test -n "$shlibpath_var"; then
msousa@353: 	# Export the shlibpath_var.
msousa@353: 	eval "export $shlibpath_var"
msousa@353:       fi
msousa@353: 
msousa@353:       # Restore saved environment variables
msousa@353:       for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
msousa@353:       do
msousa@353: 	eval "if test \"\${save_$lt_var+set}\" = set; then
msousa@353:                 $lt_var=\$save_$lt_var; export $lt_var
msousa@353: 	      else
msousa@353: 		$lt_unset $lt_var
msousa@353: 	      fi"
msousa@353:       done
msousa@353: 
msousa@353:       # Now prepare to actually exec the command.
msousa@353:       exec_cmd="\$cmd$args"
msousa@353:     else
msousa@353:       # Display what would be done.
msousa@353:       if test -n "$shlibpath_var"; then
msousa@353: 	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
msousa@353: 	$ECHO "export $shlibpath_var"
msousa@353:       fi
msousa@353:       $ECHO "$cmd$args"
msousa@353:       exit $EXIT_SUCCESS
msousa@353:     fi
msousa@353: }
msousa@353: 
msousa@353: test "$mode" = execute && func_mode_execute ${1+"$@"}
msousa@353: 
msousa@353: 
msousa@353: # func_mode_finish arg...
msousa@353: func_mode_finish ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     libdirs="$nonopt"
msousa@353:     admincmds=
msousa@353: 
msousa@353:     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
msousa@353:       for dir
msousa@353:       do
msousa@353: 	libdirs="$libdirs $dir"
msousa@353:       done
msousa@353: 
msousa@353:       for libdir in $libdirs; do
msousa@353: 	if test -n "$finish_cmds"; then
msousa@353: 	  # Do each command in the finish commands.
msousa@353: 	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
msousa@353: '"$cmd"'"'
msousa@353: 	fi
msousa@353: 	if test -n "$finish_eval"; then
msousa@353: 	  # Do the single finish_eval.
msousa@353: 	  eval cmds=\"$finish_eval\"
msousa@353: 	  $opt_dry_run || eval "$cmds" || admincmds="$admincmds
msousa@353:        $cmds"
msousa@353: 	fi
msousa@353:       done
msousa@353:     fi
msousa@353: 
msousa@353:     # Exit here if they wanted silent mode.
msousa@353:     $opt_silent && exit $EXIT_SUCCESS
msousa@353: 
msousa@353:     $ECHO "X----------------------------------------------------------------------" | $Xsed
msousa@353:     $ECHO "Libraries have been installed in:"
msousa@353:     for libdir in $libdirs; do
msousa@353:       $ECHO "   $libdir"
msousa@353:     done
msousa@353:     $ECHO
msousa@353:     $ECHO "If you ever happen to want to link against installed libraries"
msousa@353:     $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
msousa@353:     $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
msousa@353:     $ECHO "flag during linking and do at least one of the following:"
msousa@353:     if test -n "$shlibpath_var"; then
msousa@353:       $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
msousa@353:       $ECHO "     during execution"
msousa@353:     fi
msousa@353:     if test -n "$runpath_var"; then
msousa@353:       $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
msousa@353:       $ECHO "     during linking"
msousa@353:     fi
msousa@353:     if test -n "$hardcode_libdir_flag_spec"; then
msousa@353:       libdir=LIBDIR
msousa@353:       eval flag=\"$hardcode_libdir_flag_spec\"
msousa@353: 
msousa@353:       $ECHO "   - use the \`$flag' linker flag"
msousa@353:     fi
msousa@353:     if test -n "$admincmds"; then
msousa@353:       $ECHO "   - have your system administrator run these commands:$admincmds"
msousa@353:     fi
msousa@353:     if test -f /etc/ld.so.conf; then
msousa@353:       $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
msousa@353:     fi
msousa@353:     $ECHO
msousa@353: 
msousa@353:     $ECHO "See any operating system documentation about shared libraries for"
msousa@353:     case $host in
msousa@353:       solaris2.[6789]|solaris2.1[0-9])
msousa@353:         $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
msousa@353: 	$ECHO "pages."
msousa@353: 	;;
msousa@353:       *)
msousa@353:         $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
msousa@353:         ;;
msousa@353:     esac
msousa@353:     $ECHO "X----------------------------------------------------------------------" | $Xsed
msousa@353:     exit $EXIT_SUCCESS
msousa@353: }
msousa@353: 
msousa@353: test "$mode" = finish && func_mode_finish ${1+"$@"}
msousa@353: 
msousa@353: 
msousa@353: # func_mode_install arg...
msousa@353: func_mode_install ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     # There may be an optional sh(1) argument at the beginning of
msousa@353:     # install_prog (especially on Windows NT).
msousa@353:     if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
msousa@353:        # Allow the use of GNU shtool's install command.
msousa@353:        $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
msousa@353:       # Aesthetically quote it.
msousa@353:       func_quote_for_eval "$nonopt"
msousa@353:       install_prog="$func_quote_for_eval_result "
msousa@353:       arg=$1
msousa@353:       shift
msousa@353:     else
msousa@353:       install_prog=
msousa@353:       arg=$nonopt
msousa@353:     fi
msousa@353: 
msousa@353:     # The real first argument should be the name of the installation program.
msousa@353:     # Aesthetically quote it.
msousa@353:     func_quote_for_eval "$arg"
msousa@353:     install_prog="$install_prog$func_quote_for_eval_result"
msousa@353: 
msousa@353:     # We need to accept at least all the BSD install flags.
msousa@353:     dest=
msousa@353:     files=
msousa@353:     opts=
msousa@353:     prev=
msousa@353:     install_type=
msousa@353:     isdir=no
msousa@353:     stripme=
msousa@353:     for arg
msousa@353:     do
msousa@353:       if test -n "$dest"; then
msousa@353: 	files="$files $dest"
msousa@353: 	dest=$arg
msousa@353: 	continue
msousa@353:       fi
msousa@353: 
msousa@353:       case $arg in
msousa@353:       -d) isdir=yes ;;
msousa@353:       -f)
msousa@353: 	case " $install_prog " in
msousa@353: 	*[\\\ /]cp\ *) ;;
msousa@353: 	*) prev=$arg ;;
msousa@353: 	esac
msousa@353: 	;;
msousa@353:       -g | -m | -o)
msousa@353: 	prev=$arg
msousa@353: 	;;
msousa@353:       -s)
msousa@353: 	stripme=" -s"
msousa@353: 	continue
msousa@353: 	;;
msousa@353:       -*)
msousa@353: 	;;
msousa@353:       *)
msousa@353: 	# If the previous option needed an argument, then skip it.
msousa@353: 	if test -n "$prev"; then
msousa@353: 	  prev=
msousa@353: 	else
msousa@353: 	  dest=$arg
msousa@353: 	  continue
msousa@353: 	fi
msousa@353: 	;;
msousa@353:       esac
msousa@353: 
msousa@353:       # Aesthetically quote the argument.
msousa@353:       func_quote_for_eval "$arg"
msousa@353:       install_prog="$install_prog $func_quote_for_eval_result"
msousa@353:     done
msousa@353: 
msousa@353:     test -z "$install_prog" && \
msousa@353:       func_fatal_help "you must specify an install program"
msousa@353: 
msousa@353:     test -n "$prev" && \
msousa@353:       func_fatal_help "the \`$prev' option requires an argument"
msousa@353: 
msousa@353:     if test -z "$files"; then
msousa@353:       if test -z "$dest"; then
msousa@353: 	func_fatal_help "no file or destination specified"
msousa@353:       else
msousa@353: 	func_fatal_help "you must specify a destination"
msousa@353:       fi
msousa@353:     fi
msousa@353: 
msousa@353:     # Strip any trailing slash from the destination.
msousa@353:     func_stripname '' '/' "$dest"
msousa@353:     dest=$func_stripname_result
msousa@353: 
msousa@353:     # Check to see that the destination is a directory.
msousa@353:     test -d "$dest" && isdir=yes
msousa@353:     if test "$isdir" = yes; then
msousa@353:       destdir="$dest"
msousa@353:       destname=
msousa@353:     else
msousa@353:       func_dirname_and_basename "$dest" "" "."
msousa@353:       destdir="$func_dirname_result"
msousa@353:       destname="$func_basename_result"
msousa@353: 
msousa@353:       # Not a directory, so check to see that there is only one file specified.
msousa@353:       set dummy $files; shift
msousa@353:       test "$#" -gt 1 && \
msousa@353: 	func_fatal_help "\`$dest' is not a directory"
msousa@353:     fi
msousa@353:     case $destdir in
msousa@353:     [\\/]* | [A-Za-z]:[\\/]*) ;;
msousa@353:     *)
msousa@353:       for file in $files; do
msousa@353: 	case $file in
msousa@353: 	*.lo) ;;
msousa@353: 	*)
msousa@353: 	  func_fatal_help "\`$destdir' must be an absolute directory name"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353:       done
msousa@353:       ;;
msousa@353:     esac
msousa@353: 
msousa@353:     # This variable tells wrapper scripts just to set variables rather
msousa@353:     # than running their programs.
msousa@353:     libtool_install_magic="$magic"
msousa@353: 
msousa@353:     staticlibs=
msousa@353:     future_libdirs=
msousa@353:     current_libdirs=
msousa@353:     for file in $files; do
msousa@353: 
msousa@353:       # Do each installation.
msousa@353:       case $file in
msousa@353:       *.$libext)
msousa@353: 	# Do the static libraries later.
msousa@353: 	staticlibs="$staticlibs $file"
msousa@353: 	;;
msousa@353: 
msousa@353:       *.la)
msousa@353: 	# Check to see that this really is a libtool archive.
msousa@353: 	func_lalib_unsafe_p "$file" \
msousa@353: 	  || func_fatal_help "\`$file' is not a valid libtool archive"
msousa@353: 
msousa@353: 	library_names=
msousa@353: 	old_library=
msousa@353: 	relink_command=
msousa@353: 	func_source "$file"
msousa@353: 
msousa@353: 	# Add the libdir to current_libdirs if it is the destination.
msousa@353: 	if test "X$destdir" = "X$libdir"; then
msousa@353: 	  case "$current_libdirs " in
msousa@353: 	  *" $libdir "*) ;;
msousa@353: 	  *) current_libdirs="$current_libdirs $libdir" ;;
msousa@353: 	  esac
msousa@353: 	else
msousa@353: 	  # Note the libdir as a future libdir.
msousa@353: 	  case "$future_libdirs " in
msousa@353: 	  *" $libdir "*) ;;
msousa@353: 	  *) future_libdirs="$future_libdirs $libdir" ;;
msousa@353: 	  esac
msousa@353: 	fi
msousa@353: 
msousa@353: 	func_dirname "$file" "/" ""
msousa@353: 	dir="$func_dirname_result"
msousa@353: 	dir="$dir$objdir"
msousa@353: 
msousa@353: 	if test -n "$relink_command"; then
msousa@353: 	  # Determine the prefix the user has applied to our future dir.
msousa@353: 	  inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
msousa@353: 
msousa@353: 	  # Don't allow the user to place us outside of our expected
msousa@353: 	  # location b/c this prevents finding dependent libraries that
msousa@353: 	  # are installed to the same prefix.
msousa@353: 	  # At present, this check doesn't affect windows .dll's that
msousa@353: 	  # are installed into $libdir/../bin (currently, that works fine)
msousa@353: 	  # but it's something to keep an eye on.
msousa@353: 	  test "$inst_prefix_dir" = "$destdir" && \
msousa@353: 	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
msousa@353: 
msousa@353: 	  if test -n "$inst_prefix_dir"; then
msousa@353: 	    # Stick the inst_prefix_dir data into the link command.
msousa@353: 	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
msousa@353: 	  else
msousa@353: 	    relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  func_warning "relinking \`$file'"
msousa@353: 	  func_show_eval "$relink_command" \
msousa@353: 	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
msousa@353: 	fi
msousa@353: 
msousa@353: 	# See the names of the shared library.
msousa@353: 	set dummy $library_names; shift
msousa@353: 	if test -n "$1"; then
msousa@353: 	  realname="$1"
msousa@353: 	  shift
msousa@353: 
msousa@353: 	  srcname="$realname"
msousa@353: 	  test -n "$relink_command" && srcname="$realname"T
msousa@353: 
msousa@353: 	  # Install the shared library and build the symlinks.
msousa@353: 	  func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
msousa@353: 	      'exit $?'
msousa@353: 	  tstripme="$stripme"
msousa@353: 	  case $host_os in
msousa@353: 	  cygwin* | mingw* | pw32* | cegcc*)
msousa@353: 	    case $realname in
msousa@353: 	    *.dll.a)
msousa@353: 	      tstripme=""
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  if test -n "$tstripme" && test -n "$striplib"; then
msousa@353: 	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  if test "$#" -gt 0; then
msousa@353: 	    # Delete the old symlinks, and create new ones.
msousa@353: 	    # Try `ln -sf' first, because the `ln' binary might depend on
msousa@353: 	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
msousa@353: 	    # so we also need to try rm && ln -s.
msousa@353: 	    for linkname
msousa@353: 	    do
msousa@353: 	      test "$linkname" != "$realname" \
msousa@353: 		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
msousa@353: 	    done
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  # Do each command in the postinstall commands.
msousa@353: 	  lib="$destdir/$realname"
msousa@353: 	  func_execute_cmds "$postinstall_cmds" 'exit $?'
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Install the pseudo-library for information purposes.
msousa@353: 	func_basename "$file"
msousa@353: 	name="$func_basename_result"
msousa@353: 	instname="$dir/$name"i
msousa@353: 	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
msousa@353: 
msousa@353: 	# Maybe install the static library, too.
msousa@353: 	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
msousa@353: 	;;
msousa@353: 
msousa@353:       *.lo)
msousa@353: 	# Install (i.e. copy) a libtool object.
msousa@353: 
msousa@353: 	# Figure out destination file name, if it wasn't already specified.
msousa@353: 	if test -n "$destname"; then
msousa@353: 	  destfile="$destdir/$destname"
msousa@353: 	else
msousa@353: 	  func_basename "$file"
msousa@353: 	  destfile="$func_basename_result"
msousa@353: 	  destfile="$destdir/$destfile"
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Deduce the name of the destination old-style object file.
msousa@353: 	case $destfile in
msousa@353: 	*.lo)
msousa@353: 	  func_lo2o "$destfile"
msousa@353: 	  staticdest=$func_lo2o_result
msousa@353: 	  ;;
msousa@353: 	*.$objext)
msousa@353: 	  staticdest="$destfile"
msousa@353: 	  destfile=
msousa@353: 	  ;;
msousa@353: 	*)
msousa@353: 	  func_fatal_help "cannot copy a libtool object to \`$destfile'"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	# Install the libtool object if requested.
msousa@353: 	test -n "$destfile" && \
msousa@353: 	  func_show_eval "$install_prog $file $destfile" 'exit $?'
msousa@353: 
msousa@353: 	# Install the old object if enabled.
msousa@353: 	if test "$build_old_libs" = yes; then
msousa@353: 	  # Deduce the name of the old-style object file.
msousa@353: 	  func_lo2o "$file"
msousa@353: 	  staticobj=$func_lo2o_result
msousa@353: 	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
msousa@353: 	fi
msousa@353: 	exit $EXIT_SUCCESS
msousa@353: 	;;
msousa@353: 
msousa@353:       *)
msousa@353: 	# Figure out destination file name, if it wasn't already specified.
msousa@353: 	if test -n "$destname"; then
msousa@353: 	  destfile="$destdir/$destname"
msousa@353: 	else
msousa@353: 	  func_basename "$file"
msousa@353: 	  destfile="$func_basename_result"
msousa@353: 	  destfile="$destdir/$destfile"
msousa@353: 	fi
msousa@353: 
msousa@353: 	# If the file is missing, and there is a .exe on the end, strip it
msousa@353: 	# because it is most likely a libtool script we actually want to
msousa@353: 	# install
msousa@353: 	stripped_ext=""
msousa@353: 	case $file in
msousa@353: 	  *.exe)
msousa@353: 	    if test ! -f "$file"; then
msousa@353: 	      func_stripname '' '.exe' "$file"
msousa@353: 	      file=$func_stripname_result
msousa@353: 	      stripped_ext=".exe"
msousa@353: 	    fi
msousa@353: 	    ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	# Do a test to see if this is really a libtool program.
msousa@353: 	case $host in
msousa@353: 	*cygwin* | *mingw*)
msousa@353: 	    if func_ltwrapper_executable_p "$file"; then
msousa@353: 	      func_ltwrapper_scriptname "$file"
msousa@353: 	      wrapper=$func_ltwrapper_scriptname_result
msousa@353: 	    else
msousa@353: 	      func_stripname '' '.exe' "$file"
msousa@353: 	      wrapper=$func_stripname_result
msousa@353: 	    fi
msousa@353: 	    ;;
msousa@353: 	*)
msousa@353: 	    wrapper=$file
msousa@353: 	    ;;
msousa@353: 	esac
msousa@353: 	if func_ltwrapper_script_p "$wrapper"; then
msousa@353: 	  notinst_deplibs=
msousa@353: 	  relink_command=
msousa@353: 
msousa@353: 	  func_source "$wrapper"
msousa@353: 
msousa@353: 	  # Check the variables that should have been set.
msousa@353: 	  test -z "$generated_by_libtool_version" && \
msousa@353: 	    func_fatal_error "invalid libtool wrapper script \`$wrapper'"
msousa@353: 
msousa@353: 	  finalize=yes
msousa@353: 	  for lib in $notinst_deplibs; do
msousa@353: 	    # Check to see that each library is installed.
msousa@353: 	    libdir=
msousa@353: 	    if test -f "$lib"; then
msousa@353: 	      func_source "$lib"
msousa@353: 	    fi
msousa@353: 	    libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
msousa@353: 	    if test -n "$libdir" && test ! -f "$libfile"; then
msousa@353: 	      func_warning "\`$lib' has not been installed in \`$libdir'"
msousa@353: 	      finalize=no
msousa@353: 	    fi
msousa@353: 	  done
msousa@353: 
msousa@353: 	  relink_command=
msousa@353: 	  func_source "$wrapper"
msousa@353: 
msousa@353: 	  outputname=
msousa@353: 	  if test "$fast_install" = no && test -n "$relink_command"; then
msousa@353: 	    $opt_dry_run || {
msousa@353: 	      if test "$finalize" = yes; then
msousa@353: 	        tmpdir=`func_mktempdir`
msousa@353: 		func_basename "$file$stripped_ext"
msousa@353: 		file="$func_basename_result"
msousa@353: 	        outputname="$tmpdir/$file"
msousa@353: 	        # Replace the output file specification.
msousa@353: 	        relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
msousa@353: 
msousa@353: 	        $opt_silent || {
msousa@353: 	          func_quote_for_expand "$relink_command"
msousa@353: 		  eval "func_echo $func_quote_for_expand_result"
msousa@353: 	        }
msousa@353: 	        if eval "$relink_command"; then :
msousa@353: 	          else
msousa@353: 		  func_error "error: relink \`$file' with the above command before installing it"
msousa@353: 		  $opt_dry_run || ${RM}r "$tmpdir"
msousa@353: 		  continue
msousa@353: 	        fi
msousa@353: 	        file="$outputname"
msousa@353: 	      else
msousa@353: 	        func_warning "cannot relink \`$file'"
msousa@353: 	      fi
msousa@353: 	    }
msousa@353: 	  else
msousa@353: 	    # Install the binary that we compiled earlier.
msousa@353: 	    file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 
msousa@353: 	# remove .exe since cygwin /usr/bin/install will append another
msousa@353: 	# one anyway
msousa@353: 	case $install_prog,$host in
msousa@353: 	*/usr/bin/install*,*cygwin*)
msousa@353: 	  case $file:$destfile in
msousa@353: 	  *.exe:*.exe)
msousa@353: 	    # this is ok
msousa@353: 	    ;;
msousa@353: 	  *.exe:*)
msousa@353: 	    destfile=$destfile.exe
msousa@353: 	    ;;
msousa@353: 	  *:*.exe)
msousa@353: 	    func_stripname '' '.exe' "$destfile"
msousa@353: 	    destfile=$func_stripname_result
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
msousa@353: 	$opt_dry_run || if test -n "$outputname"; then
msousa@353: 	  ${RM}r "$tmpdir"
msousa@353: 	fi
msousa@353: 	;;
msousa@353:       esac
msousa@353:     done
msousa@353: 
msousa@353:     for file in $staticlibs; do
msousa@353:       func_basename "$file"
msousa@353:       name="$func_basename_result"
msousa@353: 
msousa@353:       # Set up the ranlib parameters.
msousa@353:       oldlib="$destdir/$name"
msousa@353: 
msousa@353:       func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
msousa@353: 
msousa@353:       if test -n "$stripme" && test -n "$old_striplib"; then
msousa@353: 	func_show_eval "$old_striplib $oldlib" 'exit $?'
msousa@353:       fi
msousa@353: 
msousa@353:       # Do each command in the postinstall commands.
msousa@353:       func_execute_cmds "$old_postinstall_cmds" 'exit $?'
msousa@353:     done
msousa@353: 
msousa@353:     test -n "$future_libdirs" && \
msousa@353:       func_warning "remember to run \`$progname --finish$future_libdirs'"
msousa@353: 
msousa@353:     if test -n "$current_libdirs"; then
msousa@353:       # Maybe just do a dry run.
msousa@353:       $opt_dry_run && current_libdirs=" -n$current_libdirs"
msousa@353:       exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
msousa@353:     else
msousa@353:       exit $EXIT_SUCCESS
msousa@353:     fi
msousa@353: }
msousa@353: 
msousa@353: test "$mode" = install && func_mode_install ${1+"$@"}
msousa@353: 
msousa@353: 
msousa@353: # func_generate_dlsyms outputname originator pic_p
msousa@353: # Extract symbols from dlprefiles and create ${outputname}S.o with
msousa@353: # a dlpreopen symbol table.
msousa@353: func_generate_dlsyms ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     my_outputname="$1"
msousa@353:     my_originator="$2"
msousa@353:     my_pic_p="${3-no}"
msousa@353:     my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
msousa@353:     my_dlsyms=
msousa@353: 
msousa@353:     if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
msousa@353:       if test -n "$NM" && test -n "$global_symbol_pipe"; then
msousa@353: 	my_dlsyms="${my_outputname}S.c"
msousa@353:       else
msousa@353: 	func_error "not configured to extract global symbols from dlpreopened files"
msousa@353:       fi
msousa@353:     fi
msousa@353: 
msousa@353:     if test -n "$my_dlsyms"; then
msousa@353:       case $my_dlsyms in
msousa@353:       "") ;;
msousa@353:       *.c)
msousa@353: 	# Discover the nlist of each of the dlfiles.
msousa@353: 	nlist="$output_objdir/${my_outputname}.nm"
msousa@353: 
msousa@353: 	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
msousa@353: 
msousa@353: 	# Parse the name list into a source file.
msousa@353: 	func_verbose "creating $output_objdir/$my_dlsyms"
msousa@353: 
msousa@353: 	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
msousa@353: /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
msousa@353: /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
msousa@353: 
msousa@353: #ifdef __cplusplus
msousa@353: extern \"C\" {
msousa@353: #endif
msousa@353: 
msousa@353: /* External symbol declarations for the compiler. */\
msousa@353: "
msousa@353: 
msousa@353: 	if test "$dlself" = yes; then
msousa@353: 	  func_verbose "generating symbol list for \`$output'"
msousa@353: 
msousa@353: 	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
msousa@353: 
msousa@353: 	  # Add our own program objects to the symbol list.
msousa@353: 	  progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
msousa@353: 	  for progfile in $progfiles; do
msousa@353: 	    func_verbose "extracting global C symbols from \`$progfile'"
msousa@353: 	    $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
msousa@353: 	  done
msousa@353: 
msousa@353: 	  if test -n "$exclude_expsyms"; then
msousa@353: 	    $opt_dry_run || {
msousa@353: 	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
msousa@353: 	      eval '$MV "$nlist"T "$nlist"'
msousa@353: 	    }
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  if test -n "$export_symbols_regex"; then
msousa@353: 	    $opt_dry_run || {
msousa@353: 	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
msousa@353: 	      eval '$MV "$nlist"T "$nlist"'
msousa@353: 	    }
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  # Prepare the list of exported symbols
msousa@353: 	  if test -z "$export_symbols"; then
msousa@353: 	    export_symbols="$output_objdir/$outputname.exp"
msousa@353: 	    $opt_dry_run || {
msousa@353: 	      $RM $export_symbols
msousa@353: 	      eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
msousa@353: 	      case $host in
msousa@353: 	      *cygwin* | *mingw* | *cegcc* )
msousa@353:                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
msousa@353:                 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
msousa@353: 	        ;;
msousa@353: 	      esac
msousa@353: 	    }
msousa@353: 	  else
msousa@353: 	    $opt_dry_run || {
msousa@353: 	      eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
msousa@353: 	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
msousa@353: 	      eval '$MV "$nlist"T "$nlist"'
msousa@353: 	      case $host in
msousa@353: 	        *cygwin | *mingw* | *cegcc* )
msousa@353: 	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
msousa@353: 	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
msousa@353: 	          ;;
msousa@353: 	      esac
msousa@353: 	    }
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 
msousa@353: 	for dlprefile in $dlprefiles; do
msousa@353: 	  func_verbose "extracting global C symbols from \`$dlprefile'"
msousa@353: 	  func_basename "$dlprefile"
msousa@353: 	  name="$func_basename_result"
msousa@353: 	  $opt_dry_run || {
msousa@353: 	    eval '$ECHO ": $name " >> "$nlist"'
msousa@353: 	    eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
msousa@353: 	  }
msousa@353: 	done
msousa@353: 
msousa@353: 	$opt_dry_run || {
msousa@353: 	  # Make sure we have at least an empty file.
msousa@353: 	  test -f "$nlist" || : > "$nlist"
msousa@353: 
msousa@353: 	  if test -n "$exclude_expsyms"; then
msousa@353: 	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
msousa@353: 	    $MV "$nlist"T "$nlist"
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  # Try sorting and uniquifying the output.
msousa@353: 	  if $GREP -v "^: " < "$nlist" |
msousa@353: 	      if sort -k 3 </dev/null >/dev/null 2>&1; then
msousa@353: 		sort -k 3
msousa@353: 	      else
msousa@353: 		sort +2
msousa@353: 	      fi |
msousa@353: 	      uniq > "$nlist"S; then
msousa@353: 	    :
msousa@353: 	  else
msousa@353: 	    $GREP -v "^: " < "$nlist" > "$nlist"S
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  if test -f "$nlist"S; then
msousa@353: 	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
msousa@353: 	  else
msousa@353: 	    $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  $ECHO >> "$output_objdir/$my_dlsyms" "\
msousa@353: 
msousa@353: /* The mapping between symbol names and symbols.  */
msousa@353: typedef struct {
msousa@353:   const char *name;
msousa@353:   void *address;
msousa@353: } lt_dlsymlist;
msousa@353: "
msousa@353: 	  case $host in
msousa@353: 	  *cygwin* | *mingw* | *cegcc* )
msousa@353: 	    $ECHO >> "$output_objdir/$my_dlsyms" "\
msousa@353: /* DATA imports from DLLs on WIN32 con't be const, because
msousa@353:    runtime relocations are performed -- see ld's documentation
msousa@353:    on pseudo-relocs.  */"
msousa@353: 	    lt_dlsym_const= ;;
msousa@353: 	  *osf5*)
msousa@353: 	    echo >> "$output_objdir/$my_dlsyms" "\
msousa@353: /* This system does not cope well with relocations in const data */"
msousa@353: 	    lt_dlsym_const= ;;
msousa@353: 	  *)
msousa@353: 	    lt_dlsym_const=const ;;
msousa@353: 	  esac
msousa@353: 
msousa@353: 	  $ECHO >> "$output_objdir/$my_dlsyms" "\
msousa@353: extern $lt_dlsym_const lt_dlsymlist
msousa@353: lt_${my_prefix}_LTX_preloaded_symbols[];
msousa@353: $lt_dlsym_const lt_dlsymlist
msousa@353: lt_${my_prefix}_LTX_preloaded_symbols[] =
msousa@353: {\
msousa@353:   { \"$my_originator\", (void *) 0 },"
msousa@353: 
msousa@353: 	  case $need_lib_prefix in
msousa@353: 	  no)
msousa@353: 	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
msousa@353: 	    ;;
msousa@353: 	  *)
msousa@353: 	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  $ECHO >> "$output_objdir/$my_dlsyms" "\
msousa@353:   {0, (void *) 0}
msousa@353: };
msousa@353: 
msousa@353: /* This works around a problem in FreeBSD linker */
msousa@353: #ifdef FREEBSD_WORKAROUND
msousa@353: static const void *lt_preloaded_setup() {
msousa@353:   return lt_${my_prefix}_LTX_preloaded_symbols;
msousa@353: }
msousa@353: #endif
msousa@353: 
msousa@353: #ifdef __cplusplus
msousa@353: }
msousa@353: #endif\
msousa@353: "
msousa@353: 	} # !$opt_dry_run
msousa@353: 
msousa@353: 	pic_flag_for_symtable=
msousa@353: 	case "$compile_command " in
msousa@353: 	*" -static "*) ;;
msousa@353: 	*)
msousa@353: 	  case $host in
msousa@353: 	  # compiling the symbol table file with pic_flag works around
msousa@353: 	  # a FreeBSD bug that causes programs to crash when -lm is
msousa@353: 	  # linked before any other PIC object.  But we must not use
msousa@353: 	  # pic_flag when linking with -static.  The problem exists in
msousa@353: 	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
msousa@353: 	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
msousa@353: 	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
msousa@353: 	  *-*-hpux*)
msousa@353: 	    pic_flag_for_symtable=" $pic_flag"  ;;
msousa@353: 	  *)
msousa@353: 	    if test "X$my_pic_p" != Xno; then
msousa@353: 	      pic_flag_for_symtable=" $pic_flag"
msousa@353: 	    fi
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	symtab_cflags=
msousa@353: 	for arg in $LTCFLAGS; do
msousa@353: 	  case $arg in
msousa@353: 	  -pie | -fpie | -fPIE) ;;
msousa@353: 	  *) symtab_cflags="$symtab_cflags $arg" ;;
msousa@353: 	  esac
msousa@353: 	done
msousa@353: 
msousa@353: 	# Now compile the dynamic symbol file.
msousa@353: 	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
msousa@353: 
msousa@353: 	# Clean up the generated files.
msousa@353: 	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
msousa@353: 
msousa@353: 	# Transform the symbol file into the correct name.
msousa@353: 	symfileobj="$output_objdir/${my_outputname}S.$objext"
msousa@353: 	case $host in
msousa@353: 	*cygwin* | *mingw* | *cegcc* )
msousa@353: 	  if test -f "$output_objdir/$my_outputname.def"; then
msousa@353: 	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
msousa@353: 	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
msousa@353: 	  else
msousa@353: 	    compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
msousa@353: 	    finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
msousa@353: 	  fi
msousa@353: 	  ;;
msousa@353: 	*)
msousa@353: 	  compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
msousa@353: 	  finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	;;
msousa@353:       *)
msousa@353: 	func_fatal_error "unknown suffix for \`$my_dlsyms'"
msousa@353: 	;;
msousa@353:       esac
msousa@353:     else
msousa@353:       # We keep going just in case the user didn't refer to
msousa@353:       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
msousa@353:       # really was required.
msousa@353: 
msousa@353:       # Nullify the symbol file.
msousa@353:       compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
msousa@353:       finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
msousa@353:     fi
msousa@353: }
msousa@353: 
msousa@353: # func_win32_libid arg
msousa@353: # return the library type of file 'arg'
msousa@353: #
msousa@353: # Need a lot of goo to handle *both* DLLs and import libs
msousa@353: # Has to be a shell function in order to 'eat' the argument
msousa@353: # that is supplied when $file_magic_command is called.
msousa@353: func_win32_libid ()
msousa@353: {
msousa@353:   $opt_debug
msousa@353:   win32_libid_type="unknown"
msousa@353:   win32_fileres=`file -L $1 2>/dev/null`
msousa@353:   case $win32_fileres in
msousa@353:   *ar\ archive\ import\ library*) # definitely import
msousa@353:     win32_libid_type="x86 archive import"
msousa@353:     ;;
msousa@353:   *ar\ archive*) # could be an import, or static
msousa@353:     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
msousa@353:        $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
msousa@353:       win32_nmres=`eval $NM -f posix -A $1 |
msousa@353: 	$SED -n -e '
msousa@353: 	    1,100{
msousa@353: 		/ I /{
msousa@353: 		    s,.*,import,
msousa@353: 		    p
msousa@353: 		    q
msousa@353: 		}
msousa@353: 	    }'`
msousa@353:       case $win32_nmres in
msousa@353:       import*)  win32_libid_type="x86 archive import";;
msousa@353:       *)        win32_libid_type="x86 archive static";;
msousa@353:       esac
msousa@353:     fi
msousa@353:     ;;
msousa@353:   *DLL*)
msousa@353:     win32_libid_type="x86 DLL"
msousa@353:     ;;
msousa@353:   *executable*) # but shell scripts are "executable" too...
msousa@353:     case $win32_fileres in
msousa@353:     *MS\ Windows\ PE\ Intel*)
msousa@353:       win32_libid_type="x86 DLL"
msousa@353:       ;;
msousa@353:     esac
msousa@353:     ;;
msousa@353:   esac
msousa@353:   $ECHO "$win32_libid_type"
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: # func_extract_an_archive dir oldlib
msousa@353: func_extract_an_archive ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     f_ex_an_ar_dir="$1"; shift
msousa@353:     f_ex_an_ar_oldlib="$1"
msousa@353:     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
msousa@353:     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
msousa@353:      :
msousa@353:     else
msousa@353:       func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
msousa@353:     fi
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_extract_archives gentop oldlib ...
msousa@353: func_extract_archives ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     my_gentop="$1"; shift
msousa@353:     my_oldlibs=${1+"$@"}
msousa@353:     my_oldobjs=""
msousa@353:     my_xlib=""
msousa@353:     my_xabs=""
msousa@353:     my_xdir=""
msousa@353: 
msousa@353:     for my_xlib in $my_oldlibs; do
msousa@353:       # Extract the objects.
msousa@353:       case $my_xlib in
msousa@353: 	[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
msousa@353: 	*) my_xabs=`pwd`"/$my_xlib" ;;
msousa@353:       esac
msousa@353:       func_basename "$my_xlib"
msousa@353:       my_xlib="$func_basename_result"
msousa@353:       my_xlib_u=$my_xlib
msousa@353:       while :; do
msousa@353:         case " $extracted_archives " in
msousa@353: 	*" $my_xlib_u "*)
msousa@353: 	  func_arith $extracted_serial + 1
msousa@353: 	  extracted_serial=$func_arith_result
msousa@353: 	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
msousa@353: 	*) break ;;
msousa@353: 	esac
msousa@353:       done
msousa@353:       extracted_archives="$extracted_archives $my_xlib_u"
msousa@353:       my_xdir="$my_gentop/$my_xlib_u"
msousa@353: 
msousa@353:       func_mkdir_p "$my_xdir"
msousa@353: 
msousa@353:       case $host in
msousa@353:       *-darwin*)
msousa@353: 	func_verbose "Extracting $my_xabs"
msousa@353: 	# Do not bother doing anything if just a dry run
msousa@353: 	$opt_dry_run || {
msousa@353: 	  darwin_orig_dir=`pwd`
msousa@353: 	  cd $my_xdir || exit $?
msousa@353: 	  darwin_archive=$my_xabs
msousa@353: 	  darwin_curdir=`pwd`
msousa@353: 	  darwin_base_archive=`basename "$darwin_archive"`
msousa@353: 	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
msousa@353: 	  if test -n "$darwin_arches"; then
msousa@353: 	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
msousa@353: 	    darwin_arch=
msousa@353: 	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
msousa@353: 	    for darwin_arch in  $darwin_arches ; do
msousa@353: 	      func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
msousa@353: 	      $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
msousa@353: 	      cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
msousa@353: 	      func_extract_an_archive "`pwd`" "${darwin_base_archive}"
msousa@353: 	      cd "$darwin_curdir"
msousa@353: 	      $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
msousa@353: 	    done # $darwin_arches
msousa@353:             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
msousa@353: 	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
msousa@353: 	    darwin_file=
msousa@353: 	    darwin_files=
msousa@353: 	    for darwin_file in $darwin_filelist; do
msousa@353: 	      darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
msousa@353: 	      $LIPO -create -output "$darwin_file" $darwin_files
msousa@353: 	    done # $darwin_filelist
msousa@353: 	    $RM -rf unfat-$$
msousa@353: 	    cd "$darwin_orig_dir"
msousa@353: 	  else
msousa@353: 	    cd $darwin_orig_dir
msousa@353: 	    func_extract_an_archive "$my_xdir" "$my_xabs"
msousa@353: 	  fi # $darwin_arches
msousa@353: 	} # !$opt_dry_run
msousa@353: 	;;
msousa@353:       *)
msousa@353:         func_extract_an_archive "$my_xdir" "$my_xabs"
msousa@353: 	;;
msousa@353:       esac
msousa@353:       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
msousa@353:     done
msousa@353: 
msousa@353:     func_extract_archives_result="$my_oldobjs"
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: 
msousa@353: # func_emit_wrapper_part1 [arg=no]
msousa@353: #
msousa@353: # Emit the first part of a libtool wrapper script on stdout.
msousa@353: # For more information, see the description associated with
msousa@353: # func_emit_wrapper(), below.
msousa@353: func_emit_wrapper_part1 ()
msousa@353: {
msousa@353: 	func_emit_wrapper_part1_arg1=no
msousa@353: 	if test -n "$1" ; then
msousa@353: 	  func_emit_wrapper_part1_arg1=$1
msousa@353: 	fi
msousa@353: 
msousa@353: 	$ECHO "\
msousa@353: #! $SHELL
msousa@353: 
msousa@353: # $output - temporary wrapper script for $objdir/$outputname
msousa@353: # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
msousa@353: #
msousa@353: # The $output program cannot be directly executed until all the libtool
msousa@353: # libraries that it depends on are installed.
msousa@353: #
msousa@353: # This wrapper script should never be moved out of the build directory.
msousa@353: # If it is, it will not operate correctly.
msousa@353: 
msousa@353: # Sed substitution that helps us do robust quoting.  It backslashifies
msousa@353: # metacharacters that are still active within double-quoted strings.
msousa@353: Xsed='${SED} -e 1s/^X//'
msousa@353: sed_quote_subst='$sed_quote_subst'
msousa@353: 
msousa@353: # Be Bourne compatible
msousa@353: if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
msousa@353:   emulate sh
msousa@353:   NULLCMD=:
msousa@353:   # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
msousa@353:   # is contrary to our usage.  Disable this feature.
msousa@353:   alias -g '\${1+\"\$@\"}'='\"\$@\"'
msousa@353:   setopt NO_GLOB_SUBST
msousa@353: else
msousa@353:   case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
msousa@353: fi
msousa@353: BIN_SH=xpg4; export BIN_SH # for Tru64
msousa@353: DUALCASE=1; export DUALCASE # for MKS sh
msousa@353: 
msousa@353: # The HP-UX ksh and POSIX shell print the target directory to stdout
msousa@353: # if CDPATH is set.
msousa@353: (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
msousa@353: 
msousa@353: relink_command=\"$relink_command\"
msousa@353: 
msousa@353: # This environment variable determines our operation mode.
msousa@353: if test \"\$libtool_install_magic\" = \"$magic\"; then
msousa@353:   # install mode needs the following variables:
msousa@353:   generated_by_libtool_version='$macro_version'
msousa@353:   notinst_deplibs='$notinst_deplibs'
msousa@353: else
msousa@353:   # When we are sourced in execute mode, \$file and \$ECHO are already set.
msousa@353:   if test \"\$libtool_execute_magic\" != \"$magic\"; then
msousa@353:     ECHO=\"$qecho\"
msousa@353:     file=\"\$0\"
msousa@353:     # Make sure echo works.
msousa@353:     if test \"X\$1\" = X--no-reexec; then
msousa@353:       # Discard the --no-reexec flag, and continue.
msousa@353:       shift
msousa@353:     elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
msousa@353:       # Yippee, \$ECHO works!
msousa@353:       :
msousa@353:     else
msousa@353:       # Restart under the correct shell, and then maybe \$ECHO will work.
msousa@353:       exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
msousa@353:     fi
msousa@353:   fi\
msousa@353: "
msousa@353: 	$ECHO "\
msousa@353: 
msousa@353:   # Find the directory that this script lives in.
msousa@353:   thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
msousa@353:   test \"x\$thisdir\" = \"x\$file\" && thisdir=.
msousa@353: 
msousa@353:   # Follow symbolic links until we get to the real thisdir.
msousa@353:   file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
msousa@353:   while test -n \"\$file\"; do
msousa@353:     destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
msousa@353: 
msousa@353:     # If there was a directory component, then change thisdir.
msousa@353:     if test \"x\$destdir\" != \"x\$file\"; then
msousa@353:       case \"\$destdir\" in
msousa@353:       [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
msousa@353:       *) thisdir=\"\$thisdir/\$destdir\" ;;
msousa@353:       esac
msousa@353:     fi
msousa@353: 
msousa@353:     file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
msousa@353:     file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
msousa@353:   done
msousa@353: "
msousa@353: }
msousa@353: # end: func_emit_wrapper_part1
msousa@353: 
msousa@353: # func_emit_wrapper_part2 [arg=no]
msousa@353: #
msousa@353: # Emit the second part of a libtool wrapper script on stdout.
msousa@353: # For more information, see the description associated with
msousa@353: # func_emit_wrapper(), below.
msousa@353: func_emit_wrapper_part2 ()
msousa@353: {
msousa@353: 	func_emit_wrapper_part2_arg1=no
msousa@353: 	if test -n "$1" ; then
msousa@353: 	  func_emit_wrapper_part2_arg1=$1
msousa@353: 	fi
msousa@353: 
msousa@353: 	$ECHO "\
msousa@353: 
msousa@353:   # Usually 'no', except on cygwin/mingw when embedded into
msousa@353:   # the cwrapper.
msousa@353:   WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
msousa@353:   if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
msousa@353:     # special case for '.'
msousa@353:     if test \"\$thisdir\" = \".\"; then
msousa@353:       thisdir=\`pwd\`
msousa@353:     fi
msousa@353:     # remove .libs from thisdir
msousa@353:     case \"\$thisdir\" in
msousa@353:     *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
msousa@353:     $objdir )   thisdir=. ;;
msousa@353:     esac
msousa@353:   fi
msousa@353: 
msousa@353:   # Try to get the absolute directory name.
msousa@353:   absdir=\`cd \"\$thisdir\" && pwd\`
msousa@353:   test -n \"\$absdir\" && thisdir=\"\$absdir\"
msousa@353: "
msousa@353: 
msousa@353: 	if test "$fast_install" = yes; then
msousa@353: 	  $ECHO "\
msousa@353:   program=lt-'$outputname'$exeext
msousa@353:   progdir=\"\$thisdir/$objdir\"
msousa@353: 
msousa@353:   if test ! -f \"\$progdir/\$program\" ||
msousa@353:      { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
msousa@353:        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
msousa@353: 
msousa@353:     file=\"\$\$-\$program\"
msousa@353: 
msousa@353:     if test ! -d \"\$progdir\"; then
msousa@353:       $MKDIR \"\$progdir\"
msousa@353:     else
msousa@353:       $RM \"\$progdir/\$file\"
msousa@353:     fi"
msousa@353: 
msousa@353: 	  $ECHO "\
msousa@353: 
msousa@353:     # relink executable if necessary
msousa@353:     if test -n \"\$relink_command\"; then
msousa@353:       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
msousa@353:       else
msousa@353: 	$ECHO \"\$relink_command_output\" >&2
msousa@353: 	$RM \"\$progdir/\$file\"
msousa@353: 	exit 1
msousa@353:       fi
msousa@353:     fi
msousa@353: 
msousa@353:     $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
msousa@353:     { $RM \"\$progdir/\$program\";
msousa@353:       $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
msousa@353:     $RM \"\$progdir/\$file\"
msousa@353:   fi"
msousa@353: 	else
msousa@353: 	  $ECHO "\
msousa@353:   program='$outputname'
msousa@353:   progdir=\"\$thisdir/$objdir\"
msousa@353: "
msousa@353: 	fi
msousa@353: 
msousa@353: 	$ECHO "\
msousa@353: 
msousa@353:   if test -f \"\$progdir/\$program\"; then"
msousa@353: 
msousa@353: 	# Export our shlibpath_var if we have one.
msousa@353: 	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
msousa@353: 	  $ECHO "\
msousa@353:     # Add our own library path to $shlibpath_var
msousa@353:     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
msousa@353: 
msousa@353:     # Some systems cannot cope with colon-terminated $shlibpath_var
msousa@353:     # The second colon is a workaround for a bug in BeOS R4 sed
msousa@353:     $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
msousa@353: 
msousa@353:     export $shlibpath_var
msousa@353: "
msousa@353: 	fi
msousa@353: 
msousa@353: 	# fixup the dll searchpath if we need to.
msousa@353: 	if test -n "$dllsearchpath"; then
msousa@353: 	  $ECHO "\
msousa@353:     # Add the dll search path components to the executable PATH
msousa@353:     PATH=$dllsearchpath:\$PATH
msousa@353: "
msousa@353: 	fi
msousa@353: 
msousa@353: 	$ECHO "\
msousa@353:     if test \"\$libtool_execute_magic\" != \"$magic\"; then
msousa@353:       # Run the actual program with our arguments.
msousa@353: "
msousa@353: 	case $host in
msousa@353: 	# Backslashes separate directories on plain windows
msousa@353: 	*-*-mingw | *-*-os2* | *-cegcc*)
msousa@353: 	  $ECHO "\
msousa@353:       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
msousa@353: "
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	*)
msousa@353: 	  $ECHO "\
msousa@353:       exec \"\$progdir/\$program\" \${1+\"\$@\"}
msousa@353: "
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	$ECHO "\
msousa@353:       \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
msousa@353:       exit 1
msousa@353:     fi
msousa@353:   else
msousa@353:     # The program doesn't exist.
msousa@353:     \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
msousa@353:     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
msousa@353:     $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
msousa@353:     exit 1
msousa@353:   fi
msousa@353: fi\
msousa@353: "
msousa@353: }
msousa@353: # end: func_emit_wrapper_part2
msousa@353: 
msousa@353: 
msousa@353: # func_emit_wrapper [arg=no]
msousa@353: #
msousa@353: # Emit a libtool wrapper script on stdout.
msousa@353: # Don't directly open a file because we may want to
msousa@353: # incorporate the script contents within a cygwin/mingw
msousa@353: # wrapper executable.  Must ONLY be called from within
msousa@353: # func_mode_link because it depends on a number of variables
msousa@353: # set therein.
msousa@353: #
msousa@353: # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
msousa@353: # variable will take.  If 'yes', then the emitted script
msousa@353: # will assume that the directory in which it is stored is
msousa@353: # the $objdir directory.  This is a cygwin/mingw-specific
msousa@353: # behavior.
msousa@353: func_emit_wrapper ()
msousa@353: {
msousa@353: 	func_emit_wrapper_arg1=no
msousa@353: 	if test -n "$1" ; then
msousa@353: 	  func_emit_wrapper_arg1=$1
msousa@353: 	fi
msousa@353: 
msousa@353: 	# split this up so that func_emit_cwrapperexe_src
msousa@353: 	# can call each part independently.
msousa@353: 	func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
msousa@353: 	func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: # func_to_host_path arg
msousa@353: #
msousa@353: # Convert paths to host format when used with build tools.
msousa@353: # Intended for use with "native" mingw (where libtool itself
msousa@353: # is running under the msys shell), or in the following cross-
msousa@353: # build environments:
msousa@353: #    $build          $host
msousa@353: #    mingw (msys)    mingw  [e.g. native]
msousa@353: #    cygwin          mingw
msousa@353: #    *nix + wine     mingw
msousa@353: # where wine is equipped with the `winepath' executable.
msousa@353: # In the native mingw case, the (msys) shell automatically
msousa@353: # converts paths for any non-msys applications it launches,
msousa@353: # but that facility isn't available from inside the cwrapper.
msousa@353: # Similar accommodations are necessary for $host mingw and
msousa@353: # $build cygwin.  Calling this function does no harm for other
msousa@353: # $host/$build combinations not listed above.
msousa@353: #
msousa@353: # ARG is the path (on $build) that should be converted to
msousa@353: # the proper representation for $host. The result is stored
msousa@353: # in $func_to_host_path_result.
msousa@353: func_to_host_path ()
msousa@353: {
msousa@353:   func_to_host_path_result="$1"
msousa@353:   if test -n "$1" ; then
msousa@353:     case $host in
msousa@353:       *mingw* )
msousa@353:         lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
msousa@353:         case $build in
msousa@353:           *mingw* ) # actually, msys
msousa@353:             # awkward: cmd appends spaces to result
msousa@353:             lt_sed_strip_trailing_spaces="s/[ ]*\$//"
msousa@353:             func_to_host_path_tmp1=`( cmd //c echo "$1" |\
msousa@353:               $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
msousa@353:             func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
msousa@353:               $SED -e "$lt_sed_naive_backslashify"`
msousa@353:             ;;
msousa@353:           *cygwin* )
msousa@353:             func_to_host_path_tmp1=`cygpath -w "$1"`
msousa@353:             func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
msousa@353:               $SED -e "$lt_sed_naive_backslashify"`
msousa@353:             ;;
msousa@353:           * )
msousa@353:             # Unfortunately, winepath does not exit with a non-zero
msousa@353:             # error code, so we are forced to check the contents of
msousa@353:             # stdout. On the other hand, if the command is not
msousa@353:             # found, the shell will set an exit code of 127 and print
msousa@353:             # *an error message* to stdout. So we must check for both
msousa@353:             # error code of zero AND non-empty stdout, which explains
msousa@353:             # the odd construction:
msousa@353:             func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
msousa@353:             if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
msousa@353:               func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
msousa@353:                 $SED -e "$lt_sed_naive_backslashify"`
msousa@353:             else
msousa@353:               # Allow warning below.
msousa@353:               func_to_host_path_result=""
msousa@353:             fi
msousa@353:             ;;
msousa@353:         esac
msousa@353:         if test -z "$func_to_host_path_result" ; then
msousa@353:           func_error "Could not determine host path corresponding to"
msousa@353:           func_error "  '$1'"
msousa@353:           func_error "Continuing, but uninstalled executables may not work."
msousa@353:           # Fallback:
msousa@353:           func_to_host_path_result="$1"
msousa@353:         fi
msousa@353:         ;;
msousa@353:     esac
msousa@353:   fi
msousa@353: }
msousa@353: # end: func_to_host_path
msousa@353: 
msousa@353: # func_to_host_pathlist arg
msousa@353: #
msousa@353: # Convert pathlists to host format when used with build tools.
msousa@353: # See func_to_host_path(), above. This function supports the
msousa@353: # following $build/$host combinations (but does no harm for
msousa@353: # combinations not listed here):
msousa@353: #    $build          $host
msousa@353: #    mingw (msys)    mingw  [e.g. native]
msousa@353: #    cygwin          mingw
msousa@353: #    *nix + wine     mingw
msousa@353: #
msousa@353: # Path separators are also converted from $build format to
msousa@353: # $host format. If ARG begins or ends with a path separator
msousa@353: # character, it is preserved (but converted to $host format)
msousa@353: # on output.
msousa@353: #
msousa@353: # ARG is a pathlist (on $build) that should be converted to
msousa@353: # the proper representation on $host. The result is stored
msousa@353: # in $func_to_host_pathlist_result.
msousa@353: func_to_host_pathlist ()
msousa@353: {
msousa@353:   func_to_host_pathlist_result="$1"
msousa@353:   if test -n "$1" ; then
msousa@353:     case $host in
msousa@353:       *mingw* )
msousa@353:         lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
msousa@353:         # Remove leading and trailing path separator characters from
msousa@353:         # ARG. msys behavior is inconsistent here, cygpath turns them
msousa@353:         # into '.;' and ';.', and winepath ignores them completely.
msousa@353:         func_to_host_pathlist_tmp2="$1"
msousa@353:         # Once set for this call, this variable should not be
msousa@353:         # reassigned. It is used in tha fallback case.
msousa@353:         func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
msousa@353:           $SED -e 's|^:*||' -e 's|:*$||'`
msousa@353:         case $build in
msousa@353:           *mingw* ) # Actually, msys.
msousa@353:             # Awkward: cmd appends spaces to result.
msousa@353:             lt_sed_strip_trailing_spaces="s/[ ]*\$//"
msousa@353:             func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
msousa@353:               $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
msousa@353:             func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
msousa@353:               $SED -e "$lt_sed_naive_backslashify"`
msousa@353:             ;;
msousa@353:           *cygwin* )
msousa@353:             func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
msousa@353:             func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
msousa@353:               $SED -e "$lt_sed_naive_backslashify"`
msousa@353:             ;;
msousa@353:           * )
msousa@353:             # unfortunately, winepath doesn't convert pathlists
msousa@353:             func_to_host_pathlist_result=""
msousa@353:             func_to_host_pathlist_oldIFS=$IFS
msousa@353:             IFS=:
msousa@353:             for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
msousa@353:               IFS=$func_to_host_pathlist_oldIFS
msousa@353:               if test -n "$func_to_host_pathlist_f" ; then
msousa@353:                 func_to_host_path "$func_to_host_pathlist_f"
msousa@353:                 if test -n "$func_to_host_path_result" ; then
msousa@353:                   if test -z "$func_to_host_pathlist_result" ; then
msousa@353:                     func_to_host_pathlist_result="$func_to_host_path_result"
msousa@353:                   else
msousa@353:                     func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
msousa@353:                   fi
msousa@353:                 fi
msousa@353:               fi
msousa@353:               IFS=:
msousa@353:             done
msousa@353:             IFS=$func_to_host_pathlist_oldIFS
msousa@353:             ;;
msousa@353:         esac
msousa@353:         if test -z "$func_to_host_pathlist_result" ; then
msousa@353:           func_error "Could not determine the host path(s) corresponding to"
msousa@353:           func_error "  '$1'"
msousa@353:           func_error "Continuing, but uninstalled executables may not work."
msousa@353:           # Fallback. This may break if $1 contains DOS-style drive
msousa@353:           # specifications. The fix is not to complicate the expression
msousa@353:           # below, but for the user to provide a working wine installation
msousa@353:           # with winepath so that path translation in the cross-to-mingw
msousa@353:           # case works properly.
msousa@353:           lt_replace_pathsep_nix_to_dos="s|:|;|g"
msousa@353:           func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
msousa@353:             $SED -e "$lt_replace_pathsep_nix_to_dos"`
msousa@353:         fi
msousa@353:         # Now, add the leading and trailing path separators back
msousa@353:         case "$1" in
msousa@353:           :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
msousa@353:             ;;
msousa@353:         esac
msousa@353:         case "$1" in
msousa@353:           *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
msousa@353:             ;;
msousa@353:         esac
msousa@353:         ;;
msousa@353:     esac
msousa@353:   fi
msousa@353: }
msousa@353: # end: func_to_host_pathlist
msousa@353: 
msousa@353: # func_emit_cwrapperexe_src
msousa@353: # emit the source code for a wrapper executable on stdout
msousa@353: # Must ONLY be called from within func_mode_link because
msousa@353: # it depends on a number of variable set therein.
msousa@353: func_emit_cwrapperexe_src ()
msousa@353: {
msousa@353: 	cat <<EOF
msousa@353: 
msousa@353: /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
msousa@353:    Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
msousa@353: 
msousa@353:    The $output program cannot be directly executed until all the libtool
msousa@353:    libraries that it depends on are installed.
msousa@353: 
msousa@353:    This wrapper executable should never be moved out of the build directory.
msousa@353:    If it is, it will not operate correctly.
msousa@353: 
msousa@353:    Currently, it simply execs the wrapper *script* "$SHELL $output",
msousa@353:    but could eventually absorb all of the scripts functionality and
msousa@353:    exec $objdir/$outputname directly.
msousa@353: */
msousa@353: EOF
msousa@353: 	    cat <<"EOF"
msousa@353: #include <stdio.h>
msousa@353: #include <stdlib.h>
msousa@353: #ifdef _MSC_VER
msousa@353: # include <direct.h>
msousa@353: # include <process.h>
msousa@353: # include <io.h>
msousa@353: # define setmode _setmode
msousa@353: #else
msousa@353: # include <unistd.h>
msousa@353: # include <stdint.h>
msousa@353: # ifdef __CYGWIN__
msousa@353: #  include <io.h>
msousa@353: #  define HAVE_SETENV
msousa@353: #  ifdef __STRICT_ANSI__
msousa@353: char *realpath (const char *, char *);
msousa@353: int putenv (char *);
msousa@353: int setenv (const char *, const char *, int);
msousa@353: #  endif
msousa@353: # endif
msousa@353: #endif
msousa@353: #include <malloc.h>
msousa@353: #include <stdarg.h>
msousa@353: #include <assert.h>
msousa@353: #include <string.h>
msousa@353: #include <ctype.h>
msousa@353: #include <errno.h>
msousa@353: #include <fcntl.h>
msousa@353: #include <sys/stat.h>
msousa@353: 
msousa@353: #if defined(PATH_MAX)
msousa@353: # define LT_PATHMAX PATH_MAX
msousa@353: #elif defined(MAXPATHLEN)
msousa@353: # define LT_PATHMAX MAXPATHLEN
msousa@353: #else
msousa@353: # define LT_PATHMAX 1024
msousa@353: #endif
msousa@353: 
msousa@353: #ifndef S_IXOTH
msousa@353: # define S_IXOTH 0
msousa@353: #endif
msousa@353: #ifndef S_IXGRP
msousa@353: # define S_IXGRP 0
msousa@353: #endif
msousa@353: 
msousa@353: #ifdef _MSC_VER
msousa@353: # define S_IXUSR _S_IEXEC
msousa@353: # define stat _stat
msousa@353: # ifndef _INTPTR_T_DEFINED
msousa@353: #  define intptr_t int
msousa@353: # endif
msousa@353: #endif
msousa@353: 
msousa@353: #ifndef DIR_SEPARATOR
msousa@353: # define DIR_SEPARATOR '/'
msousa@353: # define PATH_SEPARATOR ':'
msousa@353: #endif
msousa@353: 
msousa@353: #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
msousa@353:   defined (__OS2__)
msousa@353: # define HAVE_DOS_BASED_FILE_SYSTEM
msousa@353: # define FOPEN_WB "wb"
msousa@353: # ifndef DIR_SEPARATOR_2
msousa@353: #  define DIR_SEPARATOR_2 '\\'
msousa@353: # endif
msousa@353: # ifndef PATH_SEPARATOR_2
msousa@353: #  define PATH_SEPARATOR_2 ';'
msousa@353: # endif
msousa@353: #endif
msousa@353: 
msousa@353: #ifndef DIR_SEPARATOR_2
msousa@353: # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
msousa@353: #else /* DIR_SEPARATOR_2 */
msousa@353: # define IS_DIR_SEPARATOR(ch) \
msousa@353: 	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
msousa@353: #endif /* DIR_SEPARATOR_2 */
msousa@353: 
msousa@353: #ifndef PATH_SEPARATOR_2
msousa@353: # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
msousa@353: #else /* PATH_SEPARATOR_2 */
msousa@353: # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
msousa@353: #endif /* PATH_SEPARATOR_2 */
msousa@353: 
msousa@353: #ifdef __CYGWIN__
msousa@353: # define FOPEN_WB "wb"
msousa@353: #endif
msousa@353: 
msousa@353: #ifndef FOPEN_WB
msousa@353: # define FOPEN_WB "w"
msousa@353: #endif
msousa@353: #ifndef _O_BINARY
msousa@353: # define _O_BINARY 0
msousa@353: #endif
msousa@353: 
msousa@353: #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
msousa@353: #define XFREE(stale) do { \
msousa@353:   if (stale) { free ((void *) stale); stale = 0; } \
msousa@353: } while (0)
msousa@353: 
msousa@353: #undef LTWRAPPER_DEBUGPRINTF
msousa@353: #if defined DEBUGWRAPPER
msousa@353: # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
msousa@353: static void
msousa@353: ltwrapper_debugprintf (const char *fmt, ...)
msousa@353: {
msousa@353:     va_list args;
msousa@353:     va_start (args, fmt);
msousa@353:     (void) vfprintf (stderr, fmt, args);
msousa@353:     va_end (args);
msousa@353: }
msousa@353: #else
msousa@353: # define LTWRAPPER_DEBUGPRINTF(args)
msousa@353: #endif
msousa@353: 
msousa@353: const char *program_name = NULL;
msousa@353: 
msousa@353: void *xmalloc (size_t num);
msousa@353: char *xstrdup (const char *string);
msousa@353: const char *base_name (const char *name);
msousa@353: char *find_executable (const char *wrapper);
msousa@353: char *chase_symlinks (const char *pathspec);
msousa@353: int make_executable (const char *path);
msousa@353: int check_executable (const char *path);
msousa@353: char *strendzap (char *str, const char *pat);
msousa@353: void lt_fatal (const char *message, ...);
msousa@353: void lt_setenv (const char *name, const char *value);
msousa@353: char *lt_extend_str (const char *orig_value, const char *add, int to_end);
msousa@353: void lt_opt_process_env_set (const char *arg);
msousa@353: void lt_opt_process_env_prepend (const char *arg);
msousa@353: void lt_opt_process_env_append (const char *arg);
msousa@353: int lt_split_name_value (const char *arg, char** name, char** value);
msousa@353: void lt_update_exe_path (const char *name, const char *value);
msousa@353: void lt_update_lib_path (const char *name, const char *value);
msousa@353: 
msousa@353: static const char *script_text_part1 =
msousa@353: EOF
msousa@353: 
msousa@353: 	    func_emit_wrapper_part1 yes |
msousa@353: 	        $SED -e 's/\([\\"]\)/\\\1/g' \
msousa@353: 	             -e 's/^/  "/' -e 's/$/\\n"/'
msousa@353: 	    echo ";"
msousa@353: 	    cat <<EOF
msousa@353: 
msousa@353: static const char *script_text_part2 =
msousa@353: EOF
msousa@353: 	    func_emit_wrapper_part2 yes |
msousa@353: 	        $SED -e 's/\([\\"]\)/\\\1/g' \
msousa@353: 	             -e 's/^/  "/' -e 's/$/\\n"/'
msousa@353: 	    echo ";"
msousa@353: 
msousa@353: 	    cat <<EOF
msousa@353: const char * MAGIC_EXE = "$magic_exe";
msousa@353: const char * LIB_PATH_VARNAME = "$shlibpath_var";
msousa@353: EOF
msousa@353: 
msousa@353: 	    if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
msousa@353:               func_to_host_pathlist "$temp_rpath"
msousa@353: 	      cat <<EOF
msousa@353: const char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
msousa@353: EOF
msousa@353: 	    else
msousa@353: 	      cat <<"EOF"
msousa@353: const char * LIB_PATH_VALUE   = "";
msousa@353: EOF
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    if test -n "$dllsearchpath"; then
msousa@353:               func_to_host_pathlist "$dllsearchpath:"
msousa@353: 	      cat <<EOF
msousa@353: const char * EXE_PATH_VARNAME = "PATH";
msousa@353: const char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
msousa@353: EOF
msousa@353: 	    else
msousa@353: 	      cat <<"EOF"
msousa@353: const char * EXE_PATH_VARNAME = "";
msousa@353: const char * EXE_PATH_VALUE   = "";
msousa@353: EOF
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    if test "$fast_install" = yes; then
msousa@353: 	      cat <<EOF
msousa@353: const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
msousa@353: EOF
msousa@353: 	    else
msousa@353: 	      cat <<EOF
msousa@353: const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
msousa@353: EOF
msousa@353: 	    fi
msousa@353: 
msousa@353: 
msousa@353: 	    cat <<"EOF"
msousa@353: 
msousa@353: #define LTWRAPPER_OPTION_PREFIX         "--lt-"
msousa@353: #define LTWRAPPER_OPTION_PREFIX_LENGTH  5
msousa@353: 
msousa@353: static const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
msousa@353: static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
msousa@353: 
msousa@353: static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
msousa@353: 
msousa@353: static const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
msousa@353: static const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
msousa@353:   /* argument is putenv-style "foo=bar", value of foo is set to bar */
msousa@353: 
msousa@353: static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
msousa@353: static const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
msousa@353:   /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
msousa@353: 
msousa@353: static const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
msousa@353: static const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
msousa@353:   /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
msousa@353: 
msousa@353: int
msousa@353: main (int argc, char *argv[])
msousa@353: {
msousa@353:   char **newargz;
msousa@353:   int  newargc;
msousa@353:   char *tmp_pathspec;
msousa@353:   char *actual_cwrapper_path;
msousa@353:   char *actual_cwrapper_name;
msousa@353:   char *target_name;
msousa@353:   char *lt_argv_zero;
msousa@353:   intptr_t rval = 127;
msousa@353: 
msousa@353:   int i;
msousa@353: 
msousa@353:   program_name = (char *) xstrdup (base_name (argv[0]));
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
msousa@353: 
msousa@353:   /* very simple arg parsing; don't want to rely on getopt */
msousa@353:   for (i = 1; i < argc; i++)
msousa@353:     {
msousa@353:       if (strcmp (argv[i], dumpscript_opt) == 0)
msousa@353: 	{
msousa@353: EOF
msousa@353: 	    case "$host" in
msousa@353: 	      *mingw* | *cygwin* )
msousa@353: 		# make stdout use "unix" line endings
msousa@353: 		echo "          setmode(1,_O_BINARY);"
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 
msousa@353: 	    cat <<"EOF"
msousa@353: 	  printf ("%s", script_text_part1);
msousa@353: 	  printf ("%s", script_text_part2);
msousa@353: 	  return 0;
msousa@353: 	}
msousa@353:     }
msousa@353: 
msousa@353:   newargz = XMALLOC (char *, argc + 1);
msousa@353:   tmp_pathspec = find_executable (argv[0]);
msousa@353:   if (tmp_pathspec == NULL)
msousa@353:     lt_fatal ("Couldn't find %s", argv[0]);
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
msousa@353: 			  tmp_pathspec));
msousa@353: 
msousa@353:   actual_cwrapper_path = chase_symlinks (tmp_pathspec);
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
msousa@353: 			  actual_cwrapper_path));
msousa@353:   XFREE (tmp_pathspec);
msousa@353: 
msousa@353:   actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
msousa@353:   strendzap (actual_cwrapper_path, actual_cwrapper_name);
msousa@353: 
msousa@353:   /* wrapper name transforms */
msousa@353:   strendzap (actual_cwrapper_name, ".exe");
msousa@353:   tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
msousa@353:   XFREE (actual_cwrapper_name);
msousa@353:   actual_cwrapper_name = tmp_pathspec;
msousa@353:   tmp_pathspec = 0;
msousa@353: 
msousa@353:   /* target_name transforms -- use actual target program name; might have lt- prefix */
msousa@353:   target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
msousa@353:   strendzap (target_name, ".exe");
msousa@353:   tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
msousa@353:   XFREE (target_name);
msousa@353:   target_name = tmp_pathspec;
msousa@353:   tmp_pathspec = 0;
msousa@353: 
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
msousa@353: 			  target_name));
msousa@353: EOF
msousa@353: 
msousa@353: 	    cat <<EOF
msousa@353:   newargz[0] =
msousa@353:     XMALLOC (char, (strlen (actual_cwrapper_path) +
msousa@353: 		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
msousa@353:   strcpy (newargz[0], actual_cwrapper_path);
msousa@353:   strcat (newargz[0], "$objdir");
msousa@353:   strcat (newargz[0], "/");
msousa@353: EOF
msousa@353: 
msousa@353: 	    cat <<"EOF"
msousa@353:   /* stop here, and copy so we don't have to do this twice */
msousa@353:   tmp_pathspec = xstrdup (newargz[0]);
msousa@353: 
msousa@353:   /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
msousa@353:   strcat (newargz[0], actual_cwrapper_name);
msousa@353: 
msousa@353:   /* DO want the lt- prefix here if it exists, so use target_name */
msousa@353:   lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
msousa@353:   XFREE (tmp_pathspec);
msousa@353:   tmp_pathspec = NULL;
msousa@353: EOF
msousa@353: 
msousa@353: 	    case $host_os in
msousa@353: 	      mingw*)
msousa@353: 	    cat <<"EOF"
msousa@353:   {
msousa@353:     char* p;
msousa@353:     while ((p = strchr (newargz[0], '\\')) != NULL)
msousa@353:       {
msousa@353: 	*p = '/';
msousa@353:       }
msousa@353:     while ((p = strchr (lt_argv_zero, '\\')) != NULL)
msousa@353:       {
msousa@353: 	*p = '/';
msousa@353:       }
msousa@353:   }
msousa@353: EOF
msousa@353: 	    ;;
msousa@353: 	    esac
msousa@353: 
msousa@353: 	    cat <<"EOF"
msousa@353:   XFREE (target_name);
msousa@353:   XFREE (actual_cwrapper_path);
msousa@353:   XFREE (actual_cwrapper_name);
msousa@353: 
msousa@353:   lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
msousa@353:   lt_setenv ("DUALCASE", "1");  /* for MSK sh */
msousa@353:   lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
msousa@353:   lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
msousa@353: 
msousa@353:   newargc=0;
msousa@353:   for (i = 1; i < argc; i++)
msousa@353:     {
msousa@353:       if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
msousa@353:         {
msousa@353:           if (argv[i][env_set_opt_len] == '=')
msousa@353:             {
msousa@353:               const char *p = argv[i] + env_set_opt_len + 1;
msousa@353:               lt_opt_process_env_set (p);
msousa@353:             }
msousa@353:           else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
msousa@353:             {
msousa@353:               lt_opt_process_env_set (argv[++i]); /* don't copy */
msousa@353:             }
msousa@353:           else
msousa@353:             lt_fatal ("%s missing required argument", env_set_opt);
msousa@353:           continue;
msousa@353:         }
msousa@353:       if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
msousa@353:         {
msousa@353:           if (argv[i][env_prepend_opt_len] == '=')
msousa@353:             {
msousa@353:               const char *p = argv[i] + env_prepend_opt_len + 1;
msousa@353:               lt_opt_process_env_prepend (p);
msousa@353:             }
msousa@353:           else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
msousa@353:             {
msousa@353:               lt_opt_process_env_prepend (argv[++i]); /* don't copy */
msousa@353:             }
msousa@353:           else
msousa@353:             lt_fatal ("%s missing required argument", env_prepend_opt);
msousa@353:           continue;
msousa@353:         }
msousa@353:       if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
msousa@353:         {
msousa@353:           if (argv[i][env_append_opt_len] == '=')
msousa@353:             {
msousa@353:               const char *p = argv[i] + env_append_opt_len + 1;
msousa@353:               lt_opt_process_env_append (p);
msousa@353:             }
msousa@353:           else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
msousa@353:             {
msousa@353:               lt_opt_process_env_append (argv[++i]); /* don't copy */
msousa@353:             }
msousa@353:           else
msousa@353:             lt_fatal ("%s missing required argument", env_append_opt);
msousa@353:           continue;
msousa@353:         }
msousa@353:       if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
msousa@353:         {
msousa@353:           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
msousa@353:              namespace, but it is not one of the ones we know about and
msousa@353:              have already dealt with, above (inluding dump-script), then
msousa@353:              report an error. Otherwise, targets might begin to believe
msousa@353:              they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
msousa@353:              namespace. The first time any user complains about this, we'll
msousa@353:              need to make LTWRAPPER_OPTION_PREFIX a configure-time option
msousa@353:              or a configure.ac-settable value.
msousa@353:            */
msousa@353:           lt_fatal ("Unrecognized option in %s namespace: '%s'",
msousa@353:                     ltwrapper_option_prefix, argv[i]);
msousa@353:         }
msousa@353:       /* otherwise ... */
msousa@353:       newargz[++newargc] = xstrdup (argv[i]);
msousa@353:     }
msousa@353:   newargz[++newargc] = NULL;
msousa@353: 
msousa@353:   LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
msousa@353:   for (i = 0; i < newargc; i++)
msousa@353:     {
msousa@353:       LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
msousa@353:     }
msousa@353: 
msousa@353: EOF
msousa@353: 
msousa@353: 	    case $host_os in
msousa@353: 	      mingw*)
msousa@353: 		cat <<"EOF"
msousa@353:   /* execv doesn't actually work on mingw as expected on unix */
msousa@353:   rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
msousa@353:   if (rval == -1)
msousa@353:     {
msousa@353:       /* failed to start process */
msousa@353:       LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
msousa@353:       return 127;
msousa@353:     }
msousa@353:   return rval;
msousa@353: EOF
msousa@353: 		;;
msousa@353: 	      *)
msousa@353: 		cat <<"EOF"
msousa@353:   execv (lt_argv_zero, newargz);
msousa@353:   return rval; /* =127, but avoids unused variable warning */
msousa@353: EOF
msousa@353: 		;;
msousa@353: 	    esac
msousa@353: 
msousa@353: 	    cat <<"EOF"
msousa@353: }
msousa@353: 
msousa@353: void *
msousa@353: xmalloc (size_t num)
msousa@353: {
msousa@353:   void *p = (void *) malloc (num);
msousa@353:   if (!p)
msousa@353:     lt_fatal ("Memory exhausted");
msousa@353: 
msousa@353:   return p;
msousa@353: }
msousa@353: 
msousa@353: char *
msousa@353: xstrdup (const char *string)
msousa@353: {
msousa@353:   return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
msousa@353: 			  string) : NULL;
msousa@353: }
msousa@353: 
msousa@353: const char *
msousa@353: base_name (const char *name)
msousa@353: {
msousa@353:   const char *base;
msousa@353: 
msousa@353: #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
msousa@353:   /* Skip over the disk name in MSDOS pathnames. */
msousa@353:   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
msousa@353:     name += 2;
msousa@353: #endif
msousa@353: 
msousa@353:   for (base = name; *name; name++)
msousa@353:     if (IS_DIR_SEPARATOR (*name))
msousa@353:       base = name + 1;
msousa@353:   return base;
msousa@353: }
msousa@353: 
msousa@353: int
msousa@353: check_executable (const char *path)
msousa@353: {
msousa@353:   struct stat st;
msousa@353: 
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
msousa@353: 			  path ? (*path ? path : "EMPTY!") : "NULL!"));
msousa@353:   if ((!path) || (!*path))
msousa@353:     return 0;
msousa@353: 
msousa@353:   if ((stat (path, &st) >= 0)
msousa@353:       && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
msousa@353:     return 1;
msousa@353:   else
msousa@353:     return 0;
msousa@353: }
msousa@353: 
msousa@353: int
msousa@353: make_executable (const char *path)
msousa@353: {
msousa@353:   int rval = 0;
msousa@353:   struct stat st;
msousa@353: 
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
msousa@353: 			  path ? (*path ? path : "EMPTY!") : "NULL!"));
msousa@353:   if ((!path) || (!*path))
msousa@353:     return 0;
msousa@353: 
msousa@353:   if (stat (path, &st) >= 0)
msousa@353:     {
msousa@353:       rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
msousa@353:     }
msousa@353:   return rval;
msousa@353: }
msousa@353: 
msousa@353: /* Searches for the full path of the wrapper.  Returns
msousa@353:    newly allocated full path name if found, NULL otherwise
msousa@353:    Does not chase symlinks, even on platforms that support them.
msousa@353: */
msousa@353: char *
msousa@353: find_executable (const char *wrapper)
msousa@353: {
msousa@353:   int has_slash = 0;
msousa@353:   const char *p;
msousa@353:   const char *p_next;
msousa@353:   /* static buffer for getcwd */
msousa@353:   char tmp[LT_PATHMAX + 1];
msousa@353:   int tmp_len;
msousa@353:   char *concat_name;
msousa@353: 
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
msousa@353: 			  wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
msousa@353: 
msousa@353:   if ((wrapper == NULL) || (*wrapper == '\0'))
msousa@353:     return NULL;
msousa@353: 
msousa@353:   /* Absolute path? */
msousa@353: #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
msousa@353:   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
msousa@353:     {
msousa@353:       concat_name = xstrdup (wrapper);
msousa@353:       if (check_executable (concat_name))
msousa@353: 	return concat_name;
msousa@353:       XFREE (concat_name);
msousa@353:     }
msousa@353:   else
msousa@353:     {
msousa@353: #endif
msousa@353:       if (IS_DIR_SEPARATOR (wrapper[0]))
msousa@353: 	{
msousa@353: 	  concat_name = xstrdup (wrapper);
msousa@353: 	  if (check_executable (concat_name))
msousa@353: 	    return concat_name;
msousa@353: 	  XFREE (concat_name);
msousa@353: 	}
msousa@353: #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
msousa@353:     }
msousa@353: #endif
msousa@353: 
msousa@353:   for (p = wrapper; *p; p++)
msousa@353:     if (*p == '/')
msousa@353:       {
msousa@353: 	has_slash = 1;
msousa@353: 	break;
msousa@353:       }
msousa@353:   if (!has_slash)
msousa@353:     {
msousa@353:       /* no slashes; search PATH */
msousa@353:       const char *path = getenv ("PATH");
msousa@353:       if (path != NULL)
msousa@353: 	{
msousa@353: 	  for (p = path; *p; p = p_next)
msousa@353: 	    {
msousa@353: 	      const char *q;
msousa@353: 	      size_t p_len;
msousa@353: 	      for (q = p; *q; q++)
msousa@353: 		if (IS_PATH_SEPARATOR (*q))
msousa@353: 		  break;
msousa@353: 	      p_len = q - p;
msousa@353: 	      p_next = (*q == '\0' ? q : q + 1);
msousa@353: 	      if (p_len == 0)
msousa@353: 		{
msousa@353: 		  /* empty path: current directory */
msousa@353: 		  if (getcwd (tmp, LT_PATHMAX) == NULL)
msousa@353: 		    lt_fatal ("getcwd failed");
msousa@353: 		  tmp_len = strlen (tmp);
msousa@353: 		  concat_name =
msousa@353: 		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
msousa@353: 		  memcpy (concat_name, tmp, tmp_len);
msousa@353: 		  concat_name[tmp_len] = '/';
msousa@353: 		  strcpy (concat_name + tmp_len + 1, wrapper);
msousa@353: 		}
msousa@353: 	      else
msousa@353: 		{
msousa@353: 		  concat_name =
msousa@353: 		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
msousa@353: 		  memcpy (concat_name, p, p_len);
msousa@353: 		  concat_name[p_len] = '/';
msousa@353: 		  strcpy (concat_name + p_len + 1, wrapper);
msousa@353: 		}
msousa@353: 	      if (check_executable (concat_name))
msousa@353: 		return concat_name;
msousa@353: 	      XFREE (concat_name);
msousa@353: 	    }
msousa@353: 	}
msousa@353:       /* not found in PATH; assume curdir */
msousa@353:     }
msousa@353:   /* Relative path | not found in path: prepend cwd */
msousa@353:   if (getcwd (tmp, LT_PATHMAX) == NULL)
msousa@353:     lt_fatal ("getcwd failed");
msousa@353:   tmp_len = strlen (tmp);
msousa@353:   concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
msousa@353:   memcpy (concat_name, tmp, tmp_len);
msousa@353:   concat_name[tmp_len] = '/';
msousa@353:   strcpy (concat_name + tmp_len + 1, wrapper);
msousa@353: 
msousa@353:   if (check_executable (concat_name))
msousa@353:     return concat_name;
msousa@353:   XFREE (concat_name);
msousa@353:   return NULL;
msousa@353: }
msousa@353: 
msousa@353: char *
msousa@353: chase_symlinks (const char *pathspec)
msousa@353: {
msousa@353: #ifndef S_ISLNK
msousa@353:   return xstrdup (pathspec);
msousa@353: #else
msousa@353:   char buf[LT_PATHMAX];
msousa@353:   struct stat s;
msousa@353:   char *tmp_pathspec = xstrdup (pathspec);
msousa@353:   char *p;
msousa@353:   int has_symlinks = 0;
msousa@353:   while (strlen (tmp_pathspec) && !has_symlinks)
msousa@353:     {
msousa@353:       LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
msousa@353: 			      tmp_pathspec));
msousa@353:       if (lstat (tmp_pathspec, &s) == 0)
msousa@353: 	{
msousa@353: 	  if (S_ISLNK (s.st_mode) != 0)
msousa@353: 	    {
msousa@353: 	      has_symlinks = 1;
msousa@353: 	      break;
msousa@353: 	    }
msousa@353: 
msousa@353: 	  /* search backwards for last DIR_SEPARATOR */
msousa@353: 	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
msousa@353: 	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
msousa@353: 	    p--;
msousa@353: 	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
msousa@353: 	    {
msousa@353: 	      /* no more DIR_SEPARATORS left */
msousa@353: 	      break;
msousa@353: 	    }
msousa@353: 	  *p = '\0';
msousa@353: 	}
msousa@353:       else
msousa@353: 	{
msousa@353: 	  char *errstr = strerror (errno);
msousa@353: 	  lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
msousa@353: 	}
msousa@353:     }
msousa@353:   XFREE (tmp_pathspec);
msousa@353: 
msousa@353:   if (!has_symlinks)
msousa@353:     {
msousa@353:       return xstrdup (pathspec);
msousa@353:     }
msousa@353: 
msousa@353:   tmp_pathspec = realpath (pathspec, buf);
msousa@353:   if (tmp_pathspec == 0)
msousa@353:     {
msousa@353:       lt_fatal ("Could not follow symlinks for %s", pathspec);
msousa@353:     }
msousa@353:   return xstrdup (tmp_pathspec);
msousa@353: #endif
msousa@353: }
msousa@353: 
msousa@353: char *
msousa@353: strendzap (char *str, const char *pat)
msousa@353: {
msousa@353:   size_t len, patlen;
msousa@353: 
msousa@353:   assert (str != NULL);
msousa@353:   assert (pat != NULL);
msousa@353: 
msousa@353:   len = strlen (str);
msousa@353:   patlen = strlen (pat);
msousa@353: 
msousa@353:   if (patlen <= len)
msousa@353:     {
msousa@353:       str += len - patlen;
msousa@353:       if (strcmp (str, pat) == 0)
msousa@353: 	*str = '\0';
msousa@353:     }
msousa@353:   return str;
msousa@353: }
msousa@353: 
msousa@353: static void
msousa@353: lt_error_core (int exit_status, const char *mode,
msousa@353: 	       const char *message, va_list ap)
msousa@353: {
msousa@353:   fprintf (stderr, "%s: %s: ", program_name, mode);
msousa@353:   vfprintf (stderr, message, ap);
msousa@353:   fprintf (stderr, ".\n");
msousa@353: 
msousa@353:   if (exit_status >= 0)
msousa@353:     exit (exit_status);
msousa@353: }
msousa@353: 
msousa@353: void
msousa@353: lt_fatal (const char *message, ...)
msousa@353: {
msousa@353:   va_list ap;
msousa@353:   va_start (ap, message);
msousa@353:   lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
msousa@353:   va_end (ap);
msousa@353: }
msousa@353: 
msousa@353: void
msousa@353: lt_setenv (const char *name, const char *value)
msousa@353: {
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
msousa@353:                           (name ? name : "<NULL>"),
msousa@353:                           (value ? value : "<NULL>")));
msousa@353:   {
msousa@353: #ifdef HAVE_SETENV
msousa@353:     /* always make a copy, for consistency with !HAVE_SETENV */
msousa@353:     char *str = xstrdup (value);
msousa@353:     setenv (name, str, 1);
msousa@353: #else
msousa@353:     int len = strlen (name) + 1 + strlen (value) + 1;
msousa@353:     char *str = XMALLOC (char, len);
msousa@353:     sprintf (str, "%s=%s", name, value);
msousa@353:     if (putenv (str) != EXIT_SUCCESS)
msousa@353:       {
msousa@353:         XFREE (str);
msousa@353:       }
msousa@353: #endif
msousa@353:   }
msousa@353: }
msousa@353: 
msousa@353: char *
msousa@353: lt_extend_str (const char *orig_value, const char *add, int to_end)
msousa@353: {
msousa@353:   char *new_value;
msousa@353:   if (orig_value && *orig_value)
msousa@353:     {
msousa@353:       int orig_value_len = strlen (orig_value);
msousa@353:       int add_len = strlen (add);
msousa@353:       new_value = XMALLOC (char, add_len + orig_value_len + 1);
msousa@353:       if (to_end)
msousa@353:         {
msousa@353:           strcpy (new_value, orig_value);
msousa@353:           strcpy (new_value + orig_value_len, add);
msousa@353:         }
msousa@353:       else
msousa@353:         {
msousa@353:           strcpy (new_value, add);
msousa@353:           strcpy (new_value + add_len, orig_value);
msousa@353:         }
msousa@353:     }
msousa@353:   else
msousa@353:     {
msousa@353:       new_value = xstrdup (add);
msousa@353:     }
msousa@353:   return new_value;
msousa@353: }
msousa@353: 
msousa@353: int
msousa@353: lt_split_name_value (const char *arg, char** name, char** value)
msousa@353: {
msousa@353:   const char *p;
msousa@353:   int len;
msousa@353:   if (!arg || !*arg)
msousa@353:     return 1;
msousa@353: 
msousa@353:   p = strchr (arg, (int)'=');
msousa@353: 
msousa@353:   if (!p)
msousa@353:     return 1;
msousa@353: 
msousa@353:   *value = xstrdup (++p);
msousa@353: 
msousa@353:   len = strlen (arg) - strlen (*value);
msousa@353:   *name = XMALLOC (char, len);
msousa@353:   strncpy (*name, arg, len-1);
msousa@353:   (*name)[len - 1] = '\0';
msousa@353: 
msousa@353:   return 0;
msousa@353: }
msousa@353: 
msousa@353: void
msousa@353: lt_opt_process_env_set (const char *arg)
msousa@353: {
msousa@353:   char *name = NULL;
msousa@353:   char *value = NULL;
msousa@353: 
msousa@353:   if (lt_split_name_value (arg, &name, &value) != 0)
msousa@353:     {
msousa@353:       XFREE (name);
msousa@353:       XFREE (value);
msousa@353:       lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
msousa@353:     }
msousa@353: 
msousa@353:   lt_setenv (name, value);
msousa@353:   XFREE (name);
msousa@353:   XFREE (value);
msousa@353: }
msousa@353: 
msousa@353: void
msousa@353: lt_opt_process_env_prepend (const char *arg)
msousa@353: {
msousa@353:   char *name = NULL;
msousa@353:   char *value = NULL;
msousa@353:   char *new_value = NULL;
msousa@353: 
msousa@353:   if (lt_split_name_value (arg, &name, &value) != 0)
msousa@353:     {
msousa@353:       XFREE (name);
msousa@353:       XFREE (value);
msousa@353:       lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
msousa@353:     }
msousa@353: 
msousa@353:   new_value = lt_extend_str (getenv (name), value, 0);
msousa@353:   lt_setenv (name, new_value);
msousa@353:   XFREE (new_value);
msousa@353:   XFREE (name);
msousa@353:   XFREE (value);
msousa@353: }
msousa@353: 
msousa@353: void
msousa@353: lt_opt_process_env_append (const char *arg)
msousa@353: {
msousa@353:   char *name = NULL;
msousa@353:   char *value = NULL;
msousa@353:   char *new_value = NULL;
msousa@353: 
msousa@353:   if (lt_split_name_value (arg, &name, &value) != 0)
msousa@353:     {
msousa@353:       XFREE (name);
msousa@353:       XFREE (value);
msousa@353:       lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
msousa@353:     }
msousa@353: 
msousa@353:   new_value = lt_extend_str (getenv (name), value, 1);
msousa@353:   lt_setenv (name, new_value);
msousa@353:   XFREE (new_value);
msousa@353:   XFREE (name);
msousa@353:   XFREE (value);
msousa@353: }
msousa@353: 
msousa@353: void
msousa@353: lt_update_exe_path (const char *name, const char *value)
msousa@353: {
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
msousa@353:                           (name ? name : "<NULL>"),
msousa@353:                           (value ? value : "<NULL>")));
msousa@353: 
msousa@353:   if (name && *name && value && *value)
msousa@353:     {
msousa@353:       char *new_value = lt_extend_str (getenv (name), value, 0);
msousa@353:       /* some systems can't cope with a ':'-terminated path #' */
msousa@353:       int len = strlen (new_value);
msousa@353:       while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
msousa@353:         {
msousa@353:           new_value[len-1] = '\0';
msousa@353:         }
msousa@353:       lt_setenv (name, new_value);
msousa@353:       XFREE (new_value);
msousa@353:     }
msousa@353: }
msousa@353: 
msousa@353: void
msousa@353: lt_update_lib_path (const char *name, const char *value)
msousa@353: {
msousa@353:   LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
msousa@353:                           (name ? name : "<NULL>"),
msousa@353:                           (value ? value : "<NULL>")));
msousa@353: 
msousa@353:   if (name && *name && value && *value)
msousa@353:     {
msousa@353:       char *new_value = lt_extend_str (getenv (name), value, 0);
msousa@353:       lt_setenv (name, new_value);
msousa@353:       XFREE (new_value);
msousa@353:     }
msousa@353: }
msousa@353: 
msousa@353: 
msousa@353: EOF
msousa@353: }
msousa@353: # end: func_emit_cwrapperexe_src
msousa@353: 
msousa@353: # func_mode_link arg...
msousa@353: func_mode_link ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     case $host in
msousa@353:     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
msousa@353:       # It is impossible to link a dll without this setting, and
msousa@353:       # we shouldn't force the makefile maintainer to figure out
msousa@353:       # which system we are compiling for in order to pass an extra
msousa@353:       # flag for every libtool invocation.
msousa@353:       # allow_undefined=no
msousa@353: 
msousa@353:       # FIXME: Unfortunately, there are problems with the above when trying
msousa@353:       # to make a dll which has undefined symbols, in which case not
msousa@353:       # even a static library is built.  For now, we need to specify
msousa@353:       # -no-undefined on the libtool link line when we can be certain
msousa@353:       # that all symbols are satisfied, otherwise we get a static library.
msousa@353:       allow_undefined=yes
msousa@353:       ;;
msousa@353:     *)
msousa@353:       allow_undefined=yes
msousa@353:       ;;
msousa@353:     esac
msousa@353:     libtool_args=$nonopt
msousa@353:     base_compile="$nonopt $@"
msousa@353:     compile_command=$nonopt
msousa@353:     finalize_command=$nonopt
msousa@353: 
msousa@353:     compile_rpath=
msousa@353:     finalize_rpath=
msousa@353:     compile_shlibpath=
msousa@353:     finalize_shlibpath=
msousa@353:     convenience=
msousa@353:     old_convenience=
msousa@353:     deplibs=
msousa@353:     old_deplibs=
msousa@353:     compiler_flags=
msousa@353:     linker_flags=
msousa@353:     dllsearchpath=
msousa@353:     lib_search_path=`pwd`
msousa@353:     inst_prefix_dir=
msousa@353:     new_inherited_linker_flags=
msousa@353: 
msousa@353:     avoid_version=no
msousa@353:     dlfiles=
msousa@353:     dlprefiles=
msousa@353:     dlself=no
msousa@353:     export_dynamic=no
msousa@353:     export_symbols=
msousa@353:     export_symbols_regex=
msousa@353:     generated=
msousa@353:     libobjs=
msousa@353:     ltlibs=
msousa@353:     module=no
msousa@353:     no_install=no
msousa@353:     objs=
msousa@353:     non_pic_objects=
msousa@353:     precious_files_regex=
msousa@353:     prefer_static_libs=no
msousa@353:     preload=no
msousa@353:     prev=
msousa@353:     prevarg=
msousa@353:     release=
msousa@353:     rpath=
msousa@353:     xrpath=
msousa@353:     perm_rpath=
msousa@353:     temp_rpath=
msousa@353:     thread_safe=no
msousa@353:     vinfo=
msousa@353:     vinfo_number=no
msousa@353:     weak_libs=
msousa@353:     single_module="${wl}-single_module"
msousa@353:     func_infer_tag $base_compile
msousa@353: 
msousa@353:     # We need to know -static, to get the right output filenames.
msousa@353:     for arg
msousa@353:     do
msousa@353:       case $arg in
msousa@353:       -shared)
msousa@353: 	test "$build_libtool_libs" != yes && \
msousa@353: 	  func_fatal_configuration "can not build a shared library"
msousa@353: 	build_old_libs=no
msousa@353: 	break
msousa@353: 	;;
msousa@353:       -all-static | -static | -static-libtool-libs)
msousa@353: 	case $arg in
msousa@353: 	-all-static)
msousa@353: 	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
msousa@353: 	    func_warning "complete static linking is impossible in this configuration"
msousa@353: 	  fi
msousa@353: 	  if test -n "$link_static_flag"; then
msousa@353: 	    dlopen_self=$dlopen_self_static
msousa@353: 	  fi
msousa@353: 	  prefer_static_libs=yes
msousa@353: 	  ;;
msousa@353: 	-static)
msousa@353: 	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
msousa@353: 	    dlopen_self=$dlopen_self_static
msousa@353: 	  fi
msousa@353: 	  prefer_static_libs=built
msousa@353: 	  ;;
msousa@353: 	-static-libtool-libs)
msousa@353: 	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
msousa@353: 	    dlopen_self=$dlopen_self_static
msousa@353: 	  fi
msousa@353: 	  prefer_static_libs=yes
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	build_libtool_libs=no
msousa@353: 	build_old_libs=yes
msousa@353: 	break
msousa@353: 	;;
msousa@353:       esac
msousa@353:     done
msousa@353: 
msousa@353:     # See if our shared archives depend on static archives.
msousa@353:     test -n "$old_archive_from_new_cmds" && build_old_libs=yes
msousa@353: 
msousa@353:     # Go through the arguments, transforming them on the way.
msousa@353:     while test "$#" -gt 0; do
msousa@353:       arg="$1"
msousa@353:       shift
msousa@353:       func_quote_for_eval "$arg"
msousa@353:       qarg=$func_quote_for_eval_unquoted_result
msousa@353:       func_append libtool_args " $func_quote_for_eval_result"
msousa@353: 
msousa@353:       # If the previous option needs an argument, assign it.
msousa@353:       if test -n "$prev"; then
msousa@353: 	case $prev in
msousa@353: 	output)
msousa@353: 	  func_append compile_command " @OUTPUT@"
msousa@353: 	  func_append finalize_command " @OUTPUT@"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	case $prev in
msousa@353: 	dlfiles|dlprefiles)
msousa@353: 	  if test "$preload" = no; then
msousa@353: 	    # Add the symbol object into the linking commands.
msousa@353: 	    func_append compile_command " @SYMFILE@"
msousa@353: 	    func_append finalize_command " @SYMFILE@"
msousa@353: 	    preload=yes
msousa@353: 	  fi
msousa@353: 	  case $arg in
msousa@353: 	  *.la | *.lo) ;;  # We handle these cases below.
msousa@353: 	  force)
msousa@353: 	    if test "$dlself" = no; then
msousa@353: 	      dlself=needless
msousa@353: 	      export_dynamic=yes
msousa@353: 	    fi
msousa@353: 	    prev=
msousa@353: 	    continue
msousa@353: 	    ;;
msousa@353: 	  self)
msousa@353: 	    if test "$prev" = dlprefiles; then
msousa@353: 	      dlself=yes
msousa@353: 	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
msousa@353: 	      dlself=yes
msousa@353: 	    else
msousa@353: 	      dlself=needless
msousa@353: 	      export_dynamic=yes
msousa@353: 	    fi
msousa@353: 	    prev=
msousa@353: 	    continue
msousa@353: 	    ;;
msousa@353: 	  *)
msousa@353: 	    if test "$prev" = dlfiles; then
msousa@353: 	      dlfiles="$dlfiles $arg"
msousa@353: 	    else
msousa@353: 	      dlprefiles="$dlprefiles $arg"
msousa@353: 	    fi
msousa@353: 	    prev=
msousa@353: 	    continue
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	expsyms)
msousa@353: 	  export_symbols="$arg"
msousa@353: 	  test -f "$arg" \
msousa@353: 	    || func_fatal_error "symbol file \`$arg' does not exist"
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	expsyms_regex)
msousa@353: 	  export_symbols_regex="$arg"
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	framework)
msousa@353: 	  case $host in
msousa@353: 	    *-*-darwin*)
msousa@353: 	      case "$deplibs " in
msousa@353: 		*" $qarg.ltframework "*) ;;
msousa@353: 		*) deplibs="$deplibs $qarg.ltframework" # this is fixed later
msousa@353: 		   ;;
msousa@353: 	      esac
msousa@353: 	      ;;
msousa@353: 	  esac
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	inst_prefix)
msousa@353: 	  inst_prefix_dir="$arg"
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	objectlist)
msousa@353: 	  if test -f "$arg"; then
msousa@353: 	    save_arg=$arg
msousa@353: 	    moreargs=
msousa@353: 	    for fil in `cat "$save_arg"`
msousa@353: 	    do
msousa@353: #	      moreargs="$moreargs $fil"
msousa@353: 	      arg=$fil
msousa@353: 	      # A libtool-controlled object.
msousa@353: 
msousa@353: 	      # Check to see that this really is a libtool object.
msousa@353: 	      if func_lalib_unsafe_p "$arg"; then
msousa@353: 		pic_object=
msousa@353: 		non_pic_object=
msousa@353: 
msousa@353: 		# Read the .lo file
msousa@353: 		func_source "$arg"
msousa@353: 
msousa@353: 		if test -z "$pic_object" ||
msousa@353: 		   test -z "$non_pic_object" ||
msousa@353: 		   test "$pic_object" = none &&
msousa@353: 		   test "$non_pic_object" = none; then
msousa@353: 		  func_fatal_error "cannot find name of object for \`$arg'"
msousa@353: 		fi
msousa@353: 
msousa@353: 		# Extract subdirectory from the argument.
msousa@353: 		func_dirname "$arg" "/" ""
msousa@353: 		xdir="$func_dirname_result"
msousa@353: 
msousa@353: 		if test "$pic_object" != none; then
msousa@353: 		  # Prepend the subdirectory the object is found in.
msousa@353: 		  pic_object="$xdir$pic_object"
msousa@353: 
msousa@353: 		  if test "$prev" = dlfiles; then
msousa@353: 		    if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
msousa@353: 		      dlfiles="$dlfiles $pic_object"
msousa@353: 		      prev=
msousa@353: 		      continue
msousa@353: 		    else
msousa@353: 		      # If libtool objects are unsupported, then we need to preload.
msousa@353: 		      prev=dlprefiles
msousa@353: 		    fi
msousa@353: 		  fi
msousa@353: 
msousa@353: 		  # CHECK ME:  I think I busted this.  -Ossama
msousa@353: 		  if test "$prev" = dlprefiles; then
msousa@353: 		    # Preload the old-style object.
msousa@353: 		    dlprefiles="$dlprefiles $pic_object"
msousa@353: 		    prev=
msousa@353: 		  fi
msousa@353: 
msousa@353: 		  # A PIC object.
msousa@353: 		  func_append libobjs " $pic_object"
msousa@353: 		  arg="$pic_object"
msousa@353: 		fi
msousa@353: 
msousa@353: 		# Non-PIC object.
msousa@353: 		if test "$non_pic_object" != none; then
msousa@353: 		  # Prepend the subdirectory the object is found in.
msousa@353: 		  non_pic_object="$xdir$non_pic_object"
msousa@353: 
msousa@353: 		  # A standard non-PIC object
msousa@353: 		  func_append non_pic_objects " $non_pic_object"
msousa@353: 		  if test -z "$pic_object" || test "$pic_object" = none ; then
msousa@353: 		    arg="$non_pic_object"
msousa@353: 		  fi
msousa@353: 		else
msousa@353: 		  # If the PIC object exists, use it instead.
msousa@353: 		  # $xdir was prepended to $pic_object above.
msousa@353: 		  non_pic_object="$pic_object"
msousa@353: 		  func_append non_pic_objects " $non_pic_object"
msousa@353: 		fi
msousa@353: 	      else
msousa@353: 		# Only an error if not doing a dry-run.
msousa@353: 		if $opt_dry_run; then
msousa@353: 		  # Extract subdirectory from the argument.
msousa@353: 		  func_dirname "$arg" "/" ""
msousa@353: 		  xdir="$func_dirname_result"
msousa@353: 
msousa@353: 		  func_lo2o "$arg"
msousa@353: 		  pic_object=$xdir$objdir/$func_lo2o_result
msousa@353: 		  non_pic_object=$xdir$func_lo2o_result
msousa@353: 		  func_append libobjs " $pic_object"
msousa@353: 		  func_append non_pic_objects " $non_pic_object"
msousa@353: 	        else
msousa@353: 		  func_fatal_error "\`$arg' is not a valid libtool object"
msousa@353: 		fi
msousa@353: 	      fi
msousa@353: 	    done
msousa@353: 	  else
msousa@353: 	    func_fatal_error "link input file \`$arg' does not exist"
msousa@353: 	  fi
msousa@353: 	  arg=$save_arg
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	precious_regex)
msousa@353: 	  precious_files_regex="$arg"
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	release)
msousa@353: 	  release="-$arg"
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	rpath | xrpath)
msousa@353: 	  # We need an absolute path.
msousa@353: 	  case $arg in
msousa@353: 	  [\\/]* | [A-Za-z]:[\\/]*) ;;
msousa@353: 	  *)
msousa@353: 	    func_fatal_error "only absolute run-paths are allowed"
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  if test "$prev" = rpath; then
msousa@353: 	    case "$rpath " in
msousa@353: 	    *" $arg "*) ;;
msousa@353: 	    *) rpath="$rpath $arg" ;;
msousa@353: 	    esac
msousa@353: 	  else
msousa@353: 	    case "$xrpath " in
msousa@353: 	    *" $arg "*) ;;
msousa@353: 	    *) xrpath="$xrpath $arg" ;;
msousa@353: 	    esac
msousa@353: 	  fi
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	shrext)
msousa@353: 	  shrext_cmds="$arg"
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	weak)
msousa@353: 	  weak_libs="$weak_libs $arg"
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	xcclinker)
msousa@353: 	  linker_flags="$linker_flags $qarg"
msousa@353: 	  compiler_flags="$compiler_flags $qarg"
msousa@353: 	  prev=
msousa@353: 	  func_append compile_command " $qarg"
msousa@353: 	  func_append finalize_command " $qarg"
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	xcompiler)
msousa@353: 	  compiler_flags="$compiler_flags $qarg"
msousa@353: 	  prev=
msousa@353: 	  func_append compile_command " $qarg"
msousa@353: 	  func_append finalize_command " $qarg"
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	xlinker)
msousa@353: 	  linker_flags="$linker_flags $qarg"
msousa@353: 	  compiler_flags="$compiler_flags $wl$qarg"
msousa@353: 	  prev=
msousa@353: 	  func_append compile_command " $wl$qarg"
msousa@353: 	  func_append finalize_command " $wl$qarg"
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	*)
msousa@353: 	  eval "$prev=\"\$arg\""
msousa@353: 	  prev=
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353:       fi # test -n "$prev"
msousa@353: 
msousa@353:       prevarg="$arg"
msousa@353: 
msousa@353:       case $arg in
msousa@353:       -all-static)
msousa@353: 	if test -n "$link_static_flag"; then
msousa@353: 	  # See comment for -static flag below, for more details.
msousa@353: 	  func_append compile_command " $link_static_flag"
msousa@353: 	  func_append finalize_command " $link_static_flag"
msousa@353: 	fi
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -allow-undefined)
msousa@353: 	# FIXME: remove this flag sometime in the future.
msousa@353: 	func_fatal_error "\`-allow-undefined' must not be used because it is the default"
msousa@353: 	;;
msousa@353: 
msousa@353:       -avoid-version)
msousa@353: 	avoid_version=yes
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -dlopen)
msousa@353: 	prev=dlfiles
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -dlpreopen)
msousa@353: 	prev=dlprefiles
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -export-dynamic)
msousa@353: 	export_dynamic=yes
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -export-symbols | -export-symbols-regex)
msousa@353: 	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
msousa@353: 	  func_fatal_error "more than one -exported-symbols argument is not allowed"
msousa@353: 	fi
msousa@353: 	if test "X$arg" = "X-export-symbols"; then
msousa@353: 	  prev=expsyms
msousa@353: 	else
msousa@353: 	  prev=expsyms_regex
msousa@353: 	fi
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -framework)
msousa@353: 	prev=framework
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -inst-prefix-dir)
msousa@353: 	prev=inst_prefix
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
msousa@353:       # so, if we see these flags be careful not to treat them like -L
msousa@353:       -L[A-Z][A-Z]*:*)
msousa@353: 	case $with_gcc/$host in
msousa@353: 	no/*-*-irix* | /*-*-irix*)
msousa@353: 	  func_append compile_command " $arg"
msousa@353: 	  func_append finalize_command " $arg"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -L*)
msousa@353: 	func_stripname '-L' '' "$arg"
msousa@353: 	dir=$func_stripname_result
msousa@353: 	if test -z "$dir"; then
msousa@353: 	  if test "$#" -gt 0; then
msousa@353: 	    func_fatal_error "require no space between \`-L' and \`$1'"
msousa@353: 	  else
msousa@353: 	    func_fatal_error "need path for \`-L' option"
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 	# We need an absolute path.
msousa@353: 	case $dir in
msousa@353: 	[\\/]* | [A-Za-z]:[\\/]*) ;;
msousa@353: 	*)
msousa@353: 	  absdir=`cd "$dir" && pwd`
msousa@353: 	  test -z "$absdir" && \
msousa@353: 	    func_fatal_error "cannot determine absolute directory name of \`$dir'"
msousa@353: 	  dir="$absdir"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	case "$deplibs " in
msousa@353: 	*" -L$dir "*) ;;
msousa@353: 	*)
msousa@353: 	  deplibs="$deplibs -L$dir"
msousa@353: 	  lib_search_path="$lib_search_path $dir"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	case $host in
msousa@353: 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
msousa@353: 	  testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
msousa@353: 	  case :$dllsearchpath: in
msousa@353: 	  *":$dir:"*) ;;
msousa@353: 	  ::) dllsearchpath=$dir;;
msousa@353: 	  *) dllsearchpath="$dllsearchpath:$dir";;
msousa@353: 	  esac
msousa@353: 	  case :$dllsearchpath: in
msousa@353: 	  *":$testbindir:"*) ;;
msousa@353: 	  ::) dllsearchpath=$testbindir;;
msousa@353: 	  *) dllsearchpath="$dllsearchpath:$testbindir";;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -l*)
msousa@353: 	if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
msousa@353: 	  case $host in
msousa@353: 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
msousa@353: 	    # These systems don't actually have a C or math library (as such)
msousa@353: 	    continue
msousa@353: 	    ;;
msousa@353: 	  *-*-os2*)
msousa@353: 	    # These systems don't actually have a C library (as such)
msousa@353: 	    test "X$arg" = "X-lc" && continue
msousa@353: 	    ;;
msousa@353: 	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
msousa@353: 	    # Do not include libc due to us having libc/libc_r.
msousa@353: 	    test "X$arg" = "X-lc" && continue
msousa@353: 	    ;;
msousa@353: 	  *-*-rhapsody* | *-*-darwin1.[012])
msousa@353: 	    # Rhapsody C and math libraries are in the System framework
msousa@353: 	    deplibs="$deplibs System.ltframework"
msousa@353: 	    continue
msousa@353: 	    ;;
msousa@353: 	  *-*-sco3.2v5* | *-*-sco5v6*)
msousa@353: 	    # Causes problems with __ctype
msousa@353: 	    test "X$arg" = "X-lc" && continue
msousa@353: 	    ;;
msousa@353: 	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
msousa@353: 	    # Compiler inserts libc in the correct place for threads to work
msousa@353: 	    test "X$arg" = "X-lc" && continue
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	elif test "X$arg" = "X-lc_r"; then
msousa@353: 	 case $host in
msousa@353: 	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
msousa@353: 	   # Do not include libc_r directly, use -pthread flag.
msousa@353: 	   continue
msousa@353: 	   ;;
msousa@353: 	 esac
msousa@353: 	fi
msousa@353: 	deplibs="$deplibs $arg"
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -module)
msousa@353: 	module=yes
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       # Tru64 UNIX uses -model [arg] to determine the layout of C++
msousa@353:       # classes, name mangling, and exception handling.
msousa@353:       # Darwin uses the -arch flag to determine output architecture.
msousa@353:       -model|-arch|-isysroot)
msousa@353: 	compiler_flags="$compiler_flags $arg"
msousa@353: 	func_append compile_command " $arg"
msousa@353: 	func_append finalize_command " $arg"
msousa@353: 	prev=xcompiler
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
msousa@353: 	compiler_flags="$compiler_flags $arg"
msousa@353: 	func_append compile_command " $arg"
msousa@353: 	func_append finalize_command " $arg"
msousa@353: 	case "$new_inherited_linker_flags " in
msousa@353: 	    *" $arg "*) ;;
msousa@353: 	    * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
msousa@353: 	esac
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -multi_module)
msousa@353: 	single_module="${wl}-multi_module"
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -no-fast-install)
msousa@353: 	fast_install=no
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -no-install)
msousa@353: 	case $host in
msousa@353: 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
msousa@353: 	  # The PATH hackery in wrapper scripts is required on Windows
msousa@353: 	  # and Darwin in order for the loader to find any dlls it needs.
msousa@353: 	  func_warning "\`-no-install' is ignored for $host"
msousa@353: 	  func_warning "assuming \`-no-fast-install' instead"
msousa@353: 	  fast_install=no
msousa@353: 	  ;;
msousa@353: 	*) no_install=yes ;;
msousa@353: 	esac
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -no-undefined)
msousa@353: 	allow_undefined=no
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -objectlist)
msousa@353: 	prev=objectlist
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -o) prev=output ;;
msousa@353: 
msousa@353:       -precious-files-regex)
msousa@353: 	prev=precious_regex
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -release)
msousa@353: 	prev=release
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -rpath)
msousa@353: 	prev=rpath
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -R)
msousa@353: 	prev=xrpath
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -R*)
msousa@353: 	func_stripname '-R' '' "$arg"
msousa@353: 	dir=$func_stripname_result
msousa@353: 	# We need an absolute path.
msousa@353: 	case $dir in
msousa@353: 	[\\/]* | [A-Za-z]:[\\/]*) ;;
msousa@353: 	*)
msousa@353: 	  func_fatal_error "only absolute run-paths are allowed"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	case "$xrpath " in
msousa@353: 	*" $dir "*) ;;
msousa@353: 	*) xrpath="$xrpath $dir" ;;
msousa@353: 	esac
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -shared)
msousa@353: 	# The effects of -shared are defined in a previous loop.
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -shrext)
msousa@353: 	prev=shrext
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -static | -static-libtool-libs)
msousa@353: 	# The effects of -static are defined in a previous loop.
msousa@353: 	# We used to do the same as -all-static on platforms that
msousa@353: 	# didn't have a PIC flag, but the assumption that the effects
msousa@353: 	# would be equivalent was wrong.  It would break on at least
msousa@353: 	# Digital Unix and AIX.
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -thread-safe)
msousa@353: 	thread_safe=yes
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -version-info)
msousa@353: 	prev=vinfo
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -version-number)
msousa@353: 	prev=vinfo
msousa@353: 	vinfo_number=yes
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -weak)
msousa@353:         prev=weak
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -Wc,*)
msousa@353: 	func_stripname '-Wc,' '' "$arg"
msousa@353: 	args=$func_stripname_result
msousa@353: 	arg=
msousa@353: 	save_ifs="$IFS"; IFS=','
msousa@353: 	for flag in $args; do
msousa@353: 	  IFS="$save_ifs"
msousa@353:           func_quote_for_eval "$flag"
msousa@353: 	  arg="$arg $wl$func_quote_for_eval_result"
msousa@353: 	  compiler_flags="$compiler_flags $func_quote_for_eval_result"
msousa@353: 	done
msousa@353: 	IFS="$save_ifs"
msousa@353: 	func_stripname ' ' '' "$arg"
msousa@353: 	arg=$func_stripname_result
msousa@353: 	;;
msousa@353: 
msousa@353:       -Wl,*)
msousa@353: 	func_stripname '-Wl,' '' "$arg"
msousa@353: 	args=$func_stripname_result
msousa@353: 	arg=
msousa@353: 	save_ifs="$IFS"; IFS=','
msousa@353: 	for flag in $args; do
msousa@353: 	  IFS="$save_ifs"
msousa@353:           func_quote_for_eval "$flag"
msousa@353: 	  arg="$arg $wl$func_quote_for_eval_result"
msousa@353: 	  compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
msousa@353: 	  linker_flags="$linker_flags $func_quote_for_eval_result"
msousa@353: 	done
msousa@353: 	IFS="$save_ifs"
msousa@353: 	func_stripname ' ' '' "$arg"
msousa@353: 	arg=$func_stripname_result
msousa@353: 	;;
msousa@353: 
msousa@353:       -Xcompiler)
msousa@353: 	prev=xcompiler
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -Xlinker)
msousa@353: 	prev=xlinker
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       -XCClinker)
msousa@353: 	prev=xcclinker
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       # -msg_* for osf cc
msousa@353:       -msg_*)
msousa@353: 	func_quote_for_eval "$arg"
msousa@353: 	arg="$func_quote_for_eval_result"
msousa@353: 	;;
msousa@353: 
msousa@353:       # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
msousa@353:       # -r[0-9][0-9]* specifies the processor on the SGI compiler
msousa@353:       # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
msousa@353:       # +DA*, +DD* enable 64-bit mode on the HP compiler
msousa@353:       # -q* pass through compiler args for the IBM compiler
msousa@353:       # -m*, -t[45]*, -txscale* pass through architecture-specific
msousa@353:       # compiler args for GCC
msousa@353:       # -F/path gives path to uninstalled frameworks, gcc on darwin
msousa@353:       # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
msousa@353:       # @file GCC response files
msousa@353:       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
msousa@353:       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
msousa@353:         func_quote_for_eval "$arg"
msousa@353: 	arg="$func_quote_for_eval_result"
msousa@353:         func_append compile_command " $arg"
msousa@353:         func_append finalize_command " $arg"
msousa@353:         compiler_flags="$compiler_flags $arg"
msousa@353:         continue
msousa@353:         ;;
msousa@353: 
msousa@353:       # Some other compiler flag.
msousa@353:       -* | +*)
msousa@353:         func_quote_for_eval "$arg"
msousa@353: 	arg="$func_quote_for_eval_result"
msousa@353: 	;;
msousa@353: 
msousa@353:       *.$objext)
msousa@353: 	# A standard object.
msousa@353: 	objs="$objs $arg"
msousa@353: 	;;
msousa@353: 
msousa@353:       *.lo)
msousa@353: 	# A libtool-controlled object.
msousa@353: 
msousa@353: 	# Check to see that this really is a libtool object.
msousa@353: 	if func_lalib_unsafe_p "$arg"; then
msousa@353: 	  pic_object=
msousa@353: 	  non_pic_object=
msousa@353: 
msousa@353: 	  # Read the .lo file
msousa@353: 	  func_source "$arg"
msousa@353: 
msousa@353: 	  if test -z "$pic_object" ||
msousa@353: 	     test -z "$non_pic_object" ||
msousa@353: 	     test "$pic_object" = none &&
msousa@353: 	     test "$non_pic_object" = none; then
msousa@353: 	    func_fatal_error "cannot find name of object for \`$arg'"
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  # Extract subdirectory from the argument.
msousa@353: 	  func_dirname "$arg" "/" ""
msousa@353: 	  xdir="$func_dirname_result"
msousa@353: 
msousa@353: 	  if test "$pic_object" != none; then
msousa@353: 	    # Prepend the subdirectory the object is found in.
msousa@353: 	    pic_object="$xdir$pic_object"
msousa@353: 
msousa@353: 	    if test "$prev" = dlfiles; then
msousa@353: 	      if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
msousa@353: 		dlfiles="$dlfiles $pic_object"
msousa@353: 		prev=
msousa@353: 		continue
msousa@353: 	      else
msousa@353: 		# If libtool objects are unsupported, then we need to preload.
msousa@353: 		prev=dlprefiles
msousa@353: 	      fi
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    # CHECK ME:  I think I busted this.  -Ossama
msousa@353: 	    if test "$prev" = dlprefiles; then
msousa@353: 	      # Preload the old-style object.
msousa@353: 	      dlprefiles="$dlprefiles $pic_object"
msousa@353: 	      prev=
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    # A PIC object.
msousa@353: 	    func_append libobjs " $pic_object"
msousa@353: 	    arg="$pic_object"
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  # Non-PIC object.
msousa@353: 	  if test "$non_pic_object" != none; then
msousa@353: 	    # Prepend the subdirectory the object is found in.
msousa@353: 	    non_pic_object="$xdir$non_pic_object"
msousa@353: 
msousa@353: 	    # A standard non-PIC object
msousa@353: 	    func_append non_pic_objects " $non_pic_object"
msousa@353: 	    if test -z "$pic_object" || test "$pic_object" = none ; then
msousa@353: 	      arg="$non_pic_object"
msousa@353: 	    fi
msousa@353: 	  else
msousa@353: 	    # If the PIC object exists, use it instead.
msousa@353: 	    # $xdir was prepended to $pic_object above.
msousa@353: 	    non_pic_object="$pic_object"
msousa@353: 	    func_append non_pic_objects " $non_pic_object"
msousa@353: 	  fi
msousa@353: 	else
msousa@353: 	  # Only an error if not doing a dry-run.
msousa@353: 	  if $opt_dry_run; then
msousa@353: 	    # Extract subdirectory from the argument.
msousa@353: 	    func_dirname "$arg" "/" ""
msousa@353: 	    xdir="$func_dirname_result"
msousa@353: 
msousa@353: 	    func_lo2o "$arg"
msousa@353: 	    pic_object=$xdir$objdir/$func_lo2o_result
msousa@353: 	    non_pic_object=$xdir$func_lo2o_result
msousa@353: 	    func_append libobjs " $pic_object"
msousa@353: 	    func_append non_pic_objects " $non_pic_object"
msousa@353: 	  else
msousa@353: 	    func_fatal_error "\`$arg' is not a valid libtool object"
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 	;;
msousa@353: 
msousa@353:       *.$libext)
msousa@353: 	# An archive.
msousa@353: 	deplibs="$deplibs $arg"
msousa@353: 	old_deplibs="$old_deplibs $arg"
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       *.la)
msousa@353: 	# A libtool-controlled library.
msousa@353: 
msousa@353: 	if test "$prev" = dlfiles; then
msousa@353: 	  # This library was specified with -dlopen.
msousa@353: 	  dlfiles="$dlfiles $arg"
msousa@353: 	  prev=
msousa@353: 	elif test "$prev" = dlprefiles; then
msousa@353: 	  # The library was specified with -dlpreopen.
msousa@353: 	  dlprefiles="$dlprefiles $arg"
msousa@353: 	  prev=
msousa@353: 	else
msousa@353: 	  deplibs="$deplibs $arg"
msousa@353: 	fi
msousa@353: 	continue
msousa@353: 	;;
msousa@353: 
msousa@353:       # Some other compiler argument.
msousa@353:       *)
msousa@353: 	# Unknown arguments in both finalize_command and compile_command need
msousa@353: 	# to be aesthetically quoted because they are evaled later.
msousa@353: 	func_quote_for_eval "$arg"
msousa@353: 	arg="$func_quote_for_eval_result"
msousa@353: 	;;
msousa@353:       esac # arg
msousa@353: 
msousa@353:       # Now actually substitute the argument into the commands.
msousa@353:       if test -n "$arg"; then
msousa@353: 	func_append compile_command " $arg"
msousa@353: 	func_append finalize_command " $arg"
msousa@353:       fi
msousa@353:     done # argument parsing loop
msousa@353: 
msousa@353:     test -n "$prev" && \
msousa@353:       func_fatal_help "the \`$prevarg' option requires an argument"
msousa@353: 
msousa@353:     if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
msousa@353:       eval arg=\"$export_dynamic_flag_spec\"
msousa@353:       func_append compile_command " $arg"
msousa@353:       func_append finalize_command " $arg"
msousa@353:     fi
msousa@353: 
msousa@353:     oldlibs=
msousa@353:     # calculate the name of the file, without its directory
msousa@353:     func_basename "$output"
msousa@353:     outputname="$func_basename_result"
msousa@353:     libobjs_save="$libobjs"
msousa@353: 
msousa@353:     if test -n "$shlibpath_var"; then
msousa@353:       # get the directories listed in $shlibpath_var
msousa@353:       eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
msousa@353:     else
msousa@353:       shlib_search_path=
msousa@353:     fi
msousa@353:     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
msousa@353:     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
msousa@353: 
msousa@353:     func_dirname "$output" "/" ""
msousa@353:     output_objdir="$func_dirname_result$objdir"
msousa@353:     # Create the object directory.
msousa@353:     func_mkdir_p "$output_objdir"
msousa@353: 
msousa@353:     # Determine the type of output
msousa@353:     case $output in
msousa@353:     "")
msousa@353:       func_fatal_help "you must specify an output file"
msousa@353:       ;;
msousa@353:     *.$libext) linkmode=oldlib ;;
msousa@353:     *.lo | *.$objext) linkmode=obj ;;
msousa@353:     *.la) linkmode=lib ;;
msousa@353:     *) linkmode=prog ;; # Anything else should be a program.
msousa@353:     esac
msousa@353: 
msousa@353:     specialdeplibs=
msousa@353: 
msousa@353:     libs=
msousa@353:     # Find all interdependent deplibs by searching for libraries
msousa@353:     # that are linked more than once (e.g. -la -lb -la)
msousa@353:     for deplib in $deplibs; do
msousa@353:       if $opt_duplicate_deps ; then
msousa@353: 	case "$libs " in
msousa@353: 	*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
msousa@353: 	esac
msousa@353:       fi
msousa@353:       libs="$libs $deplib"
msousa@353:     done
msousa@353: 
msousa@353:     if test "$linkmode" = lib; then
msousa@353:       libs="$predeps $libs $compiler_lib_search_path $postdeps"
msousa@353: 
msousa@353:       # Compute libraries that are listed more than once in $predeps
msousa@353:       # $postdeps and mark them as special (i.e., whose duplicates are
msousa@353:       # not to be eliminated).
msousa@353:       pre_post_deps=
msousa@353:       if $opt_duplicate_compiler_generated_deps; then
msousa@353: 	for pre_post_dep in $predeps $postdeps; do
msousa@353: 	  case "$pre_post_deps " in
msousa@353: 	  *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
msousa@353: 	  esac
msousa@353: 	  pre_post_deps="$pre_post_deps $pre_post_dep"
msousa@353: 	done
msousa@353:       fi
msousa@353:       pre_post_deps=
msousa@353:     fi
msousa@353: 
msousa@353:     deplibs=
msousa@353:     newdependency_libs=
msousa@353:     newlib_search_path=
msousa@353:     need_relink=no # whether we're linking any uninstalled libtool libraries
msousa@353:     notinst_deplibs= # not-installed libtool libraries
msousa@353:     notinst_path= # paths that contain not-installed libtool libraries
msousa@353: 
msousa@353:     case $linkmode in
msousa@353:     lib)
msousa@353: 	passes="conv dlpreopen link"
msousa@353: 	for file in $dlfiles $dlprefiles; do
msousa@353: 	  case $file in
msousa@353: 	  *.la) ;;
msousa@353: 	  *)
msousa@353: 	    func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	done
msousa@353: 	;;
msousa@353:     prog)
msousa@353: 	compile_deplibs=
msousa@353: 	finalize_deplibs=
msousa@353: 	alldeplibs=no
msousa@353: 	newdlfiles=
msousa@353: 	newdlprefiles=
msousa@353: 	passes="conv scan dlopen dlpreopen link"
msousa@353: 	;;
msousa@353:     *)  passes="conv"
msousa@353: 	;;
msousa@353:     esac
msousa@353: 
msousa@353:     for pass in $passes; do
msousa@353:       # The preopen pass in lib mode reverses $deplibs; put it back here
msousa@353:       # so that -L comes before libs that need it for instance...
msousa@353:       if test "$linkmode,$pass" = "lib,link"; then
msousa@353: 	## FIXME: Find the place where the list is rebuilt in the wrong
msousa@353: 	##        order, and fix it there properly
msousa@353:         tmp_deplibs=
msousa@353: 	for deplib in $deplibs; do
msousa@353: 	  tmp_deplibs="$deplib $tmp_deplibs"
msousa@353: 	done
msousa@353: 	deplibs="$tmp_deplibs"
msousa@353:       fi
msousa@353: 
msousa@353:       if test "$linkmode,$pass" = "lib,link" ||
msousa@353: 	 test "$linkmode,$pass" = "prog,scan"; then
msousa@353: 	libs="$deplibs"
msousa@353: 	deplibs=
msousa@353:       fi
msousa@353:       if test "$linkmode" = prog; then
msousa@353: 	case $pass in
msousa@353: 	dlopen) libs="$dlfiles" ;;
msousa@353: 	dlpreopen) libs="$dlprefiles" ;;
msousa@353: 	link)
msousa@353: 	  libs="$deplibs %DEPLIBS%"
msousa@353: 	  test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353:       fi
msousa@353:       if test "$linkmode,$pass" = "lib,dlpreopen"; then
msousa@353: 	# Collect and forward deplibs of preopened libtool libs
msousa@353: 	for lib in $dlprefiles; do
msousa@353: 	  # Ignore non-libtool-libs
msousa@353: 	  dependency_libs=
msousa@353: 	  case $lib in
msousa@353: 	  *.la)	func_source "$lib" ;;
msousa@353: 	  esac
msousa@353: 
msousa@353: 	  # Collect preopened libtool deplibs, except any this library
msousa@353: 	  # has declared as weak libs
msousa@353: 	  for deplib in $dependency_libs; do
msousa@353:             deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
msousa@353: 	    case " $weak_libs " in
msousa@353: 	    *" $deplib_base "*) ;;
msousa@353: 	    *) deplibs="$deplibs $deplib" ;;
msousa@353: 	    esac
msousa@353: 	  done
msousa@353: 	done
msousa@353: 	libs="$dlprefiles"
msousa@353:       fi
msousa@353:       if test "$pass" = dlopen; then
msousa@353: 	# Collect dlpreopened libraries
msousa@353: 	save_deplibs="$deplibs"
msousa@353: 	deplibs=
msousa@353:       fi
msousa@353: 
msousa@353:       for deplib in $libs; do
msousa@353: 	lib=
msousa@353: 	found=no
msousa@353: 	case $deplib in
msousa@353: 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
msousa@353: 	  if test "$linkmode,$pass" = "prog,link"; then
msousa@353: 	    compile_deplibs="$deplib $compile_deplibs"
msousa@353: 	    finalize_deplibs="$deplib $finalize_deplibs"
msousa@353: 	  else
msousa@353: 	    compiler_flags="$compiler_flags $deplib"
msousa@353: 	    if test "$linkmode" = lib ; then
msousa@353: 		case "$new_inherited_linker_flags " in
msousa@353: 		    *" $deplib "*) ;;
msousa@353: 		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
msousa@353: 		esac
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	-l*)
msousa@353: 	  if test "$linkmode" != lib && test "$linkmode" != prog; then
msousa@353: 	    func_warning "\`-l' is ignored for archives/objects"
msousa@353: 	    continue
msousa@353: 	  fi
msousa@353: 	  func_stripname '-l' '' "$deplib"
msousa@353: 	  name=$func_stripname_result
msousa@353: 	  if test "$linkmode" = lib; then
msousa@353: 	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
msousa@353: 	  else
msousa@353: 	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
msousa@353: 	  fi
msousa@353: 	  for searchdir in $searchdirs; do
msousa@353: 	    for search_ext in .la $std_shrext .so .a; do
msousa@353: 	      # Search the libtool library
msousa@353: 	      lib="$searchdir/lib${name}${search_ext}"
msousa@353: 	      if test -f "$lib"; then
msousa@353: 		if test "$search_ext" = ".la"; then
msousa@353: 		  found=yes
msousa@353: 		else
msousa@353: 		  found=no
msousa@353: 		fi
msousa@353: 		break 2
msousa@353: 	      fi
msousa@353: 	    done
msousa@353: 	  done
msousa@353: 	  if test "$found" != yes; then
msousa@353: 	    # deplib doesn't seem to be a libtool library
msousa@353: 	    if test "$linkmode,$pass" = "prog,link"; then
msousa@353: 	      compile_deplibs="$deplib $compile_deplibs"
msousa@353: 	      finalize_deplibs="$deplib $finalize_deplibs"
msousa@353: 	    else
msousa@353: 	      deplibs="$deplib $deplibs"
msousa@353: 	      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
msousa@353: 	    fi
msousa@353: 	    continue
msousa@353: 	  else # deplib is a libtool library
msousa@353: 	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
msousa@353: 	    # We need to do some special things here, and not later.
msousa@353: 	    if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
msousa@353: 	      case " $predeps $postdeps " in
msousa@353: 	      *" $deplib "*)
msousa@353: 		if func_lalib_p "$lib"; then
msousa@353: 		  library_names=
msousa@353: 		  old_library=
msousa@353: 		  func_source "$lib"
msousa@353: 		  for l in $old_library $library_names; do
msousa@353: 		    ll="$l"
msousa@353: 		  done
msousa@353: 		  if test "X$ll" = "X$old_library" ; then # only static version available
msousa@353: 		    found=no
msousa@353: 		    func_dirname "$lib" "" "."
msousa@353: 		    ladir="$func_dirname_result"
msousa@353: 		    lib=$ladir/$old_library
msousa@353: 		    if test "$linkmode,$pass" = "prog,link"; then
msousa@353: 		      compile_deplibs="$deplib $compile_deplibs"
msousa@353: 		      finalize_deplibs="$deplib $finalize_deplibs"
msousa@353: 		    else
msousa@353: 		      deplibs="$deplib $deplibs"
msousa@353: 		      test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
msousa@353: 		    fi
msousa@353: 		    continue
msousa@353: 		  fi
msousa@353: 		fi
msousa@353: 		;;
msousa@353: 	      *) ;;
msousa@353: 	      esac
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	  ;; # -l
msousa@353: 	*.ltframework)
msousa@353: 	  if test "$linkmode,$pass" = "prog,link"; then
msousa@353: 	    compile_deplibs="$deplib $compile_deplibs"
msousa@353: 	    finalize_deplibs="$deplib $finalize_deplibs"
msousa@353: 	  else
msousa@353: 	    deplibs="$deplib $deplibs"
msousa@353: 	    if test "$linkmode" = lib ; then
msousa@353: 		case "$new_inherited_linker_flags " in
msousa@353: 		    *" $deplib "*) ;;
msousa@353: 		    * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
msousa@353: 		esac
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	-L*)
msousa@353: 	  case $linkmode in
msousa@353: 	  lib)
msousa@353: 	    deplibs="$deplib $deplibs"
msousa@353: 	    test "$pass" = conv && continue
msousa@353: 	    newdependency_libs="$deplib $newdependency_libs"
msousa@353: 	    func_stripname '-L' '' "$deplib"
msousa@353: 	    newlib_search_path="$newlib_search_path $func_stripname_result"
msousa@353: 	    ;;
msousa@353: 	  prog)
msousa@353: 	    if test "$pass" = conv; then
msousa@353: 	      deplibs="$deplib $deplibs"
msousa@353: 	      continue
msousa@353: 	    fi
msousa@353: 	    if test "$pass" = scan; then
msousa@353: 	      deplibs="$deplib $deplibs"
msousa@353: 	    else
msousa@353: 	      compile_deplibs="$deplib $compile_deplibs"
msousa@353: 	      finalize_deplibs="$deplib $finalize_deplibs"
msousa@353: 	    fi
msousa@353: 	    func_stripname '-L' '' "$deplib"
msousa@353: 	    newlib_search_path="$newlib_search_path $func_stripname_result"
msousa@353: 	    ;;
msousa@353: 	  *)
msousa@353: 	    func_warning "\`-L' is ignored for archives/objects"
msousa@353: 	    ;;
msousa@353: 	  esac # linkmode
msousa@353: 	  continue
msousa@353: 	  ;; # -L
msousa@353: 	-R*)
msousa@353: 	  if test "$pass" = link; then
msousa@353: 	    func_stripname '-R' '' "$deplib"
msousa@353: 	    dir=$func_stripname_result
msousa@353: 	    # Make sure the xrpath contains only unique directories.
msousa@353: 	    case "$xrpath " in
msousa@353: 	    *" $dir "*) ;;
msousa@353: 	    *) xrpath="$xrpath $dir" ;;
msousa@353: 	    esac
msousa@353: 	  fi
msousa@353: 	  deplibs="$deplib $deplibs"
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	*.la) lib="$deplib" ;;
msousa@353: 	*.$libext)
msousa@353: 	  if test "$pass" = conv; then
msousa@353: 	    deplibs="$deplib $deplibs"
msousa@353: 	    continue
msousa@353: 	  fi
msousa@353: 	  case $linkmode in
msousa@353: 	  lib)
msousa@353: 	    # Linking convenience modules into shared libraries is allowed,
msousa@353: 	    # but linking other static libraries is non-portable.
msousa@353: 	    case " $dlpreconveniencelibs " in
msousa@353: 	    *" $deplib "*) ;;
msousa@353: 	    *)
msousa@353: 	      valid_a_lib=no
msousa@353: 	      case $deplibs_check_method in
msousa@353: 		match_pattern*)
msousa@353: 		  set dummy $deplibs_check_method; shift
msousa@353: 		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
msousa@353: 		  if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
msousa@353: 		    | $EGREP "$match_pattern_regex" > /dev/null; then
msousa@353: 		    valid_a_lib=yes
msousa@353: 		  fi
msousa@353: 		;;
msousa@353: 		pass_all)
msousa@353: 		  valid_a_lib=yes
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 	      if test "$valid_a_lib" != yes; then
msousa@353: 		$ECHO
msousa@353: 		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
msousa@353: 		$ECHO "*** I have the capability to make that library automatically link in when"
msousa@353: 		$ECHO "*** you link to this library.  But I can only do this if you have a"
msousa@353: 		$ECHO "*** shared version of the library, which you do not appear to have"
msousa@353: 		$ECHO "*** because the file extensions .$libext of this argument makes me believe"
msousa@353: 		$ECHO "*** that it is just a static archive that I should not use here."
msousa@353: 	      else
msousa@353: 		$ECHO
msousa@353: 		$ECHO "*** Warning: Linking the shared library $output against the"
msousa@353: 		$ECHO "*** static library $deplib is not portable!"
msousa@353: 		deplibs="$deplib $deplibs"
msousa@353: 	      fi
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	    continue
msousa@353: 	    ;;
msousa@353: 	  prog)
msousa@353: 	    if test "$pass" != link; then
msousa@353: 	      deplibs="$deplib $deplibs"
msousa@353: 	    else
msousa@353: 	      compile_deplibs="$deplib $compile_deplibs"
msousa@353: 	      finalize_deplibs="$deplib $finalize_deplibs"
msousa@353: 	    fi
msousa@353: 	    continue
msousa@353: 	    ;;
msousa@353: 	  esac # linkmode
msousa@353: 	  ;; # *.$libext
msousa@353: 	*.lo | *.$objext)
msousa@353: 	  if test "$pass" = conv; then
msousa@353: 	    deplibs="$deplib $deplibs"
msousa@353: 	  elif test "$linkmode" = prog; then
msousa@353: 	    if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
msousa@353: 	      # If there is no dlopen support or we're linking statically,
msousa@353: 	      # we need to preload.
msousa@353: 	      newdlprefiles="$newdlprefiles $deplib"
msousa@353: 	      compile_deplibs="$deplib $compile_deplibs"
msousa@353: 	      finalize_deplibs="$deplib $finalize_deplibs"
msousa@353: 	    else
msousa@353: 	      newdlfiles="$newdlfiles $deplib"
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	%DEPLIBS%)
msousa@353: 	  alldeplibs=yes
msousa@353: 	  continue
msousa@353: 	  ;;
msousa@353: 	esac # case $deplib
msousa@353: 
msousa@353: 	if test "$found" = yes || test -f "$lib"; then :
msousa@353: 	else
msousa@353: 	  func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Check to see that this really is a libtool archive.
msousa@353: 	func_lalib_unsafe_p "$lib" \
msousa@353: 	  || func_fatal_error "\`$lib' is not a valid libtool archive"
msousa@353: 
msousa@353: 	func_dirname "$lib" "" "."
msousa@353: 	ladir="$func_dirname_result"
msousa@353: 
msousa@353: 	dlname=
msousa@353: 	dlopen=
msousa@353: 	dlpreopen=
msousa@353: 	libdir=
msousa@353: 	library_names=
msousa@353: 	old_library=
msousa@353: 	inherited_linker_flags=
msousa@353: 	# If the library was installed with an old release of libtool,
msousa@353: 	# it will not redefine variables installed, or shouldnotlink
msousa@353: 	installed=yes
msousa@353: 	shouldnotlink=no
msousa@353: 	avoidtemprpath=
msousa@353: 
msousa@353: 
msousa@353: 	# Read the .la file
msousa@353: 	func_source "$lib"
msousa@353: 
msousa@353: 	# Convert "-framework foo" to "foo.ltframework"
msousa@353: 	if test -n "$inherited_linker_flags"; then
msousa@353: 	  tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
msousa@353: 	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
msousa@353: 	    case " $new_inherited_linker_flags " in
msousa@353: 	      *" $tmp_inherited_linker_flag "*) ;;
msousa@353: 	      *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
msousa@353: 	    esac
msousa@353: 	  done
msousa@353: 	fi
msousa@353: 	dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
msousa@353: 	if test "$linkmode,$pass" = "lib,link" ||
msousa@353: 	   test "$linkmode,$pass" = "prog,scan" ||
msousa@353: 	   { test "$linkmode" != prog && test "$linkmode" != lib; }; then
msousa@353: 	  test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
msousa@353: 	  test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
msousa@353: 	fi
msousa@353: 
msousa@353: 	if test "$pass" = conv; then
msousa@353: 	  # Only check for convenience libraries
msousa@353: 	  deplibs="$lib $deplibs"
msousa@353: 	  if test -z "$libdir"; then
msousa@353: 	    if test -z "$old_library"; then
msousa@353: 	      func_fatal_error "cannot find name of link library for \`$lib'"
msousa@353: 	    fi
msousa@353: 	    # It is a libtool convenience library, so add in its objects.
msousa@353: 	    convenience="$convenience $ladir/$objdir/$old_library"
msousa@353: 	    old_convenience="$old_convenience $ladir/$objdir/$old_library"
msousa@353: 	    tmp_libs=
msousa@353: 	    for deplib in $dependency_libs; do
msousa@353: 	      deplibs="$deplib $deplibs"
msousa@353: 	      if $opt_duplicate_deps ; then
msousa@353: 		case "$tmp_libs " in
msousa@353: 		*" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
msousa@353: 		esac
msousa@353: 	      fi
msousa@353: 	      tmp_libs="$tmp_libs $deplib"
msousa@353: 	    done
msousa@353: 	  elif test "$linkmode" != prog && test "$linkmode" != lib; then
msousa@353: 	    func_fatal_error "\`$lib' is not a convenience library"
msousa@353: 	  fi
msousa@353: 	  continue
msousa@353: 	fi # $pass = conv
msousa@353: 
msousa@353: 
msousa@353: 	# Get the name of the library we link against.
msousa@353: 	linklib=
msousa@353: 	for l in $old_library $library_names; do
msousa@353: 	  linklib="$l"
msousa@353: 	done
msousa@353: 	if test -z "$linklib"; then
msousa@353: 	  func_fatal_error "cannot find name of link library for \`$lib'"
msousa@353: 	fi
msousa@353: 
msousa@353: 	# This library was specified with -dlopen.
msousa@353: 	if test "$pass" = dlopen; then
msousa@353: 	  if test -z "$libdir"; then
msousa@353: 	    func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
msousa@353: 	  fi
msousa@353: 	  if test -z "$dlname" ||
msousa@353: 	     test "$dlopen_support" != yes ||
msousa@353: 	     test "$build_libtool_libs" = no; then
msousa@353: 	    # If there is no dlname, no dlopen support or we're linking
msousa@353: 	    # statically, we need to preload.  We also need to preload any
msousa@353: 	    # dependent libraries so libltdl's deplib preloader doesn't
msousa@353: 	    # bomb out in the load deplibs phase.
msousa@353: 	    dlprefiles="$dlprefiles $lib $dependency_libs"
msousa@353: 	  else
msousa@353: 	    newdlfiles="$newdlfiles $lib"
msousa@353: 	  fi
msousa@353: 	  continue
msousa@353: 	fi # $pass = dlopen
msousa@353: 
msousa@353: 	# We need an absolute path.
msousa@353: 	case $ladir in
msousa@353: 	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
msousa@353: 	*)
msousa@353: 	  abs_ladir=`cd "$ladir" && pwd`
msousa@353: 	  if test -z "$abs_ladir"; then
msousa@353: 	    func_warning "cannot determine absolute directory name of \`$ladir'"
msousa@353: 	    func_warning "passing it literally to the linker, although it might fail"
msousa@353: 	    abs_ladir="$ladir"
msousa@353: 	  fi
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	func_basename "$lib"
msousa@353: 	laname="$func_basename_result"
msousa@353: 
msousa@353: 	# Find the relevant object directory and library name.
msousa@353: 	if test "X$installed" = Xyes; then
msousa@353: 	  if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
msousa@353: 	    func_warning "library \`$lib' was moved."
msousa@353: 	    dir="$ladir"
msousa@353: 	    absdir="$abs_ladir"
msousa@353: 	    libdir="$abs_ladir"
msousa@353: 	  else
msousa@353: 	    dir="$libdir"
msousa@353: 	    absdir="$libdir"
msousa@353: 	  fi
msousa@353: 	  test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
msousa@353: 	else
msousa@353: 	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
msousa@353: 	    dir="$ladir"
msousa@353: 	    absdir="$abs_ladir"
msousa@353: 	    # Remove this search path later
msousa@353: 	    notinst_path="$notinst_path $abs_ladir"
msousa@353: 	  else
msousa@353: 	    dir="$ladir/$objdir"
msousa@353: 	    absdir="$abs_ladir/$objdir"
msousa@353: 	    # Remove this search path later
msousa@353: 	    notinst_path="$notinst_path $abs_ladir"
msousa@353: 	  fi
msousa@353: 	fi # $installed = yes
msousa@353: 	func_stripname 'lib' '.la' "$laname"
msousa@353: 	name=$func_stripname_result
msousa@353: 
msousa@353: 	# This library was specified with -dlpreopen.
msousa@353: 	if test "$pass" = dlpreopen; then
msousa@353: 	  if test -z "$libdir" && test "$linkmode" = prog; then
msousa@353: 	    func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
msousa@353: 	  fi
msousa@353: 	  # Prefer using a static library (so that no silly _DYNAMIC symbols
msousa@353: 	  # are required to link).
msousa@353: 	  if test -n "$old_library"; then
msousa@353: 	    newdlprefiles="$newdlprefiles $dir/$old_library"
msousa@353: 	    # Keep a list of preopened convenience libraries to check
msousa@353: 	    # that they are being used correctly in the link pass.
msousa@353: 	    test -z "$libdir" && \
msousa@353: 		dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
msousa@353: 	  # Otherwise, use the dlname, so that lt_dlopen finds it.
msousa@353: 	  elif test -n "$dlname"; then
msousa@353: 	    newdlprefiles="$newdlprefiles $dir/$dlname"
msousa@353: 	  else
msousa@353: 	    newdlprefiles="$newdlprefiles $dir/$linklib"
msousa@353: 	  fi
msousa@353: 	fi # $pass = dlpreopen
msousa@353: 
msousa@353: 	if test -z "$libdir"; then
msousa@353: 	  # Link the convenience library
msousa@353: 	  if test "$linkmode" = lib; then
msousa@353: 	    deplibs="$dir/$old_library $deplibs"
msousa@353: 	  elif test "$linkmode,$pass" = "prog,link"; then
msousa@353: 	    compile_deplibs="$dir/$old_library $compile_deplibs"
msousa@353: 	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
msousa@353: 	  else
msousa@353: 	    deplibs="$lib $deplibs" # used for prog,scan pass
msousa@353: 	  fi
msousa@353: 	  continue
msousa@353: 	fi
msousa@353: 
msousa@353: 
msousa@353: 	if test "$linkmode" = prog && test "$pass" != link; then
msousa@353: 	  newlib_search_path="$newlib_search_path $ladir"
msousa@353: 	  deplibs="$lib $deplibs"
msousa@353: 
msousa@353: 	  linkalldeplibs=no
msousa@353: 	  if test "$link_all_deplibs" != no || test -z "$library_names" ||
msousa@353: 	     test "$build_libtool_libs" = no; then
msousa@353: 	    linkalldeplibs=yes
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  tmp_libs=
msousa@353: 	  for deplib in $dependency_libs; do
msousa@353: 	    case $deplib in
msousa@353: 	    -L*) func_stripname '-L' '' "$deplib"
msousa@353: 	         newlib_search_path="$newlib_search_path $func_stripname_result"
msousa@353: 		 ;;
msousa@353: 	    esac
msousa@353: 	    # Need to link against all dependency_libs?
msousa@353: 	    if test "$linkalldeplibs" = yes; then
msousa@353: 	      deplibs="$deplib $deplibs"
msousa@353: 	    else
msousa@353: 	      # Need to hardcode shared library paths
msousa@353: 	      # or/and link against static libraries
msousa@353: 	      newdependency_libs="$deplib $newdependency_libs"
msousa@353: 	    fi
msousa@353: 	    if $opt_duplicate_deps ; then
msousa@353: 	      case "$tmp_libs " in
msousa@353: 	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
msousa@353: 	      esac
msousa@353: 	    fi
msousa@353: 	    tmp_libs="$tmp_libs $deplib"
msousa@353: 	  done # for deplib
msousa@353: 	  continue
msousa@353: 	fi # $linkmode = prog...
msousa@353: 
msousa@353: 	if test "$linkmode,$pass" = "prog,link"; then
msousa@353: 	  if test -n "$library_names" &&
msousa@353: 	     { { test "$prefer_static_libs" = no ||
msousa@353: 	         test "$prefer_static_libs,$installed" = "built,yes"; } ||
msousa@353: 	       test -z "$old_library"; }; then
msousa@353: 	    # We need to hardcode the library path
msousa@353: 	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
msousa@353: 	      # Make sure the rpath contains only unique directories.
msousa@353: 	      case "$temp_rpath:" in
msousa@353: 	      *"$absdir:"*) ;;
msousa@353: 	      *) temp_rpath="$temp_rpath$absdir:" ;;
msousa@353: 	      esac
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    # Hardcode the library path.
msousa@353: 	    # Skip directories that are in the system default run-time
msousa@353: 	    # search path.
msousa@353: 	    case " $sys_lib_dlsearch_path " in
msousa@353: 	    *" $absdir "*) ;;
msousa@353: 	    *)
msousa@353: 	      case "$compile_rpath " in
msousa@353: 	      *" $absdir "*) ;;
msousa@353: 	      *) compile_rpath="$compile_rpath $absdir"
msousa@353: 	      esac
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	    case " $sys_lib_dlsearch_path " in
msousa@353: 	    *" $libdir "*) ;;
msousa@353: 	    *)
msousa@353: 	      case "$finalize_rpath " in
msousa@353: 	      *" $libdir "*) ;;
msousa@353: 	      *) finalize_rpath="$finalize_rpath $libdir"
msousa@353: 	      esac
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	  fi # $linkmode,$pass = prog,link...
msousa@353: 
msousa@353: 	  if test "$alldeplibs" = yes &&
msousa@353: 	     { test "$deplibs_check_method" = pass_all ||
msousa@353: 	       { test "$build_libtool_libs" = yes &&
msousa@353: 		 test -n "$library_names"; }; }; then
msousa@353: 	    # We only need to search for static libraries
msousa@353: 	    continue
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 
msousa@353: 	link_static=no # Whether the deplib will be linked statically
msousa@353: 	use_static_libs=$prefer_static_libs
msousa@353: 	if test "$use_static_libs" = built && test "$installed" = yes; then
msousa@353: 	  use_static_libs=no
msousa@353: 	fi
msousa@353: 	if test -n "$library_names" &&
msousa@353: 	   { test "$use_static_libs" = no || test -z "$old_library"; }; then
msousa@353: 	  case $host in
msousa@353: 	  *cygwin* | *mingw* | *cegcc*)
msousa@353: 	      # No point in relinking DLLs because paths are not encoded
msousa@353: 	      notinst_deplibs="$notinst_deplibs $lib"
msousa@353: 	      need_relink=no
msousa@353: 	    ;;
msousa@353: 	  *)
msousa@353: 	    if test "$installed" = no; then
msousa@353: 	      notinst_deplibs="$notinst_deplibs $lib"
msousa@353: 	      need_relink=yes
msousa@353: 	    fi
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  # This is a shared library
msousa@353: 
msousa@353: 	  # Warn about portability, can't link against -module's on some
msousa@353: 	  # systems (darwin).  Don't bleat about dlopened modules though!
msousa@353: 	  dlopenmodule=""
msousa@353: 	  for dlpremoduletest in $dlprefiles; do
msousa@353: 	    if test "X$dlpremoduletest" = "X$lib"; then
msousa@353: 	      dlopenmodule="$dlpremoduletest"
msousa@353: 	      break
msousa@353: 	    fi
msousa@353: 	  done
msousa@353: 	  if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
msousa@353: 	    $ECHO
msousa@353: 	    if test "$linkmode" = prog; then
msousa@353: 	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
msousa@353: 	    else
msousa@353: 	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
msousa@353: 	    fi
msousa@353: 	    $ECHO "*** $linklib is not portable!"
msousa@353: 	  fi
msousa@353: 	  if test "$linkmode" = lib &&
msousa@353: 	     test "$hardcode_into_libs" = yes; then
msousa@353: 	    # Hardcode the library path.
msousa@353: 	    # Skip directories that are in the system default run-time
msousa@353: 	    # search path.
msousa@353: 	    case " $sys_lib_dlsearch_path " in
msousa@353: 	    *" $absdir "*) ;;
msousa@353: 	    *)
msousa@353: 	      case "$compile_rpath " in
msousa@353: 	      *" $absdir "*) ;;
msousa@353: 	      *) compile_rpath="$compile_rpath $absdir"
msousa@353: 	      esac
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	    case " $sys_lib_dlsearch_path " in
msousa@353: 	    *" $libdir "*) ;;
msousa@353: 	    *)
msousa@353: 	      case "$finalize_rpath " in
msousa@353: 	      *" $libdir "*) ;;
msousa@353: 	      *) finalize_rpath="$finalize_rpath $libdir"
msousa@353: 	      esac
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  if test -n "$old_archive_from_expsyms_cmds"; then
msousa@353: 	    # figure out the soname
msousa@353: 	    set dummy $library_names
msousa@353: 	    shift
msousa@353: 	    realname="$1"
msousa@353: 	    shift
msousa@353: 	    libname=`eval "\\$ECHO \"$libname_spec\""`
msousa@353: 	    # use dlname if we got it. it's perfectly good, no?
msousa@353: 	    if test -n "$dlname"; then
msousa@353: 	      soname="$dlname"
msousa@353: 	    elif test -n "$soname_spec"; then
msousa@353: 	      # bleh windows
msousa@353: 	      case $host in
msousa@353: 	      *cygwin* | mingw* | *cegcc*)
msousa@353: 	        func_arith $current - $age
msousa@353: 		major=$func_arith_result
msousa@353: 		versuffix="-$major"
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 	      eval soname=\"$soname_spec\"
msousa@353: 	    else
msousa@353: 	      soname="$realname"
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    # Make a new name for the extract_expsyms_cmds to use
msousa@353: 	    soroot="$soname"
msousa@353: 	    func_basename "$soroot"
msousa@353: 	    soname="$func_basename_result"
msousa@353: 	    func_stripname 'lib' '.dll' "$soname"
msousa@353: 	    newlib=libimp-$func_stripname_result.a
msousa@353: 
msousa@353: 	    # If the library has no export list, then create one now
msousa@353: 	    if test -f "$output_objdir/$soname-def"; then :
msousa@353: 	    else
msousa@353: 	      func_verbose "extracting exported symbol list from \`$soname'"
msousa@353: 	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    # Create $newlib
msousa@353: 	    if test -f "$output_objdir/$newlib"; then :; else
msousa@353: 	      func_verbose "generating import library for \`$soname'"
msousa@353: 	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
msousa@353: 	    fi
msousa@353: 	    # make sure the library variables are pointing to the new library
msousa@353: 	    dir=$output_objdir
msousa@353: 	    linklib=$newlib
msousa@353: 	  fi # test -n "$old_archive_from_expsyms_cmds"
msousa@353: 
msousa@353: 	  if test "$linkmode" = prog || test "$mode" != relink; then
msousa@353: 	    add_shlibpath=
msousa@353: 	    add_dir=
msousa@353: 	    add=
msousa@353: 	    lib_linked=yes
msousa@353: 	    case $hardcode_action in
msousa@353: 	    immediate | unsupported)
msousa@353: 	      if test "$hardcode_direct" = no; then
msousa@353: 		add="$dir/$linklib"
msousa@353: 		case $host in
msousa@353: 		  *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
msousa@353: 		  *-*-sysv4*uw2*) add_dir="-L$dir" ;;
msousa@353: 		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
msousa@353: 		    *-*-unixware7*) add_dir="-L$dir" ;;
msousa@353: 		  *-*-darwin* )
msousa@353: 		    # if the lib is a (non-dlopened) module then we can not
msousa@353: 		    # link against it, someone is ignoring the earlier warnings
msousa@353: 		    if /usr/bin/file -L $add 2> /dev/null |
msousa@353: 			 $GREP ": [^:]* bundle" >/dev/null ; then
msousa@353: 		      if test "X$dlopenmodule" != "X$lib"; then
msousa@353: 			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
msousa@353: 			if test -z "$old_library" ; then
msousa@353: 			  $ECHO
msousa@353: 			  $ECHO "*** And there doesn't seem to be a static archive available"
msousa@353: 			  $ECHO "*** The link will probably fail, sorry"
msousa@353: 			else
msousa@353: 			  add="$dir/$old_library"
msousa@353: 			fi
msousa@353: 		      elif test -n "$old_library"; then
msousa@353: 			add="$dir/$old_library"
msousa@353: 		      fi
msousa@353: 		    fi
msousa@353: 		esac
msousa@353: 	      elif test "$hardcode_minus_L" = no; then
msousa@353: 		case $host in
msousa@353: 		*-*-sunos*) add_shlibpath="$dir" ;;
msousa@353: 		esac
msousa@353: 		add_dir="-L$dir"
msousa@353: 		add="-l$name"
msousa@353: 	      elif test "$hardcode_shlibpath_var" = no; then
msousa@353: 		add_shlibpath="$dir"
msousa@353: 		add="-l$name"
msousa@353: 	      else
msousa@353: 		lib_linked=no
msousa@353: 	      fi
msousa@353: 	      ;;
msousa@353: 	    relink)
msousa@353: 	      if test "$hardcode_direct" = yes &&
msousa@353: 	         test "$hardcode_direct_absolute" = no; then
msousa@353: 		add="$dir/$linklib"
msousa@353: 	      elif test "$hardcode_minus_L" = yes; then
msousa@353: 		add_dir="-L$dir"
msousa@353: 		# Try looking first in the location we're being installed to.
msousa@353: 		if test -n "$inst_prefix_dir"; then
msousa@353: 		  case $libdir in
msousa@353: 		    [\\/]*)
msousa@353: 		      add_dir="$add_dir -L$inst_prefix_dir$libdir"
msousa@353: 		      ;;
msousa@353: 		  esac
msousa@353: 		fi
msousa@353: 		add="-l$name"
msousa@353: 	      elif test "$hardcode_shlibpath_var" = yes; then
msousa@353: 		add_shlibpath="$dir"
msousa@353: 		add="-l$name"
msousa@353: 	      else
msousa@353: 		lib_linked=no
msousa@353: 	      fi
msousa@353: 	      ;;
msousa@353: 	    *) lib_linked=no ;;
msousa@353: 	    esac
msousa@353: 
msousa@353: 	    if test "$lib_linked" != yes; then
msousa@353: 	      func_fatal_configuration "unsupported hardcode properties"
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    if test -n "$add_shlibpath"; then
msousa@353: 	      case :$compile_shlibpath: in
msousa@353: 	      *":$add_shlibpath:"*) ;;
msousa@353: 	      *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
msousa@353: 	      esac
msousa@353: 	    fi
msousa@353: 	    if test "$linkmode" = prog; then
msousa@353: 	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
msousa@353: 	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
msousa@353: 	    else
msousa@353: 	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
msousa@353: 	      test -n "$add" && deplibs="$add $deplibs"
msousa@353: 	      if test "$hardcode_direct" != yes &&
msousa@353: 		 test "$hardcode_minus_L" != yes &&
msousa@353: 		 test "$hardcode_shlibpath_var" = yes; then
msousa@353: 		case :$finalize_shlibpath: in
msousa@353: 		*":$libdir:"*) ;;
msousa@353: 		*) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
msousa@353: 		esac
msousa@353: 	      fi
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  if test "$linkmode" = prog || test "$mode" = relink; then
msousa@353: 	    add_shlibpath=
msousa@353: 	    add_dir=
msousa@353: 	    add=
msousa@353: 	    # Finalize command for both is simple: just hardcode it.
msousa@353: 	    if test "$hardcode_direct" = yes &&
msousa@353: 	       test "$hardcode_direct_absolute" = no; then
msousa@353: 	      add="$libdir/$linklib"
msousa@353: 	    elif test "$hardcode_minus_L" = yes; then
msousa@353: 	      add_dir="-L$libdir"
msousa@353: 	      add="-l$name"
msousa@353: 	    elif test "$hardcode_shlibpath_var" = yes; then
msousa@353: 	      case :$finalize_shlibpath: in
msousa@353: 	      *":$libdir:"*) ;;
msousa@353: 	      *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
msousa@353: 	      esac
msousa@353: 	      add="-l$name"
msousa@353: 	    elif test "$hardcode_automatic" = yes; then
msousa@353: 	      if test -n "$inst_prefix_dir" &&
msousa@353: 		 test -f "$inst_prefix_dir$libdir/$linklib" ; then
msousa@353: 		add="$inst_prefix_dir$libdir/$linklib"
msousa@353: 	      else
msousa@353: 		add="$libdir/$linklib"
msousa@353: 	      fi
msousa@353: 	    else
msousa@353: 	      # We cannot seem to hardcode it, guess we'll fake it.
msousa@353: 	      add_dir="-L$libdir"
msousa@353: 	      # Try looking first in the location we're being installed to.
msousa@353: 	      if test -n "$inst_prefix_dir"; then
msousa@353: 		case $libdir in
msousa@353: 		  [\\/]*)
msousa@353: 		    add_dir="$add_dir -L$inst_prefix_dir$libdir"
msousa@353: 		    ;;
msousa@353: 		esac
msousa@353: 	      fi
msousa@353: 	      add="-l$name"
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    if test "$linkmode" = prog; then
msousa@353: 	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
msousa@353: 	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
msousa@353: 	    else
msousa@353: 	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
msousa@353: 	      test -n "$add" && deplibs="$add $deplibs"
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	elif test "$linkmode" = prog; then
msousa@353: 	  # Here we assume that one of hardcode_direct or hardcode_minus_L
msousa@353: 	  # is not unsupported.  This is valid on all known static and
msousa@353: 	  # shared platforms.
msousa@353: 	  if test "$hardcode_direct" != unsupported; then
msousa@353: 	    test -n "$old_library" && linklib="$old_library"
msousa@353: 	    compile_deplibs="$dir/$linklib $compile_deplibs"
msousa@353: 	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
msousa@353: 	  else
msousa@353: 	    compile_deplibs="-l$name -L$dir $compile_deplibs"
msousa@353: 	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
msousa@353: 	  fi
msousa@353: 	elif test "$build_libtool_libs" = yes; then
msousa@353: 	  # Not a shared library
msousa@353: 	  if test "$deplibs_check_method" != pass_all; then
msousa@353: 	    # We're trying link a shared library against a static one
msousa@353: 	    # but the system doesn't support it.
msousa@353: 
msousa@353: 	    # Just print a warning and add the library to dependency_libs so
msousa@353: 	    # that the program can be linked against the static library.
msousa@353: 	    $ECHO
msousa@353: 	    $ECHO "*** Warning: This system can not link to static lib archive $lib."
msousa@353: 	    $ECHO "*** I have the capability to make that library automatically link in when"
msousa@353: 	    $ECHO "*** you link to this library.  But I can only do this if you have a"
msousa@353: 	    $ECHO "*** shared version of the library, which you do not appear to have."
msousa@353: 	    if test "$module" = yes; then
msousa@353: 	      $ECHO "*** But as you try to build a module library, libtool will still create "
msousa@353: 	      $ECHO "*** a static module, that should work as long as the dlopening application"
msousa@353: 	      $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
msousa@353: 	      if test -z "$global_symbol_pipe"; then
msousa@353: 		$ECHO
msousa@353: 		$ECHO "*** However, this would only work if libtool was able to extract symbol"
msousa@353: 		$ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
msousa@353: 		$ECHO "*** not find such a program.  So, this module is probably useless."
msousa@353: 		$ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
msousa@353: 	      fi
msousa@353: 	      if test "$build_old_libs" = no; then
msousa@353: 		build_libtool_libs=module
msousa@353: 		build_old_libs=yes
msousa@353: 	      else
msousa@353: 		build_libtool_libs=no
msousa@353: 	      fi
msousa@353: 	    fi
msousa@353: 	  else
msousa@353: 	    deplibs="$dir/$old_library $deplibs"
msousa@353: 	    link_static=yes
msousa@353: 	  fi
msousa@353: 	fi # link shared/static library?
msousa@353: 
msousa@353: 	if test "$linkmode" = lib; then
msousa@353: 	  if test -n "$dependency_libs" &&
msousa@353: 	     { test "$hardcode_into_libs" != yes ||
msousa@353: 	       test "$build_old_libs" = yes ||
msousa@353: 	       test "$link_static" = yes; }; then
msousa@353: 	    # Extract -R from dependency_libs
msousa@353: 	    temp_deplibs=
msousa@353: 	    for libdir in $dependency_libs; do
msousa@353: 	      case $libdir in
msousa@353: 	      -R*) func_stripname '-R' '' "$libdir"
msousa@353: 	           temp_xrpath=$func_stripname_result
msousa@353: 		   case " $xrpath " in
msousa@353: 		   *" $temp_xrpath "*) ;;
msousa@353: 		   *) xrpath="$xrpath $temp_xrpath";;
msousa@353: 		   esac;;
msousa@353: 	      *) temp_deplibs="$temp_deplibs $libdir";;
msousa@353: 	      esac
msousa@353: 	    done
msousa@353: 	    dependency_libs="$temp_deplibs"
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  newlib_search_path="$newlib_search_path $absdir"
msousa@353: 	  # Link against this library
msousa@353: 	  test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
msousa@353: 	  # ... and its dependency_libs
msousa@353: 	  tmp_libs=
msousa@353: 	  for deplib in $dependency_libs; do
msousa@353: 	    newdependency_libs="$deplib $newdependency_libs"
msousa@353: 	    if $opt_duplicate_deps ; then
msousa@353: 	      case "$tmp_libs " in
msousa@353: 	      *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
msousa@353: 	      esac
msousa@353: 	    fi
msousa@353: 	    tmp_libs="$tmp_libs $deplib"
msousa@353: 	  done
msousa@353: 
msousa@353: 	  if test "$link_all_deplibs" != no; then
msousa@353: 	    # Add the search paths of all dependency libraries
msousa@353: 	    for deplib in $dependency_libs; do
msousa@353: 	      path=
msousa@353: 	      case $deplib in
msousa@353: 	      -L*) path="$deplib" ;;
msousa@353: 	      *.la)
msousa@353: 	        func_dirname "$deplib" "" "."
msousa@353: 		dir="$func_dirname_result"
msousa@353: 		# We need an absolute path.
msousa@353: 		case $dir in
msousa@353: 		[\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
msousa@353: 		*)
msousa@353: 		  absdir=`cd "$dir" && pwd`
msousa@353: 		  if test -z "$absdir"; then
msousa@353: 		    func_warning "cannot determine absolute directory name of \`$dir'"
msousa@353: 		    absdir="$dir"
msousa@353: 		  fi
msousa@353: 		  ;;
msousa@353: 		esac
msousa@353: 		if $GREP "^installed=no" $deplib > /dev/null; then
msousa@353: 		case $host in
msousa@353: 		*-*-darwin*)
msousa@353: 		  depdepl=
msousa@353: 		  eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
msousa@353: 		  if test -n "$deplibrary_names" ; then
msousa@353: 		    for tmp in $deplibrary_names ; do
msousa@353: 		      depdepl=$tmp
msousa@353: 		    done
msousa@353: 		    if test -f "$absdir/$objdir/$depdepl" ; then
msousa@353: 		      depdepl="$absdir/$objdir/$depdepl"
msousa@353: 		      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
msousa@353:                       if test -z "$darwin_install_name"; then
msousa@353:                           darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
msousa@353:                       fi
msousa@353: 		      compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
msousa@353: 		      linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
msousa@353: 		      path=
msousa@353: 		    fi
msousa@353: 		  fi
msousa@353: 		  ;;
msousa@353: 		*)
msousa@353: 		  path="-L$absdir/$objdir"
msousa@353: 		  ;;
msousa@353: 		esac
msousa@353: 		else
msousa@353: 		  eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
msousa@353: 		  test -z "$libdir" && \
msousa@353: 		    func_fatal_error "\`$deplib' is not a valid libtool archive"
msousa@353: 		  test "$absdir" != "$libdir" && \
msousa@353: 		    func_warning "\`$deplib' seems to be moved"
msousa@353: 
msousa@353: 		  path="-L$absdir"
msousa@353: 		fi
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 	      case " $deplibs " in
msousa@353: 	      *" $path "*) ;;
msousa@353: 	      *) deplibs="$path $deplibs" ;;
msousa@353: 	      esac
msousa@353: 	    done
msousa@353: 	  fi # link_all_deplibs != no
msousa@353: 	fi # linkmode = lib
msousa@353:       done # for deplib in $libs
msousa@353:       if test "$pass" = link; then
msousa@353: 	if test "$linkmode" = "prog"; then
msousa@353: 	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
msousa@353: 	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
msousa@353: 	else
msousa@353: 	  compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
msousa@353: 	fi
msousa@353:       fi
msousa@353:       dependency_libs="$newdependency_libs"
msousa@353:       if test "$pass" = dlpreopen; then
msousa@353: 	# Link the dlpreopened libraries before other libraries
msousa@353: 	for deplib in $save_deplibs; do
msousa@353: 	  deplibs="$deplib $deplibs"
msousa@353: 	done
msousa@353:       fi
msousa@353:       if test "$pass" != dlopen; then
msousa@353: 	if test "$pass" != conv; then
msousa@353: 	  # Make sure lib_search_path contains only unique directories.
msousa@353: 	  lib_search_path=
msousa@353: 	  for dir in $newlib_search_path; do
msousa@353: 	    case "$lib_search_path " in
msousa@353: 	    *" $dir "*) ;;
msousa@353: 	    *) lib_search_path="$lib_search_path $dir" ;;
msousa@353: 	    esac
msousa@353: 	  done
msousa@353: 	  newlib_search_path=
msousa@353: 	fi
msousa@353: 
msousa@353: 	if test "$linkmode,$pass" != "prog,link"; then
msousa@353: 	  vars="deplibs"
msousa@353: 	else
msousa@353: 	  vars="compile_deplibs finalize_deplibs"
msousa@353: 	fi
msousa@353: 	for var in $vars dependency_libs; do
msousa@353: 	  # Add libraries to $var in reverse order
msousa@353: 	  eval tmp_libs=\"\$$var\"
msousa@353: 	  new_libs=
msousa@353: 	  for deplib in $tmp_libs; do
msousa@353: 	    # FIXME: Pedantically, this is the right thing to do, so
msousa@353: 	    #        that some nasty dependency loop isn't accidentally
msousa@353: 	    #        broken:
msousa@353: 	    #new_libs="$deplib $new_libs"
msousa@353: 	    # Pragmatically, this seems to cause very few problems in
msousa@353: 	    # practice:
msousa@353: 	    case $deplib in
msousa@353: 	    -L*) new_libs="$deplib $new_libs" ;;
msousa@353: 	    -R*) ;;
msousa@353: 	    *)
msousa@353: 	      # And here is the reason: when a library appears more
msousa@353: 	      # than once as an explicit dependence of a library, or
msousa@353: 	      # is implicitly linked in more than once by the
msousa@353: 	      # compiler, it is considered special, and multiple
msousa@353: 	      # occurrences thereof are not removed.  Compare this
msousa@353: 	      # with having the same library being listed as a
msousa@353: 	      # dependency of multiple other libraries: in this case,
msousa@353: 	      # we know (pedantically, we assume) the library does not
msousa@353: 	      # need to be listed more than once, so we keep only the
msousa@353: 	      # last copy.  This is not always right, but it is rare
msousa@353: 	      # enough that we require users that really mean to play
msousa@353: 	      # such unportable linking tricks to link the library
msousa@353: 	      # using -Wl,-lname, so that libtool does not consider it
msousa@353: 	      # for duplicate removal.
msousa@353: 	      case " $specialdeplibs " in
msousa@353: 	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
msousa@353: 	      *)
msousa@353: 		case " $new_libs " in
msousa@353: 		*" $deplib "*) ;;
msousa@353: 		*) new_libs="$deplib $new_libs" ;;
msousa@353: 		esac
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	  done
msousa@353: 	  tmp_libs=
msousa@353: 	  for deplib in $new_libs; do
msousa@353: 	    case $deplib in
msousa@353: 	    -L*)
msousa@353: 	      case " $tmp_libs " in
msousa@353: 	      *" $deplib "*) ;;
msousa@353: 	      *) tmp_libs="$tmp_libs $deplib" ;;
msousa@353: 	      esac
msousa@353: 	      ;;
msousa@353: 	    *) tmp_libs="$tmp_libs $deplib" ;;
msousa@353: 	    esac
msousa@353: 	  done
msousa@353: 	  eval $var=\"$tmp_libs\"
msousa@353: 	done # for var
msousa@353:       fi
msousa@353:       # Last step: remove runtime libs from dependency_libs
msousa@353:       # (they stay in deplibs)
msousa@353:       tmp_libs=
msousa@353:       for i in $dependency_libs ; do
msousa@353: 	case " $predeps $postdeps $compiler_lib_search_path " in
msousa@353: 	*" $i "*)
msousa@353: 	  i=""
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	if test -n "$i" ; then
msousa@353: 	  tmp_libs="$tmp_libs $i"
msousa@353: 	fi
msousa@353:       done
msousa@353:       dependency_libs=$tmp_libs
msousa@353:     done # for pass
msousa@353:     if test "$linkmode" = prog; then
msousa@353:       dlfiles="$newdlfiles"
msousa@353:     fi
msousa@353:     if test "$linkmode" = prog || test "$linkmode" = lib; then
msousa@353:       dlprefiles="$newdlprefiles"
msousa@353:     fi
msousa@353: 
msousa@353:     case $linkmode in
msousa@353:     oldlib)
msousa@353:       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
msousa@353: 	func_warning "\`-dlopen' is ignored for archives"
msousa@353:       fi
msousa@353: 
msousa@353:       case " $deplibs" in
msousa@353:       *\ -l* | *\ -L*)
msousa@353: 	func_warning "\`-l' and \`-L' are ignored for archives" ;;
msousa@353:       esac
msousa@353: 
msousa@353:       test -n "$rpath" && \
msousa@353: 	func_warning "\`-rpath' is ignored for archives"
msousa@353: 
msousa@353:       test -n "$xrpath" && \
msousa@353: 	func_warning "\`-R' is ignored for archives"
msousa@353: 
msousa@353:       test -n "$vinfo" && \
msousa@353: 	func_warning "\`-version-info/-version-number' is ignored for archives"
msousa@353: 
msousa@353:       test -n "$release" && \
msousa@353: 	func_warning "\`-release' is ignored for archives"
msousa@353: 
msousa@353:       test -n "$export_symbols$export_symbols_regex" && \
msousa@353: 	func_warning "\`-export-symbols' is ignored for archives"
msousa@353: 
msousa@353:       # Now set the variables for building old libraries.
msousa@353:       build_libtool_libs=no
msousa@353:       oldlibs="$output"
msousa@353:       objs="$objs$old_deplibs"
msousa@353:       ;;
msousa@353: 
msousa@353:     lib)
msousa@353:       # Make sure we only generate libraries of the form `libNAME.la'.
msousa@353:       case $outputname in
msousa@353:       lib*)
msousa@353: 	func_stripname 'lib' '.la' "$outputname"
msousa@353: 	name=$func_stripname_result
msousa@353: 	eval shared_ext=\"$shrext_cmds\"
msousa@353: 	eval libname=\"$libname_spec\"
msousa@353: 	;;
msousa@353:       *)
msousa@353: 	test "$module" = no && \
msousa@353: 	  func_fatal_help "libtool library \`$output' must begin with \`lib'"
msousa@353: 
msousa@353: 	if test "$need_lib_prefix" != no; then
msousa@353: 	  # Add the "lib" prefix for modules if required
msousa@353: 	  func_stripname '' '.la' "$outputname"
msousa@353: 	  name=$func_stripname_result
msousa@353: 	  eval shared_ext=\"$shrext_cmds\"
msousa@353: 	  eval libname=\"$libname_spec\"
msousa@353: 	else
msousa@353: 	  func_stripname '' '.la' "$outputname"
msousa@353: 	  libname=$func_stripname_result
msousa@353: 	fi
msousa@353: 	;;
msousa@353:       esac
msousa@353: 
msousa@353:       if test -n "$objs"; then
msousa@353: 	if test "$deplibs_check_method" != pass_all; then
msousa@353: 	  func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
msousa@353: 	else
msousa@353: 	  $ECHO
msousa@353: 	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
msousa@353: 	  $ECHO "*** objects $objs is not portable!"
msousa@353: 	  libobjs="$libobjs $objs"
msousa@353: 	fi
msousa@353:       fi
msousa@353: 
msousa@353:       test "$dlself" != no && \
msousa@353: 	func_warning "\`-dlopen self' is ignored for libtool libraries"
msousa@353: 
msousa@353:       set dummy $rpath
msousa@353:       shift
msousa@353:       test "$#" -gt 1 && \
msousa@353: 	func_warning "ignoring multiple \`-rpath's for a libtool library"
msousa@353: 
msousa@353:       install_libdir="$1"
msousa@353: 
msousa@353:       oldlibs=
msousa@353:       if test -z "$rpath"; then
msousa@353: 	if test "$build_libtool_libs" = yes; then
msousa@353: 	  # Building a libtool convenience library.
msousa@353: 	  # Some compilers have problems with a `.al' extension so
msousa@353: 	  # convenience libraries should have the same extension an
msousa@353: 	  # archive normally would.
msousa@353: 	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
msousa@353: 	  build_libtool_libs=convenience
msousa@353: 	  build_old_libs=yes
msousa@353: 	fi
msousa@353: 
msousa@353: 	test -n "$vinfo" && \
msousa@353: 	  func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
msousa@353: 
msousa@353: 	test -n "$release" && \
msousa@353: 	  func_warning "\`-release' is ignored for convenience libraries"
msousa@353:       else
msousa@353: 
msousa@353: 	# Parse the version information argument.
msousa@353: 	save_ifs="$IFS"; IFS=':'
msousa@353: 	set dummy $vinfo 0 0 0
msousa@353: 	shift
msousa@353: 	IFS="$save_ifs"
msousa@353: 
msousa@353: 	test -n "$7" && \
msousa@353: 	  func_fatal_help "too many parameters to \`-version-info'"
msousa@353: 
msousa@353: 	# convert absolute version numbers to libtool ages
msousa@353: 	# this retains compatibility with .la files and attempts
msousa@353: 	# to make the code below a bit more comprehensible
msousa@353: 
msousa@353: 	case $vinfo_number in
msousa@353: 	yes)
msousa@353: 	  number_major="$1"
msousa@353: 	  number_minor="$2"
msousa@353: 	  number_revision="$3"
msousa@353: 	  #
msousa@353: 	  # There are really only two kinds -- those that
msousa@353: 	  # use the current revision as the major version
msousa@353: 	  # and those that subtract age and use age as
msousa@353: 	  # a minor version.  But, then there is irix
msousa@353: 	  # which has an extra 1 added just for fun
msousa@353: 	  #
msousa@353: 	  case $version_type in
msousa@353: 	  darwin|linux|osf|windows|none)
msousa@353: 	    func_arith $number_major + $number_minor
msousa@353: 	    current=$func_arith_result
msousa@353: 	    age="$number_minor"
msousa@353: 	    revision="$number_revision"
msousa@353: 	    ;;
msousa@353: 	  freebsd-aout|freebsd-elf|sunos)
msousa@353: 	    current="$number_major"
msousa@353: 	    revision="$number_minor"
msousa@353: 	    age="0"
msousa@353: 	    ;;
msousa@353: 	  irix|nonstopux)
msousa@353: 	    func_arith $number_major + $number_minor
msousa@353: 	    current=$func_arith_result
msousa@353: 	    age="$number_minor"
msousa@353: 	    revision="$number_minor"
msousa@353: 	    lt_irix_increment=no
msousa@353: 	    ;;
msousa@353: 	  *)
msousa@353: 	    func_fatal_configuration "$modename: unknown library version type \`$version_type'"
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	no)
msousa@353: 	  current="$1"
msousa@353: 	  revision="$2"
msousa@353: 	  age="$3"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	# Check that each of the things are valid numbers.
msousa@353: 	case $current in
msousa@353: 	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]) ;;
msousa@353: 	*)
msousa@353: 	  func_error "CURRENT \`$current' must be a nonnegative integer"
msousa@353: 	  func_fatal_error "\`$vinfo' is not valid version information"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	case $revision in
msousa@353: 	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]) ;;
msousa@353: 	*)
msousa@353: 	  func_error "REVISION \`$revision' must be a nonnegative integer"
msousa@353: 	  func_fatal_error "\`$vinfo' is not valid version information"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	case $age in
msousa@353: 	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]) ;;
msousa@353: 	*)
msousa@353: 	  func_error "AGE \`$age' must be a nonnegative integer"
msousa@353: 	  func_fatal_error "\`$vinfo' is not valid version information"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	if test "$age" -gt "$current"; then
msousa@353: 	  func_error "AGE \`$age' is greater than the current interface number \`$current'"
msousa@353: 	  func_fatal_error "\`$vinfo' is not valid version information"
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Calculate the version variables.
msousa@353: 	major=
msousa@353: 	versuffix=
msousa@353: 	verstring=
msousa@353: 	case $version_type in
msousa@353: 	none) ;;
msousa@353: 
msousa@353: 	darwin)
msousa@353: 	  # Like Linux, but with the current version available in
msousa@353: 	  # verstring for coding it into the library header
msousa@353: 	  func_arith $current - $age
msousa@353: 	  major=.$func_arith_result
msousa@353: 	  versuffix="$major.$age.$revision"
msousa@353: 	  # Darwin ld doesn't like 0 for these options...
msousa@353: 	  func_arith $current + 1
msousa@353: 	  minor_current=$func_arith_result
msousa@353: 	  xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
msousa@353: 	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	freebsd-aout)
msousa@353: 	  major=".$current"
msousa@353: 	  versuffix=".$current.$revision";
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	freebsd-elf)
msousa@353: 	  major=".$current"
msousa@353: 	  versuffix=".$current"
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	irix | nonstopux)
msousa@353: 	  if test "X$lt_irix_increment" = "Xno"; then
msousa@353: 	    func_arith $current - $age
msousa@353: 	  else
msousa@353: 	    func_arith $current - $age + 1
msousa@353: 	  fi
msousa@353: 	  major=$func_arith_result
msousa@353: 
msousa@353: 	  case $version_type in
msousa@353: 	    nonstopux) verstring_prefix=nonstopux ;;
msousa@353: 	    *)         verstring_prefix=sgi ;;
msousa@353: 	  esac
msousa@353: 	  verstring="$verstring_prefix$major.$revision"
msousa@353: 
msousa@353: 	  # Add in all the interfaces that we are compatible with.
msousa@353: 	  loop=$revision
msousa@353: 	  while test "$loop" -ne 0; do
msousa@353: 	    func_arith $revision - $loop
msousa@353: 	    iface=$func_arith_result
msousa@353: 	    func_arith $loop - 1
msousa@353: 	    loop=$func_arith_result
msousa@353: 	    verstring="$verstring_prefix$major.$iface:$verstring"
msousa@353: 	  done
msousa@353: 
msousa@353: 	  # Before this point, $major must not contain `.'.
msousa@353: 	  major=.$major
msousa@353: 	  versuffix="$major.$revision"
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	linux)
msousa@353: 	  func_arith $current - $age
msousa@353: 	  major=.$func_arith_result
msousa@353: 	  versuffix="$major.$age.$revision"
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	osf)
msousa@353: 	  func_arith $current - $age
msousa@353: 	  major=.$func_arith_result
msousa@353: 	  versuffix=".$current.$age.$revision"
msousa@353: 	  verstring="$current.$age.$revision"
msousa@353: 
msousa@353: 	  # Add in all the interfaces that we are compatible with.
msousa@353: 	  loop=$age
msousa@353: 	  while test "$loop" -ne 0; do
msousa@353: 	    func_arith $current - $loop
msousa@353: 	    iface=$func_arith_result
msousa@353: 	    func_arith $loop - 1
msousa@353: 	    loop=$func_arith_result
msousa@353: 	    verstring="$verstring:${iface}.0"
msousa@353: 	  done
msousa@353: 
msousa@353: 	  # Make executables depend on our current version.
msousa@353: 	  verstring="$verstring:${current}.0"
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	qnx)
msousa@353: 	  major=".$current"
msousa@353: 	  versuffix=".$current"
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	sunos)
msousa@353: 	  major=".$current"
msousa@353: 	  versuffix=".$current.$revision"
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	windows)
msousa@353: 	  # Use '-' rather than '.', since we only want one
msousa@353: 	  # extension on DOS 8.3 filesystems.
msousa@353: 	  func_arith $current - $age
msousa@353: 	  major=$func_arith_result
msousa@353: 	  versuffix="-$major"
msousa@353: 	  ;;
msousa@353: 
msousa@353: 	*)
msousa@353: 	  func_fatal_configuration "unknown library version type \`$version_type'"
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	# Clear the version info if we defaulted, and they specified a release.
msousa@353: 	if test -z "$vinfo" && test -n "$release"; then
msousa@353: 	  major=
msousa@353: 	  case $version_type in
msousa@353: 	  darwin)
msousa@353: 	    # we can't check for "0.0" in archive_cmds due to quoting
msousa@353: 	    # problems, so we reset it completely
msousa@353: 	    verstring=
msousa@353: 	    ;;
msousa@353: 	  *)
msousa@353: 	    verstring="0.0"
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  if test "$need_version" = no; then
msousa@353: 	    versuffix=
msousa@353: 	  else
msousa@353: 	    versuffix=".0.0"
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Remove version info from name if versioning should be avoided
msousa@353: 	if test "$avoid_version" = yes && test "$need_version" = no; then
msousa@353: 	  major=
msousa@353: 	  versuffix=
msousa@353: 	  verstring=""
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Check to see if the archive will have undefined symbols.
msousa@353: 	if test "$allow_undefined" = yes; then
msousa@353: 	  if test "$allow_undefined_flag" = unsupported; then
msousa@353: 	    func_warning "undefined symbols not allowed in $host shared libraries"
msousa@353: 	    build_libtool_libs=no
msousa@353: 	    build_old_libs=yes
msousa@353: 	  fi
msousa@353: 	else
msousa@353: 	  # Don't allow undefined symbols.
msousa@353: 	  allow_undefined_flag="$no_undefined_flag"
msousa@353: 	fi
msousa@353: 
msousa@353:       fi
msousa@353: 
msousa@353:       func_generate_dlsyms "$libname" "$libname" "yes"
msousa@353:       libobjs="$libobjs $symfileobj"
msousa@353:       test "X$libobjs" = "X " && libobjs=
msousa@353: 
msousa@353:       if test "$mode" != relink; then
msousa@353: 	# Remove our outputs, but don't remove object files since they
msousa@353: 	# may have been created when compiling PIC objects.
msousa@353: 	removelist=
msousa@353: 	tempremovelist=`$ECHO "$output_objdir/*"`
msousa@353: 	for p in $tempremovelist; do
msousa@353: 	  case $p in
msousa@353: 	    *.$objext | *.gcno)
msousa@353: 	       ;;
msousa@353: 	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
msousa@353: 	       if test "X$precious_files_regex" != "X"; then
msousa@353: 		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
msousa@353: 		 then
msousa@353: 		   continue
msousa@353: 		 fi
msousa@353: 	       fi
msousa@353: 	       removelist="$removelist $p"
msousa@353: 	       ;;
msousa@353: 	    *) ;;
msousa@353: 	  esac
msousa@353: 	done
msousa@353: 	test -n "$removelist" && \
msousa@353: 	  func_show_eval "${RM}r \$removelist"
msousa@353:       fi
msousa@353: 
msousa@353:       # Now set the variables for building old libraries.
msousa@353:       if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
msousa@353: 	oldlibs="$oldlibs $output_objdir/$libname.$libext"
msousa@353: 
msousa@353: 	# Transform .lo files to .o files.
msousa@353: 	oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
msousa@353:       fi
msousa@353: 
msousa@353:       # Eliminate all temporary directories.
msousa@353:       #for path in $notinst_path; do
msousa@353:       #	lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
msousa@353:       #	deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
msousa@353:       #	dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
msousa@353:       #done
msousa@353: 
msousa@353:       if test -n "$xrpath"; then
msousa@353: 	# If the user specified any rpath flags, then add them.
msousa@353: 	temp_xrpath=
msousa@353: 	for libdir in $xrpath; do
msousa@353: 	  temp_xrpath="$temp_xrpath -R$libdir"
msousa@353: 	  case "$finalize_rpath " in
msousa@353: 	  *" $libdir "*) ;;
msousa@353: 	  *) finalize_rpath="$finalize_rpath $libdir" ;;
msousa@353: 	  esac
msousa@353: 	done
msousa@353: 	if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
msousa@353: 	  dependency_libs="$temp_xrpath $dependency_libs"
msousa@353: 	fi
msousa@353:       fi
msousa@353: 
msousa@353:       # Make sure dlfiles contains only unique files that won't be dlpreopened
msousa@353:       old_dlfiles="$dlfiles"
msousa@353:       dlfiles=
msousa@353:       for lib in $old_dlfiles; do
msousa@353: 	case " $dlprefiles $dlfiles " in
msousa@353: 	*" $lib "*) ;;
msousa@353: 	*) dlfiles="$dlfiles $lib" ;;
msousa@353: 	esac
msousa@353:       done
msousa@353: 
msousa@353:       # Make sure dlprefiles contains only unique files
msousa@353:       old_dlprefiles="$dlprefiles"
msousa@353:       dlprefiles=
msousa@353:       for lib in $old_dlprefiles; do
msousa@353: 	case "$dlprefiles " in
msousa@353: 	*" $lib "*) ;;
msousa@353: 	*) dlprefiles="$dlprefiles $lib" ;;
msousa@353: 	esac
msousa@353:       done
msousa@353: 
msousa@353:       if test "$build_libtool_libs" = yes; then
msousa@353: 	if test -n "$rpath"; then
msousa@353: 	  case $host in
msousa@353: 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
msousa@353: 	    # these systems don't actually have a c library (as such)!
msousa@353: 	    ;;
msousa@353: 	  *-*-rhapsody* | *-*-darwin1.[012])
msousa@353: 	    # Rhapsody C library is in the System framework
msousa@353: 	    deplibs="$deplibs System.ltframework"
msousa@353: 	    ;;
msousa@353: 	  *-*-netbsd*)
msousa@353: 	    # Don't link with libc until the a.out ld.so is fixed.
msousa@353: 	    ;;
msousa@353: 	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
msousa@353: 	    # Do not include libc due to us having libc/libc_r.
msousa@353: 	    ;;
msousa@353: 	  *-*-sco3.2v5* | *-*-sco5v6*)
msousa@353: 	    # Causes problems with __ctype
msousa@353: 	    ;;
msousa@353: 	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
msousa@353: 	    # Compiler inserts libc in the correct place for threads to work
msousa@353: 	    ;;
msousa@353: 	  *)
msousa@353: 	    # Add libc to deplibs on all other systems if necessary.
msousa@353: 	    if test "$build_libtool_need_lc" = "yes"; then
msousa@353: 	      deplibs="$deplibs -lc"
msousa@353: 	    fi
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Transform deplibs into only deplibs that can be linked in shared.
msousa@353: 	name_save=$name
msousa@353: 	libname_save=$libname
msousa@353: 	release_save=$release
msousa@353: 	versuffix_save=$versuffix
msousa@353: 	major_save=$major
msousa@353: 	# I'm not sure if I'm treating the release correctly.  I think
msousa@353: 	# release should show up in the -l (ie -lgmp5) so we don't want to
msousa@353: 	# add it in twice.  Is that correct?
msousa@353: 	release=""
msousa@353: 	versuffix=""
msousa@353: 	major=""
msousa@353: 	newdeplibs=
msousa@353: 	droppeddeps=no
msousa@353: 	case $deplibs_check_method in
msousa@353: 	pass_all)
msousa@353: 	  # Don't check for shared/static.  Everything works.
msousa@353: 	  # This might be a little naive.  We might want to check
msousa@353: 	  # whether the library exists or not.  But this is on
msousa@353: 	  # osf3 & osf4 and I'm not really sure... Just
msousa@353: 	  # implementing what was already the behavior.
msousa@353: 	  newdeplibs=$deplibs
msousa@353: 	  ;;
msousa@353: 	test_compile)
msousa@353: 	  # This code stresses the "libraries are programs" paradigm to its
msousa@353: 	  # limits. Maybe even breaks it.  We compile a program, linking it
msousa@353: 	  # against the deplibs as a proxy for the library.  Then we can check
msousa@353: 	  # whether they linked in statically or dynamically with ldd.
msousa@353: 	  $opt_dry_run || $RM conftest.c
msousa@353: 	  cat > conftest.c <<EOF
msousa@353: 	  int main() { return 0; }
msousa@353: EOF
msousa@353: 	  $opt_dry_run || $RM conftest
msousa@353: 	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
msousa@353: 	    ldd_output=`ldd conftest`
msousa@353: 	    for i in $deplibs; do
msousa@353: 	      case $i in
msousa@353: 	      -l*)
msousa@353: 		func_stripname -l '' "$i"
msousa@353: 		name=$func_stripname_result
msousa@353: 		if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
msousa@353: 		  case " $predeps $postdeps " in
msousa@353: 		  *" $i "*)
msousa@353: 		    newdeplibs="$newdeplibs $i"
msousa@353: 		    i=""
msousa@353: 		    ;;
msousa@353: 		  esac
msousa@353: 		fi
msousa@353: 		if test -n "$i" ; then
msousa@353: 		  libname=`eval "\\$ECHO \"$libname_spec\""`
msousa@353: 		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
msousa@353: 		  set dummy $deplib_matches; shift
msousa@353: 		  deplib_match=$1
msousa@353: 		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
msousa@353: 		    newdeplibs="$newdeplibs $i"
msousa@353: 		  else
msousa@353: 		    droppeddeps=yes
msousa@353: 		    $ECHO
msousa@353: 		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
msousa@353: 		    $ECHO "*** I have the capability to make that library automatically link in when"
msousa@353: 		    $ECHO "*** you link to this library.  But I can only do this if you have a"
msousa@353: 		    $ECHO "*** shared version of the library, which I believe you do not have"
msousa@353: 		    $ECHO "*** because a test_compile did reveal that the linker did not use it for"
msousa@353: 		    $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
msousa@353: 		  fi
msousa@353: 		fi
msousa@353: 		;;
msousa@353: 	      *)
msousa@353: 		newdeplibs="$newdeplibs $i"
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 	    done
msousa@353: 	  else
msousa@353: 	    # Error occurred in the first compile.  Let's try to salvage
msousa@353: 	    # the situation: Compile a separate program for each library.
msousa@353: 	    for i in $deplibs; do
msousa@353: 	      case $i in
msousa@353: 	      -l*)
msousa@353: 		func_stripname -l '' "$i"
msousa@353: 		name=$func_stripname_result
msousa@353: 		$opt_dry_run || $RM conftest
msousa@353: 		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
msousa@353: 		  ldd_output=`ldd conftest`
msousa@353: 		  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
msousa@353: 		    case " $predeps $postdeps " in
msousa@353: 		    *" $i "*)
msousa@353: 		      newdeplibs="$newdeplibs $i"
msousa@353: 		      i=""
msousa@353: 		      ;;
msousa@353: 		    esac
msousa@353: 		  fi
msousa@353: 		  if test -n "$i" ; then
msousa@353: 		    libname=`eval "\\$ECHO \"$libname_spec\""`
msousa@353: 		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
msousa@353: 		    set dummy $deplib_matches; shift
msousa@353: 		    deplib_match=$1
msousa@353: 		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
msousa@353: 		      newdeplibs="$newdeplibs $i"
msousa@353: 		    else
msousa@353: 		      droppeddeps=yes
msousa@353: 		      $ECHO
msousa@353: 		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
msousa@353: 		      $ECHO "*** I have the capability to make that library automatically link in when"
msousa@353: 		      $ECHO "*** you link to this library.  But I can only do this if you have a"
msousa@353: 		      $ECHO "*** shared version of the library, which you do not appear to have"
msousa@353: 		      $ECHO "*** because a test_compile did reveal that the linker did not use this one"
msousa@353: 		      $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
msousa@353: 		    fi
msousa@353: 		  fi
msousa@353: 		else
msousa@353: 		  droppeddeps=yes
msousa@353: 		  $ECHO
msousa@353: 		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
msousa@353: 		  $ECHO "*** make it link in!  You will probably need to install it or some"
msousa@353: 		  $ECHO "*** library that it depends on before this library will be fully"
msousa@353: 		  $ECHO "*** functional.  Installing it before continuing would be even better."
msousa@353: 		fi
msousa@353: 		;;
msousa@353: 	      *)
msousa@353: 		newdeplibs="$newdeplibs $i"
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 	    done
msousa@353: 	  fi
msousa@353: 	  ;;
msousa@353: 	file_magic*)
msousa@353: 	  set dummy $deplibs_check_method; shift
msousa@353: 	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
msousa@353: 	  for a_deplib in $deplibs; do
msousa@353: 	    case $a_deplib in
msousa@353: 	    -l*)
msousa@353: 	      func_stripname -l '' "$a_deplib"
msousa@353: 	      name=$func_stripname_result
msousa@353: 	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
msousa@353: 		case " $predeps $postdeps " in
msousa@353: 		*" $a_deplib "*)
msousa@353: 		  newdeplibs="$newdeplibs $a_deplib"
msousa@353: 		  a_deplib=""
msousa@353: 		  ;;
msousa@353: 		esac
msousa@353: 	      fi
msousa@353: 	      if test -n "$a_deplib" ; then
msousa@353: 		libname=`eval "\\$ECHO \"$libname_spec\""`
msousa@353: 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
msousa@353: 		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
msousa@353: 		  for potent_lib in $potential_libs; do
msousa@353: 		      # Follow soft links.
msousa@353: 		      if ls -lLd "$potent_lib" 2>/dev/null |
msousa@353: 			 $GREP " -> " >/dev/null; then
msousa@353: 			continue
msousa@353: 		      fi
msousa@353: 		      # The statement above tries to avoid entering an
msousa@353: 		      # endless loop below, in case of cyclic links.
msousa@353: 		      # We might still enter an endless loop, since a link
msousa@353: 		      # loop can be closed while we follow links,
msousa@353: 		      # but so what?
msousa@353: 		      potlib="$potent_lib"
msousa@353: 		      while test -h "$potlib" 2>/dev/null; do
msousa@353: 			potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
msousa@353: 			case $potliblink in
msousa@353: 			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
msousa@353: 			*) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
msousa@353: 			esac
msousa@353: 		      done
msousa@353: 		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
msousa@353: 			 $SED -e 10q |
msousa@353: 			 $EGREP "$file_magic_regex" > /dev/null; then
msousa@353: 			newdeplibs="$newdeplibs $a_deplib"
msousa@353: 			a_deplib=""
msousa@353: 			break 2
msousa@353: 		      fi
msousa@353: 		  done
msousa@353: 		done
msousa@353: 	      fi
msousa@353: 	      if test -n "$a_deplib" ; then
msousa@353: 		droppeddeps=yes
msousa@353: 		$ECHO
msousa@353: 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
msousa@353: 		$ECHO "*** I have the capability to make that library automatically link in when"
msousa@353: 		$ECHO "*** you link to this library.  But I can only do this if you have a"
msousa@353: 		$ECHO "*** shared version of the library, which you do not appear to have"
msousa@353: 		$ECHO "*** because I did check the linker path looking for a file starting"
msousa@353: 		if test -z "$potlib" ; then
msousa@353: 		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
msousa@353: 		else
msousa@353: 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
msousa@353: 		  $ECHO "*** using a file magic. Last file checked: $potlib"
msousa@353: 		fi
msousa@353: 	      fi
msousa@353: 	      ;;
msousa@353: 	    *)
msousa@353: 	      # Add a -L argument.
msousa@353: 	      newdeplibs="$newdeplibs $a_deplib"
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	  done # Gone through all deplibs.
msousa@353: 	  ;;
msousa@353: 	match_pattern*)
msousa@353: 	  set dummy $deplibs_check_method; shift
msousa@353: 	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
msousa@353: 	  for a_deplib in $deplibs; do
msousa@353: 	    case $a_deplib in
msousa@353: 	    -l*)
msousa@353: 	      func_stripname -l '' "$a_deplib"
msousa@353: 	      name=$func_stripname_result
msousa@353: 	      if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
msousa@353: 		case " $predeps $postdeps " in
msousa@353: 		*" $a_deplib "*)
msousa@353: 		  newdeplibs="$newdeplibs $a_deplib"
msousa@353: 		  a_deplib=""
msousa@353: 		  ;;
msousa@353: 		esac
msousa@353: 	      fi
msousa@353: 	      if test -n "$a_deplib" ; then
msousa@353: 		libname=`eval "\\$ECHO \"$libname_spec\""`
msousa@353: 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
msousa@353: 		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
msousa@353: 		  for potent_lib in $potential_libs; do
msousa@353: 		    potlib="$potent_lib" # see symlink-check above in file_magic test
msousa@353: 		    if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
msousa@353: 		       $EGREP "$match_pattern_regex" > /dev/null; then
msousa@353: 		      newdeplibs="$newdeplibs $a_deplib"
msousa@353: 		      a_deplib=""
msousa@353: 		      break 2
msousa@353: 		    fi
msousa@353: 		  done
msousa@353: 		done
msousa@353: 	      fi
msousa@353: 	      if test -n "$a_deplib" ; then
msousa@353: 		droppeddeps=yes
msousa@353: 		$ECHO
msousa@353: 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
msousa@353: 		$ECHO "*** I have the capability to make that library automatically link in when"
msousa@353: 		$ECHO "*** you link to this library.  But I can only do this if you have a"
msousa@353: 		$ECHO "*** shared version of the library, which you do not appear to have"
msousa@353: 		$ECHO "*** because I did check the linker path looking for a file starting"
msousa@353: 		if test -z "$potlib" ; then
msousa@353: 		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
msousa@353: 		else
msousa@353: 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
msousa@353: 		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
msousa@353: 		fi
msousa@353: 	      fi
msousa@353: 	      ;;
msousa@353: 	    *)
msousa@353: 	      # Add a -L argument.
msousa@353: 	      newdeplibs="$newdeplibs $a_deplib"
msousa@353: 	      ;;
msousa@353: 	    esac
msousa@353: 	  done # Gone through all deplibs.
msousa@353: 	  ;;
msousa@353: 	none | unknown | *)
msousa@353: 	  newdeplibs=""
msousa@353: 	  tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
msousa@353: 	      -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
msousa@353: 	  if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
msousa@353: 	    for i in $predeps $postdeps ; do
msousa@353: 	      # can't use Xsed below, because $i might contain '/'
msousa@353: 	      tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
msousa@353: 	    done
msousa@353: 	  fi
msousa@353: 	  if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[	 ]//g' |
msousa@353: 	     $GREP . >/dev/null; then
msousa@353: 	    $ECHO
msousa@353: 	    if test "X$deplibs_check_method" = "Xnone"; then
msousa@353: 	      $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
msousa@353: 	    else
msousa@353: 	      $ECHO "*** Warning: inter-library dependencies are not known to be supported."
msousa@353: 	    fi
msousa@353: 	    $ECHO "*** All declared inter-library dependencies are being dropped."
msousa@353: 	    droppeddeps=yes
msousa@353: 	  fi
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 	versuffix=$versuffix_save
msousa@353: 	major=$major_save
msousa@353: 	release=$release_save
msousa@353: 	libname=$libname_save
msousa@353: 	name=$name_save
msousa@353: 
msousa@353: 	case $host in
msousa@353: 	*-*-rhapsody* | *-*-darwin1.[012])
msousa@353: 	  # On Rhapsody replace the C library with the System framework
msousa@353: 	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	if test "$droppeddeps" = yes; then
msousa@353: 	  if test "$module" = yes; then
msousa@353: 	    $ECHO
msousa@353: 	    $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
msousa@353: 	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
msousa@353: 	    $ECHO "*** a static module, that should work as long as the dlopening"
msousa@353: 	    $ECHO "*** application is linked with the -dlopen flag."
msousa@353: 	    if test -z "$global_symbol_pipe"; then
msousa@353: 	      $ECHO
msousa@353: 	      $ECHO "*** However, this would only work if libtool was able to extract symbol"
msousa@353: 	      $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
msousa@353: 	      $ECHO "*** not find such a program.  So, this module is probably useless."
msousa@353: 	      $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
msousa@353: 	    fi
msousa@353: 	    if test "$build_old_libs" = no; then
msousa@353: 	      oldlibs="$output_objdir/$libname.$libext"
msousa@353: 	      build_libtool_libs=module
msousa@353: 	      build_old_libs=yes
msousa@353: 	    else
msousa@353: 	      build_libtool_libs=no
msousa@353: 	    fi
msousa@353: 	  else
msousa@353: 	    $ECHO "*** The inter-library dependencies that have been dropped here will be"
msousa@353: 	    $ECHO "*** automatically added whenever a program is linked with this library"
msousa@353: 	    $ECHO "*** or is declared to -dlopen it."
msousa@353: 
msousa@353: 	    if test "$allow_undefined" = no; then
msousa@353: 	      $ECHO
msousa@353: 	      $ECHO "*** Since this library must not contain undefined symbols,"
msousa@353: 	      $ECHO "*** because either the platform does not support them or"
msousa@353: 	      $ECHO "*** it was explicitly requested with -no-undefined,"
msousa@353: 	      $ECHO "*** libtool will only create a static version of it."
msousa@353: 	      if test "$build_old_libs" = no; then
msousa@353: 		oldlibs="$output_objdir/$libname.$libext"
msousa@353: 		build_libtool_libs=module
msousa@353: 		build_old_libs=yes
msousa@353: 	      else
msousa@353: 		build_libtool_libs=no
msousa@353: 	      fi
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 	# Done checking deplibs!
msousa@353: 	deplibs=$newdeplibs
msousa@353:       fi
msousa@353:       # Time to change all our "foo.ltframework" stuff back to "-framework foo"
msousa@353:       case $host in
msousa@353: 	*-*-darwin*)
msousa@353: 	  newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
msousa@353: 	  new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
msousa@353: 	  deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
msousa@353: 	  ;;
msousa@353:       esac
msousa@353: 
msousa@353:       # move library search paths that coincide with paths to not yet
msousa@353:       # installed libraries to the beginning of the library search list
msousa@353:       new_libs=
msousa@353:       for path in $notinst_path; do
msousa@353: 	case " $new_libs " in
msousa@353: 	*" -L$path/$objdir "*) ;;
msousa@353: 	*)
msousa@353: 	  case " $deplibs " in
msousa@353: 	  *" -L$path/$objdir "*)
msousa@353: 	    new_libs="$new_libs -L$path/$objdir" ;;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353:       done
msousa@353:       for deplib in $deplibs; do
msousa@353: 	case $deplib in
msousa@353: 	-L*)
msousa@353: 	  case " $new_libs " in
msousa@353: 	  *" $deplib "*) ;;
msousa@353: 	  *) new_libs="$new_libs $deplib" ;;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	*) new_libs="$new_libs $deplib" ;;
msousa@353: 	esac
msousa@353:       done
msousa@353:       deplibs="$new_libs"
msousa@353: 
msousa@353:       # All the library-specific variables (install_libdir is set above).
msousa@353:       library_names=
msousa@353:       old_library=
msousa@353:       dlname=
msousa@353: 
msousa@353:       # Test again, we may have decided not to build it any more
msousa@353:       if test "$build_libtool_libs" = yes; then
msousa@353: 	if test "$hardcode_into_libs" = yes; then
msousa@353: 	  # Hardcode the library paths
msousa@353: 	  hardcode_libdirs=
msousa@353: 	  dep_rpath=
msousa@353: 	  rpath="$finalize_rpath"
msousa@353: 	  test "$mode" != relink && rpath="$compile_rpath$rpath"
msousa@353: 	  for libdir in $rpath; do
msousa@353: 	    if test -n "$hardcode_libdir_flag_spec"; then
msousa@353: 	      if test -n "$hardcode_libdir_separator"; then
msousa@353: 		if test -z "$hardcode_libdirs"; then
msousa@353: 		  hardcode_libdirs="$libdir"
msousa@353: 		else
msousa@353: 		  # Just accumulate the unique libdirs.
msousa@353: 		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
msousa@353: 		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
msousa@353: 		    ;;
msousa@353: 		  *)
msousa@353: 		    hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
msousa@353: 		    ;;
msousa@353: 		  esac
msousa@353: 		fi
msousa@353: 	      else
msousa@353: 		eval flag=\"$hardcode_libdir_flag_spec\"
msousa@353: 		dep_rpath="$dep_rpath $flag"
msousa@353: 	      fi
msousa@353: 	    elif test -n "$runpath_var"; then
msousa@353: 	      case "$perm_rpath " in
msousa@353: 	      *" $libdir "*) ;;
msousa@353: 	      *) perm_rpath="$perm_rpath $libdir" ;;
msousa@353: 	      esac
msousa@353: 	    fi
msousa@353: 	  done
msousa@353: 	  # Substitute the hardcoded libdirs into the rpath.
msousa@353: 	  if test -n "$hardcode_libdir_separator" &&
msousa@353: 	     test -n "$hardcode_libdirs"; then
msousa@353: 	    libdir="$hardcode_libdirs"
msousa@353: 	    if test -n "$hardcode_libdir_flag_spec_ld"; then
msousa@353: 	      eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
msousa@353: 	    else
msousa@353: 	      eval dep_rpath=\"$hardcode_libdir_flag_spec\"
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
msousa@353: 	    # We should set the runpath_var.
msousa@353: 	    rpath=
msousa@353: 	    for dir in $perm_rpath; do
msousa@353: 	      rpath="$rpath$dir:"
msousa@353: 	    done
msousa@353: 	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
msousa@353: 	  fi
msousa@353: 	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
msousa@353: 	fi
msousa@353: 
msousa@353: 	shlibpath="$finalize_shlibpath"
msousa@353: 	test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
msousa@353: 	if test -n "$shlibpath"; then
msousa@353: 	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Get the real and link names of the library.
msousa@353: 	eval shared_ext=\"$shrext_cmds\"
msousa@353: 	eval library_names=\"$library_names_spec\"
msousa@353: 	set dummy $library_names
msousa@353: 	shift
msousa@353: 	realname="$1"
msousa@353: 	shift
msousa@353: 
msousa@353: 	if test -n "$soname_spec"; then
msousa@353: 	  eval soname=\"$soname_spec\"
msousa@353: 	else
msousa@353: 	  soname="$realname"
msousa@353: 	fi
msousa@353: 	if test -z "$dlname"; then
msousa@353: 	  dlname=$soname
msousa@353: 	fi
msousa@353: 
msousa@353: 	lib="$output_objdir/$realname"
msousa@353: 	linknames=
msousa@353: 	for link
msousa@353: 	do
msousa@353: 	  linknames="$linknames $link"
msousa@353: 	done
msousa@353: 
msousa@353: 	# Use standard objects if they are pic
msousa@353: 	test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
msousa@353: 	test "X$libobjs" = "X " && libobjs=
msousa@353: 
msousa@353: 	delfiles=
msousa@353: 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
msousa@353: 	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
msousa@353: 	  export_symbols="$output_objdir/$libname.uexp"
msousa@353: 	  delfiles="$delfiles $export_symbols"
msousa@353: 	fi
msousa@353: 
msousa@353: 	orig_export_symbols=
msousa@353: 	case $host_os in
msousa@353: 	cygwin* | mingw* | cegcc*)
msousa@353: 	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
msousa@353: 	    # exporting using user supplied symfile
msousa@353: 	    if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
msousa@353: 	      # and it's NOT already a .def file. Must figure out
msousa@353: 	      # which of the given symbols are data symbols and tag
msousa@353: 	      # them as such. So, trigger use of export_symbols_cmds.
msousa@353: 	      # export_symbols gets reassigned inside the "prepare
msousa@353: 	      # the list of exported symbols" if statement, so the
msousa@353: 	      # include_expsyms logic still works.
msousa@353: 	      orig_export_symbols="$export_symbols"
msousa@353: 	      export_symbols=
msousa@353: 	      always_export_symbols=yes
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353: 
msousa@353: 	# Prepare the list of exported symbols
msousa@353: 	if test -z "$export_symbols"; then
msousa@353: 	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
msousa@353: 	    func_verbose "generating symbol list for \`$libname.la'"
msousa@353: 	    export_symbols="$output_objdir/$libname.exp"
msousa@353: 	    $opt_dry_run || $RM $export_symbols
msousa@353: 	    cmds=$export_symbols_cmds
msousa@353: 	    save_ifs="$IFS"; IFS='~'
msousa@353: 	    for cmd in $cmds; do
msousa@353: 	      IFS="$save_ifs"
msousa@353: 	      eval cmd=\"$cmd\"
msousa@353: 	      func_len " $cmd"
msousa@353: 	      len=$func_len_result
msousa@353: 	      if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
msousa@353: 		func_show_eval "$cmd" 'exit $?'
msousa@353: 		skipped_export=false
msousa@353: 	      else
msousa@353: 		# The command line is too long to execute in one step.
msousa@353: 		func_verbose "using reloadable object file for export list..."
msousa@353: 		skipped_export=:
msousa@353: 		# Break out early, otherwise skipped_export may be
msousa@353: 		# set to false by a later but shorter cmd.
msousa@353: 		break
msousa@353: 	      fi
msousa@353: 	    done
msousa@353: 	    IFS="$save_ifs"
msousa@353: 	    if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
msousa@353: 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
msousa@353: 	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 
msousa@353: 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
msousa@353: 	  tmp_export_symbols="$export_symbols"
msousa@353: 	  test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
msousa@353: 	  $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
msousa@353: 	fi
msousa@353: 
msousa@353: 	if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
msousa@353: 	  # The given exports_symbols file has to be filtered, so filter it.
msousa@353: 	  func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
msousa@353: 	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
msousa@353: 	  # 's' commands which not all seds can handle. GNU sed should be fine
msousa@353: 	  # though. Also, the filter scales superlinearly with the number of
msousa@353: 	  # global variables. join(1) would be nice here, but unfortunately
msousa@353: 	  # isn't a blessed tool.
msousa@353: 	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
msousa@353: 	  delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
msousa@353: 	  export_symbols=$output_objdir/$libname.def
msousa@353: 	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
msousa@353: 	fi
msousa@353: 
msousa@353: 	tmp_deplibs=
msousa@353: 	for test_deplib in $deplibs; do
msousa@353: 	  case " $convenience " in
msousa@353: 	  *" $test_deplib "*) ;;
msousa@353: 	  *)
msousa@353: 	    tmp_deplibs="$tmp_deplibs $test_deplib"
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	done
msousa@353: 	deplibs="$tmp_deplibs"
msousa@353: 
msousa@353: 	if test -n "$convenience"; then
msousa@353: 	  if test -n "$whole_archive_flag_spec" &&
msousa@353: 	    test "$compiler_needs_object" = yes &&
msousa@353: 	    test -z "$libobjs"; then
msousa@353: 	    # extract the archives, so we have objects to list.
msousa@353: 	    # TODO: could optimize this to just extract one archive.
msousa@353: 	    whole_archive_flag_spec=
msousa@353: 	  fi
msousa@353: 	  if test -n "$whole_archive_flag_spec"; then
msousa@353: 	    save_libobjs=$libobjs
msousa@353: 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
msousa@353: 	    test "X$libobjs" = "X " && libobjs=
msousa@353: 	  else
msousa@353: 	    gentop="$output_objdir/${outputname}x"
msousa@353: 	    generated="$generated $gentop"
msousa@353: 
msousa@353: 	    func_extract_archives $gentop $convenience
msousa@353: 	    libobjs="$libobjs $func_extract_archives_result"
msousa@353: 	    test "X$libobjs" = "X " && libobjs=
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 
msousa@353: 	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
msousa@353: 	  eval flag=\"$thread_safe_flag_spec\"
msousa@353: 	  linker_flags="$linker_flags $flag"
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Make a backup of the uninstalled library when relinking
msousa@353: 	if test "$mode" = relink; then
msousa@353: 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Do each of the archive commands.
msousa@353: 	if test "$module" = yes && test -n "$module_cmds" ; then
msousa@353: 	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
msousa@353: 	    eval test_cmds=\"$module_expsym_cmds\"
msousa@353: 	    cmds=$module_expsym_cmds
msousa@353: 	  else
msousa@353: 	    eval test_cmds=\"$module_cmds\"
msousa@353: 	    cmds=$module_cmds
msousa@353: 	  fi
msousa@353: 	else
msousa@353: 	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
msousa@353: 	    eval test_cmds=\"$archive_expsym_cmds\"
msousa@353: 	    cmds=$archive_expsym_cmds
msousa@353: 	  else
msousa@353: 	    eval test_cmds=\"$archive_cmds\"
msousa@353: 	    cmds=$archive_cmds
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 
msousa@353: 	if test "X$skipped_export" != "X:" &&
msousa@353: 	   func_len " $test_cmds" &&
msousa@353: 	   len=$func_len_result &&
msousa@353: 	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
msousa@353: 	  :
msousa@353: 	else
msousa@353: 	  # The command line is too long to link in one step, link piecewise
msousa@353: 	  # or, if using GNU ld and skipped_export is not :, use a linker
msousa@353: 	  # script.
msousa@353: 
msousa@353: 	  # Save the value of $output and $libobjs because we want to
msousa@353: 	  # use them later.  If we have whole_archive_flag_spec, we
msousa@353: 	  # want to use save_libobjs as it was before
msousa@353: 	  # whole_archive_flag_spec was expanded, because we can't
msousa@353: 	  # assume the linker understands whole_archive_flag_spec.
msousa@353: 	  # This may have to be revisited, in case too many
msousa@353: 	  # convenience libraries get linked in and end up exceeding
msousa@353: 	  # the spec.
msousa@353: 	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
msousa@353: 	    save_libobjs=$libobjs
msousa@353: 	  fi
msousa@353: 	  save_output=$output
msousa@353: 	  output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
msousa@353: 
msousa@353: 	  # Clear the reloadable object creation command queue and
msousa@353: 	  # initialize k to one.
msousa@353: 	  test_cmds=
msousa@353: 	  concat_cmds=
msousa@353: 	  objlist=
msousa@353: 	  last_robj=
msousa@353: 	  k=1
msousa@353: 
msousa@353: 	  if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
msousa@353: 	    output=${output_objdir}/${output_la}.lnkscript
msousa@353: 	    func_verbose "creating GNU ld script: $output"
msousa@353: 	    $ECHO 'INPUT (' > $output
msousa@353: 	    for obj in $save_libobjs
msousa@353: 	    do
msousa@353: 	      $ECHO "$obj" >> $output
msousa@353: 	    done
msousa@353: 	    $ECHO ')' >> $output
msousa@353: 	    delfiles="$delfiles $output"
msousa@353: 	  elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
msousa@353: 	    output=${output_objdir}/${output_la}.lnk
msousa@353: 	    func_verbose "creating linker input file list: $output"
msousa@353: 	    : > $output
msousa@353: 	    set x $save_libobjs
msousa@353: 	    shift
msousa@353: 	    firstobj=
msousa@353: 	    if test "$compiler_needs_object" = yes; then
msousa@353: 	      firstobj="$1 "
msousa@353: 	      shift
msousa@353: 	    fi
msousa@353: 	    for obj
msousa@353: 	    do
msousa@353: 	      $ECHO "$obj" >> $output
msousa@353: 	    done
msousa@353: 	    delfiles="$delfiles $output"
msousa@353: 	    output=$firstobj\"$file_list_spec$output\"
msousa@353: 	  else
msousa@353: 	    if test -n "$save_libobjs"; then
msousa@353: 	      func_verbose "creating reloadable object files..."
msousa@353: 	      output=$output_objdir/$output_la-${k}.$objext
msousa@353: 	      eval test_cmds=\"$reload_cmds\"
msousa@353: 	      func_len " $test_cmds"
msousa@353: 	      len0=$func_len_result
msousa@353: 	      len=$len0
msousa@353: 
msousa@353: 	      # Loop over the list of objects to be linked.
msousa@353: 	      for obj in $save_libobjs
msousa@353: 	      do
msousa@353: 		func_len " $obj"
msousa@353: 		func_arith $len + $func_len_result
msousa@353: 		len=$func_arith_result
msousa@353: 		if test "X$objlist" = X ||
msousa@353: 		   test "$len" -lt "$max_cmd_len"; then
msousa@353: 		  func_append objlist " $obj"
msousa@353: 		else
msousa@353: 		  # The command $test_cmds is almost too long, add a
msousa@353: 		  # command to the queue.
msousa@353: 		  if test "$k" -eq 1 ; then
msousa@353: 		    # The first file doesn't have a previous command to add.
msousa@353: 		    eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
msousa@353: 		  else
msousa@353: 		    # All subsequent reloadable object files will link in
msousa@353: 		    # the last one created.
msousa@353: 		    eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
msousa@353: 		  fi
msousa@353: 		  last_robj=$output_objdir/$output_la-${k}.$objext
msousa@353: 		  func_arith $k + 1
msousa@353: 		  k=$func_arith_result
msousa@353: 		  output=$output_objdir/$output_la-${k}.$objext
msousa@353: 		  objlist=$obj
msousa@353: 		  func_len " $last_robj"
msousa@353: 		  func_arith $len0 + $func_len_result
msousa@353: 		  len=$func_arith_result
msousa@353: 		fi
msousa@353: 	      done
msousa@353: 	      # Handle the remaining objects by creating one last
msousa@353: 	      # reloadable object file.  All subsequent reloadable object
msousa@353: 	      # files will link in the last one created.
msousa@353: 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
msousa@353: 	      eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
msousa@353: 	      if test -n "$last_robj"; then
msousa@353: 	        eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
msousa@353: 	      fi
msousa@353: 	      delfiles="$delfiles $output"
msousa@353: 
msousa@353: 	    else
msousa@353: 	      output=
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    if ${skipped_export-false}; then
msousa@353: 	      func_verbose "generating symbol list for \`$libname.la'"
msousa@353: 	      export_symbols="$output_objdir/$libname.exp"
msousa@353: 	      $opt_dry_run || $RM $export_symbols
msousa@353: 	      libobjs=$output
msousa@353: 	      # Append the command to create the export file.
msousa@353: 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
msousa@353: 	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
msousa@353: 	      if test -n "$last_robj"; then
msousa@353: 		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
msousa@353: 	      fi
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    test -n "$save_libobjs" &&
msousa@353: 	      func_verbose "creating a temporary reloadable object file: $output"
msousa@353: 
msousa@353: 	    # Loop through the commands generated above and execute them.
msousa@353: 	    save_ifs="$IFS"; IFS='~'
msousa@353: 	    for cmd in $concat_cmds; do
msousa@353: 	      IFS="$save_ifs"
msousa@353: 	      $opt_silent || {
msousa@353: 		  func_quote_for_expand "$cmd"
msousa@353: 		  eval "func_echo $func_quote_for_expand_result"
msousa@353: 	      }
msousa@353: 	      $opt_dry_run || eval "$cmd" || {
msousa@353: 		lt_exit=$?
msousa@353: 
msousa@353: 		# Restore the uninstalled library and exit
msousa@353: 		if test "$mode" = relink; then
msousa@353: 		  ( cd "$output_objdir" && \
msousa@353: 		    $RM "${realname}T" && \
msousa@353: 		    $MV "${realname}U" "$realname" )
msousa@353: 		fi
msousa@353: 
msousa@353: 		exit $lt_exit
msousa@353: 	      }
msousa@353: 	    done
msousa@353: 	    IFS="$save_ifs"
msousa@353: 
msousa@353: 	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
msousa@353: 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
msousa@353: 	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 
msousa@353:           if ${skipped_export-false}; then
msousa@353: 	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
msousa@353: 	      tmp_export_symbols="$export_symbols"
msousa@353: 	      test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
msousa@353: 	      $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    if test -n "$orig_export_symbols"; then
msousa@353: 	      # The given exports_symbols file has to be filtered, so filter it.
msousa@353: 	      func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
msousa@353: 	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
msousa@353: 	      # 's' commands which not all seds can handle. GNU sed should be fine
msousa@353: 	      # though. Also, the filter scales superlinearly with the number of
msousa@353: 	      # global variables. join(1) would be nice here, but unfortunately
msousa@353: 	      # isn't a blessed tool.
msousa@353: 	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
msousa@353: 	      delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
msousa@353: 	      export_symbols=$output_objdir/$libname.def
msousa@353: 	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  libobjs=$output
msousa@353: 	  # Restore the value of output.
msousa@353: 	  output=$save_output
msousa@353: 
msousa@353: 	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
msousa@353: 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
msousa@353: 	    test "X$libobjs" = "X " && libobjs=
msousa@353: 	  fi
msousa@353: 	  # Expand the library linking commands again to reset the
msousa@353: 	  # value of $libobjs for piecewise linking.
msousa@353: 
msousa@353: 	  # Do each of the archive commands.
msousa@353: 	  if test "$module" = yes && test -n "$module_cmds" ; then
msousa@353: 	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
msousa@353: 	      cmds=$module_expsym_cmds
msousa@353: 	    else
msousa@353: 	      cmds=$module_cmds
msousa@353: 	    fi
msousa@353: 	  else
msousa@353: 	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
msousa@353: 	      cmds=$archive_expsym_cmds
msousa@353: 	    else
msousa@353: 	      cmds=$archive_cmds
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 
msousa@353: 	if test -n "$delfiles"; then
msousa@353: 	  # Append the command to remove temporary files to $cmds.
msousa@353: 	  eval cmds=\"\$cmds~\$RM $delfiles\"
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Add any objects from preloaded convenience libraries
msousa@353: 	if test -n "$dlprefiles"; then
msousa@353: 	  gentop="$output_objdir/${outputname}x"
msousa@353: 	  generated="$generated $gentop"
msousa@353: 
msousa@353: 	  func_extract_archives $gentop $dlprefiles
msousa@353: 	  libobjs="$libobjs $func_extract_archives_result"
msousa@353: 	  test "X$libobjs" = "X " && libobjs=
msousa@353: 	fi
msousa@353: 
msousa@353: 	save_ifs="$IFS"; IFS='~'
msousa@353: 	for cmd in $cmds; do
msousa@353: 	  IFS="$save_ifs"
msousa@353: 	  eval cmd=\"$cmd\"
msousa@353: 	  $opt_silent || {
msousa@353: 	    func_quote_for_expand "$cmd"
msousa@353: 	    eval "func_echo $func_quote_for_expand_result"
msousa@353: 	  }
msousa@353: 	  $opt_dry_run || eval "$cmd" || {
msousa@353: 	    lt_exit=$?
msousa@353: 
msousa@353: 	    # Restore the uninstalled library and exit
msousa@353: 	    if test "$mode" = relink; then
msousa@353: 	      ( cd "$output_objdir" && \
msousa@353: 	        $RM "${realname}T" && \
msousa@353: 		$MV "${realname}U" "$realname" )
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    exit $lt_exit
msousa@353: 	  }
msousa@353: 	done
msousa@353: 	IFS="$save_ifs"
msousa@353: 
msousa@353: 	# Restore the uninstalled library and exit
msousa@353: 	if test "$mode" = relink; then
msousa@353: 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
msousa@353: 
msousa@353: 	  if test -n "$convenience"; then
msousa@353: 	    if test -z "$whole_archive_flag_spec"; then
msousa@353: 	      func_show_eval '${RM}r "$gentop"'
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  exit $EXIT_SUCCESS
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Create links to the real library.
msousa@353: 	for linkname in $linknames; do
msousa@353: 	  if test "$realname" != "$linkname"; then
msousa@353: 	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
msousa@353: 	  fi
msousa@353: 	done
msousa@353: 
msousa@353: 	# If -module or -export-dynamic was specified, set the dlname.
msousa@353: 	if test "$module" = yes || test "$export_dynamic" = yes; then
msousa@353: 	  # On all known operating systems, these are identical.
msousa@353: 	  dlname="$soname"
msousa@353: 	fi
msousa@353:       fi
msousa@353:       ;;
msousa@353: 
msousa@353:     obj)
msousa@353:       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
msousa@353: 	func_warning "\`-dlopen' is ignored for objects"
msousa@353:       fi
msousa@353: 
msousa@353:       case " $deplibs" in
msousa@353:       *\ -l* | *\ -L*)
msousa@353: 	func_warning "\`-l' and \`-L' are ignored for objects" ;;
msousa@353:       esac
msousa@353: 
msousa@353:       test -n "$rpath" && \
msousa@353: 	func_warning "\`-rpath' is ignored for objects"
msousa@353: 
msousa@353:       test -n "$xrpath" && \
msousa@353: 	func_warning "\`-R' is ignored for objects"
msousa@353: 
msousa@353:       test -n "$vinfo" && \
msousa@353: 	func_warning "\`-version-info' is ignored for objects"
msousa@353: 
msousa@353:       test -n "$release" && \
msousa@353: 	func_warning "\`-release' is ignored for objects"
msousa@353: 
msousa@353:       case $output in
msousa@353:       *.lo)
msousa@353: 	test -n "$objs$old_deplibs" && \
msousa@353: 	  func_fatal_error "cannot build library object \`$output' from non-libtool objects"
msousa@353: 
msousa@353: 	libobj=$output
msousa@353: 	func_lo2o "$libobj"
msousa@353: 	obj=$func_lo2o_result
msousa@353: 	;;
msousa@353:       *)
msousa@353: 	libobj=
msousa@353: 	obj="$output"
msousa@353: 	;;
msousa@353:       esac
msousa@353: 
msousa@353:       # Delete the old objects.
msousa@353:       $opt_dry_run || $RM $obj $libobj
msousa@353: 
msousa@353:       # Objects from convenience libraries.  This assumes
msousa@353:       # single-version convenience libraries.  Whenever we create
msousa@353:       # different ones for PIC/non-PIC, this we'll have to duplicate
msousa@353:       # the extraction.
msousa@353:       reload_conv_objs=
msousa@353:       gentop=
msousa@353:       # reload_cmds runs $LD directly, so let us get rid of
msousa@353:       # -Wl from whole_archive_flag_spec and hope we can get by with
msousa@353:       # turning comma into space..
msousa@353:       wl=
msousa@353: 
msousa@353:       if test -n "$convenience"; then
msousa@353: 	if test -n "$whole_archive_flag_spec"; then
msousa@353: 	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
msousa@353: 	  reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
msousa@353: 	else
msousa@353: 	  gentop="$output_objdir/${obj}x"
msousa@353: 	  generated="$generated $gentop"
msousa@353: 
msousa@353: 	  func_extract_archives $gentop $convenience
msousa@353: 	  reload_conv_objs="$reload_objs $func_extract_archives_result"
msousa@353: 	fi
msousa@353:       fi
msousa@353: 
msousa@353:       # Create the old-style object.
msousa@353:       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
msousa@353: 
msousa@353:       output="$obj"
msousa@353:       func_execute_cmds "$reload_cmds" 'exit $?'
msousa@353: 
msousa@353:       # Exit if we aren't doing a library object file.
msousa@353:       if test -z "$libobj"; then
msousa@353: 	if test -n "$gentop"; then
msousa@353: 	  func_show_eval '${RM}r "$gentop"'
msousa@353: 	fi
msousa@353: 
msousa@353: 	exit $EXIT_SUCCESS
msousa@353:       fi
msousa@353: 
msousa@353:       if test "$build_libtool_libs" != yes; then
msousa@353: 	if test -n "$gentop"; then
msousa@353: 	  func_show_eval '${RM}r "$gentop"'
msousa@353: 	fi
msousa@353: 
msousa@353: 	# Create an invalid libtool object if no PIC, so that we don't
msousa@353: 	# accidentally link it into a program.
msousa@353: 	# $show "echo timestamp > $libobj"
msousa@353: 	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
msousa@353: 	exit $EXIT_SUCCESS
msousa@353:       fi
msousa@353: 
msousa@353:       if test -n "$pic_flag" || test "$pic_mode" != default; then
msousa@353: 	# Only do commands if we really have different PIC objects.
msousa@353: 	reload_objs="$libobjs $reload_conv_objs"
msousa@353: 	output="$libobj"
msousa@353: 	func_execute_cmds "$reload_cmds" 'exit $?'
msousa@353:       fi
msousa@353: 
msousa@353:       if test -n "$gentop"; then
msousa@353: 	func_show_eval '${RM}r "$gentop"'
msousa@353:       fi
msousa@353: 
msousa@353:       exit $EXIT_SUCCESS
msousa@353:       ;;
msousa@353: 
msousa@353:     prog)
msousa@353:       case $host in
msousa@353: 	*cygwin*) func_stripname '' '.exe' "$output"
msousa@353: 	          output=$func_stripname_result.exe;;
msousa@353:       esac
msousa@353:       test -n "$vinfo" && \
msousa@353: 	func_warning "\`-version-info' is ignored for programs"
msousa@353: 
msousa@353:       test -n "$release" && \
msousa@353: 	func_warning "\`-release' is ignored for programs"
msousa@353: 
msousa@353:       test "$preload" = yes \
msousa@353:         && test "$dlopen_support" = unknown \
msousa@353: 	&& test "$dlopen_self" = unknown \
msousa@353: 	&& test "$dlopen_self_static" = unknown && \
msousa@353: 	  func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
msousa@353: 
msousa@353:       case $host in
msousa@353:       *-*-rhapsody* | *-*-darwin1.[012])
msousa@353: 	# On Rhapsody replace the C library is the System framework
msousa@353: 	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
msousa@353: 	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
msousa@353: 	;;
msousa@353:       esac
msousa@353: 
msousa@353:       case $host in
msousa@353:       *-*-darwin*)
msousa@353: 	# Don't allow lazy linking, it breaks C++ global constructors
msousa@353: 	# But is supposedly fixed on 10.4 or later (yay!).
msousa@353: 	if test "$tagname" = CXX ; then
msousa@353: 	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
msousa@353: 	    10.[0123])
msousa@353: 	      compile_command="$compile_command ${wl}-bind_at_load"
msousa@353: 	      finalize_command="$finalize_command ${wl}-bind_at_load"
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	fi
msousa@353: 	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
msousa@353: 	compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
msousa@353: 	finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
msousa@353: 	;;
msousa@353:       esac
msousa@353: 
msousa@353: 
msousa@353:       # move library search paths that coincide with paths to not yet
msousa@353:       # installed libraries to the beginning of the library search list
msousa@353:       new_libs=
msousa@353:       for path in $notinst_path; do
msousa@353: 	case " $new_libs " in
msousa@353: 	*" -L$path/$objdir "*) ;;
msousa@353: 	*)
msousa@353: 	  case " $compile_deplibs " in
msousa@353: 	  *" -L$path/$objdir "*)
msousa@353: 	    new_libs="$new_libs -L$path/$objdir" ;;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353:       done
msousa@353:       for deplib in $compile_deplibs; do
msousa@353: 	case $deplib in
msousa@353: 	-L*)
msousa@353: 	  case " $new_libs " in
msousa@353: 	  *" $deplib "*) ;;
msousa@353: 	  *) new_libs="$new_libs $deplib" ;;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	*) new_libs="$new_libs $deplib" ;;
msousa@353: 	esac
msousa@353:       done
msousa@353:       compile_deplibs="$new_libs"
msousa@353: 
msousa@353: 
msousa@353:       compile_command="$compile_command $compile_deplibs"
msousa@353:       finalize_command="$finalize_command $finalize_deplibs"
msousa@353: 
msousa@353:       if test -n "$rpath$xrpath"; then
msousa@353: 	# If the user specified any rpath flags, then add them.
msousa@353: 	for libdir in $rpath $xrpath; do
msousa@353: 	  # This is the magic to use -rpath.
msousa@353: 	  case "$finalize_rpath " in
msousa@353: 	  *" $libdir "*) ;;
msousa@353: 	  *) finalize_rpath="$finalize_rpath $libdir" ;;
msousa@353: 	  esac
msousa@353: 	done
msousa@353:       fi
msousa@353: 
msousa@353:       # Now hardcode the library paths
msousa@353:       rpath=
msousa@353:       hardcode_libdirs=
msousa@353:       for libdir in $compile_rpath $finalize_rpath; do
msousa@353: 	if test -n "$hardcode_libdir_flag_spec"; then
msousa@353: 	  if test -n "$hardcode_libdir_separator"; then
msousa@353: 	    if test -z "$hardcode_libdirs"; then
msousa@353: 	      hardcode_libdirs="$libdir"
msousa@353: 	    else
msousa@353: 	      # Just accumulate the unique libdirs.
msousa@353: 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
msousa@353: 	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
msousa@353: 		;;
msousa@353: 	      *)
msousa@353: 		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 	    fi
msousa@353: 	  else
msousa@353: 	    eval flag=\"$hardcode_libdir_flag_spec\"
msousa@353: 	    rpath="$rpath $flag"
msousa@353: 	  fi
msousa@353: 	elif test -n "$runpath_var"; then
msousa@353: 	  case "$perm_rpath " in
msousa@353: 	  *" $libdir "*) ;;
msousa@353: 	  *) perm_rpath="$perm_rpath $libdir" ;;
msousa@353: 	  esac
msousa@353: 	fi
msousa@353: 	case $host in
msousa@353: 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
msousa@353: 	  testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
msousa@353: 	  case :$dllsearchpath: in
msousa@353: 	  *":$libdir:"*) ;;
msousa@353: 	  ::) dllsearchpath=$libdir;;
msousa@353: 	  *) dllsearchpath="$dllsearchpath:$libdir";;
msousa@353: 	  esac
msousa@353: 	  case :$dllsearchpath: in
msousa@353: 	  *":$testbindir:"*) ;;
msousa@353: 	  ::) dllsearchpath=$testbindir;;
msousa@353: 	  *) dllsearchpath="$dllsearchpath:$testbindir";;
msousa@353: 	  esac
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353:       done
msousa@353:       # Substitute the hardcoded libdirs into the rpath.
msousa@353:       if test -n "$hardcode_libdir_separator" &&
msousa@353: 	 test -n "$hardcode_libdirs"; then
msousa@353: 	libdir="$hardcode_libdirs"
msousa@353: 	eval rpath=\" $hardcode_libdir_flag_spec\"
msousa@353:       fi
msousa@353:       compile_rpath="$rpath"
msousa@353: 
msousa@353:       rpath=
msousa@353:       hardcode_libdirs=
msousa@353:       for libdir in $finalize_rpath; do
msousa@353: 	if test -n "$hardcode_libdir_flag_spec"; then
msousa@353: 	  if test -n "$hardcode_libdir_separator"; then
msousa@353: 	    if test -z "$hardcode_libdirs"; then
msousa@353: 	      hardcode_libdirs="$libdir"
msousa@353: 	    else
msousa@353: 	      # Just accumulate the unique libdirs.
msousa@353: 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
msousa@353: 	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
msousa@353: 		;;
msousa@353: 	      *)
msousa@353: 		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 	    fi
msousa@353: 	  else
msousa@353: 	    eval flag=\"$hardcode_libdir_flag_spec\"
msousa@353: 	    rpath="$rpath $flag"
msousa@353: 	  fi
msousa@353: 	elif test -n "$runpath_var"; then
msousa@353: 	  case "$finalize_perm_rpath " in
msousa@353: 	  *" $libdir "*) ;;
msousa@353: 	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
msousa@353: 	  esac
msousa@353: 	fi
msousa@353:       done
msousa@353:       # Substitute the hardcoded libdirs into the rpath.
msousa@353:       if test -n "$hardcode_libdir_separator" &&
msousa@353: 	 test -n "$hardcode_libdirs"; then
msousa@353: 	libdir="$hardcode_libdirs"
msousa@353: 	eval rpath=\" $hardcode_libdir_flag_spec\"
msousa@353:       fi
msousa@353:       finalize_rpath="$rpath"
msousa@353: 
msousa@353:       if test -n "$libobjs" && test "$build_old_libs" = yes; then
msousa@353: 	# Transform all the library objects into standard objects.
msousa@353: 	compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
msousa@353: 	finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
msousa@353:       fi
msousa@353: 
msousa@353:       func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
msousa@353: 
msousa@353:       # template prelinking step
msousa@353:       if test -n "$prelink_cmds"; then
msousa@353: 	func_execute_cmds "$prelink_cmds" 'exit $?'
msousa@353:       fi
msousa@353: 
msousa@353:       wrappers_required=yes
msousa@353:       case $host in
msousa@353:       *cygwin* | *mingw* )
msousa@353:         if test "$build_libtool_libs" != yes; then
msousa@353:           wrappers_required=no
msousa@353:         fi
msousa@353:         ;;
msousa@353:       *cegcc)
msousa@353:         # Disable wrappers for cegcc, we are cross compiling anyway.
msousa@353:         wrappers_required=no
msousa@353:         ;;
msousa@353:       *)
msousa@353:         if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
msousa@353:           wrappers_required=no
msousa@353:         fi
msousa@353:         ;;
msousa@353:       esac
msousa@353:       if test "$wrappers_required" = no; then
msousa@353: 	# Replace the output file specification.
msousa@353: 	compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
msousa@353: 	link_command="$compile_command$compile_rpath"
msousa@353: 
msousa@353: 	# We have no uninstalled library dependencies, so finalize right now.
msousa@353: 	exit_status=0
msousa@353: 	func_show_eval "$link_command" 'exit_status=$?'
msousa@353: 
msousa@353: 	# Delete the generated files.
msousa@353: 	if test -f "$output_objdir/${outputname}S.${objext}"; then
msousa@353: 	  func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
msousa@353: 	fi
msousa@353: 
msousa@353: 	exit $exit_status
msousa@353:       fi
msousa@353: 
msousa@353:       if test -n "$compile_shlibpath$finalize_shlibpath"; then
msousa@353: 	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
msousa@353:       fi
msousa@353:       if test -n "$finalize_shlibpath"; then
msousa@353: 	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
msousa@353:       fi
msousa@353: 
msousa@353:       compile_var=
msousa@353:       finalize_var=
msousa@353:       if test -n "$runpath_var"; then
msousa@353: 	if test -n "$perm_rpath"; then
msousa@353: 	  # We should set the runpath_var.
msousa@353: 	  rpath=
msousa@353: 	  for dir in $perm_rpath; do
msousa@353: 	    rpath="$rpath$dir:"
msousa@353: 	  done
msousa@353: 	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
msousa@353: 	fi
msousa@353: 	if test -n "$finalize_perm_rpath"; then
msousa@353: 	  # We should set the runpath_var.
msousa@353: 	  rpath=
msousa@353: 	  for dir in $finalize_perm_rpath; do
msousa@353: 	    rpath="$rpath$dir:"
msousa@353: 	  done
msousa@353: 	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
msousa@353: 	fi
msousa@353:       fi
msousa@353: 
msousa@353:       if test "$no_install" = yes; then
msousa@353: 	# We don't need to create a wrapper script.
msousa@353: 	link_command="$compile_var$compile_command$compile_rpath"
msousa@353: 	# Replace the output file specification.
msousa@353: 	link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
msousa@353: 	# Delete the old output file.
msousa@353: 	$opt_dry_run || $RM $output
msousa@353: 	# Link the executable and exit
msousa@353: 	func_show_eval "$link_command" 'exit $?'
msousa@353: 	exit $EXIT_SUCCESS
msousa@353:       fi
msousa@353: 
msousa@353:       if test "$hardcode_action" = relink; then
msousa@353: 	# Fast installation is not supported
msousa@353: 	link_command="$compile_var$compile_command$compile_rpath"
msousa@353: 	relink_command="$finalize_var$finalize_command$finalize_rpath"
msousa@353: 
msousa@353: 	func_warning "this platform does not like uninstalled shared libraries"
msousa@353: 	func_warning "\`$output' will be relinked during installation"
msousa@353:       else
msousa@353: 	if test "$fast_install" != no; then
msousa@353: 	  link_command="$finalize_var$compile_command$finalize_rpath"
msousa@353: 	  if test "$fast_install" = yes; then
msousa@353: 	    relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
msousa@353: 	  else
msousa@353: 	    # fast_install is set to needless
msousa@353: 	    relink_command=
msousa@353: 	  fi
msousa@353: 	else
msousa@353: 	  link_command="$compile_var$compile_command$compile_rpath"
msousa@353: 	  relink_command="$finalize_var$finalize_command$finalize_rpath"
msousa@353: 	fi
msousa@353:       fi
msousa@353: 
msousa@353:       # Replace the output file specification.
msousa@353:       link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
msousa@353: 
msousa@353:       # Delete the old output files.
msousa@353:       $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
msousa@353: 
msousa@353:       func_show_eval "$link_command" 'exit $?'
msousa@353: 
msousa@353:       # Now create the wrapper script.
msousa@353:       func_verbose "creating $output"
msousa@353: 
msousa@353:       # Quote the relink command for shipping.
msousa@353:       if test -n "$relink_command"; then
msousa@353: 	# Preserve any variables that may affect compiler behavior
msousa@353: 	for var in $variables_saved_for_relink; do
msousa@353: 	  if eval test -z \"\${$var+set}\"; then
msousa@353: 	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
msousa@353: 	  elif eval var_value=\$$var; test -z "$var_value"; then
msousa@353: 	    relink_command="$var=; export $var; $relink_command"
msousa@353: 	  else
msousa@353: 	    func_quote_for_eval "$var_value"
msousa@353: 	    relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
msousa@353: 	  fi
msousa@353: 	done
msousa@353: 	relink_command="(cd `pwd`; $relink_command)"
msousa@353: 	relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
msousa@353:       fi
msousa@353: 
msousa@353:       # Quote $ECHO for shipping.
msousa@353:       if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
msousa@353: 	case $progpath in
msousa@353: 	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
msousa@353: 	*) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
msousa@353: 	esac
msousa@353: 	qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
msousa@353:       else
msousa@353: 	qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
msousa@353:       fi
msousa@353: 
msousa@353:       # Only actually do things if not in dry run mode.
msousa@353:       $opt_dry_run || {
msousa@353: 	# win32 will think the script is a binary if it has
msousa@353: 	# a .exe suffix, so we strip it off here.
msousa@353: 	case $output in
msousa@353: 	  *.exe) func_stripname '' '.exe' "$output"
msousa@353: 	         output=$func_stripname_result ;;
msousa@353: 	esac
msousa@353: 	# test for cygwin because mv fails w/o .exe extensions
msousa@353: 	case $host in
msousa@353: 	  *cygwin*)
msousa@353: 	    exeext=.exe
msousa@353: 	    func_stripname '' '.exe' "$outputname"
msousa@353: 	    outputname=$func_stripname_result ;;
msousa@353: 	  *) exeext= ;;
msousa@353: 	esac
msousa@353: 	case $host in
msousa@353: 	  *cygwin* | *mingw* )
msousa@353: 	    func_dirname_and_basename "$output" "" "."
msousa@353: 	    output_name=$func_basename_result
msousa@353: 	    output_path=$func_dirname_result
msousa@353: 	    cwrappersource="$output_path/$objdir/lt-$output_name.c"
msousa@353: 	    cwrapper="$output_path/$output_name.exe"
msousa@353: 	    $RM $cwrappersource $cwrapper
msousa@353: 	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
msousa@353: 
msousa@353: 	    func_emit_cwrapperexe_src > $cwrappersource
msousa@353: 
msousa@353: 	    # The wrapper executable is built using the $host compiler,
msousa@353: 	    # because it contains $host paths and files. If cross-
msousa@353: 	    # compiling, it, like the target executable, must be
msousa@353: 	    # executed on the $host or under an emulation environment.
msousa@353: 	    $opt_dry_run || {
msousa@353: 	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
msousa@353: 	      $STRIP $cwrapper
msousa@353: 	    }
msousa@353: 
msousa@353: 	    # Now, create the wrapper script for func_source use:
msousa@353: 	    func_ltwrapper_scriptname $cwrapper
msousa@353: 	    $RM $func_ltwrapper_scriptname_result
msousa@353: 	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
msousa@353: 	    $opt_dry_run || {
msousa@353: 	      # note: this script will not be executed, so do not chmod.
msousa@353: 	      if test "x$build" = "x$host" ; then
msousa@353: 		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
msousa@353: 	      else
msousa@353: 		func_emit_wrapper no > $func_ltwrapper_scriptname_result
msousa@353: 	      fi
msousa@353: 	    }
msousa@353: 	  ;;
msousa@353: 	  * )
msousa@353: 	    $RM $output
msousa@353: 	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
msousa@353: 
msousa@353: 	    func_emit_wrapper no > $output
msousa@353: 	    chmod +x $output
msousa@353: 	  ;;
msousa@353: 	esac
msousa@353:       }
msousa@353:       exit $EXIT_SUCCESS
msousa@353:       ;;
msousa@353:     esac
msousa@353: 
msousa@353:     # See if we need to build an old-fashioned archive.
msousa@353:     for oldlib in $oldlibs; do
msousa@353: 
msousa@353:       if test "$build_libtool_libs" = convenience; then
msousa@353: 	oldobjs="$libobjs_save $symfileobj"
msousa@353: 	addlibs="$convenience"
msousa@353: 	build_libtool_libs=no
msousa@353:       else
msousa@353: 	if test "$build_libtool_libs" = module; then
msousa@353: 	  oldobjs="$libobjs_save"
msousa@353: 	  build_libtool_libs=no
msousa@353: 	else
msousa@353: 	  oldobjs="$old_deplibs $non_pic_objects"
msousa@353: 	  if test "$preload" = yes && test -f "$symfileobj"; then
msousa@353: 	    oldobjs="$oldobjs $symfileobj"
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 	addlibs="$old_convenience"
msousa@353:       fi
msousa@353: 
msousa@353:       if test -n "$addlibs"; then
msousa@353: 	gentop="$output_objdir/${outputname}x"
msousa@353: 	generated="$generated $gentop"
msousa@353: 
msousa@353: 	func_extract_archives $gentop $addlibs
msousa@353: 	oldobjs="$oldobjs $func_extract_archives_result"
msousa@353:       fi
msousa@353: 
msousa@353:       # Do each command in the archive commands.
msousa@353:       if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
msousa@353: 	cmds=$old_archive_from_new_cmds
msousa@353:       else
msousa@353: 
msousa@353: 	# Add any objects from preloaded convenience libraries
msousa@353: 	if test -n "$dlprefiles"; then
msousa@353: 	  gentop="$output_objdir/${outputname}x"
msousa@353: 	  generated="$generated $gentop"
msousa@353: 
msousa@353: 	  func_extract_archives $gentop $dlprefiles
msousa@353: 	  oldobjs="$oldobjs $func_extract_archives_result"
msousa@353: 	fi
msousa@353: 
msousa@353: 	# POSIX demands no paths to be encoded in archives.  We have
msousa@353: 	# to avoid creating archives with duplicate basenames if we
msousa@353: 	# might have to extract them afterwards, e.g., when creating a
msousa@353: 	# static archive out of a convenience library, or when linking
msousa@353: 	# the entirety of a libtool archive into another (currently
msousa@353: 	# not supported by libtool).
msousa@353: 	if (for obj in $oldobjs
msousa@353: 	    do
msousa@353: 	      func_basename "$obj"
msousa@353: 	      $ECHO "$func_basename_result"
msousa@353: 	    done | sort | sort -uc >/dev/null 2>&1); then
msousa@353: 	  :
msousa@353: 	else
msousa@353: 	  $ECHO "copying selected object files to avoid basename conflicts..."
msousa@353: 	  gentop="$output_objdir/${outputname}x"
msousa@353: 	  generated="$generated $gentop"
msousa@353: 	  func_mkdir_p "$gentop"
msousa@353: 	  save_oldobjs=$oldobjs
msousa@353: 	  oldobjs=
msousa@353: 	  counter=1
msousa@353: 	  for obj in $save_oldobjs
msousa@353: 	  do
msousa@353: 	    func_basename "$obj"
msousa@353: 	    objbase="$func_basename_result"
msousa@353: 	    case " $oldobjs " in
msousa@353: 	    " ") oldobjs=$obj ;;
msousa@353: 	    *[\ /]"$objbase "*)
msousa@353: 	      while :; do
msousa@353: 		# Make sure we don't pick an alternate name that also
msousa@353: 		# overlaps.
msousa@353: 		newobj=lt$counter-$objbase
msousa@353: 		func_arith $counter + 1
msousa@353: 		counter=$func_arith_result
msousa@353: 		case " $oldobjs " in
msousa@353: 		*[\ /]"$newobj "*) ;;
msousa@353: 		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
msousa@353: 		esac
msousa@353: 	      done
msousa@353: 	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
msousa@353: 	      oldobjs="$oldobjs $gentop/$newobj"
msousa@353: 	      ;;
msousa@353: 	    *) oldobjs="$oldobjs $obj" ;;
msousa@353: 	    esac
msousa@353: 	  done
msousa@353: 	fi
msousa@353: 	eval cmds=\"$old_archive_cmds\"
msousa@353: 
msousa@353: 	func_len " $cmds"
msousa@353: 	len=$func_len_result
msousa@353: 	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
msousa@353: 	  cmds=$old_archive_cmds
msousa@353: 	else
msousa@353: 	  # the command line is too long to link in one step, link in parts
msousa@353: 	  func_verbose "using piecewise archive linking..."
msousa@353: 	  save_RANLIB=$RANLIB
msousa@353: 	  RANLIB=:
msousa@353: 	  objlist=
msousa@353: 	  concat_cmds=
msousa@353: 	  save_oldobjs=$oldobjs
msousa@353: 	  oldobjs=
msousa@353: 	  # Is there a better way of finding the last object in the list?
msousa@353: 	  for obj in $save_oldobjs
msousa@353: 	  do
msousa@353: 	    last_oldobj=$obj
msousa@353: 	  done
msousa@353: 	  eval test_cmds=\"$old_archive_cmds\"
msousa@353: 	  func_len " $test_cmds"
msousa@353: 	  len0=$func_len_result
msousa@353: 	  len=$len0
msousa@353: 	  for obj in $save_oldobjs
msousa@353: 	  do
msousa@353: 	    func_len " $obj"
msousa@353: 	    func_arith $len + $func_len_result
msousa@353: 	    len=$func_arith_result
msousa@353: 	    func_append objlist " $obj"
msousa@353: 	    if test "$len" -lt "$max_cmd_len"; then
msousa@353: 	      :
msousa@353: 	    else
msousa@353: 	      # the above command should be used before it gets too long
msousa@353: 	      oldobjs=$objlist
msousa@353: 	      if test "$obj" = "$last_oldobj" ; then
msousa@353: 		RANLIB=$save_RANLIB
msousa@353: 	      fi
msousa@353: 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
msousa@353: 	      eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
msousa@353: 	      objlist=
msousa@353: 	      len=$len0
msousa@353: 	    fi
msousa@353: 	  done
msousa@353: 	  RANLIB=$save_RANLIB
msousa@353: 	  oldobjs=$objlist
msousa@353: 	  if test "X$oldobjs" = "X" ; then
msousa@353: 	    eval cmds=\"\$concat_cmds\"
msousa@353: 	  else
msousa@353: 	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
msousa@353: 	  fi
msousa@353: 	fi
msousa@353:       fi
msousa@353:       func_execute_cmds "$cmds" 'exit $?'
msousa@353:     done
msousa@353: 
msousa@353:     test -n "$generated" && \
msousa@353:       func_show_eval "${RM}r$generated"
msousa@353: 
msousa@353:     # Now create the libtool archive.
msousa@353:     case $output in
msousa@353:     *.la)
msousa@353:       old_library=
msousa@353:       test "$build_old_libs" = yes && old_library="$libname.$libext"
msousa@353:       func_verbose "creating $output"
msousa@353: 
msousa@353:       # Preserve any variables that may affect compiler behavior
msousa@353:       for var in $variables_saved_for_relink; do
msousa@353: 	if eval test -z \"\${$var+set}\"; then
msousa@353: 	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
msousa@353: 	elif eval var_value=\$$var; test -z "$var_value"; then
msousa@353: 	  relink_command="$var=; export $var; $relink_command"
msousa@353: 	else
msousa@353: 	  func_quote_for_eval "$var_value"
msousa@353: 	  relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
msousa@353: 	fi
msousa@353:       done
msousa@353:       # Quote the link command for shipping.
msousa@353:       relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
msousa@353:       relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
msousa@353:       if test "$hardcode_automatic" = yes ; then
msousa@353: 	relink_command=
msousa@353:       fi
msousa@353: 
msousa@353:       # Only create the output if not a dry run.
msousa@353:       $opt_dry_run || {
msousa@353: 	for installed in no yes; do
msousa@353: 	  if test "$installed" = yes; then
msousa@353: 	    if test -z "$install_libdir"; then
msousa@353: 	      break
msousa@353: 	    fi
msousa@353: 	    output="$output_objdir/$outputname"i
msousa@353: 	    # Replace all uninstalled libtool libraries with the installed ones
msousa@353: 	    newdependency_libs=
msousa@353: 	    for deplib in $dependency_libs; do
msousa@353: 	      case $deplib in
msousa@353: 	      *.la)
msousa@353: 		func_basename "$deplib"
msousa@353: 		name="$func_basename_result"
msousa@353: 		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
msousa@353: 		test -z "$libdir" && \
msousa@353: 		  func_fatal_error "\`$deplib' is not a valid libtool archive"
msousa@353: 		newdependency_libs="$newdependency_libs $libdir/$name"
msousa@353: 		;;
msousa@353: 	      *) newdependency_libs="$newdependency_libs $deplib" ;;
msousa@353: 	      esac
msousa@353: 	    done
msousa@353: 	    dependency_libs="$newdependency_libs"
msousa@353: 	    newdlfiles=
msousa@353: 
msousa@353: 	    for lib in $dlfiles; do
msousa@353: 	      case $lib in
msousa@353: 	      *.la)
msousa@353: 	        func_basename "$lib"
msousa@353: 		name="$func_basename_result"
msousa@353: 		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
msousa@353: 		test -z "$libdir" && \
msousa@353: 		  func_fatal_error "\`$lib' is not a valid libtool archive"
msousa@353: 		newdlfiles="$newdlfiles $libdir/$name"
msousa@353: 		;;
msousa@353: 	      *) newdlfiles="$newdlfiles $lib" ;;
msousa@353: 	      esac
msousa@353: 	    done
msousa@353: 	    dlfiles="$newdlfiles"
msousa@353: 	    newdlprefiles=
msousa@353: 	    for lib in $dlprefiles; do
msousa@353: 	      case $lib in
msousa@353: 	      *.la)
msousa@353: 		# Only pass preopened files to the pseudo-archive (for
msousa@353: 		# eventual linking with the app. that links it) if we
msousa@353: 		# didn't already link the preopened objects directly into
msousa@353: 		# the library:
msousa@353: 		func_basename "$lib"
msousa@353: 		name="$func_basename_result"
msousa@353: 		eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
msousa@353: 		test -z "$libdir" && \
msousa@353: 		  func_fatal_error "\`$lib' is not a valid libtool archive"
msousa@353: 		newdlprefiles="$newdlprefiles $libdir/$name"
msousa@353: 		;;
msousa@353: 	      esac
msousa@353: 	    done
msousa@353: 	    dlprefiles="$newdlprefiles"
msousa@353: 	  else
msousa@353: 	    newdlfiles=
msousa@353: 	    for lib in $dlfiles; do
msousa@353: 	      case $lib in
msousa@353: 		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
msousa@353: 		*) abs=`pwd`"/$lib" ;;
msousa@353: 	      esac
msousa@353: 	      newdlfiles="$newdlfiles $abs"
msousa@353: 	    done
msousa@353: 	    dlfiles="$newdlfiles"
msousa@353: 	    newdlprefiles=
msousa@353: 	    for lib in $dlprefiles; do
msousa@353: 	      case $lib in
msousa@353: 		[\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
msousa@353: 		*) abs=`pwd`"/$lib" ;;
msousa@353: 	      esac
msousa@353: 	      newdlprefiles="$newdlprefiles $abs"
msousa@353: 	    done
msousa@353: 	    dlprefiles="$newdlprefiles"
msousa@353: 	  fi
msousa@353: 	  $RM $output
msousa@353: 	  # place dlname in correct position for cygwin
msousa@353: 	  tdlname=$dlname
msousa@353: 	  case $host,$output,$installed,$module,$dlname in
msousa@353: 	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
msousa@353: 	  esac
msousa@353: 	  $ECHO > $output "\
msousa@353: # $outputname - a libtool library file
msousa@353: # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
msousa@353: #
msousa@353: # Please DO NOT delete this file!
msousa@353: # It is necessary for linking the library.
msousa@353: 
msousa@353: # The name that we can dlopen(3).
msousa@353: dlname='$tdlname'
msousa@353: 
msousa@353: # Names of this library.
msousa@353: library_names='$library_names'
msousa@353: 
msousa@353: # The name of the static archive.
msousa@353: old_library='$old_library'
msousa@353: 
msousa@353: # Linker flags that can not go in dependency_libs.
msousa@353: inherited_linker_flags='$new_inherited_linker_flags'
msousa@353: 
msousa@353: # Libraries that this one depends upon.
msousa@353: dependency_libs='$dependency_libs'
msousa@353: 
msousa@353: # Names of additional weak libraries provided by this library
msousa@353: weak_library_names='$weak_libs'
msousa@353: 
msousa@353: # Version information for $libname.
msousa@353: current=$current
msousa@353: age=$age
msousa@353: revision=$revision
msousa@353: 
msousa@353: # Is this an already installed library?
msousa@353: installed=$installed
msousa@353: 
msousa@353: # Should we warn about portability when linking against -modules?
msousa@353: shouldnotlink=$module
msousa@353: 
msousa@353: # Files to dlopen/dlpreopen
msousa@353: dlopen='$dlfiles'
msousa@353: dlpreopen='$dlprefiles'
msousa@353: 
msousa@353: # Directory that this library needs to be installed in:
msousa@353: libdir='$install_libdir'"
msousa@353: 	  if test "$installed" = no && test "$need_relink" = yes; then
msousa@353: 	    $ECHO >> $output "\
msousa@353: relink_command=\"$relink_command\""
msousa@353: 	  fi
msousa@353: 	done
msousa@353:       }
msousa@353: 
msousa@353:       # Do a symbolic link so that the libtool archive can be found in
msousa@353:       # LD_LIBRARY_PATH before the program is installed.
msousa@353:       func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
msousa@353:       ;;
msousa@353:     esac
msousa@353:     exit $EXIT_SUCCESS
msousa@353: }
msousa@353: 
msousa@353: { test "$mode" = link || test "$mode" = relink; } &&
msousa@353:     func_mode_link ${1+"$@"}
msousa@353: 
msousa@353: 
msousa@353: # func_mode_uninstall arg...
msousa@353: func_mode_uninstall ()
msousa@353: {
msousa@353:     $opt_debug
msousa@353:     RM="$nonopt"
msousa@353:     files=
msousa@353:     rmforce=
msousa@353:     exit_status=0
msousa@353: 
msousa@353:     # This variable tells wrapper scripts just to set variables rather
msousa@353:     # than running their programs.
msousa@353:     libtool_install_magic="$magic"
msousa@353: 
msousa@353:     for arg
msousa@353:     do
msousa@353:       case $arg in
msousa@353:       -f) RM="$RM $arg"; rmforce=yes ;;
msousa@353:       -*) RM="$RM $arg" ;;
msousa@353:       *) files="$files $arg" ;;
msousa@353:       esac
msousa@353:     done
msousa@353: 
msousa@353:     test -z "$RM" && \
msousa@353:       func_fatal_help "you must specify an RM program"
msousa@353: 
msousa@353:     rmdirs=
msousa@353: 
msousa@353:     origobjdir="$objdir"
msousa@353:     for file in $files; do
msousa@353:       func_dirname "$file" "" "."
msousa@353:       dir="$func_dirname_result"
msousa@353:       if test "X$dir" = X.; then
msousa@353: 	objdir="$origobjdir"
msousa@353:       else
msousa@353: 	objdir="$dir/$origobjdir"
msousa@353:       fi
msousa@353:       func_basename "$file"
msousa@353:       name="$func_basename_result"
msousa@353:       test "$mode" = uninstall && objdir="$dir"
msousa@353: 
msousa@353:       # Remember objdir for removal later, being careful to avoid duplicates
msousa@353:       if test "$mode" = clean; then
msousa@353: 	case " $rmdirs " in
msousa@353: 	  *" $objdir "*) ;;
msousa@353: 	  *) rmdirs="$rmdirs $objdir" ;;
msousa@353: 	esac
msousa@353:       fi
msousa@353: 
msousa@353:       # Don't error if the file doesn't exist and rm -f was used.
msousa@353:       if { test -L "$file"; } >/dev/null 2>&1 ||
msousa@353: 	 { test -h "$file"; } >/dev/null 2>&1 ||
msousa@353: 	 test -f "$file"; then
msousa@353: 	:
msousa@353:       elif test -d "$file"; then
msousa@353: 	exit_status=1
msousa@353: 	continue
msousa@353:       elif test "$rmforce" = yes; then
msousa@353: 	continue
msousa@353:       fi
msousa@353: 
msousa@353:       rmfiles="$file"
msousa@353: 
msousa@353:       case $name in
msousa@353:       *.la)
msousa@353: 	# Possibly a libtool archive, so verify it.
msousa@353: 	if func_lalib_p "$file"; then
msousa@353: 	  func_source $dir/$name
msousa@353: 
msousa@353: 	  # Delete the libtool libraries and symlinks.
msousa@353: 	  for n in $library_names; do
msousa@353: 	    rmfiles="$rmfiles $objdir/$n"
msousa@353: 	  done
msousa@353: 	  test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
msousa@353: 
msousa@353: 	  case "$mode" in
msousa@353: 	  clean)
msousa@353: 	    case "  $library_names " in
msousa@353: 	    # "  " in the beginning catches empty $dlname
msousa@353: 	    *" $dlname "*) ;;
msousa@353: 	    *) rmfiles="$rmfiles $objdir/$dlname" ;;
msousa@353: 	    esac
msousa@353: 	    test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
msousa@353: 	    ;;
msousa@353: 	  uninstall)
msousa@353: 	    if test -n "$library_names"; then
msousa@353: 	      # Do each command in the postuninstall commands.
msousa@353: 	      func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    if test -n "$old_library"; then
msousa@353: 	      # Do each command in the old_postuninstall commands.
msousa@353: 	      func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
msousa@353: 	    fi
msousa@353: 	    # FIXME: should reinstall the best remaining shared library.
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	fi
msousa@353: 	;;
msousa@353: 
msousa@353:       *.lo)
msousa@353: 	# Possibly a libtool object, so verify it.
msousa@353: 	if func_lalib_p "$file"; then
msousa@353: 
msousa@353: 	  # Read the .lo file
msousa@353: 	  func_source $dir/$name
msousa@353: 
msousa@353: 	  # Add PIC object to the list of files to remove.
msousa@353: 	  if test -n "$pic_object" &&
msousa@353: 	     test "$pic_object" != none; then
msousa@353: 	    rmfiles="$rmfiles $dir/$pic_object"
msousa@353: 	  fi
msousa@353: 
msousa@353: 	  # Add non-PIC object to the list of files to remove.
msousa@353: 	  if test -n "$non_pic_object" &&
msousa@353: 	     test "$non_pic_object" != none; then
msousa@353: 	    rmfiles="$rmfiles $dir/$non_pic_object"
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 	;;
msousa@353: 
msousa@353:       *)
msousa@353: 	if test "$mode" = clean ; then
msousa@353: 	  noexename=$name
msousa@353: 	  case $file in
msousa@353: 	  *.exe)
msousa@353: 	    func_stripname '' '.exe' "$file"
msousa@353: 	    file=$func_stripname_result
msousa@353: 	    func_stripname '' '.exe' "$name"
msousa@353: 	    noexename=$func_stripname_result
msousa@353: 	    # $file with .exe has already been added to rmfiles,
msousa@353: 	    # add $file without .exe
msousa@353: 	    rmfiles="$rmfiles $file"
msousa@353: 	    ;;
msousa@353: 	  esac
msousa@353: 	  # Do a test to see if this is a libtool program.
msousa@353: 	  if func_ltwrapper_p "$file"; then
msousa@353: 	    if func_ltwrapper_executable_p "$file"; then
msousa@353: 	      func_ltwrapper_scriptname "$file"
msousa@353: 	      relink_command=
msousa@353: 	      func_source $func_ltwrapper_scriptname_result
msousa@353: 	      rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
msousa@353: 	    else
msousa@353: 	      relink_command=
msousa@353: 	      func_source $dir/$noexename
msousa@353: 	    fi
msousa@353: 
msousa@353: 	    # note $name still contains .exe if it was in $file originally
msousa@353: 	    # as does the version of $file that was added into $rmfiles
msousa@353: 	    rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
msousa@353: 	    if test "$fast_install" = yes && test -n "$relink_command"; then
msousa@353: 	      rmfiles="$rmfiles $objdir/lt-$name"
msousa@353: 	    fi
msousa@353: 	    if test "X$noexename" != "X$name" ; then
msousa@353: 	      rmfiles="$rmfiles $objdir/lt-${noexename}.c"
msousa@353: 	    fi
msousa@353: 	  fi
msousa@353: 	fi
msousa@353: 	;;
msousa@353:       esac
msousa@353:       func_show_eval "$RM $rmfiles" 'exit_status=1'
msousa@353:     done
msousa@353:     objdir="$origobjdir"
msousa@353: 
msousa@353:     # Try to remove the ${objdir}s in the directories where we deleted files
msousa@353:     for dir in $rmdirs; do
msousa@353:       if test -d "$dir"; then
msousa@353: 	func_show_eval "rmdir $dir >/dev/null 2>&1"
msousa@353:       fi
msousa@353:     done
msousa@353: 
msousa@353:     exit $exit_status
msousa@353: }
msousa@353: 
msousa@353: { test "$mode" = uninstall || test "$mode" = clean; } &&
msousa@353:     func_mode_uninstall ${1+"$@"}
msousa@353: 
msousa@353: test -z "$mode" && {
msousa@353:   help="$generic_help"
msousa@353:   func_fatal_help "you must specify a MODE"
msousa@353: }
msousa@353: 
msousa@353: test -z "$exec_cmd" && \
msousa@353:   func_fatal_help "invalid operation mode \`$mode'"
msousa@353: 
msousa@353: if test -n "$exec_cmd"; then
msousa@353:   eval exec "$exec_cmd"
msousa@353:   exit $EXIT_FAILURE
msousa@353: fi
msousa@353: 
msousa@353: exit $exit_status
msousa@353: 
msousa@353: 
msousa@353: # The TAGs below are defined such that we never get into a situation
msousa@353: # in which we disable both kinds of libraries.  Given conflicting
msousa@353: # choices, we go for a static library, that is the most portable,
msousa@353: # since we can't tell whether shared libraries were disabled because
msousa@353: # the user asked for that or because the platform doesn't support
msousa@353: # them.  This is particularly important on AIX, because we don't
msousa@353: # support having both static and shared libraries enabled at the same
msousa@353: # time on that platform, so we default to a shared-only configuration.
msousa@353: # If a disable-shared tag is given, we'll fallback to a static-only
msousa@353: # configuration.  But we'll never go from static-only to shared-only.
msousa@353: 
msousa@353: # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
msousa@353: build_libtool_libs=no
msousa@353: build_old_libs=yes
msousa@353: # ### END LIBTOOL TAG CONFIG: disable-shared
msousa@353: 
msousa@353: # ### BEGIN LIBTOOL TAG CONFIG: disable-static
msousa@353: build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
msousa@353: # ### END LIBTOOL TAG CONFIG: disable-static
msousa@353: 
msousa@353: # Local Variables:
msousa@353: # mode:shell-script
msousa@353: # sh-indentation:2
msousa@353: # End:
msousa@353: # vi:sw=2
msousa@353: