ltmain.sh 244 KB
Newer Older
1
# Generated from ltmain.m4sh.
2

Ralf Wildenhues's avatar
Ralf Wildenhues committed
3
# libtool (GNU libtool 1.3134 2009-11-29) 2.2.7a
4 5
# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996

Ralf Wildenhues's avatar
Ralf Wildenhues committed
6 7
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
# 2007, 2008, 2009 Free Software Foundation, Inc.
8 9 10
# This is free software; see the source for copying conditions.  There is NO
# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

11
# GNU Libtool is free software; you can redistribute it and/or modify
Richard Henderson's avatar
Richard Henderson committed
12 13 14 15
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
16 17 18 19 20 21
# As a special exception to the GNU General Public License,
# if you distribute this file as part of a program or library that
# is built using GNU Libtool, you may include this file under the
# same distribution terms that you use for the rest of that program.
#
# GNU Libtool is distributed in the hope that it will be useful, but
Richard Henderson's avatar
Richard Henderson committed
22 23 24 25 26
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
27 28 29 30
# along with GNU Libtool; see the file COPYING.  If not, a copy
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
# or obtained by writing to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Richard Henderson's avatar
Richard Henderson committed
31

32 33 34 35
# Usage: $progname [OPTION]... [MODE-ARG]...
#
# Provide generalized library-building support services.
#
Ralf Wildenhues's avatar
Ralf Wildenhues committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#       --config             show all configuration variables
#       --debug              enable verbose shell tracing
#   -n, --dry-run            display commands without modifying any files
#       --features           display basic configuration information and exit
#       --mode=MODE          use operation mode MODE
#       --no-finish          let install mode avoid finish commands
#       --preserve-dup-deps  don't remove duplicate dependency libraries
#       --quiet, --silent    don't print informational messages
#       --no-quiet, --no-silent
#                            print informational messages (default)
#       --tag=TAG            use configuration variables from tag TAG
#   -v, --verbose            print more informational messages than default
#       --no-verbose         don't print the extra informational messages
#       --version            print version information
#   -h, --help, --help-all   print short, long, or detailed help message
51 52 53
#
# MODE must be one of the following:
#
Ralf Wildenhues's avatar
Ralf Wildenhues committed
54 55 56 57 58 59 60
#         clean              remove files from the build directory
#         compile            compile a source file into a libtool object
#         execute            automatically set library path, then run a program
#         finish             complete the installation of libtool libraries
#         install            install libraries or executables
#         link               create a library or an executable
#         uninstall          remove libraries from an installed directory
61
#
Ralf Wildenhues's avatar
Ralf Wildenhues committed
62 63
# MODE-ARGS vary depending on the MODE.  When passed as first option,
# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
64 65 66 67 68
# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
#
# When reporting a bug, please describe a test case to reproduce it and
# include the following information:
#
Ralf Wildenhues's avatar
Ralf Wildenhues committed
69 70 71 72 73 74 75 76
#         host-triplet:	$host
#         shell:		$SHELL
#         compiler:		$LTCC
#         compiler flags:		$LTCFLAGS
#         linker:		$LD (gnu? $with_gnu_ld)
#         $progname:	(GNU libtool 1.3134 2009-11-29) 2.2.7a
#         automake:	$automake_version
#         autoconf:	$autoconf_version
77 78 79
#
# Report bugs to <bug-libtool@gnu.org>.

Ralf Wildenhues's avatar
Ralf Wildenhues committed
80
PROGRAM=libtool
81
PACKAGE=libtool
Ralf Wildenhues's avatar
Ralf Wildenhues committed
82 83 84
VERSION=2.2.7a
TIMESTAMP=" 1.3134 2009-11-29"
package_revision=1.3134
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  emulate sh
  NULLCMD=:
  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '${1+"$@"}'='"$@"'
  setopt NO_GLOB_SUBST
else
  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
fi
BIN_SH=xpg4; export BIN_SH # for Tru64
DUALCASE=1; export DUALCASE # for MKS sh

Ralf Wildenhues's avatar
Ralf Wildenhues committed
100 101 102 103 104 105 106 107
# A function that is used when there is no print builtin or printf.
func_fallback_echo ()
{
  eval 'cat <<_LTECHO_EOF
$1
_LTECHO_EOF'
}

108 109 110 111
# NLS nuisances: We save the old values to restore during execute mode.
# Only set LANG and LC_ALL to C if already set.
# These must not be set unconditionally because not all systems understand
# e.g. LANG=C (notably SCO).
112 113 114
lt_user_locale=
lt_safe_locale=
for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
115 116 117 118 119
do
  eval "if test \"\${$lt_var+set}\" = set; then
          save_$lt_var=\$$lt_var
          $lt_var=C
	  export $lt_var
120 121
	  lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
	  lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
122 123 124 125 126 127 128 129 130
	fi"
done

$lt_unset CDPATH





Ralf Wildenhues's avatar
Ralf Wildenhues committed
131 132 133 134 135 136 137 138 139 140 141


# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
# is ksh but when the shell is invoked as "sh" and the current value of
# the _XPG environment variable is not equal to 1 (one), the special
# positional parameter $0, within a function call, is the name of the
# function.
progpath="$0"



142
: ${CP="cp -f"}
Ralf Wildenhues's avatar
Ralf Wildenhues committed
143 144 145 146
: ${ECHO=$as_echo}
: ${EGREP="/bin/grep -E"}
: ${FGREP="/bin/grep -F"}
: ${GREP="/bin/grep"}
147 148 149 150 151
: ${LN_S="ln -s"}
: ${MAKE="make"}
: ${MKDIR="mkdir"}
: ${MV="mv -f"}
: ${RM="rm -f"}
Ralf Wildenhues's avatar
Ralf Wildenhues committed
152
: ${SED="/mount/endor/wildenhu/local-x86_64/bin/sed"}
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
: ${Xsed="$SED -e 1s/^X//"}

# Global variables:
EXIT_SUCCESS=0
EXIT_FAILURE=1
EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.

exit_status=$EXIT_SUCCESS

# Make sure IFS has a sensible default
lt_nl='
'
IFS=" 	$lt_nl"

dirname="s,/[^/]*$,,"
basename="s,^.*/,,"

172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
# func_dirname_and_basename file append nondir_replacement
# perform func_basename and func_dirname in a single function
# call:
#   dirname:  Compute the dirname of FILE.  If nonempty,
#             add APPEND to the result, otherwise set result
#             to NONDIR_REPLACEMENT.
#             value returned in "$func_dirname_result"
#   basename: Compute filename of FILE.
#             value retuned in "$func_basename_result"
# Implementation must be kept synchronized with func_dirname
# and func_basename. For efficiency, we do not delegate to
# those functions but instead duplicate the functionality here.
func_dirname_and_basename ()
{
  # Extract subdirectory from the argument.
Ralf Wildenhues's avatar
Ralf Wildenhues committed
187
  func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
188 189 190 191 192
  if test "X$func_dirname_result" = "X${1}"; then
    func_dirname_result="${3}"
  else
    func_dirname_result="$func_dirname_result${2}"
  fi
Ralf Wildenhues's avatar
Ralf Wildenhues committed
193
  func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
194 195 196 197
}

