Annotation of parser3/ltmain.sh, revision 1.7

1.7     ! moko        1: #! /usr/bin/env sh
        !             2: ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
        !             3: ##               by inline-source v2019-02-19.15
1.6       moko        4: 
1.7     ! moko        5: # libtool (GNU libtool) 2.5.4
        !             6: # Provide generalized library-building support services.
1.6       moko        7: # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
                      8: 
1.7     ! moko        9: # Copyright (C) 1996-2019, 2021-2024 Free Software Foundation, Inc.
1.6       moko       10: # This is free software; see the source for copying conditions.  There is NO
                     11: # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
                     12: 
                     13: # GNU Libtool is free software; you can redistribute it and/or modify
1.5       paf        14: # it under the terms of the GNU General Public License as published by
                     15: # the Free Software Foundation; either version 2 of the License, or
                     16: # (at your option) any later version.
                     17: #
1.6       moko       18: # As a special exception to the GNU General Public License,
                     19: # if you distribute this file as part of a program or library that
                     20: # is built using GNU Libtool, you may include this file under the
                     21: # same distribution terms that you use for the rest of that program.
                     22: #
                     23: # GNU Libtool is distributed in the hope that it will be useful, but
1.5       paf        24: # WITHOUT ANY WARRANTY; without even the implied warranty of
                     25: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
                     26: # General Public License for more details.
                     27: #
                     28: # You should have received a copy of the GNU General Public License
1.7     ! moko       29: # along with this program.  If not, see <http://www.gnu.org/licenses/>.
        !            30: 
        !            31: 
        !            32: PROGRAM=libtool
        !            33: PACKAGE=libtool
        !            34: VERSION="2.5.4 Debian-2.5.4-4"
        !            35: package_revision=2.5.4
        !            36: 
        !            37: 
        !            38: ## ------ ##
        !            39: ## Usage. ##
        !            40: ## ------ ##
        !            41: 
        !            42: # Run './libtool --help' for help with using this script from the
        !            43: # command line.
        !            44: 
        !            45: 
        !            46: ## ------------------------------- ##
        !            47: ## User overridable command paths. ##
        !            48: ## ------------------------------- ##
        !            49: 
        !            50: # After configure completes, it has a better idea of some of the
        !            51: # shell tools we need than the defaults used by the functions shared
        !            52: # with bootstrap, so set those here where they can still be over-
        !            53: # ridden by the user, but otherwise take precedence.
        !            54: 
        !            55: : ${AUTOCONF="autoconf"}
        !            56: : ${AUTOMAKE="automake"}
        !            57: 
        !            58: 
        !            59: ## -------------------------- ##
        !            60: ## Source external libraries. ##
        !            61: ## -------------------------- ##
        !            62: 
        !            63: # Much of our low-level functionality needs to be sourced from external
        !            64: # libraries, which are installed to $pkgauxdir.
        !            65: 
        !            66: # Set a version string for this script.
        !            67: scriptversion=2024-12-01.17; # UTC
1.6       moko       68: 
1.7     ! moko       69: # General shell script boiler plate, and helper functions.
        !            70: # Written by Gary V. Vaughan, 2004
        !            71: 
        !            72: # This is free software.  There is NO warranty; not even for
        !            73: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        !            74: #
        !            75: # Copyright (C) 2004-2019, 2021, 2023-2024 Bootstrap Authors
        !            76: #
        !            77: # This file is dual licensed under the terms of the MIT license
        !            78: # <https://opensource.org/licenses/MIT>, and GPL version 2 or later
        !            79: # <https://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
        !            80: # these licenses when using or redistributing this software or any of
        !            81: # the files within it.  See the URLs above, or the file `LICENSE`
        !            82: # included in the Bootstrap distribution for the full license texts.
        !            83: 
        !            84: # Please report bugs or propose patches to:
        !            85: # <https://github.com/gnulib-modules/bootstrap/issues>
        !            86: 
        !            87: 
        !            88: ## ------ ##
        !            89: ## Usage. ##
        !            90: ## ------ ##
        !            91: 
        !            92: # Evaluate this file near the top of your script to gain access to
        !            93: # the functions and variables defined here:
1.6       moko       94: #
1.7     ! moko       95: #   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
1.5       paf        96: #
1.7     ! moko       97: # If you need to override any of the default environment variable
        !            98: # settings, do that before evaluating this file.
        !            99: 
1.6       moko      100: 
1.7     ! moko      101: ## -------------------- ##
        !           102: ## Shell normalisation. ##
        !           103: ## -------------------- ##
        !           104: 
        !           105: # Some shells need a little help to be as Bourne compatible as possible.
        !           106: # Before doing anything else, make sure all that help has been provided!
1.6       moko      107: 
1.7     ! moko      108: DUALCASE=1; export DUALCASE # for MKS sh
        !           109: if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
1.6       moko      110:   emulate sh
                    111:   NULLCMD=:
1.7     ! moko      112:   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
1.6       moko      113:   # is contrary to our usage.  Disable this feature.
                    114:   alias -g '${1+"$@"}'='"$@"'
                    115:   setopt NO_GLOB_SUBST
1.5       paf       116: else
1.7     ! moko      117:   case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
1.5       paf       118: fi
                    119: 
1.7     ! moko      120: # NLS nuisances: We save the old values in case they are required later.
        !           121: _G_user_locale=
        !           122: _G_safe_locale=
        !           123: for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1.6       moko      124: do
1.7     ! moko      125:   eval "if test set = \"\${$_G_var+set}\"; then
        !           126:           save_$_G_var=\$$_G_var
        !           127:           $_G_var=C
        !           128:          export $_G_var
        !           129:          _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
        !           130:          _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
1.6       moko      131:        fi"
                    132: done
1.7     ! moko      133: # These NLS vars are set unconditionally (bootstrap issue #24).  Unset those
        !           134: # in case the environment reset is needed later and the $save_* variant is not
        !           135: # defined (see the code above).
1.6       moko      136: LC_ALL=C
                    137: LANGUAGE=C
                    138: export LANGUAGE LC_ALL
                    139: 
1.7     ! moko      140: # Make sure IFS has a sensible default
        !           141: sp=' '
        !           142: nl='
        !           143: '
        !           144: IFS="$sp       $nl"
        !           145: 
        !           146: # There are apparently some systems that use ';' as a PATH separator!
        !           147: if test "${PATH_SEPARATOR+set}" != set; then
        !           148:   PATH_SEPARATOR=:
        !           149:   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
        !           150:     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
        !           151:       PATH_SEPARATOR=';'
        !           152:   }
        !           153: fi
        !           154: 
        !           155: 
        !           156: # func_unset VAR
        !           157: # --------------
        !           158: # Portably unset VAR.
        !           159: # In some shells, an 'unset VAR' statement leaves a non-zero return
        !           160: # status if VAR is already unset, which might be problematic if the
        !           161: # statement is used at the end of a function (thus poisoning its return
        !           162: # value) or when 'set -e' is active (causing even a spurious abort of
        !           163: # the script in this case).
        !           164: func_unset ()
        !           165: {
        !           166:     { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
        !           167: }
        !           168: 
        !           169: 
        !           170: # Make sure CDPATH doesn't cause `cd` commands to output the target dir.
        !           171: func_unset CDPATH
        !           172: 
        !           173: # Make sure ${,E,F}GREP behave sanely.
        !           174: func_unset GREP_OPTIONS
        !           175: 
        !           176: 
        !           177: ## ------------------------- ##
        !           178: ## Locate command utilities. ##
        !           179: ## ------------------------- ##
        !           180: 
        !           181: 
        !           182: # func_executable_p FILE
        !           183: # ----------------------
        !           184: # Check that FILE is an executable regular file.
        !           185: func_executable_p ()
        !           186: {
        !           187:     test -f "$1" && test -x "$1"
        !           188: }
        !           189: 
        !           190: 
        !           191: # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
        !           192: # --------------------------------------------
        !           193: # Search for either a program that responds to --version with output
        !           194: # containing "GNU", or else returned by CHECK_FUNC otherwise, by
        !           195: # trying all the directories in PATH with each of the elements of
        !           196: # PROGS_LIST.
        !           197: #
        !           198: # CHECK_FUNC should accept the path to a candidate program, and
        !           199: # set $func_check_prog_result if it truncates its output less than
        !           200: # $_G_path_prog_max characters.
        !           201: func_path_progs ()
        !           202: {
        !           203:     _G_progs_list=$1
        !           204:     _G_check_func=$2
        !           205:     _G_PATH=${3-"$PATH"}
        !           206: 
        !           207:     _G_path_prog_max=0
        !           208:     _G_path_prog_found=false
        !           209:     _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
        !           210:     for _G_dir in $_G_PATH; do
        !           211:       IFS=$_G_save_IFS
        !           212:       test -z "$_G_dir" && _G_dir=.
        !           213:       for _G_prog_name in $_G_progs_list; do
        !           214:         for _exeext in '' .EXE; do
        !           215:           _G_path_prog=$_G_dir/$_G_prog_name$_exeext
        !           216:           func_executable_p "$_G_path_prog" || continue
        !           217:           case `"$_G_path_prog" --version 2>&1` in
        !           218:             *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
        !           219:             *)     $_G_check_func $_G_path_prog
        !           220:                   func_path_progs_result=$func_check_prog_result
        !           221:                   ;;
        !           222:           esac
        !           223:           $_G_path_prog_found && break 3
        !           224:         done
        !           225:       done
        !           226:     done
        !           227:     IFS=$_G_save_IFS
        !           228:     test -z "$func_path_progs_result" && {
        !           229:       echo "no acceptable sed could be found in \$PATH" >&2
        !           230:       exit 1
        !           231:     }
        !           232: }
        !           233: 
        !           234: 
        !           235: # We want to be able to use the functions in this file before configure
        !           236: # has figured out where the best binaries are kept, which means we have
        !           237: # to search for them ourselves - except when the results are already set
        !           238: # where we skip the searches.
        !           239: 
        !           240: # Unless the user overrides by setting SED, search the path for either GNU
        !           241: # sed, or the sed that truncates its output the least.
        !           242: test -z "$SED" && {
        !           243:   _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
        !           244:   for _G_i in 1 2 3 4 5 6 7; do
        !           245:     _G_sed_script=$_G_sed_script$nl$_G_sed_script
        !           246:   done
        !           247:   echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
        !           248:   _G_sed_script=
        !           249: 
        !           250:   func_check_prog_sed ()
        !           251:   {
        !           252:     _G_path_prog=$1
        !           253: 
        !           254:     _G_count=0
        !           255:     printf 0123456789 >conftest.in
        !           256:     while :
        !           257:     do
        !           258:       cat conftest.in conftest.in >conftest.tmp
        !           259:       mv conftest.tmp conftest.in
        !           260:       cp conftest.in conftest.nl
        !           261:       echo '' >> conftest.nl
        !           262:       "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
        !           263:       diff conftest.out conftest.nl >/dev/null 2>&1 || break
        !           264:       _G_count=`expr $_G_count + 1`
        !           265:       if test "$_G_count" -gt "$_G_path_prog_max"; then
        !           266:         # Best one so far, save it but keep looking for a better one
        !           267:         func_check_prog_result=$_G_path_prog
        !           268:         _G_path_prog_max=$_G_count
        !           269:       fi
        !           270:       # 10*(2^10) chars as input seems more than enough
        !           271:       test 10 -lt "$_G_count" && break
        !           272:     done
        !           273:     rm -f conftest.in conftest.tmp conftest.nl conftest.out
        !           274:   }
        !           275: 
        !           276:   func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
        !           277:   rm -f conftest.sed
        !           278:   SED=$func_path_progs_result
        !           279: }
1.6       moko      280: 
                    281: 
1.7     ! moko      282: # Unless the user overrides by setting GREP, search the path for either GNU
        !           283: # grep, or the grep that truncates its output the least.
        !           284: test -z "$GREP" && {
        !           285:   func_check_prog_grep ()
        !           286:   {
        !           287:     _G_path_prog=$1
        !           288: 
        !           289:     _G_count=0
        !           290:     _G_path_prog_max=0
        !           291:     printf 0123456789 >conftest.in
        !           292:     while :
        !           293:     do
        !           294:       cat conftest.in conftest.in >conftest.tmp
        !           295:       mv conftest.tmp conftest.in
        !           296:       cp conftest.in conftest.nl
        !           297:       echo 'GREP' >> conftest.nl
        !           298:       "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
        !           299:       diff conftest.out conftest.nl >/dev/null 2>&1 || break
        !           300:       _G_count=`expr $_G_count + 1`
        !           301:       if test "$_G_count" -gt "$_G_path_prog_max"; then
        !           302:         # Best one so far, save it but keep looking for a better one
        !           303:         func_check_prog_result=$_G_path_prog
        !           304:         _G_path_prog_max=$_G_count
        !           305:       fi
        !           306:       # 10*(2^10) chars as input seems more than enough
        !           307:       test 10 -lt "$_G_count" && break
        !           308:     done
        !           309:     rm -f conftest.in conftest.tmp conftest.nl conftest.out
        !           310:   }
        !           311: 
        !           312:   func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
        !           313:   GREP=$func_path_progs_result
        !           314: }
        !           315: 
1.5       paf       316: 
1.7     ! moko      317: ## ------------------------------- ##
        !           318: ## User overridable command paths. ##
        !           319: ## ------------------------------- ##
1.5       paf       320: 
1.7     ! moko      321: # All uppercase variable names are used for environment variables.  These
        !           322: # variables can be overridden by the user before calling a script that
        !           323: # uses them if a suitable command of that name is not already available
        !           324: # in the command search PATH.
1.5       paf       325: 
1.6       moko      326: : ${CP="cp -f"}
1.7     ! moko      327: : ${ECHO="printf %s\n"}
        !           328: : ${EGREP="$GREP -E"}
        !           329: : ${FGREP="$GREP -F"}
        !           330: : ${LN_S="ln -s"}
1.6       moko      331: : ${MAKE="make"}
                    332: : ${MKDIR="mkdir"}
                    333: : ${MV="mv -f"}
                    334: : ${RM="rm -f"}
                    335: : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
                    336: 
1.7     ! moko      337: 
        !           338: ## -------------------- ##
        !           339: ## Useful sed snippets. ##
        !           340: ## -------------------- ##
        !           341: 
        !           342: sed_dirname='s|/[^/]*$||'
        !           343: sed_basename='s|^.*/||'
        !           344: 
        !           345: # Sed substitution that helps us do robust quoting.  It backslashifies
        !           346: # metacharacters that are still active within double-quoted strings.
        !           347: sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
        !           348: 
        !           349: # Same as above, but do not quote variable references.
        !           350: sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
        !           351: 
        !           352: # Sed substitution that turns a string into a regex matching for the
        !           353: # string literally.
        !           354: sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
        !           355: 
        !           356: # Sed substitution that converts a w32 file name or path
        !           357: # that contains forward slashes, into one that contains
        !           358: # (escaped) backslashes.  A very naive implementation.
        !           359: sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
        !           360: 
        !           361: # Re-'\' parameter expansions in output of sed_double_quote_subst that
        !           362: # were '\'-ed in input to the same.  If an odd number of '\' preceded a
        !           363: # '$' in input to sed_double_quote_subst, that '$' was protected from
        !           364: # expansion.  Since each input '\' is now two '\'s, look for any number
        !           365: # of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
        !           366: _G_bs='\\'
        !           367: _G_bs2='\\\\'
        !           368: _G_bs4='\\\\\\\\'
        !           369: _G_dollar='\$'
        !           370: sed_double_backslash="\
        !           371:   s/$_G_bs4/&\\
        !           372: /g
        !           373:   s/^$_G_bs2$_G_dollar/$_G_bs&/
        !           374:   s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
        !           375:   s/\n//g"
        !           376: 
        !           377: # require_check_ifs_backslash
        !           378: # ---------------------------
        !           379: # Check if we can use backslash as IFS='\' separator, and set
        !           380: # $check_ifs_backshlash_broken to ':' or 'false'.
        !           381: require_check_ifs_backslash=func_require_check_ifs_backslash
        !           382: func_require_check_ifs_backslash ()
        !           383: {
        !           384:   _G_save_IFS=$IFS
        !           385:   IFS='\'
        !           386:   _G_check_ifs_backshlash='a\\b'
        !           387:   for _G_i in $_G_check_ifs_backshlash
        !           388:   do
        !           389:   case $_G_i in
        !           390:   a)
        !           391:     check_ifs_backshlash_broken=false
        !           392:     ;;
        !           393:   '')
        !           394:     break
        !           395:     ;;
        !           396:   *)
        !           397:     check_ifs_backshlash_broken=:
        !           398:     break
        !           399:     ;;
        !           400:   esac
        !           401:   done
        !           402:   IFS=$_G_save_IFS
        !           403:   require_check_ifs_backslash=:
        !           404: }
        !           405: 
        !           406: 
        !           407: ## ----------------- ##
        !           408: ## Global variables. ##
        !           409: ## ----------------- ##
        !           410: 
        !           411: # Except for the global variables explicitly listed below, the following
        !           412: # functions in the '^func_' namespace, and the '^require_' namespace
        !           413: # variables initialised in the 'Resource management' section, sourcing
        !           414: # this file will not pollute your global namespace with anything
        !           415: # else. There's no portable way to scope variables in Bourne shell
        !           416: # though, so actually running these functions will sometimes place
        !           417: # results into a variable named after the function, and often use
        !           418: # temporary variables in the '^_G_' namespace. If you are careful to
        !           419: # avoid using those namespaces casually in your sourcing script, things
        !           420: # should continue to work as you expect. And, of course, you can freely
        !           421: # overwrite any of the functions or variables defined here before
        !           422: # calling anything to customize them.
        !           423: 
1.6       moko      424: EXIT_SUCCESS=0
                    425: EXIT_FAILURE=1
                    426: EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
                    427: EXIT_SKIP=77     # $? = 77 is used to indicate a skipped test to automake.
1.5       paf       428: 
1.7     ! moko      429: # Allow overriding, eg assuming that you follow the convention of
        !           430: # putting '$debug_cmd' at the start of all your functions, you can get
        !           431: # bash to show function call trace with:
        !           432: #
        !           433: #    debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
        !           434: debug_cmd=${debug_cmd-":"}
        !           435: exit_cmd=:
        !           436: 
        !           437: # By convention, finish your script with:
        !           438: #
        !           439: #    exit $exit_status
        !           440: #
        !           441: # so that you can set exit_status to non-zero if you want to indicate
        !           442: # something went wrong during execution without actually bailing out at
        !           443: # the point of failure.
1.6       moko      444: exit_status=$EXIT_SUCCESS
1.5       paf       445: 
1.7     ! moko      446: # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
        !           447: # is ksh but when the shell is invoked as "sh" and the current value of
        !           448: # the _XPG environment variable is not equal to 1 (one), the special
        !           449: # positional parameter $0, within a function call, is the name of the
        !           450: # function.
        !           451: progpath=$0
        !           452: 
        !           453: # The name of this program.
        !           454: progname=`$ECHO "$progpath" |$SED "$sed_basename"`
        !           455: 
        !           456: # Make sure we have an absolute progpath for reexecution:
        !           457: case $progpath in
        !           458:   [\\/]*|[A-Za-z]:\\*) ;;
        !           459:   *[\\/]*)
        !           460:      progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
        !           461:      progdir=`cd "$progdir" && pwd`
        !           462:      progpath=$progdir/$progname
        !           463:      ;;
        !           464:   *)
        !           465:      _G_IFS=$IFS
        !           466:      IFS=${PATH_SEPARATOR-:}
        !           467:      for progdir in $PATH; do
        !           468:        IFS=$_G_IFS
        !           469:        test -x "$progdir/$progname" && break
        !           470:      done
        !           471:      IFS=$_G_IFS
        !           472:      test -n "$progdir" || progdir=`pwd`
        !           473:      progpath=$progdir/$progname
        !           474:      ;;
        !           475: esac
        !           476: 
        !           477: 
        !           478: ## ----------------- ##
        !           479: ## Standard options. ##
        !           480: ## ----------------- ##
        !           481: 
        !           482: # The following options affect the operation of the functions defined
        !           483: # below, and should be set appropriately depending on run-time para-
        !           484: # meters passed on the command line.
        !           485: 
        !           486: opt_dry_run=false
        !           487: opt_quiet=false
        !           488: opt_verbose=false
        !           489: 
        !           490: # Categories 'all' and 'none' are always available.  Append any others
        !           491: # you will pass as the first argument to func_warning from your own
        !           492: # code.
        !           493: warning_categories=
        !           494: 
        !           495: # By default, display warnings according to 'opt_warning_types'.  Set
        !           496: # 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
        !           497: # treat the next displayed warning as a fatal error.
        !           498: warning_func=func_warn_and_continue
        !           499: 
        !           500: # Set to 'all' to display all warnings, 'none' to suppress all
        !           501: # warnings, or a space delimited list of some subset of
        !           502: # 'warning_categories' to display only the listed warnings.
        !           503: opt_warning_types=all
        !           504: 
        !           505: 
        !           506: ## -------------------- ##
        !           507: ## Resource management. ##
        !           508: ## -------------------- ##
        !           509: 
        !           510: # This section contains definitions for functions that each ensure a
        !           511: # particular resource (a file, or a non-empty configuration variable for
        !           512: # example) is available, and if appropriate to extract default values
        !           513: # from pertinent package files. Call them using their associated
        !           514: # 'require_*' variable to ensure that they are executed, at most, once.
        !           515: #
        !           516: # It's entirely deliberate that calling these functions can set
        !           517: # variables that don't obey the namespace limitations obeyed by the rest
        !           518: # of this file, in order that that they be as useful as possible to
        !           519: # callers.
        !           520: 
        !           521: 
        !           522: # require_term_colors
        !           523: # -------------------
        !           524: # Allow display of bold text on terminals that support it.
        !           525: require_term_colors=func_require_term_colors
        !           526: func_require_term_colors ()
        !           527: {
        !           528:     $debug_cmd
        !           529: 
        !           530:     test -t 1 && {
        !           531:       # COLORTERM and USE_ANSI_COLORS environment variables take
        !           532:       # precedence, because most terminfo databases neglect to describe
        !           533:       # whether color sequences are supported.
        !           534:       test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
        !           535: 
        !           536:       if test 1 = "$USE_ANSI_COLORS"; then
        !           537:         # Standard ANSI escape sequences
        !           538:         tc_reset=''
        !           539:         tc_bold='';   tc_standout=''
        !           540:         tc_red='';   tc_green=''
        !           541:         tc_blue='';  tc_cyan=''
        !           542:       else
        !           543:         # Otherwise trust the terminfo database after all.
        !           544:         test -n "`tput sgr0 2>/dev/null`" && {
        !           545:           tc_reset=`tput sgr0`
        !           546:           test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
        !           547:           tc_standout=$tc_bold
        !           548:           test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
        !           549:           test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
        !           550:           test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
        !           551:           test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
        !           552:           test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
        !           553:         }
        !           554:       fi
        !           555:     }
        !           556: 
        !           557:     require_term_colors=:
        !           558: }
        !           559: 
        !           560: 
        !           561: ## ----------------- ##
        !           562: ## Function library. ##
        !           563: ## ----------------- ##
        !           564: 
        !           565: # This section contains a variety of useful functions to call in your
        !           566: # scripts. Take note of the portable wrappers for features provided by
        !           567: # some modern shells, which will fall back to slower equivalents on
        !           568: # less featureful shells.
        !           569: 
        !           570: 
        !           571: # func_append VAR VALUE
        !           572: # ---------------------
        !           573: # Append VALUE onto the existing contents of VAR.
        !           574: 
        !           575: 
        !           576:   # _G_HAVE_PLUSEQ_OP
        !           577:   # Can be empty, in which case the shell is probed, "yes" if += is
        !           578:   # usable or anything else if it does not work.
        !           579: if test -z "$_G_HAVE_PLUSEQ_OP" &&  \
        !           580:      __PLUSEQ_TEST="a" &&  \
        !           581:      __PLUSEQ_TEST+=" b" 2>/dev/null &&  \
        !           582:      test "a b" = "$__PLUSEQ_TEST"; then
        !           583:    _G_HAVE_PLUSEQ_OP=yes
        !           584: fi
        !           585: 
        !           586: if test yes = "$_G_HAVE_PLUSEQ_OP"
        !           587: then
        !           588:   # This is an XSI compatible shell, allowing a faster implementation...
        !           589:   eval 'func_append ()
        !           590:   {
        !           591:     $debug_cmd
        !           592: 
        !           593:     eval "$1+=\$2"
        !           594:   }'
        !           595: else
        !           596:   # ...otherwise fall back to using expr, which is often a shell builtin.
        !           597:   func_append ()
        !           598:   {
        !           599:     $debug_cmd
        !           600: 
        !           601:     eval "$1=\$$1\$2"
        !           602:   }
        !           603: fi
        !           604: 
        !           605: 
        !           606: # func_append_quoted VAR VALUE
        !           607: # ----------------------------
        !           608: # Quote VALUE and append to the end of shell variable VAR, separated
        !           609: # by a space.
        !           610: if test yes = "$_G_HAVE_PLUSEQ_OP"; then
        !           611:   eval 'func_append_quoted ()
        !           612:   {
        !           613:     $debug_cmd
        !           614: 
        !           615:     func_quote_arg pretty "$2"
        !           616:     eval "$1+=\\ \$func_quote_arg_result"
        !           617:   }'
        !           618: else
        !           619:   func_append_quoted ()
        !           620:   {
        !           621:     $debug_cmd
        !           622: 
        !           623:     func_quote_arg pretty "$2"
        !           624:     eval "$1=\$$1\\ \$func_quote_arg_result"
        !           625:   }
        !           626: fi
        !           627: 
        !           628: 
        !           629: # func_append_uniq VAR VALUE
        !           630: # --------------------------
        !           631: # Append unique VALUE onto the existing contents of VAR, assuming
        !           632: # entries are delimited by the first character of VALUE.  For example:
        !           633: #
        !           634: #   func_append_uniq options " --another-option option-argument"
        !           635: #
        !           636: # will only append to $options if " --another-option option-argument "
        !           637: # is not already present somewhere in $options already (note spaces at
        !           638: # each end implied by leading space in second argument).
        !           639: func_append_uniq ()
        !           640: {
        !           641:     $debug_cmd
        !           642: 
        !           643:     eval _G_current_value='`$ECHO $'$1'`'
        !           644:     _G_delim=`expr "$2" : '\(.\)'`
        !           645: 
        !           646:     case $_G_delim$_G_current_value$_G_delim in
        !           647:       *"$2$_G_delim"*) ;;
        !           648:       *) func_append "$@" ;;
        !           649:     esac
        !           650: }
        !           651: 
        !           652: 
        !           653: # func_arith TERM...
        !           654: # ------------------
        !           655: # Set func_arith_result to the result of evaluating TERMs.
        !           656:   test -z "$_G_HAVE_ARITH_OP" \
        !           657:     && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
        !           658:     && _G_HAVE_ARITH_OP=yes
        !           659: 
        !           660: if test yes = "$_G_HAVE_ARITH_OP"; then
        !           661:   eval 'func_arith ()
        !           662:   {
        !           663:     $debug_cmd
        !           664: 
        !           665:     func_arith_result=$(( $* ))
        !           666:   }'
        !           667: else
        !           668:   func_arith ()
        !           669:   {
        !           670:     $debug_cmd
        !           671: 
        !           672:     func_arith_result=`expr "$@"`
        !           673:   }
        !           674: fi
        !           675: 
        !           676: 
        !           677: # func_basename FILE
        !           678: # ------------------
        !           679: # Set func_basename_result to FILE with everything up to and including
        !           680: # the last / stripped.
        !           681: if test yes = "$_G_HAVE_XSI_OPS"; then
        !           682:   # If this shell supports suffix pattern removal, then use it to avoid
        !           683:   # forking. Hide the definitions single quotes in case the shell chokes
        !           684:   # on unsupported syntax...
        !           685:   _b='func_basename_result=${1##*/}'
        !           686:   _d='case $1 in
        !           687:         */*) func_dirname_result=${1%/*}$2 ;;
        !           688:         *  ) func_dirname_result=$3        ;;
        !           689:       esac'
        !           690: 
        !           691: else
        !           692:   # ...otherwise fall back to using sed.
        !           693:   _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
        !           694:   _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
        !           695:       if test "X$func_dirname_result" = "X$1"; then
        !           696:         func_dirname_result=$3
        !           697:       else
        !           698:         func_append func_dirname_result "$2"
        !           699:       fi'
        !           700: fi
        !           701: 
        !           702: eval 'func_basename ()
        !           703: {
        !           704:     $debug_cmd
        !           705: 
        !           706:     '"$_b"'
        !           707: }'
1.6       moko      708: 
                    709: 
1.7     ! moko      710: # func_dirname FILE APPEND NONDIR_REPLACEMENT
        !           711: # -------------------------------------------
1.6       moko      712: # Compute the dirname of FILE.  If nonempty, add APPEND to the result,
                    713: # otherwise set result to NONDIR_REPLACEMENT.
1.7     ! moko      714: eval 'func_dirname ()
1.6       moko      715: {
1.7     ! moko      716:     $debug_cmd
1.5       paf       717: 
1.7     ! moko      718:     '"$_d"'
        !           719: }'
1.6       moko      720: 
                    721: 
1.7     ! moko      722: # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
        !           723: # --------------------------------------------------------
        !           724: # Perform func_basename and func_dirname in a single function
1.6       moko      725: # call:
                    726: #   dirname:  Compute the dirname of FILE.  If nonempty,
                    727: #             add APPEND to the result, otherwise set result
                    728: #             to NONDIR_REPLACEMENT.
                    729: #             value returned in "$func_dirname_result"
                    730: #   basename: Compute filename of FILE.
1.7     ! moko      731: #             value returned in "$func_basename_result"
        !           732: # For efficiency, we do not delegate to the functions above but instead
        !           733: # duplicate the functionality here.
        !           734: eval 'func_dirname_and_basename ()
        !           735: {
        !           736:     $debug_cmd
        !           737: 
        !           738:     '"$_b"'
        !           739:     '"$_d"'
        !           740: }'
        !           741: 
        !           742: 
        !           743: # func_echo ARG...
        !           744: # ----------------
        !           745: # Echo program name prefixed message.
        !           746: func_echo ()
        !           747: {
        !           748:     $debug_cmd
        !           749: 
        !           750:     _G_message=$*
        !           751: 
        !           752:     func_echo_IFS=$IFS
        !           753:     IFS=$nl
        !           754:     for _G_line in $_G_message; do
        !           755:       IFS=$func_echo_IFS
        !           756:       $ECHO "$progname: $_G_line"
        !           757:     done
        !           758:     IFS=$func_echo_IFS
        !           759: }
        !           760: 
        !           761: 
        !           762: # func_echo_all ARG...
        !           763: # --------------------
        !           764: # Invoke $ECHO with all args, space-separated.
        !           765: func_echo_all ()
        !           766: {
        !           767:     $ECHO "$*"
        !           768: }
        !           769: 
        !           770: 
        !           771: # func_echo_infix_1 INFIX ARG...
        !           772: # ------------------------------
        !           773: # Echo program name, followed by INFIX on the first line, with any
        !           774: # additional lines not showing INFIX.
        !           775: func_echo_infix_1 ()
        !           776: {
        !           777:     $debug_cmd
        !           778: 
        !           779:     $require_term_colors
        !           780: 
        !           781:     _G_infix=$1; shift
        !           782:     _G_indent=$_G_infix
        !           783:     _G_prefix="$progname: $_G_infix: "
        !           784:     _G_message=$*
        !           785: 
        !           786:     # Strip color escape sequences before counting printable length
        !           787:     for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
        !           788:     do
        !           789:       test -n "$_G_tc" && {
        !           790:         _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
        !           791:         _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
        !           792:       }
        !           793:     done
        !           794:     _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
        !           795: 
        !           796:     func_echo_infix_1_IFS=$IFS
        !           797:     IFS=$nl
        !           798:     for _G_line in $_G_message; do
        !           799:       IFS=$func_echo_infix_1_IFS
        !           800:       $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
        !           801:       _G_prefix=$_G_indent
        !           802:     done
        !           803:     IFS=$func_echo_infix_1_IFS
        !           804: }
        !           805: 
        !           806: 
        !           807: # func_error ARG...
        !           808: # -----------------
        !           809: # Echo program name prefixed message to standard error.
        !           810: func_error ()
        !           811: {
        !           812:     $debug_cmd
        !           813: 
        !           814:     $require_term_colors
        !           815: 
        !           816:     func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
        !           817: }
        !           818: 
        !           819: 
        !           820: # func_fatal_error ARG...
        !           821: # -----------------------
        !           822: # Echo program name prefixed message to standard error, and exit.
        !           823: func_fatal_error ()
        !           824: {
        !           825:     $debug_cmd
        !           826: 
        !           827:     func_error "$*"
        !           828:     exit $EXIT_FAILURE
        !           829: }
        !           830: 
        !           831: 
        !           832: # func_grep EXPRESSION FILENAME
        !           833: # -----------------------------
        !           834: # Check whether EXPRESSION matches any line of FILENAME, without output.
        !           835: func_grep ()
        !           836: {
        !           837:     $debug_cmd
        !           838: 
        !           839:     $GREP "$1" "$2" >/dev/null 2>&1
        !           840: }
        !           841: 
        !           842: 
        !           843: # func_len STRING
        !           844: # ---------------
        !           845: # Set func_len_result to the length of STRING. STRING may not
        !           846: # start with a hyphen.
        !           847:   test -z "$_G_HAVE_XSI_OPS" \
        !           848:     && (eval 'x=a/b/c;
        !           849:       test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
        !           850:     && _G_HAVE_XSI_OPS=yes
        !           851: 
        !           852: if test yes = "$_G_HAVE_XSI_OPS"; then
        !           853:   eval 'func_len ()
        !           854:   {
        !           855:     $debug_cmd
        !           856: 
        !           857:     func_len_result=${#1}
        !           858:   }'
        !           859: else
        !           860:   func_len ()
        !           861:   {
        !           862:     $debug_cmd
        !           863: 
        !           864:     func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
        !           865:   }
        !           866: fi
        !           867: 
        !           868: 
        !           869: # func_mkdir_p DIRECTORY-PATH
        !           870: # ---------------------------
        !           871: # Make sure the entire path to DIRECTORY-PATH is available.
        !           872: func_mkdir_p ()
        !           873: {
        !           874:     $debug_cmd
        !           875: 
        !           876:     _G_directory_path=$1
        !           877:     _G_dir_list=
        !           878: 
        !           879:     if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
        !           880: 
        !           881:       # Protect directory names starting with '-'
        !           882:       case $_G_directory_path in
        !           883:         -*) _G_directory_path=./$_G_directory_path ;;
        !           884:       esac
        !           885: 
        !           886:       # While some portion of DIR does not yet exist...
        !           887:       while test ! -d "$_G_directory_path"; do
        !           888:         # ...make a list in topmost first order.  Use a colon delimited
        !           889:        # list in case some portion of path contains whitespace.
        !           890:         _G_dir_list=$_G_directory_path:$_G_dir_list
        !           891: 
        !           892:         # If the last portion added has no slash in it, the list is done
        !           893:         case $_G_directory_path in */*) ;; *) break ;; esac
        !           894: 
        !           895:         # ...otherwise throw away the child directory and loop
        !           896:         _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
        !           897:       done
        !           898:       _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
        !           899: 
        !           900:       func_mkdir_p_IFS=$IFS; IFS=:
        !           901:       for _G_dir in $_G_dir_list; do
        !           902:        IFS=$func_mkdir_p_IFS
        !           903:         # mkdir can fail with a 'File exist' error if two processes
        !           904:         # try to create one of the directories concurrently.  Don't
        !           905:         # stop in that case!
        !           906:         $MKDIR "$_G_dir" 2>/dev/null || :
        !           907:       done
        !           908:       IFS=$func_mkdir_p_IFS
        !           909: 
        !           910:       # Bail out if we (or some other process) failed to create a directory.
        !           911:       test -d "$_G_directory_path" || \
        !           912:         func_fatal_error "Failed to create '$1'"
1.6       moko      913:     fi
1.7     ! moko      914: }
1.5       paf       915: 
                    916: 
1.7     ! moko      917: # func_mktempdir [BASENAME]
        !           918: # -------------------------
        !           919: # Make a temporary directory that won't clash with other running
        !           920: # libtool processes, and avoids race conditions if possible.  If
        !           921: # given, BASENAME is the basename for that directory.
        !           922: func_mktempdir ()
1.6       moko      923: {
1.7     ! moko      924:     $debug_cmd
        !           925: 
        !           926:     _G_template=${TMPDIR-/tmp}/${1-$progname}
        !           927: 
        !           928:     if test : = "$opt_dry_run"; then
        !           929:       # Return a directory name, but don't create it in dry-run mode
        !           930:       _G_tmpdir=$_G_template-$$
        !           931:     else
        !           932: 
        !           933:       # If mktemp works, use that first and foremost
        !           934:       _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
        !           935: 
        !           936:       if test ! -d "$_G_tmpdir"; then
        !           937:         # Failing that, at least try and use $RANDOM to avoid a race
        !           938:         _G_tmpdir=$_G_template-${RANDOM-0}$$
        !           939: 
        !           940:         func_mktempdir_umask=`umask`
        !           941:         umask 0077
        !           942:         $MKDIR "$_G_tmpdir"
        !           943:         umask $func_mktempdir_umask
        !           944:       fi
        !           945: 
        !           946:       # If we're not in dry-run mode, bomb out on failure
        !           947:       test -d "$_G_tmpdir" || \
        !           948:         func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
        !           949:     fi
1.5       paf       950: 
1.7     ! moko      951:     $ECHO "$_G_tmpdir"
        !           952: }
1.5       paf       953: 
1.6       moko      954: 
                    955: # func_normal_abspath PATH
1.7     ! moko      956: # ------------------------
1.6       moko      957: # Remove doubled-up and trailing slashes, "." path components,
                    958: # and cancel out any ".." path components in PATH after making
                    959: # it an absolute path.
                    960: func_normal_abspath ()
                    961: {
1.7     ! moko      962:     $debug_cmd
        !           963: 
        !           964:     # These SED scripts presuppose an absolute path with a trailing slash.
        !           965:     _G_pathcar='s|^/\([^/]*\).*$|\1|'
        !           966:     _G_pathcdr='s|^/[^/]*||'
        !           967:     _G_removedotparts=':dotsl
        !           968:                s|/\./|/|g
        !           969:                t dotsl
        !           970:                s|/\.$|/|'
        !           971:     _G_collapseslashes='s|/\{1,\}|/|g'
        !           972:     _G_finalslash='s|/*$|/|'
        !           973: 
        !           974:     # Start from root dir and reassemble the path.
        !           975:     func_normal_abspath_result=
        !           976:     func_normal_abspath_tpath=$1
        !           977:     func_normal_abspath_altnamespace=
        !           978:     case $func_normal_abspath_tpath in
1.6       moko      979:       "")
1.7     ! moko      980:         # Empty path, that just means $cwd.
        !           981:         func_stripname '' '/' "`pwd`"
        !           982:         func_normal_abspath_result=$func_stripname_result
        !           983:         return
        !           984:         ;;
        !           985:       # The next three entries are used to spot a run of precisely
        !           986:       # two leading slashes without using negated character classes;
        !           987:       # we take advantage of case's first-match behaviour.
        !           988:       ///*)
        !           989:         # Unusual form of absolute path, do nothing.
        !           990:         ;;
        !           991:       //*)
        !           992:         # Not necessarily an ordinary path; POSIX reserves leading '//'
        !           993:         # and for example Cygwin uses it to access remote file shares
        !           994:         # over CIFS/SMB, so we conserve a leading double slash if found.
        !           995:         func_normal_abspath_altnamespace=/
        !           996:         ;;
        !           997:       /*)
        !           998:         # Absolute path, do nothing.
        !           999:         ;;
1.6       moko     1000:       *)
1.7     ! moko     1001:         # Relative path, prepend $cwd.
        !          1002:         func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
        !          1003:         ;;
1.6       moko     1004:     esac
1.7     ! moko     1005: 
        !          1006:     # Cancel out all the simple stuff to save iterations.  We also want
        !          1007:     # the path to end with a slash for ease of parsing, so make sure
        !          1008:     # there is one (and only one) here.
        !          1009:     func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
        !          1010:           -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
        !          1011:     while :; do
        !          1012:       # Processed it all yet?
        !          1013:       if test / = "$func_normal_abspath_tpath"; then
        !          1014:         # If we ascended to the root using ".." the result may be empty now.
        !          1015:         if test -z "$func_normal_abspath_result"; then
        !          1016:           func_normal_abspath_result=/
        !          1017:         fi
        !          1018:         break
        !          1019:       fi
        !          1020:       func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
        !          1021:           -e "$_G_pathcar"`
        !          1022:       func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
        !          1023:           -e "$_G_pathcdr"`
        !          1024:       # Figure out what to do with it
        !          1025:       case $func_normal_abspath_tcomponent in
        !          1026:         "")
        !          1027:           # Trailing empty path component, ignore it.
        !          1028:           ;;
        !          1029:         ..)
        !          1030:           # Parent dir; strip last assembled component from result.
        !          1031:           func_dirname "$func_normal_abspath_result"
        !          1032:           func_normal_abspath_result=$func_dirname_result
        !          1033:           ;;
        !          1034:         *)
        !          1035:           # Actual path component, append it.
        !          1036:           func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
        !          1037:           ;;
        !          1038:       esac
        !          1039:     done
        !          1040:     # Restore leading double-slash if one was found on entry.
        !          1041:     func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
        !          1042: }
        !          1043: 
        !          1044: 
        !          1045: # func_notquiet ARG...
        !          1046: # --------------------
        !          1047: # Echo program name prefixed message only when not in quiet mode.
        !          1048: func_notquiet ()
        !          1049: {
        !          1050:     $debug_cmd
        !          1051: 
        !          1052:     $opt_quiet || func_echo ${1+"$@"}
        !          1053: 
        !          1054:     # A bug in bash halts the script if the last line of a function
        !          1055:     # fails when set -e is in force, so we need another command to
        !          1056:     # work around that:
        !          1057:     :
1.6       moko     1058: }
1.5       paf      1059: 
1.7     ! moko     1060: 
1.6       moko     1061: # func_relative_path SRCDIR DSTDIR
1.7     ! moko     1062: # --------------------------------
        !          1063: # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
1.6       moko     1064: func_relative_path ()
                   1065: {
1.7     ! moko     1066:     $debug_cmd
        !          1067: 
        !          1068:     func_relative_path_result=
        !          1069:     func_normal_abspath "$1"
        !          1070:     func_relative_path_tlibdir=$func_normal_abspath_result
        !          1071:     func_normal_abspath "$2"
        !          1072:     func_relative_path_tbindir=$func_normal_abspath_result
        !          1073: 
        !          1074:     # Ascend the tree starting from libdir
        !          1075:     while :; do
        !          1076:       # check if we have found a prefix of bindir
        !          1077:       case $func_relative_path_tbindir in
        !          1078:         $func_relative_path_tlibdir)
        !          1079:           # found an exact match
        !          1080:           func_relative_path_tcancelled=
        !          1081:           break
        !          1082:           ;;
        !          1083:         $func_relative_path_tlibdir*)
        !          1084:           # found a matching prefix
        !          1085:           func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
        !          1086:           func_relative_path_tcancelled=$func_stripname_result
        !          1087:           if test -z "$func_relative_path_result"; then
        !          1088:             func_relative_path_result=.
        !          1089:           fi
        !          1090:           break
        !          1091:           ;;
        !          1092:         *)
        !          1093:           func_dirname $func_relative_path_tlibdir
        !          1094:           func_relative_path_tlibdir=$func_dirname_result
        !          1095:           if test -z "$func_relative_path_tlibdir"; then
        !          1096:             # Have to descend all the way to the root!
        !          1097:             func_relative_path_result=../$func_relative_path_result
        !          1098:             func_relative_path_tcancelled=$func_relative_path_tbindir
        !          1099:             break
        !          1100:           fi
        !          1101:           func_relative_path_result=../$func_relative_path_result
        !          1102:           ;;
        !          1103:       esac
        !          1104:     done
        !          1105: 
        !          1106:     # Now calculate path; take care to avoid doubling-up slashes.
        !          1107:     func_stripname '' '/' "$func_relative_path_result"
        !          1108:     func_relative_path_result=$func_stripname_result
        !          1109:     func_stripname '/' '/' "$func_relative_path_tcancelled"
        !          1110:     if test -n "$func_stripname_result"; then
        !          1111:       func_append func_relative_path_result "/$func_stripname_result"
        !          1112:     fi
        !          1113: 
        !          1114:     # Normalisation. If bindir is libdir, return '.' else relative path.
        !          1115:     if test -n "$func_relative_path_result"; then
        !          1116:       func_stripname './' '' "$func_relative_path_result"
        !          1117:       func_relative_path_result=$func_stripname_result
        !          1118:     fi
        !          1119: 
        !          1120:     test -n "$func_relative_path_result" || func_relative_path_result=.
        !          1121: 
        !          1122:     :
        !          1123: }
        !          1124: 
        !          1125: 
        !          1126: # func_quote_portable EVAL ARG
        !          1127: # ----------------------------
        !          1128: # Internal function to portably implement func_quote_arg.  Note that we still
        !          1129: # keep attention to performance here so we as much as possible try to avoid
        !          1130: # calling sed binary (so far O(N) complexity as long as func_append is O(1)).
        !          1131: func_quote_portable ()
        !          1132: {
        !          1133:     $debug_cmd
        !          1134: 
        !          1135:     $require_check_ifs_backslash
        !          1136: 
        !          1137:     func_quote_portable_result=$2
        !          1138: 
        !          1139:     # one-time-loop (easy break)
        !          1140:     while true
        !          1141:     do
        !          1142:       if $1; then
        !          1143:         func_quote_portable_result=`$ECHO "$2" | $SED \
        !          1144:           -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
1.6       moko     1145:         break
1.7     ! moko     1146:       fi
        !          1147: 
        !          1148:       # Quote for eval.
        !          1149:       case $func_quote_portable_result in
        !          1150:         *[\\\`\"\$]*)
        !          1151:           # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string
        !          1152:           # contains the shell wildcard characters.
        !          1153:           case $check_ifs_backshlash_broken$func_quote_portable_result in
        !          1154:             :*|*[\[\*\?]*)
        !          1155:               func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
        !          1156:                   | $SED "$sed_quote_subst"`
        !          1157:               break
        !          1158:               ;;
        !          1159:           esac
        !          1160: 
        !          1161:           func_quote_portable_old_IFS=$IFS
        !          1162:           for _G_char in '\' '`' '"' '$'
        !          1163:           do
        !          1164:             # STATE($1) PREV($2) SEPARATOR($3)
        !          1165:             set start "" ""
        !          1166:             func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
        !          1167:             IFS=$_G_char
        !          1168:             for _G_part in $func_quote_portable_result
        !          1169:             do
        !          1170:               case $1 in
        !          1171:               quote)
        !          1172:                 func_append func_quote_portable_result "$3$2"
        !          1173:                 set quote "$_G_part" "\\$_G_char"
        !          1174:                 ;;
        !          1175:               start)
        !          1176:                 set first "" ""
        !          1177:                 func_quote_portable_result=
        !          1178:                 ;;
        !          1179:               first)
        !          1180:                 set quote "$_G_part" ""
        !          1181:                 ;;
        !          1182:               esac
        !          1183:             done
        !          1184:           done
        !          1185:           IFS=$func_quote_portable_old_IFS
        !          1186:           ;;
        !          1187:         *) ;;
        !          1188:       esac
        !          1189:       break
        !          1190:     done
        !          1191: 
        !          1192:     func_quote_portable_unquoted_result=$func_quote_portable_result
        !          1193:     case $func_quote_portable_result in
        !          1194:       # double-quote args containing shell metacharacters to delay
        !          1195:       # word splitting, command substitution and variable expansion
        !          1196:       # for a subsequent eval.
        !          1197:       # many bourne shells cannot handle close brackets correctly
        !          1198:       # in scan sets, so we specify it separately.
        !          1199:       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
        !          1200:         func_quote_portable_result=\"$func_quote_portable_result\"
        !          1201:         ;;
        !          1202:     esac
        !          1203: }
        !          1204: 
        !          1205: 
        !          1206: # func_quotefast_eval ARG
        !          1207: # -----------------------
        !          1208: # Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
        !          1209: # but optimized for speed.  Result is stored in $func_quotefast_eval.
        !          1210: if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
        !          1211:   printf -v _GL_test_printf_tilde %q '~'
        !          1212:   if test '\~' = "$_GL_test_printf_tilde"; then
        !          1213:     func_quotefast_eval ()
        !          1214:     {
        !          1215:       printf -v func_quotefast_eval_result %q "$1"
        !          1216:     }
        !          1217:   else
        !          1218:     # Broken older Bash implementations.  Make those faster too if possible.
        !          1219:     func_quotefast_eval ()
        !          1220:     {
        !          1221:       case $1 in
        !          1222:         '~'*)
        !          1223:           func_quote_portable false "$1"
        !          1224:           func_quotefast_eval_result=$func_quote_portable_result
        !          1225:           ;;
        !          1226:         *)
        !          1227:           printf -v func_quotefast_eval_result %q "$1"
        !          1228:           ;;
        !          1229:       esac
        !          1230:     }
        !          1231:   fi
        !          1232: else
        !          1233:   func_quotefast_eval ()
        !          1234:   {
        !          1235:     func_quote_portable false "$1"
        !          1236:     func_quotefast_eval_result=$func_quote_portable_result
        !          1237:   }
        !          1238: fi
        !          1239: 
        !          1240: 
        !          1241: # func_quote_arg MODEs ARG
        !          1242: # ------------------------
        !          1243: # Quote one ARG to be evaled later.  MODEs argument may contain zero or more
        !          1244: # specifiers listed below separated by ',' character.  This function returns two
        !          1245: # values:
        !          1246: #   i) func_quote_arg_result
        !          1247: #      double-quoted (when needed), suitable for a subsequent eval
        !          1248: #  ii) func_quote_arg_unquoted_result
        !          1249: #      has all characters that are still active within double
        !          1250: #      quotes backslashified.  Available only if 'unquoted' is specified.
        !          1251: #
        !          1252: # Available modes:
        !          1253: # ----------------
        !          1254: # 'eval' (default)
        !          1255: #       - escape shell special characters
        !          1256: # 'expand'
        !          1257: #       - the same as 'eval';  but do not quote variable references
        !          1258: # 'pretty'
        !          1259: #       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
        !          1260: #         be used later in func_quote to get output like: 'echo "a b"' instead
        !          1261: #         of 'echo a\ b'.  This is slower than default on some shells.
        !          1262: # 'unquoted'
        !          1263: #       - produce also $func_quote_arg_unquoted_result which does not contain
        !          1264: #         wrapping double-quotes.
        !          1265: #
        !          1266: # Examples for 'func_quote_arg pretty,unquoted string':
        !          1267: #
        !          1268: #   string      | *_result              | *_unquoted_result
        !          1269: #   ------------+-----------------------+-------------------
        !          1270: #   "           | \"                    | \"
        !          1271: #   a b         | "a b"                 | a b
        !          1272: #   "a b"       | "\"a b\""             | \"a b\"
        !          1273: #   *           | "*"                   | *
        !          1274: #   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
        !          1275: #
        !          1276: # Examples for 'func_quote_arg pretty,unquoted,expand string':
        !          1277: #
        !          1278: #   string        |   *_result          |  *_unquoted_result
        !          1279: #   --------------+---------------------+--------------------
        !          1280: #   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
        !          1281: func_quote_arg ()
        !          1282: {
        !          1283:     _G_quote_expand=false
        !          1284:     case ,$1, in
        !          1285:       *,expand,*)
        !          1286:         _G_quote_expand=:
1.6       moko     1287:         ;;
1.7     ! moko     1288:     esac
        !          1289: 
        !          1290:     case ,$1, in
        !          1291:       *,pretty,*|*,expand,*|*,unquoted,*)
        !          1292:         func_quote_portable $_G_quote_expand "$2"
        !          1293:         func_quote_arg_result=$func_quote_portable_result
        !          1294:         func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
1.6       moko     1295:         ;;
                   1296:       *)
1.7     ! moko     1297:         # Faster quote-for-eval for some shells.
        !          1298:         func_quotefast_eval "$2"
        !          1299:         func_quote_arg_result=$func_quotefast_eval_result
1.6       moko     1300:         ;;
                   1301:     esac
1.7     ! moko     1302: }
1.5       paf      1303: 
                   1304: 
1.7     ! moko     1305: # func_quote MODEs ARGs...
        !          1306: # ------------------------
        !          1307: # Quote all ARGs to be evaled later and join them into single command.  See
        !          1308: # func_quote_arg's description for more info.
        !          1309: func_quote ()
        !          1310: {
        !          1311:     $debug_cmd
        !          1312:     _G_func_quote_mode=$1 ; shift
        !          1313:     func_quote_result=
        !          1314:     while test 0 -lt $#; do
        !          1315:       func_quote_arg "$_G_func_quote_mode" "$1"
        !          1316:       if test -n "$func_quote_result"; then
        !          1317:         func_append func_quote_result " $func_quote_arg_result"
        !          1318:       else
        !          1319:         func_append func_quote_result "$func_quote_arg_result"
        !          1320:       fi
        !          1321:       shift
        !          1322:     done
1.6       moko     1323: }
1.5       paf      1324: 
1.6       moko     1325: 
1.7     ! moko     1326: # func_stripname PREFIX SUFFIX NAME
        !          1327: # ---------------------------------
        !          1328: # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
        !          1329: # PREFIX and SUFFIX must not contain globbing or regex special
        !          1330: # characters, hashes, percent signs, but SUFFIX may contain a leading
        !          1331: # dot (in which case that matches only a dot).
        !          1332: if test yes = "$_G_HAVE_XSI_OPS"; then
        !          1333:   eval 'func_stripname ()
        !          1334:   {
        !          1335:     $debug_cmd
        !          1336: 
        !          1337:     # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
        !          1338:     # positional parameters, so assign one to ordinary variable first.
        !          1339:     func_stripname_result=$3
        !          1340:     func_stripname_result=${func_stripname_result#"$1"}
        !          1341:     func_stripname_result=${func_stripname_result%"$2"}
        !          1342:   }'
        !          1343: else
        !          1344:   func_stripname ()
        !          1345:   {
        !          1346:     $debug_cmd
        !          1347: 
        !          1348:     case $2 in
        !          1349:       .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
        !          1350:       *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
        !          1351:     esac
        !          1352:   }
        !          1353: fi
        !          1354: 
        !          1355: 
        !          1356: # func_show_eval CMD [FAIL_EXP]
        !          1357: # -----------------------------
        !          1358: # Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
        !          1359: # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
        !          1360: # is given, then evaluate it.
        !          1361: func_show_eval ()
        !          1362: {
        !          1363:     $debug_cmd
        !          1364: 
        !          1365:     _G_cmd=$1
        !          1366:     _G_fail_exp=${2-':'}
        !          1367: 
        !          1368:     func_quote_arg pretty,expand "$_G_cmd"
        !          1369:     eval "func_notquiet $func_quote_arg_result"
        !          1370: 
        !          1371:     $opt_dry_run || {
        !          1372:       eval "$_G_cmd"
        !          1373:       _G_status=$?
        !          1374:       if test 0 -ne "$_G_status"; then
        !          1375:        eval "(exit $_G_status); $_G_fail_exp"
        !          1376:       fi
        !          1377:     }
        !          1378: }
1.5       paf      1379: 
                   1380: 
1.7     ! moko     1381: # func_show_eval_locale CMD [FAIL_EXP]
        !          1382: # ------------------------------------
        !          1383: # Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
        !          1384: # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
        !          1385: # is given, then evaluate it.  Use the saved locale for evaluation.
        !          1386: func_show_eval_locale ()
        !          1387: {
        !          1388:     $debug_cmd
1.5       paf      1389: 
1.7     ! moko     1390:     _G_cmd=$1
        !          1391:     _G_fail_exp=${2-':'}
1.6       moko     1392: 
1.7     ! moko     1393:     $opt_quiet || {
        !          1394:       func_quote_arg expand,pretty "$_G_cmd"
        !          1395:       eval "func_echo $func_quote_arg_result"
        !          1396:     }
1.6       moko     1397: 
1.7     ! moko     1398:     $opt_dry_run || {
        !          1399:       eval "$_G_user_locale
        !          1400:            $_G_cmd"
        !          1401:       _G_status=$?
        !          1402:       eval "$_G_safe_locale"
        !          1403:       if test 0 -ne "$_G_status"; then
        !          1404:        eval "(exit $_G_status); $_G_fail_exp"
        !          1405:       fi
        !          1406:     }
        !          1407: }
1.6       moko     1408: 
                   1409: 
1.7     ! moko     1410: # func_tr_sh
        !          1411: # ----------
        !          1412: # Turn $1 into a string suitable for a shell variable name.
        !          1413: # Result is stored in $func_tr_sh_result.  All characters
        !          1414: # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
        !          1415: # if $1 begins with a digit, a '_' is prepended as well.
        !          1416: func_tr_sh ()
1.6       moko     1417: {
1.7     ! moko     1418:     $debug_cmd
        !          1419: 
        !          1420:     case $1 in
        !          1421:     [0-9]* | *[!a-zA-Z0-9_]*)
        !          1422:       func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
        !          1423:       ;;
        !          1424:     * )
        !          1425:       func_tr_sh_result=$1
        !          1426:       ;;
        !          1427:     esac
1.6       moko     1428: }
1.5       paf      1429: 
1.7     ! moko     1430: 
        !          1431: # func_verbose ARG...
        !          1432: # -------------------
1.6       moko     1433: # Echo program name prefixed message in verbose mode only.
                   1434: func_verbose ()
                   1435: {
1.7     ! moko     1436:     $debug_cmd
        !          1437: 
        !          1438:     $opt_verbose && func_echo "$*"
1.6       moko     1439: 
                   1440:     :
                   1441: }
1.5       paf      1442: 
1.7     ! moko     1443: 
        !          1444: # func_warn_and_continue ARG...
        !          1445: # -----------------------------
        !          1446: # Echo program name prefixed warning message to standard error.
        !          1447: func_warn_and_continue ()
1.6       moko     1448: {
1.7     ! moko     1449:     $debug_cmd
        !          1450: 
        !          1451:     $require_term_colors
        !          1452: 
        !          1453:     func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
1.6       moko     1454: }
1.5       paf      1455: 
                   1456: 
1.7     ! moko     1457: # func_warning CATEGORY ARG...
        !          1458: # ----------------------------
        !          1459: # Echo program name prefixed warning message to standard error. Warning
        !          1460: # messages can be filtered according to CATEGORY, where this function
        !          1461: # elides messages where CATEGORY is not listed in the global variable
        !          1462: # 'opt_warning_types'.
1.6       moko     1463: func_warning ()
                   1464: {
1.7     ! moko     1465:     $debug_cmd
        !          1466: 
        !          1467:     # CATEGORY must be in the warning_categories list!
        !          1468:     case " $warning_categories " in
        !          1469:       *" $1 "*) ;;
        !          1470:       *) func_internal_error "invalid warning category '$1'" ;;
        !          1471:     esac
        !          1472: 
        !          1473:     _G_category=$1
        !          1474:     shift
1.5       paf      1475: 
1.7     ! moko     1476:     case " $opt_warning_types " in
        !          1477:       *" $_G_category "*) $warning_func ${1+"$@"} ;;
        !          1478:     esac
1.6       moko     1479: }
1.5       paf      1480: 
1.7     ! moko     1481: 
        !          1482: # func_sort_ver VER1 VER2
        !          1483: # -----------------------
        !          1484: # 'sort -V' is not generally available.
        !          1485: # Note this deviates from the version comparison in automake
        !          1486: # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
        !          1487: # but this should suffice as we won't be specifying old
        !          1488: # version formats or redundant trailing .0 in bootstrap.conf.
        !          1489: # If we did want full compatibility then we should probably
        !          1490: # use m4_version_compare from autoconf.
        !          1491: func_sort_ver ()
        !          1492: {
        !          1493:     $debug_cmd
        !          1494: 
        !          1495:     printf '%s\n%s\n' "$1" "$2" \
        !          1496:       | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
        !          1497: }
        !          1498: 
        !          1499: # func_lt_ver PREV CURR
        !          1500: # ---------------------
        !          1501: # Return true if PREV and CURR are in the correct order according to
        !          1502: # func_sort_ver, otherwise false.  Use it like this:
        !          1503: #
        !          1504: #  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
        !          1505: func_lt_ver ()
1.6       moko     1506: {
1.7     ! moko     1507:     $debug_cmd
        !          1508: 
        !          1509:     test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
1.6       moko     1510: }
1.5       paf      1511: 
                   1512: 
1.7     ! moko     1513: # Local variables:
        !          1514: # mode: shell-script
        !          1515: # sh-indentation: 2
        !          1516: # eval: (add-hook 'before-save-hook 'time-stamp)
        !          1517: # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
        !          1518: # time-stamp-time-zone: "UTC"
        !          1519: # End:
        !          1520: #! /bin/sh
        !          1521: 
        !          1522: # A portable, pluggable option parser for Bourne shell.
        !          1523: # Written by Gary V. Vaughan, 2010
        !          1524: 
        !          1525: # This is free software.  There is NO warranty; not even for
        !          1526: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        !          1527: #
        !          1528: # Copyright (C) 2010-2019, 2021, 2023-2024 Bootstrap Authors
        !          1529: #
        !          1530: # This file is dual licensed under the terms of the MIT license
        !          1531: # <https://opensource.org/licenses/MIT>, and GPL version 2 or later
        !          1532: # <https://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
        !          1533: # these licenses when using or redistributing this software or any of
        !          1534: # the files within it.  See the URLs above, or the file `LICENSE`
        !          1535: # included in the Bootstrap distribution for the full license texts.
        !          1536: 
        !          1537: # Please report bugs or propose patches to:
        !          1538: # <https://github.com/gnulib-modules/bootstrap/issues>
        !          1539: 
        !          1540: # Set a version string for this script.
        !          1541: scriptversion=2019-02-19.15; # UTC
        !          1542: 
        !          1543: 
        !          1544: ## ------ ##
        !          1545: ## Usage. ##
        !          1546: ## ------ ##
        !          1547: 
        !          1548: # This file is a library for parsing options in your shell scripts along
        !          1549: # with assorted other useful supporting features that you can make use
        !          1550: # of too.
        !          1551: #
        !          1552: # For the simplest scripts you might need only:
        !          1553: #
        !          1554: #   #!/bin/sh
        !          1555: #   . relative/path/to/funclib.sh
        !          1556: #   . relative/path/to/options-parser
        !          1557: #   scriptversion=1.0
        !          1558: #   func_options ${1+"$@"}
        !          1559: #   eval set dummy "$func_options_result"; shift
        !          1560: #   ...rest of your script...
        !          1561: #
        !          1562: # In order for the '--version' option to work, you will need to have a
        !          1563: # suitably formatted comment like the one at the top of this file
        !          1564: # starting with '# Written by ' and ending with '# Copyright'.
        !          1565: #
        !          1566: # For '-h' and '--help' to work, you will also need a one line
        !          1567: # description of your script's purpose in a comment directly above the
        !          1568: # '# Written by ' line, like the one at the top of this file.
        !          1569: #
        !          1570: # The default options also support '--debug', which will turn on shell
        !          1571: # execution tracing (see the comment above debug_cmd below for another
        !          1572: # use), and '--verbose' and the func_verbose function to allow your script
        !          1573: # to display verbose messages only when your user has specified
        !          1574: # '--verbose'.
        !          1575: #
        !          1576: # After sourcing this file, you can plug in processing for additional
        !          1577: # options by amending the variables from the 'Configuration' section
        !          1578: # below, and following the instructions in the 'Option parsing'
        !          1579: # section further down.
        !          1580: 
        !          1581: ## -------------- ##
        !          1582: ## Configuration. ##
        !          1583: ## -------------- ##
        !          1584: 
        !          1585: # You should override these variables in your script after sourcing this
        !          1586: # file so that they reflect the customisations you have added to the
        !          1587: # option parser.
        !          1588: 
        !          1589: # The usage line for option parsing errors and the start of '-h' and
        !          1590: # '--help' output messages. You can embed shell variables for delayed
        !          1591: # expansion at the time the message is displayed, but you will need to
        !          1592: # quote other shell meta-characters carefully to prevent them being
        !          1593: # expanded when the contents are evaled.
        !          1594: usage='$progpath [OPTION]...'
        !          1595: 
        !          1596: # Short help message in response to '-h' and '--help'.  Add to this or
        !          1597: # override it after sourcing this library to reflect the full set of
        !          1598: # options your script accepts.
        !          1599: usage_message="\
        !          1600:        --debug        enable verbose shell tracing
        !          1601:    -W, --warnings=CATEGORY
        !          1602:                       report the warnings falling in CATEGORY [all]
        !          1603:    -v, --verbose      verbosely report processing
        !          1604:        --version      print version information and exit
        !          1605:    -h, --help         print short or long help message and exit
        !          1606: "
        !          1607: 
        !          1608: # Additional text appended to 'usage_message' in response to '--help'.
        !          1609: long_help_message="
        !          1610: Warning categories include:
        !          1611:        'all'          show all warnings
        !          1612:        'none'         turn off all the warnings
        !          1613:        'error'        warnings are treated as fatal errors"
        !          1614: 
        !          1615: # Help message printed before fatal option parsing errors.
        !          1616: fatal_help="Try '\$progname --help' for more information."
        !          1617: 
        !          1618: 
        !          1619: 
        !          1620: ## ------------------------- ##
        !          1621: ## Hook function management. ##
        !          1622: ## ------------------------- ##
        !          1623: 
        !          1624: # This section contains functions for adding, removing, and running hooks
        !          1625: # in the main code.  A hook is just a list of function names that can be
        !          1626: # run in order later on.
1.5       paf      1627: 
1.7     ! moko     1628: # func_hookable FUNC_NAME
        !          1629: # -----------------------
        !          1630: # Declare that FUNC_NAME will run hooks added with
        !          1631: # 'func_add_hook FUNC_NAME ...'.
        !          1632: func_hookable ()
1.6       moko     1633: {
1.7     ! moko     1634:     $debug_cmd
        !          1635: 
        !          1636:     func_append hookable_fns " $1"
1.6       moko     1637: }
1.5       paf      1638: 
                   1639: 
1.7     ! moko     1640: # func_add_hook FUNC_NAME HOOK_FUNC
        !          1641: # ---------------------------------
        !          1642: # Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
        !          1643: # first have been declared "hookable" by a call to 'func_hookable'.
        !          1644: func_add_hook ()
1.6       moko     1645: {
1.7     ! moko     1646:     $debug_cmd
        !          1647: 
        !          1648:     case " $hookable_fns " in
        !          1649:       *" $1 "*) ;;
        !          1650:       *) func_fatal_error "'$1' does not accept hook functions." ;;
        !          1651:     esac
1.6       moko     1652: 
1.7     ! moko     1653:     eval func_append ${1}_hooks '" $2"'
        !          1654: }
1.6       moko     1655: 
1.5       paf      1656: 
1.7     ! moko     1657: # func_remove_hook FUNC_NAME HOOK_FUNC
        !          1658: # ------------------------------------
        !          1659: # Remove HOOK_FUNC from the list of hook functions to be called by
        !          1660: # FUNC_NAME.
        !          1661: func_remove_hook ()
        !          1662: {
        !          1663:     $debug_cmd
1.5       paf      1664: 
1.7     ! moko     1665:     eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
        !          1666: }
1.5       paf      1667: 
                   1668: 
1.7     ! moko     1669: # func_propagate_result FUNC_NAME_A FUNC_NAME_B
        !          1670: # ---------------------------------------------
        !          1671: # If the *_result variable of FUNC_NAME_A _is set_, assign its value to
        !          1672: # *_result variable of FUNC_NAME_B.
        !          1673: func_propagate_result ()
        !          1674: {
        !          1675:     $debug_cmd
1.5       paf      1676: 
1.7     ! moko     1677:     func_propagate_result_result=:
        !          1678:     if eval "test \"\${${1}_result+set}\" = set"
        !          1679:     then
        !          1680:       eval "${2}_result=\$${1}_result"
        !          1681:     else
        !          1682:       func_propagate_result_result=false
1.6       moko     1683:     fi
                   1684: }
1.5       paf      1685: 
                   1686: 
1.7     ! moko     1687: # func_run_hooks FUNC_NAME [ARG]...
        !          1688: # ---------------------------------
        !          1689: # Run all hook functions registered to FUNC_NAME.
        !          1690: # It's assumed that the list of hook functions contains nothing more
        !          1691: # than a whitespace-delimited list of legal shell function names, and
        !          1692: # no effort is wasted trying to catch shell meta-characters or preserve
        !          1693: # whitespace.
        !          1694: func_run_hooks ()
1.6       moko     1695: {
1.7     ! moko     1696:     $debug_cmd
1.6       moko     1697: 
1.7     ! moko     1698:     _G_rc_run_hooks=false
1.5       paf      1699: 
1.7     ! moko     1700:     case " $hookable_fns " in
        !          1701:       *" $1 "*) ;;
        !          1702:       *) func_fatal_error "'$1' does not support hook functions." ;;
        !          1703:     esac
1.5       paf      1704: 
1.7     ! moko     1705:     eval _G_hook_fns=\$$1_hooks; shift
1.6       moko     1706: 
1.7     ! moko     1707:     for _G_hook in $_G_hook_fns; do
        !          1708:       func_unset "${_G_hook}_result"
        !          1709:       eval $_G_hook '${1+"$@"}'
        !          1710:       func_propagate_result $_G_hook func_run_hooks
        !          1711:       if $func_propagate_result_result; then
        !          1712:         eval set dummy "$func_run_hooks_result"; shift
1.6       moko     1713:       fi
1.7     ! moko     1714:     done
        !          1715: }
        !          1716: 
1.6       moko     1717: 
1.5       paf      1718: 
1.7     ! moko     1719: ## --------------- ##
        !          1720: ## Option parsing. ##
        !          1721: ## --------------- ##
        !          1722: 
        !          1723: # In order to add your own option parsing hooks, you must accept the
        !          1724: # full positional parameter list from your hook function.  You may remove
        !          1725: # or edit any options that you action, and then pass back the remaining
        !          1726: # unprocessed options in '<hooked_function_name>_result', escaped
        !          1727: # suitably for 'eval'.
        !          1728: #
        !          1729: # The '<hooked_function_name>_result' variable is automatically unset
        !          1730: # before your hook gets called; for best performance, only set the
        !          1731: # *_result variable when necessary (i.e. don't call the 'func_quote'
        !          1732: # function unnecessarily because it can be an expensive operation on some
        !          1733: # machines).
        !          1734: #
        !          1735: # Like this:
        !          1736: #
        !          1737: #    my_options_prep ()
        !          1738: #    {
        !          1739: #        $debug_cmd
        !          1740: #
        !          1741: #        # Extend the existing usage message.
        !          1742: #        usage_message=$usage_message'
        !          1743: #      -s, --silent       don'\''t print informational messages
        !          1744: #    '
        !          1745: #        # No change in '$@' (ignored completely by this hook).  Leave
        !          1746: #        # my_options_prep_result variable intact.
        !          1747: #    }
        !          1748: #    func_add_hook func_options_prep my_options_prep
        !          1749: #
        !          1750: #
        !          1751: #    my_silent_option ()
        !          1752: #    {
        !          1753: #        $debug_cmd
        !          1754: #
        !          1755: #        args_changed=false
        !          1756: #
        !          1757: #        # Note that, for efficiency, we parse as many options as we can
        !          1758: #        # recognise in a loop before passing the remainder back to the
        !          1759: #        # caller on the first unrecognised argument we encounter.
        !          1760: #        while test $# -gt 0; do
        !          1761: #          opt=$1; shift
        !          1762: #          case $opt in
        !          1763: #            --silent|-s) opt_silent=:
        !          1764: #                         args_changed=:
        !          1765: #                         ;;
        !          1766: #            # Separate non-argument short options:
        !          1767: #            -s*)         func_split_short_opt "$_G_opt"
        !          1768: #                         set dummy "$func_split_short_opt_name" \
        !          1769: #                             "-$func_split_short_opt_arg" ${1+"$@"}
        !          1770: #                         shift
        !          1771: #                         args_changed=:
        !          1772: #                         ;;
        !          1773: #            *)           # Make sure the first unrecognised option "$_G_opt"
        !          1774: #                         # is added back to "$@" in case we need it later,
        !          1775: #                         # if $args_changed was set to 'true'.
        !          1776: #                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
        !          1777: #          esac
        !          1778: #        done
        !          1779: #
        !          1780: #        # Only call 'func_quote' here if we processed at least one argument.
        !          1781: #        if $args_changed; then
        !          1782: #          func_quote eval ${1+"$@"}
        !          1783: #          my_silent_option_result=$func_quote_result
        !          1784: #        fi
        !          1785: #    }
        !          1786: #    func_add_hook func_parse_options my_silent_option
        !          1787: #
        !          1788: #
        !          1789: #    my_option_validation ()
        !          1790: #    {
        !          1791: #        $debug_cmd
        !          1792: #
        !          1793: #        $opt_silent && $opt_verbose && func_fatal_help "\
        !          1794: #    '--silent' and '--verbose' options are mutually exclusive."
        !          1795: #    }
        !          1796: #    func_add_hook func_validate_options my_option_validation
        !          1797: #
        !          1798: # You'll also need to manually amend $usage_message to reflect the extra
        !          1799: # options you parse.  It's preferable to append if you can, so that
        !          1800: # multiple option parsing hooks can be added safely.
1.5       paf      1801: 
                   1802: 
1.7     ! moko     1803: # func_options_finish [ARG]...
        !          1804: # ----------------------------
        !          1805: # Finishing the option parse loop (call 'func_options' hooks ATM).
        !          1806: func_options_finish ()
1.6       moko     1807: {
1.7     ! moko     1808:     $debug_cmd
1.5       paf      1809: 
1.7     ! moko     1810:     func_run_hooks func_options ${1+"$@"}
        !          1811:     func_propagate_result func_run_hooks func_options_finish
1.6       moko     1812: }
1.5       paf      1813: 
                   1814: 
1.7     ! moko     1815: # func_options [ARG]...
        !          1816: # ---------------------
        !          1817: # All the functions called inside func_options are hookable. See the
        !          1818: # individual implementations for details.
        !          1819: func_hookable func_options
        !          1820: func_options ()
1.6       moko     1821: {
1.7     ! moko     1822:     $debug_cmd
        !          1823: 
        !          1824:     _G_options_quoted=false
        !          1825: 
        !          1826:     for my_func in options_prep parse_options validate_options options_finish
        !          1827:     do
        !          1828:       func_unset func_${my_func}_result
        !          1829:       func_unset func_run_hooks_result
        !          1830:       eval func_$my_func '${1+"$@"}'
        !          1831:       func_propagate_result func_$my_func func_options
        !          1832:       if $func_propagate_result_result; then
        !          1833:         eval set dummy "$func_options_result"; shift
        !          1834:         _G_options_quoted=:
        !          1835:       fi
        !          1836:     done
        !          1837: 
        !          1838:     $_G_options_quoted || {
        !          1839:       # As we (func_options) are top-level options-parser function and
        !          1840:       # nobody quoted "$@" for us yet, we need to do it explicitly for
        !          1841:       # caller.
        !          1842:       func_quote eval ${1+"$@"}
        !          1843:       func_options_result=$func_quote_result
        !          1844:     }
        !          1845: }
1.5       paf      1846: 
                   1847: 
1.7     ! moko     1848: # func_options_prep [ARG]...
        !          1849: # --------------------------
        !          1850: # All initialisations required before starting the option parse loop.
        !          1851: # Note that when calling hook functions, we pass through the list of
        !          1852: # positional parameters.  If a hook function modifies that list, and
        !          1853: # needs to propagate that back to rest of this script, then the complete
        !          1854: # modified list must be put in 'func_run_hooks_result' before returning.
        !          1855: func_hookable func_options_prep
        !          1856: func_options_prep ()
        !          1857: {
        !          1858:     $debug_cmd
        !          1859: 
        !          1860:     # Option defaults:
        !          1861:     opt_verbose=false
        !          1862:     opt_warning_types=
        !          1863: 
        !          1864:     func_run_hooks func_options_prep ${1+"$@"}
        !          1865:     func_propagate_result func_run_hooks func_options_prep
1.6       moko     1866: }
1.5       paf      1867: 
                   1868: 
1.7     ! moko     1869: # func_parse_options [ARG]...
        !          1870: # ---------------------------
        !          1871: # The main option parsing loop.
        !          1872: func_hookable func_parse_options
        !          1873: func_parse_options ()
        !          1874: {
        !          1875:     $debug_cmd
        !          1876: 
        !          1877:     _G_parse_options_requote=false
        !          1878:     # this just eases exit handling
        !          1879:     while test $# -gt 0; do
        !          1880:       # Defer to hook functions for initial option parsing, so they
        !          1881:       # get priority in the event of reusing an option name.
        !          1882:       func_run_hooks func_parse_options ${1+"$@"}
        !          1883:       func_propagate_result func_run_hooks func_parse_options
        !          1884:       if $func_propagate_result_result; then
        !          1885:         eval set dummy "$func_parse_options_result"; shift
        !          1886:         # Even though we may have changed "$@", we passed the "$@" array
        !          1887:         # down into the hook and it quoted it for us (because we are in
        !          1888:         # this if-branch).  No need to quote it again.
        !          1889:         _G_parse_options_requote=false
        !          1890:       fi
        !          1891: 
        !          1892:       # Break out of the loop if we already parsed every option.
        !          1893:       test $# -gt 0 || break
        !          1894: 
        !          1895:       # We expect that one of the options parsed in this function matches
        !          1896:       # and thus we remove _G_opt from "$@" and need to re-quote.
        !          1897:       _G_match_parse_options=:
        !          1898:       _G_opt=$1
        !          1899:       shift
        !          1900:       case $_G_opt in
        !          1901:         --debug|-x)   debug_cmd='set -x'
        !          1902:                       func_echo "enabling shell trace mode" >&2
        !          1903:                       $debug_cmd
        !          1904:                       ;;
        !          1905: 
        !          1906:         --no-warnings|--no-warning|--no-warn)
        !          1907:                       set dummy --warnings none ${1+"$@"}
        !          1908:                       shift
        !          1909:                      ;;
1.6       moko     1910: 
1.7     ! moko     1911:         --warnings|--warning|-W)
        !          1912:                       if test $# = 0 && func_missing_arg $_G_opt; then
        !          1913:                         _G_parse_options_requote=:
        !          1914:                         break
        !          1915:                       fi
        !          1916:                       case " $warning_categories $1" in
        !          1917:                         *" $1 "*)
        !          1918:                           # trailing space prevents matching last $1 above
        !          1919:                           func_append_uniq opt_warning_types " $1"
        !          1920:                           ;;
        !          1921:                         *all)
        !          1922:                           opt_warning_types=$warning_categories
        !          1923:                           ;;
        !          1924:                         *none)
        !          1925:                           opt_warning_types=none
        !          1926:                           warning_func=:
        !          1927:                           ;;
        !          1928:                         *error)
        !          1929:                           opt_warning_types=$warning_categories
        !          1930:                           warning_func=func_fatal_error
        !          1931:                           ;;
        !          1932:                         *)
        !          1933:                           func_fatal_error \
        !          1934:                              "unsupported warning category: '$1'"
        !          1935:                           ;;
        !          1936:                       esac
        !          1937:                       shift
        !          1938:                       ;;
        !          1939: 
        !          1940:         --verbose|-v) opt_verbose=: ;;
        !          1941:         --version)    func_version ;;
        !          1942:         -\?|-h)       func_usage ;;
        !          1943:         --help)       func_help ;;
        !          1944: 
        !          1945:        # Separate optargs to long options (plugins may need this):
        !          1946:        --*=*)        func_split_equals "$_G_opt"
        !          1947:                      set dummy "$func_split_equals_lhs" \
        !          1948:                           "$func_split_equals_rhs" ${1+"$@"}
        !          1949:                       shift
        !          1950:                       ;;
        !          1951: 
        !          1952:        # Separate optargs to short options:
        !          1953:         -W*)
        !          1954:                       func_split_short_opt "$_G_opt"
        !          1955:                       set dummy "$func_split_short_opt_name" \
        !          1956:                           "$func_split_short_opt_arg" ${1+"$@"}
        !          1957:                       shift
        !          1958:                       ;;
        !          1959: 
        !          1960:         # Separate non-argument short options:
        !          1961:         -\?*|-h*|-v*|-x*)
        !          1962:                       func_split_short_opt "$_G_opt"
        !          1963:                       set dummy "$func_split_short_opt_name" \
        !          1964:                           "-$func_split_short_opt_arg" ${1+"$@"}
        !          1965:                       shift
        !          1966:                       ;;
        !          1967: 
        !          1968:         --)           _G_parse_options_requote=: ; break ;;
        !          1969:         -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
        !          1970:         *)            set dummy "$_G_opt" ${1+"$@"}; shift
        !          1971:                       _G_match_parse_options=false
        !          1972:                       break
        !          1973:                       ;;
        !          1974:       esac
1.6       moko     1975: 
1.7     ! moko     1976:       if $_G_match_parse_options; then
        !          1977:         _G_parse_options_requote=:
1.6       moko     1978:       fi
1.7     ! moko     1979:     done
        !          1980: 
        !          1981:     if $_G_parse_options_requote; then
        !          1982:       # save modified positional parameters for caller
        !          1983:       func_quote eval ${1+"$@"}
        !          1984:       func_parse_options_result=$func_quote_result
1.5       paf      1985:     fi
1.6       moko     1986: }
                   1987: 
1.5       paf      1988: 
1.7     ! moko     1989: # func_validate_options [ARG]...
        !          1990: # ------------------------------
        !          1991: # Perform any sanity checks on option settings and/or unconsumed
        !          1992: # arguments.
        !          1993: func_hookable func_validate_options
        !          1994: func_validate_options ()
1.6       moko     1995: {
1.7     ! moko     1996:     $debug_cmd
1.6       moko     1997: 
1.7     ! moko     1998:     # Display all warnings if -W was not given.
        !          1999:     test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
        !          2000: 
        !          2001:     func_run_hooks func_validate_options ${1+"$@"}
        !          2002:     func_propagate_result func_run_hooks func_validate_options
1.6       moko     2003: 
1.7     ! moko     2004:     # Bail if the options were screwed!
        !          2005:     $exit_cmd $EXIT_FAILURE
1.6       moko     2006: }
                   2007: 
                   2008: 
                   2009: 
1.7     ! moko     2010: ## ----------------- ##
        !          2011: ## Helper functions. ##
        !          2012: ## ----------------- ##
        !          2013: 
        !          2014: # This section contains the helper functions used by the rest of the
        !          2015: # hookable option parser framework in ascii-betical order.
1.6       moko     2016: 
1.5       paf      2017: 
1.7     ! moko     2018: # func_fatal_help ARG...
        !          2019: # ----------------------
        !          2020: # Echo program name prefixed message to standard error, followed by
        !          2021: # a help hint, and exit.
        !          2022: func_fatal_help ()
1.6       moko     2023: {
1.7     ! moko     2024:     $debug_cmd
1.6       moko     2025: 
1.7     ! moko     2026:     eval \$ECHO \""Usage: $usage"\"
        !          2027:     eval \$ECHO \""$fatal_help"\"
        !          2028:     func_error ${1+"$@"}
        !          2029:     exit $EXIT_FAILURE
1.6       moko     2030: }
1.5       paf      2031: 
1.7     ! moko     2032: 
        !          2033: # func_help
        !          2034: # ---------
        !          2035: # Echo long help message to standard output and exit.
1.6       moko     2036: func_help ()
                   2037: {
1.7     ! moko     2038:     $debug_cmd
1.6       moko     2039: 
1.7     ! moko     2040:     func_usage_message
        !          2041:     $ECHO "$long_help_message"
        !          2042:     exit 0
1.6       moko     2043: }
                   2044: 
1.7     ! moko     2045: 
        !          2046: # func_missing_arg ARGNAME
        !          2047: # ------------------------
1.6       moko     2048: # Echo program name prefixed message to standard error and set global
                   2049: # exit_cmd.
                   2050: func_missing_arg ()
                   2051: {
1.7     ! moko     2052:     $debug_cmd
1.6       moko     2053: 
1.7     ! moko     2054:     func_error "Missing argument for '$1'."
1.6       moko     2055:     exit_cmd=exit
                   2056: }
                   2057: 
1.5       paf      2058: 
1.7     ! moko     2059: # func_split_equals STRING
        !          2060: # ------------------------
        !          2061: # Set func_split_equals_lhs and func_split_equals_rhs shell variables
        !          2062: # after splitting STRING at the '=' sign.
        !          2063: test -z "$_G_HAVE_XSI_OPS" \
        !          2064:     && (eval 'x=a/b/c;
        !          2065:       test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
        !          2066:     && _G_HAVE_XSI_OPS=yes
        !          2067: 
        !          2068: if test yes = "$_G_HAVE_XSI_OPS"
        !          2069: then
        !          2070:   # This is an XSI compatible shell, allowing a faster implementation...
        !          2071:   eval 'func_split_equals ()
        !          2072:   {
        !          2073:       $debug_cmd
        !          2074: 
        !          2075:       func_split_equals_lhs=${1%%=*}
        !          2076:       func_split_equals_rhs=${1#*=}
        !          2077:       if test "x$func_split_equals_lhs" = "x$1"; then
        !          2078:         func_split_equals_rhs=
        !          2079:       fi
        !          2080:   }'
        !          2081: else
        !          2082:   # ...otherwise fall back to using expr, which is often a shell builtin.
        !          2083:   func_split_equals ()
        !          2084:   {
        !          2085:       $debug_cmd
        !          2086: 
        !          2087:       func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
        !          2088:       func_split_equals_rhs=
        !          2089:       test "x$func_split_equals_lhs=" = "x$1" \
        !          2090:         || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
        !          2091:   }
        !          2092: fi #func_split_equals
        !          2093: 
        !          2094: 
        !          2095: # func_split_short_opt SHORTOPT
        !          2096: # -----------------------------
1.6       moko     2097: # Set func_split_short_opt_name and func_split_short_opt_arg shell
                   2098: # variables after splitting SHORTOPT after the 2nd character.
1.7     ! moko     2099: if test yes = "$_G_HAVE_XSI_OPS"
        !          2100: then
        !          2101:   # This is an XSI compatible shell, allowing a faster implementation...
        !          2102:   eval 'func_split_short_opt ()
        !          2103:   {
        !          2104:       $debug_cmd
        !          2105: 
        !          2106:       func_split_short_opt_arg=${1#??}
        !          2107:       func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
        !          2108:   }'
        !          2109: else
        !          2110:   # ...otherwise fall back to using expr, which is often a shell builtin.
        !          2111:   func_split_short_opt ()
        !          2112:   {
        !          2113:       $debug_cmd
        !          2114: 
        !          2115:       func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'`
        !          2116:       func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
        !          2117:   }
        !          2118: fi #func_split_short_opt
        !          2119: 
        !          2120: 
        !          2121: # func_usage
        !          2122: # ----------
        !          2123: # Echo short help message to standard output and exit.
        !          2124: func_usage ()
        !          2125: {
        !          2126:     $debug_cmd
        !          2127: 
        !          2128:     func_usage_message
        !          2129:     $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
        !          2130:     exit 0
        !          2131: }
        !          2132: 
        !          2133: 
        !          2134: # func_usage_message
        !          2135: # ------------------
        !          2136: # Echo short help message to standard output.
        !          2137: func_usage_message ()
        !          2138: {
        !          2139:     $debug_cmd
        !          2140: 
        !          2141:     eval \$ECHO \""Usage: $usage"\"
        !          2142:     echo
        !          2143:     $SED -n 's|^# ||
        !          2144:         /^Written by/{
        !          2145:           x;p;x
        !          2146:         }
        !          2147:        h
        !          2148:        /^Written by/q' < "$progpath"
        !          2149:     echo
        !          2150:     eval \$ECHO \""$usage_message"\"
        !          2151: }
        !          2152: 
        !          2153: 
        !          2154: # func_version
        !          2155: # ------------
        !          2156: # Echo version message to standard output and exit.
        !          2157: # The version message is extracted from the calling file's header
        !          2158: # comments, with leading '# ' stripped:
        !          2159: #   1. First display the progname and version
        !          2160: #   2. Followed by the header comment line matching  /^# Written by /
        !          2161: #   3. Then a blank line followed by the first following line matching
        !          2162: #      /^# Copyright /
        !          2163: #   4. Immediately followed by any lines between the previous matches,
        !          2164: #      except lines preceding the intervening completely blank line.
        !          2165: # For example, see the header comments of this file.
        !          2166: func_version ()
1.6       moko     2167: {
1.7     ! moko     2168:     $debug_cmd
        !          2169: 
        !          2170:     printf '%s\n' "$progname $scriptversion"
        !          2171:     $SED -n '
        !          2172:         /^# Written by /!b
        !          2173:         s|^# ||; p; n
        !          2174: 
        !          2175:         :fwd2blnk
        !          2176:         /./ {
        !          2177:           n
        !          2178:           b fwd2blnk
        !          2179:         }
        !          2180:         p; n
1.6       moko     2181: 
1.7     ! moko     2182:         :holdwrnt
        !          2183:         s|^# ||
        !          2184:         s|^# *$||
        !          2185:         /^Copyright /!{
        !          2186:           /./H
        !          2187:           n
        !          2188:           b holdwrnt
        !          2189:         }
        !          2190: 
        !          2191:         s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
        !          2192:         G
        !          2193:         s|\(\n\)\n*|\1|g
        !          2194:         p; q' < "$progpath"
        !          2195: 
        !          2196:     exit $?
        !          2197: }
        !          2198: 
        !          2199: 
        !          2200: # Local variables:
        !          2201: # mode: shell-script
        !          2202: # sh-indentation: 2
        !          2203: # eval: (add-hook 'before-save-hook 'time-stamp)
        !          2204: # time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
        !          2205: # time-stamp-time-zone: "UTC"
        !          2206: # End:
1.6       moko     2207: 
1.7     ! moko     2208: # Set a version string.
        !          2209: scriptversion='(GNU libtool) 2.5.4'
1.6       moko     2210: 
1.7     ! moko     2211: # func_version
        !          2212: # ------------
        !          2213: # Echo version message to standard output and exit.
        !          2214: func_version ()
1.6       moko     2215: {
1.7     ! moko     2216:     $debug_cmd
        !          2217: 
        !          2218:        year=`date +%Y`
1.6       moko     2219: 
1.7     ! moko     2220:        cat <<EOF
        !          2221: $progname $scriptversion Debian-2.5.4-4
        !          2222: Copyright (C) $year Free Software Foundation, Inc.
        !          2223: License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl.html>
        !          2224: This is free software: you are free to change and redistribute it.
        !          2225: There is NO WARRANTY, to the extent permitted by law.
1.5       paf      2226: 
1.7     ! moko     2227: Originally written by Gordon Matzigkeit, 1996
        !          2228: (See AUTHORS for complete contributor listing)
        !          2229: EOF
1.5       paf      2230: 
1.7     ! moko     2231:     exit $?
        !          2232: }
1.5       paf      2233: 
                   2234: 
1.7     ! moko     2235: # func_echo ARG...
        !          2236: # ----------------
        !          2237: # Libtool also displays the current mode in messages, so override
        !          2238: # funclib.sh func_echo with this custom definition.
        !          2239: func_echo ()
        !          2240: {
        !          2241:     $debug_cmd
1.5       paf      2242: 
1.7     ! moko     2243:     _G_message=$*
1.5       paf      2244: 
1.7     ! moko     2245:     func_echo_IFS=$IFS
        !          2246:     IFS=$nl
        !          2247:     for _G_line in $_G_message; do
        !          2248:       IFS=$func_echo_IFS
        !          2249:       $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
        !          2250:     done
        !          2251:     IFS=$func_echo_IFS
        !          2252: }
1.5       paf      2253: 
                   2254: 
1.7     ! moko     2255: ## ---------------- ##
        !          2256: ## Options parsing. ##
        !          2257: ## ---------------- ##
        !          2258: 
        !          2259: # Hook in the functions to make sure our own options are parsed during
        !          2260: # the option parsing loop.
        !          2261: 
        !          2262: usage='$progpath [OPTION]... [MODE-ARG]...'
        !          2263: 
        !          2264: # Short help message in response to '-h'.
        !          2265: usage_message="Options:
        !          2266:        --config                 show all configuration variables
        !          2267:        --debug                  enable verbose shell tracing
        !          2268:    -n, --dry-run                display commands without modifying any files
        !          2269:        --features               display basic configuration information
        !          2270:        --finish                 use operation '--mode=finish'
        !          2271:        --mode=MODE              use operation mode MODE
        !          2272:        --no-finish              don't update shared library cache
        !          2273:        --no-quiet, --no-silent  print default informational messages
        !          2274:        --no-warnings            equivalent to '-Wnone'
        !          2275:        --preserve-dup-deps      don't remove duplicate dependency libraries
        !          2276:        --quiet, --silent        don't print informational messages
        !          2277:        --reorder-cache=DIRS     reorder shared library cache for preferred DIRS
        !          2278:        --tag=TAG                use configuration variables from tag TAG
        !          2279:    -v, --verbose                print more informational messages than default
        !          2280:        --version                print version information
        !          2281:    -W, --warnings=CATEGORY      report the warnings falling in CATEGORY [all]
        !          2282:    -h, --help, --help-all       print short, long, or detailed help message
        !          2283: "
1.5       paf      2284: 
1.7     ! moko     2285: # Additional text appended to 'usage_message' in response to '--help'.
        !          2286: func_help ()
1.6       moko     2287: {
1.7     ! moko     2288:     $debug_cmd
1.6       moko     2289: 
1.7     ! moko     2290:     func_usage_message
        !          2291:     $ECHO "$long_help_message
1.6       moko     2292: 
1.7     ! moko     2293: MODE must be one of the following:
1.6       moko     2294: 
1.7     ! moko     2295:        clean           remove files from the build directory
        !          2296:        compile         compile a source file into a libtool object
        !          2297:        execute         automatically set library path, then run a program
        !          2298:        finish          complete the installation of libtool libraries
        !          2299:        install         install libraries or executables
        !          2300:        link            create a library or an executable
        !          2301:        uninstall       remove libraries from an installed directory
        !          2302: 
        !          2303: MODE-ARGS vary depending on the MODE.  When passed as first option,
        !          2304: '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
        !          2305: Try '$progname --help --mode=MODE' for a more detailed description of MODE.
        !          2306: 
        !          2307: When reporting a bug, please describe a test case to reproduce it and
        !          2308: include the following information:
        !          2309: 
        !          2310:        host-triplet:   $host
        !          2311:        shell:          $SHELL
        !          2312:        compiler:       $LTCC
        !          2313:        compiler flags: $LTCFLAGS
        !          2314:        linker:         $LD (gnu? $with_gnu_ld)
        !          2315:        version:        $progname $scriptversion Debian-2.5.4-4
        !          2316:        automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
        !          2317:        autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
        !          2318: 
        !          2319: Report bugs to <bug-libtool@gnu.org>.
        !          2320: GNU libtool home page: <https://www.gnu.org/s/libtool/>.
        !          2321: General help using GNU software: <https://www.gnu.org/gethelp/>."
        !          2322:     exit 0
        !          2323: }
1.6       moko     2324: 
                   2325: 
1.7     ! moko     2326: # func_lo2o OBJECT-NAME
        !          2327: # ---------------------
        !          2328: # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
        !          2329: # object suffix.
1.6       moko     2330: 
1.7     ! moko     2331: lo2o=s/\\.lo\$/.$objext/
        !          2332: o2lo=s/\\.$objext\$/.lo/
1.6       moko     2333: 
1.7     ! moko     2334: if test yes = "$_G_HAVE_XSI_OPS"; then
        !          2335:   eval 'func_lo2o ()
        !          2336:   {
        !          2337:     case $1 in
        !          2338:       *.lo) func_lo2o_result=${1%.lo}.$objext ;;
        !          2339:       *   ) func_lo2o_result=$1               ;;
        !          2340:     esac
        !          2341:   }'
1.6       moko     2342: 
1.7     ! moko     2343:   # func_xform LIBOBJ-OR-SOURCE
        !          2344:   # ---------------------------
        !          2345:   # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
        !          2346:   # suffix to a '.lo' libtool-object suffix.
        !          2347:   eval 'func_xform ()
        !          2348:   {
        !          2349:     func_xform_result=${1%.*}.lo
        !          2350:   }'
        !          2351: else
        !          2352:   # ...otherwise fall back to using sed.
        !          2353:   func_lo2o ()
        !          2354:   {
        !          2355:     func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
        !          2356:   }
1.6       moko     2357: 
1.7     ! moko     2358:   func_xform ()
        !          2359:   {
        !          2360:     func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
        !          2361:   }
        !          2362: fi
1.6       moko     2363: 
                   2364: 
1.7     ! moko     2365: # func_fatal_configuration ARG...
        !          2366: # -------------------------------
1.6       moko     2367: # Echo program name prefixed message to standard error, followed by
                   2368: # a configuration failure hint, and exit.
                   2369: func_fatal_configuration ()
                   2370: {
1.7     ! moko     2371:     func_fatal_error ${1+"$@"} \
        !          2372:       "See the $PACKAGE documentation for more information." \
        !          2373:       "Fatal configuration error."
1.6       moko     2374: }
1.5       paf      2375: 
                   2376: 
1.6       moko     2377: # func_config
1.7     ! moko     2378: # -----------
1.6       moko     2379: # Display the configuration for all the tags in this script.
                   2380: func_config ()
                   2381: {
                   2382:     re_begincf='^# ### BEGIN LIBTOOL'
                   2383:     re_endcf='^# ### END LIBTOOL'
                   2384: 
                   2385:     # Default configuration.
                   2386:     $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
                   2387: 
                   2388:     # Now print the configurations for the tags.
                   2389:     for tagname in $taglist; do
                   2390:       $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
                   2391:     done
1.5       paf      2392: 
1.6       moko     2393:     exit $?
                   2394: }
1.5       paf      2395: 
1.7     ! moko     2396: 
1.6       moko     2397: # func_features
1.7     ! moko     2398: # -------------
1.6       moko     2399: # Display the features supported by this script.
                   2400: func_features ()
                   2401: {
                   2402:     echo "host: $host"
1.7     ! moko     2403:     if test yes = "$build_libtool_libs"; then
1.6       moko     2404:       echo "enable shared libraries"
                   2405:     else
                   2406:       echo "disable shared libraries"
                   2407:     fi
1.7     ! moko     2408:     if test yes = "$build_old_libs"; then
1.6       moko     2409:       echo "enable static libraries"
                   2410:     else
                   2411:       echo "disable static libraries"
                   2412:     fi
1.5       paf      2413: 
1.6       moko     2414:     exit $?
                   2415: }
1.5       paf      2416: 
1.7     ! moko     2417: 
        !          2418: # func_enable_tag TAGNAME
        !          2419: # -----------------------
1.6       moko     2420: # Verify that TAGNAME is valid, and either flag an error and exit, or
                   2421: # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
                   2422: # variable here.
                   2423: func_enable_tag ()
                   2424: {
1.7     ! moko     2425:     # Global variable:
        !          2426:     tagname=$1
1.6       moko     2427: 
1.7     ! moko     2428:     re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
        !          2429:     re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
        !          2430:     sed_extractcf=/$re_begincf/,/$re_endcf/p
        !          2431: 
        !          2432:     # Validate tagname.
        !          2433:     case $tagname in
        !          2434:       *[!-_A-Za-z0-9,/]*)
        !          2435:         func_fatal_error "invalid tag name: $tagname"
        !          2436:         ;;
        !          2437:     esac
1.5       paf      2438: 
1.7     ! moko     2439:     # Don't test for the "default" C tag, as we know it's
        !          2440:     # there but not specially marked.
        !          2441:     case $tagname in
        !          2442:         CC) ;;
1.6       moko     2443:     *)
1.7     ! moko     2444:         if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
        !          2445:          taglist="$taglist $tagname"
1.5       paf      2446: 
1.7     ! moko     2447:          # Evaluate the configuration.  Be careful to quote the path
        !          2448:          # and the sed script, to avoid splitting on whitespace, but
        !          2449:          # also don't use non-portable quotes within backquotes within
        !          2450:          # quotes we have to do it in 2 steps:
        !          2451:          extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
        !          2452:          eval "$extractedcf"
        !          2453:         else
        !          2454:          func_error "ignoring unknown tag $tagname"
        !          2455:         fi
        !          2456:         ;;
        !          2457:     esac
1.6       moko     2458: }
1.5       paf      2459: 
1.7     ! moko     2460: 
1.6       moko     2461: # func_check_version_match
1.7     ! moko     2462: # ------------------------
1.6       moko     2463: # Ensure that we are using m4 macros, and libtool script from the same
                   2464: # release of libtool.
                   2465: func_check_version_match ()
                   2466: {
1.7     ! moko     2467:     if test "$package_revision" != "$macro_revision"; then
        !          2468:       if test "$VERSION" != "$macro_version"; then
        !          2469:         if test -z "$macro_version"; then
        !          2470:           cat >&2 <<_LT_EOF
1.6       moko     2471: $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
                   2472: $progname: definition of this LT_INIT comes from an older release.
                   2473: $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
                   2474: $progname: and run autoconf again.
                   2475: _LT_EOF
1.7     ! moko     2476:         else
        !          2477:           cat >&2 <<_LT_EOF
1.6       moko     2478: $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
                   2479: $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
                   2480: $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
                   2481: $progname: and run autoconf again.
                   2482: _LT_EOF
1.7     ! moko     2483:         fi
        !          2484:       else
        !          2485:         cat >&2 <<_LT_EOF
1.6       moko     2486: $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
                   2487: $progname: but the definition of this LT_INIT comes from revision $macro_revision.
                   2488: $progname: You should recreate aclocal.m4 with macros from revision $package_revision
                   2489: $progname: of $PACKAGE $VERSION and run autoconf again.
                   2490: _LT_EOF
1.7     ! moko     2491:       fi
        !          2492: 
        !          2493:       exit $EXIT_MISMATCH
1.6       moko     2494:     fi
                   2495: }
1.5       paf      2496: 
                   2497: 
1.7     ! moko     2498: # libtool_options_prep [ARG]...
        !          2499: # -----------------------------
        !          2500: # Preparation for options parsed by libtool.
        !          2501: libtool_options_prep ()
        !          2502: {
        !          2503:     $debug_mode
1.5       paf      2504: 
1.7     ! moko     2505:     # Option defaults:
        !          2506:     opt_config=false
        !          2507:     opt_dlopen=
        !          2508:     opt_dry_run=false
        !          2509:     opt_help=false
        !          2510:     opt_mode=
        !          2511:     opt_reorder_cache=false
        !          2512:     opt_preserve_dup_deps=false
        !          2513:     opt_quiet=false
        !          2514:     opt_finishing=true
        !          2515:     opt_warning=
1.5       paf      2516: 
1.7     ! moko     2517:     nonopt=
        !          2518:     preserve_args=
1.5       paf      2519: 
1.7     ! moko     2520:     _G_rc_lt_options_prep=:
1.6       moko     2521: 
1.7     ! moko     2522:     _G_rc_lt_options_prep=:
1.6       moko     2523: 
1.7     ! moko     2524:     # Shorthand for --mode=foo, only valid as the first argument
        !          2525:     case $1 in
        !          2526:     clean|clea|cle|cl)
        !          2527:       shift; set dummy --mode clean ${1+"$@"}; shift
        !          2528:       ;;
        !          2529:     compile|compil|compi|comp|com|co|c)
        !          2530:       shift; set dummy --mode compile ${1+"$@"}; shift
        !          2531:       ;;
        !          2532:     execute|execut|execu|exec|exe|ex|e)
        !          2533:       shift; set dummy --mode execute ${1+"$@"}; shift
        !          2534:       ;;
        !          2535:     finish|finis|fini|fin|fi|f)
        !          2536:       shift; set dummy --mode finish ${1+"$@"}; shift
        !          2537:       ;;
        !          2538:     install|instal|insta|inst|ins|in|i)
        !          2539:       shift; set dummy --mode install ${1+"$@"}; shift
        !          2540:       ;;
        !          2541:     link|lin|li|l)
        !          2542:       shift; set dummy --mode link ${1+"$@"}; shift
        !          2543:       ;;
        !          2544:     uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
        !          2545:       shift; set dummy --mode uninstall ${1+"$@"}; shift
        !          2546:       ;;
        !          2547:     *)
        !          2548:       _G_rc_lt_options_prep=false
        !          2549:       ;;
1.6       moko     2550:     esac
1.5       paf      2551: 
1.7     ! moko     2552:     if $_G_rc_lt_options_prep; then
        !          2553:       # Pass back the list of options.
        !          2554:       func_quote eval ${1+"$@"}
        !          2555:       libtool_options_prep_result=$func_quote_result
        !          2556:     fi
        !          2557: }
        !          2558: func_add_hook func_options_prep libtool_options_prep
        !          2559: 
        !          2560: 
        !          2561: # libtool_parse_options [ARG]...
        !          2562: # ---------------------------------
        !          2563: # Provide handling for libtool specific options.
        !          2564: libtool_parse_options ()
        !          2565: {
        !          2566:     $debug_cmd
1.5       paf      2567: 
1.7     ! moko     2568:     _G_rc_lt_parse_options=false
1.5       paf      2569: 
1.7     ! moko     2570:     # Perform our own loop to consume as many options as possible in
        !          2571:     # each iteration.
        !          2572:     while test $# -gt 0; do
        !          2573:       _G_match_lt_parse_options=:
        !          2574:       _G_opt=$1
        !          2575:       shift
        !          2576:       case $_G_opt in
        !          2577:         --dry-run|--dryrun|-n)
        !          2578:                         opt_dry_run=:
        !          2579:                         ;;
        !          2580: 
        !          2581:         --config)       func_config ;;
        !          2582: 
        !          2583:         --dlopen|-dlopen)
        !          2584:                         opt_dlopen="${opt_dlopen+$opt_dlopen
        !          2585: }$1"
        !          2586:                         shift
        !          2587:                         ;;
        !          2588: 
        !          2589:         --preserve-dup-deps)
        !          2590:                         opt_preserve_dup_deps=: ;;
        !          2591: 
        !          2592:         --features)     func_features ;;
        !          2593: 
        !          2594:         --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
        !          2595: 
        !          2596:         --help)         opt_help=: ;;
        !          2597: 
        !          2598:         --help-all)     opt_help=': help-all' ;;
        !          2599: 
        !          2600:         --mode)         test $# = 0 && func_missing_arg $_G_opt && break
        !          2601:                         opt_mode=$1
        !          2602:                         case $1 in
        !          2603:                           # Valid mode arguments:
        !          2604:                           clean|compile|execute|finish|install|link|relink|uninstall) ;;
        !          2605: 
        !          2606:                           # Catch anything else as an error
        !          2607:                           *) func_error "invalid argument '$1' for $_G_opt"
        !          2608:                              exit_cmd=exit
        !          2609:                              ;;
        !          2610:                         esac
        !          2611:                         shift
        !          2612:                         ;;
        !          2613: 
        !          2614:         --no-finish)
        !          2615:                         opt_finishing=false
        !          2616:                         func_append preserve_args " $_G_opt"
        !          2617:                         ;;
        !          2618: 
        !          2619:         --no-silent|--no-quiet)
        !          2620:                         opt_quiet=false
        !          2621:                         func_append preserve_args " $_G_opt"
        !          2622:                         ;;
        !          2623: 
        !          2624:         --no-warnings|--no-warning|--no-warn)
        !          2625:                         opt_warning=false
        !          2626:                         func_append preserve_args " $_G_opt"
        !          2627:                         ;;
        !          2628: 
        !          2629:         --no-verbose)
        !          2630:                         opt_verbose=false
        !          2631:                         func_append preserve_args " $_G_opt"
        !          2632:                         ;;
        !          2633: 
        !          2634:         --reorder-cache)
        !          2635:                         opt_reorder_cache=true
        !          2636:                         shared_lib_dirs=$1
        !          2637:                         if test -n "$shared_lib_dirs"; then
        !          2638:                           case $1 in
        !          2639:                             # Must begin with /:
        !          2640:                             /*) ;;
        !          2641: 
        !          2642:                             # Catch anything else as an error (relative paths)
        !          2643:                             *) func_error "invalid argument '$1' for $_G_opt"
        !          2644:                                func_error "absolute paths are required for $_G_opt"
        !          2645:                                exit_cmd=exit
        !          2646:                                ;;
        !          2647:                           esac
        !          2648:                         fi
        !          2649:                         shift
        !          2650:                         ;;
        !          2651: 
        !          2652:         --silent|--quiet)
        !          2653:                         opt_quiet=:
        !          2654:                         opt_verbose=false
        !          2655:                         func_append preserve_args " $_G_opt"
        !          2656:                         ;;
        !          2657: 
        !          2658:         --tag)          test $# = 0 && func_missing_arg $_G_opt && break
        !          2659:                         opt_tag=$1
        !          2660:                         func_append preserve_args " $_G_opt $1"
        !          2661:                         func_enable_tag "$1"
        !          2662:                         shift
        !          2663:                         ;;
        !          2664: 
        !          2665:         --verbose|-v)   opt_quiet=false
        !          2666:                         opt_verbose=:
        !          2667:                         func_append preserve_args " $_G_opt"
        !          2668:                         ;;
        !          2669: 
        !          2670:         # An option not handled by this hook function:
        !          2671:         *)              set dummy "$_G_opt" ${1+"$@"} ; shift
        !          2672:                         _G_match_lt_parse_options=false
        !          2673:                         break
        !          2674:                         ;;
        !          2675:       esac
        !          2676:       $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
        !          2677:     done
1.5       paf      2678: 
1.7     ! moko     2679:     if $_G_rc_lt_parse_options; then
        !          2680:       # save modified positional parameters for caller
        !          2681:       func_quote eval ${1+"$@"}
        !          2682:       libtool_parse_options_result=$func_quote_result
        !          2683:     fi
        !          2684: }
        !          2685: func_add_hook func_parse_options libtool_parse_options
1.6       moko     2686: 
                   2687: 
1.7     ! moko     2688: # func_warning ARG...
        !          2689: # -------------------
        !          2690: # Libtool warnings are not categorized, so override funclib.sh
        !          2691: # func_warning with this simpler definition.
        !          2692: func_warning ()
        !          2693: {
        !          2694:     if $opt_warning; then
        !          2695:         $debug_cmd
        !          2696:         $warning_func ${1+"$@"}
1.6       moko     2697:     fi
1.7     ! moko     2698: }
1.6       moko     2699: 
                   2700: 
1.7     ! moko     2701: # libtool_validate_options [ARG]...
        !          2702: # ---------------------------------
        !          2703: # Perform any sanity checks on option settings and/or unconsumed
        !          2704: # arguments.
        !          2705: libtool_validate_options ()
        !          2706: {
        !          2707:     # save first non-option argument
        !          2708:     if test 0 -lt $#; then
        !          2709:       nonopt=$1
        !          2710:       shift
1.6       moko     2711:     fi
                   2712: 
1.7     ! moko     2713:     # preserve --debug
        !          2714:     test : = "$debug_cmd" || func_append preserve_args " --debug"
        !          2715: 
        !          2716:     case $host_os in
        !          2717:       # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
        !          2718:       # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
        !          2719:       cygwin* | mingw* | windows* | pw32* | cegcc* | solaris2* | os2*)
        !          2720:         # don't eliminate duplications in $postdeps and $predeps
        !          2721:         opt_duplicate_compiler_generated_deps=:
        !          2722:         ;;
        !          2723:       *)
        !          2724:         opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
        !          2725:         ;;
        !          2726:     esac
1.6       moko     2727: 
1.7     ! moko     2728:     $opt_help || {
        !          2729:       # Sanity checks first:
        !          2730:       func_check_version_match
        !          2731: 
        !          2732:       test yes != "$build_libtool_libs" \
        !          2733:         && test yes != "$build_old_libs" \
        !          2734:         && func_fatal_configuration "not configured to build any kind of library"
        !          2735: 
        !          2736:       # Darwin sucks
        !          2737:       eval std_shrext=\"$shrext_cmds\"
        !          2738: 
        !          2739:       # Only execute mode is allowed to have -dlopen flags.
        !          2740:       if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
        !          2741:         func_error "unrecognized option '-dlopen'"
        !          2742:         $ECHO "$help" 1>&2
        !          2743:         exit $EXIT_FAILURE
        !          2744:       fi
        !          2745: 
        !          2746:       # Change the help message to a mode-specific one.
        !          2747:       generic_help=$help
        !          2748:       help="Try '$progname --help --mode=$opt_mode' for more information."
        !          2749:     }
1.6       moko     2750: 
1.7     ! moko     2751:     # Pass back the unparsed argument list
        !          2752:     func_quote eval ${1+"$@"}
        !          2753:     libtool_validate_options_result=$func_quote_result
1.6       moko     2754: }
1.7     ! moko     2755: func_add_hook func_validate_options libtool_validate_options
1.6       moko     2756: 
                   2757: 
1.7     ! moko     2758: # Process options as early as possible so that --help and --version
        !          2759: # can return quickly.
        !          2760: func_options ${1+"$@"}
        !          2761: eval set dummy "$func_options_result"; shift
        !          2762: 
1.6       moko     2763: 
                   2764: 
                   2765: ## ----------- ##
                   2766: ##    Main.    ##
                   2767: ## ----------- ##
                   2768: 
1.7     ! moko     2769: magic='%%%MAGIC variable%%%'
        !          2770: magic_exe='%%%MAGIC EXE variable%%%'
        !          2771: 
        !          2772: # Global variables.
        !          2773: extracted_archives=
        !          2774: extracted_serial=0
        !          2775: 
        !          2776: # If this variable is set in any of the actions, the command in it
        !          2777: # will be execed at the end.  This prevents here-documents from being
        !          2778: # left over by shells.
        !          2779: exec_cmd=
        !          2780: 
        !          2781: 
        !          2782: # A function that is used when there is no print builtin or printf.
        !          2783: func_fallback_echo ()
        !          2784: {
        !          2785:   eval 'cat <<_LTECHO_EOF
        !          2786: $1
        !          2787: _LTECHO_EOF'
        !          2788: }
        !          2789: 
        !          2790: # func_generated_by_libtool
        !          2791: # True iff stdin has been generated by Libtool. This function is only
        !          2792: # a basic sanity check; it will hardly flush out determined imposters.
        !          2793: func_generated_by_libtool_p ()
        !          2794: {
        !          2795:   $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
        !          2796: }
        !          2797: 
1.6       moko     2798: # func_lalib_p file
1.7     ! moko     2799: # True iff FILE is a libtool '.la' library or '.lo' object file.
1.6       moko     2800: # This function is only a basic sanity check; it will hardly flush out
                   2801: # determined imposters.
                   2802: func_lalib_p ()
                   2803: {
                   2804:     test -f "$1" &&
1.7     ! moko     2805:       $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
1.6       moko     2806: }
                   2807: 
                   2808: # func_lalib_unsafe_p file
1.7     ! moko     2809: # True iff FILE is a libtool '.la' library or '.lo' object file.
1.6       moko     2810: # This function implements the same check as func_lalib_p without
                   2811: # resorting to external programs.  To this end, it redirects stdin and
                   2812: # closes it afterwards, without saving the original file descriptor.
                   2813: # As a safety measure, use it only where a negative result would be
1.7     ! moko     2814: # fatal anyway.  Works if 'file' does not exist.
1.6       moko     2815: func_lalib_unsafe_p ()
                   2816: {
                   2817:     lalib_p=no
                   2818:     if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
                   2819:        for lalib_p_l in 1 2 3 4
                   2820:        do
                   2821:            read lalib_p_line
1.7     ! moko     2822:            case $lalib_p_line in
1.6       moko     2823:                \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
                   2824:            esac
                   2825:        done
                   2826:        exec 0<&5 5<&-
                   2827:     fi
1.7     ! moko     2828:     test yes = "$lalib_p"
1.6       moko     2829: }
                   2830: 
                   2831: # func_ltwrapper_script_p file
                   2832: # True iff FILE is a libtool wrapper script
                   2833: # This function is only a basic sanity check; it will hardly flush out
                   2834: # determined imposters.
                   2835: func_ltwrapper_script_p ()
                   2836: {
1.7     ! moko     2837:     test -f "$1" &&
        !          2838:       $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
1.6       moko     2839: }
                   2840: 
                   2841: # func_ltwrapper_executable_p file
                   2842: # True iff FILE is a libtool wrapper executable
                   2843: # This function is only a basic sanity check; it will hardly flush out
                   2844: # determined imposters.
                   2845: func_ltwrapper_executable_p ()
                   2846: {
                   2847:     func_ltwrapper_exec_suffix=
                   2848:     case $1 in
                   2849:     *.exe) ;;
                   2850:     *) func_ltwrapper_exec_suffix=.exe ;;
1.5       paf      2851:     esac
1.6       moko     2852:     $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
                   2853: }
                   2854: 
                   2855: # func_ltwrapper_scriptname file
                   2856: # Assumes file is an ltwrapper_executable
                   2857: # uses $file to determine the appropriate filename for a
                   2858: # temporary ltwrapper_script.
                   2859: func_ltwrapper_scriptname ()
                   2860: {
                   2861:     func_dirname_and_basename "$1" "" "."
                   2862:     func_stripname '' '.exe' "$func_basename_result"
1.7     ! moko     2863:     func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
1.6       moko     2864: }
1.5       paf      2865: 
1.6       moko     2866: # func_ltwrapper_p file
                   2867: # True iff FILE is a libtool wrapper script or wrapper executable
                   2868: # This function is only a basic sanity check; it will hardly flush out
                   2869: # determined imposters.
                   2870: func_ltwrapper_p ()
                   2871: {
                   2872:     func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
                   2873: }
1.5       paf      2874: 
                   2875: 
1.6       moko     2876: # func_execute_cmds commands fail_cmd
                   2877: # Execute tilde-delimited COMMANDS.
                   2878: # If FAIL_CMD is given, eval that upon failure.
                   2879: # FAIL_CMD may read-access the current command in variable CMD!
                   2880: func_execute_cmds ()
                   2881: {
1.7     ! moko     2882:     $debug_cmd
        !          2883: 
1.6       moko     2884:     save_ifs=$IFS; IFS='~'
                   2885:     for cmd in $1; do
1.7     ! moko     2886:       IFS=$sp$nl
        !          2887:       eval cmd=\"$cmd\"
1.6       moko     2888:       IFS=$save_ifs
                   2889:       func_show_eval "$cmd" "${2-:}"
1.5       paf      2890:     done
1.6       moko     2891:     IFS=$save_ifs
                   2892: }
1.5       paf      2893: 
                   2894: 
1.6       moko     2895: # func_source file
                   2896: # Source FILE, adding directory component if necessary.
                   2897: # Note that it is not necessary on cygwin/mingw to append a dot to
                   2898: # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
                   2899: # behavior happens only for exec(3), not for open(2)!  Also, sourcing
1.7     ! moko     2900: # 'FILE.' does not work on cygwin managed mounts.
1.6       moko     2901: func_source ()
                   2902: {
1.7     ! moko     2903:     $debug_cmd
        !          2904: 
1.6       moko     2905:     case $1 in
                   2906:     */* | *\\*)        . "$1" ;;
                   2907:     *)         . "./$1" ;;
                   2908:     esac
                   2909: }
                   2910: 
1.5       paf      2911: 
1.6       moko     2912: # func_resolve_sysroot PATH
                   2913: # Replace a leading = in PATH with a sysroot.  Store the result into
                   2914: # func_resolve_sysroot_result
                   2915: func_resolve_sysroot ()
                   2916: {
                   2917:   func_resolve_sysroot_result=$1
                   2918:   case $func_resolve_sysroot_result in
                   2919:   =*)
                   2920:     func_stripname '=' '' "$func_resolve_sysroot_result"
                   2921:     func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
                   2922:     ;;
                   2923:   esac
                   2924: }
                   2925: 
                   2926: # func_replace_sysroot PATH
                   2927: # If PATH begins with the sysroot, replace it with = and
                   2928: # store the result into func_replace_sysroot_result.
                   2929: func_replace_sysroot ()
                   2930: {
1.7     ! moko     2931:   case $lt_sysroot:$1 in
1.6       moko     2932:   ?*:"$lt_sysroot"*)
                   2933:     func_stripname "$lt_sysroot" '' "$1"
1.7     ! moko     2934:     func_replace_sysroot_result='='$func_stripname_result
1.6       moko     2935:     ;;
                   2936:   *)
                   2937:     # Including no sysroot.
                   2938:     func_replace_sysroot_result=$1
                   2939:     ;;
                   2940:   esac
                   2941: }
1.5       paf      2942: 
1.6       moko     2943: # func_infer_tag arg
                   2944: # Infer tagged configuration to use if any are available and
                   2945: # if one wasn't chosen via the "--tag" command line option.
                   2946: # Only attempt this if the compiler in the base compile
                   2947: # command doesn't match the default compiler.
                   2948: # arg is usually of the form 'gcc ...'
                   2949: func_infer_tag ()
                   2950: {
1.7     ! moko     2951:     $debug_cmd
        !          2952: 
1.6       moko     2953:     if test -n "$available_tags" && test -z "$tagname"; then
                   2954:       CC_quoted=
                   2955:       for arg in $CC; do
                   2956:        func_append_quoted CC_quoted "$arg"
                   2957:       done
                   2958:       CC_expanded=`func_echo_all $CC`
                   2959:       CC_quoted_expanded=`func_echo_all $CC_quoted`
                   2960:       case $@ in
                   2961:       # Blanks in the command may have been stripped by the calling shell,
                   2962:       # but not from the CC environment variable when configure was run.
                   2963:       " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
                   2964:       " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
                   2965:       # Blanks at the start of $base_compile will cause this to fail
                   2966:       # if we don't check for them as well.
                   2967:       *)
                   2968:        for z in $available_tags; do
                   2969:          if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
                   2970:            # Evaluate the configuration.
1.7     ! moko     2971:            eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1.6       moko     2972:            CC_quoted=
                   2973:            for arg in $CC; do
                   2974:              # Double-quote args containing other shell metacharacters.
                   2975:              func_append_quoted CC_quoted "$arg"
                   2976:            done
                   2977:            CC_expanded=`func_echo_all $CC`
                   2978:            CC_quoted_expanded=`func_echo_all $CC_quoted`
                   2979:            case "$@ " in
                   2980:            " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
                   2981:            " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
                   2982:              # The compiler in the base compile command matches
                   2983:              # the one in the tagged configuration.
                   2984:              # Assume this is the tagged configuration we want.
                   2985:              tagname=$z
                   2986:              break
                   2987:              ;;
1.5       paf      2988:            esac
                   2989:          fi
1.6       moko     2990:        done
                   2991:        # If $tagname still isn't set, then no tagged configuration
                   2992:        # was found and let the user know that the "--tag" command
                   2993:        # line option must be used.
                   2994:        if test -z "$tagname"; then
                   2995:          func_echo "unable to infer tagged configuration"
1.7     ! moko     2996:          func_fatal_error "specify a tag with '--tag'"
1.6       moko     2997: #      else
                   2998: #        func_verbose "using $tagname tagged configuration"
1.5       paf      2999:        fi
                   3000:        ;;
1.6       moko     3001:       esac
                   3002:     fi
                   3003: }
1.5       paf      3004: 
                   3005: 
                   3006: 
1.6       moko     3007: # func_write_libtool_object output_name pic_name nonpic_name
                   3008: # Create a libtool object file (analogous to a ".la" file),
                   3009: # but don't create it if we're doing a dry run.
                   3010: func_write_libtool_object ()
                   3011: {
1.7     ! moko     3012:     write_libobj=$1
        !          3013:     if test yes = "$build_libtool_libs"; then
        !          3014:       write_lobj=\'$2\'
1.6       moko     3015:     else
                   3016:       write_lobj=none
                   3017:     fi
1.5       paf      3018: 
1.7     ! moko     3019:     if test yes = "$build_old_libs"; then
        !          3020:       write_oldobj=\'$3\'
1.6       moko     3021:     else
                   3022:       write_oldobj=none
                   3023:     fi
1.5       paf      3024: 
1.6       moko     3025:     $opt_dry_run || {
                   3026:       cat >${write_libobj}T <<EOF
                   3027: # $write_libobj - a libtool object file
1.7     ! moko     3028: # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
1.6       moko     3029: #
                   3030: # Please DO NOT delete this file!
                   3031: # It is necessary for linking the library.
1.5       paf      3032: 
1.6       moko     3033: # Name of the PIC object.
                   3034: pic_object=$write_lobj
1.5       paf      3035: 
1.6       moko     3036: # Name of the non-PIC object
                   3037: non_pic_object=$write_oldobj
1.5       paf      3038: 
1.6       moko     3039: EOF
1.7     ! moko     3040:       $MV "${write_libobj}T" "$write_libobj"
1.6       moko     3041:     }
                   3042: }
1.5       paf      3043: 
                   3044: 
1.6       moko     3045: ##################################################
                   3046: # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
                   3047: ##################################################
                   3048: 
                   3049: # func_convert_core_file_wine_to_w32 ARG
                   3050: # Helper function used by file name conversion functions when $build is *nix,
1.7     ! moko     3051: # and $host is mingw, windows, cygwin, or some other w32 environment. Relies on a
1.6       moko     3052: # correctly configured wine environment available, with the winepath program
                   3053: # in $build's $PATH.
                   3054: #
                   3055: # ARG is the $build file name to be converted to w32 format.
                   3056: # Result is available in $func_convert_core_file_wine_to_w32_result, and will
                   3057: # be empty on error (or when ARG is empty)
                   3058: func_convert_core_file_wine_to_w32 ()
                   3059: {
1.7     ! moko     3060:   $debug_cmd
        !          3061: 
        !          3062:   func_convert_core_file_wine_to_w32_result=$1
1.6       moko     3063:   if test -n "$1"; then
                   3064:     # Unfortunately, winepath does not exit with a non-zero error code, so we
                   3065:     # are forced to check the contents of stdout. On the other hand, if the
                   3066:     # command is not found, the shell will set an exit code of 127 and print
                   3067:     # *an error message* to stdout. So we must check for both error code of
                   3068:     # zero AND non-empty stdout, which explains the odd construction:
                   3069:     func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
1.7     ! moko     3070:     if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
1.6       moko     3071:       func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
1.7     ! moko     3072:         $SED -e "$sed_naive_backslashify"`
1.6       moko     3073:     else
                   3074:       func_convert_core_file_wine_to_w32_result=
                   3075:     fi
                   3076:   fi
                   3077: }
                   3078: # end: func_convert_core_file_wine_to_w32
1.5       paf      3079: 
                   3080: 
1.6       moko     3081: # func_convert_core_path_wine_to_w32 ARG
                   3082: # Helper function used by path conversion functions when $build is *nix, and
1.7     ! moko     3083: # $host is mingw, windows, cygwin, or some other w32 environment. Relies on a
        !          3084: # correctly configured wine environment available, with the winepath program
        !          3085: # in $build's $PATH. Assumes ARG has no leading or trailing path separator
        !          3086: # characters.
1.6       moko     3087: #
                   3088: # ARG is path to be converted from $build format to win32.
                   3089: # Result is available in $func_convert_core_path_wine_to_w32_result.
                   3090: # Unconvertible file (directory) names in ARG are skipped; if no directory names
                   3091: # are convertible, then the result may be empty.
                   3092: func_convert_core_path_wine_to_w32 ()
                   3093: {
1.7     ! moko     3094:   $debug_cmd
        !          3095: 
1.6       moko     3096:   # unfortunately, winepath doesn't convert paths, only file names
1.7     ! moko     3097:   func_convert_core_path_wine_to_w32_result=
1.6       moko     3098:   if test -n "$1"; then
                   3099:     oldIFS=$IFS
                   3100:     IFS=:
                   3101:     for func_convert_core_path_wine_to_w32_f in $1; do
                   3102:       IFS=$oldIFS
                   3103:       func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
1.7     ! moko     3104:       if test -n "$func_convert_core_file_wine_to_w32_result"; then
1.6       moko     3105:         if test -z "$func_convert_core_path_wine_to_w32_result"; then
1.7     ! moko     3106:           func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
1.6       moko     3107:         else
                   3108:           func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
                   3109:         fi
                   3110:       fi
                   3111:     done
                   3112:     IFS=$oldIFS
                   3113:   fi
                   3114: }
                   3115: # end: func_convert_core_path_wine_to_w32
1.5       paf      3116: 
                   3117: 
1.6       moko     3118: # func_cygpath ARGS...
                   3119: # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
                   3120: # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
                   3121: # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
                   3122: # (2), returns the Cygwin file name or path in func_cygpath_result (input
                   3123: # file name or path is assumed to be in w32 format, as previously converted
                   3124: # from $build's *nix or MSYS format). In case (3), returns the w32 file name
                   3125: # or path in func_cygpath_result (input file name or path is assumed to be in
                   3126: # Cygwin format). Returns an empty string on error.
                   3127: #
                   3128: # ARGS are passed to cygpath, with the last one being the file name or path to
                   3129: # be converted.
                   3130: #
                   3131: # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
                   3132: # environment variable; do not put it in $PATH.
                   3133: func_cygpath ()
                   3134: {
1.7     ! moko     3135:   $debug_cmd
        !          3136: 
1.6       moko     3137:   if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
                   3138:     func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
                   3139:     if test "$?" -ne 0; then
                   3140:       # on failure, ensure result is empty
                   3141:       func_cygpath_result=
                   3142:     fi
                   3143:   else
                   3144:     func_cygpath_result=
1.7     ! moko     3145:     func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
1.6       moko     3146:   fi
                   3147: }
                   3148: #end: func_cygpath
1.5       paf      3149: 
                   3150: 
1.6       moko     3151: # func_convert_core_msys_to_w32 ARG
                   3152: # Convert file name or path ARG from MSYS format to w32 format.  Return
                   3153: # result in func_convert_core_msys_to_w32_result.
                   3154: func_convert_core_msys_to_w32 ()
                   3155: {
1.7     ! moko     3156:   $debug_cmd
        !          3157: 
1.6       moko     3158:   # awkward: cmd appends spaces to result
                   3159:   func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
1.7     ! moko     3160:     $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
1.6       moko     3161: }
                   3162: #end: func_convert_core_msys_to_w32
1.5       paf      3163: 
                   3164: 
1.6       moko     3165: # func_convert_file_check ARG1 ARG2
                   3166: # Verify that ARG1 (a file name in $build format) was converted to $host
                   3167: # format in ARG2. Otherwise, emit an error message, but continue (resetting
                   3168: # func_to_host_file_result to ARG1).
                   3169: func_convert_file_check ()
                   3170: {
1.7     ! moko     3171:   $debug_cmd
        !          3172: 
        !          3173:   if test -z "$2" && test -n "$1"; then
1.6       moko     3174:     func_error "Could not determine host file name corresponding to"
1.7     ! moko     3175:     func_error "  '$1'"
1.6       moko     3176:     func_error "Continuing, but uninstalled executables may not work."
                   3177:     # Fallback:
1.7     ! moko     3178:     func_to_host_file_result=$1
1.6       moko     3179:   fi
                   3180: }
                   3181: # end func_convert_file_check
                   3182: 
                   3183: 
                   3184: # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
                   3185: # Verify that FROM_PATH (a path in $build format) was converted to $host
                   3186: # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
                   3187: # func_to_host_file_result to a simplistic fallback value (see below).
                   3188: func_convert_path_check ()
                   3189: {
1.7     ! moko     3190:   $debug_cmd
        !          3191: 
1.6       moko     3192:   if test -z "$4" && test -n "$3"; then
                   3193:     func_error "Could not determine the host path corresponding to"
1.7     ! moko     3194:     func_error "  '$3'"
1.6       moko     3195:     func_error "Continuing, but uninstalled executables may not work."
                   3196:     # Fallback.  This is a deliberately simplistic "conversion" and
                   3197:     # should not be "improved".  See libtool.info.
                   3198:     if test "x$1" != "x$2"; then
                   3199:       lt_replace_pathsep_chars="s|$1|$2|g"
                   3200:       func_to_host_path_result=`echo "$3" |
                   3201:         $SED -e "$lt_replace_pathsep_chars"`
                   3202:     else
1.7     ! moko     3203:       func_to_host_path_result=$3
1.6       moko     3204:     fi
                   3205:   fi
                   3206: }
                   3207: # end func_convert_path_check
                   3208: 
                   3209: 
                   3210: # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
                   3211: # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
                   3212: # and appending REPL if ORIG matches BACKPAT.
                   3213: func_convert_path_front_back_pathsep ()
                   3214: {
1.7     ! moko     3215:   $debug_cmd
        !          3216: 
1.6       moko     3217:   case $4 in
1.7     ! moko     3218:   $1 ) func_to_host_path_result=$3$func_to_host_path_result
1.6       moko     3219:     ;;
                   3220:   esac
                   3221:   case $4 in
                   3222:   $2 ) func_append func_to_host_path_result "$3"
                   3223:     ;;
                   3224:   esac
                   3225: }
                   3226: # end func_convert_path_front_back_pathsep
                   3227: 
                   3228: 
1.7     ! moko     3229: # func_convert_delimited_path PATH ORIG_DELIMITER NEW_DELIMITER
        !          3230: # Replaces a delimiter for a given path.
        !          3231: func_convert_delimited_path ()
        !          3232: {
        !          3233:        converted_path=`$ECHO "$1" | $SED "s#$2#$3#g"`
        !          3234: }
        !          3235: # end func_convert_delimited_path
        !          3236: 
        !          3237: 
1.6       moko     3238: ##################################################
                   3239: # $build to $host FILE NAME CONVERSION FUNCTIONS #
                   3240: ##################################################
1.7     ! moko     3241: # invoked via '$to_host_file_cmd ARG'
1.6       moko     3242: #
                   3243: # In each case, ARG is the path to be converted from $build to $host format.
                   3244: # Result will be available in $func_to_host_file_result.
                   3245: 
                   3246: 
                   3247: # func_to_host_file ARG
                   3248: # Converts the file name ARG from $build format to $host format. Return result
                   3249: # in func_to_host_file_result.
                   3250: func_to_host_file ()
                   3251: {
1.7     ! moko     3252:   $debug_cmd
        !          3253: 
1.6       moko     3254:   $to_host_file_cmd "$1"
                   3255: }
                   3256: # end func_to_host_file
                   3257: 
                   3258: 
                   3259: # func_to_tool_file ARG LAZY
                   3260: # converts the file name ARG from $build format to toolchain format. Return
                   3261: # result in func_to_tool_file_result.  If the conversion in use is listed
                   3262: # in (the comma separated) LAZY, no conversion takes place.
                   3263: func_to_tool_file ()
                   3264: {
1.7     ! moko     3265:   $debug_cmd
        !          3266: 
1.6       moko     3267:   case ,$2, in
                   3268:     *,"$to_tool_file_cmd",*)
                   3269:       func_to_tool_file_result=$1
                   3270:       ;;
                   3271:     *)
                   3272:       $to_tool_file_cmd "$1"
                   3273:       func_to_tool_file_result=$func_to_host_file_result
                   3274:       ;;
                   3275:   esac
                   3276: }
                   3277: # end func_to_tool_file
                   3278: 
                   3279: 
                   3280: # func_convert_file_noop ARG
                   3281: # Copy ARG to func_to_host_file_result.
                   3282: func_convert_file_noop ()
                   3283: {
1.7     ! moko     3284:   func_to_host_file_result=$1
1.6       moko     3285: }
                   3286: # end func_convert_file_noop
                   3287: 
                   3288: 
                   3289: # func_convert_file_msys_to_w32 ARG
                   3290: # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
                   3291: # conversion to w32 is not available inside the cwrapper.  Returns result in
                   3292: # func_to_host_file_result.
                   3293: func_convert_file_msys_to_w32 ()
                   3294: {
1.7     ! moko     3295:   $debug_cmd
        !          3296: 
        !          3297:   func_to_host_file_result=$1
1.6       moko     3298:   if test -n "$1"; then
                   3299:     func_convert_core_msys_to_w32 "$1"
1.7     ! moko     3300:     func_to_host_file_result=$func_convert_core_msys_to_w32_result
1.6       moko     3301:   fi
                   3302:   func_convert_file_check "$1" "$func_to_host_file_result"
                   3303: }
                   3304: # end func_convert_file_msys_to_w32
                   3305: 
                   3306: 
                   3307: # func_convert_file_cygwin_to_w32 ARG
                   3308: # Convert file name ARG from Cygwin to w32 format.  Returns result in
                   3309: # func_to_host_file_result.
                   3310: func_convert_file_cygwin_to_w32 ()
                   3311: {
1.7     ! moko     3312:   $debug_cmd
        !          3313: 
        !          3314:   func_to_host_file_result=$1
1.6       moko     3315:   if test -n "$1"; then
                   3316:     # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
                   3317:     # LT_CYGPATH in this case.
                   3318:     func_to_host_file_result=`cygpath -m "$1"`
                   3319:   fi
                   3320:   func_convert_file_check "$1" "$func_to_host_file_result"
                   3321: }
                   3322: # end func_convert_file_cygwin_to_w32
                   3323: 
                   3324: 
                   3325: # func_convert_file_nix_to_w32 ARG
                   3326: # Convert file name ARG from *nix to w32 format.  Requires a wine environment
                   3327: # and a working winepath. Returns result in func_to_host_file_result.
                   3328: func_convert_file_nix_to_w32 ()
                   3329: {
1.7     ! moko     3330:   $debug_cmd
        !          3331: 
        !          3332:   func_to_host_file_result=$1
1.6       moko     3333:   if test -n "$1"; then
                   3334:     func_convert_core_file_wine_to_w32 "$1"
1.7     ! moko     3335:     func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
1.6       moko     3336:   fi
                   3337:   func_convert_file_check "$1" "$func_to_host_file_result"
                   3338: }
                   3339: # end func_convert_file_nix_to_w32
                   3340: 
                   3341: 
                   3342: # func_convert_file_msys_to_cygwin ARG
                   3343: # Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
                   3344: # Returns result in func_to_host_file_result.
                   3345: func_convert_file_msys_to_cygwin ()
                   3346: {
1.7     ! moko     3347:   $debug_cmd
        !          3348: 
        !          3349:   func_to_host_file_result=$1
1.6       moko     3350:   if test -n "$1"; then
                   3351:     func_convert_core_msys_to_w32 "$1"
                   3352:     func_cygpath -u "$func_convert_core_msys_to_w32_result"
1.7     ! moko     3353:     func_to_host_file_result=$func_cygpath_result
1.6       moko     3354:   fi
                   3355:   func_convert_file_check "$1" "$func_to_host_file_result"
                   3356: }
                   3357: # end func_convert_file_msys_to_cygwin
                   3358: 
                   3359: 
                   3360: # func_convert_file_nix_to_cygwin ARG
                   3361: # Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
                   3362: # in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
                   3363: # in func_to_host_file_result.
                   3364: func_convert_file_nix_to_cygwin ()
                   3365: {
1.7     ! moko     3366:   $debug_cmd
        !          3367: 
        !          3368:   func_to_host_file_result=$1
1.6       moko     3369:   if test -n "$1"; then
                   3370:     # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
                   3371:     func_convert_core_file_wine_to_w32 "$1"
                   3372:     func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
1.7     ! moko     3373:     func_to_host_file_result=$func_cygpath_result
1.6       moko     3374:   fi
                   3375:   func_convert_file_check "$1" "$func_to_host_file_result"
                   3376: }
                   3377: # end func_convert_file_nix_to_cygwin
                   3378: 
                   3379: 
                   3380: #############################################
                   3381: # $build to $host PATH CONVERSION FUNCTIONS #
                   3382: #############################################
1.7     ! moko     3383: # invoked via '$to_host_path_cmd ARG'
1.6       moko     3384: #
                   3385: # In each case, ARG is the path to be converted from $build to $host format.
                   3386: # The result will be available in $func_to_host_path_result.
                   3387: #
                   3388: # Path separators are also converted from $build format to $host format.  If
                   3389: # ARG begins or ends with a path separator character, it is preserved (but
                   3390: # converted to $host format) on output.
                   3391: #
                   3392: # All path conversion functions are named using the following convention:
                   3393: #   file name conversion function    : func_convert_file_X_to_Y ()
                   3394: #   path conversion function         : func_convert_path_X_to_Y ()
                   3395: # where, for any given $build/$host combination the 'X_to_Y' value is the
                   3396: # same.  If conversion functions are added for new $build/$host combinations,
                   3397: # the two new functions must follow this pattern, or func_init_to_host_path_cmd
                   3398: # will break.
                   3399: 
                   3400: 
                   3401: # func_init_to_host_path_cmd
                   3402: # Ensures that function "pointer" variable $to_host_path_cmd is set to the
                   3403: # appropriate value, based on the value of $to_host_file_cmd.
                   3404: to_host_path_cmd=
                   3405: func_init_to_host_path_cmd ()
                   3406: {
1.7     ! moko     3407:   $debug_cmd
        !          3408: 
1.6       moko     3409:   if test -z "$to_host_path_cmd"; then
                   3410:     func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
1.7     ! moko     3411:     to_host_path_cmd=func_convert_path_$func_stripname_result
1.6       moko     3412:   fi
                   3413: }
                   3414: 
                   3415: 
                   3416: # func_to_host_path ARG
                   3417: # Converts the path ARG from $build format to $host format. Return result
                   3418: # in func_to_host_path_result.
                   3419: func_to_host_path ()
                   3420: {
1.7     ! moko     3421:   $debug_cmd
        !          3422: 
1.6       moko     3423:   func_init_to_host_path_cmd
                   3424:   $to_host_path_cmd "$1"
                   3425: }
                   3426: # end func_to_host_path
                   3427: 
                   3428: 
                   3429: # func_convert_path_noop ARG
                   3430: # Copy ARG to func_to_host_path_result.
                   3431: func_convert_path_noop ()
                   3432: {
1.7     ! moko     3433:   func_to_host_path_result=$1
1.6       moko     3434: }
                   3435: # end func_convert_path_noop
                   3436: 
                   3437: 
                   3438: # func_convert_path_msys_to_w32 ARG
                   3439: # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
                   3440: # conversion to w32 is not available inside the cwrapper.  Returns result in
                   3441: # func_to_host_path_result.
                   3442: func_convert_path_msys_to_w32 ()
                   3443: {
1.7     ! moko     3444:   $debug_cmd
        !          3445: 
        !          3446:   func_to_host_path_result=$1
1.6       moko     3447:   if test -n "$1"; then
                   3448:     # Remove leading and trailing path separator characters from ARG.  MSYS
                   3449:     # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
                   3450:     # and winepath ignores them completely.
                   3451:     func_stripname : : "$1"
                   3452:     func_to_host_path_tmp1=$func_stripname_result
                   3453:     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
1.7     ! moko     3454:     func_to_host_path_result=$func_convert_core_msys_to_w32_result
1.6       moko     3455:     func_convert_path_check : ";" \
                   3456:       "$func_to_host_path_tmp1" "$func_to_host_path_result"
                   3457:     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
                   3458:   fi
                   3459: }
                   3460: # end func_convert_path_msys_to_w32
                   3461: 
                   3462: 
                   3463: # func_convert_path_cygwin_to_w32 ARG
                   3464: # Convert path ARG from Cygwin to w32 format.  Returns result in
                   3465: # func_to_host_file_result.
                   3466: func_convert_path_cygwin_to_w32 ()
                   3467: {
1.7     ! moko     3468:   $debug_cmd
        !          3469: 
        !          3470:   func_to_host_path_result=$1
1.6       moko     3471:   if test -n "$1"; then
                   3472:     # See func_convert_path_msys_to_w32:
                   3473:     func_stripname : : "$1"
                   3474:     func_to_host_path_tmp1=$func_stripname_result
                   3475:     func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
                   3476:     func_convert_path_check : ";" \
                   3477:       "$func_to_host_path_tmp1" "$func_to_host_path_result"
                   3478:     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
                   3479:   fi
                   3480: }
                   3481: # end func_convert_path_cygwin_to_w32
                   3482: 
                   3483: 
                   3484: # func_convert_path_nix_to_w32 ARG
                   3485: # Convert path ARG from *nix to w32 format.  Requires a wine environment and
                   3486: # a working winepath.  Returns result in func_to_host_file_result.
                   3487: func_convert_path_nix_to_w32 ()
                   3488: {
1.7     ! moko     3489:   $debug_cmd
        !          3490: 
        !          3491:   func_to_host_path_result=$1
1.6       moko     3492:   if test -n "$1"; then
                   3493:     # See func_convert_path_msys_to_w32:
                   3494:     func_stripname : : "$1"
                   3495:     func_to_host_path_tmp1=$func_stripname_result
                   3496:     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
1.7     ! moko     3497:     func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
1.6       moko     3498:     func_convert_path_check : ";" \
                   3499:       "$func_to_host_path_tmp1" "$func_to_host_path_result"
                   3500:     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
                   3501:   fi
                   3502: }
                   3503: # end func_convert_path_nix_to_w32
                   3504: 
1.5       paf      3505: 
1.6       moko     3506: # func_convert_path_msys_to_cygwin ARG
                   3507: # Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
                   3508: # Returns result in func_to_host_file_result.
                   3509: func_convert_path_msys_to_cygwin ()
                   3510: {
1.7     ! moko     3511:   $debug_cmd
        !          3512: 
        !          3513:   func_to_host_path_result=$1
1.6       moko     3514:   if test -n "$1"; then
                   3515:     # See func_convert_path_msys_to_w32:
                   3516:     func_stripname : : "$1"
                   3517:     func_to_host_path_tmp1=$func_stripname_result
                   3518:     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
                   3519:     func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
1.7     ! moko     3520:     func_to_host_path_result=$func_cygpath_result
1.6       moko     3521:     func_convert_path_check : : \
                   3522:       "$func_to_host_path_tmp1" "$func_to_host_path_result"
                   3523:     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
                   3524:   fi
                   3525: }
                   3526: # end func_convert_path_msys_to_cygwin
1.5       paf      3527: 
                   3528: 
1.6       moko     3529: # func_convert_path_nix_to_cygwin ARG
                   3530: # Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
                   3531: # a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
                   3532: # func_to_host_file_result.
                   3533: func_convert_path_nix_to_cygwin ()
                   3534: {
1.7     ! moko     3535:   $debug_cmd
        !          3536: 
        !          3537:   func_to_host_path_result=$1
1.6       moko     3538:   if test -n "$1"; then
                   3539:     # Remove leading and trailing path separator characters from
                   3540:     # ARG. msys behavior is inconsistent here, cygpath turns them
                   3541:     # into '.;' and ';.', and winepath ignores them completely.
                   3542:     func_stripname : : "$1"
                   3543:     func_to_host_path_tmp1=$func_stripname_result
                   3544:     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
                   3545:     func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
1.7     ! moko     3546:     func_to_host_path_result=$func_cygpath_result
1.6       moko     3547:     func_convert_path_check : : \
                   3548:       "$func_to_host_path_tmp1" "$func_to_host_path_result"
                   3549:     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
                   3550:   fi
                   3551: }
                   3552: # end func_convert_path_nix_to_cygwin
1.5       paf      3553: 
                   3554: 
1.7     ! moko     3555: # func_dll_def_p FILE
        !          3556: # True iff FILE is a Windows DLL '.def' file.
        !          3557: # Keep in sync with _LT_DLL_DEF_P in libtool.m4
        !          3558: func_dll_def_p ()
        !          3559: {
        !          3560:   $debug_cmd
        !          3561: 
        !          3562:   func_dll_def_p_tmp=`$SED -n \
        !          3563:     -e 's/^[    ]*//' \
        !          3564:     -e '/^\(;.*\)*$/d' \
        !          3565:     -e 's/^\(EXPORTS\|LIBRARY\)\([      ].*\)*$/DEF/p' \
        !          3566:     -e q \
        !          3567:     "$1"`
        !          3568:   test DEF = "$func_dll_def_p_tmp"
        !          3569: }
        !          3570: 
        !          3571: 
        !          3572: # func_reorder_shared_lib_cache DIRS
        !          3573: # Reorder the shared library cache by unconfiguring previous shared library cache
        !          3574: # and configuring preferred search directories before previous search directories.
        !          3575: # Previous shared library cache: /usr/lib /usr/local/lib
        !          3576: # Preferred search directories: /tmp/testing
        !          3577: # Reordered shared library cache: /tmp/testing /usr/lib /usr/local/lib
        !          3578: func_reorder_shared_lib_cache ()
        !          3579: {
        !          3580:        $debug_cmd
        !          3581: 
        !          3582:        case $host_os in
        !          3583:          openbsd*)
        !          3584:            get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"`
        !          3585:            func_convert_delimited_path "$get_search_directories" ':' '\ '
        !          3586:            save_search_directories=$converted_path
        !          3587:            func_convert_delimited_path "$1" ':' '\ '
        !          3588: 
        !          3589:            # Ensure directories exist
        !          3590:            for dir in $converted_path; do
        !          3591:              # Ensure each directory is an absolute path
        !          3592:              case $dir in
        !          3593:                /*) ;;
        !          3594:                *) func_error "Directory '$dir' is not an absolute path"
        !          3595:                   exit $EXIT_FAILURE ;;
        !          3596:              esac
        !          3597:              # Ensure no trailing slashes
        !          3598:              func_stripname '' '/' "$dir"
        !          3599:              dir=$func_stripname_result
        !          3600:              if test -d "$dir"; then
        !          3601:                if test -n "$preferred_search_directories"; then
        !          3602:                  preferred_search_directories="$preferred_search_directories $dir"
        !          3603:                else
        !          3604:                  preferred_search_directories=$dir
        !          3605:                fi
        !          3606:              else
        !          3607:                func_error "Directory '$dir' does not exist"
        !          3608:                exit $EXIT_FAILURE
        !          3609:              fi
        !          3610:            done
        !          3611: 
        !          3612:            PATH="$PATH:/sbin" ldconfig -U $save_search_directories
        !          3613:            PATH="$PATH:/sbin" ldconfig -m $preferred_search_directories $save_search_directories
        !          3614:            get_search_directories=`PATH="$PATH:/sbin" ldconfig -r | $GREP "search directories" | $SED "s#.*search directories:\ ##g"`
        !          3615:            func_convert_delimited_path "$get_search_directories" ':' '\ '
        !          3616:            reordered_search_directories=$converted_path
        !          3617: 
        !          3618:            $ECHO "Original: $save_search_directories"
        !          3619:            $ECHO "Reordered: $reordered_search_directories"
        !          3620:            exit $EXIT_SUCCESS
        !          3621:          ;;
        !          3622:          *)
        !          3623:            func_error "--reorder-cache is not supported for host_os=$host_os."
        !          3624:            exit $EXIT_FAILURE
        !          3625:          ;;
        !          3626:        esac
        !          3627: }
        !          3628: # end func_reorder_shared_lib_cache
        !          3629: 
        !          3630: 
1.6       moko     3631: # func_mode_compile arg...
                   3632: func_mode_compile ()
                   3633: {
1.7     ! moko     3634:     $debug_cmd
        !          3635: 
1.6       moko     3636:     # Get the compilation command and the source file.
                   3637:     base_compile=
1.7     ! moko     3638:     srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
1.6       moko     3639:     suppress_opt=yes
                   3640:     suppress_output=
                   3641:     arg_mode=normal
                   3642:     libobj=
                   3643:     later=
                   3644:     pie_flag=
1.5       paf      3645: 
1.6       moko     3646:     for arg
                   3647:     do
                   3648:       case $arg_mode in
                   3649:       arg  )
                   3650:        # do not "continue".  Instead, add this to base_compile
1.7     ! moko     3651:        lastarg=$arg
1.6       moko     3652:        arg_mode=normal
1.5       paf      3653:        ;;
                   3654: 
1.6       moko     3655:       target )
1.7     ! moko     3656:        libobj=$arg
1.6       moko     3657:        arg_mode=normal
1.5       paf      3658:        continue
                   3659:        ;;
                   3660: 
1.6       moko     3661:       normal )
                   3662:        # Accept any command-line options.
1.5       paf      3663:        case $arg in
1.6       moko     3664:        -o)
                   3665:          test -n "$libobj" && \
1.7     ! moko     3666:            func_fatal_error "you cannot specify '-o' more than once"
1.6       moko     3667:          arg_mode=target
                   3668:          continue
                   3669:          ;;
                   3670: 
                   3671:        -pie | -fpie | -fPIE)
                   3672:           func_append pie_flag " $arg"
                   3673:          continue
                   3674:          ;;
                   3675: 
                   3676:        -shared | -static | -prefer-pic | -prefer-non-pic)
                   3677:          func_append later " $arg"
                   3678:          continue
                   3679:          ;;
                   3680: 
                   3681:        -no-suppress)
                   3682:          suppress_opt=no
                   3683:          continue
                   3684:          ;;
                   3685: 
                   3686:        -Xcompiler)
                   3687:          arg_mode=arg  #  the next one goes into the "base_compile" arg list
                   3688:          continue      #  The current "srcfile" will either be retained or
                   3689:          ;;            #  replaced later.  I would guess that would be a bug.
                   3690: 
                   3691:        -Wc,*)
                   3692:          func_stripname '-Wc,' '' "$arg"
                   3693:          args=$func_stripname_result
                   3694:          lastarg=
1.7     ! moko     3695:          save_ifs=$IFS; IFS=,
1.6       moko     3696:          for arg in $args; do
1.7     ! moko     3697:            IFS=$save_ifs
1.6       moko     3698:            func_append_quoted lastarg "$arg"
                   3699:          done
1.7     ! moko     3700:          IFS=$save_ifs
1.6       moko     3701:          func_stripname ' ' '' "$lastarg"
                   3702:          lastarg=$func_stripname_result
                   3703: 
                   3704:          # Add the arguments to base_compile.
                   3705:          func_append base_compile " $lastarg"
                   3706:          continue
1.5       paf      3707:          ;;
1.6       moko     3708: 
                   3709:        *)
                   3710:          # Accept the current argument as the source file.
                   3711:          # The previous "srcfile" becomes the current argument.
                   3712:          #
1.7     ! moko     3713:          lastarg=$srcfile
        !          3714:          srcfile=$arg
1.6       moko     3715:          ;;
                   3716:        esac  #  case $arg
1.5       paf      3717:        ;;
1.6       moko     3718:       esac    #  case $arg_mode
                   3719: 
                   3720:       # Aesthetically quote the previous argument.
                   3721:       func_append_quoted base_compile "$lastarg"
                   3722:     done # for arg
                   3723: 
                   3724:     case $arg_mode in
                   3725:     arg)
                   3726:       func_fatal_error "you must specify an argument for -Xcompile"
                   3727:       ;;
                   3728:     target)
1.7     ! moko     3729:       func_fatal_error "you must specify a target with '-o'"
1.6       moko     3730:       ;;
                   3731:     *)
                   3732:       # Get the name of the library object.
                   3733:       test -z "$libobj" && {
                   3734:        func_basename "$srcfile"
1.7     ! moko     3735:        libobj=$func_basename_result
1.6       moko     3736:       }
                   3737:       ;;
                   3738:     esac
                   3739: 
                   3740:     # Recognize several different file suffixes.
                   3741:     # If the user specifies -o file.o, it is replaced with file.lo
                   3742:     case $libobj in
                   3743:     *.[cCFSifmso] | \
                   3744:     *.ada | *.adb | *.ads | *.asm | \
                   3745:     *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
                   3746:     *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
                   3747:       func_xform "$libobj"
                   3748:       libobj=$func_xform_result
                   3749:       ;;
                   3750:     esac
                   3751: 
                   3752:     case $libobj in
                   3753:     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
                   3754:     *)
1.7     ! moko     3755:       func_fatal_error "cannot determine name of library object from '$libobj'"
1.6       moko     3756:       ;;
                   3757:     esac
1.5       paf      3758: 
1.6       moko     3759:     func_infer_tag $base_compile
1.5       paf      3760: 
1.6       moko     3761:     for arg in $later; do
                   3762:       case $arg in
                   3763:       -shared)
1.7     ! moko     3764:        test yes = "$build_libtool_libs" \
        !          3765:          || func_fatal_configuration "cannot build a shared library"
1.6       moko     3766:        build_old_libs=no
                   3767:        continue
1.5       paf      3768:        ;;
                   3769: 
1.6       moko     3770:       -static)
                   3771:        build_libtool_libs=no
                   3772:        build_old_libs=yes
1.5       paf      3773:        continue
                   3774:        ;;
                   3775: 
1.6       moko     3776:       -prefer-pic)
                   3777:        pic_mode=yes
                   3778:        continue
                   3779:        ;;
1.5       paf      3780: 
1.6       moko     3781:       -prefer-non-pic)
                   3782:        pic_mode=no
1.5       paf      3783:        continue
                   3784:        ;;
1.6       moko     3785:       esac
                   3786:     done
1.5       paf      3787: 
1.7     ! moko     3788:     func_quote_arg pretty "$libobj"
        !          3789:     test "X$libobj" != "X$func_quote_arg_result" \
1.6       moko     3790:       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'   &()|`$[]' \
1.7     ! moko     3791:       && func_warning "libobj name '$libobj' may not contain shell special characters."
1.6       moko     3792:     func_dirname_and_basename "$obj" "/" ""
1.7     ! moko     3793:     objname=$func_basename_result
        !          3794:     xdir=$func_dirname_result
        !          3795:     lobj=$xdir$objdir/$objname
1.5       paf      3796: 
1.6       moko     3797:     test -z "$base_compile" && \
                   3798:       func_fatal_help "you must specify a compilation command"
1.5       paf      3799: 
1.6       moko     3800:     # Delete any leftover library objects.
1.7     ! moko     3801:     if test yes = "$build_old_libs"; then
1.6       moko     3802:       removelist="$obj $lobj $libobj ${libobj}T"
                   3803:     else
                   3804:       removelist="$lobj $libobj ${libobj}T"
1.5       paf      3805:     fi
                   3806: 
1.6       moko     3807:     # On Cygwin there's no "real" PIC flag so we must build both object types
                   3808:     case $host_os in
1.7     ! moko     3809:     cygwin* | mingw* | windows* | pw32* | os2* | cegcc*)
1.6       moko     3810:       pic_mode=default
                   3811:       ;;
                   3812:     esac
1.7     ! moko     3813:     if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
1.6       moko     3814:       # non-PIC code in shared libraries is not supported
                   3815:       pic_mode=default
1.5       paf      3816:     fi
                   3817: 
1.6       moko     3818:     # Calculate the filename of the output object if compiler does
                   3819:     # not support -o with -c
1.7     ! moko     3820:     if test no = "$compiler_c_o"; then
        !          3821:       output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
        !          3822:       lockfile=$output_obj.lock
1.5       paf      3823:     else
1.6       moko     3824:       output_obj=
                   3825:       need_locks=no
                   3826:       lockfile=
1.5       paf      3827:     fi
                   3828: 
1.6       moko     3829:     # Lock this critical section if it is needed
                   3830:     # We use this script file to make the link, it avoids creating a new file
1.7     ! moko     3831:     if test yes = "$need_locks"; then
1.6       moko     3832:       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
                   3833:        func_echo "Waiting for $lockfile to be removed"
                   3834:        sleep 2
                   3835:       done
1.7     ! moko     3836:     elif test warn = "$need_locks"; then
1.6       moko     3837:       if test -f "$lockfile"; then
                   3838:        $ECHO "\
                   3839: *** ERROR, $lockfile exists and contains:
                   3840: `cat $lockfile 2>/dev/null`
                   3841: 
                   3842: This indicates that another process is trying to use the same
                   3843: temporary object file, and libtool could not work around it because
1.7     ! moko     3844: your compiler does not support '-c' and '-o' together.  If you
1.6       moko     3845: repeat this compilation, it may succeed, by chance, but you had better
                   3846: avoid parallel builds (make -j) in this platform, or get a better
                   3847: compiler."
                   3848: 
                   3849:        $opt_dry_run || $RM $removelist
                   3850:        exit $EXIT_FAILURE
1.5       paf      3851:       fi
1.6       moko     3852:       func_append removelist " $output_obj"
                   3853:       $ECHO "$srcfile" > "$lockfile"
1.5       paf      3854:     fi
                   3855: 
1.6       moko     3856:     $opt_dry_run || $RM $removelist
                   3857:     func_append removelist " $lockfile"
                   3858:     trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
                   3859: 
                   3860:     func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
                   3861:     srcfile=$func_to_tool_file_result
1.7     ! moko     3862:     func_quote_arg pretty "$srcfile"
        !          3863:     qsrcfile=$func_quote_arg_result
1.6       moko     3864: 
                   3865:     # Only build a PIC object if we are building libtool libraries.
1.7     ! moko     3866:     if test yes = "$build_libtool_libs"; then
1.6       moko     3867:       # Without this assignment, base_compile gets emptied.
                   3868:       fbsd_hideous_sh_bug=$base_compile
1.5       paf      3869: 
1.7     ! moko     3870:       if test no != "$pic_mode"; then
1.6       moko     3871:        command="$base_compile $qsrcfile $pic_flag"
                   3872:       else
                   3873:        # Don't build PIC code
                   3874:        command="$base_compile $qsrcfile"
1.5       paf      3875:       fi
1.6       moko     3876: 
                   3877:       func_mkdir_p "$xdir$objdir"
                   3878: 
                   3879:       if test -z "$output_obj"; then
                   3880:        # Place PIC objects in $objdir
                   3881:        func_append command " -o $lobj"
1.5       paf      3882:       fi
                   3883: 
1.6       moko     3884:       func_show_eval_locale "$command" \
                   3885:           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1.5       paf      3886: 
1.7     ! moko     3887:       if test warn = "$need_locks" &&
1.6       moko     3888:         test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
                   3889:        $ECHO "\
                   3890: *** ERROR, $lockfile contains:
                   3891: `cat $lockfile 2>/dev/null`
1.5       paf      3892: 
1.6       moko     3893: but it should contain:
                   3894: $srcfile
1.5       paf      3895: 
1.6       moko     3896: This indicates that another process is trying to use the same
                   3897: temporary object file, and libtool could not work around it because
1.7     ! moko     3898: your compiler does not support '-c' and '-o' together.  If you
1.6       moko     3899: repeat this compilation, it may succeed, by chance, but you had better
                   3900: avoid parallel builds (make -j) in this platform, or get a better
                   3901: compiler."
1.5       paf      3902: 
1.6       moko     3903:        $opt_dry_run || $RM $removelist
                   3904:        exit $EXIT_FAILURE
                   3905:       fi
1.5       paf      3906: 
1.6       moko     3907:       # Just move the object if needed, then go on to compile the next one
                   3908:       if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
                   3909:        func_show_eval '$MV "$output_obj" "$lobj"' \
                   3910:          'error=$?; $opt_dry_run || $RM $removelist; exit $error'
                   3911:       fi
1.5       paf      3912: 
1.6       moko     3913:       # Allow error messages only from the first compilation.
1.7     ! moko     3914:       if test yes = "$suppress_opt"; then
1.6       moko     3915:        suppress_output=' >/dev/null 2>&1'
                   3916:       fi
                   3917:     fi
1.5       paf      3918: 
1.6       moko     3919:     # Only build a position-dependent object if we build old libraries.
1.7     ! moko     3920:     if test yes = "$build_old_libs"; then
        !          3921:       if test yes != "$pic_mode"; then
1.6       moko     3922:        # Don't build PIC code
                   3923:        command="$base_compile $qsrcfile$pie_flag"
                   3924:       else
                   3925:        command="$base_compile $qsrcfile $pic_flag"
                   3926:       fi
1.7     ! moko     3927:       if test yes = "$compiler_c_o"; then
1.6       moko     3928:        func_append command " -o $obj"
                   3929:       fi
1.5       paf      3930: 
1.6       moko     3931:       # Suppress compiler output if we already did a PIC compilation.
                   3932:       func_append command "$suppress_output"
                   3933:       func_show_eval_locale "$command" \
                   3934:         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1.5       paf      3935: 
1.7     ! moko     3936:       if test warn = "$need_locks" &&
1.6       moko     3937:         test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
                   3938:        $ECHO "\
                   3939: *** ERROR, $lockfile contains:
                   3940: `cat $lockfile 2>/dev/null`
                   3941: 
                   3942: but it should contain:
                   3943: $srcfile
                   3944: 
                   3945: This indicates that another process is trying to use the same
                   3946: temporary object file, and libtool could not work around it because
1.7     ! moko     3947: your compiler does not support '-c' and '-o' together.  If you
1.6       moko     3948: repeat this compilation, it may succeed, by chance, but you had better
                   3949: avoid parallel builds (make -j) in this platform, or get a better
                   3950: compiler."
                   3951: 
                   3952:        $opt_dry_run || $RM $removelist
                   3953:        exit $EXIT_FAILURE
                   3954:       fi
                   3955: 
                   3956:       # Just move the object if needed
                   3957:       if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
                   3958:        func_show_eval '$MV "$output_obj" "$obj"' \
                   3959:          'error=$?; $opt_dry_run || $RM $removelist; exit $error'
                   3960:       fi
                   3961:     fi
1.5       paf      3962: 
1.6       moko     3963:     $opt_dry_run || {
                   3964:       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1.5       paf      3965: 
1.6       moko     3966:       # Unlock the critical section if it was locked
1.7     ! moko     3967:       if test no != "$need_locks"; then
1.6       moko     3968:        removelist=$lockfile
                   3969:         $RM "$lockfile"
                   3970:       fi
                   3971:     }
1.5       paf      3972: 
1.6       moko     3973:     exit $EXIT_SUCCESS
                   3974: }
1.5       paf      3975: 
1.6       moko     3976: $opt_help || {
1.7     ! moko     3977:   test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
1.6       moko     3978: }
1.5       paf      3979: 
1.6       moko     3980: func_mode_help ()
                   3981: {
                   3982:     # We need to display help for each of the modes.
                   3983:     case $opt_mode in
                   3984:       "")
                   3985:         # Generic help is extracted from the usage comments
                   3986:         # at the start of this file.
                   3987:         func_help
                   3988:         ;;
                   3989: 
                   3990:       clean)
                   3991:         $ECHO \
                   3992: "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1.5       paf      3993: 
1.6       moko     3994: Remove files from the build directory.
1.5       paf      3995: 
1.6       moko     3996: RM is the name of the program to use to delete files associated with each FILE
1.7     ! moko     3997: (typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
1.6       moko     3998: to RM.
1.5       paf      3999: 
1.6       moko     4000: If FILE is a libtool library, object or program, all the files associated
                   4001: with it are deleted. Otherwise, only FILE itself is deleted using RM."
                   4002:         ;;
1.5       paf      4003: 
1.6       moko     4004:       compile)
                   4005:       $ECHO \
                   4006: "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1.5       paf      4007: 
1.6       moko     4008: Compile a source file into a libtool library object.
1.5       paf      4009: 
1.6       moko     4010: This mode accepts the following additional options:
1.5       paf      4011: 
1.6       moko     4012:   -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
                   4013:   -no-suppress      do not suppress compiler output for multiple passes
                   4014:   -prefer-pic       try to build PIC objects only
                   4015:   -prefer-non-pic   try to build non-PIC objects only
1.7     ! moko     4016:   -shared           do not build a '.o' file suitable for static linking
        !          4017:   -static           only build a '.o' file suitable for static linking
        !          4018:   -Wc,FLAG
        !          4019:   -Xcompiler FLAG   pass FLAG directly to the compiler
1.5       paf      4020: 
1.7     ! moko     4021: COMPILE-COMMAND is a command to be used in creating a 'standard' object file
1.6       moko     4022: from the given SOURCEFILE.
1.5       paf      4023: 
1.6       moko     4024: The output file name is determined by removing the directory component from
1.7     ! moko     4025: SOURCEFILE, then substituting the C source code suffix '.c' with the
        !          4026: library object suffix, '.lo'."
1.6       moko     4027:         ;;
1.5       paf      4028: 
1.6       moko     4029:       execute)
                   4030:         $ECHO \
                   4031: "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1.5       paf      4032: 
1.6       moko     4033: Automatically set library path, then run a program.
1.5       paf      4034: 
1.6       moko     4035: This mode accepts the following additional options:
1.5       paf      4036: 
1.6       moko     4037:   -dlopen FILE      add the directory containing FILE to the library path
1.5       paf      4038: 
1.7     ! moko     4039: This mode sets the library path environment variable according to '-dlopen'
1.6       moko     4040: flags.
1.5       paf      4041: 
1.6       moko     4042: If any of the ARGS are libtool executable wrappers, then they are translated
                   4043: into their corresponding uninstalled binary, and any of their required library
                   4044: directories are added to the library path.
                   4045: 
                   4046: Then, COMMAND is executed, with ARGS as arguments."
                   4047:         ;;
1.5       paf      4048: 
1.6       moko     4049:       finish)
                   4050:         $ECHO \
                   4051: "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1.5       paf      4052: 
1.6       moko     4053: Complete the installation of libtool libraries.
1.5       paf      4054: 
1.6       moko     4055: Each LIBDIR is a directory that contains libtool libraries.
1.5       paf      4056: 
1.6       moko     4057: The commands that this mode executes may require superuser privileges.  Use
1.7     ! moko     4058: the '--dry-run' option if you just want to see what would be executed."
1.6       moko     4059:         ;;
1.5       paf      4060: 
1.6       moko     4061:       install)
                   4062:         $ECHO \
                   4063: "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1.5       paf      4064: 
1.6       moko     4065: Install executables or libraries.
1.5       paf      4066: 
1.6       moko     4067: INSTALL-COMMAND is the installation command.  The first component should be
1.7     ! moko     4068: either the 'install' or 'cp' program.
1.5       paf      4069: 
1.6       moko     4070: The following components of INSTALL-COMMAND are treated specially:
1.5       paf      4071: 
1.6       moko     4072:   -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
1.5       paf      4073: 
1.6       moko     4074: The rest of the components are interpreted as arguments to that command (only
                   4075: BSD-compatible install options are recognized)."
                   4076:         ;;
1.5       paf      4077: 
1.6       moko     4078:       link)
                   4079:         $ECHO \
                   4080: "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1.5       paf      4081: 
1.6       moko     4082: Link object files or libraries together to form another library, or to
                   4083: create an executable program.
1.5       paf      4084: 
1.6       moko     4085: LINK-COMMAND is a command using the C compiler that you would use to create
                   4086: a program from several object files.
1.5       paf      4087: 
1.6       moko     4088: The following components of LINK-COMMAND are treated specially:
1.5       paf      4089: 
1.6       moko     4090:   -all-static       do not do any dynamic linking at all
                   4091:   -avoid-version    do not add a version suffix if possible
                   4092:   -bindir BINDIR    specify path to binaries directory (for systems where
                   4093:                     libraries must be found in the PATH setting at runtime)
1.7     ! moko     4094:   -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
1.6       moko     4095:   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
                   4096:   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
                   4097:   -export-symbols SYMFILE
                   4098:                     try to export only the symbols listed in SYMFILE
                   4099:   -export-symbols-regex REGEX
                   4100:                     try to export only the symbols matching REGEX
                   4101:   -LLIBDIR          search LIBDIR for required installed libraries
                   4102:   -lNAME            OUTPUT-FILE requires the installed library libNAME
                   4103:   -module           build a library that can dlopened
                   4104:   -no-fast-install  disable the fast-install mode
                   4105:   -no-install       link a not-installable executable
                   4106:   -no-undefined     declare that a library does not refer to external symbols
                   4107:   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
1.7     ! moko     4108:   -objectlist FILE  use a list of object files found in FILE to specify objects
        !          4109:   -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
1.6       moko     4110:   -precious-files-regex REGEX
                   4111:                     don't remove output files matching REGEX
                   4112:   -release RELEASE  specify package release information
                   4113:   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
                   4114:   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
                   4115:   -shared           only do dynamic linking of libtool libraries
                   4116:   -shrext SUFFIX    override the standard shared library file extension
                   4117:   -static           do not do any dynamic linking of uninstalled libtool libraries
                   4118:   -static-libtool-libs
                   4119:                     do not do any dynamic linking of libtool libraries
                   4120:   -version-info CURRENT[:REVISION[:AGE]]
                   4121:                     specify library version info [each variable defaults to 0]
                   4122:   -weak LIBNAME     declare that the target provides the LIBNAME interface
                   4123:   -Wc,FLAG
                   4124:   -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
1.7     ! moko     4125:   -Wa,FLAG
        !          4126:   -Xassembler FLAG  pass linker-specific FLAG directly to the assembler
1.6       moko     4127:   -Wl,FLAG
                   4128:   -Xlinker FLAG     pass linker-specific FLAG directly to the linker
                   4129:   -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
1.5       paf      4130: 
1.7     ! moko     4131: All other options (arguments beginning with '-') are ignored.
1.5       paf      4132: 
1.7     ! moko     4133: Every other argument is treated as a filename.  Files ending in '.la' are
1.6       moko     4134: treated as uninstalled libtool libraries, other files are standard or library
                   4135: object files.
1.5       paf      4136: 
1.7     ! moko     4137: If the OUTPUT-FILE ends in '.la', then a libtool library is created,
        !          4138: only library objects ('.lo' files) may be specified, and '-rpath' is
1.6       moko     4139: required, except when creating a convenience library.
1.5       paf      4140: 
1.7     ! moko     4141: If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
        !          4142: using 'ar' and 'ranlib', or on Windows using 'lib'.
1.5       paf      4143: 
1.7     ! moko     4144: If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
1.6       moko     4145: is created, otherwise an executable program is created."
                   4146:         ;;
1.5       paf      4147: 
1.6       moko     4148:       uninstall)
                   4149:         $ECHO \
                   4150: "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1.5       paf      4151: 
1.6       moko     4152: Remove libraries from an installation directory.
1.5       paf      4153: 
1.6       moko     4154: RM is the name of the program to use to delete files associated with each FILE
1.7     ! moko     4155: (typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
1.6       moko     4156: to RM.
1.5       paf      4157: 
1.6       moko     4158: If FILE is a libtool library, all the files associated with it are deleted.
                   4159: Otherwise, only FILE itself is deleted using RM."
                   4160:         ;;
1.5       paf      4161: 
1.6       moko     4162:       *)
1.7     ! moko     4163:         func_fatal_help "invalid operation mode '$opt_mode'"
1.6       moko     4164:         ;;
                   4165:     esac
1.5       paf      4166: 
1.6       moko     4167:     echo
1.7     ! moko     4168:     $ECHO "Try '$progname --help' for more information about other modes."
1.6       moko     4169: }
1.5       paf      4170: 
1.6       moko     4171: # Now that we've collected a possible --mode arg, show help if necessary
                   4172: if $opt_help; then
1.7     ! moko     4173:   if test : = "$opt_help"; then
1.6       moko     4174:     func_mode_help
                   4175:   else
                   4176:     {
                   4177:       func_help noexit
                   4178:       for opt_mode in compile link execute install finish uninstall clean; do
                   4179:        func_mode_help
                   4180:       done
1.7     ! moko     4181:     } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
1.6       moko     4182:     {
                   4183:       func_help noexit
                   4184:       for opt_mode in compile link execute install finish uninstall clean; do
                   4185:        echo
                   4186:        func_mode_help
                   4187:       done
                   4188:     } |
1.7     ! moko     4189:     $SED '1d
1.6       moko     4190:       /^When reporting/,/^Report/{
                   4191:        H
                   4192:        d
                   4193:       }
                   4194:       $x
                   4195:       /information about other modes/d
                   4196:       /more detailed .*MODE/d
                   4197:       s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
                   4198:   fi
                   4199:   exit $?
                   4200: fi
1.5       paf      4201: 
                   4202: 
1.7     ! moko     4203: # If option '--reorder-cache', reorder the shared library cache and exit.
        !          4204: if $opt_reorder_cache; then
        !          4205:     func_reorder_shared_lib_cache $shared_lib_dirs
        !          4206: fi
        !          4207: 
        !          4208: 
1.6       moko     4209: # func_mode_execute arg...
                   4210: func_mode_execute ()
                   4211: {
1.7     ! moko     4212:     $debug_cmd
        !          4213: 
1.6       moko     4214:     # The first argument is the command name.
1.7     ! moko     4215:     cmd=$nonopt
1.6       moko     4216:     test -z "$cmd" && \
                   4217:       func_fatal_help "you must specify a COMMAND"
1.5       paf      4218: 
1.6       moko     4219:     # Handle -dlopen flags immediately.
                   4220:     for file in $opt_dlopen; do
                   4221:       test -f "$file" \
1.7     ! moko     4222:        || func_fatal_help "'$file' is not a file"
1.5       paf      4223: 
1.6       moko     4224:       dir=
                   4225:       case $file in
                   4226:       *.la)
                   4227:        func_resolve_sysroot "$file"
                   4228:        file=$func_resolve_sysroot_result
1.5       paf      4229: 
1.6       moko     4230:        # Check to see that this really is a libtool archive.
                   4231:        func_lalib_unsafe_p "$file" \
1.7     ! moko     4232:          || func_fatal_help "'$lib' is not a valid libtool archive"
1.5       paf      4233: 
1.6       moko     4234:        # Read the libtool library.
                   4235:        dlname=
                   4236:        library_names=
                   4237:        func_source "$file"
1.5       paf      4238: 
1.6       moko     4239:        # Skip this library if it cannot be dlopened.
                   4240:        if test -z "$dlname"; then
                   4241:          # Warn if it was a shared library.
                   4242:          test -n "$library_names" && \
1.7     ! moko     4243:            func_warning "'$file' was not linked with '-export-dynamic'"
1.6       moko     4244:          continue
                   4245:        fi
1.5       paf      4246: 
1.6       moko     4247:        func_dirname "$file" "" "."
1.7     ! moko     4248:        dir=$func_dirname_result
1.5       paf      4249: 
1.6       moko     4250:        if test -f "$dir/$objdir/$dlname"; then
                   4251:          func_append dir "/$objdir"
                   4252:        else
                   4253:          if test ! -f "$dir/$dlname"; then
1.7     ! moko     4254:            func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
1.6       moko     4255:          fi
                   4256:        fi
                   4257:        ;;
1.5       paf      4258: 
1.6       moko     4259:       *.lo)
                   4260:        # Just add the directory containing the .lo file.
                   4261:        func_dirname "$file" "" "."
1.7     ! moko     4262:        dir=$func_dirname_result
1.6       moko     4263:        ;;
1.5       paf      4264: 
1.6       moko     4265:       *)
1.7     ! moko     4266:        func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
1.6       moko     4267:        continue
                   4268:        ;;
                   4269:       esac
1.5       paf      4270: 
1.6       moko     4271:       # Get the absolute pathname.
                   4272:       absdir=`cd "$dir" && pwd`
1.7     ! moko     4273:       test -n "$absdir" && dir=$absdir
1.5       paf      4274: 
1.6       moko     4275:       # Now add the directory to shlibpath_var.
                   4276:       if eval "test -z \"\$$shlibpath_var\""; then
                   4277:        eval "$shlibpath_var=\"\$dir\""
                   4278:       else
                   4279:        eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
                   4280:       fi
                   4281:     done
1.5       paf      4282: 
1.6       moko     4283:     # This variable tells wrapper scripts just to set shlibpath_var
                   4284:     # rather than running their programs.
1.7     ! moko     4285:     libtool_execute_magic=$magic
1.5       paf      4286: 
1.6       moko     4287:     # Check if any of the arguments is a wrapper script.
                   4288:     args=
                   4289:     for file
                   4290:     do
                   4291:       case $file in
                   4292:       -* | *.la | *.lo ) ;;
                   4293:       *)
                   4294:        # Do a test to see if this is really a libtool program.
                   4295:        if func_ltwrapper_script_p "$file"; then
                   4296:          func_source "$file"
                   4297:          # Transform arg to wrapped name.
1.7     ! moko     4298:          file=$progdir/$program
1.6       moko     4299:        elif func_ltwrapper_executable_p "$file"; then
                   4300:          func_ltwrapper_scriptname "$file"
                   4301:          func_source "$func_ltwrapper_scriptname_result"
                   4302:          # Transform arg to wrapped name.
1.7     ! moko     4303:          file=$progdir/$program
1.5       paf      4304:        fi
1.6       moko     4305:        ;;
                   4306:       esac
                   4307:       # Quote arguments (to preserve shell metacharacters).
                   4308:       func_append_quoted args "$file"
                   4309:     done
1.5       paf      4310: 
1.7     ! moko     4311:     if $opt_dry_run; then
        !          4312:       # Display what would be done.
        !          4313:       if test -n "$shlibpath_var"; then
        !          4314:        eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
        !          4315:        echo "export $shlibpath_var"
        !          4316:       fi
        !          4317:       $ECHO "$cmd$args"
        !          4318:       exit $EXIT_SUCCESS
        !          4319:     else
1.6       moko     4320:       if test -n "$shlibpath_var"; then
                   4321:        # Export the shlibpath_var.
                   4322:        eval "export $shlibpath_var"
1.5       paf      4323:       fi
                   4324: 
1.6       moko     4325:       # Restore saved environment variables
                   4326:       for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
                   4327:       do
                   4328:        eval "if test \"\${save_$lt_var+set}\" = set; then
                   4329:                 $lt_var=\$save_$lt_var; export $lt_var
                   4330:              else
                   4331:                $lt_unset $lt_var
                   4332:              fi"
                   4333:       done
                   4334: 
                   4335:       # Now prepare to actually exec the command.
1.7     ! moko     4336:       exec_cmd=\$cmd$args
1.6       moko     4337:     fi
                   4338: }
                   4339: 
1.7     ! moko     4340: test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
1.6       moko     4341: 
                   4342: 
                   4343: # func_mode_finish arg...
                   4344: func_mode_finish ()
                   4345: {
1.7     ! moko     4346:     $debug_cmd
        !          4347: 
1.6       moko     4348:     libs=
                   4349:     libdirs=
                   4350:     admincmds=
                   4351: 
                   4352:     for opt in "$nonopt" ${1+"$@"}
                   4353:     do
                   4354:       if test -d "$opt"; then
                   4355:        func_append libdirs " $opt"
1.5       paf      4356: 
1.6       moko     4357:       elif test -f "$opt"; then
                   4358:        if func_lalib_unsafe_p "$opt"; then
                   4359:          func_append libs " $opt"
                   4360:        else
1.7     ! moko     4361:          func_warning "'$opt' is not a valid libtool archive"
1.6       moko     4362:        fi
1.5       paf      4363: 
1.6       moko     4364:       else
1.7     ! moko     4365:        func_fatal_error "invalid argument '$opt'"
1.5       paf      4366:       fi
1.6       moko     4367:     done
1.5       paf      4368: 
1.6       moko     4369:     if test -n "$libs"; then
                   4370:       if test -n "$lt_sysroot"; then
                   4371:         sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
                   4372:         sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
                   4373:       else
                   4374:         sysroot_cmd=
                   4375:       fi
1.5       paf      4376: 
1.6       moko     4377:       # Remove sysroot references
                   4378:       if $opt_dry_run; then
                   4379:         for lib in $libs; do
1.7     ! moko     4380:           echo "removing references to $lt_sysroot and '=' prefixes from $lib"
1.6       moko     4381:         done
                   4382:       else
                   4383:         tmpdir=`func_mktempdir`
                   4384:         for lib in $libs; do
1.7     ! moko     4385:          $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
1.6       moko     4386:            > $tmpdir/tmp-la
                   4387:          mv -f $tmpdir/tmp-la $lib
1.5       paf      4388:        done
1.6       moko     4389:         ${RM}r "$tmpdir"
1.5       paf      4390:       fi
1.6       moko     4391:     fi
1.5       paf      4392: 
1.7     ! moko     4393:     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs" && $opt_finishing; then
1.6       moko     4394:       for libdir in $libdirs; do
                   4395:        if test -n "$finish_cmds"; then
                   4396:          # Do each command in the finish commands.
                   4397:          func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
                   4398: '"$cmd"'"'
                   4399:        fi
                   4400:        if test -n "$finish_eval"; then
                   4401:          # Do the single finish_eval.
                   4402:          eval cmds=\"$finish_eval\"
                   4403:          $opt_dry_run || eval "$cmds" || func_append admincmds "
                   4404:        $cmds"
                   4405:        fi
1.5       paf      4406:       done
1.6       moko     4407:     fi
                   4408: 
                   4409:     # Exit here if they wanted silent mode.
1.7     ! moko     4410:     $opt_quiet && exit $EXIT_SUCCESS
1.5       paf      4411: 
1.6       moko     4412:     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
                   4413:       echo "----------------------------------------------------------------------"
                   4414:       echo "Libraries have been installed in:"
                   4415:       for libdir in $libdirs; do
                   4416:        $ECHO "   $libdir"
1.5       paf      4417:       done
1.7     ! moko     4418:       if test "false" = "$opt_finishing"; then
        !          4419:         echo
        !          4420:         echo "NOTE: finish_cmds were not executed during testing, so you must"
        !          4421:         echo "manually run ldconfig to add a given test directory, LIBDIR, to"
        !          4422:         echo "the search path for generated executables."
        !          4423:       fi
1.6       moko     4424:       echo
                   4425:       echo "If you ever happen to want to link against installed libraries"
                   4426:       echo "in a given directory, LIBDIR, you must either use libtool, and"
1.7     ! moko     4427:       echo "specify the full pathname of the library, or use the '-LLIBDIR'"
1.6       moko     4428:       echo "flag during linking and do at least one of the following:"
                   4429:       if test -n "$shlibpath_var"; then
1.7     ! moko     4430:        echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
1.6       moko     4431:        echo "     during execution"
                   4432:       fi
                   4433:       if test -n "$runpath_var"; then
1.7     ! moko     4434:        echo "   - add LIBDIR to the '$runpath_var' environment variable"
1.6       moko     4435:        echo "     during linking"
                   4436:       fi
                   4437:       if test -n "$hardcode_libdir_flag_spec"; then
                   4438:        libdir=LIBDIR
                   4439:        eval flag=\"$hardcode_libdir_flag_spec\"
                   4440: 
1.7     ! moko     4441:        $ECHO "   - use the '$flag' linker flag"
1.6       moko     4442:       fi
                   4443:       if test -n "$admincmds"; then
                   4444:        $ECHO "   - have your system administrator run these commands:$admincmds"
                   4445:       fi
                   4446:       if test -f /etc/ld.so.conf; then
1.7     ! moko     4447:        echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
1.6       moko     4448:       fi
                   4449:       echo
1.5       paf      4450: 
1.6       moko     4451:       echo "See any operating system documentation about shared libraries for"
                   4452:       case $host in
                   4453:        solaris2.[6789]|solaris2.1[0-9])
                   4454:          echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
                   4455:          echo "pages."
                   4456:          ;;
                   4457:        *)
                   4458:          echo "more information, such as the ld(1) and ld.so(8) manual pages."
                   4459:          ;;
                   4460:       esac
                   4461:       echo "----------------------------------------------------------------------"
                   4462:     fi
                   4463:     exit $EXIT_SUCCESS
                   4464: }
                   4465: 
1.7     ! moko     4466: test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
1.6       moko     4467: 
                   4468: 
                   4469: # func_mode_install arg...
                   4470: func_mode_install ()
                   4471: {
1.7     ! moko     4472:     $debug_cmd
        !          4473: 
1.6       moko     4474:     # There may be an optional sh(1) argument at the beginning of
                   4475:     # install_prog (especially on Windows NT).
1.7     ! moko     4476:     if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
1.6       moko     4477:        # Allow the use of GNU shtool's install command.
1.7     ! moko     4478:        case $nonopt in *shtool*) :;; *) false;; esac
        !          4479:     then
1.6       moko     4480:       # Aesthetically quote it.
1.7     ! moko     4481:       func_quote_arg pretty "$nonopt"
        !          4482:       install_prog="$func_quote_arg_result "
1.6       moko     4483:       arg=$1
                   4484:       shift
                   4485:     else
                   4486:       install_prog=
                   4487:       arg=$nonopt
                   4488:     fi
                   4489: 
                   4490:     # The real first argument should be the name of the installation program.
                   4491:     # Aesthetically quote it.
1.7     ! moko     4492:     func_quote_arg pretty "$arg"
        !          4493:     func_append install_prog "$func_quote_arg_result"
1.6       moko     4494:     install_shared_prog=$install_prog
                   4495:     case " $install_prog " in
                   4496:       *[\\\ /]cp\ *) install_cp=: ;;
                   4497:       *) install_cp=false ;;
                   4498:     esac
                   4499: 
                   4500:     # We need to accept at least all the BSD install flags.
                   4501:     dest=
                   4502:     files=
                   4503:     opts=
                   4504:     prev=
                   4505:     install_type=
1.7     ! moko     4506:     isdir=false
1.6       moko     4507:     stripme=
                   4508:     no_mode=:
                   4509:     for arg
                   4510:     do
                   4511:       arg2=
                   4512:       if test -n "$dest"; then
                   4513:        func_append files " $dest"
                   4514:        dest=$arg
                   4515:        continue
                   4516:       fi
                   4517: 
                   4518:       case $arg in
1.7     ! moko     4519:       -d) isdir=: ;;
1.6       moko     4520:       -f)
                   4521:        if $install_cp; then :; else
                   4522:          prev=$arg
                   4523:        fi
                   4524:        ;;
                   4525:       -g | -m | -o)
                   4526:        prev=$arg
                   4527:        ;;
                   4528:       -s)
                   4529:        stripme=" -s"
                   4530:        continue
                   4531:        ;;
                   4532:       -*)
                   4533:        ;;
                   4534:       *)
                   4535:        # If the previous option needed an argument, then skip it.
                   4536:        if test -n "$prev"; then
1.7     ! moko     4537:          if test X-m = "X$prev" && test -n "$install_override_mode"; then
1.6       moko     4538:            arg2=$install_override_mode
                   4539:            no_mode=false
                   4540:          fi
                   4541:          prev=
                   4542:        else
                   4543:          dest=$arg
                   4544:          continue
                   4545:        fi
                   4546:        ;;
                   4547:       esac
                   4548: 
                   4549:       # Aesthetically quote the argument.
1.7     ! moko     4550:       func_quote_arg pretty "$arg"
        !          4551:       func_append install_prog " $func_quote_arg_result"
1.6       moko     4552:       if test -n "$arg2"; then
1.7     ! moko     4553:        func_quote_arg pretty "$arg2"
1.6       moko     4554:       fi
1.7     ! moko     4555:       func_append install_shared_prog " $func_quote_arg_result"
1.6       moko     4556:     done
                   4557: 
                   4558:     test -z "$install_prog" && \
                   4559:       func_fatal_help "you must specify an install program"
                   4560: 
                   4561:     test -n "$prev" && \
1.7     ! moko     4562:       func_fatal_help "the '$prev' option requires an argument"
1.6       moko     4563: 
                   4564:     if test -n "$install_override_mode" && $no_mode; then
                   4565:       if $install_cp; then :; else
1.7     ! moko     4566:        func_quote_arg pretty "$install_override_mode"
        !          4567:        func_append install_shared_prog " -m $func_quote_arg_result"
1.6       moko     4568:       fi
                   4569:     fi
                   4570: 
                   4571:     if test -z "$files"; then
                   4572:       if test -z "$dest"; then
                   4573:        func_fatal_help "no file or destination specified"
                   4574:       else
                   4575:        func_fatal_help "you must specify a destination"
                   4576:       fi
                   4577:     fi
                   4578: 
                   4579:     # Strip any trailing slash from the destination.
                   4580:     func_stripname '' '/' "$dest"
                   4581:     dest=$func_stripname_result
                   4582: 
                   4583:     # Check to see that the destination is a directory.
1.7     ! moko     4584:     test -d "$dest" && isdir=:
        !          4585:     if $isdir; then
        !          4586:       destdir=$dest
1.6       moko     4587:       destname=
                   4588:     else
                   4589:       func_dirname_and_basename "$dest" "" "."
1.7     ! moko     4590:       destdir=$func_dirname_result
        !          4591:       destname=$func_basename_result
1.6       moko     4592: 
                   4593:       # Not a directory, so check to see that there is only one file specified.
                   4594:       set dummy $files; shift
                   4595:       test "$#" -gt 1 && \
1.7     ! moko     4596:        func_fatal_help "'$dest' is not a directory"
1.6       moko     4597:     fi
                   4598:     case $destdir in
                   4599:     [\\/]* | [A-Za-z]:[\\/]*) ;;
                   4600:     *)
                   4601:       for file in $files; do
                   4602:        case $file in
                   4603:        *.lo) ;;
                   4604:        *)
1.7     ! moko     4605:          func_fatal_help "'$destdir' must be an absolute directory name"
1.6       moko     4606:          ;;
                   4607:        esac
                   4608:       done
                   4609:       ;;
                   4610:     esac
                   4611: 
                   4612:     # This variable tells wrapper scripts just to set variables rather
                   4613:     # than running their programs.
1.7     ! moko     4614:     libtool_install_magic=$magic
1.6       moko     4615: 
                   4616:     staticlibs=
                   4617:     future_libdirs=
                   4618:     current_libdirs=
                   4619:     for file in $files; do
                   4620: 
                   4621:       # Do each installation.
                   4622:       case $file in
                   4623:       *.$libext)
                   4624:        # Do the static libraries later.
                   4625:        func_append staticlibs " $file"
                   4626:        ;;
                   4627: 
                   4628:       *.la)
                   4629:        func_resolve_sysroot "$file"
                   4630:        file=$func_resolve_sysroot_result
                   4631: 
                   4632:        # Check to see that this really is a libtool archive.
                   4633:        func_lalib_unsafe_p "$file" \
1.7     ! moko     4634:          || func_fatal_help "'$file' is not a valid libtool archive"
1.6       moko     4635: 
                   4636:        library_names=
                   4637:        old_library=
                   4638:        relink_command=
                   4639:        func_source "$file"
                   4640: 
                   4641:        # Add the libdir to current_libdirs if it is the destination.
                   4642:        if test "X$destdir" = "X$libdir"; then
                   4643:          case "$current_libdirs " in
                   4644:          *" $libdir "*) ;;
                   4645:          *) func_append current_libdirs " $libdir" ;;
                   4646:          esac
                   4647:        else
                   4648:          # Note the libdir as a future libdir.
                   4649:          case "$future_libdirs " in
                   4650:          *" $libdir "*) ;;
                   4651:          *) func_append future_libdirs " $libdir" ;;
                   4652:          esac
                   4653:        fi
                   4654: 
                   4655:        func_dirname "$file" "/" ""
1.7     ! moko     4656:        dir=$func_dirname_result
1.6       moko     4657:        func_append dir "$objdir"
                   4658: 
                   4659:        if test -n "$relink_command"; then
1.7     ! moko     4660:          # Strip any trailing slash from the destination.
        !          4661:          func_stripname '' '/' "$libdir"
        !          4662:          destlibdir=$func_stripname_result
        !          4663: 
        !          4664:          func_stripname '' '/' "$destdir"
        !          4665:          s_destdir=$func_stripname_result
        !          4666: 
1.6       moko     4667:          # Determine the prefix the user has applied to our future dir.
1.7     ! moko     4668:          inst_prefix_dir=`$ECHO "X$s_destdir" | $Xsed -e "s%$destlibdir\$%%"`
1.6       moko     4669: 
                   4670:          # Don't allow the user to place us outside of our expected
                   4671:          # location b/c this prevents finding dependent libraries that
                   4672:          # are installed to the same prefix.
                   4673:          # At present, this check doesn't affect windows .dll's that
                   4674:          # are installed into $libdir/../bin (currently, that works fine)
                   4675:          # but it's something to keep an eye on.
                   4676:          test "$inst_prefix_dir" = "$destdir" && \
1.7     ! moko     4677:            func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
1.6       moko     4678: 
                   4679:          if test -n "$inst_prefix_dir"; then
                   4680:            # Stick the inst_prefix_dir data into the link command.
                   4681:            relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
                   4682:          else
                   4683:            relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
                   4684:          fi
                   4685: 
1.7     ! moko     4686:          func_warning "relinking '$file'"
1.6       moko     4687:          func_show_eval "$relink_command" \
1.7     ! moko     4688:            'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
1.6       moko     4689:        fi
                   4690: 
                   4691:        # See the names of the shared library.
                   4692:        set dummy $library_names; shift
                   4693:        if test -n "$1"; then
1.7     ! moko     4694:          realname=$1
1.6       moko     4695:          shift
                   4696: 
1.7     ! moko     4697:          srcname=$realname
        !          4698:          test -n "$relink_command" && srcname=${realname}T
1.6       moko     4699: 
                   4700:          # Install the shared library and build the symlinks.
                   4701:          func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
                   4702:              'exit $?'
1.7     ! moko     4703:          tstripme=$stripme
1.6       moko     4704:          case $host_os in
1.7     ! moko     4705:          cygwin* | mingw* | windows* | pw32* | cegcc*)
1.6       moko     4706:            case $realname in
                   4707:            *.dll.a)
1.7     ! moko     4708:              tstripme=
        !          4709:              ;;
        !          4710:            esac
        !          4711:            ;;
        !          4712:          os2*)
        !          4713:            case $realname in
        !          4714:            *_dll.a)
        !          4715:              tstripme=
1.6       moko     4716:              ;;
                   4717:            esac
                   4718:            ;;
                   4719:          esac
                   4720:          if test -n "$tstripme" && test -n "$striplib"; then
                   4721:            func_show_eval "$striplib $destdir/$realname" 'exit $?'
                   4722:          fi
                   4723: 
                   4724:          if test "$#" -gt 0; then
                   4725:            # Delete the old symlinks, and create new ones.
1.7     ! moko     4726:            # Try 'ln -sf' first, because the 'ln' binary might depend on
1.6       moko     4727:            # the symlink we replace!  Solaris /bin/ln does not understand -f,
                   4728:            # so we also need to try rm && ln -s.
                   4729:            for linkname
                   4730:            do
                   4731:              test "$linkname" != "$realname" \
                   4732:                && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
                   4733:            done
                   4734:          fi
                   4735: 
                   4736:          # Do each command in the postinstall commands.
1.7     ! moko     4737:          lib=$destdir/$realname
1.6       moko     4738:          func_execute_cmds "$postinstall_cmds" 'exit $?'
                   4739:        fi
                   4740: 
                   4741:        # Install the pseudo-library for information purposes.
                   4742:        func_basename "$file"
1.7     ! moko     4743:        name=$func_basename_result
        !          4744:        instname=$dir/${name}i
1.6       moko     4745:        func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
                   4746: 
                   4747:        # Maybe install the static library, too.
                   4748:        test -n "$old_library" && func_append staticlibs " $dir/$old_library"
                   4749:        ;;
                   4750: 
                   4751:       *.lo)
                   4752:        # Install (i.e. copy) a libtool object.
                   4753: 
                   4754:        # Figure out destination file name, if it wasn't already specified.
                   4755:        if test -n "$destname"; then
1.7     ! moko     4756:          destfile=$destdir/$destname
1.6       moko     4757:        else
                   4758:          func_basename "$file"
1.7     ! moko     4759:          destfile=$func_basename_result
        !          4760:          destfile=$destdir/$destfile
1.6       moko     4761:        fi
                   4762: 
                   4763:        # Deduce the name of the destination old-style object file.
                   4764:        case $destfile in
                   4765:        *.lo)
                   4766:          func_lo2o "$destfile"
                   4767:          staticdest=$func_lo2o_result
                   4768:          ;;
                   4769:        *.$objext)
1.7     ! moko     4770:          staticdest=$destfile
1.6       moko     4771:          destfile=
                   4772:          ;;
                   4773:        *)
1.7     ! moko     4774:          func_fatal_help "cannot copy a libtool object to '$destfile'"
1.6       moko     4775:          ;;
                   4776:        esac
                   4777: 
                   4778:        # Install the libtool object if requested.
                   4779:        test -n "$destfile" && \
                   4780:          func_show_eval "$install_prog $file $destfile" 'exit $?'
                   4781: 
                   4782:        # Install the old object if enabled.
1.7     ! moko     4783:        if test yes = "$build_old_libs"; then
1.6       moko     4784:          # Deduce the name of the old-style object file.
                   4785:          func_lo2o "$file"
                   4786:          staticobj=$func_lo2o_result
                   4787:          func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
                   4788:        fi
                   4789:        exit $EXIT_SUCCESS
                   4790:        ;;
                   4791: 
                   4792:       *)
                   4793:        # Figure out destination file name, if it wasn't already specified.
                   4794:        if test -n "$destname"; then
1.7     ! moko     4795:          destfile=$destdir/$destname
1.6       moko     4796:        else
                   4797:          func_basename "$file"
1.7     ! moko     4798:          destfile=$func_basename_result
        !          4799:          destfile=$destdir/$destfile
1.6       moko     4800:        fi
                   4801: 
                   4802:        # If the file is missing, and there is a .exe on the end, strip it
                   4803:        # because it is most likely a libtool script we actually want to
                   4804:        # install
1.7     ! moko     4805:        stripped_ext=
1.6       moko     4806:        case $file in
                   4807:          *.exe)
                   4808:            if test ! -f "$file"; then
                   4809:              func_stripname '' '.exe' "$file"
                   4810:              file=$func_stripname_result
1.7     ! moko     4811:              stripped_ext=.exe
1.6       moko     4812:            fi
                   4813:            ;;
                   4814:        esac
                   4815: 
                   4816:        # Do a test to see if this is really a libtool program.
                   4817:        case $host in
1.7     ! moko     4818:        *cygwin* | *mingw* | *windows*)
1.6       moko     4819:            if func_ltwrapper_executable_p "$file"; then
                   4820:              func_ltwrapper_scriptname "$file"
                   4821:              wrapper=$func_ltwrapper_scriptname_result
                   4822:            else
                   4823:              func_stripname '' '.exe' "$file"
                   4824:              wrapper=$func_stripname_result
                   4825:            fi
                   4826:            ;;
                   4827:        *)
                   4828:            wrapper=$file
                   4829:            ;;
                   4830:        esac
                   4831:        if func_ltwrapper_script_p "$wrapper"; then
                   4832:          notinst_deplibs=
                   4833:          relink_command=
                   4834: 
                   4835:          func_source "$wrapper"
                   4836: 
                   4837:          # Check the variables that should have been set.
                   4838:          test -z "$generated_by_libtool_version" && \
1.7     ! moko     4839:            func_fatal_error "invalid libtool wrapper script '$wrapper'"
1.6       moko     4840: 
1.7     ! moko     4841:          finalize=:
1.6       moko     4842:          for lib in $notinst_deplibs; do
                   4843:            # Check to see that each library is installed.
                   4844:            libdir=
                   4845:            if test -f "$lib"; then
                   4846:              func_source "$lib"
                   4847:            fi
1.7     ! moko     4848:            libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
1.6       moko     4849:            if test -n "$libdir" && test ! -f "$libfile"; then
1.7     ! moko     4850:              func_warning "'$lib' has not been installed in '$libdir'"
        !          4851:              finalize=false
1.6       moko     4852:            fi
                   4853:          done
                   4854: 
                   4855:          relink_command=
                   4856:          func_source "$wrapper"
                   4857: 
                   4858:          outputname=
1.7     ! moko     4859:          if test no = "$fast_install" && test -n "$relink_command"; then
1.6       moko     4860:            $opt_dry_run || {
1.7     ! moko     4861:              if $finalize; then
1.6       moko     4862:                tmpdir=`func_mktempdir`
                   4863:                func_basename "$file$stripped_ext"
1.7     ! moko     4864:                file=$func_basename_result
        !          4865:                outputname=$tmpdir/$file
1.6       moko     4866:                # Replace the output file specification.
                   4867:                relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
                   4868: 
1.7     ! moko     4869:                $opt_quiet || {
        !          4870:                  func_quote_arg expand,pretty "$relink_command"
        !          4871:                  eval "func_echo $func_quote_arg_result"
1.6       moko     4872:                }
                   4873:                if eval "$relink_command"; then :
                   4874:                  else
1.7     ! moko     4875:                  func_error "error: relink '$file' with the above command before installing it"
1.6       moko     4876:                  $opt_dry_run || ${RM}r "$tmpdir"
                   4877:                  continue
                   4878:                fi
1.7     ! moko     4879:                file=$outputname
1.6       moko     4880:              else
1.7     ! moko     4881:                func_warning "cannot relink '$file'"
1.6       moko     4882:              fi
                   4883:            }
                   4884:          else
                   4885:            # Install the binary that we compiled earlier.
                   4886:            file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
                   4887:          fi
                   4888:        fi
                   4889: 
                   4890:        # remove .exe since cygwin /usr/bin/install will append another
                   4891:        # one anyway
                   4892:        case $install_prog,$host in
                   4893:        */usr/bin/install*,*cygwin*)
                   4894:          case $file:$destfile in
                   4895:          *.exe:*.exe)
                   4896:            # this is ok
                   4897:            ;;
                   4898:          *.exe:*)
                   4899:            destfile=$destfile.exe
                   4900:            ;;
                   4901:          *:*.exe)
                   4902:            func_stripname '' '.exe' "$destfile"
                   4903:            destfile=$func_stripname_result
                   4904:            ;;
                   4905:          esac
                   4906:          ;;
                   4907:        esac
                   4908:        func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
                   4909:        $opt_dry_run || if test -n "$outputname"; then
                   4910:          ${RM}r "$tmpdir"
                   4911:        fi
                   4912:        ;;
                   4913:       esac
                   4914:     done
                   4915: 
                   4916:     for file in $staticlibs; do
                   4917:       func_basename "$file"
1.7     ! moko     4918:       name=$func_basename_result
1.6       moko     4919: 
                   4920:       # Set up the ranlib parameters.
1.7     ! moko     4921:       oldlib=$destdir/$name
1.6       moko     4922:       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
                   4923:       tool_oldlib=$func_to_tool_file_result
                   4924: 
                   4925:       func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
                   4926: 
                   4927:       if test -n "$stripme" && test -n "$old_striplib"; then
                   4928:        func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
                   4929:       fi
                   4930: 
                   4931:       # Do each command in the postinstall commands.
                   4932:       func_execute_cmds "$old_postinstall_cmds" 'exit $?'
                   4933:     done
                   4934: 
                   4935:     test -n "$future_libdirs" && \
1.7     ! moko     4936:       func_warning "remember to run '$progname --finish$future_libdirs'"
1.6       moko     4937: 
                   4938:     if test -n "$current_libdirs"; then
                   4939:       # Maybe just do a dry run.
                   4940:       $opt_dry_run && current_libdirs=" -n$current_libdirs"
1.7     ! moko     4941:       exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
1.6       moko     4942:     else
                   4943:       exit $EXIT_SUCCESS
                   4944:     fi
                   4945: }
                   4946: 
1.7     ! moko     4947: test install = "$opt_mode" && func_mode_install ${1+"$@"}
1.6       moko     4948: 
                   4949: 
                   4950: # func_generate_dlsyms outputname originator pic_p
                   4951: # Extract symbols from dlprefiles and create ${outputname}S.o with
                   4952: # a dlpreopen symbol table.
                   4953: func_generate_dlsyms ()
                   4954: {
1.7     ! moko     4955:     $debug_cmd
        !          4956: 
        !          4957:     my_outputname=$1
        !          4958:     my_originator=$2
        !          4959:     my_pic_p=${3-false}
        !          4960:     my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
1.6       moko     4961:     my_dlsyms=
                   4962: 
1.7     ! moko     4963:     if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
1.6       moko     4964:       if test -n "$NM" && test -n "$global_symbol_pipe"; then
1.7     ! moko     4965:        my_dlsyms=${my_outputname}S.c
1.6       moko     4966:       else
                   4967:        func_error "not configured to extract global symbols from dlpreopened files"
                   4968:       fi
                   4969:     fi
                   4970: 
                   4971:     if test -n "$my_dlsyms"; then
                   4972:       case $my_dlsyms in
                   4973:       "") ;;
                   4974:       *.c)
                   4975:        # Discover the nlist of each of the dlfiles.
1.7     ! moko     4976:        nlist=$output_objdir/$my_outputname.nm
1.6       moko     4977: 
                   4978:        func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
                   4979: 
                   4980:        # Parse the name list into a source file.
                   4981:        func_verbose "creating $output_objdir/$my_dlsyms"
                   4982: 
                   4983:        $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
1.7     ! moko     4984: /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
        !          4985: /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
1.6       moko     4986: 
                   4987: #ifdef __cplusplus
                   4988: extern \"C\" {
                   4989: #endif
                   4990: 
1.7     ! moko     4991: #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
1.6       moko     4992: #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
                   4993: #endif
                   4994: 
                   4995: /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
1.7     ! moko     4996: #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
        !          4997: /* DATA imports from DLLs on WIN32 can't be const, because runtime
1.6       moko     4998:    relocations are performed -- see ld's documentation on pseudo-relocs.  */
                   4999: # define LT_DLSYM_CONST
1.7     ! moko     5000: #elif defined __osf__
1.6       moko     5001: /* This system does not cope well with relocations in const data.  */
                   5002: # define LT_DLSYM_CONST
                   5003: #else
                   5004: # define LT_DLSYM_CONST const
                   5005: #endif
                   5006: 
1.7     ! moko     5007: #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
        !          5008: 
1.6       moko     5009: /* External symbol declarations for the compiler. */\
                   5010: "
                   5011: 
1.7     ! moko     5012:        if test yes = "$dlself"; then
        !          5013:          func_verbose "generating symbol list for '$output'"
1.6       moko     5014: 
                   5015:          $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
                   5016: 
                   5017:          # Add our own program objects to the symbol list.
                   5018:          progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
                   5019:          for progfile in $progfiles; do
                   5020:            func_to_tool_file "$progfile" func_convert_file_msys_to_w32
1.7     ! moko     5021:            func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
1.6       moko     5022:            $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
                   5023:          done
                   5024: 
                   5025:          if test -n "$exclude_expsyms"; then
                   5026:            $opt_dry_run || {
                   5027:              eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
                   5028:              eval '$MV "$nlist"T "$nlist"'
                   5029:            }
                   5030:          fi
                   5031: 
                   5032:          if test -n "$export_symbols_regex"; then
                   5033:            $opt_dry_run || {
                   5034:              eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
                   5035:              eval '$MV "$nlist"T "$nlist"'
                   5036:            }
                   5037:          fi
                   5038: 
                   5039:          # Prepare the list of exported symbols
                   5040:          if test -z "$export_symbols"; then
1.7     ! moko     5041:            export_symbols=$output_objdir/$outputname.exp
1.6       moko     5042:            $opt_dry_run || {
                   5043:              $RM $export_symbols
1.7     ! moko     5044:              eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
1.6       moko     5045:              case $host in
1.7     ! moko     5046:              *cygwin* | *mingw* | *windows* | *cegcc* )
1.6       moko     5047:                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
                   5048:                 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
                   5049:                ;;
                   5050:              esac
                   5051:            }
                   5052:          else
                   5053:            $opt_dry_run || {
1.7     ! moko     5054:              eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
1.6       moko     5055:              eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
                   5056:              eval '$MV "$nlist"T "$nlist"'
                   5057:              case $host in
1.7     ! moko     5058:                *cygwin* | *mingw* | *windows* | *cegcc* )
1.6       moko     5059:                  eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
                   5060:                  eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
                   5061:                  ;;
                   5062:              esac
                   5063:            }
                   5064:          fi
                   5065:        fi
                   5066: 
                   5067:        for dlprefile in $dlprefiles; do
1.7     ! moko     5068:          func_verbose "extracting global C symbols from '$dlprefile'"
1.6       moko     5069:          func_basename "$dlprefile"
1.7     ! moko     5070:          name=$func_basename_result
1.6       moko     5071:           case $host in
1.7     ! moko     5072:            *cygwin* | *mingw* | *windows* | *cegcc* )
1.6       moko     5073:              # if an import library, we need to obtain dlname
                   5074:              if func_win32_import_lib_p "$dlprefile"; then
                   5075:                func_tr_sh "$dlprefile"
                   5076:                eval "curr_lafile=\$libfile_$func_tr_sh_result"
1.7     ! moko     5077:                dlprefile_dlbasename=
1.6       moko     5078:                if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
                   5079:                  # Use subshell, to avoid clobbering current variable values
                   5080:                  dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
1.7     ! moko     5081:                  if test -n "$dlprefile_dlname"; then
1.6       moko     5082:                    func_basename "$dlprefile_dlname"
1.7     ! moko     5083:                    dlprefile_dlbasename=$func_basename_result
1.6       moko     5084:                  else
                   5085:                    # no lafile. user explicitly requested -dlpreopen <import library>.
                   5086:                    $sharedlib_from_linklib_cmd "$dlprefile"
                   5087:                    dlprefile_dlbasename=$sharedlib_from_linklib_result
                   5088:                  fi
                   5089:                fi
                   5090:                $opt_dry_run || {
1.7     ! moko     5091:                  if test -n "$dlprefile_dlbasename"; then
1.6       moko     5092:                    eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
                   5093:                  else
                   5094:                    func_warning "Could not compute DLL name from $name"
                   5095:                    eval '$ECHO ": $name " >> "$nlist"'
                   5096:                  fi
                   5097:                  func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
1.7     ! moko     5098:                  case $host in
        !          5099:                    i[3456]86-*-mingw32*)
        !          5100:                      eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
        !          5101:                        $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
        !          5102:                    ;;
        !          5103:                    *)
        !          5104:                      eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
        !          5105:                        $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/__nm_//' >> '$nlist'"
        !          5106:                    ;;
        !          5107:                  esac
1.6       moko     5108:                }
                   5109:              else # not an import lib
                   5110:                $opt_dry_run || {
                   5111:                  eval '$ECHO ": $name " >> "$nlist"'
                   5112:                  func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
                   5113:                  eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
                   5114:                }
                   5115:              fi
                   5116:            ;;
                   5117:            *)
                   5118:              $opt_dry_run || {
                   5119:                eval '$ECHO ": $name " >> "$nlist"'
                   5120:                func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
                   5121:                eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
                   5122:              }
                   5123:            ;;
                   5124:           esac
                   5125:        done
                   5126: 
                   5127:        $opt_dry_run || {
                   5128:          # Make sure we have at least an empty file.
                   5129:          test -f "$nlist" || : > "$nlist"
                   5130: 
                   5131:          if test -n "$exclude_expsyms"; then
                   5132:            $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
                   5133:            $MV "$nlist"T "$nlist"
                   5134:          fi
                   5135: 
                   5136:          # Try sorting and uniquifying the output.
                   5137:          if $GREP -v "^: " < "$nlist" |
                   5138:              if sort -k 3 </dev/null >/dev/null 2>&1; then
                   5139:                sort -k 3
                   5140:              else
                   5141:                sort +2
                   5142:              fi |
                   5143:              uniq > "$nlist"S; then
                   5144:            :
                   5145:          else
                   5146:            $GREP -v "^: " < "$nlist" > "$nlist"S
                   5147:          fi
                   5148: 
                   5149:          if test -f "$nlist"S; then
                   5150:            eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
                   5151:          else
                   5152:            echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
                   5153:          fi
                   5154: 
1.7     ! moko     5155:          func_show_eval '$RM "${nlist}I"'
        !          5156:          if test -n "$global_symbol_to_import"; then
        !          5157:            eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
        !          5158:          fi
        !          5159: 
1.6       moko     5160:          echo >> "$output_objdir/$my_dlsyms" "\
                   5161: 
                   5162: /* The mapping between symbol names and symbols.  */
                   5163: typedef struct {
                   5164:   const char *name;
                   5165:   void *address;
                   5166: } lt_dlsymlist;
                   5167: extern LT_DLSYM_CONST lt_dlsymlist
1.7     ! moko     5168: lt_${my_prefix}_LTX_preloaded_symbols[];\
        !          5169: "
        !          5170: 
        !          5171:          if test -s "$nlist"I; then
        !          5172:            echo >> "$output_objdir/$my_dlsyms" "\
        !          5173: static void lt_syminit(void)
        !          5174: {
        !          5175:   LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
        !          5176:   for (; symbol->name; ++symbol)
        !          5177:     {"
        !          5178:            $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
        !          5179:            echo >> "$output_objdir/$my_dlsyms" "\
        !          5180:     }
        !          5181: }"
        !          5182:          fi
        !          5183:          echo >> "$output_objdir/$my_dlsyms" "\
1.6       moko     5184: LT_DLSYM_CONST lt_dlsymlist
                   5185: lt_${my_prefix}_LTX_preloaded_symbols[] =
1.7     ! moko     5186: { {\"$my_originator\", (void *) 0},"
        !          5187: 
        !          5188:          if test -s "$nlist"I; then
        !          5189:            echo >> "$output_objdir/$my_dlsyms" "\
        !          5190:   {\"@INIT@\", (void *) &lt_syminit},"
        !          5191:          fi
1.6       moko     5192: 
                   5193:          case $need_lib_prefix in
                   5194:          no)
                   5195:            eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
                   5196:            ;;
                   5197:          *)
                   5198:            eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
                   5199:            ;;
                   5200:          esac
                   5201:          echo >> "$output_objdir/$my_dlsyms" "\
                   5202:   {0, (void *) 0}
                   5203: };
                   5204: 
                   5205: /* This works around a problem in FreeBSD linker */
                   5206: #ifdef FREEBSD_WORKAROUND
                   5207: static const void *lt_preloaded_setup() {
                   5208:   return lt_${my_prefix}_LTX_preloaded_symbols;
                   5209: }
                   5210: #endif
                   5211: 
                   5212: #ifdef __cplusplus
                   5213: }
                   5214: #endif\
                   5215: "
                   5216:        } # !$opt_dry_run
                   5217: 
                   5218:        pic_flag_for_symtable=
                   5219:        case "$compile_command " in
                   5220:        *" -static "*) ;;
                   5221:        *)
                   5222:          case $host in
                   5223:          # compiling the symbol table file with pic_flag works around
                   5224:          # a FreeBSD bug that causes programs to crash when -lm is
                   5225:          # linked before any other PIC object.  But we must not use
                   5226:          # pic_flag when linking with -static.  The problem exists in
                   5227:          # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
                   5228:          *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
                   5229:            pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
                   5230:          *-*-hpux*)
                   5231:            pic_flag_for_symtable=" $pic_flag"  ;;
                   5232:          *)
1.7     ! moko     5233:            $my_pic_p && pic_flag_for_symtable=" $pic_flag"
1.6       moko     5234:            ;;
                   5235:          esac
                   5236:          ;;
                   5237:        esac
                   5238:        symtab_cflags=
                   5239:        for arg in $LTCFLAGS; do
                   5240:          case $arg in
                   5241:          -pie | -fpie | -fPIE) ;;
                   5242:          *) func_append symtab_cflags " $arg" ;;
                   5243:          esac
                   5244:        done
                   5245: 
                   5246:        # Now compile the dynamic symbol file.
                   5247:        func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
                   5248: 
                   5249:        # Clean up the generated files.
1.7     ! moko     5250:        func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
1.6       moko     5251: 
                   5252:        # Transform the symbol file into the correct name.
1.7     ! moko     5253:        symfileobj=$output_objdir/${my_outputname}S.$objext
1.6       moko     5254:        case $host in
1.7     ! moko     5255:        *cygwin* | *mingw* | *windows* | *cegcc* )
1.6       moko     5256:          if test -f "$output_objdir/$my_outputname.def"; then
                   5257:            compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
                   5258:            finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
                   5259:          else
                   5260:            compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
                   5261:            finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
                   5262:          fi
                   5263:          ;;
                   5264:        *)
                   5265:          compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
                   5266:          finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
                   5267:          ;;
                   5268:        esac
                   5269:        ;;
                   5270:       *)
1.7     ! moko     5271:        func_fatal_error "unknown suffix for '$my_dlsyms'"
1.6       moko     5272:        ;;
                   5273:       esac
                   5274:     else
                   5275:       # We keep going just in case the user didn't refer to
                   5276:       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
                   5277:       # really was required.
                   5278: 
                   5279:       # Nullify the symbol file.
                   5280:       compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
                   5281:       finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
                   5282:     fi
                   5283: }
                   5284: 
1.7     ! moko     5285: # func_cygming_gnu_implib_p ARG
        !          5286: # This predicate returns with zero status (TRUE) if
        !          5287: # ARG is a GNU/binutils-style import library. Returns
        !          5288: # with nonzero status (FALSE) otherwise.
        !          5289: func_cygming_gnu_implib_p ()
        !          5290: {
        !          5291:   $debug_cmd
        !          5292: 
        !          5293:   func_to_tool_file "$1" func_convert_file_msys_to_w32
        !          5294:   func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
        !          5295:   test -n "$func_cygming_gnu_implib_tmp"
        !          5296: }
        !          5297: 
        !          5298: # func_cygming_ms_implib_p ARG
        !          5299: # This predicate returns with zero status (TRUE) if
        !          5300: # ARG is an MS-style import library. Returns
        !          5301: # with nonzero status (FALSE) otherwise.
        !          5302: func_cygming_ms_implib_p ()
        !          5303: {
        !          5304:   $debug_cmd
        !          5305: 
        !          5306:   func_to_tool_file "$1" func_convert_file_msys_to_w32
        !          5307:   func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
        !          5308:   test -n "$func_cygming_ms_implib_tmp"
        !          5309: }
        !          5310: 
1.6       moko     5311: # func_win32_libid arg
                   5312: # return the library type of file 'arg'
                   5313: #
                   5314: # Need a lot of goo to handle *both* DLLs and import libs
                   5315: # Has to be a shell function in order to 'eat' the argument
                   5316: # that is supplied when $file_magic_command is called.
                   5317: # Despite the name, also deal with 64 bit binaries.
                   5318: func_win32_libid ()
                   5319: {
1.7     ! moko     5320:   $debug_cmd
        !          5321: 
        !          5322:   win32_libid_type=unknown
1.6       moko     5323:   win32_fileres=`file -L $1 2>/dev/null`
                   5324:   case $win32_fileres in
                   5325:   *ar\ archive\ import\ library*) # definitely import
                   5326:     win32_libid_type="x86 archive import"
                   5327:     ;;
                   5328:   *ar\ archive*) # could be an import, or static
                   5329:     # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
                   5330:     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
1.7     ! moko     5331:        $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64|pe-aarch64)' >/dev/null; then
        !          5332:       case $nm_interface in
        !          5333:       "MS dumpbin")
        !          5334:        if func_cygming_ms_implib_p "$1" ||
        !          5335:           func_cygming_gnu_implib_p "$1"
        !          5336:        then
        !          5337:          win32_nmres=import
        !          5338:        else
        !          5339:          win32_nmres=
        !          5340:        fi
        !          5341:        ;;
        !          5342:       *)
        !          5343:        func_to_tool_file "$1" func_convert_file_msys_to_w32
        !          5344:        win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
        !          5345:          $SED -n -e '
1.6       moko     5346:            1,100{
                   5347:                / I /{
1.7     ! moko     5348:                    s|.*|import|
1.6       moko     5349:                    p
                   5350:                    q
                   5351:                }
                   5352:            }'`
1.7     ! moko     5353:        ;;
        !          5354:       esac
1.6       moko     5355:       case $win32_nmres in
                   5356:       import*)  win32_libid_type="x86 archive import";;
                   5357:       *)        win32_libid_type="x86 archive static";;
                   5358:       esac
                   5359:     fi
                   5360:     ;;
                   5361:   *DLL*)
                   5362:     win32_libid_type="x86 DLL"
                   5363:     ;;
                   5364:   *executable*) # but shell scripts are "executable" too...
                   5365:     case $win32_fileres in
                   5366:     *MS\ Windows\ PE\ Intel*)
                   5367:       win32_libid_type="x86 DLL"
                   5368:       ;;
                   5369:     esac
                   5370:     ;;
                   5371:   esac
                   5372:   $ECHO "$win32_libid_type"
                   5373: }
                   5374: 
                   5375: # func_cygming_dll_for_implib ARG
                   5376: #
                   5377: # Platform-specific function to extract the
                   5378: # name of the DLL associated with the specified
                   5379: # import library ARG.
                   5380: # Invoked by eval'ing the libtool variable
                   5381: #    $sharedlib_from_linklib_cmd
                   5382: # Result is available in the variable
                   5383: #    $sharedlib_from_linklib_result
                   5384: func_cygming_dll_for_implib ()
                   5385: {
1.7     ! moko     5386:   $debug_cmd
        !          5387: 
1.6       moko     5388:   sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
                   5389: }
                   5390: 
                   5391: # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
                   5392: #
                   5393: # The is the core of a fallback implementation of a
                   5394: # platform-specific function to extract the name of the
                   5395: # DLL associated with the specified import library LIBNAME.
                   5396: #
                   5397: # SECTION_NAME is either .idata$6 or .idata$7, depending
                   5398: # on the platform and compiler that created the implib.
                   5399: #
                   5400: # Echos the name of the DLL associated with the
                   5401: # specified import library.
                   5402: func_cygming_dll_for_implib_fallback_core ()
                   5403: {
1.7     ! moko     5404:   $debug_cmd
        !          5405: 
1.6       moko     5406:   match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
                   5407:   $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
                   5408:     $SED '/^Contents of section '"$match_literal"':/{
                   5409:       # Place marker at beginning of archive member dllname section
                   5410:       s/.*/====MARK====/
                   5411:       p
                   5412:       d
                   5413:     }
                   5414:     # These lines can sometimes be longer than 43 characters, but
                   5415:     # are always uninteresting
                   5416:     /:[         ]*file format pe[i]\{,1\}-/d
                   5417:     /^In archive [^:]*:/d
                   5418:     # Ensure marker is printed
                   5419:     /^====MARK====/p
                   5420:     # Remove all lines with less than 43 characters
                   5421:     /^.\{43\}/!d
                   5422:     # From remaining lines, remove first 43 characters
                   5423:     s/^.\{43\}//' |
                   5424:     $SED -n '
                   5425:       # Join marker and all lines until next marker into a single line
                   5426:       /^====MARK====/ b para
                   5427:       H
                   5428:       $ b para
                   5429:       b
                   5430:       :para
                   5431:       x
                   5432:       s/\n//g
                   5433:       # Remove the marker
                   5434:       s/^====MARK====//
                   5435:       # Remove trailing dots and whitespace
                   5436:       s/[\. \t]*$//
                   5437:       # Print
                   5438:       /./p' |
                   5439:     # we now have a list, one entry per line, of the stringified
                   5440:     # contents of the appropriate section of all members of the
1.7     ! moko     5441:     # archive that possess that section. Heuristic: eliminate
        !          5442:     # all those that have a first or second character that is
1.6       moko     5443:     # a '.' (that is, objdump's representation of an unprintable
                   5444:     # character.) This should work for all archives with less than
                   5445:     # 0x302f exports -- but will fail for DLLs whose name actually
                   5446:     # begins with a literal '.' or a single character followed by
                   5447:     # a '.'.
                   5448:     #
                   5449:     # Of those that remain, print the first one.
                   5450:     $SED -e '/^\./d;/^.\./d;q'
                   5451: }
                   5452: 
                   5453: # func_cygming_dll_for_implib_fallback ARG
                   5454: # Platform-specific function to extract the
                   5455: # name of the DLL associated with the specified
                   5456: # import library ARG.
                   5457: #
                   5458: # This fallback implementation is for use when $DLLTOOL
                   5459: # does not support the --identify-strict option.
                   5460: # Invoked by eval'ing the libtool variable
                   5461: #    $sharedlib_from_linklib_cmd
                   5462: # Result is available in the variable
                   5463: #    $sharedlib_from_linklib_result
                   5464: func_cygming_dll_for_implib_fallback ()
                   5465: {
1.7     ! moko     5466:   $debug_cmd
        !          5467: 
        !          5468:   if func_cygming_gnu_implib_p "$1"; then
1.6       moko     5469:     # binutils import library
                   5470:     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
1.7     ! moko     5471:   elif func_cygming_ms_implib_p "$1"; then
1.6       moko     5472:     # ms-generated import library
                   5473:     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
                   5474:   else
                   5475:     # unknown
1.7     ! moko     5476:     sharedlib_from_linklib_result=
1.6       moko     5477:   fi
                   5478: }
                   5479: 
                   5480: 
                   5481: # func_extract_an_archive dir oldlib
                   5482: func_extract_an_archive ()
                   5483: {
1.7     ! moko     5484:     $debug_cmd
        !          5485: 
        !          5486:     f_ex_an_ar_dir=$1; shift
        !          5487:     f_ex_an_ar_oldlib=$1
        !          5488:     if test yes = "$lock_old_archive_extraction"; then
1.6       moko     5489:       lockfile=$f_ex_an_ar_oldlib.lock
                   5490:       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
                   5491:        func_echo "Waiting for $lockfile to be removed"
                   5492:        sleep 2
                   5493:       done
                   5494:     fi
                   5495:     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
                   5496:                   'stat=$?; rm -f "$lockfile"; exit $stat'
1.7     ! moko     5497:     if test yes = "$lock_old_archive_extraction"; then
1.6       moko     5498:       $opt_dry_run || rm -f "$lockfile"
                   5499:     fi
                   5500:     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
                   5501:      :
                   5502:     else
                   5503:       func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
                   5504:     fi
                   5505: }
                   5506: 
                   5507: 
                   5508: # func_extract_archives gentop oldlib ...
                   5509: func_extract_archives ()
                   5510: {
1.7     ! moko     5511:     $debug_cmd
        !          5512: 
        !          5513:     my_gentop=$1; shift
1.6       moko     5514:     my_oldlibs=${1+"$@"}
1.7     ! moko     5515:     my_oldobjs=
        !          5516:     my_xlib=
        !          5517:     my_xabs=
        !          5518:     my_xdir=
1.6       moko     5519: 
                   5520:     for my_xlib in $my_oldlibs; do
                   5521:       # Extract the objects.
                   5522:       case $my_xlib in
1.7     ! moko     5523:        [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
1.6       moko     5524:        *) my_xabs=`pwd`"/$my_xlib" ;;
                   5525:       esac
                   5526:       func_basename "$my_xlib"
1.7     ! moko     5527:       my_xlib=$func_basename_result
1.6       moko     5528:       my_xlib_u=$my_xlib
                   5529:       while :; do
                   5530:         case " $extracted_archives " in
                   5531:        *" $my_xlib_u "*)
                   5532:          func_arith $extracted_serial + 1
                   5533:          extracted_serial=$func_arith_result
                   5534:          my_xlib_u=lt$extracted_serial-$my_xlib ;;
                   5535:        *) break ;;
                   5536:        esac
                   5537:       done
                   5538:       extracted_archives="$extracted_archives $my_xlib_u"
1.7     ! moko     5539:       my_xdir=$my_gentop/$my_xlib_u
1.6       moko     5540: 
                   5541:       func_mkdir_p "$my_xdir"
                   5542: 
                   5543:       case $host in
                   5544:       *-darwin*)
                   5545:        func_verbose "Extracting $my_xabs"
                   5546:        # Do not bother doing anything if just a dry run
                   5547:        $opt_dry_run || {
                   5548:          darwin_orig_dir=`pwd`
                   5549:          cd $my_xdir || exit $?
                   5550:          darwin_archive=$my_xabs
                   5551:          darwin_curdir=`pwd`
1.7     ! moko     5552:          func_basename "$darwin_archive"
        !          5553:          darwin_base_archive=$func_basename_result
1.6       moko     5554:          darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
                   5555:          if test -n "$darwin_arches"; then
                   5556:            darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
                   5557:            darwin_arch=
                   5558:            func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
1.7     ! moko     5559:            for darwin_arch in  $darwin_arches; do
        !          5560:              func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
        !          5561:              $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
        !          5562:              cd "unfat-$$/$darwin_base_archive-$darwin_arch"
        !          5563:              func_extract_an_archive "`pwd`" "$darwin_base_archive"
1.6       moko     5564:              cd "$darwin_curdir"
1.7     ! moko     5565:              $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
1.6       moko     5566:            done # $darwin_arches
                   5567:             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
1.7     ! moko     5568:            darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
1.6       moko     5569:            darwin_file=
                   5570:            darwin_files=
                   5571:            for darwin_file in $darwin_filelist; do
                   5572:              darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
                   5573:              $LIPO -create -output "$darwin_file" $darwin_files
                   5574:            done # $darwin_filelist
                   5575:            $RM -rf unfat-$$
                   5576:            cd "$darwin_orig_dir"
                   5577:          else
                   5578:            cd $darwin_orig_dir
                   5579:            func_extract_an_archive "$my_xdir" "$my_xabs"
                   5580:          fi # $darwin_arches
                   5581:        } # !$opt_dry_run
                   5582:        ;;
                   5583:       *)
                   5584:         func_extract_an_archive "$my_xdir" "$my_xabs"
                   5585:        ;;
                   5586:       esac
                   5587:       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
                   5588:     done
                   5589: 
1.7     ! moko     5590:     func_extract_archives_result=$my_oldobjs
1.6       moko     5591: }
                   5592: 
                   5593: 
                   5594: # func_emit_wrapper [arg=no]
                   5595: #
                   5596: # Emit a libtool wrapper script on stdout.
                   5597: # Don't directly open a file because we may want to
1.7     ! moko     5598: # incorporate the script contents within a cygwin/mingw/windows
1.6       moko     5599: # wrapper executable.  Must ONLY be called from within
                   5600: # func_mode_link because it depends on a number of variables
                   5601: # set therein.
                   5602: #
                   5603: # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
                   5604: # variable will take.  If 'yes', then the emitted script
1.7     ! moko     5605: # will assume that the directory where it is stored is
        !          5606: # the $objdir directory.  This is a cygwin/mingw/windows-specific
1.6       moko     5607: # behavior.
                   5608: func_emit_wrapper ()
                   5609: {
                   5610:        func_emit_wrapper_arg1=${1-no}
                   5611: 
                   5612:        $ECHO "\
                   5613: #! $SHELL
                   5614: 
                   5615: # $output - temporary wrapper script for $objdir/$outputname
1.7     ! moko     5616: # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
1.6       moko     5617: #
                   5618: # The $output program cannot be directly executed until all the libtool
                   5619: # libraries that it depends on are installed.
                   5620: #
                   5621: # This wrapper script should never be moved out of the build directory.
                   5622: # If it is, it will not operate correctly.
                   5623: 
                   5624: # Sed substitution that helps us do robust quoting.  It backslashifies
                   5625: # metacharacters that are still active within double-quoted strings.
                   5626: sed_quote_subst='$sed_quote_subst'
                   5627: 
                   5628: # Be Bourne compatible
                   5629: if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
                   5630:   emulate sh
                   5631:   NULLCMD=:
                   5632:   # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
                   5633:   # is contrary to our usage.  Disable this feature.
                   5634:   alias -g '\${1+\"\$@\"}'='\"\$@\"'
                   5635:   setopt NO_GLOB_SUBST
                   5636: else
                   5637:   case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
                   5638: fi
                   5639: BIN_SH=xpg4; export BIN_SH # for Tru64
                   5640: DUALCASE=1; export DUALCASE # for MKS sh
                   5641: 
                   5642: # The HP-UX ksh and POSIX shell print the target directory to stdout
                   5643: # if CDPATH is set.
                   5644: (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
                   5645: 
                   5646: relink_command=\"$relink_command\"
                   5647: 
                   5648: # This environment variable determines our operation mode.
                   5649: if test \"\$libtool_install_magic\" = \"$magic\"; then
                   5650:   # install mode needs the following variables:
                   5651:   generated_by_libtool_version='$macro_version'
                   5652:   notinst_deplibs='$notinst_deplibs'
                   5653: else
                   5654:   # When we are sourced in execute mode, \$file and \$ECHO are already set.
                   5655:   if test \"\$libtool_execute_magic\" != \"$magic\"; then
                   5656:     file=\"\$0\""
                   5657: 
1.7     ! moko     5658:     func_quote_arg pretty "$ECHO"
        !          5659:     qECHO=$func_quote_arg_result
1.6       moko     5660:     $ECHO "\
                   5661: 
                   5662: # A function that is used when there is no print builtin or printf.
                   5663: func_fallback_echo ()
                   5664: {
                   5665:   eval 'cat <<_LTECHO_EOF
                   5666: \$1
                   5667: _LTECHO_EOF'
                   5668: }
1.7     ! moko     5669:     ECHO=$qECHO
1.6       moko     5670:   fi
                   5671: 
                   5672: # Very basic option parsing. These options are (a) specific to
                   5673: # the libtool wrapper, (b) are identical between the wrapper
1.7     ! moko     5674: # /script/ and the wrapper /executable/ that is used only on
1.6       moko     5675: # windows platforms, and (c) all begin with the string "--lt-"
1.7     ! moko     5676: # (application programs are unlikely to have options that match
1.6       moko     5677: # this pattern).
                   5678: #
                   5679: # There are only two supported options: --lt-debug and
                   5680: # --lt-dump-script. There is, deliberately, no --lt-help.
                   5681: #
                   5682: # The first argument to this parsing function should be the
                   5683: # script's $0 value, followed by "$@".
                   5684: lt_option_debug=
                   5685: func_parse_lt_options ()
                   5686: {
                   5687:   lt_script_arg0=\$0
                   5688:   shift
                   5689:   for lt_opt
                   5690:   do
                   5691:     case \"\$lt_opt\" in
                   5692:     --lt-debug) lt_option_debug=1 ;;
                   5693:     --lt-dump-script)
                   5694:         lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
                   5695:         test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
                   5696:         lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
                   5697:         cat \"\$lt_dump_D/\$lt_dump_F\"
                   5698:         exit 0
                   5699:       ;;
                   5700:     --lt-*)
                   5701:         \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
                   5702:         exit 1
                   5703:       ;;
                   5704:     esac
                   5705:   done
                   5706: 
                   5707:   # Print the debug banner immediately:
                   5708:   if test -n \"\$lt_option_debug\"; then
1.7     ! moko     5709:     echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
1.6       moko     5710:   fi
                   5711: }
                   5712: 
                   5713: # Used when --lt-debug. Prints its arguments to stdout
                   5714: # (redirection is the responsibility of the caller)
                   5715: func_lt_dump_args ()
                   5716: {
                   5717:   lt_dump_args_N=1;
                   5718:   for lt_arg
                   5719:   do
1.7     ! moko     5720:     \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
1.6       moko     5721:     lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
                   5722:   done
                   5723: }
                   5724: 
                   5725: # Core function for launching the target application
                   5726: func_exec_program_core ()
                   5727: {
                   5728: "
                   5729:   case $host in
                   5730:   # Backslashes separate directories on plain windows
1.7     ! moko     5731:   *-*-mingw* | *-*-windows* | *-*-os2* | *-cegcc*)
1.6       moko     5732:     $ECHO "\
                   5733:       if test -n \"\$lt_option_debug\"; then
1.7     ! moko     5734:         \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
1.6       moko     5735:         func_lt_dump_args \${1+\"\$@\"} 1>&2
                   5736:       fi
                   5737:       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
                   5738: "
                   5739:     ;;
                   5740: 
                   5741:   *)
                   5742:     $ECHO "\
                   5743:       if test -n \"\$lt_option_debug\"; then
1.7     ! moko     5744:         \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
1.6       moko     5745:         func_lt_dump_args \${1+\"\$@\"} 1>&2
                   5746:       fi
                   5747:       exec \"\$progdir/\$program\" \${1+\"\$@\"}
                   5748: "
                   5749:     ;;
                   5750:   esac
                   5751:   $ECHO "\
                   5752:       \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
                   5753:       exit 1
                   5754: }
                   5755: 
                   5756: # A function to encapsulate launching the target application
                   5757: # Strips options in the --lt-* namespace from \$@ and
                   5758: # launches target application with the remaining arguments.
                   5759: func_exec_program ()
                   5760: {
                   5761:   case \" \$* \" in
                   5762:   *\\ --lt-*)
                   5763:     for lt_wr_arg
                   5764:     do
                   5765:       case \$lt_wr_arg in
                   5766:       --lt-*) ;;
                   5767:       *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
                   5768:       esac
                   5769:       shift
                   5770:     done ;;
                   5771:   esac
                   5772:   func_exec_program_core \${1+\"\$@\"}
                   5773: }
                   5774: 
                   5775:   # Parse options
                   5776:   func_parse_lt_options \"\$0\" \${1+\"\$@\"}
                   5777: 
                   5778:   # Find the directory that this script lives in.
                   5779:   thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
                   5780:   test \"x\$thisdir\" = \"x\$file\" && thisdir=.
                   5781: 
                   5782:   # Follow symbolic links until we get to the real thisdir.
                   5783:   file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
                   5784:   while test -n \"\$file\"; do
                   5785:     destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
                   5786: 
                   5787:     # If there was a directory component, then change thisdir.
                   5788:     if test \"x\$destdir\" != \"x\$file\"; then
                   5789:       case \"\$destdir\" in
                   5790:       [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
                   5791:       *) thisdir=\"\$thisdir/\$destdir\" ;;
                   5792:       esac
                   5793:     fi
                   5794: 
                   5795:     file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
                   5796:     file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
                   5797:   done
                   5798: 
1.7     ! moko     5799:   # Usually 'no', except on cygwin/mingw/windows when embedded into
1.6       moko     5800:   # the cwrapper.
                   5801:   WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
                   5802:   if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
                   5803:     # special case for '.'
                   5804:     if test \"\$thisdir\" = \".\"; then
                   5805:       thisdir=\`pwd\`
                   5806:     fi
                   5807:     # remove .libs from thisdir
                   5808:     case \"\$thisdir\" in
                   5809:     *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
                   5810:     $objdir )   thisdir=. ;;
                   5811:     esac
                   5812:   fi
                   5813: 
                   5814:   # Try to get the absolute directory name.
                   5815:   absdir=\`cd \"\$thisdir\" && pwd\`
                   5816:   test -n \"\$absdir\" && thisdir=\"\$absdir\"
                   5817: "
                   5818: 
1.7     ! moko     5819:        if test yes = "$fast_install"; then
1.6       moko     5820:          $ECHO "\
                   5821:   program=lt-'$outputname'$exeext
                   5822:   progdir=\"\$thisdir/$objdir\"
                   5823: 
                   5824:   if test ! -f \"\$progdir/\$program\" ||
1.7     ! moko     5825:      { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
1.6       moko     5826:        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
                   5827: 
                   5828:     file=\"\$\$-\$program\"
                   5829: 
                   5830:     if test ! -d \"\$progdir\"; then
                   5831:       $MKDIR \"\$progdir\"
                   5832:     else
                   5833:       $RM \"\$progdir/\$file\"
                   5834:     fi"
                   5835: 
                   5836:          $ECHO "\
                   5837: 
                   5838:     # relink executable if necessary
                   5839:     if test -n \"\$relink_command\"; then
                   5840:       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
                   5841:       else
1.7     ! moko     5842:        \$ECHO \"\$relink_command_output\" >&2
1.6       moko     5843:        $RM \"\$progdir/\$file\"
                   5844:        exit 1
                   5845:       fi
                   5846:     fi
                   5847: 
                   5848:     $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
                   5849:     { $RM \"\$progdir/\$program\";
                   5850:       $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
                   5851:     $RM \"\$progdir/\$file\"
                   5852:   fi"
                   5853:        else
                   5854:          $ECHO "\
                   5855:   program='$outputname'
                   5856:   progdir=\"\$thisdir/$objdir\"
                   5857: "
                   5858:        fi
                   5859: 
                   5860:        $ECHO "\
                   5861: 
                   5862:   if test -f \"\$progdir/\$program\"; then"
                   5863: 
                   5864:        # fixup the dll searchpath if we need to.
                   5865:        #
                   5866:        # Fix the DLL searchpath if we need to.  Do this before prepending
                   5867:        # to shlibpath, because on Windows, both are PATH and uninstalled
                   5868:        # libraries must come first.
                   5869:        if test -n "$dllsearchpath"; then
                   5870:          $ECHO "\
                   5871:     # Add the dll search path components to the executable PATH
                   5872:     PATH=$dllsearchpath:\$PATH
                   5873: "
                   5874:        fi
                   5875: 
                   5876:        # Export our shlibpath_var if we have one.
1.7     ! moko     5877:        if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
1.6       moko     5878:          $ECHO "\
                   5879:     # Add our own library path to $shlibpath_var
                   5880:     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
                   5881: 
                   5882:     # Some systems cannot cope with colon-terminated $shlibpath_var
                   5883:     # The second colon is a workaround for a bug in BeOS R4 sed
                   5884:     $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
                   5885: 
                   5886:     export $shlibpath_var
                   5887: "
                   5888:        fi
                   5889: 
                   5890:        $ECHO "\
                   5891:     if test \"\$libtool_execute_magic\" != \"$magic\"; then
                   5892:       # Run the actual program with our arguments.
                   5893:       func_exec_program \${1+\"\$@\"}
                   5894:     fi
                   5895:   else
                   5896:     # The program doesn't exist.
1.7     ! moko     5897:     \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
1.6       moko     5898:     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
                   5899:     \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
                   5900:     exit 1
                   5901:   fi
                   5902: fi\
                   5903: "
                   5904: }
                   5905: 
                   5906: 
                   5907: # func_emit_cwrapperexe_src
                   5908: # emit the source code for a wrapper executable on stdout
                   5909: # Must ONLY be called from within func_mode_link because
                   5910: # it depends on a number of variable set therein.
                   5911: func_emit_cwrapperexe_src ()
                   5912: {
                   5913:        cat <<EOF
                   5914: 
                   5915: /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
1.7     ! moko     5916:    Generated by $PROGRAM (GNU $PACKAGE) $VERSION
1.6       moko     5917: 
                   5918:    The $output program cannot be directly executed until all the libtool
                   5919:    libraries that it depends on are installed.
                   5920: 
                   5921:    This wrapper executable should never be moved out of the build directory.
                   5922:    If it is, it will not operate correctly.
                   5923: */
                   5924: EOF
                   5925:            cat <<"EOF"
                   5926: #ifdef _MSC_VER
                   5927: # define _CRT_SECURE_NO_DEPRECATE 1
                   5928: #endif
                   5929: #include <stdio.h>
                   5930: #include <stdlib.h>
1.7     ! moko     5931: #if defined _WIN32 && !defined __GNUC__
1.6       moko     5932: # include <direct.h>
                   5933: # include <process.h>
                   5934: # include <io.h>
                   5935: #else
                   5936: # include <unistd.h>
                   5937: # include <stdint.h>
                   5938: # ifdef __CYGWIN__
                   5939: #  include <io.h>
                   5940: # endif
                   5941: #endif
                   5942: #include <malloc.h>
                   5943: #include <stdarg.h>
                   5944: #include <assert.h>
                   5945: #include <string.h>
                   5946: #include <ctype.h>
                   5947: #include <errno.h>
                   5948: #include <fcntl.h>
                   5949: #include <sys/stat.h>
                   5950: 
1.7     ! moko     5951: #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
        !          5952: 
1.6       moko     5953: /* declarations of non-ANSI functions */
1.7     ! moko     5954: #if defined __MINGW32__
1.6       moko     5955: # ifdef __STRICT_ANSI__
1.7     ! moko     5956: _CRTIMP int __cdecl _putenv (const char *);
1.6       moko     5957: # endif
1.7     ! moko     5958: #elif defined __CYGWIN__
1.6       moko     5959: # ifdef __STRICT_ANSI__
                   5960: char *realpath (const char *, char *);
                   5961: int putenv (char *);
                   5962: int setenv (const char *, const char *, int);
                   5963: # endif
1.7     ! moko     5964: /* #elif defined other_platform || defined ... */
1.6       moko     5965: #endif
                   5966: 
                   5967: /* portability defines, excluding path handling macros */
1.7     ! moko     5968: #if defined _MSC_VER
1.6       moko     5969: # define setmode _setmode
                   5970: # define stat    _stat
                   5971: # define chmod   _chmod
                   5972: # define getcwd  _getcwd
                   5973: # define putenv  _putenv
                   5974: # define S_IXUSR _S_IEXEC
1.7     ! moko     5975: #elif defined __MINGW32__
1.6       moko     5976: # define setmode _setmode
                   5977: # define stat    _stat
                   5978: # define chmod   _chmod
                   5979: # define getcwd  _getcwd
                   5980: # define putenv  _putenv
1.7     ! moko     5981: #elif defined __CYGWIN__
1.6       moko     5982: # define HAVE_SETENV
                   5983: # define FOPEN_WB "wb"
1.7     ! moko     5984: /* #elif defined other platforms ... */
1.6       moko     5985: #endif
                   5986: 
1.7     ! moko     5987: #if defined PATH_MAX
1.6       moko     5988: # define LT_PATHMAX PATH_MAX
1.7     ! moko     5989: #elif defined MAXPATHLEN
1.6       moko     5990: # define LT_PATHMAX MAXPATHLEN
                   5991: #else
                   5992: # define LT_PATHMAX 1024
                   5993: #endif
                   5994: 
                   5995: #ifndef S_IXOTH
                   5996: # define S_IXOTH 0
                   5997: #endif
                   5998: #ifndef S_IXGRP
                   5999: # define S_IXGRP 0
                   6000: #endif
                   6001: 
                   6002: /* path handling portability macros */
                   6003: #ifndef DIR_SEPARATOR
                   6004: # define DIR_SEPARATOR '/'
                   6005: # define PATH_SEPARATOR ':'
                   6006: #endif
                   6007: 
1.7     ! moko     6008: #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
        !          6009:   defined __OS2__
1.6       moko     6010: # define HAVE_DOS_BASED_FILE_SYSTEM
                   6011: # define FOPEN_WB "wb"
                   6012: # ifndef DIR_SEPARATOR_2
                   6013: #  define DIR_SEPARATOR_2 '\\'
                   6014: # endif
                   6015: # ifndef PATH_SEPARATOR_2
                   6016: #  define PATH_SEPARATOR_2 ';'
                   6017: # endif
                   6018: #endif
                   6019: 
                   6020: #ifndef DIR_SEPARATOR_2
                   6021: # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
                   6022: #else /* DIR_SEPARATOR_2 */
                   6023: # define IS_DIR_SEPARATOR(ch) \
                   6024:        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
                   6025: #endif /* DIR_SEPARATOR_2 */
                   6026: 
                   6027: #ifndef PATH_SEPARATOR_2
                   6028: # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
                   6029: #else /* PATH_SEPARATOR_2 */
                   6030: # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
                   6031: #endif /* PATH_SEPARATOR_2 */
                   6032: 
                   6033: #ifndef FOPEN_WB
                   6034: # define FOPEN_WB "w"
                   6035: #endif
                   6036: #ifndef _O_BINARY
                   6037: # define _O_BINARY 0
                   6038: #endif
                   6039: 
                   6040: #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
                   6041: #define XFREE(stale) do { \
1.7     ! moko     6042:   if (stale) { free (stale); stale = 0; } \
1.6       moko     6043: } while (0)
                   6044: 
1.7     ! moko     6045: #if defined LT_DEBUGWRAPPER
1.6       moko     6046: static int lt_debug = 1;
                   6047: #else
                   6048: static int lt_debug = 0;
                   6049: #endif
                   6050: 
                   6051: const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
                   6052: 
                   6053: void *xmalloc (size_t num);
                   6054: char *xstrdup (const char *string);
                   6055: const char *base_name (const char *name);
                   6056: char *find_executable (const char *wrapper);
                   6057: char *chase_symlinks (const char *pathspec);
                   6058: int make_executable (const char *path);
                   6059: int check_executable (const char *path);
                   6060: char *strendzap (char *str, const char *pat);
                   6061: void lt_debugprintf (const char *file, int line, const char *fmt, ...);
                   6062: void lt_fatal (const char *file, int line, const char *message, ...);
                   6063: static const char *nonnull (const char *s);
                   6064: static const char *nonempty (const char *s);
                   6065: void lt_setenv (const char *name, const char *value);
                   6066: char *lt_extend_str (const char *orig_value, const char *add, int to_end);
                   6067: void lt_update_exe_path (const char *name, const char *value);
                   6068: void lt_update_lib_path (const char *name, const char *value);
                   6069: char **prepare_spawn (char **argv);
                   6070: void lt_dump_script (FILE *f);
                   6071: EOF
                   6072: 
                   6073:            cat <<EOF
1.7     ! moko     6074: #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
        !          6075: # define externally_visible volatile
        !          6076: #else
        !          6077: # define externally_visible __attribute__((externally_visible)) volatile
        !          6078: #endif
        !          6079: externally_visible const char * MAGIC_EXE = "$magic_exe";
1.6       moko     6080: const char * LIB_PATH_VARNAME = "$shlibpath_var";
                   6081: EOF
                   6082: 
1.7     ! moko     6083:            if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
1.6       moko     6084:               func_to_host_path "$temp_rpath"
                   6085:              cat <<EOF
                   6086: const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
                   6087: EOF
                   6088:            else
                   6089:              cat <<"EOF"
                   6090: const char * LIB_PATH_VALUE   = "";
                   6091: EOF
                   6092:            fi
                   6093: 
                   6094:            if test -n "$dllsearchpath"; then
                   6095:               func_to_host_path "$dllsearchpath:"
                   6096:              cat <<EOF
                   6097: const char * EXE_PATH_VARNAME = "PATH";
                   6098: const char * EXE_PATH_VALUE   = "$func_to_host_path_result";
                   6099: EOF
                   6100:            else
                   6101:              cat <<"EOF"
                   6102: const char * EXE_PATH_VARNAME = "";
                   6103: const char * EXE_PATH_VALUE   = "";
                   6104: EOF
                   6105:            fi
                   6106: 
1.7     ! moko     6107:            if test yes = "$fast_install"; then
1.6       moko     6108:              cat <<EOF
                   6109: const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
                   6110: EOF
                   6111:            else
                   6112:              cat <<EOF
                   6113: const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
                   6114: EOF
                   6115:            fi
                   6116: 
                   6117: 
                   6118:            cat <<"EOF"
                   6119: 
                   6120: #define LTWRAPPER_OPTION_PREFIX         "--lt-"
                   6121: 
                   6122: static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
                   6123: static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
                   6124: static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
                   6125: 
                   6126: int
                   6127: main (int argc, char *argv[])
                   6128: {
                   6129:   char **newargz;
                   6130:   int  newargc;
                   6131:   char *tmp_pathspec;
                   6132:   char *actual_cwrapper_path;
                   6133:   char *actual_cwrapper_name;
                   6134:   char *target_name;
                   6135:   char *lt_argv_zero;
1.7     ! moko     6136:   int rval = 127;
1.6       moko     6137: 
                   6138:   int i;
                   6139: 
                   6140:   program_name = (char *) xstrdup (base_name (argv[0]));
1.7     ! moko     6141:   newargz = XMALLOC (char *, (size_t) argc + 1);
1.6       moko     6142: 
                   6143:   /* very simple arg parsing; don't want to rely on getopt
                   6144:    * also, copy all non cwrapper options to newargz, except
                   6145:    * argz[0], which is handled differently
                   6146:    */
                   6147:   newargc=0;
                   6148:   for (i = 1; i < argc; i++)
                   6149:     {
1.7     ! moko     6150:       if (STREQ (argv[i], dumpscript_opt))
1.6       moko     6151:        {
                   6152: EOF
1.7     ! moko     6153:            case $host in
        !          6154:              *mingw* | *windows* | *cygwin* )
1.6       moko     6155:                # make stdout use "unix" line endings
                   6156:                echo "          setmode(1,_O_BINARY);"
                   6157:                ;;
                   6158:              esac
                   6159: 
                   6160:            cat <<"EOF"
                   6161:          lt_dump_script (stdout);
                   6162:          return 0;
                   6163:        }
1.7     ! moko     6164:       if (STREQ (argv[i], debug_opt))
1.6       moko     6165:        {
                   6166:           lt_debug = 1;
                   6167:           continue;
                   6168:        }
1.7     ! moko     6169:       if (STREQ (argv[i], ltwrapper_option_prefix))
1.6       moko     6170:         {
                   6171:           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
                   6172:              namespace, but it is not one of the ones we know about and
1.7     ! moko     6173:              have already dealt with, above (including dump-script), then
1.6       moko     6174:              report an error. Otherwise, targets might begin to believe
                   6175:              they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
                   6176:              namespace. The first time any user complains about this, we'll
                   6177:              need to make LTWRAPPER_OPTION_PREFIX a configure-time option
                   6178:              or a configure.ac-settable value.
                   6179:            */
                   6180:           lt_fatal (__FILE__, __LINE__,
                   6181:                    "unrecognized %s option: '%s'",
                   6182:                     ltwrapper_option_prefix, argv[i]);
                   6183:         }
                   6184:       /* otherwise ... */
                   6185:       newargz[++newargc] = xstrdup (argv[i]);
                   6186:     }
                   6187:   newargz[++newargc] = NULL;
                   6188: 
                   6189: EOF
                   6190:            cat <<EOF
                   6191:   /* The GNU banner must be the first non-error debug message */
1.7     ! moko     6192:   lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
1.6       moko     6193: EOF
                   6194:            cat <<"EOF"
                   6195:   lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
                   6196:   lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
                   6197: 
                   6198:   tmp_pathspec = find_executable (argv[0]);
                   6199:   if (tmp_pathspec == NULL)
                   6200:     lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
                   6201:   lt_debugprintf (__FILE__, __LINE__,
                   6202:                   "(main) found exe (before symlink chase) at: %s\n",
                   6203:                  tmp_pathspec);
                   6204: 
                   6205:   actual_cwrapper_path = chase_symlinks (tmp_pathspec);
                   6206:   lt_debugprintf (__FILE__, __LINE__,
                   6207:                   "(main) found exe (after symlink chase) at: %s\n",
                   6208:                  actual_cwrapper_path);
                   6209:   XFREE (tmp_pathspec);
                   6210: 
                   6211:   actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
                   6212:   strendzap (actual_cwrapper_path, actual_cwrapper_name);
                   6213: 
                   6214:   /* wrapper name transforms */
                   6215:   strendzap (actual_cwrapper_name, ".exe");
                   6216:   tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
                   6217:   XFREE (actual_cwrapper_name);
                   6218:   actual_cwrapper_name = tmp_pathspec;
                   6219:   tmp_pathspec = 0;
                   6220: 
                   6221:   /* target_name transforms -- use actual target program name; might have lt- prefix */
                   6222:   target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
                   6223:   strendzap (target_name, ".exe");
                   6224:   tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
                   6225:   XFREE (target_name);
                   6226:   target_name = tmp_pathspec;
                   6227:   tmp_pathspec = 0;
                   6228: 
                   6229:   lt_debugprintf (__FILE__, __LINE__,
                   6230:                  "(main) libtool target name: %s\n",
                   6231:                  target_name);
                   6232: EOF
                   6233: 
                   6234:            cat <<EOF
                   6235:   newargz[0] =
                   6236:     XMALLOC (char, (strlen (actual_cwrapper_path) +
                   6237:                    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
                   6238:   strcpy (newargz[0], actual_cwrapper_path);
                   6239:   strcat (newargz[0], "$objdir");
                   6240:   strcat (newargz[0], "/");
                   6241: EOF
                   6242: 
                   6243:            cat <<"EOF"
                   6244:   /* stop here, and copy so we don't have to do this twice */
                   6245:   tmp_pathspec = xstrdup (newargz[0]);
                   6246: 
                   6247:   /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
                   6248:   strcat (newargz[0], actual_cwrapper_name);
                   6249: 
                   6250:   /* DO want the lt- prefix here if it exists, so use target_name */
                   6251:   lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
                   6252:   XFREE (tmp_pathspec);
                   6253:   tmp_pathspec = NULL;
                   6254: EOF
                   6255: 
                   6256:            case $host_os in
1.7     ! moko     6257:              mingw* | windows*)
1.6       moko     6258:            cat <<"EOF"
                   6259:   {
                   6260:     char* p;
                   6261:     while ((p = strchr (newargz[0], '\\')) != NULL)
                   6262:       {
                   6263:        *p = '/';
                   6264:       }
                   6265:     while ((p = strchr (lt_argv_zero, '\\')) != NULL)
                   6266:       {
                   6267:        *p = '/';
                   6268:       }
                   6269:   }
                   6270: EOF
                   6271:            ;;
                   6272:            esac
                   6273: 
                   6274:            cat <<"EOF"
                   6275:   XFREE (target_name);
                   6276:   XFREE (actual_cwrapper_path);
                   6277:   XFREE (actual_cwrapper_name);
                   6278: 
                   6279:   lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
                   6280:   lt_setenv ("DUALCASE", "1");  /* for MSK sh */
                   6281:   /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
                   6282:      be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
                   6283:      because on Windows, both *_VARNAMEs are PATH but uninstalled
                   6284:      libraries must come first. */
                   6285:   lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
                   6286:   lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
                   6287: 
                   6288:   lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
                   6289:                  nonnull (lt_argv_zero));
                   6290:   for (i = 0; i < newargc; i++)
                   6291:     {
                   6292:       lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
                   6293:                      i, nonnull (newargz[i]));
                   6294:     }
                   6295: 
                   6296: EOF
                   6297: 
                   6298:            case $host_os in
1.7     ! moko     6299:              mingw* | windows*)
1.6       moko     6300:                cat <<"EOF"
                   6301:   /* execv doesn't actually work on mingw as expected on unix */
                   6302:   newargz = prepare_spawn (newargz);
1.7     ! moko     6303:   rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
1.6       moko     6304:   if (rval == -1)
                   6305:     {
                   6306:       /* failed to start process */
                   6307:       lt_debugprintf (__FILE__, __LINE__,
                   6308:                      "(main) failed to launch target \"%s\": %s\n",
                   6309:                      lt_argv_zero, nonnull (strerror (errno)));
                   6310:       return 127;
                   6311:     }
                   6312:   return rval;
                   6313: EOF
                   6314:                ;;
                   6315:              *)
                   6316:                cat <<"EOF"
                   6317:   execv (lt_argv_zero, newargz);
                   6318:   return rval; /* =127, but avoids unused variable warning */
                   6319: EOF
                   6320:                ;;
                   6321:            esac
                   6322: 
                   6323:            cat <<"EOF"
                   6324: }
                   6325: 
                   6326: void *
                   6327: xmalloc (size_t num)
                   6328: {
                   6329:   void *p = (void *) malloc (num);
                   6330:   if (!p)
                   6331:     lt_fatal (__FILE__, __LINE__, "memory exhausted");
                   6332: 
                   6333:   return p;
                   6334: }
                   6335: 
                   6336: char *
                   6337: xstrdup (const char *string)
                   6338: {
                   6339:   return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
                   6340:                          string) : NULL;
                   6341: }
                   6342: 
                   6343: const char *
                   6344: base_name (const char *name)
                   6345: {
                   6346:   const char *base;
                   6347: 
1.7     ! moko     6348: #if defined HAVE_DOS_BASED_FILE_SYSTEM
1.6       moko     6349:   /* Skip over the disk name in MSDOS pathnames. */
                   6350:   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
                   6351:     name += 2;
                   6352: #endif
                   6353: 
                   6354:   for (base = name; *name; name++)
                   6355:     if (IS_DIR_SEPARATOR (*name))
                   6356:       base = name + 1;
                   6357:   return base;
                   6358: }
                   6359: 
                   6360: int
                   6361: check_executable (const char *path)
                   6362: {
                   6363:   struct stat st;
                   6364: 
                   6365:   lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
                   6366:                   nonempty (path));
                   6367:   if ((!path) || (!*path))
                   6368:     return 0;
                   6369: 
                   6370:   if ((stat (path, &st) >= 0)
                   6371:       && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
                   6372:     return 1;
                   6373:   else
                   6374:     return 0;
                   6375: }
                   6376: 
                   6377: int
                   6378: make_executable (const char *path)
                   6379: {
                   6380:   int rval = 0;
                   6381:   struct stat st;
                   6382: 
                   6383:   lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
                   6384:                   nonempty (path));
                   6385:   if ((!path) || (!*path))
                   6386:     return 0;
                   6387: 
                   6388:   if (stat (path, &st) >= 0)
                   6389:     {
                   6390:       rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
                   6391:     }
                   6392:   return rval;
                   6393: }
                   6394: 
                   6395: /* Searches for the full path of the wrapper.  Returns
                   6396:    newly allocated full path name if found, NULL otherwise
                   6397:    Does not chase symlinks, even on platforms that support them.
                   6398: */
                   6399: char *
                   6400: find_executable (const char *wrapper)
                   6401: {
                   6402:   int has_slash = 0;
                   6403:   const char *p;
                   6404:   const char *p_next;
                   6405:   /* static buffer for getcwd */
                   6406:   char tmp[LT_PATHMAX + 1];
1.7     ! moko     6407:   size_t tmp_len;
1.6       moko     6408:   char *concat_name;
                   6409: 
                   6410:   lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
                   6411:                   nonempty (wrapper));
                   6412: 
                   6413:   if ((wrapper == NULL) || (*wrapper == '\0'))
                   6414:     return NULL;
                   6415: 
                   6416:   /* Absolute path? */
1.7     ! moko     6417: #if defined HAVE_DOS_BASED_FILE_SYSTEM
1.6       moko     6418:   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
                   6419:     {
                   6420:       concat_name = xstrdup (wrapper);
                   6421:       if (check_executable (concat_name))
                   6422:        return concat_name;
                   6423:       XFREE (concat_name);
                   6424:     }
                   6425:   else
                   6426:     {
                   6427: #endif
                   6428:       if (IS_DIR_SEPARATOR (wrapper[0]))
                   6429:        {
                   6430:          concat_name = xstrdup (wrapper);
                   6431:          if (check_executable (concat_name))
                   6432:            return concat_name;
                   6433:          XFREE (concat_name);
                   6434:        }
1.7     ! moko     6435: #if defined HAVE_DOS_BASED_FILE_SYSTEM
1.6       moko     6436:     }
                   6437: #endif
                   6438: 
                   6439:   for (p = wrapper; *p; p++)
                   6440:     if (*p == '/')
                   6441:       {
                   6442:        has_slash = 1;
                   6443:        break;
                   6444:       }
                   6445:   if (!has_slash)
                   6446:     {
                   6447:       /* no slashes; search PATH */
                   6448:       const char *path = getenv ("PATH");
                   6449:       if (path != NULL)
                   6450:        {
                   6451:          for (p = path; *p; p = p_next)
                   6452:            {
                   6453:              const char *q;
                   6454:              size_t p_len;
                   6455:              for (q = p; *q; q++)
                   6456:                if (IS_PATH_SEPARATOR (*q))
                   6457:                  break;
1.7     ! moko     6458:              p_len = (size_t) (q - p);
1.6       moko     6459:              p_next = (*q == '\0' ? q : q + 1);
                   6460:              if (p_len == 0)
                   6461:                {
                   6462:                  /* empty path: current directory */
                   6463:                  if (getcwd (tmp, LT_PATHMAX) == NULL)
                   6464:                    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
                   6465:                               nonnull (strerror (errno)));
                   6466:                  tmp_len = strlen (tmp);
                   6467:                  concat_name =
                   6468:                    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
                   6469:                  memcpy (concat_name, tmp, tmp_len);
                   6470:                  concat_name[tmp_len] = '/';
                   6471:                  strcpy (concat_name + tmp_len + 1, wrapper);
                   6472:                }
                   6473:              else
                   6474:                {
                   6475:                  concat_name =
                   6476:                    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
                   6477:                  memcpy (concat_name, p, p_len);
                   6478:                  concat_name[p_len] = '/';
                   6479:                  strcpy (concat_name + p_len + 1, wrapper);
                   6480:                }
                   6481:              if (check_executable (concat_name))
                   6482:                return concat_name;
                   6483:              XFREE (concat_name);
                   6484:            }
                   6485:        }
                   6486:       /* not found in PATH; assume curdir */
                   6487:     }
                   6488:   /* Relative path | not found in path: prepend cwd */
                   6489:   if (getcwd (tmp, LT_PATHMAX) == NULL)
                   6490:     lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
                   6491:               nonnull (strerror (errno)));
                   6492:   tmp_len = strlen (tmp);
                   6493:   concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
                   6494:   memcpy (concat_name, tmp, tmp_len);
                   6495:   concat_name[tmp_len] = '/';
                   6496:   strcpy (concat_name + tmp_len + 1, wrapper);
                   6497: 
                   6498:   if (check_executable (concat_name))
                   6499:     return concat_name;
                   6500:   XFREE (concat_name);
                   6501:   return NULL;
                   6502: }
                   6503: 
                   6504: char *
                   6505: chase_symlinks (const char *pathspec)
                   6506: {
                   6507: #ifndef S_ISLNK
                   6508:   return xstrdup (pathspec);
                   6509: #else
                   6510:   char buf[LT_PATHMAX];
                   6511:   struct stat s;
                   6512:   char *tmp_pathspec = xstrdup (pathspec);
                   6513:   char *p;
                   6514:   int has_symlinks = 0;
                   6515:   while (strlen (tmp_pathspec) && !has_symlinks)
                   6516:     {
                   6517:       lt_debugprintf (__FILE__, __LINE__,
                   6518:                      "checking path component for symlinks: %s\n",
                   6519:                      tmp_pathspec);
                   6520:       if (lstat (tmp_pathspec, &s) == 0)
                   6521:        {
                   6522:          if (S_ISLNK (s.st_mode) != 0)
                   6523:            {
                   6524:              has_symlinks = 1;
                   6525:              break;
                   6526:            }
                   6527: 
                   6528:          /* search backwards for last DIR_SEPARATOR */
                   6529:          p = tmp_pathspec + strlen (tmp_pathspec) - 1;
                   6530:          while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
                   6531:            p--;
                   6532:          if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
                   6533:            {
                   6534:              /* no more DIR_SEPARATORS left */
                   6535:              break;
                   6536:            }
                   6537:          *p = '\0';
                   6538:        }
                   6539:       else
                   6540:        {
                   6541:          lt_fatal (__FILE__, __LINE__,
                   6542:                    "error accessing file \"%s\": %s",
                   6543:                    tmp_pathspec, nonnull (strerror (errno)));
                   6544:        }
                   6545:     }
                   6546:   XFREE (tmp_pathspec);
                   6547: 
                   6548:   if (!has_symlinks)
                   6549:     {
                   6550:       return xstrdup (pathspec);
                   6551:     }
                   6552: 
                   6553:   tmp_pathspec = realpath (pathspec, buf);
                   6554:   if (tmp_pathspec == 0)
                   6555:     {
                   6556:       lt_fatal (__FILE__, __LINE__,
                   6557:                "could not follow symlinks for %s", pathspec);
                   6558:     }
                   6559:   return xstrdup (tmp_pathspec);
                   6560: #endif
                   6561: }
                   6562: 
                   6563: char *
                   6564: strendzap (char *str, const char *pat)
                   6565: {
                   6566:   size_t len, patlen;
                   6567: 
                   6568:   assert (str != NULL);
                   6569:   assert (pat != NULL);
                   6570: 
                   6571:   len = strlen (str);
                   6572:   patlen = strlen (pat);
                   6573: 
                   6574:   if (patlen <= len)
                   6575:     {
                   6576:       str += len - patlen;
1.7     ! moko     6577:       if (STREQ (str, pat))
1.6       moko     6578:        *str = '\0';
                   6579:     }
                   6580:   return str;
                   6581: }
                   6582: 
                   6583: void
                   6584: lt_debugprintf (const char *file, int line, const char *fmt, ...)
                   6585: {
                   6586:   va_list args;
                   6587:   if (lt_debug)
                   6588:     {
                   6589:       (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
                   6590:       va_start (args, fmt);
                   6591:       (void) vfprintf (stderr, fmt, args);
                   6592:       va_end (args);
                   6593:     }
                   6594: }
                   6595: 
                   6596: static void
                   6597: lt_error_core (int exit_status, const char *file,
                   6598:               int line, const char *mode,
                   6599:               const char *message, va_list ap)
                   6600: {
                   6601:   fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
                   6602:   vfprintf (stderr, message, ap);
                   6603:   fprintf (stderr, ".\n");
                   6604: 
                   6605:   if (exit_status >= 0)
                   6606:     exit (exit_status);
                   6607: }
                   6608: 
                   6609: void
                   6610: lt_fatal (const char *file, int line, const char *message, ...)
                   6611: {
                   6612:   va_list ap;
                   6613:   va_start (ap, message);
                   6614:   lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
                   6615:   va_end (ap);
                   6616: }
                   6617: 
                   6618: static const char *
                   6619: nonnull (const char *s)
                   6620: {
                   6621:   return s ? s : "(null)";
                   6622: }
                   6623: 
                   6624: static const char *
                   6625: nonempty (const char *s)
                   6626: {
                   6627:   return (s && !*s) ? "(empty)" : nonnull (s);
                   6628: }
                   6629: 
                   6630: void
                   6631: lt_setenv (const char *name, const char *value)
                   6632: {
                   6633:   lt_debugprintf (__FILE__, __LINE__,
                   6634:                  "(lt_setenv) setting '%s' to '%s'\n",
                   6635:                   nonnull (name), nonnull (value));
                   6636:   {
                   6637: #ifdef HAVE_SETENV
                   6638:     /* always make a copy, for consistency with !HAVE_SETENV */
                   6639:     char *str = xstrdup (value);
                   6640:     setenv (name, str, 1);
                   6641: #else
1.7     ! moko     6642:     size_t len = strlen (name) + 1 + strlen (value) + 1;
1.6       moko     6643:     char *str = XMALLOC (char, len);
                   6644:     sprintf (str, "%s=%s", name, value);
                   6645:     if (putenv (str) != EXIT_SUCCESS)
                   6646:       {
                   6647:         XFREE (str);
                   6648:       }
                   6649: #endif
                   6650:   }
                   6651: }
                   6652: 
                   6653: char *
                   6654: lt_extend_str (const char *orig_value, const char *add, int to_end)
                   6655: {
                   6656:   char *new_value;
                   6657:   if (orig_value && *orig_value)
                   6658:     {
1.7     ! moko     6659:       size_t orig_value_len = strlen (orig_value);
        !          6660:       size_t add_len = strlen (add);
1.6       moko     6661:       new_value = XMALLOC (char, add_len + orig_value_len + 1);
                   6662:       if (to_end)
                   6663:         {
                   6664:           strcpy (new_value, orig_value);
                   6665:           strcpy (new_value + orig_value_len, add);
                   6666:         }
                   6667:       else
                   6668:         {
                   6669:           strcpy (new_value, add);
                   6670:           strcpy (new_value + add_len, orig_value);
                   6671:         }
                   6672:     }
                   6673:   else
                   6674:     {
                   6675:       new_value = xstrdup (add);
                   6676:     }
                   6677:   return new_value;
                   6678: }
                   6679: 
                   6680: void
                   6681: lt_update_exe_path (const char *name, const char *value)
                   6682: {
                   6683:   lt_debugprintf (__FILE__, __LINE__,
                   6684:                  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
                   6685:                   nonnull (name), nonnull (value));
                   6686: 
                   6687:   if (name && *name && value && *value)
                   6688:     {
                   6689:       char *new_value = lt_extend_str (getenv (name), value, 0);
                   6690:       /* some systems can't cope with a ':'-terminated path #' */
1.7     ! moko     6691:       size_t len = strlen (new_value);
        !          6692:       while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
1.6       moko     6693:         {
1.7     ! moko     6694:           new_value[--len] = '\0';
1.6       moko     6695:         }
                   6696:       lt_setenv (name, new_value);
                   6697:       XFREE (new_value);
                   6698:     }
                   6699: }
                   6700: 
                   6701: void
                   6702: lt_update_lib_path (const char *name, const char *value)
                   6703: {
                   6704:   lt_debugprintf (__FILE__, __LINE__,
                   6705:                  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
                   6706:                   nonnull (name), nonnull (value));
                   6707: 
                   6708:   if (name && *name && value && *value)
                   6709:     {
                   6710:       char *new_value = lt_extend_str (getenv (name), value, 0);
                   6711:       lt_setenv (name, new_value);
                   6712:       XFREE (new_value);
                   6713:     }
                   6714: }
                   6715: 
                   6716: EOF
                   6717:            case $host_os in
1.7     ! moko     6718:              mingw* | windows*)
1.6       moko     6719:                cat <<"EOF"
                   6720: 
                   6721: /* Prepares an argument vector before calling spawn().
                   6722:    Note that spawn() does not by itself call the command interpreter
                   6723:      (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
                   6724:       ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
                   6725:          GetVersionEx(&v);
                   6726:          v.dwPlatformId == VER_PLATFORM_WIN32_NT;
                   6727:       }) ? "cmd.exe" : "command.com").
                   6728:    Instead it simply concatenates the arguments, separated by ' ', and calls
                   6729:    CreateProcess().  We must quote the arguments since Win32 CreateProcess()
                   6730:    interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
                   6731:    special way:
                   6732:    - Space and tab are interpreted as delimiters. They are not treated as
                   6733:      delimiters if they are surrounded by double quotes: "...".
                   6734:    - Unescaped double quotes are removed from the input. Their only effect is
                   6735:      that within double quotes, space and tab are treated like normal
                   6736:      characters.
                   6737:    - Backslashes not followed by double quotes are not special.
                   6738:    - But 2*n+1 backslashes followed by a double quote become
                   6739:      n backslashes followed by a double quote (n >= 0):
                   6740:        \" -> "
                   6741:        \\\" -> \"
                   6742:        \\\\\" -> \\"
                   6743:  */
                   6744: #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
                   6745: #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
                   6746: char **
                   6747: prepare_spawn (char **argv)
                   6748: {
                   6749:   size_t argc;
                   6750:   char **new_argv;
                   6751:   size_t i;
                   6752: 
                   6753:   /* Count number of arguments.  */
                   6754:   for (argc = 0; argv[argc] != NULL; argc++)
                   6755:     ;
                   6756: 
                   6757:   /* Allocate new argument vector.  */
                   6758:   new_argv = XMALLOC (char *, argc + 1);
                   6759: 
                   6760:   /* Put quoted arguments into the new argument vector.  */
                   6761:   for (i = 0; i < argc; i++)
                   6762:     {
                   6763:       const char *string = argv[i];
                   6764: 
                   6765:       if (string[0] == '\0')
                   6766:        new_argv[i] = xstrdup ("\"\"");
                   6767:       else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
                   6768:        {
                   6769:          int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
                   6770:          size_t length;
                   6771:          unsigned int backslashes;
                   6772:          const char *s;
                   6773:          char *quoted_string;
                   6774:          char *p;
                   6775: 
                   6776:          length = 0;
                   6777:          backslashes = 0;
                   6778:          if (quote_around)
                   6779:            length++;
                   6780:          for (s = string; *s != '\0'; s++)
                   6781:            {
                   6782:              char c = *s;
                   6783:              if (c == '"')
                   6784:                length += backslashes + 1;
                   6785:              length++;
                   6786:              if (c == '\\')
                   6787:                backslashes++;
                   6788:              else
                   6789:                backslashes = 0;
                   6790:            }
                   6791:          if (quote_around)
                   6792:            length += backslashes + 1;
                   6793: 
                   6794:          quoted_string = XMALLOC (char, length + 1);
                   6795: 
                   6796:          p = quoted_string;
                   6797:          backslashes = 0;
                   6798:          if (quote_around)
                   6799:            *p++ = '"';
                   6800:          for (s = string; *s != '\0'; s++)
                   6801:            {
                   6802:              char c = *s;
                   6803:              if (c == '"')
                   6804:                {
                   6805:                  unsigned int j;
                   6806:                  for (j = backslashes + 1; j > 0; j--)
                   6807:                    *p++ = '\\';
                   6808:                }
                   6809:              *p++ = c;
                   6810:              if (c == '\\')
                   6811:                backslashes++;
                   6812:              else
                   6813:                backslashes = 0;
                   6814:            }
                   6815:          if (quote_around)
                   6816:            {
                   6817:              unsigned int j;
                   6818:              for (j = backslashes; j > 0; j--)
                   6819:                *p++ = '\\';
                   6820:              *p++ = '"';
                   6821:            }
                   6822:          *p = '\0';
                   6823: 
                   6824:          new_argv[i] = quoted_string;
                   6825:        }
                   6826:       else
                   6827:        new_argv[i] = (char *) string;
                   6828:     }
                   6829:   new_argv[argc] = NULL;
                   6830: 
                   6831:   return new_argv;
                   6832: }
                   6833: EOF
                   6834:                ;;
                   6835:            esac
                   6836: 
                   6837:             cat <<"EOF"
                   6838: void lt_dump_script (FILE* f)
                   6839: {
                   6840: EOF
                   6841:            func_emit_wrapper yes |
                   6842:              $SED -n -e '
                   6843: s/^\(.\{79\}\)\(..*\)/\1\
                   6844: \2/
                   6845: h
                   6846: s/\([\\"]\)/\\\1/g
                   6847: s/$/\\n/
                   6848: s/\([^\n]*\).*/  fputs ("\1", f);/p
                   6849: g
                   6850: D'
                   6851:             cat <<"EOF"
                   6852: }
                   6853: EOF
                   6854: }
                   6855: # end: func_emit_cwrapperexe_src
                   6856: 
                   6857: # func_win32_import_lib_p ARG
                   6858: # True if ARG is an import lib, as indicated by $file_magic_cmd
                   6859: func_win32_import_lib_p ()
                   6860: {
1.7     ! moko     6861:     $debug_cmd
        !          6862: 
1.6       moko     6863:     case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
                   6864:     *import*) : ;;
                   6865:     *) false ;;
                   6866:     esac
                   6867: }
                   6868: 
1.7     ! moko     6869: # func_suncc_cstd_abi
        !          6870: # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
        !          6871: # Several compiler flags select an ABI that is incompatible with the
        !          6872: # Cstd library. Avoid specifying it if any are in CXXFLAGS.
        !          6873: func_suncc_cstd_abi ()
        !          6874: {
        !          6875:     $debug_cmd
        !          6876: 
        !          6877:     case " $compile_command " in
        !          6878:     *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
        !          6879:       suncc_use_cstd_abi=no
        !          6880:       ;;
        !          6881:     *)
        !          6882:       suncc_use_cstd_abi=yes
        !          6883:       ;;
        !          6884:     esac
        !          6885: }
        !          6886: 
1.6       moko     6887: # func_mode_link arg...
                   6888: func_mode_link ()
                   6889: {
1.7     ! moko     6890:     $debug_cmd
        !          6891: 
1.6       moko     6892:     case $host in
1.7     ! moko     6893:     *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
1.6       moko     6894:       # It is impossible to link a dll without this setting, and
                   6895:       # we shouldn't force the makefile maintainer to figure out
1.7     ! moko     6896:       # what system we are compiling for in order to pass an extra
1.6       moko     6897:       # flag for every libtool invocation.
                   6898:       # allow_undefined=no
                   6899: 
                   6900:       # FIXME: Unfortunately, there are problems with the above when trying
1.7     ! moko     6901:       # to make a dll that has undefined symbols, in which case not
1.6       moko     6902:       # even a static library is built.  For now, we need to specify
                   6903:       # -no-undefined on the libtool link line when we can be certain
                   6904:       # that all symbols are satisfied, otherwise we get a static library.
                   6905:       allow_undefined=yes
                   6906:       ;;
                   6907:     *)
                   6908:       allow_undefined=yes
                   6909:       ;;
                   6910:     esac
                   6911:     libtool_args=$nonopt
                   6912:     base_compile="$nonopt $@"
                   6913:     compile_command=$nonopt
                   6914:     finalize_command=$nonopt
                   6915: 
                   6916:     compile_rpath=
1.7     ! moko     6917:     compile_rpath_tail=
1.6       moko     6918:     finalize_rpath=
                   6919:     compile_shlibpath=
                   6920:     finalize_shlibpath=
                   6921:     convenience=
                   6922:     old_convenience=
                   6923:     deplibs=
                   6924:     old_deplibs=
                   6925:     compiler_flags=
                   6926:     linker_flags=
                   6927:     dllsearchpath=
                   6928:     lib_search_path=`pwd`
                   6929:     inst_prefix_dir=
                   6930:     new_inherited_linker_flags=
                   6931: 
                   6932:     avoid_version=no
                   6933:     bindir=
                   6934:     dlfiles=
                   6935:     dlprefiles=
                   6936:     dlself=no
                   6937:     export_dynamic=no
                   6938:     export_symbols=
                   6939:     export_symbols_regex=
                   6940:     generated=
                   6941:     libobjs=
                   6942:     ltlibs=
                   6943:     module=no
                   6944:     no_install=no
                   6945:     objs=
1.7     ! moko     6946:     os2dllname=
1.6       moko     6947:     non_pic_objects=
                   6948:     precious_files_regex=
                   6949:     prefer_static_libs=no
1.7     ! moko     6950:     preload=false
1.6       moko     6951:     prev=
                   6952:     prevarg=
                   6953:     release=
                   6954:     rpath=
                   6955:     xrpath=
                   6956:     perm_rpath=
                   6957:     temp_rpath=
1.7     ! moko     6958:     temp_rpath_tail=
1.6       moko     6959:     thread_safe=no
                   6960:     vinfo=
                   6961:     vinfo_number=no
                   6962:     weak_libs=
1.7     ! moko     6963:     rpath_arg=
        !          6964:     single_module=$wl-single_module
1.6       moko     6965:     func_infer_tag $base_compile
                   6966: 
                   6967:     # We need to know -static, to get the right output filenames.
                   6968:     for arg
                   6969:     do
                   6970:       case $arg in
                   6971:       -shared)
1.7     ! moko     6972:        test yes != "$build_libtool_libs" \
        !          6973:          && func_fatal_configuration "cannot build a shared library"
1.6       moko     6974:        build_old_libs=no
                   6975:        break
                   6976:        ;;
                   6977:       -all-static | -static | -static-libtool-libs)
                   6978:        case $arg in
                   6979:        -all-static)
1.7     ! moko     6980:          if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
1.6       moko     6981:            func_warning "complete static linking is impossible in this configuration"
                   6982:          fi
                   6983:          if test -n "$link_static_flag"; then
                   6984:            dlopen_self=$dlopen_self_static
                   6985:          fi
                   6986:          prefer_static_libs=yes
                   6987:          ;;
                   6988:        -static)
                   6989:          if test -z "$pic_flag" && test -n "$link_static_flag"; then
                   6990:            dlopen_self=$dlopen_self_static
                   6991:          fi
                   6992:          prefer_static_libs=built
                   6993:          ;;
                   6994:        -static-libtool-libs)
                   6995:          if test -z "$pic_flag" && test -n "$link_static_flag"; then
                   6996:            dlopen_self=$dlopen_self_static
                   6997:          fi
                   6998:          prefer_static_libs=yes
                   6999:          ;;
                   7000:        esac
                   7001:        build_libtool_libs=no
                   7002:        build_old_libs=yes
                   7003:        break
                   7004:        ;;
                   7005:       esac
                   7006:     done
                   7007: 
                   7008:     # See if our shared archives depend on static archives.
                   7009:     test -n "$old_archive_from_new_cmds" && build_old_libs=yes
                   7010: 
                   7011:     # Go through the arguments, transforming them on the way.
                   7012:     while test "$#" -gt 0; do
1.7     ! moko     7013:       arg=$1
1.6       moko     7014:       shift
1.7     ! moko     7015:       func_quote_arg pretty,unquoted "$arg"
        !          7016:       qarg=$func_quote_arg_unquoted_result
        !          7017:       func_append libtool_args " $func_quote_arg_result"
1.6       moko     7018: 
                   7019:       # If the previous option needs an argument, assign it.
                   7020:       if test -n "$prev"; then
                   7021:        case $prev in
                   7022:        output)
                   7023:          func_append compile_command " @OUTPUT@"
                   7024:          func_append finalize_command " @OUTPUT@"
                   7025:          ;;
                   7026:        esac
                   7027: 
                   7028:        case $prev in
                   7029:        bindir)
1.7     ! moko     7030:          bindir=$arg
1.6       moko     7031:          prev=
                   7032:          continue
                   7033:          ;;
                   7034:        dlfiles|dlprefiles)
1.7     ! moko     7035:          $preload || {
1.6       moko     7036:            # Add the symbol object into the linking commands.
                   7037:            func_append compile_command " @SYMFILE@"
                   7038:            func_append finalize_command " @SYMFILE@"
1.7     ! moko     7039:            preload=:
        !          7040:          }
1.6       moko     7041:          case $arg in
                   7042:          *.la | *.lo) ;;  # We handle these cases below.
                   7043:          force)
1.7     ! moko     7044:            if test no = "$dlself"; then
1.6       moko     7045:              dlself=needless
                   7046:              export_dynamic=yes
                   7047:            fi
                   7048:            prev=
                   7049:            continue
                   7050:            ;;
                   7051:          self)
1.7     ! moko     7052:            if test dlprefiles = "$prev"; then
1.6       moko     7053:              dlself=yes
1.7     ! moko     7054:            elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
1.6       moko     7055:              dlself=yes
                   7056:            else
                   7057:              dlself=needless
                   7058:              export_dynamic=yes
                   7059:            fi
                   7060:            prev=
                   7061:            continue
                   7062:            ;;
                   7063:          *)
1.7     ! moko     7064:            if test dlfiles = "$prev"; then
1.6       moko     7065:              func_append dlfiles " $arg"
                   7066:            else
                   7067:              func_append dlprefiles " $arg"
                   7068:            fi
                   7069:            prev=
                   7070:            continue
                   7071:            ;;
                   7072:          esac
                   7073:          ;;
                   7074:        expsyms)
1.7     ! moko     7075:          export_symbols=$arg
1.6       moko     7076:          test -f "$arg" \
1.7     ! moko     7077:            || func_fatal_error "symbol file '$arg' does not exist"
1.6       moko     7078:          prev=
                   7079:          continue
                   7080:          ;;
                   7081:        expsyms_regex)
1.7     ! moko     7082:          export_symbols_regex=$arg
1.6       moko     7083:          prev=
                   7084:          continue
                   7085:          ;;
                   7086:        framework)
                   7087:          case $host in
                   7088:            *-*-darwin*)
                   7089:              case "$deplibs " in
                   7090:                *" $qarg.ltframework "*) ;;
                   7091:                *) func_append deplibs " $qarg.ltframework" # this is fixed later
                   7092:                   ;;
                   7093:              esac
                   7094:              ;;
                   7095:          esac
                   7096:          prev=
                   7097:          continue
                   7098:          ;;
                   7099:        inst_prefix)
1.7     ! moko     7100:          inst_prefix_dir=$arg
        !          7101:          prev=
        !          7102:          continue
        !          7103:          ;;
        !          7104:        mllvm)
        !          7105:          # Clang does not use LLVM to link, so we can simply discard any
        !          7106:          # '-mllvm $arg' options when doing the link step.
1.6       moko     7107:          prev=
                   7108:          continue
                   7109:          ;;
                   7110:        objectlist)
                   7111:          if test -f "$arg"; then
                   7112:            save_arg=$arg
                   7113:            moreargs=
                   7114:            for fil in `cat "$save_arg"`
                   7115:            do
                   7116: #            func_append moreargs " $fil"
                   7117:              arg=$fil
                   7118:              # A libtool-controlled object.
                   7119: 
                   7120:              # Check to see that this really is a libtool object.
                   7121:              if func_lalib_unsafe_p "$arg"; then
                   7122:                pic_object=
                   7123:                non_pic_object=
                   7124: 
                   7125:                # Read the .lo file
                   7126:                func_source "$arg"
                   7127: 
                   7128:                if test -z "$pic_object" ||
                   7129:                   test -z "$non_pic_object" ||
1.7     ! moko     7130:                   test none = "$pic_object" &&
        !          7131:                   test none = "$non_pic_object"; then
        !          7132:                  func_fatal_error "cannot find name of object for '$arg'"
1.6       moko     7133:                fi
                   7134: 
                   7135:                # Extract subdirectory from the argument.
                   7136:                func_dirname "$arg" "/" ""
1.7     ! moko     7137:                xdir=$func_dirname_result
1.6       moko     7138: 
1.7     ! moko     7139:                if test none != "$pic_object"; then
1.6       moko     7140:                  # Prepend the subdirectory the object is found in.
1.7     ! moko     7141:                  pic_object=$xdir$pic_object
1.6       moko     7142: 
1.7     ! moko     7143:                  if test dlfiles = "$prev"; then
        !          7144:                    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
1.6       moko     7145:                      func_append dlfiles " $pic_object"
                   7146:                      prev=
                   7147:                      continue
                   7148:                    else
                   7149:                      # If libtool objects are unsupported, then we need to preload.
                   7150:                      prev=dlprefiles
                   7151:                    fi
                   7152:                  fi
                   7153: 
                   7154:                  # CHECK ME:  I think I busted this.  -Ossama
1.7     ! moko     7155:                  if test dlprefiles = "$prev"; then
1.6       moko     7156:                    # Preload the old-style object.
                   7157:                    func_append dlprefiles " $pic_object"
                   7158:                    prev=
                   7159:                  fi
                   7160: 
                   7161:                  # A PIC object.
                   7162:                  func_append libobjs " $pic_object"
1.7     ! moko     7163:                  arg=$pic_object
1.6       moko     7164:                fi
                   7165: 
                   7166:                # Non-PIC object.
1.7     ! moko     7167:                if test none != "$non_pic_object"; then
1.6       moko     7168:                  # Prepend the subdirectory the object is found in.
1.7     ! moko     7169:                  non_pic_object=$xdir$non_pic_object
1.6       moko     7170: 
                   7171:                  # A standard non-PIC object
                   7172:                  func_append non_pic_objects " $non_pic_object"
1.7     ! moko     7173:                  if test -z "$pic_object" || test none = "$pic_object"; then
        !          7174:                    arg=$non_pic_object
1.6       moko     7175:                  fi
                   7176:                else
                   7177:                  # If the PIC object exists, use it instead.
                   7178:                  # $xdir was prepended to $pic_object above.
1.7     ! moko     7179:                  non_pic_object=$pic_object
1.6       moko     7180:                  func_append non_pic_objects " $non_pic_object"
                   7181:                fi
                   7182:              else
                   7183:                # Only an error if not doing a dry-run.
                   7184:                if $opt_dry_run; then
                   7185:                  # Extract subdirectory from the argument.
                   7186:                  func_dirname "$arg" "/" ""
1.7     ! moko     7187:                  xdir=$func_dirname_result
1.6       moko     7188: 
                   7189:                  func_lo2o "$arg"
                   7190:                  pic_object=$xdir$objdir/$func_lo2o_result
                   7191:                  non_pic_object=$xdir$func_lo2o_result
                   7192:                  func_append libobjs " $pic_object"
                   7193:                  func_append non_pic_objects " $non_pic_object"
                   7194:                else
1.7     ! moko     7195:                  func_fatal_error "'$arg' is not a valid libtool object"
1.6       moko     7196:                fi
                   7197:              fi
                   7198:            done
                   7199:          else
1.7     ! moko     7200:            func_fatal_error "link input file '$arg' does not exist"
1.6       moko     7201:          fi
                   7202:          arg=$save_arg
                   7203:          prev=
                   7204:          continue
                   7205:          ;;
1.7     ! moko     7206:        os2dllname)
        !          7207:          os2dllname=$arg
        !          7208:          prev=
        !          7209:          continue
        !          7210:          ;;
1.6       moko     7211:        precious_regex)
1.7     ! moko     7212:          precious_files_regex=$arg
1.6       moko     7213:          prev=
                   7214:          continue
                   7215:          ;;
                   7216:        release)
1.7     ! moko     7217:          release=-$arg
1.6       moko     7218:          prev=
                   7219:          continue
                   7220:          ;;
                   7221:        rpath | xrpath)
                   7222:          # We need an absolute path.
                   7223:          case $arg in
                   7224:          [\\/]* | [A-Za-z]:[\\/]*) ;;
                   7225:          *)
1.7     ! moko     7226:            func_fatal_error "argument to -rpath is not absolute: $arg"
1.6       moko     7227:            ;;
                   7228:          esac
1.7     ! moko     7229:          if test rpath = "$prev"; then
1.6       moko     7230:            case "$rpath " in
                   7231:            *" $arg "*) ;;
                   7232:            *) func_append rpath " $arg" ;;
                   7233:            esac
                   7234:          else
                   7235:            case "$xrpath " in
                   7236:            *" $arg "*) ;;
                   7237:            *) func_append xrpath " $arg" ;;
                   7238:            esac
                   7239:          fi
                   7240:          prev=
                   7241:          continue
                   7242:          ;;
                   7243:        shrext)
1.7     ! moko     7244:          shrext_cmds=$arg
1.6       moko     7245:          prev=
                   7246:          continue
                   7247:          ;;
                   7248:        weak)
                   7249:          func_append weak_libs " $arg"
                   7250:          prev=
                   7251:          continue
                   7252:          ;;
1.7     ! moko     7253:        xassembler)
        !          7254:          func_append compiler_flags " -Xassembler $qarg"
        !          7255:          prev=
        !          7256:          func_append compile_command " -Xassembler $qarg"
        !          7257:          func_append finalize_command " -Xassembler $qarg"
        !          7258:          continue
        !          7259:          ;;
1.6       moko     7260:        xcclinker)
                   7261:          func_append linker_flags " $qarg"
                   7262:          func_append compiler_flags " $qarg"
                   7263:          prev=
                   7264:          func_append compile_command " $qarg"
                   7265:          func_append finalize_command " $qarg"
                   7266:          continue
                   7267:          ;;
                   7268:        xcompiler)
                   7269:          func_append compiler_flags " $qarg"
                   7270:          prev=
                   7271:          func_append compile_command " $qarg"
                   7272:          func_append finalize_command " $qarg"
                   7273:          continue
                   7274:          ;;
                   7275:        xlinker)
                   7276:          func_append linker_flags " $qarg"
                   7277:          func_append compiler_flags " $wl$qarg"
                   7278:          prev=
                   7279:          func_append compile_command " $wl$qarg"
                   7280:          func_append finalize_command " $wl$qarg"
                   7281:          continue
                   7282:          ;;
                   7283:        *)
                   7284:          eval "$prev=\"\$arg\""
                   7285:          prev=
                   7286:          continue
                   7287:          ;;
                   7288:        esac
                   7289:       fi # test -n "$prev"
                   7290: 
1.7     ! moko     7291:       prevarg=$arg
1.6       moko     7292: 
                   7293:       case $arg in
                   7294:       -all-static)
                   7295:        if test -n "$link_static_flag"; then
                   7296:          # See comment for -static flag below, for more details.
                   7297:          func_append compile_command " $link_static_flag"
                   7298:          func_append finalize_command " $link_static_flag"
                   7299:        fi
                   7300:        continue
                   7301:        ;;
                   7302: 
                   7303:       -allow-undefined)
                   7304:        # FIXME: remove this flag sometime in the future.
1.7     ! moko     7305:        func_fatal_error "'-allow-undefined' must not be used because it is the default"
1.6       moko     7306:        ;;
                   7307: 
                   7308:       -avoid-version)
                   7309:        avoid_version=yes
                   7310:        continue
                   7311:        ;;
                   7312: 
                   7313:       -bindir)
                   7314:        prev=bindir
                   7315:        continue
                   7316:        ;;
                   7317: 
                   7318:       -dlopen)
                   7319:        prev=dlfiles
                   7320:        continue
                   7321:        ;;
                   7322: 
                   7323:       -dlpreopen)
                   7324:        prev=dlprefiles
                   7325:        continue
                   7326:        ;;
                   7327: 
                   7328:       -export-dynamic)
                   7329:        export_dynamic=yes
                   7330:        continue
                   7331:        ;;
                   7332: 
                   7333:       -export-symbols | -export-symbols-regex)
                   7334:        if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
                   7335:          func_fatal_error "more than one -exported-symbols argument is not allowed"
                   7336:        fi
1.7     ! moko     7337:        if test X-export-symbols = "X$arg"; then
1.6       moko     7338:          prev=expsyms
                   7339:        else
                   7340:          prev=expsyms_regex
                   7341:        fi
                   7342:        continue
                   7343:        ;;
                   7344: 
                   7345:       -framework)
                   7346:        prev=framework
                   7347:        continue
                   7348:        ;;
                   7349: 
                   7350:       -inst-prefix-dir)
                   7351:        prev=inst_prefix
                   7352:        continue
                   7353:        ;;
                   7354: 
                   7355:       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
                   7356:       # so, if we see these flags be careful not to treat them like -L
                   7357:       -L[A-Z][A-Z]*:*)
                   7358:        case $with_gcc/$host in
                   7359:        no/*-*-irix* | /*-*-irix*)
                   7360:          func_append compile_command " $arg"
                   7361:          func_append finalize_command " $arg"
                   7362:          ;;
                   7363:        esac
                   7364:        continue
                   7365:        ;;
                   7366: 
                   7367:       -L*)
                   7368:        func_stripname "-L" '' "$arg"
                   7369:        if test -z "$func_stripname_result"; then
                   7370:          if test "$#" -gt 0; then
1.7     ! moko     7371:            func_fatal_error "require no space between '-L' and '$1'"
1.6       moko     7372:          else
1.7     ! moko     7373:            func_fatal_error "need path for '-L' option"
1.6       moko     7374:          fi
                   7375:        fi
                   7376:        func_resolve_sysroot "$func_stripname_result"
                   7377:        dir=$func_resolve_sysroot_result
                   7378:        # We need an absolute path.
                   7379:        case $dir in
                   7380:        [\\/]* | [A-Za-z]:[\\/]*) ;;
                   7381:        *)
                   7382:          absdir=`cd "$dir" && pwd`
                   7383:          test -z "$absdir" && \
1.7     ! moko     7384:            func_fatal_error "cannot determine absolute directory name of '$dir'"
        !          7385:          dir=$absdir
1.6       moko     7386:          ;;
                   7387:        esac
                   7388:        case "$deplibs " in
                   7389:        *" -L$dir "* | *" $arg "*)
                   7390:          # Will only happen for absolute or sysroot arguments
                   7391:          ;;
                   7392:        *)
                   7393:          # Preserve sysroot, but never include relative directories
                   7394:          case $dir in
                   7395:            [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
                   7396:            *) func_append deplibs " -L$dir" ;;
                   7397:          esac
                   7398:          func_append lib_search_path " $dir"
                   7399:          ;;
                   7400:        esac
                   7401:        case $host in
1.7     ! moko     7402:        *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
1.6       moko     7403:          testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
                   7404:          case :$dllsearchpath: in
                   7405:          *":$dir:"*) ;;
                   7406:          ::) dllsearchpath=$dir;;
                   7407:          *) func_append dllsearchpath ":$dir";;
                   7408:          esac
                   7409:          case :$dllsearchpath: in
                   7410:          *":$testbindir:"*) ;;
                   7411:          ::) dllsearchpath=$testbindir;;
                   7412:          *) func_append dllsearchpath ":$testbindir";;
                   7413:          esac
                   7414:          ;;
                   7415:        esac
                   7416:        continue
                   7417:        ;;
                   7418: 
                   7419:       -l*)
1.7     ! moko     7420:        if test X-lc = "X$arg" || test X-lm = "X$arg"; then
1.6       moko     7421:          case $host in
1.7     ! moko     7422:          *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
1.6       moko     7423:            # These systems don't actually have a C or math library (as such)
                   7424:            continue
                   7425:            ;;
                   7426:          *-*-os2*)
                   7427:            # These systems don't actually have a C library (as such)
1.7     ! moko     7428:            test X-lc = "X$arg" && continue
1.6       moko     7429:            ;;
1.7     ! moko     7430:          *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
1.6       moko     7431:            # Do not include libc due to us having libc/libc_r.
1.7     ! moko     7432:            test X-lc = "X$arg" && continue
1.6       moko     7433:            ;;
                   7434:          *-*-rhapsody* | *-*-darwin1.[012])
                   7435:            # Rhapsody C and math libraries are in the System framework
                   7436:            func_append deplibs " System.ltframework"
                   7437:            continue
                   7438:            ;;
                   7439:          *-*-sco3.2v5* | *-*-sco5v6*)
                   7440:            # Causes problems with __ctype
1.7     ! moko     7441:            test X-lc = "X$arg" && continue
1.6       moko     7442:            ;;
                   7443:          *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
                   7444:            # Compiler inserts libc in the correct place for threads to work
1.7     ! moko     7445:            test X-lc = "X$arg" && continue
1.6       moko     7446:            ;;
                   7447:          esac
1.7     ! moko     7448:        elif test X-lc_r = "X$arg"; then
1.6       moko     7449:         case $host in
1.7     ! moko     7450:         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
1.6       moko     7451:           # Do not include libc_r directly, use -pthread flag.
                   7452:           continue
                   7453:           ;;
                   7454:         esac
                   7455:        fi
                   7456:        func_append deplibs " $arg"
                   7457:        continue
                   7458:        ;;
                   7459: 
1.7     ! moko     7460:       -mllvm)
        !          7461:        prev=mllvm
        !          7462:        continue
        !          7463:        ;;
        !          7464: 
1.6       moko     7465:       -module)
                   7466:        module=yes
                   7467:        continue
                   7468:        ;;
                   7469: 
                   7470:       # Tru64 UNIX uses -model [arg] to determine the layout of C++
                   7471:       # classes, name mangling, and exception handling.
                   7472:       # Darwin uses the -arch flag to determine output architecture.
1.7     ! moko     7473:       # -q <option> for IBM XL C/C++ compiler.
        !          7474:       -model|-arch|-isysroot|--sysroot|-q)
1.6       moko     7475:        func_append compiler_flags " $arg"
                   7476:        func_append compile_command " $arg"
                   7477:        func_append finalize_command " $arg"
                   7478:        prev=xcompiler
                   7479:        continue
                   7480:        ;;
1.7     ! moko     7481:      # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199.
        !          7482:      -pthread)
        !          7483:        case $host in
        !          7484:          *solaris2*) ;;
        !          7485:          *)
        !          7486:            case "$new_inherited_linker_flags " in
        !          7487:                *" $arg "*) ;;
        !          7488:                * ) func_append new_inherited_linker_flags " $arg" ;;
        !          7489:            esac
        !          7490:          ;;
        !          7491:        esac
        !          7492:        continue
        !          7493:        ;;
        !          7494:       -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
        !          7495:       |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
1.6       moko     7496:        func_append compiler_flags " $arg"
                   7497:        func_append compile_command " $arg"
                   7498:        func_append finalize_command " $arg"
                   7499:        case "$new_inherited_linker_flags " in
                   7500:            *" $arg "*) ;;
                   7501:            * ) func_append new_inherited_linker_flags " $arg" ;;
                   7502:        esac
                   7503:        continue
                   7504:        ;;
                   7505: 
                   7506:       -multi_module)
1.7     ! moko     7507:        single_module=$wl-multi_module
1.6       moko     7508:        continue
                   7509:        ;;
                   7510: 
                   7511:       -no-fast-install)
                   7512:        fast_install=no
                   7513:        continue
                   7514:        ;;
                   7515: 
                   7516:       -no-install)
                   7517:        case $host in
1.7     ! moko     7518:        *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
1.6       moko     7519:          # The PATH hackery in wrapper scripts is required on Windows
                   7520:          # and Darwin in order for the loader to find any dlls it needs.
1.7     ! moko     7521:          func_warning "'-no-install' is ignored for $host"
        !          7522:          func_warning "assuming '-no-fast-install' instead"
1.6       moko     7523:          fast_install=no
                   7524:          ;;
                   7525:        *) no_install=yes ;;
                   7526:        esac
                   7527:        continue
                   7528:        ;;
                   7529: 
                   7530:       -no-undefined)
                   7531:        allow_undefined=no
                   7532:        continue
                   7533:        ;;
                   7534: 
                   7535:       -objectlist)
                   7536:        prev=objectlist
                   7537:        continue
                   7538:        ;;
                   7539: 
1.7     ! moko     7540:       -os2dllname)
        !          7541:        prev=os2dllname
        !          7542:        continue
        !          7543:        ;;
        !          7544: 
1.6       moko     7545:       -o) prev=output ;;
                   7546: 
                   7547:       -precious-files-regex)
                   7548:        prev=precious_regex
                   7549:        continue
                   7550:        ;;
                   7551: 
                   7552:       -release)
                   7553:        prev=release
                   7554:        continue
                   7555:        ;;
                   7556: 
                   7557:       -rpath)
                   7558:        prev=rpath
                   7559:        continue
                   7560:        ;;
                   7561: 
                   7562:       -R)
                   7563:        prev=xrpath
                   7564:        continue
                   7565:        ;;
                   7566: 
                   7567:       -R*)
                   7568:        func_stripname '-R' '' "$arg"
                   7569:        dir=$func_stripname_result
                   7570:        # We need an absolute path.
                   7571:        case $dir in
                   7572:        [\\/]* | [A-Za-z]:[\\/]*) ;;
                   7573:        =*)
                   7574:          func_stripname '=' '' "$dir"
                   7575:          dir=$lt_sysroot$func_stripname_result
                   7576:          ;;
                   7577:        *)
1.7     ! moko     7578:          func_fatal_error "argument ($arg) to '-R' is not an absolute path: $dir"
1.6       moko     7579:          ;;
                   7580:        esac
                   7581:        case "$xrpath " in
                   7582:        *" $dir "*) ;;
                   7583:        *) func_append xrpath " $dir" ;;
                   7584:        esac
                   7585:        continue
                   7586:        ;;
                   7587: 
                   7588:       -shared)
                   7589:        # The effects of -shared are defined in a previous loop.
                   7590:        continue
                   7591:        ;;
                   7592: 
                   7593:       -shrext)
                   7594:        prev=shrext
                   7595:        continue
                   7596:        ;;
                   7597: 
                   7598:       -static | -static-libtool-libs)
                   7599:        # The effects of -static are defined in a previous loop.
                   7600:        # We used to do the same as -all-static on platforms that
                   7601:        # didn't have a PIC flag, but the assumption that the effects
                   7602:        # would be equivalent was wrong.  It would break on at least
                   7603:        # Digital Unix and AIX.
                   7604:        continue
                   7605:        ;;
                   7606: 
                   7607:       -thread-safe)
                   7608:        thread_safe=yes
                   7609:        continue
                   7610:        ;;
                   7611: 
                   7612:       -version-info)
                   7613:        prev=vinfo
                   7614:        continue
                   7615:        ;;
                   7616: 
                   7617:       -version-number)
                   7618:        prev=vinfo
                   7619:        vinfo_number=yes
                   7620:        continue
                   7621:        ;;
                   7622: 
                   7623:       -weak)
                   7624:         prev=weak
                   7625:        continue
                   7626:        ;;
                   7627: 
                   7628:       -Wc,*)
                   7629:        func_stripname '-Wc,' '' "$arg"
                   7630:        args=$func_stripname_result
                   7631:        arg=
1.7     ! moko     7632:        save_ifs=$IFS; IFS=,
1.6       moko     7633:        for flag in $args; do
1.7     ! moko     7634:          IFS=$save_ifs
        !          7635:           func_quote_arg pretty "$flag"
        !          7636:          func_append arg " $func_quote_arg_result"
        !          7637:          func_append compiler_flags " $func_quote_arg_result"
1.6       moko     7638:        done
1.7     ! moko     7639:        IFS=$save_ifs
1.6       moko     7640:        func_stripname ' ' '' "$arg"
                   7641:        arg=$func_stripname_result
                   7642:        ;;
                   7643: 
                   7644:       -Wl,*)
                   7645:        func_stripname '-Wl,' '' "$arg"
                   7646:        args=$func_stripname_result
                   7647:        arg=
1.7     ! moko     7648:        save_ifs=$IFS; IFS=,
1.6       moko     7649:        for flag in $args; do
1.7     ! moko     7650:          IFS=$save_ifs
        !          7651:           func_quote_arg pretty "$flag"
        !          7652:          func_append arg " $wl$func_quote_arg_result"
        !          7653:          func_append compiler_flags " $wl$func_quote_arg_result"
        !          7654:          func_append linker_flags " $func_quote_arg_result"
1.6       moko     7655:        done
1.7     ! moko     7656:        IFS=$save_ifs
1.6       moko     7657:        func_stripname ' ' '' "$arg"
                   7658:        arg=$func_stripname_result
                   7659:        ;;
                   7660: 
1.7     ! moko     7661:       -Xassembler)
        !          7662:         prev=xassembler
        !          7663:         continue
        !          7664:         ;;
        !          7665: 
1.6       moko     7666:       -Xcompiler)
                   7667:        prev=xcompiler
                   7668:        continue
                   7669:        ;;
                   7670: 
                   7671:       -Xlinker)
                   7672:        prev=xlinker
                   7673:        continue
                   7674:        ;;
                   7675: 
                   7676:       -XCClinker)
                   7677:        prev=xcclinker
                   7678:        continue
                   7679:        ;;
                   7680: 
                   7681:       # -msg_* for osf cc
                   7682:       -msg_*)
1.7     ! moko     7683:        func_quote_arg pretty "$arg"
        !          7684:        arg=$func_quote_arg_result
1.6       moko     7685:        ;;
                   7686: 
                   7687:       # Flags to be passed through unchanged, with rationale:
                   7688:       # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
                   7689:       # -r[0-9][0-9]*        specify processor for the SGI compiler
                   7690:       # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
                   7691:       # +DA*, +DD*           enable 64-bit mode for the HP compiler
                   7692:       # -q*                  compiler args for the IBM compiler
                   7693:       # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
                   7694:       # -F/path              path to uninstalled frameworks, gcc on darwin
                   7695:       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
1.7     ! moko     7696:       # -fstack-protector*   stack protector flags for GCC
1.6       moko     7697:       # @file                GCC response files
                   7698:       # -tp=*                Portland pgcc target processor selection
                   7699:       # --sysroot=*          for sysroot support
1.7     ! moko     7700:       # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
        !          7701:       # -specs=*             GCC specs files
        !          7702:       # -stdlib=*            select c++ std lib with clang
        !          7703:       # -fdiagnostics-color* simply affects output
        !          7704:       # -frecord-gcc-switches used to verify flags were respected
        !          7705:       # -fsanitize=*         Clang/GCC memory and address sanitizer
        !          7706:       # -fno-sanitize*       Clang/GCC memory and address sanitizer
        !          7707:       # -shared-libsan       Link with shared sanitizer runtimes (Clang)
        !          7708:       # -static-libsan       Link with static sanitizer runtimes (Clang)
        !          7709:       # -no-canonical-prefixes Do not expand any symbolic links
        !          7710:       # -fuse-ld=*           Linker select flags for GCC
        !          7711:       # -static-*            direct GCC to link specific libraries statically
        !          7712:       # -fcilkplus           Cilk Plus language extension features for C/C++
        !          7713:       # -rtlib=*             select c runtime lib with clang
        !          7714:       # --unwindlib=*        select unwinder library with clang
        !          7715:       # -f{file|debug|macro|profile}-prefix-map=* needed for lto linking
        !          7716:       # -Wa,*                Pass flags directly to the assembler
        !          7717:       # -Werror, -Werror=*   Report (specified) warnings as errors
1.6       moko     7718:       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
                   7719:       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
1.7     ! moko     7720:       -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-no-canonical-prefixes| \
        !          7721:       -stdlib=*|-rtlib=*|--unwindlib=*| \
        !          7722:       -specs=*|-fsanitize=*|-fno-sanitize*|-shared-libsan|-static-libsan| \
        !          7723:       -ffile-prefix-map=*|-fdebug-prefix-map=*|-fmacro-prefix-map=*|-fprofile-prefix-map=*| \
        !          7724:       -fdiagnostics-color*|-frecord-gcc-switches| \
        !          7725:       -fuse-ld=*|-static-*|-fcilkplus|-Wa,*|-Werror|-Werror=*)
        !          7726:         func_quote_arg pretty "$arg"
        !          7727:        arg=$func_quote_arg_result
1.6       moko     7728:         func_append compile_command " $arg"
                   7729:         func_append finalize_command " $arg"
                   7730:         func_append compiler_flags " $arg"
                   7731:         continue
                   7732:         ;;
                   7733: 
1.7     ! moko     7734:       -Z*)
        !          7735:         if test os2 = "`expr $host : '.*\(os2\)'`"; then
        !          7736:           # OS/2 uses -Zxxx to specify OS/2-specific options
        !          7737:          compiler_flags="$compiler_flags $arg"
        !          7738:          func_append compile_command " $arg"
        !          7739:          func_append finalize_command " $arg"
        !          7740:          case $arg in
        !          7741:          -Zlinker | -Zstack)
        !          7742:            prev=xcompiler
        !          7743:            ;;
        !          7744:          esac
        !          7745:          continue
        !          7746:         else
        !          7747:          # Otherwise treat like 'Some other compiler flag' below
        !          7748:          func_quote_arg pretty "$arg"
        !          7749:          arg=$func_quote_arg_result
        !          7750:         fi
        !          7751:        ;;
        !          7752: 
1.6       moko     7753:       # Some other compiler flag.
                   7754:       -* | +*)
1.7     ! moko     7755:         func_quote_arg pretty "$arg"
        !          7756:        arg=$func_quote_arg_result
1.6       moko     7757:        ;;
                   7758: 
                   7759:       *.$objext)
                   7760:        # A standard object.
                   7761:        func_append objs " $arg"
                   7762:        ;;
                   7763: 
                   7764:       *.lo)
                   7765:        # A libtool-controlled object.
                   7766: 
                   7767:        # Check to see that this really is a libtool object.
                   7768:        if func_lalib_unsafe_p "$arg"; then
                   7769:          pic_object=
                   7770:          non_pic_object=
                   7771: 
                   7772:          # Read the .lo file
                   7773:          func_source "$arg"
                   7774: 
                   7775:          if test -z "$pic_object" ||
                   7776:             test -z "$non_pic_object" ||
1.7     ! moko     7777:             test none = "$pic_object" &&
        !          7778:             test none = "$non_pic_object"; then
        !          7779:            func_fatal_error "cannot find name of object for '$arg'"
1.6       moko     7780:          fi
                   7781: 
                   7782:          # Extract subdirectory from the argument.
                   7783:          func_dirname "$arg" "/" ""
1.7     ! moko     7784:          xdir=$func_dirname_result
1.6       moko     7785: 
1.7     ! moko     7786:          test none = "$pic_object" || {
1.6       moko     7787:            # Prepend the subdirectory the object is found in.
1.7     ! moko     7788:            pic_object=$xdir$pic_object
1.6       moko     7789: 
1.7     ! moko     7790:            if test dlfiles = "$prev"; then
        !          7791:              if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
1.6       moko     7792:                func_append dlfiles " $pic_object"
                   7793:                prev=
                   7794:                continue
                   7795:              else
                   7796:                # If libtool objects are unsupported, then we need to preload.
                   7797:                prev=dlprefiles
                   7798:              fi
                   7799:            fi
                   7800: 
                   7801:            # CHECK ME:  I think I busted this.  -Ossama
1.7     ! moko     7802:            if test dlprefiles = "$prev"; then
1.6       moko     7803:              # Preload the old-style object.
                   7804:              func_append dlprefiles " $pic_object"
                   7805:              prev=
                   7806:            fi
                   7807: 
                   7808:            # A PIC object.
                   7809:            func_append libobjs " $pic_object"
1.7     ! moko     7810:            arg=$pic_object
        !          7811:          }
1.6       moko     7812: 
                   7813:          # Non-PIC object.
1.7     ! moko     7814:          if test none != "$non_pic_object"; then
1.6       moko     7815:            # Prepend the subdirectory the object is found in.
1.7     ! moko     7816:            non_pic_object=$xdir$non_pic_object
1.6       moko     7817: 
                   7818:            # A standard non-PIC object
                   7819:            func_append non_pic_objects " $non_pic_object"
1.7     ! moko     7820:            if test -z "$pic_object" || test none = "$pic_object"; then
        !          7821:              arg=$non_pic_object
1.6       moko     7822:            fi
                   7823:          else
                   7824:            # If the PIC object exists, use it instead.
                   7825:            # $xdir was prepended to $pic_object above.
1.7     ! moko     7826:            non_pic_object=$pic_object
1.6       moko     7827:            func_append non_pic_objects " $non_pic_object"
                   7828:          fi
                   7829:        else
                   7830:          # Only an error if not doing a dry-run.
                   7831:          if $opt_dry_run; then
                   7832:            # Extract subdirectory from the argument.
                   7833:            func_dirname "$arg" "/" ""
1.7     ! moko     7834:            xdir=$func_dirname_result
1.6       moko     7835: 
                   7836:            func_lo2o "$arg"
                   7837:            pic_object=$xdir$objdir/$func_lo2o_result
                   7838:            non_pic_object=$xdir$func_lo2o_result
                   7839:            func_append libobjs " $pic_object"
                   7840:            func_append non_pic_objects " $non_pic_object"
                   7841:          else
1.7     ! moko     7842:            func_fatal_error "'$arg' is not a valid libtool object"
1.6       moko     7843:          fi
                   7844:        fi
                   7845:        ;;
                   7846: 
                   7847:       *.$libext)
                   7848:        # An archive.
                   7849:        func_append deplibs " $arg"
                   7850:        func_append old_deplibs " $arg"
                   7851:        continue
                   7852:        ;;
                   7853: 
                   7854:       *.la)
                   7855:        # A libtool-controlled library.
                   7856: 
                   7857:        func_resolve_sysroot "$arg"
1.7     ! moko     7858:        if test dlfiles = "$prev"; then
1.6       moko     7859:          # This library was specified with -dlopen.
                   7860:          func_append dlfiles " $func_resolve_sysroot_result"
                   7861:          prev=
1.7     ! moko     7862:        elif test dlprefiles = "$prev"; then
1.6       moko     7863:          # The library was specified with -dlpreopen.
                   7864:          func_append dlprefiles " $func_resolve_sysroot_result"
                   7865:          prev=
                   7866:        else
                   7867:          func_append deplibs " $func_resolve_sysroot_result"
                   7868:        fi
                   7869:        continue
                   7870:        ;;
                   7871: 
                   7872:       # Some other compiler argument.
                   7873:       *)
                   7874:        # Unknown arguments in both finalize_command and compile_command need
                   7875:        # to be aesthetically quoted because they are evaled later.
1.7     ! moko     7876:        func_quote_arg pretty "$arg"
        !          7877:        arg=$func_quote_arg_result
1.6       moko     7878:        ;;
                   7879:       esac # arg
                   7880: 
                   7881:       # Now actually substitute the argument into the commands.
                   7882:       if test -n "$arg"; then
1.7     ! moko     7883:        if test -n "$rpath_arg"; then
        !          7884:           func_append finalize_rpath " ${arg##*,}"
        !          7885:          unset rpath_arg
        !          7886:        else
        !          7887:          case $arg in
        !          7888:           -Wl,-rpath,*)
        !          7889:            func_append finalize_rpath " ${arg##*,}";;
        !          7890:           -Wl,-rpath)
        !          7891:            rpath_arg=1;;
        !          7892:           *)
        !          7893:             func_append compile_command " $arg"
        !          7894:            func_append finalize_command " $arg"
        !          7895:          esac
        !          7896:         fi
1.6       moko     7897:       fi
                   7898:     done # argument parsing loop
                   7899: 
                   7900:     test -n "$prev" && \
1.7     ! moko     7901:       func_fatal_help "the '$prevarg' option requires an argument"
1.6       moko     7902: 
1.7     ! moko     7903:     if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
1.6       moko     7904:       eval arg=\"$export_dynamic_flag_spec\"
                   7905:       func_append compile_command " $arg"
                   7906:       func_append finalize_command " $arg"
                   7907:     fi
                   7908: 
                   7909:     oldlibs=
                   7910:     # calculate the name of the file, without its directory
                   7911:     func_basename "$output"
1.7     ! moko     7912:     outputname=$func_basename_result
        !          7913:     libobjs_save=$libobjs
1.6       moko     7914: 
                   7915:     if test -n "$shlibpath_var"; then
                   7916:       # get the directories listed in $shlibpath_var
1.7     ! moko     7917:       eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
1.6       moko     7918:     else
                   7919:       shlib_search_path=
                   7920:     fi
                   7921:     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
                   7922:     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
                   7923: 
1.7     ! moko     7924:     # Definition is injected by LT_CONFIG during libtool generation.
        !          7925:     func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
        !          7926: 
1.6       moko     7927:     func_dirname "$output" "/" ""
1.7     ! moko     7928:     output_objdir=$func_dirname_result$objdir
1.6       moko     7929:     func_to_tool_file "$output_objdir/"
                   7930:     tool_output_objdir=$func_to_tool_file_result
                   7931:     # Create the object directory.
                   7932:     func_mkdir_p "$output_objdir"
                   7933: 
                   7934:     # Determine the type of output
                   7935:     case $output in
                   7936:     "")
                   7937:       func_fatal_help "you must specify an output file"
                   7938:       ;;
                   7939:     *.$libext) linkmode=oldlib ;;
                   7940:     *.lo | *.$objext) linkmode=obj ;;
                   7941:     *.la) linkmode=lib ;;
                   7942:     *) linkmode=prog ;; # Anything else should be a program.
                   7943:     esac
                   7944: 
                   7945:     specialdeplibs=
                   7946: 
                   7947:     libs=
                   7948:     # Find all interdependent deplibs by searching for libraries
                   7949:     # that are linked more than once (e.g. -la -lb -la)
                   7950:     for deplib in $deplibs; do
1.7     ! moko     7951:       if $opt_preserve_dup_deps; then
1.6       moko     7952:        case "$libs " in
                   7953:        *" $deplib "*) func_append specialdeplibs " $deplib" ;;
                   7954:        esac
                   7955:       fi
                   7956:       func_append libs " $deplib"
                   7957:     done
                   7958: 
1.7     ! moko     7959:     if test lib = "$linkmode"; then
1.6       moko     7960:       libs="$predeps $libs $compiler_lib_search_path $postdeps"
                   7961: 
                   7962:       # Compute libraries that are listed more than once in $predeps
                   7963:       # $postdeps and mark them as special (i.e., whose duplicates are
                   7964:       # not to be eliminated).
                   7965:       pre_post_deps=
                   7966:       if $opt_duplicate_compiler_generated_deps; then
                   7967:        for pre_post_dep in $predeps $postdeps; do
                   7968:          case "$pre_post_deps " in
                   7969:          *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
                   7970:          esac
                   7971:          func_append pre_post_deps " $pre_post_dep"
                   7972:        done
                   7973:       fi
                   7974:       pre_post_deps=
                   7975:     fi
                   7976: 
                   7977:     deplibs=
                   7978:     newdependency_libs=
                   7979:     newlib_search_path=
                   7980:     need_relink=no # whether we're linking any uninstalled libtool libraries
                   7981:     notinst_deplibs= # not-installed libtool libraries
                   7982:     notinst_path= # paths that contain not-installed libtool libraries
                   7983: 
                   7984:     case $linkmode in
                   7985:     lib)
                   7986:        passes="conv dlpreopen link"
                   7987:        for file in $dlfiles $dlprefiles; do
                   7988:          case $file in
                   7989:          *.la) ;;
                   7990:          *)
1.7     ! moko     7991:            func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
1.6       moko     7992:            ;;
                   7993:          esac
                   7994:        done
                   7995:        ;;
                   7996:     prog)
                   7997:        compile_deplibs=
                   7998:        finalize_deplibs=
1.7     ! moko     7999:        alldeplibs=false
1.6       moko     8000:        newdlfiles=
                   8001:        newdlprefiles=
                   8002:        passes="conv scan dlopen dlpreopen link"
                   8003:        ;;
                   8004:     *)  passes="conv"
                   8005:        ;;
                   8006:     esac
                   8007: 
                   8008:     for pass in $passes; do
                   8009:       # The preopen pass in lib mode reverses $deplibs; put it back here
                   8010:       # so that -L comes before libs that need it for instance...
1.7     ! moko     8011:       if test lib,link = "$linkmode,$pass"; then
1.6       moko     8012:        ## FIXME: Find the place where the list is rebuilt in the wrong
                   8013:        ##        order, and fix it there properly
                   8014:         tmp_deplibs=
                   8015:        for deplib in $deplibs; do
                   8016:          tmp_deplibs="$deplib $tmp_deplibs"
                   8017:        done
1.7     ! moko     8018:        deplibs=$tmp_deplibs
1.6       moko     8019:       fi
                   8020: 
1.7     ! moko     8021:       if test lib,link = "$linkmode,$pass" ||
        !          8022:         test prog,scan = "$linkmode,$pass"; then
        !          8023:        libs=$deplibs
1.6       moko     8024:        deplibs=
                   8025:       fi
1.7     ! moko     8026:       if test prog = "$linkmode"; then
1.6       moko     8027:        case $pass in
1.7     ! moko     8028:        dlopen) libs=$dlfiles ;;
        !          8029:        dlpreopen) libs=$dlprefiles ;;
        !          8030:        link)
        !          8031:          libs="$deplibs %DEPLIBS%"
        !          8032:          test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
        !          8033:          ;;
1.6       moko     8034:        esac
                   8035:       fi
1.7     ! moko     8036:       if test lib,dlpreopen = "$linkmode,$pass"; then
1.6       moko     8037:        # Collect and forward deplibs of preopened libtool libs
                   8038:        for lib in $dlprefiles; do
                   8039:          # Ignore non-libtool-libs
                   8040:          dependency_libs=
                   8041:          func_resolve_sysroot "$lib"
                   8042:          case $lib in
                   8043:          *.la) func_source "$func_resolve_sysroot_result" ;;
                   8044:          esac
                   8045: 
                   8046:          # Collect preopened libtool deplibs, except any this library
                   8047:          # has declared as weak libs
                   8048:          for deplib in $dependency_libs; do
                   8049:            func_basename "$deplib"
                   8050:             deplib_base=$func_basename_result
                   8051:            case " $weak_libs " in
                   8052:            *" $deplib_base "*) ;;
                   8053:            *) func_append deplibs " $deplib" ;;
                   8054:            esac
                   8055:          done
                   8056:        done
1.7     ! moko     8057:        libs=$dlprefiles
1.6       moko     8058:       fi
1.7     ! moko     8059:       if test dlopen = "$pass"; then
1.6       moko     8060:        # Collect dlpreopened libraries
1.7     ! moko     8061:        save_deplibs=$deplibs
1.6       moko     8062:        deplibs=
                   8063:       fi
                   8064: 
                   8065:       for deplib in $libs; do
                   8066:        lib=
1.7     ! moko     8067:        found=false
1.6       moko     8068:        case $deplib in
                   8069:        -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
1.7     ! moko     8070:         |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
        !          8071:          if test prog,link = "$linkmode,$pass"; then
1.6       moko     8072:            compile_deplibs="$deplib $compile_deplibs"
                   8073:            finalize_deplibs="$deplib $finalize_deplibs"
                   8074:          else
                   8075:            func_append compiler_flags " $deplib"
1.7     ! moko     8076:            if test lib = "$linkmode"; then
1.6       moko     8077:                case "$new_inherited_linker_flags " in
                   8078:                    *" $deplib "*) ;;
                   8079:                    * ) func_append new_inherited_linker_flags " $deplib" ;;
                   8080:                esac
                   8081:            fi
                   8082:          fi
                   8083:          continue
                   8084:          ;;
                   8085:        -l*)
1.7     ! moko     8086:          if test lib != "$linkmode" && test prog != "$linkmode"; then
        !          8087:            func_warning "'-l' is ignored for archives/objects"
1.6       moko     8088:            continue
                   8089:          fi
                   8090:          func_stripname '-l' '' "$deplib"
                   8091:          name=$func_stripname_result
1.7     ! moko     8092:          if test lib = "$linkmode"; then
1.6       moko     8093:            searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
                   8094:          else
                   8095:            searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
                   8096:          fi
                   8097:          for searchdir in $searchdirs; do
                   8098:            for search_ext in .la $std_shrext .so .a; do
                   8099:              # Search the libtool library
1.7     ! moko     8100:              lib=$searchdir/lib$name$search_ext
1.6       moko     8101:              if test -f "$lib"; then
1.7     ! moko     8102:                if test .la = "$search_ext"; then
        !          8103:                  found=:
1.6       moko     8104:                else
1.7     ! moko     8105:                  found=false
1.6       moko     8106:                fi
                   8107:                break 2
                   8108:              fi
                   8109:            done
                   8110:          done
1.7     ! moko     8111:          if $found; then
        !          8112:            # deplib is a libtool library
1.6       moko     8113:            # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
                   8114:            # We need to do some special things here, and not later.
1.7     ! moko     8115:            if test yes = "$allow_libtool_libs_with_static_runtimes"; then
1.6       moko     8116:              case " $predeps $postdeps " in
                   8117:              *" $deplib "*)
                   8118:                if func_lalib_p "$lib"; then
                   8119:                  library_names=
                   8120:                  old_library=
                   8121:                  func_source "$lib"
                   8122:                  for l in $old_library $library_names; do
1.7     ! moko     8123:                    ll=$l
1.6       moko     8124:                  done
1.7     ! moko     8125:                  if test "X$ll" = "X$old_library"; then # only static version available
        !          8126:                    found=false
1.6       moko     8127:                    func_dirname "$lib" "" "."
1.7     ! moko     8128:                    ladir=$func_dirname_result
1.6       moko     8129:                    lib=$ladir/$old_library
1.7     ! moko     8130:                    if test prog,link = "$linkmode,$pass"; then
1.6       moko     8131:                      compile_deplibs="$deplib $compile_deplibs"
                   8132:                      finalize_deplibs="$deplib $finalize_deplibs"
                   8133:                    else
                   8134:                      deplibs="$deplib $deplibs"
1.7     ! moko     8135:                      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
1.6       moko     8136:                    fi
                   8137:                    continue
                   8138:                  fi
                   8139:                fi
                   8140:                ;;
                   8141:              *) ;;
                   8142:              esac
                   8143:            fi
1.7     ! moko     8144:          else
        !          8145:            # deplib doesn't seem to be a libtool library
        !          8146:            if test prog,link = "$linkmode,$pass"; then
        !          8147:              compile_deplibs="$deplib $compile_deplibs"
        !          8148:              finalize_deplibs="$deplib $finalize_deplibs"
        !          8149:            else
        !          8150:              deplibs="$deplib $deplibs"
        !          8151:              test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
        !          8152:            fi
        !          8153:            continue
1.6       moko     8154:          fi
                   8155:          ;; # -l
                   8156:        *.ltframework)
1.7     ! moko     8157:          if test prog,link = "$linkmode,$pass"; then
1.6       moko     8158:            compile_deplibs="$deplib $compile_deplibs"
                   8159:            finalize_deplibs="$deplib $finalize_deplibs"
                   8160:          else
                   8161:            deplibs="$deplib $deplibs"
1.7     ! moko     8162:            if test lib = "$linkmode"; then
1.6       moko     8163:                case "$new_inherited_linker_flags " in
                   8164:                    *" $deplib "*) ;;
                   8165:                    * ) func_append new_inherited_linker_flags " $deplib" ;;
                   8166:                esac
                   8167:            fi
                   8168:          fi
                   8169:          continue
                   8170:          ;;
                   8171:        -L*)
                   8172:          case $linkmode in
                   8173:          lib)
                   8174:            deplibs="$deplib $deplibs"
1.7     ! moko     8175:            test conv = "$pass" && continue
1.6       moko     8176:            newdependency_libs="$deplib $newdependency_libs"
                   8177:            func_stripname '-L' '' "$deplib"
                   8178:            func_resolve_sysroot "$func_stripname_result"
                   8179:            func_append newlib_search_path " $func_resolve_sysroot_result"
                   8180:            ;;
                   8181:          prog)
1.7     ! moko     8182:            if test conv = "$pass"; then
1.6       moko     8183:              deplibs="$deplib $deplibs"
                   8184:              continue
                   8185:            fi
1.7     ! moko     8186:            if test scan = "$pass"; then
1.6       moko     8187:              deplibs="$deplib $deplibs"
                   8188:            else
                   8189:              compile_deplibs="$deplib $compile_deplibs"
                   8190:              finalize_deplibs="$deplib $finalize_deplibs"
                   8191:            fi
                   8192:            func_stripname '-L' '' "$deplib"
                   8193:            func_resolve_sysroot "$func_stripname_result"
                   8194:            func_append newlib_search_path " $func_resolve_sysroot_result"
                   8195:            ;;
                   8196:          *)
1.7     ! moko     8197:            func_warning "'-L' is ignored for archives/objects"
1.6       moko     8198:            ;;
                   8199:          esac # linkmode
                   8200:          continue
                   8201:          ;; # -L
                   8202:        -R*)
1.7     ! moko     8203:          if test link = "$pass"; then
1.6       moko     8204:            func_stripname '-R' '' "$deplib"
                   8205:            func_resolve_sysroot "$func_stripname_result"
                   8206:            dir=$func_resolve_sysroot_result
                   8207:            # Make sure the xrpath contains only unique directories.
                   8208:            case "$xrpath " in
                   8209:            *" $dir "*) ;;
                   8210:            *) func_append xrpath " $dir" ;;
                   8211:            esac
                   8212:          fi
                   8213:          deplibs="$deplib $deplibs"
                   8214:          continue
                   8215:          ;;
                   8216:        *.la)
                   8217:          func_resolve_sysroot "$deplib"
                   8218:          lib=$func_resolve_sysroot_result
                   8219:          ;;
                   8220:        *.$libext)
1.7     ! moko     8221:          if test conv = "$pass"; then
1.6       moko     8222:            deplibs="$deplib $deplibs"
                   8223:            continue
                   8224:          fi
                   8225:          case $linkmode in
                   8226:          lib)
                   8227:            # Linking convenience modules into shared libraries is allowed,
                   8228:            # but linking other static libraries is non-portable.
                   8229:            case " $dlpreconveniencelibs " in
                   8230:            *" $deplib "*) ;;
                   8231:            *)
1.7     ! moko     8232:              valid_a_lib=false
1.6       moko     8233:              case $deplibs_check_method in
                   8234:                match_pattern*)
                   8235:                  set dummy $deplibs_check_method; shift
                   8236:                  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
                   8237:                  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
                   8238:                    | $EGREP "$match_pattern_regex" > /dev/null; then
1.7     ! moko     8239:                    valid_a_lib=:
1.6       moko     8240:                  fi
                   8241:                ;;
                   8242:                pass_all)
1.7     ! moko     8243:                  valid_a_lib=:
1.6       moko     8244:                ;;
                   8245:              esac
1.7     ! moko     8246:              if $valid_a_lib; then
        !          8247:                func_warning "Linking the shared library $output against the static library $deplib is not portable!"
        !          8248:                deplibs="$deplib $deplibs"
1.6       moko     8249:              else
1.7     ! moko     8250:                func_warning "Trying to link with static lib archive $deplib."
        !          8251:                func_warning "I have the capability to make that library automatically link in when"
        !          8252:                func_warning "you link to this library.  But I can only do this if you have a"
        !          8253:                func_warning "shared version of the library, which you do not appear to have"
        !          8254:                func_warning "because the file extensions .$libext of this argument makes me believe"
        !          8255:                func_warning "that it is just a static archive that I should not use here."
1.6       moko     8256:              fi
                   8257:              ;;
                   8258:            esac
                   8259:            continue
                   8260:            ;;
                   8261:          prog)
1.7     ! moko     8262:            if test link != "$pass"; then
1.6       moko     8263:              deplibs="$deplib $deplibs"
                   8264:            else
                   8265:              compile_deplibs="$deplib $compile_deplibs"
                   8266:              finalize_deplibs="$deplib $finalize_deplibs"
                   8267:            fi
                   8268:            continue
                   8269:            ;;
                   8270:          esac # linkmode
                   8271:          ;; # *.$libext
                   8272:        *.lo | *.$objext)
1.7     ! moko     8273:          if test conv = "$pass"; then
1.6       moko     8274:            deplibs="$deplib $deplibs"
1.7     ! moko     8275:          elif test prog = "$linkmode"; then
        !          8276:            if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
1.6       moko     8277:              # If there is no dlopen support or we're linking statically,
                   8278:              # we need to preload.
                   8279:              func_append newdlprefiles " $deplib"
                   8280:              compile_deplibs="$deplib $compile_deplibs"
                   8281:              finalize_deplibs="$deplib $finalize_deplibs"
                   8282:            else
                   8283:              func_append newdlfiles " $deplib"
                   8284:            fi
                   8285:          fi
                   8286:          continue
                   8287:          ;;
                   8288:        %DEPLIBS%)
1.7     ! moko     8289:          alldeplibs=:
1.6       moko     8290:          continue
                   8291:          ;;
                   8292:        esac # case $deplib
                   8293: 
1.7     ! moko     8294:        $found || test -f "$lib" \
        !          8295:          || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
1.6       moko     8296: 
                   8297:        # Check to see that this really is a libtool archive.
                   8298:        func_lalib_unsafe_p "$lib" \
1.7     ! moko     8299:          || func_fatal_error "'$lib' is not a valid libtool archive"
1.6       moko     8300: 
                   8301:        func_dirname "$lib" "" "."
1.7     ! moko     8302:        ladir=$func_dirname_result
1.6       moko     8303: 
                   8304:        dlname=
                   8305:        dlopen=
                   8306:        dlpreopen=
                   8307:        libdir=
                   8308:        library_names=
                   8309:        old_library=
                   8310:        inherited_linker_flags=
                   8311:        # If the library was installed with an old release of libtool,
                   8312:        # it will not redefine variables installed, or shouldnotlink
                   8313:        installed=yes
                   8314:        shouldnotlink=no
                   8315:        avoidtemprpath=
                   8316: 
                   8317: 
                   8318:        # Read the .la file
                   8319:        func_source "$lib"
                   8320: 
                   8321:        # Convert "-framework foo" to "foo.ltframework"
                   8322:        if test -n "$inherited_linker_flags"; then
                   8323:          tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
                   8324:          for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
                   8325:            case " $new_inherited_linker_flags " in
                   8326:              *" $tmp_inherited_linker_flag "*) ;;
                   8327:              *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
                   8328:            esac
                   8329:          done
                   8330:        fi
                   8331:        dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
1.7     ! moko     8332:        if test lib,link = "$linkmode,$pass" ||
        !          8333:           test prog,scan = "$linkmode,$pass" ||
        !          8334:           { test prog != "$linkmode" && test lib != "$linkmode"; }; then
1.6       moko     8335:          test -n "$dlopen" && func_append dlfiles " $dlopen"
                   8336:          test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
                   8337:        fi
                   8338: 
1.7     ! moko     8339:        if test conv = "$pass"; then
1.6       moko     8340:          # Only check for convenience libraries
                   8341:          deplibs="$lib $deplibs"
                   8342:          if test -z "$libdir"; then
                   8343:            if test -z "$old_library"; then
1.7     ! moko     8344:              func_fatal_error "cannot find name of link library for '$lib'"
1.6       moko     8345:            fi
                   8346:            # It is a libtool convenience library, so add in its objects.
                   8347:            func_append convenience " $ladir/$objdir/$old_library"
                   8348:            func_append old_convenience " $ladir/$objdir/$old_library"
1.7     ! moko     8349:            tmp_libs=
        !          8350:            for deplib in $dependency_libs; do
        !          8351:              deplibs="$deplib $deplibs"
        !          8352:              if $opt_preserve_dup_deps; then
        !          8353:                case "$tmp_libs " in
        !          8354:                *" $deplib "*) func_append specialdeplibs " $deplib" ;;
        !          8355:                esac
        !          8356:              fi
        !          8357:              func_append tmp_libs " $deplib"
        !          8358:            done
        !          8359:          elif test prog != "$linkmode" && test lib != "$linkmode"; then
        !          8360:            func_fatal_error "'$lib' is not a convenience library"
1.6       moko     8361:          fi
                   8362:          continue
                   8363:        fi # $pass = conv
                   8364: 
                   8365: 
                   8366:        # Get the name of the library we link against.
                   8367:        linklib=
                   8368:        if test -n "$old_library" &&
1.7     ! moko     8369:           { test yes = "$prefer_static_libs" ||
        !          8370:             test built,no = "$prefer_static_libs,$installed"; }; then
1.6       moko     8371:          linklib=$old_library
                   8372:        else
                   8373:          for l in $old_library $library_names; do
1.7     ! moko     8374:            linklib=$l
1.6       moko     8375:          done
                   8376:        fi
                   8377:        if test -z "$linklib"; then
1.7     ! moko     8378:          func_fatal_error "cannot find name of link library for '$lib'"
1.6       moko     8379:        fi
                   8380: 
                   8381:        # This library was specified with -dlopen.
1.7     ! moko     8382:        if test dlopen = "$pass"; then
        !          8383:          test -z "$libdir" \
        !          8384:            && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
1.6       moko     8385:          if test -z "$dlname" ||
1.7     ! moko     8386:             test yes != "$dlopen_support" ||
        !          8387:             test no = "$build_libtool_libs"
        !          8388:          then
1.6       moko     8389:            # If there is no dlname, no dlopen support or we're linking
                   8390:            # statically, we need to preload.  We also need to preload any
                   8391:            # dependent libraries so libltdl's deplib preloader doesn't
                   8392:            # bomb out in the load deplibs phase.
                   8393:            func_append dlprefiles " $lib $dependency_libs"
                   8394:          else
                   8395:            func_append newdlfiles " $lib"
                   8396:          fi
                   8397:          continue
                   8398:        fi # $pass = dlopen
                   8399: 
                   8400:        # We need an absolute path.
                   8401:        case $ladir in
1.7     ! moko     8402:        [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
1.6       moko     8403:        *)
                   8404:          abs_ladir=`cd "$ladir" && pwd`
                   8405:          if test -z "$abs_ladir"; then
1.7     ! moko     8406:            func_warning "cannot determine absolute directory name of '$ladir'"
1.6       moko     8407:            func_warning "passing it literally to the linker, although it might fail"
1.7     ! moko     8408:            abs_ladir=$ladir
1.6       moko     8409:          fi
                   8410:          ;;
                   8411:        esac
                   8412:        func_basename "$lib"
1.7     ! moko     8413:        laname=$func_basename_result
1.6       moko     8414: 
                   8415:        # Find the relevant object directory and library name.
1.7     ! moko     8416:        if test yes = "$installed"; then
1.6       moko     8417:          if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
1.7     ! moko     8418:            func_warning "library '$lib' was moved."
        !          8419:            dir=$ladir
        !          8420:            absdir=$abs_ladir
        !          8421:            libdir=$abs_ladir
1.6       moko     8422:          else
1.7     ! moko     8423:            dir=$lt_sysroot$libdir
        !          8424:            absdir=$lt_sysroot$libdir
1.6       moko     8425:          fi
1.7     ! moko     8426:          test yes = "$hardcode_automatic" && avoidtemprpath=yes
1.6       moko     8427:        else
                   8428:          if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
1.7     ! moko     8429:            dir=$ladir
        !          8430:            absdir=$abs_ladir
1.6       moko     8431:            # Remove this search path later
                   8432:            func_append notinst_path " $abs_ladir"
                   8433:          else
1.7     ! moko     8434:            dir=$ladir/$objdir
        !          8435:            absdir=$abs_ladir/$objdir
1.6       moko     8436:            # Remove this search path later
                   8437:            func_append notinst_path " $abs_ladir"
                   8438:          fi
                   8439:        fi # $installed = yes
                   8440:        func_stripname 'lib' '.la' "$laname"
                   8441:        name=$func_stripname_result
                   8442: 
                   8443:        # This library was specified with -dlpreopen.
1.7     ! moko     8444:        if test dlpreopen = "$pass"; then
        !          8445:          if test -z "$libdir" && test prog = "$linkmode"; then
        !          8446:            func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
1.6       moko     8447:          fi
1.7     ! moko     8448:          case $host in
1.6       moko     8449:            # special handling for platforms with PE-DLLs.
1.7     ! moko     8450:            *cygwin* | *mingw* | *windows* | *cegcc* )
1.6       moko     8451:              # Linker will automatically link against shared library if both
                   8452:              # static and shared are present.  Therefore, ensure we extract
                   8453:              # symbols from the import library if a shared library is present
                   8454:              # (otherwise, the dlopen module name will be incorrect).  We do
                   8455:              # this by putting the import library name into $newdlprefiles.
                   8456:              # We recover the dlopen module name by 'saving' the la file
                   8457:              # name in a special purpose variable, and (later) extracting the
                   8458:              # dlname from the la file.
                   8459:              if test -n "$dlname"; then
                   8460:                func_tr_sh "$dir/$linklib"
                   8461:                eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
                   8462:                func_append newdlprefiles " $dir/$linklib"
                   8463:              else
                   8464:                func_append newdlprefiles " $dir/$old_library"
                   8465:                # Keep a list of preopened convenience libraries to check
                   8466:                # that they are being used correctly in the link pass.
                   8467:                test -z "$libdir" && \
                   8468:                  func_append dlpreconveniencelibs " $dir/$old_library"
                   8469:              fi
                   8470:            ;;
                   8471:            * )
                   8472:              # Prefer using a static library (so that no silly _DYNAMIC symbols
                   8473:              # are required to link).
                   8474:              if test -n "$old_library"; then
                   8475:                func_append newdlprefiles " $dir/$old_library"
                   8476:                # Keep a list of preopened convenience libraries to check
                   8477:                # that they are being used correctly in the link pass.
                   8478:                test -z "$libdir" && \
                   8479:                  func_append dlpreconveniencelibs " $dir/$old_library"
                   8480:              # Otherwise, use the dlname, so that lt_dlopen finds it.
                   8481:              elif test -n "$dlname"; then
                   8482:                func_append newdlprefiles " $dir/$dlname"
                   8483:              else
                   8484:                func_append newdlprefiles " $dir/$linklib"
                   8485:              fi
                   8486:            ;;
                   8487:          esac
                   8488:        fi # $pass = dlpreopen
                   8489: 
                   8490:        if test -z "$libdir"; then
                   8491:          # Link the convenience library
1.7     ! moko     8492:          if test lib = "$linkmode"; then
1.6       moko     8493:            deplibs="$dir/$old_library $deplibs"
1.7     ! moko     8494:          elif test prog,link = "$linkmode,$pass"; then
1.6       moko     8495:            compile_deplibs="$dir/$old_library $compile_deplibs"
                   8496:            finalize_deplibs="$dir/$old_library $finalize_deplibs"
                   8497:          else
                   8498:            deplibs="$lib $deplibs" # used for prog,scan pass
                   8499:          fi
                   8500:          continue
                   8501:        fi
                   8502: 
                   8503: 
1.7     ! moko     8504:        if test prog = "$linkmode" && test link != "$pass"; then
1.6       moko     8505:          func_append newlib_search_path " $ladir"
                   8506:          deplibs="$lib $deplibs"
                   8507: 
1.7     ! moko     8508:          linkalldeplibs=false
        !          8509:          if test no != "$link_all_deplibs" || test -z "$library_names" ||
        !          8510:             test no = "$build_libtool_libs"; then
        !          8511:            linkalldeplibs=:
1.6       moko     8512:          fi
                   8513: 
                   8514:          tmp_libs=
                   8515:          for deplib in $dependency_libs; do
                   8516:            case $deplib in
                   8517:            -L*) func_stripname '-L' '' "$deplib"
                   8518:                 func_resolve_sysroot "$func_stripname_result"
                   8519:                 func_append newlib_search_path " $func_resolve_sysroot_result"
                   8520:                 ;;
                   8521:            esac
                   8522:            # Need to link against all dependency_libs?
1.7     ! moko     8523:            if $linkalldeplibs; then
1.6       moko     8524:              deplibs="$deplib $deplibs"
                   8525:            else
                   8526:              # Need to hardcode shared library paths
                   8527:              # or/and link against static libraries
                   8528:              newdependency_libs="$deplib $newdependency_libs"
                   8529:            fi
1.7     ! moko     8530:            if $opt_preserve_dup_deps; then
1.6       moko     8531:              case "$tmp_libs " in
                   8532:              *" $deplib "*) func_append specialdeplibs " $deplib" ;;
                   8533:              esac
                   8534:            fi
                   8535:            func_append tmp_libs " $deplib"
                   8536:          done # for deplib
                   8537:          continue
                   8538:        fi # $linkmode = prog...
                   8539: 
1.7     ! moko     8540:        if test prog,link = "$linkmode,$pass"; then
1.6       moko     8541:          if test -n "$library_names" &&
1.7     ! moko     8542:             { { test no = "$prefer_static_libs" ||
        !          8543:                 test built,yes = "$prefer_static_libs,$installed"; } ||
1.6       moko     8544:               test -z "$old_library"; }; then
                   8545:            # We need to hardcode the library path
1.7     ! moko     8546:            if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
1.6       moko     8547:              # Make sure the rpath contains only unique directories.
1.7     ! moko     8548:              case $temp_rpath: in
1.6       moko     8549:              *"$absdir:"*) ;;
1.7     ! moko     8550:               *) case $absdir in
        !          8551:                  "$progdir/"*) func_append temp_rpath "$absdir:" ;;
        !          8552:                  *)            func_append temp_rpath_tail "$absdir:" ;;
        !          8553:                  esac
1.6       moko     8554:              esac
                   8555:            fi
                   8556: 
                   8557:            # Hardcode the library path.
                   8558:            # Skip directories that are in the system default run-time
                   8559:            # search path.
                   8560:            case " $sys_lib_dlsearch_path " in
                   8561:            *" $absdir "*) ;;
                   8562:            *)
1.7     ! moko     8563:              case "$compile_rpath$compile_rpath_tail " in
1.6       moko     8564:              *" $absdir "*) ;;
1.7     ! moko     8565:              *) case $absdir in
        !          8566:                  "$progdir/"*) func_append compile_rpath " $absdir" ;;
        !          8567:                  *) func_append compile_rpath_tail " $absdir" ;;
        !          8568:                 esac
1.6       moko     8569:              esac
                   8570:              ;;
                   8571:            esac
                   8572:            case " $sys_lib_dlsearch_path " in
                   8573:            *" $libdir "*) ;;
                   8574:            *)
                   8575:              case "$finalize_rpath " in
                   8576:              *" $libdir "*) ;;
                   8577:              *) func_append finalize_rpath " $libdir" ;;
                   8578:              esac
                   8579:              ;;
                   8580:            esac
                   8581:          fi # $linkmode,$pass = prog,link...
                   8582: 
1.7     ! moko     8583:          if $alldeplibs &&
        !          8584:             { test pass_all = "$deplibs_check_method" ||
        !          8585:               { test yes = "$build_libtool_libs" &&
1.6       moko     8586:                 test -n "$library_names"; }; }; then
                   8587:            # We only need to search for static libraries
                   8588:            continue
                   8589:          fi
                   8590:        fi
                   8591: 
                   8592:        link_static=no # Whether the deplib will be linked statically
                   8593:        use_static_libs=$prefer_static_libs
1.7     ! moko     8594:        if test built = "$use_static_libs" && test yes = "$installed"; then
1.6       moko     8595:          use_static_libs=no
                   8596:        fi
                   8597:        if test -n "$library_names" &&
1.7     ! moko     8598:           { test no = "$use_static_libs" || test -z "$old_library"; }; then
        !          8599:          case $host_os in
        !          8600:          cygwin* | mingw* | windows* | cegcc* | os2*)
1.6       moko     8601:              # No point in relinking DLLs because paths are not encoded
                   8602:              func_append notinst_deplibs " $lib"
                   8603:              need_relink=no
                   8604:            ;;
                   8605:          *)
1.7     ! moko     8606:            if test no = "$installed"; then
1.6       moko     8607:              func_append notinst_deplibs " $lib"
                   8608:              need_relink=yes
                   8609:            fi
                   8610:            ;;
                   8611:          esac
                   8612:          # This is a shared library
                   8613: 
                   8614:          # Warn about portability, can't link against -module's on some
                   8615:          # systems (darwin).  Don't bleat about dlopened modules though!
1.7     ! moko     8616:          dlopenmodule=
1.6       moko     8617:          for dlpremoduletest in $dlprefiles; do
                   8618:            if test "X$dlpremoduletest" = "X$lib"; then
1.7     ! moko     8619:              dlopenmodule=$dlpremoduletest
1.6       moko     8620:              break
                   8621:            fi
                   8622:          done
1.7     ! moko     8623:          if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
1.6       moko     8624:            echo
1.7     ! moko     8625:            if test prog = "$linkmode"; then
        !          8626:              func_warning "Linking the executable $output against the loadable module"
1.6       moko     8627:            else
1.7     ! moko     8628:              func_warning "Linking the shared library $output against the loadable module"
1.6       moko     8629:            fi
1.7     ! moko     8630:            func_warning "$linklib is not portable!"
1.6       moko     8631:          fi
1.7     ! moko     8632:          if test lib = "$linkmode" &&
        !          8633:             test yes = "$hardcode_into_libs"; then
1.6       moko     8634:            # Hardcode the library path.
                   8635:            # Skip directories that are in the system default run-time
                   8636:            # search path.
                   8637:            case " $sys_lib_dlsearch_path " in
                   8638:            *" $absdir "*) ;;
                   8639:            *)
1.7     ! moko     8640:              case "$compile_rpath$compile_rpath_tail " in
1.6       moko     8641:              *" $absdir "*) ;;
1.7     ! moko     8642:              *) case $absdir in
        !          8643:                  "$progdir/"*) func_append compile_rpath " $absdir" ;;
        !          8644:                  *) func_append compile_rpath_tail " $absdir" ;;
        !          8645:                 esac
1.6       moko     8646:              esac
                   8647:              ;;
                   8648:            esac
                   8649:            case " $sys_lib_dlsearch_path " in
                   8650:            *" $libdir "*) ;;
                   8651:            *)
                   8652:              case "$finalize_rpath " in
                   8653:              *" $libdir "*) ;;
                   8654:              *) func_append finalize_rpath " $libdir" ;;
                   8655:              esac
                   8656:              ;;
                   8657:            esac
                   8658:          fi
                   8659: 
                   8660:          if test -n "$old_archive_from_expsyms_cmds"; then
                   8661:            # figure out the soname
                   8662:            set dummy $library_names
                   8663:            shift
1.7     ! moko     8664:            realname=$1
1.6       moko     8665:            shift
                   8666:            libname=`eval "\\$ECHO \"$libname_spec\""`
                   8667:            # use dlname if we got it. it's perfectly good, no?
                   8668:            if test -n "$dlname"; then
1.7     ! moko     8669:              soname=$dlname
1.6       moko     8670:            elif test -n "$soname_spec"; then
                   8671:              # bleh windows
1.7     ! moko     8672:              case $host_os in
        !          8673:              cygwin* | mingw* | windows* | cegcc* | os2*)
1.6       moko     8674:                func_arith $current - $age
                   8675:                major=$func_arith_result
1.7     ! moko     8676:                versuffix=-$major
1.6       moko     8677:                ;;
                   8678:              esac
                   8679:              eval soname=\"$soname_spec\"
                   8680:            else
1.7     ! moko     8681:              soname=$realname
1.6       moko     8682:            fi
                   8683: 
                   8684:            # Make a new name for the extract_expsyms_cmds to use
1.7     ! moko     8685:            soroot=$soname
1.6       moko     8686:            func_basename "$soroot"
1.7     ! moko     8687:            soname=$func_basename_result
1.6       moko     8688:            func_stripname 'lib' '.dll' "$soname"
                   8689:            newlib=libimp-$func_stripname_result.a
                   8690: 
                   8691:            # If the library has no export list, then create one now
                   8692:            if test -f "$output_objdir/$soname-def"; then :
                   8693:            else
1.7     ! moko     8694:              func_verbose "extracting exported symbol list from '$soname'"
1.6       moko     8695:              func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
                   8696:            fi
                   8697: 
                   8698:            # Create $newlib
                   8699:            if test -f "$output_objdir/$newlib"; then :; else
1.7     ! moko     8700:              func_verbose "generating import library for '$soname'"
1.6       moko     8701:              func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
1.5       paf      8702:            fi
1.6       moko     8703:            # make sure the library variables are pointing to the new library
                   8704:            dir=$output_objdir
                   8705:            linklib=$newlib
                   8706:          fi # test -n "$old_archive_from_expsyms_cmds"
1.5       paf      8707: 
1.7     ! moko     8708:          if test prog = "$linkmode" || test relink != "$opt_mode"; then
1.6       moko     8709:            add_shlibpath=
                   8710:            add_dir=
                   8711:            add=
                   8712:            lib_linked=yes
                   8713:            case $hardcode_action in
                   8714:            immediate | unsupported)
1.7     ! moko     8715:              if test no = "$hardcode_direct"; then
        !          8716:                add=$dir/$linklib
1.6       moko     8717:                case $host in
1.7     ! moko     8718:                  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
        !          8719:                  *-*-sysv4*uw2*) add_dir=-L$dir ;;
        !          8720:                  *-*-emscripten*) add_dir=-L$dir ;;
1.6       moko     8721:                  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
1.7     ! moko     8722:                    *-*-unixware7*) add_dir=-L$dir ;;
1.6       moko     8723:                  *-*-darwin* )
1.7     ! moko     8724:                    # if the lib is a (non-dlopened) module then we cannot
1.6       moko     8725:                    # link against it, someone is ignoring the earlier warnings
                   8726:                    if /usr/bin/file -L $add 2> /dev/null |
1.7     ! moko     8727:                         $GREP ": [^:]* bundle" >/dev/null; then
1.6       moko     8728:                      if test "X$dlopenmodule" != "X$lib"; then
1.7     ! moko     8729:                        func_warning "lib $linklib is a module, not a shared library"
        !          8730:                        if test -z "$old_library"; then
        !          8731:                          func_warning "And there doesn't seem to be a static archive available"
        !          8732:                          func_warning "The link will probably fail, sorry"
1.6       moko     8733:                        else
1.7     ! moko     8734:                          add=$dir/$old_library
1.6       moko     8735:                        fi
                   8736:                      elif test -n "$old_library"; then
1.7     ! moko     8737:                        add=$dir/$old_library
1.6       moko     8738:                      fi
                   8739:                    fi
                   8740:                esac
1.7     ! moko     8741:              elif test no = "$hardcode_minus_L"; then
1.6       moko     8742:                case $host in
1.7     ! moko     8743:                *-*-sunos*) add_shlibpath=$dir ;;
1.6       moko     8744:                esac
1.7     ! moko     8745:                add_dir=-L$dir
        !          8746:                add=-l$name
        !          8747:              elif test no = "$hardcode_shlibpath_var"; then
        !          8748:                add_shlibpath=$dir
        !          8749:                add=-l$name
1.5       paf      8750:              else
1.6       moko     8751:                lib_linked=no
1.5       paf      8752:              fi
1.6       moko     8753:              ;;
                   8754:            relink)
1.7     ! moko     8755:              if test yes = "$hardcode_direct" &&
        !          8756:                 test no = "$hardcode_direct_absolute"; then
        !          8757:                add=$dir/$linklib
        !          8758:              elif test yes = "$hardcode_minus_L"; then
        !          8759:                add_dir=-L$absdir
1.6       moko     8760:                # Try looking first in the location we're being installed to.
                   8761:                if test -n "$inst_prefix_dir"; then
                   8762:                  case $libdir in
                   8763:                    [\\/]*)
                   8764:                      func_append add_dir " -L$inst_prefix_dir$libdir"
                   8765:                      ;;
                   8766:                  esac
1.5       paf      8767:                fi
1.7     ! moko     8768:                add=-l$name
        !          8769:              elif test yes = "$hardcode_shlibpath_var"; then
        !          8770:                add_shlibpath=$dir
        !          8771:                add=-l$name
1.5       paf      8772:              else
1.6       moko     8773:                lib_linked=no
                   8774:              fi
                   8775:              ;;
                   8776:            *) lib_linked=no ;;
                   8777:            esac
                   8778: 
1.7     ! moko     8779:            if test yes != "$lib_linked"; then
1.6       moko     8780:              func_fatal_configuration "unsupported hardcode properties"
                   8781:            fi
                   8782: 
                   8783:            if test -n "$add_shlibpath"; then
                   8784:              case :$compile_shlibpath: in
                   8785:              *":$add_shlibpath:"*) ;;
                   8786:              *) func_append compile_shlibpath "$add_shlibpath:" ;;
                   8787:              esac
                   8788:            fi
1.7     ! moko     8789:            if test prog = "$linkmode"; then
1.6       moko     8790:              test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
                   8791:              test -n "$add" && compile_deplibs="$add $compile_deplibs"
                   8792:            else
                   8793:              test -n "$add_dir" && deplibs="$add_dir $deplibs"
                   8794:              test -n "$add" && deplibs="$add $deplibs"
1.7     ! moko     8795:              if test yes != "$hardcode_direct" &&
        !          8796:                 test yes != "$hardcode_minus_L" &&
        !          8797:                 test yes = "$hardcode_shlibpath_var"; then
1.6       moko     8798:                case :$finalize_shlibpath: in
                   8799:                *":$libdir:"*) ;;
                   8800:                *) func_append finalize_shlibpath "$libdir:" ;;
                   8801:                esac
1.5       paf      8802:              fi
1.6       moko     8803:            fi
1.5       paf      8804:          fi
1.6       moko     8805: 
1.7     ! moko     8806:          if test prog = "$linkmode" || test relink = "$opt_mode"; then
1.6       moko     8807:            add_shlibpath=
                   8808:            add_dir=
                   8809:            add=
                   8810:            # Finalize command for both is simple: just hardcode it.
1.7     ! moko     8811:            if test yes = "$hardcode_direct" &&
        !          8812:               test no = "$hardcode_direct_absolute"; then
        !          8813:              add=$libdir/$linklib
        !          8814:            elif test yes = "$hardcode_minus_L"; then
        !          8815:              add_dir=-L$lt_sysroot$libdir
        !          8816:              add=-l$name
        !          8817:            elif test yes = "$hardcode_shlibpath_var"; then
1.6       moko     8818:              case :$finalize_shlibpath: in
                   8819:              *":$libdir:"*) ;;
                   8820:              *) func_append finalize_shlibpath "$libdir:" ;;
                   8821:              esac
1.7     ! moko     8822:              add=-l$name
        !          8823:            elif test yes = "$hardcode_automatic"; then
1.6       moko     8824:              if test -n "$inst_prefix_dir" &&
1.7     ! moko     8825:                 test -f "$inst_prefix_dir$libdir/$linklib"; then
        !          8826:                add=$inst_prefix_dir$libdir/$linklib
1.6       moko     8827:              else
1.7     ! moko     8828:                add=$libdir/$linklib
1.5       paf      8829:              fi
                   8830:            else
1.6       moko     8831:              # We cannot seem to hardcode it, guess we'll fake it.
1.7     ! moko     8832:              add_dir=-L$lt_sysroot$libdir
1.6       moko     8833:              # Try looking first in the location we're being installed to.
                   8834:              if test -n "$inst_prefix_dir"; then
                   8835:                case $libdir in
                   8836:                  [\\/]*)
                   8837:                    func_append add_dir " -L$inst_prefix_dir$libdir"
                   8838:                    ;;
                   8839:                esac
1.5       paf      8840:              fi
1.7     ! moko     8841:              add=-l$name
1.5       paf      8842:            fi
                   8843: 
1.7     ! moko     8844:            if test prog = "$linkmode"; then
1.6       moko     8845:              test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
                   8846:              test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
1.5       paf      8847:            else
1.6       moko     8848:              test -n "$add_dir" && deplibs="$add_dir $deplibs"
                   8849:              test -n "$add" && deplibs="$add $deplibs"
1.5       paf      8850:            fi
1.6       moko     8851:          fi
1.7     ! moko     8852:        elif test prog = "$linkmode"; then
1.6       moko     8853:          # Here we assume that one of hardcode_direct or hardcode_minus_L
                   8854:          # is not unsupported.  This is valid on all known static and
                   8855:          # shared platforms.
1.7     ! moko     8856:          if test unsupported != "$hardcode_direct"; then
        !          8857:            test -n "$old_library" && linklib=$old_library
1.6       moko     8858:            compile_deplibs="$dir/$linklib $compile_deplibs"
                   8859:            finalize_deplibs="$dir/$linklib $finalize_deplibs"
1.5       paf      8860:          else
1.6       moko     8861:            compile_deplibs="-l$name -L$dir $compile_deplibs"
                   8862:            finalize_deplibs="-l$name -L$dir $finalize_deplibs"
                   8863:          fi
1.7     ! moko     8864:        elif test yes = "$build_libtool_libs"; then
1.6       moko     8865:          # Not a shared library
1.7     ! moko     8866:          if test pass_all != "$deplibs_check_method"; then
1.6       moko     8867:            # We're trying link a shared library against a static one
                   8868:            # but the system doesn't support it.
1.5       paf      8869: 
1.6       moko     8870:            # Just print a warning and add the library to dependency_libs so
                   8871:            # that the program can be linked against the static library.
1.7     ! moko     8872:            func_warning "This system cannot link to static lib archive $lib."
        !          8873:            func_warning "I have the capability to make that library automatically link in when"
        !          8874:            func_warning "you link to this library.  But I can only do this if you have a"
        !          8875:            func_warning "shared version of the library, which you do not appear to have."
        !          8876:            if test yes = "$module"; then
        !          8877:              func_warning "But as you try to build a module library, libtool will still create "
        !          8878:              func_warning "a static module, that should work as long as the dlopening application"
        !          8879:              func_warning "is linked with the -dlopen flag to resolve symbols at runtime."
1.6       moko     8880:              if test -z "$global_symbol_pipe"; then
1.7     ! moko     8881:                func_warning "However, this would only work if libtool was able to extract symbol"
        !          8882:                func_warning "lists from a program, using 'nm' or equivalent, but libtool could"
        !          8883:                func_warning "not find such a program.  So, this module is probably useless."
        !          8884:                func_warning "'nm' from GNU binutils and a full rebuild may help."
1.6       moko     8885:              fi
1.7     ! moko     8886:              if test no = "$build_old_libs"; then
1.5       paf      8887:                build_libtool_libs=module
                   8888:                build_old_libs=yes
                   8889:              else
                   8890:                build_libtool_libs=no
                   8891:              fi
                   8892:            fi
1.6       moko     8893:          else
                   8894:            deplibs="$dir/$old_library $deplibs"
                   8895:            link_static=yes
                   8896:          fi
                   8897:        fi # link shared/static library?
                   8898: 
1.7     ! moko     8899:        if test lib = "$linkmode"; then
1.6       moko     8900:          if test -n "$dependency_libs" &&
1.7     ! moko     8901:             { test yes != "$hardcode_into_libs" ||
        !          8902:               test yes = "$build_old_libs" ||
        !          8903:               test yes = "$link_static"; }; then
1.6       moko     8904:            # Extract -R from dependency_libs
                   8905:            temp_deplibs=
                   8906:            for libdir in $dependency_libs; do
                   8907:              case $libdir in
                   8908:              -R*) func_stripname '-R' '' "$libdir"
                   8909:                   temp_xrpath=$func_stripname_result
                   8910:                   case " $xrpath " in
                   8911:                   *" $temp_xrpath "*) ;;
                   8912:                   *) func_append xrpath " $temp_xrpath";;
                   8913:                   esac;;
                   8914:              *) func_append temp_deplibs " $libdir";;
                   8915:              esac
                   8916:            done
1.7     ! moko     8917:            dependency_libs=$temp_deplibs
1.5       paf      8918:          fi
                   8919: 
1.6       moko     8920:          func_append newlib_search_path " $absdir"
                   8921:          # Link against this library
1.7     ! moko     8922:          test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
1.6       moko     8923:          # ... and its dependency_libs
                   8924:          tmp_libs=
                   8925:          for deplib in $dependency_libs; do
                   8926:            newdependency_libs="$deplib $newdependency_libs"
                   8927:            case $deplib in
                   8928:               -L*) func_stripname '-L' '' "$deplib"
                   8929:                    func_resolve_sysroot "$func_stripname_result";;
                   8930:               *) func_resolve_sysroot "$deplib" ;;
                   8931:             esac
1.7     ! moko     8932:            if $opt_preserve_dup_deps; then
1.6       moko     8933:              case "$tmp_libs " in
                   8934:              *" $func_resolve_sysroot_result "*)
                   8935:                 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
                   8936:              esac
                   8937:            fi
                   8938:            func_append tmp_libs " $func_resolve_sysroot_result"
                   8939:          done
1.5       paf      8940: 
1.7     ! moko     8941:          if test no != "$link_all_deplibs"; then
1.6       moko     8942:            # Add the search paths of all dependency libraries
                   8943:            for deplib in $dependency_libs; do
                   8944:              path=
                   8945:              case $deplib in
1.7     ! moko     8946:              -L*) path=$deplib ;;
1.6       moko     8947:              *.la)
                   8948:                func_resolve_sysroot "$deplib"
                   8949:                deplib=$func_resolve_sysroot_result
                   8950:                func_dirname "$deplib" "" "."
                   8951:                dir=$func_dirname_result
                   8952:                # We need an absolute path.
                   8953:                case $dir in
1.7     ! moko     8954:                [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
1.6       moko     8955:                *)
                   8956:                  absdir=`cd "$dir" && pwd`
                   8957:                  if test -z "$absdir"; then
1.7     ! moko     8958:                    func_warning "cannot determine absolute directory name of '$dir'"
        !          8959:                    absdir=$dir
1.6       moko     8960:                  fi
                   8961:                  ;;
                   8962:                esac
                   8963:                if $GREP "^installed=no" $deplib > /dev/null; then
                   8964:                case $host in
                   8965:                *-*-darwin*)
                   8966:                  depdepl=
1.7     ! moko     8967:                  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
        !          8968:                  if test -n "$deplibrary_names"; then
        !          8969:                    for tmp in $deplibrary_names; do
1.6       moko     8970:                      depdepl=$tmp
                   8971:                    done
1.7     ! moko     8972:                    if test -f "$absdir/$objdir/$depdepl"; then
        !          8973:                      depdepl=$absdir/$objdir/$depdepl
        !          8974:                      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
1.6       moko     8975:                       if test -z "$darwin_install_name"; then
1.7     ! moko     8976:                           darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
1.6       moko     8977:                       fi
1.7     ! moko     8978:                      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
        !          8979:                      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
1.6       moko     8980:                      path=
                   8981:                    fi
                   8982:                  fi
                   8983:                  ;;
                   8984:                *)
1.7     ! moko     8985:                  path=-L$absdir/$objdir
1.6       moko     8986:                  ;;
                   8987:                esac
1.5       paf      8988:                else
1.7     ! moko     8989:                  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
1.6       moko     8990:                  test -z "$libdir" && \
1.7     ! moko     8991:                    func_fatal_error "'$deplib' is not a valid libtool archive"
1.6       moko     8992:                  test "$absdir" != "$libdir" && \
1.7     ! moko     8993:                    func_warning "'$deplib' seems to be moved"
1.6       moko     8994: 
1.7     ! moko     8995:                  path=-L$absdir
1.5       paf      8996:                fi
1.6       moko     8997:                ;;
                   8998:              esac
                   8999:              case " $deplibs " in
                   9000:              *" $path "*) ;;
                   9001:              *) deplibs="$path $deplibs" ;;
                   9002:              esac
                   9003:            done
                   9004:          fi # link_all_deplibs != no
                   9005:        fi # linkmode = lib
                   9006:       done # for deplib in $libs
1.7     ! moko     9007: 
        !          9008:       func_append temp_rpath "$temp_rpath_tail"
        !          9009:       func_append compile_rpath "$compile_rpath_tail"
        !          9010: 
        !          9011:       if test link = "$pass"; then
        !          9012:        if test prog = "$linkmode"; then
1.6       moko     9013:          compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
                   9014:          finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
                   9015:        else
                   9016:          compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
                   9017:        fi
                   9018:       fi
1.7     ! moko     9019:       dependency_libs=$newdependency_libs
        !          9020:       if test dlpreopen = "$pass"; then
1.6       moko     9021:        # Link the dlpreopened libraries before other libraries
                   9022:        for deplib in $save_deplibs; do
                   9023:          deplibs="$deplib $deplibs"
                   9024:        done
                   9025:       fi
1.7     ! moko     9026:       if test dlopen != "$pass"; then
        !          9027:        test conv = "$pass" || {
1.6       moko     9028:          # Make sure lib_search_path contains only unique directories.
                   9029:          lib_search_path=
                   9030:          for dir in $newlib_search_path; do
                   9031:            case "$lib_search_path " in
                   9032:            *" $dir "*) ;;
                   9033:            *) func_append lib_search_path " $dir" ;;
                   9034:            esac
                   9035:          done
                   9036:          newlib_search_path=
1.7     ! moko     9037:        }
1.6       moko     9038: 
1.7     ! moko     9039:        if test prog,link = "$linkmode,$pass"; then
        !          9040:          vars="compile_deplibs finalize_deplibs"
1.6       moko     9041:        else
1.7     ! moko     9042:          vars=deplibs
1.6       moko     9043:        fi
                   9044:        for var in $vars dependency_libs; do
                   9045:          # Add libraries to $var in reverse order
                   9046:          eval tmp_libs=\"\$$var\"
                   9047:          new_libs=
1.7     ! moko     9048:          # FIXME: Pedantically, this is the right thing to do, so
        !          9049:          #        that some nasty dependency loop isn't accidentally
        !          9050:          #        broken: new_libs="$deplib $new_libs"
1.6       moko     9051:          for deplib in $tmp_libs; do
1.7     ! moko     9052:            if $opt_preserve_dup_deps; then
        !          9053:              new_libs="$deplib $new_libs"
        !          9054:            else
        !          9055:              # Pragmatically, this seems to cause very few problems in
        !          9056:              # practice:
        !          9057:              case $deplib in
        !          9058:              -L*) new_libs="$deplib $new_libs" ;;
        !          9059:              -R*) ;;
1.6       moko     9060:              *)
1.7     ! moko     9061:                # And here is the reason: when a library appears more
        !          9062:                # than once as an explicit dependence of a library, or
        !          9063:                # is implicitly linked in more than once by the
        !          9064:                # compiler, it is considered special, and multiple
        !          9065:                # occurrences thereof are not removed.  Compare this
        !          9066:                # with having the same library being listed as a
        !          9067:                # dependency of multiple other libraries: in this case,
        !          9068:                # we know (pedantically, we assume) the library does not
        !          9069:                # need to be listed more than once, so we keep only the
        !          9070:                # last copy.  This is not always right, but it is rare
        !          9071:                # enough that we require users that really mean to play
        !          9072:                # such unportable linking tricks to link the library
        !          9073:                # using -Wl,-lname, so that libtool does not consider it
        !          9074:                # for duplicate removal.  And if not possible for portability
        !          9075:                # reasons, then --preserve-dup-deps should be used.
        !          9076:                case " $specialdeplibs " in
        !          9077:                *" $deplib "*) new_libs="$deplib $new_libs" ;;
        !          9078:                *)
        !          9079:                  case " $new_libs " in
        !          9080:                  *" $deplib "*) ;;
        !          9081:                  *) new_libs="$deplib $new_libs" ;;
        !          9082:                  esac
        !          9083:                  ;;
        !          9084:                esac
        !          9085:                ;;
1.6       moko     9086:              esac
1.7     ! moko     9087:            fi
1.6       moko     9088:          done
                   9089:          tmp_libs=
                   9090:          for deplib in $new_libs; do
                   9091:            case $deplib in
                   9092:            -L*)
                   9093:              case " $tmp_libs " in
                   9094:              *" $deplib "*) ;;
                   9095:              *) func_append tmp_libs " $deplib" ;;
1.5       paf      9096:              esac
1.6       moko     9097:              ;;
                   9098:            *) func_append tmp_libs " $deplib" ;;
                   9099:            esac
1.5       paf      9100:          done
1.6       moko     9101:          eval $var=\"$tmp_libs\"
                   9102:        done # for var
                   9103:       fi
1.7     ! moko     9104: 
        !          9105:       # Add Sun CC postdeps if required:
        !          9106:       test CXX = "$tagname" && {
        !          9107:         case $host_os in
        !          9108:         linux*)
        !          9109:           case `$CC -V 2>&1 | $SED 5q` in
        !          9110:           *Sun\ C*) # Sun C++ 5.9
        !          9111:             func_suncc_cstd_abi
        !          9112: 
        !          9113:             if test no != "$suncc_use_cstd_abi"; then
        !          9114:               func_append postdeps ' -library=Cstd -library=Crun'
        !          9115:             fi
        !          9116:             ;;
        !          9117:           esac
        !          9118:           ;;
        !          9119: 
        !          9120:         solaris*)
        !          9121:           func_cc_basename "$CC"
        !          9122:           case $func_cc_basename_result in
        !          9123:           CC* | sunCC*)
        !          9124:             func_suncc_cstd_abi
        !          9125: 
        !          9126:             if test no != "$suncc_use_cstd_abi"; then
        !          9127:               func_append postdeps ' -library=Cstd -library=Crun'
        !          9128:             fi
        !          9129:             ;;
        !          9130:           esac
        !          9131:           ;;
        !          9132:         esac
        !          9133:       }
        !          9134: 
1.6       moko     9135:       # Last step: remove runtime libs from dependency_libs
                   9136:       # (they stay in deplibs)
                   9137:       tmp_libs=
1.7     ! moko     9138:       for i in $dependency_libs; do
1.6       moko     9139:        case " $predeps $postdeps $compiler_lib_search_path " in
                   9140:        *" $i "*)
1.7     ! moko     9141:          i=
1.6       moko     9142:          ;;
                   9143:        esac
1.7     ! moko     9144:        if test -n "$i"; then
1.6       moko     9145:          func_append tmp_libs " $i"
                   9146:        fi
                   9147:       done
                   9148:       dependency_libs=$tmp_libs
                   9149:     done # for pass
1.7     ! moko     9150:     if test prog = "$linkmode"; then
        !          9151:       dlfiles=$newdlfiles
1.6       moko     9152:     fi
1.7     ! moko     9153:     if test prog = "$linkmode" || test lib = "$linkmode"; then
        !          9154:       dlprefiles=$newdlprefiles
1.6       moko     9155:     fi
                   9156: 
                   9157:     case $linkmode in
                   9158:     oldlib)
1.7     ! moko     9159:       if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
        !          9160:        func_warning "'-dlopen' is ignored for archives"
1.6       moko     9161:       fi
                   9162: 
                   9163:       case " $deplibs" in
                   9164:       *\ -l* | *\ -L*)
1.7     ! moko     9165:        func_warning "'-l' and '-L' are ignored for archives" ;;
1.6       moko     9166:       esac
                   9167: 
                   9168:       test -n "$rpath" && \
1.7     ! moko     9169:        func_warning "'-rpath' is ignored for archives"
1.6       moko     9170: 
                   9171:       test -n "$xrpath" && \
1.7     ! moko     9172:        func_warning "'-R' is ignored for archives"
1.6       moko     9173: 
                   9174:       test -n "$vinfo" && \
1.7     ! moko     9175:        func_warning "'-version-info/-version-number' is ignored for archives"
1.6       moko     9176: 
                   9177:       test -n "$release" && \
1.7     ! moko     9178:        func_warning "'-release' is ignored for archives"
1.6       moko     9179: 
                   9180:       test -n "$export_symbols$export_symbols_regex" && \
1.7     ! moko     9181:        func_warning "'-export-symbols' is ignored for archives"
1.6       moko     9182: 
                   9183:       # Now set the variables for building old libraries.
                   9184:       build_libtool_libs=no
1.7     ! moko     9185:       oldlibs=$output
1.6       moko     9186:       func_append objs "$old_deplibs"
                   9187:       ;;
                   9188: 
                   9189:     lib)
1.7     ! moko     9190:       # Make sure we only generate libraries of the form 'libNAME.la'.
1.6       moko     9191:       case $outputname in
                   9192:       lib*)
                   9193:        func_stripname 'lib' '.la' "$outputname"
                   9194:        name=$func_stripname_result
                   9195:        eval shared_ext=\"$shrext_cmds\"
                   9196:        eval libname=\"$libname_spec\"
                   9197:        ;;
                   9198:       *)
1.7     ! moko     9199:        test no = "$module" \
        !          9200:          && func_fatal_help "libtool library '$output' must begin with 'lib'"
1.5       paf      9201: 
1.7     ! moko     9202:        if test no != "$need_lib_prefix"; then
1.6       moko     9203:          # Add the "lib" prefix for modules if required
                   9204:          func_stripname '' '.la' "$outputname"
                   9205:          name=$func_stripname_result
                   9206:          eval shared_ext=\"$shrext_cmds\"
                   9207:          eval libname=\"$libname_spec\"
                   9208:        else
                   9209:          func_stripname '' '.la' "$outputname"
                   9210:          libname=$func_stripname_result
1.5       paf      9211:        fi
1.6       moko     9212:        ;;
                   9213:       esac
1.5       paf      9214: 
1.6       moko     9215:       if test -n "$objs"; then
1.7     ! moko     9216:        if test pass_all != "$deplibs_check_method"; then
        !          9217:          func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
1.5       paf      9218:        else
1.7     ! moko     9219:          func_warning "Linking the shared library $output against the non-libtool objects $objs is not portable!"
1.6       moko     9220:          func_append libobjs " $objs"
1.5       paf      9221:        fi
1.6       moko     9222:       fi
1.5       paf      9223: 
1.7     ! moko     9224:       test no = "$dlself" \
        !          9225:        || func_warning "'-dlopen self' is ignored for libtool libraries"
1.5       paf      9226: 
1.6       moko     9227:       set dummy $rpath
                   9228:       shift
1.7     ! moko     9229:       test 1 -lt "$#" \
        !          9230:        && func_warning "ignoring multiple '-rpath's for a libtool library"
1.5       paf      9231: 
1.7     ! moko     9232:       install_libdir=$1
1.5       paf      9233: 
1.6       moko     9234:       oldlibs=
                   9235:       if test -z "$rpath"; then
1.7     ! moko     9236:        if test yes = "$build_libtool_libs"; then
1.6       moko     9237:          # Building a libtool convenience library.
1.7     ! moko     9238:          # Some compilers have problems with a '.al' extension so
1.6       moko     9239:          # convenience libraries should have the same extension an
                   9240:          # archive normally would.
                   9241:          oldlibs="$output_objdir/$libname.$libext $oldlibs"
                   9242:          build_libtool_libs=convenience
                   9243:          build_old_libs=yes
1.5       paf      9244:        fi
                   9245: 
1.6       moko     9246:        test -n "$vinfo" && \
1.7     ! moko     9247:          func_warning "'-version-info/-version-number' is ignored for convenience libraries"
1.6       moko     9248: 
                   9249:        test -n "$release" && \
1.7     ! moko     9250:          func_warning "'-release' is ignored for convenience libraries"
1.6       moko     9251:       else
1.5       paf      9252: 
1.6       moko     9253:        # Parse the version information argument.
1.7     ! moko     9254:        save_ifs=$IFS; IFS=:
1.6       moko     9255:        set dummy $vinfo 0 0 0
                   9256:        shift
1.7     ! moko     9257:        IFS=$save_ifs
1.5       paf      9258: 
1.6       moko     9259:        test -n "$7" && \
1.7     ! moko     9260:          func_fatal_help "too many parameters to '-version-info'"
1.5       paf      9261: 
1.6       moko     9262:        # convert absolute version numbers to libtool ages
                   9263:        # this retains compatibility with .la files and attempts
                   9264:        # to make the code below a bit more comprehensible
                   9265: 
                   9266:        case $vinfo_number in
                   9267:        yes)
1.7     ! moko     9268:          number_major=$1
        !          9269:          number_minor=$2
        !          9270:          number_revision=$3
1.6       moko     9271:          #
                   9272:          # There are really only two kinds -- those that
                   9273:          # use the current revision as the major version
                   9274:          # and those that subtract age and use age as
                   9275:          # a minor version.  But, then there is irix
1.7     ! moko     9276:          # that has an extra 1 added just for fun
1.6       moko     9277:          #
                   9278:          case $version_type in
                   9279:          # correct linux to gnu/linux during the next big refactor
1.7     ! moko     9280:          darwin|freebsd-elf|linux|midnightbsd-elf|osf|qnx|windows|none)
1.6       moko     9281:            func_arith $number_major + $number_minor
                   9282:            current=$func_arith_result
1.7     ! moko     9283:            age=$number_minor
        !          9284:            revision=$number_revision
1.6       moko     9285:            ;;
1.7     ! moko     9286:          freebsd-aout|sco|sunos)
        !          9287:            current=$number_major
        !          9288:            revision=$number_minor
        !          9289:            age=0
1.6       moko     9290:            ;;
                   9291:          irix|nonstopux)
                   9292:            func_arith $number_major + $number_minor
                   9293:            current=$func_arith_result
1.7     ! moko     9294:            age=$number_minor
        !          9295:            revision=$number_minor
1.6       moko     9296:            lt_irix_increment=no
                   9297:            ;;
1.7     ! moko     9298:          *)
        !          9299:            func_fatal_configuration "$modename: unknown library version type '$version_type'"
        !          9300:            ;;
        !          9301:          *)
        !          9302:            func_fatal_configuration "$modename: unknown library version type '$version_type'"
        !          9303:            ;;
1.6       moko     9304:          esac
                   9305:          ;;
                   9306:        no)
1.7     ! moko     9307:          current=$1
        !          9308:          revision=$2
        !          9309:          age=$3
1.6       moko     9310:          ;;
                   9311:        esac
1.5       paf      9312: 
1.6       moko     9313:        # Check that each of the things are valid numbers.
                   9314:        case $current in
                   9315:        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]) ;;
                   9316:        *)
1.7     ! moko     9317:          func_error "CURRENT '$current' must be a nonnegative integer"
        !          9318:          func_fatal_error "'$vinfo' is not valid version information"
1.6       moko     9319:          ;;
                   9320:        esac
1.5       paf      9321: 
1.6       moko     9322:        case $revision in
                   9323:        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]) ;;
                   9324:        *)
1.7     ! moko     9325:          func_error "REVISION '$revision' must be a nonnegative integer"
        !          9326:          func_fatal_error "'$vinfo' is not valid version information"
1.6       moko     9327:          ;;
                   9328:        esac
1.5       paf      9329: 
1.6       moko     9330:        case $age in
                   9331:        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]) ;;
                   9332:        *)
1.7     ! moko     9333:          func_error "AGE '$age' must be a nonnegative integer"
        !          9334:          func_fatal_error "'$vinfo' is not valid version information"
1.6       moko     9335:          ;;
                   9336:        esac
1.5       paf      9337: 
1.6       moko     9338:        if test "$age" -gt "$current"; then
1.7     ! moko     9339:          func_error "AGE '$age' is greater than the current interface number '$current'"
        !          9340:          func_fatal_error "'$vinfo' is not valid version information"
1.5       paf      9341:        fi
                   9342: 
1.6       moko     9343:        # Calculate the version variables.
                   9344:        major=
                   9345:        versuffix=
                   9346:        verstring=
                   9347:        case $version_type in
                   9348:        none) ;;
1.5       paf      9349: 
1.6       moko     9350:        darwin)
                   9351:          # Like Linux, but with the current version available in
                   9352:          # verstring for coding it into the library header
                   9353:          func_arith $current - $age
                   9354:          major=.$func_arith_result
1.7     ! moko     9355:          versuffix=$major.$age.$revision
1.6       moko     9356:          # Darwin ld doesn't like 0 for these options...
                   9357:          func_arith $current + 1
                   9358:          minor_current=$func_arith_result
1.7     ! moko     9359:          xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
1.6       moko     9360:          verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
1.7     ! moko     9361:           # On Darwin other compilers
        !          9362:           case $CC in
        !          9363:               nagfor*)
        !          9364:                   verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
        !          9365:                   ;;
        !          9366:               *)
        !          9367:                   verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
        !          9368:                   ;;
        !          9369:           esac
1.6       moko     9370:          ;;
1.5       paf      9371: 
1.6       moko     9372:        freebsd-aout)
1.7     ! moko     9373:          major=.$current
        !          9374:          versuffix=.$current.$revision
1.6       moko     9375:          ;;
1.5       paf      9376: 
1.7     ! moko     9377:        freebsd-elf | midnightbsd-elf)
        !          9378:          func_arith $current - $age
        !          9379:          major=.$func_arith_result
        !          9380:          versuffix=$major.$age.$revision
1.6       moko     9381:          ;;
1.5       paf      9382: 
1.6       moko     9383:        irix | nonstopux)
1.7     ! moko     9384:          if test no = "$lt_irix_increment"; then
1.6       moko     9385:            func_arith $current - $age
                   9386:          else
                   9387:            func_arith $current - $age + 1
                   9388:          fi
                   9389:          major=$func_arith_result
1.5       paf      9390: 
1.6       moko     9391:          case $version_type in
                   9392:            nonstopux) verstring_prefix=nonstopux ;;
                   9393:            *)         verstring_prefix=sgi ;;
                   9394:          esac
1.7     ! moko     9395:          verstring=$verstring_prefix$major.$revision
1.5       paf      9396: 
1.6       moko     9397:          # Add in all the interfaces that we are compatible with.
                   9398:          loop=$revision
1.7     ! moko     9399:          while test 0 -ne "$loop"; do
1.6       moko     9400:            func_arith $revision - $loop
                   9401:            iface=$func_arith_result
                   9402:            func_arith $loop - 1
                   9403:            loop=$func_arith_result
1.7     ! moko     9404:            verstring=$verstring_prefix$major.$iface:$verstring
1.6       moko     9405:          done
1.5       paf      9406: 
1.7     ! moko     9407:          # Before this point, $major must not contain '.'.
1.6       moko     9408:          major=.$major
1.7     ! moko     9409:          versuffix=$major.$revision
1.6       moko     9410:          ;;
1.5       paf      9411: 
1.6       moko     9412:        linux) # correct to gnu/linux during the next big refactor
                   9413:          func_arith $current - $age
                   9414:          major=.$func_arith_result
1.7     ! moko     9415:          versuffix=$major.$age.$revision
1.6       moko     9416:          ;;
1.5       paf      9417: 
1.6       moko     9418:        osf)
                   9419:          func_arith $current - $age
                   9420:          major=.$func_arith_result
1.7     ! moko     9421:          versuffix=.$current.$age.$revision
        !          9422:          verstring=$current.$age.$revision
1.5       paf      9423: 
1.6       moko     9424:          # Add in all the interfaces that we are compatible with.
                   9425:          loop=$age
1.7     ! moko     9426:          while test 0 -ne "$loop"; do
1.6       moko     9427:            func_arith $current - $loop
                   9428:            iface=$func_arith_result
                   9429:            func_arith $loop - 1
                   9430:            loop=$func_arith_result
1.7     ! moko     9431:            verstring=$verstring:$iface.0
1.6       moko     9432:          done
1.5       paf      9433: 
1.6       moko     9434:          # Make executables depend on our current version.
1.7     ! moko     9435:          func_append verstring ":$current.0"
1.6       moko     9436:          ;;
1.5       paf      9437: 
1.6       moko     9438:        qnx)
1.7     ! moko     9439:          func_arith $current - $age
        !          9440:          major=.$func_arith_result
        !          9441:          versuffix=$major.$age.$revision
        !          9442:          ;;
        !          9443: 
        !          9444:        sco)
        !          9445:          major=.$current
        !          9446:          versuffix=.$current
1.6       moko     9447:          ;;
1.5       paf      9448: 
1.6       moko     9449:        sunos)
1.7     ! moko     9450:          major=.$current
        !          9451:          versuffix=.$current.$revision
1.6       moko     9452:          ;;
1.5       paf      9453: 
1.6       moko     9454:        windows)
                   9455:          # Use '-' rather than '.', since we only want one
1.7     ! moko     9456:          # extension on DOS 8.3 file systems.
1.6       moko     9457:          func_arith $current - $age
                   9458:          major=$func_arith_result
1.7     ! moko     9459:          versuffix=-$major
1.6       moko     9460:          ;;
1.5       paf      9461: 
1.6       moko     9462:        *)
1.7     ! moko     9463:          func_fatal_configuration "unknown library version type '$version_type'"
1.6       moko     9464:          ;;
                   9465:        esac
1.5       paf      9466: 
1.6       moko     9467:        # Clear the version info if we defaulted, and they specified a release.
                   9468:        if test -z "$vinfo" && test -n "$release"; then
                   9469:          major=
                   9470:          case $version_type in
                   9471:          darwin)
                   9472:            # we can't check for "0.0" in archive_cmds due to quoting
                   9473:            # problems, so we reset it completely
                   9474:            verstring=
                   9475:            ;;
                   9476:          *)
1.7     ! moko     9477:            verstring=0.0
1.6       moko     9478:            ;;
                   9479:          esac
1.7     ! moko     9480:          if test no = "$need_version"; then
1.6       moko     9481:            versuffix=
                   9482:          else
1.7     ! moko     9483:            versuffix=.0.0
1.6       moko     9484:          fi
1.5       paf      9485:        fi
                   9486: 
1.6       moko     9487:        # Remove version info from name if versioning should be avoided
1.7     ! moko     9488:        if test yes,no = "$avoid_version,$need_version"; then
1.6       moko     9489:          major=
                   9490:          versuffix=
1.7     ! moko     9491:          verstring=
1.6       moko     9492:        fi
1.5       paf      9493: 
1.6       moko     9494:        # Check to see if the archive will have undefined symbols.
1.7     ! moko     9495:        if test yes = "$allow_undefined"; then
        !          9496:          if test unsupported = "$allow_undefined_flag"; then
        !          9497:            if test yes = "$build_old_libs"; then
        !          9498:              func_warning "undefined symbols not allowed in $host shared libraries; building static only"
        !          9499:              build_libtool_libs=no
        !          9500:            else
        !          9501:              func_fatal_error "can't build $host shared library unless -no-undefined is specified"
        !          9502:            fi
1.6       moko     9503:          fi
                   9504:        else
                   9505:          # Don't allow undefined symbols.
1.7     ! moko     9506:          allow_undefined_flag=$no_undefined_flag
1.5       paf      9507:        fi
                   9508: 
                   9509:       fi
                   9510: 
1.7     ! moko     9511:       func_generate_dlsyms "$libname" "$libname" :
1.6       moko     9512:       func_append libobjs " $symfileobj"
1.7     ! moko     9513:       test " " = "$libobjs" && libobjs=
1.6       moko     9514: 
1.7     ! moko     9515:       if test relink != "$opt_mode"; then
1.6       moko     9516:        # Remove our outputs, but don't remove object files since they
                   9517:        # may have been created when compiling PIC objects.
                   9518:        removelist=
                   9519:        tempremovelist=`$ECHO "$output_objdir/*"`
                   9520:        for p in $tempremovelist; do
                   9521:          case $p in
                   9522:            *.$objext | *.gcno)
                   9523:               ;;
1.7     ! moko     9524:            $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
        !          9525:               if test -n "$precious_files_regex"; then
1.6       moko     9526:                 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
                   9527:                 then
                   9528:                   continue
                   9529:                 fi
                   9530:               fi
                   9531:               func_append removelist " $p"
                   9532:               ;;
                   9533:            *) ;;
                   9534:          esac
1.5       paf      9535:        done
1.6       moko     9536:        test -n "$removelist" && \
                   9537:          func_show_eval "${RM}r \$removelist"
1.5       paf      9538:       fi
                   9539: 
1.6       moko     9540:       # Now set the variables for building old libraries.
1.7     ! moko     9541:       if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
1.6       moko     9542:        func_append oldlibs " $output_objdir/$libname.$libext"
1.5       paf      9543: 
1.6       moko     9544:        # Transform .lo files to .o files.
1.7     ! moko     9545:        oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
1.5       paf      9546:       fi
                   9547: 
1.6       moko     9548:       # Eliminate all temporary directories.
                   9549:       #for path in $notinst_path; do
                   9550:       #        lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
                   9551:       #        deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
                   9552:       #        dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
                   9553:       #done
1.5       paf      9554: 
1.6       moko     9555:       if test -n "$xrpath"; then
                   9556:        # If the user specified any rpath flags, then add them.
                   9557:        temp_xrpath=
                   9558:        for libdir in $xrpath; do
                   9559:          func_replace_sysroot "$libdir"
                   9560:          func_append temp_xrpath " -R$func_replace_sysroot_result"
                   9561:          case "$finalize_rpath " in
                   9562:          *" $libdir "*) ;;
                   9563:          *) func_append finalize_rpath " $libdir" ;;
                   9564:          esac
                   9565:        done
1.7     ! moko     9566:        if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
1.6       moko     9567:          dependency_libs="$temp_xrpath $dependency_libs"
1.5       paf      9568:        fi
                   9569:       fi
                   9570: 
1.6       moko     9571:       # Make sure dlfiles contains only unique files that won't be dlpreopened
1.7     ! moko     9572:       old_dlfiles=$dlfiles
1.6       moko     9573:       dlfiles=
                   9574:       for lib in $old_dlfiles; do
                   9575:        case " $dlprefiles $dlfiles " in
                   9576:        *" $lib "*) ;;
                   9577:        *) func_append dlfiles " $lib" ;;
1.5       paf      9578:        esac
1.6       moko     9579:       done
1.5       paf      9580: 
1.6       moko     9581:       # Make sure dlprefiles contains only unique files
1.7     ! moko     9582:       old_dlprefiles=$dlprefiles
1.6       moko     9583:       dlprefiles=
                   9584:       for lib in $old_dlprefiles; do
                   9585:        case "$dlprefiles " in
                   9586:        *" $lib "*) ;;
                   9587:        *) func_append dlprefiles " $lib" ;;
                   9588:        esac
                   9589:       done
1.5       paf      9590: 
1.7     ! moko     9591:       if test yes = "$build_libtool_libs"; then
1.6       moko     9592:        if test -n "$rpath"; then
                   9593:          case $host in
1.7     ! moko     9594:          *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
1.6       moko     9595:            # these systems don't actually have a c library (as such)!
                   9596:            ;;
                   9597:          *-*-rhapsody* | *-*-darwin1.[012])
                   9598:            # Rhapsody C library is in the System framework
                   9599:            func_append deplibs " System.ltframework"
                   9600:            ;;
                   9601:          *-*-netbsd*)
                   9602:            # Don't link with libc until the a.out ld.so is fixed.
                   9603:            ;;
1.7     ! moko     9604:          *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
1.6       moko     9605:            # Do not include libc due to us having libc/libc_r.
                   9606:            ;;
                   9607:          *-*-sco3.2v5* | *-*-sco5v6*)
                   9608:            # Causes problems with __ctype
                   9609:            ;;
                   9610:          *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
                   9611:            # Compiler inserts libc in the correct place for threads to work
                   9612:            ;;
                   9613:          *)
                   9614:            # Add libc to deplibs on all other systems if necessary.
1.7     ! moko     9615:            if test yes = "$build_libtool_need_lc"; then
1.6       moko     9616:              func_append deplibs " -lc"
                   9617:            fi
                   9618:            ;;
1.5       paf      9619:          esac
1.6       moko     9620:        fi
1.5       paf      9621: 
1.6       moko     9622:        # Transform deplibs into only deplibs that can be linked in shared.
                   9623:        name_save=$name
                   9624:        libname_save=$libname
                   9625:        release_save=$release
                   9626:        versuffix_save=$versuffix
                   9627:        major_save=$major
                   9628:        # I'm not sure if I'm treating the release correctly.  I think
                   9629:        # release should show up in the -l (ie -lgmp5) so we don't want to
                   9630:        # add it in twice.  Is that correct?
1.7     ! moko     9631:        release=
        !          9632:        versuffix=
        !          9633:        major=
1.6       moko     9634:        newdeplibs=
                   9635:        droppeddeps=no
                   9636:        case $deplibs_check_method in
                   9637:        pass_all)
                   9638:          # Don't check for shared/static.  Everything works.
                   9639:          # This might be a little naive.  We might want to check
                   9640:          # whether the library exists or not.  But this is on
                   9641:          # osf3 & osf4 and I'm not really sure... Just
                   9642:          # implementing what was already the behavior.
                   9643:          newdeplibs=$deplibs
                   9644:          ;;
                   9645:        file_magic*)
                   9646:          set dummy $deplibs_check_method; shift
                   9647:          file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
                   9648:          for a_deplib in $deplibs; do
                   9649:            case $a_deplib in
                   9650:            -l*)
                   9651:              func_stripname -l '' "$a_deplib"
                   9652:              name=$func_stripname_result
1.7     ! moko     9653:              if test yes = "$allow_libtool_libs_with_static_runtimes"; then
1.6       moko     9654:                case " $predeps $postdeps " in
                   9655:                *" $a_deplib "*)
                   9656:                  func_append newdeplibs " $a_deplib"
1.7     ! moko     9657:                  a_deplib=
1.6       moko     9658:                  ;;
                   9659:                esac
                   9660:              fi
1.7     ! moko     9661:              if test -n "$a_deplib"; then
1.6       moko     9662:                libname=`eval "\\$ECHO \"$libname_spec\""`
                   9663:                if test -n "$file_magic_glob"; then
                   9664:                  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
                   9665:                else
                   9666:                  libnameglob=$libname
                   9667:                fi
1.7     ! moko     9668:                test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
1.6       moko     9669:                for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
1.7     ! moko     9670:                  if test yes = "$want_nocaseglob"; then
1.6       moko     9671:                    shopt -s nocaseglob
                   9672:                    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
                   9673:                    $nocaseglob
                   9674:                  else
                   9675:                    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
                   9676:                  fi
                   9677:                  for potent_lib in $potential_libs; do
                   9678:                      # Follow soft links.
                   9679:                      if ls -lLd "$potent_lib" 2>/dev/null |
                   9680:                         $GREP " -> " >/dev/null; then
                   9681:                        continue
                   9682:                      fi
                   9683:                      # The statement above tries to avoid entering an
                   9684:                      # endless loop below, in case of cyclic links.
                   9685:                      # We might still enter an endless loop, since a link
                   9686:                      # loop can be closed while we follow links,
                   9687:                      # but so what?
1.7     ! moko     9688:                      potlib=$potent_lib
1.6       moko     9689:                      while test -h "$potlib" 2>/dev/null; do
1.7     ! moko     9690:                        potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
1.6       moko     9691:                        case $potliblink in
1.7     ! moko     9692:                        [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
        !          9693:                        *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
1.6       moko     9694:                        esac
                   9695:                      done
                   9696:                      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
                   9697:                         $SED -e 10q |
                   9698:                         $EGREP "$file_magic_regex" > /dev/null; then
                   9699:                        func_append newdeplibs " $a_deplib"
1.7     ! moko     9700:                        a_deplib=
1.6       moko     9701:                        break 2
                   9702:                      fi
                   9703:                  done
                   9704:                done
                   9705:              fi
1.7     ! moko     9706:              if test -n "$a_deplib"; then
1.6       moko     9707:                droppeddeps=yes
1.7     ! moko     9708:                func_warning "Linker path does not have real file for library $a_deplib."
        !          9709:                func_warning "I have the capability to make that library automatically link in when"
        !          9710:                func_warning "you link to this library.  But I can only do this if you have a"
        !          9711:                func_warning "shared version of the library, which you do not appear to have"
        !          9712:                func_warning "because I did check the linker path looking for a file starting"
        !          9713:                if test -z "$potlib"; then
        !          9714:                  func_warning "with $libname but no candidates were found. (...for file magic test)"
1.6       moko     9715:                else
1.7     ! moko     9716:                  func_warning "with $libname and none of the candidates passed a file format test"
        !          9717:                  func_warning "using a file magic. Last file checked: $potlib"
1.6       moko     9718:                fi
                   9719:              fi
                   9720:              ;;
                   9721:            *)
                   9722:              # Add a -L argument.
                   9723:              func_append newdeplibs " $a_deplib"
                   9724:              ;;
                   9725:            esac
                   9726:          done # Gone through all deplibs.
                   9727:          ;;
                   9728:        match_pattern*)
                   9729:          set dummy $deplibs_check_method; shift
                   9730:          match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
                   9731:          for a_deplib in $deplibs; do
                   9732:            case $a_deplib in
                   9733:            -l*)
                   9734:              func_stripname -l '' "$a_deplib"
                   9735:              name=$func_stripname_result
1.7     ! moko     9736:              if test yes = "$allow_libtool_libs_with_static_runtimes"; then
1.6       moko     9737:                case " $predeps $postdeps " in
                   9738:                *" $a_deplib "*)
                   9739:                  func_append newdeplibs " $a_deplib"
1.7     ! moko     9740:                  a_deplib=
1.6       moko     9741:                  ;;
                   9742:                esac
                   9743:              fi
1.7     ! moko     9744:              if test -n "$a_deplib"; then
1.6       moko     9745:                libname=`eval "\\$ECHO \"$libname_spec\""`
                   9746:                for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
                   9747:                  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
                   9748:                  for potent_lib in $potential_libs; do
1.7     ! moko     9749:                    potlib=$potent_lib # see symlink-check above in file_magic test
1.6       moko     9750:                    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
                   9751:                       $EGREP "$match_pattern_regex" > /dev/null; then
                   9752:                      func_append newdeplibs " $a_deplib"
1.7     ! moko     9753:                      a_deplib=
1.6       moko     9754:                      break 2
                   9755:                    fi
                   9756:                  done
                   9757:                done
                   9758:              fi
1.7     ! moko     9759:              if test -n "$a_deplib"; then
1.6       moko     9760:                droppeddeps=yes
1.7     ! moko     9761:                func_warning "Linker path does not have real file for library $a_deplib."
        !          9762:                func_warning "I have the capability to make that library automatically link in when"
        !          9763:                func_warning "you link to this library.  But I can only do this if you have a"
        !          9764:                func_warning "shared version of the library, which you do not appear to have"
        !          9765:                func_warning "because I did check the linker path looking for a file starting"
        !          9766:                if test -z "$potlib"; then
        !          9767:                  func_warning "with $libname but no candidates were found. (...for regex pattern test)"
1.6       moko     9768:                else
1.7     ! moko     9769:                  func_warning "with $libname and none of the candidates passed a file format test"
        !          9770:                  func_warning "using a regex pattern. Last file checked: $potlib"
1.6       moko     9771:                fi
                   9772:              fi
                   9773:              ;;
                   9774:            *)
                   9775:              # Add a -L argument.
                   9776:              func_append newdeplibs " $a_deplib"
                   9777:              ;;
                   9778:            esac
                   9779:          done # Gone through all deplibs.
                   9780:          ;;
                   9781:        none | unknown | *)
1.7     ! moko     9782:          newdeplibs=
1.6       moko     9783:          tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
1.7     ! moko     9784:          if test yes = "$allow_libtool_libs_with_static_runtimes"; then
        !          9785:            for i in $predeps $postdeps; do
1.6       moko     9786:              # can't use Xsed below, because $i might contain '/'
1.7     ! moko     9787:              tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
1.5       paf      9788:            done
                   9789:          fi
1.6       moko     9790:          case $tmp_deplibs in
                   9791:          *[!\  \ ]*)
                   9792:            echo
1.7     ! moko     9793:            if test none = "$deplibs_check_method"; then
        !          9794:              func_warning "Inter-library dependencies are not supported in this platform."
1.5       paf      9795:            else
1.7     ! moko     9796:              func_warning "Inter-library dependencies are not known to be supported."
1.5       paf      9797:            fi
1.7     ! moko     9798:            func_warning "All declared inter-library dependencies are being dropped."
1.6       moko     9799:            droppeddeps=yes
                   9800:            ;;
1.5       paf      9801:          esac
1.6       moko     9802:          ;;
                   9803:        esac
                   9804:        versuffix=$versuffix_save
                   9805:        major=$major_save
                   9806:        release=$release_save
                   9807:        libname=$libname_save
                   9808:        name=$name_save
1.5       paf      9809: 
1.6       moko     9810:        case $host in
                   9811:        *-*-rhapsody* | *-*-darwin1.[012])
                   9812:          # On Rhapsody replace the C library with the System framework
                   9813:          newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
1.5       paf      9814:          ;;
                   9815:        esac
                   9816: 
1.7     ! moko     9817:        if test yes = "$droppeddeps"; then
        !          9818:          if test yes = "$module"; then
        !          9819:            func_warning "libtool could not satisfy all declared inter-library"
        !          9820:            func_warning "dependencies of module $libname.  Therefore, libtool will create"
        !          9821:            func_warning "a static module, that should work as long as the dlopening"
        !          9822:            func_warning "application is linked with the -dlopen flag."
1.6       moko     9823:            if test -z "$global_symbol_pipe"; then
1.7     ! moko     9824:              func_warning "However, this would only work if libtool was able to extract symbol"
        !          9825:              func_warning "lists from a program, using 'nm' or equivalent, but libtool could"
        !          9826:              func_warning "not find such a program.  So, this module is probably useless."
        !          9827:              func_warning "'nm' from GNU binutils and a full rebuild may help."
1.6       moko     9828:            fi
1.7     ! moko     9829:            if test no = "$build_old_libs"; then
        !          9830:              oldlibs=$output_objdir/$libname.$libext
1.6       moko     9831:              build_libtool_libs=module
                   9832:              build_old_libs=yes
                   9833:            else
                   9834:              build_libtool_libs=no
                   9835:            fi
1.5       paf      9836:          else
1.6       moko     9837:            echo "*** The inter-library dependencies that have been dropped here will be"
                   9838:            echo "*** automatically added whenever a program is linked with this library"
                   9839:            echo "*** or is declared to -dlopen it."
1.5       paf      9840: 
1.7     ! moko     9841:            if test no = "$allow_undefined"; then
1.6       moko     9842:              echo
                   9843:              echo "*** Since this library must not contain undefined symbols,"
                   9844:              echo "*** because either the platform does not support them or"
                   9845:              echo "*** it was explicitly requested with -no-undefined,"
                   9846:              echo "*** libtool will only create a static version of it."
1.7     ! moko     9847:              if test no = "$build_old_libs"; then
        !          9848:                oldlibs=$output_objdir/$libname.$libext
1.6       moko     9849:                build_libtool_libs=module
                   9850:                build_old_libs=yes
                   9851:              else
                   9852:                build_libtool_libs=no
                   9853:              fi
                   9854:            fi
1.5       paf      9855:          fi
1.6       moko     9856:        fi
                   9857:        # Done checking deplibs!
                   9858:        deplibs=$newdeplibs
1.5       paf      9859:       fi
1.6       moko     9860:       # Time to change all our "foo.ltframework" stuff back to "-framework foo"
                   9861:       case $host in
                   9862:        *-*-darwin*)
                   9863:          newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
                   9864:          new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
                   9865:          deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
                   9866:          ;;
                   9867:       esac
1.5       paf      9868: 
1.6       moko     9869:       # move library search paths that coincide with paths to not yet
                   9870:       # installed libraries to the beginning of the library search list
                   9871:       new_libs=
                   9872:       for path in $notinst_path; do
                   9873:        case " $new_libs " in
                   9874:        *" -L$path/$objdir "*) ;;
                   9875:        *)
                   9876:          case " $deplibs " in
                   9877:          *" -L$path/$objdir "*)
                   9878:            func_append new_libs " -L$path/$objdir" ;;
                   9879:          esac
                   9880:          ;;
1.5       paf      9881:        esac
1.6       moko     9882:       done
                   9883:       for deplib in $deplibs; do
                   9884:        case $deplib in
                   9885:        -L*)
                   9886:          case " $new_libs " in
                   9887:          *" $deplib "*) ;;
                   9888:          *) func_append new_libs " $deplib" ;;
                   9889:          esac
                   9890:          ;;
                   9891:        *) func_append new_libs " $deplib" ;;
1.5       paf      9892:        esac
1.6       moko     9893:       done
1.7     ! moko     9894:       deplibs=$new_libs
1.5       paf      9895: 
1.6       moko     9896:       # All the library-specific variables (install_libdir is set above).
                   9897:       library_names=
                   9898:       old_library=
                   9899:       dlname=
1.5       paf      9900: 
1.6       moko     9901:       # Test again, we may have decided not to build it any more
1.7     ! moko     9902:       if test yes = "$build_libtool_libs"; then
        !          9903:        # Remove $wl instances when linking with ld.
1.6       moko     9904:        # FIXME: should test the right _cmds variable.
                   9905:        case $archive_cmds in
                   9906:          *\$LD\ *) wl= ;;
                   9907:         esac
1.7     ! moko     9908:        if test yes = "$hardcode_into_libs"; then
1.6       moko     9909:          # Hardcode the library paths
                   9910:          hardcode_libdirs=
                   9911:          dep_rpath=
1.7     ! moko     9912:          rpath=$finalize_rpath
        !          9913:          test relink = "$opt_mode" || rpath=$compile_rpath$rpath
1.6       moko     9914:          for libdir in $rpath; do
                   9915:            if test -n "$hardcode_libdir_flag_spec"; then
                   9916:              if test -n "$hardcode_libdir_separator"; then
                   9917:                func_replace_sysroot "$libdir"
                   9918:                libdir=$func_replace_sysroot_result
                   9919:                if test -z "$hardcode_libdirs"; then
1.7     ! moko     9920:                  hardcode_libdirs=$libdir
1.6       moko     9921:                else
                   9922:                  # Just accumulate the unique libdirs.
                   9923:                  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
                   9924:                  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
                   9925:                    ;;
                   9926:                  *)
                   9927:                    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
                   9928:                    ;;
                   9929:                  esac
                   9930:                fi
                   9931:              else
                   9932:                eval flag=\"$hardcode_libdir_flag_spec\"
                   9933:                func_append dep_rpath " $flag"
                   9934:              fi
                   9935:            elif test -n "$runpath_var"; then
                   9936:              case "$perm_rpath " in
                   9937:              *" $libdir "*) ;;
                   9938:              *) func_append perm_rpath " $libdir" ;;
                   9939:              esac
                   9940:            fi
                   9941:          done
                   9942:          # Substitute the hardcoded libdirs into the rpath.
                   9943:          if test -n "$hardcode_libdir_separator" &&
                   9944:             test -n "$hardcode_libdirs"; then
1.7     ! moko     9945:            libdir=$hardcode_libdirs
1.6       moko     9946:            eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
                   9947:          fi
                   9948:          if test -n "$runpath_var" && test -n "$perm_rpath"; then
                   9949:            # We should set the runpath_var.
                   9950:            rpath=
                   9951:            for dir in $perm_rpath; do
                   9952:              func_append rpath "$dir:"
                   9953:            done
                   9954:            eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
                   9955:          fi
                   9956:          test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
                   9957:        fi
1.5       paf      9958: 
1.7     ! moko     9959:        shlibpath=$finalize_shlibpath
        !          9960:        test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
1.6       moko     9961:        if test -n "$shlibpath"; then
                   9962:          eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
                   9963:        fi
1.5       paf      9964: 
1.6       moko     9965:        # Get the real and link names of the library.
                   9966:        eval shared_ext=\"$shrext_cmds\"
                   9967:        eval library_names=\"$library_names_spec\"
                   9968:        set dummy $library_names
                   9969:        shift
1.7     ! moko     9970:        realname=$1
1.6       moko     9971:        shift
1.5       paf      9972: 
1.6       moko     9973:        if test -n "$soname_spec"; then
                   9974:          eval soname=\"$soname_spec\"
                   9975:        else
1.7     ! moko     9976:          soname=$realname
1.6       moko     9977:        fi
                   9978:        if test -z "$dlname"; then
                   9979:          dlname=$soname
                   9980:        fi
1.5       paf      9981: 
1.7     ! moko     9982:        lib=$output_objdir/$realname
1.6       moko     9983:        linknames=
                   9984:        for link
                   9985:        do
                   9986:          func_append linknames " $link"
                   9987:        done
1.5       paf      9988: 
1.6       moko     9989:        # Use standard objects if they are pic
                   9990:        test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
                   9991:        test "X$libobjs" = "X " && libobjs=
1.5       paf      9992: 
1.6       moko     9993:        delfiles=
                   9994:        if test -n "$export_symbols" && test -n "$include_expsyms"; then
                   9995:          $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
1.7     ! moko     9996:          export_symbols=$output_objdir/$libname.uexp
1.6       moko     9997:          func_append delfiles " $export_symbols"
                   9998:        fi
                   9999: 
                   10000:        orig_export_symbols=
                   10001:        case $host_os in
1.7     ! moko     10002:        cygwin* | mingw* | windows* | cegcc*)
1.6       moko     10003:          if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
                   10004:            # exporting using user supplied symfile
1.7     ! moko     10005:            func_dll_def_p "$export_symbols" || {
1.6       moko     10006:              # and it's NOT already a .def file. Must figure out
                   10007:              # which of the given symbols are data symbols and tag
                   10008:              # them as such. So, trigger use of export_symbols_cmds.
                   10009:              # export_symbols gets reassigned inside the "prepare
                   10010:              # the list of exported symbols" if statement, so the
                   10011:              # include_expsyms logic still works.
1.7     ! moko     10012:              orig_export_symbols=$export_symbols
1.6       moko     10013:              export_symbols=
                   10014:              always_export_symbols=yes
1.7     ! moko     10015:            }
1.6       moko     10016:          fi
                   10017:          ;;
                   10018:        esac
1.5       paf      10019: 
1.6       moko     10020:        # Prepare the list of exported symbols
                   10021:        if test -z "$export_symbols"; then
1.7     ! moko     10022:          if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
        !          10023:            func_verbose "generating symbol list for '$libname.la'"
        !          10024:            export_symbols=$output_objdir/$libname.exp
1.6       moko     10025:            $opt_dry_run || $RM $export_symbols
                   10026:            cmds=$export_symbols_cmds
1.7     ! moko     10027:            save_ifs=$IFS; IFS='~'
1.6       moko     10028:            for cmd1 in $cmds; do
1.7     ! moko     10029:              IFS=$save_ifs
1.6       moko     10030:              # Take the normal branch if the nm_file_list_spec branch
                   10031:              # doesn't work or if tool conversion is not needed.
                   10032:              case $nm_file_list_spec~$to_tool_file_cmd in
                   10033:                *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
                   10034:                  try_normal_branch=yes
                   10035:                  eval cmd=\"$cmd1\"
                   10036:                  func_len " $cmd"
                   10037:                  len=$func_len_result
                   10038:                  ;;
                   10039:                *)
                   10040:                  try_normal_branch=no
                   10041:                  ;;
                   10042:              esac
1.7     ! moko     10043:              if test yes = "$try_normal_branch" \
1.6       moko     10044:                 && { test "$len" -lt "$max_cmd_len" \
                   10045:                      || test "$max_cmd_len" -le -1; }
                   10046:              then
                   10047:                func_show_eval "$cmd" 'exit $?'
                   10048:                skipped_export=false
                   10049:              elif test -n "$nm_file_list_spec"; then
                   10050:                func_basename "$output"
                   10051:                output_la=$func_basename_result
                   10052:                save_libobjs=$libobjs
                   10053:                save_output=$output
1.7     ! moko     10054:                output=$output_objdir/$output_la.nm
1.6       moko     10055:                func_to_tool_file "$output"
                   10056:                libobjs=$nm_file_list_spec$func_to_tool_file_result
                   10057:                func_append delfiles " $output"
                   10058:                func_verbose "creating $NM input file list: $output"
                   10059:                for obj in $save_libobjs; do
                   10060:                  func_to_tool_file "$obj"
                   10061:                  $ECHO "$func_to_tool_file_result"
                   10062:                done > "$output"
                   10063:                eval cmd=\"$cmd1\"
                   10064:                func_show_eval "$cmd" 'exit $?'
                   10065:                output=$save_output
                   10066:                libobjs=$save_libobjs
                   10067:                skipped_export=false
                   10068:              else
                   10069:                # The command line is too long to execute in one step.
                   10070:                func_verbose "using reloadable object file for export list..."
                   10071:                skipped_export=:
                   10072:                # Break out early, otherwise skipped_export may be
                   10073:                # set to false by a later but shorter cmd.
                   10074:                break
                   10075:              fi
                   10076:            done
1.7     ! moko     10077:            IFS=$save_ifs
        !          10078:            if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
1.6       moko     10079:              func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
                   10080:              func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
                   10081:            fi
                   10082:          fi
                   10083:        fi
1.5       paf      10084: 
1.6       moko     10085:        if test -n "$export_symbols" && test -n "$include_expsyms"; then
1.7     ! moko     10086:          tmp_export_symbols=$export_symbols
        !          10087:          test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
1.6       moko     10088:          $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
                   10089:        fi
                   10090: 
1.7     ! moko     10091:        if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
1.6       moko     10092:          # The given exports_symbols file has to be filtered, so filter it.
1.7     ! moko     10093:          func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
1.6       moko     10094:          # FIXME: $output_objdir/$libname.filter potentially contains lots of
1.7     ! moko     10095:          # 's' commands, which not all seds can handle. GNU sed should be fine
1.6       moko     10096:          # though. Also, the filter scales superlinearly with the number of
                   10097:          # global variables. join(1) would be nice here, but unfortunately
                   10098:          # isn't a blessed tool.
                   10099:          $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
                   10100:          func_append delfiles " $export_symbols $output_objdir/$libname.filter"
                   10101:          export_symbols=$output_objdir/$libname.def
                   10102:          $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
                   10103:        fi
                   10104: 
                   10105:        tmp_deplibs=
                   10106:        for test_deplib in $deplibs; do
                   10107:          case " $convenience " in
                   10108:          *" $test_deplib "*) ;;
                   10109:          *)
                   10110:            func_append tmp_deplibs " $test_deplib"
                   10111:            ;;
                   10112:          esac
                   10113:        done
1.7     ! moko     10114:        deplibs=$tmp_deplibs
1.5       paf      10115: 
1.6       moko     10116:        if test -n "$convenience"; then
                   10117:          if test -n "$whole_archive_flag_spec" &&
1.7     ! moko     10118:            test yes = "$compiler_needs_object" &&
1.6       moko     10119:            test -z "$libobjs"; then
                   10120:            # extract the archives, so we have objects to list.
                   10121:            # TODO: could optimize this to just extract one archive.
                   10122:            whole_archive_flag_spec=
                   10123:          fi
                   10124:          if test -n "$whole_archive_flag_spec"; then
                   10125:            save_libobjs=$libobjs
                   10126:            eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
                   10127:            test "X$libobjs" = "X " && libobjs=
                   10128:          else
1.7     ! moko     10129:            gentop=$output_objdir/${outputname}x
1.6       moko     10130:            func_append generated " $gentop"
1.5       paf      10131: 
1.6       moko     10132:            func_extract_archives $gentop $convenience
                   10133:            func_append libobjs " $func_extract_archives_result"
                   10134:            test "X$libobjs" = "X " && libobjs=
                   10135:          fi
                   10136:        fi
1.5       paf      10137: 
1.7     ! moko     10138:        if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
1.6       moko     10139:          eval flag=\"$thread_safe_flag_spec\"
                   10140:          func_append linker_flags " $flag"
1.5       paf      10141:        fi
                   10142: 
1.6       moko     10143:        # Make a backup of the uninstalled library when relinking
1.7     ! moko     10144:        if test relink = "$opt_mode"; then
1.6       moko     10145:          $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
1.5       paf      10146:        fi
                   10147: 
1.6       moko     10148:        # Do each of the archive commands.
1.7     ! moko     10149:        if test yes = "$module" && test -n "$module_cmds"; then
1.6       moko     10150:          if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
                   10151:            eval test_cmds=\"$module_expsym_cmds\"
                   10152:            cmds=$module_expsym_cmds
                   10153:          else
                   10154:            eval test_cmds=\"$module_cmds\"
                   10155:            cmds=$module_cmds
                   10156:          fi
                   10157:        else
                   10158:          if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
                   10159:            eval test_cmds=\"$archive_expsym_cmds\"
                   10160:            cmds=$archive_expsym_cmds
                   10161:          else
                   10162:            eval test_cmds=\"$archive_cmds\"
                   10163:            cmds=$archive_cmds
                   10164:          fi
1.5       paf      10165:        fi
                   10166: 
1.7     ! moko     10167:        if test : != "$skipped_export" &&
1.6       moko     10168:           func_len " $test_cmds" &&
                   10169:           len=$func_len_result &&
                   10170:           test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
                   10171:          :
                   10172:        else
                   10173:          # The command line is too long to link in one step, link piecewise
                   10174:          # or, if using GNU ld and skipped_export is not :, use a linker
                   10175:          # script.
                   10176: 
                   10177:          # Save the value of $output and $libobjs because we want to
                   10178:          # use them later.  If we have whole_archive_flag_spec, we
                   10179:          # want to use save_libobjs as it was before
                   10180:          # whole_archive_flag_spec was expanded, because we can't
                   10181:          # assume the linker understands whole_archive_flag_spec.
                   10182:          # This may have to be revisited, in case too many
                   10183:          # convenience libraries get linked in and end up exceeding
                   10184:          # the spec.
                   10185:          if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
                   10186:            save_libobjs=$libobjs
                   10187:          fi
                   10188:          save_output=$output
                   10189:          func_basename "$output"
                   10190:          output_la=$func_basename_result
                   10191: 
                   10192:          # Clear the reloadable object creation command queue and
                   10193:          # initialize k to one.
                   10194:          test_cmds=
                   10195:          concat_cmds=
                   10196:          objlist=
                   10197:          last_robj=
                   10198:          k=1
                   10199: 
1.7     ! moko     10200:          if test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
        !          10201:            output=$output_objdir/$output_la.lnk
1.6       moko     10202:            func_verbose "creating linker input file list: $output"
                   10203:            : > $output
                   10204:            set x $save_libobjs
                   10205:            shift
                   10206:            firstobj=
1.7     ! moko     10207:            if test yes = "$compiler_needs_object"; then
1.6       moko     10208:              firstobj="$1 "
                   10209:              shift
                   10210:            fi
                   10211:            for obj
                   10212:            do
                   10213:              func_to_tool_file "$obj"
                   10214:              $ECHO "$func_to_tool_file_result" >> $output
                   10215:            done
                   10216:            func_append delfiles " $output"
                   10217:            func_to_tool_file "$output"
                   10218:            output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
1.7     ! moko     10219:          elif test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
        !          10220:            output=$output_objdir/$output_la.lnkscript
        !          10221:            func_verbose "creating GNU ld script: $output"
        !          10222:            echo 'INPUT (' > $output
        !          10223:            for obj in $save_libobjs
        !          10224:            do
        !          10225:              func_to_tool_file "$obj"
        !          10226:              $ECHO "$func_to_tool_file_result" >> $output
        !          10227:            done
        !          10228:            echo ')' >> $output
        !          10229:            func_append delfiles " $output"
        !          10230:            func_to_tool_file "$output"
        !          10231:            output=$func_to_tool_file_result
1.6       moko     10232:          else
                   10233:            if test -n "$save_libobjs"; then
                   10234:              func_verbose "creating reloadable object files..."
1.7     ! moko     10235:              output=$output_objdir/$output_la-$k.$objext
1.6       moko     10236:              eval test_cmds=\"$reload_cmds\"
                   10237:              func_len " $test_cmds"
                   10238:              len0=$func_len_result
                   10239:              len=$len0
                   10240: 
                   10241:              # Loop over the list of objects to be linked.
                   10242:              for obj in $save_libobjs
                   10243:              do
                   10244:                func_len " $obj"
                   10245:                func_arith $len + $func_len_result
                   10246:                len=$func_arith_result
1.7     ! moko     10247:                if test -z "$objlist" ||
1.6       moko     10248:                   test "$len" -lt "$max_cmd_len"; then
                   10249:                  func_append objlist " $obj"
                   10250:                else
                   10251:                  # The command $test_cmds is almost too long, add a
                   10252:                  # command to the queue.
1.7     ! moko     10253:                  if test 1 -eq "$k"; then
1.6       moko     10254:                    # The first file doesn't have a previous command to add.
                   10255:                    reload_objs=$objlist
                   10256:                    eval concat_cmds=\"$reload_cmds\"
                   10257:                  else
                   10258:                    # All subsequent reloadable object files will link in
                   10259:                    # the last one created.
                   10260:                    reload_objs="$objlist $last_robj"
                   10261:                    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
                   10262:                  fi
1.7     ! moko     10263:                  last_robj=$output_objdir/$output_la-$k.$objext
1.6       moko     10264:                  func_arith $k + 1
                   10265:                  k=$func_arith_result
1.7     ! moko     10266:                  output=$output_objdir/$output_la-$k.$objext
1.6       moko     10267:                  objlist=" $obj"
                   10268:                  func_len " $last_robj"
                   10269:                  func_arith $len0 + $func_len_result
                   10270:                  len=$func_arith_result
                   10271:                fi
                   10272:              done
                   10273:              # Handle the remaining objects by creating one last
                   10274:              # reloadable object file.  All subsequent reloadable object
                   10275:              # files will link in the last one created.
                   10276:              test -z "$concat_cmds" || concat_cmds=$concat_cmds~
                   10277:              reload_objs="$objlist $last_robj"
1.7     ! moko     10278:              eval concat_cmds=\"\$concat_cmds$reload_cmds\"
1.6       moko     10279:              if test -n "$last_robj"; then
1.7     ! moko     10280:                eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
1.6       moko     10281:              fi
                   10282:              func_append delfiles " $output"
1.5       paf      10283: 
1.6       moko     10284:            else
                   10285:              output=
                   10286:            fi
1.5       paf      10287: 
1.7     ! moko     10288:            ${skipped_export-false} && {
        !          10289:              func_verbose "generating symbol list for '$libname.la'"
        !          10290:              export_symbols=$output_objdir/$libname.exp
1.6       moko     10291:              $opt_dry_run || $RM $export_symbols
                   10292:              libobjs=$output
                   10293:              # Append the command to create the export file.
                   10294:              test -z "$concat_cmds" || concat_cmds=$concat_cmds~
                   10295:              eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
                   10296:              if test -n "$last_robj"; then
                   10297:                eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
                   10298:              fi
1.7     ! moko     10299:            }
1.5       paf      10300: 
1.6       moko     10301:            test -n "$save_libobjs" &&
                   10302:              func_verbose "creating a temporary reloadable object file: $output"
1.5       paf      10303: 
1.6       moko     10304:            # Loop through the commands generated above and execute them.
1.7     ! moko     10305:            save_ifs=$IFS; IFS='~'
1.6       moko     10306:            for cmd in $concat_cmds; do
1.7     ! moko     10307:              IFS=$save_ifs
        !          10308:              $opt_quiet || {
        !          10309:                  func_quote_arg expand,pretty "$cmd"
        !          10310:                  eval "func_echo $func_quote_arg_result"
1.6       moko     10311:              }
                   10312:              $opt_dry_run || eval "$cmd" || {
                   10313:                lt_exit=$?
                   10314: 
                   10315:                # Restore the uninstalled library and exit
1.7     ! moko     10316:                if test relink = "$opt_mode"; then
1.6       moko     10317:                  ( cd "$output_objdir" && \
                   10318:                    $RM "${realname}T" && \
                   10319:                    $MV "${realname}U" "$realname" )
                   10320:                fi
1.5       paf      10321: 
1.6       moko     10322:                exit $lt_exit
                   10323:              }
                   10324:            done
1.7     ! moko     10325:            IFS=$save_ifs
1.5       paf      10326: 
1.6       moko     10327:            if test -n "$export_symbols_regex" && ${skipped_export-false}; then
                   10328:              func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
                   10329:              func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
1.5       paf      10330:            fi
                   10331:          fi
                   10332: 
1.7     ! moko     10333:           ${skipped_export-false} && {
1.6       moko     10334:            if test -n "$export_symbols" && test -n "$include_expsyms"; then
1.7     ! moko     10335:              tmp_export_symbols=$export_symbols
        !          10336:              test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
1.6       moko     10337:              $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
                   10338:            fi
1.5       paf      10339: 
1.6       moko     10340:            if test -n "$orig_export_symbols"; then
                   10341:              # The given exports_symbols file has to be filtered, so filter it.
1.7     ! moko     10342:              func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
1.6       moko     10343:              # FIXME: $output_objdir/$libname.filter potentially contains lots of
1.7     ! moko     10344:              # 's' commands, which not all seds can handle. GNU sed should be fine
1.6       moko     10345:              # though. Also, the filter scales superlinearly with the number of
                   10346:              # global variables. join(1) would be nice here, but unfortunately
                   10347:              # isn't a blessed tool.
                   10348:              $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
                   10349:              func_append delfiles " $export_symbols $output_objdir/$libname.filter"
                   10350:              export_symbols=$output_objdir/$libname.def
                   10351:              $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
                   10352:            fi
1.7     ! moko     10353:          }
1.5       paf      10354: 
1.6       moko     10355:          libobjs=$output
                   10356:          # Restore the value of output.
                   10357:          output=$save_output
1.5       paf      10358: 
1.6       moko     10359:          if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
                   10360:            eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
                   10361:            test "X$libobjs" = "X " && libobjs=
                   10362:          fi
                   10363:          # Expand the library linking commands again to reset the
                   10364:          # value of $libobjs for piecewise linking.
1.5       paf      10365: 
1.6       moko     10366:          # Do each of the archive commands.
1.7     ! moko     10367:          if test yes = "$module" && test -n "$module_cmds"; then
1.6       moko     10368:            if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
                   10369:              cmds=$module_expsym_cmds
                   10370:            else
                   10371:              cmds=$module_cmds
                   10372:            fi
                   10373:          else
                   10374:            if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
                   10375:              cmds=$archive_expsym_cmds
                   10376:            else
                   10377:              cmds=$archive_cmds
1.5       paf      10378:            fi
                   10379:          fi
1.6       moko     10380:        fi
                   10381: 
                   10382:        if test -n "$delfiles"; then
                   10383:          # Append the command to remove temporary files to $cmds.
                   10384:          eval cmds=\"\$cmds~\$RM $delfiles\"
                   10385:        fi
1.5       paf      10386: 
1.6       moko     10387:        # Add any objects from preloaded convenience libraries
                   10388:        if test -n "$dlprefiles"; then
1.7     ! moko     10389:          gentop=$output_objdir/${outputname}x
1.6       moko     10390:          func_append generated " $gentop"
1.5       paf      10391: 
1.6       moko     10392:          func_extract_archives $gentop $dlprefiles
                   10393:          func_append libobjs " $func_extract_archives_result"
                   10394:          test "X$libobjs" = "X " && libobjs=
                   10395:        fi
1.5       paf      10396: 
1.7     ! moko     10397:        save_ifs=$IFS; IFS='~'
1.6       moko     10398:        for cmd in $cmds; do
1.7     ! moko     10399:          IFS=$sp$nl
1.6       moko     10400:          eval cmd=\"$cmd\"
1.7     ! moko     10401:          IFS=$save_ifs
        !          10402:          $opt_quiet || {
        !          10403:            func_quote_arg expand,pretty "$cmd"
        !          10404:            eval "func_echo $func_quote_arg_result"
1.6       moko     10405:          }
                   10406:          $opt_dry_run || eval "$cmd" || {
                   10407:            lt_exit=$?
                   10408: 
                   10409:            # Restore the uninstalled library and exit
1.7     ! moko     10410:            if test relink = "$opt_mode"; then
1.6       moko     10411:              ( cd "$output_objdir" && \
                   10412:                $RM "${realname}T" && \
                   10413:                $MV "${realname}U" "$realname" )
                   10414:            fi
1.5       paf      10415: 
1.6       moko     10416:            exit $lt_exit
                   10417:          }
                   10418:        done
1.7     ! moko     10419:        IFS=$save_ifs
1.5       paf      10420: 
1.6       moko     10421:        # Restore the uninstalled library and exit
1.7     ! moko     10422:        if test relink = "$opt_mode"; then
1.6       moko     10423:          $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
1.5       paf      10424: 
1.6       moko     10425:          if test -n "$convenience"; then
                   10426:            if test -z "$whole_archive_flag_spec"; then
                   10427:              func_show_eval '${RM}r "$gentop"'
                   10428:            fi
                   10429:          fi
1.5       paf      10430: 
1.6       moko     10431:          exit $EXIT_SUCCESS
                   10432:        fi
1.5       paf      10433: 
1.6       moko     10434:        # Create links to the real library.
                   10435:        for linkname in $linknames; do
                   10436:          if test "$realname" != "$linkname"; then
                   10437:            func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
1.5       paf      10438:          fi
                   10439:        done
1.6       moko     10440: 
                   10441:        # If -module or -export-dynamic was specified, set the dlname.
1.7     ! moko     10442:        if test yes = "$module" || test yes = "$export_dynamic"; then
1.6       moko     10443:          # On all known operating systems, these are identical.
1.7     ! moko     10444:          dlname=$soname
1.6       moko     10445:        fi
1.5       paf      10446:       fi
                   10447:       ;;
                   10448: 
1.6       moko     10449:     obj)
1.7     ! moko     10450:       if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
        !          10451:        func_warning "'-dlopen' is ignored for objects"
1.6       moko     10452:       fi
1.5       paf      10453: 
1.6       moko     10454:       case " $deplibs" in
                   10455:       *\ -l* | *\ -L*)
1.7     ! moko     10456:        func_warning "'-l' and '-L' are ignored for objects" ;;
1.5       paf      10457:       esac
                   10458: 
1.6       moko     10459:       test -n "$rpath" && \
1.7     ! moko     10460:        func_warning "'-rpath' is ignored for objects"
1.6       moko     10461: 
                   10462:       test -n "$xrpath" && \
1.7     ! moko     10463:        func_warning "'-R' is ignored for objects"
1.6       moko     10464: 
                   10465:       test -n "$vinfo" && \
1.7     ! moko     10466:        func_warning "'-version-info' is ignored for objects"
1.6       moko     10467: 
                   10468:       test -n "$release" && \
1.7     ! moko     10469:        func_warning "'-release' is ignored for objects"
1.5       paf      10470: 
1.6       moko     10471:       case $output in
                   10472:       *.lo)
                   10473:        test -n "$objs$old_deplibs" && \
1.7     ! moko     10474:          func_fatal_error "cannot build library object '$output' from non-libtool objects"
1.5       paf      10475: 
1.6       moko     10476:        libobj=$output
                   10477:        func_lo2o "$libobj"
                   10478:        obj=$func_lo2o_result
                   10479:        ;;
                   10480:       *)
                   10481:        libobj=
1.7     ! moko     10482:        obj=$output
1.5       paf      10483:        ;;
1.6       moko     10484:       esac
                   10485: 
                   10486:       # Delete the old objects.
                   10487:       $opt_dry_run || $RM $obj $libobj
                   10488: 
                   10489:       # Objects from convenience libraries.  This assumes
                   10490:       # single-version convenience libraries.  Whenever we create
                   10491:       # different ones for PIC/non-PIC, this we'll have to duplicate
                   10492:       # the extraction.
                   10493:       reload_conv_objs=
                   10494:       gentop=
1.7     ! moko     10495:       # if reload_cmds runs $LD directly, get rid of -Wl from
        !          10496:       # whole_archive_flag_spec and hope we can get by with turning comma
        !          10497:       # into space.
        !          10498:       case $reload_cmds in
        !          10499:         *\$LD[\ \$]*) wl= ;;
        !          10500:       esac
1.6       moko     10501:       if test -n "$convenience"; then
                   10502:        if test -n "$whole_archive_flag_spec"; then
                   10503:          eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
1.7     ! moko     10504:          test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
        !          10505:          reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
1.5       paf      10506:        else
1.7     ! moko     10507:          gentop=$output_objdir/${obj}x
1.6       moko     10508:          func_append generated " $gentop"
                   10509: 
                   10510:          func_extract_archives $gentop $convenience
                   10511:          reload_conv_objs="$reload_objs $func_extract_archives_result"
1.5       paf      10512:        fi
1.6       moko     10513:       fi
                   10514: 
                   10515:       # If we're not building shared, we need to use non_pic_objs
1.7     ! moko     10516:       test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
1.6       moko     10517: 
                   10518:       # Create the old-style object.
1.7     ! moko     10519:       reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
1.6       moko     10520: 
1.7     ! moko     10521:       output=$obj
1.6       moko     10522:       func_execute_cmds "$reload_cmds" 'exit $?'
1.5       paf      10523: 
1.6       moko     10524:       # Exit if we aren't doing a library object file.
                   10525:       if test -z "$libobj"; then
                   10526:        if test -n "$gentop"; then
                   10527:          func_show_eval '${RM}r "$gentop"'
                   10528:        fi
1.5       paf      10529: 
1.6       moko     10530:        exit $EXIT_SUCCESS
                   10531:       fi
1.5       paf      10532: 
1.7     ! moko     10533:       test yes = "$build_libtool_libs" || {
1.6       moko     10534:        if test -n "$gentop"; then
                   10535:          func_show_eval '${RM}r "$gentop"'
                   10536:        fi
1.5       paf      10537: 
1.6       moko     10538:        # Create an invalid libtool object if no PIC, so that we don't
                   10539:        # accidentally link it into a program.
                   10540:        # $show "echo timestamp > $libobj"
                   10541:        # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
                   10542:        exit $EXIT_SUCCESS
1.7     ! moko     10543:       }
1.5       paf      10544: 
1.7     ! moko     10545:       if test -n "$pic_flag" || test default != "$pic_mode"; then
1.6       moko     10546:        # Only do commands if we really have different PIC objects.
                   10547:        reload_objs="$libobjs $reload_conv_objs"
1.7     ! moko     10548:        output=$libobj
1.6       moko     10549:        func_execute_cmds "$reload_cmds" 'exit $?'
                   10550:       fi
1.5       paf      10551: 
1.6       moko     10552:       if test -n "$gentop"; then
                   10553:        func_show_eval '${RM}r "$gentop"'
                   10554:       fi
1.5       paf      10555: 
1.6       moko     10556:       exit $EXIT_SUCCESS
1.5       paf      10557:       ;;
                   10558: 
1.6       moko     10559:     prog)
                   10560:       case $host in
                   10561:        *cygwin*) func_stripname '' '.exe' "$output"
                   10562:                  output=$func_stripname_result.exe;;
                   10563:       esac
                   10564:       test -n "$vinfo" && \
1.7     ! moko     10565:        func_warning "'-version-info' is ignored for programs"
1.6       moko     10566: 
                   10567:       test -n "$release" && \
1.7     ! moko     10568:        func_warning "'-release' is ignored for programs"
1.5       paf      10569: 
1.7     ! moko     10570:       $preload \
        !          10571:        && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
        !          10572:        && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
1.5       paf      10573: 
1.6       moko     10574:       case $host in
                   10575:       *-*-rhapsody* | *-*-darwin1.[012])
                   10576:        # On Rhapsody replace the C library is the System framework
                   10577:        compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
                   10578:        finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
1.5       paf      10579:        ;;
1.6       moko     10580:       esac
1.5       paf      10581: 
1.6       moko     10582:       case $host in
                   10583:       *-*-darwin*)
                   10584:        # Don't allow lazy linking, it breaks C++ global constructors
                   10585:        # But is supposedly fixed on 10.4 or later (yay!).
1.7     ! moko     10586:        if test CXX = "$tagname"; then
1.6       moko     10587:          case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
                   10588:            10.[0123])
1.7     ! moko     10589:              func_append compile_command " $wl-bind_at_load"
        !          10590:              func_append finalize_command " $wl-bind_at_load"
1.6       moko     10591:            ;;
                   10592:          esac
1.5       paf      10593:        fi
1.6       moko     10594:        # Time to change all our "foo.ltframework" stuff back to "-framework foo"
                   10595:        compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
                   10596:        finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
                   10597:        ;;
                   10598:       esac
1.5       paf      10599: 
1.6       moko     10600: 
                   10601:       # move library search paths that coincide with paths to not yet
                   10602:       # installed libraries to the beginning of the library search list
                   10603:       new_libs=
                   10604:       for path in $notinst_path; do
                   10605:        case " $new_libs " in
                   10606:        *" -L$path/$objdir "*) ;;
                   10607:        *)
                   10608:          case " $compile_deplibs " in
                   10609:          *" -L$path/$objdir "*)
                   10610:            func_append new_libs " -L$path/$objdir" ;;
                   10611:          esac
                   10612:          ;;
                   10613:        esac
                   10614:       done
                   10615:       for deplib in $compile_deplibs; do
                   10616:        case $deplib in
                   10617:        -L*)
                   10618:          case " $new_libs " in
                   10619:          *" $deplib "*) ;;
                   10620:          *) func_append new_libs " $deplib" ;;
                   10621:          esac
                   10622:          ;;
                   10623:        *) func_append new_libs " $deplib" ;;
1.5       paf      10624:        esac
1.6       moko     10625:       done
1.7     ! moko     10626:       compile_deplibs=$new_libs
1.6       moko     10627: 
                   10628: 
                   10629:       func_append compile_command " $compile_deplibs"
                   10630:       func_append finalize_command " $finalize_deplibs"
1.5       paf      10631: 
1.6       moko     10632:       if test -n "$rpath$xrpath"; then
                   10633:        # If the user specified any rpath flags, then add them.
                   10634:        for libdir in $rpath $xrpath; do
                   10635:          # This is the magic to use -rpath.
                   10636:          case "$finalize_rpath " in
1.5       paf      10637:          *" $libdir "*) ;;
1.6       moko     10638:          *) func_append finalize_rpath " $libdir" ;;
1.5       paf      10639:          esac
1.6       moko     10640:        done
                   10641:       fi
                   10642: 
                   10643:       # Now hardcode the library paths
                   10644:       rpath=
                   10645:       hardcode_libdirs=
                   10646:       for libdir in $compile_rpath $finalize_rpath; do
                   10647:        if test -n "$hardcode_libdir_flag_spec"; then
                   10648:          if test -n "$hardcode_libdir_separator"; then
                   10649:            if test -z "$hardcode_libdirs"; then
1.7     ! moko     10650:              hardcode_libdirs=$libdir
1.6       moko     10651:            else
                   10652:              # Just accumulate the unique libdirs.
                   10653:              case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
                   10654:              *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
                   10655:                ;;
                   10656:              *)
                   10657:                func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
                   10658:                ;;
                   10659:              esac
                   10660:            fi
                   10661:          else
                   10662:            eval flag=\"$hardcode_libdir_flag_spec\"
                   10663:            func_append rpath " $flag"
                   10664:          fi
                   10665:        elif test -n "$runpath_var"; then
                   10666:          case "$perm_rpath " in
1.5       paf      10667:          *" $libdir "*) ;;
1.6       moko     10668:          *) func_append perm_rpath " $libdir" ;;
1.5       paf      10669:          esac
                   10670:        fi
1.6       moko     10671:        case $host in
1.7     ! moko     10672:        *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
        !          10673:          testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
1.6       moko     10674:          case :$dllsearchpath: in
                   10675:          *":$libdir:"*) ;;
                   10676:          ::) dllsearchpath=$libdir;;
                   10677:          *) func_append dllsearchpath ":$libdir";;
                   10678:          esac
                   10679:          case :$dllsearchpath: in
                   10680:          *":$testbindir:"*) ;;
                   10681:          ::) dllsearchpath=$testbindir;;
                   10682:          *) func_append dllsearchpath ":$testbindir";;
                   10683:          esac
                   10684:          ;;
                   10685:        esac
                   10686:       done
                   10687:       # Substitute the hardcoded libdirs into the rpath.
                   10688:       if test -n "$hardcode_libdir_separator" &&
                   10689:         test -n "$hardcode_libdirs"; then
1.7     ! moko     10690:        libdir=$hardcode_libdirs
1.6       moko     10691:        eval rpath=\" $hardcode_libdir_flag_spec\"
                   10692:       fi
1.7     ! moko     10693:       compile_rpath=$rpath
1.5       paf      10694: 
1.6       moko     10695:       rpath=
                   10696:       hardcode_libdirs=
                   10697:       for libdir in $finalize_rpath; do
                   10698:        if test -n "$hardcode_libdir_flag_spec"; then
                   10699:          if test -n "$hardcode_libdir_separator"; then
                   10700:            if test -z "$hardcode_libdirs"; then
1.7     ! moko     10701:              hardcode_libdirs=$libdir
1.6       moko     10702:            else
                   10703:              # Just accumulate the unique libdirs.
                   10704:              case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
                   10705:              *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
                   10706:                ;;
                   10707:              *)
                   10708:                func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
                   10709:                ;;
                   10710:              esac
                   10711:            fi
1.5       paf      10712:          else
1.6       moko     10713:            eval flag=\"$hardcode_libdir_flag_spec\"
                   10714:            func_append rpath " $flag"
1.5       paf      10715:          fi
1.6       moko     10716:        elif test -n "$runpath_var"; then
                   10717:          case "$finalize_perm_rpath " in
                   10718:          *" $libdir "*) ;;
                   10719:          *) func_append finalize_perm_rpath " $libdir" ;;
                   10720:          esac
1.5       paf      10721:        fi
1.6       moko     10722:       done
                   10723:       # Substitute the hardcoded libdirs into the rpath.
                   10724:       if test -n "$hardcode_libdir_separator" &&
                   10725:         test -n "$hardcode_libdirs"; then
1.7     ! moko     10726:        libdir=$hardcode_libdirs
1.6       moko     10727:        eval rpath=\" $hardcode_libdir_flag_spec\"
                   10728:       fi
1.7     ! moko     10729:       finalize_rpath=$rpath
1.5       paf      10730: 
1.7     ! moko     10731:       if test -n "$libobjs" && test yes = "$build_old_libs"; then
1.6       moko     10732:        # Transform all the library objects into standard objects.
                   10733:        compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
                   10734:        finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
                   10735:       fi
                   10736: 
1.7     ! moko     10737:       func_generate_dlsyms "$outputname" "@PROGRAM@" false
1.5       paf      10738: 
1.6       moko     10739:       # template prelinking step
                   10740:       if test -n "$prelink_cmds"; then
                   10741:        func_execute_cmds "$prelink_cmds" 'exit $?'
                   10742:       fi
1.5       paf      10743: 
1.7     ! moko     10744:       wrappers_required=:
1.6       moko     10745:       case $host in
                   10746:       *cegcc* | *mingw32ce*)
                   10747:         # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
1.7     ! moko     10748:         wrappers_required=false
1.6       moko     10749:         ;;
1.7     ! moko     10750:       *cygwin* | *mingw* | *windows* )
        !          10751:         test yes = "$build_libtool_libs" || wrappers_required=false
1.6       moko     10752:         ;;
                   10753:       *)
1.7     ! moko     10754:         if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
        !          10755:           wrappers_required=false
1.6       moko     10756:         fi
                   10757:         ;;
                   10758:       esac
1.7     ! moko     10759:       $wrappers_required || {
1.6       moko     10760:        # Replace the output file specification.
                   10761:        compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
1.7     ! moko     10762:        link_command=$compile_command$compile_rpath
1.5       paf      10763: 
1.6       moko     10764:        # We have no uninstalled library dependencies, so finalize right now.
                   10765:        exit_status=0
                   10766:        func_show_eval "$link_command" 'exit_status=$?'
1.5       paf      10767: 
1.6       moko     10768:        if test -n "$postlink_cmds"; then
                   10769:          func_to_tool_file "$output"
                   10770:          postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
                   10771:          func_execute_cmds "$postlink_cmds" 'exit $?'
1.5       paf      10772:        fi
                   10773: 
1.6       moko     10774:        # Delete the generated files.
1.7     ! moko     10775:        if test -f "$output_objdir/${outputname}S.$objext"; then
        !          10776:          func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
1.6       moko     10777:        fi
1.5       paf      10778: 
1.6       moko     10779:        exit $exit_status
1.7     ! moko     10780:       }
1.5       paf      10781: 
1.6       moko     10782:       if test -n "$compile_shlibpath$finalize_shlibpath"; then
                   10783:        compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
                   10784:       fi
                   10785:       if test -n "$finalize_shlibpath"; then
                   10786:        finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
                   10787:       fi
1.5       paf      10788: 
1.6       moko     10789:       compile_var=
                   10790:       finalize_var=
                   10791:       if test -n "$runpath_var"; then
                   10792:        if test -n "$perm_rpath"; then
                   10793:          # We should set the runpath_var.
                   10794:          rpath=
                   10795:          for dir in $perm_rpath; do
                   10796:            func_append rpath "$dir:"
                   10797:          done
                   10798:          compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
                   10799:        fi
                   10800:        if test -n "$finalize_perm_rpath"; then
                   10801:          # We should set the runpath_var.
                   10802:          rpath=
                   10803:          for dir in $finalize_perm_rpath; do
                   10804:            func_append rpath "$dir:"
                   10805:          done
                   10806:          finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
1.5       paf      10807:        fi
1.6       moko     10808:       fi
1.5       paf      10809: 
1.7     ! moko     10810:       if test yes = "$no_install"; then
1.6       moko     10811:        # We don't need to create a wrapper script.
1.7     ! moko     10812:        link_command=$compile_var$compile_command$compile_rpath
1.6       moko     10813:        # Replace the output file specification.
                   10814:        link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
                   10815:        # Delete the old output file.
                   10816:        $opt_dry_run || $RM $output
                   10817:        # Link the executable and exit
                   10818:        func_show_eval "$link_command" 'exit $?'
1.5       paf      10819: 
1.6       moko     10820:        if test -n "$postlink_cmds"; then
                   10821:          func_to_tool_file "$output"
                   10822:          postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
                   10823:          func_execute_cmds "$postlink_cmds" 'exit $?'
1.5       paf      10824:        fi
                   10825: 
1.6       moko     10826:        exit $EXIT_SUCCESS
                   10827:       fi
                   10828: 
1.7     ! moko     10829:       case $hardcode_action,$fast_install in
        !          10830:         relink,*)
        !          10831:          # Fast installation is not supported
        !          10832:          link_command=$compile_var$compile_command$compile_rpath
        !          10833:          relink_command=$finalize_var$finalize_command$finalize_rpath
        !          10834: 
        !          10835:          func_warning "this platform does not like uninstalled shared libraries"
        !          10836:          func_warning "'$output' will be relinked during installation"
        !          10837:          ;;
        !          10838:         *,yes)
        !          10839:          link_command=$finalize_var$compile_command$finalize_rpath
        !          10840:          relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
        !          10841:           ;;
        !          10842:        *,no)
        !          10843:          link_command=$compile_var$compile_command$compile_rpath
        !          10844:          relink_command=$finalize_var$finalize_command$finalize_rpath
        !          10845:           ;;
        !          10846:        *,needless)
        !          10847:          link_command=$finalize_var$compile_command$finalize_rpath
        !          10848:          relink_command=
        !          10849:           ;;
        !          10850:       esac
1.5       paf      10851: 
1.6       moko     10852:       # Replace the output file specification.
                   10853:       link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
1.5       paf      10854: 
1.6       moko     10855:       # Delete the old output files.
                   10856:       $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
1.5       paf      10857: 
1.6       moko     10858:       func_show_eval "$link_command" 'exit $?'
1.5       paf      10859: 
1.6       moko     10860:       if test -n "$postlink_cmds"; then
                   10861:        func_to_tool_file "$output_objdir/$outputname"
                   10862:        postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
                   10863:        func_execute_cmds "$postlink_cmds" 'exit $?'
                   10864:       fi
1.5       paf      10865: 
1.6       moko     10866:       # Now create the wrapper script.
                   10867:       func_verbose "creating $output"
1.5       paf      10868: 
1.6       moko     10869:       # Quote the relink command for shipping.
                   10870:       if test -n "$relink_command"; then
                   10871:        # Preserve any variables that may affect compiler behavior
                   10872:        for var in $variables_saved_for_relink; do
                   10873:          if eval test -z \"\${$var+set}\"; then
                   10874:            relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
                   10875:          elif eval var_value=\$$var; test -z "$var_value"; then
                   10876:            relink_command="$var=; export $var; $relink_command"
                   10877:          else
1.7     ! moko     10878:            func_quote_arg pretty "$var_value"
        !          10879:            relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
1.6       moko     10880:          fi
                   10881:        done
1.7     ! moko     10882:        func_quote eval cd "`pwd`"
        !          10883:        func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)"
        !          10884:        relink_command=$func_quote_arg_unquoted_result
1.6       moko     10885:       fi
1.5       paf      10886: 
1.6       moko     10887:       # Only actually do things if not in dry run mode.
                   10888:       $opt_dry_run || {
                   10889:        # win32 will think the script is a binary if it has
                   10890:        # a .exe suffix, so we strip it off here.
                   10891:        case $output in
                   10892:          *.exe) func_stripname '' '.exe' "$output"
                   10893:                 output=$func_stripname_result ;;
                   10894:        esac
                   10895:        # test for cygwin because mv fails w/o .exe extensions
                   10896:        case $host in
                   10897:          *cygwin*)
                   10898:            exeext=.exe
                   10899:            func_stripname '' '.exe' "$outputname"
                   10900:            outputname=$func_stripname_result ;;
                   10901:          *) exeext= ;;
                   10902:        esac
                   10903:        case $host in
1.7     ! moko     10904:          *cygwin* | *mingw* | windows* )
1.6       moko     10905:            func_dirname_and_basename "$output" "" "."
                   10906:            output_name=$func_basename_result
                   10907:            output_path=$func_dirname_result
1.7     ! moko     10908:            cwrappersource=$output_path/$objdir/lt-$output_name.c
        !          10909:            cwrapper=$output_path/$output_name.exe
1.6       moko     10910:            $RM $cwrappersource $cwrapper
                   10911:            trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
                   10912: 
                   10913:            func_emit_cwrapperexe_src > $cwrappersource
                   10914: 
                   10915:            # The wrapper executable is built using the $host compiler,
                   10916:            # because it contains $host paths and files. If cross-
                   10917:            # compiling, it, like the target executable, must be
                   10918:            # executed on the $host or under an emulation environment.
                   10919:            $opt_dry_run || {
                   10920:              $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
                   10921:              $STRIP $cwrapper
                   10922:            }
                   10923: 
                   10924:            # Now, create the wrapper script for func_source use:
                   10925:            func_ltwrapper_scriptname $cwrapper
                   10926:            $RM $func_ltwrapper_scriptname_result
                   10927:            trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
                   10928:            $opt_dry_run || {
                   10929:              # note: this script will not be executed, so do not chmod.
1.7     ! moko     10930:              if test "x$build" = "x$host"; then
1.6       moko     10931:                $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
1.5       paf      10932:              else
1.6       moko     10933:                func_emit_wrapper no > $func_ltwrapper_scriptname_result
1.5       paf      10934:              fi
1.6       moko     10935:            }
                   10936:          ;;
                   10937:          * )
                   10938:            $RM $output
                   10939:            trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
1.5       paf      10940: 
1.6       moko     10941:            func_emit_wrapper no > $output
                   10942:            chmod +x $output
1.5       paf      10943:          ;;
                   10944:        esac
1.6       moko     10945:       }
                   10946:       exit $EXIT_SUCCESS
                   10947:       ;;
                   10948:     esac
1.5       paf      10949: 
1.6       moko     10950:     # See if we need to build an old-fashioned archive.
                   10951:     for oldlib in $oldlibs; do
1.5       paf      10952: 
1.7     ! moko     10953:       case $build_libtool_libs in
        !          10954:         convenience)
        !          10955:          oldobjs="$libobjs_save $symfileobj"
        !          10956:          addlibs=$convenience
        !          10957:          build_libtool_libs=no
        !          10958:          ;;
        !          10959:        module)
        !          10960:          oldobjs=$libobjs_save
        !          10961:          addlibs=$old_convenience
1.6       moko     10962:          build_libtool_libs=no
1.7     ! moko     10963:           ;;
        !          10964:        *)
1.6       moko     10965:          oldobjs="$old_deplibs $non_pic_objects"
1.7     ! moko     10966:          $preload && test -f "$symfileobj" \
        !          10967:            && func_append oldobjs " $symfileobj"
        !          10968:          addlibs=$old_convenience
        !          10969:          ;;
        !          10970:       esac
1.5       paf      10971: 
1.6       moko     10972:       if test -n "$addlibs"; then
1.7     ! moko     10973:        gentop=$output_objdir/${outputname}x
1.6       moko     10974:        func_append generated " $gentop"
1.5       paf      10975: 
1.6       moko     10976:        func_extract_archives $gentop $addlibs
                   10977:        func_append oldobjs " $func_extract_archives_result"
1.5       paf      10978:       fi
                   10979: 
1.6       moko     10980:       # Do each command in the archive commands.
1.7     ! moko     10981:       if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
1.6       moko     10982:        cmds=$old_archive_from_new_cmds
                   10983:       else
1.5       paf      10984: 
1.6       moko     10985:        # Add any objects from preloaded convenience libraries
                   10986:        if test -n "$dlprefiles"; then
1.7     ! moko     10987:          gentop=$output_objdir/${outputname}x
1.6       moko     10988:          func_append generated " $gentop"
                   10989: 
                   10990:          func_extract_archives $gentop $dlprefiles
                   10991:          func_append oldobjs " $func_extract_archives_result"
                   10992:        fi
                   10993: 
                   10994:        # POSIX demands no paths to be encoded in archives.  We have
                   10995:        # to avoid creating archives with duplicate basenames if we
                   10996:        # might have to extract them afterwards, e.g., when creating a
                   10997:        # static archive out of a convenience library, or when linking
                   10998:        # the entirety of a libtool archive into another (currently
                   10999:        # not supported by libtool).
                   11000:        if (for obj in $oldobjs
                   11001:            do
                   11002:              func_basename "$obj"
                   11003:              $ECHO "$func_basename_result"
                   11004:            done | sort | sort -uc >/dev/null 2>&1); then
                   11005:          :
                   11006:        else
                   11007:          echo "copying selected object files to avoid basename conflicts..."
1.7     ! moko     11008:          gentop=$output_objdir/${outputname}x
1.6       moko     11009:          func_append generated " $gentop"
                   11010:          func_mkdir_p "$gentop"
                   11011:          save_oldobjs=$oldobjs
                   11012:          oldobjs=
                   11013:          counter=1
                   11014:          for obj in $save_oldobjs
                   11015:          do
                   11016:            func_basename "$obj"
1.7     ! moko     11017:            objbase=$func_basename_result
1.6       moko     11018:            case " $oldobjs " in
                   11019:            " ") oldobjs=$obj ;;
                   11020:            *[\ /]"$objbase "*)
                   11021:              while :; do
                   11022:                # Make sure we don't pick an alternate name that also
                   11023:                # overlaps.
                   11024:                newobj=lt$counter-$objbase
                   11025:                func_arith $counter + 1
                   11026:                counter=$func_arith_result
                   11027:                case " $oldobjs " in
                   11028:                *[\ /]"$newobj "*) ;;
                   11029:                *) if test ! -f "$gentop/$newobj"; then break; fi ;;
                   11030:                esac
                   11031:              done
                   11032:              func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
                   11033:              func_append oldobjs " $gentop/$newobj"
                   11034:              ;;
                   11035:            *) func_append oldobjs " $obj" ;;
                   11036:            esac
                   11037:          done
                   11038:        fi
                   11039:        func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
                   11040:        tool_oldlib=$func_to_tool_file_result
                   11041:        eval cmds=\"$old_archive_cmds\"
1.5       paf      11042: 
1.6       moko     11043:        func_len " $cmds"
                   11044:        len=$func_len_result
                   11045:        if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
                   11046:          cmds=$old_archive_cmds
                   11047:        elif test -n "$archiver_list_spec"; then
                   11048:          func_verbose "using command file archive linking..."
                   11049:          for obj in $oldobjs
                   11050:          do
                   11051:            func_to_tool_file "$obj"
                   11052:            $ECHO "$func_to_tool_file_result"
                   11053:          done > $output_objdir/$libname.libcmd
                   11054:          func_to_tool_file "$output_objdir/$libname.libcmd"
                   11055:          oldobjs=" $archiver_list_spec$func_to_tool_file_result"
                   11056:          cmds=$old_archive_cmds
                   11057:        else
                   11058:          # the command line is too long to link in one step, link in parts
                   11059:          func_verbose "using piecewise archive linking..."
                   11060:          save_RANLIB=$RANLIB
                   11061:          RANLIB=:
                   11062:          objlist=
                   11063:          concat_cmds=
                   11064:          save_oldobjs=$oldobjs
                   11065:          oldobjs=
                   11066:          # Is there a better way of finding the last object in the list?
                   11067:          for obj in $save_oldobjs
                   11068:          do
                   11069:            last_oldobj=$obj
                   11070:          done
                   11071:          eval test_cmds=\"$old_archive_cmds\"
                   11072:          func_len " $test_cmds"
                   11073:          len0=$func_len_result
                   11074:          len=$len0
                   11075:          for obj in $save_oldobjs
                   11076:          do
                   11077:            func_len " $obj"
                   11078:            func_arith $len + $func_len_result
                   11079:            len=$func_arith_result
                   11080:            func_append objlist " $obj"
                   11081:            if test "$len" -lt "$max_cmd_len"; then
                   11082:              :
                   11083:            else
                   11084:              # the above command should be used before it gets too long
                   11085:              oldobjs=$objlist
1.7     ! moko     11086:              if test "$obj" = "$last_oldobj"; then
1.6       moko     11087:                RANLIB=$save_RANLIB
                   11088:              fi
                   11089:              test -z "$concat_cmds" || concat_cmds=$concat_cmds~
1.7     ! moko     11090:              eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
1.6       moko     11091:              objlist=
                   11092:              len=$len0
                   11093:            fi
                   11094:          done
                   11095:          RANLIB=$save_RANLIB
                   11096:          oldobjs=$objlist
1.7     ! moko     11097:          if test -z "$oldobjs"; then
1.6       moko     11098:            eval cmds=\"\$concat_cmds\"
                   11099:          else
                   11100:            eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
                   11101:          fi
                   11102:        fi
                   11103:       fi
                   11104:       func_execute_cmds "$cmds" 'exit $?'
                   11105:     done
1.5       paf      11106: 
1.6       moko     11107:     test -n "$generated" && \
                   11108:       func_show_eval "${RM}r$generated"
1.5       paf      11109: 
1.6       moko     11110:     # Now create the libtool archive.
                   11111:     case $output in
                   11112:     *.la)
                   11113:       old_library=
1.7     ! moko     11114:       test yes = "$build_old_libs" && old_library=$libname.$libext
1.6       moko     11115:       func_verbose "creating $output"
1.5       paf      11116: 
1.6       moko     11117:       # Preserve any variables that may affect compiler behavior
                   11118:       for var in $variables_saved_for_relink; do
                   11119:        if eval test -z \"\${$var+set}\"; then
                   11120:          relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
                   11121:        elif eval var_value=\$$var; test -z "$var_value"; then
                   11122:          relink_command="$var=; export $var; $relink_command"
                   11123:        else
1.7     ! moko     11124:          func_quote_arg pretty,unquoted "$var_value"
        !          11125:          relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
1.5       paf      11126:        fi
                   11127:       done
1.6       moko     11128:       # Quote the link command for shipping.
1.7     ! moko     11129:       func_quote eval cd "`pwd`"
        !          11130:       relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
        !          11131:       func_quote_arg pretty,unquoted "$relink_command"
        !          11132:       relink_command=$func_quote_arg_unquoted_result
        !          11133:       if test yes = "$hardcode_automatic"; then
1.6       moko     11134:        relink_command=
                   11135:       fi
1.5       paf      11136: 
1.6       moko     11137:       # Only create the output if not a dry run.
                   11138:       $opt_dry_run || {
                   11139:        for installed in no yes; do
1.7     ! moko     11140:          if test yes = "$installed"; then
1.6       moko     11141:            if test -z "$install_libdir"; then
                   11142:              break
                   11143:            fi
1.7     ! moko     11144:            output=$output_objdir/${outputname}i
1.6       moko     11145:            # Replace all uninstalled libtool libraries with the installed ones
                   11146:            newdependency_libs=
                   11147:            for deplib in $dependency_libs; do
                   11148:              case $deplib in
                   11149:              *.la)
                   11150:                func_basename "$deplib"
1.7     ! moko     11151:                name=$func_basename_result
1.6       moko     11152:                func_resolve_sysroot "$deplib"
1.7     ! moko     11153:                eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
1.6       moko     11154:                test -z "$libdir" && \
1.7     ! moko     11155:                  func_fatal_error "'$deplib' is not a valid libtool archive"
1.6       moko     11156:                func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
                   11157:                ;;
                   11158:              -L*)
                   11159:                func_stripname -L '' "$deplib"
                   11160:                func_replace_sysroot "$func_stripname_result"
                   11161:                func_append newdependency_libs " -L$func_replace_sysroot_result"
                   11162:                ;;
                   11163:              -R*)
                   11164:                func_stripname -R '' "$deplib"
                   11165:                func_replace_sysroot "$func_stripname_result"
                   11166:                func_append newdependency_libs " -R$func_replace_sysroot_result"
                   11167:                ;;
                   11168:              *) func_append newdependency_libs " $deplib" ;;
                   11169:              esac
                   11170:            done
1.7     ! moko     11171:            dependency_libs=$newdependency_libs
1.6       moko     11172:            newdlfiles=
1.5       paf      11173: 
1.6       moko     11174:            for lib in $dlfiles; do
                   11175:              case $lib in
                   11176:              *.la)
                   11177:                func_basename "$lib"
1.7     ! moko     11178:                name=$func_basename_result
        !          11179:                eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
1.6       moko     11180:                test -z "$libdir" && \
1.7     ! moko     11181:                  func_fatal_error "'$lib' is not a valid libtool archive"
1.6       moko     11182:                func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
                   11183:                ;;
                   11184:              *) func_append newdlfiles " $lib" ;;
                   11185:              esac
                   11186:            done
1.7     ! moko     11187:            dlfiles=$newdlfiles
1.6       moko     11188:            newdlprefiles=
                   11189:            for lib in $dlprefiles; do
                   11190:              case $lib in
                   11191:              *.la)
                   11192:                # Only pass preopened files to the pseudo-archive (for
                   11193:                # eventual linking with the app. that links it) if we
                   11194:                # didn't already link the preopened objects directly into
                   11195:                # the library:
                   11196:                func_basename "$lib"
1.7     ! moko     11197:                name=$func_basename_result
        !          11198:                eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
1.6       moko     11199:                test -z "$libdir" && \
1.7     ! moko     11200:                  func_fatal_error "'$lib' is not a valid libtool archive"
1.6       moko     11201:                func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
                   11202:                ;;
                   11203:              esac
                   11204:            done
1.7     ! moko     11205:            dlprefiles=$newdlprefiles
1.6       moko     11206:          else
                   11207:            newdlfiles=
                   11208:            for lib in $dlfiles; do
                   11209:              case $lib in
1.7     ! moko     11210:                [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
1.6       moko     11211:                *) abs=`pwd`"/$lib" ;;
                   11212:              esac
                   11213:              func_append newdlfiles " $abs"
                   11214:            done
1.7     ! moko     11215:            dlfiles=$newdlfiles
1.6       moko     11216:            newdlprefiles=
                   11217:            for lib in $dlprefiles; do
                   11218:              case $lib in
1.7     ! moko     11219:                [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
1.6       moko     11220:                *) abs=`pwd`"/$lib" ;;
                   11221:              esac
                   11222:              func_append newdlprefiles " $abs"
                   11223:            done
1.7     ! moko     11224:            dlprefiles=$newdlprefiles
1.6       moko     11225:          fi
                   11226:          $RM $output
                   11227:          # place dlname in correct position for cygwin
                   11228:          # In fact, it would be nice if we could use this code for all target
                   11229:          # systems that can't hard-code library paths into their executables
                   11230:          # and that have no shared library path variable independent of PATH,
                   11231:          # but it turns out we can't easily determine that from inspecting
                   11232:          # libtool variables, so we have to hard-code the OSs to which it
                   11233:          # applies here; at the moment, that means platforms that use the PE
                   11234:          # object format with DLL files.  See the long comment at the top of
                   11235:          # tests/bindir.at for full details.
                   11236:          tdlname=$dlname
                   11237:          case $host,$output,$installed,$module,$dlname in
1.7     ! moko     11238:            *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *windows*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
1.6       moko     11239:              # If a -bindir argument was supplied, place the dll there.
1.7     ! moko     11240:              if test -n "$bindir"; then
1.6       moko     11241:                func_relative_path "$install_libdir" "$bindir"
1.7     ! moko     11242:                tdlname=$func_relative_path_result/$dlname
1.6       moko     11243:              else
                   11244:                # Otherwise fall back on heuristic.
                   11245:                tdlname=../bin/$dlname
                   11246:              fi
                   11247:              ;;
                   11248:          esac
                   11249:          $ECHO > $output "\
                   11250: # $outputname - a libtool library file
1.7     ! moko     11251: # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
1.6       moko     11252: #
                   11253: # Please DO NOT delete this file!
                   11254: # It is necessary for linking the library.
1.5       paf      11255: 
1.6       moko     11256: # The name that we can dlopen(3).
                   11257: dlname='$tdlname'
1.5       paf      11258: 
1.6       moko     11259: # Names of this library.
                   11260: library_names='$library_names'
1.5       paf      11261: 
1.6       moko     11262: # The name of the static archive.
                   11263: old_library='$old_library'
1.5       paf      11264: 
1.7     ! moko     11265: # Linker flags that cannot go in dependency_libs.
1.6       moko     11266: inherited_linker_flags='$new_inherited_linker_flags'
1.5       paf      11267: 
1.6       moko     11268: # Libraries that this one depends upon.
                   11269: dependency_libs='$dependency_libs'
1.5       paf      11270: 
1.6       moko     11271: # Names of additional weak libraries provided by this library
                   11272: weak_library_names='$weak_libs'
1.5       paf      11273: 
1.6       moko     11274: # Version information for $libname.
                   11275: current=$current
                   11276: age=$age
                   11277: revision=$revision
1.5       paf      11278: 
1.6       moko     11279: # Is this an already installed library?
                   11280: installed=$installed
1.5       paf      11281: 
1.6       moko     11282: # Should we warn about portability when linking against -modules?
                   11283: shouldnotlink=$module
1.5       paf      11284: 
1.6       moko     11285: # Files to dlopen/dlpreopen
                   11286: dlopen='$dlfiles'
                   11287: dlpreopen='$dlprefiles'
1.5       paf      11288: 
1.6       moko     11289: # Directory that this library needs to be installed in:
                   11290: libdir='$install_libdir'"
1.7     ! moko     11291:          if test no,yes = "$installed,$need_relink"; then
1.6       moko     11292:            $ECHO >> $output "\
                   11293: relink_command=\"$relink_command\""
                   11294:          fi
                   11295:        done
                   11296:       }
1.5       paf      11297: 
1.6       moko     11298:       # Do a symbolic link so that the libtool archive can be found in
                   11299:       # LD_LIBRARY_PATH before the program is installed.
                   11300:       func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
                   11301:       ;;
                   11302:     esac
                   11303:     exit $EXIT_SUCCESS
                   11304: }
1.5       paf      11305: 
1.7     ! moko     11306: if test link = "$opt_mode" || test relink = "$opt_mode"; then
        !          11307:   func_mode_link ${1+"$@"}
        !          11308: fi
1.5       paf      11309: 
                   11310: 
1.6       moko     11311: # func_mode_uninstall arg...
                   11312: func_mode_uninstall ()
                   11313: {
1.7     ! moko     11314:     $debug_cmd
        !          11315: 
        !          11316:     RM=$nonopt
1.5       paf      11317:     files=
1.7     ! moko     11318:     rmforce=false
1.5       paf      11319:     exit_status=0
                   11320: 
                   11321:     # This variable tells wrapper scripts just to set variables rather
                   11322:     # than running their programs.
1.7     ! moko     11323:     libtool_install_magic=$magic
1.5       paf      11324: 
                   11325:     for arg
                   11326:     do
                   11327:       case $arg in
1.7     ! moko     11328:       -f) func_append RM " $arg"; rmforce=: ;;
1.6       moko     11329:       -*) func_append RM " $arg" ;;
                   11330:       *) func_append files " $arg" ;;
1.5       paf      11331:       esac
                   11332:     done
                   11333: 
1.6       moko     11334:     test -z "$RM" && \
                   11335:       func_fatal_help "you must specify an RM program"
1.5       paf      11336: 
                   11337:     rmdirs=
                   11338: 
                   11339:     for file in $files; do
1.6       moko     11340:       func_dirname "$file" "" "."
1.7     ! moko     11341:       dir=$func_dirname_result
        !          11342:       if test . = "$dir"; then
        !          11343:        odir=$objdir
1.5       paf      11344:       else
1.7     ! moko     11345:        odir=$dir/$objdir
1.5       paf      11346:       fi
1.6       moko     11347:       func_basename "$file"
1.7     ! moko     11348:       name=$func_basename_result
        !          11349:       test uninstall = "$opt_mode" && odir=$dir
1.5       paf      11350: 
1.6       moko     11351:       # Remember odir for removal later, being careful to avoid duplicates
1.7     ! moko     11352:       if test clean = "$opt_mode"; then
1.5       paf      11353:        case " $rmdirs " in
1.6       moko     11354:          *" $odir "*) ;;
                   11355:          *) func_append rmdirs " $odir" ;;
1.5       paf      11356:        esac
                   11357:       fi
                   11358: 
                   11359:       # Don't error if the file doesn't exist and rm -f was used.
1.6       moko     11360:       if { test -L "$file"; } >/dev/null 2>&1 ||
                   11361:         { test -h "$file"; } >/dev/null 2>&1 ||
                   11362:         test -f "$file"; then
1.5       paf      11363:        :
                   11364:       elif test -d "$file"; then
                   11365:        exit_status=1
                   11366:        continue
1.7     ! moko     11367:       elif $rmforce; then
1.5       paf      11368:        continue
                   11369:       fi
                   11370: 
1.7     ! moko     11371:       rmfiles=$file
1.5       paf      11372: 
                   11373:       case $name in
                   11374:       *.la)
                   11375:        # Possibly a libtool archive, so verify it.
1.6       moko     11376:        if func_lalib_p "$file"; then
                   11377:          func_source $dir/$name
1.5       paf      11378: 
                   11379:          # Delete the libtool libraries and symlinks.
                   11380:          for n in $library_names; do
1.6       moko     11381:            func_append rmfiles " $odir/$n"
1.5       paf      11382:          done
1.6       moko     11383:          test -n "$old_library" && func_append rmfiles " $odir/$old_library"
1.5       paf      11384: 
1.7     ! moko     11385:          case $opt_mode in
1.6       moko     11386:          clean)
                   11387:            case " $library_names " in
                   11388:            *" $dlname "*) ;;
                   11389:            *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
                   11390:            esac
                   11391:            test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
                   11392:            ;;
                   11393:          uninstall)
1.5       paf      11394:            if test -n "$library_names"; then
                   11395:              # Do each command in the postuninstall commands.
1.7     ! moko     11396:              func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
1.5       paf      11397:            fi
                   11398: 
                   11399:            if test -n "$old_library"; then
                   11400:              # Do each command in the old_postuninstall commands.
1.7     ! moko     11401:              func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
1.5       paf      11402:            fi
                   11403:            # FIXME: should reinstall the best remaining shared library.
1.6       moko     11404:            ;;
                   11405:          esac
1.5       paf      11406:        fi
                   11407:        ;;
                   11408: 
                   11409:       *.lo)
1.6       moko     11410:        # Possibly a libtool object, so verify it.
                   11411:        if func_lalib_p "$file"; then
                   11412: 
                   11413:          # Read the .lo file
                   11414:          func_source $dir/$name
                   11415: 
                   11416:          # Add PIC object to the list of files to remove.
1.7     ! moko     11417:          if test -n "$pic_object" && test none != "$pic_object"; then
1.6       moko     11418:            func_append rmfiles " $dir/$pic_object"
                   11419:          fi
                   11420: 
                   11421:          # Add non-PIC object to the list of files to remove.
1.7     ! moko     11422:          if test -n "$non_pic_object" && test none != "$non_pic_object"; then
1.6       moko     11423:            func_append rmfiles " $dir/$non_pic_object"
                   11424:          fi
1.5       paf      11425:        fi
                   11426:        ;;
                   11427: 
                   11428:       *)
1.7     ! moko     11429:        if test clean = "$opt_mode"; then
1.6       moko     11430:          noexename=$name
                   11431:          case $file in
                   11432:          *.exe)
                   11433:            func_stripname '' '.exe' "$file"
                   11434:            file=$func_stripname_result
                   11435:            func_stripname '' '.exe' "$name"
                   11436:            noexename=$func_stripname_result
                   11437:            # $file with .exe has already been added to rmfiles,
                   11438:            # add $file without .exe
                   11439:            func_append rmfiles " $file"
                   11440:            ;;
                   11441:          esac
                   11442:          # Do a test to see if this is a libtool program.
                   11443:          if func_ltwrapper_p "$file"; then
                   11444:            if func_ltwrapper_executable_p "$file"; then
                   11445:              func_ltwrapper_scriptname "$file"
                   11446:              relink_command=
                   11447:              func_source $func_ltwrapper_scriptname_result
                   11448:              func_append rmfiles " $func_ltwrapper_scriptname_result"
                   11449:            else
                   11450:              relink_command=
                   11451:              func_source $dir/$noexename
                   11452:            fi
1.5       paf      11453: 
1.6       moko     11454:            # note $name still contains .exe if it was in $file originally
                   11455:            # as does the version of $file that was added into $rmfiles
1.7     ! moko     11456:            func_append rmfiles " $odir/$name $odir/${name}S.$objext"
        !          11457:            if test yes = "$fast_install" && test -n "$relink_command"; then
1.6       moko     11458:              func_append rmfiles " $odir/lt-$name"
                   11459:            fi
1.7     ! moko     11460:            if test "X$noexename" != "X$name"; then
        !          11461:              func_append rmfiles " $odir/lt-$noexename.c"
1.6       moko     11462:            fi
1.5       paf      11463:          fi
                   11464:        fi
                   11465:        ;;
                   11466:       esac
1.6       moko     11467:       func_show_eval "$RM $rmfiles" 'exit_status=1'
1.5       paf      11468:     done
                   11469: 
1.7     ! moko     11470:     # Try to remove the $objdir's in the directories where we deleted files
1.5       paf      11471:     for dir in $rmdirs; do
                   11472:       if test -d "$dir"; then
1.6       moko     11473:        func_show_eval "rmdir $dir >/dev/null 2>&1"
1.5       paf      11474:       fi
                   11475:     done
                   11476: 
                   11477:     exit $exit_status
1.6       moko     11478: }
                   11479: 
1.7     ! moko     11480: if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
        !          11481:   func_mode_uninstall ${1+"$@"}
        !          11482: fi
1.5       paf      11483: 
1.6       moko     11484: test -z "$opt_mode" && {
1.7     ! moko     11485:   help=$generic_help
1.6       moko     11486:   func_fatal_help "you must specify a MODE"
                   11487: }
1.5       paf      11488: 
1.6       moko     11489: test -z "$exec_cmd" && \
1.7     ! moko     11490:   func_fatal_help "invalid operation mode '$opt_mode'"
1.5       paf      11491: 
                   11492: if test -n "$exec_cmd"; then
1.6       moko     11493:   eval exec "$exec_cmd"
                   11494:   exit $EXIT_FAILURE
1.5       paf      11495: fi
                   11496: 
1.6       moko     11497: exit $exit_status
1.5       paf      11498: 
                   11499: 
1.6       moko     11500: # The TAGs below are defined such that we never get into a situation
1.7     ! moko     11501: # where we disable both kinds of libraries.  Given conflicting
1.6       moko     11502: # choices, we go for a static library, that is the most portable,
                   11503: # since we can't tell whether shared libraries were disabled because
                   11504: # the user asked for that or because the platform doesn't support
                   11505: # them.  This is particularly important on AIX, because we don't
                   11506: # support having both static and shared libraries enabled at the same
                   11507: # time on that platform, so we default to a shared-only configuration.
                   11508: # If a disable-shared tag is given, we'll fallback to a static-only
                   11509: # configuration.  But we'll never go from static-only to shared-only.
                   11510: 
                   11511: # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
                   11512: build_libtool_libs=no
                   11513: build_old_libs=yes
                   11514: # ### END LIBTOOL TAG CONFIG: disable-shared
                   11515: 
                   11516: # ### BEGIN LIBTOOL TAG CONFIG: disable-static
                   11517: build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
                   11518: # ### END LIBTOOL TAG CONFIG: disable-static
1.5       paf      11519: 
                   11520: # Local Variables:
                   11521: # mode:shell-script
                   11522: # sh-indentation:2
                   11523: # End:

E-mail: