Home | History | Annotate | Line # | Download | only in build-aux
      1  1.1  joerg #! /bin/sh
      2  1.1  joerg ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
      3  1.1  joerg ##               by inline-source v2016-02-21.11
      4  1.1  joerg 
      5  1.1  joerg # libtool (GNU libtool) 2.4.6.40-6ca5-dirty
      6  1.1  joerg # Provide generalized library-building support services.
      7  1.1  joerg # Written by Gordon Matzigkeit <gord (at] gnu.ai.mit.edu>, 1996
      8  1.1  joerg 
      9  1.1  joerg # Copyright (C) 1996-2017 Free Software Foundation, Inc.
     10  1.1  joerg # This is free software; see the source for copying conditions.  There is NO
     11  1.1  joerg # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     12  1.1  joerg 
     13  1.1  joerg # GNU Libtool is free software; you can redistribute it and/or modify
     14  1.1  joerg # it under the terms of the GNU General Public License as published by
     15  1.1  joerg # the Free Software Foundation; either version 2 of the License, or
     16  1.1  joerg # (at your option) any later version.
     17  1.1  joerg #
     18  1.1  joerg # As a special exception to the GNU General Public License,
     19  1.1  joerg # if you distribute this file as part of a program or library that
     20  1.1  joerg # is built using GNU Libtool, you may include this file under the
     21  1.1  joerg # same distribution terms that you use for the rest of that program.
     22  1.1  joerg #
     23  1.1  joerg # GNU Libtool is distributed in the hope that it will be useful, but
     24  1.1  joerg # WITHOUT ANY WARRANTY; without even the implied warranty of
     25  1.1  joerg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     26  1.1  joerg # General Public License for more details.
     27  1.1  joerg #
     28  1.1  joerg # You should have received a copy of the GNU General Public License
     29  1.1  joerg # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     30  1.1  joerg 
     31  1.1  joerg 
     32  1.1  joerg PROGRAM=libtool
     33  1.1  joerg PACKAGE=libtool
     34  1.1  joerg VERSION=2.4.6.40-6ca5-dirty
     35  1.1  joerg package_revision=2.4.6.40
     36  1.1  joerg 
     37  1.1  joerg 
     38  1.1  joerg ## ------ ##
     39  1.1  joerg ## Usage. ##
     40  1.1  joerg ## ------ ##
     41  1.1  joerg 
     42  1.1  joerg # Run './libtool --help' for help with using this script from the
     43  1.1  joerg # command line.
     44  1.1  joerg 
     45  1.1  joerg 
     46  1.1  joerg ## ------------------------------- ##
     47  1.1  joerg ## User overridable command paths. ##
     48  1.1  joerg ## ------------------------------- ##
     49  1.1  joerg 
     50  1.1  joerg # After configure completes, it has a better idea of some of the
     51  1.1  joerg # shell tools we need than the defaults used by the functions shared
     52  1.1  joerg # with bootstrap, so set those here where they can still be over-
     53  1.1  joerg # ridden by the user, but otherwise take precedence.
     54  1.1  joerg 
     55  1.1  joerg : ${AUTOCONF="autoconf"}
     56  1.1  joerg : ${AUTOMAKE="automake"}
     57  1.1  joerg 
     58  1.1  joerg 
     59  1.1  joerg ## -------------------------- ##
     60  1.1  joerg ## Source external libraries. ##
     61  1.1  joerg ## -------------------------- ##
     62  1.1  joerg 
     63  1.1  joerg # Much of our low-level functionality needs to be sourced from external
     64  1.1  joerg # libraries, which are installed to $pkgauxdir.
     65  1.1  joerg 
     66  1.1  joerg # Set a version string for this script.
     67  1.1  joerg scriptversion=2017-04-19.12; # UTC
     68  1.1  joerg 
     69  1.1  joerg # General shell script boiler plate, and helper functions.
     70  1.1  joerg # Written by Gary V. Vaughan, 2004
     71  1.1  joerg 
     72  1.1  joerg # This is free software.  There is NO warranty; not even for
     73  1.1  joerg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     74  1.1  joerg #
     75  1.1  joerg # Copyright (C) 2004-2017 Bootstrap Authors
     76  1.1  joerg #
     77  1.1  joerg # This file is dual licensed under the terms of the MIT license
     78  1.1  joerg # <https://opensource.org/license/MIT>, and GPL version 3 or later
     79  1.1  joerg # <http://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
     80  1.1  joerg # these licenses when using or redistributing this software or any of
     81  1.1  joerg # the files within it.  See the URLs above, or the file `LICENSE`
     82  1.1  joerg # included in the Bootstrap distribution for the full license texts.
     83  1.1  joerg 
     84  1.1  joerg # Please report bugs or propose patches to:
     85  1.1  joerg # <https://github.com/gnulib-modules/bootstrap/issues>
     86  1.1  joerg 
     87  1.1  joerg 
     88  1.1  joerg ## ------ ##
     89  1.1  joerg ## Usage. ##
     90  1.1  joerg ## ------ ##
     91  1.1  joerg 
     92  1.1  joerg # Evaluate this file near the top of your script to gain access to
     93  1.1  joerg # the functions and variables defined here:
     94  1.1  joerg #
     95  1.1  joerg #   . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
     96  1.1  joerg #
     97  1.1  joerg # If you need to override any of the default environment variable
     98  1.1  joerg # settings, do that before evaluating this file.
     99  1.1  joerg 
    100  1.1  joerg 
    101  1.1  joerg ## -------------------- ##
    102  1.1  joerg ## Shell normalisation. ##
    103  1.1  joerg ## -------------------- ##
    104  1.1  joerg 
    105  1.1  joerg # Some shells need a little help to be as Bourne compatible as possible.
    106  1.1  joerg # Before doing anything else, make sure all that help has been provided!
    107  1.1  joerg 
    108  1.1  joerg DUALCASE=1; export DUALCASE # for MKS sh
    109  1.1  joerg if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
    110  1.1  joerg   emulate sh
    111  1.1  joerg   NULLCMD=:
    112  1.1  joerg   # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
    113  1.1  joerg   # is contrary to our usage.  Disable this feature.
    114  1.1  joerg   alias -g '${1+"$@"}'='"$@"'
    115  1.1  joerg   setopt NO_GLOB_SUBST
    116  1.1  joerg else
    117  1.1  joerg   case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
    118  1.1  joerg fi
    119  1.1  joerg 
    120  1.1  joerg # NLS nuisances: We save the old values in case they are required later.
    121  1.1  joerg _G_user_locale=
    122  1.1  joerg _G_safe_locale=
    123  1.1  joerg for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
    124  1.1  joerg do
    125  1.1  joerg   eval "if test set = \"\${$_G_var+set}\"; then
    126  1.1  joerg           save_$_G_var=\$$_G_var
    127  1.1  joerg           $_G_var=C
    128  1.1  joerg 	  export $_G_var
    129  1.1  joerg 	  _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
    130  1.1  joerg 	  _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
    131  1.1  joerg 	fi"
    132  1.1  joerg done
    133  1.1  joerg 
    134  1.1  joerg # Make sure IFS has a sensible default
    135  1.1  joerg sp=' '
    136  1.1  joerg nl='
    137  1.1  joerg '
    138  1.1  joerg IFS="$sp	$nl"
    139  1.1  joerg 
    140  1.1  joerg # There are apparently some retarded systems that use ';' as a PATH separator!
    141  1.1  joerg if test "${PATH_SEPARATOR+set}" != set; then
    142  1.1  joerg   PATH_SEPARATOR=:
    143  1.1  joerg   (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
    144  1.1  joerg     (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
    145  1.1  joerg       PATH_SEPARATOR=';'
    146  1.1  joerg   }
    147  1.1  joerg fi
    148  1.1  joerg 
    149  1.1  joerg 
    150  1.1  joerg # func_unset VAR
    151  1.1  joerg # --------------
    152  1.1  joerg # Portably unset VAR.
    153  1.1  joerg # In some shells, an 'unset VAR' statement leaves a non-zero return
    154  1.1  joerg # status if VAR is already unset, which might be problematic if the
    155  1.1  joerg # statement is used at the end of a function (thus poisoning its return
    156  1.1  joerg # value) or when 'set -e' is active (causing even a spurious abort of
    157  1.1  joerg # the script in this case).
    158  1.1  joerg func_unset ()
    159  1.1  joerg {
    160  1.1  joerg     { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
    161  1.1  joerg }
    162  1.1  joerg 
    163  1.1  joerg 
    164  1.1  joerg # Make sure CDPATH doesn't cause `cd` commands to output the target dir.
    165  1.1  joerg func_unset CDPATH
    166  1.1  joerg 
    167  1.1  joerg # Make sure ${,E,F}GREP behave sanely.
    168  1.1  joerg func_unset GREP_OPTIONS
    169  1.1  joerg 
    170  1.1  joerg 
    171  1.1  joerg ## ------------------------- ##
    172  1.1  joerg ## Locate command utilities. ##
    173  1.1  joerg ## ------------------------- ##
    174  1.1  joerg 
    175  1.1  joerg 
    176  1.1  joerg # func_executable_p FILE
    177  1.1  joerg # ----------------------
    178  1.1  joerg # Check that FILE is an executable regular file.
    179  1.1  joerg func_executable_p ()
    180  1.1  joerg {
    181  1.1  joerg     test -f "$1" && test -x "$1"
    182  1.1  joerg }
    183  1.1  joerg 
    184  1.1  joerg 
    185  1.1  joerg # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
    186  1.1  joerg # --------------------------------------------
    187  1.1  joerg # Search for either a program that responds to --version with output
    188  1.1  joerg # containing "GNU", or else returned by CHECK_FUNC otherwise, by
    189  1.1  joerg # trying all the directories in PATH with each of the elements of
    190  1.1  joerg # PROGS_LIST.
    191  1.1  joerg #
    192  1.1  joerg # CHECK_FUNC should accept the path to a candidate program, and
    193  1.1  joerg # set $func_check_prog_result if it truncates its output less than
    194  1.1  joerg # $_G_path_prog_max characters.
    195  1.1  joerg func_path_progs ()
    196  1.1  joerg {
    197  1.1  joerg     _G_progs_list=$1
    198  1.1  joerg     _G_check_func=$2
    199  1.1  joerg     _G_PATH=${3-"$PATH"}
    200  1.1  joerg 
    201  1.1  joerg     _G_path_prog_max=0
    202  1.1  joerg     _G_path_prog_found=false
    203  1.1  joerg     _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
    204  1.1  joerg     for _G_dir in $_G_PATH; do
    205  1.1  joerg       IFS=$_G_save_IFS
    206  1.1  joerg       test -z "$_G_dir" && _G_dir=.
    207  1.1  joerg       for _G_prog_name in $_G_progs_list; do
    208  1.1  joerg         for _exeext in '' .EXE; do
    209  1.1  joerg           _G_path_prog=$_G_dir/$_G_prog_name$_exeext
    210  1.1  joerg           func_executable_p "$_G_path_prog" || continue
    211  1.1  joerg           case `"$_G_path_prog" --version 2>&1` in
    212  1.1  joerg             *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
    213  1.1  joerg             *)     $_G_check_func $_G_path_prog
    214  1.1  joerg 		   func_path_progs_result=$func_check_prog_result
    215  1.1  joerg 		   ;;
    216  1.1  joerg           esac
    217  1.1  joerg           $_G_path_prog_found && break 3
    218  1.1  joerg         done
    219  1.1  joerg       done
    220  1.1  joerg     done
    221  1.1  joerg     IFS=$_G_save_IFS
    222  1.1  joerg     test -z "$func_path_progs_result" && {
    223  1.1  joerg       echo "no acceptable sed could be found in \$PATH" >&2
    224  1.1  joerg       exit 1
    225  1.1  joerg     }
    226  1.1  joerg }
    227  1.1  joerg 
    228  1.1  joerg 
    229  1.1  joerg # We want to be able to use the functions in this file before configure
    230  1.1  joerg # has figured out where the best binaries are kept, which means we have
    231  1.1  joerg # to search for them ourselves - except when the results are already set
    232  1.1  joerg # where we skip the searches.
    233  1.1  joerg 
    234  1.1  joerg # Unless the user overrides by setting SED, search the path for either GNU
    235  1.1  joerg # sed, or the sed that truncates its output the least.
    236  1.1  joerg test -z "$SED" && {
    237  1.1  joerg   _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
    238  1.1  joerg   for _G_i in 1 2 3 4 5 6 7; do
    239  1.1  joerg     _G_sed_script=$_G_sed_script$nl$_G_sed_script
    240  1.1  joerg   done
    241  1.1  joerg   echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
    242  1.1  joerg   _G_sed_script=
    243  1.1  joerg 
    244  1.1  joerg   func_check_prog_sed ()
    245  1.1  joerg   {
    246  1.1  joerg     _G_path_prog=$1
    247  1.1  joerg 
    248  1.1  joerg     _G_count=0
    249  1.1  joerg     printf 0123456789 >conftest.in
    250  1.1  joerg     while :
    251  1.1  joerg     do
    252  1.1  joerg       cat conftest.in conftest.in >conftest.tmp
    253  1.1  joerg       mv conftest.tmp conftest.in
    254  1.1  joerg       cp conftest.in conftest.nl
    255  1.1  joerg       echo '' >> conftest.nl
    256  1.1  joerg       "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
    257  1.1  joerg       diff conftest.out conftest.nl >/dev/null 2>&1 || break
    258  1.1  joerg       _G_count=`expr $_G_count + 1`
    259  1.1  joerg       if test "$_G_count" -gt "$_G_path_prog_max"; then
    260  1.1  joerg         # Best one so far, save it but keep looking for a better one
    261  1.1  joerg         func_check_prog_result=$_G_path_prog
    262  1.1  joerg         _G_path_prog_max=$_G_count
    263  1.1  joerg       fi
    264  1.1  joerg       # 10*(2^10) chars as input seems more than enough
    265  1.1  joerg       test 10 -lt "$_G_count" && break
    266  1.1  joerg     done
    267  1.1  joerg     rm -f conftest.in conftest.tmp conftest.nl conftest.out
    268  1.1  joerg   }
    269  1.1  joerg 
    270  1.1  joerg   func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
    271  1.1  joerg   rm -f conftest.sed
    272  1.1  joerg   SED=$func_path_progs_result
    273  1.1  joerg }
    274  1.1  joerg 
    275  1.1  joerg 
    276  1.1  joerg # Unless the user overrides by setting GREP, search the path for either GNU
    277  1.1  joerg # grep, or the grep that truncates its output the least.
    278  1.1  joerg test -z "$GREP" && {
    279  1.1  joerg   func_check_prog_grep ()
    280  1.1  joerg   {
    281  1.1  joerg     _G_path_prog=$1
    282  1.1  joerg 
    283  1.1  joerg     _G_count=0
    284  1.1  joerg     _G_path_prog_max=0
    285  1.1  joerg     printf 0123456789 >conftest.in
    286  1.1  joerg     while :
    287  1.1  joerg     do
    288  1.1  joerg       cat conftest.in conftest.in >conftest.tmp
    289  1.1  joerg       mv conftest.tmp conftest.in
    290  1.1  joerg       cp conftest.in conftest.nl
    291  1.1  joerg       echo 'GREP' >> conftest.nl
    292  1.1  joerg       "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
    293  1.1  joerg       diff conftest.out conftest.nl >/dev/null 2>&1 || break
    294  1.1  joerg       _G_count=`expr $_G_count + 1`
    295  1.1  joerg       if test "$_G_count" -gt "$_G_path_prog_max"; then
    296  1.1  joerg         # Best one so far, save it but keep looking for a better one
    297  1.1  joerg         func_check_prog_result=$_G_path_prog
    298  1.1  joerg         _G_path_prog_max=$_G_count
    299  1.1  joerg       fi
    300  1.1  joerg       # 10*(2^10) chars as input seems more than enough
    301  1.1  joerg       test 10 -lt "$_G_count" && break
    302  1.1  joerg     done
    303  1.1  joerg     rm -f conftest.in conftest.tmp conftest.nl conftest.out
    304  1.1  joerg   }
    305  1.1  joerg 
    306  1.1  joerg   func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
    307  1.1  joerg   GREP=$func_path_progs_result
    308  1.1  joerg }
    309  1.1  joerg 
    310  1.1  joerg 
    311  1.1  joerg ## ------------------------------- ##
    312  1.1  joerg ## User overridable command paths. ##
    313  1.1  joerg ## ------------------------------- ##
    314  1.1  joerg 
    315  1.1  joerg # All uppercase variable names are used for environment variables.  These
    316  1.1  joerg # variables can be overridden by the user before calling a script that
    317  1.1  joerg # uses them if a suitable command of that name is not already available
    318  1.1  joerg # in the command search PATH.
    319  1.1  joerg 
    320  1.1  joerg : ${CP="cp -f"}
    321  1.1  joerg : ${ECHO="printf %s\n"}
    322  1.1  joerg : ${EGREP="$GREP -E"}
    323  1.1  joerg : ${FGREP="$GREP -F"}
    324  1.1  joerg : ${LN_S="ln -s"}
    325  1.1  joerg : ${MAKE="make"}
    326  1.1  joerg : ${MKDIR="mkdir"}
    327  1.1  joerg : ${MV="mv -f"}
    328  1.1  joerg : ${RM="rm -f"}
    329  1.1  joerg : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
    330  1.1  joerg 
    331  1.1  joerg 
    332  1.1  joerg ## -------------------- ##
    333  1.1  joerg ## Useful sed snippets. ##
    334  1.1  joerg ## -------------------- ##
    335  1.1  joerg 
    336  1.1  joerg sed_dirname='s|/[^/]*$||'
    337  1.1  joerg sed_basename='s|^.*/||'
    338  1.1  joerg 
    339  1.1  joerg # Sed substitution that helps us do robust quoting.  It backslashifies
    340  1.1  joerg # metacharacters that are still active within double-quoted strings.
    341  1.1  joerg sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
    342  1.1  joerg 
    343  1.1  joerg # Same as above, but do not quote variable references.
    344  1.1  joerg sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
    345  1.1  joerg 
    346  1.1  joerg # Sed substitution that turns a string into a regex matching for the
    347  1.1  joerg # string literally.
    348  1.1  joerg sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
    349  1.1  joerg 
    350  1.1  joerg # Sed substitution that converts a w32 file name or path
    351  1.1  joerg # that contains forward slashes, into one that contains
    352  1.1  joerg # (escaped) backslashes.  A very naive implementation.
    353  1.1  joerg sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
    354  1.1  joerg 
    355  1.1  joerg # Re-'\' parameter expansions in output of sed_double_quote_subst that
    356  1.1  joerg # were '\'-ed in input to the same.  If an odd number of '\' preceded a
    357  1.1  joerg # '$' in input to sed_double_quote_subst, that '$' was protected from
    358  1.1  joerg # expansion.  Since each input '\' is now two '\'s, look for any number
    359  1.1  joerg # of runs of four '\'s followed by two '\'s and then a '$'.  '\' that '$'.
    360  1.1  joerg _G_bs='\\'
    361  1.1  joerg _G_bs2='\\\\'
    362  1.1  joerg _G_bs4='\\\\\\\\'
    363  1.1  joerg _G_dollar='\$'
    364  1.1  joerg sed_double_backslash="\
    365  1.1  joerg   s/$_G_bs4/&\\
    366  1.1  joerg /g
    367  1.1  joerg   s/^$_G_bs2$_G_dollar/$_G_bs&/
    368  1.1  joerg   s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
    369  1.1  joerg   s/\n//g"
    370  1.1  joerg 
    371  1.1  joerg 
    372  1.1  joerg ## ----------------- ##
    373  1.1  joerg ## Global variables. ##
    374  1.1  joerg ## ----------------- ##
    375  1.1  joerg 
    376  1.1  joerg # Except for the global variables explicitly listed below, the following
    377  1.1  joerg # functions in the '^func_' namespace, and the '^require_' namespace
    378  1.1  joerg # variables initialised in the 'Resource management' section, sourcing
    379  1.1  joerg # this file will not pollute your global namespace with anything
    380  1.1  joerg # else. There's no portable way to scope variables in Bourne shell
    381  1.1  joerg # though, so actually running these functions will sometimes place
    382  1.1  joerg # results into a variable named after the function, and often use
    383  1.1  joerg # temporary variables in the '^_G_' namespace. If you are careful to
    384  1.1  joerg # avoid using those namespaces casually in your sourcing script, things
    385  1.1  joerg # should continue to work as you expect. And, of course, you can freely
    386  1.1  joerg # overwrite any of the functions or variables defined here before
    387  1.1  joerg # calling anything to customize them.
    388  1.1  joerg 
    389  1.1  joerg EXIT_SUCCESS=0
    390  1.1  joerg EXIT_FAILURE=1
    391  1.1  joerg EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
    392  1.1  joerg EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
    393  1.1  joerg 
    394  1.1  joerg # Allow overriding, eg assuming that you follow the convention of
    395  1.1  joerg # putting '$debug_cmd' at the start of all your functions, you can get
    396  1.1  joerg # bash to show function call trace with:
    397  1.1  joerg #
    398  1.1  joerg #    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
    399  1.1  joerg debug_cmd=${debug_cmd-":"}
    400  1.1  joerg exit_cmd=:
    401  1.1  joerg 
    402  1.1  joerg # By convention, finish your script with:
    403  1.1  joerg #
    404  1.1  joerg #    exit $exit_status
    405  1.1  joerg #
    406  1.1  joerg # so that you can set exit_status to non-zero if you want to indicate
    407  1.1  joerg # something went wrong during execution without actually bailing out at
    408  1.1  joerg # the point of failure.
    409  1.1  joerg exit_status=$EXIT_SUCCESS
    410  1.1  joerg 
    411  1.1  joerg # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
    412  1.1  joerg # is ksh but when the shell is invoked as "sh" and the current value of
    413  1.1  joerg # the _XPG environment variable is not equal to 1 (one), the special
    414  1.1  joerg # positional parameter $0, within a function call, is the name of the
    415  1.1  joerg # function.
    416  1.1  joerg progpath=$0
    417  1.1  joerg 
    418  1.1  joerg # The name of this program.
    419  1.1  joerg progname=`$ECHO "$progpath" |$SED "$sed_basename"`
    420  1.1  joerg 
    421  1.1  joerg # Make sure we have an absolute progpath for reexecution:
    422  1.1  joerg case $progpath in
    423  1.1  joerg   [\\/]*|[A-Za-z]:\\*) ;;
    424  1.1  joerg   *[\\/]*)
    425  1.1  joerg      progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
    426  1.1  joerg      progdir=`cd "$progdir" && pwd`
    427  1.1  joerg      progpath=$progdir/$progname
    428  1.1  joerg      ;;
    429  1.1  joerg   *)
    430  1.1  joerg      _G_IFS=$IFS
    431  1.1  joerg      IFS=${PATH_SEPARATOR-:}
    432  1.1  joerg      for progdir in $PATH; do
    433  1.1  joerg        IFS=$_G_IFS
    434  1.1  joerg        test -x "$progdir/$progname" && break
    435  1.1  joerg      done
    436  1.1  joerg      IFS=$_G_IFS
    437  1.1  joerg      test -n "$progdir" || progdir=`pwd`
    438  1.1  joerg      progpath=$progdir/$progname
    439  1.1  joerg      ;;
    440  1.1  joerg esac
    441  1.1  joerg 
    442  1.1  joerg 
    443  1.1  joerg ## ----------------- ##
    444  1.1  joerg ## Standard options. ##
    445  1.1  joerg ## ----------------- ##
    446  1.1  joerg 
    447  1.1  joerg # The following options affect the operation of the functions defined
    448  1.1  joerg # below, and should be set appropriately depending on run-time para-
    449  1.1  joerg # meters passed on the command line.
    450  1.1  joerg 
    451  1.1  joerg opt_dry_run=false
    452  1.1  joerg opt_quiet=false
    453  1.1  joerg opt_verbose=false
    454  1.1  joerg 
    455  1.1  joerg # Categories 'all' and 'none' are always available.  Append any others
    456  1.1  joerg # you will pass as the first argument to func_warning from your own
    457  1.1  joerg # code.
    458  1.1  joerg warning_categories=
    459  1.1  joerg 
    460  1.1  joerg # By default, display warnings according to 'opt_warning_types'.  Set
    461  1.1  joerg # 'warning_func'  to ':' to elide all warnings, or func_fatal_error to
    462  1.1  joerg # treat the next displayed warning as a fatal error.
    463  1.1  joerg warning_func=func_warn_and_continue
    464  1.1  joerg 
    465  1.1  joerg # Set to 'all' to display all warnings, 'none' to suppress all
    466  1.1  joerg # warnings, or a space delimited list of some subset of
    467  1.1  joerg # 'warning_categories' to display only the listed warnings.
    468  1.1  joerg opt_warning_types=all
    469  1.1  joerg 
    470  1.1  joerg 
    471  1.1  joerg ## -------------------- ##
    472  1.1  joerg ## Resource management. ##
    473  1.1  joerg ## -------------------- ##
    474  1.1  joerg 
    475  1.1  joerg # This section contains definitions for functions that each ensure a
    476  1.1  joerg # particular resource (a file, or a non-empty configuration variable for
    477  1.1  joerg # example) is available, and if appropriate to extract default values
    478  1.1  joerg # from pertinent package files. Call them using their associated
    479  1.1  joerg # 'require_*' variable to ensure that they are executed, at most, once.
    480  1.1  joerg #
    481  1.1  joerg # It's entirely deliberate that calling these functions can set
    482  1.1  joerg # variables that don't obey the namespace limitations obeyed by the rest
    483  1.1  joerg # of this file, in order that that they be as useful as possible to
    484  1.1  joerg # callers.
    485  1.1  joerg 
    486  1.1  joerg 
    487  1.1  joerg # require_term_colors
    488  1.1  joerg # -------------------
    489  1.1  joerg # Allow display of bold text on terminals that support it.
    490  1.1  joerg require_term_colors=func_require_term_colors
    491  1.1  joerg func_require_term_colors ()
    492  1.1  joerg {
    493  1.1  joerg     $debug_cmd
    494  1.1  joerg 
    495  1.1  joerg     test -t 1 && {
    496  1.1  joerg       # COLORTERM and USE_ANSI_COLORS environment variables take
    497  1.1  joerg       # precedence, because most terminfo databases neglect to describe
    498  1.1  joerg       # whether color sequences are supported.
    499  1.1  joerg       test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
    500  1.1  joerg 
    501  1.1  joerg       if test 1 = "$USE_ANSI_COLORS"; then
    502  1.1  joerg         # Standard ANSI escape sequences
    503  1.1  joerg         tc_reset='[0m'
    504  1.1  joerg         tc_bold='[1m';   tc_standout='[7m'
    505  1.1  joerg         tc_red='[31m';   tc_green='[32m'
    506  1.1  joerg         tc_blue='[34m';  tc_cyan='[36m'
    507  1.1  joerg       else
    508  1.1  joerg         # Otherwise trust the terminfo database after all.
    509  1.1  joerg         test -n "`tput sgr0 2>/dev/null`" && {
    510  1.1  joerg           tc_reset=`tput sgr0`
    511  1.1  joerg           test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
    512  1.1  joerg           tc_standout=$tc_bold
    513  1.1  joerg           test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
    514  1.1  joerg           test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
    515  1.1  joerg           test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
    516  1.1  joerg           test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
    517  1.1  joerg           test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
    518  1.1  joerg         }
    519  1.1  joerg       fi
    520  1.1  joerg     }
    521  1.1  joerg 
    522  1.1  joerg     require_term_colors=:
    523  1.1  joerg }
    524  1.1  joerg 
    525  1.1  joerg 
    526  1.1  joerg ## ----------------- ##
    527  1.1  joerg ## Function library. ##
    528  1.1  joerg ## ----------------- ##
    529  1.1  joerg 
    530  1.1  joerg # This section contains a variety of useful functions to call in your
    531  1.1  joerg # scripts. Take note of the portable wrappers for features provided by
    532  1.1  joerg # some modern shells, which will fall back to slower equivalents on
    533  1.1  joerg # less featureful shells.
    534  1.1  joerg 
    535  1.1  joerg 
    536  1.1  joerg # func_append VAR VALUE
    537  1.1  joerg # ---------------------
    538  1.1  joerg # Append VALUE onto the existing contents of VAR.
    539  1.1  joerg 
    540  1.1  joerg   # We should try to minimise forks, especially on Windows where they are
    541  1.1  joerg   # unreasonably slow, so skip the feature probes when bash or zsh are
    542  1.1  joerg   # being used:
    543  1.1  joerg   if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
    544  1.1  joerg     : ${_G_HAVE_ARITH_OP="yes"}
    545  1.1  joerg     : ${_G_HAVE_XSI_OPS="yes"}
    546  1.1  joerg     # The += operator was introduced in bash 3.1
    547  1.1  joerg     case $BASH_VERSION in
    548  1.1  joerg       [12].* | 3.0 | 3.0*) ;;
    549  1.1  joerg       *)
    550  1.1  joerg         : ${_G_HAVE_PLUSEQ_OP="yes"}
    551  1.1  joerg         ;;
    552  1.1  joerg     esac
    553  1.1  joerg   fi
    554  1.1  joerg 
    555  1.1  joerg   # _G_HAVE_PLUSEQ_OP
    556  1.1  joerg   # Can be empty, in which case the shell is probed, "yes" if += is
    557  1.1  joerg   # useable or anything else if it does not work.
    558  1.1  joerg   test -z "$_G_HAVE_PLUSEQ_OP" \
    559  1.1  joerg     && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
    560  1.1  joerg     && _G_HAVE_PLUSEQ_OP=yes
    561  1.1  joerg 
    562  1.1  joerg if test yes = "$_G_HAVE_PLUSEQ_OP"
    563  1.1  joerg then
    564  1.1  joerg   # This is an XSI compatible shell, allowing a faster implementation...
    565  1.1  joerg   eval 'func_append ()
    566  1.1  joerg   {
    567  1.1  joerg     $debug_cmd
    568  1.1  joerg 
    569  1.1  joerg     eval "$1+=\$2"
    570  1.1  joerg   }'
    571  1.1  joerg else
    572  1.1  joerg   # ...otherwise fall back to using expr, which is often a shell builtin.
    573  1.1  joerg   func_append ()
    574  1.1  joerg   {
    575  1.1  joerg     $debug_cmd
    576  1.1  joerg 
    577  1.1  joerg     eval "$1=\$$1\$2"
    578  1.1  joerg   }
    579  1.1  joerg fi
    580  1.1  joerg 
    581  1.1  joerg 
    582  1.1  joerg # func_append_quoted VAR VALUE
    583  1.1  joerg # ----------------------------
    584  1.1  joerg # Quote VALUE and append to the end of shell variable VAR, separated
    585  1.1  joerg # by a space.
    586  1.1  joerg if test yes = "$_G_HAVE_PLUSEQ_OP"; then
    587  1.1  joerg   eval 'func_append_quoted ()
    588  1.1  joerg   {
    589  1.1  joerg     $debug_cmd
    590  1.1  joerg 
    591  1.1  joerg     func_quote_arg pretty "$2"
    592  1.1  joerg     eval "$1+=\\ \$func_quote_arg_result"
    593  1.1  joerg   }'
    594  1.1  joerg else
    595  1.1  joerg   func_append_quoted ()
    596  1.1  joerg   {
    597  1.1  joerg     $debug_cmd
    598  1.1  joerg 
    599  1.1  joerg     func_quote_arg pretty "$2"
    600  1.1  joerg     eval "$1=\$$1\\ \$func_quote_arg_result"
    601  1.1  joerg   }
    602  1.1  joerg fi
    603  1.1  joerg 
    604  1.1  joerg 
    605  1.1  joerg # func_append_uniq VAR VALUE
    606  1.1  joerg # --------------------------
    607  1.1  joerg # Append unique VALUE onto the existing contents of VAR, assuming
    608  1.1  joerg # entries are delimited by the first character of VALUE.  For example:
    609  1.1  joerg #
    610  1.1  joerg #   func_append_uniq options " --another-option option-argument"
    611  1.1  joerg #
    612  1.1  joerg # will only append to $options if " --another-option option-argument "
    613  1.1  joerg # is not already present somewhere in $options already (note spaces at
    614  1.1  joerg # each end implied by leading space in second argument).
    615  1.1  joerg func_append_uniq ()
    616  1.1  joerg {
    617  1.1  joerg     $debug_cmd
    618  1.1  joerg 
    619  1.1  joerg     eval _G_current_value='`$ECHO $'$1'`'
    620  1.1  joerg     _G_delim=`expr "$2" : '\(.\)'`
    621  1.1  joerg 
    622  1.1  joerg     case $_G_delim$_G_current_value$_G_delim in
    623  1.1  joerg       *"$2$_G_delim"*) ;;
    624  1.1  joerg       *) func_append "$@" ;;
    625  1.1  joerg     esac
    626  1.1  joerg }
    627  1.1  joerg 
    628  1.1  joerg 
    629  1.1  joerg # func_arith TERM...
    630  1.1  joerg # ------------------
    631  1.1  joerg # Set func_arith_result to the result of evaluating TERMs.
    632  1.1  joerg   test -z "$_G_HAVE_ARITH_OP" \
    633  1.1  joerg     && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
    634  1.1  joerg     && _G_HAVE_ARITH_OP=yes
    635  1.1  joerg 
    636  1.1  joerg if test yes = "$_G_HAVE_ARITH_OP"; then
    637  1.1  joerg   eval 'func_arith ()
    638  1.1  joerg   {
    639  1.1  joerg     $debug_cmd
    640  1.1  joerg 
    641  1.1  joerg     func_arith_result=$(( $* ))
    642  1.1  joerg   }'
    643  1.1  joerg else
    644  1.1  joerg   func_arith ()
    645  1.1  joerg   {
    646  1.1  joerg     $debug_cmd
    647  1.1  joerg 
    648  1.1  joerg     func_arith_result=`expr "$@"`
    649  1.1  joerg   }
    650  1.1  joerg fi
    651  1.1  joerg 
    652  1.1  joerg 
    653  1.1  joerg # func_basename FILE
    654  1.1  joerg # ------------------
    655  1.1  joerg # Set func_basename_result to FILE with everything up to and including
    656  1.1  joerg # the last / stripped.
    657  1.1  joerg if test yes = "$_G_HAVE_XSI_OPS"; then
    658  1.1  joerg   # If this shell supports suffix pattern removal, then use it to avoid
    659  1.1  joerg   # forking. Hide the definitions single quotes in case the shell chokes
    660  1.1  joerg   # on unsupported syntax...
    661  1.1  joerg   _b='func_basename_result=${1##*/}'
    662  1.1  joerg   _d='case $1 in
    663  1.1  joerg         */*) func_dirname_result=${1%/*}$2 ;;
    664  1.1  joerg         *  ) func_dirname_result=$3        ;;
    665  1.1  joerg       esac'
    666  1.1  joerg 
    667  1.1  joerg else
    668  1.1  joerg   # ...otherwise fall back to using sed.
    669  1.1  joerg   _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
    670  1.1  joerg   _d='func_dirname_result=`$ECHO "$1"  |$SED "$sed_dirname"`
    671  1.1  joerg       if test "X$func_dirname_result" = "X$1"; then
    672  1.1  joerg         func_dirname_result=$3
    673  1.1  joerg       else
    674  1.1  joerg         func_append func_dirname_result "$2"
    675  1.1  joerg       fi'
    676  1.1  joerg fi
    677  1.1  joerg 
    678  1.1  joerg eval 'func_basename ()
    679  1.1  joerg {
    680  1.1  joerg     $debug_cmd
    681  1.1  joerg 
    682  1.1  joerg     '"$_b"'
    683  1.1  joerg }'
    684  1.1  joerg 
    685  1.1  joerg 
    686  1.1  joerg # func_dirname FILE APPEND NONDIR_REPLACEMENT
    687  1.1  joerg # -------------------------------------------
    688  1.1  joerg # Compute the dirname of FILE.  If nonempty, add APPEND to the result,
    689  1.1  joerg # otherwise set result to NONDIR_REPLACEMENT.
    690  1.1  joerg eval 'func_dirname ()
    691  1.1  joerg {
    692  1.1  joerg     $debug_cmd
    693  1.1  joerg 
    694  1.1  joerg     '"$_d"'
    695  1.1  joerg }'
    696  1.1  joerg 
    697  1.1  joerg 
    698  1.1  joerg # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
    699  1.1  joerg # --------------------------------------------------------
    700  1.1  joerg # Perform func_basename and func_dirname in a single function
    701  1.1  joerg # call:
    702  1.1  joerg #   dirname:  Compute the dirname of FILE.  If nonempty,
    703  1.1  joerg #             add APPEND to the result, otherwise set result
    704  1.1  joerg #             to NONDIR_REPLACEMENT.
    705  1.1  joerg #             value returned in "$func_dirname_result"
    706  1.1  joerg #   basename: Compute filename of FILE.
    707  1.1  joerg #             value retuned in "$func_basename_result"
    708  1.1  joerg # For efficiency, we do not delegate to the functions above but instead
    709  1.1  joerg # duplicate the functionality here.
    710  1.1  joerg eval 'func_dirname_and_basename ()
    711  1.1  joerg {
    712  1.1  joerg     $debug_cmd
    713  1.1  joerg 
    714  1.1  joerg     '"$_b"'
    715  1.1  joerg     '"$_d"'
    716  1.1  joerg }'
    717  1.1  joerg 
    718  1.1  joerg 
    719  1.1  joerg # func_echo ARG...
    720  1.1  joerg # ----------------
    721  1.1  joerg # Echo program name prefixed message.
    722  1.1  joerg func_echo ()
    723  1.1  joerg {
    724  1.1  joerg     $debug_cmd
    725  1.1  joerg 
    726  1.1  joerg     _G_message=$*
    727  1.1  joerg 
    728  1.1  joerg     func_echo_IFS=$IFS
    729  1.1  joerg     IFS=$nl
    730  1.1  joerg     for _G_line in $_G_message; do
    731  1.1  joerg       IFS=$func_echo_IFS
    732  1.1  joerg       $ECHO "$progname: $_G_line"
    733  1.1  joerg     done
    734  1.1  joerg     IFS=$func_echo_IFS
    735  1.1  joerg }
    736  1.1  joerg 
    737  1.1  joerg 
    738  1.1  joerg # func_echo_all ARG...
    739  1.1  joerg # --------------------
    740  1.1  joerg # Invoke $ECHO with all args, space-separated.
    741  1.1  joerg func_echo_all ()
    742  1.1  joerg {
    743  1.1  joerg     $ECHO "$*"
    744  1.1  joerg }
    745  1.1  joerg 
    746  1.1  joerg 
    747  1.1  joerg # func_echo_infix_1 INFIX ARG...
    748  1.1  joerg # ------------------------------
    749  1.1  joerg # Echo program name, followed by INFIX on the first line, with any
    750  1.1  joerg # additional lines not showing INFIX.
    751  1.1  joerg func_echo_infix_1 ()
    752  1.1  joerg {
    753  1.1  joerg     $debug_cmd
    754  1.1  joerg 
    755  1.1  joerg     $require_term_colors
    756  1.1  joerg 
    757  1.1  joerg     _G_infix=$1; shift
    758  1.1  joerg     _G_indent=$_G_infix
    759  1.1  joerg     _G_prefix="$progname: $_G_infix: "
    760  1.1  joerg     _G_message=$*
    761  1.1  joerg 
    762  1.1  joerg     # Strip color escape sequences before counting printable length
    763  1.1  joerg     for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
    764  1.1  joerg     do
    765  1.1  joerg       test -n "$_G_tc" && {
    766  1.1  joerg         _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
    767  1.1  joerg         _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
    768  1.1  joerg       }
    769  1.1  joerg     done
    770  1.1  joerg     _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`"  " ## exclude from sc_prohibit_nested_quotes
    771  1.1  joerg 
    772  1.1  joerg     func_echo_infix_1_IFS=$IFS
    773  1.1  joerg     IFS=$nl
    774  1.1  joerg     for _G_line in $_G_message; do
    775  1.1  joerg       IFS=$func_echo_infix_1_IFS
    776  1.1  joerg       $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
    777  1.1  joerg       _G_prefix=$_G_indent
    778  1.1  joerg     done
    779  1.1  joerg     IFS=$func_echo_infix_1_IFS
    780  1.1  joerg }
    781  1.1  joerg 
    782  1.1  joerg 
    783  1.1  joerg # func_error ARG...
    784  1.1  joerg # -----------------
    785  1.1  joerg # Echo program name prefixed message to standard error.
    786  1.1  joerg func_error ()
    787  1.1  joerg {
    788  1.1  joerg     $debug_cmd
    789  1.1  joerg 
    790  1.1  joerg     $require_term_colors
    791  1.1  joerg 
    792  1.1  joerg     func_echo_infix_1 "  $tc_standout${tc_red}error$tc_reset" "$*" >&2
    793  1.1  joerg }
    794  1.1  joerg 
    795  1.1  joerg 
    796  1.1  joerg # func_fatal_error ARG...
    797  1.1  joerg # -----------------------
    798  1.1  joerg # Echo program name prefixed message to standard error, and exit.
    799  1.1  joerg func_fatal_error ()
    800  1.1  joerg {
    801  1.1  joerg     $debug_cmd
    802  1.1  joerg 
    803  1.1  joerg     func_error "$*"
    804  1.1  joerg     exit $EXIT_FAILURE
    805  1.1  joerg }
    806  1.1  joerg 
    807  1.1  joerg 
    808  1.1  joerg # func_grep EXPRESSION FILENAME
    809  1.1  joerg # -----------------------------
    810  1.1  joerg # Check whether EXPRESSION matches any line of FILENAME, without output.
    811  1.1  joerg func_grep ()
    812  1.1  joerg {
    813  1.1  joerg     $debug_cmd
    814  1.1  joerg 
    815  1.1  joerg     $GREP "$1" "$2" >/dev/null 2>&1
    816  1.1  joerg }
    817  1.1  joerg 
    818  1.1  joerg 
    819  1.1  joerg # func_len STRING
    820  1.1  joerg # ---------------
    821  1.1  joerg # Set func_len_result to the length of STRING. STRING may not
    822  1.1  joerg # start with a hyphen.
    823  1.1  joerg   test -z "$_G_HAVE_XSI_OPS" \
    824  1.1  joerg     && (eval 'x=a/b/c;
    825  1.1  joerg       test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
    826  1.1  joerg     && _G_HAVE_XSI_OPS=yes
    827  1.1  joerg 
    828  1.1  joerg if test yes = "$_G_HAVE_XSI_OPS"; then
    829  1.1  joerg   eval 'func_len ()
    830  1.1  joerg   {
    831  1.1  joerg     $debug_cmd
    832  1.1  joerg 
    833  1.1  joerg     func_len_result=${#1}
    834  1.1  joerg   }'
    835  1.1  joerg else
    836  1.1  joerg   func_len ()
    837  1.1  joerg   {
    838  1.1  joerg     $debug_cmd
    839  1.1  joerg 
    840  1.1  joerg     func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
    841  1.1  joerg   }
    842  1.1  joerg fi
    843  1.1  joerg 
    844  1.1  joerg 
    845  1.1  joerg # func_mkdir_p DIRECTORY-PATH
    846  1.1  joerg # ---------------------------
    847  1.1  joerg # Make sure the entire path to DIRECTORY-PATH is available.
    848  1.1  joerg func_mkdir_p ()
    849  1.1  joerg {
    850  1.1  joerg     $debug_cmd
    851  1.1  joerg 
    852  1.1  joerg     _G_directory_path=$1
    853  1.1  joerg     _G_dir_list=
    854  1.1  joerg 
    855  1.1  joerg     if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
    856  1.1  joerg 
    857  1.1  joerg       # Protect directory names starting with '-'
    858  1.1  joerg       case $_G_directory_path in
    859  1.1  joerg         -*) _G_directory_path=./$_G_directory_path ;;
    860  1.1  joerg       esac
    861  1.1  joerg 
    862  1.1  joerg       # While some portion of DIR does not yet exist...
    863  1.1  joerg       while test ! -d "$_G_directory_path"; do
    864  1.1  joerg         # ...make a list in topmost first order.  Use a colon delimited
    865  1.1  joerg 	# list incase some portion of path contains whitespace.
    866  1.1  joerg         _G_dir_list=$_G_directory_path:$_G_dir_list
    867  1.1  joerg 
    868  1.1  joerg         # If the last portion added has no slash in it, the list is done
    869  1.1  joerg         case $_G_directory_path in */*) ;; *) break ;; esac
    870  1.1  joerg 
    871  1.1  joerg         # ...otherwise throw away the child directory and loop
    872  1.1  joerg         _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
    873  1.1  joerg       done
    874  1.1  joerg       _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
    875  1.1  joerg 
    876  1.1  joerg       func_mkdir_p_IFS=$IFS; IFS=:
    877  1.1  joerg       for _G_dir in $_G_dir_list; do
    878  1.1  joerg 	IFS=$func_mkdir_p_IFS
    879  1.1  joerg         # mkdir can fail with a 'File exist' error if two processes
    880  1.1  joerg         # try to create one of the directories concurrently.  Don't
    881  1.1  joerg         # stop in that case!
    882  1.1  joerg         $MKDIR "$_G_dir" 2>/dev/null || :
    883  1.1  joerg       done
    884  1.1  joerg       IFS=$func_mkdir_p_IFS
    885  1.1  joerg 
    886  1.1  joerg       # Bail out if we (or some other process) failed to create a directory.
    887  1.1  joerg       test -d "$_G_directory_path" || \
    888  1.1  joerg         func_fatal_error "Failed to create '$1'"
    889  1.1  joerg     fi
    890  1.1  joerg }
    891  1.1  joerg 
    892  1.1  joerg 
    893  1.1  joerg # func_mktempdir [BASENAME]
    894  1.1  joerg # -------------------------
    895  1.1  joerg # Make a temporary directory that won't clash with other running
    896  1.1  joerg # libtool processes, and avoids race conditions if possible.  If
    897  1.1  joerg # given, BASENAME is the basename for that directory.
    898  1.1  joerg func_mktempdir ()
    899  1.1  joerg {
    900  1.1  joerg     $debug_cmd
    901  1.1  joerg 
    902  1.1  joerg     _G_template=${TMPDIR-/tmp}/${1-$progname}
    903  1.1  joerg 
    904  1.1  joerg     if test : = "$opt_dry_run"; then
    905  1.1  joerg       # Return a directory name, but don't create it in dry-run mode
    906  1.1  joerg       _G_tmpdir=$_G_template-$$
    907  1.1  joerg     else
    908  1.1  joerg 
    909  1.1  joerg       # If mktemp works, use that first and foremost
    910  1.1  joerg       _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
    911  1.1  joerg 
    912  1.1  joerg       if test ! -d "$_G_tmpdir"; then
    913  1.1  joerg         # Failing that, at least try and use $RANDOM to avoid a race
    914  1.1  joerg         _G_tmpdir=$_G_template-${RANDOM-0}$$
    915  1.1  joerg 
    916  1.1  joerg         func_mktempdir_umask=`umask`
    917  1.1  joerg         umask 0077
    918  1.1  joerg         $MKDIR "$_G_tmpdir"
    919  1.1  joerg         umask $func_mktempdir_umask
    920  1.1  joerg       fi
    921  1.1  joerg 
    922  1.1  joerg       # If we're not in dry-run mode, bomb out on failure
    923  1.1  joerg       test -d "$_G_tmpdir" || \
    924  1.1  joerg         func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
    925  1.1  joerg     fi
    926  1.1  joerg 
    927  1.1  joerg     $ECHO "$_G_tmpdir"
    928  1.1  joerg }
    929  1.1  joerg 
    930  1.1  joerg 
    931  1.1  joerg # func_normal_abspath PATH
    932  1.1  joerg # ------------------------
    933  1.1  joerg # Remove doubled-up and trailing slashes, "." path components,
    934  1.1  joerg # and cancel out any ".." path components in PATH after making
    935  1.1  joerg # it an absolute path.
    936  1.1  joerg func_normal_abspath ()
    937  1.1  joerg {
    938  1.1  joerg     $debug_cmd
    939  1.1  joerg 
    940  1.1  joerg     # These SED scripts presuppose an absolute path with a trailing slash.
    941  1.1  joerg     _G_pathcar='s|^/\([^/]*\).*$|\1|'
    942  1.1  joerg     _G_pathcdr='s|^/[^/]*||'
    943  1.1  joerg     _G_removedotparts=':dotsl
    944  1.1  joerg 		s|/\./|/|g
    945  1.1  joerg 		t dotsl
    946  1.1  joerg 		s|/\.$|/|'
    947  1.1  joerg     _G_collapseslashes='s|/\{1,\}|/|g'
    948  1.1  joerg     _G_finalslash='s|/*$|/|'
    949  1.1  joerg 
    950  1.1  joerg     # Start from root dir and reassemble the path.
    951  1.1  joerg     func_normal_abspath_result=
    952  1.1  joerg     func_normal_abspath_tpath=$1
    953  1.1  joerg     func_normal_abspath_altnamespace=
    954  1.1  joerg     case $func_normal_abspath_tpath in
    955  1.1  joerg       "")
    956  1.1  joerg         # Empty path, that just means $cwd.
    957  1.1  joerg         func_stripname '' '/' "`pwd`"
    958  1.1  joerg         func_normal_abspath_result=$func_stripname_result
    959  1.1  joerg         return
    960  1.1  joerg         ;;
    961  1.1  joerg       # The next three entries are used to spot a run of precisely
    962  1.1  joerg       # two leading slashes without using negated character classes;
    963  1.1  joerg       # we take advantage of case's first-match behaviour.
    964  1.1  joerg       ///*)
    965  1.1  joerg         # Unusual form of absolute path, do nothing.
    966  1.1  joerg         ;;
    967  1.1  joerg       //*)
    968  1.1  joerg         # Not necessarily an ordinary path; POSIX reserves leading '//'
    969  1.1  joerg         # and for example Cygwin uses it to access remote file shares
    970  1.1  joerg         # over CIFS/SMB, so we conserve a leading double slash if found.
    971  1.1  joerg         func_normal_abspath_altnamespace=/
    972  1.1  joerg         ;;
    973  1.1  joerg       /*)
    974  1.1  joerg         # Absolute path, do nothing.
    975  1.1  joerg         ;;
    976  1.1  joerg       *)
    977  1.1  joerg         # Relative path, prepend $cwd.
    978  1.1  joerg         func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
    979  1.1  joerg         ;;
    980  1.1  joerg     esac
    981  1.1  joerg 
    982  1.1  joerg     # Cancel out all the simple stuff to save iterations.  We also want
    983  1.1  joerg     # the path to end with a slash for ease of parsing, so make sure
    984  1.1  joerg     # there is one (and only one) here.
    985  1.1  joerg     func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
    986  1.1  joerg           -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
    987  1.1  joerg     while :; do
    988  1.1  joerg       # Processed it all yet?
    989  1.1  joerg       if test / = "$func_normal_abspath_tpath"; then
    990  1.1  joerg         # If we ascended to the root using ".." the result may be empty now.
    991  1.1  joerg         if test -z "$func_normal_abspath_result"; then
    992  1.1  joerg           func_normal_abspath_result=/
    993  1.1  joerg         fi
    994  1.1  joerg         break
    995  1.1  joerg       fi
    996  1.1  joerg       func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
    997  1.1  joerg           -e "$_G_pathcar"`
    998  1.1  joerg       func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
    999  1.1  joerg           -e "$_G_pathcdr"`
   1000  1.1  joerg       # Figure out what to do with it
   1001  1.1  joerg       case $func_normal_abspath_tcomponent in
   1002  1.1  joerg         "")
   1003  1.1  joerg           # Trailing empty path component, ignore it.
   1004  1.1  joerg           ;;
   1005  1.1  joerg         ..)
   1006  1.1  joerg           # Parent dir; strip last assembled component from result.
   1007  1.1  joerg           func_dirname "$func_normal_abspath_result"
   1008  1.1  joerg           func_normal_abspath_result=$func_dirname_result
   1009  1.1  joerg           ;;
   1010  1.1  joerg         *)
   1011  1.1  joerg           # Actual path component, append it.
   1012  1.1  joerg           func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
   1013  1.1  joerg           ;;
   1014  1.1  joerg       esac
   1015  1.1  joerg     done
   1016  1.1  joerg     # Restore leading double-slash if one was found on entry.
   1017  1.1  joerg     func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
   1018  1.1  joerg }
   1019  1.1  joerg 
   1020  1.1  joerg 
   1021  1.1  joerg # func_notquiet ARG...
   1022  1.1  joerg # --------------------
   1023  1.1  joerg # Echo program name prefixed message only when not in quiet mode.
   1024  1.1  joerg func_notquiet ()
   1025  1.1  joerg {
   1026  1.1  joerg     $debug_cmd
   1027  1.1  joerg 
   1028  1.1  joerg     $opt_quiet || func_echo ${1+"$@"}
   1029  1.1  joerg 
   1030  1.1  joerg     # A bug in bash halts the script if the last line of a function
   1031  1.1  joerg     # fails when set -e is in force, so we need another command to
   1032  1.1  joerg     # work around that:
   1033  1.1  joerg     :
   1034  1.1  joerg }
   1035  1.1  joerg 
   1036  1.1  joerg 
   1037  1.1  joerg # func_relative_path SRCDIR DSTDIR
   1038  1.1  joerg # --------------------------------
   1039  1.1  joerg # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
   1040  1.1  joerg func_relative_path ()
   1041  1.1  joerg {
   1042  1.1  joerg     $debug_cmd
   1043  1.1  joerg 
   1044  1.1  joerg     func_relative_path_result=
   1045  1.1  joerg     func_normal_abspath "$1"
   1046  1.1  joerg     func_relative_path_tlibdir=$func_normal_abspath_result
   1047  1.1  joerg     func_normal_abspath "$2"
   1048  1.1  joerg     func_relative_path_tbindir=$func_normal_abspath_result
   1049  1.1  joerg 
   1050  1.1  joerg     # Ascend the tree starting from libdir
   1051  1.1  joerg     while :; do
   1052  1.1  joerg       # check if we have found a prefix of bindir
   1053  1.1  joerg       case $func_relative_path_tbindir in
   1054  1.1  joerg         $func_relative_path_tlibdir)
   1055  1.1  joerg           # found an exact match
   1056  1.1  joerg           func_relative_path_tcancelled=
   1057  1.1  joerg           break
   1058  1.1  joerg           ;;
   1059  1.1  joerg         $func_relative_path_tlibdir*)
   1060  1.1  joerg           # found a matching prefix
   1061  1.1  joerg           func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
   1062  1.1  joerg           func_relative_path_tcancelled=$func_stripname_result
   1063  1.1  joerg           if test -z "$func_relative_path_result"; then
   1064  1.1  joerg             func_relative_path_result=.
   1065  1.1  joerg           fi
   1066  1.1  joerg           break
   1067  1.1  joerg           ;;
   1068  1.1  joerg         *)
   1069  1.1  joerg           func_dirname $func_relative_path_tlibdir
   1070  1.1  joerg           func_relative_path_tlibdir=$func_dirname_result
   1071  1.1  joerg           if test -z "$func_relative_path_tlibdir"; then
   1072  1.1  joerg             # Have to descend all the way to the root!
   1073  1.1  joerg             func_relative_path_result=../$func_relative_path_result
   1074  1.1  joerg             func_relative_path_tcancelled=$func_relative_path_tbindir
   1075  1.1  joerg             break
   1076  1.1  joerg           fi
   1077  1.1  joerg           func_relative_path_result=../$func_relative_path_result
   1078  1.1  joerg           ;;
   1079  1.1  joerg       esac
   1080  1.1  joerg     done
   1081  1.1  joerg 
   1082  1.1  joerg     # Now calculate path; take care to avoid doubling-up slashes.
   1083  1.1  joerg     func_stripname '' '/' "$func_relative_path_result"
   1084  1.1  joerg     func_relative_path_result=$func_stripname_result
   1085  1.1  joerg     func_stripname '/' '/' "$func_relative_path_tcancelled"
   1086  1.1  joerg     if test -n "$func_stripname_result"; then
   1087  1.1  joerg       func_append func_relative_path_result "/$func_stripname_result"
   1088  1.1  joerg     fi
   1089  1.1  joerg 
   1090  1.1  joerg     # Normalisation. If bindir is libdir, return '.' else relative path.
   1091  1.1  joerg     if test -n "$func_relative_path_result"; then
   1092  1.1  joerg       func_stripname './' '' "$func_relative_path_result"
   1093  1.1  joerg       func_relative_path_result=$func_stripname_result
   1094  1.1  joerg     fi
   1095  1.1  joerg 
   1096  1.1  joerg     test -n "$func_relative_path_result" || func_relative_path_result=.
   1097  1.1  joerg 
   1098  1.1  joerg     :
   1099  1.1  joerg }
   1100  1.1  joerg 
   1101  1.1  joerg 
   1102  1.1  joerg # func_quote_portable EVAL ARG
   1103  1.1  joerg # ----------------------------
   1104  1.1  joerg # Internal function to portably implement func_quote_arg.  Note that we still
   1105  1.1  joerg # keep attention to performance here so we as much as possible try to avoid
   1106  1.1  joerg # calling sed binary (so far O(N) complexity as long as func_append is O(1)).
   1107  1.1  joerg func_quote_portable ()
   1108  1.1  joerg {
   1109  1.1  joerg     $debug_cmd
   1110  1.1  joerg 
   1111  1.1  joerg     func_quote_portable_result=$2
   1112  1.1  joerg 
   1113  1.1  joerg     # one-time-loop (easy break)
   1114  1.1  joerg     while true
   1115  1.1  joerg     do
   1116  1.1  joerg       if $1; then
   1117  1.1  joerg         func_quote_portable_result=`$ECHO "$2" | $SED \
   1118  1.1  joerg           -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
   1119  1.1  joerg         break
   1120  1.1  joerg       fi
   1121  1.1  joerg 
   1122  1.1  joerg       # Quote for eval.
   1123  1.1  joerg       case $func_quote_portable_result in
   1124  1.1  joerg         *[\\\`\"\$]*)
   1125  1.1  joerg           case $func_quote_portable_result in
   1126  1.1  joerg             *[\[\*\?]*)
   1127  1.1  joerg               func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
   1128  1.1  joerg                   | $SED "$sed_quote_subst"`
   1129  1.1  joerg               break
   1130  1.1  joerg               ;;
   1131  1.1  joerg           esac
   1132  1.1  joerg 
   1133  1.1  joerg           func_quote_portable_old_IFS=$IFS
   1134  1.1  joerg           for _G_char in '\' '`' '"' '$'
   1135  1.1  joerg           do
   1136  1.1  joerg             # STATE($1) PREV($2) SEPARATOR($3)
   1137  1.1  joerg             set start "" ""
   1138  1.1  joerg             func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
   1139  1.1  joerg             IFS=$_G_char
   1140  1.1  joerg             for _G_part in $func_quote_portable_result
   1141  1.1  joerg             do
   1142  1.1  joerg               case $1 in
   1143  1.1  joerg               quote)
   1144  1.1  joerg                 func_append func_quote_portable_result "$3$2"
   1145  1.1  joerg                 set quote "$_G_part" "\\$_G_char"
   1146  1.1  joerg                 ;;
   1147  1.1  joerg               start)
   1148  1.1  joerg                 set first "" ""
   1149  1.1  joerg                 func_quote_portable_result=
   1150  1.1  joerg                 ;;
   1151  1.1  joerg               first)
   1152  1.1  joerg                 set quote "$_G_part" ""
   1153  1.1  joerg                 ;;
   1154  1.1  joerg               esac
   1155  1.1  joerg             done
   1156  1.1  joerg           done
   1157  1.1  joerg           IFS=$func_quote_portable_old_IFS
   1158  1.1  joerg           ;;
   1159  1.1  joerg         *) ;;
   1160  1.1  joerg       esac
   1161  1.1  joerg       break
   1162  1.1  joerg     done
   1163  1.1  joerg 
   1164  1.1  joerg     func_quote_portable_unquoted_result=$func_quote_portable_result
   1165  1.1  joerg     case $func_quote_portable_result in
   1166  1.1  joerg       # double-quote args containing shell metacharacters to delay
   1167  1.1  joerg       # word splitting, command substitution and variable expansion
   1168  1.1  joerg       # for a subsequent eval.
   1169  1.1  joerg       # many bourne shells cannot handle close brackets correctly
   1170  1.1  joerg       # in scan sets, so we specify it separately.
   1171  1.1  joerg       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*|"")
   1172  1.1  joerg         func_quote_portable_result=\"$func_quote_portable_result\"
   1173  1.1  joerg         ;;
   1174  1.1  joerg     esac
   1175  1.1  joerg }
   1176  1.1  joerg 
   1177  1.1  joerg 
   1178  1.1  joerg # func_quotefast_eval ARG
   1179  1.1  joerg # -----------------------
   1180  1.1  joerg # Quote one ARG (internal).  This is equivalent to 'func_quote_arg eval ARG',
   1181  1.1  joerg # but optimized for speed.  Result is stored in $func_quotefast_eval.
   1182  1.1  joerg if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
   1183  1.1  joerg   printf -v _GL_test_printf_tilde %q '~'
   1184  1.1  joerg   if test '\~' = "$_GL_test_printf_tilde"; then
   1185  1.1  joerg     func_quotefast_eval ()
   1186  1.1  joerg     {
   1187  1.1  joerg       printf -v func_quotefast_eval_result %q "$1"
   1188  1.1  joerg     }
   1189  1.1  joerg   else
   1190  1.1  joerg     # Broken older Bash implementations.  Make those faster too if possible.
   1191  1.1  joerg     func_quotefast_eval ()
   1192  1.1  joerg     {
   1193  1.1  joerg       case $1 in
   1194  1.1  joerg         '~'*)
   1195  1.1  joerg           func_quote_portable false "$1"
   1196  1.1  joerg           func_quotefast_eval_result=$func_quote_portable_result
   1197  1.1  joerg           ;;
   1198  1.1  joerg         *)
   1199  1.1  joerg           printf -v func_quotefast_eval_result %q "$1"
   1200  1.1  joerg           ;;
   1201  1.1  joerg       esac
   1202  1.1  joerg     }
   1203  1.1  joerg   fi
   1204  1.1  joerg else
   1205  1.1  joerg   func_quotefast_eval ()
   1206  1.1  joerg   {
   1207  1.1  joerg     func_quote_portable false "$1"
   1208  1.1  joerg     func_quotefast_eval_result=$func_quote_portable_result
   1209  1.1  joerg   }
   1210  1.1  joerg fi
   1211  1.1  joerg 
   1212  1.1  joerg 
   1213  1.1  joerg # func_quote_arg MODEs ARG
   1214  1.1  joerg # ------------------------
   1215  1.1  joerg # Quote one ARG to be evaled later.  MODEs argument may contain zero or more
   1216  1.1  joerg # specifiers listed below separated by ',' character.  This function returns two
   1217  1.1  joerg # values:
   1218  1.1  joerg #   i) func_quote_arg_result
   1219  1.1  joerg #      double-quoted (when needed), suitable for a subsequent eval
   1220  1.1  joerg #  ii) func_quote_arg_unquoted_result
   1221  1.1  joerg #      has all characters that are still active within double
   1222  1.1  joerg #      quotes backslashified.  Available only if 'unquoted' is specified.
   1223  1.1  joerg #
   1224  1.1  joerg # Available modes:
   1225  1.1  joerg # ----------------
   1226  1.1  joerg # 'eval' (default)
   1227  1.1  joerg #       - escape shell special characters
   1228  1.1  joerg # 'expand'
   1229  1.1  joerg #       - the same as 'eval';  but do not quote variable references
   1230  1.1  joerg # 'pretty'
   1231  1.1  joerg #       - request aesthetic output, i.e. '"a b"' instead of 'a\ b'.  This might
   1232  1.1  joerg #         be used later in func_quote to get output like: 'echo "a b"' instead
   1233  1.1  joerg #         of 'echo a\ b'.  This is slower than default on some shells.
   1234  1.1  joerg # 'unquoted'
   1235  1.1  joerg #       - produce also $func_quote_arg_unquoted_result which does not contain
   1236  1.1  joerg #         wrapping double-quotes.
   1237  1.1  joerg #
   1238  1.1  joerg # Examples for 'func_quote_arg pretty,unquoted string':
   1239  1.1  joerg #
   1240  1.1  joerg #   string      | *_result              | *_unquoted_result
   1241  1.1  joerg #   ------------+-----------------------+-------------------
   1242  1.1  joerg #   "           | \"                    | \"
   1243  1.1  joerg #   a b         | "a b"                 | a b
   1244  1.1  joerg #   "a b"       | "\"a b\""             | \"a b\"
   1245  1.1  joerg #   *           | "*"                   | *
   1246  1.1  joerg #   z="${x-$y}" | "z=\"\${x-\$y}\""     | z=\"\${x-\$y}\"
   1247  1.1  joerg #
   1248  1.1  joerg # Examples for 'func_quote_arg pretty,unquoted,expand string':
   1249  1.1  joerg #
   1250  1.1  joerg #   string        |   *_result          |  *_unquoted_result
   1251  1.1  joerg #   --------------+---------------------+--------------------
   1252  1.1  joerg #   z="${x-$y}"   | "z=\"${x-$y}\""     | z=\"${x-$y}\"
   1253  1.1  joerg func_quote_arg ()
   1254  1.1  joerg {
   1255  1.1  joerg     _G_quote_expand=false
   1256  1.1  joerg     case ,$1, in
   1257  1.1  joerg       *,expand,*)
   1258  1.1  joerg         _G_quote_expand=:
   1259  1.1  joerg         ;;
   1260  1.1  joerg     esac
   1261  1.1  joerg 
   1262  1.1  joerg     case ,$1, in
   1263  1.1  joerg       *,pretty,*|*,expand,*|*,unquoted,*)
   1264  1.1  joerg         func_quote_portable $_G_quote_expand "$2"
   1265  1.1  joerg         func_quote_arg_result=$func_quote_portable_result
   1266  1.1  joerg         func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
   1267  1.1  joerg         ;;
   1268  1.1  joerg       *)
   1269  1.1  joerg         # Faster quote-for-eval for some shells.
   1270  1.1  joerg         func_quotefast_eval "$2"
   1271  1.1  joerg         func_quote_arg_result=$func_quotefast_eval_result
   1272  1.1  joerg         ;;
   1273  1.1  joerg     esac
   1274  1.1  joerg }
   1275  1.1  joerg 
   1276  1.1  joerg 
   1277  1.1  joerg # func_quote MODEs ARGs...
   1278  1.1  joerg # ------------------------
   1279  1.1  joerg # Quote all ARGs to be evaled later and join them into single command.  See
   1280  1.1  joerg # func_quote_arg's description for more info.
   1281  1.1  joerg func_quote ()
   1282  1.1  joerg {
   1283  1.1  joerg     $debug_cmd
   1284  1.1  joerg     _G_func_quote_mode=$1 ; shift
   1285  1.1  joerg     func_quote_result=
   1286  1.1  joerg     while test 0 -lt $#; do
   1287  1.1  joerg       func_quote_arg "$_G_func_quote_mode" "$1"
   1288  1.1  joerg       if test -n "$func_quote_result"; then
   1289  1.1  joerg         func_append func_quote_result " $func_quote_arg_result"
   1290  1.1  joerg       else
   1291  1.1  joerg         func_append func_quote_result "$func_quote_arg_result"
   1292  1.1  joerg       fi
   1293  1.1  joerg       shift
   1294  1.1  joerg     done
   1295  1.1  joerg }
   1296  1.1  joerg 
   1297  1.1  joerg 
   1298  1.1  joerg # func_stripname PREFIX SUFFIX NAME
   1299  1.1  joerg # ---------------------------------
   1300  1.1  joerg # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
   1301  1.1  joerg # PREFIX and SUFFIX must not contain globbing or regex special
   1302  1.1  joerg # characters, hashes, percent signs, but SUFFIX may contain a leading
   1303  1.1  joerg # dot (in which case that matches only a dot).
   1304  1.1  joerg if test yes = "$_G_HAVE_XSI_OPS"; then
   1305  1.1  joerg   eval 'func_stripname ()
   1306  1.1  joerg   {
   1307  1.1  joerg     $debug_cmd
   1308  1.1  joerg 
   1309  1.1  joerg     # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
   1310  1.1  joerg     # positional parameters, so assign one to ordinary variable first.
   1311  1.1  joerg     func_stripname_result=$3
   1312  1.1  joerg     func_stripname_result=${func_stripname_result#"$1"}
   1313  1.1  joerg     func_stripname_result=${func_stripname_result%"$2"}
   1314  1.1  joerg   }'
   1315  1.1  joerg else
   1316  1.1  joerg   func_stripname ()
   1317  1.1  joerg   {
   1318  1.1  joerg     $debug_cmd
   1319  1.1  joerg 
   1320  1.1  joerg     case $2 in
   1321  1.1  joerg       .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
   1322  1.1  joerg       *)  func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
   1323  1.1  joerg     esac
   1324  1.1  joerg   }
   1325  1.1  joerg fi
   1326  1.1  joerg 
   1327  1.1  joerg 
   1328  1.1  joerg # func_show_eval CMD [FAIL_EXP]
   1329  1.1  joerg # -----------------------------
   1330  1.1  joerg # Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
   1331  1.1  joerg # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
   1332  1.1  joerg # is given, then evaluate it.
   1333  1.1  joerg func_show_eval ()
   1334  1.1  joerg {
   1335  1.1  joerg     $debug_cmd
   1336  1.1  joerg 
   1337  1.1  joerg     _G_cmd=$1
   1338  1.1  joerg     _G_fail_exp=${2-':'}
   1339  1.1  joerg 
   1340  1.1  joerg     func_quote_arg pretty,expand "$_G_cmd"
   1341  1.1  joerg     eval "func_notquiet $func_quote_arg_result"
   1342  1.1  joerg 
   1343  1.1  joerg     $opt_dry_run || {
   1344  1.1  joerg       eval "$_G_cmd"
   1345  1.1  joerg       _G_status=$?
   1346  1.1  joerg       if test 0 -ne "$_G_status"; then
   1347  1.1  joerg 	eval "(exit $_G_status); $_G_fail_exp"
   1348  1.1  joerg       fi
   1349  1.1  joerg     }
   1350  1.1  joerg }
   1351  1.1  joerg 
   1352  1.1  joerg 
   1353  1.1  joerg # func_show_eval_locale CMD [FAIL_EXP]
   1354  1.1  joerg # ------------------------------------
   1355  1.1  joerg # Unless opt_quiet is true, then output CMD.  Then, if opt_dryrun is
   1356  1.1  joerg # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
   1357  1.1  joerg # is given, then evaluate it.  Use the saved locale for evaluation.
   1358  1.1  joerg func_show_eval_locale ()
   1359  1.1  joerg {
   1360  1.1  joerg     $debug_cmd
   1361  1.1  joerg 
   1362  1.1  joerg     _G_cmd=$1
   1363  1.1  joerg     _G_fail_exp=${2-':'}
   1364  1.1  joerg 
   1365  1.1  joerg     $opt_quiet || {
   1366  1.1  joerg       func_quote_arg expand,pretty "$_G_cmd"
   1367  1.1  joerg       eval "func_echo $func_quote_arg_result"
   1368  1.1  joerg     }
   1369  1.1  joerg 
   1370  1.1  joerg     $opt_dry_run || {
   1371  1.1  joerg       eval "$_G_user_locale
   1372  1.1  joerg 	    $_G_cmd"
   1373  1.1  joerg       _G_status=$?
   1374  1.1  joerg       eval "$_G_safe_locale"
   1375  1.1  joerg       if test 0 -ne "$_G_status"; then
   1376  1.1  joerg 	eval "(exit $_G_status); $_G_fail_exp"
   1377  1.1  joerg       fi
   1378  1.1  joerg     }
   1379  1.1  joerg }
   1380  1.1  joerg 
   1381  1.1  joerg 
   1382  1.1  joerg # func_tr_sh
   1383  1.1  joerg # ----------
   1384  1.1  joerg # Turn $1 into a string suitable for a shell variable name.
   1385  1.1  joerg # Result is stored in $func_tr_sh_result.  All characters
   1386  1.1  joerg # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
   1387  1.1  joerg # if $1 begins with a digit, a '_' is prepended as well.
   1388  1.1  joerg func_tr_sh ()
   1389  1.1  joerg {
   1390  1.1  joerg     $debug_cmd
   1391  1.1  joerg 
   1392  1.1  joerg     case $1 in
   1393  1.1  joerg     [0-9]* | *[!a-zA-Z0-9_]*)
   1394  1.1  joerg       func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
   1395  1.1  joerg       ;;
   1396  1.1  joerg     * )
   1397  1.1  joerg       func_tr_sh_result=$1
   1398  1.1  joerg       ;;
   1399  1.1  joerg     esac
   1400  1.1  joerg }
   1401  1.1  joerg 
   1402  1.1  joerg 
   1403  1.1  joerg # func_verbose ARG...
   1404  1.1  joerg # -------------------
   1405  1.1  joerg # Echo program name prefixed message in verbose mode only.
   1406  1.1  joerg func_verbose ()
   1407  1.1  joerg {
   1408  1.1  joerg     $debug_cmd
   1409  1.1  joerg 
   1410  1.1  joerg     $opt_verbose && func_echo "$*"
   1411  1.1  joerg 
   1412  1.1  joerg     :
   1413  1.1  joerg }
   1414  1.1  joerg 
   1415  1.1  joerg 
   1416  1.1  joerg # func_warn_and_continue ARG...
   1417  1.1  joerg # -----------------------------
   1418  1.1  joerg # Echo program name prefixed warning message to standard error.
   1419  1.1  joerg func_warn_and_continue ()
   1420  1.1  joerg {
   1421  1.1  joerg     $debug_cmd
   1422  1.1  joerg 
   1423  1.1  joerg     $require_term_colors
   1424  1.1  joerg 
   1425  1.1  joerg     func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
   1426  1.1  joerg }
   1427  1.1  joerg 
   1428  1.1  joerg 
   1429  1.1  joerg # func_warning CATEGORY ARG...
   1430  1.1  joerg # ----------------------------
   1431  1.1  joerg # Echo program name prefixed warning message to standard error. Warning
   1432  1.1  joerg # messages can be filtered according to CATEGORY, where this function
   1433  1.1  joerg # elides messages where CATEGORY is not listed in the global variable
   1434  1.1  joerg # 'opt_warning_types'.
   1435  1.1  joerg func_warning ()
   1436  1.1  joerg {
   1437  1.1  joerg     $debug_cmd
   1438  1.1  joerg 
   1439  1.1  joerg     # CATEGORY must be in the warning_categories list!
   1440  1.1  joerg     case " $warning_categories " in
   1441  1.1  joerg       *" $1 "*) ;;
   1442  1.1  joerg       *) func_internal_error "invalid warning category '$1'" ;;
   1443  1.1  joerg     esac
   1444  1.1  joerg 
   1445  1.1  joerg     _G_category=$1
   1446  1.1  joerg     shift
   1447  1.1  joerg 
   1448  1.1  joerg     case " $opt_warning_types " in
   1449  1.1  joerg       *" $_G_category "*) $warning_func ${1+"$@"} ;;
   1450  1.1  joerg     esac
   1451  1.1  joerg }
   1452  1.1  joerg 
   1453  1.1  joerg 
   1454  1.1  joerg # func_sort_ver VER1 VER2
   1455  1.1  joerg # -----------------------
   1456  1.1  joerg # 'sort -V' is not generally available.
   1457  1.1  joerg # Note this deviates from the version comparison in automake
   1458  1.1  joerg # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
   1459  1.1  joerg # but this should suffice as we won't be specifying old
   1460  1.1  joerg # version formats or redundant trailing .0 in bootstrap.conf.
   1461  1.1  joerg # If we did want full compatibility then we should probably
   1462  1.1  joerg # use m4_version_compare from autoconf.
   1463  1.1  joerg func_sort_ver ()
   1464  1.1  joerg {
   1465  1.1  joerg     $debug_cmd
   1466  1.1  joerg 
   1467  1.1  joerg     printf '%s\n%s\n' "$1" "$2" \
   1468  1.1  joerg       | 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
   1469  1.1  joerg }
   1470  1.1  joerg 
   1471  1.1  joerg # func_lt_ver PREV CURR
   1472  1.1  joerg # ---------------------
   1473  1.1  joerg # Return true if PREV and CURR are in the correct order according to
   1474  1.1  joerg # func_sort_ver, otherwise false.  Use it like this:
   1475  1.1  joerg #
   1476  1.1  joerg #  func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
   1477  1.1  joerg func_lt_ver ()
   1478  1.1  joerg {
   1479  1.1  joerg     $debug_cmd
   1480  1.1  joerg 
   1481  1.1  joerg     test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
   1482  1.1  joerg }
   1483  1.1  joerg 
   1484  1.1  joerg 
   1485  1.1  joerg # Local variables:
   1486  1.1  joerg # mode: shell-script
   1487  1.1  joerg # sh-indentation: 2
   1488  1.1  joerg # eval: (add-hook 'before-save-hook 'time-stamp)
   1489  1.1  joerg # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
   1490  1.1  joerg # time-stamp-time-zone: "UTC"
   1491  1.1  joerg # End:
   1492  1.1  joerg #! /bin/sh
   1493  1.1  joerg 
   1494  1.1  joerg # A portable, pluggable option parser for Bourne shell.
   1495  1.1  joerg # Written by Gary V. Vaughan, 2010
   1496  1.1  joerg 
   1497  1.1  joerg # This is free software.  There is NO warranty; not even for
   1498  1.1  joerg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   1499  1.1  joerg #
   1500  1.1  joerg # Copyright (C) 2010-2017 Bootstrap Authors
   1501  1.1  joerg #
   1502  1.1  joerg # This file is dual licensed under the terms of the MIT license
   1503  1.1  joerg # <https://opensource.org/license/MIT>, and GPL version 3 or later
   1504  1.1  joerg # <http://www.gnu.org/licenses/gpl-2.0.html>.  You must apply one of
   1505  1.1  joerg # these licenses when using or redistributing this software or any of
   1506  1.1  joerg # the files within it.  See the URLs above, or the file `LICENSE`
   1507  1.1  joerg # included in the Bootstrap distribution for the full license texts.
   1508  1.1  joerg 
   1509  1.1  joerg # Please report bugs or propose patches to:
   1510  1.1  joerg # <https://github.com/gnulib-modules/bootstrap/issues>
   1511  1.1  joerg 
   1512  1.1  joerg # Set a version string for this script.
   1513  1.1  joerg scriptversion=2016-03-06.01; # UTC
   1514  1.1  joerg 
   1515  1.1  joerg 
   1516  1.1  joerg ## ------ ##
   1517  1.1  joerg ## Usage. ##
   1518  1.1  joerg ## ------ ##
   1519  1.1  joerg 
   1520  1.1  joerg # This file is a library for parsing options in your shell scripts along
   1521  1.1  joerg # with assorted other useful supporting features that you can make use
   1522  1.1  joerg # of too.
   1523  1.1  joerg #
   1524  1.1  joerg # For the simplest scripts you might need only:
   1525  1.1  joerg #
   1526  1.1  joerg #   #!/bin/sh
   1527  1.1  joerg #   . relative/path/to/funclib.sh
   1528  1.1  joerg #   . relative/path/to/options-parser
   1529  1.1  joerg #   scriptversion=1.0
   1530  1.1  joerg #   func_options ${1+"$@"}
   1531  1.1  joerg #   eval set dummy "$func_options_result"; shift
   1532  1.1  joerg #   ...rest of your script...
   1533  1.1  joerg #
   1534  1.1  joerg # In order for the '--version' option to work, you will need to have a
   1535  1.1  joerg # suitably formatted comment like the one at the top of this file
   1536  1.1  joerg # starting with '# Written by ' and ending with '# Copyright'.
   1537  1.1  joerg #
   1538  1.1  joerg # For '-h' and '--help' to work, you will also need a one line
   1539  1.1  joerg # description of your script's purpose in a comment directly above the
   1540  1.1  joerg # '# Written by ' line, like the one at the top of this file.
   1541  1.1  joerg #
   1542  1.1  joerg # The default options also support '--debug', which will turn on shell
   1543  1.1  joerg # execution tracing (see the comment above debug_cmd below for another
   1544  1.1  joerg # use), and '--verbose' and the func_verbose function to allow your script
   1545  1.1  joerg # to display verbose messages only when your user has specified
   1546  1.1  joerg # '--verbose'.
   1547  1.1  joerg #
   1548  1.1  joerg # After sourcing this file, you can plug in processing for additional
   1549  1.1  joerg # options by amending the variables from the 'Configuration' section
   1550  1.1  joerg # below, and following the instructions in the 'Option parsing'
   1551  1.1  joerg # section further down.
   1552  1.1  joerg 
   1553  1.1  joerg ## -------------- ##
   1554  1.1  joerg ## Configuration. ##
   1555  1.1  joerg ## -------------- ##
   1556  1.1  joerg 
   1557  1.1  joerg # You should override these variables in your script after sourcing this
   1558  1.1  joerg # file so that they reflect the customisations you have added to the
   1559  1.1  joerg # option parser.
   1560  1.1  joerg 
   1561  1.1  joerg # The usage line for option parsing errors and the start of '-h' and
   1562  1.1  joerg # '--help' output messages. You can embed shell variables for delayed
   1563  1.1  joerg # expansion at the time the message is displayed, but you will need to
   1564  1.1  joerg # quote other shell meta-characters carefully to prevent them being
   1565  1.1  joerg # expanded when the contents are evaled.
   1566  1.1  joerg usage='$progpath [OPTION]...'
   1567  1.1  joerg 
   1568  1.1  joerg # Short help message in response to '-h' and '--help'.  Add to this or
   1569  1.1  joerg # override it after sourcing this library to reflect the full set of
   1570  1.1  joerg # options your script accepts.
   1571  1.1  joerg usage_message="\
   1572  1.1  joerg        --debug        enable verbose shell tracing
   1573  1.1  joerg    -W, --warnings=CATEGORY
   1574  1.1  joerg                       report the warnings falling in CATEGORY [all]
   1575  1.1  joerg    -v, --verbose      verbosely report processing
   1576  1.1  joerg        --version      print version information and exit
   1577  1.1  joerg    -h, --help         print short or long help message and exit
   1578  1.1  joerg "
   1579  1.1  joerg 
   1580  1.1  joerg # Additional text appended to 'usage_message' in response to '--help'.
   1581  1.1  joerg long_help_message="
   1582  1.1  joerg Warning categories include:
   1583  1.1  joerg        'all'          show all warnings
   1584  1.1  joerg        'none'         turn off all the warnings
   1585  1.1  joerg        'error'        warnings are treated as fatal errors"
   1586  1.1  joerg 
   1587  1.1  joerg # Help message printed before fatal option parsing errors.
   1588  1.1  joerg fatal_help="Try '\$progname --help' for more information."
   1589  1.1  joerg 
   1590  1.1  joerg 
   1591  1.1  joerg 
   1592  1.1  joerg ## ------------------------- ##
   1593  1.1  joerg ## Hook function management. ##
   1594  1.1  joerg ## ------------------------- ##
   1595  1.1  joerg 
   1596  1.1  joerg # This section contains functions for adding, removing, and running hooks
   1597  1.1  joerg # in the main code.  A hook is just a list of function names that can be
   1598  1.1  joerg # run in order later on.
   1599  1.1  joerg 
   1600  1.1  joerg # func_hookable FUNC_NAME
   1601  1.1  joerg # -----------------------
   1602  1.1  joerg # Declare that FUNC_NAME will run hooks added with
   1603  1.1  joerg # 'func_add_hook FUNC_NAME ...'.
   1604  1.1  joerg func_hookable ()
   1605  1.1  joerg {
   1606  1.1  joerg     $debug_cmd
   1607  1.1  joerg 
   1608  1.1  joerg     func_append hookable_fns " $1"
   1609  1.1  joerg }
   1610  1.1  joerg 
   1611  1.1  joerg 
   1612  1.1  joerg # func_add_hook FUNC_NAME HOOK_FUNC
   1613  1.1  joerg # ---------------------------------
   1614  1.1  joerg # Request that FUNC_NAME call HOOK_FUNC before it returns.  FUNC_NAME must
   1615  1.1  joerg # first have been declared "hookable" by a call to 'func_hookable'.
   1616  1.1  joerg func_add_hook ()
   1617  1.1  joerg {
   1618  1.1  joerg     $debug_cmd
   1619  1.1  joerg 
   1620  1.1  joerg     case " $hookable_fns " in
   1621  1.1  joerg       *" $1 "*) ;;
   1622  1.1  joerg       *) func_fatal_error "'$1' does not accept hook functions." ;;
   1623  1.1  joerg     esac
   1624  1.1  joerg 
   1625  1.1  joerg     eval func_append ${1}_hooks '" $2"'
   1626  1.1  joerg }
   1627  1.1  joerg 
   1628  1.1  joerg 
   1629  1.1  joerg # func_remove_hook FUNC_NAME HOOK_FUNC
   1630  1.1  joerg # ------------------------------------
   1631  1.1  joerg # Remove HOOK_FUNC from the list of hook functions to be called by
   1632  1.1  joerg # FUNC_NAME.
   1633  1.1  joerg func_remove_hook ()
   1634  1.1  joerg {
   1635  1.1  joerg     $debug_cmd
   1636  1.1  joerg 
   1637  1.1  joerg     eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
   1638  1.1  joerg }
   1639  1.1  joerg 
   1640  1.1  joerg 
   1641  1.1  joerg # func_propagate_result FUNC_NAME_A FUNC_NAME_B
   1642  1.1  joerg # ---------------------------------------------
   1643  1.1  joerg # If the *_result variable of FUNC_NAME_A _is set_, assign its value to
   1644  1.1  joerg # *_result variable of FUNC_NAME_B.
   1645  1.1  joerg func_propagate_result ()
   1646  1.1  joerg {
   1647  1.1  joerg     $debug_cmd
   1648  1.1  joerg 
   1649  1.1  joerg     func_propagate_result_result=:
   1650  1.1  joerg     if eval "test \"\${${1}_result+set}\" = set"
   1651  1.1  joerg     then
   1652  1.1  joerg       eval "${2}_result=\$${1}_result"
   1653  1.1  joerg     else
   1654  1.1  joerg       func_propagate_result_result=false
   1655  1.1  joerg     fi
   1656  1.1  joerg }
   1657  1.1  joerg 
   1658  1.1  joerg 
   1659  1.1  joerg # func_run_hooks FUNC_NAME [ARG]...
   1660  1.1  joerg # ---------------------------------
   1661  1.1  joerg # Run all hook functions registered to FUNC_NAME.
   1662  1.1  joerg # It's assumed that the list of hook functions contains nothing more
   1663  1.1  joerg # than a whitespace-delimited list of legal shell function names, and
   1664  1.1  joerg # no effort is wasted trying to catch shell meta-characters or preserve
   1665  1.1  joerg # whitespace.
   1666  1.1  joerg func_run_hooks ()
   1667  1.1  joerg {
   1668  1.1  joerg     $debug_cmd
   1669  1.1  joerg 
   1670  1.1  joerg     case " $hookable_fns " in
   1671  1.1  joerg       *" $1 "*) ;;
   1672  1.1  joerg       *) func_fatal_error "'$1' does not support hook functions." ;;
   1673  1.1  joerg     esac
   1674  1.1  joerg 
   1675  1.1  joerg     eval _G_hook_fns=\$$1_hooks; shift
   1676  1.1  joerg 
   1677  1.1  joerg     for _G_hook in $_G_hook_fns; do
   1678  1.1  joerg       func_unset "${_G_hook}_result"
   1679  1.1  joerg       eval $_G_hook '${1+"$@"}'
   1680  1.1  joerg       func_propagate_result $_G_hook func_run_hooks
   1681  1.1  joerg       if $func_propagate_result_result; then
   1682  1.1  joerg         eval set dummy "$func_run_hooks_result"; shift
   1683  1.1  joerg       fi
   1684  1.1  joerg     done
   1685  1.1  joerg }
   1686  1.1  joerg 
   1687  1.1  joerg 
   1688  1.1  joerg 
   1689  1.1  joerg ## --------------- ##
   1690  1.1  joerg ## Option parsing. ##
   1691  1.1  joerg ## --------------- ##
   1692  1.1  joerg 
   1693  1.1  joerg # In order to add your own option parsing hooks, you must accept the
   1694  1.1  joerg # full positional parameter list from your hook function.  You may remove
   1695  1.1  joerg # or edit any options that you action, and then pass back the remaining
   1696  1.1  joerg # unprocessed options in '<hooked_function_name>_result', escaped
   1697  1.1  joerg # suitably for 'eval'.
   1698  1.1  joerg #
   1699  1.1  joerg # The '<hooked_function_name>_result' variable is automatically unset
   1700  1.1  joerg # before your hook gets called; for best performance, only set the
   1701  1.1  joerg # *_result variable when necessary (i.e. don't call the 'func_quote'
   1702  1.1  joerg # function unnecessarily because it can be an expensive operation on some
   1703  1.1  joerg # machines).
   1704  1.1  joerg #
   1705  1.1  joerg # Like this:
   1706  1.1  joerg #
   1707  1.1  joerg #    my_options_prep ()
   1708  1.1  joerg #    {
   1709  1.1  joerg #        $debug_cmd
   1710  1.1  joerg #
   1711  1.1  joerg #        # Extend the existing usage message.
   1712  1.1  joerg #        usage_message=$usage_message'
   1713  1.1  joerg #      -s, --silent       don'\''t print informational messages
   1714  1.1  joerg #    '
   1715  1.1  joerg #        # No change in '$@' (ignored completely by this hook).  Leave
   1716  1.1  joerg #        # my_options_prep_result variable intact.
   1717  1.1  joerg #    }
   1718  1.1  joerg #    func_add_hook func_options_prep my_options_prep
   1719  1.1  joerg #
   1720  1.1  joerg #
   1721  1.1  joerg #    my_silent_option ()
   1722  1.1  joerg #    {
   1723  1.1  joerg #        $debug_cmd
   1724  1.1  joerg #
   1725  1.1  joerg #        args_changed=false
   1726  1.1  joerg #
   1727  1.1  joerg #        # Note that, for efficiency, we parse as many options as we can
   1728  1.1  joerg #        # recognise in a loop before passing the remainder back to the
   1729  1.1  joerg #        # caller on the first unrecognised argument we encounter.
   1730  1.1  joerg #        while test $# -gt 0; do
   1731  1.1  joerg #          opt=$1; shift
   1732  1.1  joerg #          case $opt in
   1733  1.1  joerg #            --silent|-s) opt_silent=:
   1734  1.1  joerg #                         args_changed=:
   1735  1.1  joerg #                         ;;
   1736  1.1  joerg #            # Separate non-argument short options:
   1737  1.1  joerg #            -s*)         func_split_short_opt "$_G_opt"
   1738  1.1  joerg #                         set dummy "$func_split_short_opt_name" \
   1739  1.1  joerg #                             "-$func_split_short_opt_arg" ${1+"$@"}
   1740  1.1  joerg #                         shift
   1741  1.1  joerg #                         args_changed=:
   1742  1.1  joerg #                         ;;
   1743  1.1  joerg #            *)           # Make sure the first unrecognised option "$_G_opt"
   1744  1.1  joerg #                         # is added back to "$@" in case we need it later,
   1745  1.1  joerg #                         # if $args_changed was set to 'true'.
   1746  1.1  joerg #                         set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
   1747  1.1  joerg #          esac
   1748  1.1  joerg #        done
   1749  1.1  joerg #
   1750  1.1  joerg #        # Only call 'func_quote' here if we processed at least one argument.
   1751  1.1  joerg #        if $args_changed; then
   1752  1.1  joerg #          func_quote eval ${1+"$@"}
   1753  1.1  joerg #          my_silent_option_result=$func_quote_result
   1754  1.1  joerg #        fi
   1755  1.1  joerg #    }
   1756  1.1  joerg #    func_add_hook func_parse_options my_silent_option
   1757  1.1  joerg #
   1758  1.1  joerg #
   1759  1.1  joerg #    my_option_validation ()
   1760  1.1  joerg #    {
   1761  1.1  joerg #        $debug_cmd
   1762  1.1  joerg #
   1763  1.1  joerg #        $opt_silent && $opt_verbose && func_fatal_help "\
   1764  1.1  joerg #    '--silent' and '--verbose' options are mutually exclusive."
   1765  1.1  joerg #    }
   1766  1.1  joerg #    func_add_hook func_validate_options my_option_validation
   1767  1.1  joerg #
   1768  1.1  joerg # You'll also need to manually amend $usage_message to reflect the extra
   1769  1.1  joerg # options you parse.  It's preferable to append if you can, so that
   1770  1.1  joerg # multiple option parsing hooks can be added safely.
   1771  1.1  joerg 
   1772  1.1  joerg 
   1773  1.1  joerg # func_options_finish [ARG]...
   1774  1.1  joerg # ----------------------------
   1775  1.1  joerg # Finishing the option parse loop (call 'func_options' hooks ATM).
   1776  1.1  joerg func_options_finish ()
   1777  1.1  joerg {
   1778  1.1  joerg     $debug_cmd
   1779  1.1  joerg 
   1780  1.1  joerg     func_run_hooks func_options ${1+"$@"}
   1781  1.1  joerg     func_propagate_result func_run_hooks func_options_finish
   1782  1.1  joerg }
   1783  1.1  joerg 
   1784  1.1  joerg 
   1785  1.1  joerg # func_options [ARG]...
   1786  1.1  joerg # ---------------------
   1787  1.1  joerg # All the functions called inside func_options are hookable. See the
   1788  1.1  joerg # individual implementations for details.
   1789  1.1  joerg func_hookable func_options
   1790  1.1  joerg func_options ()
   1791  1.1  joerg {
   1792  1.1  joerg     $debug_cmd
   1793  1.1  joerg 
   1794  1.1  joerg     _G_options_quoted=false
   1795  1.1  joerg 
   1796  1.1  joerg     for my_func in options_prep parse_options validate_options options_finish
   1797  1.1  joerg     do
   1798  1.1  joerg       func_unset func_${my_func}_result
   1799  1.1  joerg       func_unset func_run_hooks_result
   1800  1.1  joerg       eval func_$my_func '${1+"$@"}'
   1801  1.1  joerg       func_propagate_result func_$my_func func_options
   1802  1.1  joerg       if $func_propagate_result_result; then
   1803  1.1  joerg         eval set dummy "$func_options_result"; shift
   1804  1.1  joerg         _G_options_quoted=:
   1805  1.1  joerg       fi
   1806  1.1  joerg     done
   1807  1.1  joerg 
   1808  1.1  joerg     $_G_options_quoted || {
   1809  1.1  joerg       # As we (func_options) are top-level options-parser function and
   1810  1.1  joerg       # nobody quoted "$@" for us yet, we need to do it explicitly for
   1811  1.1  joerg       # caller.
   1812  1.1  joerg       func_quote eval ${1+"$@"}
   1813  1.1  joerg       func_options_result=$func_quote_result
   1814  1.1  joerg     }
   1815  1.1  joerg }
   1816  1.1  joerg 
   1817  1.1  joerg 
   1818  1.1  joerg # func_options_prep [ARG]...
   1819  1.1  joerg # --------------------------
   1820  1.1  joerg # All initialisations required before starting the option parse loop.
   1821  1.1  joerg # Note that when calling hook functions, we pass through the list of
   1822  1.1  joerg # positional parameters.  If a hook function modifies that list, and
   1823  1.1  joerg # needs to propagate that back to rest of this script, then the complete
   1824  1.1  joerg # modified list must be put in 'func_run_hooks_result' before returning.
   1825  1.1  joerg func_hookable func_options_prep
   1826  1.1  joerg func_options_prep ()
   1827  1.1  joerg {
   1828  1.1  joerg     $debug_cmd
   1829  1.1  joerg 
   1830  1.1  joerg     # Option defaults:
   1831  1.1  joerg     opt_verbose=false
   1832  1.1  joerg     opt_warning_types=
   1833  1.1  joerg 
   1834  1.1  joerg     func_run_hooks func_options_prep ${1+"$@"}
   1835  1.1  joerg     func_propagate_result func_run_hooks func_options_prep
   1836  1.1  joerg }
   1837  1.1  joerg 
   1838  1.1  joerg 
   1839  1.1  joerg # func_parse_options [ARG]...
   1840  1.1  joerg # ---------------------------
   1841  1.1  joerg # The main option parsing loop.
   1842  1.1  joerg func_hookable func_parse_options
   1843  1.1  joerg func_parse_options ()
   1844  1.1  joerg {
   1845  1.1  joerg     $debug_cmd
   1846  1.1  joerg 
   1847  1.1  joerg     _G_parse_options_requote=false
   1848  1.1  joerg     # this just eases exit handling
   1849  1.1  joerg     while test $# -gt 0; do
   1850  1.1  joerg       # Defer to hook functions for initial option parsing, so they
   1851  1.1  joerg       # get priority in the event of reusing an option name.
   1852  1.1  joerg       func_run_hooks func_parse_options ${1+"$@"}
   1853  1.1  joerg       func_propagate_result func_run_hooks func_parse_options
   1854  1.1  joerg       if $func_propagate_result_result; then
   1855  1.1  joerg         eval set dummy "$func_parse_options_result"; shift
   1856  1.1  joerg         # Even though we may have changed "$@", we passed the "$@" array
   1857  1.1  joerg         # down into the hook and it quoted it for us (because we are in
   1858  1.1  joerg         # this if-branch).  No need to quote it again.
   1859  1.1  joerg         _G_parse_options_requote=false
   1860  1.1  joerg       fi
   1861  1.1  joerg 
   1862  1.1  joerg       # Break out of the loop if we already parsed every option.
   1863  1.1  joerg       test $# -gt 0 || break
   1864  1.1  joerg 
   1865  1.1  joerg       # We expect that one of the options parsed in this function matches
   1866  1.1  joerg       # and thus we remove _G_opt from "$@" and need to re-quote.
   1867  1.1  joerg       _G_match_parse_options=:
   1868  1.1  joerg       _G_opt=$1
   1869  1.1  joerg       shift
   1870  1.1  joerg       case $_G_opt in
   1871  1.1  joerg         --debug|-x)   debug_cmd='set -x'
   1872  1.1  joerg                       func_echo "enabling shell trace mode" >&2
   1873  1.1  joerg                       $debug_cmd
   1874  1.1  joerg                       ;;
   1875  1.1  joerg 
   1876  1.1  joerg         --no-warnings|--no-warning|--no-warn)
   1877  1.1  joerg                       set dummy --warnings none ${1+"$@"}
   1878  1.1  joerg                       shift
   1879  1.1  joerg 		      ;;
   1880  1.1  joerg 
   1881  1.1  joerg         --warnings|--warning|-W)
   1882  1.1  joerg                       if test $# = 0 && func_missing_arg $_G_opt; then
   1883  1.1  joerg                         _G_parse_options_requote=:
   1884  1.1  joerg                         break
   1885  1.1  joerg                       fi
   1886  1.1  joerg                       case " $warning_categories $1" in
   1887  1.1  joerg                         *" $1 "*)
   1888  1.1  joerg                           # trailing space prevents matching last $1 above
   1889  1.1  joerg                           func_append_uniq opt_warning_types " $1"
   1890  1.1  joerg                           ;;
   1891  1.1  joerg                         *all)
   1892  1.1  joerg                           opt_warning_types=$warning_categories
   1893  1.1  joerg                           ;;
   1894  1.1  joerg                         *none)
   1895  1.1  joerg                           opt_warning_types=none
   1896  1.1  joerg                           warning_func=:
   1897  1.1  joerg                           ;;
   1898  1.1  joerg                         *error)
   1899  1.1  joerg                           opt_warning_types=$warning_categories
   1900  1.1  joerg                           warning_func=func_fatal_error
   1901  1.1  joerg                           ;;
   1902  1.1  joerg                         *)
   1903  1.1  joerg                           func_fatal_error \
   1904  1.1  joerg                              "unsupported warning category: '$1'"
   1905  1.1  joerg                           ;;
   1906  1.1  joerg                       esac
   1907  1.1  joerg                       shift
   1908  1.1  joerg                       ;;
   1909  1.1  joerg 
   1910  1.1  joerg         --verbose|-v) opt_verbose=: ;;
   1911  1.1  joerg         --version)    func_version ;;
   1912  1.1  joerg         -\?|-h)       func_usage ;;
   1913  1.1  joerg         --help)       func_help ;;
   1914  1.1  joerg 
   1915  1.1  joerg 	# Separate optargs to long options (plugins may need this):
   1916  1.1  joerg 	--*=*)        func_split_equals "$_G_opt"
   1917  1.1  joerg 	              set dummy "$func_split_equals_lhs" \
   1918  1.1  joerg                           "$func_split_equals_rhs" ${1+"$@"}
   1919  1.1  joerg                       shift
   1920  1.1  joerg                       ;;
   1921  1.1  joerg 
   1922  1.1  joerg        # Separate optargs to short options:
   1923  1.1  joerg         -W*)
   1924  1.1  joerg                       func_split_short_opt "$_G_opt"
   1925  1.1  joerg                       set dummy "$func_split_short_opt_name" \
   1926  1.1  joerg                           "$func_split_short_opt_arg" ${1+"$@"}
   1927  1.1  joerg                       shift
   1928  1.1  joerg                       ;;
   1929  1.1  joerg 
   1930  1.1  joerg         # Separate non-argument short options:
   1931  1.1  joerg         -\?*|-h*|-v*|-x*)
   1932  1.1  joerg                       func_split_short_opt "$_G_opt"
   1933  1.1  joerg                       set dummy "$func_split_short_opt_name" \
   1934  1.1  joerg                           "-$func_split_short_opt_arg" ${1+"$@"}
   1935  1.1  joerg                       shift
   1936  1.1  joerg                       ;;
   1937  1.1  joerg 
   1938  1.1  joerg         --)           _G_parse_options_requote=: ; break ;;
   1939  1.1  joerg         -*)           func_fatal_help "unrecognised option: '$_G_opt'" ;;
   1940  1.1  joerg         *)            set dummy "$_G_opt" ${1+"$@"}; shift
   1941  1.1  joerg                       _G_match_parse_options=false
   1942  1.1  joerg                       break
   1943  1.1  joerg                       ;;
   1944  1.1  joerg       esac
   1945  1.1  joerg 
   1946  1.1  joerg       if $_G_match_parse_options; then
   1947  1.1  joerg         _G_parse_options_requote=:
   1948  1.1  joerg       fi
   1949  1.1  joerg     done
   1950  1.1  joerg 
   1951  1.1  joerg     if $_G_parse_options_requote; then
   1952  1.1  joerg       # save modified positional parameters for caller
   1953  1.1  joerg       func_quote eval ${1+"$@"}
   1954  1.1  joerg       func_parse_options_result=$func_quote_result
   1955  1.1  joerg     fi
   1956  1.1  joerg }
   1957  1.1  joerg 
   1958  1.1  joerg 
   1959  1.1  joerg # func_validate_options [ARG]...
   1960  1.1  joerg # ------------------------------
   1961  1.1  joerg # Perform any sanity checks on option settings and/or unconsumed
   1962  1.1  joerg # arguments.
   1963  1.1  joerg func_hookable func_validate_options
   1964  1.1  joerg func_validate_options ()
   1965  1.1  joerg {
   1966  1.1  joerg     $debug_cmd
   1967  1.1  joerg 
   1968  1.1  joerg     # Display all warnings if -W was not given.
   1969  1.1  joerg     test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
   1970  1.1  joerg 
   1971  1.1  joerg     func_run_hooks func_validate_options ${1+"$@"}
   1972  1.1  joerg     func_propagate_result func_run_hooks func_validate_options
   1973  1.1  joerg 
   1974  1.1  joerg     # Bail if the options were screwed!
   1975  1.1  joerg     $exit_cmd $EXIT_FAILURE
   1976  1.1  joerg }
   1977  1.1  joerg 
   1978  1.1  joerg 
   1979  1.1  joerg 
   1980  1.1  joerg ## ----------------- ##
   1981  1.1  joerg ## Helper functions. ##
   1982  1.1  joerg ## ----------------- ##
   1983  1.1  joerg 
   1984  1.1  joerg # This section contains the helper functions used by the rest of the
   1985  1.1  joerg # hookable option parser framework in ascii-betical order.
   1986  1.1  joerg 
   1987  1.1  joerg 
   1988  1.1  joerg # func_fatal_help ARG...
   1989  1.1  joerg # ----------------------
   1990  1.1  joerg # Echo program name prefixed message to standard error, followed by
   1991  1.1  joerg # a help hint, and exit.
   1992  1.1  joerg func_fatal_help ()
   1993  1.1  joerg {
   1994  1.1  joerg     $debug_cmd
   1995  1.1  joerg 
   1996  1.1  joerg     eval \$ECHO \""Usage: $usage"\"
   1997  1.1  joerg     eval \$ECHO \""$fatal_help"\"
   1998  1.1  joerg     func_error ${1+"$@"}
   1999  1.1  joerg     exit $EXIT_FAILURE
   2000  1.1  joerg }
   2001  1.1  joerg 
   2002  1.1  joerg 
   2003  1.1  joerg # func_help
   2004  1.1  joerg # ---------
   2005  1.1  joerg # Echo long help message to standard output and exit.
   2006  1.1  joerg func_help ()
   2007  1.1  joerg {
   2008  1.1  joerg     $debug_cmd
   2009  1.1  joerg 
   2010  1.1  joerg     func_usage_message
   2011  1.1  joerg     $ECHO "$long_help_message"
   2012  1.1  joerg     exit 0
   2013  1.1  joerg }
   2014  1.1  joerg 
   2015  1.1  joerg 
   2016  1.1  joerg # func_missing_arg ARGNAME
   2017  1.1  joerg # ------------------------
   2018  1.1  joerg # Echo program name prefixed message to standard error and set global
   2019  1.1  joerg # exit_cmd.
   2020  1.1  joerg func_missing_arg ()
   2021  1.1  joerg {
   2022  1.1  joerg     $debug_cmd
   2023  1.1  joerg 
   2024  1.1  joerg     func_error "Missing argument for '$1'."
   2025  1.1  joerg     exit_cmd=exit
   2026  1.1  joerg }
   2027  1.1  joerg 
   2028  1.1  joerg 
   2029  1.1  joerg # func_split_equals STRING
   2030  1.1  joerg # ------------------------
   2031  1.1  joerg # Set func_split_equals_lhs and func_split_equals_rhs shell variables
   2032  1.1  joerg # after splitting STRING at the '=' sign.
   2033  1.1  joerg test -z "$_G_HAVE_XSI_OPS" \
   2034  1.1  joerg     && (eval 'x=a/b/c;
   2035  1.1  joerg       test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
   2036  1.1  joerg     && _G_HAVE_XSI_OPS=yes
   2037  1.1  joerg 
   2038  1.1  joerg if test yes = "$_G_HAVE_XSI_OPS"
   2039  1.1  joerg then
   2040  1.1  joerg   # This is an XSI compatible shell, allowing a faster implementation...
   2041  1.1  joerg   eval 'func_split_equals ()
   2042  1.1  joerg   {
   2043  1.1  joerg       $debug_cmd
   2044  1.1  joerg 
   2045  1.1  joerg       func_split_equals_lhs=${1%%=*}
   2046  1.1  joerg       func_split_equals_rhs=${1#*=}
   2047  1.1  joerg       if test "x$func_split_equals_lhs" = "x$1"; then
   2048  1.1  joerg         func_split_equals_rhs=
   2049  1.1  joerg       fi
   2050  1.1  joerg   }'
   2051  1.1  joerg else
   2052  1.1  joerg   # ...otherwise fall back to using expr, which is often a shell builtin.
   2053  1.1  joerg   func_split_equals ()
   2054  1.1  joerg   {
   2055  1.1  joerg       $debug_cmd
   2056  1.1  joerg 
   2057  1.1  joerg       func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
   2058  1.1  joerg       func_split_equals_rhs=
   2059  1.1  joerg       test "x$func_split_equals_lhs" = "x$1" \
   2060  1.1  joerg         || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
   2061  1.1  joerg   }
   2062  1.1  joerg fi #func_split_equals
   2063  1.1  joerg 
   2064  1.1  joerg 
   2065  1.1  joerg # func_split_short_opt SHORTOPT
   2066  1.1  joerg # -----------------------------
   2067  1.1  joerg # Set func_split_short_opt_name and func_split_short_opt_arg shell
   2068  1.1  joerg # variables after splitting SHORTOPT after the 2nd character.
   2069  1.1  joerg if test yes = "$_G_HAVE_XSI_OPS"
   2070  1.1  joerg then
   2071  1.1  joerg   # This is an XSI compatible shell, allowing a faster implementation...
   2072  1.1  joerg   eval 'func_split_short_opt ()
   2073  1.1  joerg   {
   2074  1.1  joerg       $debug_cmd
   2075  1.1  joerg 
   2076  1.1  joerg       func_split_short_opt_arg=${1#??}
   2077  1.1  joerg       func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
   2078  1.1  joerg   }'
   2079  1.1  joerg else
   2080  1.1  joerg   # ...otherwise fall back to using expr, which is often a shell builtin.
   2081  1.1  joerg   func_split_short_opt ()
   2082  1.1  joerg   {
   2083  1.1  joerg       $debug_cmd
   2084  1.1  joerg 
   2085  1.1  joerg       func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
   2086  1.1  joerg       func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
   2087  1.1  joerg   }
   2088  1.1  joerg fi #func_split_short_opt
   2089  1.1  joerg 
   2090  1.1  joerg 
   2091  1.1  joerg # func_usage
   2092  1.1  joerg # ----------
   2093  1.1  joerg # Echo short help message to standard output and exit.
   2094  1.1  joerg func_usage ()
   2095  1.1  joerg {
   2096  1.1  joerg     $debug_cmd
   2097  1.1  joerg 
   2098  1.1  joerg     func_usage_message
   2099  1.1  joerg     $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
   2100  1.1  joerg     exit 0
   2101  1.1  joerg }
   2102  1.1  joerg 
   2103  1.1  joerg 
   2104  1.1  joerg # func_usage_message
   2105  1.1  joerg # ------------------
   2106  1.1  joerg # Echo short help message to standard output.
   2107  1.1  joerg func_usage_message ()
   2108  1.1  joerg {
   2109  1.1  joerg     $debug_cmd
   2110  1.1  joerg 
   2111  1.1  joerg     eval \$ECHO \""Usage: $usage"\"
   2112  1.1  joerg     echo
   2113  1.1  joerg     $SED -n 's|^# ||
   2114  1.1  joerg         /^Written by/{
   2115  1.1  joerg           x;p;x
   2116  1.1  joerg         }
   2117  1.1  joerg 	h
   2118  1.1  joerg 	/^Written by/q' < "$progpath"
   2119  1.1  joerg     echo
   2120  1.1  joerg     eval \$ECHO \""$usage_message"\"
   2121  1.1  joerg }
   2122  1.1  joerg 
   2123  1.1  joerg 
   2124  1.1  joerg # func_version
   2125  1.1  joerg # ------------
   2126  1.1  joerg # Echo version message to standard output and exit.
   2127  1.1  joerg # The version message is extracted from the calling file's header
   2128  1.1  joerg # comments, with leading '# ' stripped:
   2129  1.1  joerg #   1. First display the progname and version
   2130  1.1  joerg #   2. Followed by the header comment line matching  /^# Written by /
   2131  1.1  joerg #   3. Then a blank line followed by the first following line matching
   2132  1.1  joerg #      /^# Copyright /
   2133  1.1  joerg #   4. Immediately followed by any lines between the previous matches,
   2134  1.1  joerg #      except lines preceding the intervening completely blank line.
   2135  1.1  joerg # For example, see the header comments of this file.
   2136  1.1  joerg func_version ()
   2137  1.1  joerg {
   2138  1.1  joerg     $debug_cmd
   2139  1.1  joerg 
   2140  1.1  joerg     printf '%s\n' "$progname $scriptversion"
   2141  1.1  joerg     $SED -n '
   2142  1.1  joerg         /^# Written by /!b
   2143  1.1  joerg         s|^# ||; p; n
   2144  1.1  joerg 
   2145  1.1  joerg         :fwd2blnk
   2146  1.1  joerg         /./ {
   2147  1.1  joerg           n
   2148  1.1  joerg           b fwd2blnk
   2149  1.1  joerg         }
   2150  1.1  joerg         p; n
   2151  1.1  joerg 
   2152  1.1  joerg         :holdwrnt
   2153  1.1  joerg         s|^# ||
   2154  1.1  joerg         s|^# *$||
   2155  1.1  joerg         /^Copyright /!{
   2156  1.1  joerg           /./H
   2157  1.1  joerg           n
   2158  1.1  joerg           b holdwrnt
   2159  1.1  joerg         }
   2160  1.1  joerg 
   2161  1.1  joerg         s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
   2162  1.1  joerg         G
   2163  1.1  joerg         s|\(\n\)\n*|\1|g
   2164  1.1  joerg         p; q' < "$progpath"
   2165  1.1  joerg 
   2166  1.1  joerg     exit $?
   2167  1.1  joerg }
   2168  1.1  joerg 
   2169  1.1  joerg 
   2170  1.1  joerg # Local variables:
   2171  1.1  joerg # mode: shell-script
   2172  1.1  joerg # sh-indentation: 2
   2173  1.1  joerg # eval: (add-hook 'before-save-hook 'time-stamp)
   2174  1.1  joerg # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
   2175  1.1  joerg # time-stamp-time-zone: "UTC"
   2176  1.1  joerg # End:
   2177  1.1  joerg 
   2178  1.1  joerg # Set a version string.
   2179  1.1  joerg scriptversion='(GNU libtool) 2.4.6.40-6ca5-dirty'
   2180  1.1  joerg 
   2181  1.1  joerg 
   2182  1.1  joerg # func_echo ARG...
   2183  1.1  joerg # ----------------
   2184  1.1  joerg # Libtool also displays the current mode in messages, so override
   2185  1.1  joerg # funclib.sh func_echo with this custom definition.
   2186  1.1  joerg func_echo ()
   2187  1.1  joerg {
   2188  1.1  joerg     $debug_cmd
   2189  1.1  joerg 
   2190  1.1  joerg     _G_message=$*
   2191  1.1  joerg 
   2192  1.1  joerg     func_echo_IFS=$IFS
   2193  1.1  joerg     IFS=$nl
   2194  1.1  joerg     for _G_line in $_G_message; do
   2195  1.1  joerg       IFS=$func_echo_IFS
   2196  1.1  joerg       $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
   2197  1.1  joerg     done
   2198  1.1  joerg     IFS=$func_echo_IFS
   2199  1.1  joerg }
   2200  1.1  joerg 
   2201  1.1  joerg 
   2202  1.1  joerg # func_warning ARG...
   2203  1.1  joerg # -------------------
   2204  1.1  joerg # Libtool warnings are not categorized, so override funclib.sh
   2205  1.1  joerg # func_warning with this simpler definition.
   2206  1.1  joerg func_warning ()
   2207  1.1  joerg {
   2208  1.1  joerg     $debug_cmd
   2209  1.1  joerg 
   2210  1.1  joerg     $warning_func ${1+"$@"}
   2211  1.1  joerg }
   2212  1.1  joerg 
   2213  1.1  joerg 
   2214  1.1  joerg ## ---------------- ##
   2215  1.1  joerg ## Options parsing. ##
   2216  1.1  joerg ## ---------------- ##
   2217  1.1  joerg 
   2218  1.1  joerg # Hook in the functions to make sure our own options are parsed during
   2219  1.1  joerg # the option parsing loop.
   2220  1.1  joerg 
   2221  1.1  joerg usage='$progpath [OPTION]... [MODE-ARG]...'
   2222  1.1  joerg 
   2223  1.1  joerg # Short help message in response to '-h'.
   2224  1.1  joerg usage_message="Options:
   2225  1.1  joerg        --config             show all configuration variables
   2226  1.1  joerg        --debug              enable verbose shell tracing
   2227  1.1  joerg    -n, --dry-run            display commands without modifying any files
   2228  1.1  joerg        --features           display basic configuration information and exit
   2229  1.1  joerg        --mode=MODE          use operation mode MODE
   2230  1.1  joerg        --no-warnings        equivalent to '-Wnone'
   2231  1.1  joerg        --preserve-dup-deps  don't remove duplicate dependency libraries
   2232  1.1  joerg        --quiet, --silent    don't print informational messages
   2233  1.1  joerg        --tag=TAG            use configuration variables from tag TAG
   2234  1.1  joerg    -v, --verbose            print more informational messages than default
   2235  1.1  joerg        --version            print version information
   2236  1.1  joerg    -W, --warnings=CATEGORY  report the warnings falling in CATEGORY [all]
   2237  1.1  joerg    -h, --help, --help-all   print short, long, or detailed help message
   2238  1.1  joerg "
   2239  1.1  joerg 
   2240  1.1  joerg # Additional text appended to 'usage_message' in response to '--help'.
   2241  1.1  joerg func_help ()
   2242  1.1  joerg {
   2243  1.1  joerg     $debug_cmd
   2244  1.1  joerg 
   2245  1.1  joerg     func_usage_message
   2246  1.1  joerg     $ECHO "$long_help_message
   2247  1.1  joerg 
   2248  1.1  joerg MODE must be one of the following:
   2249  1.1  joerg 
   2250  1.1  joerg        clean           remove files from the build directory
   2251  1.1  joerg        compile         compile a source file into a libtool object
   2252  1.1  joerg        execute         automatically set library path, then run a program
   2253  1.1  joerg        finish          complete the installation of libtool libraries
   2254  1.1  joerg        install         install libraries or executables
   2255  1.1  joerg        link            create a library or an executable
   2256  1.1  joerg        uninstall       remove libraries from an installed directory
   2257  1.1  joerg 
   2258  1.1  joerg MODE-ARGS vary depending on the MODE.  When passed as first option,
   2259  1.1  joerg '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
   2260  1.1  joerg Try '$progname --help --mode=MODE' for a more detailed description of MODE.
   2261  1.1  joerg 
   2262  1.1  joerg When reporting a bug, please describe a test case to reproduce it and
   2263  1.1  joerg include the following information:
   2264  1.1  joerg 
   2265  1.1  joerg        host-triplet:   $host
   2266  1.1  joerg        shell:          $SHELL
   2267  1.1  joerg        compiler:       $LTCC
   2268  1.1  joerg        compiler flags: $LTCFLAGS
   2269  1.1  joerg        linker:         $LD (gnu? $with_gnu_ld)
   2270  1.1  joerg        version:        $progname (GNU libtool) 2.4.6.40-6ca5-dirty
   2271  1.1  joerg        automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
   2272  1.1  joerg        autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
   2273  1.1  joerg 
   2274  1.1  joerg Report bugs to <bug-libtool (at] gnu.org>.
   2275  1.1  joerg GNU libtool home page: <http://www.gnu.org/s/libtool/>.
   2276  1.1  joerg General help using GNU software: <http://www.gnu.org/gethelp/>."
   2277  1.1  joerg     exit 0
   2278  1.1  joerg }
   2279  1.1  joerg 
   2280  1.1  joerg 
   2281  1.1  joerg # func_lo2o OBJECT-NAME
   2282  1.1  joerg # ---------------------
   2283  1.1  joerg # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
   2284  1.1  joerg # object suffix.
   2285  1.1  joerg 
   2286  1.1  joerg lo2o=s/\\.lo\$/.$objext/
   2287  1.1  joerg o2lo=s/\\.$objext\$/.lo/
   2288  1.1  joerg 
   2289  1.1  joerg if test yes = "$_G_HAVE_XSI_OPS"; then
   2290  1.1  joerg   eval 'func_lo2o ()
   2291  1.1  joerg   {
   2292  1.1  joerg     case $1 in
   2293  1.1  joerg       *.lo) func_lo2o_result=${1%.lo}.$objext ;;
   2294  1.1  joerg       *   ) func_lo2o_result=$1               ;;
   2295  1.1  joerg     esac
   2296  1.1  joerg   }'
   2297  1.1  joerg 
   2298  1.1  joerg   # func_xform LIBOBJ-OR-SOURCE
   2299  1.1  joerg   # ---------------------------
   2300  1.1  joerg   # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
   2301  1.1  joerg   # suffix to a '.lo' libtool-object suffix.
   2302  1.1  joerg   eval 'func_xform ()
   2303  1.1  joerg   {
   2304  1.1  joerg     func_xform_result=${1%.*}.lo
   2305  1.1  joerg   }'
   2306  1.1  joerg else
   2307  1.1  joerg   # ...otherwise fall back to using sed.
   2308  1.1  joerg   func_lo2o ()
   2309  1.1  joerg   {
   2310  1.1  joerg     func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
   2311  1.1  joerg   }
   2312  1.1  joerg 
   2313  1.1  joerg   func_xform ()
   2314  1.1  joerg   {
   2315  1.1  joerg     func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
   2316  1.1  joerg   }
   2317  1.1  joerg fi
   2318  1.1  joerg 
   2319  1.1  joerg 
   2320  1.1  joerg # func_fatal_configuration ARG...
   2321  1.1  joerg # -------------------------------
   2322  1.1  joerg # Echo program name prefixed message to standard error, followed by
   2323  1.1  joerg # a configuration failure hint, and exit.
   2324  1.1  joerg func_fatal_configuration ()
   2325  1.1  joerg {
   2326  1.1  joerg     func_fatal_error ${1+"$@"} \
   2327  1.1  joerg       "See the $PACKAGE documentation for more information." \
   2328  1.1  joerg       "Fatal configuration error."
   2329  1.1  joerg }
   2330  1.1  joerg 
   2331  1.1  joerg 
   2332  1.1  joerg # func_config
   2333  1.1  joerg # -----------
   2334  1.1  joerg # Display the configuration for all the tags in this script.
   2335  1.1  joerg func_config ()
   2336  1.1  joerg {
   2337  1.1  joerg     re_begincf='^# ### BEGIN LIBTOOL'
   2338  1.1  joerg     re_endcf='^# ### END LIBTOOL'
   2339  1.1  joerg 
   2340  1.1  joerg     # Default configuration.
   2341  1.1  joerg     $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
   2342  1.1  joerg 
   2343  1.1  joerg     # Now print the configurations for the tags.
   2344  1.1  joerg     for tagname in $taglist; do
   2345  1.1  joerg       $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
   2346  1.1  joerg     done
   2347  1.1  joerg 
   2348  1.1  joerg     exit $?
   2349  1.1  joerg }
   2350  1.1  joerg 
   2351  1.1  joerg 
   2352  1.1  joerg # func_features
   2353  1.1  joerg # -------------
   2354  1.1  joerg # Display the features supported by this script.
   2355  1.1  joerg func_features ()
   2356  1.1  joerg {
   2357  1.1  joerg     echo "host: $host"
   2358  1.1  joerg     if test yes = "$build_libtool_libs"; then
   2359  1.1  joerg       echo "enable shared libraries"
   2360  1.1  joerg     else
   2361  1.1  joerg       echo "disable shared libraries"
   2362  1.1  joerg     fi
   2363  1.1  joerg     if test yes = "$build_old_libs"; then
   2364  1.1  joerg       echo "enable static libraries"
   2365  1.1  joerg     else
   2366  1.1  joerg       echo "disable static libraries"
   2367  1.1  joerg     fi
   2368  1.1  joerg 
   2369  1.1  joerg     exit $?
   2370  1.1  joerg }
   2371  1.1  joerg 
   2372  1.1  joerg 
   2373  1.1  joerg # func_enable_tag TAGNAME
   2374  1.1  joerg # -----------------------
   2375  1.1  joerg # Verify that TAGNAME is valid, and either flag an error and exit, or
   2376  1.1  joerg # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
   2377  1.1  joerg # variable here.
   2378  1.1  joerg func_enable_tag ()
   2379  1.1  joerg {
   2380  1.1  joerg     # Global variable:
   2381  1.1  joerg     tagname=$1
   2382  1.1  joerg 
   2383  1.1  joerg     re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
   2384  1.1  joerg     re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
   2385  1.1  joerg     sed_extractcf=/$re_begincf/,/$re_endcf/p
   2386  1.1  joerg 
   2387  1.1  joerg     # Validate tagname.
   2388  1.1  joerg     case $tagname in
   2389  1.1  joerg       *[!-_A-Za-z0-9,/]*)
   2390  1.1  joerg         func_fatal_error "invalid tag name: $tagname"
   2391  1.1  joerg         ;;
   2392  1.1  joerg     esac
   2393  1.1  joerg 
   2394  1.1  joerg     # Don't test for the "default" C tag, as we know it's
   2395  1.1  joerg     # there but not specially marked.
   2396  1.1  joerg     case $tagname in
   2397  1.1  joerg         CC) ;;
   2398  1.1  joerg     *)
   2399  1.1  joerg         if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
   2400  1.1  joerg 	  taglist="$taglist $tagname"
   2401  1.1  joerg 
   2402  1.1  joerg 	  # Evaluate the configuration.  Be careful to quote the path
   2403  1.1  joerg 	  # and the sed script, to avoid splitting on whitespace, but
   2404  1.1  joerg 	  # also don't use non-portable quotes within backquotes within
   2405  1.1  joerg 	  # quotes we have to do it in 2 steps:
   2406  1.1  joerg 	  extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
   2407  1.1  joerg 	  eval "$extractedcf"
   2408  1.1  joerg         else
   2409  1.1  joerg 	  func_error "ignoring unknown tag $tagname"
   2410  1.1  joerg         fi
   2411  1.1  joerg         ;;
   2412  1.1  joerg     esac
   2413  1.1  joerg }
   2414  1.1  joerg 
   2415  1.1  joerg 
   2416  1.1  joerg # func_check_version_match
   2417  1.1  joerg # ------------------------
   2418  1.1  joerg # Ensure that we are using m4 macros, and libtool script from the same
   2419  1.1  joerg # release of libtool.
   2420  1.1  joerg func_check_version_match ()
   2421  1.1  joerg {
   2422  1.1  joerg     if test "$package_revision" != "$macro_revision"; then
   2423  1.1  joerg       if test "$VERSION" != "$macro_version"; then
   2424  1.1  joerg         if test -z "$macro_version"; then
   2425  1.1  joerg           cat >&2 <<_LT_EOF
   2426  1.1  joerg $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
   2427  1.1  joerg $progname: definition of this LT_INIT comes from an older release.
   2428  1.1  joerg $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
   2429  1.1  joerg $progname: and run autoconf again.
   2430  1.1  joerg _LT_EOF
   2431  1.1  joerg         else
   2432  1.1  joerg           cat >&2 <<_LT_EOF
   2433  1.1  joerg $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
   2434  1.1  joerg $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
   2435  1.1  joerg $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
   2436  1.1  joerg $progname: and run autoconf again.
   2437  1.1  joerg _LT_EOF
   2438  1.1  joerg         fi
   2439  1.1  joerg       else
   2440  1.1  joerg         cat >&2 <<_LT_EOF
   2441  1.1  joerg $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
   2442  1.1  joerg $progname: but the definition of this LT_INIT comes from revision $macro_revision.
   2443  1.1  joerg $progname: You should recreate aclocal.m4 with macros from revision $package_revision
   2444  1.1  joerg $progname: of $PACKAGE $VERSION and run autoconf again.
   2445  1.1  joerg _LT_EOF
   2446  1.1  joerg       fi
   2447  1.1  joerg 
   2448  1.1  joerg       exit $EXIT_MISMATCH
   2449  1.1  joerg     fi
   2450  1.1  joerg }
   2451  1.1  joerg 
   2452  1.1  joerg 
   2453  1.1  joerg # libtool_options_prep [ARG]...
   2454  1.1  joerg # -----------------------------
   2455  1.1  joerg # Preparation for options parsed by libtool.
   2456  1.1  joerg libtool_options_prep ()
   2457  1.1  joerg {
   2458  1.1  joerg     $debug_mode
   2459  1.1  joerg 
   2460  1.1  joerg     # Option defaults:
   2461  1.1  joerg     opt_config=false
   2462  1.1  joerg     opt_dlopen=
   2463  1.1  joerg     opt_dry_run=false
   2464  1.1  joerg     opt_help=false
   2465  1.1  joerg     opt_mode=
   2466  1.1  joerg     opt_preserve_dup_deps=false
   2467  1.1  joerg     opt_quiet=false
   2468  1.1  joerg 
   2469  1.1  joerg     nonopt=
   2470  1.1  joerg     preserve_args=
   2471  1.1  joerg 
   2472  1.1  joerg     _G_rc_lt_options_prep=:
   2473  1.1  joerg 
   2474  1.1  joerg     # Shorthand for --mode=foo, only valid as the first argument
   2475  1.1  joerg     case $1 in
   2476  1.1  joerg     clean|clea|cle|cl)
   2477  1.1  joerg       shift; set dummy --mode clean ${1+"$@"}; shift
   2478  1.1  joerg       ;;
   2479  1.1  joerg     compile|compil|compi|comp|com|co|c)
   2480  1.1  joerg       shift; set dummy --mode compile ${1+"$@"}; shift
   2481  1.1  joerg       ;;
   2482  1.1  joerg     execute|execut|execu|exec|exe|ex|e)
   2483  1.1  joerg       shift; set dummy --mode execute ${1+"$@"}; shift
   2484  1.1  joerg       ;;
   2485  1.1  joerg     finish|finis|fini|fin|fi|f)
   2486  1.1  joerg       shift; set dummy --mode finish ${1+"$@"}; shift
   2487  1.1  joerg       ;;
   2488  1.1  joerg     install|instal|insta|inst|ins|in|i)
   2489  1.1  joerg       shift; set dummy --mode install ${1+"$@"}; shift
   2490  1.1  joerg       ;;
   2491  1.1  joerg     link|lin|li|l)
   2492  1.1  joerg       shift; set dummy --mode link ${1+"$@"}; shift
   2493  1.1  joerg       ;;
   2494  1.1  joerg     uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
   2495  1.1  joerg       shift; set dummy --mode uninstall ${1+"$@"}; shift
   2496  1.1  joerg       ;;
   2497  1.1  joerg     *)
   2498  1.1  joerg       _G_rc_lt_options_prep=false
   2499  1.1  joerg       ;;
   2500  1.1  joerg     esac
   2501  1.1  joerg 
   2502  1.1  joerg     if $_G_rc_lt_options_prep; then
   2503  1.1  joerg       # Pass back the list of options.
   2504  1.1  joerg       func_quote eval ${1+"$@"}
   2505  1.1  joerg       libtool_options_prep_result=$func_quote_result
   2506  1.1  joerg     fi
   2507  1.1  joerg }
   2508  1.1  joerg func_add_hook func_options_prep libtool_options_prep
   2509  1.1  joerg 
   2510  1.1  joerg 
   2511  1.1  joerg # libtool_parse_options [ARG]...
   2512  1.1  joerg # ---------------------------------
   2513  1.1  joerg # Provide handling for libtool specific options.
   2514  1.1  joerg libtool_parse_options ()
   2515  1.1  joerg {
   2516  1.1  joerg     $debug_cmd
   2517  1.1  joerg 
   2518  1.1  joerg     _G_rc_lt_parse_options=false
   2519  1.1  joerg 
   2520  1.1  joerg     # Perform our own loop to consume as many options as possible in
   2521  1.1  joerg     # each iteration.
   2522  1.1  joerg     while test $# -gt 0; do
   2523  1.1  joerg       _G_match_lt_parse_options=:
   2524  1.1  joerg       _G_opt=$1
   2525  1.1  joerg       shift
   2526  1.1  joerg       case $_G_opt in
   2527  1.1  joerg         --dry-run|--dryrun|-n)
   2528  1.1  joerg                         opt_dry_run=:
   2529  1.1  joerg                         ;;
   2530  1.1  joerg 
   2531  1.1  joerg         --config)       func_config ;;
   2532  1.1  joerg 
   2533  1.1  joerg         --dlopen|-dlopen)
   2534  1.1  joerg                         opt_dlopen="${opt_dlopen+$opt_dlopen
   2535  1.1  joerg }$1"
   2536  1.1  joerg                         shift
   2537  1.1  joerg                         ;;
   2538  1.1  joerg 
   2539  1.1  joerg         --preserve-dup-deps)
   2540  1.1  joerg                         opt_preserve_dup_deps=: ;;
   2541  1.1  joerg 
   2542  1.1  joerg         --features)     func_features ;;
   2543  1.1  joerg 
   2544  1.1  joerg         --finish)       set dummy --mode finish ${1+"$@"}; shift ;;
   2545  1.1  joerg 
   2546  1.1  joerg         --help)         opt_help=: ;;
   2547  1.1  joerg 
   2548  1.1  joerg         --help-all)     opt_help=': help-all' ;;
   2549  1.1  joerg 
   2550  1.1  joerg         --mode)         test $# = 0 && func_missing_arg $_G_opt && break
   2551  1.1  joerg                         opt_mode=$1
   2552  1.1  joerg                         case $1 in
   2553  1.1  joerg                           # Valid mode arguments:
   2554  1.1  joerg                           clean|compile|execute|finish|install|link|relink|uninstall) ;;
   2555  1.1  joerg 
   2556  1.1  joerg                           # Catch anything else as an error
   2557  1.1  joerg                           *) func_error "invalid argument for $_G_opt"
   2558  1.1  joerg                              exit_cmd=exit
   2559  1.1  joerg                              break
   2560  1.1  joerg                              ;;
   2561  1.1  joerg                         esac
   2562  1.1  joerg                         shift
   2563  1.1  joerg                         ;;
   2564  1.1  joerg 
   2565  1.1  joerg         --no-silent|--no-quiet)
   2566  1.1  joerg                         opt_quiet=false
   2567  1.1  joerg                         func_append preserve_args " $_G_opt"
   2568  1.1  joerg                         ;;
   2569  1.1  joerg 
   2570  1.1  joerg         --no-warnings|--no-warning|--no-warn)
   2571  1.1  joerg                         opt_warning=false
   2572  1.1  joerg                         func_append preserve_args " $_G_opt"
   2573  1.1  joerg                         ;;
   2574  1.1  joerg 
   2575  1.1  joerg         --no-verbose)
   2576  1.1  joerg                         opt_verbose=false
   2577  1.1  joerg                         func_append preserve_args " $_G_opt"
   2578  1.1  joerg                         ;;
   2579  1.1  joerg 
   2580  1.1  joerg         --silent|--quiet)
   2581  1.1  joerg                         opt_quiet=:
   2582  1.1  joerg                         opt_verbose=false
   2583  1.1  joerg                         func_append preserve_args " $_G_opt"
   2584  1.1  joerg                         ;;
   2585  1.1  joerg 
   2586  1.1  joerg         --tag)          test $# = 0 && func_missing_arg $_G_opt && break
   2587  1.1  joerg                         opt_tag=$1
   2588  1.1  joerg                         func_append preserve_args " $_G_opt $1"
   2589  1.1  joerg                         func_enable_tag "$1"
   2590  1.1  joerg                         shift
   2591  1.1  joerg                         ;;
   2592  1.1  joerg 
   2593  1.1  joerg         --verbose|-v)   opt_quiet=false
   2594  1.1  joerg                         opt_verbose=:
   2595  1.1  joerg                         func_append preserve_args " $_G_opt"
   2596  1.1  joerg                         ;;
   2597  1.1  joerg 
   2598  1.1  joerg         # An option not handled by this hook function:
   2599  1.1  joerg         *)              set dummy "$_G_opt" ${1+"$@"} ; shift
   2600  1.1  joerg                         _G_match_lt_parse_options=false
   2601  1.1  joerg                         break
   2602  1.1  joerg                         ;;
   2603  1.1  joerg       esac
   2604  1.1  joerg       $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
   2605  1.1  joerg     done
   2606  1.1  joerg 
   2607  1.1  joerg     if $_G_rc_lt_parse_options; then
   2608  1.1  joerg       # save modified positional parameters for caller
   2609  1.1  joerg       func_quote eval ${1+"$@"}
   2610  1.1  joerg       libtool_parse_options_result=$func_quote_result
   2611  1.1  joerg     fi
   2612  1.1  joerg }
   2613  1.1  joerg func_add_hook func_parse_options libtool_parse_options
   2614  1.1  joerg 
   2615  1.1  joerg 
   2616  1.1  joerg 
   2617  1.1  joerg # libtool_validate_options [ARG]...
   2618  1.1  joerg # ---------------------------------
   2619  1.1  joerg # Perform any sanity checks on option settings and/or unconsumed
   2620  1.1  joerg # arguments.
   2621  1.1  joerg libtool_validate_options ()
   2622  1.1  joerg {
   2623  1.1  joerg     # save first non-option argument
   2624  1.1  joerg     if test 0 -lt $#; then
   2625  1.1  joerg       nonopt=$1
   2626  1.1  joerg       shift
   2627  1.1  joerg     fi
   2628  1.1  joerg 
   2629  1.1  joerg     # preserve --debug
   2630  1.1  joerg     test : = "$debug_cmd" || func_append preserve_args " --debug"
   2631  1.1  joerg 
   2632  1.1  joerg     case $host in
   2633  1.1  joerg       # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
   2634  1.1  joerg       # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
   2635  1.1  joerg       *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
   2636  1.1  joerg         # don't eliminate duplications in $postdeps and $predeps
   2637  1.1  joerg         opt_duplicate_compiler_generated_deps=:
   2638  1.1  joerg         ;;
   2639  1.1  joerg       *)
   2640  1.1  joerg         opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
   2641  1.1  joerg         ;;
   2642  1.1  joerg     esac
   2643  1.1  joerg 
   2644  1.1  joerg     $opt_help || {
   2645  1.1  joerg       # Sanity checks first:
   2646  1.1  joerg       func_check_version_match
   2647  1.1  joerg 
   2648  1.1  joerg       test yes != "$build_libtool_libs" \
   2649  1.1  joerg         && test yes != "$build_old_libs" \
   2650  1.1  joerg         && func_fatal_configuration "not configured to build any kind of library"
   2651  1.1  joerg 
   2652  1.1  joerg       # Darwin sucks
   2653  1.1  joerg       eval std_shrext=\"$shrext_cmds\"
   2654  1.1  joerg 
   2655  1.1  joerg       # Only execute mode is allowed to have -dlopen flags.
   2656  1.1  joerg       if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
   2657  1.1  joerg         func_error "unrecognized option '-dlopen'"
   2658  1.1  joerg         $ECHO "$help" 1>&2
   2659  1.1  joerg         exit $EXIT_FAILURE
   2660  1.1  joerg       fi
   2661  1.1  joerg 
   2662  1.1  joerg       # Change the help message to a mode-specific one.
   2663  1.1  joerg       generic_help=$help
   2664  1.1  joerg       help="Try '$progname --help --mode=$opt_mode' for more information."
   2665  1.1  joerg     }
   2666  1.1  joerg 
   2667  1.1  joerg     # Pass back the unparsed argument list
   2668  1.1  joerg     func_quote eval ${1+"$@"}
   2669  1.1  joerg     libtool_validate_options_result=$func_quote_result
   2670  1.1  joerg }
   2671  1.1  joerg func_add_hook func_validate_options libtool_validate_options
   2672  1.1  joerg 
   2673  1.1  joerg 
   2674  1.1  joerg # Process options as early as possible so that --help and --version
   2675  1.1  joerg # can return quickly.
   2676  1.1  joerg func_options ${1+"$@"}
   2677  1.1  joerg eval set dummy "$func_options_result"; shift
   2678  1.1  joerg 
   2679  1.1  joerg 
   2680  1.1  joerg 
   2681  1.1  joerg ## ----------- ##
   2682  1.1  joerg ##    Main.    ##
   2683  1.1  joerg ## ----------- ##
   2684  1.1  joerg 
   2685  1.1  joerg magic='%%%MAGIC variable%%%'
   2686  1.1  joerg magic_exe='%%%MAGIC EXE variable%%%'
   2687  1.1  joerg 
   2688  1.1  joerg # Global variables.
   2689  1.1  joerg extracted_archives=
   2690  1.1  joerg extracted_serial=0
   2691  1.1  joerg 
   2692  1.1  joerg # If this variable is set in any of the actions, the command in it
   2693  1.1  joerg # will be execed at the end.  This prevents here-documents from being
   2694  1.1  joerg # left over by shells.
   2695  1.1  joerg exec_cmd=
   2696  1.1  joerg 
   2697  1.1  joerg 
   2698  1.1  joerg # A function that is used when there is no print builtin or printf.
   2699  1.1  joerg func_fallback_echo ()
   2700  1.1  joerg {
   2701  1.1  joerg   eval 'cat <<_LTECHO_EOF
   2702  1.1  joerg $1
   2703  1.1  joerg _LTECHO_EOF'
   2704  1.1  joerg }
   2705  1.1  joerg 
   2706  1.1  joerg # func_generated_by_libtool
   2707  1.1  joerg # True iff stdin has been generated by Libtool. This function is only
   2708  1.1  joerg # a basic sanity check; it will hardly flush out determined imposters.
   2709  1.1  joerg func_generated_by_libtool_p ()
   2710  1.1  joerg {
   2711  1.1  joerg   $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
   2712  1.1  joerg }
   2713  1.1  joerg 
   2714  1.1  joerg # func_lalib_p file
   2715  1.1  joerg # True iff FILE is a libtool '.la' library or '.lo' object file.
   2716  1.1  joerg # This function is only a basic sanity check; it will hardly flush out
   2717  1.1  joerg # determined imposters.
   2718  1.1  joerg func_lalib_p ()
   2719  1.1  joerg {
   2720  1.1  joerg     test -f "$1" &&
   2721  1.1  joerg       $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
   2722  1.1  joerg }
   2723  1.1  joerg 
   2724  1.1  joerg # func_lalib_unsafe_p file
   2725  1.1  joerg # True iff FILE is a libtool '.la' library or '.lo' object file.
   2726  1.1  joerg # This function implements the same check as func_lalib_p without
   2727  1.1  joerg # resorting to external programs.  To this end, it redirects stdin and
   2728  1.1  joerg # closes it afterwards, without saving the original file descriptor.
   2729  1.1  joerg # As a safety measure, use it only where a negative result would be
   2730  1.1  joerg # fatal anyway.  Works if 'file' does not exist.
   2731  1.1  joerg func_lalib_unsafe_p ()
   2732  1.1  joerg {
   2733  1.1  joerg     lalib_p=no
   2734  1.1  joerg     if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
   2735  1.1  joerg 	for lalib_p_l in 1 2 3 4
   2736  1.1  joerg 	do
   2737  1.1  joerg 	    read lalib_p_line
   2738  1.1  joerg 	    case $lalib_p_line in
   2739  1.1  joerg 		\#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
   2740  1.1  joerg 	    esac
   2741  1.1  joerg 	done
   2742  1.1  joerg 	exec 0<&5 5<&-
   2743  1.1  joerg     fi
   2744  1.1  joerg     test yes = "$lalib_p"
   2745  1.1  joerg }
   2746  1.1  joerg 
   2747  1.1  joerg # func_ltwrapper_script_p file
   2748  1.1  joerg # True iff FILE is a libtool wrapper script
   2749  1.1  joerg # This function is only a basic sanity check; it will hardly flush out
   2750  1.1  joerg # determined imposters.
   2751  1.1  joerg func_ltwrapper_script_p ()
   2752  1.1  joerg {
   2753  1.1  joerg     test -f "$1" &&
   2754  1.1  joerg       $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
   2755  1.1  joerg }
   2756  1.1  joerg 
   2757  1.1  joerg # func_ltwrapper_executable_p file
   2758  1.1  joerg # True iff FILE is a libtool wrapper executable
   2759  1.1  joerg # This function is only a basic sanity check; it will hardly flush out
   2760  1.1  joerg # determined imposters.
   2761  1.1  joerg func_ltwrapper_executable_p ()
   2762  1.1  joerg {
   2763  1.1  joerg     func_ltwrapper_exec_suffix=
   2764  1.1  joerg     case $1 in
   2765  1.1  joerg     *.exe) ;;
   2766  1.1  joerg     *) func_ltwrapper_exec_suffix=.exe ;;
   2767  1.1  joerg     esac
   2768  1.1  joerg     $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
   2769  1.1  joerg }
   2770  1.1  joerg 
   2771  1.1  joerg # func_ltwrapper_scriptname file
   2772  1.1  joerg # Assumes file is an ltwrapper_executable
   2773  1.1  joerg # uses $file to determine the appropriate filename for a
   2774  1.1  joerg # temporary ltwrapper_script.
   2775  1.1  joerg func_ltwrapper_scriptname ()
   2776  1.1  joerg {
   2777  1.1  joerg     func_dirname_and_basename "$1" "" "."
   2778  1.1  joerg     func_stripname '' '.exe' "$func_basename_result"
   2779  1.1  joerg     func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
   2780  1.1  joerg }
   2781  1.1  joerg 
   2782  1.1  joerg # func_ltwrapper_p file
   2783  1.1  joerg # True iff FILE is a libtool wrapper script or wrapper executable
   2784  1.1  joerg # This function is only a basic sanity check; it will hardly flush out
   2785  1.1  joerg # determined imposters.
   2786  1.1  joerg func_ltwrapper_p ()
   2787  1.1  joerg {
   2788  1.1  joerg     func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
   2789  1.1  joerg }
   2790  1.1  joerg 
   2791  1.1  joerg 
   2792  1.1  joerg # func_execute_cmds commands fail_cmd
   2793  1.1  joerg # Execute tilde-delimited COMMANDS.
   2794  1.1  joerg # If FAIL_CMD is given, eval that upon failure.
   2795  1.1  joerg # FAIL_CMD may read-access the current command in variable CMD!
   2796  1.1  joerg func_execute_cmds ()
   2797  1.1  joerg {
   2798  1.1  joerg     $debug_cmd
   2799  1.1  joerg 
   2800  1.1  joerg     save_ifs=$IFS; IFS='~'
   2801  1.1  joerg     for cmd in $1; do
   2802  1.1  joerg       IFS=$sp$nl
   2803  1.1  joerg       eval cmd=\"$cmd\"
   2804  1.1  joerg       IFS=$save_ifs
   2805  1.1  joerg       func_show_eval "$cmd" "${2-:}"
   2806  1.1  joerg     done
   2807  1.1  joerg     IFS=$save_ifs
   2808  1.1  joerg }
   2809  1.1  joerg 
   2810  1.1  joerg 
   2811  1.1  joerg # func_source file
   2812  1.1  joerg # Source FILE, adding directory component if necessary.
   2813  1.1  joerg # Note that it is not necessary on cygwin/mingw to append a dot to
   2814  1.1  joerg # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
   2815  1.1  joerg # behavior happens only for exec(3), not for open(2)!  Also, sourcing
   2816  1.1  joerg # 'FILE.' does not work on cygwin managed mounts.
   2817  1.1  joerg func_source ()
   2818  1.1  joerg {
   2819  1.1  joerg     $debug_cmd
   2820  1.1  joerg 
   2821  1.1  joerg     case $1 in
   2822  1.1  joerg     */* | *\\*)	. "$1" ;;
   2823  1.1  joerg     *)		. "./$1" ;;
   2824  1.1  joerg     esac
   2825  1.1  joerg }
   2826  1.1  joerg 
   2827  1.1  joerg 
   2828  1.1  joerg # func_resolve_sysroot PATH
   2829  1.1  joerg # Replace a leading = in PATH with a sysroot.  Store the result into
   2830  1.1  joerg # func_resolve_sysroot_result
   2831  1.1  joerg func_resolve_sysroot ()
   2832  1.1  joerg {
   2833  1.1  joerg   func_resolve_sysroot_result=$1
   2834  1.1  joerg   case $func_resolve_sysroot_result in
   2835  1.1  joerg   =*)
   2836  1.1  joerg     func_stripname '=' '' "$func_resolve_sysroot_result"
   2837  1.1  joerg     func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
   2838  1.1  joerg     ;;
   2839  1.1  joerg   esac
   2840  1.1  joerg }
   2841  1.1  joerg 
   2842  1.1  joerg # func_replace_sysroot PATH
   2843  1.1  joerg # If PATH begins with the sysroot, replace it with = and
   2844  1.1  joerg # store the result into func_replace_sysroot_result.
   2845  1.1  joerg func_replace_sysroot ()
   2846  1.1  joerg {
   2847  1.1  joerg   case $lt_sysroot:$1 in
   2848  1.1  joerg   ?*:"$lt_sysroot"*)
   2849  1.1  joerg     func_stripname "$lt_sysroot" '' "$1"
   2850  1.1  joerg     func_replace_sysroot_result='='$func_stripname_result
   2851  1.1  joerg     ;;
   2852  1.1  joerg   *)
   2853  1.1  joerg     # Including no sysroot.
   2854  1.1  joerg     func_replace_sysroot_result=$1
   2855  1.1  joerg     ;;
   2856  1.1  joerg   esac
   2857  1.1  joerg }
   2858  1.1  joerg 
   2859  1.1  joerg # func_infer_tag arg
   2860  1.1  joerg # Infer tagged configuration to use if any are available and
   2861  1.1  joerg # if one wasn't chosen via the "--tag" command line option.
   2862  1.1  joerg # Only attempt this if the compiler in the base compile
   2863  1.1  joerg # command doesn't match the default compiler.
   2864  1.1  joerg # arg is usually of the form 'gcc ...'
   2865  1.1  joerg func_infer_tag ()
   2866  1.1  joerg {
   2867  1.1  joerg     $debug_cmd
   2868  1.1  joerg 
   2869  1.1  joerg     if test -n "$available_tags" && test -z "$tagname"; then
   2870  1.1  joerg       CC_quoted=
   2871  1.1  joerg       for arg in $CC; do
   2872  1.1  joerg 	func_append_quoted CC_quoted "$arg"
   2873  1.1  joerg       done
   2874  1.1  joerg       CC_expanded=`func_echo_all $CC`
   2875  1.1  joerg       CC_quoted_expanded=`func_echo_all $CC_quoted`
   2876  1.1  joerg       case $@ in
   2877  1.1  joerg       # Blanks in the command may have been stripped by the calling shell,
   2878  1.1  joerg       # but not from the CC environment variable when configure was run.
   2879  1.1  joerg       " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
   2880  1.1  joerg       " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
   2881  1.1  joerg       # Blanks at the start of $base_compile will cause this to fail
   2882  1.1  joerg       # if we don't check for them as well.
   2883  1.1  joerg       *)
   2884  1.1  joerg 	for z in $available_tags; do
   2885  1.1  joerg 	  if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
   2886  1.1  joerg 	    # Evaluate the configuration.
   2887  1.1  joerg 	    eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
   2888  1.1  joerg 	    CC_quoted=
   2889  1.1  joerg 	    for arg in $CC; do
   2890  1.1  joerg 	      # Double-quote args containing other shell metacharacters.
   2891  1.1  joerg 	      func_append_quoted CC_quoted "$arg"
   2892  1.1  joerg 	    done
   2893  1.1  joerg 	    CC_expanded=`func_echo_all $CC`
   2894  1.1  joerg 	    CC_quoted_expanded=`func_echo_all $CC_quoted`
   2895  1.1  joerg 	    case "$@ " in
   2896  1.1  joerg 	    " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
   2897  1.1  joerg 	    " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
   2898  1.1  joerg 	      # The compiler in the base compile command matches
   2899  1.1  joerg 	      # the one in the tagged configuration.
   2900  1.1  joerg 	      # Assume this is the tagged configuration we want.
   2901  1.1  joerg 	      tagname=$z
   2902  1.1  joerg 	      break
   2903  1.1  joerg 	      ;;
   2904  1.1  joerg 	    esac
   2905  1.1  joerg 	  fi
   2906  1.1  joerg 	done
   2907  1.1  joerg 	# If $tagname still isn't set, then no tagged configuration
   2908  1.1  joerg 	# was found and let the user know that the "--tag" command
   2909  1.1  joerg 	# line option must be used.
   2910  1.1  joerg 	if test -z "$tagname"; then
   2911  1.1  joerg 	  func_echo "unable to infer tagged configuration"
   2912  1.1  joerg 	  func_fatal_error "specify a tag with '--tag'"
   2913  1.1  joerg #	else
   2914  1.1  joerg #	  func_verbose "using $tagname tagged configuration"
   2915  1.1  joerg 	fi
   2916  1.1  joerg 	;;
   2917  1.1  joerg       esac
   2918  1.1  joerg     fi
   2919  1.1  joerg }
   2920  1.1  joerg 
   2921  1.1  joerg 
   2922  1.1  joerg 
   2923  1.1  joerg # func_write_libtool_object output_name pic_name nonpic_name
   2924  1.1  joerg # Create a libtool object file (analogous to a ".la" file),
   2925  1.1  joerg # but don't create it if we're doing a dry run.
   2926  1.1  joerg func_write_libtool_object ()
   2927  1.1  joerg {
   2928  1.1  joerg     write_libobj=$1
   2929  1.1  joerg     if test yes = "$build_libtool_libs"; then
   2930  1.1  joerg       write_lobj=\'$2\'
   2931  1.1  joerg     else
   2932  1.1  joerg       write_lobj=none
   2933  1.1  joerg     fi
   2934  1.1  joerg 
   2935  1.1  joerg     if test yes = "$build_old_libs"; then
   2936  1.1  joerg       write_oldobj=\'$3\'
   2937  1.1  joerg     else
   2938  1.1  joerg       write_oldobj=none
   2939  1.1  joerg     fi
   2940  1.1  joerg 
   2941  1.1  joerg     $opt_dry_run || {
   2942  1.1  joerg       cat >${write_libobj}T <<EOF
   2943  1.1  joerg # $write_libobj - a libtool object file
   2944  1.1  joerg # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
   2945  1.1  joerg #
   2946  1.1  joerg # Please DO NOT delete this file!
   2947  1.1  joerg # It is necessary for linking the library.
   2948  1.1  joerg 
   2949  1.1  joerg # Name of the PIC object.
   2950  1.1  joerg pic_object=$write_lobj
   2951  1.1  joerg 
   2952  1.1  joerg # Name of the non-PIC object
   2953  1.1  joerg non_pic_object=$write_oldobj
   2954  1.1  joerg 
   2955  1.1  joerg EOF
   2956  1.1  joerg       $MV "${write_libobj}T" "$write_libobj"
   2957  1.1  joerg     }
   2958  1.1  joerg }
   2959  1.1  joerg 
   2960  1.1  joerg 
   2961  1.1  joerg ##################################################
   2962  1.1  joerg # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
   2963  1.1  joerg ##################################################
   2964  1.1  joerg 
   2965  1.1  joerg # func_convert_core_file_wine_to_w32 ARG
   2966  1.1  joerg # Helper function used by file name conversion functions when $build is *nix,
   2967  1.1  joerg # and $host is mingw, cygwin, or some other w32 environment. Relies on a
   2968  1.1  joerg # correctly configured wine environment available, with the winepath program
   2969  1.1  joerg # in $build's $PATH.
   2970  1.1  joerg #
   2971  1.1  joerg # ARG is the $build file name to be converted to w32 format.
   2972  1.1  joerg # Result is available in $func_convert_core_file_wine_to_w32_result, and will
   2973  1.1  joerg # be empty on error (or when ARG is empty)
   2974  1.1  joerg func_convert_core_file_wine_to_w32 ()
   2975  1.1  joerg {
   2976  1.1  joerg   $debug_cmd
   2977  1.1  joerg 
   2978  1.1  joerg   func_convert_core_file_wine_to_w32_result=$1
   2979  1.1  joerg   if test -n "$1"; then
   2980  1.1  joerg     # Unfortunately, winepath does not exit with a non-zero error code, so we
   2981  1.1  joerg     # are forced to check the contents of stdout. On the other hand, if the
   2982  1.1  joerg     # command is not found, the shell will set an exit code of 127 and print
   2983  1.1  joerg     # *an error message* to stdout. So we must check for both error code of
   2984  1.1  joerg     # zero AND non-empty stdout, which explains the odd construction:
   2985  1.1  joerg     func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
   2986  1.1  joerg     if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
   2987  1.1  joerg       func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
   2988  1.1  joerg         $SED -e "$sed_naive_backslashify"`
   2989  1.1  joerg     else
   2990  1.1  joerg       func_convert_core_file_wine_to_w32_result=
   2991  1.1  joerg     fi
   2992  1.1  joerg   fi
   2993  1.1  joerg }
   2994  1.1  joerg # end: func_convert_core_file_wine_to_w32
   2995  1.1  joerg 
   2996  1.1  joerg 
   2997  1.1  joerg # func_convert_core_path_wine_to_w32 ARG
   2998  1.1  joerg # Helper function used by path conversion functions when $build is *nix, and
   2999  1.1  joerg # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
   3000  1.1  joerg # configured wine environment available, with the winepath program in $build's
   3001  1.1  joerg # $PATH. Assumes ARG has no leading or trailing path separator characters.
   3002  1.1  joerg #
   3003  1.1  joerg # ARG is path to be converted from $build format to win32.
   3004  1.1  joerg # Result is available in $func_convert_core_path_wine_to_w32_result.
   3005  1.1  joerg # Unconvertible file (directory) names in ARG are skipped; if no directory names
   3006  1.1  joerg # are convertible, then the result may be empty.
   3007  1.1  joerg func_convert_core_path_wine_to_w32 ()
   3008  1.1  joerg {
   3009  1.1  joerg   $debug_cmd
   3010  1.1  joerg 
   3011  1.1  joerg   # unfortunately, winepath doesn't convert paths, only file names
   3012  1.1  joerg   func_convert_core_path_wine_to_w32_result=
   3013  1.1  joerg   if test -n "$1"; then
   3014  1.1  joerg     oldIFS=$IFS
   3015  1.1  joerg     IFS=:
   3016  1.1  joerg     for func_convert_core_path_wine_to_w32_f in $1; do
   3017  1.1  joerg       IFS=$oldIFS
   3018  1.1  joerg       func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
   3019  1.1  joerg       if test -n "$func_convert_core_file_wine_to_w32_result"; then
   3020  1.1  joerg         if test -z "$func_convert_core_path_wine_to_w32_result"; then
   3021  1.1  joerg           func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
   3022  1.1  joerg         else
   3023  1.1  joerg           func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
   3024  1.1  joerg         fi
   3025  1.1  joerg       fi
   3026  1.1  joerg     done
   3027  1.1  joerg     IFS=$oldIFS
   3028  1.1  joerg   fi
   3029  1.1  joerg }
   3030  1.1  joerg # end: func_convert_core_path_wine_to_w32
   3031  1.1  joerg 
   3032  1.1  joerg 
   3033  1.1  joerg # func_cygpath ARGS...
   3034  1.1  joerg # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
   3035  1.1  joerg # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
   3036  1.1  joerg # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
   3037  1.1  joerg # (2), returns the Cygwin file name or path in func_cygpath_result (input
   3038  1.1  joerg # file name or path is assumed to be in w32 format, as previously converted
   3039  1.1  joerg # from $build's *nix or MSYS format). In case (3), returns the w32 file name
   3040  1.1  joerg # or path in func_cygpath_result (input file name or path is assumed to be in
   3041  1.1  joerg # Cygwin format). Returns an empty string on error.
   3042  1.1  joerg #
   3043  1.1  joerg # ARGS are passed to cygpath, with the last one being the file name or path to
   3044  1.1  joerg # be converted.
   3045  1.1  joerg #
   3046  1.1  joerg # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
   3047  1.1  joerg # environment variable; do not put it in $PATH.
   3048  1.1  joerg func_cygpath ()
   3049  1.1  joerg {
   3050  1.1  joerg   $debug_cmd
   3051  1.1  joerg 
   3052  1.1  joerg   if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
   3053  1.1  joerg     func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
   3054  1.1  joerg     if test "$?" -ne 0; then
   3055  1.1  joerg       # on failure, ensure result is empty
   3056  1.1  joerg       func_cygpath_result=
   3057  1.1  joerg     fi
   3058  1.1  joerg   else
   3059  1.1  joerg     func_cygpath_result=
   3060  1.1  joerg     func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
   3061  1.1  joerg   fi
   3062  1.1  joerg }
   3063  1.1  joerg #end: func_cygpath
   3064  1.1  joerg 
   3065  1.1  joerg 
   3066  1.1  joerg # func_convert_core_msys_to_w32 ARG
   3067  1.1  joerg # Convert file name or path ARG from MSYS format to w32 format.  Return
   3068  1.1  joerg # result in func_convert_core_msys_to_w32_result.
   3069  1.1  joerg func_convert_core_msys_to_w32 ()
   3070  1.1  joerg {
   3071  1.1  joerg   $debug_cmd
   3072  1.1  joerg 
   3073  1.1  joerg   # awkward: cmd appends spaces to result
   3074  1.1  joerg   func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
   3075  1.1  joerg     $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
   3076  1.1  joerg }
   3077  1.1  joerg #end: func_convert_core_msys_to_w32
   3078  1.1  joerg 
   3079  1.1  joerg 
   3080  1.1  joerg # func_convert_file_check ARG1 ARG2
   3081  1.1  joerg # Verify that ARG1 (a file name in $build format) was converted to $host
   3082  1.1  joerg # format in ARG2. Otherwise, emit an error message, but continue (resetting
   3083  1.1  joerg # func_to_host_file_result to ARG1).
   3084  1.1  joerg func_convert_file_check ()
   3085  1.1  joerg {
   3086  1.1  joerg   $debug_cmd
   3087  1.1  joerg 
   3088  1.1  joerg   if test -z "$2" && test -n "$1"; then
   3089  1.1  joerg     func_error "Could not determine host file name corresponding to"
   3090  1.1  joerg     func_error "  '$1'"
   3091  1.1  joerg     func_error "Continuing, but uninstalled executables may not work."
   3092  1.1  joerg     # Fallback:
   3093  1.1  joerg     func_to_host_file_result=$1
   3094  1.1  joerg   fi
   3095  1.1  joerg }
   3096  1.1  joerg # end func_convert_file_check
   3097  1.1  joerg 
   3098  1.1  joerg 
   3099  1.1  joerg # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
   3100  1.1  joerg # Verify that FROM_PATH (a path in $build format) was converted to $host
   3101  1.1  joerg # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
   3102  1.1  joerg # func_to_host_file_result to a simplistic fallback value (see below).
   3103  1.1  joerg func_convert_path_check ()
   3104  1.1  joerg {
   3105  1.1  joerg   $debug_cmd
   3106  1.1  joerg 
   3107  1.1  joerg   if test -z "$4" && test -n "$3"; then
   3108  1.1  joerg     func_error "Could not determine the host path corresponding to"
   3109  1.1  joerg     func_error "  '$3'"
   3110  1.1  joerg     func_error "Continuing, but uninstalled executables may not work."
   3111  1.1  joerg     # Fallback.  This is a deliberately simplistic "conversion" and
   3112  1.1  joerg     # should not be "improved".  See libtool.info.
   3113  1.1  joerg     if test "x$1" != "x$2"; then
   3114  1.1  joerg       lt_replace_pathsep_chars="s|$1|$2|g"
   3115  1.1  joerg       func_to_host_path_result=`echo "$3" |
   3116  1.1  joerg         $SED -e "$lt_replace_pathsep_chars"`
   3117  1.1  joerg     else
   3118  1.1  joerg       func_to_host_path_result=$3
   3119  1.1  joerg     fi
   3120  1.1  joerg   fi
   3121  1.1  joerg }
   3122  1.1  joerg # end func_convert_path_check
   3123  1.1  joerg 
   3124  1.1  joerg 
   3125  1.1  joerg # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
   3126  1.1  joerg # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
   3127  1.1  joerg # and appending REPL if ORIG matches BACKPAT.
   3128  1.1  joerg func_convert_path_front_back_pathsep ()
   3129  1.1  joerg {
   3130  1.1  joerg   $debug_cmd
   3131  1.1  joerg 
   3132  1.1  joerg   case $4 in
   3133  1.1  joerg   $1 ) func_to_host_path_result=$3$func_to_host_path_result
   3134  1.1  joerg     ;;
   3135  1.1  joerg   esac
   3136  1.1  joerg   case $4 in
   3137  1.1  joerg   $2 ) func_append func_to_host_path_result "$3"
   3138  1.1  joerg     ;;
   3139  1.1  joerg   esac
   3140  1.1  joerg }
   3141  1.1  joerg # end func_convert_path_front_back_pathsep
   3142  1.1  joerg 
   3143  1.1  joerg 
   3144  1.1  joerg ##################################################
   3145  1.1  joerg # $build to $host FILE NAME CONVERSION FUNCTIONS #
   3146  1.1  joerg ##################################################
   3147  1.1  joerg # invoked via '$to_host_file_cmd ARG'
   3148  1.1  joerg #
   3149  1.1  joerg # In each case, ARG is the path to be converted from $build to $host format.
   3150  1.1  joerg # Result will be available in $func_to_host_file_result.
   3151  1.1  joerg 
   3152  1.1  joerg 
   3153  1.1  joerg # func_to_host_file ARG
   3154  1.1  joerg # Converts the file name ARG from $build format to $host format. Return result
   3155  1.1  joerg # in func_to_host_file_result.
   3156  1.1  joerg func_to_host_file ()
   3157  1.1  joerg {
   3158  1.1  joerg   $debug_cmd
   3159  1.1  joerg 
   3160  1.1  joerg   $to_host_file_cmd "$1"
   3161  1.1  joerg }
   3162  1.1  joerg # end func_to_host_file
   3163  1.1  joerg 
   3164  1.1  joerg 
   3165  1.1  joerg # func_to_tool_file ARG LAZY
   3166  1.1  joerg # converts the file name ARG from $build format to toolchain format. Return
   3167  1.1  joerg # result in func_to_tool_file_result.  If the conversion in use is listed
   3168  1.1  joerg # in (the comma separated) LAZY, no conversion takes place.
   3169  1.1  joerg func_to_tool_file ()
   3170  1.1  joerg {
   3171  1.1  joerg   $debug_cmd
   3172  1.1  joerg 
   3173  1.1  joerg   case ,$2, in
   3174  1.1  joerg     *,"$to_tool_file_cmd",*)
   3175  1.1  joerg       func_to_tool_file_result=$1
   3176  1.1  joerg       ;;
   3177  1.1  joerg     *)
   3178  1.1  joerg       $to_tool_file_cmd "$1"
   3179  1.1  joerg       func_to_tool_file_result=$func_to_host_file_result
   3180  1.1  joerg       ;;
   3181  1.1  joerg   esac
   3182  1.1  joerg }
   3183  1.1  joerg # end func_to_tool_file
   3184  1.1  joerg 
   3185  1.1  joerg 
   3186  1.1  joerg # func_convert_file_noop ARG
   3187  1.1  joerg # Copy ARG to func_to_host_file_result.
   3188  1.1  joerg func_convert_file_noop ()
   3189  1.1  joerg {
   3190  1.1  joerg   func_to_host_file_result=$1
   3191  1.1  joerg }
   3192  1.1  joerg # end func_convert_file_noop
   3193  1.1  joerg 
   3194  1.1  joerg 
   3195  1.1  joerg # func_convert_file_msys_to_w32 ARG
   3196  1.1  joerg # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
   3197  1.1  joerg # conversion to w32 is not available inside the cwrapper.  Returns result in
   3198  1.1  joerg # func_to_host_file_result.
   3199  1.1  joerg func_convert_file_msys_to_w32 ()
   3200  1.1  joerg {
   3201  1.1  joerg   $debug_cmd
   3202  1.1  joerg 
   3203  1.1  joerg   func_to_host_file_result=$1
   3204  1.1  joerg   if test -n "$1"; then
   3205  1.1  joerg     func_convert_core_msys_to_w32 "$1"
   3206  1.1  joerg     func_to_host_file_result=$func_convert_core_msys_to_w32_result
   3207  1.1  joerg   fi
   3208  1.1  joerg   func_convert_file_check "$1" "$func_to_host_file_result"
   3209  1.1  joerg }
   3210  1.1  joerg # end func_convert_file_msys_to_w32
   3211  1.1  joerg 
   3212  1.1  joerg 
   3213  1.1  joerg # func_convert_file_cygwin_to_w32 ARG
   3214  1.1  joerg # Convert file name ARG from Cygwin to w32 format.  Returns result in
   3215  1.1  joerg # func_to_host_file_result.
   3216  1.1  joerg func_convert_file_cygwin_to_w32 ()
   3217  1.1  joerg {
   3218  1.1  joerg   $debug_cmd
   3219  1.1  joerg 
   3220  1.1  joerg   func_to_host_file_result=$1
   3221  1.1  joerg   if test -n "$1"; then
   3222  1.1  joerg     # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
   3223  1.1  joerg     # LT_CYGPATH in this case.
   3224  1.1  joerg     func_to_host_file_result=`cygpath -m "$1"`
   3225  1.1  joerg   fi
   3226  1.1  joerg   func_convert_file_check "$1" "$func_to_host_file_result"
   3227  1.1  joerg }
   3228  1.1  joerg # end func_convert_file_cygwin_to_w32
   3229  1.1  joerg 
   3230  1.1  joerg 
   3231  1.1  joerg # func_convert_file_nix_to_w32 ARG
   3232  1.1  joerg # Convert file name ARG from *nix to w32 format.  Requires a wine environment
   3233  1.1  joerg # and a working winepath. Returns result in func_to_host_file_result.
   3234  1.1  joerg func_convert_file_nix_to_w32 ()
   3235  1.1  joerg {
   3236  1.1  joerg   $debug_cmd
   3237  1.1  joerg 
   3238  1.1  joerg   func_to_host_file_result=$1
   3239  1.1  joerg   if test -n "$1"; then
   3240  1.1  joerg     func_convert_core_file_wine_to_w32 "$1"
   3241  1.1  joerg     func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
   3242  1.1  joerg   fi
   3243  1.1  joerg   func_convert_file_check "$1" "$func_to_host_file_result"
   3244  1.1  joerg }
   3245  1.1  joerg # end func_convert_file_nix_to_w32
   3246  1.1  joerg 
   3247  1.1  joerg 
   3248  1.1  joerg # func_convert_file_msys_to_cygwin ARG
   3249  1.1  joerg # Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
   3250  1.1  joerg # Returns result in func_to_host_file_result.
   3251  1.1  joerg func_convert_file_msys_to_cygwin ()
   3252  1.1  joerg {
   3253  1.1  joerg   $debug_cmd
   3254  1.1  joerg 
   3255  1.1  joerg   func_to_host_file_result=$1
   3256  1.1  joerg   if test -n "$1"; then
   3257  1.1  joerg     func_convert_core_msys_to_w32 "$1"
   3258  1.1  joerg     func_cygpath -u "$func_convert_core_msys_to_w32_result"
   3259  1.1  joerg     func_to_host_file_result=$func_cygpath_result
   3260  1.1  joerg   fi
   3261  1.1  joerg   func_convert_file_check "$1" "$func_to_host_file_result"
   3262  1.1  joerg }
   3263  1.1  joerg # end func_convert_file_msys_to_cygwin
   3264  1.1  joerg 
   3265  1.1  joerg 
   3266  1.1  joerg # func_convert_file_nix_to_cygwin ARG
   3267  1.1  joerg # Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed
   3268  1.1  joerg # in a wine environment, working winepath, and LT_CYGPATH set.  Returns result
   3269  1.1  joerg # in func_to_host_file_result.
   3270  1.1  joerg func_convert_file_nix_to_cygwin ()
   3271  1.1  joerg {
   3272  1.1  joerg   $debug_cmd
   3273  1.1  joerg 
   3274  1.1  joerg   func_to_host_file_result=$1
   3275  1.1  joerg   if test -n "$1"; then
   3276  1.1  joerg     # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
   3277  1.1  joerg     func_convert_core_file_wine_to_w32 "$1"
   3278  1.1  joerg     func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
   3279  1.1  joerg     func_to_host_file_result=$func_cygpath_result
   3280  1.1  joerg   fi
   3281  1.1  joerg   func_convert_file_check "$1" "$func_to_host_file_result"
   3282  1.1  joerg }
   3283  1.1  joerg # end func_convert_file_nix_to_cygwin
   3284  1.1  joerg 
   3285  1.1  joerg 
   3286  1.1  joerg #############################################
   3287  1.1  joerg # $build to $host PATH CONVERSION FUNCTIONS #
   3288  1.1  joerg #############################################
   3289  1.1  joerg # invoked via '$to_host_path_cmd ARG'
   3290  1.1  joerg #
   3291  1.1  joerg # In each case, ARG is the path to be converted from $build to $host format.
   3292  1.1  joerg # The result will be available in $func_to_host_path_result.
   3293  1.1  joerg #
   3294  1.1  joerg # Path separators are also converted from $build format to $host format.  If
   3295  1.1  joerg # ARG begins or ends with a path separator character, it is preserved (but
   3296  1.1  joerg # converted to $host format) on output.
   3297  1.1  joerg #
   3298  1.1  joerg # All path conversion functions are named using the following convention:
   3299  1.1  joerg #   file name conversion function    : func_convert_file_X_to_Y ()
   3300  1.1  joerg #   path conversion function         : func_convert_path_X_to_Y ()
   3301  1.1  joerg # where, for any given $build/$host combination the 'X_to_Y' value is the
   3302  1.1  joerg # same.  If conversion functions are added for new $build/$host combinations,
   3303  1.1  joerg # the two new functions must follow this pattern, or func_init_to_host_path_cmd
   3304  1.1  joerg # will break.
   3305  1.1  joerg 
   3306  1.1  joerg 
   3307  1.1  joerg # func_init_to_host_path_cmd
   3308  1.1  joerg # Ensures that function "pointer" variable $to_host_path_cmd is set to the
   3309  1.1  joerg # appropriate value, based on the value of $to_host_file_cmd.
   3310  1.1  joerg to_host_path_cmd=
   3311  1.1  joerg func_init_to_host_path_cmd ()
   3312  1.1  joerg {
   3313  1.1  joerg   $debug_cmd
   3314  1.1  joerg 
   3315  1.1  joerg   if test -z "$to_host_path_cmd"; then
   3316  1.1  joerg     func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
   3317  1.1  joerg     to_host_path_cmd=func_convert_path_$func_stripname_result
   3318  1.1  joerg   fi
   3319  1.1  joerg }
   3320  1.1  joerg 
   3321  1.1  joerg 
   3322  1.1  joerg # func_to_host_path ARG
   3323  1.1  joerg # Converts the path ARG from $build format to $host format. Return result
   3324  1.1  joerg # in func_to_host_path_result.
   3325  1.1  joerg func_to_host_path ()
   3326  1.1  joerg {
   3327  1.1  joerg   $debug_cmd
   3328  1.1  joerg 
   3329  1.1  joerg   func_init_to_host_path_cmd
   3330  1.1  joerg   $to_host_path_cmd "$1"
   3331  1.1  joerg }
   3332  1.1  joerg # end func_to_host_path
   3333  1.1  joerg 
   3334  1.1  joerg 
   3335  1.1  joerg # func_convert_path_noop ARG
   3336  1.1  joerg # Copy ARG to func_to_host_path_result.
   3337  1.1  joerg func_convert_path_noop ()
   3338  1.1  joerg {
   3339  1.1  joerg   func_to_host_path_result=$1
   3340  1.1  joerg }
   3341  1.1  joerg # end func_convert_path_noop
   3342  1.1  joerg 
   3343  1.1  joerg 
   3344  1.1  joerg # func_convert_path_msys_to_w32 ARG
   3345  1.1  joerg # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
   3346  1.1  joerg # conversion to w32 is not available inside the cwrapper.  Returns result in
   3347  1.1  joerg # func_to_host_path_result.
   3348  1.1  joerg func_convert_path_msys_to_w32 ()
   3349  1.1  joerg {
   3350  1.1  joerg   $debug_cmd
   3351  1.1  joerg 
   3352  1.1  joerg   func_to_host_path_result=$1
   3353  1.1  joerg   if test -n "$1"; then
   3354  1.1  joerg     # Remove leading and trailing path separator characters from ARG.  MSYS
   3355  1.1  joerg     # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
   3356  1.1  joerg     # and winepath ignores them completely.
   3357  1.1  joerg     func_stripname : : "$1"
   3358  1.1  joerg     func_to_host_path_tmp1=$func_stripname_result
   3359  1.1  joerg     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
   3360  1.1  joerg     func_to_host_path_result=$func_convert_core_msys_to_w32_result
   3361  1.1  joerg     func_convert_path_check : ";" \
   3362  1.1  joerg       "$func_to_host_path_tmp1" "$func_to_host_path_result"
   3363  1.1  joerg     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
   3364  1.1  joerg   fi
   3365  1.1  joerg }
   3366  1.1  joerg # end func_convert_path_msys_to_w32
   3367  1.1  joerg 
   3368  1.1  joerg 
   3369  1.1  joerg # func_convert_path_cygwin_to_w32 ARG
   3370  1.1  joerg # Convert path ARG from Cygwin to w32 format.  Returns result in
   3371  1.1  joerg # func_to_host_file_result.
   3372  1.1  joerg func_convert_path_cygwin_to_w32 ()
   3373  1.1  joerg {
   3374  1.1  joerg   $debug_cmd
   3375  1.1  joerg 
   3376  1.1  joerg   func_to_host_path_result=$1
   3377  1.1  joerg   if test -n "$1"; then
   3378  1.1  joerg     # See func_convert_path_msys_to_w32:
   3379  1.1  joerg     func_stripname : : "$1"
   3380  1.1  joerg     func_to_host_path_tmp1=$func_stripname_result
   3381  1.1  joerg     func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
   3382  1.1  joerg     func_convert_path_check : ";" \
   3383  1.1  joerg       "$func_to_host_path_tmp1" "$func_to_host_path_result"
   3384  1.1  joerg     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
   3385  1.1  joerg   fi
   3386  1.1  joerg }
   3387  1.1  joerg # end func_convert_path_cygwin_to_w32
   3388  1.1  joerg 
   3389  1.1  joerg 
   3390  1.1  joerg # func_convert_path_nix_to_w32 ARG
   3391  1.1  joerg # Convert path ARG from *nix to w32 format.  Requires a wine environment and
   3392  1.1  joerg # a working winepath.  Returns result in func_to_host_file_result.
   3393  1.1  joerg func_convert_path_nix_to_w32 ()
   3394  1.1  joerg {
   3395  1.1  joerg   $debug_cmd
   3396  1.1  joerg 
   3397  1.1  joerg   func_to_host_path_result=$1
   3398  1.1  joerg   if test -n "$1"; then
   3399  1.1  joerg     # See func_convert_path_msys_to_w32:
   3400  1.1  joerg     func_stripname : : "$1"
   3401  1.1  joerg     func_to_host_path_tmp1=$func_stripname_result
   3402  1.1  joerg     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
   3403  1.1  joerg     func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
   3404  1.1  joerg     func_convert_path_check : ";" \
   3405  1.1  joerg       "$func_to_host_path_tmp1" "$func_to_host_path_result"
   3406  1.1  joerg     func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
   3407  1.1  joerg   fi
   3408  1.1  joerg }
   3409  1.1  joerg # end func_convert_path_nix_to_w32
   3410  1.1  joerg 
   3411  1.1  joerg 
   3412  1.1  joerg # func_convert_path_msys_to_cygwin ARG
   3413  1.1  joerg # Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.
   3414  1.1  joerg # Returns result in func_to_host_file_result.
   3415  1.1  joerg func_convert_path_msys_to_cygwin ()
   3416  1.1  joerg {
   3417  1.1  joerg   $debug_cmd
   3418  1.1  joerg 
   3419  1.1  joerg   func_to_host_path_result=$1
   3420  1.1  joerg   if test -n "$1"; then
   3421  1.1  joerg     # See func_convert_path_msys_to_w32:
   3422  1.1  joerg     func_stripname : : "$1"
   3423  1.1  joerg     func_to_host_path_tmp1=$func_stripname_result
   3424  1.1  joerg     func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
   3425  1.1  joerg     func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
   3426  1.1  joerg     func_to_host_path_result=$func_cygpath_result
   3427  1.1  joerg     func_convert_path_check : : \
   3428  1.1  joerg       "$func_to_host_path_tmp1" "$func_to_host_path_result"
   3429  1.1  joerg     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
   3430  1.1  joerg   fi
   3431  1.1  joerg }
   3432  1.1  joerg # end func_convert_path_msys_to_cygwin
   3433  1.1  joerg 
   3434  1.1  joerg 
   3435  1.1  joerg # func_convert_path_nix_to_cygwin ARG
   3436  1.1  joerg # Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
   3437  1.1  joerg # a wine environment, working winepath, and LT_CYGPATH set.  Returns result in
   3438  1.1  joerg # func_to_host_file_result.
   3439  1.1  joerg func_convert_path_nix_to_cygwin ()
   3440  1.1  joerg {
   3441  1.1  joerg   $debug_cmd
   3442  1.1  joerg 
   3443  1.1  joerg   func_to_host_path_result=$1
   3444  1.1  joerg   if test -n "$1"; then
   3445  1.1  joerg     # Remove leading and trailing path separator characters from
   3446  1.1  joerg     # ARG. msys behavior is inconsistent here, cygpath turns them
   3447  1.1  joerg     # into '.;' and ';.', and winepath ignores them completely.
   3448  1.1  joerg     func_stripname : : "$1"
   3449  1.1  joerg     func_to_host_path_tmp1=$func_stripname_result
   3450  1.1  joerg     func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
   3451  1.1  joerg     func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
   3452  1.1  joerg     func_to_host_path_result=$func_cygpath_result
   3453  1.1  joerg     func_convert_path_check : : \
   3454  1.1  joerg       "$func_to_host_path_tmp1" "$func_to_host_path_result"
   3455  1.1  joerg     func_convert_path_front_back_pathsep ":*" "*:" : "$1"
   3456  1.1  joerg   fi
   3457  1.1  joerg }
   3458  1.1  joerg # end func_convert_path_nix_to_cygwin
   3459  1.1  joerg 
   3460  1.1  joerg 
   3461  1.1  joerg # func_dll_def_p FILE
   3462  1.1  joerg # True iff FILE is a Windows DLL '.def' file.
   3463  1.1  joerg # Keep in sync with _LT_DLL_DEF_P in libtool.m4
   3464  1.1  joerg func_dll_def_p ()
   3465  1.1  joerg {
   3466  1.1  joerg   $debug_cmd
   3467  1.1  joerg 
   3468  1.1  joerg   func_dll_def_p_tmp=`$SED -n \
   3469  1.1  joerg     -e 's/^[	 ]*//' \
   3470  1.1  joerg     -e '/^\(;.*\)*$/d' \
   3471  1.1  joerg     -e 's/^\(EXPORTS\|LIBRARY\)\([	 ].*\)*$/DEF/p' \
   3472  1.1  joerg     -e q \
   3473  1.1  joerg     "$1"`
   3474  1.1  joerg   test DEF = "$func_dll_def_p_tmp"
   3475  1.1  joerg }
   3476  1.1  joerg 
   3477  1.1  joerg 
   3478  1.1  joerg # func_mode_compile arg...
   3479  1.1  joerg func_mode_compile ()
   3480  1.1  joerg {
   3481  1.1  joerg     $debug_cmd
   3482  1.1  joerg 
   3483  1.1  joerg     # Get the compilation command and the source file.
   3484  1.1  joerg     base_compile=
   3485  1.1  joerg     srcfile=$nonopt  #  always keep a non-empty value in "srcfile"
   3486  1.1  joerg     suppress_opt=yes
   3487  1.1  joerg     suppress_output=
   3488  1.1  joerg     arg_mode=normal
   3489  1.1  joerg     libobj=
   3490  1.1  joerg     later=
   3491  1.1  joerg     pie_flag=
   3492  1.1  joerg 
   3493  1.1  joerg     for arg
   3494  1.1  joerg     do
   3495  1.1  joerg       case $arg_mode in
   3496  1.1  joerg       arg  )
   3497  1.1  joerg 	# do not "continue".  Instead, add this to base_compile
   3498  1.1  joerg 	lastarg=$arg
   3499  1.1  joerg 	arg_mode=normal
   3500  1.1  joerg 	;;
   3501  1.1  joerg 
   3502  1.1  joerg       target )
   3503  1.1  joerg 	libobj=$arg
   3504  1.1  joerg 	arg_mode=normal
   3505  1.1  joerg 	continue
   3506  1.1  joerg 	;;
   3507  1.1  joerg 
   3508  1.1  joerg       normal )
   3509  1.1  joerg 	# Accept any command-line options.
   3510  1.1  joerg 	case $arg in
   3511  1.1  joerg 	-o)
   3512  1.1  joerg 	  test -n "$libobj" && \
   3513  1.1  joerg 	    func_fatal_error "you cannot specify '-o' more than once"
   3514  1.1  joerg 	  arg_mode=target
   3515  1.1  joerg 	  continue
   3516  1.1  joerg 	  ;;
   3517  1.1  joerg 
   3518  1.1  joerg 	-pie | -fpie | -fPIE)
   3519  1.1  joerg           func_append pie_flag " $arg"
   3520  1.1  joerg 	  continue
   3521  1.1  joerg 	  ;;
   3522  1.1  joerg 
   3523  1.1  joerg 	-shared | -static | -prefer-pic | -prefer-non-pic)
   3524  1.1  joerg 	  func_append later " $arg"
   3525  1.1  joerg 	  continue
   3526  1.1  joerg 	  ;;
   3527  1.1  joerg 
   3528  1.1  joerg 	-no-suppress)
   3529  1.1  joerg 	  suppress_opt=no
   3530  1.1  joerg 	  continue
   3531  1.1  joerg 	  ;;
   3532  1.1  joerg 
   3533  1.1  joerg 	-Xcompiler)
   3534  1.1  joerg 	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
   3535  1.1  joerg 	  continue      #  The current "srcfile" will either be retained or
   3536  1.1  joerg 	  ;;            #  replaced later.  I would guess that would be a bug.
   3537  1.1  joerg 
   3538  1.1  joerg 	-Wc,*)
   3539  1.1  joerg 	  func_stripname '-Wc,' '' "$arg"
   3540  1.1  joerg 	  args=$func_stripname_result
   3541  1.1  joerg 	  lastarg=
   3542  1.1  joerg 	  save_ifs=$IFS; IFS=,
   3543  1.1  joerg 	  for arg in $args; do
   3544  1.1  joerg 	    IFS=$save_ifs
   3545  1.1  joerg 	    func_append_quoted lastarg "$arg"
   3546  1.1  joerg 	  done
   3547  1.1  joerg 	  IFS=$save_ifs
   3548  1.1  joerg 	  func_stripname ' ' '' "$lastarg"
   3549  1.1  joerg 	  lastarg=$func_stripname_result
   3550  1.1  joerg 
   3551  1.1  joerg 	  # Add the arguments to base_compile.
   3552  1.1  joerg 	  func_append base_compile " $lastarg"
   3553  1.1  joerg 	  continue
   3554  1.1  joerg 	  ;;
   3555  1.1  joerg 
   3556  1.1  joerg 	*)
   3557  1.1  joerg 	  # Accept the current argument as the source file.
   3558  1.1  joerg 	  # The previous "srcfile" becomes the current argument.
   3559  1.1  joerg 	  #
   3560  1.1  joerg 	  lastarg=$srcfile
   3561  1.1  joerg 	  srcfile=$arg
   3562  1.1  joerg 	  ;;
   3563  1.1  joerg 	esac  #  case $arg
   3564  1.1  joerg 	;;
   3565  1.1  joerg       esac    #  case $arg_mode
   3566  1.1  joerg 
   3567  1.1  joerg       # Aesthetically quote the previous argument.
   3568  1.1  joerg       func_append_quoted base_compile "$lastarg"
   3569  1.1  joerg     done # for arg
   3570  1.1  joerg 
   3571  1.1  joerg     case $arg_mode in
   3572  1.1  joerg     arg)
   3573  1.1  joerg       func_fatal_error "you must specify an argument for -Xcompile"
   3574  1.1  joerg       ;;
   3575  1.1  joerg     target)
   3576  1.1  joerg       func_fatal_error "you must specify a target with '-o'"
   3577  1.1  joerg       ;;
   3578  1.1  joerg     *)
   3579  1.1  joerg       # Get the name of the library object.
   3580  1.1  joerg       test -z "$libobj" && {
   3581  1.1  joerg 	func_basename "$srcfile"
   3582  1.1  joerg 	libobj=$func_basename_result
   3583  1.1  joerg       }
   3584  1.1  joerg       ;;
   3585  1.1  joerg     esac
   3586  1.1  joerg 
   3587  1.1  joerg     # Recognize several different file suffixes.
   3588  1.1  joerg     # If the user specifies -o file.o, it is replaced with file.lo
   3589  1.1  joerg     case $libobj in
   3590  1.1  joerg     *.[cCFSifmso] | \
   3591  1.1  joerg     *.ada | *.adb | *.ads | *.asm | \
   3592  1.1  joerg     *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
   3593  1.1  joerg     *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
   3594  1.1  joerg       func_xform "$libobj"
   3595  1.1  joerg       libobj=$func_xform_result
   3596  1.1  joerg       ;;
   3597  1.1  joerg     esac
   3598  1.1  joerg 
   3599  1.1  joerg     case $libobj in
   3600  1.1  joerg     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
   3601  1.1  joerg     *)
   3602  1.1  joerg       func_fatal_error "cannot determine name of library object from '$libobj'"
   3603  1.1  joerg       ;;
   3604  1.1  joerg     esac
   3605  1.1  joerg 
   3606  1.1  joerg     func_infer_tag $base_compile
   3607  1.1  joerg 
   3608  1.1  joerg     for arg in $later; do
   3609  1.1  joerg       case $arg in
   3610  1.1  joerg       -shared)
   3611  1.1  joerg 	test yes = "$build_libtool_libs" \
   3612  1.1  joerg 	  || func_fatal_configuration "cannot build a shared library"
   3613  1.1  joerg 	build_old_libs=no
   3614  1.1  joerg 	continue
   3615  1.1  joerg 	;;
   3616  1.1  joerg 
   3617  1.1  joerg       -static)
   3618  1.1  joerg 	build_libtool_libs=no
   3619  1.1  joerg 	build_old_libs=yes
   3620  1.1  joerg 	continue
   3621  1.1  joerg 	;;
   3622  1.1  joerg 
   3623  1.1  joerg       -prefer-pic)
   3624  1.1  joerg 	pic_mode=yes
   3625  1.1  joerg 	continue
   3626  1.1  joerg 	;;
   3627  1.1  joerg 
   3628  1.1  joerg       -prefer-non-pic)
   3629  1.1  joerg 	pic_mode=no
   3630  1.1  joerg 	continue
   3631  1.1  joerg 	;;
   3632  1.1  joerg       esac
   3633  1.1  joerg     done
   3634  1.1  joerg 
   3635  1.1  joerg     func_quote_arg pretty "$libobj"
   3636  1.1  joerg     test "X$libobj" != "X$func_quote_arg_result" \
   3637  1.1  joerg       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
   3638  1.1  joerg       && func_warning "libobj name '$libobj' may not contain shell special characters."
   3639  1.1  joerg     func_dirname_and_basename "$obj" "/" ""
   3640  1.1  joerg     objname=$func_basename_result
   3641  1.1  joerg     xdir=$func_dirname_result
   3642  1.1  joerg     lobj=$xdir$objdir/$objname
   3643  1.1  joerg 
   3644  1.1  joerg     test -z "$base_compile" && \
   3645  1.1  joerg       func_fatal_help "you must specify a compilation command"
   3646  1.1  joerg 
   3647  1.1  joerg     # Delete any leftover library objects.
   3648  1.1  joerg     if test yes = "$build_old_libs"; then
   3649  1.1  joerg       removelist="$obj $lobj $libobj ${libobj}T"
   3650  1.1  joerg     else
   3651  1.1  joerg       removelist="$lobj $libobj ${libobj}T"
   3652  1.1  joerg     fi
   3653  1.1  joerg 
   3654  1.1  joerg     # On Cygwin there's no "real" PIC flag so we must build both object types
   3655  1.1  joerg     case $host_os in
   3656  1.1  joerg     cygwin* | mingw* | pw32* | os2* | cegcc*)
   3657  1.1  joerg       pic_mode=default
   3658  1.1  joerg       ;;
   3659  1.1  joerg     esac
   3660  1.1  joerg     if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
   3661  1.1  joerg       # non-PIC code in shared libraries is not supported
   3662  1.1  joerg       pic_mode=default
   3663  1.1  joerg     fi
   3664  1.1  joerg 
   3665  1.1  joerg     # Calculate the filename of the output object if compiler does
   3666  1.1  joerg     # not support -o with -c
   3667  1.1  joerg     if test no = "$compiler_c_o"; then
   3668  1.1  joerg       output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
   3669  1.1  joerg       lockfile=$output_obj.lock
   3670  1.1  joerg     else
   3671  1.1  joerg       output_obj=
   3672  1.1  joerg       need_locks=no
   3673  1.1  joerg       lockfile=
   3674  1.1  joerg     fi
   3675  1.1  joerg 
   3676  1.1  joerg     # Lock this critical section if it is needed
   3677  1.1  joerg     # We use this script file to make the link, it avoids creating a new file
   3678  1.1  joerg     if test yes = "$need_locks"; then
   3679  1.1  joerg       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
   3680  1.1  joerg 	func_echo "Waiting for $lockfile to be removed"
   3681  1.1  joerg 	sleep 2
   3682  1.1  joerg       done
   3683  1.1  joerg     elif test warn = "$need_locks"; then
   3684  1.1  joerg       if test -f "$lockfile"; then
   3685  1.1  joerg 	$ECHO "\
   3686  1.1  joerg *** ERROR, $lockfile exists and contains:
   3687  1.1  joerg `cat $lockfile 2>/dev/null`
   3688  1.1  joerg 
   3689  1.1  joerg This indicates that another process is trying to use the same
   3690  1.1  joerg temporary object file, and libtool could not work around it because
   3691  1.1  joerg your compiler does not support '-c' and '-o' together.  If you
   3692  1.1  joerg repeat this compilation, it may succeed, by chance, but you had better
   3693  1.1  joerg avoid parallel builds (make -j) in this platform, or get a better
   3694  1.1  joerg compiler."
   3695  1.1  joerg 
   3696  1.1  joerg 	$opt_dry_run || $RM $removelist
   3697  1.1  joerg 	exit $EXIT_FAILURE
   3698  1.1  joerg       fi
   3699  1.1  joerg       func_append removelist " $output_obj"
   3700  1.1  joerg       $ECHO "$srcfile" > "$lockfile"
   3701  1.1  joerg     fi
   3702  1.1  joerg 
   3703  1.1  joerg     $opt_dry_run || $RM $removelist
   3704  1.1  joerg     func_append removelist " $lockfile"
   3705  1.1  joerg     trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
   3706  1.1  joerg 
   3707  1.1  joerg     func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
   3708  1.1  joerg     srcfile=$func_to_tool_file_result
   3709  1.1  joerg     func_quote_arg pretty "$srcfile"
   3710  1.1  joerg     qsrcfile=$func_quote_arg_result
   3711  1.1  joerg 
   3712  1.1  joerg     # Only build a PIC object if we are building libtool libraries.
   3713  1.1  joerg     if test yes = "$build_libtool_libs"; then
   3714  1.1  joerg       # Without this assignment, base_compile gets emptied.
   3715  1.1  joerg       fbsd_hideous_sh_bug=$base_compile
   3716  1.1  joerg 
   3717  1.1  joerg       if test no != "$pic_mode"; then
   3718  1.1  joerg 	command="$base_compile $qsrcfile $pic_flag"
   3719  1.1  joerg       else
   3720  1.1  joerg 	# Don't build PIC code
   3721  1.1  joerg 	command="$base_compile $qsrcfile"
   3722  1.1  joerg       fi
   3723  1.1  joerg 
   3724  1.1  joerg       func_mkdir_p "$xdir$objdir"
   3725  1.1  joerg 
   3726  1.1  joerg       if test -z "$output_obj"; then
   3727  1.1  joerg 	# Place PIC objects in $objdir
   3728  1.1  joerg 	func_append command " -o $lobj"
   3729  1.1  joerg       fi
   3730  1.1  joerg 
   3731  1.1  joerg       func_show_eval_locale "$command"	\
   3732  1.1  joerg           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
   3733  1.1  joerg 
   3734  1.1  joerg       if test warn = "$need_locks" &&
   3735  1.1  joerg 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
   3736  1.1  joerg 	$ECHO "\
   3737  1.1  joerg *** ERROR, $lockfile contains:
   3738  1.1  joerg `cat $lockfile 2>/dev/null`
   3739  1.1  joerg 
   3740  1.1  joerg but it should contain:
   3741  1.1  joerg $srcfile
   3742  1.1  joerg 
   3743  1.1  joerg This indicates that another process is trying to use the same
   3744  1.1  joerg temporary object file, and libtool could not work around it because
   3745  1.1  joerg your compiler does not support '-c' and '-o' together.  If you
   3746  1.1  joerg repeat this compilation, it may succeed, by chance, but you had better
   3747  1.1  joerg avoid parallel builds (make -j) in this platform, or get a better
   3748  1.1  joerg compiler."
   3749  1.1  joerg 
   3750  1.1  joerg 	$opt_dry_run || $RM $removelist
   3751  1.1  joerg 	exit $EXIT_FAILURE
   3752  1.1  joerg       fi
   3753  1.1  joerg 
   3754  1.1  joerg       # Just move the object if needed, then go on to compile the next one
   3755  1.1  joerg       if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
   3756  1.1  joerg 	func_show_eval '$MV "$output_obj" "$lobj"' \
   3757  1.1  joerg 	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
   3758  1.1  joerg       fi
   3759  1.1  joerg 
   3760  1.1  joerg       # Allow error messages only from the first compilation.
   3761  1.1  joerg       if test yes = "$suppress_opt"; then
   3762  1.1  joerg 	suppress_output=' >/dev/null 2>&1'
   3763  1.1  joerg       fi
   3764  1.1  joerg     fi
   3765  1.1  joerg 
   3766  1.1  joerg     # Only build a position-dependent object if we build old libraries.
   3767  1.1  joerg     if test yes = "$build_old_libs"; then
   3768  1.1  joerg       if test yes != "$pic_mode"; then
   3769  1.1  joerg 	# Don't build PIC code
   3770  1.1  joerg 	command="$base_compile $qsrcfile$pie_flag"
   3771  1.1  joerg       else
   3772  1.1  joerg 	command="$base_compile $qsrcfile $pic_flag"
   3773  1.1  joerg       fi
   3774  1.1  joerg       if test yes = "$compiler_c_o"; then
   3775  1.1  joerg 	func_append command " -o $obj"
   3776  1.1  joerg       fi
   3777  1.1  joerg 
   3778  1.1  joerg       # Suppress compiler output if we already did a PIC compilation.
   3779  1.1  joerg       func_append command "$suppress_output"
   3780  1.1  joerg       func_show_eval_locale "$command" \
   3781  1.1  joerg         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
   3782  1.1  joerg 
   3783  1.1  joerg       if test warn = "$need_locks" &&
   3784  1.1  joerg 	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
   3785  1.1  joerg 	$ECHO "\
   3786  1.1  joerg *** ERROR, $lockfile contains:
   3787  1.1  joerg `cat $lockfile 2>/dev/null`
   3788  1.1  joerg 
   3789  1.1  joerg but it should contain:
   3790  1.1  joerg $srcfile
   3791  1.1  joerg 
   3792  1.1  joerg This indicates that another process is trying to use the same
   3793  1.1  joerg temporary object file, and libtool could not work around it because
   3794  1.1  joerg your compiler does not support '-c' and '-o' together.  If you
   3795  1.1  joerg repeat this compilation, it may succeed, by chance, but you had better
   3796  1.1  joerg avoid parallel builds (make -j) in this platform, or get a better
   3797  1.1  joerg compiler."
   3798  1.1  joerg 
   3799  1.1  joerg 	$opt_dry_run || $RM $removelist
   3800  1.1  joerg 	exit $EXIT_FAILURE
   3801  1.1  joerg       fi
   3802  1.1  joerg 
   3803  1.1  joerg       # Just move the object if needed
   3804  1.1  joerg       if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
   3805  1.1  joerg 	func_show_eval '$MV "$output_obj" "$obj"' \
   3806  1.1  joerg 	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
   3807  1.1  joerg       fi
   3808  1.1  joerg     fi
   3809  1.1  joerg 
   3810  1.1  joerg     $opt_dry_run || {
   3811  1.1  joerg       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
   3812  1.1  joerg 
   3813  1.1  joerg       # Unlock the critical section if it was locked
   3814  1.1  joerg       if test no != "$need_locks"; then
   3815  1.1  joerg 	removelist=$lockfile
   3816  1.1  joerg         $RM "$lockfile"
   3817  1.1  joerg       fi
   3818  1.1  joerg     }
   3819  1.1  joerg 
   3820  1.1  joerg     exit $EXIT_SUCCESS
   3821  1.1  joerg }
   3822  1.1  joerg 
   3823  1.1  joerg $opt_help || {
   3824  1.1  joerg   test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
   3825  1.1  joerg }
   3826  1.1  joerg 
   3827  1.1  joerg func_mode_help ()
   3828  1.1  joerg {
   3829  1.1  joerg     # We need to display help for each of the modes.
   3830  1.1  joerg     case $opt_mode in
   3831  1.1  joerg       "")
   3832  1.1  joerg         # Generic help is extracted from the usage comments
   3833  1.1  joerg         # at the start of this file.
   3834  1.1  joerg         func_help
   3835  1.1  joerg         ;;
   3836  1.1  joerg 
   3837  1.1  joerg       clean)
   3838  1.1  joerg         $ECHO \
   3839  1.1  joerg "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
   3840  1.1  joerg 
   3841  1.1  joerg Remove files from the build directory.
   3842  1.1  joerg 
   3843  1.1  joerg RM is the name of the program to use to delete files associated with each FILE
   3844  1.1  joerg (typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
   3845  1.1  joerg to RM.
   3846  1.1  joerg 
   3847  1.1  joerg If FILE is a libtool library, object or program, all the files associated
   3848  1.1  joerg with it are deleted. Otherwise, only FILE itself is deleted using RM."
   3849  1.1  joerg         ;;
   3850  1.1  joerg 
   3851  1.1  joerg       compile)
   3852  1.1  joerg       $ECHO \
   3853  1.1  joerg "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
   3854  1.1  joerg 
   3855  1.1  joerg Compile a source file into a libtool library object.
   3856  1.1  joerg 
   3857  1.1  joerg This mode accepts the following additional options:
   3858  1.1  joerg 
   3859  1.1  joerg   -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
   3860  1.1  joerg   -no-suppress      do not suppress compiler output for multiple passes
   3861  1.1  joerg   -prefer-pic       try to build PIC objects only
   3862  1.1  joerg   -prefer-non-pic   try to build non-PIC objects only
   3863  1.1  joerg   -shared           do not build a '.o' file suitable for static linking
   3864  1.1  joerg   -static           only build a '.o' file suitable for static linking
   3865  1.1  joerg   -Wc,FLAG          pass FLAG directly to the compiler
   3866  1.1  joerg 
   3867  1.1  joerg COMPILE-COMMAND is a command to be used in creating a 'standard' object file
   3868  1.1  joerg from the given SOURCEFILE.
   3869  1.1  joerg 
   3870  1.1  joerg The output file name is determined by removing the directory component from
   3871  1.1  joerg SOURCEFILE, then substituting the C source code suffix '.c' with the
   3872  1.1  joerg library object suffix, '.lo'."
   3873  1.1  joerg         ;;
   3874  1.1  joerg 
   3875  1.1  joerg       execute)
   3876  1.1  joerg         $ECHO \
   3877  1.1  joerg "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
   3878  1.1  joerg 
   3879  1.1  joerg Automatically set library path, then run a program.
   3880  1.1  joerg 
   3881  1.1  joerg This mode accepts the following additional options:
   3882  1.1  joerg 
   3883  1.1  joerg   -dlopen FILE      add the directory containing FILE to the library path
   3884  1.1  joerg 
   3885  1.1  joerg This mode sets the library path environment variable according to '-dlopen'
   3886  1.1  joerg flags.
   3887  1.1  joerg 
   3888  1.1  joerg If any of the ARGS are libtool executable wrappers, then they are translated
   3889  1.1  joerg into their corresponding uninstalled binary, and any of their required library
   3890  1.1  joerg directories are added to the library path.
   3891  1.1  joerg 
   3892  1.1  joerg Then, COMMAND is executed, with ARGS as arguments."
   3893  1.1  joerg         ;;
   3894  1.1  joerg 
   3895  1.1  joerg       finish)
   3896  1.1  joerg         $ECHO \
   3897  1.1  joerg "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
   3898  1.1  joerg 
   3899  1.1  joerg Complete the installation of libtool libraries.
   3900  1.1  joerg 
   3901  1.1  joerg Each LIBDIR is a directory that contains libtool libraries.
   3902  1.1  joerg 
   3903  1.1  joerg The commands that this mode executes may require superuser privileges.  Use
   3904  1.1  joerg the '--dry-run' option if you just want to see what would be executed."
   3905  1.1  joerg         ;;
   3906  1.1  joerg 
   3907  1.1  joerg       install)
   3908  1.1  joerg         $ECHO \
   3909  1.1  joerg "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
   3910  1.1  joerg 
   3911  1.1  joerg Install executables or libraries.
   3912  1.1  joerg 
   3913  1.1  joerg INSTALL-COMMAND is the installation command.  The first component should be
   3914  1.1  joerg either the 'install' or 'cp' program.
   3915  1.1  joerg 
   3916  1.1  joerg The following components of INSTALL-COMMAND are treated specially:
   3917  1.1  joerg 
   3918  1.1  joerg   -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
   3919  1.1  joerg 
   3920  1.1  joerg The rest of the components are interpreted as arguments to that command (only
   3921  1.1  joerg BSD-compatible install options are recognized)."
   3922  1.1  joerg         ;;
   3923  1.1  joerg 
   3924  1.1  joerg       link)
   3925  1.1  joerg         $ECHO \
   3926  1.1  joerg "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
   3927  1.1  joerg 
   3928  1.1  joerg Link object files or libraries together to form another library, or to
   3929  1.1  joerg create an executable program.
   3930  1.1  joerg 
   3931  1.1  joerg LINK-COMMAND is a command using the C compiler that you would use to create
   3932  1.1  joerg a program from several object files.
   3933  1.1  joerg 
   3934  1.1  joerg The following components of LINK-COMMAND are treated specially:
   3935  1.1  joerg 
   3936  1.1  joerg   -all-static       do not do any dynamic linking at all
   3937  1.1  joerg   -avoid-version    do not add a version suffix if possible
   3938  1.1  joerg   -bindir BINDIR    specify path to binaries directory (for systems where
   3939  1.1  joerg                     libraries must be found in the PATH setting at runtime)
   3940  1.1  joerg   -dlopen FILE      '-dlpreopen' FILE if it cannot be dlopened at runtime
   3941  1.1  joerg   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
   3942  1.1  joerg   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
   3943  1.1  joerg   -export-symbols SYMFILE
   3944  1.1  joerg                     try to export only the symbols listed in SYMFILE
   3945  1.1  joerg   -export-symbols-regex REGEX
   3946  1.1  joerg                     try to export only the symbols matching REGEX
   3947  1.1  joerg   -LLIBDIR          search LIBDIR for required installed libraries
   3948  1.1  joerg   -lNAME            OUTPUT-FILE requires the installed library libNAME
   3949  1.1  joerg   -module           build a library that can dlopened
   3950  1.1  joerg   -no-fast-install  disable the fast-install mode
   3951  1.1  joerg   -no-install       link a not-installable executable
   3952  1.1  joerg   -no-undefined     declare that a library does not refer to external symbols
   3953  1.1  joerg   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
   3954  1.1  joerg   -objectlist FILE  use a list of object files found in FILE to specify objects
   3955  1.1  joerg   -os2dllname NAME  force a short DLL name on OS/2 (no effect on other OSes)
   3956  1.1  joerg   -precious-files-regex REGEX
   3957  1.1  joerg                     don't remove output files matching REGEX
   3958  1.1  joerg   -release RELEASE  specify package release information
   3959  1.1  joerg   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
   3960  1.1  joerg   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
   3961  1.1  joerg   -shared           only do dynamic linking of libtool libraries
   3962  1.1  joerg   -shrext SUFFIX    override the standard shared library file extension
   3963  1.1  joerg   -static           do not do any dynamic linking of uninstalled libtool libraries
   3964  1.1  joerg   -static-libtool-libs
   3965  1.1  joerg                     do not do any dynamic linking of libtool libraries
   3966  1.1  joerg   -version-info CURRENT[:REVISION[:AGE]]
   3967  1.1  joerg                     specify library version info [each variable defaults to 0]
   3968  1.1  joerg   -weak LIBNAME     declare that the target provides the LIBNAME interface
   3969  1.1  joerg   -Wc,FLAG
   3970  1.1  joerg   -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
   3971  1.1  joerg   -Wl,FLAG
   3972  1.1  joerg   -Xlinker FLAG     pass linker-specific FLAG directly to the linker
   3973  1.1  joerg   -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
   3974  1.1  joerg 
   3975  1.1  joerg All other options (arguments beginning with '-') are ignored.
   3976  1.1  joerg 
   3977  1.1  joerg Every other argument is treated as a filename.  Files ending in '.la' are
   3978  1.1  joerg treated as uninstalled libtool libraries, other files are standard or library
   3979  1.1  joerg object files.
   3980  1.1  joerg 
   3981  1.1  joerg If the OUTPUT-FILE ends in '.la', then a libtool library is created,
   3982  1.1  joerg only library objects ('.lo' files) may be specified, and '-rpath' is
   3983  1.1  joerg required, except when creating a convenience library.
   3984  1.1  joerg 
   3985  1.1  joerg If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
   3986  1.1  joerg using 'ar' and 'ranlib', or on Windows using 'lib'.
   3987  1.1  joerg 
   3988  1.1  joerg If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
   3989  1.1  joerg is created, otherwise an executable program is created."
   3990  1.1  joerg         ;;
   3991  1.1  joerg 
   3992  1.1  joerg       uninstall)
   3993  1.1  joerg         $ECHO \
   3994  1.1  joerg "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
   3995  1.1  joerg 
   3996  1.1  joerg Remove libraries from an installation directory.
   3997  1.1  joerg 
   3998  1.1  joerg RM is the name of the program to use to delete files associated with each FILE
   3999  1.1  joerg (typically '/bin/rm').  RM-OPTIONS are options (such as '-f') to be passed
   4000  1.1  joerg to RM.
   4001  1.1  joerg 
   4002  1.1  joerg If FILE is a libtool library, all the files associated with it are deleted.
   4003  1.1  joerg Otherwise, only FILE itself is deleted using RM."
   4004  1.1  joerg         ;;
   4005  1.1  joerg 
   4006  1.1  joerg       *)
   4007  1.1  joerg         func_fatal_help "invalid operation mode '$opt_mode'"
   4008  1.1  joerg         ;;
   4009  1.1  joerg     esac
   4010  1.1  joerg 
   4011  1.1  joerg     echo
   4012  1.1  joerg     $ECHO "Try '$progname --help' for more information about other modes."
   4013  1.1  joerg }
   4014  1.1  joerg 
   4015  1.1  joerg # Now that we've collected a possible --mode arg, show help if necessary
   4016  1.1  joerg if $opt_help; then
   4017  1.1  joerg   if test : = "$opt_help"; then
   4018  1.1  joerg     func_mode_help
   4019  1.1  joerg   else
   4020  1.1  joerg     {
   4021  1.1  joerg       func_help noexit
   4022  1.1  joerg       for opt_mode in compile link execute install finish uninstall clean; do
   4023  1.1  joerg 	func_mode_help
   4024  1.1  joerg       done
   4025  1.1  joerg     } | $SED -n '1p; 2,$s/^Usage:/  or: /p'
   4026  1.1  joerg     {
   4027  1.1  joerg       func_help noexit
   4028  1.1  joerg       for opt_mode in compile link execute install finish uninstall clean; do
   4029  1.1  joerg 	echo
   4030  1.1  joerg 	func_mode_help
   4031  1.1  joerg       done
   4032  1.1  joerg     } |
   4033  1.1  joerg     $SED '1d
   4034  1.1  joerg       /^When reporting/,/^Report/{
   4035  1.1  joerg 	H
   4036  1.1  joerg 	d
   4037  1.1  joerg       }
   4038  1.1  joerg       $x
   4039  1.1  joerg       /information about other modes/d
   4040  1.1  joerg       /more detailed .*MODE/d
   4041  1.1  joerg       s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
   4042  1.1  joerg   fi
   4043  1.1  joerg   exit $?
   4044  1.1  joerg fi
   4045  1.1  joerg 
   4046  1.1  joerg 
   4047  1.1  joerg # func_mode_execute arg...
   4048  1.1  joerg func_mode_execute ()
   4049  1.1  joerg {
   4050  1.1  joerg     $debug_cmd
   4051  1.1  joerg 
   4052  1.1  joerg     # The first argument is the command name.
   4053  1.1  joerg     cmd=$nonopt
   4054  1.1  joerg     test -z "$cmd" && \
   4055  1.1  joerg       func_fatal_help "you must specify a COMMAND"
   4056  1.1  joerg 
   4057  1.1  joerg     # Handle -dlopen flags immediately.
   4058  1.1  joerg     for file in $opt_dlopen; do
   4059  1.1  joerg       test -f "$file" \
   4060  1.1  joerg 	|| func_fatal_help "'$file' is not a file"
   4061  1.1  joerg 
   4062  1.1  joerg       dir=
   4063  1.1  joerg       case $file in
   4064  1.1  joerg       *.la)
   4065  1.1  joerg 	func_resolve_sysroot "$file"
   4066  1.1  joerg 	file=$func_resolve_sysroot_result
   4067  1.1  joerg 
   4068  1.1  joerg 	# Check to see that this really is a libtool archive.
   4069  1.1  joerg 	func_lalib_unsafe_p "$file" \
   4070  1.1  joerg 	  || func_fatal_help "'$lib' is not a valid libtool archive"
   4071  1.1  joerg 
   4072  1.1  joerg 	# Read the libtool library.
   4073  1.1  joerg 	dlname=
   4074  1.1  joerg 	library_names=
   4075  1.1  joerg 	func_source "$file"
   4076  1.1  joerg 
   4077  1.1  joerg 	# Skip this library if it cannot be dlopened.
   4078  1.1  joerg 	if test -z "$dlname"; then
   4079  1.1  joerg 	  # Warn if it was a shared library.
   4080  1.1  joerg 	  test -n "$library_names" && \
   4081  1.1  joerg 	    func_warning "'$file' was not linked with '-export-dynamic'"
   4082  1.1  joerg 	  continue
   4083  1.1  joerg 	fi
   4084  1.1  joerg 
   4085  1.1  joerg 	func_dirname "$file" "" "."
   4086  1.1  joerg 	dir=$func_dirname_result
   4087  1.1  joerg 
   4088  1.1  joerg 	if test -f "$dir/$objdir/$dlname"; then
   4089  1.1  joerg 	  func_append dir "/$objdir"
   4090  1.1  joerg 	else
   4091  1.1  joerg 	  if test ! -f "$dir/$dlname"; then
   4092  1.1  joerg 	    func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
   4093  1.1  joerg 	  fi
   4094  1.1  joerg 	fi
   4095  1.1  joerg 	;;
   4096  1.1  joerg 
   4097  1.1  joerg       *.lo)
   4098  1.1  joerg 	# Just add the directory containing the .lo file.
   4099  1.1  joerg 	func_dirname "$file" "" "."
   4100  1.1  joerg 	dir=$func_dirname_result
   4101  1.1  joerg 	;;
   4102  1.1  joerg 
   4103  1.1  joerg       *)
   4104  1.1  joerg 	func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
   4105  1.1  joerg 	continue
   4106  1.1  joerg 	;;
   4107  1.1  joerg       esac
   4108  1.1  joerg 
   4109  1.1  joerg       # Get the absolute pathname.
   4110  1.1  joerg       absdir=`cd "$dir" && pwd`
   4111  1.1  joerg       test -n "$absdir" && dir=$absdir
   4112  1.1  joerg 
   4113  1.1  joerg       # Now add the directory to shlibpath_var.
   4114  1.1  joerg       if eval "test -z \"\$$shlibpath_var\""; then
   4115  1.1  joerg 	eval "$shlibpath_var=\"\$dir\""
   4116  1.1  joerg       else
   4117  1.1  joerg 	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
   4118  1.1  joerg       fi
   4119  1.1  joerg     done
   4120  1.1  joerg 
   4121  1.1  joerg     # This variable tells wrapper scripts just to set shlibpath_var
   4122  1.1  joerg     # rather than running their programs.
   4123  1.1  joerg     libtool_execute_magic=$magic
   4124  1.1  joerg 
   4125  1.1  joerg     # Check if any of the arguments is a wrapper script.
   4126  1.1  joerg     args=
   4127  1.1  joerg     for file
   4128  1.1  joerg     do
   4129  1.1  joerg       case $file in
   4130  1.1  joerg       -* | *.la | *.lo ) ;;
   4131  1.1  joerg       *)
   4132  1.1  joerg 	# Do a test to see if this is really a libtool program.
   4133  1.1  joerg 	if func_ltwrapper_script_p "$file"; then
   4134  1.1  joerg 	  func_source "$file"
   4135  1.1  joerg 	  # Transform arg to wrapped name.
   4136  1.1  joerg 	  file=$progdir/$program
   4137  1.1  joerg 	elif func_ltwrapper_executable_p "$file"; then
   4138  1.1  joerg 	  func_ltwrapper_scriptname "$file"
   4139  1.1  joerg 	  func_source "$func_ltwrapper_scriptname_result"
   4140  1.1  joerg 	  # Transform arg to wrapped name.
   4141  1.1  joerg 	  file=$progdir/$program
   4142  1.1  joerg 	fi
   4143  1.1  joerg 	;;
   4144  1.1  joerg       esac
   4145  1.1  joerg       # Quote arguments (to preserve shell metacharacters).
   4146  1.1  joerg       func_append_quoted args "$file"
   4147  1.1  joerg     done
   4148  1.1  joerg 
   4149  1.1  joerg     if $opt_dry_run; then
   4150  1.1  joerg       # Display what would be done.
   4151  1.1  joerg       if test -n "$shlibpath_var"; then
   4152  1.1  joerg 	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
   4153  1.1  joerg 	echo "export $shlibpath_var"
   4154  1.1  joerg       fi
   4155  1.1  joerg       $ECHO "$cmd$args"
   4156  1.1  joerg       exit $EXIT_SUCCESS
   4157  1.1  joerg     else
   4158  1.1  joerg       if test -n "$shlibpath_var"; then
   4159  1.1  joerg 	# Export the shlibpath_var.
   4160  1.1  joerg 	eval "export $shlibpath_var"
   4161  1.1  joerg       fi
   4162  1.1  joerg 
   4163  1.1  joerg       # Restore saved environment variables
   4164  1.1  joerg       for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
   4165  1.1  joerg       do
   4166  1.1  joerg 	eval "if test \"\${save_$lt_var+set}\" = set; then
   4167  1.1  joerg                 $lt_var=\$save_$lt_var; export $lt_var
   4168  1.1  joerg 	      else
   4169  1.1  joerg 		$lt_unset $lt_var
   4170  1.1  joerg 	      fi"
   4171  1.1  joerg       done
   4172  1.1  joerg 
   4173  1.1  joerg       # Now prepare to actually exec the command.
   4174  1.1  joerg       exec_cmd=\$cmd$args
   4175  1.1  joerg     fi
   4176  1.1  joerg }
   4177  1.1  joerg 
   4178  1.1  joerg test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
   4179  1.1  joerg 
   4180  1.1  joerg 
   4181  1.1  joerg # func_mode_finish arg...
   4182  1.1  joerg func_mode_finish ()
   4183  1.1  joerg {
   4184  1.1  joerg     $debug_cmd
   4185  1.1  joerg 
   4186  1.1  joerg     libs=
   4187  1.1  joerg     libdirs=
   4188  1.1  joerg     admincmds=
   4189  1.1  joerg 
   4190  1.1  joerg     for opt in "$nonopt" ${1+"$@"}
   4191  1.1  joerg     do
   4192  1.1  joerg       if test -d "$opt"; then
   4193  1.1  joerg 	func_append libdirs " $opt"
   4194  1.1  joerg 
   4195  1.1  joerg       elif test -f "$opt"; then
   4196  1.1  joerg 	if func_lalib_unsafe_p "$opt"; then
   4197  1.1  joerg 	  func_append libs " $opt"
   4198  1.1  joerg 	else
   4199  1.1  joerg 	  func_warning "'$opt' is not a valid libtool archive"
   4200  1.1  joerg 	fi
   4201  1.1  joerg 
   4202  1.1  joerg       else
   4203  1.1  joerg 	func_fatal_error "invalid argument '$opt'"
   4204  1.1  joerg       fi
   4205  1.1  joerg     done
   4206  1.1  joerg 
   4207  1.1  joerg     if test -n "$libs"; then
   4208  1.1  joerg       if test -n "$lt_sysroot"; then
   4209  1.1  joerg         sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
   4210  1.1  joerg         sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
   4211  1.1  joerg       else
   4212  1.1  joerg         sysroot_cmd=
   4213  1.1  joerg       fi
   4214  1.1  joerg 
   4215  1.1  joerg       # Remove sysroot references
   4216  1.1  joerg       if $opt_dry_run; then
   4217  1.1  joerg         for lib in $libs; do
   4218  1.1  joerg           echo "removing references to $lt_sysroot and '=' prefixes from $lib"
   4219  1.1  joerg         done
   4220  1.1  joerg       else
   4221  1.1  joerg         tmpdir=`func_mktempdir`
   4222  1.1  joerg         for lib in $libs; do
   4223  1.1  joerg 	  $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
   4224  1.1  joerg 	    > $tmpdir/tmp-la
   4225  1.1  joerg 	  mv -f $tmpdir/tmp-la $lib
   4226  1.1  joerg 	done
   4227  1.1  joerg         ${RM}r "$tmpdir"
   4228  1.1  joerg       fi
   4229  1.1  joerg     fi
   4230  1.1  joerg 
   4231  1.1  joerg     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
   4232  1.1  joerg       for libdir in $libdirs; do
   4233  1.1  joerg 	if test -n "$finish_cmds"; then
   4234  1.1  joerg 	  # Do each command in the finish commands.
   4235  1.1  joerg 	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
   4236  1.1  joerg '"$cmd"'"'
   4237  1.1  joerg 	fi
   4238  1.1  joerg 	if test -n "$finish_eval"; then
   4239  1.1  joerg 	  # Do the single finish_eval.
   4240  1.1  joerg 	  eval cmds=\"$finish_eval\"
   4241  1.1  joerg 	  $opt_dry_run || eval "$cmds" || func_append admincmds "
   4242  1.1  joerg        $cmds"
   4243  1.1  joerg 	fi
   4244  1.1  joerg       done
   4245  1.1  joerg     fi
   4246  1.1  joerg 
   4247  1.1  joerg     # Exit here if they wanted silent mode.
   4248  1.1  joerg     $opt_quiet && exit $EXIT_SUCCESS
   4249  1.1  joerg 
   4250  1.1  joerg     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
   4251  1.1  joerg       echo "----------------------------------------------------------------------"
   4252  1.1  joerg       echo "Libraries have been installed in:"
   4253  1.1  joerg       for libdir in $libdirs; do
   4254  1.1  joerg 	$ECHO "   $libdir"
   4255  1.1  joerg       done
   4256  1.1  joerg       echo
   4257  1.1  joerg       echo "If you ever happen to want to link against installed libraries"
   4258  1.1  joerg       echo "in a given directory, LIBDIR, you must either use libtool, and"
   4259  1.1  joerg       echo "specify the full pathname of the library, or use the '-LLIBDIR'"
   4260  1.1  joerg       echo "flag during linking and do at least one of the following:"
   4261  1.1  joerg       if test -n "$shlibpath_var"; then
   4262  1.1  joerg 	echo "   - add LIBDIR to the '$shlibpath_var' environment variable"
   4263  1.1  joerg 	echo "     during execution"
   4264  1.1  joerg       fi
   4265  1.1  joerg       if test -n "$runpath_var"; then
   4266  1.1  joerg 	echo "   - add LIBDIR to the '$runpath_var' environment variable"
   4267  1.1  joerg 	echo "     during linking"
   4268  1.1  joerg       fi
   4269  1.1  joerg       if test -n "$hardcode_libdir_flag_spec"; then
   4270  1.1  joerg 	libdir=LIBDIR
   4271  1.1  joerg 	eval flag=\"$hardcode_libdir_flag_spec\"
   4272  1.1  joerg 
   4273  1.1  joerg 	$ECHO "   - use the '$flag' linker flag"
   4274  1.1  joerg       fi
   4275  1.1  joerg       if test -n "$admincmds"; then
   4276  1.1  joerg 	$ECHO "   - have your system administrator run these commands:$admincmds"
   4277  1.1  joerg       fi
   4278  1.1  joerg       if test -f /etc/ld.so.conf; then
   4279  1.1  joerg 	echo "   - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
   4280  1.1  joerg       fi
   4281  1.1  joerg       echo
   4282  1.1  joerg 
   4283  1.1  joerg       echo "See any operating system documentation about shared libraries for"
   4284  1.1  joerg       case $host in
   4285  1.1  joerg 	solaris2.[6789]|solaris2.1[0-9])
   4286  1.1  joerg 	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
   4287  1.1  joerg 	  echo "pages."
   4288  1.1  joerg 	  ;;
   4289  1.1  joerg 	*)
   4290  1.1  joerg 	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
   4291  1.1  joerg 	  ;;
   4292  1.1  joerg       esac
   4293  1.1  joerg       echo "----------------------------------------------------------------------"
   4294  1.1  joerg     fi
   4295  1.1  joerg     exit $EXIT_SUCCESS
   4296  1.1  joerg }
   4297  1.1  joerg 
   4298  1.1  joerg test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
   4299  1.1  joerg 
   4300  1.1  joerg 
   4301  1.1  joerg # func_mode_install arg...
   4302  1.1  joerg func_mode_install ()
   4303  1.1  joerg {
   4304  1.1  joerg     $debug_cmd
   4305  1.1  joerg 
   4306  1.1  joerg     # There may be an optional sh(1) argument at the beginning of
   4307  1.1  joerg     # install_prog (especially on Windows NT).
   4308  1.1  joerg     if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
   4309  1.1  joerg        # Allow the use of GNU shtool's install command.
   4310  1.1  joerg        case $nonopt in *shtool*) :;; *) false;; esac
   4311  1.1  joerg     then
   4312  1.1  joerg       # Aesthetically quote it.
   4313  1.1  joerg       func_quote_arg pretty "$nonopt"
   4314  1.1  joerg       install_prog="$func_quote_arg_result "
   4315  1.1  joerg       arg=$1
   4316  1.1  joerg       shift
   4317  1.1  joerg     else
   4318  1.1  joerg       install_prog=
   4319  1.1  joerg       arg=$nonopt
   4320  1.1  joerg     fi
   4321  1.1  joerg 
   4322  1.1  joerg     # The real first argument should be the name of the installation program.
   4323  1.1  joerg     # Aesthetically quote it.
   4324  1.1  joerg     func_quote_arg pretty "$arg"
   4325  1.1  joerg     func_append install_prog "$func_quote_arg_result"
   4326  1.1  joerg     install_shared_prog=$install_prog
   4327  1.1  joerg     case " $install_prog " in
   4328  1.1  joerg       *[\\\ /]cp\ *) install_cp=: ;;
   4329  1.1  joerg       *) install_cp=false ;;
   4330  1.1  joerg     esac
   4331  1.1  joerg 
   4332  1.1  joerg     # We need to accept at least all the BSD install flags.
   4333  1.1  joerg     dest=
   4334  1.1  joerg     files=
   4335  1.1  joerg     opts=
   4336  1.1  joerg     prev=
   4337  1.1  joerg     install_type=
   4338  1.1  joerg     isdir=false
   4339  1.1  joerg     stripme=
   4340  1.1  joerg     no_mode=:
   4341  1.1  joerg     for arg
   4342  1.1  joerg     do
   4343  1.1  joerg       arg2=
   4344  1.1  joerg       if test -n "$dest"; then
   4345  1.1  joerg 	func_append files " $dest"
   4346  1.1  joerg 	dest=$arg
   4347  1.1  joerg 	continue
   4348  1.1  joerg       fi
   4349  1.1  joerg 
   4350  1.1  joerg       case $arg in
   4351  1.1  joerg       -d) isdir=: ;;
   4352  1.1  joerg       -f)
   4353  1.1  joerg 	if $install_cp; then :; else
   4354  1.1  joerg 	  prev=$arg
   4355  1.1  joerg 	fi
   4356  1.1  joerg 	;;
   4357  1.1  joerg       -g | -m | -o)
   4358  1.1  joerg 	prev=$arg
   4359  1.1  joerg 	;;
   4360  1.1  joerg       -s)
   4361  1.1  joerg 	stripme=" -s"
   4362  1.1  joerg 	continue
   4363  1.1  joerg 	;;
   4364  1.1  joerg       -*)
   4365  1.1  joerg 	;;
   4366  1.1  joerg       *)
   4367  1.1  joerg 	# If the previous option needed an argument, then skip it.
   4368  1.1  joerg 	if test -n "$prev"; then
   4369  1.1  joerg 	  if test X-m = "X$prev" && test -n "$install_override_mode"; then
   4370  1.1  joerg 	    arg2=$install_override_mode
   4371  1.1  joerg 	    no_mode=false
   4372  1.1  joerg 	  fi
   4373  1.1  joerg 	  prev=
   4374  1.1  joerg 	else
   4375  1.1  joerg 	  dest=$arg
   4376  1.1  joerg 	  continue
   4377  1.1  joerg 	fi
   4378  1.1  joerg 	;;
   4379  1.1  joerg       esac
   4380  1.1  joerg 
   4381  1.1  joerg       # Aesthetically quote the argument.
   4382  1.1  joerg       func_quote_arg pretty "$arg"
   4383  1.1  joerg       func_append install_prog " $func_quote_arg_result"
   4384  1.1  joerg       if test -n "$arg2"; then
   4385  1.1  joerg 	func_quote_arg pretty "$arg2"
   4386  1.1  joerg       fi
   4387  1.1  joerg       func_append install_shared_prog " $func_quote_arg_result"
   4388  1.1  joerg     done
   4389  1.1  joerg 
   4390  1.1  joerg     test -z "$install_prog" && \
   4391  1.1  joerg       func_fatal_help "you must specify an install program"
   4392  1.1  joerg 
   4393  1.1  joerg     test -n "$prev" && \
   4394  1.1  joerg       func_fatal_help "the '$prev' option requires an argument"
   4395  1.1  joerg 
   4396  1.1  joerg     if test -n "$install_override_mode" && $no_mode; then
   4397  1.1  joerg       if $install_cp; then :; else
   4398  1.1  joerg 	func_quote_arg pretty "$install_override_mode"
   4399  1.1  joerg 	func_append install_shared_prog " -m $func_quote_arg_result"
   4400  1.1  joerg       fi
   4401  1.1  joerg     fi
   4402  1.1  joerg 
   4403  1.1  joerg     if test -z "$files"; then
   4404  1.1  joerg       if test -z "$dest"; then
   4405  1.1  joerg 	func_fatal_help "no file or destination specified"
   4406  1.1  joerg       else
   4407  1.1  joerg 	func_fatal_help "you must specify a destination"
   4408  1.1  joerg       fi
   4409  1.1  joerg     fi
   4410  1.1  joerg 
   4411  1.1  joerg     # Strip any trailing slash from the destination.
   4412  1.1  joerg     func_stripname '' '/' "$dest"
   4413  1.1  joerg     dest=$func_stripname_result
   4414  1.1  joerg 
   4415  1.1  joerg     # Check to see that the destination is a directory.
   4416  1.1  joerg     test -d "$dest" && isdir=:
   4417  1.1  joerg     if $isdir; then
   4418  1.1  joerg       destdir=$dest
   4419  1.1  joerg       destname=
   4420  1.1  joerg     else
   4421  1.1  joerg       func_dirname_and_basename "$dest" "" "."
   4422  1.1  joerg       destdir=$func_dirname_result
   4423  1.1  joerg       destname=$func_basename_result
   4424  1.1  joerg 
   4425  1.1  joerg       # Not a directory, so check to see that there is only one file specified.
   4426  1.1  joerg       set dummy $files; shift
   4427  1.1  joerg       test "$#" -gt 1 && \
   4428  1.1  joerg 	func_fatal_help "'$dest' is not a directory"
   4429  1.1  joerg     fi
   4430  1.1  joerg     case $destdir in
   4431  1.1  joerg     [\\/]* | [A-Za-z]:[\\/]*) ;;
   4432  1.1  joerg     *)
   4433  1.1  joerg       for file in $files; do
   4434  1.1  joerg 	case $file in
   4435  1.1  joerg 	*.lo) ;;
   4436  1.1  joerg 	*)
   4437  1.1  joerg 	  func_fatal_help "'$destdir' must be an absolute directory name"
   4438  1.1  joerg 	  ;;
   4439  1.1  joerg 	esac
   4440  1.1  joerg       done
   4441  1.1  joerg       ;;
   4442  1.1  joerg     esac
   4443  1.1  joerg 
   4444  1.1  joerg     # This variable tells wrapper scripts just to set variables rather
   4445  1.1  joerg     # than running their programs.
   4446  1.1  joerg     libtool_install_magic=$magic
   4447  1.1  joerg 
   4448  1.1  joerg     staticlibs=
   4449  1.1  joerg     future_libdirs=
   4450  1.1  joerg     current_libdirs=
   4451  1.1  joerg     for file in $files; do
   4452  1.1  joerg 
   4453  1.1  joerg       # Do each installation.
   4454  1.1  joerg       case $file in
   4455  1.1  joerg       *.$libext)
   4456  1.1  joerg 	# Do the static libraries later.
   4457  1.1  joerg 	func_append staticlibs " $file"
   4458  1.1  joerg 	;;
   4459  1.1  joerg 
   4460  1.1  joerg       *.la)
   4461  1.1  joerg 	func_resolve_sysroot "$file"
   4462  1.1  joerg 	file=$func_resolve_sysroot_result
   4463  1.1  joerg 
   4464  1.1  joerg 	# Check to see that this really is a libtool archive.
   4465  1.1  joerg 	func_lalib_unsafe_p "$file" \
   4466  1.1  joerg 	  || func_fatal_help "'$file' is not a valid libtool archive"
   4467  1.1  joerg 
   4468  1.1  joerg 	library_names=
   4469  1.1  joerg 	old_library=
   4470  1.1  joerg 	relink_command=
   4471  1.1  joerg 	func_source "$file"
   4472  1.1  joerg 
   4473  1.1  joerg 	# Add the libdir to current_libdirs if it is the destination.
   4474  1.1  joerg 	if test "X$destdir" = "X$libdir"; then
   4475  1.1  joerg 	  case "$current_libdirs " in
   4476  1.1  joerg 	  *" $libdir "*) ;;
   4477  1.1  joerg 	  *) func_append current_libdirs " $libdir" ;;
   4478  1.1  joerg 	  esac
   4479  1.1  joerg 	else
   4480  1.1  joerg 	  # Note the libdir as a future libdir.
   4481  1.1  joerg 	  case "$future_libdirs " in
   4482  1.1  joerg 	  *" $libdir "*) ;;
   4483  1.1  joerg 	  *) func_append future_libdirs " $libdir" ;;
   4484  1.1  joerg 	  esac
   4485  1.1  joerg 	fi
   4486  1.1  joerg 
   4487  1.1  joerg 	func_dirname "$file" "/" ""
   4488  1.1  joerg 	dir=$func_dirname_result
   4489  1.1  joerg 	func_append dir "$objdir"
   4490  1.1  joerg 
   4491  1.1  joerg 	if test -n "$relink_command"; then
   4492  1.1  joerg 	  # Determine the prefix the user has applied to our future dir.
   4493  1.1  joerg 	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
   4494  1.1  joerg 
   4495  1.1  joerg 	  # Don't allow the user to place us outside of our expected
   4496  1.1  joerg 	  # location b/c this prevents finding dependent libraries that
   4497  1.1  joerg 	  # are installed to the same prefix.
   4498  1.1  joerg 	  # At present, this check doesn't affect windows .dll's that
   4499  1.1  joerg 	  # are installed into $libdir/../bin (currently, that works fine)
   4500  1.1  joerg 	  # but it's something to keep an eye on.
   4501  1.1  joerg 	  test "$inst_prefix_dir" = "$destdir" && \
   4502  1.1  joerg 	    func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
   4503  1.1  joerg 
   4504  1.1  joerg 	  if test -n "$inst_prefix_dir"; then
   4505  1.1  joerg 	    # Stick the inst_prefix_dir data into the link command.
   4506  1.1  joerg 	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
   4507  1.1  joerg 	  else
   4508  1.1  joerg 	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
   4509  1.1  joerg 	  fi
   4510  1.1  joerg 
   4511  1.1  joerg 	  func_warning "relinking '$file'"
   4512  1.1  joerg 	  func_show_eval "$relink_command" \
   4513  1.1  joerg 	    'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
   4514  1.1  joerg 	fi
   4515  1.1  joerg 
   4516  1.1  joerg 	# See the names of the shared library.
   4517  1.1  joerg 	set dummy $library_names; shift
   4518  1.1  joerg 	if test -n "$1"; then
   4519  1.1  joerg 	  realname=$1
   4520  1.1  joerg 	  shift
   4521  1.1  joerg 
   4522  1.1  joerg 	  srcname=$realname
   4523  1.1  joerg 	  test -n "$relink_command" && srcname=${realname}T
   4524  1.1  joerg 
   4525  1.1  joerg 	  # Install the shared library and build the symlinks.
   4526  1.1  joerg 	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
   4527  1.1  joerg 	      'exit $?'
   4528  1.1  joerg 	  tstripme=$stripme
   4529  1.1  joerg 	  case $host_os in
   4530  1.1  joerg 	  cygwin* | mingw* | pw32* | cegcc*)
   4531  1.1  joerg 	    case $realname in
   4532  1.1  joerg 	    *.dll.a)
   4533  1.1  joerg 	      tstripme=
   4534  1.1  joerg 	      ;;
   4535  1.1  joerg 	    esac
   4536  1.1  joerg 	    ;;
   4537  1.1  joerg 	  os2*)
   4538  1.1  joerg 	    case $realname in
   4539  1.1  joerg 	    *_dll.a)
   4540  1.1  joerg 	      tstripme=
   4541  1.1  joerg 	      ;;
   4542  1.1  joerg 	    esac
   4543  1.1  joerg 	    ;;
   4544  1.1  joerg 	  esac
   4545  1.1  joerg 	  if test -n "$tstripme" && test -n "$striplib"; then
   4546  1.1  joerg 	    func_show_eval "$striplib $destdir/$realname" 'exit $?'
   4547  1.1  joerg 	  fi
   4548  1.1  joerg 
   4549  1.1  joerg 	  if test "$#" -gt 0; then
   4550  1.1  joerg 	    # Delete the old symlinks, and create new ones.
   4551  1.1  joerg 	    # Try 'ln -sf' first, because the 'ln' binary might depend on
   4552  1.1  joerg 	    # the symlink we replace!  Solaris /bin/ln does not understand -f,
   4553  1.1  joerg 	    # so we also need to try rm && ln -s.
   4554  1.1  joerg 	    for linkname
   4555  1.1  joerg 	    do
   4556  1.1  joerg 	      test "$linkname" != "$realname" \
   4557  1.1  joerg 		&& func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
   4558  1.1  joerg 	    done
   4559  1.1  joerg 	  fi
   4560  1.1  joerg 
   4561  1.1  joerg 	  # Do each command in the postinstall commands.
   4562  1.1  joerg 	  lib=$destdir/$realname
   4563  1.1  joerg 	  func_execute_cmds "$postinstall_cmds" 'exit $?'
   4564  1.1  joerg 	fi
   4565  1.1  joerg 
   4566  1.1  joerg 	# Install the pseudo-library for information purposes.
   4567  1.1  joerg 	func_basename "$file"
   4568  1.1  joerg 	name=$func_basename_result
   4569  1.1  joerg 	instname=$dir/${name}i
   4570  1.1  joerg 	func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
   4571  1.1  joerg 
   4572  1.1  joerg 	# Maybe install the static library, too.
   4573  1.1  joerg 	test -n "$old_library" && func_append staticlibs " $dir/$old_library"
   4574  1.1  joerg 	;;
   4575  1.1  joerg 
   4576  1.1  joerg       *.lo)
   4577  1.1  joerg 	# Install (i.e. copy) a libtool object.
   4578  1.1  joerg 
   4579  1.1  joerg 	# Figure out destination file name, if it wasn't already specified.
   4580  1.1  joerg 	if test -n "$destname"; then
   4581  1.1  joerg 	  destfile=$destdir/$destname
   4582  1.1  joerg 	else
   4583  1.1  joerg 	  func_basename "$file"
   4584  1.1  joerg 	  destfile=$func_basename_result
   4585  1.1  joerg 	  destfile=$destdir/$destfile
   4586  1.1  joerg 	fi
   4587  1.1  joerg 
   4588  1.1  joerg 	# Deduce the name of the destination old-style object file.
   4589  1.1  joerg 	case $destfile in
   4590  1.1  joerg 	*.lo)
   4591  1.1  joerg 	  func_lo2o "$destfile"
   4592  1.1  joerg 	  staticdest=$func_lo2o_result
   4593  1.1  joerg 	  ;;
   4594  1.1  joerg 	*.$objext)
   4595  1.1  joerg 	  staticdest=$destfile
   4596  1.1  joerg 	  destfile=
   4597  1.1  joerg 	  ;;
   4598  1.1  joerg 	*)
   4599  1.1  joerg 	  func_fatal_help "cannot copy a libtool object to '$destfile'"
   4600  1.1  joerg 	  ;;
   4601  1.1  joerg 	esac
   4602  1.1  joerg 
   4603  1.1  joerg 	# Install the libtool object if requested.
   4604  1.1  joerg 	test -n "$destfile" && \
   4605  1.1  joerg 	  func_show_eval "$install_prog $file $destfile" 'exit $?'
   4606  1.1  joerg 
   4607  1.1  joerg 	# Install the old object if enabled.
   4608  1.1  joerg 	if test yes = "$build_old_libs"; then
   4609  1.1  joerg 	  # Deduce the name of the old-style object file.
   4610  1.1  joerg 	  func_lo2o "$file"
   4611  1.1  joerg 	  staticobj=$func_lo2o_result
   4612  1.1  joerg 	  func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
   4613  1.1  joerg 	fi
   4614  1.1  joerg 	exit $EXIT_SUCCESS
   4615  1.1  joerg 	;;
   4616  1.1  joerg 
   4617  1.1  joerg       *)
   4618  1.1  joerg 	# Figure out destination file name, if it wasn't already specified.
   4619  1.1  joerg 	if test -n "$destname"; then
   4620  1.1  joerg 	  destfile=$destdir/$destname
   4621  1.1  joerg 	else
   4622  1.1  joerg 	  func_basename "$file"
   4623  1.1  joerg 	  destfile=$func_basename_result
   4624  1.1  joerg 	  destfile=$destdir/$destfile
   4625  1.1  joerg 	fi
   4626  1.1  joerg 
   4627  1.1  joerg 	# If the file is missing, and there is a .exe on the end, strip it
   4628  1.1  joerg 	# because it is most likely a libtool script we actually want to
   4629  1.1  joerg 	# install
   4630  1.1  joerg 	stripped_ext=
   4631  1.1  joerg 	case $file in
   4632  1.1  joerg 	  *.exe)
   4633  1.1  joerg 	    if test ! -f "$file"; then
   4634  1.1  joerg 	      func_stripname '' '.exe' "$file"
   4635  1.1  joerg 	      file=$func_stripname_result
   4636  1.1  joerg 	      stripped_ext=.exe
   4637  1.1  joerg 	    fi
   4638  1.1  joerg 	    ;;
   4639  1.1  joerg 	esac
   4640  1.1  joerg 
   4641  1.1  joerg 	# Do a test to see if this is really a libtool program.
   4642  1.1  joerg 	case $host in
   4643  1.1  joerg 	*cygwin* | *mingw*)
   4644  1.1  joerg 	    if func_ltwrapper_executable_p "$file"; then
   4645  1.1  joerg 	      func_ltwrapper_scriptname "$file"
   4646  1.1  joerg 	      wrapper=$func_ltwrapper_scriptname_result
   4647  1.1  joerg 	    else
   4648  1.1  joerg 	      func_stripname '' '.exe' "$file"
   4649  1.1  joerg 	      wrapper=$func_stripname_result
   4650  1.1  joerg 	    fi
   4651  1.1  joerg 	    ;;
   4652  1.1  joerg 	*)
   4653  1.1  joerg 	    wrapper=$file
   4654  1.1  joerg 	    ;;
   4655  1.1  joerg 	esac
   4656  1.1  joerg 	if func_ltwrapper_script_p "$wrapper"; then
   4657  1.1  joerg 	  notinst_deplibs=
   4658  1.1  joerg 	  relink_command=
   4659  1.1  joerg 
   4660  1.1  joerg 	  func_source "$wrapper"
   4661  1.1  joerg 
   4662  1.1  joerg 	  # Check the variables that should have been set.
   4663  1.1  joerg 	  test -z "$generated_by_libtool_version" && \
   4664  1.1  joerg 	    func_fatal_error "invalid libtool wrapper script '$wrapper'"
   4665  1.1  joerg 
   4666  1.1  joerg 	  finalize=:
   4667  1.1  joerg 	  for lib in $notinst_deplibs; do
   4668  1.1  joerg 	    # Check to see that each library is installed.
   4669  1.1  joerg 	    libdir=
   4670  1.1  joerg 	    if test -f "$lib"; then
   4671  1.1  joerg 	      func_source "$lib"
   4672  1.1  joerg 	    fi
   4673  1.1  joerg 	    libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
   4674  1.1  joerg 	    if test -n "$libdir" && test ! -f "$libfile"; then
   4675  1.1  joerg 	      func_warning "'$lib' has not been installed in '$libdir'"
   4676  1.1  joerg 	      finalize=false
   4677  1.1  joerg 	    fi
   4678  1.1  joerg 	  done
   4679  1.1  joerg 
   4680  1.1  joerg 	  relink_command=
   4681  1.1  joerg 	  func_source "$wrapper"
   4682  1.1  joerg 
   4683  1.1  joerg 	  outputname=
   4684  1.1  joerg 	  if test no = "$fast_install" && test -n "$relink_command"; then
   4685  1.1  joerg 	    $opt_dry_run || {
   4686  1.1  joerg 	      if $finalize; then
   4687  1.1  joerg 	        tmpdir=`func_mktempdir`
   4688  1.1  joerg 		func_basename "$file$stripped_ext"
   4689  1.1  joerg 		file=$func_basename_result
   4690  1.1  joerg 	        outputname=$tmpdir/$file
   4691  1.1  joerg 	        # Replace the output file specification.
   4692  1.1  joerg 	        relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
   4693  1.1  joerg 
   4694  1.1  joerg 	        $opt_quiet || {
   4695  1.1  joerg 	          func_quote_arg expand,pretty "$relink_command"
   4696  1.1  joerg 		  eval "func_echo $func_quote_arg_result"
   4697  1.1  joerg 	        }
   4698  1.1  joerg 	        if eval "$relink_command"; then :
   4699  1.1  joerg 	          else
   4700  1.1  joerg 		  func_error "error: relink '$file' with the above command before installing it"
   4701  1.1  joerg 		  $opt_dry_run || ${RM}r "$tmpdir"
   4702  1.1  joerg 		  continue
   4703  1.1  joerg 	        fi
   4704  1.1  joerg 	        file=$outputname
   4705  1.1  joerg 	      else
   4706  1.1  joerg 	        func_warning "cannot relink '$file'"
   4707  1.1  joerg 	      fi
   4708  1.1  joerg 	    }
   4709  1.1  joerg 	  else
   4710  1.1  joerg 	    # Install the binary that we compiled earlier.
   4711  1.1  joerg 	    file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
   4712  1.1  joerg 	  fi
   4713  1.1  joerg 	fi
   4714  1.1  joerg 
   4715  1.1  joerg 	# remove .exe since cygwin /usr/bin/install will append another
   4716  1.1  joerg 	# one anyway
   4717  1.1  joerg 	case $install_prog,$host in
   4718  1.1  joerg 	*/usr/bin/install*,*cygwin*)
   4719  1.1  joerg 	  case $file:$destfile in
   4720  1.1  joerg 	  *.exe:*.exe)
   4721  1.1  joerg 	    # this is ok
   4722  1.1  joerg 	    ;;
   4723  1.1  joerg 	  *.exe:*)
   4724  1.1  joerg 	    destfile=$destfile.exe
   4725  1.1  joerg 	    ;;
   4726  1.1  joerg 	  *:*.exe)
   4727  1.1  joerg 	    func_stripname '' '.exe' "$destfile"
   4728  1.1  joerg 	    destfile=$func_stripname_result
   4729  1.1  joerg 	    ;;
   4730  1.1  joerg 	  esac
   4731  1.1  joerg 	  ;;
   4732  1.1  joerg 	esac
   4733  1.1  joerg 	func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
   4734  1.1  joerg 	$opt_dry_run || if test -n "$outputname"; then
   4735  1.1  joerg 	  ${RM}r "$tmpdir"
   4736  1.1  joerg 	fi
   4737  1.1  joerg 	;;
   4738  1.1  joerg       esac
   4739  1.1  joerg     done
   4740  1.1  joerg 
   4741  1.1  joerg     for file in $staticlibs; do
   4742  1.1  joerg       func_basename "$file"
   4743  1.1  joerg       name=$func_basename_result
   4744  1.1  joerg 
   4745  1.1  joerg       # Set up the ranlib parameters.
   4746  1.1  joerg       oldlib=$destdir/$name
   4747  1.1  joerg       func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
   4748  1.1  joerg       tool_oldlib=$func_to_tool_file_result
   4749  1.1  joerg 
   4750  1.1  joerg       func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
   4751  1.1  joerg 
   4752  1.1  joerg       if test -n "$stripme" && test -n "$old_striplib"; then
   4753  1.1  joerg 	func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
   4754  1.1  joerg       fi
   4755  1.1  joerg 
   4756  1.1  joerg       # Do each command in the postinstall commands.
   4757  1.1  joerg       func_execute_cmds "$old_postinstall_cmds" 'exit $?'
   4758  1.1  joerg     done
   4759  1.1  joerg 
   4760  1.1  joerg     test -n "$future_libdirs" && \
   4761  1.1  joerg       func_warning "remember to run '$progname --finish$future_libdirs'"
   4762  1.1  joerg 
   4763  1.1  joerg     if test -n "$current_libdirs"; then
   4764  1.1  joerg       # Maybe just do a dry run.
   4765  1.1  joerg       $opt_dry_run && current_libdirs=" -n$current_libdirs"
   4766  1.1  joerg       exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
   4767  1.1  joerg     else
   4768  1.1  joerg       exit $EXIT_SUCCESS
   4769  1.1  joerg     fi
   4770  1.1  joerg }
   4771  1.1  joerg 
   4772  1.1  joerg test install = "$opt_mode" && func_mode_install ${1+"$@"}
   4773  1.1  joerg 
   4774  1.1  joerg 
   4775  1.1  joerg # func_generate_dlsyms outputname originator pic_p
   4776  1.1  joerg # Extract symbols from dlprefiles and create ${outputname}S.o with
   4777  1.1  joerg # a dlpreopen symbol table.
   4778  1.1  joerg func_generate_dlsyms ()
   4779  1.1  joerg {
   4780  1.1  joerg     $debug_cmd
   4781  1.1  joerg 
   4782  1.1  joerg     my_outputname=$1
   4783  1.1  joerg     my_originator=$2
   4784  1.1  joerg     my_pic_p=${3-false}
   4785  1.1  joerg     my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
   4786  1.1  joerg     my_dlsyms=
   4787  1.1  joerg 
   4788  1.1  joerg     if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
   4789  1.1  joerg       if test -n "$NM" && test -n "$global_symbol_pipe"; then
   4790  1.1  joerg 	my_dlsyms=${my_outputname}S.c
   4791  1.1  joerg       else
   4792  1.1  joerg 	func_error "not configured to extract global symbols from dlpreopened files"
   4793  1.1  joerg       fi
   4794  1.1  joerg     fi
   4795  1.1  joerg 
   4796  1.1  joerg     if test -n "$my_dlsyms"; then
   4797  1.1  joerg       case $my_dlsyms in
   4798  1.1  joerg       "") ;;
   4799  1.1  joerg       *.c)
   4800  1.1  joerg 	# Discover the nlist of each of the dlfiles.
   4801  1.1  joerg 	nlist=$output_objdir/$my_outputname.nm
   4802  1.1  joerg 
   4803  1.1  joerg 	func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
   4804  1.1  joerg 
   4805  1.1  joerg 	# Parse the name list into a source file.
   4806  1.1  joerg 	func_verbose "creating $output_objdir/$my_dlsyms"
   4807  1.1  joerg 
   4808  1.1  joerg 	$opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
   4809  1.1  joerg /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
   4810  1.1  joerg /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
   4811  1.1  joerg 
   4812  1.1  joerg #ifdef __cplusplus
   4813  1.1  joerg extern \"C\" {
   4814  1.1  joerg #endif
   4815  1.1  joerg 
   4816  1.1  joerg #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
   4817  1.1  joerg #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
   4818  1.1  joerg #endif
   4819  1.1  joerg 
   4820  1.1  joerg /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
   4821  1.1  joerg #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
   4822  1.1  joerg /* DATA imports from DLLs on WIN32 can't be const, because runtime
   4823  1.1  joerg    relocations are performed -- see ld's documentation on pseudo-relocs.  */
   4824  1.1  joerg # define LT_DLSYM_CONST
   4825  1.1  joerg #elif defined __osf__
   4826  1.1  joerg /* This system does not cope well with relocations in const data.  */
   4827  1.1  joerg # define LT_DLSYM_CONST
   4828  1.1  joerg #else
   4829  1.1  joerg # define LT_DLSYM_CONST const
   4830  1.1  joerg #endif
   4831  1.1  joerg 
   4832  1.1  joerg #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
   4833  1.1  joerg 
   4834  1.1  joerg /* External symbol declarations for the compiler. */\
   4835  1.1  joerg "
   4836  1.1  joerg 
   4837  1.1  joerg 	if test yes = "$dlself"; then
   4838  1.1  joerg 	  func_verbose "generating symbol list for '$output'"
   4839  1.1  joerg 
   4840  1.1  joerg 	  $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
   4841  1.1  joerg 
   4842  1.1  joerg 	  # Add our own program objects to the symbol list.
   4843  1.1  joerg 	  progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
   4844  1.1  joerg 	  for progfile in $progfiles; do
   4845  1.1  joerg 	    func_to_tool_file "$progfile" func_convert_file_msys_to_w32
   4846  1.1  joerg 	    func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
   4847  1.1  joerg 	    $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
   4848  1.1  joerg 	  done
   4849  1.1  joerg 
   4850  1.1  joerg 	  if test -n "$exclude_expsyms"; then
   4851  1.1  joerg 	    $opt_dry_run || {
   4852  1.1  joerg 	      eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
   4853  1.1  joerg 	      eval '$MV "$nlist"T "$nlist"'
   4854  1.1  joerg 	    }
   4855  1.1  joerg 	  fi
   4856  1.1  joerg 
   4857  1.1  joerg 	  if test -n "$export_symbols_regex"; then
   4858  1.1  joerg 	    $opt_dry_run || {
   4859  1.1  joerg 	      eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
   4860  1.1  joerg 	      eval '$MV "$nlist"T "$nlist"'
   4861  1.1  joerg 	    }
   4862  1.1  joerg 	  fi
   4863  1.1  joerg 
   4864  1.1  joerg 	  # Prepare the list of exported symbols
   4865  1.1  joerg 	  if test -z "$export_symbols"; then
   4866  1.1  joerg 	    export_symbols=$output_objdir/$outputname.exp
   4867  1.1  joerg 	    $opt_dry_run || {
   4868  1.1  joerg 	      $RM $export_symbols
   4869  1.1  joerg 	      eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
   4870  1.1  joerg 	      case $host in
   4871  1.1  joerg 	      *cygwin* | *mingw* | *cegcc* )
   4872  1.1  joerg                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
   4873  1.1  joerg                 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
   4874  1.1  joerg 	        ;;
   4875  1.1  joerg 	      esac
   4876  1.1  joerg 	    }
   4877  1.1  joerg 	  else
   4878  1.1  joerg 	    $opt_dry_run || {
   4879  1.1  joerg 	      eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
   4880  1.1  joerg 	      eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
   4881  1.1  joerg 	      eval '$MV "$nlist"T "$nlist"'
   4882  1.1  joerg 	      case $host in
   4883  1.1  joerg 	        *cygwin* | *mingw* | *cegcc* )
   4884  1.1  joerg 	          eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
   4885  1.1  joerg 	          eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
   4886  1.1  joerg 	          ;;
   4887  1.1  joerg 	      esac
   4888  1.1  joerg 	    }
   4889  1.1  joerg 	  fi
   4890  1.1  joerg 	fi
   4891  1.1  joerg 
   4892  1.1  joerg 	for dlprefile in $dlprefiles; do
   4893  1.1  joerg 	  func_verbose "extracting global C symbols from '$dlprefile'"
   4894  1.1  joerg 	  func_basename "$dlprefile"
   4895  1.1  joerg 	  name=$func_basename_result
   4896  1.1  joerg           case $host in
   4897  1.1  joerg 	    *cygwin* | *mingw* | *cegcc* )
   4898  1.1  joerg 	      # if an import library, we need to obtain dlname
   4899  1.1  joerg 	      if func_win32_import_lib_p "$dlprefile"; then
   4900  1.1  joerg 	        func_tr_sh "$dlprefile"
   4901  1.1  joerg 	        eval "curr_lafile=\$libfile_$func_tr_sh_result"
   4902  1.1  joerg 	        dlprefile_dlbasename=
   4903  1.1  joerg 	        if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
   4904  1.1  joerg 	          # Use subshell, to avoid clobbering current variable values
   4905  1.1  joerg 	          dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
   4906  1.1  joerg 	          if test -n "$dlprefile_dlname"; then
   4907  1.1  joerg 	            func_basename "$dlprefile_dlname"
   4908  1.1  joerg 	            dlprefile_dlbasename=$func_basename_result
   4909  1.1  joerg 	          else
   4910  1.1  joerg 	            # no lafile. user explicitly requested -dlpreopen <import library>.
   4911  1.1  joerg 	            $sharedlib_from_linklib_cmd "$dlprefile"
   4912  1.1  joerg 	            dlprefile_dlbasename=$sharedlib_from_linklib_result
   4913  1.1  joerg 	          fi
   4914  1.1  joerg 	        fi
   4915  1.1  joerg 	        $opt_dry_run || {
   4916  1.1  joerg 	          if test -n "$dlprefile_dlbasename"; then
   4917  1.1  joerg 	            eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
   4918  1.1  joerg 	          else
   4919  1.1  joerg 	            func_warning "Could not compute DLL name from $name"
   4920  1.1  joerg 	            eval '$ECHO ": $name " >> "$nlist"'
   4921  1.1  joerg 	          fi
   4922  1.1  joerg 	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
   4923  1.1  joerg 	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
   4924  1.1  joerg 	            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
   4925  1.1  joerg 	        }
   4926  1.1  joerg 	      else # not an import lib
   4927  1.1  joerg 	        $opt_dry_run || {
   4928  1.1  joerg 	          eval '$ECHO ": $name " >> "$nlist"'
   4929  1.1  joerg 	          func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
   4930  1.1  joerg 	          eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
   4931  1.1  joerg 	        }
   4932  1.1  joerg 	      fi
   4933  1.1  joerg 	    ;;
   4934  1.1  joerg 	    *)
   4935  1.1  joerg 	      $opt_dry_run || {
   4936  1.1  joerg 	        eval '$ECHO ": $name " >> "$nlist"'
   4937  1.1  joerg 	        func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
   4938  1.1  joerg 	        eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
   4939  1.1  joerg 	      }
   4940  1.1  joerg 	    ;;
   4941  1.1  joerg           esac
   4942  1.1  joerg 	done
   4943  1.1  joerg 
   4944  1.1  joerg 	$opt_dry_run || {
   4945  1.1  joerg 	  # Make sure we have at least an empty file.
   4946  1.1  joerg 	  test -f "$nlist" || : > "$nlist"
   4947  1.1  joerg 
   4948  1.1  joerg 	  if test -n "$exclude_expsyms"; then
   4949  1.1  joerg 	    $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
   4950  1.1  joerg 	    $MV "$nlist"T "$nlist"
   4951  1.1  joerg 	  fi
   4952  1.1  joerg 
   4953  1.1  joerg 	  # Try sorting and uniquifying the output.
   4954  1.1  joerg 	  if $GREP -v "^: " < "$nlist" |
   4955  1.1  joerg 	      if sort -k 3 </dev/null >/dev/null 2>&1; then
   4956  1.1  joerg 		sort -k 3
   4957  1.1  joerg 	      else
   4958  1.1  joerg 		sort +2
   4959  1.1  joerg 	      fi |
   4960  1.1  joerg 	      uniq > "$nlist"S; then
   4961  1.1  joerg 	    :
   4962  1.1  joerg 	  else
   4963  1.1  joerg 	    $GREP -v "^: " < "$nlist" > "$nlist"S
   4964  1.1  joerg 	  fi
   4965  1.1  joerg 
   4966  1.1  joerg 	  if test -f "$nlist"S; then
   4967  1.1  joerg 	    eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
   4968  1.1  joerg 	  else
   4969  1.1  joerg 	    echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
   4970  1.1  joerg 	  fi
   4971  1.1  joerg 
   4972  1.1  joerg 	  func_show_eval '$RM "${nlist}I"'
   4973  1.1  joerg 	  if test -n "$global_symbol_to_import"; then
   4974  1.1  joerg 	    eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
   4975  1.1  joerg 	  fi
   4976  1.1  joerg 
   4977  1.1  joerg 	  echo >> "$output_objdir/$my_dlsyms" "\
   4978  1.1  joerg 
   4979  1.1  joerg /* The mapping between symbol names and symbols.  */
   4980  1.1  joerg typedef struct {
   4981  1.1  joerg   const char *name;
   4982  1.1  joerg   void *address;
   4983  1.1  joerg } lt_dlsymlist;
   4984  1.1  joerg extern LT_DLSYM_CONST lt_dlsymlist
   4985  1.1  joerg lt_${my_prefix}_LTX_preloaded_symbols[];\
   4986  1.1  joerg "
   4987  1.1  joerg 
   4988  1.1  joerg 	  if test -s "$nlist"I; then
   4989  1.1  joerg 	    echo >> "$output_objdir/$my_dlsyms" "\
   4990  1.1  joerg static void lt_syminit(void)
   4991  1.1  joerg {
   4992  1.1  joerg   LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
   4993  1.1  joerg   for (; symbol->name; ++symbol)
   4994  1.1  joerg     {"
   4995  1.1  joerg 	    $SED 's/.*/      if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
   4996  1.1  joerg 	    echo >> "$output_objdir/$my_dlsyms" "\
   4997  1.1  joerg     }
   4998  1.1  joerg }"
   4999  1.1  joerg 	  fi
   5000  1.1  joerg 	  echo >> "$output_objdir/$my_dlsyms" "\
   5001  1.1  joerg LT_DLSYM_CONST lt_dlsymlist
   5002  1.1  joerg lt_${my_prefix}_LTX_preloaded_symbols[] =
   5003  1.1  joerg { {\"$my_originator\", (void *) 0},"
   5004  1.1  joerg 
   5005  1.1  joerg 	  if test -s "$nlist"I; then
   5006  1.1  joerg 	    echo >> "$output_objdir/$my_dlsyms" "\
   5007  1.1  joerg   {\"@INIT@\", (void *) &lt_syminit},"
   5008  1.1  joerg 	  fi
   5009  1.1  joerg 
   5010  1.1  joerg 	  case $need_lib_prefix in
   5011  1.1  joerg 	  no)
   5012  1.1  joerg 	    eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
   5013  1.1  joerg 	    ;;
   5014  1.1  joerg 	  *)
   5015  1.1  joerg 	    eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
   5016  1.1  joerg 	    ;;
   5017  1.1  joerg 	  esac
   5018  1.1  joerg 	  echo >> "$output_objdir/$my_dlsyms" "\
   5019  1.1  joerg   {0, (void *) 0}
   5020  1.1  joerg };
   5021  1.1  joerg 
   5022  1.1  joerg /* This works around a problem in FreeBSD linker */
   5023  1.1  joerg #ifdef FREEBSD_WORKAROUND
   5024  1.1  joerg static const void *lt_preloaded_setup() {
   5025  1.1  joerg   return lt_${my_prefix}_LTX_preloaded_symbols;
   5026  1.1  joerg }
   5027  1.1  joerg #endif
   5028  1.1  joerg 
   5029  1.1  joerg #ifdef __cplusplus
   5030  1.1  joerg }
   5031  1.1  joerg #endif\
   5032  1.1  joerg "
   5033  1.1  joerg 	} # !$opt_dry_run
   5034  1.1  joerg 
   5035  1.1  joerg 	pic_flag_for_symtable=
   5036  1.1  joerg 	case "$compile_command " in
   5037  1.1  joerg 	*" -static "*) ;;
   5038  1.1  joerg 	*)
   5039  1.1  joerg 	  case $host in
   5040  1.1  joerg 	  # compiling the symbol table file with pic_flag works around
   5041  1.1  joerg 	  # a FreeBSD bug that causes programs to crash when -lm is
   5042  1.1  joerg 	  # linked before any other PIC object.  But we must not use
   5043  1.1  joerg 	  # pic_flag when linking with -static.  The problem exists in
   5044  1.1  joerg 	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
   5045  1.1  joerg 	  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
   5046  1.1  joerg 	    pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
   5047  1.1  joerg 	  *-*-hpux*)
   5048  1.1  joerg 	    pic_flag_for_symtable=" $pic_flag"  ;;
   5049  1.1  joerg 	  *)
   5050  1.1  joerg 	    $my_pic_p && pic_flag_for_symtable=" $pic_flag"
   5051  1.1  joerg 	    ;;
   5052  1.1  joerg 	  esac
   5053  1.1  joerg 	  ;;
   5054  1.1  joerg 	esac
   5055  1.1  joerg 	symtab_cflags=
   5056  1.1  joerg 	for arg in $LTCFLAGS; do
   5057  1.1  joerg 	  case $arg in
   5058  1.1  joerg 	  -pie | -fpie | -fPIE) ;;
   5059  1.1  joerg 	  *) func_append symtab_cflags " $arg" ;;
   5060  1.1  joerg 	  esac
   5061  1.1  joerg 	done
   5062  1.1  joerg 
   5063  1.1  joerg 	# Now compile the dynamic symbol file.
   5064  1.1  joerg 	func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
   5065  1.1  joerg 
   5066  1.1  joerg 	# Clean up the generated files.
   5067  1.1  joerg 	func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
   5068  1.1  joerg 
   5069  1.1  joerg 	# Transform the symbol file into the correct name.
   5070  1.1  joerg 	symfileobj=$output_objdir/${my_outputname}S.$objext
   5071  1.1  joerg 	case $host in
   5072  1.1  joerg 	*cygwin* | *mingw* | *cegcc* )
   5073  1.1  joerg 	  if test -f "$output_objdir/$my_outputname.def"; then
   5074  1.1  joerg 	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
   5075  1.1  joerg 	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
   5076  1.1  joerg 	  else
   5077  1.1  joerg 	    compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
   5078  1.1  joerg 	    finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
   5079  1.1  joerg 	  fi
   5080  1.1  joerg 	  ;;
   5081  1.1  joerg 	*)
   5082  1.1  joerg 	  compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
   5083  1.1  joerg 	  finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
   5084  1.1  joerg 	  ;;
   5085  1.1  joerg 	esac
   5086  1.1  joerg 	;;
   5087  1.1  joerg       *)
   5088  1.1  joerg 	func_fatal_error "unknown suffix for '$my_dlsyms'"
   5089  1.1  joerg 	;;
   5090  1.1  joerg       esac
   5091  1.1  joerg     else
   5092  1.1  joerg       # We keep going just in case the user didn't refer to
   5093  1.1  joerg       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
   5094  1.1  joerg       # really was required.
   5095  1.1  joerg 
   5096  1.1  joerg       # Nullify the symbol file.
   5097  1.1  joerg       compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
   5098  1.1  joerg       finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
   5099  1.1  joerg     fi
   5100  1.1  joerg }
   5101  1.1  joerg 
   5102  1.1  joerg # func_cygming_gnu_implib_p ARG
   5103  1.1  joerg # This predicate returns with zero status (TRUE) if
   5104  1.1  joerg # ARG is a GNU/binutils-style import library. Returns
   5105  1.1  joerg # with nonzero status (FALSE) otherwise.
   5106  1.1  joerg func_cygming_gnu_implib_p ()
   5107  1.1  joerg {
   5108  1.1  joerg   $debug_cmd
   5109  1.1  joerg 
   5110  1.1  joerg   func_to_tool_file "$1" func_convert_file_msys_to_w32
   5111  1.1  joerg   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)$'`
   5112  1.1  joerg   test -n "$func_cygming_gnu_implib_tmp"
   5113  1.1  joerg }
   5114  1.1  joerg 
   5115  1.1  joerg # func_cygming_ms_implib_p ARG
   5116  1.1  joerg # This predicate returns with zero status (TRUE) if
   5117  1.1  joerg # ARG is an MS-style import library. Returns
   5118  1.1  joerg # with nonzero status (FALSE) otherwise.
   5119  1.1  joerg func_cygming_ms_implib_p ()
   5120  1.1  joerg {
   5121  1.1  joerg   $debug_cmd
   5122  1.1  joerg 
   5123  1.1  joerg   func_to_tool_file "$1" func_convert_file_msys_to_w32
   5124  1.1  joerg   func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
   5125  1.1  joerg   test -n "$func_cygming_ms_implib_tmp"
   5126  1.1  joerg }
   5127  1.1  joerg 
   5128  1.1  joerg # func_win32_libid arg
   5129  1.1  joerg # return the library type of file 'arg'
   5130  1.1  joerg #
   5131  1.1  joerg # Need a lot of goo to handle *both* DLLs and import libs
   5132  1.1  joerg # Has to be a shell function in order to 'eat' the argument
   5133  1.1  joerg # that is supplied when $file_magic_command is called.
   5134  1.1  joerg # Despite the name, also deal with 64 bit binaries.
   5135  1.1  joerg func_win32_libid ()
   5136  1.1  joerg {
   5137  1.1  joerg   $debug_cmd
   5138  1.1  joerg 
   5139  1.1  joerg   win32_libid_type=unknown
   5140  1.1  joerg   win32_fileres=`file -L $1 2>/dev/null`
   5141  1.1  joerg   case $win32_fileres in
   5142  1.1  joerg   *ar\ archive\ import\ library*) # definitely import
   5143  1.1  joerg     win32_libid_type="x86 archive import"
   5144  1.1  joerg     ;;
   5145  1.1  joerg   *ar\ archive*) # could be an import, or static
   5146  1.1  joerg     # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
   5147  1.1  joerg     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
   5148  1.1  joerg        $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
   5149  1.1  joerg       case $nm_interface in
   5150  1.1  joerg       "MS dumpbin")
   5151  1.1  joerg 	if func_cygming_ms_implib_p "$1" ||
   5152  1.1  joerg 	   func_cygming_gnu_implib_p "$1"
   5153  1.1  joerg 	then
   5154  1.1  joerg 	  win32_nmres=import
   5155  1.1  joerg 	else
   5156  1.1  joerg 	  win32_nmres=
   5157  1.1  joerg 	fi
   5158  1.1  joerg 	;;
   5159  1.1  joerg       *)
   5160  1.1  joerg 	func_to_tool_file "$1" func_convert_file_msys_to_w32
   5161  1.1  joerg 	win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
   5162  1.1  joerg 	  $SED -n -e '
   5163  1.1  joerg 	    1,100{
   5164  1.1  joerg 		/ I /{
   5165  1.1  joerg 		    s|.*|import|
   5166  1.1  joerg 		    p
   5167  1.1  joerg 		    q
   5168  1.1  joerg 		}
   5169  1.1  joerg 	    }'`
   5170  1.1  joerg 	;;
   5171  1.1  joerg       esac
   5172  1.1  joerg       case $win32_nmres in
   5173  1.1  joerg       import*)  win32_libid_type="x86 archive import";;
   5174  1.1  joerg       *)        win32_libid_type="x86 archive static";;
   5175  1.1  joerg       esac
   5176  1.1  joerg     fi
   5177  1.1  joerg     ;;
   5178  1.1  joerg   *DLL*)
   5179  1.1  joerg     win32_libid_type="x86 DLL"
   5180  1.1  joerg     ;;
   5181  1.1  joerg   *executable*) # but shell scripts are "executable" too...
   5182  1.1  joerg     case $win32_fileres in
   5183  1.1  joerg     *MS\ Windows\ PE\ Intel*)
   5184  1.1  joerg       win32_libid_type="x86 DLL"
   5185  1.1  joerg       ;;
   5186  1.1  joerg     esac
   5187  1.1  joerg     ;;
   5188  1.1  joerg   esac
   5189  1.1  joerg   $ECHO "$win32_libid_type"
   5190  1.1  joerg }
   5191  1.1  joerg 
   5192  1.1  joerg # func_cygming_dll_for_implib ARG
   5193  1.1  joerg #
   5194  1.1  joerg # Platform-specific function to extract the
   5195  1.1  joerg # name of the DLL associated with the specified
   5196  1.1  joerg # import library ARG.
   5197  1.1  joerg # Invoked by eval'ing the libtool variable
   5198  1.1  joerg #    $sharedlib_from_linklib_cmd
   5199  1.1  joerg # Result is available in the variable
   5200  1.1  joerg #    $sharedlib_from_linklib_result
   5201  1.1  joerg func_cygming_dll_for_implib ()
   5202  1.1  joerg {
   5203  1.1  joerg   $debug_cmd
   5204  1.1  joerg 
   5205  1.1  joerg   sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
   5206  1.1  joerg }
   5207  1.1  joerg 
   5208  1.1  joerg # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
   5209  1.1  joerg #
   5210  1.1  joerg # The is the core of a fallback implementation of a
   5211  1.1  joerg # platform-specific function to extract the name of the
   5212  1.1  joerg # DLL associated with the specified import library LIBNAME.
   5213  1.1  joerg #
   5214  1.1  joerg # SECTION_NAME is either .idata$6 or .idata$7, depending
   5215  1.1  joerg # on the platform and compiler that created the implib.
   5216  1.1  joerg #
   5217  1.1  joerg # Echos the name of the DLL associated with the
   5218  1.1  joerg # specified import library.
   5219  1.1  joerg func_cygming_dll_for_implib_fallback_core ()
   5220  1.1  joerg {
   5221  1.1  joerg   $debug_cmd
   5222  1.1  joerg 
   5223  1.1  joerg   match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
   5224  1.1  joerg   $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
   5225  1.1  joerg     $SED '/^Contents of section '"$match_literal"':/{
   5226  1.1  joerg       # Place marker at beginning of archive member dllname section
   5227  1.1  joerg       s/.*/====MARK====/
   5228  1.1  joerg       p
   5229  1.1  joerg       d
   5230  1.1  joerg     }
   5231  1.1  joerg     # These lines can sometimes be longer than 43 characters, but
   5232  1.1  joerg     # are always uninteresting
   5233  1.1  joerg     /:[	 ]*file format pe[i]\{,1\}-/d
   5234  1.1  joerg     /^In archive [^:]*:/d
   5235  1.1  joerg     # Ensure marker is printed
   5236  1.1  joerg     /^====MARK====/p
   5237  1.1  joerg     # Remove all lines with less than 43 characters
   5238  1.1  joerg     /^.\{43\}/!d
   5239  1.1  joerg     # From remaining lines, remove first 43 characters
   5240  1.1  joerg     s/^.\{43\}//' |
   5241  1.1  joerg     $SED -n '
   5242  1.1  joerg       # Join marker and all lines until next marker into a single line
   5243  1.1  joerg       /^====MARK====/ b para
   5244  1.1  joerg       H
   5245  1.1  joerg       $ b para
   5246  1.1  joerg       b
   5247  1.1  joerg       :para
   5248  1.1  joerg       x
   5249  1.1  joerg       s/\n//g
   5250  1.1  joerg       # Remove the marker
   5251  1.1  joerg       s/^====MARK====//
   5252  1.1  joerg       # Remove trailing dots and whitespace
   5253  1.1  joerg       s/[\. \t]*$//
   5254  1.1  joerg       # Print
   5255  1.1  joerg       /./p' |
   5256  1.1  joerg     # we now have a list, one entry per line, of the stringified
   5257  1.1  joerg     # contents of the appropriate section of all members of the
   5258  1.1  joerg     # archive that possess that section. Heuristic: eliminate
   5259  1.1  joerg     # all those that have a first or second character that is
   5260  1.1  joerg     # a '.' (that is, objdump's representation of an unprintable
   5261  1.1  joerg     # character.) This should work for all archives with less than
   5262  1.1  joerg     # 0x302f exports -- but will fail for DLLs whose name actually
   5263  1.1  joerg     # begins with a literal '.' or a single character followed by
   5264  1.1  joerg     # a '.'.
   5265  1.1  joerg     #
   5266  1.1  joerg     # Of those that remain, print the first one.
   5267  1.1  joerg     $SED -e '/^\./d;/^.\./d;q'
   5268  1.1  joerg }
   5269  1.1  joerg 
   5270  1.1  joerg # func_cygming_dll_for_implib_fallback ARG
   5271  1.1  joerg # Platform-specific function to extract the
   5272  1.1  joerg # name of the DLL associated with the specified
   5273  1.1  joerg # import library ARG.
   5274  1.1  joerg #
   5275  1.1  joerg # This fallback implementation is for use when $DLLTOOL
   5276  1.1  joerg # does not support the --identify-strict option.
   5277  1.1  joerg # Invoked by eval'ing the libtool variable
   5278  1.1  joerg #    $sharedlib_from_linklib_cmd
   5279  1.1  joerg # Result is available in the variable
   5280  1.1  joerg #    $sharedlib_from_linklib_result
   5281  1.1  joerg func_cygming_dll_for_implib_fallback ()
   5282  1.1  joerg {
   5283  1.1  joerg   $debug_cmd
   5284  1.1  joerg 
   5285  1.1  joerg   if func_cygming_gnu_implib_p "$1"; then
   5286  1.1  joerg     # binutils import library
   5287  1.1  joerg     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
   5288  1.1  joerg   elif func_cygming_ms_implib_p "$1"; then
   5289  1.1  joerg     # ms-generated import library
   5290  1.1  joerg     sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
   5291  1.1  joerg   else
   5292  1.1  joerg     # unknown
   5293  1.1  joerg     sharedlib_from_linklib_result=
   5294  1.1  joerg   fi
   5295  1.1  joerg }
   5296  1.1  joerg 
   5297  1.1  joerg 
   5298  1.1  joerg # func_extract_an_archive dir oldlib
   5299  1.1  joerg func_extract_an_archive ()
   5300  1.1  joerg {
   5301  1.1  joerg     $debug_cmd
   5302  1.1  joerg 
   5303  1.1  joerg     f_ex_an_ar_dir=$1; shift
   5304  1.1  joerg     f_ex_an_ar_oldlib=$1
   5305  1.1  joerg     if test yes = "$lock_old_archive_extraction"; then
   5306  1.1  joerg       lockfile=$f_ex_an_ar_oldlib.lock
   5307  1.1  joerg       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
   5308  1.1  joerg 	func_echo "Waiting for $lockfile to be removed"
   5309  1.1  joerg 	sleep 2
   5310  1.1  joerg       done
   5311  1.1  joerg     fi
   5312  1.1  joerg     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
   5313  1.1  joerg 		   'stat=$?; rm -f "$lockfile"; exit $stat'
   5314  1.1  joerg     if test yes = "$lock_old_archive_extraction"; then
   5315  1.1  joerg       $opt_dry_run || rm -f "$lockfile"
   5316  1.1  joerg     fi
   5317  1.1  joerg     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
   5318  1.1  joerg      :
   5319  1.1  joerg     else
   5320  1.1  joerg       func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
   5321  1.1  joerg     fi
   5322  1.1  joerg }
   5323  1.1  joerg 
   5324  1.1  joerg 
   5325  1.1  joerg # func_extract_archives gentop oldlib ...
   5326  1.1  joerg func_extract_archives ()
   5327  1.1  joerg {
   5328  1.1  joerg     $debug_cmd
   5329  1.1  joerg 
   5330  1.1  joerg     my_gentop=$1; shift
   5331  1.1  joerg     my_oldlibs=${1+"$@"}
   5332  1.1  joerg     my_oldobjs=
   5333  1.1  joerg     my_xlib=
   5334  1.1  joerg     my_xabs=
   5335  1.1  joerg     my_xdir=
   5336  1.1  joerg 
   5337  1.1  joerg     for my_xlib in $my_oldlibs; do
   5338  1.1  joerg       # Extract the objects.
   5339  1.1  joerg       case $my_xlib in
   5340  1.1  joerg 	[\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
   5341  1.1  joerg 	*) my_xabs=`pwd`"/$my_xlib" ;;
   5342  1.1  joerg       esac
   5343  1.1  joerg       func_basename "$my_xlib"
   5344  1.1  joerg       my_xlib=$func_basename_result
   5345  1.1  joerg       my_xlib_u=$my_xlib
   5346  1.1  joerg       while :; do
   5347  1.1  joerg         case " $extracted_archives " in
   5348  1.1  joerg 	*" $my_xlib_u "*)
   5349  1.1  joerg 	  func_arith $extracted_serial + 1
   5350  1.1  joerg 	  extracted_serial=$func_arith_result
   5351  1.1  joerg 	  my_xlib_u=lt$extracted_serial-$my_xlib ;;
   5352  1.1  joerg 	*) break ;;
   5353  1.1  joerg 	esac
   5354  1.1  joerg       done
   5355  1.1  joerg       extracted_archives="$extracted_archives $my_xlib_u"
   5356  1.1  joerg       my_xdir=$my_gentop/$my_xlib_u
   5357  1.1  joerg 
   5358  1.1  joerg       func_mkdir_p "$my_xdir"
   5359  1.1  joerg 
   5360  1.1  joerg       case $host in
   5361  1.1  joerg       *-darwin*)
   5362  1.1  joerg 	func_verbose "Extracting $my_xabs"
   5363  1.1  joerg 	# Do not bother doing anything if just a dry run
   5364  1.1  joerg 	$opt_dry_run || {
   5365  1.1  joerg 	  darwin_orig_dir=`pwd`
   5366  1.1  joerg 	  cd $my_xdir || exit $?
   5367  1.1  joerg 	  darwin_archive=$my_xabs
   5368  1.1  joerg 	  darwin_curdir=`pwd`
   5369  1.1  joerg 	  func_basename "$darwin_archive"
   5370  1.1  joerg 	  darwin_base_archive=$func_basename_result
   5371  1.1  joerg 	  darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
   5372  1.1  joerg 	  if test -n "$darwin_arches"; then
   5373  1.1  joerg 	    darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
   5374  1.1  joerg 	    darwin_arch=
   5375  1.1  joerg 	    func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
   5376  1.1  joerg 	    for darwin_arch in  $darwin_arches; do
   5377  1.1  joerg 	      func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
   5378  1.1  joerg 	      $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
   5379  1.1  joerg 	      cd "unfat-$$/$darwin_base_archive-$darwin_arch"
   5380  1.1  joerg 	      func_extract_an_archive "`pwd`" "$darwin_base_archive"
   5381  1.1  joerg 	      cd "$darwin_curdir"
   5382  1.1  joerg 	      $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
   5383  1.1  joerg 	    done # $darwin_arches
   5384  1.1  joerg             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
   5385  1.1  joerg 	    darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
   5386  1.1  joerg 	    darwin_file=
   5387  1.1  joerg 	    darwin_files=
   5388  1.1  joerg 	    for darwin_file in $darwin_filelist; do
   5389  1.1  joerg 	      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
   5390  1.1  joerg 	      $LIPO -create -output "$darwin_file" $darwin_files
   5391  1.1  joerg 	    done # $darwin_filelist
   5392  1.1  joerg 	    $RM -rf unfat-$$
   5393  1.1  joerg 	    cd "$darwin_orig_dir"
   5394  1.1  joerg 	  else
   5395  1.1  joerg 	    cd $darwin_orig_dir
   5396  1.1  joerg 	    func_extract_an_archive "$my_xdir" "$my_xabs"
   5397  1.1  joerg 	  fi # $darwin_arches
   5398  1.1  joerg 	} # !$opt_dry_run
   5399  1.1  joerg 	;;
   5400  1.1  joerg       *)
   5401  1.1  joerg         func_extract_an_archive "$my_xdir" "$my_xabs"
   5402  1.1  joerg 	;;
   5403  1.1  joerg       esac
   5404  1.1  joerg       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
   5405  1.1  joerg     done
   5406  1.1  joerg 
   5407  1.1  joerg     func_extract_archives_result=$my_oldobjs
   5408  1.1  joerg }
   5409  1.1  joerg 
   5410  1.1  joerg 
   5411  1.1  joerg # func_emit_wrapper [arg=no]
   5412  1.1  joerg #
   5413  1.1  joerg # Emit a libtool wrapper script on stdout.
   5414  1.1  joerg # Don't directly open a file because we may want to
   5415  1.1  joerg # incorporate the script contents within a cygwin/mingw
   5416  1.1  joerg # wrapper executable.  Must ONLY be called from within
   5417  1.1  joerg # func_mode_link because it depends on a number of variables
   5418  1.1  joerg # set therein.
   5419  1.1  joerg #
   5420  1.1  joerg # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
   5421  1.1  joerg # variable will take.  If 'yes', then the emitted script
   5422  1.1  joerg # will assume that the directory where it is stored is
   5423  1.1  joerg # the $objdir directory.  This is a cygwin/mingw-specific
   5424  1.1  joerg # behavior.
   5425  1.1  joerg func_emit_wrapper ()
   5426  1.1  joerg {
   5427  1.1  joerg 	func_emit_wrapper_arg1=${1-no}
   5428  1.1  joerg 
   5429  1.1  joerg 	$ECHO "\
   5430  1.1  joerg #! $SHELL
   5431  1.1  joerg 
   5432  1.1  joerg # $output - temporary wrapper script for $objdir/$outputname
   5433  1.1  joerg # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
   5434  1.1  joerg #
   5435  1.1  joerg # The $output program cannot be directly executed until all the libtool
   5436  1.1  joerg # libraries that it depends on are installed.
   5437  1.1  joerg #
   5438  1.1  joerg # This wrapper script should never be moved out of the build directory.
   5439  1.1  joerg # If it is, it will not operate correctly.
   5440  1.1  joerg 
   5441  1.1  joerg # Sed substitution that helps us do robust quoting.  It backslashifies
   5442  1.1  joerg # metacharacters that are still active within double-quoted strings.
   5443  1.1  joerg sed_quote_subst='$sed_quote_subst'
   5444  1.1  joerg 
   5445  1.1  joerg # Be Bourne compatible
   5446  1.1  joerg if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
   5447  1.1  joerg   emulate sh
   5448  1.1  joerg   NULLCMD=:
   5449  1.1  joerg   # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
   5450  1.1  joerg   # is contrary to our usage.  Disable this feature.
   5451  1.1  joerg   alias -g '\${1+\"\$@\"}'='\"\$@\"'
   5452  1.1  joerg   setopt NO_GLOB_SUBST
   5453  1.1  joerg else
   5454  1.1  joerg   case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
   5455  1.1  joerg fi
   5456  1.1  joerg BIN_SH=xpg4; export BIN_SH # for Tru64
   5457  1.1  joerg DUALCASE=1; export DUALCASE # for MKS sh
   5458  1.1  joerg 
   5459  1.1  joerg # The HP-UX ksh and POSIX shell print the target directory to stdout
   5460  1.1  joerg # if CDPATH is set.
   5461  1.1  joerg (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
   5462  1.1  joerg 
   5463  1.1  joerg relink_command=\"$relink_command\"
   5464  1.1  joerg 
   5465  1.1  joerg # This environment variable determines our operation mode.
   5466  1.1  joerg if test \"\$libtool_install_magic\" = \"$magic\"; then
   5467  1.1  joerg   # install mode needs the following variables:
   5468  1.1  joerg   generated_by_libtool_version='$macro_version'
   5469  1.1  joerg   notinst_deplibs='$notinst_deplibs'
   5470  1.1  joerg else
   5471  1.1  joerg   # When we are sourced in execute mode, \$file and \$ECHO are already set.
   5472  1.1  joerg   if test \"\$libtool_execute_magic\" != \"$magic\"; then
   5473  1.1  joerg     file=\"\$0\""
   5474  1.1  joerg 
   5475  1.1  joerg     func_quote_arg pretty "$ECHO"
   5476  1.1  joerg     qECHO=$func_quote_arg_result
   5477  1.1  joerg     $ECHO "\
   5478  1.1  joerg 
   5479  1.1  joerg # A function that is used when there is no print builtin or printf.
   5480  1.1  joerg func_fallback_echo ()
   5481  1.1  joerg {
   5482  1.1  joerg   eval 'cat <<_LTECHO_EOF
   5483  1.1  joerg \$1
   5484  1.1  joerg _LTECHO_EOF'
   5485  1.1  joerg }
   5486  1.1  joerg     ECHO=$qECHO
   5487  1.1  joerg   fi
   5488  1.1  joerg 
   5489  1.1  joerg # Very basic option parsing. These options are (a) specific to
   5490  1.1  joerg # the libtool wrapper, (b) are identical between the wrapper
   5491  1.1  joerg # /script/ and the wrapper /executable/ that is used only on
   5492  1.1  joerg # windows platforms, and (c) all begin with the string "--lt-"
   5493  1.1  joerg # (application programs are unlikely to have options that match
   5494  1.1  joerg # this pattern).
   5495  1.1  joerg #
   5496  1.1  joerg # There are only two supported options: --lt-debug and
   5497  1.1  joerg # --lt-dump-script. There is, deliberately, no --lt-help.
   5498  1.1  joerg #
   5499  1.1  joerg # The first argument to this parsing function should be the
   5500  1.1  joerg # script's $0 value, followed by "$@".
   5501  1.1  joerg lt_option_debug=
   5502  1.1  joerg func_parse_lt_options ()
   5503  1.1  joerg {
   5504  1.1  joerg   lt_script_arg0=\$0
   5505  1.1  joerg   shift
   5506  1.1  joerg   for lt_opt
   5507  1.1  joerg   do
   5508  1.1  joerg     case \"\$lt_opt\" in
   5509  1.1  joerg     --lt-debug) lt_option_debug=1 ;;
   5510  1.1  joerg     --lt-dump-script)
   5511  1.1  joerg         lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
   5512  1.1  joerg         test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
   5513  1.1  joerg         lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
   5514  1.1  joerg         cat \"\$lt_dump_D/\$lt_dump_F\"
   5515  1.1  joerg         exit 0
   5516  1.1  joerg       ;;
   5517  1.1  joerg     --lt-*)
   5518  1.1  joerg         \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
   5519  1.1  joerg         exit 1
   5520  1.1  joerg       ;;
   5521  1.1  joerg     esac
   5522  1.1  joerg   done
   5523  1.1  joerg 
   5524  1.1  joerg   # Print the debug banner immediately:
   5525  1.1  joerg   if test -n \"\$lt_option_debug\"; then
   5526  1.1  joerg     echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
   5527  1.1  joerg   fi
   5528  1.1  joerg }
   5529  1.1  joerg 
   5530  1.1  joerg # Used when --lt-debug. Prints its arguments to stdout
   5531  1.1  joerg # (redirection is the responsibility of the caller)
   5532  1.1  joerg func_lt_dump_args ()
   5533  1.1  joerg {
   5534  1.1  joerg   lt_dump_args_N=1;
   5535  1.1  joerg   for lt_arg
   5536  1.1  joerg   do
   5537  1.1  joerg     \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
   5538  1.1  joerg     lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
   5539  1.1  joerg   done
   5540  1.1  joerg }
   5541  1.1  joerg 
   5542  1.1  joerg # Core function for launching the target application
   5543  1.1  joerg func_exec_program_core ()
   5544  1.1  joerg {
   5545  1.1  joerg "
   5546  1.1  joerg   case $host in
   5547  1.1  joerg   # Backslashes separate directories on plain windows
   5548  1.1  joerg   *-*-mingw | *-*-os2* | *-cegcc*)
   5549  1.1  joerg     $ECHO "\
   5550  1.1  joerg       if test -n \"\$lt_option_debug\"; then
   5551  1.1  joerg         \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
   5552  1.1  joerg         func_lt_dump_args \${1+\"\$@\"} 1>&2
   5553  1.1  joerg       fi
   5554  1.1  joerg       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
   5555  1.1  joerg "
   5556  1.1  joerg     ;;
   5557  1.1  joerg 
   5558  1.1  joerg   *)
   5559  1.1  joerg     $ECHO "\
   5560  1.1  joerg       if test -n \"\$lt_option_debug\"; then
   5561  1.1  joerg         \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
   5562  1.1  joerg         func_lt_dump_args \${1+\"\$@\"} 1>&2
   5563  1.1  joerg       fi
   5564  1.1  joerg       exec \"\$progdir/\$program\" \${1+\"\$@\"}
   5565  1.1  joerg "
   5566  1.1  joerg     ;;
   5567  1.1  joerg   esac
   5568  1.1  joerg   $ECHO "\
   5569  1.1  joerg       \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
   5570  1.1  joerg       exit 1
   5571  1.1  joerg }
   5572  1.1  joerg 
   5573  1.1  joerg # A function to encapsulate launching the target application
   5574  1.1  joerg # Strips options in the --lt-* namespace from \$@ and
   5575  1.1  joerg # launches target application with the remaining arguments.
   5576  1.1  joerg func_exec_program ()
   5577  1.1  joerg {
   5578  1.1  joerg   case \" \$* \" in
   5579  1.1  joerg   *\\ --lt-*)
   5580  1.1  joerg     for lt_wr_arg
   5581  1.1  joerg     do
   5582  1.1  joerg       case \$lt_wr_arg in
   5583  1.1  joerg       --lt-*) ;;
   5584  1.1  joerg       *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
   5585  1.1  joerg       esac
   5586  1.1  joerg       shift
   5587  1.1  joerg     done ;;
   5588  1.1  joerg   esac
   5589  1.1  joerg   func_exec_program_core \${1+\"\$@\"}
   5590  1.1  joerg }
   5591  1.1  joerg 
   5592  1.1  joerg   # Parse options
   5593  1.1  joerg   func_parse_lt_options \"\$0\" \${1+\"\$@\"}
   5594  1.1  joerg 
   5595  1.1  joerg   # Find the directory that this script lives in.
   5596  1.1  joerg   thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
   5597  1.1  joerg   test \"x\$thisdir\" = \"x\$file\" && thisdir=.
   5598  1.1  joerg 
   5599  1.1  joerg   # Follow symbolic links until we get to the real thisdir.
   5600  1.1  joerg   file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
   5601  1.1  joerg   while test -n \"\$file\"; do
   5602  1.1  joerg     destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
   5603  1.1  joerg 
   5604  1.1  joerg     # If there was a directory component, then change thisdir.
   5605  1.1  joerg     if test \"x\$destdir\" != \"x\$file\"; then
   5606  1.1  joerg       case \"\$destdir\" in
   5607  1.1  joerg       [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
   5608  1.1  joerg       *) thisdir=\"\$thisdir/\$destdir\" ;;
   5609  1.1  joerg       esac
   5610  1.1  joerg     fi
   5611  1.1  joerg 
   5612  1.1  joerg     file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
   5613  1.1  joerg     file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
   5614  1.1  joerg   done
   5615  1.1  joerg 
   5616  1.1  joerg   # Usually 'no', except on cygwin/mingw when embedded into
   5617  1.1  joerg   # the cwrapper.
   5618  1.1  joerg   WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
   5619  1.1  joerg   if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
   5620  1.1  joerg     # special case for '.'
   5621  1.1  joerg     if test \"\$thisdir\" = \".\"; then
   5622  1.1  joerg       thisdir=\`pwd\`
   5623  1.1  joerg     fi
   5624  1.1  joerg     # remove .libs from thisdir
   5625  1.1  joerg     case \"\$thisdir\" in
   5626  1.1  joerg     *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
   5627  1.1  joerg     $objdir )   thisdir=. ;;
   5628  1.1  joerg     esac
   5629  1.1  joerg   fi
   5630  1.1  joerg 
   5631  1.1  joerg   # Try to get the absolute directory name.
   5632  1.1  joerg   absdir=\`cd \"\$thisdir\" && pwd\`
   5633  1.1  joerg   test -n \"\$absdir\" && thisdir=\"\$absdir\"
   5634  1.1  joerg "
   5635  1.1  joerg 
   5636  1.1  joerg 	if test yes = "$fast_install"; then
   5637  1.1  joerg 	  $ECHO "\
   5638  1.1  joerg   program=lt-'$outputname'$exeext
   5639  1.1  joerg   progdir=\"\$thisdir/$objdir\"
   5640  1.1  joerg 
   5641  1.1  joerg   if test ! -f \"\$progdir/\$program\" ||
   5642  1.1  joerg      { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
   5643  1.1  joerg        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
   5644  1.1  joerg 
   5645  1.1  joerg     file=\"\$\$-\$program\"
   5646  1.1  joerg 
   5647  1.1  joerg     if test ! -d \"\$progdir\"; then
   5648  1.1  joerg       $MKDIR \"\$progdir\"
   5649  1.1  joerg     else
   5650  1.1  joerg       $RM \"\$progdir/\$file\"
   5651  1.1  joerg     fi"
   5652  1.1  joerg 
   5653  1.1  joerg 	  $ECHO "\
   5654  1.1  joerg 
   5655  1.1  joerg     # relink executable if necessary
   5656  1.1  joerg     if test -n \"\$relink_command\"; then
   5657  1.1  joerg       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
   5658  1.1  joerg       else
   5659  1.1  joerg 	\$ECHO \"\$relink_command_output\" >&2
   5660  1.1  joerg 	$RM \"\$progdir/\$file\"
   5661  1.1  joerg 	exit 1
   5662  1.1  joerg       fi
   5663  1.1  joerg     fi
   5664  1.1  joerg 
   5665  1.1  joerg     $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
   5666  1.1  joerg     { $RM \"\$progdir/\$program\";
   5667  1.1  joerg       $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
   5668  1.1  joerg     $RM \"\$progdir/\$file\"
   5669  1.1  joerg   fi"
   5670  1.1  joerg 	else
   5671  1.1  joerg 	  $ECHO "\
   5672  1.1  joerg   program='$outputname'
   5673  1.1  joerg   progdir=\"\$thisdir/$objdir\"
   5674  1.1  joerg "
   5675  1.1  joerg 	fi
   5676  1.1  joerg 
   5677  1.1  joerg 	$ECHO "\
   5678  1.1  joerg 
   5679  1.1  joerg   if test -f \"\$progdir/\$program\"; then"
   5680  1.1  joerg 
   5681  1.1  joerg 	# fixup the dll searchpath if we need to.
   5682  1.1  joerg 	#
   5683  1.1  joerg 	# Fix the DLL searchpath if we need to.  Do this before prepending
   5684  1.1  joerg 	# to shlibpath, because on Windows, both are PATH and uninstalled
   5685  1.1  joerg 	# libraries must come first.
   5686  1.1  joerg 	if test -n "$dllsearchpath"; then
   5687  1.1  joerg 	  $ECHO "\
   5688  1.1  joerg     # Add the dll search path components to the executable PATH
   5689  1.1  joerg     PATH=$dllsearchpath:\$PATH
   5690  1.1  joerg "
   5691  1.1  joerg 	fi
   5692  1.1  joerg 
   5693  1.1  joerg 	# Export our shlibpath_var if we have one.
   5694  1.1  joerg 	if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
   5695  1.1  joerg 	  $ECHO "\
   5696  1.1  joerg     # Add our own library path to $shlibpath_var
   5697  1.1  joerg     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
   5698  1.1  joerg 
   5699  1.1  joerg     # Some systems cannot cope with colon-terminated $shlibpath_var
   5700  1.1  joerg     # The second colon is a workaround for a bug in BeOS R4 sed
   5701  1.1  joerg     $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
   5702  1.1  joerg 
   5703  1.1  joerg     export $shlibpath_var
   5704  1.1  joerg "
   5705  1.1  joerg 	fi
   5706  1.1  joerg 
   5707  1.1  joerg 	$ECHO "\
   5708  1.1  joerg     if test \"\$libtool_execute_magic\" != \"$magic\"; then
   5709  1.1  joerg       # Run the actual program with our arguments.
   5710  1.1  joerg       func_exec_program \${1+\"\$@\"}
   5711  1.1  joerg     fi
   5712  1.1  joerg   else
   5713  1.1  joerg     # The program doesn't exist.
   5714  1.1  joerg     \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
   5715  1.1  joerg     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
   5716  1.1  joerg     \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
   5717  1.1  joerg     exit 1
   5718  1.1  joerg   fi
   5719  1.1  joerg fi\
   5720  1.1  joerg "
   5721  1.1  joerg }
   5722  1.1  joerg 
   5723  1.1  joerg 
   5724  1.1  joerg # func_emit_cwrapperexe_src
   5725  1.1  joerg # emit the source code for a wrapper executable on stdout
   5726  1.1  joerg # Must ONLY be called from within func_mode_link because
   5727  1.1  joerg # it depends on a number of variable set therein.
   5728  1.1  joerg func_emit_cwrapperexe_src ()
   5729  1.1  joerg {
   5730  1.1  joerg 	cat <<EOF
   5731  1.1  joerg 
   5732  1.1  joerg /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
   5733  1.1  joerg    Generated by $PROGRAM (GNU $PACKAGE) $VERSION
   5734  1.1  joerg 
   5735  1.1  joerg    The $output program cannot be directly executed until all the libtool
   5736  1.1  joerg    libraries that it depends on are installed.
   5737  1.1  joerg 
   5738  1.1  joerg    This wrapper executable should never be moved out of the build directory.
   5739  1.1  joerg    If it is, it will not operate correctly.
   5740  1.1  joerg */
   5741  1.1  joerg EOF
   5742  1.1  joerg 	    cat <<"EOF"
   5743  1.1  joerg #ifdef _MSC_VER
   5744  1.1  joerg # define _CRT_SECURE_NO_DEPRECATE 1
   5745  1.1  joerg #endif
   5746  1.1  joerg #include <stdio.h>
   5747  1.1  joerg #include <stdlib.h>
   5748  1.1  joerg #ifdef _MSC_VER
   5749  1.1  joerg # include <direct.h>
   5750  1.1  joerg # include <process.h>
   5751  1.1  joerg # include <io.h>
   5752  1.1  joerg #else
   5753  1.1  joerg # include <unistd.h>
   5754  1.1  joerg # include <stdint.h>
   5755  1.1  joerg # ifdef __CYGWIN__
   5756  1.1  joerg #  include <io.h>
   5757  1.1  joerg # endif
   5758  1.1  joerg #endif
   5759  1.1  joerg #include <malloc.h>
   5760  1.1  joerg #include <stdarg.h>
   5761  1.1  joerg #include <assert.h>
   5762  1.1  joerg #include <string.h>
   5763  1.1  joerg #include <ctype.h>
   5764  1.1  joerg #include <errno.h>
   5765  1.1  joerg #include <fcntl.h>
   5766  1.1  joerg #include <sys/stat.h>
   5767  1.1  joerg 
   5768  1.1  joerg #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
   5769  1.1  joerg 
   5770  1.1  joerg /* declarations of non-ANSI functions */
   5771  1.1  joerg #if defined __MINGW32__
   5772  1.1  joerg # ifdef __STRICT_ANSI__
   5773  1.1  joerg int _putenv (const char *);
   5774  1.1  joerg # endif
   5775  1.1  joerg #elif defined __CYGWIN__
   5776  1.1  joerg # ifdef __STRICT_ANSI__
   5777  1.1  joerg char *realpath (const char *, char *);
   5778  1.1  joerg int putenv (char *);
   5779  1.1  joerg int setenv (const char *, const char *, int);
   5780  1.1  joerg # endif
   5781  1.1  joerg /* #elif defined other_platform || defined ... */
   5782  1.1  joerg #endif
   5783  1.1  joerg 
   5784  1.1  joerg /* portability defines, excluding path handling macros */
   5785  1.1  joerg #if defined _MSC_VER
   5786  1.1  joerg # define setmode _setmode
   5787  1.1  joerg # define stat    _stat
   5788  1.1  joerg # define chmod   _chmod
   5789  1.1  joerg # define getcwd  _getcwd
   5790  1.1  joerg # define putenv  _putenv
   5791  1.1  joerg # define S_IXUSR _S_IEXEC
   5792  1.1  joerg #elif defined __MINGW32__
   5793  1.1  joerg # define setmode _setmode
   5794  1.1  joerg # define stat    _stat
   5795  1.1  joerg # define chmod   _chmod
   5796  1.1  joerg # define getcwd  _getcwd
   5797  1.1  joerg # define putenv  _putenv
   5798  1.1  joerg #elif defined __CYGWIN__
   5799  1.1  joerg # define HAVE_SETENV
   5800  1.1  joerg # define FOPEN_WB "wb"
   5801  1.1  joerg /* #elif defined other platforms ... */
   5802  1.1  joerg #endif
   5803  1.1  joerg 
   5804  1.1  joerg #if defined PATH_MAX
   5805  1.1  joerg # define LT_PATHMAX PATH_MAX
   5806  1.1  joerg #elif defined MAXPATHLEN
   5807  1.1  joerg # define LT_PATHMAX MAXPATHLEN
   5808  1.1  joerg #else
   5809  1.1  joerg # define LT_PATHMAX 1024
   5810  1.1  joerg #endif
   5811  1.1  joerg 
   5812  1.1  joerg #ifndef S_IXOTH
   5813  1.1  joerg # define S_IXOTH 0
   5814  1.1  joerg #endif
   5815  1.1  joerg #ifndef S_IXGRP
   5816  1.1  joerg # define S_IXGRP 0
   5817  1.1  joerg #endif
   5818  1.1  joerg 
   5819  1.1  joerg /* path handling portability macros */
   5820  1.1  joerg #ifndef DIR_SEPARATOR
   5821  1.1  joerg # define DIR_SEPARATOR '/'
   5822  1.1  joerg # define PATH_SEPARATOR ':'
   5823  1.1  joerg #endif
   5824  1.1  joerg 
   5825  1.1  joerg #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
   5826  1.1  joerg   defined __OS2__
   5827  1.1  joerg # define HAVE_DOS_BASED_FILE_SYSTEM
   5828  1.1  joerg # define FOPEN_WB "wb"
   5829  1.1  joerg # ifndef DIR_SEPARATOR_2
   5830  1.1  joerg #  define DIR_SEPARATOR_2 '\\'
   5831  1.1  joerg # endif
   5832  1.1  joerg # ifndef PATH_SEPARATOR_2
   5833  1.1  joerg #  define PATH_SEPARATOR_2 ';'
   5834  1.1  joerg # endif
   5835  1.1  joerg #endif
   5836  1.1  joerg 
   5837  1.1  joerg #ifndef DIR_SEPARATOR_2
   5838  1.1  joerg # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
   5839  1.1  joerg #else /* DIR_SEPARATOR_2 */
   5840  1.1  joerg # define IS_DIR_SEPARATOR(ch) \
   5841  1.1  joerg 	(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
   5842  1.1  joerg #endif /* DIR_SEPARATOR_2 */
   5843  1.1  joerg 
   5844  1.1  joerg #ifndef PATH_SEPARATOR_2
   5845  1.1  joerg # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
   5846  1.1  joerg #else /* PATH_SEPARATOR_2 */
   5847  1.1  joerg # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
   5848  1.1  joerg #endif /* PATH_SEPARATOR_2 */
   5849  1.1  joerg 
   5850  1.1  joerg #ifndef FOPEN_WB
   5851  1.1  joerg # define FOPEN_WB "w"
   5852  1.1  joerg #endif
   5853  1.1  joerg #ifndef _O_BINARY
   5854  1.1  joerg # define _O_BINARY 0
   5855  1.1  joerg #endif
   5856  1.1  joerg 
   5857  1.1  joerg #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
   5858  1.1  joerg #define XFREE(stale) do { \
   5859  1.1  joerg   if (stale) { free (stale); stale = 0; } \
   5860  1.1  joerg } while (0)
   5861  1.1  joerg 
   5862  1.1  joerg #if defined LT_DEBUGWRAPPER
   5863  1.1  joerg static int lt_debug = 1;
   5864  1.1  joerg #else
   5865  1.1  joerg static int lt_debug = 0;
   5866  1.1  joerg #endif
   5867  1.1  joerg 
   5868  1.1  joerg const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
   5869  1.1  joerg 
   5870  1.1  joerg void *xmalloc (size_t num);
   5871  1.1  joerg char *xstrdup (const char *string);
   5872  1.1  joerg const char *base_name (const char *name);
   5873  1.1  joerg char *find_executable (const char *wrapper);
   5874  1.1  joerg char *chase_symlinks (const char *pathspec);
   5875  1.1  joerg int make_executable (const char *path);
   5876  1.1  joerg int check_executable (const char *path);
   5877  1.1  joerg char *strendzap (char *str, const char *pat);
   5878  1.1  joerg void lt_debugprintf (const char *file, int line, const char *fmt, ...);
   5879  1.1  joerg void lt_fatal (const char *file, int line, const char *message, ...);
   5880  1.1  joerg static const char *nonnull (const char *s);
   5881  1.1  joerg static const char *nonempty (const char *s);
   5882  1.1  joerg void lt_setenv (const char *name, const char *value);
   5883  1.1  joerg char *lt_extend_str (const char *orig_value, const char *add, int to_end);
   5884  1.1  joerg void lt_update_exe_path (const char *name, const char *value);
   5885  1.1  joerg void lt_update_lib_path (const char *name, const char *value);
   5886  1.1  joerg char **prepare_spawn (char **argv);
   5887  1.1  joerg void lt_dump_script (FILE *f);
   5888  1.1  joerg EOF
   5889  1.1  joerg 
   5890  1.1  joerg 	    cat <<EOF
   5891  1.1  joerg #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
   5892  1.1  joerg # define externally_visible volatile
   5893  1.1  joerg #else
   5894  1.1  joerg # define externally_visible __attribute__((externally_visible)) volatile
   5895  1.1  joerg #endif
   5896  1.1  joerg externally_visible const char * MAGIC_EXE = "$magic_exe";
   5897  1.1  joerg const char * LIB_PATH_VARNAME = "$shlibpath_var";
   5898  1.1  joerg EOF
   5899  1.1  joerg 
   5900  1.1  joerg 	    if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
   5901  1.1  joerg               func_to_host_path "$temp_rpath"
   5902  1.1  joerg 	      cat <<EOF
   5903  1.1  joerg const char * LIB_PATH_VALUE   = "$func_to_host_path_result";
   5904  1.1  joerg EOF
   5905  1.1  joerg 	    else
   5906  1.1  joerg 	      cat <<"EOF"
   5907  1.1  joerg const char * LIB_PATH_VALUE   = "";
   5908  1.1  joerg EOF
   5909  1.1  joerg 	    fi
   5910  1.1  joerg 
   5911  1.1  joerg 	    if test -n "$dllsearchpath"; then
   5912  1.1  joerg               func_to_host_path "$dllsearchpath:"
   5913  1.1  joerg 	      cat <<EOF
   5914  1.1  joerg const char * EXE_PATH_VARNAME = "PATH";
   5915  1.1  joerg const char * EXE_PATH_VALUE   = "$func_to_host_path_result";
   5916  1.1  joerg EOF
   5917  1.1  joerg 	    else
   5918  1.1  joerg 	      cat <<"EOF"
   5919  1.1  joerg const char * EXE_PATH_VARNAME = "";
   5920  1.1  joerg const char * EXE_PATH_VALUE   = "";
   5921  1.1  joerg EOF
   5922  1.1  joerg 	    fi
   5923  1.1  joerg 
   5924  1.1  joerg 	    if test yes = "$fast_install"; then
   5925  1.1  joerg 	      cat <<EOF
   5926  1.1  joerg const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
   5927  1.1  joerg EOF
   5928  1.1  joerg 	    else
   5929  1.1  joerg 	      cat <<EOF
   5930  1.1  joerg const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
   5931  1.1  joerg EOF
   5932  1.1  joerg 	    fi
   5933  1.1  joerg 
   5934  1.1  joerg 
   5935  1.1  joerg 	    cat <<"EOF"
   5936  1.1  joerg 
   5937  1.1  joerg #define LTWRAPPER_OPTION_PREFIX         "--lt-"
   5938  1.1  joerg 
   5939  1.1  joerg static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
   5940  1.1  joerg static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
   5941  1.1  joerg static const char *debug_opt            = LTWRAPPER_OPTION_PREFIX "debug";
   5942  1.1  joerg 
   5943  1.1  joerg int
   5944  1.1  joerg main (int argc, char *argv[])
   5945  1.1  joerg {
   5946  1.1  joerg   char **newargz;
   5947  1.1  joerg   int  newargc;
   5948  1.1  joerg   char *tmp_pathspec;
   5949  1.1  joerg   char *actual_cwrapper_path;
   5950  1.1  joerg   char *actual_cwrapper_name;
   5951  1.1  joerg   char *target_name;
   5952  1.1  joerg   char *lt_argv_zero;
   5953  1.1  joerg   int rval = 127;
   5954  1.1  joerg 
   5955  1.1  joerg   int i;
   5956  1.1  joerg 
   5957  1.1  joerg   program_name = (char *) xstrdup (base_name (argv[0]));
   5958  1.1  joerg   newargz = XMALLOC (char *, (size_t) argc + 1);
   5959  1.1  joerg 
   5960  1.1  joerg   /* very simple arg parsing; don't want to rely on getopt
   5961  1.1  joerg    * also, copy all non cwrapper options to newargz, except
   5962  1.1  joerg    * argz[0], which is handled differently
   5963  1.1  joerg    */
   5964  1.1  joerg   newargc=0;
   5965  1.1  joerg   for (i = 1; i < argc; i++)
   5966  1.1  joerg     {
   5967  1.1  joerg       if (STREQ (argv[i], dumpscript_opt))
   5968  1.1  joerg 	{
   5969  1.1  joerg EOF
   5970  1.1  joerg 	    case $host in
   5971  1.1  joerg 	      *mingw* | *cygwin* )
   5972  1.1  joerg 		# make stdout use "unix" line endings
   5973  1.1  joerg 		echo "          setmode(1,_O_BINARY);"
   5974  1.1  joerg 		;;
   5975  1.1  joerg 	      esac
   5976  1.1  joerg 
   5977  1.1  joerg 	    cat <<"EOF"
   5978  1.1  joerg 	  lt_dump_script (stdout);
   5979  1.1  joerg 	  return 0;
   5980  1.1  joerg 	}
   5981  1.1  joerg       if (STREQ (argv[i], debug_opt))
   5982  1.1  joerg 	{
   5983  1.1  joerg           lt_debug = 1;
   5984  1.1  joerg           continue;
   5985  1.1  joerg 	}
   5986  1.1  joerg       if (STREQ (argv[i], ltwrapper_option_prefix))
   5987  1.1  joerg         {
   5988  1.1  joerg           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
   5989  1.1  joerg              namespace, but it is not one of the ones we know about and
   5990  1.1  joerg              have already dealt with, above (inluding dump-script), then
   5991  1.1  joerg              report an error. Otherwise, targets might begin to believe
   5992  1.1  joerg              they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
   5993  1.1  joerg              namespace. The first time any user complains about this, we'll
   5994  1.1  joerg              need to make LTWRAPPER_OPTION_PREFIX a configure-time option
   5995  1.1  joerg              or a configure.ac-settable value.
   5996  1.1  joerg            */
   5997  1.1  joerg           lt_fatal (__FILE__, __LINE__,
   5998  1.1  joerg 		    "unrecognized %s option: '%s'",
   5999  1.1  joerg                     ltwrapper_option_prefix, argv[i]);
   6000  1.1  joerg         }
   6001  1.1  joerg       /* otherwise ... */
   6002  1.1  joerg       newargz[++newargc] = xstrdup (argv[i]);
   6003  1.1  joerg     }
   6004  1.1  joerg   newargz[++newargc] = NULL;
   6005  1.1  joerg 
   6006  1.1  joerg EOF
   6007  1.1  joerg 	    cat <<EOF
   6008  1.1  joerg   /* The GNU banner must be the first non-error debug message */
   6009  1.1  joerg   lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
   6010  1.1  joerg EOF
   6011  1.1  joerg 	    cat <<"EOF"
   6012  1.1  joerg   lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
   6013  1.1  joerg   lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
   6014  1.1  joerg 
   6015  1.1  joerg   tmp_pathspec = find_executable (argv[0]);
   6016  1.1  joerg   if (tmp_pathspec == NULL)
   6017  1.1  joerg     lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
   6018  1.1  joerg   lt_debugprintf (__FILE__, __LINE__,
   6019  1.1  joerg                   "(main) found exe (before symlink chase) at: %s\n",
   6020  1.1  joerg 		  tmp_pathspec);
   6021  1.1  joerg 
   6022  1.1  joerg   actual_cwrapper_path = chase_symlinks (tmp_pathspec);
   6023  1.1  joerg   lt_debugprintf (__FILE__, __LINE__,
   6024  1.1  joerg                   "(main) found exe (after symlink chase) at: %s\n",
   6025  1.1  joerg 		  actual_cwrapper_path);
   6026  1.1  joerg   XFREE (tmp_pathspec);
   6027  1.1  joerg 
   6028  1.1  joerg   actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
   6029  1.1  joerg   strendzap (actual_cwrapper_path, actual_cwrapper_name);
   6030  1.1  joerg 
   6031  1.1  joerg   /* wrapper name transforms */
   6032  1.1  joerg   strendzap (actual_cwrapper_name, ".exe");
   6033  1.1  joerg   tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
   6034  1.1  joerg   XFREE (actual_cwrapper_name);
   6035  1.1  joerg   actual_cwrapper_name = tmp_pathspec;
   6036  1.1  joerg   tmp_pathspec = 0;
   6037  1.1  joerg 
   6038  1.1  joerg   /* target_name transforms -- use actual target program name; might have lt- prefix */
   6039  1.1  joerg   target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
   6040  1.1  joerg   strendzap (target_name, ".exe");
   6041  1.1  joerg   tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
   6042  1.1  joerg   XFREE (target_name);
   6043  1.1  joerg   target_name = tmp_pathspec;
   6044  1.1  joerg   tmp_pathspec = 0;
   6045  1.1  joerg 
   6046  1.1  joerg   lt_debugprintf (__FILE__, __LINE__,
   6047  1.1  joerg 		  "(main) libtool target name: %s\n",
   6048  1.1  joerg 		  target_name);
   6049  1.1  joerg EOF
   6050  1.1  joerg 
   6051  1.1  joerg 	    cat <<EOF
   6052  1.1  joerg   newargz[0] =
   6053  1.1  joerg     XMALLOC (char, (strlen (actual_cwrapper_path) +
   6054  1.1  joerg 		    strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
   6055  1.1  joerg   strcpy (newargz[0], actual_cwrapper_path);
   6056  1.1  joerg   strcat (newargz[0], "$objdir");
   6057  1.1  joerg   strcat (newargz[0], "/");
   6058  1.1  joerg EOF
   6059  1.1  joerg 
   6060  1.1  joerg 	    cat <<"EOF"
   6061  1.1  joerg   /* stop here, and copy so we don't have to do this twice */
   6062  1.1  joerg   tmp_pathspec = xstrdup (newargz[0]);
   6063  1.1  joerg 
   6064  1.1  joerg   /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
   6065  1.1  joerg   strcat (newargz[0], actual_cwrapper_name);
   6066  1.1  joerg 
   6067  1.1  joerg   /* DO want the lt- prefix here if it exists, so use target_name */
   6068  1.1  joerg   lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
   6069  1.1  joerg   XFREE (tmp_pathspec);
   6070  1.1  joerg   tmp_pathspec = NULL;
   6071  1.1  joerg EOF
   6072  1.1  joerg 
   6073  1.1  joerg 	    case $host_os in
   6074  1.1  joerg 	      mingw*)
   6075  1.1  joerg 	    cat <<"EOF"
   6076  1.1  joerg   {
   6077  1.1  joerg     char* p;
   6078  1.1  joerg     while ((p = strchr (newargz[0], '\\')) != NULL)
   6079  1.1  joerg       {
   6080  1.1  joerg 	*p = '/';
   6081  1.1  joerg       }
   6082  1.1  joerg     while ((p = strchr (lt_argv_zero, '\\')) != NULL)
   6083  1.1  joerg       {
   6084  1.1  joerg 	*p = '/';
   6085  1.1  joerg       }
   6086  1.1  joerg   }
   6087  1.1  joerg EOF
   6088  1.1  joerg 	    ;;
   6089  1.1  joerg 	    esac
   6090  1.1  joerg 
   6091  1.1  joerg 	    cat <<"EOF"
   6092  1.1  joerg   XFREE (target_name);
   6093  1.1  joerg   XFREE (actual_cwrapper_path);
   6094  1.1  joerg   XFREE (actual_cwrapper_name);
   6095  1.1  joerg 
   6096  1.1  joerg   lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
   6097  1.1  joerg   lt_setenv ("DUALCASE", "1");  /* for MSK sh */
   6098  1.1  joerg   /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must
   6099  1.1  joerg      be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
   6100  1.1  joerg      because on Windows, both *_VARNAMEs are PATH but uninstalled
   6101  1.1  joerg      libraries must come first. */
   6102  1.1  joerg   lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
   6103  1.1  joerg   lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
   6104  1.1  joerg 
   6105  1.1  joerg   lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
   6106  1.1  joerg 		  nonnull (lt_argv_zero));
   6107  1.1  joerg   for (i = 0; i < newargc; i++)
   6108  1.1  joerg     {
   6109  1.1  joerg       lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
   6110  1.1  joerg 		      i, nonnull (newargz[i]));
   6111  1.1  joerg     }
   6112  1.1  joerg 
   6113  1.1  joerg EOF
   6114  1.1  joerg 
   6115  1.1  joerg 	    case $host_os in
   6116  1.1  joerg 	      mingw*)
   6117  1.1  joerg 		cat <<"EOF"
   6118  1.1  joerg   /* execv doesn't actually work on mingw as expected on unix */
   6119  1.1  joerg   newargz = prepare_spawn (newargz);
   6120  1.1  joerg   rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
   6121  1.1  joerg   if (rval == -1)
   6122  1.1  joerg     {
   6123  1.1  joerg       /* failed to start process */
   6124  1.1  joerg       lt_debugprintf (__FILE__, __LINE__,
   6125  1.1  joerg 		      "(main) failed to launch target \"%s\": %s\n",
   6126  1.1  joerg 		      lt_argv_zero, nonnull (strerror (errno)));
   6127  1.1  joerg       return 127;
   6128  1.1  joerg     }
   6129  1.1  joerg   return rval;
   6130  1.1  joerg EOF
   6131  1.1  joerg 		;;
   6132  1.1  joerg 	      *)
   6133  1.1  joerg 		cat <<"EOF"
   6134  1.1  joerg   execv (lt_argv_zero, newargz);
   6135  1.1  joerg   return rval; /* =127, but avoids unused variable warning */
   6136  1.1  joerg EOF
   6137  1.1  joerg 		;;
   6138  1.1  joerg 	    esac
   6139  1.1  joerg 
   6140  1.1  joerg 	    cat <<"EOF"
   6141  1.1  joerg }
   6142  1.1  joerg 
   6143  1.1  joerg void *
   6144  1.1  joerg xmalloc (size_t num)
   6145  1.1  joerg {
   6146  1.1  joerg   void *p = (void *) malloc (num);
   6147  1.1  joerg   if (!p)
   6148  1.1  joerg     lt_fatal (__FILE__, __LINE__, "memory exhausted");
   6149  1.1  joerg 
   6150  1.1  joerg   return p;
   6151  1.1  joerg }
   6152  1.1  joerg 
   6153  1.1  joerg char *
   6154  1.1  joerg xstrdup (const char *string)
   6155  1.1  joerg {
   6156  1.1  joerg   return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
   6157  1.1  joerg 			  string) : NULL;
   6158  1.1  joerg }
   6159  1.1  joerg 
   6160  1.1  joerg const char *
   6161  1.1  joerg base_name (const char *name)
   6162  1.1  joerg {
   6163  1.1  joerg   const char *base;
   6164  1.1  joerg 
   6165  1.1  joerg #if defined HAVE_DOS_BASED_FILE_SYSTEM
   6166  1.1  joerg   /* Skip over the disk name in MSDOS pathnames. */
   6167  1.1  joerg   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
   6168  1.1  joerg     name += 2;
   6169  1.1  joerg #endif
   6170  1.1  joerg 
   6171  1.1  joerg   for (base = name; *name; name++)
   6172  1.1  joerg     if (IS_DIR_SEPARATOR (*name))
   6173  1.1  joerg       base = name + 1;
   6174  1.1  joerg   return base;
   6175  1.1  joerg }
   6176  1.1  joerg 
   6177  1.1  joerg int
   6178  1.1  joerg check_executable (const char *path)
   6179  1.1  joerg {
   6180  1.1  joerg   struct stat st;
   6181  1.1  joerg 
   6182  1.1  joerg   lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
   6183  1.1  joerg                   nonempty (path));
   6184  1.1  joerg   if ((!path) || (!*path))
   6185  1.1  joerg     return 0;
   6186  1.1  joerg 
   6187  1.1  joerg   if ((stat (path, &st) >= 0)
   6188  1.1  joerg       && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
   6189  1.1  joerg     return 1;
   6190  1.1  joerg   else
   6191  1.1  joerg     return 0;
   6192  1.1  joerg }
   6193  1.1  joerg 
   6194  1.1  joerg int
   6195  1.1  joerg make_executable (const char *path)
   6196  1.1  joerg {
   6197  1.1  joerg   int rval = 0;
   6198  1.1  joerg   struct stat st;
   6199  1.1  joerg 
   6200  1.1  joerg   lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
   6201  1.1  joerg                   nonempty (path));
   6202  1.1  joerg   if ((!path) || (!*path))
   6203  1.1  joerg     return 0;
   6204  1.1  joerg 
   6205  1.1  joerg   if (stat (path, &st) >= 0)
   6206  1.1  joerg     {
   6207  1.1  joerg       rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
   6208  1.1  joerg     }
   6209  1.1  joerg   return rval;
   6210  1.1  joerg }
   6211  1.1  joerg 
   6212  1.1  joerg /* Searches for the full path of the wrapper.  Returns
   6213  1.1  joerg    newly allocated full path name if found, NULL otherwise
   6214  1.1  joerg    Does not chase symlinks, even on platforms that support them.
   6215  1.1  joerg */
   6216  1.1  joerg char *
   6217  1.1  joerg find_executable (const char *wrapper)
   6218  1.1  joerg {
   6219  1.1  joerg   int has_slash = 0;
   6220  1.1  joerg   const char *p;
   6221  1.1  joerg   const char *p_next;
   6222  1.1  joerg   /* static buffer for getcwd */
   6223  1.1  joerg   char tmp[LT_PATHMAX + 1];
   6224  1.1  joerg   size_t tmp_len;
   6225  1.1  joerg   char *concat_name;
   6226  1.1  joerg 
   6227  1.1  joerg   lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
   6228  1.1  joerg                   nonempty (wrapper));
   6229  1.1  joerg 
   6230  1.1  joerg   if ((wrapper == NULL) || (*wrapper == '\0'))
   6231  1.1  joerg     return NULL;
   6232  1.1  joerg 
   6233  1.1  joerg   /* Absolute path? */
   6234  1.1  joerg #if defined HAVE_DOS_BASED_FILE_SYSTEM
   6235  1.1  joerg   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
   6236  1.1  joerg     {
   6237  1.1  joerg       concat_name = xstrdup (wrapper);
   6238  1.1  joerg       if (check_executable (concat_name))
   6239  1.1  joerg 	return concat_name;
   6240  1.1  joerg       XFREE (concat_name);
   6241  1.1  joerg     }
   6242  1.1  joerg   else
   6243  1.1  joerg     {
   6244  1.1  joerg #endif
   6245  1.1  joerg       if (IS_DIR_SEPARATOR (wrapper[0]))
   6246  1.1  joerg 	{
   6247  1.1  joerg 	  concat_name = xstrdup (wrapper);
   6248  1.1  joerg 	  if (check_executable (concat_name))
   6249  1.1  joerg 	    return concat_name;
   6250  1.1  joerg 	  XFREE (concat_name);
   6251  1.1  joerg 	}
   6252  1.1  joerg #if defined HAVE_DOS_BASED_FILE_SYSTEM
   6253  1.1  joerg     }
   6254  1.1  joerg #endif
   6255  1.1  joerg 
   6256  1.1  joerg   for (p = wrapper; *p; p++)
   6257  1.1  joerg     if (*p == '/')
   6258  1.1  joerg       {
   6259  1.1  joerg 	has_slash = 1;
   6260  1.1  joerg 	break;
   6261  1.1  joerg       }
   6262  1.1  joerg   if (!has_slash)
   6263  1.1  joerg     {
   6264  1.1  joerg       /* no slashes; search PATH */
   6265  1.1  joerg       const char *path = getenv ("PATH");
   6266  1.1  joerg       if (path != NULL)
   6267  1.1  joerg 	{
   6268  1.1  joerg 	  for (p = path; *p; p = p_next)
   6269  1.1  joerg 	    {
   6270  1.1  joerg 	      const char *q;
   6271  1.1  joerg 	      size_t p_len;
   6272  1.1  joerg 	      for (q = p; *q; q++)
   6273  1.1  joerg 		if (IS_PATH_SEPARATOR (*q))
   6274  1.1  joerg 		  break;
   6275  1.1  joerg 	      p_len = (size_t) (q - p);
   6276  1.1  joerg 	      p_next = (*q == '\0' ? q : q + 1);
   6277  1.1  joerg 	      if (p_len == 0)
   6278  1.1  joerg 		{
   6279  1.1  joerg 		  /* empty path: current directory */
   6280  1.1  joerg 		  if (getcwd (tmp, LT_PATHMAX) == NULL)
   6281  1.1  joerg 		    lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
   6282  1.1  joerg                               nonnull (strerror (errno)));
   6283  1.1  joerg 		  tmp_len = strlen (tmp);
   6284  1.1  joerg 		  concat_name =
   6285  1.1  joerg 		    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
   6286  1.1  joerg 		  memcpy (concat_name, tmp, tmp_len);
   6287  1.1  joerg 		  concat_name[tmp_len] = '/';
   6288  1.1  joerg 		  strcpy (concat_name + tmp_len + 1, wrapper);
   6289  1.1  joerg 		}
   6290  1.1  joerg 	      else
   6291  1.1  joerg 		{
   6292  1.1  joerg 		  concat_name =
   6293  1.1  joerg 		    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
   6294  1.1  joerg 		  memcpy (concat_name, p, p_len);
   6295  1.1  joerg 		  concat_name[p_len] = '/';
   6296  1.1  joerg 		  strcpy (concat_name + p_len + 1, wrapper);
   6297  1.1  joerg 		}
   6298  1.1  joerg 	      if (check_executable (concat_name))
   6299  1.1  joerg 		return concat_name;
   6300  1.1  joerg 	      XFREE (concat_name);
   6301  1.1  joerg 	    }
   6302  1.1  joerg 	}
   6303  1.1  joerg       /* not found in PATH; assume curdir */
   6304  1.1  joerg     }
   6305  1.1  joerg   /* Relative path | not found in path: prepend cwd */
   6306  1.1  joerg   if (getcwd (tmp, LT_PATHMAX) == NULL)
   6307  1.1  joerg     lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
   6308  1.1  joerg               nonnull (strerror (errno)));
   6309  1.1  joerg   tmp_len = strlen (tmp);
   6310  1.1  joerg   concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
   6311  1.1  joerg   memcpy (concat_name, tmp, tmp_len);
   6312  1.1  joerg   concat_name[tmp_len] = '/';
   6313  1.1  joerg   strcpy (concat_name + tmp_len + 1, wrapper);
   6314  1.1  joerg 
   6315  1.1  joerg   if (check_executable (concat_name))
   6316  1.1  joerg     return concat_name;
   6317  1.1  joerg   XFREE (concat_name);
   6318  1.1  joerg   return NULL;
   6319  1.1  joerg }
   6320  1.1  joerg 
   6321  1.1  joerg char *
   6322  1.1  joerg chase_symlinks (const char *pathspec)
   6323  1.1  joerg {
   6324  1.1  joerg #ifndef S_ISLNK
   6325  1.1  joerg   return xstrdup (pathspec);
   6326  1.1  joerg #else
   6327  1.1  joerg   char buf[LT_PATHMAX];
   6328  1.1  joerg   struct stat s;
   6329  1.1  joerg   char *tmp_pathspec = xstrdup (pathspec);
   6330  1.1  joerg   char *p;
   6331  1.1  joerg   int has_symlinks = 0;
   6332  1.1  joerg   while (strlen (tmp_pathspec) && !has_symlinks)
   6333  1.1  joerg     {
   6334  1.1  joerg       lt_debugprintf (__FILE__, __LINE__,
   6335  1.1  joerg 		      "checking path component for symlinks: %s\n",
   6336  1.1  joerg 		      tmp_pathspec);
   6337  1.1  joerg       if (lstat (tmp_pathspec, &s) == 0)
   6338  1.1  joerg 	{
   6339  1.1  joerg 	  if (S_ISLNK (s.st_mode) != 0)
   6340  1.1  joerg 	    {
   6341  1.1  joerg 	      has_symlinks = 1;
   6342  1.1  joerg 	      break;
   6343  1.1  joerg 	    }
   6344  1.1  joerg 
   6345  1.1  joerg 	  /* search backwards for last DIR_SEPARATOR */
   6346  1.1  joerg 	  p = tmp_pathspec + strlen (tmp_pathspec) - 1;
   6347  1.1  joerg 	  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
   6348  1.1  joerg 	    p--;
   6349  1.1  joerg 	  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
   6350  1.1  joerg 	    {
   6351  1.1  joerg 	      /* no more DIR_SEPARATORS left */
   6352  1.1  joerg 	      break;
   6353  1.1  joerg 	    }
   6354  1.1  joerg 	  *p = '\0';
   6355  1.1  joerg 	}
   6356  1.1  joerg       else
   6357  1.1  joerg 	{
   6358  1.1  joerg 	  lt_fatal (__FILE__, __LINE__,
   6359  1.1  joerg 		    "error accessing file \"%s\": %s",
   6360  1.1  joerg 		    tmp_pathspec, nonnull (strerror (errno)));
   6361  1.1  joerg 	}
   6362  1.1  joerg     }
   6363  1.1  joerg   XFREE (tmp_pathspec);
   6364  1.1  joerg 
   6365  1.1  joerg   if (!has_symlinks)
   6366  1.1  joerg     {
   6367  1.1  joerg       return xstrdup (pathspec);
   6368  1.1  joerg     }
   6369  1.1  joerg 
   6370  1.1  joerg   tmp_pathspec = realpath (pathspec, buf);
   6371  1.1  joerg   if (tmp_pathspec == 0)
   6372  1.1  joerg     {
   6373  1.1  joerg       lt_fatal (__FILE__, __LINE__,
   6374  1.1  joerg 		"could not follow symlinks for %s", pathspec);
   6375  1.1  joerg     }
   6376  1.1  joerg   return xstrdup (tmp_pathspec);
   6377  1.1  joerg #endif
   6378  1.1  joerg }
   6379  1.1  joerg 
   6380  1.1  joerg char *
   6381  1.1  joerg strendzap (char *str, const char *pat)
   6382  1.1  joerg {
   6383  1.1  joerg   size_t len, patlen;
   6384  1.1  joerg 
   6385  1.1  joerg   assert (str != NULL);
   6386  1.1  joerg   assert (pat != NULL);
   6387  1.1  joerg 
   6388  1.1  joerg   len = strlen (str);
   6389  1.1  joerg   patlen = strlen (pat);
   6390  1.1  joerg 
   6391  1.1  joerg   if (patlen <= len)
   6392  1.1  joerg     {
   6393  1.1  joerg       str += len - patlen;
   6394  1.1  joerg       if (STREQ (str, pat))
   6395  1.1  joerg 	*str = '\0';
   6396  1.1  joerg     }
   6397  1.1  joerg   return str;
   6398  1.1  joerg }
   6399  1.1  joerg 
   6400  1.1  joerg void
   6401  1.1  joerg lt_debugprintf (const char *file, int line, const char *fmt, ...)
   6402  1.1  joerg {
   6403  1.1  joerg   va_list args;
   6404  1.1  joerg   if (lt_debug)
   6405  1.1  joerg     {
   6406  1.1  joerg       (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
   6407  1.1  joerg       va_start (args, fmt);
   6408  1.1  joerg       (void) vfprintf (stderr, fmt, args);
   6409  1.1  joerg       va_end (args);
   6410  1.1  joerg     }
   6411  1.1  joerg }
   6412  1.1  joerg 
   6413  1.1  joerg static void
   6414  1.1  joerg lt_error_core (int exit_status, const char *file,
   6415  1.1  joerg 	       int line, const char *mode,
   6416  1.1  joerg 	       const char *message, va_list ap)
   6417  1.1  joerg {
   6418  1.1  joerg   fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
   6419  1.1  joerg   vfprintf (stderr, message, ap);
   6420  1.1  joerg   fprintf (stderr, ".\n");
   6421  1.1  joerg 
   6422  1.1  joerg   if (exit_status >= 0)
   6423  1.1  joerg     exit (exit_status);
   6424  1.1  joerg }
   6425  1.1  joerg 
   6426  1.1  joerg void
   6427  1.1  joerg lt_fatal (const char *file, int line, const char *message, ...)
   6428  1.1  joerg {
   6429  1.1  joerg   va_list ap;
   6430  1.1  joerg   va_start (ap, message);
   6431  1.1  joerg   lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
   6432  1.1  joerg   va_end (ap);
   6433  1.1  joerg }
   6434  1.1  joerg 
   6435  1.1  joerg static const char *
   6436  1.1  joerg nonnull (const char *s)
   6437  1.1  joerg {
   6438  1.1  joerg   return s ? s : "(null)";
   6439  1.1  joerg }
   6440  1.1  joerg 
   6441  1.1  joerg static const char *
   6442  1.1  joerg nonempty (const char *s)
   6443  1.1  joerg {
   6444  1.1  joerg   return (s && !*s) ? "(empty)" : nonnull (s);
   6445  1.1  joerg }
   6446  1.1  joerg 
   6447  1.1  joerg void
   6448  1.1  joerg lt_setenv (const char *name, const char *value)
   6449  1.1  joerg {
   6450  1.1  joerg   lt_debugprintf (__FILE__, __LINE__,
   6451  1.1  joerg 		  "(lt_setenv) setting '%s' to '%s'\n",
   6452  1.1  joerg                   nonnull (name), nonnull (value));
   6453  1.1  joerg   {
   6454  1.1  joerg #ifdef HAVE_SETENV
   6455  1.1  joerg     /* always make a copy, for consistency with !HAVE_SETENV */
   6456  1.1  joerg     char *str = xstrdup (value);
   6457  1.1  joerg     setenv (name, str, 1);
   6458  1.1  joerg #else
   6459  1.1  joerg     size_t len = strlen (name) + 1 + strlen (value) + 1;
   6460  1.1  joerg     char *str = XMALLOC (char, len);
   6461  1.1  joerg     sprintf (str, "%s=%s", name, value);
   6462  1.1  joerg     if (putenv (str) != EXIT_SUCCESS)
   6463  1.1  joerg       {
   6464  1.1  joerg         XFREE (str);
   6465  1.1  joerg       }
   6466  1.1  joerg #endif
   6467  1.1  joerg   }
   6468  1.1  joerg }
   6469  1.1  joerg 
   6470  1.1  joerg char *
   6471  1.1  joerg lt_extend_str (const char *orig_value, const char *add, int to_end)
   6472  1.1  joerg {
   6473  1.1  joerg   char *new_value;
   6474  1.1  joerg   if (orig_value && *orig_value)
   6475  1.1  joerg     {
   6476  1.1  joerg       size_t orig_value_len = strlen (orig_value);
   6477  1.1  joerg       size_t add_len = strlen (add);
   6478  1.1  joerg       new_value = XMALLOC (char, add_len + orig_value_len + 1);
   6479  1.1  joerg       if (to_end)
   6480  1.1  joerg         {
   6481  1.1  joerg           strcpy (new_value, orig_value);
   6482  1.1  joerg           strcpy (new_value + orig_value_len, add);
   6483  1.1  joerg         }
   6484  1.1  joerg       else
   6485  1.1  joerg         {
   6486  1.1  joerg           strcpy (new_value, add);
   6487  1.1  joerg           strcpy (new_value + add_len, orig_value);
   6488  1.1  joerg         }
   6489  1.1  joerg     }
   6490  1.1  joerg   else
   6491  1.1  joerg     {
   6492  1.1  joerg       new_value = xstrdup (add);
   6493  1.1  joerg     }
   6494  1.1  joerg   return new_value;
   6495  1.1  joerg }
   6496  1.1  joerg 
   6497  1.1  joerg void
   6498  1.1  joerg lt_update_exe_path (const char *name, const char *value)
   6499  1.1  joerg {
   6500  1.1  joerg   lt_debugprintf (__FILE__, __LINE__,
   6501  1.1  joerg 		  "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
   6502  1.1  joerg                   nonnull (name), nonnull (value));
   6503  1.1  joerg 
   6504  1.1  joerg   if (name && *name && value && *value)
   6505  1.1  joerg     {
   6506  1.1  joerg       char *new_value = lt_extend_str (getenv (name), value, 0);
   6507  1.1  joerg       /* some systems can't cope with a ':'-terminated path #' */
   6508  1.1  joerg       size_t len = strlen (new_value);
   6509  1.1  joerg       while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
   6510  1.1  joerg         {
   6511  1.1  joerg           new_value[--len] = '\0';
   6512  1.1  joerg         }
   6513  1.1  joerg       lt_setenv (name, new_value);
   6514  1.1  joerg       XFREE (new_value);
   6515  1.1  joerg     }
   6516  1.1  joerg }
   6517  1.1  joerg 
   6518  1.1  joerg void
   6519  1.1  joerg lt_update_lib_path (const char *name, const char *value)
   6520  1.1  joerg {
   6521  1.1  joerg   lt_debugprintf (__FILE__, __LINE__,
   6522  1.1  joerg 		  "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
   6523  1.1  joerg                   nonnull (name), nonnull (value));
   6524  1.1  joerg 
   6525  1.1  joerg   if (name && *name && value && *value)
   6526  1.1  joerg     {
   6527  1.1  joerg       char *new_value = lt_extend_str (getenv (name), value, 0);
   6528  1.1  joerg       lt_setenv (name, new_value);
   6529  1.1  joerg       XFREE (new_value);
   6530  1.1  joerg     }
   6531  1.1  joerg }
   6532  1.1  joerg 
   6533  1.1  joerg EOF
   6534  1.1  joerg 	    case $host_os in
   6535  1.1  joerg 	      mingw*)
   6536  1.1  joerg 		cat <<"EOF"
   6537  1.1  joerg 
   6538  1.1  joerg /* Prepares an argument vector before calling spawn().
   6539  1.1  joerg    Note that spawn() does not by itself call the command interpreter
   6540  1.1  joerg      (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
   6541  1.1  joerg       ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
   6542  1.1  joerg          GetVersionEx(&v);
   6543  1.1  joerg          v.dwPlatformId == VER_PLATFORM_WIN32_NT;
   6544  1.1  joerg       }) ? "cmd.exe" : "command.com").
   6545  1.1  joerg    Instead it simply concatenates the arguments, separated by ' ', and calls
   6546  1.1  joerg    CreateProcess().  We must quote the arguments since Win32 CreateProcess()
   6547  1.1  joerg    interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
   6548  1.1  joerg    special way:
   6549  1.1  joerg    - Space and tab are interpreted as delimiters. They are not treated as
   6550  1.1  joerg      delimiters if they are surrounded by double quotes: "...".
   6551  1.1  joerg    - Unescaped double quotes are removed from the input. Their only effect is
   6552  1.1  joerg      that within double quotes, space and tab are treated like normal
   6553  1.1  joerg      characters.
   6554  1.1  joerg    - Backslashes not followed by double quotes are not special.
   6555  1.1  joerg    - But 2*n+1 backslashes followed by a double quote become
   6556  1.1  joerg      n backslashes followed by a double quote (n >= 0):
   6557  1.1  joerg        \" -> "
   6558  1.1  joerg        \\\" -> \"
   6559  1.1  joerg        \\\\\" -> \\"
   6560  1.1  joerg  */
   6561  1.1  joerg #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"
   6562  1.1  joerg #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"
   6563  1.1  joerg char **
   6564  1.1  joerg prepare_spawn (char **argv)
   6565  1.1  joerg {
   6566  1.1  joerg   size_t argc;
   6567  1.1  joerg   char **new_argv;
   6568  1.1  joerg   size_t i;
   6569  1.1  joerg 
   6570  1.1  joerg   /* Count number of arguments.  */
   6571  1.1  joerg   for (argc = 0; argv[argc] != NULL; argc++)
   6572  1.1  joerg     ;
   6573  1.1  joerg 
   6574  1.1  joerg   /* Allocate new argument vector.  */
   6575  1.1  joerg   new_argv = XMALLOC (char *, argc + 1);
   6576  1.1  joerg 
   6577  1.1  joerg   /* Put quoted arguments into the new argument vector.  */
   6578  1.1  joerg   for (i = 0; i < argc; i++)
   6579  1.1  joerg     {
   6580  1.1  joerg       const char *string = argv[i];
   6581  1.1  joerg 
   6582  1.1  joerg       if (string[0] == '\0')
   6583  1.1  joerg 	new_argv[i] = xstrdup ("\"\"");
   6584  1.1  joerg       else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
   6585  1.1  joerg 	{
   6586  1.1  joerg 	  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
   6587  1.1  joerg 	  size_t length;
   6588  1.1  joerg 	  unsigned int backslashes;
   6589  1.1  joerg 	  const char *s;
   6590  1.1  joerg 	  char *quoted_string;
   6591  1.1  joerg 	  char *p;
   6592  1.1  joerg 
   6593  1.1  joerg 	  length = 0;
   6594  1.1  joerg 	  backslashes = 0;
   6595  1.1  joerg 	  if (quote_around)
   6596  1.1  joerg 	    length++;
   6597  1.1  joerg 	  for (s = string; *s != '\0'; s++)
   6598  1.1  joerg 	    {
   6599  1.1  joerg 	      char c = *s;
   6600  1.1  joerg 	      if (c == '"')
   6601  1.1  joerg 		length += backslashes + 1;
   6602  1.1  joerg 	      length++;
   6603  1.1  joerg 	      if (c == '\\')
   6604  1.1  joerg 		backslashes++;
   6605  1.1  joerg 	      else
   6606  1.1  joerg 		backslashes = 0;
   6607  1.1  joerg 	    }
   6608  1.1  joerg 	  if (quote_around)
   6609  1.1  joerg 	    length += backslashes + 1;
   6610  1.1  joerg 
   6611  1.1  joerg 	  quoted_string = XMALLOC (char, length + 1);
   6612  1.1  joerg 
   6613  1.1  joerg 	  p = quoted_string;
   6614  1.1  joerg 	  backslashes = 0;
   6615  1.1  joerg 	  if (quote_around)
   6616  1.1  joerg 	    *p++ = '"';
   6617  1.1  joerg 	  for (s = string; *s != '\0'; s++)
   6618  1.1  joerg 	    {
   6619  1.1  joerg 	      char c = *s;
   6620  1.1  joerg 	      if (c == '"')
   6621  1.1  joerg 		{
   6622  1.1  joerg 		  unsigned int j;
   6623  1.1  joerg 		  for (j = backslashes + 1; j > 0; j--)
   6624  1.1  joerg 		    *p++ = '\\';
   6625  1.1  joerg 		}
   6626  1.1  joerg 	      *p++ = c;
   6627  1.1  joerg 	      if (c == '\\')
   6628  1.1  joerg 		backslashes++;
   6629  1.1  joerg 	      else
   6630  1.1  joerg 		backslashes = 0;
   6631  1.1  joerg 	    }
   6632  1.1  joerg 	  if (quote_around)
   6633  1.1  joerg 	    {
   6634  1.1  joerg 	      unsigned int j;
   6635  1.1  joerg 	      for (j = backslashes; j > 0; j--)
   6636  1.1  joerg 		*p++ = '\\';
   6637  1.1  joerg 	      *p++ = '"';
   6638  1.1  joerg 	    }
   6639  1.1  joerg 	  *p = '\0';
   6640  1.1  joerg 
   6641  1.1  joerg 	  new_argv[i] = quoted_string;
   6642  1.1  joerg 	}
   6643  1.1  joerg       else
   6644  1.1  joerg 	new_argv[i] = (char *) string;
   6645  1.1  joerg     }
   6646  1.1  joerg   new_argv[argc] = NULL;
   6647  1.1  joerg 
   6648  1.1  joerg   return new_argv;
   6649  1.1  joerg }
   6650  1.1  joerg EOF
   6651  1.1  joerg 		;;
   6652  1.1  joerg 	    esac
   6653  1.1  joerg 
   6654  1.1  joerg             cat <<"EOF"
   6655  1.1  joerg void lt_dump_script (FILE* f)
   6656  1.1  joerg {
   6657  1.1  joerg EOF
   6658  1.1  joerg 	    func_emit_wrapper yes |
   6659  1.1  joerg 	      $SED -n -e '
   6660  1.1  joerg s/^\(.\{79\}\)\(..*\)/\1\
   6661  1.1  joerg \2/
   6662  1.1  joerg h
   6663  1.1  joerg s/\([\\"]\)/\\\1/g
   6664  1.1  joerg s/$/\\n/
   6665  1.1  joerg s/\([^\n]*\).*/  fputs ("\1", f);/p
   6666  1.1  joerg g
   6667  1.1  joerg D'
   6668  1.1  joerg             cat <<"EOF"
   6669  1.1  joerg }
   6670  1.1  joerg EOF
   6671  1.1  joerg }
   6672  1.1  joerg # end: func_emit_cwrapperexe_src
   6673  1.1  joerg 
   6674  1.1  joerg # func_win32_import_lib_p ARG
   6675  1.1  joerg # True if ARG is an import lib, as indicated by $file_magic_cmd
   6676  1.1  joerg func_win32_import_lib_p ()
   6677  1.1  joerg {
   6678  1.1  joerg     $debug_cmd
   6679  1.1  joerg 
   6680  1.1  joerg     case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
   6681  1.1  joerg     *import*) : ;;
   6682  1.1  joerg     *) false ;;
   6683  1.1  joerg     esac
   6684  1.1  joerg }
   6685  1.1  joerg 
   6686  1.1  joerg # func_suncc_cstd_abi
   6687  1.1  joerg # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
   6688  1.1  joerg # Several compiler flags select an ABI that is incompatible with the
   6689  1.1  joerg # Cstd library. Avoid specifying it if any are in CXXFLAGS.
   6690  1.1  joerg func_suncc_cstd_abi ()
   6691  1.1  joerg {
   6692  1.1  joerg     $debug_cmd
   6693  1.1  joerg 
   6694  1.1  joerg     case " $compile_command " in
   6695  1.1  joerg     *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
   6696  1.1  joerg       suncc_use_cstd_abi=no
   6697  1.1  joerg       ;;
   6698  1.1  joerg     *)
   6699  1.1  joerg       suncc_use_cstd_abi=yes
   6700  1.1  joerg       ;;
   6701  1.1  joerg     esac
   6702  1.1  joerg }
   6703  1.1  joerg 
   6704  1.1  joerg # func_mode_link arg...
   6705  1.1  joerg func_mode_link ()
   6706  1.1  joerg {
   6707  1.1  joerg     $debug_cmd
   6708  1.1  joerg 
   6709  1.1  joerg     case $host in
   6710  1.1  joerg     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
   6711  1.1  joerg       # It is impossible to link a dll without this setting, and
   6712  1.1  joerg       # we shouldn't force the makefile maintainer to figure out
   6713  1.1  joerg       # what system we are compiling for in order to pass an extra
   6714  1.1  joerg       # flag for every libtool invocation.
   6715  1.1  joerg       # allow_undefined=no
   6716  1.1  joerg 
   6717  1.1  joerg       # FIXME: Unfortunately, there are problems with the above when trying
   6718  1.1  joerg       # to make a dll that has undefined symbols, in which case not
   6719  1.1  joerg       # even a static library is built.  For now, we need to specify
   6720  1.1  joerg       # -no-undefined on the libtool link line when we can be certain
   6721  1.1  joerg       # that all symbols are satisfied, otherwise we get a static library.
   6722  1.1  joerg       allow_undefined=yes
   6723  1.1  joerg       ;;
   6724  1.1  joerg     *)
   6725  1.1  joerg       allow_undefined=yes
   6726  1.1  joerg       ;;
   6727  1.1  joerg     esac
   6728  1.1  joerg     libtool_args=$nonopt
   6729  1.1  joerg     base_compile="$nonopt $@"
   6730  1.1  joerg     compile_command=$nonopt
   6731  1.1  joerg     finalize_command=$nonopt
   6732  1.1  joerg 
   6733  1.1  joerg     compile_rpath=
   6734  1.1  joerg     finalize_rpath=
   6735  1.1  joerg     compile_shlibpath=
   6736  1.1  joerg     finalize_shlibpath=
   6737  1.1  joerg     convenience=
   6738  1.1  joerg     old_convenience=
   6739  1.1  joerg     deplibs=
   6740  1.1  joerg     old_deplibs=
   6741  1.1  joerg     compiler_flags=
   6742  1.1  joerg     linker_flags=
   6743  1.1  joerg     dllsearchpath=
   6744  1.1  joerg     lib_search_path=`pwd`
   6745  1.1  joerg     inst_prefix_dir=
   6746  1.1  joerg     new_inherited_linker_flags=
   6747  1.1  joerg 
   6748  1.1  joerg     avoid_version=no
   6749  1.1  joerg     bindir=
   6750  1.1  joerg     dlfiles=
   6751  1.1  joerg     dlprefiles=
   6752  1.1  joerg     dlself=no
   6753  1.1  joerg     export_dynamic=no
   6754  1.1  joerg     export_symbols=
   6755  1.1  joerg     export_symbols_regex=
   6756  1.1  joerg     generated=
   6757  1.1  joerg     libobjs=
   6758  1.1  joerg     ltlibs=
   6759  1.1  joerg     module=no
   6760  1.1  joerg     no_install=no
   6761  1.1  joerg     objs=
   6762  1.1  joerg     os2dllname=
   6763  1.1  joerg     non_pic_objects=
   6764  1.1  joerg     precious_files_regex=
   6765  1.1  joerg     prefer_static_libs=no
   6766  1.1  joerg     preload=false
   6767  1.1  joerg     prev=
   6768  1.1  joerg     prevarg=
   6769  1.1  joerg     release=
   6770  1.1  joerg     rpath=
   6771  1.1  joerg     xrpath=
   6772  1.1  joerg     perm_rpath=
   6773  1.1  joerg     temp_rpath=
   6774  1.1  joerg     thread_safe=no
   6775  1.1  joerg     vinfo=
   6776  1.1  joerg     vinfo_number=no
   6777  1.1  joerg     weak_libs=
   6778  1.1  joerg     single_module=$wl-single_module
   6779  1.1  joerg     func_infer_tag $base_compile
   6780  1.1  joerg 
   6781  1.1  joerg     # We need to know -static, to get the right output filenames.
   6782  1.1  joerg     for arg
   6783  1.1  joerg     do
   6784  1.1  joerg       case $arg in
   6785  1.1  joerg       -shared)
   6786  1.1  joerg 	test yes != "$build_libtool_libs" \
   6787  1.1  joerg 	  && func_fatal_configuration "cannot build a shared library"
   6788  1.1  joerg 	build_old_libs=no
   6789  1.1  joerg 	break
   6790  1.1  joerg 	;;
   6791  1.1  joerg       -all-static | -static | -static-libtool-libs)
   6792  1.1  joerg 	case $arg in
   6793  1.1  joerg 	-all-static)
   6794  1.1  joerg 	  if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
   6795  1.1  joerg 	    func_warning "complete static linking is impossible in this configuration"
   6796  1.1  joerg 	  fi
   6797  1.1  joerg 	  if test -n "$link_static_flag"; then
   6798  1.1  joerg 	    dlopen_self=$dlopen_self_static
   6799  1.1  joerg 	  fi
   6800  1.1  joerg 	  prefer_static_libs=yes
   6801  1.1  joerg 	  ;;
   6802  1.1  joerg 	-static)
   6803  1.1  joerg 	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
   6804  1.1  joerg 	    dlopen_self=$dlopen_self_static
   6805  1.1  joerg 	  fi
   6806  1.1  joerg 	  prefer_static_libs=built
   6807  1.1  joerg 	  ;;
   6808  1.1  joerg 	-static-libtool-libs)
   6809  1.1  joerg 	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
   6810  1.1  joerg 	    dlopen_self=$dlopen_self_static
   6811  1.1  joerg 	  fi
   6812  1.1  joerg 	  prefer_static_libs=yes
   6813  1.1  joerg 	  ;;
   6814  1.1  joerg 	esac
   6815  1.1  joerg 	build_libtool_libs=no
   6816  1.1  joerg 	build_old_libs=yes
   6817  1.1  joerg 	break
   6818  1.1  joerg 	;;
   6819  1.1  joerg       esac
   6820  1.1  joerg     done
   6821  1.1  joerg 
   6822  1.1  joerg     # See if our shared archives depend on static archives.
   6823  1.1  joerg     test -n "$old_archive_from_new_cmds" && build_old_libs=yes
   6824  1.1  joerg 
   6825  1.1  joerg     # Go through the arguments, transforming them on the way.
   6826  1.1  joerg     while test "$#" -gt 0; do
   6827  1.1  joerg       arg=$1
   6828  1.1  joerg       shift
   6829  1.1  joerg       func_quote_arg pretty,unquoted "$arg"
   6830  1.1  joerg       qarg=$func_quote_arg_unquoted_result
   6831  1.1  joerg       func_append libtool_args " $func_quote_arg_result"
   6832  1.1  joerg 
   6833  1.1  joerg       # If the previous option needs an argument, assign it.
   6834  1.1  joerg       if test -n "$prev"; then
   6835  1.1  joerg 	case $prev in
   6836  1.1  joerg 	output)
   6837  1.1  joerg 	  func_append compile_command " @OUTPUT@"
   6838  1.1  joerg 	  func_append finalize_command " @OUTPUT@"
   6839  1.1  joerg 	  ;;
   6840  1.1  joerg 	esac
   6841  1.1  joerg 
   6842  1.1  joerg 	case $prev in
   6843  1.1  joerg 	bindir)
   6844  1.1  joerg 	  bindir=$arg
   6845  1.1  joerg 	  prev=
   6846  1.1  joerg 	  continue
   6847  1.1  joerg 	  ;;
   6848  1.1  joerg 	dlfiles|dlprefiles)
   6849  1.1  joerg 	  $preload || {
   6850  1.1  joerg 	    # Add the symbol object into the linking commands.
   6851  1.1  joerg 	    func_append compile_command " @SYMFILE@"
   6852  1.1  joerg 	    func_append finalize_command " @SYMFILE@"
   6853  1.1  joerg 	    preload=:
   6854  1.1  joerg 	  }
   6855  1.1  joerg 	  case $arg in
   6856  1.1  joerg 	  *.la | *.lo) ;;  # We handle these cases below.
   6857  1.1  joerg 	  force)
   6858  1.1  joerg 	    if test no = "$dlself"; then
   6859  1.1  joerg 	      dlself=needless
   6860  1.1  joerg 	      export_dynamic=yes
   6861  1.1  joerg 	    fi
   6862  1.1  joerg 	    prev=
   6863  1.1  joerg 	    continue
   6864  1.1  joerg 	    ;;
   6865  1.1  joerg 	  self)
   6866  1.1  joerg 	    if test dlprefiles = "$prev"; then
   6867  1.1  joerg 	      dlself=yes
   6868  1.1  joerg 	    elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
   6869  1.1  joerg 	      dlself=yes
   6870  1.1  joerg 	    else
   6871  1.1  joerg 	      dlself=needless
   6872  1.1  joerg 	      export_dynamic=yes
   6873  1.1  joerg 	    fi
   6874  1.1  joerg 	    prev=
   6875  1.1  joerg 	    continue
   6876  1.1  joerg 	    ;;
   6877  1.1  joerg 	  *)
   6878  1.1  joerg 	    if test dlfiles = "$prev"; then
   6879  1.1  joerg 	      func_append dlfiles " $arg"
   6880  1.1  joerg 	    else
   6881  1.1  joerg 	      func_append dlprefiles " $arg"
   6882  1.1  joerg 	    fi
   6883  1.1  joerg 	    prev=
   6884  1.1  joerg 	    continue
   6885  1.1  joerg 	    ;;
   6886  1.1  joerg 	  esac
   6887  1.1  joerg 	  ;;
   6888  1.1  joerg 	expsyms)
   6889  1.1  joerg 	  export_symbols=$arg
   6890  1.1  joerg 	  test -f "$arg" \
   6891  1.1  joerg 	    || func_fatal_error "symbol file '$arg' does not exist"
   6892  1.1  joerg 	  prev=
   6893  1.1  joerg 	  continue
   6894  1.1  joerg 	  ;;
   6895  1.1  joerg 	expsyms_regex)
   6896  1.1  joerg 	  export_symbols_regex=$arg
   6897  1.1  joerg 	  prev=
   6898  1.1  joerg 	  continue
   6899  1.1  joerg 	  ;;
   6900  1.1  joerg 	framework)
   6901  1.1  joerg 	  case $host in
   6902  1.1  joerg 	    *-*-darwin*)
   6903  1.1  joerg 	      case "$deplibs " in
   6904  1.1  joerg 		*" $qarg.ltframework "*) ;;
   6905  1.1  joerg 		*) func_append deplibs " $qarg.ltframework" # this is fixed later
   6906  1.1  joerg 		   ;;
   6907  1.1  joerg 	      esac
   6908  1.1  joerg 	      ;;
   6909  1.1  joerg 	  esac
   6910  1.1  joerg 	  prev=
   6911  1.1  joerg 	  continue
   6912  1.1  joerg 	  ;;
   6913  1.1  joerg 	inst_prefix)
   6914  1.1  joerg 	  inst_prefix_dir=$arg
   6915  1.1  joerg 	  prev=
   6916  1.1  joerg 	  continue
   6917  1.1  joerg 	  ;;
   6918  1.1  joerg 	mllvm)
   6919  1.1  joerg 	  # Clang does not use LLVM to link, so we can simply discard any
   6920  1.1  joerg 	  # '-mllvm $arg' options when doing the link step.
   6921  1.1  joerg 	  prev=
   6922  1.1  joerg 	  continue
   6923  1.1  joerg 	  ;;
   6924  1.1  joerg 	objectlist)
   6925  1.1  joerg 	  if test -f "$arg"; then
   6926  1.1  joerg 	    save_arg=$arg
   6927  1.1  joerg 	    moreargs=
   6928  1.1  joerg 	    for fil in `cat "$save_arg"`
   6929  1.1  joerg 	    do
   6930  1.1  joerg #	      func_append moreargs " $fil"
   6931  1.1  joerg 	      arg=$fil
   6932  1.1  joerg 	      # A libtool-controlled object.
   6933  1.1  joerg 
   6934  1.1  joerg 	      # Check to see that this really is a libtool object.
   6935  1.1  joerg 	      if func_lalib_unsafe_p "$arg"; then
   6936  1.1  joerg 		pic_object=
   6937  1.1  joerg 		non_pic_object=
   6938  1.1  joerg 
   6939  1.1  joerg 		# Read the .lo file
   6940  1.1  joerg 		func_source "$arg"
   6941  1.1  joerg 
   6942  1.1  joerg 		if test -z "$pic_object" ||
   6943  1.1  joerg 		   test -z "$non_pic_object" ||
   6944  1.1  joerg 		   test none = "$pic_object" &&
   6945  1.1  joerg 		   test none = "$non_pic_object"; then
   6946  1.1  joerg 		  func_fatal_error "cannot find name of object for '$arg'"
   6947  1.1  joerg 		fi
   6948  1.1  joerg 
   6949  1.1  joerg 		# Extract subdirectory from the argument.
   6950  1.1  joerg 		func_dirname "$arg" "/" ""
   6951  1.1  joerg 		xdir=$func_dirname_result
   6952  1.1  joerg 
   6953  1.1  joerg 		if test none != "$pic_object"; then
   6954  1.1  joerg 		  # Prepend the subdirectory the object is found in.
   6955  1.1  joerg 		  pic_object=$xdir$pic_object
   6956  1.1  joerg 
   6957  1.1  joerg 		  if test dlfiles = "$prev"; then
   6958  1.1  joerg 		    if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
   6959  1.1  joerg 		      func_append dlfiles " $pic_object"
   6960  1.1  joerg 		      prev=
   6961  1.1  joerg 		      continue
   6962  1.1  joerg 		    else
   6963  1.1  joerg 		      # If libtool objects are unsupported, then we need to preload.
   6964  1.1  joerg 		      prev=dlprefiles
   6965  1.1  joerg 		    fi
   6966  1.1  joerg 		  fi
   6967  1.1  joerg 
   6968  1.1  joerg 		  # CHECK ME:  I think I busted this.  -Ossama
   6969  1.1  joerg 		  if test dlprefiles = "$prev"; then
   6970  1.1  joerg 		    # Preload the old-style object.
   6971  1.1  joerg 		    func_append dlprefiles " $pic_object"
   6972  1.1  joerg 		    prev=
   6973  1.1  joerg 		  fi
   6974  1.1  joerg 
   6975  1.1  joerg 		  # A PIC object.
   6976  1.1  joerg 		  func_append libobjs " $pic_object"
   6977  1.1  joerg 		  arg=$pic_object
   6978  1.1  joerg 		fi
   6979  1.1  joerg 
   6980  1.1  joerg 		# Non-PIC object.
   6981  1.1  joerg 		if test none != "$non_pic_object"; then
   6982  1.1  joerg 		  # Prepend the subdirectory the object is found in.
   6983  1.1  joerg 		  non_pic_object=$xdir$non_pic_object
   6984  1.1  joerg 
   6985  1.1  joerg 		  # A standard non-PIC object
   6986  1.1  joerg 		  func_append non_pic_objects " $non_pic_object"
   6987  1.1  joerg 		  if test -z "$pic_object" || test none = "$pic_object"; then
   6988  1.1  joerg 		    arg=$non_pic_object
   6989  1.1  joerg 		  fi
   6990  1.1  joerg 		else
   6991  1.1  joerg 		  # If the PIC object exists, use it instead.
   6992  1.1  joerg 		  # $xdir was prepended to $pic_object above.
   6993  1.1  joerg 		  non_pic_object=$pic_object
   6994  1.1  joerg 		  func_append non_pic_objects " $non_pic_object"
   6995  1.1  joerg 		fi
   6996  1.1  joerg 	      else
   6997  1.1  joerg 		# Only an error if not doing a dry-run.
   6998  1.1  joerg 		if $opt_dry_run; then
   6999  1.1  joerg 		  # Extract subdirectory from the argument.
   7000  1.1  joerg 		  func_dirname "$arg" "/" ""
   7001  1.1  joerg 		  xdir=$func_dirname_result
   7002  1.1  joerg 
   7003  1.1  joerg 		  func_lo2o "$arg"
   7004  1.1  joerg 		  pic_object=$xdir$objdir/$func_lo2o_result
   7005  1.1  joerg 		  non_pic_object=$xdir$func_lo2o_result
   7006  1.1  joerg 		  func_append libobjs " $pic_object"
   7007  1.1  joerg 		  func_append non_pic_objects " $non_pic_object"
   7008  1.1  joerg 	        else
   7009  1.1  joerg 		  func_fatal_error "'$arg' is not a valid libtool object"
   7010  1.1  joerg 		fi
   7011  1.1  joerg 	      fi
   7012  1.1  joerg 	    done
   7013  1.1  joerg 	  else
   7014  1.1  joerg 	    func_fatal_error "link input file '$arg' does not exist"
   7015  1.1  joerg 	  fi
   7016  1.1  joerg 	  arg=$save_arg
   7017  1.1  joerg 	  prev=
   7018  1.1  joerg 	  continue
   7019  1.1  joerg 	  ;;
   7020  1.1  joerg 	os2dllname)
   7021  1.1  joerg 	  os2dllname=$arg
   7022  1.1  joerg 	  prev=
   7023  1.1  joerg 	  continue
   7024  1.1  joerg 	  ;;
   7025  1.1  joerg 	precious_regex)
   7026  1.1  joerg 	  precious_files_regex=$arg
   7027  1.1  joerg 	  prev=
   7028  1.1  joerg 	  continue
   7029  1.1  joerg 	  ;;
   7030  1.1  joerg 	release)
   7031  1.1  joerg 	  release=-$arg
   7032  1.1  joerg 	  prev=
   7033  1.1  joerg 	  continue
   7034  1.1  joerg 	  ;;
   7035  1.1  joerg 	rpath | xrpath)
   7036  1.1  joerg 	  # We need an absolute path.
   7037  1.1  joerg 	  case $arg in
   7038  1.1  joerg 	  [\\/]* | [A-Za-z]:[\\/]*) ;;
   7039  1.1  joerg 	  *)
   7040  1.1  joerg 	    func_fatal_error "only absolute run-paths are allowed"
   7041  1.1  joerg 	    ;;
   7042  1.1  joerg 	  esac
   7043  1.1  joerg 	  if test rpath = "$prev"; then
   7044  1.1  joerg 	    case "$rpath " in
   7045  1.1  joerg 	    *" $arg "*) ;;
   7046  1.1  joerg 	    *) func_append rpath " $arg" ;;
   7047  1.1  joerg 	    esac
   7048  1.1  joerg 	  else
   7049  1.1  joerg 	    case "$xrpath " in
   7050  1.1  joerg 	    *" $arg "*) ;;
   7051  1.1  joerg 	    *) func_append xrpath " $arg" ;;
   7052  1.1  joerg 	    esac
   7053  1.1  joerg 	  fi
   7054  1.1  joerg 	  prev=
   7055  1.1  joerg 	  continue
   7056  1.1  joerg 	  ;;
   7057  1.1  joerg 	shrext)
   7058  1.1  joerg 	  shrext_cmds=$arg
   7059  1.1  joerg 	  prev=
   7060  1.1  joerg 	  continue
   7061  1.1  joerg 	  ;;
   7062  1.1  joerg 	weak)
   7063  1.1  joerg 	  func_append weak_libs " $arg"
   7064  1.1  joerg 	  prev=
   7065  1.1  joerg 	  continue
   7066  1.1  joerg 	  ;;
   7067  1.1  joerg 	xcclinker)
   7068  1.1  joerg 	  func_append linker_flags " $qarg"
   7069  1.1  joerg 	  func_append compiler_flags " $qarg"
   7070  1.1  joerg 	  prev=
   7071  1.1  joerg 	  func_append compile_command " $qarg"
   7072  1.1  joerg 	  func_append finalize_command " $qarg"
   7073  1.1  joerg 	  continue
   7074  1.1  joerg 	  ;;
   7075  1.1  joerg 	xcompiler)
   7076  1.1  joerg 	  func_append compiler_flags " $qarg"
   7077  1.1  joerg 	  prev=
   7078  1.1  joerg 	  func_append compile_command " $qarg"
   7079  1.1  joerg 	  func_append finalize_command " $qarg"
   7080  1.1  joerg 	  continue
   7081  1.1  joerg 	  ;;
   7082  1.1  joerg 	xlinker)
   7083  1.1  joerg 	  func_append linker_flags " $qarg"
   7084  1.1  joerg 	  func_append compiler_flags " $wl$qarg"
   7085  1.1  joerg 	  prev=
   7086  1.1  joerg 	  func_append compile_command " $wl$qarg"
   7087  1.1  joerg 	  func_append finalize_command " $wl$qarg"
   7088  1.1  joerg 	  continue
   7089  1.1  joerg 	  ;;
   7090  1.1  joerg 	*)
   7091  1.1  joerg 	  eval "$prev=\"\$arg\""
   7092  1.1  joerg 	  prev=
   7093  1.1  joerg 	  continue
   7094  1.1  joerg 	  ;;
   7095  1.1  joerg 	esac
   7096  1.1  joerg       fi # test -n "$prev"
   7097  1.1  joerg 
   7098  1.1  joerg       prevarg=$arg
   7099  1.1  joerg 
   7100  1.1  joerg       case $arg in
   7101  1.1  joerg       -all-static)
   7102  1.1  joerg 	if test -n "$link_static_flag"; then
   7103  1.1  joerg 	  # See comment for -static flag below, for more details.
   7104  1.1  joerg 	  func_append compile_command " $link_static_flag"
   7105  1.1  joerg 	  func_append finalize_command " $link_static_flag"
   7106  1.1  joerg 	fi
   7107  1.1  joerg 	continue
   7108  1.1  joerg 	;;
   7109  1.1  joerg 
   7110  1.1  joerg       -allow-undefined)
   7111  1.1  joerg 	# FIXME: remove this flag sometime in the future.
   7112  1.1  joerg 	func_fatal_error "'-allow-undefined' must not be used because it is the default"
   7113  1.1  joerg 	;;
   7114  1.1  joerg 
   7115  1.1  joerg       -avoid-version)
   7116  1.1  joerg 	avoid_version=yes
   7117  1.1  joerg 	continue
   7118  1.1  joerg 	;;
   7119  1.1  joerg 
   7120  1.1  joerg       -bindir)
   7121  1.1  joerg 	prev=bindir
   7122  1.1  joerg 	continue
   7123  1.1  joerg 	;;
   7124  1.1  joerg 
   7125  1.1  joerg       -dlopen)
   7126  1.1  joerg 	prev=dlfiles
   7127  1.1  joerg 	continue
   7128  1.1  joerg 	;;
   7129  1.1  joerg 
   7130  1.1  joerg       -dlpreopen)
   7131  1.1  joerg 	prev=dlprefiles
   7132  1.1  joerg 	continue
   7133  1.1  joerg 	;;
   7134  1.1  joerg 
   7135  1.1  joerg       -export-dynamic)
   7136  1.1  joerg 	export_dynamic=yes
   7137  1.1  joerg 	continue
   7138  1.1  joerg 	;;
   7139  1.1  joerg 
   7140  1.1  joerg       -export-symbols | -export-symbols-regex)
   7141  1.1  joerg 	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
   7142  1.1  joerg 	  func_fatal_error "more than one -exported-symbols argument is not allowed"
   7143  1.1  joerg 	fi
   7144  1.1  joerg 	if test X-export-symbols = "X$arg"; then
   7145  1.1  joerg 	  prev=expsyms
   7146  1.1  joerg 	else
   7147  1.1  joerg 	  prev=expsyms_regex
   7148  1.1  joerg 	fi
   7149  1.1  joerg 	continue
   7150  1.1  joerg 	;;
   7151  1.1  joerg 
   7152  1.1  joerg       -framework)
   7153  1.1  joerg 	prev=framework
   7154  1.1  joerg 	continue
   7155  1.1  joerg 	;;
   7156  1.1  joerg 
   7157  1.1  joerg       -inst-prefix-dir)
   7158  1.1  joerg 	prev=inst_prefix
   7159  1.1  joerg 	continue
   7160  1.1  joerg 	;;
   7161  1.1  joerg 
   7162  1.1  joerg       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
   7163  1.1  joerg       # so, if we see these flags be careful not to treat them like -L
   7164  1.1  joerg       -L[A-Z][A-Z]*:*)
   7165  1.1  joerg 	case $with_gcc/$host in
   7166  1.1  joerg 	no/*-*-irix* | /*-*-irix*)
   7167  1.1  joerg 	  func_append compile_command " $arg"
   7168  1.1  joerg 	  func_append finalize_command " $arg"
   7169  1.1  joerg 	  ;;
   7170  1.1  joerg 	esac
   7171  1.1  joerg 	continue
   7172  1.1  joerg 	;;
   7173  1.1  joerg 
   7174  1.1  joerg       -L*)
   7175  1.1  joerg 	func_stripname "-L" '' "$arg"
   7176  1.1  joerg 	if test -z "$func_stripname_result"; then
   7177  1.1  joerg 	  if test "$#" -gt 0; then
   7178  1.1  joerg 	    func_fatal_error "require no space between '-L' and '$1'"
   7179  1.1  joerg 	  else
   7180  1.1  joerg 	    func_fatal_error "need path for '-L' option"
   7181  1.1  joerg 	  fi
   7182  1.1  joerg 	fi
   7183  1.1  joerg 	func_resolve_sysroot "$func_stripname_result"
   7184  1.1  joerg 	dir=$func_resolve_sysroot_result
   7185  1.1  joerg 	# We need an absolute path.
   7186  1.1  joerg 	case $dir in
   7187  1.1  joerg 	[\\/]* | [A-Za-z]:[\\/]*) ;;
   7188  1.1  joerg 	*)
   7189  1.1  joerg 	  absdir=`cd "$dir" && pwd`
   7190  1.1  joerg 	  test -z "$absdir" && \
   7191  1.1  joerg 	    func_fatal_error "cannot determine absolute directory name of '$dir'"
   7192  1.1  joerg 	  dir=$absdir
   7193  1.1  joerg 	  ;;
   7194  1.1  joerg 	esac
   7195  1.1  joerg 	case "$deplibs " in
   7196  1.1  joerg 	*" -L$dir "* | *" $arg "*)
   7197  1.1  joerg 	  # Will only happen for absolute or sysroot arguments
   7198  1.1  joerg 	  ;;
   7199  1.1  joerg 	*)
   7200  1.1  joerg 	  # Preserve sysroot, but never include relative directories
   7201  1.1  joerg 	  case $dir in
   7202  1.1  joerg 	    [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
   7203  1.1  joerg 	    *) func_append deplibs " -L$dir" ;;
   7204  1.1  joerg 	  esac
   7205  1.1  joerg 	  func_append lib_search_path " $dir"
   7206  1.1  joerg 	  ;;
   7207  1.1  joerg 	esac
   7208  1.1  joerg 	case $host in
   7209  1.1  joerg 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
   7210  1.1  joerg 	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
   7211  1.1  joerg 	  case :$dllsearchpath: in
   7212  1.1  joerg 	  *":$dir:"*) ;;
   7213  1.1  joerg 	  ::) dllsearchpath=$dir;;
   7214  1.1  joerg 	  *) func_append dllsearchpath ":$dir";;
   7215  1.1  joerg 	  esac
   7216  1.1  joerg 	  case :$dllsearchpath: in
   7217  1.1  joerg 	  *":$testbindir:"*) ;;
   7218  1.1  joerg 	  ::) dllsearchpath=$testbindir;;
   7219  1.1  joerg 	  *) func_append dllsearchpath ":$testbindir";;
   7220  1.1  joerg 	  esac
   7221  1.1  joerg 	  ;;
   7222  1.1  joerg 	esac
   7223  1.1  joerg 	continue
   7224  1.1  joerg 	;;
   7225  1.1  joerg 
   7226  1.1  joerg       -l*)
   7227  1.1  joerg 	if test X-lc = "X$arg" || test X-lm = "X$arg"; then
   7228  1.1  joerg 	  case $host in
   7229  1.1  joerg 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
   7230  1.1  joerg 	    # These systems don't actually have a C or math library (as such)
   7231  1.1  joerg 	    continue
   7232  1.1  joerg 	    ;;
   7233  1.1  joerg 	  *-*-os2*)
   7234  1.1  joerg 	    # These systems don't actually have a C library (as such)
   7235  1.1  joerg 	    test X-lc = "X$arg" && continue
   7236  1.1  joerg 	    ;;
   7237  1.1  joerg 	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
   7238  1.1  joerg 	    # Do not include libc due to us having libc/libc_r.
   7239  1.1  joerg 	    test X-lc = "X$arg" && continue
   7240  1.1  joerg 	    ;;
   7241  1.1  joerg 	  *-*-rhapsody* | *-*-darwin1.[012])
   7242  1.1  joerg 	    # Rhapsody C and math libraries are in the System framework
   7243  1.1  joerg 	    func_append deplibs " System.ltframework"
   7244  1.1  joerg 	    continue
   7245  1.1  joerg 	    ;;
   7246  1.1  joerg 	  *-*-sco3.2v5* | *-*-sco5v6*)
   7247  1.1  joerg 	    # Causes problems with __ctype
   7248  1.1  joerg 	    test X-lc = "X$arg" && continue
   7249  1.1  joerg 	    ;;
   7250  1.1  joerg 	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
   7251  1.1  joerg 	    # Compiler inserts libc in the correct place for threads to work
   7252  1.1  joerg 	    test X-lc = "X$arg" && continue
   7253  1.1  joerg 	    ;;
   7254  1.1  joerg 	  esac
   7255  1.1  joerg 	elif test X-lc_r = "X$arg"; then
   7256  1.1  joerg 	 case $host in
   7257  1.1  joerg 	 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
   7258  1.1  joerg 	   # Do not include libc_r directly, use -pthread flag.
   7259  1.1  joerg 	   continue
   7260  1.1  joerg 	   ;;
   7261  1.1  joerg 	 esac
   7262  1.1  joerg 	fi
   7263  1.1  joerg 	func_append deplibs " $arg"
   7264  1.1  joerg 	continue
   7265  1.1  joerg 	;;
   7266  1.1  joerg 
   7267  1.1  joerg       -mllvm)
   7268  1.1  joerg 	prev=mllvm
   7269  1.1  joerg 	continue
   7270  1.1  joerg 	;;
   7271  1.1  joerg 
   7272  1.1  joerg       -module)
   7273  1.1  joerg 	module=yes
   7274  1.1  joerg 	continue
   7275  1.1  joerg 	;;
   7276  1.1  joerg 
   7277  1.1  joerg       # Tru64 UNIX uses -model [arg] to determine the layout of C++
   7278  1.1  joerg       # classes, name mangling, and exception handling.
   7279  1.1  joerg       # Darwin uses the -arch flag to determine output architecture.
   7280  1.1  joerg       -model|-arch|-isysroot|--sysroot)
   7281  1.1  joerg 	func_append compiler_flags " $arg"
   7282  1.1  joerg 	func_append compile_command " $arg"
   7283  1.1  joerg 	func_append finalize_command " $arg"
   7284  1.1  joerg 	prev=xcompiler
   7285  1.1  joerg 	continue
   7286  1.1  joerg 	;;
   7287  1.1  joerg 
   7288  1.1  joerg       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
   7289  1.1  joerg       |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
   7290  1.1  joerg 	func_append compiler_flags " $arg"
   7291  1.1  joerg 	func_append compile_command " $arg"
   7292  1.1  joerg 	func_append finalize_command " $arg"
   7293  1.1  joerg 	case "$new_inherited_linker_flags " in
   7294  1.1  joerg 	    *" $arg "*) ;;
   7295  1.1  joerg 	    * ) func_append new_inherited_linker_flags " $arg" ;;
   7296  1.1  joerg 	esac
   7297  1.1  joerg 	continue
   7298  1.1  joerg 	;;
   7299  1.1  joerg 
   7300  1.1  joerg       -multi_module)
   7301  1.1  joerg 	single_module=$wl-multi_module
   7302  1.1  joerg 	continue
   7303  1.1  joerg 	;;
   7304  1.1  joerg 
   7305  1.1  joerg       -no-fast-install)
   7306  1.1  joerg 	fast_install=no
   7307  1.1  joerg 	continue
   7308  1.1  joerg 	;;
   7309  1.1  joerg 
   7310  1.1  joerg       -no-install)
   7311  1.1  joerg 	case $host in
   7312  1.1  joerg 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
   7313  1.1  joerg 	  # The PATH hackery in wrapper scripts is required on Windows
   7314  1.1  joerg 	  # and Darwin in order for the loader to find any dlls it needs.
   7315  1.1  joerg 	  func_warning "'-no-install' is ignored for $host"
   7316  1.1  joerg 	  func_warning "assuming '-no-fast-install' instead"
   7317  1.1  joerg 	  fast_install=no
   7318  1.1  joerg 	  ;;
   7319  1.1  joerg 	*) no_install=yes ;;
   7320  1.1  joerg 	esac
   7321  1.1  joerg 	continue
   7322  1.1  joerg 	;;
   7323  1.1  joerg 
   7324  1.1  joerg       -no-undefined)
   7325  1.1  joerg 	allow_undefined=no
   7326  1.1  joerg 	continue
   7327  1.1  joerg 	;;
   7328  1.1  joerg 
   7329  1.1  joerg       -objectlist)
   7330  1.1  joerg 	prev=objectlist
   7331  1.1  joerg 	continue
   7332  1.1  joerg 	;;
   7333  1.1  joerg 
   7334  1.1  joerg       -os2dllname)
   7335  1.1  joerg 	prev=os2dllname
   7336  1.1  joerg 	continue
   7337  1.1  joerg 	;;
   7338  1.1  joerg 
   7339  1.1  joerg       -o) prev=output ;;
   7340  1.1  joerg 
   7341  1.1  joerg       -precious-files-regex)
   7342  1.1  joerg 	prev=precious_regex
   7343  1.1  joerg 	continue
   7344  1.1  joerg 	;;
   7345  1.1  joerg 
   7346  1.1  joerg       -release)
   7347  1.1  joerg 	prev=release
   7348  1.1  joerg 	continue
   7349  1.1  joerg 	;;
   7350  1.1  joerg 
   7351  1.1  joerg       -rpath)
   7352  1.1  joerg 	prev=rpath
   7353  1.1  joerg 	continue
   7354  1.1  joerg 	;;
   7355  1.1  joerg 
   7356  1.1  joerg       -R)
   7357  1.1  joerg 	prev=xrpath
   7358  1.1  joerg 	continue
   7359  1.1  joerg 	;;
   7360  1.1  joerg 
   7361  1.1  joerg       -R*)
   7362  1.1  joerg 	func_stripname '-R' '' "$arg"
   7363  1.1  joerg 	dir=$func_stripname_result
   7364  1.1  joerg 	# We need an absolute path.
   7365  1.1  joerg 	case $dir in
   7366  1.1  joerg 	[\\/]* | [A-Za-z]:[\\/]*) ;;
   7367  1.1  joerg 	=*)
   7368  1.1  joerg 	  func_stripname '=' '' "$dir"
   7369  1.1  joerg 	  dir=$lt_sysroot$func_stripname_result
   7370  1.1  joerg 	  ;;
   7371  1.1  joerg 	*)
   7372  1.1  joerg 	  func_fatal_error "only absolute run-paths are allowed"
   7373  1.1  joerg 	  ;;
   7374  1.1  joerg 	esac
   7375  1.1  joerg 	case "$xrpath " in
   7376  1.1  joerg 	*" $dir "*) ;;
   7377  1.1  joerg 	*) func_append xrpath " $dir" ;;
   7378  1.1  joerg 	esac
   7379  1.1  joerg 	continue
   7380  1.1  joerg 	;;
   7381  1.1  joerg 
   7382  1.1  joerg       -shared)
   7383  1.1  joerg 	# The effects of -shared are defined in a previous loop.
   7384  1.1  joerg 	continue
   7385  1.1  joerg 	;;
   7386  1.1  joerg 
   7387  1.1  joerg       -shrext)
   7388  1.1  joerg 	prev=shrext
   7389  1.1  joerg 	continue
   7390  1.1  joerg 	;;
   7391  1.1  joerg 
   7392  1.1  joerg       -static | -static-libtool-libs)
   7393  1.1  joerg 	# The effects of -static are defined in a previous loop.
   7394  1.1  joerg 	# We used to do the same as -all-static on platforms that
   7395  1.1  joerg 	# didn't have a PIC flag, but the assumption that the effects
   7396  1.1  joerg 	# would be equivalent was wrong.  It would break on at least
   7397  1.1  joerg 	# Digital Unix and AIX.
   7398  1.1  joerg 	continue
   7399  1.1  joerg 	;;
   7400  1.1  joerg 
   7401  1.1  joerg       -thread-safe)
   7402  1.1  joerg 	thread_safe=yes
   7403  1.1  joerg 	continue
   7404  1.1  joerg 	;;
   7405  1.1  joerg 
   7406  1.1  joerg       -version-info)
   7407  1.1  joerg 	prev=vinfo
   7408  1.1  joerg 	continue
   7409  1.1  joerg 	;;
   7410  1.1  joerg 
   7411  1.1  joerg       -version-number)
   7412  1.1  joerg 	prev=vinfo
   7413  1.1  joerg 	vinfo_number=yes
   7414  1.1  joerg 	continue
   7415  1.1  joerg 	;;
   7416  1.1  joerg 
   7417  1.1  joerg       -weak)
   7418  1.1  joerg         prev=weak
   7419  1.1  joerg 	continue
   7420  1.1  joerg 	;;
   7421  1.1  joerg 
   7422  1.1  joerg       -Wc,*)
   7423  1.1  joerg 	func_stripname '-Wc,' '' "$arg"
   7424  1.1  joerg 	args=$func_stripname_result
   7425  1.1  joerg 	arg=
   7426  1.1  joerg 	save_ifs=$IFS; IFS=,
   7427  1.1  joerg 	for flag in $args; do
   7428  1.1  joerg 	  IFS=$save_ifs
   7429  1.1  joerg           func_quote_arg pretty "$flag"
   7430  1.1  joerg 	  func_append arg " $func_quote_arg_result"
   7431  1.1  joerg 	  func_append compiler_flags " $func_quote_arg_result"
   7432  1.1  joerg 	done
   7433  1.1  joerg 	IFS=$save_ifs
   7434  1.1  joerg 	func_stripname ' ' '' "$arg"
   7435  1.1  joerg 	arg=$func_stripname_result
   7436  1.1  joerg 	;;
   7437  1.1  joerg 
   7438  1.1  joerg       -Wl,*)
   7439  1.1  joerg 	func_stripname '-Wl,' '' "$arg"
   7440  1.1  joerg 	args=$func_stripname_result
   7441  1.1  joerg 	arg=
   7442  1.1  joerg 	save_ifs=$IFS; IFS=,
   7443  1.1  joerg 	for flag in $args; do
   7444  1.1  joerg 	  IFS=$save_ifs
   7445  1.1  joerg           func_quote_arg pretty "$flag"
   7446  1.1  joerg 	  func_append arg " $wl$func_quote_arg_result"
   7447  1.1  joerg 	  func_append compiler_flags " $wl$func_quote_arg_result"
   7448  1.1  joerg 	  func_append linker_flags " $func_quote_arg_result"
   7449  1.1  joerg 	done
   7450  1.1  joerg 	IFS=$save_ifs
   7451  1.1  joerg 	func_stripname ' ' '' "$arg"
   7452  1.1  joerg 	arg=$func_stripname_result
   7453  1.1  joerg 	;;
   7454  1.1  joerg 
   7455  1.1  joerg       -Xcompiler)
   7456  1.1  joerg 	prev=xcompiler
   7457  1.1  joerg 	continue
   7458  1.1  joerg 	;;
   7459  1.1  joerg 
   7460  1.1  joerg       -Xlinker)
   7461  1.1  joerg 	prev=xlinker
   7462  1.1  joerg 	continue
   7463  1.1  joerg 	;;
   7464  1.1  joerg 
   7465  1.1  joerg       -XCClinker)
   7466  1.1  joerg 	prev=xcclinker
   7467  1.1  joerg 	continue
   7468  1.1  joerg 	;;
   7469  1.1  joerg 
   7470  1.1  joerg       # -msg_* for osf cc
   7471  1.1  joerg       -msg_*)
   7472  1.1  joerg 	func_quote_arg pretty "$arg"
   7473  1.1  joerg 	arg=$func_quote_arg_result
   7474  1.1  joerg 	;;
   7475  1.1  joerg 
   7476  1.1  joerg       # Flags to be passed through unchanged, with rationale:
   7477  1.1  joerg       # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler
   7478  1.1  joerg       # -r[0-9][0-9]*        specify processor for the SGI compiler
   7479  1.1  joerg       # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
   7480  1.1  joerg       # +DA*, +DD*           enable 64-bit mode for the HP compiler
   7481  1.1  joerg       # -q*                  compiler args for the IBM compiler
   7482  1.1  joerg       # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
   7483  1.1  joerg       # -F/path              path to uninstalled frameworks, gcc on darwin
   7484  1.1  joerg       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
   7485  1.1  joerg       # -fstack-protector*   stack protector flags for GCC
   7486  1.1  joerg       # @file                GCC response files
   7487  1.1  joerg       # -tp=*                Portland pgcc target processor selection
   7488  1.1  joerg       # --sysroot=*          for sysroot support
   7489  1.1  joerg       # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
   7490  1.1  joerg       # -specs=*             GCC specs files
   7491  1.1  joerg       # -stdlib=*            select c++ std lib with clang
   7492  1.1  joerg       # -fsanitize=*         Clang/GCC memory and address sanitizer
   7493  1.1  joerg       # -fuse-ld=*           Linker select flags for GCC
   7494  1.1  joerg       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
   7495  1.1  joerg       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
   7496  1.1  joerg       -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
   7497  1.1  joerg       -specs=*|-fsanitize=*|-fuse-ld=*)
   7498  1.1  joerg         func_quote_arg pretty "$arg"
   7499  1.1  joerg 	arg=$func_quote_arg_result
   7500  1.1  joerg         func_append compile_command " $arg"
   7501  1.1  joerg         func_append finalize_command " $arg"
   7502  1.1  joerg         func_append compiler_flags " $arg"
   7503  1.1  joerg         continue
   7504  1.1  joerg         ;;
   7505  1.1  joerg 
   7506  1.1  joerg       -Z*)
   7507  1.1  joerg         if test os2 = "`expr $host : '.*\(os2\)'`"; then
   7508  1.1  joerg           # OS/2 uses -Zxxx to specify OS/2-specific options
   7509  1.1  joerg 	  compiler_flags="$compiler_flags $arg"
   7510  1.1  joerg 	  func_append compile_command " $arg"
   7511  1.1  joerg 	  func_append finalize_command " $arg"
   7512  1.1  joerg 	  case $arg in
   7513  1.1  joerg 	  -Zlinker | -Zstack)
   7514  1.1  joerg 	    prev=xcompiler
   7515  1.1  joerg 	    ;;
   7516  1.1  joerg 	  esac
   7517  1.1  joerg 	  continue
   7518  1.1  joerg         else
   7519  1.1  joerg 	  # Otherwise treat like 'Some other compiler flag' below
   7520  1.1  joerg 	  func_quote_arg pretty "$arg"
   7521  1.1  joerg 	  arg=$func_quote_arg_result
   7522  1.1  joerg         fi
   7523  1.1  joerg 	;;
   7524  1.1  joerg 
   7525  1.1  joerg       # Some other compiler flag.
   7526  1.1  joerg       -* | +*)
   7527  1.1  joerg         func_quote_arg pretty "$arg"
   7528  1.1  joerg 	arg=$func_quote_arg_result
   7529  1.1  joerg 	;;
   7530  1.1  joerg 
   7531  1.1  joerg       *.$objext)
   7532  1.1  joerg 	# A standard object.
   7533  1.1  joerg 	func_append objs " $arg"
   7534  1.1  joerg 	;;
   7535  1.1  joerg 
   7536  1.1  joerg       *.lo)
   7537  1.1  joerg 	# A libtool-controlled object.
   7538  1.1  joerg 
   7539  1.1  joerg 	# Check to see that this really is a libtool object.
   7540  1.1  joerg 	if func_lalib_unsafe_p "$arg"; then
   7541  1.1  joerg 	  pic_object=
   7542  1.1  joerg 	  non_pic_object=
   7543  1.1  joerg 
   7544  1.1  joerg 	  # Read the .lo file
   7545  1.1  joerg 	  func_source "$arg"
   7546  1.1  joerg 
   7547  1.1  joerg 	  if test -z "$pic_object" ||
   7548  1.1  joerg 	     test -z "$non_pic_object" ||
   7549  1.1  joerg 	     test none = "$pic_object" &&
   7550  1.1  joerg 	     test none = "$non_pic_object"; then
   7551  1.1  joerg 	    func_fatal_error "cannot find name of object for '$arg'"
   7552  1.1  joerg 	  fi
   7553  1.1  joerg 
   7554  1.1  joerg 	  # Extract subdirectory from the argument.
   7555  1.1  joerg 	  func_dirname "$arg" "/" ""
   7556  1.1  joerg 	  xdir=$func_dirname_result
   7557  1.1  joerg 
   7558  1.1  joerg 	  test none = "$pic_object" || {
   7559  1.1  joerg 	    # Prepend the subdirectory the object is found in.
   7560  1.1  joerg 	    pic_object=$xdir$pic_object
   7561  1.1  joerg 
   7562  1.1  joerg 	    if test dlfiles = "$prev"; then
   7563  1.1  joerg 	      if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
   7564  1.1  joerg 		func_append dlfiles " $pic_object"
   7565  1.1  joerg 		prev=
   7566  1.1  joerg 		continue
   7567  1.1  joerg 	      else
   7568  1.1  joerg 		# If libtool objects are unsupported, then we need to preload.
   7569  1.1  joerg 		prev=dlprefiles
   7570  1.1  joerg 	      fi
   7571  1.1  joerg 	    fi
   7572  1.1  joerg 
   7573  1.1  joerg 	    # CHECK ME:  I think I busted this.  -Ossama
   7574  1.1  joerg 	    if test dlprefiles = "$prev"; then
   7575  1.1  joerg 	      # Preload the old-style object.
   7576  1.1  joerg 	      func_append dlprefiles " $pic_object"
   7577  1.1  joerg 	      prev=
   7578  1.1  joerg 	    fi
   7579  1.1  joerg 
   7580  1.1  joerg 	    # A PIC object.
   7581  1.1  joerg 	    func_append libobjs " $pic_object"
   7582  1.1  joerg 	    arg=$pic_object
   7583  1.1  joerg 	  }
   7584  1.1  joerg 
   7585  1.1  joerg 	  # Non-PIC object.
   7586  1.1  joerg 	  if test none != "$non_pic_object"; then
   7587  1.1  joerg 	    # Prepend the subdirectory the object is found in.
   7588  1.1  joerg 	    non_pic_object=$xdir$non_pic_object
   7589  1.1  joerg 
   7590  1.1  joerg 	    # A standard non-PIC object
   7591  1.1  joerg 	    func_append non_pic_objects " $non_pic_object"
   7592  1.1  joerg 	    if test -z "$pic_object" || test none = "$pic_object"; then
   7593  1.1  joerg 	      arg=$non_pic_object
   7594  1.1  joerg 	    fi
   7595  1.1  joerg 	  else
   7596  1.1  joerg 	    # If the PIC object exists, use it instead.
   7597  1.1  joerg 	    # $xdir was prepended to $pic_object above.
   7598  1.1  joerg 	    non_pic_object=$pic_object
   7599  1.1  joerg 	    func_append non_pic_objects " $non_pic_object"
   7600  1.1  joerg 	  fi
   7601  1.1  joerg 	else
   7602  1.1  joerg 	  # Only an error if not doing a dry-run.
   7603  1.1  joerg 	  if $opt_dry_run; then
   7604  1.1  joerg 	    # Extract subdirectory from the argument.
   7605  1.1  joerg 	    func_dirname "$arg" "/" ""
   7606  1.1  joerg 	    xdir=$func_dirname_result
   7607  1.1  joerg 
   7608  1.1  joerg 	    func_lo2o "$arg"
   7609  1.1  joerg 	    pic_object=$xdir$objdir/$func_lo2o_result
   7610  1.1  joerg 	    non_pic_object=$xdir$func_lo2o_result
   7611  1.1  joerg 	    func_append libobjs " $pic_object"
   7612  1.1  joerg 	    func_append non_pic_objects " $non_pic_object"
   7613  1.1  joerg 	  else
   7614  1.1  joerg 	    func_fatal_error "'$arg' is not a valid libtool object"
   7615  1.1  joerg 	  fi
   7616  1.1  joerg 	fi
   7617  1.1  joerg 	;;
   7618  1.1  joerg 
   7619  1.1  joerg       *.$libext)
   7620  1.1  joerg 	# An archive.
   7621  1.1  joerg 	func_append deplibs " $arg"
   7622  1.1  joerg 	func_append old_deplibs " $arg"
   7623  1.1  joerg 	continue
   7624  1.1  joerg 	;;
   7625  1.1  joerg 
   7626  1.1  joerg       *.la)
   7627  1.1  joerg 	# A libtool-controlled library.
   7628  1.1  joerg 
   7629  1.1  joerg 	func_resolve_sysroot "$arg"
   7630  1.1  joerg 	if test dlfiles = "$prev"; then
   7631  1.1  joerg 	  # This library was specified with -dlopen.
   7632  1.1  joerg 	  func_append dlfiles " $func_resolve_sysroot_result"
   7633  1.1  joerg 	  prev=
   7634  1.1  joerg 	elif test dlprefiles = "$prev"; then
   7635  1.1  joerg 	  # The library was specified with -dlpreopen.
   7636  1.1  joerg 	  func_append dlprefiles " $func_resolve_sysroot_result"
   7637  1.1  joerg 	  prev=
   7638  1.1  joerg 	else
   7639  1.1  joerg 	  func_append deplibs " $func_resolve_sysroot_result"
   7640  1.1  joerg 	fi
   7641  1.1  joerg 	continue
   7642  1.1  joerg 	;;
   7643  1.1  joerg 
   7644  1.1  joerg       # Some other compiler argument.
   7645  1.1  joerg       *)
   7646  1.1  joerg 	# Unknown arguments in both finalize_command and compile_command need
   7647  1.1  joerg 	# to be aesthetically quoted because they are evaled later.
   7648  1.1  joerg 	func_quote_arg pretty "$arg"
   7649  1.1  joerg 	arg=$func_quote_arg_result
   7650  1.1  joerg 	;;
   7651  1.1  joerg       esac # arg
   7652  1.1  joerg 
   7653  1.1  joerg       # Now actually substitute the argument into the commands.
   7654  1.1  joerg       if test -n "$arg"; then
   7655  1.1  joerg 	func_append compile_command " $arg"
   7656  1.1  joerg 	func_append finalize_command " $arg"
   7657  1.1  joerg       fi
   7658  1.1  joerg     done # argument parsing loop
   7659  1.1  joerg 
   7660  1.1  joerg     test -n "$prev" && \
   7661  1.1  joerg       func_fatal_help "the '$prevarg' option requires an argument"
   7662  1.1  joerg 
   7663  1.1  joerg     if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
   7664  1.1  joerg       eval arg=\"$export_dynamic_flag_spec\"
   7665  1.1  joerg       func_append compile_command " $arg"
   7666  1.1  joerg       func_append finalize_command " $arg"
   7667  1.1  joerg     fi
   7668  1.1  joerg 
   7669  1.1  joerg     oldlibs=
   7670  1.1  joerg     # calculate the name of the file, without its directory
   7671  1.1  joerg     func_basename "$output"
   7672  1.1  joerg     outputname=$func_basename_result
   7673  1.1  joerg     libobjs_save=$libobjs
   7674  1.1  joerg 
   7675  1.1  joerg     if test -n "$shlibpath_var"; then
   7676  1.1  joerg       # get the directories listed in $shlibpath_var
   7677  1.1  joerg       eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
   7678  1.1  joerg     else
   7679  1.1  joerg       shlib_search_path=
   7680  1.1  joerg     fi
   7681  1.1  joerg     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
   7682  1.1  joerg     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
   7683  1.1  joerg 
   7684  1.1  joerg     # Definition is injected by LT_CONFIG during libtool generation.
   7685  1.1  joerg     func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
   7686  1.1  joerg 
   7687  1.1  joerg     func_dirname "$output" "/" ""
   7688  1.1  joerg     output_objdir=$func_dirname_result$objdir
   7689  1.1  joerg     func_to_tool_file "$output_objdir/"
   7690  1.1  joerg     tool_output_objdir=$func_to_tool_file_result
   7691  1.1  joerg     # Create the object directory.
   7692  1.1  joerg     func_mkdir_p "$output_objdir"
   7693  1.1  joerg 
   7694  1.1  joerg     # Determine the type of output
   7695  1.1  joerg     case $output in
   7696  1.1  joerg     "")
   7697  1.1  joerg       func_fatal_help "you must specify an output file"
   7698  1.1  joerg       ;;
   7699  1.1  joerg     *.$libext) linkmode=oldlib ;;
   7700  1.1  joerg     *.lo | *.$objext) linkmode=obj ;;
   7701  1.1  joerg     *.la) linkmode=lib ;;
   7702  1.1  joerg     *) linkmode=prog ;; # Anything else should be a program.
   7703  1.1  joerg     esac
   7704  1.1  joerg 
   7705  1.1  joerg     specialdeplibs=
   7706  1.1  joerg 
   7707  1.1  joerg     libs=
   7708  1.1  joerg     # Find all interdependent deplibs by searching for libraries
   7709  1.1  joerg     # that are linked more than once (e.g. -la -lb -la)
   7710  1.1  joerg     for deplib in $deplibs; do
   7711  1.1  joerg       if $opt_preserve_dup_deps; then
   7712  1.1  joerg 	case "$libs " in
   7713  1.1  joerg 	*" $deplib "*) func_append specialdeplibs " $deplib" ;;
   7714  1.1  joerg 	esac
   7715  1.1  joerg       fi
   7716  1.1  joerg       func_append libs " $deplib"
   7717  1.1  joerg     done
   7718  1.1  joerg 
   7719  1.1  joerg     if test lib = "$linkmode"; then
   7720  1.1  joerg       libs="$predeps $libs $compiler_lib_search_path $postdeps"
   7721  1.1  joerg 
   7722  1.1  joerg       # Compute libraries that are listed more than once in $predeps
   7723  1.1  joerg       # $postdeps and mark them as special (i.e., whose duplicates are
   7724  1.1  joerg       # not to be eliminated).
   7725  1.1  joerg       pre_post_deps=
   7726  1.1  joerg       if $opt_duplicate_compiler_generated_deps; then
   7727  1.1  joerg 	for pre_post_dep in $predeps $postdeps; do
   7728  1.1  joerg 	  case "$pre_post_deps " in
   7729  1.1  joerg 	  *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
   7730  1.1  joerg 	  esac
   7731  1.1  joerg 	  func_append pre_post_deps " $pre_post_dep"
   7732  1.1  joerg 	done
   7733  1.1  joerg       fi
   7734  1.1  joerg       pre_post_deps=
   7735  1.1  joerg     fi
   7736  1.1  joerg 
   7737  1.1  joerg     deplibs=
   7738  1.1  joerg     newdependency_libs=
   7739  1.1  joerg     newlib_search_path=
   7740  1.1  joerg     need_relink=no # whether we're linking any uninstalled libtool libraries
   7741  1.1  joerg     notinst_deplibs= # not-installed libtool libraries
   7742  1.1  joerg     notinst_path= # paths that contain not-installed libtool libraries
   7743  1.1  joerg 
   7744  1.1  joerg     case $linkmode in
   7745  1.1  joerg     lib)
   7746  1.1  joerg 	passes="conv dlpreopen link"
   7747  1.1  joerg 	for file in $dlfiles $dlprefiles; do
   7748  1.1  joerg 	  case $file in
   7749  1.1  joerg 	  *.la) ;;
   7750  1.1  joerg 	  *)
   7751  1.1  joerg 	    func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
   7752  1.1  joerg 	    ;;
   7753  1.1  joerg 	  esac
   7754  1.1  joerg 	done
   7755  1.1  joerg 	;;
   7756  1.1  joerg     prog)
   7757  1.1  joerg 	compile_deplibs=
   7758  1.1  joerg 	finalize_deplibs=
   7759  1.1  joerg 	alldeplibs=false
   7760  1.1  joerg 	newdlfiles=
   7761  1.1  joerg 	newdlprefiles=
   7762  1.1  joerg 	passes="conv scan dlopen dlpreopen link"
   7763  1.1  joerg 	;;
   7764  1.1  joerg     *)  passes="conv"
   7765  1.1  joerg 	;;
   7766  1.1  joerg     esac
   7767  1.1  joerg 
   7768  1.1  joerg     for pass in $passes; do
   7769  1.1  joerg       # The preopen pass in lib mode reverses $deplibs; put it back here
   7770  1.1  joerg       # so that -L comes before libs that need it for instance...
   7771  1.1  joerg       if test lib,link = "$linkmode,$pass"; then
   7772  1.1  joerg 	## FIXME: Find the place where the list is rebuilt in the wrong
   7773  1.1  joerg 	##        order, and fix it there properly
   7774  1.1  joerg         tmp_deplibs=
   7775  1.1  joerg 	for deplib in $deplibs; do
   7776  1.1  joerg 	  tmp_deplibs="$deplib $tmp_deplibs"
   7777  1.1  joerg 	done
   7778  1.1  joerg 	deplibs=$tmp_deplibs
   7779  1.1  joerg       fi
   7780  1.1  joerg 
   7781  1.1  joerg       if test lib,link = "$linkmode,$pass" ||
   7782  1.1  joerg 	 test prog,scan = "$linkmode,$pass"; then
   7783  1.1  joerg 	libs=$deplibs
   7784  1.1  joerg 	deplibs=
   7785  1.1  joerg       fi
   7786  1.1  joerg       if test prog = "$linkmode"; then
   7787  1.1  joerg 	case $pass in
   7788  1.1  joerg 	dlopen) libs=$dlfiles ;;
   7789  1.1  joerg 	dlpreopen) libs=$dlprefiles ;;
   7790  1.1  joerg 	link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
   7791  1.1  joerg 	esac
   7792  1.1  joerg       fi
   7793  1.1  joerg       if test lib,dlpreopen = "$linkmode,$pass"; then
   7794  1.1  joerg 	# Collect and forward deplibs of preopened libtool libs
   7795  1.1  joerg 	for lib in $dlprefiles; do
   7796  1.1  joerg 	  # Ignore non-libtool-libs
   7797  1.1  joerg 	  dependency_libs=
   7798  1.1  joerg 	  func_resolve_sysroot "$lib"
   7799  1.1  joerg 	  case $lib in
   7800  1.1  joerg 	  *.la)	func_source "$func_resolve_sysroot_result" ;;
   7801  1.1  joerg 	  esac
   7802  1.1  joerg 
   7803  1.1  joerg 	  # Collect preopened libtool deplibs, except any this library
   7804  1.1  joerg 	  # has declared as weak libs
   7805  1.1  joerg 	  for deplib in $dependency_libs; do
   7806  1.1  joerg 	    func_basename "$deplib"
   7807  1.1  joerg             deplib_base=$func_basename_result
   7808  1.1  joerg 	    case " $weak_libs " in
   7809  1.1  joerg 	    *" $deplib_base "*) ;;
   7810  1.1  joerg 	    *) func_append deplibs " $deplib" ;;
   7811  1.1  joerg 	    esac
   7812  1.1  joerg 	  done
   7813  1.1  joerg 	done
   7814  1.1  joerg 	libs=$dlprefiles
   7815  1.1  joerg       fi
   7816  1.1  joerg       if test dlopen = "$pass"; then
   7817  1.1  joerg 	# Collect dlpreopened libraries
   7818  1.1  joerg 	save_deplibs=$deplibs
   7819  1.1  joerg 	deplibs=
   7820  1.1  joerg       fi
   7821  1.1  joerg 
   7822  1.1  joerg       for deplib in $libs; do
   7823  1.1  joerg 	lib=
   7824  1.1  joerg 	found=false
   7825  1.1  joerg 	case $deplib in
   7826  1.1  joerg 	-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
   7827  1.1  joerg         |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
   7828  1.1  joerg 	  if test prog,link = "$linkmode,$pass"; then
   7829  1.1  joerg 	    compile_deplibs="$deplib $compile_deplibs"
   7830  1.1  joerg 	    finalize_deplibs="$deplib $finalize_deplibs"
   7831  1.1  joerg 	  else
   7832  1.1  joerg 	    func_append compiler_flags " $deplib"
   7833  1.1  joerg 	    if test lib = "$linkmode"; then
   7834  1.1  joerg 		case "$new_inherited_linker_flags " in
   7835  1.1  joerg 		    *" $deplib "*) ;;
   7836  1.1  joerg 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
   7837  1.1  joerg 		esac
   7838  1.1  joerg 	    fi
   7839  1.1  joerg 	  fi
   7840  1.1  joerg 	  continue
   7841  1.1  joerg 	  ;;
   7842  1.1  joerg 	-l*)
   7843  1.1  joerg 	  if test lib != "$linkmode" && test prog != "$linkmode"; then
   7844  1.1  joerg 	    func_warning "'-l' is ignored for archives/objects"
   7845  1.1  joerg 	    continue
   7846  1.1  joerg 	  fi
   7847  1.1  joerg 	  func_stripname '-l' '' "$deplib"
   7848  1.1  joerg 	  name=$func_stripname_result
   7849  1.1  joerg 	  if test lib = "$linkmode"; then
   7850  1.1  joerg 	    searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
   7851  1.1  joerg 	  else
   7852  1.1  joerg 	    searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
   7853  1.1  joerg 	  fi
   7854  1.1  joerg 	  for searchdir in $searchdirs; do
   7855  1.1  joerg 	    for search_ext in .la $std_shrext .so .a; do
   7856  1.1  joerg 	      # Search the libtool library
   7857  1.1  joerg 	      lib=$searchdir/lib$name$search_ext
   7858  1.1  joerg 	      if test -f "$lib"; then
   7859  1.1  joerg 		if test .la = "$search_ext"; then
   7860  1.1  joerg 		  found=:
   7861  1.1  joerg 		else
   7862  1.1  joerg 		  found=false
   7863  1.1  joerg 		fi
   7864  1.1  joerg 		break 2
   7865  1.1  joerg 	      fi
   7866  1.1  joerg 	    done
   7867  1.1  joerg 	  done
   7868  1.1  joerg 	  if $found; then
   7869  1.1  joerg 	    # deplib is a libtool library
   7870  1.1  joerg 	    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
   7871  1.1  joerg 	    # We need to do some special things here, and not later.
   7872  1.1  joerg 	    if test yes = "$allow_libtool_libs_with_static_runtimes"; then
   7873  1.1  joerg 	      case " $predeps $postdeps " in
   7874  1.1  joerg 	      *" $deplib "*)
   7875  1.1  joerg 		if func_lalib_p "$lib"; then
   7876  1.1  joerg 		  library_names=
   7877  1.1  joerg 		  old_library=
   7878  1.1  joerg 		  func_source "$lib"
   7879  1.1  joerg 		  for l in $old_library $library_names; do
   7880  1.1  joerg 		    ll=$l
   7881  1.1  joerg 		  done
   7882  1.1  joerg 		  if test "X$ll" = "X$old_library"; then # only static version available
   7883  1.1  joerg 		    found=false
   7884  1.1  joerg 		    func_dirname "$lib" "" "."
   7885  1.1  joerg 		    ladir=$func_dirname_result
   7886  1.1  joerg 		    lib=$ladir/$old_library
   7887  1.1  joerg 		    if test prog,link = "$linkmode,$pass"; then
   7888  1.1  joerg 		      compile_deplibs="$deplib $compile_deplibs"
   7889  1.1  joerg 		      finalize_deplibs="$deplib $finalize_deplibs"
   7890  1.1  joerg 		    else
   7891  1.1  joerg 		      deplibs="$deplib $deplibs"
   7892  1.1  joerg 		      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
   7893  1.1  joerg 		    fi
   7894  1.1  joerg 		    continue
   7895  1.1  joerg 		  fi
   7896  1.1  joerg 		fi
   7897  1.1  joerg 		;;
   7898  1.1  joerg 	      *) ;;
   7899  1.1  joerg 	      esac
   7900  1.1  joerg 	    fi
   7901  1.1  joerg 	  else
   7902  1.1  joerg 	    # deplib doesn't seem to be a libtool library
   7903  1.1  joerg 	    if test prog,link = "$linkmode,$pass"; then
   7904  1.1  joerg 	      compile_deplibs="$deplib $compile_deplibs"
   7905  1.1  joerg 	      finalize_deplibs="$deplib $finalize_deplibs"
   7906  1.1  joerg 	    else
   7907  1.1  joerg 	      deplibs="$deplib $deplibs"
   7908  1.1  joerg 	      test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
   7909  1.1  joerg 	    fi
   7910  1.1  joerg 	    continue
   7911  1.1  joerg 	  fi
   7912  1.1  joerg 	  ;; # -l
   7913  1.1  joerg 	*.ltframework)
   7914  1.1  joerg 	  if test prog,link = "$linkmode,$pass"; then
   7915  1.1  joerg 	    compile_deplibs="$deplib $compile_deplibs"
   7916  1.1  joerg 	    finalize_deplibs="$deplib $finalize_deplibs"
   7917  1.1  joerg 	  else
   7918  1.1  joerg 	    deplibs="$deplib $deplibs"
   7919  1.1  joerg 	    if test lib = "$linkmode"; then
   7920  1.1  joerg 		case "$new_inherited_linker_flags " in
   7921  1.1  joerg 		    *" $deplib "*) ;;
   7922  1.1  joerg 		    * ) func_append new_inherited_linker_flags " $deplib" ;;
   7923  1.1  joerg 		esac
   7924  1.1  joerg 	    fi
   7925  1.1  joerg 	  fi
   7926  1.1  joerg 	  continue
   7927  1.1  joerg 	  ;;
   7928  1.1  joerg 	-L*)
   7929  1.1  joerg 	  case $linkmode in
   7930  1.1  joerg 	  lib)
   7931  1.1  joerg 	    deplibs="$deplib $deplibs"
   7932  1.1  joerg 	    test conv = "$pass" && continue
   7933  1.1  joerg 	    newdependency_libs="$deplib $newdependency_libs"
   7934  1.1  joerg 	    func_stripname '-L' '' "$deplib"
   7935  1.1  joerg 	    func_resolve_sysroot "$func_stripname_result"
   7936  1.1  joerg 	    func_append newlib_search_path " $func_resolve_sysroot_result"
   7937  1.1  joerg 	    ;;
   7938  1.1  joerg 	  prog)
   7939  1.1  joerg 	    if test conv = "$pass"; then
   7940  1.1  joerg 	      deplibs="$deplib $deplibs"
   7941  1.1  joerg 	      continue
   7942  1.1  joerg 	    fi
   7943  1.1  joerg 	    if test scan = "$pass"; then
   7944  1.1  joerg 	      deplibs="$deplib $deplibs"
   7945  1.1  joerg 	    else
   7946  1.1  joerg 	      compile_deplibs="$deplib $compile_deplibs"
   7947  1.1  joerg 	      finalize_deplibs="$deplib $finalize_deplibs"
   7948  1.1  joerg 	    fi
   7949  1.1  joerg 	    func_stripname '-L' '' "$deplib"
   7950  1.1  joerg 	    func_resolve_sysroot "$func_stripname_result"
   7951  1.1  joerg 	    func_append newlib_search_path " $func_resolve_sysroot_result"
   7952  1.1  joerg 	    ;;
   7953  1.1  joerg 	  *)
   7954  1.1  joerg 	    func_warning "'-L' is ignored for archives/objects"
   7955  1.1  joerg 	    ;;
   7956  1.1  joerg 	  esac # linkmode
   7957  1.1  joerg 	  continue
   7958  1.1  joerg 	  ;; # -L
   7959  1.1  joerg 	-R*)
   7960  1.1  joerg 	  if test link = "$pass"; then
   7961  1.1  joerg 	    func_stripname '-R' '' "$deplib"
   7962  1.1  joerg 	    func_resolve_sysroot "$func_stripname_result"
   7963  1.1  joerg 	    dir=$func_resolve_sysroot_result
   7964  1.1  joerg 	    # Make sure the xrpath contains only unique directories.
   7965  1.1  joerg 	    case "$xrpath " in
   7966  1.1  joerg 	    *" $dir "*) ;;
   7967  1.1  joerg 	    *) func_append xrpath " $dir" ;;
   7968  1.1  joerg 	    esac
   7969  1.1  joerg 	  fi
   7970  1.1  joerg 	  deplibs="$deplib $deplibs"
   7971  1.1  joerg 	  continue
   7972  1.1  joerg 	  ;;
   7973  1.1  joerg 	*.la)
   7974  1.1  joerg 	  func_resolve_sysroot "$deplib"
   7975  1.1  joerg 	  lib=$func_resolve_sysroot_result
   7976  1.1  joerg 	  ;;
   7977  1.1  joerg 	*.$libext)
   7978  1.1  joerg 	  if test conv = "$pass"; then
   7979  1.1  joerg 	    deplibs="$deplib $deplibs"
   7980  1.1  joerg 	    continue
   7981  1.1  joerg 	  fi
   7982  1.1  joerg 	  case $linkmode in
   7983  1.1  joerg 	  lib)
   7984  1.1  joerg 	    # Linking convenience modules into shared libraries is allowed,
   7985  1.1  joerg 	    # but linking other static libraries is non-portable.
   7986  1.1  joerg 	    case " $dlpreconveniencelibs " in
   7987  1.1  joerg 	    *" $deplib "*) ;;
   7988  1.1  joerg 	    *)
   7989  1.1  joerg 	      valid_a_lib=false
   7990  1.1  joerg 	      case $deplibs_check_method in
   7991  1.1  joerg 		match_pattern*)
   7992  1.1  joerg 		  set dummy $deplibs_check_method; shift
   7993  1.1  joerg 		  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
   7994  1.1  joerg 		  if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
   7995  1.1  joerg 		    | $EGREP "$match_pattern_regex" > /dev/null; then
   7996  1.1  joerg 		    valid_a_lib=:
   7997  1.1  joerg 		  fi
   7998  1.1  joerg 		;;
   7999  1.1  joerg 		pass_all)
   8000  1.1  joerg 		  valid_a_lib=:
   8001  1.1  joerg 		;;
   8002  1.1  joerg 	      esac
   8003  1.1  joerg 	      if $valid_a_lib; then
   8004  1.1  joerg 		echo
   8005  1.1  joerg 		$ECHO "*** Warning: Linking the shared library $output against the"
   8006  1.1  joerg 		$ECHO "*** static library $deplib is not portable!"
   8007  1.1  joerg 		deplibs="$deplib $deplibs"
   8008  1.1  joerg 	      else
   8009  1.1  joerg 		echo
   8010  1.1  joerg 		$ECHO "*** Warning: Trying to link with static lib archive $deplib."
   8011  1.1  joerg 		echo "*** I have the capability to make that library automatically link in when"
   8012  1.1  joerg 		echo "*** you link to this library.  But I can only do this if you have a"
   8013  1.1  joerg 		echo "*** shared version of the library, which you do not appear to have"
   8014  1.1  joerg 		echo "*** because the file extensions .$libext of this argument makes me believe"
   8015  1.1  joerg 		echo "*** that it is just a static archive that I should not use here."
   8016  1.1  joerg 	      fi
   8017  1.1  joerg 	      ;;
   8018  1.1  joerg 	    esac
   8019  1.1  joerg 	    continue
   8020  1.1  joerg 	    ;;
   8021  1.1  joerg 	  prog)
   8022  1.1  joerg 	    if test link != "$pass"; then
   8023  1.1  joerg 	      deplibs="$deplib $deplibs"
   8024  1.1  joerg 	    else
   8025  1.1  joerg 	      compile_deplibs="$deplib $compile_deplibs"
   8026  1.1  joerg 	      finalize_deplibs="$deplib $finalize_deplibs"
   8027  1.1  joerg 	    fi
   8028  1.1  joerg 	    continue
   8029  1.1  joerg 	    ;;
   8030  1.1  joerg 	  esac # linkmode
   8031  1.1  joerg 	  ;; # *.$libext
   8032  1.1  joerg 	*.lo | *.$objext)
   8033  1.1  joerg 	  if test conv = "$pass"; then
   8034  1.1  joerg 	    deplibs="$deplib $deplibs"
   8035  1.1  joerg 	  elif test prog = "$linkmode"; then
   8036  1.1  joerg 	    if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
   8037  1.1  joerg 	      # If there is no dlopen support or we're linking statically,
   8038  1.1  joerg 	      # we need to preload.
   8039  1.1  joerg 	      func_append newdlprefiles " $deplib"
   8040  1.1  joerg 	      compile_deplibs="$deplib $compile_deplibs"
   8041  1.1  joerg 	      finalize_deplibs="$deplib $finalize_deplibs"
   8042  1.1  joerg 	    else
   8043  1.1  joerg 	      func_append newdlfiles " $deplib"
   8044  1.1  joerg 	    fi
   8045  1.1  joerg 	  fi
   8046  1.1  joerg 	  continue
   8047  1.1  joerg 	  ;;
   8048  1.1  joerg 	%DEPLIBS%)
   8049  1.1  joerg 	  alldeplibs=:
   8050  1.1  joerg 	  continue
   8051  1.1  joerg 	  ;;
   8052  1.1  joerg 	esac # case $deplib
   8053  1.1  joerg 
   8054  1.1  joerg 	$found || test -f "$lib" \
   8055  1.1  joerg 	  || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
   8056  1.1  joerg 
   8057  1.1  joerg 	# Check to see that this really is a libtool archive.
   8058  1.1  joerg 	func_lalib_unsafe_p "$lib" \
   8059  1.1  joerg 	  || func_fatal_error "'$lib' is not a valid libtool archive"
   8060  1.1  joerg 
   8061  1.1  joerg 	func_dirname "$lib" "" "."
   8062  1.1  joerg 	ladir=$func_dirname_result
   8063  1.1  joerg 
   8064  1.1  joerg 	dlname=
   8065  1.1  joerg 	dlopen=
   8066  1.1  joerg 	dlpreopen=
   8067  1.1  joerg 	libdir=
   8068  1.1  joerg 	library_names=
   8069  1.1  joerg 	old_library=
   8070  1.1  joerg 	inherited_linker_flags=
   8071  1.1  joerg 	# If the library was installed with an old release of libtool,
   8072  1.1  joerg 	# it will not redefine variables installed, or shouldnotlink
   8073  1.1  joerg 	installed=yes
   8074  1.1  joerg 	shouldnotlink=no
   8075  1.1  joerg 	avoidtemprpath=
   8076  1.1  joerg 
   8077  1.1  joerg 
   8078  1.1  joerg 	# Read the .la file
   8079  1.1  joerg 	func_source "$lib"
   8080  1.1  joerg 
   8081  1.1  joerg 	# Convert "-framework foo" to "foo.ltframework"
   8082  1.1  joerg 	if test -n "$inherited_linker_flags"; then
   8083  1.1  joerg 	  tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
   8084  1.1  joerg 	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
   8085  1.1  joerg 	    case " $new_inherited_linker_flags " in
   8086  1.1  joerg 	      *" $tmp_inherited_linker_flag "*) ;;
   8087  1.1  joerg 	      *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
   8088  1.1  joerg 	    esac
   8089  1.1  joerg 	  done
   8090  1.1  joerg 	fi
   8091  1.1  joerg 	dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
   8092  1.1  joerg 	if test lib,link = "$linkmode,$pass" ||
   8093  1.1  joerg 	   test prog,scan = "$linkmode,$pass" ||
   8094  1.1  joerg 	   { test prog != "$linkmode" && test lib != "$linkmode"; }; then
   8095  1.1  joerg 	  test -n "$dlopen" && func_append dlfiles " $dlopen"
   8096  1.1  joerg 	  test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
   8097  1.1  joerg 	fi
   8098  1.1  joerg 
   8099  1.1  joerg 	if test conv = "$pass"; then
   8100  1.1  joerg 	  # Only check for convenience libraries
   8101  1.1  joerg 	  deplibs="$lib $deplibs"
   8102  1.1  joerg 	  if test -z "$libdir"; then
   8103  1.1  joerg 	    if test -z "$old_library"; then
   8104  1.1  joerg 	      func_fatal_error "cannot find name of link library for '$lib'"
   8105  1.1  joerg 	    fi
   8106  1.1  joerg 	    # It is a libtool convenience library, so add in its objects.
   8107  1.1  joerg 	    func_append convenience " $ladir/$objdir/$old_library"
   8108  1.1  joerg 	    func_append old_convenience " $ladir/$objdir/$old_library"
   8109  1.1  joerg 	  elif test prog != "$linkmode" && test lib != "$linkmode"; then
   8110  1.1  joerg 	    func_fatal_error "'$lib' is not a convenience library"
   8111  1.1  joerg 	  fi
   8112  1.1  joerg 	  tmp_libs=
   8113  1.1  joerg 	  for deplib in $dependency_libs; do
   8114  1.1  joerg 	    deplibs="$deplib $deplibs"
   8115  1.1  joerg 	    if $opt_preserve_dup_deps; then
   8116  1.1  joerg 	      case "$tmp_libs " in
   8117  1.1  joerg 	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
   8118  1.1  joerg 	      esac
   8119  1.1  joerg 	    fi
   8120  1.1  joerg 	    func_append tmp_libs " $deplib"
   8121  1.1  joerg 	  done
   8122  1.1  joerg 	  continue
   8123  1.1  joerg 	fi # $pass = conv
   8124  1.1  joerg 
   8125  1.1  joerg 
   8126  1.1  joerg 	# Get the name of the library we link against.
   8127  1.1  joerg 	linklib=
   8128  1.1  joerg 	if test -n "$old_library" &&
   8129  1.1  joerg 	   { test yes = "$prefer_static_libs" ||
   8130  1.1  joerg 	     test built,no = "$prefer_static_libs,$installed"; }; then
   8131  1.1  joerg 	  linklib=$old_library
   8132  1.1  joerg 	else
   8133  1.1  joerg 	  for l in $old_library $library_names; do
   8134  1.1  joerg 	    linklib=$l
   8135  1.1  joerg 	  done
   8136  1.1  joerg 	fi
   8137  1.1  joerg 	if test -z "$linklib"; then
   8138  1.1  joerg 	  func_fatal_error "cannot find name of link library for '$lib'"
   8139  1.1  joerg 	fi
   8140  1.1  joerg 
   8141  1.1  joerg 	# This library was specified with -dlopen.
   8142  1.1  joerg 	if test dlopen = "$pass"; then
   8143  1.1  joerg 	  test -z "$libdir" \
   8144  1.1  joerg 	    && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
   8145  1.1  joerg 	  if test -z "$dlname" ||
   8146  1.1  joerg 	     test yes != "$dlopen_support" ||
   8147  1.1  joerg 	     test no = "$build_libtool_libs"
   8148  1.1  joerg 	  then
   8149  1.1  joerg 	    # If there is no dlname, no dlopen support or we're linking
   8150  1.1  joerg 	    # statically, we need to preload.  We also need to preload any
   8151  1.1  joerg 	    # dependent libraries so libltdl's deplib preloader doesn't
   8152  1.1  joerg 	    # bomb out in the load deplibs phase.
   8153  1.1  joerg 	    func_append dlprefiles " $lib $dependency_libs"
   8154  1.1  joerg 	  else
   8155  1.1  joerg 	    func_append newdlfiles " $lib"
   8156  1.1  joerg 	  fi
   8157  1.1  joerg 	  continue
   8158  1.1  joerg 	fi # $pass = dlopen
   8159  1.1  joerg 
   8160  1.1  joerg 	# We need an absolute path.
   8161  1.1  joerg 	case $ladir in
   8162  1.1  joerg 	[\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
   8163  1.1  joerg 	*)
   8164  1.1  joerg 	  abs_ladir=`cd "$ladir" && pwd`
   8165  1.1  joerg 	  if test -z "$abs_ladir"; then
   8166  1.1  joerg 	    func_warning "cannot determine absolute directory name of '$ladir'"
   8167  1.1  joerg 	    func_warning "passing it literally to the linker, although it might fail"
   8168  1.1  joerg 	    abs_ladir=$ladir
   8169  1.1  joerg 	  fi
   8170  1.1  joerg 	  ;;
   8171  1.1  joerg 	esac
   8172  1.1  joerg 	func_basename "$lib"
   8173  1.1  joerg 	laname=$func_basename_result
   8174  1.1  joerg 
   8175  1.1  joerg 	# Find the relevant object directory and library name.
   8176  1.1  joerg 	if test yes = "$installed"; then
   8177  1.1  joerg 	  if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
   8178  1.1  joerg 	    func_warning "library '$lib' was moved."
   8179  1.1  joerg 	    dir=$ladir
   8180  1.1  joerg 	    absdir=$abs_ladir
   8181  1.1  joerg 	    libdir=$abs_ladir
   8182  1.1  joerg 	  else
   8183  1.1  joerg 	    dir=$lt_sysroot$libdir
   8184  1.1  joerg 	    absdir=$lt_sysroot$libdir
   8185  1.1  joerg 	  fi
   8186  1.1  joerg 	  test yes = "$hardcode_automatic" && avoidtemprpath=yes
   8187  1.1  joerg 	else
   8188  1.1  joerg 	  if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
   8189  1.1  joerg 	    dir=$ladir
   8190  1.1  joerg 	    absdir=$abs_ladir
   8191  1.1  joerg 	    # Remove this search path later
   8192  1.1  joerg 	    func_append notinst_path " $abs_ladir"
   8193  1.1  joerg 	  else
   8194  1.1  joerg 	    dir=$ladir/$objdir
   8195  1.1  joerg 	    absdir=$abs_ladir/$objdir
   8196  1.1  joerg 	    # Remove this search path later
   8197  1.1  joerg 	    func_append notinst_path " $abs_ladir"
   8198  1.1  joerg 	  fi
   8199  1.1  joerg 	fi # $installed = yes
   8200  1.1  joerg 	func_stripname 'lib' '.la' "$laname"
   8201  1.1  joerg 	name=$func_stripname_result
   8202  1.1  joerg 
   8203  1.1  joerg 	# This library was specified with -dlpreopen.
   8204  1.1  joerg 	if test dlpreopen = "$pass"; then
   8205  1.1  joerg 	  if test -z "$libdir" && test prog = "$linkmode"; then
   8206  1.1  joerg 	    func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
   8207  1.1  joerg 	  fi
   8208  1.1  joerg 	  case $host in
   8209  1.1  joerg 	    # special handling for platforms with PE-DLLs.
   8210  1.1  joerg 	    *cygwin* | *mingw* | *cegcc* )
   8211  1.1  joerg 	      # Linker will automatically link against shared library if both
   8212  1.1  joerg 	      # static and shared are present.  Therefore, ensure we extract
   8213  1.1  joerg 	      # symbols from the import library if a shared library is present
   8214  1.1  joerg 	      # (otherwise, the dlopen module name will be incorrect).  We do
   8215  1.1  joerg 	      # this by putting the import library name into $newdlprefiles.
   8216  1.1  joerg 	      # We recover the dlopen module name by 'saving' the la file
   8217  1.1  joerg 	      # name in a special purpose variable, and (later) extracting the
   8218  1.1  joerg 	      # dlname from the la file.
   8219  1.1  joerg 	      if test -n "$dlname"; then
   8220  1.1  joerg 	        func_tr_sh "$dir/$linklib"
   8221  1.1  joerg 	        eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
   8222  1.1  joerg 	        func_append newdlprefiles " $dir/$linklib"
   8223  1.1  joerg 	      else
   8224  1.1  joerg 	        func_append newdlprefiles " $dir/$old_library"
   8225  1.1  joerg 	        # Keep a list of preopened convenience libraries to check
   8226  1.1  joerg 	        # that they are being used correctly in the link pass.
   8227  1.1  joerg 	        test -z "$libdir" && \
   8228  1.1  joerg 	          func_append dlpreconveniencelibs " $dir/$old_library"
   8229  1.1  joerg 	      fi
   8230  1.1  joerg 	    ;;
   8231  1.1  joerg 	    * )
   8232  1.1  joerg 	      # Prefer using a static library (so that no silly _DYNAMIC symbols
   8233  1.1  joerg 	      # are required to link).
   8234  1.1  joerg 	      if test -n "$old_library"; then
   8235  1.1  joerg 	        func_append newdlprefiles " $dir/$old_library"
   8236  1.1  joerg 	        # Keep a list of preopened convenience libraries to check
   8237  1.1  joerg 	        # that they are being used correctly in the link pass.
   8238  1.1  joerg 	        test -z "$libdir" && \
   8239  1.1  joerg 	          func_append dlpreconveniencelibs " $dir/$old_library"
   8240  1.1  joerg 	      # Otherwise, use the dlname, so that lt_dlopen finds it.
   8241  1.1  joerg 	      elif test -n "$dlname"; then
   8242  1.1  joerg 	        func_append newdlprefiles " $dir/$dlname"
   8243  1.1  joerg 	      else
   8244  1.1  joerg 	        func_append newdlprefiles " $dir/$linklib"
   8245  1.1  joerg 	      fi
   8246  1.1  joerg 	    ;;
   8247  1.1  joerg 	  esac
   8248  1.1  joerg 	fi # $pass = dlpreopen
   8249  1.1  joerg 
   8250  1.1  joerg 	if test -z "$libdir"; then
   8251  1.1  joerg 	  # Link the convenience library
   8252  1.1  joerg 	  if test lib = "$linkmode"; then
   8253  1.1  joerg 	    deplibs="$dir/$old_library $deplibs"
   8254  1.1  joerg 	  elif test prog,link = "$linkmode,$pass"; then
   8255  1.1  joerg 	    compile_deplibs="$dir/$old_library $compile_deplibs"
   8256  1.1  joerg 	    finalize_deplibs="$dir/$old_library $finalize_deplibs"
   8257  1.1  joerg 	  else
   8258  1.1  joerg 	    deplibs="$lib $deplibs" # used for prog,scan pass
   8259  1.1  joerg 	  fi
   8260  1.1  joerg 	  continue
   8261  1.1  joerg 	fi
   8262  1.1  joerg 
   8263  1.1  joerg 
   8264  1.1  joerg 	if test prog = "$linkmode" && test link != "$pass"; then
   8265  1.1  joerg 	  func_append newlib_search_path " $ladir"
   8266  1.1  joerg 	  deplibs="$lib $deplibs"
   8267  1.1  joerg 
   8268  1.1  joerg 	  linkalldeplibs=false
   8269  1.1  joerg 	  if test no != "$link_all_deplibs" || test -z "$library_names" ||
   8270  1.1  joerg 	     test no = "$build_libtool_libs"; then
   8271  1.1  joerg 	    linkalldeplibs=:
   8272  1.1  joerg 	  fi
   8273  1.1  joerg 
   8274  1.1  joerg 	  tmp_libs=
   8275  1.1  joerg 	  for deplib in $dependency_libs; do
   8276  1.1  joerg 	    case $deplib in
   8277  1.1  joerg 	    -L*) func_stripname '-L' '' "$deplib"
   8278  1.1  joerg 	         func_resolve_sysroot "$func_stripname_result"
   8279  1.1  joerg 	         func_append newlib_search_path " $func_resolve_sysroot_result"
   8280  1.1  joerg 		 ;;
   8281  1.1  joerg 	    esac
   8282  1.1  joerg 	    # Need to link against all dependency_libs?
   8283  1.1  joerg 	    if $linkalldeplibs; then
   8284  1.1  joerg 	      deplibs="$deplib $deplibs"
   8285  1.1  joerg 	    else
   8286  1.1  joerg 	      # Need to hardcode shared library paths
   8287  1.1  joerg 	      # or/and link against static libraries
   8288  1.1  joerg 	      newdependency_libs="$deplib $newdependency_libs"
   8289  1.1  joerg 	    fi
   8290  1.1  joerg 	    if $opt_preserve_dup_deps; then
   8291  1.1  joerg 	      case "$tmp_libs " in
   8292  1.1  joerg 	      *" $deplib "*) func_append specialdeplibs " $deplib" ;;
   8293  1.1  joerg 	      esac
   8294  1.1  joerg 	    fi
   8295  1.1  joerg 	    func_append tmp_libs " $deplib"
   8296  1.1  joerg 	  done # for deplib
   8297  1.1  joerg 	  continue
   8298  1.1  joerg 	fi # $linkmode = prog...
   8299  1.1  joerg 
   8300  1.1  joerg 	if test prog,link = "$linkmode,$pass"; then
   8301  1.1  joerg 	  if test -n "$library_names" &&
   8302  1.1  joerg 	     { { test no = "$prefer_static_libs" ||
   8303  1.1  joerg 	         test built,yes = "$prefer_static_libs,$installed"; } ||
   8304  1.1  joerg 	       test -z "$old_library"; }; then
   8305  1.1  joerg 	    # We need to hardcode the library path
   8306  1.1  joerg 	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
   8307  1.1  joerg 	      # Make sure the rpath contains only unique directories.
   8308  1.1  joerg 	      case $temp_rpath: in
   8309  1.1  joerg 	      *"$absdir:"*) ;;
   8310  1.1  joerg 	      *) func_append temp_rpath "$absdir:" ;;
   8311  1.1  joerg 	      esac
   8312  1.1  joerg 	    fi
   8313  1.1  joerg 
   8314  1.1  joerg 	    # Hardcode the library path.
   8315  1.1  joerg 	    # Skip directories that are in the system default run-time
   8316  1.1  joerg 	    # search path.
   8317  1.1  joerg 	    case " $sys_lib_dlsearch_path " in
   8318  1.1  joerg 	    *" $absdir "*) ;;
   8319  1.1  joerg 	    *)
   8320  1.1  joerg 	      case "$compile_rpath " in
   8321  1.1  joerg 	      *" $absdir "*) ;;
   8322  1.1  joerg 	      *) func_append compile_rpath " $absdir" ;;
   8323  1.1  joerg 	      esac
   8324  1.1  joerg 	      ;;
   8325  1.1  joerg 	    esac
   8326  1.1  joerg 	    case " $sys_lib_dlsearch_path " in
   8327  1.1  joerg 	    *" $libdir "*) ;;
   8328  1.1  joerg 	    *)
   8329  1.1  joerg 	      case "$finalize_rpath " in
   8330  1.1  joerg 	      *" $libdir "*) ;;
   8331  1.1  joerg 	      *) func_append finalize_rpath " $libdir" ;;
   8332  1.1  joerg 	      esac
   8333  1.1  joerg 	      ;;
   8334  1.1  joerg 	    esac
   8335  1.1  joerg 	  fi # $linkmode,$pass = prog,link...
   8336  1.1  joerg 
   8337  1.1  joerg 	  if $alldeplibs &&
   8338  1.1  joerg 	     { test pass_all = "$deplibs_check_method" ||
   8339  1.1  joerg 	       { test yes = "$build_libtool_libs" &&
   8340  1.1  joerg 		 test -n "$library_names"; }; }; then
   8341  1.1  joerg 	    # We only need to search for static libraries
   8342  1.1  joerg 	    continue
   8343  1.1  joerg 	  fi
   8344  1.1  joerg 	fi
   8345  1.1  joerg 
   8346  1.1  joerg 	link_static=no # Whether the deplib will be linked statically
   8347  1.1  joerg 	use_static_libs=$prefer_static_libs
   8348  1.1  joerg 	if test built = "$use_static_libs" && test yes = "$installed"; then
   8349  1.1  joerg 	  use_static_libs=no
   8350  1.1  joerg 	fi
   8351  1.1  joerg 	if test -n "$library_names" &&
   8352  1.1  joerg 	   { test no = "$use_static_libs" || test -z "$old_library"; }; then
   8353  1.1  joerg 	  case $host in
   8354  1.1  joerg 	  *cygwin* | *mingw* | *cegcc* | *os2*)
   8355  1.1  joerg 	      # No point in relinking DLLs because paths are not encoded
   8356  1.1  joerg 	      func_append notinst_deplibs " $lib"
   8357  1.1  joerg 	      need_relink=no
   8358  1.1  joerg 	    ;;
   8359  1.1  joerg 	  *)
   8360  1.1  joerg 	    if test no = "$installed"; then
   8361  1.1  joerg 	      func_append notinst_deplibs " $lib"
   8362  1.1  joerg 	      need_relink=yes
   8363  1.1  joerg 	    fi
   8364  1.1  joerg 	    ;;
   8365  1.1  joerg 	  esac
   8366  1.1  joerg 	  # This is a shared library
   8367  1.1  joerg 
   8368  1.1  joerg 	  # Warn about portability, can't link against -module's on some
   8369  1.1  joerg 	  # systems (darwin).  Don't bleat about dlopened modules though!
   8370  1.1  joerg 	  dlopenmodule=
   8371  1.1  joerg 	  for dlpremoduletest in $dlprefiles; do
   8372  1.1  joerg 	    if test "X$dlpremoduletest" = "X$lib"; then
   8373  1.1  joerg 	      dlopenmodule=$dlpremoduletest
   8374  1.1  joerg 	      break
   8375  1.1  joerg 	    fi
   8376  1.1  joerg 	  done
   8377  1.1  joerg 	  if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
   8378  1.1  joerg 	    echo
   8379  1.1  joerg 	    if test prog = "$linkmode"; then
   8380  1.1  joerg 	      $ECHO "*** Warning: Linking the executable $output against the loadable module"
   8381  1.1  joerg 	    else
   8382  1.1  joerg 	      $ECHO "*** Warning: Linking the shared library $output against the loadable module"
   8383  1.1  joerg 	    fi
   8384  1.1  joerg 	    $ECHO "*** $linklib is not portable!"
   8385  1.1  joerg 	  fi
   8386  1.1  joerg 	  if test lib = "$linkmode" &&
   8387  1.1  joerg 	     test yes = "$hardcode_into_libs"; then
   8388  1.1  joerg 	    # Hardcode the library path.
   8389  1.1  joerg 	    # Skip directories that are in the system default run-time
   8390  1.1  joerg 	    # search path.
   8391  1.1  joerg 	    case " $sys_lib_dlsearch_path " in
   8392  1.1  joerg 	    *" $absdir "*) ;;
   8393  1.1  joerg 	    *)
   8394  1.1  joerg 	      case "$compile_rpath " in
   8395  1.1  joerg 	      *" $absdir "*) ;;
   8396  1.1  joerg 	      *) func_append compile_rpath " $absdir" ;;
   8397  1.1  joerg 	      esac
   8398  1.1  joerg 	      ;;
   8399  1.1  joerg 	    esac
   8400  1.1  joerg 	    case " $sys_lib_dlsearch_path " in
   8401  1.1  joerg 	    *" $libdir "*) ;;
   8402  1.1  joerg 	    *)
   8403  1.1  joerg 	      case "$finalize_rpath " in
   8404  1.1  joerg 	      *" $libdir "*) ;;
   8405  1.1  joerg 	      *) func_append finalize_rpath " $libdir" ;;
   8406  1.1  joerg 	      esac
   8407  1.1  joerg 	      ;;
   8408  1.1  joerg 	    esac
   8409  1.1  joerg 	  fi
   8410  1.1  joerg 
   8411  1.1  joerg 	  if test -n "$old_archive_from_expsyms_cmds"; then
   8412  1.1  joerg 	    # figure out the soname
   8413  1.1  joerg 	    set dummy $library_names
   8414  1.1  joerg 	    shift
   8415  1.1  joerg 	    realname=$1
   8416  1.1  joerg 	    shift
   8417  1.1  joerg 	    libname=`eval "\\$ECHO \"$libname_spec\""`
   8418  1.1  joerg 	    # use dlname if we got it. it's perfectly good, no?
   8419  1.1  joerg 	    if test -n "$dlname"; then
   8420  1.1  joerg 	      soname=$dlname
   8421  1.1  joerg 	    elif test -n "$soname_spec"; then
   8422  1.1  joerg 	      # bleh windows
   8423  1.1  joerg 	      case $host in
   8424  1.1  joerg 	      *cygwin* | mingw* | *cegcc* | *os2*)
   8425  1.1  joerg 	        func_arith $current - $age
   8426  1.1  joerg 		major=$func_arith_result
   8427  1.1  joerg 		versuffix=-$major
   8428  1.1  joerg 		;;
   8429  1.1  joerg 	      esac
   8430  1.1  joerg 	      eval soname=\"$soname_spec\"
   8431  1.1  joerg 	    else
   8432  1.1  joerg 	      soname=$realname
   8433  1.1  joerg 	    fi
   8434  1.1  joerg 
   8435  1.1  joerg 	    # Make a new name for the extract_expsyms_cmds to use
   8436  1.1  joerg 	    soroot=$soname
   8437  1.1  joerg 	    func_basename "$soroot"
   8438  1.1  joerg 	    soname=$func_basename_result
   8439  1.1  joerg 	    func_stripname 'lib' '.dll' "$soname"
   8440  1.1  joerg 	    newlib=libimp-$func_stripname_result.a
   8441  1.1  joerg 
   8442  1.1  joerg 	    # If the library has no export list, then create one now
   8443  1.1  joerg 	    if test -f "$output_objdir/$soname-def"; then :
   8444  1.1  joerg 	    else
   8445  1.1  joerg 	      func_verbose "extracting exported symbol list from '$soname'"
   8446  1.1  joerg 	      func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
   8447  1.1  joerg 	    fi
   8448  1.1  joerg 
   8449  1.1  joerg 	    # Create $newlib
   8450  1.1  joerg 	    if test -f "$output_objdir/$newlib"; then :; else
   8451  1.1  joerg 	      func_verbose "generating import library for '$soname'"
   8452  1.1  joerg 	      func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
   8453  1.1  joerg 	    fi
   8454  1.1  joerg 	    # make sure the library variables are pointing to the new library
   8455  1.1  joerg 	    dir=$output_objdir
   8456  1.1  joerg 	    linklib=$newlib
   8457  1.1  joerg 	  fi # test -n "$old_archive_from_expsyms_cmds"
   8458  1.1  joerg 
   8459  1.1  joerg 	  if test prog = "$linkmode" || test relink != "$opt_mode"; then
   8460  1.1  joerg 	    add_shlibpath=
   8461  1.1  joerg 	    add_dir=
   8462  1.1  joerg 	    add=
   8463  1.1  joerg 	    lib_linked=yes
   8464  1.1  joerg 	    case $hardcode_action in
   8465  1.1  joerg 	    immediate | unsupported)
   8466  1.1  joerg 	      if test no = "$hardcode_direct"; then
   8467  1.1  joerg 		add=$dir/$linklib
   8468  1.1  joerg 		case $host in
   8469  1.1  joerg 		  *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
   8470  1.1  joerg 		  *-*-sysv4*uw2*) add_dir=-L$dir ;;
   8471  1.1  joerg 		  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
   8472  1.1  joerg 		    *-*-unixware7*) add_dir=-L$dir ;;
   8473  1.1  joerg 		  *-*-darwin* )
   8474  1.1  joerg 		    # if the lib is a (non-dlopened) module then we cannot
   8475  1.1  joerg 		    # link against it, someone is ignoring the earlier warnings
   8476  1.1  joerg 		    if /usr/bin/file -L $add 2> /dev/null |
   8477  1.1  joerg 			 $GREP ": [^:]* bundle" >/dev/null; then
   8478  1.1  joerg 		      if test "X$dlopenmodule" != "X$lib"; then
   8479  1.1  joerg 			$ECHO "*** Warning: lib $linklib is a module, not a shared library"
   8480  1.1  joerg 			if test -z "$old_library"; then
   8481  1.1  joerg 			  echo
   8482  1.1  joerg 			  echo "*** And there doesn't seem to be a static archive available"
   8483  1.1  joerg 			  echo "*** The link will probably fail, sorry"
   8484  1.1  joerg 			else
   8485  1.1  joerg 			  add=$dir/$old_library
   8486  1.1  joerg 			fi
   8487  1.1  joerg 		      elif test -n "$old_library"; then
   8488  1.1  joerg 			add=$dir/$old_library
   8489  1.1  joerg 		      fi
   8490  1.1  joerg 		    fi
   8491  1.1  joerg 		esac
   8492  1.1  joerg 	      elif test no = "$hardcode_minus_L"; then
   8493  1.1  joerg 		case $host in
   8494  1.1  joerg 		*-*-sunos*) add_shlibpath=$dir ;;
   8495  1.1  joerg 		esac
   8496  1.1  joerg 		add_dir=-L$dir
   8497  1.1  joerg 		add=-l$name
   8498  1.1  joerg 	      elif test no = "$hardcode_shlibpath_var"; then
   8499  1.1  joerg 		add_shlibpath=$dir
   8500  1.1  joerg 		add=-l$name
   8501  1.1  joerg 	      else
   8502  1.1  joerg 		lib_linked=no
   8503  1.1  joerg 	      fi
   8504  1.1  joerg 	      ;;
   8505  1.1  joerg 	    relink)
   8506  1.1  joerg 	      if test yes = "$hardcode_direct" &&
   8507  1.1  joerg 	         test no = "$hardcode_direct_absolute"; then
   8508  1.1  joerg 		add=$dir/$linklib
   8509  1.1  joerg 	      elif test yes = "$hardcode_minus_L"; then
   8510  1.1  joerg 		add_dir=-L$absdir
   8511  1.1  joerg 		# Try looking first in the location we're being installed to.
   8512  1.1  joerg 		if test -n "$inst_prefix_dir"; then
   8513  1.1  joerg 		  case $libdir in
   8514  1.1  joerg 		    [\\/]*)
   8515  1.1  joerg 		      func_append add_dir " -L$inst_prefix_dir$libdir"
   8516  1.1  joerg 		      ;;
   8517  1.1  joerg 		  esac
   8518  1.1  joerg 		fi
   8519  1.1  joerg 		add=-l$name
   8520  1.1  joerg 	      elif test yes = "$hardcode_shlibpath_var"; then
   8521  1.1  joerg 		add_shlibpath=$dir
   8522  1.1  joerg 		add=-l$name
   8523  1.1  joerg 	      else
   8524  1.1  joerg 		lib_linked=no
   8525  1.1  joerg 	      fi
   8526  1.1  joerg 	      ;;
   8527  1.1  joerg 	    *) lib_linked=no ;;
   8528  1.1  joerg 	    esac
   8529  1.1  joerg 
   8530  1.1  joerg 	    if test yes != "$lib_linked"; then
   8531  1.1  joerg 	      func_fatal_configuration "unsupported hardcode properties"
   8532  1.1  joerg 	    fi
   8533  1.1  joerg 
   8534  1.1  joerg 	    if test -n "$add_shlibpath"; then
   8535  1.1  joerg 	      case :$compile_shlibpath: in
   8536  1.1  joerg 	      *":$add_shlibpath:"*) ;;
   8537  1.1  joerg 	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
   8538  1.1  joerg 	      esac
   8539  1.1  joerg 	    fi
   8540  1.1  joerg 	    if test prog = "$linkmode"; then
   8541  1.1  joerg 	      test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
   8542  1.1  joerg 	      test -n "$add" && compile_deplibs="$add $compile_deplibs"
   8543  1.1  joerg 	    else
   8544  1.1  joerg 	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
   8545  1.1  joerg 	      test -n "$add" && deplibs="$add $deplibs"
   8546  1.1  joerg 	      if test yes != "$hardcode_direct" &&
   8547  1.1  joerg 		 test yes != "$hardcode_minus_L" &&
   8548  1.1  joerg 		 test yes = "$hardcode_shlibpath_var"; then
   8549  1.1  joerg 		case :$finalize_shlibpath: in
   8550  1.1  joerg 		*":$libdir:"*) ;;
   8551  1.1  joerg 		*) func_append finalize_shlibpath "$libdir:" ;;
   8552  1.1  joerg 		esac
   8553  1.1  joerg 	      fi
   8554  1.1  joerg 	    fi
   8555  1.1  joerg 	  fi
   8556  1.1  joerg 
   8557  1.1  joerg 	  if test prog = "$linkmode" || test relink = "$opt_mode"; then
   8558  1.1  joerg 	    add_shlibpath=
   8559  1.1  joerg 	    add_dir=
   8560  1.1  joerg 	    add=
   8561  1.1  joerg 	    # Finalize command for both is simple: just hardcode it.
   8562  1.1  joerg 	    if test yes = "$hardcode_direct" &&
   8563  1.1  joerg 	       test no = "$hardcode_direct_absolute"; then
   8564  1.1  joerg 	      add=$libdir/$linklib
   8565  1.1  joerg 	    elif test yes = "$hardcode_minus_L"; then
   8566  1.1  joerg 	      add_dir=-L$libdir
   8567  1.1  joerg 	      add=-l$name
   8568  1.1  joerg 	    elif test yes = "$hardcode_shlibpath_var"; then
   8569  1.1  joerg 	      case :$finalize_shlibpath: in
   8570  1.1  joerg 	      *":$libdir:"*) ;;
   8571  1.1  joerg 	      *) func_append finalize_shlibpath "$libdir:" ;;
   8572  1.1  joerg 	      esac
   8573  1.1  joerg 	      add=-l$name
   8574  1.1  joerg 	    elif test yes = "$hardcode_automatic"; then
   8575  1.1  joerg 	      if test -n "$inst_prefix_dir" &&
   8576  1.1  joerg 		 test -f "$inst_prefix_dir$libdir/$linklib"; then
   8577  1.1  joerg 		add=$inst_prefix_dir$libdir/$linklib
   8578  1.1  joerg 	      else
   8579  1.1  joerg 		add=$libdir/$linklib
   8580  1.1  joerg 	      fi
   8581  1.1  joerg 	    else
   8582  1.1  joerg 	      # We cannot seem to hardcode it, guess we'll fake it.
   8583  1.1  joerg 	      add_dir=-L$libdir
   8584  1.1  joerg 	      # Try looking first in the location we're being installed to.
   8585  1.1  joerg 	      if test -n "$inst_prefix_dir"; then
   8586  1.1  joerg 		case $libdir in
   8587  1.1  joerg 		  [\\/]*)
   8588  1.1  joerg 		    func_append add_dir " -L$inst_prefix_dir$libdir"
   8589  1.1  joerg 		    ;;
   8590  1.1  joerg 		esac
   8591  1.1  joerg 	      fi
   8592  1.1  joerg 	      add=-l$name
   8593  1.1  joerg 	    fi
   8594  1.1  joerg 
   8595  1.1  joerg 	    if test prog = "$linkmode"; then
   8596  1.1  joerg 	      test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
   8597  1.1  joerg 	      test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
   8598  1.1  joerg 	    else
   8599  1.1  joerg 	      test -n "$add_dir" && deplibs="$add_dir $deplibs"
   8600  1.1  joerg 	      test -n "$add" && deplibs="$add $deplibs"
   8601  1.1  joerg 	    fi
   8602  1.1  joerg 	  fi
   8603  1.1  joerg 	elif test prog = "$linkmode"; then
   8604  1.1  joerg 	  # Here we assume that one of hardcode_direct or hardcode_minus_L
   8605  1.1  joerg 	  # is not unsupported.  This is valid on all known static and
   8606  1.1  joerg 	  # shared platforms.
   8607  1.1  joerg 	  if test unsupported != "$hardcode_direct"; then
   8608  1.1  joerg 	    test -n "$old_library" && linklib=$old_library
   8609  1.1  joerg 	    compile_deplibs="$dir/$linklib $compile_deplibs"
   8610  1.1  joerg 	    finalize_deplibs="$dir/$linklib $finalize_deplibs"
   8611  1.1  joerg 	  else
   8612  1.1  joerg 	    compile_deplibs="-l$name -L$dir $compile_deplibs"
   8613  1.1  joerg 	    finalize_deplibs="-l$name -L$dir $finalize_deplibs"
   8614  1.1  joerg 	  fi
   8615  1.1  joerg 	elif test yes = "$build_libtool_libs"; then
   8616  1.1  joerg 	  # Not a shared library
   8617  1.1  joerg 	  if test pass_all != "$deplibs_check_method"; then
   8618  1.1  joerg 	    # We're trying link a shared library against a static one
   8619  1.1  joerg 	    # but the system doesn't support it.
   8620  1.1  joerg 
   8621  1.1  joerg 	    # Just print a warning and add the library to dependency_libs so
   8622  1.1  joerg 	    # that the program can be linked against the static library.
   8623  1.1  joerg 	    echo
   8624  1.1  joerg 	    $ECHO "*** Warning: This system cannot link to static lib archive $lib."
   8625  1.1  joerg 	    echo "*** I have the capability to make that library automatically link in when"
   8626  1.1  joerg 	    echo "*** you link to this library.  But I can only do this if you have a"
   8627  1.1  joerg 	    echo "*** shared version of the library, which you do not appear to have."
   8628  1.1  joerg 	    if test yes = "$module"; then
   8629  1.1  joerg 	      echo "*** But as you try to build a module library, libtool will still create "
   8630  1.1  joerg 	      echo "*** a static module, that should work as long as the dlopening application"
   8631  1.1  joerg 	      echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
   8632  1.1  joerg 	      if test -z "$global_symbol_pipe"; then
   8633  1.1  joerg 		echo
   8634  1.1  joerg 		echo "*** However, this would only work if libtool was able to extract symbol"
   8635  1.1  joerg 		echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
   8636  1.1  joerg 		echo "*** not find such a program.  So, this module is probably useless."
   8637  1.1  joerg 		echo "*** 'nm' from GNU binutils and a full rebuild may help."
   8638  1.1  joerg 	      fi
   8639  1.1  joerg 	      if test no = "$build_old_libs"; then
   8640  1.1  joerg 		build_libtool_libs=module
   8641  1.1  joerg 		build_old_libs=yes
   8642  1.1  joerg 	      else
   8643  1.1  joerg 		build_libtool_libs=no
   8644  1.1  joerg 	      fi
   8645  1.1  joerg 	    fi
   8646  1.1  joerg 	  else
   8647  1.1  joerg 	    deplibs="$dir/$old_library $deplibs"
   8648  1.1  joerg 	    link_static=yes
   8649  1.1  joerg 	  fi
   8650  1.1  joerg 	fi # link shared/static library?
   8651  1.1  joerg 
   8652  1.1  joerg 	if test lib = "$linkmode"; then
   8653  1.1  joerg 	  if test -n "$dependency_libs" &&
   8654  1.1  joerg 	     { test yes != "$hardcode_into_libs" ||
   8655  1.1  joerg 	       test yes = "$build_old_libs" ||
   8656  1.1  joerg 	       test yes = "$link_static"; }; then
   8657  1.1  joerg 	    # Extract -R from dependency_libs
   8658  1.1  joerg 	    temp_deplibs=
   8659  1.1  joerg 	    for libdir in $dependency_libs; do
   8660  1.1  joerg 	      case $libdir in
   8661  1.1  joerg 	      -R*) func_stripname '-R' '' "$libdir"
   8662  1.1  joerg 	           temp_xrpath=$func_stripname_result
   8663  1.1  joerg 		   case " $xrpath " in
   8664  1.1  joerg 		   *" $temp_xrpath "*) ;;
   8665  1.1  joerg 		   *) func_append xrpath " $temp_xrpath";;
   8666  1.1  joerg 		   esac;;
   8667  1.1  joerg 	      *) func_append temp_deplibs " $libdir";;
   8668  1.1  joerg 	      esac
   8669  1.1  joerg 	    done
   8670  1.1  joerg 	    dependency_libs=$temp_deplibs
   8671  1.1  joerg 	  fi
   8672  1.1  joerg 
   8673  1.1  joerg 	  func_append newlib_search_path " $absdir"
   8674  1.1  joerg 	  # Link against this library
   8675  1.1  joerg 	  test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
   8676  1.1  joerg 	  # ... and its dependency_libs
   8677  1.1  joerg 	  tmp_libs=
   8678  1.1  joerg 	  for deplib in $dependency_libs; do
   8679  1.1  joerg 	    newdependency_libs="$deplib $newdependency_libs"
   8680  1.1  joerg 	    case $deplib in
   8681  1.1  joerg               -L*) func_stripname '-L' '' "$deplib"
   8682  1.1  joerg                    func_resolve_sysroot "$func_stripname_result";;
   8683  1.1  joerg               *) func_resolve_sysroot "$deplib" ;;
   8684  1.1  joerg             esac
   8685  1.1  joerg 	    if $opt_preserve_dup_deps; then
   8686  1.1  joerg 	      case "$tmp_libs " in
   8687  1.1  joerg 	      *" $func_resolve_sysroot_result "*)
   8688  1.1  joerg                 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
   8689  1.1  joerg 	      esac
   8690  1.1  joerg 	    fi
   8691  1.1  joerg 	    func_append tmp_libs " $func_resolve_sysroot_result"
   8692  1.1  joerg 	  done
   8693  1.1  joerg 
   8694  1.1  joerg 	  if test no != "$link_all_deplibs"; then
   8695  1.1  joerg 	    # Add the search paths of all dependency libraries
   8696  1.1  joerg 	    for deplib in $dependency_libs; do
   8697  1.1  joerg 	      path=
   8698  1.1  joerg 	      case $deplib in
   8699  1.1  joerg 	      -L*) path=$deplib ;;
   8700  1.1  joerg 	      *.la)
   8701  1.1  joerg 	        func_resolve_sysroot "$deplib"
   8702  1.1  joerg 	        deplib=$func_resolve_sysroot_result
   8703  1.1  joerg 	        func_dirname "$deplib" "" "."
   8704  1.1  joerg 		dir=$func_dirname_result
   8705  1.1  joerg 		# We need an absolute path.
   8706  1.1  joerg 		case $dir in
   8707  1.1  joerg 		[\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
   8708  1.1  joerg 		*)
   8709  1.1  joerg 		  absdir=`cd "$dir" && pwd`
   8710  1.1  joerg 		  if test -z "$absdir"; then
   8711  1.1  joerg 		    func_warning "cannot determine absolute directory name of '$dir'"
   8712  1.1  joerg 		    absdir=$dir
   8713  1.1  joerg 		  fi
   8714  1.1  joerg 		  ;;
   8715  1.1  joerg 		esac
   8716  1.1  joerg 		if $GREP "^installed=no" $deplib > /dev/null; then
   8717  1.1  joerg 		case $host in
   8718  1.1  joerg 		*-*-darwin*)
   8719  1.1  joerg 		  depdepl=
   8720  1.1  joerg 		  eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
   8721  1.1  joerg 		  if test -n "$deplibrary_names"; then
   8722  1.1  joerg 		    for tmp in $deplibrary_names; do
   8723  1.1  joerg 		      depdepl=$tmp
   8724  1.1  joerg 		    done
   8725  1.1  joerg 		    if test -f "$absdir/$objdir/$depdepl"; then
   8726  1.1  joerg 		      depdepl=$absdir/$objdir/$depdepl
   8727  1.1  joerg 		      darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
   8728  1.1  joerg                       if test -z "$darwin_install_name"; then
   8729  1.1  joerg                           darwin_install_name=`$OTOOL64 -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
   8730  1.1  joerg                       fi
   8731  1.1  joerg 		      func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
   8732  1.1  joerg 		      func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
   8733  1.1  joerg 		      path=
   8734  1.1  joerg 		    fi
   8735  1.1  joerg 		  fi
   8736  1.1  joerg 		  ;;
   8737  1.1  joerg 		*)
   8738  1.1  joerg 		  path=-L$absdir/$objdir
   8739  1.1  joerg 		  ;;
   8740  1.1  joerg 		esac
   8741  1.1  joerg 		else
   8742  1.1  joerg 		  eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
   8743  1.1  joerg 		  test -z "$libdir" && \
   8744  1.1  joerg 		    func_fatal_error "'$deplib' is not a valid libtool archive"
   8745  1.1  joerg 		  test "$absdir" != "$libdir" && \
   8746  1.1  joerg 		    func_warning "'$deplib' seems to be moved"
   8747  1.1  joerg 
   8748  1.1  joerg 		  path=-L$absdir
   8749  1.1  joerg 		fi
   8750  1.1  joerg 		;;
   8751  1.1  joerg 	      esac
   8752  1.1  joerg 	      case " $deplibs " in
   8753  1.1  joerg 	      *" $path "*) ;;
   8754  1.1  joerg 	      *) deplibs="$path $deplibs" ;;
   8755  1.1  joerg 	      esac
   8756  1.1  joerg 	    done
   8757  1.1  joerg 	  fi # link_all_deplibs != no
   8758  1.1  joerg 	fi # linkmode = lib
   8759  1.1  joerg       done # for deplib in $libs
   8760  1.1  joerg       if test link = "$pass"; then
   8761  1.1  joerg 	if test prog = "$linkmode"; then
   8762  1.1  joerg 	  compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
   8763  1.1  joerg 	  finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
   8764  1.1  joerg 	else
   8765  1.1  joerg 	  compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
   8766  1.1  joerg 	fi
   8767  1.1  joerg       fi
   8768  1.1  joerg       dependency_libs=$newdependency_libs
   8769  1.1  joerg       if test dlpreopen = "$pass"; then
   8770  1.1  joerg 	# Link the dlpreopened libraries before other libraries
   8771  1.1  joerg 	for deplib in $save_deplibs; do
   8772  1.1  joerg 	  deplibs="$deplib $deplibs"
   8773  1.1  joerg 	done
   8774  1.1  joerg       fi
   8775  1.1  joerg       if test dlopen != "$pass"; then
   8776  1.1  joerg 	test conv = "$pass" || {
   8777  1.1  joerg 	  # Make sure lib_search_path contains only unique directories.
   8778  1.1  joerg 	  lib_search_path=
   8779  1.1  joerg 	  for dir in $newlib_search_path; do
   8780  1.1  joerg 	    case "$lib_search_path " in
   8781  1.1  joerg 	    *" $dir "*) ;;
   8782  1.1  joerg 	    *) func_append lib_search_path " $dir" ;;
   8783  1.1  joerg 	    esac
   8784  1.1  joerg 	  done
   8785  1.1  joerg 	  newlib_search_path=
   8786  1.1  joerg 	}
   8787  1.1  joerg 
   8788  1.1  joerg 	if test prog,link = "$linkmode,$pass"; then
   8789  1.1  joerg 	  vars="compile_deplibs finalize_deplibs"
   8790  1.1  joerg 	else
   8791  1.1  joerg 	  vars=deplibs
   8792  1.1  joerg 	fi
   8793  1.1  joerg 	for var in $vars dependency_libs; do
   8794  1.1  joerg 	  # Add libraries to $var in reverse order
   8795  1.1  joerg 	  eval tmp_libs=\"\$$var\"
   8796  1.1  joerg 	  new_libs=
   8797  1.1  joerg 	  for deplib in $tmp_libs; do
   8798  1.1  joerg 	    # FIXME: Pedantically, this is the right thing to do, so
   8799  1.1  joerg 	    #        that some nasty dependency loop isn't accidentally
   8800  1.1  joerg 	    #        broken:
   8801  1.1  joerg 	    #new_libs="$deplib $new_libs"
   8802  1.1  joerg 	    # Pragmatically, this seems to cause very few problems in
   8803  1.1  joerg 	    # practice:
   8804  1.1  joerg 	    case $deplib in
   8805  1.1  joerg 	    -L*) new_libs="$deplib $new_libs" ;;
   8806  1.1  joerg 	    -R*) ;;
   8807  1.1  joerg 	    *)
   8808  1.1  joerg 	      # And here is the reason: when a library appears more
   8809  1.1  joerg 	      # than once as an explicit dependence of a library, or
   8810  1.1  joerg 	      # is implicitly linked in more than once by the
   8811  1.1  joerg 	      # compiler, it is considered special, and multiple
   8812  1.1  joerg 	      # occurrences thereof are not removed.  Compare this
   8813  1.1  joerg 	      # with having the same library being listed as a
   8814  1.1  joerg 	      # dependency of multiple other libraries: in this case,
   8815  1.1  joerg 	      # we know (pedantically, we assume) the library does not
   8816  1.1  joerg 	      # need to be listed more than once, so we keep only the
   8817  1.1  joerg 	      # last copy.  This is not always right, but it is rare
   8818  1.1  joerg 	      # enough that we require users that really mean to play
   8819  1.1  joerg 	      # such unportable linking tricks to link the library
   8820  1.1  joerg 	      # using -Wl,-lname, so that libtool does not consider it
   8821  1.1  joerg 	      # for duplicate removal.
   8822  1.1  joerg 	      case " $specialdeplibs " in
   8823  1.1  joerg 	      *" $deplib "*) new_libs="$deplib $new_libs" ;;
   8824  1.1  joerg 	      *)
   8825  1.1  joerg 		case " $new_libs " in
   8826  1.1  joerg 		*" $deplib "*) ;;
   8827  1.1  joerg 		*) new_libs="$deplib $new_libs" ;;
   8828  1.1  joerg 		esac
   8829  1.1  joerg 		;;
   8830  1.1  joerg 	      esac
   8831  1.1  joerg 	      ;;
   8832  1.1  joerg 	    esac
   8833  1.1  joerg 	  done
   8834  1.1  joerg 	  tmp_libs=
   8835  1.1  joerg 	  for deplib in $new_libs; do
   8836  1.1  joerg 	    case $deplib in
   8837  1.1  joerg 	    -L*)
   8838  1.1  joerg 	      case " $tmp_libs " in
   8839  1.1  joerg 	      *" $deplib "*) ;;
   8840  1.1  joerg 	      *) func_append tmp_libs " $deplib" ;;
   8841  1.1  joerg 	      esac
   8842  1.1  joerg 	      ;;
   8843  1.1  joerg 	    *) func_append tmp_libs " $deplib" ;;
   8844  1.1  joerg 	    esac
   8845  1.1  joerg 	  done
   8846  1.1  joerg 	  eval $var=\"$tmp_libs\"
   8847  1.1  joerg 	done # for var
   8848  1.1  joerg       fi
   8849  1.1  joerg 
   8850  1.1  joerg       # Add Sun CC postdeps if required:
   8851  1.1  joerg       test CXX = "$tagname" && {
   8852  1.1  joerg         case $host_os in
   8853  1.1  joerg         linux*)
   8854  1.1  joerg           case `$CC -V 2>&1 | sed 5q` in
   8855  1.1  joerg           *Sun\ C*) # Sun C++ 5.9
   8856  1.1  joerg             func_suncc_cstd_abi
   8857  1.1  joerg 
   8858  1.1  joerg             if test no != "$suncc_use_cstd_abi"; then
   8859  1.1  joerg               func_append postdeps ' -library=Cstd -library=Crun'
   8860  1.1  joerg             fi
   8861  1.1  joerg             ;;
   8862  1.1  joerg           esac
   8863  1.1  joerg           ;;
   8864  1.1  joerg 
   8865  1.1  joerg         solaris*)
   8866  1.1  joerg           func_cc_basename "$CC"
   8867  1.1  joerg           case $func_cc_basename_result in
   8868  1.1  joerg           CC* | sunCC*)
   8869  1.1  joerg             func_suncc_cstd_abi
   8870  1.1  joerg 
   8871  1.1  joerg             if test no != "$suncc_use_cstd_abi"; then
   8872  1.1  joerg               func_append postdeps ' -library=Cstd -library=Crun'
   8873  1.1  joerg             fi
   8874  1.1  joerg             ;;
   8875  1.1  joerg           esac
   8876  1.1  joerg           ;;
   8877  1.1  joerg         esac
   8878  1.1  joerg       }
   8879  1.1  joerg 
   8880  1.1  joerg       # Last step: remove runtime libs from dependency_libs
   8881  1.1  joerg       # (they stay in deplibs)
   8882  1.1  joerg       tmp_libs=
   8883  1.1  joerg       for i in $dependency_libs; do
   8884  1.1  joerg 	case " $predeps $postdeps $compiler_lib_search_path " in
   8885  1.1  joerg 	*" $i "*)
   8886  1.1  joerg 	  i=
   8887  1.1  joerg 	  ;;
   8888  1.1  joerg 	esac
   8889  1.1  joerg 	if test -n "$i"; then
   8890  1.1  joerg 	  func_append tmp_libs " $i"
   8891  1.1  joerg 	fi
   8892  1.1  joerg       done
   8893  1.1  joerg       dependency_libs=$tmp_libs
   8894  1.1  joerg     done # for pass
   8895  1.1  joerg     if test prog = "$linkmode"; then
   8896  1.1  joerg       dlfiles=$newdlfiles
   8897  1.1  joerg     fi
   8898  1.1  joerg     if test prog = "$linkmode" || test lib = "$linkmode"; then
   8899  1.1  joerg       dlprefiles=$newdlprefiles
   8900  1.1  joerg     fi
   8901  1.1  joerg 
   8902  1.1  joerg     case $linkmode in
   8903  1.1  joerg     oldlib)
   8904  1.1  joerg       if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
   8905  1.1  joerg 	func_warning "'-dlopen' is ignored for archives"
   8906  1.1  joerg       fi
   8907  1.1  joerg 
   8908  1.1  joerg       case " $deplibs" in
   8909  1.1  joerg       *\ -l* | *\ -L*)
   8910  1.1  joerg 	func_warning "'-l' and '-L' are ignored for archives" ;;
   8911  1.1  joerg       esac
   8912  1.1  joerg 
   8913  1.1  joerg       test -n "$rpath" && \
   8914  1.1  joerg 	func_warning "'-rpath' is ignored for archives"
   8915  1.1  joerg 
   8916  1.1  joerg       test -n "$xrpath" && \
   8917  1.1  joerg 	func_warning "'-R' is ignored for archives"
   8918  1.1  joerg 
   8919  1.1  joerg       test -n "$vinfo" && \
   8920  1.1  joerg 	func_warning "'-version-info/-version-number' is ignored for archives"
   8921  1.1  joerg 
   8922  1.1  joerg       test -n "$release" && \
   8923  1.1  joerg 	func_warning "'-release' is ignored for archives"
   8924  1.1  joerg 
   8925  1.1  joerg       test -n "$export_symbols$export_symbols_regex" && \
   8926  1.1  joerg 	func_warning "'-export-symbols' is ignored for archives"
   8927  1.1  joerg 
   8928  1.1  joerg       # Now set the variables for building old libraries.
   8929  1.1  joerg       build_libtool_libs=no
   8930  1.1  joerg       oldlibs=$output
   8931  1.1  joerg       func_append objs "$old_deplibs"
   8932  1.1  joerg       ;;
   8933  1.1  joerg 
   8934  1.1  joerg     lib)
   8935  1.1  joerg       # Make sure we only generate libraries of the form 'libNAME.la'.
   8936  1.1  joerg       case $outputname in
   8937  1.1  joerg       lib*)
   8938  1.1  joerg 	func_stripname 'lib' '.la' "$outputname"
   8939  1.1  joerg 	name=$func_stripname_result
   8940  1.1  joerg 	eval shared_ext=\"$shrext_cmds\"
   8941  1.1  joerg 	eval libname=\"$libname_spec\"
   8942  1.1  joerg 	;;
   8943  1.1  joerg       *)
   8944  1.1  joerg 	test no = "$module" \
   8945  1.1  joerg 	  && func_fatal_help "libtool library '$output' must begin with 'lib'"
   8946  1.1  joerg 
   8947  1.1  joerg 	if test no != "$need_lib_prefix"; then
   8948  1.1  joerg 	  # Add the "lib" prefix for modules if required
   8949  1.1  joerg 	  func_stripname '' '.la' "$outputname"
   8950  1.1  joerg 	  name=$func_stripname_result
   8951  1.1  joerg 	  eval shared_ext=\"$shrext_cmds\"
   8952  1.1  joerg 	  eval libname=\"$libname_spec\"
   8953  1.1  joerg 	else
   8954  1.1  joerg 	  func_stripname '' '.la' "$outputname"
   8955  1.1  joerg 	  libname=$func_stripname_result
   8956  1.1  joerg 	fi
   8957  1.1  joerg 	;;
   8958  1.1  joerg       esac
   8959  1.1  joerg 
   8960  1.1  joerg       if test -n "$objs"; then
   8961  1.1  joerg 	if test pass_all != "$deplibs_check_method"; then
   8962  1.1  joerg 	  func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
   8963  1.1  joerg 	else
   8964  1.1  joerg 	  echo
   8965  1.1  joerg 	  $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
   8966  1.1  joerg 	  $ECHO "*** objects $objs is not portable!"
   8967  1.1  joerg 	  func_append libobjs " $objs"
   8968  1.1  joerg 	fi
   8969  1.1  joerg       fi
   8970  1.1  joerg 
   8971  1.1  joerg       test no = "$dlself" \
   8972  1.1  joerg 	|| func_warning "'-dlopen self' is ignored for libtool libraries"
   8973  1.1  joerg 
   8974  1.1  joerg       set dummy $rpath
   8975  1.1  joerg       shift
   8976  1.1  joerg       test 1 -lt "$#" \
   8977  1.1  joerg 	&& func_warning "ignoring multiple '-rpath's for a libtool library"
   8978  1.1  joerg 
   8979  1.1  joerg       install_libdir=$1
   8980  1.1  joerg 
   8981  1.1  joerg       oldlibs=
   8982  1.1  joerg       if test -z "$rpath"; then
   8983  1.1  joerg 	if test yes = "$build_libtool_libs"; then
   8984  1.1  joerg 	  # Building a libtool convenience library.
   8985  1.1  joerg 	  # Some compilers have problems with a '.al' extension so
   8986  1.1  joerg 	  # convenience libraries should have the same extension an
   8987  1.1  joerg 	  # archive normally would.
   8988  1.1  joerg 	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
   8989  1.1  joerg 	  build_libtool_libs=convenience
   8990  1.1  joerg 	  build_old_libs=yes
   8991  1.1  joerg 	fi
   8992  1.1  joerg 
   8993  1.1  joerg 	test -n "$vinfo" && \
   8994  1.1  joerg 	  func_warning "'-version-info/-version-number' is ignored for convenience libraries"
   8995  1.1  joerg 
   8996  1.1  joerg 	test -n "$release" && \
   8997  1.1  joerg 	  func_warning "'-release' is ignored for convenience libraries"
   8998  1.1  joerg       else
   8999  1.1  joerg 
   9000  1.1  joerg 	# Parse the version information argument.
   9001  1.1  joerg 	save_ifs=$IFS; IFS=:
   9002  1.1  joerg 	set dummy $vinfo 0 0 0
   9003  1.1  joerg 	shift
   9004  1.1  joerg 	IFS=$save_ifs
   9005  1.1  joerg 
   9006  1.1  joerg 	test -n "$7" && \
   9007  1.1  joerg 	  func_fatal_help "too many parameters to '-version-info'"
   9008  1.1  joerg 
   9009  1.1  joerg 	# convert absolute version numbers to libtool ages
   9010  1.1  joerg 	# this retains compatibility with .la files and attempts
   9011  1.1  joerg 	# to make the code below a bit more comprehensible
   9012  1.1  joerg 
   9013  1.1  joerg 	case $vinfo_number in
   9014  1.1  joerg 	yes)
   9015  1.1  joerg 	  number_major=$1
   9016  1.1  joerg 	  number_minor=$2
   9017  1.1  joerg 	  number_revision=$3
   9018  1.1  joerg 	  #
   9019  1.1  joerg 	  # There are really only two kinds -- those that
   9020  1.1  joerg 	  # use the current revision as the major version
   9021  1.1  joerg 	  # and those that subtract age and use age as
   9022  1.1  joerg 	  # a minor version.  But, then there is irix
   9023  1.1  joerg 	  # that has an extra 1 added just for fun
   9024  1.1  joerg 	  #
   9025  1.1  joerg 	  case $version_type in
   9026  1.1  joerg 	  # correct linux to gnu/linux during the next big refactor
   9027  1.1  joerg 	  darwin|freebsd-elf|linux|osf|windows|none)
   9028  1.1  joerg 	    func_arith $number_major + $number_minor
   9029  1.1  joerg 	    current=$func_arith_result
   9030  1.1  joerg 	    age=$number_minor
   9031  1.1  joerg 	    revision=$number_revision
   9032  1.1  joerg 	    ;;
   9033  1.1  joerg 	  freebsd-aout|qnx|sunos)
   9034  1.1  joerg 	    current=$number_major
   9035  1.1  joerg 	    revision=$number_minor
   9036  1.1  joerg 	    age=0
   9037  1.1  joerg 	    ;;
   9038  1.1  joerg 	  irix|nonstopux)
   9039  1.1  joerg 	    func_arith $number_major + $number_minor
   9040  1.1  joerg 	    current=$func_arith_result
   9041  1.1  joerg 	    age=$number_minor
   9042  1.1  joerg 	    revision=$number_minor
   9043  1.1  joerg 	    lt_irix_increment=no
   9044  1.1  joerg 	    ;;
   9045  1.1  joerg 	  esac
   9046  1.1  joerg 	  ;;
   9047  1.1  joerg 	no)
   9048  1.1  joerg 	  current=$1
   9049  1.1  joerg 	  revision=$2
   9050  1.1  joerg 	  age=$3
   9051  1.1  joerg 	  ;;
   9052  1.1  joerg 	esac
   9053  1.1  joerg 
   9054  1.1  joerg 	# Check that each of the things are valid numbers.
   9055  1.1  joerg 	case $current in
   9056  1.1  joerg 	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]) ;;
   9057  1.1  joerg 	*)
   9058  1.1  joerg 	  func_error "CURRENT '$current' must be a nonnegative integer"
   9059  1.1  joerg 	  func_fatal_error "'$vinfo' is not valid version information"
   9060  1.1  joerg 	  ;;
   9061  1.1  joerg 	esac
   9062  1.1  joerg 
   9063  1.1  joerg 	case $revision in
   9064  1.1  joerg 	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]) ;;
   9065  1.1  joerg 	*)
   9066  1.1  joerg 	  func_error "REVISION '$revision' must be a nonnegative integer"
   9067  1.1  joerg 	  func_fatal_error "'$vinfo' is not valid version information"
   9068  1.1  joerg 	  ;;
   9069  1.1  joerg 	esac
   9070  1.1  joerg 
   9071  1.1  joerg 	case $age in
   9072  1.1  joerg 	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]) ;;
   9073  1.1  joerg 	*)
   9074  1.1  joerg 	  func_error "AGE '$age' must be a nonnegative integer"
   9075  1.1  joerg 	  func_fatal_error "'$vinfo' is not valid version information"
   9076  1.1  joerg 	  ;;
   9077  1.1  joerg 	esac
   9078  1.1  joerg 
   9079  1.1  joerg 	if test "$age" -gt "$current"; then
   9080  1.1  joerg 	  func_error "AGE '$age' is greater than the current interface number '$current'"
   9081  1.1  joerg 	  func_fatal_error "'$vinfo' is not valid version information"
   9082  1.1  joerg 	fi
   9083  1.1  joerg 
   9084  1.1  joerg 	# Calculate the version variables.
   9085  1.1  joerg 	major=
   9086  1.1  joerg 	versuffix=
   9087  1.1  joerg 	verstring=
   9088  1.1  joerg 	case $version_type in
   9089  1.1  joerg 	none) ;;
   9090  1.1  joerg 
   9091  1.1  joerg 	darwin)
   9092  1.1  joerg 	  # Like Linux, but with the current version available in
   9093  1.1  joerg 	  # verstring for coding it into the library header
   9094  1.1  joerg 	  func_arith $current - $age
   9095  1.1  joerg 	  major=.$func_arith_result
   9096  1.1  joerg 	  versuffix=$major.$age.$revision
   9097  1.1  joerg 	  # Darwin ld doesn't like 0 for these options...
   9098  1.1  joerg 	  func_arith $current + 1
   9099  1.1  joerg 	  minor_current=$func_arith_result
   9100  1.1  joerg 	  xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
   9101  1.1  joerg 	  verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
   9102  1.1  joerg           # On Darwin other compilers
   9103  1.1  joerg           case $CC in
   9104  1.1  joerg               nagfor*)
   9105  1.1  joerg                   verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
   9106  1.1  joerg                   ;;
   9107  1.1  joerg               *)
   9108  1.1  joerg                   verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
   9109  1.1  joerg                   ;;
   9110  1.1  joerg           esac
   9111  1.1  joerg 	  ;;
   9112  1.1  joerg 
   9113  1.1  joerg 	freebsd-aout)
   9114  1.1  joerg 	  major=.$current
   9115  1.1  joerg 	  versuffix=.$current.$revision
   9116  1.1  joerg 	  ;;
   9117  1.1  joerg 
   9118  1.1  joerg 	freebsd-elf)
   9119  1.1  joerg 	  func_arith $current - $age
   9120  1.1  joerg 	  major=.$func_arith_result
   9121  1.1  joerg 	  versuffix=$major.$age.$revision
   9122  1.1  joerg 	  ;;
   9123  1.1  joerg 
   9124  1.1  joerg 	irix | nonstopux)
   9125  1.1  joerg 	  if test no = "$lt_irix_increment"; then
   9126  1.1  joerg 	    func_arith $current - $age
   9127  1.1  joerg 	  else
   9128  1.1  joerg 	    func_arith $current - $age + 1
   9129  1.1  joerg 	  fi
   9130  1.1  joerg 	  major=$func_arith_result
   9131  1.1  joerg 
   9132  1.1  joerg 	  case $version_type in
   9133  1.1  joerg 	    nonstopux) verstring_prefix=nonstopux ;;
   9134  1.1  joerg 	    *)         verstring_prefix=sgi ;;
   9135  1.1  joerg 	  esac
   9136  1.1  joerg 	  verstring=$verstring_prefix$major.$revision
   9137  1.1  joerg 
   9138  1.1  joerg 	  # Add in all the interfaces that we are compatible with.
   9139  1.1  joerg 	  loop=$revision
   9140  1.1  joerg 	  while test 0 -ne "$loop"; do
   9141  1.1  joerg 	    func_arith $revision - $loop
   9142  1.1  joerg 	    iface=$func_arith_result
   9143  1.1  joerg 	    func_arith $loop - 1
   9144  1.1  joerg 	    loop=$func_arith_result
   9145  1.1  joerg 	    verstring=$verstring_prefix$major.$iface:$verstring
   9146  1.1  joerg 	  done
   9147  1.1  joerg 
   9148  1.1  joerg 	  # Before this point, $major must not contain '.'.
   9149  1.1  joerg 	  major=.$major
   9150  1.1  joerg 	  versuffix=$major.$revision
   9151  1.1  joerg 	  ;;
   9152  1.1  joerg 
   9153  1.1  joerg 	linux) # correct to gnu/linux during the next big refactor
   9154  1.1  joerg 	  func_arith $current - $age
   9155  1.1  joerg 	  major=.$func_arith_result
   9156  1.1  joerg 	  versuffix=$major.$age.$revision
   9157  1.1  joerg 	  ;;
   9158  1.1  joerg 
   9159  1.1  joerg 	osf)
   9160  1.1  joerg 	  func_arith $current - $age
   9161  1.1  joerg 	  major=.$func_arith_result
   9162  1.1  joerg 	  versuffix=.$current.$age.$revision
   9163  1.1  joerg 	  verstring=$current.$age.$revision
   9164  1.1  joerg 
   9165  1.1  joerg 	  # Add in all the interfaces that we are compatible with.
   9166  1.1  joerg 	  loop=$age
   9167  1.1  joerg 	  while test 0 -ne "$loop"; do
   9168  1.1  joerg 	    func_arith $current - $loop
   9169  1.1  joerg 	    iface=$func_arith_result
   9170  1.1  joerg 	    func_arith $loop - 1
   9171  1.1  joerg 	    loop=$func_arith_result
   9172  1.1  joerg 	    verstring=$verstring:$iface.0
   9173  1.1  joerg 	  done
   9174  1.1  joerg 
   9175  1.1  joerg 	  # Make executables depend on our current version.
   9176  1.1  joerg 	  func_append verstring ":$current.0"
   9177  1.1  joerg 	  ;;
   9178  1.1  joerg 
   9179  1.1  joerg 	qnx)
   9180  1.1  joerg 	  major=.$current
   9181  1.1  joerg 	  versuffix=.$current
   9182  1.1  joerg 	  ;;
   9183  1.1  joerg 
   9184  1.1  joerg 	sco)
   9185  1.1  joerg 	  major=.$current
   9186  1.1  joerg 	  versuffix=.$current
   9187  1.1  joerg 	  ;;
   9188  1.1  joerg 
   9189  1.1  joerg 	sunos)
   9190  1.1  joerg 	  major=.$current
   9191  1.1  joerg 	  versuffix=.$current.$revision
   9192  1.1  joerg 	  ;;
   9193  1.1  joerg 
   9194  1.1  joerg 	windows)
   9195  1.1  joerg 	  # Use '-' rather than '.', since we only want one
   9196  1.1  joerg 	  # extension on DOS 8.3 file systems.
   9197  1.1  joerg 	  func_arith $current - $age
   9198  1.1  joerg 	  major=$func_arith_result
   9199  1.1  joerg 	  versuffix=-$major
   9200  1.1  joerg 	  ;;
   9201  1.1  joerg 
   9202  1.1  joerg 	*)
   9203  1.1  joerg 	  func_fatal_configuration "unknown library version type '$version_type'"
   9204  1.1  joerg 	  ;;
   9205  1.1  joerg 	esac
   9206  1.1  joerg 
   9207  1.1  joerg 	# Clear the version info if we defaulted, and they specified a release.
   9208  1.1  joerg 	if test -z "$vinfo" && test -n "$release"; then
   9209  1.1  joerg 	  major=
   9210  1.1  joerg 	  case $version_type in
   9211  1.1  joerg 	  darwin)
   9212  1.1  joerg 	    # we can't check for "0.0" in archive_cmds due to quoting
   9213  1.1  joerg 	    # problems, so we reset it completely
   9214  1.1  joerg 	    verstring=
   9215  1.1  joerg 	    ;;
   9216  1.1  joerg 	  *)
   9217  1.1  joerg 	    verstring=0.0
   9218  1.1  joerg 	    ;;
   9219  1.1  joerg 	  esac
   9220  1.1  joerg 	  if test no = "$need_version"; then
   9221  1.1  joerg 	    versuffix=
   9222  1.1  joerg 	  else
   9223  1.1  joerg 	    versuffix=.0.0
   9224  1.1  joerg 	  fi
   9225  1.1  joerg 	fi
   9226  1.1  joerg 
   9227  1.1  joerg 	# Remove version info from name if versioning should be avoided
   9228  1.1  joerg 	if test yes,no = "$avoid_version,$need_version"; then
   9229  1.1  joerg 	  major=
   9230  1.1  joerg 	  versuffix=
   9231  1.1  joerg 	  verstring=
   9232  1.1  joerg 	fi
   9233  1.1  joerg 
   9234  1.1  joerg 	# Check to see if the archive will have undefined symbols.
   9235  1.1  joerg 	if test yes = "$allow_undefined"; then
   9236  1.1  joerg 	  if test unsupported = "$allow_undefined_flag"; then
   9237  1.1  joerg 	    if test yes = "$build_old_libs"; then
   9238  1.1  joerg 	      func_warning "undefined symbols not allowed in $host shared libraries; building static only"
   9239  1.1  joerg 	      build_libtool_libs=no
   9240  1.1  joerg 	    else
   9241  1.1  joerg 	      func_fatal_error "can't build $host shared library unless -no-undefined is specified"
   9242  1.1  joerg 	    fi
   9243  1.1  joerg 	  fi
   9244  1.1  joerg 	else
   9245  1.1  joerg 	  # Don't allow undefined symbols.
   9246  1.1  joerg 	  allow_undefined_flag=$no_undefined_flag
   9247  1.1  joerg 	fi
   9248  1.1  joerg 
   9249  1.1  joerg       fi
   9250  1.1  joerg 
   9251  1.1  joerg       func_generate_dlsyms "$libname" "$libname" :
   9252  1.1  joerg       func_append libobjs " $symfileobj"
   9253  1.1  joerg       test " " = "$libobjs" && libobjs=
   9254  1.1  joerg 
   9255  1.1  joerg       if test relink != "$opt_mode"; then
   9256  1.1  joerg 	# Remove our outputs, but don't remove object files since they
   9257  1.1  joerg 	# may have been created when compiling PIC objects.
   9258  1.1  joerg 	removelist=
   9259  1.1  joerg 	tempremovelist=`$ECHO "$output_objdir/*"`
   9260  1.1  joerg 	for p in $tempremovelist; do
   9261  1.1  joerg 	  case $p in
   9262  1.1  joerg 	    *.$objext | *.gcno)
   9263  1.1  joerg 	       ;;
   9264  1.1  joerg 	    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
   9265  1.1  joerg 	       if test -n "$precious_files_regex"; then
   9266  1.1  joerg 		 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
   9267  1.1  joerg 		 then
   9268  1.1  joerg 		   continue
   9269  1.1  joerg 		 fi
   9270  1.1  joerg 	       fi
   9271  1.1  joerg 	       func_append removelist " $p"
   9272  1.1  joerg 	       ;;
   9273  1.1  joerg 	    *) ;;
   9274  1.1  joerg 	  esac
   9275  1.1  joerg 	done
   9276  1.1  joerg 	test -n "$removelist" && \
   9277  1.1  joerg 	  func_show_eval "${RM}r \$removelist"
   9278  1.1  joerg       fi
   9279  1.1  joerg 
   9280  1.1  joerg       # Now set the variables for building old libraries.
   9281  1.1  joerg       if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
   9282  1.1  joerg 	func_append oldlibs " $output_objdir/$libname.$libext"
   9283  1.1  joerg 
   9284  1.1  joerg 	# Transform .lo files to .o files.
   9285  1.1  joerg 	oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
   9286  1.1  joerg       fi
   9287  1.1  joerg 
   9288  1.1  joerg       # Eliminate all temporary directories.
   9289  1.1  joerg       #for path in $notinst_path; do
   9290  1.1  joerg       #	lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
   9291  1.1  joerg       #	deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
   9292  1.1  joerg       #	dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
   9293  1.1  joerg       #done
   9294  1.1  joerg 
   9295  1.1  joerg       if test -n "$xrpath"; then
   9296  1.1  joerg 	# If the user specified any rpath flags, then add them.
   9297  1.1  joerg 	temp_xrpath=
   9298  1.1  joerg 	for libdir in $xrpath; do
   9299  1.1  joerg 	  func_replace_sysroot "$libdir"
   9300  1.1  joerg 	  func_append temp_xrpath " -R$func_replace_sysroot_result"
   9301  1.1  joerg 	  case "$finalize_rpath " in
   9302  1.1  joerg 	  *" $libdir "*) ;;
   9303  1.1  joerg 	  *) func_append finalize_rpath " $libdir" ;;
   9304  1.1  joerg 	  esac
   9305  1.1  joerg 	done
   9306  1.1  joerg 	if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
   9307  1.1  joerg 	  dependency_libs="$temp_xrpath $dependency_libs"
   9308  1.1  joerg 	fi
   9309  1.1  joerg       fi
   9310  1.1  joerg 
   9311  1.1  joerg       # Make sure dlfiles contains only unique files that won't be dlpreopened
   9312  1.1  joerg       old_dlfiles=$dlfiles
   9313  1.1  joerg       dlfiles=
   9314  1.1  joerg       for lib in $old_dlfiles; do
   9315  1.1  joerg 	case " $dlprefiles $dlfiles " in
   9316  1.1  joerg 	*" $lib "*) ;;
   9317  1.1  joerg 	*) func_append dlfiles " $lib" ;;
   9318  1.1  joerg 	esac
   9319  1.1  joerg       done
   9320  1.1  joerg 
   9321  1.1  joerg       # Make sure dlprefiles contains only unique files
   9322  1.1  joerg       old_dlprefiles=$dlprefiles
   9323  1.1  joerg       dlprefiles=
   9324  1.1  joerg       for lib in $old_dlprefiles; do
   9325  1.1  joerg 	case "$dlprefiles " in
   9326  1.1  joerg 	*" $lib "*) ;;
   9327  1.1  joerg 	*) func_append dlprefiles " $lib" ;;
   9328  1.1  joerg 	esac
   9329  1.1  joerg       done
   9330  1.1  joerg 
   9331  1.1  joerg       if test yes = "$build_libtool_libs"; then
   9332  1.1  joerg 	if test -n "$rpath"; then
   9333  1.1  joerg 	  case $host in
   9334  1.1  joerg 	  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
   9335  1.1  joerg 	    # these systems don't actually have a c library (as such)!
   9336  1.1  joerg 	    ;;
   9337  1.1  joerg 	  *-*-rhapsody* | *-*-darwin1.[012])
   9338  1.1  joerg 	    # Rhapsody C library is in the System framework
   9339  1.1  joerg 	    func_append deplibs " System.ltframework"
   9340  1.1  joerg 	    ;;
   9341  1.1  joerg 	  *-*-netbsd*)
   9342  1.1  joerg 	    # Don't link with libc until the a.out ld.so is fixed.
   9343  1.1  joerg 	    ;;
   9344  1.1  joerg 	  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
   9345  1.1  joerg 	    # Do not include libc due to us having libc/libc_r.
   9346  1.1  joerg 	    ;;
   9347  1.1  joerg 	  *-*-sco3.2v5* | *-*-sco5v6*)
   9348  1.1  joerg 	    # Causes problems with __ctype
   9349  1.1  joerg 	    ;;
   9350  1.1  joerg 	  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
   9351  1.1  joerg 	    # Compiler inserts libc in the correct place for threads to work
   9352  1.1  joerg 	    ;;
   9353  1.1  joerg 	  *)
   9354  1.1  joerg 	    # Add libc to deplibs on all other systems if necessary.
   9355  1.1  joerg 	    if test yes = "$build_libtool_need_lc"; then
   9356  1.1  joerg 	      func_append deplibs " -lc"
   9357  1.1  joerg 	    fi
   9358  1.1  joerg 	    ;;
   9359  1.1  joerg 	  esac
   9360  1.1  joerg 	fi
   9361  1.1  joerg 
   9362  1.1  joerg 	# Transform deplibs into only deplibs that can be linked in shared.
   9363  1.1  joerg 	name_save=$name
   9364  1.1  joerg 	libname_save=$libname
   9365  1.1  joerg 	release_save=$release
   9366  1.1  joerg 	versuffix_save=$versuffix
   9367  1.1  joerg 	major_save=$major
   9368  1.1  joerg 	# I'm not sure if I'm treating the release correctly.  I think
   9369  1.1  joerg 	# release should show up in the -l (ie -lgmp5) so we don't want to
   9370  1.1  joerg 	# add it in twice.  Is that correct?
   9371  1.1  joerg 	release=
   9372  1.1  joerg 	versuffix=
   9373  1.1  joerg 	major=
   9374  1.1  joerg 	newdeplibs=
   9375  1.1  joerg 	droppeddeps=no
   9376  1.1  joerg 	case $deplibs_check_method in
   9377  1.1  joerg 	pass_all)
   9378  1.1  joerg 	  # Don't check for shared/static.  Everything works.
   9379  1.1  joerg 	  # This might be a little naive.  We might want to check
   9380  1.1  joerg 	  # whether the library exists or not.  But this is on
   9381  1.1  joerg 	  # osf3 & osf4 and I'm not really sure... Just
   9382  1.1  joerg 	  # implementing what was already the behavior.
   9383  1.1  joerg 	  newdeplibs=$deplibs
   9384  1.1  joerg 	  ;;
   9385  1.1  joerg 	test_compile)
   9386  1.1  joerg 	  # This code stresses the "libraries are programs" paradigm to its
   9387  1.1  joerg 	  # limits. Maybe even breaks it.  We compile a program, linking it
   9388  1.1  joerg 	  # against the deplibs as a proxy for the library.  Then we can check
   9389  1.1  joerg 	  # whether they linked in statically or dynamically with ldd.
   9390  1.1  joerg 	  $opt_dry_run || $RM conftest.c
   9391  1.1  joerg 	  cat > conftest.c <<EOF
   9392  1.1  joerg 	  int main() { return 0; }
   9393  1.1  joerg EOF
   9394  1.1  joerg 	  $opt_dry_run || $RM conftest
   9395  1.1  joerg 	  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
   9396  1.1  joerg 	    ldd_output=`ldd conftest`
   9397  1.1  joerg 	    for i in $deplibs; do
   9398  1.1  joerg 	      case $i in
   9399  1.1  joerg 	      -l*)
   9400  1.1  joerg 		func_stripname -l '' "$i"
   9401  1.1  joerg 		name=$func_stripname_result
   9402  1.1  joerg 		if test yes = "$allow_libtool_libs_with_static_runtimes"; then
   9403  1.1  joerg 		  case " $predeps $postdeps " in
   9404  1.1  joerg 		  *" $i "*)
   9405  1.1  joerg 		    func_append newdeplibs " $i"
   9406  1.1  joerg 		    i=
   9407  1.1  joerg 		    ;;
   9408  1.1  joerg 		  esac
   9409  1.1  joerg 		fi
   9410  1.1  joerg 		if test -n "$i"; then
   9411  1.1  joerg 		  libname=`eval "\\$ECHO \"$libname_spec\""`
   9412  1.1  joerg 		  deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
   9413  1.1  joerg 		  set dummy $deplib_matches; shift
   9414  1.1  joerg 		  deplib_match=$1
   9415  1.1  joerg 		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
   9416  1.1  joerg 		    func_append newdeplibs " $i"
   9417  1.1  joerg 		  else
   9418  1.1  joerg 		    droppeddeps=yes
   9419  1.1  joerg 		    echo
   9420  1.1  joerg 		    $ECHO "*** Warning: dynamic linker does not accept needed library $i."
   9421  1.1  joerg 		    echo "*** I have the capability to make that library automatically link in when"
   9422  1.1  joerg 		    echo "*** you link to this library.  But I can only do this if you have a"
   9423  1.1  joerg 		    echo "*** shared version of the library, which I believe you do not have"
   9424  1.1  joerg 		    echo "*** because a test_compile did reveal that the linker did not use it for"
   9425  1.1  joerg 		    echo "*** its dynamic dependency list that programs get resolved with at runtime."
   9426  1.1  joerg 		  fi
   9427  1.1  joerg 		fi
   9428  1.1  joerg 		;;
   9429  1.1  joerg 	      *)
   9430  1.1  joerg 		func_append newdeplibs " $i"
   9431  1.1  joerg 		;;
   9432  1.1  joerg 	      esac
   9433  1.1  joerg 	    done
   9434  1.1  joerg 	  else
   9435  1.1  joerg 	    # Error occurred in the first compile.  Let's try to salvage
   9436  1.1  joerg 	    # the situation: Compile a separate program for each library.
   9437  1.1  joerg 	    for i in $deplibs; do
   9438  1.1  joerg 	      case $i in
   9439  1.1  joerg 	      -l*)
   9440  1.1  joerg 		func_stripname -l '' "$i"
   9441  1.1  joerg 		name=$func_stripname_result
   9442  1.1  joerg 		$opt_dry_run || $RM conftest
   9443  1.1  joerg 		if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
   9444  1.1  joerg 		  ldd_output=`ldd conftest`
   9445  1.1  joerg 		  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
   9446  1.1  joerg 		    case " $predeps $postdeps " in
   9447  1.1  joerg 		    *" $i "*)
   9448  1.1  joerg 		      func_append newdeplibs " $i"
   9449  1.1  joerg 		      i=
   9450  1.1  joerg 		      ;;
   9451  1.1  joerg 		    esac
   9452  1.1  joerg 		  fi
   9453  1.1  joerg 		  if test -n "$i"; then
   9454  1.1  joerg 		    libname=`eval "\\$ECHO \"$libname_spec\""`
   9455  1.1  joerg 		    deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
   9456  1.1  joerg 		    set dummy $deplib_matches; shift
   9457  1.1  joerg 		    deplib_match=$1
   9458  1.1  joerg 		    if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
   9459  1.1  joerg 		      func_append newdeplibs " $i"
   9460  1.1  joerg 		    else
   9461  1.1  joerg 		      droppeddeps=yes
   9462  1.1  joerg 		      echo
   9463  1.1  joerg 		      $ECHO "*** Warning: dynamic linker does not accept needed library $i."
   9464  1.1  joerg 		      echo "*** I have the capability to make that library automatically link in when"
   9465  1.1  joerg 		      echo "*** you link to this library.  But I can only do this if you have a"
   9466  1.1  joerg 		      echo "*** shared version of the library, which you do not appear to have"
   9467  1.1  joerg 		      echo "*** because a test_compile did reveal that the linker did not use this one"
   9468  1.1  joerg 		      echo "*** as a dynamic dependency that programs can get resolved with at runtime."
   9469  1.1  joerg 		    fi
   9470  1.1  joerg 		  fi
   9471  1.1  joerg 		else
   9472  1.1  joerg 		  droppeddeps=yes
   9473  1.1  joerg 		  echo
   9474  1.1  joerg 		  $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
   9475  1.1  joerg 		  echo "*** make it link in!  You will probably need to install it or some"
   9476  1.1  joerg 		  echo "*** library that it depends on before this library will be fully"
   9477  1.1  joerg 		  echo "*** functional.  Installing it before continuing would be even better."
   9478  1.1  joerg 		fi
   9479  1.1  joerg 		;;
   9480  1.1  joerg 	      *)
   9481  1.1  joerg 		func_append newdeplibs " $i"
   9482  1.1  joerg 		;;
   9483  1.1  joerg 	      esac
   9484  1.1  joerg 	    done
   9485  1.1  joerg 	  fi
   9486  1.1  joerg 	  ;;
   9487  1.1  joerg 	file_magic*)
   9488  1.1  joerg 	  set dummy $deplibs_check_method; shift
   9489  1.1  joerg 	  file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
   9490  1.1  joerg 	  for a_deplib in $deplibs; do
   9491  1.1  joerg 	    case $a_deplib in
   9492  1.1  joerg 	    -l*)
   9493  1.1  joerg 	      func_stripname -l '' "$a_deplib"
   9494  1.1  joerg 	      name=$func_stripname_result
   9495  1.1  joerg 	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
   9496  1.1  joerg 		case " $predeps $postdeps " in
   9497  1.1  joerg 		*" $a_deplib "*)
   9498  1.1  joerg 		  func_append newdeplibs " $a_deplib"
   9499  1.1  joerg 		  a_deplib=
   9500  1.1  joerg 		  ;;
   9501  1.1  joerg 		esac
   9502  1.1  joerg 	      fi
   9503  1.1  joerg 	      if test -n "$a_deplib"; then
   9504  1.1  joerg 		libname=`eval "\\$ECHO \"$libname_spec\""`
   9505  1.1  joerg 		if test -n "$file_magic_glob"; then
   9506  1.1  joerg 		  libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
   9507  1.1  joerg 		else
   9508  1.1  joerg 		  libnameglob=$libname
   9509  1.1  joerg 		fi
   9510  1.1  joerg 		test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
   9511  1.1  joerg 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
   9512  1.1  joerg 		  if test yes = "$want_nocaseglob"; then
   9513  1.1  joerg 		    shopt -s nocaseglob
   9514  1.1  joerg 		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
   9515  1.1  joerg 		    $nocaseglob
   9516  1.1  joerg 		  else
   9517  1.1  joerg 		    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
   9518  1.1  joerg 		  fi
   9519  1.1  joerg 		  for potent_lib in $potential_libs; do
   9520  1.1  joerg 		      # Follow soft links.
   9521  1.1  joerg 		      if ls -lLd "$potent_lib" 2>/dev/null |
   9522  1.1  joerg 			 $GREP " -> " >/dev/null; then
   9523  1.1  joerg 			continue
   9524  1.1  joerg 		      fi
   9525  1.1  joerg 		      # The statement above tries to avoid entering an
   9526  1.1  joerg 		      # endless loop below, in case of cyclic links.
   9527  1.1  joerg 		      # We might still enter an endless loop, since a link
   9528  1.1  joerg 		      # loop can be closed while we follow links,
   9529  1.1  joerg 		      # but so what?
   9530  1.1  joerg 		      potlib=$potent_lib
   9531  1.1  joerg 		      while test -h "$potlib" 2>/dev/null; do
   9532  1.1  joerg 			potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
   9533  1.1  joerg 			case $potliblink in
   9534  1.1  joerg 			[\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
   9535  1.1  joerg 			*) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
   9536  1.1  joerg 			esac
   9537  1.1  joerg 		      done
   9538  1.1  joerg 		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
   9539  1.1  joerg 			 $SED -e 10q |
   9540  1.1  joerg 			 $EGREP "$file_magic_regex" > /dev/null; then
   9541  1.1  joerg 			func_append newdeplibs " $a_deplib"
   9542  1.1  joerg 			a_deplib=
   9543  1.1  joerg 			break 2
   9544  1.1  joerg 		      fi
   9545  1.1  joerg 		  done
   9546  1.1  joerg 		done
   9547  1.1  joerg 	      fi
   9548  1.1  joerg 	      if test -n "$a_deplib"; then
   9549  1.1  joerg 		droppeddeps=yes
   9550  1.1  joerg 		echo
   9551  1.1  joerg 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
   9552  1.1  joerg 		echo "*** I have the capability to make that library automatically link in when"
   9553  1.1  joerg 		echo "*** you link to this library.  But I can only do this if you have a"
   9554  1.1  joerg 		echo "*** shared version of the library, which you do not appear to have"
   9555  1.1  joerg 		echo "*** because I did check the linker path looking for a file starting"
   9556  1.1  joerg 		if test -z "$potlib"; then
   9557  1.1  joerg 		  $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
   9558  1.1  joerg 		else
   9559  1.1  joerg 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
   9560  1.1  joerg 		  $ECHO "*** using a file magic. Last file checked: $potlib"
   9561  1.1  joerg 		fi
   9562  1.1  joerg 	      fi
   9563  1.1  joerg 	      ;;
   9564  1.1  joerg 	    *)
   9565  1.1  joerg 	      # Add a -L argument.
   9566  1.1  joerg 	      func_append newdeplibs " $a_deplib"
   9567  1.1  joerg 	      ;;
   9568  1.1  joerg 	    esac
   9569  1.1  joerg 	  done # Gone through all deplibs.
   9570  1.1  joerg 	  ;;
   9571  1.1  joerg 	match_pattern*)
   9572  1.1  joerg 	  set dummy $deplibs_check_method; shift
   9573  1.1  joerg 	  match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
   9574  1.1  joerg 	  for a_deplib in $deplibs; do
   9575  1.1  joerg 	    case $a_deplib in
   9576  1.1  joerg 	    -l*)
   9577  1.1  joerg 	      func_stripname -l '' "$a_deplib"
   9578  1.1  joerg 	      name=$func_stripname_result
   9579  1.1  joerg 	      if test yes = "$allow_libtool_libs_with_static_runtimes"; then
   9580  1.1  joerg 		case " $predeps $postdeps " in
   9581  1.1  joerg 		*" $a_deplib "*)
   9582  1.1  joerg 		  func_append newdeplibs " $a_deplib"
   9583  1.1  joerg 		  a_deplib=
   9584  1.1  joerg 		  ;;
   9585  1.1  joerg 		esac
   9586  1.1  joerg 	      fi
   9587  1.1  joerg 	      if test -n "$a_deplib"; then
   9588  1.1  joerg 		libname=`eval "\\$ECHO \"$libname_spec\""`
   9589  1.1  joerg 		for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
   9590  1.1  joerg 		  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
   9591  1.1  joerg 		  for potent_lib in $potential_libs; do
   9592  1.1  joerg 		    potlib=$potent_lib # see symlink-check above in file_magic test
   9593  1.1  joerg 		    if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
   9594  1.1  joerg 		       $EGREP "$match_pattern_regex" > /dev/null; then
   9595  1.1  joerg 		      func_append newdeplibs " $a_deplib"
   9596  1.1  joerg 		      a_deplib=
   9597  1.1  joerg 		      break 2
   9598  1.1  joerg 		    fi
   9599  1.1  joerg 		  done
   9600  1.1  joerg 		done
   9601  1.1  joerg 	      fi
   9602  1.1  joerg 	      if test -n "$a_deplib"; then
   9603  1.1  joerg 		droppeddeps=yes
   9604  1.1  joerg 		echo
   9605  1.1  joerg 		$ECHO "*** Warning: linker path does not have real file for library $a_deplib."
   9606  1.1  joerg 		echo "*** I have the capability to make that library automatically link in when"
   9607  1.1  joerg 		echo "*** you link to this library.  But I can only do this if you have a"
   9608  1.1  joerg 		echo "*** shared version of the library, which you do not appear to have"
   9609  1.1  joerg 		echo "*** because I did check the linker path looking for a file starting"
   9610  1.1  joerg 		if test -z "$potlib"; then
   9611  1.1  joerg 		  $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
   9612  1.1  joerg 		else
   9613  1.1  joerg 		  $ECHO "*** with $libname and none of the candidates passed a file format test"
   9614  1.1  joerg 		  $ECHO "*** using a regex pattern. Last file checked: $potlib"
   9615  1.1  joerg 		fi
   9616  1.1  joerg 	      fi
   9617  1.1  joerg 	      ;;
   9618  1.1  joerg 	    *)
   9619  1.1  joerg 	      # Add a -L argument.
   9620  1.1  joerg 	      func_append newdeplibs " $a_deplib"
   9621  1.1  joerg 	      ;;
   9622  1.1  joerg 	    esac
   9623  1.1  joerg 	  done # Gone through all deplibs.
   9624  1.1  joerg 	  ;;
   9625  1.1  joerg 	none | unknown | *)
   9626  1.1  joerg 	  newdeplibs=
   9627  1.1  joerg 	  tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
   9628  1.1  joerg 	  if test yes = "$allow_libtool_libs_with_static_runtimes"; then
   9629  1.1  joerg 	    for i in $predeps $postdeps; do
   9630  1.1  joerg 	      # can't use Xsed below, because $i might contain '/'
   9631  1.1  joerg 	      tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
   9632  1.1  joerg 	    done
   9633  1.1  joerg 	  fi
   9634  1.1  joerg 	  case $tmp_deplibs in
   9635  1.1  joerg 	  *[!\	\ ]*)
   9636  1.1  joerg 	    echo
   9637  1.1  joerg 	    if test none = "$deplibs_check_method"; then
   9638  1.1  joerg 	      echo "*** Warning: inter-library dependencies are not supported in this platform."
   9639  1.1  joerg 	    else
   9640  1.1  joerg 	      echo "*** Warning: inter-library dependencies are not known to be supported."
   9641  1.1  joerg 	    fi
   9642  1.1  joerg 	    echo "*** All declared inter-library dependencies are being dropped."
   9643  1.1  joerg 	    droppeddeps=yes
   9644  1.1  joerg 	    ;;
   9645  1.1  joerg 	  esac
   9646  1.1  joerg 	  ;;
   9647  1.1  joerg 	esac
   9648  1.1  joerg 	versuffix=$versuffix_save
   9649  1.1  joerg 	major=$major_save
   9650  1.1  joerg 	release=$release_save
   9651  1.1  joerg 	libname=$libname_save
   9652  1.1  joerg 	name=$name_save
   9653  1.1  joerg 
   9654  1.1  joerg 	case $host in
   9655  1.1  joerg 	*-*-rhapsody* | *-*-darwin1.[012])
   9656  1.1  joerg 	  # On Rhapsody replace the C library with the System framework
   9657  1.1  joerg 	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
   9658  1.1  joerg 	  ;;
   9659  1.1  joerg 	esac
   9660  1.1  joerg 
   9661  1.1  joerg 	if test yes = "$droppeddeps"; then
   9662  1.1  joerg 	  if test yes = "$module"; then
   9663  1.1  joerg 	    echo
   9664  1.1  joerg 	    echo "*** Warning: libtool could not satisfy all declared inter-library"
   9665  1.1  joerg 	    $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
   9666  1.1  joerg 	    echo "*** a static module, that should work as long as the dlopening"
   9667  1.1  joerg 	    echo "*** application is linked with the -dlopen flag."
   9668  1.1  joerg 	    if test -z "$global_symbol_pipe"; then
   9669  1.1  joerg 	      echo
   9670  1.1  joerg 	      echo "*** However, this would only work if libtool was able to extract symbol"
   9671  1.1  joerg 	      echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
   9672  1.1  joerg 	      echo "*** not find such a program.  So, this module is probably useless."
   9673  1.1  joerg 	      echo "*** 'nm' from GNU binutils and a full rebuild may help."
   9674  1.1  joerg 	    fi
   9675  1.1  joerg 	    if test no = "$build_old_libs"; then
   9676  1.1  joerg 	      oldlibs=$output_objdir/$libname.$libext
   9677  1.1  joerg 	      build_libtool_libs=module
   9678  1.1  joerg 	      build_old_libs=yes
   9679  1.1  joerg 	    else
   9680  1.1  joerg 	      build_libtool_libs=no
   9681  1.1  joerg 	    fi
   9682  1.1  joerg 	  else
   9683  1.1  joerg 	    echo "*** The inter-library dependencies that have been dropped here will be"
   9684  1.1  joerg 	    echo "*** automatically added whenever a program is linked with this library"
   9685  1.1  joerg 	    echo "*** or is declared to -dlopen it."
   9686  1.1  joerg 
   9687  1.1  joerg 	    if test no = "$allow_undefined"; then
   9688  1.1  joerg 	      echo
   9689  1.1  joerg 	      echo "*** Since this library must not contain undefined symbols,"
   9690  1.1  joerg 	      echo "*** because either the platform does not support them or"
   9691  1.1  joerg 	      echo "*** it was explicitly requested with -no-undefined,"
   9692  1.1  joerg 	      echo "*** libtool will only create a static version of it."
   9693  1.1  joerg 	      if test no = "$build_old_libs"; then
   9694  1.1  joerg 		oldlibs=$output_objdir/$libname.$libext
   9695  1.1  joerg 		build_libtool_libs=module
   9696  1.1  joerg 		build_old_libs=yes
   9697  1.1  joerg 	      else
   9698  1.1  joerg 		build_libtool_libs=no
   9699  1.1  joerg 	      fi
   9700  1.1  joerg 	    fi
   9701  1.1  joerg 	  fi
   9702  1.1  joerg 	fi
   9703  1.1  joerg 	# Done checking deplibs!
   9704  1.1  joerg 	deplibs=$newdeplibs
   9705  1.1  joerg       fi
   9706  1.1  joerg       # Time to change all our "foo.ltframework" stuff back to "-framework foo"
   9707  1.1  joerg       case $host in
   9708  1.1  joerg 	*-*-darwin*)
   9709  1.1  joerg 	  newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
   9710  1.1  joerg 	  new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
   9711  1.1  joerg 	  deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
   9712  1.1  joerg 	  ;;
   9713  1.1  joerg       esac
   9714  1.1  joerg 
   9715  1.1  joerg       # move library search paths that coincide with paths to not yet
   9716  1.1  joerg       # installed libraries to the beginning of the library search list
   9717  1.1  joerg       new_libs=
   9718  1.1  joerg       for path in $notinst_path; do
   9719  1.1  joerg 	case " $new_libs " in
   9720  1.1  joerg 	*" -L$path/$objdir "*) ;;
   9721  1.1  joerg 	*)
   9722  1.1  joerg 	  case " $deplibs " in
   9723  1.1  joerg 	  *" -L$path/$objdir "*)
   9724  1.1  joerg 	    func_append new_libs " -L$path/$objdir" ;;
   9725  1.1  joerg 	  esac
   9726  1.1  joerg 	  ;;
   9727  1.1  joerg 	esac
   9728  1.1  joerg       done
   9729  1.1  joerg       for deplib in $deplibs; do
   9730  1.1  joerg 	case $deplib in
   9731  1.1  joerg 	-L*)
   9732  1.1  joerg 	  case " $new_libs " in
   9733  1.1  joerg 	  *" $deplib "*) ;;
   9734  1.1  joerg 	  *) func_append new_libs " $deplib" ;;
   9735  1.1  joerg 	  esac
   9736  1.1  joerg 	  ;;
   9737  1.1  joerg 	*) func_append new_libs " $deplib" ;;
   9738  1.1  joerg 	esac
   9739  1.1  joerg       done
   9740  1.1  joerg       deplibs=$new_libs
   9741  1.1  joerg 
   9742  1.1  joerg       # All the library-specific variables (install_libdir is set above).
   9743  1.1  joerg       library_names=
   9744  1.1  joerg       old_library=
   9745  1.1  joerg       dlname=
   9746  1.1  joerg 
   9747  1.1  joerg       # Test again, we may have decided not to build it any more
   9748  1.1  joerg       if test yes = "$build_libtool_libs"; then
   9749  1.1  joerg 	# Remove $wl instances when linking with ld.
   9750  1.1  joerg 	# FIXME: should test the right _cmds variable.
   9751  1.1  joerg 	case $archive_cmds in
   9752  1.1  joerg 	  *\$LD\ *) wl= ;;
   9753  1.1  joerg         esac
   9754  1.1  joerg 	if test yes = "$hardcode_into_libs"; then
   9755  1.1  joerg 	  # Hardcode the library paths
   9756  1.1  joerg 	  hardcode_libdirs=
   9757  1.1  joerg 	  dep_rpath=
   9758  1.1  joerg 	  rpath=$finalize_rpath
   9759  1.1  joerg 	  test relink = "$opt_mode" || rpath=$compile_rpath$rpath
   9760  1.1  joerg 	  for libdir in $rpath; do
   9761  1.1  joerg 	    if test -n "$hardcode_libdir_flag_spec"; then
   9762  1.1  joerg 	      if test -n "$hardcode_libdir_separator"; then
   9763  1.1  joerg 		func_replace_sysroot "$libdir"
   9764  1.1  joerg 		libdir=$func_replace_sysroot_result
   9765  1.1  joerg 		if test -z "$hardcode_libdirs"; then
   9766  1.1  joerg 		  hardcode_libdirs=$libdir
   9767  1.1  joerg 		else
   9768  1.1  joerg 		  # Just accumulate the unique libdirs.
   9769  1.1  joerg 		  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
   9770  1.1  joerg 		  *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
   9771  1.1  joerg 		    ;;
   9772  1.1  joerg 		  *)
   9773  1.1  joerg 		    func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
   9774  1.1  joerg 		    ;;
   9775  1.1  joerg 		  esac
   9776  1.1  joerg 		fi
   9777  1.1  joerg 	      else
   9778  1.1  joerg 		eval flag=\"$hardcode_libdir_flag_spec\"
   9779  1.1  joerg 		func_append dep_rpath " $flag"
   9780  1.1  joerg 	      fi
   9781  1.1  joerg 	    elif test -n "$runpath_var"; then
   9782  1.1  joerg 	      case "$perm_rpath " in
   9783  1.1  joerg 	      *" $libdir "*) ;;
   9784  1.1  joerg 	      *) func_append perm_rpath " $libdir" ;;
   9785  1.1  joerg 	      esac
   9786  1.1  joerg 	    fi
   9787  1.1  joerg 	  done
   9788  1.1  joerg 	  # Substitute the hardcoded libdirs into the rpath.
   9789  1.1  joerg 	  if test -n "$hardcode_libdir_separator" &&
   9790  1.1  joerg 	     test -n "$hardcode_libdirs"; then
   9791  1.1  joerg 	    libdir=$hardcode_libdirs
   9792  1.1  joerg 	    eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
   9793  1.1  joerg 	  fi
   9794  1.1  joerg 	  if test -n "$runpath_var" && test -n "$perm_rpath"; then
   9795  1.1  joerg 	    # We should set the runpath_var.
   9796  1.1  joerg 	    rpath=
   9797  1.1  joerg 	    for dir in $perm_rpath; do
   9798  1.1  joerg 	      func_append rpath "$dir:"
   9799  1.1  joerg 	    done
   9800  1.1  joerg 	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
   9801  1.1  joerg 	  fi
   9802  1.1  joerg 	  test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
   9803  1.1  joerg 	fi
   9804  1.1  joerg 
   9805  1.1  joerg 	shlibpath=$finalize_shlibpath
   9806  1.1  joerg 	test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
   9807  1.1  joerg 	if test -n "$shlibpath"; then
   9808  1.1  joerg 	  eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
   9809  1.1  joerg 	fi
   9810  1.1  joerg 
   9811  1.1  joerg 	# Get the real and link names of the library.
   9812  1.1  joerg 	eval shared_ext=\"$shrext_cmds\"
   9813  1.1  joerg 	eval library_names=\"$library_names_spec\"
   9814  1.1  joerg 	set dummy $library_names
   9815  1.1  joerg 	shift
   9816  1.1  joerg 	realname=$1
   9817  1.1  joerg 	shift
   9818  1.1  joerg 
   9819  1.1  joerg 	if test -n "$soname_spec"; then
   9820  1.1  joerg 	  eval soname=\"$soname_spec\"
   9821  1.1  joerg 	else
   9822  1.1  joerg 	  soname=$realname
   9823  1.1  joerg 	fi
   9824  1.1  joerg 	if test -z "$dlname"; then
   9825  1.1  joerg 	  dlname=$soname
   9826  1.1  joerg 	fi
   9827  1.1  joerg 
   9828  1.1  joerg 	lib=$output_objdir/$realname
   9829  1.1  joerg 	linknames=
   9830  1.1  joerg 	for link
   9831  1.1  joerg 	do
   9832  1.1  joerg 	  func_append linknames " $link"
   9833  1.1  joerg 	done
   9834  1.1  joerg 
   9835  1.1  joerg 	# Use standard objects if they are pic
   9836  1.1  joerg 	test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
   9837  1.1  joerg 	test "X$libobjs" = "X " && libobjs=
   9838  1.1  joerg 
   9839  1.1  joerg 	delfiles=
   9840  1.1  joerg 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
   9841  1.1  joerg 	  $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
   9842  1.1  joerg 	  export_symbols=$output_objdir/$libname.uexp
   9843  1.1  joerg 	  func_append delfiles " $export_symbols"
   9844  1.1  joerg 	fi
   9845  1.1  joerg 
   9846  1.1  joerg 	orig_export_symbols=
   9847  1.1  joerg 	case $host_os in
   9848  1.1  joerg 	cygwin* | mingw* | cegcc*)
   9849  1.1  joerg 	  if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
   9850  1.1  joerg 	    # exporting using user supplied symfile
   9851  1.1  joerg 	    func_dll_def_p "$export_symbols" || {
   9852  1.1  joerg 	      # and it's NOT already a .def file. Must figure out
   9853  1.1  joerg 	      # which of the given symbols are data symbols and tag
   9854  1.1  joerg 	      # them as such. So, trigger use of export_symbols_cmds.
   9855  1.1  joerg 	      # export_symbols gets reassigned inside the "prepare
   9856  1.1  joerg 	      # the list of exported symbols" if statement, so the
   9857  1.1  joerg 	      # include_expsyms logic still works.
   9858  1.1  joerg 	      orig_export_symbols=$export_symbols
   9859  1.1  joerg 	      export_symbols=
   9860  1.1  joerg 	      always_export_symbols=yes
   9861  1.1  joerg 	    }
   9862  1.1  joerg 	  fi
   9863  1.1  joerg 	  ;;
   9864  1.1  joerg 	esac
   9865  1.1  joerg 
   9866  1.1  joerg 	# Prepare the list of exported symbols
   9867  1.1  joerg 	if test -z "$export_symbols"; then
   9868  1.1  joerg 	  if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
   9869  1.1  joerg 	    func_verbose "generating symbol list for '$libname.la'"
   9870  1.1  joerg 	    export_symbols=$output_objdir/$libname.exp
   9871  1.1  joerg 	    $opt_dry_run || $RM $export_symbols
   9872  1.1  joerg 	    cmds=$export_symbols_cmds
   9873  1.1  joerg 	    save_ifs=$IFS; IFS='~'
   9874  1.1  joerg 	    for cmd1 in $cmds; do
   9875  1.1  joerg 	      IFS=$save_ifs
   9876  1.1  joerg 	      # Take the normal branch if the nm_file_list_spec branch
   9877  1.1  joerg 	      # doesn't work or if tool conversion is not needed.
   9878  1.1  joerg 	      case $nm_file_list_spec~$to_tool_file_cmd in
   9879  1.1  joerg 		*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
   9880  1.1  joerg 		  try_normal_branch=yes
   9881  1.1  joerg 		  eval cmd=\"$cmd1\"
   9882  1.1  joerg 		  func_len " $cmd"
   9883  1.1  joerg 		  len=$func_len_result
   9884  1.1  joerg 		  ;;
   9885  1.1  joerg 		*)
   9886  1.1  joerg 		  try_normal_branch=no
   9887  1.1  joerg 		  ;;
   9888  1.1  joerg 	      esac
   9889  1.1  joerg 	      if test yes = "$try_normal_branch" \
   9890  1.1  joerg 		 && { test "$len" -lt "$max_cmd_len" \
   9891  1.1  joerg 		      || test "$max_cmd_len" -le -1; }
   9892  1.1  joerg 	      then
   9893  1.1  joerg 		func_show_eval "$cmd" 'exit $?'
   9894  1.1  joerg 		skipped_export=false
   9895  1.1  joerg 	      elif test -n "$nm_file_list_spec"; then
   9896  1.1  joerg 		func_basename "$output"
   9897  1.1  joerg 		output_la=$func_basename_result
   9898  1.1  joerg 		save_libobjs=$libobjs
   9899  1.1  joerg 		save_output=$output
   9900  1.1  joerg 		output=$output_objdir/$output_la.nm
   9901  1.1  joerg 		func_to_tool_file "$output"
   9902  1.1  joerg 		libobjs=$nm_file_list_spec$func_to_tool_file_result
   9903  1.1  joerg 		func_append delfiles " $output"
   9904  1.1  joerg 		func_verbose "creating $NM input file list: $output"
   9905  1.1  joerg 		for obj in $save_libobjs; do
   9906  1.1  joerg 		  func_to_tool_file "$obj"
   9907  1.1  joerg 		  $ECHO "$func_to_tool_file_result"
   9908  1.1  joerg 		done > "$output"
   9909  1.1  joerg 		eval cmd=\"$cmd1\"
   9910  1.1  joerg 		func_show_eval "$cmd" 'exit $?'
   9911  1.1  joerg 		output=$save_output
   9912  1.1  joerg 		libobjs=$save_libobjs
   9913  1.1  joerg 		skipped_export=false
   9914  1.1  joerg 	      else
   9915  1.1  joerg 		# The command line is too long to execute in one step.
   9916  1.1  joerg 		func_verbose "using reloadable object file for export list..."
   9917  1.1  joerg 		skipped_export=:
   9918  1.1  joerg 		# Break out early, otherwise skipped_export may be
   9919  1.1  joerg 		# set to false by a later but shorter cmd.
   9920  1.1  joerg 		break
   9921  1.1  joerg 	      fi
   9922  1.1  joerg 	    done
   9923  1.1  joerg 	    IFS=$save_ifs
   9924  1.1  joerg 	    if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
   9925  1.1  joerg 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
   9926  1.1  joerg 	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
   9927  1.1  joerg 	    fi
   9928  1.1  joerg 	  fi
   9929  1.1  joerg 	fi
   9930  1.1  joerg 
   9931  1.1  joerg 	if test -n "$export_symbols" && test -n "$include_expsyms"; then
   9932  1.1  joerg 	  tmp_export_symbols=$export_symbols
   9933  1.1  joerg 	  test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
   9934  1.1  joerg 	  $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
   9935  1.1  joerg 	fi
   9936  1.1  joerg 
   9937  1.1  joerg 	if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
   9938  1.1  joerg 	  # The given exports_symbols file has to be filtered, so filter it.
   9939  1.1  joerg 	  func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
   9940  1.1  joerg 	  # FIXME: $output_objdir/$libname.filter potentially contains lots of
   9941  1.1  joerg 	  # 's' commands, which not all seds can handle. GNU sed should be fine
   9942  1.1  joerg 	  # though. Also, the filter scales superlinearly with the number of
   9943  1.1  joerg 	  # global variables. join(1) would be nice here, but unfortunately
   9944  1.1  joerg 	  # isn't a blessed tool.
   9945  1.1  joerg 	  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
   9946  1.1  joerg 	  func_append delfiles " $export_symbols $output_objdir/$libname.filter"
   9947  1.1  joerg 	  export_symbols=$output_objdir/$libname.def
   9948  1.1  joerg 	  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
   9949  1.1  joerg 	fi
   9950  1.1  joerg 
   9951  1.1  joerg 	tmp_deplibs=
   9952  1.1  joerg 	for test_deplib in $deplibs; do
   9953  1.1  joerg 	  case " $convenience " in
   9954  1.1  joerg 	  *" $test_deplib "*) ;;
   9955  1.1  joerg 	  *)
   9956  1.1  joerg 	    func_append tmp_deplibs " $test_deplib"
   9957  1.1  joerg 	    ;;
   9958  1.1  joerg 	  esac
   9959  1.1  joerg 	done
   9960  1.1  joerg 	deplibs=$tmp_deplibs
   9961  1.1  joerg 
   9962  1.1  joerg 	if test -n "$convenience"; then
   9963  1.1  joerg 	  if test -n "$whole_archive_flag_spec" &&
   9964  1.1  joerg 	    test yes = "$compiler_needs_object" &&
   9965  1.1  joerg 	    test -z "$libobjs"; then
   9966  1.1  joerg 	    # extract the archives, so we have objects to list.
   9967  1.1  joerg 	    # TODO: could optimize this to just extract one archive.
   9968  1.1  joerg 	    whole_archive_flag_spec=
   9969  1.1  joerg 	  fi
   9970  1.1  joerg 	  if test -n "$whole_archive_flag_spec"; then
   9971  1.1  joerg 	    save_libobjs=$libobjs
   9972  1.1  joerg 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
   9973  1.1  joerg 	    test "X$libobjs" = "X " && libobjs=
   9974  1.1  joerg 	  else
   9975  1.1  joerg 	    gentop=$output_objdir/${outputname}x
   9976  1.1  joerg 	    func_append generated " $gentop"
   9977  1.1  joerg 
   9978  1.1  joerg 	    func_extract_archives $gentop $convenience
   9979  1.1  joerg 	    func_append libobjs " $func_extract_archives_result"
   9980  1.1  joerg 	    test "X$libobjs" = "X " && libobjs=
   9981  1.1  joerg 	  fi
   9982  1.1  joerg 	fi
   9983  1.1  joerg 
   9984  1.1  joerg 	if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
   9985  1.1  joerg 	  eval flag=\"$thread_safe_flag_spec\"
   9986  1.1  joerg 	  func_append linker_flags " $flag"
   9987  1.1  joerg 	fi
   9988  1.1  joerg 
   9989  1.1  joerg 	# Make a backup of the uninstalled library when relinking
   9990  1.1  joerg 	if test relink = "$opt_mode"; then
   9991  1.1  joerg 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
   9992  1.1  joerg 	fi
   9993  1.1  joerg 
   9994  1.1  joerg 	# Do each of the archive commands.
   9995  1.1  joerg 	if test yes = "$module" && test -n "$module_cmds"; then
   9996  1.1  joerg 	  if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
   9997  1.1  joerg 	    eval test_cmds=\"$module_expsym_cmds\"
   9998  1.1  joerg 	    cmds=$module_expsym_cmds
   9999  1.1  joerg 	  else
   10000  1.1  joerg 	    eval test_cmds=\"$module_cmds\"
   10001  1.1  joerg 	    cmds=$module_cmds
   10002  1.1  joerg 	  fi
   10003  1.1  joerg 	else
   10004  1.1  joerg 	  if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
   10005  1.1  joerg 	    eval test_cmds=\"$archive_expsym_cmds\"
   10006  1.1  joerg 	    cmds=$archive_expsym_cmds
   10007  1.1  joerg 	  else
   10008  1.1  joerg 	    eval test_cmds=\"$archive_cmds\"
   10009  1.1  joerg 	    cmds=$archive_cmds
   10010  1.1  joerg 	  fi
   10011  1.1  joerg 	fi
   10012  1.1  joerg 
   10013  1.1  joerg 	if test : != "$skipped_export" &&
   10014  1.1  joerg 	   func_len " $test_cmds" &&
   10015  1.1  joerg 	   len=$func_len_result &&
   10016  1.1  joerg 	   test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
   10017  1.1  joerg 	  :
   10018  1.1  joerg 	else
   10019  1.1  joerg 	  # The command line is too long to link in one step, link piecewise
   10020  1.1  joerg 	  # or, if using GNU ld and skipped_export is not :, use a linker
   10021  1.1  joerg 	  # script.
   10022  1.1  joerg 
   10023  1.1  joerg 	  # Save the value of $output and $libobjs because we want to
   10024  1.1  joerg 	  # use them later.  If we have whole_archive_flag_spec, we
   10025  1.1  joerg 	  # want to use save_libobjs as it was before
   10026  1.1  joerg 	  # whole_archive_flag_spec was expanded, because we can't
   10027  1.1  joerg 	  # assume the linker understands whole_archive_flag_spec.
   10028  1.1  joerg 	  # This may have to be revisited, in case too many
   10029  1.1  joerg 	  # convenience libraries get linked in and end up exceeding
   10030  1.1  joerg 	  # the spec.
   10031  1.1  joerg 	  if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
   10032  1.1  joerg 	    save_libobjs=$libobjs
   10033  1.1  joerg 	  fi
   10034  1.1  joerg 	  save_output=$output
   10035  1.1  joerg 	  func_basename "$output"
   10036  1.1  joerg 	  output_la=$func_basename_result
   10037  1.1  joerg 
   10038  1.1  joerg 	  # Clear the reloadable object creation command queue and
   10039  1.1  joerg 	  # initialize k to one.
   10040  1.1  joerg 	  test_cmds=
   10041  1.1  joerg 	  concat_cmds=
   10042  1.1  joerg 	  objlist=
   10043  1.1  joerg 	  last_robj=
   10044  1.1  joerg 	  k=1
   10045  1.1  joerg 
   10046  1.1  joerg 	  if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
   10047  1.1  joerg 	    output=$output_objdir/$output_la.lnkscript
   10048  1.1  joerg 	    func_verbose "creating GNU ld script: $output"
   10049  1.1  joerg 	    echo 'INPUT (' > $output
   10050  1.1  joerg 	    for obj in $save_libobjs
   10051  1.1  joerg 	    do
   10052  1.1  joerg 	      func_to_tool_file "$obj"
   10053  1.1  joerg 	      $ECHO "$func_to_tool_file_result" >> $output
   10054  1.1  joerg 	    done
   10055  1.1  joerg 	    echo ')' >> $output
   10056  1.1  joerg 	    func_append delfiles " $output"
   10057  1.1  joerg 	    func_to_tool_file "$output"
   10058  1.1  joerg 	    output=$func_to_tool_file_result
   10059  1.1  joerg 	  elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
   10060  1.1  joerg 	    output=$output_objdir/$output_la.lnk
   10061  1.1  joerg 	    func_verbose "creating linker input file list: $output"
   10062  1.1  joerg 	    : > $output
   10063  1.1  joerg 	    set x $save_libobjs
   10064  1.1  joerg 	    shift
   10065  1.1  joerg 	    firstobj=
   10066  1.1  joerg 	    if test yes = "$compiler_needs_object"; then
   10067  1.1  joerg 	      firstobj="$1 "
   10068  1.1  joerg 	      shift
   10069  1.1  joerg 	    fi
   10070  1.1  joerg 	    for obj
   10071  1.1  joerg 	    do
   10072  1.1  joerg 	      func_to_tool_file "$obj"
   10073  1.1  joerg 	      $ECHO "$func_to_tool_file_result" >> $output
   10074  1.1  joerg 	    done
   10075  1.1  joerg 	    func_append delfiles " $output"
   10076  1.1  joerg 	    func_to_tool_file "$output"
   10077  1.1  joerg 	    output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
   10078  1.1  joerg 	  else
   10079  1.1  joerg 	    if test -n "$save_libobjs"; then
   10080  1.1  joerg 	      func_verbose "creating reloadable object files..."
   10081  1.1  joerg 	      output=$output_objdir/$output_la-$k.$objext
   10082  1.1  joerg 	      eval test_cmds=\"$reload_cmds\"
   10083  1.1  joerg 	      func_len " $test_cmds"
   10084  1.1  joerg 	      len0=$func_len_result
   10085  1.1  joerg 	      len=$len0
   10086  1.1  joerg 
   10087  1.1  joerg 	      # Loop over the list of objects to be linked.
   10088  1.1  joerg 	      for obj in $save_libobjs
   10089  1.1  joerg 	      do
   10090  1.1  joerg 		func_len " $obj"
   10091  1.1  joerg 		func_arith $len + $func_len_result
   10092  1.1  joerg 		len=$func_arith_result
   10093  1.1  joerg 		if test -z "$objlist" ||
   10094  1.1  joerg 		   test "$len" -lt "$max_cmd_len"; then
   10095  1.1  joerg 		  func_append objlist " $obj"
   10096  1.1  joerg 		else
   10097  1.1  joerg 		  # The command $test_cmds is almost too long, add a
   10098  1.1  joerg 		  # command to the queue.
   10099  1.1  joerg 		  if test 1 -eq "$k"; then
   10100  1.1  joerg 		    # The first file doesn't have a previous command to add.
   10101  1.1  joerg 		    reload_objs=$objlist
   10102  1.1  joerg 		    eval concat_cmds=\"$reload_cmds\"
   10103  1.1  joerg 		  else
   10104  1.1  joerg 		    # All subsequent reloadable object files will link in
   10105  1.1  joerg 		    # the last one created.
   10106  1.1  joerg 		    reload_objs="$objlist $last_robj"
   10107  1.1  joerg 		    eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
   10108  1.1  joerg 		  fi
   10109  1.1  joerg 		  last_robj=$output_objdir/$output_la-$k.$objext
   10110  1.1  joerg 		  func_arith $k + 1
   10111  1.1  joerg 		  k=$func_arith_result
   10112  1.1  joerg 		  output=$output_objdir/$output_la-$k.$objext
   10113  1.1  joerg 		  objlist=" $obj"
   10114  1.1  joerg 		  func_len " $last_robj"
   10115  1.1  joerg 		  func_arith $len0 + $func_len_result
   10116  1.1  joerg 		  len=$func_arith_result
   10117  1.1  joerg 		fi
   10118  1.1  joerg 	      done
   10119  1.1  joerg 	      # Handle the remaining objects by creating one last
   10120  1.1  joerg 	      # reloadable object file.  All subsequent reloadable object
   10121  1.1  joerg 	      # files will link in the last one created.
   10122  1.1  joerg 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
   10123  1.1  joerg 	      reload_objs="$objlist $last_robj"
   10124  1.1  joerg 	      eval concat_cmds=\"\$concat_cmds$reload_cmds\"
   10125  1.1  joerg 	      if test -n "$last_robj"; then
   10126  1.1  joerg 	        eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
   10127  1.1  joerg 	      fi
   10128  1.1  joerg 	      func_append delfiles " $output"
   10129  1.1  joerg 
   10130  1.1  joerg 	    else
   10131  1.1  joerg 	      output=
   10132  1.1  joerg 	    fi
   10133  1.1  joerg 
   10134  1.1  joerg 	    ${skipped_export-false} && {
   10135  1.1  joerg 	      func_verbose "generating symbol list for '$libname.la'"
   10136  1.1  joerg 	      export_symbols=$output_objdir/$libname.exp
   10137  1.1  joerg 	      $opt_dry_run || $RM $export_symbols
   10138  1.1  joerg 	      libobjs=$output
   10139  1.1  joerg 	      # Append the command to create the export file.
   10140  1.1  joerg 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
   10141  1.1  joerg 	      eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
   10142  1.1  joerg 	      if test -n "$last_robj"; then
   10143  1.1  joerg 		eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
   10144  1.1  joerg 	      fi
   10145  1.1  joerg 	    }
   10146  1.1  joerg 
   10147  1.1  joerg 	    test -n "$save_libobjs" &&
   10148  1.1  joerg 	      func_verbose "creating a temporary reloadable object file: $output"
   10149  1.1  joerg 
   10150  1.1  joerg 	    # Loop through the commands generated above and execute them.
   10151  1.1  joerg 	    save_ifs=$IFS; IFS='~'
   10152  1.1  joerg 	    for cmd in $concat_cmds; do
   10153  1.1  joerg 	      IFS=$save_ifs
   10154  1.1  joerg 	      $opt_quiet || {
   10155  1.1  joerg 		  func_quote_arg expand,pretty "$cmd"
   10156  1.1  joerg 		  eval "func_echo $func_quote_arg_result"
   10157  1.1  joerg 	      }
   10158  1.1  joerg 	      $opt_dry_run || eval "$cmd" || {
   10159  1.1  joerg 		lt_exit=$?
   10160  1.1  joerg 
   10161  1.1  joerg 		# Restore the uninstalled library and exit
   10162  1.1  joerg 		if test relink = "$opt_mode"; then
   10163  1.1  joerg 		  ( cd "$output_objdir" && \
   10164  1.1  joerg 		    $RM "${realname}T" && \
   10165  1.1  joerg 		    $MV "${realname}U" "$realname" )
   10166  1.1  joerg 		fi
   10167  1.1  joerg 
   10168  1.1  joerg 		exit $lt_exit
   10169  1.1  joerg 	      }
   10170  1.1  joerg 	    done
   10171  1.1  joerg 	    IFS=$save_ifs
   10172  1.1  joerg 
   10173  1.1  joerg 	    if test -n "$export_symbols_regex" && ${skipped_export-false}; then
   10174  1.1  joerg 	      func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
   10175  1.1  joerg 	      func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
   10176  1.1  joerg 	    fi
   10177  1.1  joerg 	  fi
   10178  1.1  joerg 
   10179  1.1  joerg           ${skipped_export-false} && {
   10180  1.1  joerg 	    if test -n "$export_symbols" && test -n "$include_expsyms"; then
   10181  1.1  joerg 	      tmp_export_symbols=$export_symbols
   10182  1.1  joerg 	      test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
   10183  1.1  joerg 	      $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
   10184  1.1  joerg 	    fi
   10185  1.1  joerg 
   10186  1.1  joerg 	    if test -n "$orig_export_symbols"; then
   10187  1.1  joerg 	      # The given exports_symbols file has to be filtered, so filter it.
   10188  1.1  joerg 	      func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
   10189  1.1  joerg 	      # FIXME: $output_objdir/$libname.filter potentially contains lots of
   10190  1.1  joerg 	      # 's' commands, which not all seds can handle. GNU sed should be fine
   10191  1.1  joerg 	      # though. Also, the filter scales superlinearly with the number of
   10192  1.1  joerg 	      # global variables. join(1) would be nice here, but unfortunately
   10193  1.1  joerg 	      # isn't a blessed tool.
   10194  1.1  joerg 	      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
   10195  1.1  joerg 	      func_append delfiles " $export_symbols $output_objdir/$libname.filter"
   10196  1.1  joerg 	      export_symbols=$output_objdir/$libname.def
   10197  1.1  joerg 	      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
   10198  1.1  joerg 	    fi
   10199  1.1  joerg 	  }
   10200  1.1  joerg 
   10201  1.1  joerg 	  libobjs=$output
   10202  1.1  joerg 	  # Restore the value of output.
   10203  1.1  joerg 	  output=$save_output
   10204  1.1  joerg 
   10205  1.1  joerg 	  if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
   10206  1.1  joerg 	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
   10207  1.1  joerg 	    test "X$libobjs" = "X " && libobjs=
   10208  1.1  joerg 	  fi
   10209  1.1  joerg 	  # Expand the library linking commands again to reset the
   10210  1.1  joerg 	  # value of $libobjs for piecewise linking.
   10211  1.1  joerg 
   10212  1.1  joerg 	  # Do each of the archive commands.
   10213  1.1  joerg 	  if test yes = "$module" && test -n "$module_cmds"; then
   10214  1.1  joerg 	    if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
   10215  1.1  joerg 	      cmds=$module_expsym_cmds
   10216  1.1  joerg 	    else
   10217  1.1  joerg 	      cmds=$module_cmds
   10218  1.1  joerg 	    fi
   10219  1.1  joerg 	  else
   10220  1.1  joerg 	    if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
   10221  1.1  joerg 	      cmds=$archive_expsym_cmds
   10222  1.1  joerg 	    else
   10223  1.1  joerg 	      cmds=$archive_cmds
   10224  1.1  joerg 	    fi
   10225  1.1  joerg 	  fi
   10226  1.1  joerg 	fi
   10227  1.1  joerg 
   10228  1.1  joerg 	if test -n "$delfiles"; then
   10229  1.1  joerg 	  # Append the command to remove temporary files to $cmds.
   10230  1.1  joerg 	  eval cmds=\"\$cmds~\$RM $delfiles\"
   10231  1.1  joerg 	fi
   10232  1.1  joerg 
   10233  1.1  joerg 	# Add any objects from preloaded convenience libraries
   10234  1.1  joerg 	if test -n "$dlprefiles"; then
   10235  1.1  joerg 	  gentop=$output_objdir/${outputname}x
   10236  1.1  joerg 	  func_append generated " $gentop"
   10237  1.1  joerg 
   10238  1.1  joerg 	  func_extract_archives $gentop $dlprefiles
   10239  1.1  joerg 	  func_append libobjs " $func_extract_archives_result"
   10240  1.1  joerg 	  test "X$libobjs" = "X " && libobjs=
   10241  1.1  joerg 	fi
   10242  1.1  joerg 
   10243  1.1  joerg 	save_ifs=$IFS; IFS='~'
   10244  1.1  joerg 	for cmd in $cmds; do
   10245  1.1  joerg 	  IFS=$sp$nl
   10246  1.1  joerg 	  eval cmd=\"$cmd\"
   10247  1.1  joerg 	  IFS=$save_ifs
   10248  1.1  joerg 	  $opt_quiet || {
   10249  1.1  joerg 	    func_quote_arg expand,pretty "$cmd"
   10250  1.1  joerg 	    eval "func_echo $func_quote_arg_result"
   10251  1.1  joerg 	  }
   10252  1.1  joerg 	  $opt_dry_run || eval "$cmd" || {
   10253  1.1  joerg 	    lt_exit=$?
   10254  1.1  joerg 
   10255  1.1  joerg 	    # Restore the uninstalled library and exit
   10256  1.1  joerg 	    if test relink = "$opt_mode"; then
   10257  1.1  joerg 	      ( cd "$output_objdir" && \
   10258  1.1  joerg 	        $RM "${realname}T" && \
   10259  1.1  joerg 		$MV "${realname}U" "$realname" )
   10260  1.1  joerg 	    fi
   10261  1.1  joerg 
   10262  1.1  joerg 	    exit $lt_exit
   10263  1.1  joerg 	  }
   10264  1.1  joerg 	done
   10265  1.1  joerg 	IFS=$save_ifs
   10266  1.1  joerg 
   10267  1.1  joerg 	# Restore the uninstalled library and exit
   10268  1.1  joerg 	if test relink = "$opt_mode"; then
   10269  1.1  joerg 	  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
   10270  1.1  joerg 
   10271  1.1  joerg 	  if test -n "$convenience"; then
   10272  1.1  joerg 	    if test -z "$whole_archive_flag_spec"; then
   10273  1.1  joerg 	      func_show_eval '${RM}r "$gentop"'
   10274  1.1  joerg 	    fi
   10275  1.1  joerg 	  fi
   10276  1.1  joerg 
   10277  1.1  joerg 	  exit $EXIT_SUCCESS
   10278  1.1  joerg 	fi
   10279  1.1  joerg 
   10280  1.1  joerg 	# Create links to the real library.
   10281  1.1  joerg 	for linkname in $linknames; do
   10282  1.1  joerg 	  if test "$realname" != "$linkname"; then
   10283  1.1  joerg 	    func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
   10284  1.1  joerg 	  fi
   10285  1.1  joerg 	done
   10286  1.1  joerg 
   10287  1.1  joerg 	# If -module or -export-dynamic was specified, set the dlname.
   10288  1.1  joerg 	if test yes = "$module" || test yes = "$export_dynamic"; then
   10289  1.1  joerg 	  # On all known operating systems, these are identical.
   10290  1.1  joerg 	  dlname=$soname
   10291  1.1  joerg 	fi
   10292  1.1  joerg       fi
   10293  1.1  joerg       ;;
   10294  1.1  joerg 
   10295  1.1  joerg     obj)
   10296  1.1  joerg       if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
   10297  1.1  joerg 	func_warning "'-dlopen' is ignored for objects"
   10298  1.1  joerg       fi
   10299  1.1  joerg 
   10300  1.1  joerg       case " $deplibs" in
   10301  1.1  joerg       *\ -l* | *\ -L*)
   10302  1.1  joerg 	func_warning "'-l' and '-L' are ignored for objects" ;;
   10303  1.1  joerg       esac
   10304  1.1  joerg 
   10305  1.1  joerg       test -n "$rpath" && \
   10306  1.1  joerg 	func_warning "'-rpath' is ignored for objects"
   10307  1.1  joerg 
   10308  1.1  joerg       test -n "$xrpath" && \
   10309  1.1  joerg 	func_warning "'-R' is ignored for objects"
   10310  1.1  joerg 
   10311  1.1  joerg       test -n "$vinfo" && \
   10312  1.1  joerg 	func_warning "'-version-info' is ignored for objects"
   10313  1.1  joerg 
   10314  1.1  joerg       test -n "$release" && \
   10315  1.1  joerg 	func_warning "'-release' is ignored for objects"
   10316  1.1  joerg 
   10317  1.1  joerg       case $output in
   10318  1.1  joerg       *.lo)
   10319  1.1  joerg 	test -n "$objs$old_deplibs" && \
   10320  1.1  joerg 	  func_fatal_error "cannot build library object '$output' from non-libtool objects"
   10321  1.1  joerg 
   10322  1.1  joerg 	libobj=$output
   10323  1.1  joerg 	func_lo2o "$libobj"
   10324  1.1  joerg 	obj=$func_lo2o_result
   10325  1.1  joerg 	;;
   10326  1.1  joerg       *)
   10327  1.1  joerg 	libobj=
   10328  1.1  joerg 	obj=$output
   10329  1.1  joerg 	;;
   10330  1.1  joerg       esac
   10331  1.1  joerg 
   10332  1.1  joerg       # Delete the old objects.
   10333  1.1  joerg       $opt_dry_run || $RM $obj $libobj
   10334  1.1  joerg 
   10335  1.1  joerg       # Objects from convenience libraries.  This assumes
   10336  1.1  joerg       # single-version convenience libraries.  Whenever we create
   10337  1.1  joerg       # different ones for PIC/non-PIC, this we'll have to duplicate
   10338  1.1  joerg       # the extraction.
   10339  1.1  joerg       reload_conv_objs=
   10340  1.1  joerg       gentop=
   10341  1.1  joerg       # if reload_cmds runs $LD directly, get rid of -Wl from
   10342  1.1  joerg       # whole_archive_flag_spec and hope we can get by with turning comma
   10343  1.1  joerg       # into space.
   10344  1.1  joerg       case $reload_cmds in
   10345  1.1  joerg         *\$LD[\ \$]*) wl= ;;
   10346  1.1  joerg       esac
   10347  1.1  joerg       if test -n "$convenience"; then
   10348  1.1  joerg 	if test -n "$whole_archive_flag_spec"; then
   10349  1.1  joerg 	  eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
   10350  1.1  joerg 	  test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
   10351  1.1  joerg 	  reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
   10352  1.1  joerg 	else
   10353  1.1  joerg 	  gentop=$output_objdir/${obj}x
   10354  1.1  joerg 	  func_append generated " $gentop"
   10355  1.1  joerg 
   10356  1.1  joerg 	  func_extract_archives $gentop $convenience
   10357  1.1  joerg 	  reload_conv_objs="$reload_objs $func_extract_archives_result"
   10358  1.1  joerg 	fi
   10359  1.1  joerg       fi
   10360  1.1  joerg 
   10361  1.1  joerg       # If we're not building shared, we need to use non_pic_objs
   10362  1.1  joerg       test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
   10363  1.1  joerg 
   10364  1.1  joerg       # Create the old-style object.
   10365  1.1  joerg       reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
   10366  1.1  joerg 
   10367  1.1  joerg       output=$obj
   10368  1.1  joerg       func_execute_cmds "$reload_cmds" 'exit $?'
   10369  1.1  joerg 
   10370  1.1  joerg       # Exit if we aren't doing a library object file.
   10371  1.1  joerg       if test -z "$libobj"; then
   10372  1.1  joerg 	if test -n "$gentop"; then
   10373  1.1  joerg 	  func_show_eval '${RM}r "$gentop"'
   10374  1.1  joerg 	fi
   10375  1.1  joerg 
   10376  1.1  joerg 	exit $EXIT_SUCCESS
   10377  1.1  joerg       fi
   10378  1.1  joerg 
   10379  1.1  joerg       test yes = "$build_libtool_libs" || {
   10380  1.1  joerg 	if test -n "$gentop"; then
   10381  1.1  joerg 	  func_show_eval '${RM}r "$gentop"'
   10382  1.1  joerg 	fi
   10383  1.1  joerg 
   10384  1.1  joerg 	# Create an invalid libtool object if no PIC, so that we don't
   10385  1.1  joerg 	# accidentally link it into a program.
   10386  1.1  joerg 	# $show "echo timestamp > $libobj"
   10387  1.1  joerg 	# $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
   10388  1.1  joerg 	exit $EXIT_SUCCESS
   10389  1.1  joerg       }
   10390  1.1  joerg 
   10391  1.1  joerg       if test -n "$pic_flag" || test default != "$pic_mode"; then
   10392  1.1  joerg 	# Only do commands if we really have different PIC objects.
   10393  1.1  joerg 	reload_objs="$libobjs $reload_conv_objs"
   10394  1.1  joerg 	output=$libobj
   10395  1.1  joerg 	func_execute_cmds "$reload_cmds" 'exit $?'
   10396  1.1  joerg       fi
   10397  1.1  joerg 
   10398  1.1  joerg       if test -n "$gentop"; then
   10399  1.1  joerg 	func_show_eval '${RM}r "$gentop"'
   10400  1.1  joerg       fi
   10401  1.1  joerg 
   10402  1.1  joerg       exit $EXIT_SUCCESS
   10403  1.1  joerg       ;;
   10404  1.1  joerg 
   10405  1.1  joerg     prog)
   10406  1.1  joerg       case $host in
   10407  1.1  joerg 	*cygwin*) func_stripname '' '.exe' "$output"
   10408  1.1  joerg 	          output=$func_stripname_result.exe;;
   10409  1.1  joerg       esac
   10410  1.1  joerg       test -n "$vinfo" && \
   10411  1.1  joerg 	func_warning "'-version-info' is ignored for programs"
   10412  1.1  joerg 
   10413  1.1  joerg       test -n "$release" && \
   10414  1.1  joerg 	func_warning "'-release' is ignored for programs"
   10415  1.1  joerg 
   10416  1.1  joerg       $preload \
   10417  1.1  joerg 	&& test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
   10418  1.1  joerg 	&& func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
   10419  1.1  joerg 
   10420  1.1  joerg       case $host in
   10421  1.1  joerg       *-*-rhapsody* | *-*-darwin1.[012])
   10422  1.1  joerg 	# On Rhapsody replace the C library is the System framework
   10423  1.1  joerg 	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
   10424  1.1  joerg 	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
   10425  1.1  joerg 	;;
   10426  1.1  joerg       esac
   10427  1.1  joerg 
   10428  1.1  joerg       case $host in
   10429  1.1  joerg       *-*-darwin*)
   10430  1.1  joerg 	# Don't allow lazy linking, it breaks C++ global constructors
   10431  1.1  joerg 	# But is supposedly fixed on 10.4 or later (yay!).
   10432  1.1  joerg 	if test CXX = "$tagname"; then
   10433  1.1  joerg 	  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
   10434  1.1  joerg 	    10.[0123])
   10435  1.1  joerg 	      func_append compile_command " $wl-bind_at_load"
   10436  1.1  joerg 	      func_append finalize_command " $wl-bind_at_load"
   10437  1.1  joerg 	    ;;
   10438  1.1  joerg 	  esac
   10439  1.1  joerg 	fi
   10440  1.1  joerg 	# Time to change all our "foo.ltframework" stuff back to "-framework foo"
   10441  1.1  joerg 	compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
   10442  1.1  joerg 	finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
   10443  1.1  joerg 	;;
   10444  1.1  joerg       esac
   10445  1.1  joerg 
   10446  1.1  joerg 
   10447  1.1  joerg       # move library search paths that coincide with paths to not yet
   10448  1.1  joerg       # installed libraries to the beginning of the library search list
   10449  1.1  joerg       new_libs=
   10450  1.1  joerg       for path in $notinst_path; do
   10451  1.1  joerg 	case " $new_libs " in
   10452  1.1  joerg 	*" -L$path/$objdir "*) ;;
   10453  1.1  joerg 	*)
   10454  1.1  joerg 	  case " $compile_deplibs " in
   10455  1.1  joerg 	  *" -L$path/$objdir "*)
   10456  1.1  joerg 	    func_append new_libs " -L$path/$objdir" ;;
   10457  1.1  joerg 	  esac
   10458  1.1  joerg 	  ;;
   10459  1.1  joerg 	esac
   10460  1.1  joerg       done
   10461  1.1  joerg       for deplib in $compile_deplibs; do
   10462  1.1  joerg 	case $deplib in
   10463  1.1  joerg 	-L*)
   10464  1.1  joerg 	  case " $new_libs " in
   10465  1.1  joerg 	  *" $deplib "*) ;;
   10466  1.1  joerg 	  *) func_append new_libs " $deplib" ;;
   10467  1.1  joerg 	  esac
   10468  1.1  joerg 	  ;;
   10469  1.1  joerg 	*) func_append new_libs " $deplib" ;;
   10470  1.1  joerg 	esac
   10471  1.1  joerg       done
   10472  1.1  joerg       compile_deplibs=$new_libs
   10473  1.1  joerg 
   10474  1.1  joerg 
   10475  1.1  joerg       func_append compile_command " $compile_deplibs"
   10476  1.1  joerg       func_append finalize_command " $finalize_deplibs"
   10477  1.1  joerg 
   10478  1.1  joerg       if test -n "$rpath$xrpath"; then
   10479  1.1  joerg 	# If the user specified any rpath flags, then add them.
   10480  1.1  joerg 	for libdir in $rpath $xrpath; do
   10481  1.1  joerg 	  # This is the magic to use -rpath.
   10482  1.1  joerg 	  case "$finalize_rpath " in
   10483  1.1  joerg 	  *" $libdir "*) ;;
   10484  1.1  joerg 	  *) func_append finalize_rpath " $libdir" ;;
   10485  1.1  joerg 	  esac
   10486  1.1  joerg 	done
   10487  1.1  joerg       fi
   10488  1.1  joerg 
   10489  1.1  joerg       # Now hardcode the library paths
   10490  1.1  joerg       rpath=
   10491  1.1  joerg       hardcode_libdirs=
   10492  1.1  joerg       for libdir in $compile_rpath $finalize_rpath; do
   10493  1.1  joerg 	if test -n "$hardcode_libdir_flag_spec"; then
   10494  1.1  joerg 	  if test -n "$hardcode_libdir_separator"; then
   10495  1.1  joerg 	    if test -z "$hardcode_libdirs"; then
   10496  1.1  joerg 	      hardcode_libdirs=$libdir
   10497  1.1  joerg 	    else
   10498  1.1  joerg 	      # Just accumulate the unique libdirs.
   10499  1.1  joerg 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
   10500  1.1  joerg 	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
   10501  1.1  joerg 		;;
   10502  1.1  joerg 	      *)
   10503  1.1  joerg 		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
   10504  1.1  joerg 		;;
   10505  1.1  joerg 	      esac
   10506  1.1  joerg 	    fi
   10507  1.1  joerg 	  else
   10508  1.1  joerg 	    eval flag=\"$hardcode_libdir_flag_spec\"
   10509  1.1  joerg 	    func_append rpath " $flag"
   10510  1.1  joerg 	  fi
   10511  1.1  joerg 	elif test -n "$runpath_var"; then
   10512  1.1  joerg 	  case "$perm_rpath " in
   10513  1.1  joerg 	  *" $libdir "*) ;;
   10514  1.1  joerg 	  *) func_append perm_rpath " $libdir" ;;
   10515  1.1  joerg 	  esac
   10516  1.1  joerg 	fi
   10517  1.1  joerg 	case $host in
   10518  1.1  joerg 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
   10519  1.1  joerg 	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
   10520  1.1  joerg 	  case :$dllsearchpath: in
   10521  1.1  joerg 	  *":$libdir:"*) ;;
   10522  1.1  joerg 	  ::) dllsearchpath=$libdir;;
   10523  1.1  joerg 	  *) func_append dllsearchpath ":$libdir";;
   10524  1.1  joerg 	  esac
   10525  1.1  joerg 	  case :$dllsearchpath: in
   10526  1.1  joerg 	  *":$testbindir:"*) ;;
   10527  1.1  joerg 	  ::) dllsearchpath=$testbindir;;
   10528  1.1  joerg 	  *) func_append dllsearchpath ":$testbindir";;
   10529  1.1  joerg 	  esac
   10530  1.1  joerg 	  ;;
   10531  1.1  joerg 	esac
   10532  1.1  joerg       done
   10533  1.1  joerg       # Substitute the hardcoded libdirs into the rpath.
   10534  1.1  joerg       if test -n "$hardcode_libdir_separator" &&
   10535  1.1  joerg 	 test -n "$hardcode_libdirs"; then
   10536  1.1  joerg 	libdir=$hardcode_libdirs
   10537  1.1  joerg 	eval rpath=\" $hardcode_libdir_flag_spec\"
   10538  1.1  joerg       fi
   10539  1.1  joerg       compile_rpath=$rpath
   10540  1.1  joerg 
   10541  1.1  joerg       rpath=
   10542  1.1  joerg       hardcode_libdirs=
   10543  1.1  joerg       for libdir in $finalize_rpath; do
   10544  1.1  joerg 	if test -n "$hardcode_libdir_flag_spec"; then
   10545  1.1  joerg 	  if test -n "$hardcode_libdir_separator"; then
   10546  1.1  joerg 	    if test -z "$hardcode_libdirs"; then
   10547  1.1  joerg 	      hardcode_libdirs=$libdir
   10548  1.1  joerg 	    else
   10549  1.1  joerg 	      # Just accumulate the unique libdirs.
   10550  1.1  joerg 	      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
   10551  1.1  joerg 	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
   10552  1.1  joerg 		;;
   10553  1.1  joerg 	      *)
   10554  1.1  joerg 		func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
   10555  1.1  joerg 		;;
   10556  1.1  joerg 	      esac
   10557  1.1  joerg 	    fi
   10558  1.1  joerg 	  else
   10559  1.1  joerg 	    eval flag=\"$hardcode_libdir_flag_spec\"
   10560  1.1  joerg 	    func_append rpath " $flag"
   10561  1.1  joerg 	  fi
   10562  1.1  joerg 	elif test -n "$runpath_var"; then
   10563  1.1  joerg 	  case "$finalize_perm_rpath " in
   10564  1.1  joerg 	  *" $libdir "*) ;;
   10565  1.1  joerg 	  *) func_append finalize_perm_rpath " $libdir" ;;
   10566  1.1  joerg 	  esac
   10567  1.1  joerg 	fi
   10568  1.1  joerg       done
   10569  1.1  joerg       # Substitute the hardcoded libdirs into the rpath.
   10570  1.1  joerg       if test -n "$hardcode_libdir_separator" &&
   10571  1.1  joerg 	 test -n "$hardcode_libdirs"; then
   10572  1.1  joerg 	libdir=$hardcode_libdirs
   10573  1.1  joerg 	eval rpath=\" $hardcode_libdir_flag_spec\"
   10574  1.1  joerg       fi
   10575  1.1  joerg       finalize_rpath=$rpath
   10576  1.1  joerg 
   10577  1.1  joerg       if test -n "$libobjs" && test yes = "$build_old_libs"; then
   10578  1.1  joerg 	# Transform all the library objects into standard objects.
   10579  1.1  joerg 	compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
   10580  1.1  joerg 	finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
   10581  1.1  joerg       fi
   10582  1.1  joerg 
   10583  1.1  joerg       func_generate_dlsyms "$outputname" "@PROGRAM@" false
   10584  1.1  joerg 
   10585  1.1  joerg       # template prelinking step
   10586  1.1  joerg       if test -n "$prelink_cmds"; then
   10587  1.1  joerg 	func_execute_cmds "$prelink_cmds" 'exit $?'
   10588  1.1  joerg       fi
   10589  1.1  joerg 
   10590  1.1  joerg       wrappers_required=:
   10591  1.1  joerg       case $host in
   10592  1.1  joerg       *cegcc* | *mingw32ce*)
   10593  1.1  joerg         # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
   10594  1.1  joerg         wrappers_required=false
   10595  1.1  joerg         ;;
   10596  1.1  joerg       *cygwin* | *mingw* )
   10597  1.1  joerg         test yes = "$build_libtool_libs" || wrappers_required=false
   10598  1.1  joerg         ;;
   10599  1.1  joerg       *)
   10600  1.1  joerg         if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
   10601  1.1  joerg           wrappers_required=false
   10602  1.1  joerg         fi
   10603  1.1  joerg         ;;
   10604  1.1  joerg       esac
   10605  1.1  joerg       $wrappers_required || {
   10606  1.1  joerg 	# Replace the output file specification.
   10607  1.1  joerg 	compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
   10608  1.1  joerg 	link_command=$compile_command$compile_rpath
   10609  1.1  joerg 
   10610  1.1  joerg 	# We have no uninstalled library dependencies, so finalize right now.
   10611  1.1  joerg 	exit_status=0
   10612  1.1  joerg 	func_show_eval "$link_command" 'exit_status=$?'
   10613  1.1  joerg 
   10614  1.1  joerg 	if test -n "$postlink_cmds"; then
   10615  1.1  joerg 	  func_to_tool_file "$output"
   10616  1.1  joerg 	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
   10617  1.1  joerg 	  func_execute_cmds "$postlink_cmds" 'exit $?'
   10618  1.1  joerg 	fi
   10619  1.1  joerg 
   10620  1.1  joerg 	# Delete the generated files.
   10621  1.1  joerg 	if test -f "$output_objdir/${outputname}S.$objext"; then
   10622  1.1  joerg 	  func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
   10623  1.1  joerg 	fi
   10624  1.1  joerg 
   10625  1.1  joerg 	exit $exit_status
   10626  1.1  joerg       }
   10627  1.1  joerg 
   10628  1.1  joerg       if test -n "$compile_shlibpath$finalize_shlibpath"; then
   10629  1.1  joerg 	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
   10630  1.1  joerg       fi
   10631  1.1  joerg       if test -n "$finalize_shlibpath"; then
   10632  1.1  joerg 	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
   10633  1.1  joerg       fi
   10634  1.1  joerg 
   10635  1.1  joerg       compile_var=
   10636  1.1  joerg       finalize_var=
   10637  1.1  joerg       if test -n "$runpath_var"; then
   10638  1.1  joerg 	if test -n "$perm_rpath"; then
   10639  1.1  joerg 	  # We should set the runpath_var.
   10640  1.1  joerg 	  rpath=
   10641  1.1  joerg 	  for dir in $perm_rpath; do
   10642  1.1  joerg 	    func_append rpath "$dir:"
   10643  1.1  joerg 	  done
   10644  1.1  joerg 	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
   10645  1.1  joerg 	fi
   10646  1.1  joerg 	if test -n "$finalize_perm_rpath"; then
   10647  1.1  joerg 	  # We should set the runpath_var.
   10648  1.1  joerg 	  rpath=
   10649  1.1  joerg 	  for dir in $finalize_perm_rpath; do
   10650  1.1  joerg 	    func_append rpath "$dir:"
   10651  1.1  joerg 	  done
   10652  1.1  joerg 	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
   10653  1.1  joerg 	fi
   10654  1.1  joerg       fi
   10655  1.1  joerg 
   10656  1.1  joerg       if test yes = "$no_install"; then
   10657  1.1  joerg 	# We don't need to create a wrapper script.
   10658  1.1  joerg 	link_command=$compile_var$compile_command$compile_rpath
   10659  1.1  joerg 	# Replace the output file specification.
   10660  1.1  joerg 	link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
   10661  1.1  joerg 	# Delete the old output file.
   10662  1.1  joerg 	$opt_dry_run || $RM $output
   10663  1.1  joerg 	# Link the executable and exit
   10664  1.1  joerg 	func_show_eval "$link_command" 'exit $?'
   10665  1.1  joerg 
   10666  1.1  joerg 	if test -n "$postlink_cmds"; then
   10667  1.1  joerg 	  func_to_tool_file "$output"
   10668  1.1  joerg 	  postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
   10669  1.1  joerg 	  func_execute_cmds "$postlink_cmds" 'exit $?'
   10670  1.1  joerg 	fi
   10671  1.1  joerg 
   10672  1.1  joerg 	exit $EXIT_SUCCESS
   10673  1.1  joerg       fi
   10674  1.1  joerg 
   10675  1.1  joerg       case $hardcode_action,$fast_install in
   10676  1.1  joerg         relink,*)
   10677  1.1  joerg 	  # Fast installation is not supported
   10678  1.1  joerg 	  link_command=$compile_var$compile_command$compile_rpath
   10679  1.1  joerg 	  relink_command=$finalize_var$finalize_command$finalize_rpath
   10680  1.1  joerg 
   10681  1.1  joerg 	  func_warning "this platform does not like uninstalled shared libraries"
   10682  1.1  joerg 	  func_warning "'$output' will be relinked during installation"
   10683  1.1  joerg 	  ;;
   10684  1.1  joerg         *,yes)
   10685  1.1  joerg 	  link_command=$finalize_var$compile_command$finalize_rpath
   10686  1.1  joerg 	  relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
   10687  1.1  joerg           ;;
   10688  1.1  joerg 	*,no)
   10689  1.1  joerg 	  link_command=$compile_var$compile_command$compile_rpath
   10690  1.1  joerg 	  relink_command=$finalize_var$finalize_command$finalize_rpath
   10691  1.1  joerg           ;;
   10692  1.1  joerg 	*,needless)
   10693  1.1  joerg 	  link_command=$finalize_var$compile_command$finalize_rpath
   10694  1.1  joerg 	  relink_command=
   10695  1.1  joerg           ;;
   10696  1.1  joerg       esac
   10697  1.1  joerg 
   10698  1.1  joerg       # Replace the output file specification.
   10699  1.1  joerg       link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
   10700  1.1  joerg 
   10701  1.1  joerg       # Delete the old output files.
   10702  1.1  joerg       $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
   10703  1.1  joerg 
   10704  1.1  joerg       func_show_eval "$link_command" 'exit $?'
   10705  1.1  joerg 
   10706  1.1  joerg       if test -n "$postlink_cmds"; then
   10707  1.1  joerg 	func_to_tool_file "$output_objdir/$outputname"
   10708  1.1  joerg 	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'`
   10709  1.1  joerg 	func_execute_cmds "$postlink_cmds" 'exit $?'
   10710  1.1  joerg       fi
   10711  1.1  joerg 
   10712  1.1  joerg       # Now create the wrapper script.
   10713  1.1  joerg       func_verbose "creating $output"
   10714  1.1  joerg 
   10715  1.1  joerg       # Quote the relink command for shipping.
   10716  1.1  joerg       if test -n "$relink_command"; then
   10717  1.1  joerg 	# Preserve any variables that may affect compiler behavior
   10718  1.1  joerg 	for var in $variables_saved_for_relink; do
   10719  1.1  joerg 	  if eval test -z \"\${$var+set}\"; then
   10720  1.1  joerg 	    relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
   10721  1.1  joerg 	  elif eval var_value=\$$var; test -z "$var_value"; then
   10722  1.1  joerg 	    relink_command="$var=; export $var; $relink_command"
   10723  1.1  joerg 	  else
   10724  1.1  joerg 	    func_quote_arg pretty "$var_value"
   10725  1.1  joerg 	    relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
   10726  1.1  joerg 	  fi
   10727  1.1  joerg 	done
   10728  1.1  joerg 	func_quote eval cd "`pwd`"
   10729  1.1  joerg 	func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)"
   10730  1.1  joerg 	relink_command=$func_quote_arg_unquoted_result
   10731  1.1  joerg       fi
   10732  1.1  joerg 
   10733  1.1  joerg       # Only actually do things if not in dry run mode.
   10734  1.1  joerg       $opt_dry_run || {
   10735  1.1  joerg 	# win32 will think the script is a binary if it has
   10736  1.1  joerg 	# a .exe suffix, so we strip it off here.
   10737  1.1  joerg 	case $output in
   10738  1.1  joerg 	  *.exe) func_stripname '' '.exe' "$output"
   10739  1.1  joerg 	         output=$func_stripname_result ;;
   10740  1.1  joerg 	esac
   10741  1.1  joerg 	# test for cygwin because mv fails w/o .exe extensions
   10742  1.1  joerg 	case $host in
   10743  1.1  joerg 	  *cygwin*)
   10744  1.1  joerg 	    exeext=.exe
   10745  1.1  joerg 	    func_stripname '' '.exe' "$outputname"
   10746  1.1  joerg 	    outputname=$func_stripname_result ;;
   10747  1.1  joerg 	  *) exeext= ;;
   10748  1.1  joerg 	esac
   10749  1.1  joerg 	case $host in
   10750  1.1  joerg 	  *cygwin* | *mingw* )
   10751  1.1  joerg 	    func_dirname_and_basename "$output" "" "."
   10752  1.1  joerg 	    output_name=$func_basename_result
   10753  1.1  joerg 	    output_path=$func_dirname_result
   10754  1.1  joerg 	    cwrappersource=$output_path/$objdir/lt-$output_name.c
   10755  1.1  joerg 	    cwrapper=$output_path/$output_name.exe
   10756  1.1  joerg 	    $RM $cwrappersource $cwrapper
   10757  1.1  joerg 	    trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
   10758  1.1  joerg 
   10759  1.1  joerg 	    func_emit_cwrapperexe_src > $cwrappersource
   10760  1.1  joerg 
   10761  1.1  joerg 	    # The wrapper executable is built using the $host compiler,
   10762  1.1  joerg 	    # because it contains $host paths and files. If cross-
   10763  1.1  joerg 	    # compiling, it, like the target executable, must be
   10764  1.1  joerg 	    # executed on the $host or under an emulation environment.
   10765  1.1  joerg 	    $opt_dry_run || {
   10766  1.1  joerg 	      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
   10767  1.1  joerg 	      $STRIP $cwrapper
   10768  1.1  joerg 	    }
   10769  1.1  joerg 
   10770  1.1  joerg 	    # Now, create the wrapper script for func_source use:
   10771  1.1  joerg 	    func_ltwrapper_scriptname $cwrapper
   10772  1.1  joerg 	    $RM $func_ltwrapper_scriptname_result
   10773  1.1  joerg 	    trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
   10774  1.1  joerg 	    $opt_dry_run || {
   10775  1.1  joerg 	      # note: this script will not be executed, so do not chmod.
   10776  1.1  joerg 	      if test "x$build" = "x$host"; then
   10777  1.1  joerg 		$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
   10778  1.1  joerg 	      else
   10779  1.1  joerg 		func_emit_wrapper no > $func_ltwrapper_scriptname_result
   10780  1.1  joerg 	      fi
   10781  1.1  joerg 	    }
   10782  1.1  joerg 	  ;;
   10783  1.1  joerg 	  * )
   10784  1.1  joerg 	    $RM $output
   10785  1.1  joerg 	    trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
   10786  1.1  joerg 
   10787  1.1  joerg 	    func_emit_wrapper no > $output
   10788  1.1  joerg 	    chmod +x $output
   10789  1.1  joerg 	  ;;
   10790  1.1  joerg 	esac
   10791  1.1  joerg       }
   10792  1.1  joerg       exit $EXIT_SUCCESS
   10793  1.1  joerg       ;;
   10794  1.1  joerg     esac
   10795  1.1  joerg 
   10796  1.1  joerg     # See if we need to build an old-fashioned archive.
   10797  1.1  joerg     for oldlib in $oldlibs; do
   10798  1.1  joerg 
   10799  1.1  joerg       case $build_libtool_libs in
   10800  1.1  joerg         convenience)
   10801  1.1  joerg 	  oldobjs="$libobjs_save $symfileobj"
   10802  1.1  joerg 	  addlibs=$convenience
   10803  1.1  joerg 	  build_libtool_libs=no
   10804  1.1  joerg 	  ;;
   10805  1.1  joerg 	module)
   10806  1.1  joerg 	  oldobjs=$libobjs_save
   10807  1.1  joerg 	  addlibs=$old_convenience
   10808  1.1  joerg 	  build_libtool_libs=no
   10809  1.1  joerg           ;;
   10810  1.1  joerg 	*)
   10811  1.1  joerg 	  oldobjs="$old_deplibs $non_pic_objects"
   10812  1.1  joerg 	  $preload && test -f "$symfileobj" \
   10813  1.1  joerg 	    && func_append oldobjs " $symfileobj"
   10814  1.1  joerg 	  addlibs=$old_convenience
   10815  1.1  joerg 	  ;;
   10816  1.1  joerg       esac
   10817  1.1  joerg 
   10818  1.1  joerg       if test -n "$addlibs"; then
   10819  1.1  joerg 	gentop=$output_objdir/${outputname}x
   10820  1.1  joerg 	func_append generated " $gentop"
   10821  1.1  joerg 
   10822  1.1  joerg 	func_extract_archives $gentop $addlibs
   10823  1.1  joerg 	func_append oldobjs " $func_extract_archives_result"
   10824  1.1  joerg       fi
   10825  1.1  joerg 
   10826  1.1  joerg       # Do each command in the archive commands.
   10827  1.1  joerg       if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
   10828  1.1  joerg 	cmds=$old_archive_from_new_cmds
   10829  1.1  joerg       else
   10830  1.1  joerg 
   10831  1.1  joerg 	# Add any objects from preloaded convenience libraries
   10832  1.1  joerg 	if test -n "$dlprefiles"; then
   10833  1.1  joerg 	  gentop=$output_objdir/${outputname}x
   10834  1.1  joerg 	  func_append generated " $gentop"
   10835  1.1  joerg 
   10836  1.1  joerg 	  func_extract_archives $gentop $dlprefiles
   10837  1.1  joerg 	  func_append oldobjs " $func_extract_archives_result"
   10838  1.1  joerg 	fi
   10839  1.1  joerg 
   10840  1.1  joerg 	# POSIX demands no paths to be encoded in archives.  We have
   10841  1.1  joerg 	# to avoid creating archives with duplicate basenames if we
   10842  1.1  joerg 	# might have to extract them afterwards, e.g., when creating a
   10843  1.1  joerg 	# static archive out of a convenience library, or when linking
   10844  1.1  joerg 	# the entirety of a libtool archive into another (currently
   10845  1.1  joerg 	# not supported by libtool).
   10846  1.1  joerg 	if (for obj in $oldobjs
   10847  1.1  joerg 	    do
   10848  1.1  joerg 	      func_basename "$obj"
   10849  1.1  joerg 	      $ECHO "$func_basename_result"
   10850  1.1  joerg 	    done | sort | sort -uc >/dev/null 2>&1); then
   10851  1.1  joerg 	  :
   10852  1.1  joerg 	else
   10853  1.1  joerg 	  echo "copying selected object files to avoid basename conflicts..."
   10854  1.1  joerg 	  gentop=$output_objdir/${outputname}x
   10855  1.1  joerg 	  func_append generated " $gentop"
   10856  1.1  joerg 	  func_mkdir_p "$gentop"
   10857  1.1  joerg 	  save_oldobjs=$oldobjs
   10858  1.1  joerg 	  oldobjs=
   10859  1.1  joerg 	  counter=1
   10860  1.1  joerg 	  for obj in $save_oldobjs
   10861  1.1  joerg 	  do
   10862  1.1  joerg 	    func_basename "$obj"
   10863  1.1  joerg 	    objbase=$func_basename_result
   10864  1.1  joerg 	    case " $oldobjs " in
   10865  1.1  joerg 	    " ") oldobjs=$obj ;;
   10866  1.1  joerg 	    *[\ /]"$objbase "*)
   10867  1.1  joerg 	      while :; do
   10868  1.1  joerg 		# Make sure we don't pick an alternate name that also
   10869  1.1  joerg 		# overlaps.
   10870  1.1  joerg 		newobj=lt$counter-$objbase
   10871  1.1  joerg 		func_arith $counter + 1
   10872  1.1  joerg 		counter=$func_arith_result
   10873  1.1  joerg 		case " $oldobjs " in
   10874  1.1  joerg 		*[\ /]"$newobj "*) ;;
   10875  1.1  joerg 		*) if test ! -f "$gentop/$newobj"; then break; fi ;;
   10876  1.1  joerg 		esac
   10877  1.1  joerg 	      done
   10878  1.1  joerg 	      func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
   10879  1.1  joerg 	      func_append oldobjs " $gentop/$newobj"
   10880  1.1  joerg 	      ;;
   10881  1.1  joerg 	    *) func_append oldobjs " $obj" ;;
   10882  1.1  joerg 	    esac
   10883  1.1  joerg 	  done
   10884  1.1  joerg 	fi
   10885  1.1  joerg 	func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
   10886  1.1  joerg 	tool_oldlib=$func_to_tool_file_result
   10887  1.1  joerg 	eval cmds=\"$old_archive_cmds\"
   10888  1.1  joerg 
   10889  1.1  joerg 	func_len " $cmds"
   10890  1.1  joerg 	len=$func_len_result
   10891  1.1  joerg 	if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
   10892  1.1  joerg 	  cmds=$old_archive_cmds
   10893  1.1  joerg 	elif test -n "$archiver_list_spec"; then
   10894  1.1  joerg 	  func_verbose "using command file archive linking..."
   10895  1.1  joerg 	  for obj in $oldobjs
   10896  1.1  joerg 	  do
   10897  1.1  joerg 	    func_to_tool_file "$obj"
   10898  1.1  joerg 	    $ECHO "$func_to_tool_file_result"
   10899  1.1  joerg 	  done > $output_objdir/$libname.libcmd
   10900  1.1  joerg 	  func_to_tool_file "$output_objdir/$libname.libcmd"
   10901  1.1  joerg 	  oldobjs=" $archiver_list_spec$func_to_tool_file_result"
   10902  1.1  joerg 	  cmds=$old_archive_cmds
   10903  1.1  joerg 	else
   10904  1.1  joerg 	  # the command line is too long to link in one step, link in parts
   10905  1.1  joerg 	  func_verbose "using piecewise archive linking..."
   10906  1.1  joerg 	  save_RANLIB=$RANLIB
   10907  1.1  joerg 	  RANLIB=:
   10908  1.1  joerg 	  objlist=
   10909  1.1  joerg 	  concat_cmds=
   10910  1.1  joerg 	  save_oldobjs=$oldobjs
   10911  1.1  joerg 	  oldobjs=
   10912  1.1  joerg 	  # Is there a better way of finding the last object in the list?
   10913  1.1  joerg 	  for obj in $save_oldobjs
   10914  1.1  joerg 	  do
   10915  1.1  joerg 	    last_oldobj=$obj
   10916  1.1  joerg 	  done
   10917  1.1  joerg 	  eval test_cmds=\"$old_archive_cmds\"
   10918  1.1  joerg 	  func_len " $test_cmds"
   10919  1.1  joerg 	  len0=$func_len_result
   10920  1.1  joerg 	  len=$len0
   10921  1.1  joerg 	  for obj in $save_oldobjs
   10922  1.1  joerg 	  do
   10923  1.1  joerg 	    func_len " $obj"
   10924  1.1  joerg 	    func_arith $len + $func_len_result
   10925  1.1  joerg 	    len=$func_arith_result
   10926  1.1  joerg 	    func_append objlist " $obj"
   10927  1.1  joerg 	    if test "$len" -lt "$max_cmd_len"; then
   10928  1.1  joerg 	      :
   10929  1.1  joerg 	    else
   10930  1.1  joerg 	      # the above command should be used before it gets too long
   10931  1.1  joerg 	      oldobjs=$objlist
   10932  1.1  joerg 	      if test "$obj" = "$last_oldobj"; then
   10933  1.1  joerg 		RANLIB=$save_RANLIB
   10934  1.1  joerg 	      fi
   10935  1.1  joerg 	      test -z "$concat_cmds" || concat_cmds=$concat_cmds~
   10936  1.1  joerg 	      eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
   10937  1.1  joerg 	      objlist=
   10938  1.1  joerg 	      len=$len0
   10939  1.1  joerg 	    fi
   10940  1.1  joerg 	  done
   10941  1.1  joerg 	  RANLIB=$save_RANLIB
   10942  1.1  joerg 	  oldobjs=$objlist
   10943  1.1  joerg 	  if test -z "$oldobjs"; then
   10944  1.1  joerg 	    eval cmds=\"\$concat_cmds\"
   10945  1.1  joerg 	  else
   10946  1.1  joerg 	    eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
   10947  1.1  joerg 	  fi
   10948  1.1  joerg 	fi
   10949  1.1  joerg       fi
   10950  1.1  joerg       func_execute_cmds "$cmds" 'exit $?'
   10951  1.1  joerg     done
   10952  1.1  joerg 
   10953  1.1  joerg     test -n "$generated" && \
   10954  1.1  joerg       func_show_eval "${RM}r$generated"
   10955  1.1  joerg 
   10956  1.1  joerg     # Now create the libtool archive.
   10957  1.1  joerg     case $output in
   10958  1.1  joerg     *.la)
   10959  1.1  joerg       old_library=
   10960  1.1  joerg       test yes = "$build_old_libs" && old_library=$libname.$libext
   10961  1.1  joerg       func_verbose "creating $output"
   10962  1.1  joerg 
   10963  1.1  joerg       # Preserve any variables that may affect compiler behavior
   10964  1.1  joerg       for var in $variables_saved_for_relink; do
   10965  1.1  joerg 	if eval test -z \"\${$var+set}\"; then
   10966  1.1  joerg 	  relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
   10967  1.1  joerg 	elif eval var_value=\$$var; test -z "$var_value"; then
   10968  1.1  joerg 	  relink_command="$var=; export $var; $relink_command"
   10969  1.1  joerg 	else
   10970  1.1  joerg 	  func_quote_arg pretty,unquoted "$var_value"
   10971  1.1  joerg 	  relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
   10972  1.1  joerg 	fi
   10973  1.1  joerg       done
   10974  1.1  joerg       # Quote the link command for shipping.
   10975  1.1  joerg       func_quote eval cd "`pwd`"
   10976  1.1  joerg       relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
   10977  1.1  joerg       func_quote_arg pretty,unquoted "$relink_command"
   10978  1.1  joerg       relink_command=$func_quote_arg_unquoted_result
   10979  1.1  joerg       if test yes = "$hardcode_automatic"; then
   10980  1.1  joerg 	relink_command=
   10981  1.1  joerg       fi
   10982  1.1  joerg 
   10983  1.1  joerg       # Only create the output if not a dry run.
   10984  1.1  joerg       $opt_dry_run || {
   10985  1.1  joerg 	for installed in no yes; do
   10986  1.1  joerg 	  if test yes = "$installed"; then
   10987  1.1  joerg 	    if test -z "$install_libdir"; then
   10988  1.1  joerg 	      break
   10989  1.1  joerg 	    fi
   10990  1.1  joerg 	    output=$output_objdir/${outputname}i
   10991  1.1  joerg 	    # Replace all uninstalled libtool libraries with the installed ones
   10992  1.1  joerg 	    newdependency_libs=
   10993  1.1  joerg 	    for deplib in $dependency_libs; do
   10994  1.1  joerg 	      case $deplib in
   10995  1.1  joerg 	      *.la)
   10996  1.1  joerg 		func_basename "$deplib"
   10997  1.1  joerg 		name=$func_basename_result
   10998  1.1  joerg 		func_resolve_sysroot "$deplib"
   10999  1.1  joerg 		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
   11000  1.1  joerg 		test -z "$libdir" && \
   11001  1.1  joerg 		  func_fatal_error "'$deplib' is not a valid libtool archive"
   11002  1.1  joerg 		func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
   11003  1.1  joerg 		;;
   11004  1.1  joerg 	      -L*)
   11005  1.1  joerg 		func_stripname -L '' "$deplib"
   11006  1.1  joerg 		func_replace_sysroot "$func_stripname_result"
   11007  1.1  joerg 		func_append newdependency_libs " -L$func_replace_sysroot_result"
   11008  1.1  joerg 		;;
   11009  1.1  joerg 	      -R*)
   11010  1.1  joerg 		func_stripname -R '' "$deplib"
   11011  1.1  joerg 		func_replace_sysroot "$func_stripname_result"
   11012  1.1  joerg 		func_append newdependency_libs " -R$func_replace_sysroot_result"
   11013  1.1  joerg 		;;
   11014  1.1  joerg 	      *) func_append newdependency_libs " $deplib" ;;
   11015  1.1  joerg 	      esac
   11016  1.1  joerg 	    done
   11017  1.1  joerg 	    dependency_libs=$newdependency_libs
   11018  1.1  joerg 	    newdlfiles=
   11019  1.1  joerg 
   11020  1.1  joerg 	    for lib in $dlfiles; do
   11021  1.1  joerg 	      case $lib in
   11022  1.1  joerg 	      *.la)
   11023  1.1  joerg 	        func_basename "$lib"
   11024  1.1  joerg 		name=$func_basename_result
   11025  1.1  joerg 		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
   11026  1.1  joerg 		test -z "$libdir" && \
   11027  1.1  joerg 		  func_fatal_error "'$lib' is not a valid libtool archive"
   11028  1.1  joerg 		func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
   11029  1.1  joerg 		;;
   11030  1.1  joerg 	      *) func_append newdlfiles " $lib" ;;
   11031  1.1  joerg 	      esac
   11032  1.1  joerg 	    done
   11033  1.1  joerg 	    dlfiles=$newdlfiles
   11034  1.1  joerg 	    newdlprefiles=
   11035  1.1  joerg 	    for lib in $dlprefiles; do
   11036  1.1  joerg 	      case $lib in
   11037  1.1  joerg 	      *.la)
   11038  1.1  joerg 		# Only pass preopened files to the pseudo-archive (for
   11039  1.1  joerg 		# eventual linking with the app. that links it) if we
   11040  1.1  joerg 		# didn't already link the preopened objects directly into
   11041  1.1  joerg 		# the library:
   11042  1.1  joerg 		func_basename "$lib"
   11043  1.1  joerg 		name=$func_basename_result
   11044  1.1  joerg 		eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
   11045  1.1  joerg 		test -z "$libdir" && \
   11046  1.1  joerg 		  func_fatal_error "'$lib' is not a valid libtool archive"
   11047  1.1  joerg 		func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
   11048  1.1  joerg 		;;
   11049  1.1  joerg 	      esac
   11050  1.1  joerg 	    done
   11051  1.1  joerg 	    dlprefiles=$newdlprefiles
   11052  1.1  joerg 	  else
   11053  1.1  joerg 	    newdlfiles=
   11054  1.1  joerg 	    for lib in $dlfiles; do
   11055  1.1  joerg 	      case $lib in
   11056  1.1  joerg 		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
   11057  1.1  joerg 		*) abs=`pwd`"/$lib" ;;
   11058  1.1  joerg 	      esac
   11059  1.1  joerg 	      func_append newdlfiles " $abs"
   11060  1.1  joerg 	    done
   11061  1.1  joerg 	    dlfiles=$newdlfiles
   11062  1.1  joerg 	    newdlprefiles=
   11063  1.1  joerg 	    for lib in $dlprefiles; do
   11064  1.1  joerg 	      case $lib in
   11065  1.1  joerg 		[\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
   11066  1.1  joerg 		*) abs=`pwd`"/$lib" ;;
   11067  1.1  joerg 	      esac
   11068  1.1  joerg 	      func_append newdlprefiles " $abs"
   11069  1.1  joerg 	    done
   11070  1.1  joerg 	    dlprefiles=$newdlprefiles
   11071  1.1  joerg 	  fi
   11072  1.1  joerg 	  $RM $output
   11073  1.1  joerg 	  # place dlname in correct position for cygwin
   11074  1.1  joerg 	  # In fact, it would be nice if we could use this code for all target
   11075  1.1  joerg 	  # systems that can't hard-code library paths into their executables
   11076  1.1  joerg 	  # and that have no shared library path variable independent of PATH,
   11077  1.1  joerg 	  # but it turns out we can't easily determine that from inspecting
   11078  1.1  joerg 	  # libtool variables, so we have to hard-code the OSs to which it
   11079  1.1  joerg 	  # applies here; at the moment, that means platforms that use the PE
   11080  1.1  joerg 	  # object format with DLL files.  See the long comment at the top of
   11081  1.1  joerg 	  # tests/bindir.at for full details.
   11082  1.1  joerg 	  tdlname=$dlname
   11083  1.1  joerg 	  case $host,$output,$installed,$module,$dlname in
   11084  1.1  joerg 	    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
   11085  1.1  joerg 	      # If a -bindir argument was supplied, place the dll there.
   11086  1.1  joerg 	      if test -n "$bindir"; then
   11087  1.1  joerg 		func_relative_path "$install_libdir" "$bindir"
   11088  1.1  joerg 		tdlname=$func_relative_path_result/$dlname
   11089  1.1  joerg 	      else
   11090  1.1  joerg 		# Otherwise fall back on heuristic.
   11091  1.1  joerg 		tdlname=../bin/$dlname
   11092  1.1  joerg 	      fi
   11093  1.1  joerg 	      ;;
   11094  1.1  joerg 	  esac
   11095  1.1  joerg 	  $ECHO > $output "\
   11096  1.1  joerg # $outputname - a libtool library file
   11097  1.1  joerg # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
   11098  1.1  joerg #
   11099  1.1  joerg # Please DO NOT delete this file!
   11100  1.1  joerg # It is necessary for linking the library.
   11101  1.1  joerg 
   11102  1.1  joerg # The name that we can dlopen(3).
   11103  1.1  joerg dlname='$tdlname'
   11104  1.1  joerg 
   11105  1.1  joerg # Names of this library.
   11106  1.1  joerg library_names='$library_names'
   11107  1.1  joerg 
   11108  1.1  joerg # The name of the static archive.
   11109  1.1  joerg old_library='$old_library'
   11110  1.1  joerg 
   11111  1.1  joerg # Linker flags that cannot go in dependency_libs.
   11112  1.1  joerg inherited_linker_flags='$new_inherited_linker_flags'
   11113  1.1  joerg 
   11114  1.1  joerg # Libraries that this one depends upon.
   11115  1.1  joerg dependency_libs='$dependency_libs'
   11116  1.1  joerg 
   11117  1.1  joerg # Names of additional weak libraries provided by this library
   11118  1.1  joerg weak_library_names='$weak_libs'
   11119  1.1  joerg 
   11120  1.1  joerg # Version information for $libname.
   11121  1.1  joerg current=$current
   11122  1.1  joerg age=$age
   11123  1.1  joerg revision=$revision
   11124  1.1  joerg 
   11125  1.1  joerg # Is this an already installed library?
   11126  1.1  joerg installed=$installed
   11127  1.1  joerg 
   11128  1.1  joerg # Should we warn about portability when linking against -modules?
   11129  1.1  joerg shouldnotlink=$module
   11130  1.1  joerg 
   11131  1.1  joerg # Files to dlopen/dlpreopen
   11132  1.1  joerg dlopen='$dlfiles'
   11133  1.1  joerg dlpreopen='$dlprefiles'
   11134  1.1  joerg 
   11135  1.1  joerg # Directory that this library needs to be installed in:
   11136  1.1  joerg libdir='$install_libdir'"
   11137  1.1  joerg 	  if test no,yes = "$installed,$need_relink"; then
   11138  1.1  joerg 	    $ECHO >> $output "\
   11139  1.1  joerg relink_command=\"$relink_command\""
   11140  1.1  joerg 	  fi
   11141  1.1  joerg 	done
   11142  1.1  joerg       }
   11143  1.1  joerg 
   11144  1.1  joerg       # Do a symbolic link so that the libtool archive can be found in
   11145  1.1  joerg       # LD_LIBRARY_PATH before the program is installed.
   11146  1.1  joerg       func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
   11147  1.1  joerg       ;;
   11148  1.1  joerg     esac
   11149  1.1  joerg     exit $EXIT_SUCCESS
   11150  1.1  joerg }
   11151  1.1  joerg 
   11152  1.1  joerg if test link = "$opt_mode" || test relink = "$opt_mode"; then
   11153  1.1  joerg   func_mode_link ${1+"$@"}
   11154  1.1  joerg fi
   11155  1.1  joerg 
   11156  1.1  joerg 
   11157  1.1  joerg # func_mode_uninstall arg...
   11158  1.1  joerg func_mode_uninstall ()
   11159  1.1  joerg {
   11160  1.1  joerg     $debug_cmd
   11161  1.1  joerg 
   11162  1.1  joerg     RM=$nonopt
   11163  1.1  joerg     files=
   11164  1.1  joerg     rmforce=false
   11165  1.1  joerg     exit_status=0
   11166  1.1  joerg 
   11167  1.1  joerg     # This variable tells wrapper scripts just to set variables rather
   11168  1.1  joerg     # than running their programs.
   11169  1.1  joerg     libtool_install_magic=$magic
   11170  1.1  joerg 
   11171  1.1  joerg     for arg
   11172  1.1  joerg     do
   11173  1.1  joerg       case $arg in
   11174  1.1  joerg       -f) func_append RM " $arg"; rmforce=: ;;
   11175  1.1  joerg       -*) func_append RM " $arg" ;;
   11176  1.1  joerg       *) func_append files " $arg" ;;
   11177  1.1  joerg       esac
   11178  1.1  joerg     done
   11179  1.1  joerg 
   11180  1.1  joerg     test -z "$RM" && \
   11181  1.1  joerg       func_fatal_help "you must specify an RM program"
   11182  1.1  joerg 
   11183  1.1  joerg     rmdirs=
   11184  1.1  joerg 
   11185  1.1  joerg     for file in $files; do
   11186  1.1  joerg       func_dirname "$file" "" "."
   11187  1.1  joerg       dir=$func_dirname_result
   11188  1.1  joerg       if test . = "$dir"; then
   11189  1.1  joerg 	odir=$objdir
   11190  1.1  joerg       else
   11191  1.1  joerg 	odir=$dir/$objdir
   11192  1.1  joerg       fi
   11193  1.1  joerg       func_basename "$file"
   11194  1.1  joerg       name=$func_basename_result
   11195  1.1  joerg       test uninstall = "$opt_mode" && odir=$dir
   11196  1.1  joerg 
   11197  1.1  joerg       # Remember odir for removal later, being careful to avoid duplicates
   11198  1.1  joerg       if test clean = "$opt_mode"; then
   11199  1.1  joerg 	case " $rmdirs " in
   11200  1.1  joerg 	  *" $odir "*) ;;
   11201  1.1  joerg 	  *) func_append rmdirs " $odir" ;;
   11202  1.1  joerg 	esac
   11203  1.1  joerg       fi
   11204  1.1  joerg 
   11205  1.1  joerg       # Don't error if the file doesn't exist and rm -f was used.
   11206  1.1  joerg       if { test -L "$file"; } >/dev/null 2>&1 ||
   11207  1.1  joerg 	 { test -h "$file"; } >/dev/null 2>&1 ||
   11208  1.1  joerg 	 test -f "$file"; then
   11209  1.1  joerg 	:
   11210  1.1  joerg       elif test -d "$file"; then
   11211  1.1  joerg 	exit_status=1
   11212  1.1  joerg 	continue
   11213  1.1  joerg       elif $rmforce; then
   11214  1.1  joerg 	continue
   11215  1.1  joerg       fi
   11216  1.1  joerg 
   11217  1.1  joerg       rmfiles=$file
   11218  1.1  joerg 
   11219  1.1  joerg       case $name in
   11220  1.1  joerg       *.la)
   11221  1.1  joerg 	# Possibly a libtool archive, so verify it.
   11222  1.1  joerg 	if func_lalib_p "$file"; then
   11223  1.1  joerg 	  func_source $dir/$name
   11224  1.1  joerg 
   11225  1.1  joerg 	  # Delete the libtool libraries and symlinks.
   11226  1.1  joerg 	  for n in $library_names; do
   11227  1.1  joerg 	    func_append rmfiles " $odir/$n"
   11228  1.1  joerg 	  done
   11229  1.1  joerg 	  test -n "$old_library" && func_append rmfiles " $odir/$old_library"
   11230  1.1  joerg 
   11231  1.1  joerg 	  case $opt_mode in
   11232  1.1  joerg 	  clean)
   11233  1.1  joerg 	    case " $library_names " in
   11234  1.1  joerg 	    *" $dlname "*) ;;
   11235  1.1  joerg 	    *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
   11236  1.1  joerg 	    esac
   11237  1.1  joerg 	    test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
   11238  1.1  joerg 	    ;;
   11239  1.1  joerg 	  uninstall)
   11240  1.1  joerg 	    if test -n "$library_names"; then
   11241  1.1  joerg 	      # Do each command in the postuninstall commands.
   11242  1.1  joerg 	      func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
   11243  1.1  joerg 	    fi
   11244  1.1  joerg 
   11245  1.1  joerg 	    if test -n "$old_library"; then
   11246  1.1  joerg 	      # Do each command in the old_postuninstall commands.
   11247  1.1  joerg 	      func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
   11248  1.1  joerg 	    fi
   11249  1.1  joerg 	    # FIXME: should reinstall the best remaining shared library.
   11250  1.1  joerg 	    ;;
   11251  1.1  joerg 	  esac
   11252  1.1  joerg 	fi
   11253  1.1  joerg 	;;
   11254  1.1  joerg 
   11255  1.1  joerg       *.lo)
   11256  1.1  joerg 	# Possibly a libtool object, so verify it.
   11257  1.1  joerg 	if func_lalib_p "$file"; then
   11258  1.1  joerg 
   11259  1.1  joerg 	  # Read the .lo file
   11260  1.1  joerg 	  func_source $dir/$name
   11261  1.1  joerg 
   11262  1.1  joerg 	  # Add PIC object to the list of files to remove.
   11263  1.1  joerg 	  if test -n "$pic_object" && test none != "$pic_object"; then
   11264  1.1  joerg 	    func_append rmfiles " $dir/$pic_object"
   11265  1.1  joerg 	  fi
   11266  1.1  joerg 
   11267  1.1  joerg 	  # Add non-PIC object to the list of files to remove.
   11268  1.1  joerg 	  if test -n "$non_pic_object" && test none != "$non_pic_object"; then
   11269  1.1  joerg 	    func_append rmfiles " $dir/$non_pic_object"
   11270  1.1  joerg 	  fi
   11271  1.1  joerg 	fi
   11272  1.1  joerg 	;;
   11273  1.1  joerg 
   11274  1.1  joerg       *)
   11275  1.1  joerg 	if test clean = "$opt_mode"; then
   11276  1.1  joerg 	  noexename=$name
   11277  1.1  joerg 	  case $file in
   11278  1.1  joerg 	  *.exe)
   11279  1.1  joerg 	    func_stripname '' '.exe' "$file"
   11280  1.1  joerg 	    file=$func_stripname_result
   11281  1.1  joerg 	    func_stripname '' '.exe' "$name"
   11282  1.1  joerg 	    noexename=$func_stripname_result
   11283  1.1  joerg 	    # $file with .exe has already been added to rmfiles,
   11284  1.1  joerg 	    # add $file without .exe
   11285  1.1  joerg 	    func_append rmfiles " $file"
   11286  1.1  joerg 	    ;;
   11287  1.1  joerg 	  esac
   11288  1.1  joerg 	  # Do a test to see if this is a libtool program.
   11289  1.1  joerg 	  if func_ltwrapper_p "$file"; then
   11290  1.1  joerg 	    if func_ltwrapper_executable_p "$file"; then
   11291  1.1  joerg 	      func_ltwrapper_scriptname "$file"
   11292  1.1  joerg 	      relink_command=
   11293  1.1  joerg 	      func_source $func_ltwrapper_scriptname_result
   11294  1.1  joerg 	      func_append rmfiles " $func_ltwrapper_scriptname_result"
   11295  1.1  joerg 	    else
   11296  1.1  joerg 	      relink_command=
   11297  1.1  joerg 	      func_source $dir/$noexename
   11298  1.1  joerg 	    fi
   11299  1.1  joerg 
   11300  1.1  joerg 	    # note $name still contains .exe if it was in $file originally
   11301  1.1  joerg 	    # as does the version of $file that was added into $rmfiles
   11302  1.1  joerg 	    func_append rmfiles " $odir/$name $odir/${name}S.$objext"
   11303  1.1  joerg 	    if test yes = "$fast_install" && test -n "$relink_command"; then
   11304  1.1  joerg 	      func_append rmfiles " $odir/lt-$name"
   11305  1.1  joerg 	    fi
   11306  1.1  joerg 	    if test "X$noexename" != "X$name"; then
   11307  1.1  joerg 	      func_append rmfiles " $odir/lt-$noexename.c"
   11308  1.1  joerg 	    fi
   11309  1.1  joerg 	  fi
   11310  1.1  joerg 	fi
   11311  1.1  joerg 	;;
   11312  1.1  joerg       esac
   11313  1.1  joerg       func_show_eval "$RM $rmfiles" 'exit_status=1'
   11314  1.1  joerg     done
   11315  1.1  joerg 
   11316  1.1  joerg     # Try to remove the $objdir's in the directories where we deleted files
   11317  1.1  joerg     for dir in $rmdirs; do
   11318  1.1  joerg       if test -d "$dir"; then
   11319  1.1  joerg 	func_show_eval "rmdir $dir >/dev/null 2>&1"
   11320  1.1  joerg       fi
   11321  1.1  joerg     done
   11322  1.1  joerg 
   11323  1.1  joerg     exit $exit_status
   11324  1.1  joerg }
   11325  1.1  joerg 
   11326  1.1  joerg if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
   11327  1.1  joerg   func_mode_uninstall ${1+"$@"}
   11328  1.1  joerg fi
   11329  1.1  joerg 
   11330  1.1  joerg test -z "$opt_mode" && {
   11331  1.1  joerg   help=$generic_help
   11332  1.1  joerg   func_fatal_help "you must specify a MODE"
   11333  1.1  joerg }
   11334  1.1  joerg 
   11335  1.1  joerg test -z "$exec_cmd" && \
   11336  1.1  joerg   func_fatal_help "invalid operation mode '$opt_mode'"
   11337  1.1  joerg 
   11338  1.1  joerg if test -n "$exec_cmd"; then
   11339  1.1  joerg   eval exec "$exec_cmd"
   11340  1.1  joerg   exit $EXIT_FAILURE
   11341  1.1  joerg fi
   11342  1.1  joerg 
   11343  1.1  joerg exit $exit_status
   11344  1.1  joerg 
   11345  1.1  joerg 
   11346  1.1  joerg # The TAGs below are defined such that we never get into a situation
   11347  1.1  joerg # where we disable both kinds of libraries.  Given conflicting
   11348  1.1  joerg # choices, we go for a static library, that is the most portable,
   11349  1.1  joerg # since we can't tell whether shared libraries were disabled because
   11350  1.1  joerg # the user asked for that or because the platform doesn't support
   11351  1.1  joerg # them.  This is particularly important on AIX, because we don't
   11352  1.1  joerg # support having both static and shared libraries enabled at the same
   11353  1.1  joerg # time on that platform, so we default to a shared-only configuration.
   11354  1.1  joerg # If a disable-shared tag is given, we'll fallback to a static-only
   11355  1.1  joerg # configuration.  But we'll never go from static-only to shared-only.
   11356  1.1  joerg 
   11357  1.1  joerg # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
   11358  1.1  joerg build_libtool_libs=no
   11359  1.1  joerg build_old_libs=yes
   11360  1.1  joerg # ### END LIBTOOL TAG CONFIG: disable-shared
   11361  1.1  joerg 
   11362  1.1  joerg # ### BEGIN LIBTOOL TAG CONFIG: disable-static
   11363  1.1  joerg build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
   11364  1.1  joerg # ### END LIBTOOL TAG CONFIG: disable-static
   11365  1.1  joerg 
   11366  1.1  joerg # Local Variables:
   11367  1.1  joerg # mode:shell-script
   11368  1.1  joerg # sh-indentation:2
   11369  1.1  joerg # End:
   11370