# Generated shell functions inserted here.

198
# These SED scripts presuppose an absolute path with a trailing slash.
Ralf Wildenhues's avatar
Ralf Wildenhues committed
199 200 201 202 203 204 205 206
pathcar='s,^/\([^/]*\).*$,\1,'
pathcdr='s,^/[^/]*,,'
removedotparts=':dotsl
		s@/\./@/@g
		t dotsl
		s,/\.$,/,'
collapseslashes='s@/\{1,\}@/@g'
finalslash='s,/*$,/,'
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345

# func_normal_abspath PATH
# Remove doubled-up and trailing slashes, "." path components,
# and cancel out any ".." path components in PATH after making
# it an absolute path.
#             value returned in "$func_normal_abspath_result"
func_normal_abspath ()
{
  # Start from root dir and reassemble the path.
  func_normal_abspath_result=
  func_normal_abspath_tpath=$1
  func_normal_abspath_altnamespace=
  case $func_normal_abspath_tpath in
    "")
      # Empty path, that just means $cwd.
      func_stripname '' '/' "`pwd`"
      func_normal_abspath_result=$func_stripname_result
      return
    ;;
    # The next three entries are used to spot a run of precisely
    # two leading slashes without using negated character classes;
    # we take advantage of case's first-match behaviour.
    ///*)
      # Unusual form of absolute path, do nothing.
    ;;
    //*)
      # Not necessarily an ordinary path; POSIX reserves leading '//'
      # and for example Cygwin uses it to access remote file shares
      # over CIFS/SMB, so we conserve a leading double slash if found.
      func_normal_abspath_altnamespace=/
    ;;
    /*)
      # Absolute path, do nothing.
    ;;
    *)
      # Relative path, prepend $cwd.
      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
    ;;
  esac
  # Cancel out all the simple stuff to save iterations.  We also want
  # the path to end with a slash for ease of parsing, so make sure
  # there is one (and only one) here.
  func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
        -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
  while :; do
    # Processed it all yet?
    if test "$func_normal_abspath_tpath" = / ; then
      # If we ascended to the root using ".." the result may be empty now.
      if test -z "$func_normal_abspath_result" ; then
        func_normal_abspath_result=/
      fi
      break
    fi
    func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
        -e "$pathcar"`
    func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
        -e "$pathcdr"`
    # Figure out what to do with it
    case $func_normal_abspath_tcomponent in
      "")
        # Trailing empty path component, ignore it.
      ;;
      ..)
        # Parent dir; strip last assembled component from result.
        func_dirname "$func_normal_abspath_result"
        func_normal_abspath_result=$func_dirname_result
      ;;
      *)
        # Actual path component, append it.
        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
      ;;
    esac
  done
  # Restore leading double-slash if one was found on entry.
  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
}

# func_relative_path SRCDIR DSTDIR
# generates a relative path from SRCDIR to DSTDIR, with a trailing
# slash if non-empty, suitable for immediately appending a filename
# without needing to append a separator.
#             value returned in "$func_relative_path_result"
func_relative_path ()
{
  func_relative_path_result=
  func_normal_abspath "$1"
  func_relative_path_tlibdir=$func_normal_abspath_result
  func_normal_abspath "$2"
  func_relative_path_tbindir=$func_normal_abspath_result

  # Ascend the tree starting from libdir
  while :; do
    # check if we have found a prefix of bindir
    case $func_relative_path_tbindir in
      $func_relative_path_tlibdir)
        # found an exact match
        func_relative_path_tcancelled=
        break
        ;;
      $func_relative_path_tlibdir*)
        # found a matching prefix
        func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
        func_relative_path_tcancelled=$func_stripname_result
        if test -z "$func_relative_path_result"; then
          func_relative_path_result=.
        fi
        break
        ;;
      *)
        func_dirname $func_relative_path_tlibdir
        func_relative_path_tlibdir=${func_dirname_result}
        if test "x$func_relative_path_tlibdir" = x ; then
          # Have to descend all the way to the root!
          func_relative_path_result=../$func_relative_path_result
          func_relative_path_tcancelled=$func_relative_path_tbindir
          break
        fi
        func_relative_path_result=../$func_relative_path_result
        ;;
    esac
  done

  # Now calculate path; take care to avoid doubling-up slashes.
  func_stripname '' '/' "$func_relative_path_result"
  func_relative_path_result=$func_stripname_result
  func_stripname '/' '/' "$func_relative_path_tcancelled"
  if test "x$func_stripname_result" != x ; then
    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
  fi

  # Normalisation. If bindir is libdir, return empty string,
  # else relative path ending with a slash; either way, target
  # file name can be directly appended.
  if test ! -z "$func_relative_path_result"; then
    func_stripname './' '' "$func_relative_path_result/"
    func_relative_path_result=$func_stripname_result
  fi
}

346
# The name of this program:
347 348
func_dirname_and_basename "$progpath"
progname=$func_basename_result
349 350 351 352 353

# Make sure we have an absolute path for reexecution:
case $progpath in
  [\\/]*|[A-Za-z]:\\*) ;;
  *[\\/]*)
354
     progdir=$func_dirname_result
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
     progdir=`cd "$progdir" && pwd`
     progpath="$progdir/$progname"
     ;;
  *)
     save_IFS="$IFS"
     IFS=:
     for progdir in $PATH; do
       IFS="$save_IFS"
       test -x "$progdir/$progname" && break
     done
     IFS="$save_IFS"
     test -n "$progdir" || progdir=`pwd`
     progpath="$progdir/$progname"
     ;;
esac

# Sed substitution that helps us do robust quoting.  It backslashifies
# metacharacters that are still active within double-quoted strings.
Xsed="${SED}"' -e 1s/^X//'
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'

# Same as above, but do not quote variable references.
double_quote_subst='s/\(["`\\]\)/\\\1/g'

# Re-`\' parameter expansions in output of double_quote_subst that were
# `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
# in input to double_quote_subst, that '$' was protected from expansion.
# Since each input `\' is now two `\'s, look for any number of runs of
# four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
bs='\\'
bs2='\\\\'
bs4='\\\\\\\\'
dollar='\$'
sed_double_backslash="\
  s/$bs4/&\\
/g
  s/^$bs2$dollar/$bs&/
  s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
  s/\n//g"

# Standard options:
opt_dry_run=false
opt_help=false
opt_quiet=false
opt_verbose=false
400
opt_warning=:
401 402 403 404 405 406

# func_echo arg...
# Echo program name prefixed message, along with the current mode
# name if it has been set yet.
func_echo ()
{
407
    $ECHO "$progname${mode+: }$mode: $*"
408 409 410 411 412 413 414 415 416 417 418 419 420 421
}

# func_verbose arg...
# Echo program name prefixed message in verbose mode only.
func_verbose ()
{
    $opt_verbose && func_echo ${1+"$@"}

    # A bug in bash halts the script if the last line of a function
    # fails when set -e is in force, so we need another command to
    # work around that:
    :
}

Ralf Wildenhues's avatar
Ralf Wildenhues committed
422 423 424 425 426 427 428
# func_echo_all arg...
# Invoke $ECHO with all args, space-separated.
func_echo_all ()
{
    $ECHO "$*"
}

429 430 431 432 433 434 435 436 437 438 439
# func_error arg...
# Echo program name prefixed message to standard error.
func_error ()
{
    $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
}

# func_warning arg...
# Echo program name prefixed warning message to standard error.
func_warning ()
{
440 441 442 443
    $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2

    # bash bug again:
    :
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496
}

# func_fatal_error arg...
# Echo program name prefixed message to standard error, and exit.
func_fatal_error ()
{
    func_error ${1+"$@"}
    exit $EXIT_FAILURE
}

# func_fatal_help arg...
# Echo program name prefixed message to standard error, followed by
# a help hint, and exit.
func_fatal_help ()
{
    func_error ${1+"$@"}
    func_fatal_error "$help"
}
help="Try \`$progname --help' for more information."  ## default


# func_grep expression filename
# Check whether EXPRESSION matches any line of FILENAME, without output.
func_grep ()
{
    $GREP "$1" "$2" >/dev/null 2>&1
}


# func_mkdir_p directory-path
# Make sure the entire path to DIRECTORY-PATH is available.
func_mkdir_p ()
{
    my_directory_path="$1"
    my_dir_list=

    if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then

      # Protect directory names starting with `-'
      case $my_directory_path in
        -*) my_directory_path="./$my_directory_path" ;;
      esac

      # While some portion of DIR does not yet exist...
      while test ! -d "$my_directory_path"; do
        # ...make a list in topmost first order.  Use a colon delimited
	# list incase some portion of path contains whitespace.
        my_dir_list="$my_directory_path:$my_dir_list"

        # If the last portion added has no slash in it, the list is done
        case $my_directory_path in */*) ;; *) break ;; esac

        # ...otherwise throw away the child directory and loop
Ralf Wildenhues's avatar
Ralf Wildenhues committed
497
        my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
498
      done
Ralf Wildenhues's avatar
Ralf Wildenhues committed
499
      my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548

      save_mkdir_p_IFS="$IFS"; IFS=':'
      for my_dir in $my_dir_list; do
	IFS="$save_mkdir_p_IFS"
        # mkdir can fail with a `File exist' error if two processes
        # try to create one of the directories concurrently.  Don't
        # stop in that case!
        $MKDIR "$my_dir" 2>/dev/null || :
      done
      IFS="$save_mkdir_p_IFS"

      # Bail out if we (or some other process) failed to create a directory.
      test -d "$my_directory_path" || \
        func_fatal_error "Failed to create \`$1'"
    fi
}


# func_mktempdir [string]
# Make a temporary directory that won't clash with other running
# libtool processes, and avoids race conditions if possible.  If
# given, STRING is the basename for that directory.
func_mktempdir ()
{
    my_template="${TMPDIR-/tmp}/${1-$progname}"

    if test "$opt_dry_run" = ":"; then
      # Return a directory name, but don't create it in dry-run mode
      my_tmpdir="${my_template}-$$"
    else

      # If mktemp works, use that first and foremost
      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`

      if test ! -d "$my_tmpdir"; then
        # Failing that, at least try and use $RANDOM to avoid a race
        my_tmpdir="${my_template}-${RANDOM-0}$$"

        save_mktempdir_umask=`umask`
        umask 0077
        $MKDIR "$my_tmpdir"
        umask $save_mktempdir_umask
      fi

      # If we're not in dry-run mode, bomb out on failure
      test -d "$my_tmpdir" || \
        func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
    fi

Ralf Wildenhues's avatar
Ralf Wildenhues committed
549
    $ECHO "$my_tmpdir"
550 551 552 553 554 555 556 557 558 559 560 561 562
}


# func_quote_for_eval arg
# Aesthetically quote ARG to be evaled later.
# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
# is double-quoted, suitable for a subsequent eval, whereas
# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
# which are still active within double quotes backslashified.
func_quote_for_eval ()
{
    case $1 in
      *[\\\`\"\$]*)
Ralf Wildenhues's avatar
Ralf Wildenhues committed
563
	func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
      *)
        func_quote_for_eval_unquoted_result="$1" ;;
    esac

    case $func_quote_for_eval_unquoted_result in
      # Double-quote args containing shell metacharacters to delay
      # word splitting, command substitution and and variable
      # expansion for a subsequent eval.
      # Many Bourne shells cannot handle close brackets correctly
      # in scan sets, so we specify it separately.
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
        func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
        ;;
      *)
        func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
    esac
}


# func_quote_for_expand arg
# Aesthetically quote ARG to be evaled later; same as above,
# but do not quote variable references.
func_quote_for_expand ()
{
    case $1 in
      *[\\\`\"]*)
Ralf Wildenhues's avatar
Ralf Wildenhues committed
590
	my_arg=`$ECHO "$1" | $SED \
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633
	    -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
      *)
        my_arg="$1" ;;
    esac

    case $my_arg in
      # Double-quote args containing shell metacharacters to delay
      # word splitting and command substitution for a subsequent eval.
      # Many Bourne shells cannot handle close brackets correctly
      # in scan sets, so we specify it separately.
      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
        my_arg="\"$my_arg\""
        ;;
    esac

    func_quote_for_expand_result="$my_arg"
}


# func_show_eval cmd [fail_exp]
# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
# is given, then evaluate it.
func_show_eval ()
{
    my_cmd="$1"
    my_fail_exp="${2-:}"

    ${opt_silent-false} || {
      func_quote_for_expand "$my_cmd"
      eval "func_echo $func_quote_for_expand_result"
    }

    if ${opt_dry_run-false}; then :; else
      eval "$my_cmd"
      my_status=$?
      if test "$my_status" -eq 0; then :; else
	eval "(exit $my_status); $my_fail_exp"
      fi
    fi
}


634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
# func_show_eval_locale cmd [fail_exp]
# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
# is given, then evaluate it.  Use the saved locale for evaluation.
func_show_eval_locale ()
{
    my_cmd="$1"
    my_fail_exp="${2-:}"

    ${opt_silent-false} || {
      func_quote_for_expand "$my_cmd"
      eval "func_echo $func_quote_for_expand_result"
    }

    if ${opt_dry_run-false}; then :; else
      eval "$lt_user_locale
	    $my_cmd"
      my_status=$?
      eval "$lt_safe_locale"
      if test "$my_status" -eq 0; then :; else
	eval "(exit $my_status); $my_fail_exp"
      fi
    fi
}


660 661 662 663 664 665 666



# func_version
# Echo version message to standard output and exit.
func_version ()
{
Ralf Wildenhues's avatar
Ralf Wildenhues committed
667 668 669 670 671 672 673 674 675
    $SED -n '/(C)/!b go
	:more
	/\./!{
	  N
	  s/\n# //
	  b more
	}
	:go
	/^# '$PROGRAM' (GNU /,/# warranty; / {
676 677 678 679 680 681 682 683 684 685 686 687
        s/^# //
	s/^# *$//
        s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
        p
     }' < "$progpath"
     exit $?
}

# func_usage
# Echo short help message to standard output and exit.
func_usage ()
{
Ralf Wildenhues's avatar
Ralf Wildenhues committed
688
    $SED -n '/^# Usage:/,/^#  *-h/ {
689 690 691 692 693
        s/^# //
	s/^# *$//
	s/\$progname/'$progname'/
	p
    }' < "$progpath"
Ralf Wildenhues's avatar
Ralf Wildenhues committed
694
    echo
695 696 697 698
    $ECHO "run \`$progname --help | more' for full usage"
    exit $?
}

Ralf Wildenhues's avatar
Ralf Wildenhues committed
699 700 701
# func_help [NOEXIT]
# Echo long help message to standard output and exit,
# unless 'noexit' is passed as argument.
702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717
func_help ()
{
    $SED -n '/^# Usage:/,/# Report bugs to/ {
        s/^# //
	s/^# *$//
	s*\$progname*'$progname'*
	s*\$host*'"$host"'*
	s*\$SHELL*'"$SHELL"'*
	s*\$LTCC*'"$LTCC"'*
	s*\$LTCFLAGS*'"$LTCFLAGS"'*
	s*\$LD*'"$LD"'*
	s/\$with_gnu_ld/'"$with_gnu_ld"'/
	s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
	s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
	p
     }' < "$progpath"
Ralf Wildenhues's avatar
Ralf Wildenhues committed
718 719 720 721
    ret=$?
    if test -z "$1"; then
      exit $ret
    fi
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738
}

# func_missing_arg argname
# Echo program name prefixed message to standard error and set global
# exit_cmd.
func_missing_arg ()
{
    func_error "missing argument for $1"
    exit_cmd=exit
}

exit_cmd=:





739

Richard Henderson's avatar
Richard Henderson committed
740
magic="%%%MAGIC variable%%%"
741
magic_exe="%%%MAGIC EXE variable%%%"
Richard Henderson's avatar
Richard Henderson committed
742 743

# Global variables.
744
# $mode is unset
Richard Henderson's avatar
Richard Henderson committed
745 746
nonopt=
execute_dlfiles=
747
preserve_args=
Richard Henderson's avatar
Richard Henderson committed
748
lo2o="s/\\.lo\$/.${objext}/"
749
o2lo="s/\\.${objext}\$/.lo/"
750 751
extracted_archives=
extracted_serial=0
Richard Henderson's avatar
Richard Henderson committed
752

753
opt_dry_run=false
Ralf Wildenhues's avatar
Ralf Wildenhues committed
754
opt_finish=:
755 756 757
opt_duplicate_deps=false
opt_silent=false
opt_debug=:
758

759 760 761 762
# If this variable is set in any of the actions, the command in it
# will be execed at the end.  This prevents here-documents from being
# left over by shells.
exec_cmd=
763

764 765 766 767 768 769 770 771 772
# func_fatal_configuration arg...
# Echo program name prefixed message to standard error, followed by
# a configuration failure hint, and exit.
func_fatal_configuration ()
{
    func_error ${1+"$@"}
    func_error "See the $PACKAGE documentation for more information."
    func_fatal_error "Fatal configuration error."
}
Richard Henderson's avatar
Richard Henderson committed
773 774


775 776 777 778 779 780
# func_config
# Display the configuration for all the tags in this script.
func_config ()
{
    re_begincf='^# ### BEGIN LIBTOOL'
    re_endcf='^# ### END LIBTOOL'
Richard Henderson's avatar
Richard Henderson committed
781

782 783
    # Default configuration.
    $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
Richard Henderson's avatar
Richard Henderson committed
784

785 786
    # Now print the configurations for the tags.
    for tagname in $taglist; do
787
      $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
788
    done
Richard Henderson's avatar
Richard Henderson committed
789

790 791
    exit $?
}
Richard Henderson's avatar
Richard Henderson committed
792

793 794 795 796
# func_features
# Display the features supported by this script.
func_features ()
{
Ralf Wildenhues's avatar
Ralf Wildenhues committed
797
    echo "host: $host"
Richard Henderson's avatar
Richard Henderson committed
798
    if test "$build_libtool_libs" = yes; then
Ralf Wildenhues's avatar
Ralf Wildenhues committed
799
      echo "enable shared libraries"
Richard Henderson's avatar
Richard Henderson committed
800
    else
Ralf Wildenhues's avatar
Ralf Wildenhues committed
801
      echo "disable shared libraries"
Richard Henderson's avatar
Richard Henderson committed
802 803
    fi
    if test "$build_old_libs" = yes; then
Ralf Wildenhues's avatar
Ralf Wildenhues committed
804
      echo "enable static libraries"
Richard Henderson's avatar
Richard Henderson committed
805
    else
Ralf Wildenhues's avatar
Ralf Wildenhues committed
806
      echo "disable static libraries"
Richard Henderson's avatar
Richard Henderson committed
807 808
    fi

809 810
    exit $?
}
Richard Henderson's avatar
Richard Henderson committed
811

812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830
# func_enable_tag tagname
# Verify that TAGNAME is valid, and either flag an error and exit, or
# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
# variable here.
func_enable_tag ()
{
  # Global variable:
  tagname="$1"

  re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
  re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
  sed_extractcf="/$re_begincf/,/$re_endcf/p"

  # Validate tagname.
  case $tagname in
    *[!-_A-Za-z0-9,/]*)
      func_fatal_error "invalid tag name: $tagname"
      ;;
  esac
Richard Henderson's avatar
Richard Henderson committed
831

832 833 834 835 836 837 838
  # Don't test for the "default" C tag, as we know it's
  # there but not specially marked.
  case $tagname in
    CC) ;;
    *)
      if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
	taglist="$taglist $tagname"
Richard Henderson's avatar
Richard Henderson committed
839

840 841 842 843 844 845 846 847 848 849 850 851
	# Evaluate the configuration.  Be careful to quote the path
	# and the sed script, to avoid splitting on whitespace, but
	# also don't use non-portable quotes within backquotes within
	# quotes we have to do it in 2 steps:
	extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
	eval "$extractedcf"
      else
	func_error "ignoring unknown tag $tagname"
      fi
      ;;
  esac
}
852

853 854 855
# Parse options once, thoroughly.  This comes as soon as possible in
# the script to make things like `libtool --version' happen quickly.
{
856

857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880
  # Shorthand for --mode=foo, only valid as the first argument
  case $1 in
  clean|clea|cle|cl)
    shift; set dummy --mode clean ${1+"$@"}; shift
    ;;
  compile|compil|compi|comp|com|co|c)
    shift; set dummy --mode compile ${1+"$@"}; shift
    ;;
  execute|execut|execu|exec|exe|ex|e)
    shift; set dummy --mode execute ${1+"$@"}; shift
    ;;
  finish|finis|fini|fin|fi|f)
    shift; set dummy --mode finish ${1+"$@"}; shift
    ;;
  install|instal|insta|inst|ins|in|i)
    shift; set dummy --mode install ${1+"$@"}; shift
    ;;
  link|lin|li|l)
    shift; set dummy --mode link ${1+"$@"}; shift
    ;;
  uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
    shift; set dummy --mode uninstall ${1+"$@"}; shift
    ;;
  esac
Richard Henderson's avatar
Richard Henderson committed
881

882 883 884 885
  # Parse non-mode specific arguments:
  while test "$#" -gt 0; do
    opt="$1"
    shift
886

887
    case $opt in
888
      --config)		func_config					;;
889 890

      --debug)		preserve_args="$preserve_args $opt"
891 892
			func_echo "enabling shell trace mode"
			opt_debug='set -x'
893 894 895 896 897 898 899 900 901 902 903
			$opt_debug
			;;

      -dlopen)		test "$#" -eq 0 && func_missing_arg "$opt" && break
			execute_dlfiles="$execute_dlfiles $1"
			shift
			;;

      --dry-run | -n)	opt_dry_run=:					;;
      --features)       func_features					;;
      --finish)		mode="finish"					;;
Ralf Wildenhues's avatar
Ralf Wildenhues committed
904
      --no-finish)	opt_finish=false				;;
905 906

      --mode)		test "$#" -eq 0 && func_missing_arg "$opt" && break
907
			case $1 in
908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924
			  # Valid mode arguments:
			  clean)	;;
			  compile)	;;
			  execute)	;;
			  finish)	;;
			  install)	;;
			  link)		;;
			  relink)	;;
			  uninstall)	;;

			  # Catch anything else as an error
			  *) func_error "invalid argument for $opt"
			     exit_cmd=exit
			     break
			     ;;
		        esac

925
			mode="$1"
926 927 928 929
			shift
			;;

      --preserve-dup-deps)
930
			opt_duplicate_deps=:				;;
931 932

      --quiet|--silent)	preserve_args="$preserve_args $opt"
933
			opt_silent=:
Ralf Wildenhues's avatar
Ralf Wildenhues committed
934 935 936 937 938 939
			opt_verbose=false
			;;

      --no-quiet|--no-silent)
			preserve_args="$preserve_args $opt"
			opt_silent=false
940 941 942
			;;

      --verbose| -v)	preserve_args="$preserve_args $opt"
943
			opt_silent=false
Ralf Wildenhues's avatar
Ralf Wildenhues committed
944 945 946 947 948
			opt_verbose=:
			;;

      --no-verbose)	preserve_args="$preserve_args $opt"
			opt_verbose=false
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965
			;;

      --tag)		test "$#" -eq 0 && func_missing_arg "$opt" && break
			preserve_args="$preserve_args $opt $1"
			func_enable_tag "$1"	# tagname is set here
			shift
			;;

      # Separate optargs to long options:
      -dlopen=*|--mode=*|--tag=*)
			func_opt_split "$opt"
			set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
			shift
			;;

      -\?|-h)		func_usage					;;
      --help)		opt_help=:					;;
Ralf Wildenhues's avatar
Ralf Wildenhues committed
966
      --help-all)	opt_help=': help-all'				;;
967 968 969 970 971
      --version)	func_version					;;

      -*)		func_fatal_help "unrecognized option \`$opt'"	;;

      *)		nonopt="$opt"
972
			break
973 974 975
			;;
    esac
  done
Richard Henderson's avatar
Richard Henderson committed
976 977


978
  case $host in
Rainer Orth's avatar
Rainer Orth committed
979
    *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* )
980 981 982 983 984 985 986
      # don't eliminate duplications in $postdeps and $predeps
      opt_duplicate_compiler_generated_deps=:
      ;;
    *)
      opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
      ;;
  esac
Richard Henderson's avatar
Richard Henderson committed
987

988 989 990 991
  # Having warned about all mis-specified options, bail out if
  # anything was wrong.
  $exit_cmd $EXIT_FAILURE
}
Richard Henderson's avatar
Richard Henderson committed
992

993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
# func_check_version_match
# Ensure that we are using m4 macros, and libtool script from the same
# release of libtool.
func_check_version_match ()
{
  if test "$package_revision" != "$macro_revision"; then
    if test "$VERSION" != "$macro_version"; then
      if test -z "$macro_version"; then
        cat >&2 <<_LT_EOF
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
$progname: definition of this LT_INIT comes from an older release.
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
$progname: and run autoconf again.
_LT_EOF
      else
        cat >&2 <<_LT_EOF
$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
$progname: and run autoconf again.
_LT_EOF
Richard Henderson's avatar
Richard Henderson committed
1014
      fi
1015 1016 1017 1018 1019 1020 1021 1022
    else
      cat >&2 <<_LT_EOF
$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
$progname: but the definition of this LT_INIT comes from revision $macro_revision.
$progname: You should recreate aclocal.m4 with macros from revision $package_revision
$progname: of $PACKAGE $VERSION and run autoconf again.
_LT_EOF
    fi
Richard Henderson's avatar
Richard Henderson committed
1023

1024 1025 1026
    exit $EXIT_MISMATCH
  fi
}
Richard Henderson's avatar
Richard Henderson committed
1027 1028


1029 1030 1031
## ----------- ##
##    Main.    ##
## ----------- ##
Richard Henderson's avatar
Richard Henderson committed
1032

1033
$opt_help || {
1034 1035
  # Sanity checks first:
  func_check_version_match
Richard Henderson's avatar
Richard Henderson committed
1036

1037 1038 1039
  if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
    func_fatal_configuration "not configured to build any kind of library"
  fi
Richard Henderson's avatar
Richard Henderson committed
1040

1041
  test -z "$mode" && func_fatal_error "error: you must specify a MODE."
Richard Henderson's avatar
Richard Henderson committed
1042 1043


1044
  # Darwin sucks
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1045
  eval "std_shrext=\"$shrext_cmds\""
Richard Henderson's avatar
Richard Henderson committed
1046 1047


1048 1049 1050 1051 1052 1053
  # Only execute mode is allowed to have -dlopen flags.
  if test -n "$execute_dlfiles" && test "$mode" != execute; then
    func_error "unrecognized option \`-dlopen'"
    $ECHO "$help" 1>&2
    exit $EXIT_FAILURE
  fi
Richard Henderson's avatar
Richard Henderson committed
1054

1055 1056 1057 1058
  # Change the help message to a mode-specific one.
  generic_help="$help"
  help="Try \`$progname --help --mode=$mode' for more information."
}
Richard Henderson's avatar
Richard Henderson committed
1059

1060

1061 1062 1063 1064 1065 1066
# func_lalib_p file
# True iff FILE is a libtool `.la' library or `.lo' object file.
# This function is only a basic sanity check; it will hardly flush out
# determined imposters.
func_lalib_p ()
{
1067 1068 1069
    test -f "$1" &&
      $SED -e 4q "$1" 2>/dev/null \
        | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
1070
}
1071

1072 1073 1074 1075 1076 1077 1078 1079 1080 1081
# func_lalib_unsafe_p file
# True iff FILE is a libtool `.la' library or `.lo' object file.
# This function implements the same check as func_lalib_p without
# resorting to external programs.  To this end, it redirects stdin and
# closes it afterwards, without saving the original file descriptor.
# As a safety measure, use it only where a negative result would be
# fatal anyway.  Works if `file' does not exist.
func_lalib_unsafe_p ()
{
    lalib_p=no
1082
    if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
1083 1084 1085 1086 1087 1088 1089
	for lalib_p_l in 1 2 3 4
	do
	    read lalib_p_line
	    case "$lalib_p_line" in
		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
	    esac
	done
1090
	exec 0<&5 5<&-
Richard Henderson's avatar
Richard Henderson committed
1091
    fi
1092 1093
    test "$lalib_p" = yes
}
Richard Henderson's avatar
Richard Henderson committed
1094

1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131
# func_ltwrapper_script_p file
# True iff FILE is a libtool wrapper script
# This function is only a basic sanity check; it will hardly flush out
# determined imposters.
func_ltwrapper_script_p ()
{
    func_lalib_p "$1"
}

# func_ltwrapper_executable_p file
# True iff FILE is a libtool wrapper executable
# This function is only a basic sanity check; it will hardly flush out
# determined imposters.
func_ltwrapper_executable_p ()
{
    func_ltwrapper_exec_suffix=
    case $1 in
    *.exe) ;;
    *) func_ltwrapper_exec_suffix=.exe ;;
    esac
    $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
}

# func_ltwrapper_scriptname file
# Assumes file is an ltwrapper_executable
# uses $file to determine the appropriate filename for a
# temporary ltwrapper_script.
func_ltwrapper_scriptname ()
{
    func_ltwrapper_scriptname_result=""
    if func_ltwrapper_executable_p "$1"; then
	func_dirname_and_basename "$1" "" "."
	func_stripname '' '.exe' "$func_basename_result"
	func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
    fi
}

1132
# func_ltwrapper_p file
1133
# True iff FILE is a libtool wrapper script or wrapper executable
1134 1135 1136 1137
# This function is only a basic sanity check; it will hardly flush out
# determined imposters.
func_ltwrapper_p ()
{
1138
    func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
1139
}
1140

Richard Henderson's avatar
Richard Henderson committed
1141

1142 1143 1144 1145 1146 1147 1148 1149 1150 1151
# func_execute_cmds commands fail_cmd
# Execute tilde-delimited COMMANDS.
# If FAIL_CMD is given, eval that upon failure.
# FAIL_CMD may read-access the current command in variable CMD!
func_execute_cmds ()
{
    $opt_debug
    save_ifs=$IFS; IFS='~'
    for cmd in $1; do
      IFS=$save_ifs
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1152
      eval "cmd=\"$cmd\""
1153 1154 1155 1156
      func_show_eval "$cmd" "${2-:}"
    done
    IFS=$save_ifs
}
Richard Henderson's avatar
Richard Henderson committed
1157 1158


1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174
# func_source file
# Source FILE, adding directory component if necessary.
# Note that it is not necessary on cygwin/mingw to append a dot to
# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
# behavior happens only for exec(3), not for open(2)!  Also, sourcing
# `FILE.' does not work on cygwin managed mounts.
func_source ()
{
    $opt_debug
    case $1 in
    */* | *\\*)	. "$1" ;;
    *)		. "./$1" ;;
    esac
}


1175 1176 1177 1178 1179 1180 1181
# func_infer_tag arg
# Infer tagged configuration to use if any are available and
# if one wasn't chosen via the "--tag" command line option.
# Only attempt this if the compiler in the base compile
# command doesn't match the default compiler.
# arg is usually of the form 'gcc ...'
func_infer_tag ()
1182 1183 1184 1185 1186 1187 1188 1189
{
    $opt_debug
    if test -n "$available_tags" && test -z "$tagname"; then
      CC_quoted=
      for arg in $CC; do
        func_quote_for_eval "$arg"
	CC_quoted="$CC_quoted $func_quote_for_eval_result"
      done
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1190 1191
      CC_expanded=`func_echo_all $CC`
      CC_quoted_expanded=`func_echo_all $CC_quoted`
1192 1193 1194
      case $@ in
      # Blanks in the command may have been stripped by the calling shell,
      # but not from the CC environment variable when configure was run.
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1195 1196
      " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
      " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209
      # Blanks at the start of $base_compile will cause this to fail
      # if we don't check for them as well.
      *)
	for z in $available_tags; do
	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
	    # Evaluate the configuration.
	    eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
	    CC_quoted=
	    for arg in $CC; do
	      # Double-quote args containing other shell metacharacters.
	      func_quote_for_eval "$arg"
	      CC_quoted="$CC_quoted $func_quote_for_eval_result"
	    done
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1210 1211
	    CC_expanded=`func_echo_all $CC`
	    CC_quoted_expanded=`func_echo_all $CC_quoted`
1212
	    case "$@ " in
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1213 1214
	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
1215 1216 1217 1218 1219 1220 1221
	      # The compiler in the base compile command matches
	      # the one in the tagged configuration.
	      # Assume this is the tagged configuration we want.
	      tagname=$z
	      break
	      ;;
	    esac
1222
	  fi
1223 1224 1225 1226 1227 1228 1229 1230 1231
	done
	# If $tagname still isn't set, then no tagged configuration
	# was found and let the user know that the "--tag" command
	# line option must be used.
	if test -z "$tagname"; then
	  func_echo "unable to infer tagged configuration"
	  func_fatal_error "specify a tag with \`--tag'"
#	else
#	  func_verbose "using $tagname tagged configuration"
Richard Henderson's avatar
Richard Henderson committed
1232 1233 1234
	fi
	;;
      esac
1235 1236
    fi
}
Richard Henderson's avatar
Richard Henderson committed
1237 1238 1239



1240 1241 1242 1243
# func_write_libtool_object output_name pic_name nonpic_name
# Create a libtool object file (analogous to a ".la" file),
# but don't create it if we're doing a dry run.
func_write_libtool_object ()
1244
{
1245 1246 1247 1248 1249
    write_libobj=${1}
    if test "$build_libtool_libs" = yes; then
      write_lobj=\'${2}\'
    else
      write_lobj=none
1250 1251
    fi

1252 1253 1254 1255 1256
    if test "$build_old_libs" = yes; then
      write_oldobj=\'${3}\'
    else
      write_oldobj=none
    fi
1257

1258 1259 1260 1261 1262 1263 1264
    $opt_dry_run || {
      cat >${write_libobj}T <<EOF
# $write_libobj - a libtool object file
# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
1265

1266 1267
# Name of the PIC object.
pic_object=$write_lobj
1268

1269 1270
# Name of the non-PIC object
non_pic_object=$write_oldobj
1271

1272 1273 1274 1275
EOF
      $MV "${write_libobj}T" "${write_libobj}"
    }
}
1276

1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289
# func_mode_compile arg...
func_mode_compile ()
{
    $opt_debug
    # Get the compilation command and the source file.
    base_compile=
    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
    suppress_opt=yes
    suppress_output=
    arg_mode=normal
    libobj=
    later=
    pie_flag=
1290

1291 1292 1293 1294 1295 1296 1297 1298
    for arg
    do
      case $arg_mode in
      arg  )
	# do not "continue".  Instead, add this to base_compile
	lastarg="$arg"
	arg_mode=normal
	;;
1299

1300 1301 1302 1303 1304
      target )
	libobj="$arg"
	arg_mode=normal
	continue
	;;
1305

1306 1307 1308 1309 1310 1311 1312 1313 1314
      normal )
	# Accept any command-line options.
	case $arg in
	-o)
	  test -n "$libobj" && \
	    func_fatal_error "you cannot specify \`-o' more than once"
	  arg_mode=target
	  continue
	  ;;
1315

1316 1317 1318 1319
	-pie | -fpie | -fPIE)
          pie_flag="$pie_flag $arg"
	  continue
	  ;;
1320

1321 1322 1323 1324
	-shared | -static | -prefer-pic | -prefer-non-pic)
	  later="$later $arg"
	  continue
	  ;;
1325

1326 1327 1328 1329
	-no-suppress)
	  suppress_opt=no
	  continue
	  ;;
1330

1331 1332 1333 1334
	-Xcompiler)
	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
	  continue      #  The current "srcfile" will either be retained or
	  ;;            #  replaced later.  I would guess that would be a bug.
1335

1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348
	-Wc,*)
	  func_stripname '-Wc,' '' "$arg"
	  args=$func_stripname_result
	  lastarg=
	  save_ifs="$IFS"; IFS=','
	  for arg in $args; do
	    IFS="$save_ifs"
	    func_quote_for_eval "$arg"
	    lastarg="$lastarg $func_quote_for_eval_result"
	  done
	  IFS="$save_ifs"
	  func_stripname ' ' '' "$lastarg"
	  lastarg=$func_stripname_result
1349

1350 1351 1352 1353
	  # Add the arguments to base_compile.
	  base_compile="$base_compile $lastarg"
	  continue
	  ;;
1354

1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
	*)
	  # Accept the current argument as the source file.
	  # The previous "srcfile" becomes the current argument.
	  #
	  lastarg="$srcfile"
	  srcfile="$arg"
	  ;;
	esac  #  case $arg
	;;
      esac    #  case $arg_mode
Richard Henderson's avatar
Richard Henderson committed
1365

1366 1367 1368 1369
      # Aesthetically quote the previous argument.
      func_quote_for_eval "$lastarg"
      base_compile="$base_compile $func_quote_for_eval_result"
    done # for arg
Richard Henderson's avatar
Richard Henderson committed
1370

1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385
    case $arg_mode in
    arg)
      func_fatal_error "you must specify an argument for -Xcompile"
      ;;
    target)
      func_fatal_error "you must specify a target with \`-o'"
      ;;
    *)
      # Get the name of the library object.
      test -z "$libobj" && {
	func_basename "$srcfile"
	libobj="$func_basename_result"
      }
      ;;
    esac
Richard Henderson's avatar
Richard Henderson committed
1386

1387 1388 1389 1390 1391 1392
    # Recognize several different file suffixes.
    # If the user specifies -o file.o, it is replaced with file.lo
    case $libobj in
    *.[cCFSifmso] | \
    *.ada | *.adb | *.ads | *.asm | \
    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1393
    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
1394 1395 1396 1397
      func_xform "$libobj"
      libobj=$func_xform_result
      ;;
    esac
Richard Henderson's avatar
Richard Henderson committed
1398

1399 1400 1401 1402 1403 1404
    case $libobj in
    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
    *)
      func_fatal_error "cannot determine name of library object from \`$libobj'"
      ;;
    esac
Richard Henderson's avatar
Richard Henderson committed
1405

1406
    func_infer_tag $base_compile
Richard Henderson's avatar
Richard Henderson committed
1407

1408 1409 1410 1411 1412 1413 1414 1415
    for arg in $later; do
      case $arg in
      -shared)
	test "$build_libtool_libs" != yes && \
	  func_fatal_configuration "can not build a shared library"
	build_old_libs=no
	continue
	;;
Richard Henderson's avatar
Richard Henderson committed
1416

1417 1418 1419 1420 1421
      -static)
	build_libtool_libs=no
	build_old_libs=yes
	continue
	;;
Richard Henderson's avatar
Richard Henderson committed
1422

1423 1424 1425 1426
      -prefer-pic)
	pic_mode=yes
	continue
	;;
Richard Henderson's avatar
Richard Henderson committed
1427

1428 1429 1430 1431 1432 1433
      -prefer-non-pic)
	pic_mode=no
	continue
	;;
      esac
    done
1434

1435 1436 1437 1438 1439 1440 1441 1442
    func_quote_for_eval "$libobj"
    test "X$libobj" != "X$func_quote_for_eval_result" \
      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
      && func_warning "libobj name \`$libobj' may not contain shell special characters."
    func_dirname_and_basename "$obj" "/" ""
    objname="$func_basename_result"
    xdir="$func_dirname_result"
    lobj=${xdir}$objdir/$objname
1443

1444 1445
    test -z "$base_compile" && \
      func_fatal_help "you must specify a compilation command"
1446

1447 1448 1449
    # Delete any leftover library objects.
    if test "$build_old_libs" = yes; then
      removelist="$obj $lobj $libobj ${libobj}T"
1450
    else
1451 1452
      removelist="$lobj $libobj ${libobj}T"
    fi
Richard Henderson's avatar
Richard Henderson committed
1453

1454 1455 1456 1457 1458 1459 1460 1461 1462
    # On Cygwin there's no "real" PIC flag so we must build both object types
    case $host_os in
    cygwin* | mingw* | pw32* | os2* | cegcc*)
      pic_mode=default
      ;;
    esac
    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
      # non-PIC code in shared libraries is not supported
      pic_mode=default
1463
    fi
1464

1465 1466 1467
    # Calculate the filename of the output object if compiler does
    # not support -o with -c
    if test "$compiler_c_o" = no; then
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1468
      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
1469
      lockfile="$output_obj.lock"
1470
    else
1471 1472 1473
      output_obj=
      need_locks=no
      lockfile=
1474
    fi
1475

1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487
    # Lock this critical section if it is needed
    # We use this script file to make the link, it avoids creating a new file
    if test "$need_locks" = yes; then
      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
	func_echo "Waiting for $lockfile to be removed"
	sleep 2
      done
    elif test "$need_locks" = warn; then
      if test -f "$lockfile"; then
	$ECHO "\
*** ERROR, $lockfile exists and contains:
`cat $lockfile 2>/dev/null`
1488

1489 1490 1491 1492 1493 1494
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
1495

1496 1497 1498 1499 1500 1501
	$opt_dry_run || $RM $removelist
	exit $EXIT_FAILURE
      fi
      removelist="$removelist $output_obj"
      $ECHO "$srcfile" > "$lockfile"
    fi
1502

1503 1504 1505
    $opt_dry_run || $RM $removelist
    removelist="$removelist $lockfile"
    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
Richard Henderson's avatar
Richard Henderson committed
1506

1507
    if test -n "$fix_srcfile_path"; then
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1508
      eval "srcfile=\"$fix_srcfile_path\""
1509 1510 1511
    fi
    func_quote_for_eval "$srcfile"
    qsrcfile=$func_quote_for_eval_result
1512

1513 1514 1515 1516
    # Only build a PIC object if we are building libtool libraries.
    if test "$build_libtool_libs" = yes; then
      # Without this assignment, base_compile gets emptied.
      fbsd_hideous_sh_bug=$base_compile
Richard Henderson's avatar
Richard Henderson committed
1517

1518 1519 1520 1521 1522 1523
      if test "$pic_mode" != no; then
	command="$base_compile $qsrcfile $pic_flag"
      else
	# Don't build PIC code
	command="$base_compile $qsrcfile"
      fi
Richard Henderson's avatar
Richard Henderson committed
1524

1525
      func_mkdir_p "$xdir$objdir"
1526

1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564
      if test -z "$output_obj"; then
	# Place PIC objects in $objdir
	command="$command -o $lobj"
      fi

      func_show_eval_locale "$command"	\
          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'

      if test "$need_locks" = warn &&
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
	$ECHO "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`

but it should contain:
$srcfile

This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."

	$opt_dry_run || $RM $removelist
	exit $EXIT_FAILURE
      fi

      # Just move the object if needed, then go on to compile the next one
      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
	func_show_eval '$MV "$output_obj" "$lobj"' \
	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
      fi

      # Allow error messages only from the first compilation.
      if test "$suppress_opt" = yes; then
	suppress_output=' >/dev/null 2>&1'
      fi
1565 1566
    fi

1567
    # Only build a position-dependent object if we build old libraries.
1568
    if test "$build_old_libs" = yes; then
1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608
      if test "$pic_mode" != yes; then
	# Don't build PIC code
	command="$base_compile $qsrcfile$pie_flag"
      else
	command="$base_compile $qsrcfile $pic_flag"
      fi
      if test "$compiler_c_o" = yes; then
	command="$command -o $obj"
      fi

      # Suppress compiler output if we already did a PIC compilation.
      command="$command$suppress_output"
      func_show_eval_locale "$command" \
        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'

      if test "$need_locks" = warn &&
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
	$ECHO "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`

but it should contain:
$srcfile

This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."

	$opt_dry_run || $RM $removelist
	exit $EXIT_FAILURE
      fi

      # Just move the object if needed
      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
	func_show_eval '$MV "$output_obj" "$obj"' \
	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
      fi
1609 1610 1611
    fi

    $opt_dry_run || {
1612
      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1613

1614 1615 1616 1617 1618 1619
      # Unlock the critical section if it was locked
      if test "$need_locks" != no; then
	removelist=$lockfile
        $RM "$lockfile"
      fi
    }
1620

1621 1622
    exit $EXIT_SUCCESS
}
1623

1624
$opt_help || {
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1625
  test "$mode" = compile && func_mode_compile ${1+"$@"}
1626 1627
}

1628
func_mode_help ()
1629
{
1630 1631 1632 1633 1634 1635 1636
    # We need to display help for each of the modes.
    case $mode in
      "")
        # Generic help is extracted from the usage comments
        # at the start of this file.
        func_help
        ;;
1637

1638 1639 1640
      clean)
        $ECHO \
"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
Richard Henderson's avatar
Richard Henderson committed
1641

1642
Remove files from the build directory.
Richard Henderson's avatar
Richard Henderson committed
1643

1644 1645 1646
RM is the name of the program to use to delete files associated with each FILE
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
to RM.
Richard Henderson's avatar
Richard Henderson committed
1647

1648 1649 1650
If FILE is a libtool library, object or program, all the files associated
with it are deleted. Otherwise, only FILE itself is deleted using RM."
        ;;
Richard Henderson's avatar
Richard Henderson committed
1651

1652 1653 1654
      compile)
      $ECHO \
"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
Richard Henderson's avatar
Richard Henderson committed
1655

1656
Compile a source file into a libtool library object.
1657

1658
This mode accepts the following additional options:
1659

1660 1661 1662 1663 1664 1665
  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
  -no-suppress      do not suppress compiler output for multiple passes
  -prefer-pic       try to building PIC objects only
  -prefer-non-pic   try to building non-PIC objects only
  -shared           do not build a \`.o' file suitable for static linking
  -static           only build a \`.o' file suitable for static linking
Ralf Wildenhues's avatar
Ralf Wildenhues committed
1666
  -Wc,FLAG          pass FLAG directly to the compiler
1667

1668 1669
COMPILE-COMMAND is a command to be used in creating a \`standard' object file
from the given SOURCEFILE.
Richard Henderson's avatar
Richard Henderson committed
1670

1671 1672 1673 1674
The output file name is determined by removing the directory component from
SOURCEFILE, then substituting the C source code suffix \`.c' with the
library object suffix, \`.lo'."
        ;;
Richard Henderson's avatar
Richard Henderson committed
1675

1676 1677 1678
      execute)
        $ECHO \
"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1679

1680
Automatically set library path, then run a program.
1681

1682
This mode accepts the following additional options:
1683

1684
  -dlopen FILE      add the directory containing FILE to the library path
1685

1686 1687
This mode sets the library path environment variable according to \`-dlopen'
flags.
1688

1689 1690 1691
If any of the ARGS are libtool executable wrappers, then they are translated
into their corresponding uninstalled binary, and any of their required library
directories are added to the library path.
1692

1693 1694
Then, COMMAND is executed, with ARGS as arguments."
        ;;
1695

1696 1697 1698
      finish)
        $ECHO \
"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
Richard Henderson's avatar
Richard Henderson committed
1699

1700
Complete the installation of libtool libraries.
Richard Henderson's avatar
Richard Henderson committed
1701

1702
Each LIBDIR is a directory that contains libtool libraries.
Richard Henderson's avatar
Richard Henderson committed
1703

1704 1705 1706
The commands that this mode executes may require superuser privileges.  Use
the \`--dry-run' option if you just want to see what would be executed."
        ;;
Richard Henderson's avatar
Richard Henderson committed
1707

1708 1709 1710
      install)
        $ECHO \
"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1711

1712
Install executables or libraries.
1713

1714 1715
INSTALL-COMMAND is the installation command.  The first component should be
either the \`install' or \`cp' program.
1716