lemon-project-template-glpk

annotate deps/glpk/ltmain.sh @ 9:33de93886c88

Import GLPK 4.47
author Alpar Juttner <alpar@cs.elte.hu>
date Sun, 06 Nov 2011 20:59:10 +0100
parents
children
rev   line source
alpar@9 1 # Generated from ltmain.m4sh.
alpar@9 2
alpar@9 3 # libtool (GNU libtool 1.3140 2009-12-30) 2.2.7a
alpar@9 4 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
alpar@9 5
alpar@9 6 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
alpar@9 7 # 2007, 2008, 2009 Free Software Foundation, Inc.
alpar@9 8 # This is free software; see the source for copying conditions. There is NO
alpar@9 9 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
alpar@9 10
alpar@9 11 # GNU Libtool is free software; you can redistribute it and/or modify
alpar@9 12 # it under the terms of the GNU General Public License as published by
alpar@9 13 # the Free Software Foundation; either version 2 of the License, or
alpar@9 14 # (at your option) any later version.
alpar@9 15 #
alpar@9 16 # As a special exception to the GNU General Public License,
alpar@9 17 # if you distribute this file as part of a program or library that
alpar@9 18 # is built using GNU Libtool, you may include this file under the
alpar@9 19 # same distribution terms that you use for the rest of that program.
alpar@9 20 #
alpar@9 21 # GNU Libtool is distributed in the hope that it will be useful, but
alpar@9 22 # WITHOUT ANY WARRANTY; without even the implied warranty of
alpar@9 23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
alpar@9 24 # General Public License for more details.
alpar@9 25 #
alpar@9 26 # You should have received a copy of the GNU General Public License
alpar@9 27 # along with GNU Libtool; see the file COPYING. If not, a copy
alpar@9 28 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
alpar@9 29 # or obtained by writing to the Free Software Foundation, Inc.,
alpar@9 30 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
alpar@9 31
alpar@9 32 # Usage: $progname [OPTION]... [MODE-ARG]...
alpar@9 33 #
alpar@9 34 # Provide generalized library-building support services.
alpar@9 35 #
alpar@9 36 # --config show all configuration variables
alpar@9 37 # --debug enable verbose shell tracing
alpar@9 38 # -n, --dry-run display commands without modifying any files
alpar@9 39 # --features display basic configuration information and exit
alpar@9 40 # --mode=MODE use operation mode MODE
alpar@9 41 # --preserve-dup-deps don't remove duplicate dependency libraries
alpar@9 42 # --quiet, --silent don't print informational messages
alpar@9 43 # --no-quiet, --no-silent
alpar@9 44 # print informational messages (default)
alpar@9 45 # --tag=TAG use configuration variables from tag TAG
alpar@9 46 # -v, --verbose print more informational messages than default
alpar@9 47 # --no-verbose don't print the extra informational messages
alpar@9 48 # --version print version information
alpar@9 49 # -h, --help, --help-all print short, long, or detailed help message
alpar@9 50 #
alpar@9 51 # MODE must be one of the following:
alpar@9 52 #
alpar@9 53 # clean remove files from the build directory
alpar@9 54 # compile compile a source file into a libtool object
alpar@9 55 # execute automatically set library path, then run a program
alpar@9 56 # finish complete the installation of libtool libraries
alpar@9 57 # install install libraries or executables
alpar@9 58 # link create a library or an executable
alpar@9 59 # uninstall remove libraries from an installed directory
alpar@9 60 #
alpar@9 61 # MODE-ARGS vary depending on the MODE. When passed as first option,
alpar@9 62 # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
alpar@9 63 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
alpar@9 64 #
alpar@9 65 # When reporting a bug, please describe a test case to reproduce it and
alpar@9 66 # include the following information:
alpar@9 67 #
alpar@9 68 # host-triplet: $host
alpar@9 69 # shell: $SHELL
alpar@9 70 # compiler: $LTCC
alpar@9 71 # compiler flags: $LTCFLAGS
alpar@9 72 # linker: $LD (gnu? $with_gnu_ld)
alpar@9 73 # $progname: (GNU libtool 1.3140 2009-12-30) 2.2.7a
alpar@9 74 # automake: $automake_version
alpar@9 75 # autoconf: $autoconf_version
alpar@9 76 #
alpar@9 77 # Report bugs to <bug-libtool@gnu.org>.
alpar@9 78
alpar@9 79 PROGRAM=libtool
alpar@9 80 PACKAGE=libtool
alpar@9 81 VERSION=2.2.7a
alpar@9 82 TIMESTAMP=" 1.3140 2009-12-30"
alpar@9 83 package_revision=1.3140
alpar@9 84
alpar@9 85 # Be Bourne compatible
alpar@9 86 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
alpar@9 87 emulate sh
alpar@9 88 NULLCMD=:
alpar@9 89 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
alpar@9 90 # is contrary to our usage. Disable this feature.
alpar@9 91 alias -g '${1+"$@"}'='"$@"'
alpar@9 92 setopt NO_GLOB_SUBST
alpar@9 93 else
alpar@9 94 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
alpar@9 95 fi
alpar@9 96 BIN_SH=xpg4; export BIN_SH # for Tru64
alpar@9 97 DUALCASE=1; export DUALCASE # for MKS sh
alpar@9 98
alpar@9 99 # A function that is used when there is no print builtin or printf.
alpar@9 100 func_fallback_echo ()
alpar@9 101 {
alpar@9 102 eval 'cat <<_LTECHO_EOF
alpar@9 103 $1
alpar@9 104 _LTECHO_EOF'
alpar@9 105 }
alpar@9 106
alpar@9 107 # NLS nuisances: We save the old values to restore during execute mode.
alpar@9 108 # Only set LANG and LC_ALL to C if already set.
alpar@9 109 # These must not be set unconditionally because not all systems understand
alpar@9 110 # e.g. LANG=C (notably SCO).
alpar@9 111 lt_user_locale=
alpar@9 112 lt_safe_locale=
alpar@9 113 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
alpar@9 114 do
alpar@9 115 eval "if test \"\${$lt_var+set}\" = set; then
alpar@9 116 save_$lt_var=\$$lt_var
alpar@9 117 $lt_var=C
alpar@9 118 export $lt_var
alpar@9 119 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
alpar@9 120 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
alpar@9 121 fi"
alpar@9 122 done
alpar@9 123
alpar@9 124 $lt_unset CDPATH
alpar@9 125
alpar@9 126
alpar@9 127
alpar@9 128
alpar@9 129
alpar@9 130
alpar@9 131
alpar@9 132 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
alpar@9 133 # is ksh but when the shell is invoked as "sh" and the current value of
alpar@9 134 # the _XPG environment variable is not equal to 1 (one), the special
alpar@9 135 # positional parameter $0, within a function call, is the name of the
alpar@9 136 # function.
alpar@9 137 progpath="$0"
alpar@9 138
alpar@9 139
alpar@9 140
alpar@9 141 : ${CP="cp -f"}
alpar@9 142 test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
alpar@9 143 : ${EGREP="/usr/bin/grep -E"}
alpar@9 144 : ${FGREP="/usr/bin/grep -F"}
alpar@9 145 : ${GREP="/usr/bin/grep"}
alpar@9 146 : ${LN_S="ln -s"}
alpar@9 147 : ${MAKE="make"}
alpar@9 148 : ${MKDIR="mkdir"}
alpar@9 149 : ${MV="mv -f"}
alpar@9 150 : ${RM="rm -f"}
alpar@9 151 : ${SED="/usr/bin/sed"}
alpar@9 152 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
alpar@9 153 : ${Xsed="$SED -e 1s/^X//"}
alpar@9 154
alpar@9 155 # Global variables:
alpar@9 156 EXIT_SUCCESS=0
alpar@9 157 EXIT_FAILURE=1
alpar@9 158 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
alpar@9 159 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
alpar@9 160
alpar@9 161 exit_status=$EXIT_SUCCESS
alpar@9 162
alpar@9 163 # Make sure IFS has a sensible default
alpar@9 164 lt_nl='
alpar@9 165 '
alpar@9 166 IFS=" $lt_nl"
alpar@9 167
alpar@9 168 dirname="s,/[^/]*$,,"
alpar@9 169 basename="s,^.*/,,"
alpar@9 170
alpar@9 171 # func_dirname_and_basename file append nondir_replacement
alpar@9 172 # perform func_basename and func_dirname in a single function
alpar@9 173 # call:
alpar@9 174 # dirname: Compute the dirname of FILE. If nonempty,
alpar@9 175 # add APPEND to the result, otherwise set result
alpar@9 176 # to NONDIR_REPLACEMENT.
alpar@9 177 # value returned in "$func_dirname_result"
alpar@9 178 # basename: Compute filename of FILE.
alpar@9 179 # value retuned in "$func_basename_result"
alpar@9 180 # Implementation must be kept synchronized with func_dirname
alpar@9 181 # and func_basename. For efficiency, we do not delegate to
alpar@9 182 # those functions but instead duplicate the functionality here.
alpar@9 183 func_dirname_and_basename ()
alpar@9 184 {
alpar@9 185 # Extract subdirectory from the argument.
alpar@9 186 func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
alpar@9 187 if test "X$func_dirname_result" = "X${1}"; then
alpar@9 188 func_dirname_result="${3}"
alpar@9 189 else
alpar@9 190 func_dirname_result="$func_dirname_result${2}"
alpar@9 191 fi
alpar@9 192 func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
alpar@9 193 }
alpar@9 194
alpar@9 195 # Generated shell functions inserted here.
alpar@9 196
alpar@9 197 # These SED scripts presuppose an absolute path with a trailing slash.
alpar@9 198 pathcar='s,^/\([^/]*\).*$,\1,'
alpar@9 199 pathcdr='s,^/[^/]*,,'
alpar@9 200 removedotparts=':dotsl
alpar@9 201 s@/\./@/@g
alpar@9 202 t dotsl
alpar@9 203 s,/\.$,/,'
alpar@9 204 collapseslashes='s@/\{1,\}@/@g'
alpar@9 205 finalslash='s,/*$,/,'
alpar@9 206
alpar@9 207 # func_normal_abspath PATH
alpar@9 208 # Remove doubled-up and trailing slashes, "." path components,
alpar@9 209 # and cancel out any ".." path components in PATH after making
alpar@9 210 # it an absolute path.
alpar@9 211 # value returned in "$func_normal_abspath_result"
alpar@9 212 func_normal_abspath ()
alpar@9 213 {
alpar@9 214 # Start from root dir and reassemble the path.
alpar@9 215 func_normal_abspath_result=
alpar@9 216 func_normal_abspath_tpath=$1
alpar@9 217 func_normal_abspath_altnamespace=
alpar@9 218 case $func_normal_abspath_tpath in
alpar@9 219 "")
alpar@9 220 # Empty path, that just means $cwd.
alpar@9 221 func_stripname '' '/' "`pwd`"
alpar@9 222 func_normal_abspath_result=$func_stripname_result
alpar@9 223 return
alpar@9 224 ;;
alpar@9 225 # The next three entries are used to spot a run of precisely
alpar@9 226 # two leading slashes without using negated character classes;
alpar@9 227 # we take advantage of case's first-match behaviour.
alpar@9 228 ///*)
alpar@9 229 # Unusual form of absolute path, do nothing.
alpar@9 230 ;;
alpar@9 231 //*)
alpar@9 232 # Not necessarily an ordinary path; POSIX reserves leading '//'
alpar@9 233 # and for example Cygwin uses it to access remote file shares
alpar@9 234 # over CIFS/SMB, so we conserve a leading double slash if found.
alpar@9 235 func_normal_abspath_altnamespace=/
alpar@9 236 ;;
alpar@9 237 /*)
alpar@9 238 # Absolute path, do nothing.
alpar@9 239 ;;
alpar@9 240 *)
alpar@9 241 # Relative path, prepend $cwd.
alpar@9 242 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
alpar@9 243 ;;
alpar@9 244 esac
alpar@9 245 # Cancel out all the simple stuff to save iterations. We also want
alpar@9 246 # the path to end with a slash for ease of parsing, so make sure
alpar@9 247 # there is one (and only one) here.
alpar@9 248 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
alpar@9 249 -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
alpar@9 250 while :; do
alpar@9 251 # Processed it all yet?
alpar@9 252 if test "$func_normal_abspath_tpath" = / ; then
alpar@9 253 # If we ascended to the root using ".." the result may be empty now.
alpar@9 254 if test -z "$func_normal_abspath_result" ; then
alpar@9 255 func_normal_abspath_result=/
alpar@9 256 fi
alpar@9 257 break
alpar@9 258 fi
alpar@9 259 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
alpar@9 260 -e "$pathcar"`
alpar@9 261 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
alpar@9 262 -e "$pathcdr"`
alpar@9 263 # Figure out what to do with it
alpar@9 264 case $func_normal_abspath_tcomponent in
alpar@9 265 "")
alpar@9 266 # Trailing empty path component, ignore it.
alpar@9 267 ;;
alpar@9 268 ..)
alpar@9 269 # Parent dir; strip last assembled component from result.
alpar@9 270 func_dirname "$func_normal_abspath_result"
alpar@9 271 func_normal_abspath_result=$func_dirname_result
alpar@9 272 ;;
alpar@9 273 *)
alpar@9 274 # Actual path component, append it.
alpar@9 275 func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
alpar@9 276 ;;
alpar@9 277 esac
alpar@9 278 done
alpar@9 279 # Restore leading double-slash if one was found on entry.
alpar@9 280 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
alpar@9 281 }
alpar@9 282
alpar@9 283 # func_relative_path SRCDIR DSTDIR
alpar@9 284 # generates a relative path from SRCDIR to DSTDIR, with a trailing
alpar@9 285 # slash if non-empty, suitable for immediately appending a filename
alpar@9 286 # without needing to append a separator.
alpar@9 287 # value returned in "$func_relative_path_result"
alpar@9 288 func_relative_path ()
alpar@9 289 {
alpar@9 290 func_relative_path_result=
alpar@9 291 func_normal_abspath "$1"
alpar@9 292 func_relative_path_tlibdir=$func_normal_abspath_result
alpar@9 293 func_normal_abspath "$2"
alpar@9 294 func_relative_path_tbindir=$func_normal_abspath_result
alpar@9 295
alpar@9 296 # Ascend the tree starting from libdir
alpar@9 297 while :; do
alpar@9 298 # check if we have found a prefix of bindir
alpar@9 299 case $func_relative_path_tbindir in
alpar@9 300 $func_relative_path_tlibdir)
alpar@9 301 # found an exact match
alpar@9 302 func_relative_path_tcancelled=
alpar@9 303 break
alpar@9 304 ;;
alpar@9 305 $func_relative_path_tlibdir*)
alpar@9 306 # found a matching prefix
alpar@9 307 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
alpar@9 308 func_relative_path_tcancelled=$func_stripname_result
alpar@9 309 if test -z "$func_relative_path_result"; then
alpar@9 310 func_relative_path_result=.
alpar@9 311 fi
alpar@9 312 break
alpar@9 313 ;;
alpar@9 314 *)
alpar@9 315 func_dirname $func_relative_path_tlibdir
alpar@9 316 func_relative_path_tlibdir=${func_dirname_result}
alpar@9 317 if test "x$func_relative_path_tlibdir" = x ; then
alpar@9 318 # Have to descend all the way to the root!
alpar@9 319 func_relative_path_result=../$func_relative_path_result
alpar@9 320 func_relative_path_tcancelled=$func_relative_path_tbindir
alpar@9 321 break
alpar@9 322 fi
alpar@9 323 func_relative_path_result=../$func_relative_path_result
alpar@9 324 ;;
alpar@9 325 esac
alpar@9 326 done
alpar@9 327
alpar@9 328 # Now calculate path; take care to avoid doubling-up slashes.
alpar@9 329 func_stripname '' '/' "$func_relative_path_result"
alpar@9 330 func_relative_path_result=$func_stripname_result
alpar@9 331 func_stripname '/' '/' "$func_relative_path_tcancelled"
alpar@9 332 if test "x$func_stripname_result" != x ; then
alpar@9 333 func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
alpar@9 334 fi
alpar@9 335
alpar@9 336 # Normalisation. If bindir is libdir, return empty string,
alpar@9 337 # else relative path ending with a slash; either way, target
alpar@9 338 # file name can be directly appended.
alpar@9 339 if test ! -z "$func_relative_path_result"; then
alpar@9 340 func_stripname './' '' "$func_relative_path_result/"
alpar@9 341 func_relative_path_result=$func_stripname_result
alpar@9 342 fi
alpar@9 343 }
alpar@9 344
alpar@9 345 # The name of this program:
alpar@9 346 func_dirname_and_basename "$progpath"
alpar@9 347 progname=$func_basename_result
alpar@9 348
alpar@9 349 # Make sure we have an absolute path for reexecution:
alpar@9 350 case $progpath in
alpar@9 351 [\\/]*|[A-Za-z]:\\*) ;;
alpar@9 352 *[\\/]*)
alpar@9 353 progdir=$func_dirname_result
alpar@9 354 progdir=`cd "$progdir" && pwd`
alpar@9 355 progpath="$progdir/$progname"
alpar@9 356 ;;
alpar@9 357 *)
alpar@9 358 save_IFS="$IFS"
alpar@9 359 IFS=:
alpar@9 360 for progdir in $PATH; do
alpar@9 361 IFS="$save_IFS"
alpar@9 362 test -x "$progdir/$progname" && break
alpar@9 363 done
alpar@9 364 IFS="$save_IFS"
alpar@9 365 test -n "$progdir" || progdir=`pwd`
alpar@9 366 progpath="$progdir/$progname"
alpar@9 367 ;;
alpar@9 368 esac
alpar@9 369
alpar@9 370 # Sed substitution that helps us do robust quoting. It backslashifies
alpar@9 371 # metacharacters that are still active within double-quoted strings.
alpar@9 372 Xsed="${SED}"' -e 1s/^X//'
alpar@9 373 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
alpar@9 374
alpar@9 375 # Same as above, but do not quote variable references.
alpar@9 376 double_quote_subst='s/\(["`\\]\)/\\\1/g'
alpar@9 377
alpar@9 378 # Re-`\' parameter expansions in output of double_quote_subst that were
alpar@9 379 # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
alpar@9 380 # in input to double_quote_subst, that '$' was protected from expansion.
alpar@9 381 # Since each input `\' is now two `\'s, look for any number of runs of
alpar@9 382 # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
alpar@9 383 bs='\\'
alpar@9 384 bs2='\\\\'
alpar@9 385 bs4='\\\\\\\\'
alpar@9 386 dollar='\$'
alpar@9 387 sed_double_backslash="\
alpar@9 388 s/$bs4/&\\
alpar@9 389 /g
alpar@9 390 s/^$bs2$dollar/$bs&/
alpar@9 391 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
alpar@9 392 s/\n//g"
alpar@9 393
alpar@9 394 # Standard options:
alpar@9 395 opt_dry_run=false
alpar@9 396 opt_help=false
alpar@9 397 opt_quiet=false
alpar@9 398 opt_verbose=false
alpar@9 399 opt_warning=:
alpar@9 400
alpar@9 401 # func_echo arg...
alpar@9 402 # Echo program name prefixed message, along with the current mode
alpar@9 403 # name if it has been set yet.
alpar@9 404 func_echo ()
alpar@9 405 {
alpar@9 406 $ECHO "$progname${mode+: }$mode: $*"
alpar@9 407 }
alpar@9 408
alpar@9 409 # func_verbose arg...
alpar@9 410 # Echo program name prefixed message in verbose mode only.
alpar@9 411 func_verbose ()
alpar@9 412 {
alpar@9 413 $opt_verbose && func_echo ${1+"$@"}
alpar@9 414
alpar@9 415 # A bug in bash halts the script if the last line of a function
alpar@9 416 # fails when set -e is in force, so we need another command to
alpar@9 417 # work around that:
alpar@9 418 :
alpar@9 419 }
alpar@9 420
alpar@9 421 # func_echo_all arg...
alpar@9 422 # Invoke $ECHO with all args, space-separated.
alpar@9 423 func_echo_all ()
alpar@9 424 {
alpar@9 425 $ECHO "$*"
alpar@9 426 }
alpar@9 427
alpar@9 428 # func_error arg...
alpar@9 429 # Echo program name prefixed message to standard error.
alpar@9 430 func_error ()
alpar@9 431 {
alpar@9 432 $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
alpar@9 433 }
alpar@9 434
alpar@9 435 # func_warning arg...
alpar@9 436 # Echo program name prefixed warning message to standard error.
alpar@9 437 func_warning ()
alpar@9 438 {
alpar@9 439 $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
alpar@9 440
alpar@9 441 # bash bug again:
alpar@9 442 :
alpar@9 443 }
alpar@9 444
alpar@9 445 # func_fatal_error arg...
alpar@9 446 # Echo program name prefixed message to standard error, and exit.
alpar@9 447 func_fatal_error ()
alpar@9 448 {
alpar@9 449 func_error ${1+"$@"}
alpar@9 450 exit $EXIT_FAILURE
alpar@9 451 }
alpar@9 452
alpar@9 453 # func_fatal_help arg...
alpar@9 454 # Echo program name prefixed message to standard error, followed by
alpar@9 455 # a help hint, and exit.
alpar@9 456 func_fatal_help ()
alpar@9 457 {
alpar@9 458 func_error ${1+"$@"}
alpar@9 459 func_fatal_error "$help"
alpar@9 460 }
alpar@9 461 help="Try \`$progname --help' for more information." ## default
alpar@9 462
alpar@9 463
alpar@9 464 # func_grep expression filename
alpar@9 465 # Check whether EXPRESSION matches any line of FILENAME, without output.
alpar@9 466 func_grep ()
alpar@9 467 {
alpar@9 468 $GREP "$1" "$2" >/dev/null 2>&1
alpar@9 469 }
alpar@9 470
alpar@9 471
alpar@9 472 # func_mkdir_p directory-path
alpar@9 473 # Make sure the entire path to DIRECTORY-PATH is available.
alpar@9 474 func_mkdir_p ()
alpar@9 475 {
alpar@9 476 my_directory_path="$1"
alpar@9 477 my_dir_list=
alpar@9 478
alpar@9 479 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
alpar@9 480
alpar@9 481 # Protect directory names starting with `-'
alpar@9 482 case $my_directory_path in
alpar@9 483 -*) my_directory_path="./$my_directory_path" ;;
alpar@9 484 esac
alpar@9 485
alpar@9 486 # While some portion of DIR does not yet exist...
alpar@9 487 while test ! -d "$my_directory_path"; do
alpar@9 488 # ...make a list in topmost first order. Use a colon delimited
alpar@9 489 # list incase some portion of path contains whitespace.
alpar@9 490 my_dir_list="$my_directory_path:$my_dir_list"
alpar@9 491
alpar@9 492 # If the last portion added has no slash in it, the list is done
alpar@9 493 case $my_directory_path in */*) ;; *) break ;; esac
alpar@9 494
alpar@9 495 # ...otherwise throw away the child directory and loop
alpar@9 496 my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
alpar@9 497 done
alpar@9 498 my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
alpar@9 499
alpar@9 500 save_mkdir_p_IFS="$IFS"; IFS=':'
alpar@9 501 for my_dir in $my_dir_list; do
alpar@9 502 IFS="$save_mkdir_p_IFS"
alpar@9 503 # mkdir can fail with a `File exist' error if two processes
alpar@9 504 # try to create one of the directories concurrently. Don't
alpar@9 505 # stop in that case!
alpar@9 506 $MKDIR "$my_dir" 2>/dev/null || :
alpar@9 507 done
alpar@9 508 IFS="$save_mkdir_p_IFS"
alpar@9 509
alpar@9 510 # Bail out if we (or some other process) failed to create a directory.
alpar@9 511 test -d "$my_directory_path" || \
alpar@9 512 func_fatal_error "Failed to create \`$1'"
alpar@9 513 fi
alpar@9 514 }
alpar@9 515
alpar@9 516
alpar@9 517 # func_mktempdir [string]
alpar@9 518 # Make a temporary directory that won't clash with other running
alpar@9 519 # libtool processes, and avoids race conditions if possible. If
alpar@9 520 # given, STRING is the basename for that directory.
alpar@9 521 func_mktempdir ()
alpar@9 522 {
alpar@9 523 my_template="${TMPDIR-/tmp}/${1-$progname}"
alpar@9 524
alpar@9 525 if test "$opt_dry_run" = ":"; then
alpar@9 526 # Return a directory name, but don't create it in dry-run mode
alpar@9 527 my_tmpdir="${my_template}-$$"
alpar@9 528 else
alpar@9 529
alpar@9 530 # If mktemp works, use that first and foremost
alpar@9 531 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
alpar@9 532
alpar@9 533 if test ! -d "$my_tmpdir"; then
alpar@9 534 # Failing that, at least try and use $RANDOM to avoid a race
alpar@9 535 my_tmpdir="${my_template}-${RANDOM-0}$$"
alpar@9 536
alpar@9 537 save_mktempdir_umask=`umask`
alpar@9 538 umask 0077
alpar@9 539 $MKDIR "$my_tmpdir"
alpar@9 540 umask $save_mktempdir_umask
alpar@9 541 fi
alpar@9 542
alpar@9 543 # If we're not in dry-run mode, bomb out on failure
alpar@9 544 test -d "$my_tmpdir" || \
alpar@9 545 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
alpar@9 546 fi
alpar@9 547
alpar@9 548 $ECHO "$my_tmpdir"
alpar@9 549 }
alpar@9 550
alpar@9 551
alpar@9 552 # func_quote_for_eval arg
alpar@9 553 # Aesthetically quote ARG to be evaled later.
alpar@9 554 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
alpar@9 555 # is double-quoted, suitable for a subsequent eval, whereas
alpar@9 556 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
alpar@9 557 # which are still active within double quotes backslashified.
alpar@9 558 func_quote_for_eval ()
alpar@9 559 {
alpar@9 560 case $1 in
alpar@9 561 *[\\\`\"\$]*)
alpar@9 562 func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
alpar@9 563 *)
alpar@9 564 func_quote_for_eval_unquoted_result="$1" ;;
alpar@9 565 esac
alpar@9 566
alpar@9 567 case $func_quote_for_eval_unquoted_result in
alpar@9 568 # Double-quote args containing shell metacharacters to delay
alpar@9 569 # word splitting, command substitution and and variable
alpar@9 570 # expansion for a subsequent eval.
alpar@9 571 # Many Bourne shells cannot handle close brackets correctly
alpar@9 572 # in scan sets, so we specify it separately.
alpar@9 573 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
alpar@9 574 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
alpar@9 575 ;;
alpar@9 576 *)
alpar@9 577 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
alpar@9 578 esac
alpar@9 579 }
alpar@9 580
alpar@9 581
alpar@9 582 # func_quote_for_expand arg
alpar@9 583 # Aesthetically quote ARG to be evaled later; same as above,
alpar@9 584 # but do not quote variable references.
alpar@9 585 func_quote_for_expand ()
alpar@9 586 {
alpar@9 587 case $1 in
alpar@9 588 *[\\\`\"]*)
alpar@9 589 my_arg=`$ECHO "$1" | $SED \
alpar@9 590 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
alpar@9 591 *)
alpar@9 592 my_arg="$1" ;;
alpar@9 593 esac
alpar@9 594
alpar@9 595 case $my_arg in
alpar@9 596 # Double-quote args containing shell metacharacters to delay
alpar@9 597 # word splitting and command substitution for a subsequent eval.
alpar@9 598 # Many Bourne shells cannot handle close brackets correctly
alpar@9 599 # in scan sets, so we specify it separately.
alpar@9 600 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
alpar@9 601 my_arg="\"$my_arg\""
alpar@9 602 ;;
alpar@9 603 esac
alpar@9 604
alpar@9 605 func_quote_for_expand_result="$my_arg"
alpar@9 606 }
alpar@9 607
alpar@9 608
alpar@9 609 # func_show_eval cmd [fail_exp]
alpar@9 610 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
alpar@9 611 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
alpar@9 612 # is given, then evaluate it.
alpar@9 613 func_show_eval ()
alpar@9 614 {
alpar@9 615 my_cmd="$1"
alpar@9 616 my_fail_exp="${2-:}"
alpar@9 617
alpar@9 618 ${opt_silent-false} || {
alpar@9 619 func_quote_for_expand "$my_cmd"
alpar@9 620 eval "func_echo $func_quote_for_expand_result"
alpar@9 621 }
alpar@9 622
alpar@9 623 if ${opt_dry_run-false}; then :; else
alpar@9 624 eval "$my_cmd"
alpar@9 625 my_status=$?
alpar@9 626 if test "$my_status" -eq 0; then :; else
alpar@9 627 eval "(exit $my_status); $my_fail_exp"
alpar@9 628 fi
alpar@9 629 fi
alpar@9 630 }
alpar@9 631
alpar@9 632
alpar@9 633 # func_show_eval_locale cmd [fail_exp]
alpar@9 634 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
alpar@9 635 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
alpar@9 636 # is given, then evaluate it. Use the saved locale for evaluation.
alpar@9 637 func_show_eval_locale ()
alpar@9 638 {
alpar@9 639 my_cmd="$1"
alpar@9 640 my_fail_exp="${2-:}"
alpar@9 641
alpar@9 642 ${opt_silent-false} || {
alpar@9 643 func_quote_for_expand "$my_cmd"
alpar@9 644 eval "func_echo $func_quote_for_expand_result"
alpar@9 645 }
alpar@9 646
alpar@9 647 if ${opt_dry_run-false}; then :; else
alpar@9 648 eval "$lt_user_locale
alpar@9 649 $my_cmd"
alpar@9 650 my_status=$?
alpar@9 651 eval "$lt_safe_locale"
alpar@9 652 if test "$my_status" -eq 0; then :; else
alpar@9 653 eval "(exit $my_status); $my_fail_exp"
alpar@9 654 fi
alpar@9 655 fi
alpar@9 656 }
alpar@9 657
alpar@9 658 # func_tr_sh
alpar@9 659 # Turn $1 into a string suitable for a shell variable name.
alpar@9 660 # Result is stored in $func_tr_sh_result. All characters
alpar@9 661 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
alpar@9 662 # if $1 begins with a digit, a '_' is prepended as well.
alpar@9 663 func_tr_sh ()
alpar@9 664 {
alpar@9 665 case "$1" in
alpar@9 666 [0-9]* | *[!a-zA-Z0-9_]*)
alpar@9 667 func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
alpar@9 668 ;;
alpar@9 669 * )
alpar@9 670 func_tr_sh_result=$1
alpar@9 671 ;;
alpar@9 672 esac
alpar@9 673 }
alpar@9 674
alpar@9 675
alpar@9 676
alpar@9 677
alpar@9 678
alpar@9 679 # func_version
alpar@9 680 # Echo version message to standard output and exit.
alpar@9 681 func_version ()
alpar@9 682 {
alpar@9 683 $SED -n '/(C)/!b go
alpar@9 684 :more
alpar@9 685 /\./!{
alpar@9 686 N
alpar@9 687 s/\n# //
alpar@9 688 b more
alpar@9 689 }
alpar@9 690 :go
alpar@9 691 /^# '$PROGRAM' (GNU /,/# warranty; / {
alpar@9 692 s/^# //
alpar@9 693 s/^# *$//
alpar@9 694 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
alpar@9 695 p
alpar@9 696 }' < "$progpath"
alpar@9 697 exit $?
alpar@9 698 }
alpar@9 699
alpar@9 700 # func_usage
alpar@9 701 # Echo short help message to standard output and exit.
alpar@9 702 func_usage ()
alpar@9 703 {
alpar@9 704 $SED -n '/^# Usage:/,/^# *-h/ {
alpar@9 705 s/^# //
alpar@9 706 s/^# *$//
alpar@9 707 s/\$progname/'$progname'/
alpar@9 708 p
alpar@9 709 }' < "$progpath"
alpar@9 710 echo
alpar@9 711 $ECHO "run \`$progname --help | more' for full usage"
alpar@9 712 exit $?
alpar@9 713 }
alpar@9 714
alpar@9 715 # func_help [NOEXIT]
alpar@9 716 # Echo long help message to standard output and exit,
alpar@9 717 # unless 'noexit' is passed as argument.
alpar@9 718 func_help ()
alpar@9 719 {
alpar@9 720 $SED -n '/^# Usage:/,/# Report bugs to/ {
alpar@9 721 s/^# //
alpar@9 722 s/^# *$//
alpar@9 723 s*\$progname*'$progname'*
alpar@9 724 s*\$host*'"$host"'*
alpar@9 725 s*\$SHELL*'"$SHELL"'*
alpar@9 726 s*\$LTCC*'"$LTCC"'*
alpar@9 727 s*\$LTCFLAGS*'"$LTCFLAGS"'*
alpar@9 728 s*\$LD*'"$LD"'*
alpar@9 729 s/\$with_gnu_ld/'"$with_gnu_ld"'/
alpar@9 730 s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
alpar@9 731 s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
alpar@9 732 p
alpar@9 733 }' < "$progpath"
alpar@9 734 ret=$?
alpar@9 735 if test -z "$1"; then
alpar@9 736 exit $ret
alpar@9 737 fi
alpar@9 738 }
alpar@9 739
alpar@9 740 # func_missing_arg argname
alpar@9 741 # Echo program name prefixed message to standard error and set global
alpar@9 742 # exit_cmd.
alpar@9 743 func_missing_arg ()
alpar@9 744 {
alpar@9 745 func_error "missing argument for $1"
alpar@9 746 exit_cmd=exit
alpar@9 747 }
alpar@9 748
alpar@9 749 exit_cmd=:
alpar@9 750
alpar@9 751
alpar@9 752
alpar@9 753
alpar@9 754
alpar@9 755
alpar@9 756 magic="%%%MAGIC variable%%%"
alpar@9 757 magic_exe="%%%MAGIC EXE variable%%%"
alpar@9 758
alpar@9 759 # Global variables.
alpar@9 760 # $mode is unset
alpar@9 761 nonopt=
alpar@9 762 execute_dlfiles=
alpar@9 763 preserve_args=
alpar@9 764 lo2o="s/\\.lo\$/.${objext}/"
alpar@9 765 o2lo="s/\\.${objext}\$/.lo/"
alpar@9 766 extracted_archives=
alpar@9 767 extracted_serial=0
alpar@9 768
alpar@9 769 opt_dry_run=false
alpar@9 770 opt_duplicate_deps=false
alpar@9 771 opt_silent=false
alpar@9 772 opt_debug=:
alpar@9 773
alpar@9 774 # If this variable is set in any of the actions, the command in it
alpar@9 775 # will be execed at the end. This prevents here-documents from being
alpar@9 776 # left over by shells.
alpar@9 777 exec_cmd=
alpar@9 778
alpar@9 779 # func_fatal_configuration arg...
alpar@9 780 # Echo program name prefixed message to standard error, followed by
alpar@9 781 # a configuration failure hint, and exit.
alpar@9 782 func_fatal_configuration ()
alpar@9 783 {
alpar@9 784 func_error ${1+"$@"}
alpar@9 785 func_error "See the $PACKAGE documentation for more information."
alpar@9 786 func_fatal_error "Fatal configuration error."
alpar@9 787 }
alpar@9 788
alpar@9 789
alpar@9 790 # func_config
alpar@9 791 # Display the configuration for all the tags in this script.
alpar@9 792 func_config ()
alpar@9 793 {
alpar@9 794 re_begincf='^# ### BEGIN LIBTOOL'
alpar@9 795 re_endcf='^# ### END LIBTOOL'
alpar@9 796
alpar@9 797 # Default configuration.
alpar@9 798 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
alpar@9 799
alpar@9 800 # Now print the configurations for the tags.
alpar@9 801 for tagname in $taglist; do
alpar@9 802 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
alpar@9 803 done
alpar@9 804
alpar@9 805 exit $?
alpar@9 806 }
alpar@9 807
alpar@9 808 # func_features
alpar@9 809 # Display the features supported by this script.
alpar@9 810 func_features ()
alpar@9 811 {
alpar@9 812 echo "host: $host"
alpar@9 813 if test "$build_libtool_libs" = yes; then
alpar@9 814 echo "enable shared libraries"
alpar@9 815 else
alpar@9 816 echo "disable shared libraries"
alpar@9 817 fi
alpar@9 818 if test "$build_old_libs" = yes; then
alpar@9 819 echo "enable static libraries"
alpar@9 820 else
alpar@9 821 echo "disable static libraries"
alpar@9 822 fi
alpar@9 823
alpar@9 824 exit $?
alpar@9 825 }
alpar@9 826
alpar@9 827 # func_enable_tag tagname
alpar@9 828 # Verify that TAGNAME is valid, and either flag an error and exit, or
alpar@9 829 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
alpar@9 830 # variable here.
alpar@9 831 func_enable_tag ()
alpar@9 832 {
alpar@9 833 # Global variable:
alpar@9 834 tagname="$1"
alpar@9 835
alpar@9 836 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
alpar@9 837 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
alpar@9 838 sed_extractcf="/$re_begincf/,/$re_endcf/p"
alpar@9 839
alpar@9 840 # Validate tagname.
alpar@9 841 case $tagname in
alpar@9 842 *[!-_A-Za-z0-9,/]*)
alpar@9 843 func_fatal_error "invalid tag name: $tagname"
alpar@9 844 ;;
alpar@9 845 esac
alpar@9 846
alpar@9 847 # Don't test for the "default" C tag, as we know it's
alpar@9 848 # there but not specially marked.
alpar@9 849 case $tagname in
alpar@9 850 CC) ;;
alpar@9 851 *)
alpar@9 852 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
alpar@9 853 taglist="$taglist $tagname"
alpar@9 854
alpar@9 855 # Evaluate the configuration. Be careful to quote the path
alpar@9 856 # and the sed script, to avoid splitting on whitespace, but
alpar@9 857 # also don't use non-portable quotes within backquotes within
alpar@9 858 # quotes we have to do it in 2 steps:
alpar@9 859 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
alpar@9 860 eval "$extractedcf"
alpar@9 861 else
alpar@9 862 func_error "ignoring unknown tag $tagname"
alpar@9 863 fi
alpar@9 864 ;;
alpar@9 865 esac
alpar@9 866 }
alpar@9 867
alpar@9 868 # Parse options once, thoroughly. This comes as soon as possible in
alpar@9 869 # the script to make things like `libtool --version' happen quickly.
alpar@9 870 {
alpar@9 871
alpar@9 872 # Shorthand for --mode=foo, only valid as the first argument
alpar@9 873 case $1 in
alpar@9 874 clean|clea|cle|cl)
alpar@9 875 shift; set dummy --mode clean ${1+"$@"}; shift
alpar@9 876 ;;
alpar@9 877 compile|compil|compi|comp|com|co|c)
alpar@9 878 shift; set dummy --mode compile ${1+"$@"}; shift
alpar@9 879 ;;
alpar@9 880 execute|execut|execu|exec|exe|ex|e)
alpar@9 881 shift; set dummy --mode execute ${1+"$@"}; shift
alpar@9 882 ;;
alpar@9 883 finish|finis|fini|fin|fi|f)
alpar@9 884 shift; set dummy --mode finish ${1+"$@"}; shift
alpar@9 885 ;;
alpar@9 886 install|instal|insta|inst|ins|in|i)
alpar@9 887 shift; set dummy --mode install ${1+"$@"}; shift
alpar@9 888 ;;
alpar@9 889 link|lin|li|l)
alpar@9 890 shift; set dummy --mode link ${1+"$@"}; shift
alpar@9 891 ;;
alpar@9 892 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
alpar@9 893 shift; set dummy --mode uninstall ${1+"$@"}; shift
alpar@9 894 ;;
alpar@9 895 esac
alpar@9 896
alpar@9 897 # Parse non-mode specific arguments:
alpar@9 898 while test "$#" -gt 0; do
alpar@9 899 opt="$1"
alpar@9 900 shift
alpar@9 901
alpar@9 902 case $opt in
alpar@9 903 --config) func_config ;;
alpar@9 904
alpar@9 905 --debug) preserve_args="$preserve_args $opt"
alpar@9 906 func_echo "enabling shell trace mode"
alpar@9 907 opt_debug='set -x'
alpar@9 908 $opt_debug
alpar@9 909 ;;
alpar@9 910
alpar@9 911 -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
alpar@9 912 execute_dlfiles="$execute_dlfiles $1"
alpar@9 913 shift
alpar@9 914 ;;
alpar@9 915
alpar@9 916 --dry-run | -n) opt_dry_run=: ;;
alpar@9 917 --features) func_features ;;
alpar@9 918 --finish) mode="finish" ;;
alpar@9 919
alpar@9 920 --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
alpar@9 921 case $1 in
alpar@9 922 # Valid mode arguments:
alpar@9 923 clean) ;;
alpar@9 924 compile) ;;
alpar@9 925 execute) ;;
alpar@9 926 finish) ;;
alpar@9 927 install) ;;
alpar@9 928 link) ;;
alpar@9 929 relink) ;;
alpar@9 930 uninstall) ;;
alpar@9 931
alpar@9 932 # Catch anything else as an error
alpar@9 933 *) func_error "invalid argument for $opt"
alpar@9 934 exit_cmd=exit
alpar@9 935 break
alpar@9 936 ;;
alpar@9 937 esac
alpar@9 938
alpar@9 939 mode="$1"
alpar@9 940 shift
alpar@9 941 ;;
alpar@9 942
alpar@9 943 --preserve-dup-deps)
alpar@9 944 opt_duplicate_deps=: ;;
alpar@9 945
alpar@9 946 --quiet|--silent) preserve_args="$preserve_args $opt"
alpar@9 947 opt_silent=:
alpar@9 948 opt_verbose=false
alpar@9 949 ;;
alpar@9 950
alpar@9 951 --no-quiet|--no-silent)
alpar@9 952 preserve_args="$preserve_args $opt"
alpar@9 953 opt_silent=false
alpar@9 954 ;;
alpar@9 955
alpar@9 956 --verbose| -v) preserve_args="$preserve_args $opt"
alpar@9 957 opt_silent=false
alpar@9 958 opt_verbose=:
alpar@9 959 ;;
alpar@9 960
alpar@9 961 --no-verbose) preserve_args="$preserve_args $opt"
alpar@9 962 opt_verbose=false
alpar@9 963 ;;
alpar@9 964
alpar@9 965 --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
alpar@9 966 preserve_args="$preserve_args $opt $1"
alpar@9 967 func_enable_tag "$1" # tagname is set here
alpar@9 968 shift
alpar@9 969 ;;
alpar@9 970
alpar@9 971 # Separate optargs to long options:
alpar@9 972 -dlopen=*|--mode=*|--tag=*)
alpar@9 973 func_opt_split "$opt"
alpar@9 974 set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
alpar@9 975 shift
alpar@9 976 ;;
alpar@9 977
alpar@9 978 -\?|-h) func_usage ;;
alpar@9 979 --help) opt_help=: ;;
alpar@9 980 --help-all) opt_help=': help-all' ;;
alpar@9 981 --version) func_version ;;
alpar@9 982
alpar@9 983 -*) func_fatal_help "unrecognized option \`$opt'" ;;
alpar@9 984
alpar@9 985 *) nonopt="$opt"
alpar@9 986 break
alpar@9 987 ;;
alpar@9 988 esac
alpar@9 989 done
alpar@9 990
alpar@9 991
alpar@9 992 case $host in
alpar@9 993 *cygwin* | *mingw* | *pw32* | *cegcc*)
alpar@9 994 # don't eliminate duplications in $postdeps and $predeps
alpar@9 995 opt_duplicate_compiler_generated_deps=:
alpar@9 996 ;;
alpar@9 997 *)
alpar@9 998 opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
alpar@9 999 ;;
alpar@9 1000 esac
alpar@9 1001
alpar@9 1002 # Having warned about all mis-specified options, bail out if
alpar@9 1003 # anything was wrong.
alpar@9 1004 $exit_cmd $EXIT_FAILURE
alpar@9 1005 }
alpar@9 1006
alpar@9 1007 # func_check_version_match
alpar@9 1008 # Ensure that we are using m4 macros, and libtool script from the same
alpar@9 1009 # release of libtool.
alpar@9 1010 func_check_version_match ()
alpar@9 1011 {
alpar@9 1012 if test "$package_revision" != "$macro_revision"; then
alpar@9 1013 if test "$VERSION" != "$macro_version"; then
alpar@9 1014 if test -z "$macro_version"; then
alpar@9 1015 cat >&2 <<_LT_EOF
alpar@9 1016 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
alpar@9 1017 $progname: definition of this LT_INIT comes from an older release.
alpar@9 1018 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
alpar@9 1019 $progname: and run autoconf again.
alpar@9 1020 _LT_EOF
alpar@9 1021 else
alpar@9 1022 cat >&2 <<_LT_EOF
alpar@9 1023 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
alpar@9 1024 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
alpar@9 1025 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
alpar@9 1026 $progname: and run autoconf again.
alpar@9 1027 _LT_EOF
alpar@9 1028 fi
alpar@9 1029 else
alpar@9 1030 cat >&2 <<_LT_EOF
alpar@9 1031 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
alpar@9 1032 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
alpar@9 1033 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
alpar@9 1034 $progname: of $PACKAGE $VERSION and run autoconf again.
alpar@9 1035 _LT_EOF
alpar@9 1036 fi
alpar@9 1037
alpar@9 1038 exit $EXIT_MISMATCH
alpar@9 1039 fi
alpar@9 1040 }
alpar@9 1041
alpar@9 1042
alpar@9 1043 ## ----------- ##
alpar@9 1044 ## Main. ##
alpar@9 1045 ## ----------- ##
alpar@9 1046
alpar@9 1047 $opt_help || {
alpar@9 1048 # Sanity checks first:
alpar@9 1049 func_check_version_match
alpar@9 1050
alpar@9 1051 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
alpar@9 1052 func_fatal_configuration "not configured to build any kind of library"
alpar@9 1053 fi
alpar@9 1054
alpar@9 1055 test -z "$mode" && func_fatal_error "error: you must specify a MODE."
alpar@9 1056
alpar@9 1057
alpar@9 1058 # Darwin sucks
alpar@9 1059 eval std_shrext=\"$shrext_cmds\"
alpar@9 1060
alpar@9 1061
alpar@9 1062 # Only execute mode is allowed to have -dlopen flags.
alpar@9 1063 if test -n "$execute_dlfiles" && test "$mode" != execute; then
alpar@9 1064 func_error "unrecognized option \`-dlopen'"
alpar@9 1065 $ECHO "$help" 1>&2
alpar@9 1066 exit $EXIT_FAILURE
alpar@9 1067 fi
alpar@9 1068
alpar@9 1069 # Change the help message to a mode-specific one.
alpar@9 1070 generic_help="$help"
alpar@9 1071 help="Try \`$progname --help --mode=$mode' for more information."
alpar@9 1072 }
alpar@9 1073
alpar@9 1074
alpar@9 1075 # func_lalib_p file
alpar@9 1076 # True iff FILE is a libtool `.la' library or `.lo' object file.
alpar@9 1077 # This function is only a basic sanity check; it will hardly flush out
alpar@9 1078 # determined imposters.
alpar@9 1079 func_lalib_p ()
alpar@9 1080 {
alpar@9 1081 test -f "$1" &&
alpar@9 1082 $SED -e 4q "$1" 2>/dev/null \
alpar@9 1083 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
alpar@9 1084 }
alpar@9 1085
alpar@9 1086 # func_lalib_unsafe_p file
alpar@9 1087 # True iff FILE is a libtool `.la' library or `.lo' object file.
alpar@9 1088 # This function implements the same check as func_lalib_p without
alpar@9 1089 # resorting to external programs. To this end, it redirects stdin and
alpar@9 1090 # closes it afterwards, without saving the original file descriptor.
alpar@9 1091 # As a safety measure, use it only where a negative result would be
alpar@9 1092 # fatal anyway. Works if `file' does not exist.
alpar@9 1093 func_lalib_unsafe_p ()
alpar@9 1094 {
alpar@9 1095 lalib_p=no
alpar@9 1096 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
alpar@9 1097 for lalib_p_l in 1 2 3 4
alpar@9 1098 do
alpar@9 1099 read lalib_p_line
alpar@9 1100 case "$lalib_p_line" in
alpar@9 1101 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
alpar@9 1102 esac
alpar@9 1103 done
alpar@9 1104 exec 0<&5 5<&-
alpar@9 1105 fi
alpar@9 1106 test "$lalib_p" = yes
alpar@9 1107 }
alpar@9 1108
alpar@9 1109 # func_ltwrapper_script_p file
alpar@9 1110 # True iff FILE is a libtool wrapper script
alpar@9 1111 # This function is only a basic sanity check; it will hardly flush out
alpar@9 1112 # determined imposters.
alpar@9 1113 func_ltwrapper_script_p ()
alpar@9 1114 {
alpar@9 1115 func_lalib_p "$1"
alpar@9 1116 }
alpar@9 1117
alpar@9 1118 # func_ltwrapper_executable_p file
alpar@9 1119 # True iff FILE is a libtool wrapper executable
alpar@9 1120 # This function is only a basic sanity check; it will hardly flush out
alpar@9 1121 # determined imposters.
alpar@9 1122 func_ltwrapper_executable_p ()
alpar@9 1123 {
alpar@9 1124 func_ltwrapper_exec_suffix=
alpar@9 1125 case $1 in
alpar@9 1126 *.exe) ;;
alpar@9 1127 *) func_ltwrapper_exec_suffix=.exe ;;
alpar@9 1128 esac
alpar@9 1129 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
alpar@9 1130 }
alpar@9 1131
alpar@9 1132 # func_ltwrapper_scriptname file
alpar@9 1133 # Assumes file is an ltwrapper_executable
alpar@9 1134 # uses $file to determine the appropriate filename for a
alpar@9 1135 # temporary ltwrapper_script.
alpar@9 1136 func_ltwrapper_scriptname ()
alpar@9 1137 {
alpar@9 1138 func_ltwrapper_scriptname_result=""
alpar@9 1139 if func_ltwrapper_executable_p "$1"; then
alpar@9 1140 func_dirname_and_basename "$1" "" "."
alpar@9 1141 func_stripname '' '.exe' "$func_basename_result"
alpar@9 1142 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
alpar@9 1143 fi
alpar@9 1144 }
alpar@9 1145
alpar@9 1146 # func_ltwrapper_p file
alpar@9 1147 # True iff FILE is a libtool wrapper script or wrapper executable
alpar@9 1148 # This function is only a basic sanity check; it will hardly flush out
alpar@9 1149 # determined imposters.
alpar@9 1150 func_ltwrapper_p ()
alpar@9 1151 {
alpar@9 1152 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
alpar@9 1153 }
alpar@9 1154
alpar@9 1155
alpar@9 1156 # func_execute_cmds commands fail_cmd
alpar@9 1157 # Execute tilde-delimited COMMANDS.
alpar@9 1158 # If FAIL_CMD is given, eval that upon failure.
alpar@9 1159 # FAIL_CMD may read-access the current command in variable CMD!
alpar@9 1160 func_execute_cmds ()
alpar@9 1161 {
alpar@9 1162 $opt_debug
alpar@9 1163 save_ifs=$IFS; IFS='~'
alpar@9 1164 for cmd in $1; do
alpar@9 1165 IFS=$save_ifs
alpar@9 1166 eval cmd=\"$cmd\"
alpar@9 1167 func_show_eval "$cmd" "${2-:}"
alpar@9 1168 done
alpar@9 1169 IFS=$save_ifs
alpar@9 1170 }
alpar@9 1171
alpar@9 1172
alpar@9 1173 # func_source file
alpar@9 1174 # Source FILE, adding directory component if necessary.
alpar@9 1175 # Note that it is not necessary on cygwin/mingw to append a dot to
alpar@9 1176 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
alpar@9 1177 # behavior happens only for exec(3), not for open(2)! Also, sourcing
alpar@9 1178 # `FILE.' does not work on cygwin managed mounts.
alpar@9 1179 func_source ()
alpar@9 1180 {
alpar@9 1181 $opt_debug
alpar@9 1182 case $1 in
alpar@9 1183 */* | *\\*) . "$1" ;;
alpar@9 1184 *) . "./$1" ;;
alpar@9 1185 esac
alpar@9 1186 }
alpar@9 1187
alpar@9 1188
alpar@9 1189 # func_infer_tag arg
alpar@9 1190 # Infer tagged configuration to use if any are available and
alpar@9 1191 # if one wasn't chosen via the "--tag" command line option.
alpar@9 1192 # Only attempt this if the compiler in the base compile
alpar@9 1193 # command doesn't match the default compiler.
alpar@9 1194 # arg is usually of the form 'gcc ...'
alpar@9 1195 func_infer_tag ()
alpar@9 1196 {
alpar@9 1197 $opt_debug
alpar@9 1198 if test -n "$available_tags" && test -z "$tagname"; then
alpar@9 1199 CC_quoted=
alpar@9 1200 for arg in $CC; do
alpar@9 1201 func_quote_for_eval "$arg"
alpar@9 1202 CC_quoted="$CC_quoted $func_quote_for_eval_result"
alpar@9 1203 done
alpar@9 1204 CC_expanded=`func_echo_all $CC`
alpar@9 1205 CC_quoted_expanded=`func_echo_all $CC_quoted`
alpar@9 1206 case $@ in
alpar@9 1207 # Blanks in the command may have been stripped by the calling shell,
alpar@9 1208 # but not from the CC environment variable when configure was run.
alpar@9 1209 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
alpar@9 1210 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
alpar@9 1211 # Blanks at the start of $base_compile will cause this to fail
alpar@9 1212 # if we don't check for them as well.
alpar@9 1213 *)
alpar@9 1214 for z in $available_tags; do
alpar@9 1215 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
alpar@9 1216 # Evaluate the configuration.
alpar@9 1217 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
alpar@9 1218 CC_quoted=
alpar@9 1219 for arg in $CC; do
alpar@9 1220 # Double-quote args containing other shell metacharacters.
alpar@9 1221 func_quote_for_eval "$arg"
alpar@9 1222 CC_quoted="$CC_quoted $func_quote_for_eval_result"
alpar@9 1223 done
alpar@9 1224 CC_expanded=`func_echo_all $CC`
alpar@9 1225 CC_quoted_expanded=`func_echo_all $CC_quoted`
alpar@9 1226 case "$@ " in
alpar@9 1227 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
alpar@9 1228 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
alpar@9 1229 # The compiler in the base compile command matches
alpar@9 1230 # the one in the tagged configuration.
alpar@9 1231 # Assume this is the tagged configuration we want.
alpar@9 1232 tagname=$z
alpar@9 1233 break
alpar@9 1234 ;;
alpar@9 1235 esac
alpar@9 1236 fi
alpar@9 1237 done
alpar@9 1238 # If $tagname still isn't set, then no tagged configuration
alpar@9 1239 # was found and let the user know that the "--tag" command
alpar@9 1240 # line option must be used.
alpar@9 1241 if test -z "$tagname"; then
alpar@9 1242 func_echo "unable to infer tagged configuration"
alpar@9 1243 func_fatal_error "specify a tag with \`--tag'"
alpar@9 1244 # else
alpar@9 1245 # func_verbose "using $tagname tagged configuration"
alpar@9 1246 fi
alpar@9 1247 ;;
alpar@9 1248 esac
alpar@9 1249 fi
alpar@9 1250 }
alpar@9 1251
alpar@9 1252
alpar@9 1253
alpar@9 1254 # func_write_libtool_object output_name pic_name nonpic_name
alpar@9 1255 # Create a libtool object file (analogous to a ".la" file),
alpar@9 1256 # but don't create it if we're doing a dry run.
alpar@9 1257 func_write_libtool_object ()
alpar@9 1258 {
alpar@9 1259 write_libobj=${1}
alpar@9 1260 if test "$build_libtool_libs" = yes; then
alpar@9 1261 write_lobj=\'${2}\'
alpar@9 1262 else
alpar@9 1263 write_lobj=none
alpar@9 1264 fi
alpar@9 1265
alpar@9 1266 if test "$build_old_libs" = yes; then
alpar@9 1267 write_oldobj=\'${3}\'
alpar@9 1268 else
alpar@9 1269 write_oldobj=none
alpar@9 1270 fi
alpar@9 1271
alpar@9 1272 $opt_dry_run || {
alpar@9 1273 cat >${write_libobj}T <<EOF
alpar@9 1274 # $write_libobj - a libtool object file
alpar@9 1275 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
alpar@9 1276 #
alpar@9 1277 # Please DO NOT delete this file!
alpar@9 1278 # It is necessary for linking the library.
alpar@9 1279
alpar@9 1280 # Name of the PIC object.
alpar@9 1281 pic_object=$write_lobj
alpar@9 1282
alpar@9 1283 # Name of the non-PIC object
alpar@9 1284 non_pic_object=$write_oldobj
alpar@9 1285
alpar@9 1286 EOF
alpar@9 1287 $MV "${write_libobj}T" "${write_libobj}"
alpar@9 1288 }
alpar@9 1289 }
alpar@9 1290
alpar@9 1291 # func_mode_compile arg...
alpar@9 1292 func_mode_compile ()
alpar@9 1293 {
alpar@9 1294 $opt_debug
alpar@9 1295 # Get the compilation command and the source file.
alpar@9 1296 base_compile=
alpar@9 1297 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
alpar@9 1298 suppress_opt=yes
alpar@9 1299 suppress_output=
alpar@9 1300 arg_mode=normal
alpar@9 1301 libobj=
alpar@9 1302 later=
alpar@9 1303 pie_flag=
alpar@9 1304
alpar@9 1305 for arg
alpar@9 1306 do
alpar@9 1307 case $arg_mode in
alpar@9 1308 arg )
alpar@9 1309 # do not "continue". Instead, add this to base_compile
alpar@9 1310 lastarg="$arg"
alpar@9 1311 arg_mode=normal
alpar@9 1312 ;;
alpar@9 1313
alpar@9 1314 target )
alpar@9 1315 libobj="$arg"
alpar@9 1316 arg_mode=normal
alpar@9 1317 continue
alpar@9 1318 ;;
alpar@9 1319
alpar@9 1320 normal )
alpar@9 1321 # Accept any command-line options.
alpar@9 1322 case $arg in
alpar@9 1323 -o)
alpar@9 1324 test -n "$libobj" && \
alpar@9 1325 func_fatal_error "you cannot specify \`-o' more than once"
alpar@9 1326 arg_mode=target
alpar@9 1327 continue
alpar@9 1328 ;;
alpar@9 1329
alpar@9 1330 -pie | -fpie | -fPIE)
alpar@9 1331 pie_flag="$pie_flag $arg"
alpar@9 1332 continue
alpar@9 1333 ;;
alpar@9 1334
alpar@9 1335 -shared | -static | -prefer-pic | -prefer-non-pic)
alpar@9 1336 later="$later $arg"
alpar@9 1337 continue
alpar@9 1338 ;;
alpar@9 1339
alpar@9 1340 -no-suppress)
alpar@9 1341 suppress_opt=no
alpar@9 1342 continue
alpar@9 1343 ;;
alpar@9 1344
alpar@9 1345 -Xcompiler)
alpar@9 1346 arg_mode=arg # the next one goes into the "base_compile" arg list
alpar@9 1347 continue # The current "srcfile" will either be retained or
alpar@9 1348 ;; # replaced later. I would guess that would be a bug.
alpar@9 1349
alpar@9 1350 -Wc,*)
alpar@9 1351 func_stripname '-Wc,' '' "$arg"
alpar@9 1352 args=$func_stripname_result
alpar@9 1353 lastarg=
alpar@9 1354 save_ifs="$IFS"; IFS=','
alpar@9 1355 for arg in $args; do
alpar@9 1356 IFS="$save_ifs"
alpar@9 1357 func_quote_for_eval "$arg"
alpar@9 1358 lastarg="$lastarg $func_quote_for_eval_result"
alpar@9 1359 done
alpar@9 1360 IFS="$save_ifs"
alpar@9 1361 func_stripname ' ' '' "$lastarg"
alpar@9 1362 lastarg=$func_stripname_result
alpar@9 1363
alpar@9 1364 # Add the arguments to base_compile.
alpar@9 1365 base_compile="$base_compile $lastarg"
alpar@9 1366 continue
alpar@9 1367 ;;
alpar@9 1368
alpar@9 1369 *)
alpar@9 1370 # Accept the current argument as the source file.
alpar@9 1371 # The previous "srcfile" becomes the current argument.
alpar@9 1372 #
alpar@9 1373 lastarg="$srcfile"
alpar@9 1374 srcfile="$arg"
alpar@9 1375 ;;
alpar@9 1376 esac # case $arg
alpar@9 1377 ;;
alpar@9 1378 esac # case $arg_mode
alpar@9 1379
alpar@9 1380 # Aesthetically quote the previous argument.
alpar@9 1381 func_quote_for_eval "$lastarg"
alpar@9 1382 base_compile="$base_compile $func_quote_for_eval_result"
alpar@9 1383 done # for arg
alpar@9 1384
alpar@9 1385 case $arg_mode in
alpar@9 1386 arg)
alpar@9 1387 func_fatal_error "you must specify an argument for -Xcompile"
alpar@9 1388 ;;
alpar@9 1389 target)
alpar@9 1390 func_fatal_error "you must specify a target with \`-o'"
alpar@9 1391 ;;
alpar@9 1392 *)
alpar@9 1393 # Get the name of the library object.
alpar@9 1394 test -z "$libobj" && {
alpar@9 1395 func_basename "$srcfile"
alpar@9 1396 libobj="$func_basename_result"
alpar@9 1397 }
alpar@9 1398 ;;
alpar@9 1399 esac
alpar@9 1400
alpar@9 1401 # Recognize several different file suffixes.
alpar@9 1402 # If the user specifies -o file.o, it is replaced with file.lo
alpar@9 1403 case $libobj in
alpar@9 1404 *.[cCFSifmso] | \
alpar@9 1405 *.ada | *.adb | *.ads | *.asm | \
alpar@9 1406 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
alpar@9 1407 *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
alpar@9 1408 func_xform "$libobj"
alpar@9 1409 libobj=$func_xform_result
alpar@9 1410 ;;
alpar@9 1411 esac
alpar@9 1412
alpar@9 1413 case $libobj in
alpar@9 1414 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
alpar@9 1415 *)
alpar@9 1416 func_fatal_error "cannot determine name of library object from \`$libobj'"
alpar@9 1417 ;;
alpar@9 1418 esac
alpar@9 1419
alpar@9 1420 func_infer_tag $base_compile
alpar@9 1421
alpar@9 1422 for arg in $later; do
alpar@9 1423 case $arg in
alpar@9 1424 -shared)
alpar@9 1425 test "$build_libtool_libs" != yes && \
alpar@9 1426 func_fatal_configuration "can not build a shared library"
alpar@9 1427 build_old_libs=no
alpar@9 1428 continue
alpar@9 1429 ;;
alpar@9 1430
alpar@9 1431 -static)
alpar@9 1432 build_libtool_libs=no
alpar@9 1433 build_old_libs=yes
alpar@9 1434 continue
alpar@9 1435 ;;
alpar@9 1436
alpar@9 1437 -prefer-pic)
alpar@9 1438 pic_mode=yes
alpar@9 1439 continue
alpar@9 1440 ;;
alpar@9 1441
alpar@9 1442 -prefer-non-pic)
alpar@9 1443 pic_mode=no
alpar@9 1444 continue
alpar@9 1445 ;;
alpar@9 1446 esac
alpar@9 1447 done
alpar@9 1448
alpar@9 1449 func_quote_for_eval "$libobj"
alpar@9 1450 test "X$libobj" != "X$func_quote_for_eval_result" \
alpar@9 1451 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
alpar@9 1452 && func_warning "libobj name \`$libobj' may not contain shell special characters."
alpar@9 1453 func_dirname_and_basename "$obj" "/" ""
alpar@9 1454 objname="$func_basename_result"
alpar@9 1455 xdir="$func_dirname_result"
alpar@9 1456 lobj=${xdir}$objdir/$objname
alpar@9 1457
alpar@9 1458 test -z "$base_compile" && \
alpar@9 1459 func_fatal_help "you must specify a compilation command"
alpar@9 1460
alpar@9 1461 # Delete any leftover library objects.
alpar@9 1462 if test "$build_old_libs" = yes; then
alpar@9 1463 removelist="$obj $lobj $libobj ${libobj}T"
alpar@9 1464 else
alpar@9 1465 removelist="$lobj $libobj ${libobj}T"
alpar@9 1466 fi
alpar@9 1467
alpar@9 1468 # On Cygwin there's no "real" PIC flag so we must build both object types
alpar@9 1469 case $host_os in
alpar@9 1470 cygwin* | mingw* | pw32* | os2* | cegcc*)
alpar@9 1471 pic_mode=default
alpar@9 1472 ;;
alpar@9 1473 esac
alpar@9 1474 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
alpar@9 1475 # non-PIC code in shared libraries is not supported
alpar@9 1476 pic_mode=default
alpar@9 1477 fi
alpar@9 1478
alpar@9 1479 # Calculate the filename of the output object if compiler does
alpar@9 1480 # not support -o with -c
alpar@9 1481 if test "$compiler_c_o" = no; then
alpar@9 1482 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
alpar@9 1483 lockfile="$output_obj.lock"
alpar@9 1484 else
alpar@9 1485 output_obj=
alpar@9 1486 need_locks=no
alpar@9 1487 lockfile=
alpar@9 1488 fi
alpar@9 1489
alpar@9 1490 # Lock this critical section if it is needed
alpar@9 1491 # We use this script file to make the link, it avoids creating a new file
alpar@9 1492 if test "$need_locks" = yes; then
alpar@9 1493 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
alpar@9 1494 func_echo "Waiting for $lockfile to be removed"
alpar@9 1495 sleep 2
alpar@9 1496 done
alpar@9 1497 elif test "$need_locks" = warn; then
alpar@9 1498 if test -f "$lockfile"; then
alpar@9 1499 $ECHO "\
alpar@9 1500 *** ERROR, $lockfile exists and contains:
alpar@9 1501 `cat $lockfile 2>/dev/null`
alpar@9 1502
alpar@9 1503 This indicates that another process is trying to use the same
alpar@9 1504 temporary object file, and libtool could not work around it because
alpar@9 1505 your compiler does not support \`-c' and \`-o' together. If you
alpar@9 1506 repeat this compilation, it may succeed, by chance, but you had better
alpar@9 1507 avoid parallel builds (make -j) in this platform, or get a better
alpar@9 1508 compiler."
alpar@9 1509
alpar@9 1510 $opt_dry_run || $RM $removelist
alpar@9 1511 exit $EXIT_FAILURE
alpar@9 1512 fi
alpar@9 1513 removelist="$removelist $output_obj"
alpar@9 1514 $ECHO "$srcfile" > "$lockfile"
alpar@9 1515 fi
alpar@9 1516
alpar@9 1517 $opt_dry_run || $RM $removelist
alpar@9 1518 removelist="$removelist $lockfile"
alpar@9 1519 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
alpar@9 1520
alpar@9 1521 if test -n "$fix_srcfile_path"; then
alpar@9 1522 eval srcfile=\"$fix_srcfile_path\"
alpar@9 1523 fi
alpar@9 1524 func_quote_for_eval "$srcfile"
alpar@9 1525 qsrcfile=$func_quote_for_eval_result
alpar@9 1526
alpar@9 1527 # Only build a PIC object if we are building libtool libraries.
alpar@9 1528 if test "$build_libtool_libs" = yes; then
alpar@9 1529 # Without this assignment, base_compile gets emptied.
alpar@9 1530 fbsd_hideous_sh_bug=$base_compile
alpar@9 1531
alpar@9 1532 if test "$pic_mode" != no; then
alpar@9 1533 command="$base_compile $qsrcfile $pic_flag"
alpar@9 1534 else
alpar@9 1535 # Don't build PIC code
alpar@9 1536 command="$base_compile $qsrcfile"
alpar@9 1537 fi
alpar@9 1538
alpar@9 1539 func_mkdir_p "$xdir$objdir"
alpar@9 1540
alpar@9 1541 if test -z "$output_obj"; then
alpar@9 1542 # Place PIC objects in $objdir
alpar@9 1543 command="$command -o $lobj"
alpar@9 1544 fi
alpar@9 1545
alpar@9 1546 func_show_eval_locale "$command" \
alpar@9 1547 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
alpar@9 1548
alpar@9 1549 if test "$need_locks" = warn &&
alpar@9 1550 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
alpar@9 1551 $ECHO "\
alpar@9 1552 *** ERROR, $lockfile contains:
alpar@9 1553 `cat $lockfile 2>/dev/null`
alpar@9 1554
alpar@9 1555 but it should contain:
alpar@9 1556 $srcfile
alpar@9 1557
alpar@9 1558 This indicates that another process is trying to use the same
alpar@9 1559 temporary object file, and libtool could not work around it because
alpar@9 1560 your compiler does not support \`-c' and \`-o' together. If you
alpar@9 1561 repeat this compilation, it may succeed, by chance, but you had better
alpar@9 1562 avoid parallel builds (make -j) in this platform, or get a better
alpar@9 1563 compiler."
alpar@9 1564
alpar@9 1565 $opt_dry_run || $RM $removelist
alpar@9 1566 exit $EXIT_FAILURE
alpar@9 1567 fi
alpar@9 1568
alpar@9 1569 # Just move the object if needed, then go on to compile the next one
alpar@9 1570 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
alpar@9 1571 func_show_eval '$MV "$output_obj" "$lobj"' \
alpar@9 1572 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
alpar@9 1573 fi
alpar@9 1574
alpar@9 1575 # Allow error messages only from the first compilation.
alpar@9 1576 if test "$suppress_opt" = yes; then
alpar@9 1577 suppress_output=' >/dev/null 2>&1'
alpar@9 1578 fi
alpar@9 1579 fi
alpar@9 1580
alpar@9 1581 # Only build a position-dependent object if we build old libraries.
alpar@9 1582 if test "$build_old_libs" = yes; then
alpar@9 1583 if test "$pic_mode" != yes; then
alpar@9 1584 # Don't build PIC code
alpar@9 1585 command="$base_compile $qsrcfile$pie_flag"
alpar@9 1586 else
alpar@9 1587 command="$base_compile $qsrcfile $pic_flag"
alpar@9 1588 fi
alpar@9 1589 if test "$compiler_c_o" = yes; then
alpar@9 1590 command="$command -o $obj"
alpar@9 1591 fi
alpar@9 1592
alpar@9 1593 # Suppress compiler output if we already did a PIC compilation.
alpar@9 1594 command="$command$suppress_output"
alpar@9 1595 func_show_eval_locale "$command" \
alpar@9 1596 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
alpar@9 1597
alpar@9 1598 if test "$need_locks" = warn &&
alpar@9 1599 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
alpar@9 1600 $ECHO "\
alpar@9 1601 *** ERROR, $lockfile contains:
alpar@9 1602 `cat $lockfile 2>/dev/null`
alpar@9 1603
alpar@9 1604 but it should contain:
alpar@9 1605 $srcfile
alpar@9 1606
alpar@9 1607 This indicates that another process is trying to use the same
alpar@9 1608 temporary object file, and libtool could not work around it because
alpar@9 1609 your compiler does not support \`-c' and \`-o' together. If you
alpar@9 1610 repeat this compilation, it may succeed, by chance, but you had better
alpar@9 1611 avoid parallel builds (make -j) in this platform, or get a better
alpar@9 1612 compiler."
alpar@9 1613
alpar@9 1614 $opt_dry_run || $RM $removelist
alpar@9 1615 exit $EXIT_FAILURE
alpar@9 1616 fi
alpar@9 1617
alpar@9 1618 # Just move the object if needed
alpar@9 1619 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
alpar@9 1620 func_show_eval '$MV "$output_obj" "$obj"' \
alpar@9 1621 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
alpar@9 1622 fi
alpar@9 1623 fi
alpar@9 1624
alpar@9 1625 $opt_dry_run || {
alpar@9 1626 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
alpar@9 1627
alpar@9 1628 # Unlock the critical section if it was locked
alpar@9 1629 if test "$need_locks" != no; then
alpar@9 1630 removelist=$lockfile
alpar@9 1631 $RM "$lockfile"
alpar@9 1632 fi
alpar@9 1633 }
alpar@9 1634
alpar@9 1635 exit $EXIT_SUCCESS
alpar@9 1636 }
alpar@9 1637
alpar@9 1638 $opt_help || {
alpar@9 1639 test "$mode" = compile && func_mode_compile ${1+"$@"}
alpar@9 1640 }
alpar@9 1641
alpar@9 1642 func_mode_help ()
alpar@9 1643 {
alpar@9 1644 # We need to display help for each of the modes.
alpar@9 1645 case $mode in
alpar@9 1646 "")
alpar@9 1647 # Generic help is extracted from the usage comments
alpar@9 1648 # at the start of this file.
alpar@9 1649 func_help
alpar@9 1650 ;;
alpar@9 1651
alpar@9 1652 clean)
alpar@9 1653 $ECHO \
alpar@9 1654 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
alpar@9 1655
alpar@9 1656 Remove files from the build directory.
alpar@9 1657
alpar@9 1658 RM is the name of the program to use to delete files associated with each FILE
alpar@9 1659 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
alpar@9 1660 to RM.
alpar@9 1661
alpar@9 1662 If FILE is a libtool library, object or program, all the files associated
alpar@9 1663 with it are deleted. Otherwise, only FILE itself is deleted using RM."
alpar@9 1664 ;;
alpar@9 1665
alpar@9 1666 compile)
alpar@9 1667 $ECHO \
alpar@9 1668 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
alpar@9 1669
alpar@9 1670 Compile a source file into a libtool library object.
alpar@9 1671
alpar@9 1672 This mode accepts the following additional options:
alpar@9 1673
alpar@9 1674 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
alpar@9 1675 -no-suppress do not suppress compiler output for multiple passes
alpar@9 1676 -prefer-pic try to building PIC objects only
alpar@9 1677 -prefer-non-pic try to building non-PIC objects only
alpar@9 1678 -shared do not build a \`.o' file suitable for static linking
alpar@9 1679 -static only build a \`.o' file suitable for static linking
alpar@9 1680 -Wc,FLAG pass FLAG directly to the compiler
alpar@9 1681
alpar@9 1682 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
alpar@9 1683 from the given SOURCEFILE.
alpar@9 1684
alpar@9 1685 The output file name is determined by removing the directory component from
alpar@9 1686 SOURCEFILE, then substituting the C source code suffix \`.c' with the
alpar@9 1687 library object suffix, \`.lo'."
alpar@9 1688 ;;
alpar@9 1689
alpar@9 1690 execute)
alpar@9 1691 $ECHO \
alpar@9 1692 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
alpar@9 1693
alpar@9 1694 Automatically set library path, then run a program.
alpar@9 1695
alpar@9 1696 This mode accepts the following additional options:
alpar@9 1697
alpar@9 1698 -dlopen FILE add the directory containing FILE to the library path
alpar@9 1699
alpar@9 1700 This mode sets the library path environment variable according to \`-dlopen'
alpar@9 1701 flags.
alpar@9 1702
alpar@9 1703 If any of the ARGS are libtool executable wrappers, then they are translated
alpar@9 1704 into their corresponding uninstalled binary, and any of their required library
alpar@9 1705 directories are added to the library path.
alpar@9 1706
alpar@9 1707 Then, COMMAND is executed, with ARGS as arguments."
alpar@9 1708 ;;
alpar@9 1709
alpar@9 1710 finish)
alpar@9 1711 $ECHO \
alpar@9 1712 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
alpar@9 1713
alpar@9 1714 Complete the installation of libtool libraries.
alpar@9 1715
alpar@9 1716 Each LIBDIR is a directory that contains libtool libraries.
alpar@9 1717
alpar@9 1718 The commands that this mode executes may require superuser privileges. Use
alpar@9 1719 the \`--dry-run' option if you just want to see what would be executed."
alpar@9 1720 ;;
alpar@9 1721
alpar@9 1722 install)
alpar@9 1723 $ECHO \
alpar@9 1724 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
alpar@9 1725
alpar@9 1726 Install executables or libraries.
alpar@9 1727
alpar@9 1728 INSTALL-COMMAND is the installation command. The first component should be
alpar@9 1729 either the \`install' or \`cp' program.
alpar@9 1730
alpar@9 1731 The following components of INSTALL-COMMAND are treated specially:
alpar@9 1732
alpar@9 1733 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
alpar@9 1734
alpar@9 1735 The rest of the components are interpreted as arguments to that command (only
alpar@9 1736 BSD-compatible install options are recognized)."
alpar@9 1737 ;;
alpar@9 1738
alpar@9 1739 link)
alpar@9 1740 $ECHO \
alpar@9 1741 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
alpar@9 1742
alpar@9 1743 Link object files or libraries together to form another library, or to
alpar@9 1744 create an executable program.
alpar@9 1745
alpar@9 1746 LINK-COMMAND is a command using the C compiler that you would use to create
alpar@9 1747 a program from several object files.
alpar@9 1748
alpar@9 1749 The following components of LINK-COMMAND are treated specially:
alpar@9 1750
alpar@9 1751 -all-static do not do any dynamic linking at all
alpar@9 1752 -avoid-version do not add a version suffix if possible
alpar@9 1753 -bindir BINDIR specify path to binaries directory (for systems where
alpar@9 1754 libraries must be found in the PATH setting at runtime)
alpar@9 1755 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
alpar@9 1756 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
alpar@9 1757 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
alpar@9 1758 -export-symbols SYMFILE
alpar@9 1759 try to export only the symbols listed in SYMFILE
alpar@9 1760 -export-symbols-regex REGEX
alpar@9 1761 try to export only the symbols matching REGEX
alpar@9 1762 -LLIBDIR search LIBDIR for required installed libraries
alpar@9 1763 -lNAME OUTPUT-FILE requires the installed library libNAME
alpar@9 1764 -module build a library that can dlopened
alpar@9 1765 -no-fast-install disable the fast-install mode
alpar@9 1766 -no-install link a not-installable executable
alpar@9 1767 -no-undefined declare that a library does not refer to external symbols
alpar@9 1768 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
alpar@9 1769 -objectlist FILE Use a list of object files found in FILE to specify objects
alpar@9 1770 -precious-files-regex REGEX
alpar@9 1771 don't remove output files matching REGEX
alpar@9 1772 -release RELEASE specify package release information
alpar@9 1773 -rpath LIBDIR the created library will eventually be installed in LIBDIR
alpar@9 1774 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
alpar@9 1775 -shared only do dynamic linking of libtool libraries
alpar@9 1776 -shrext SUFFIX override the standard shared library file extension
alpar@9 1777 -static do not do any dynamic linking of uninstalled libtool libraries
alpar@9 1778 -static-libtool-libs
alpar@9 1779 do not do any dynamic linking of libtool libraries
alpar@9 1780 -version-info CURRENT[:REVISION[:AGE]]
alpar@9 1781 specify library version info [each variable defaults to 0]
alpar@9 1782 -weak LIBNAME declare that the target provides the LIBNAME interface
alpar@9 1783 -Wc,FLAG
alpar@9 1784 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
alpar@9 1785 -Wl,FLAG
alpar@9 1786 -Xlinker FLAG pass linker-specific FLAG directly to the linker
alpar@9 1787 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
alpar@9 1788
alpar@9 1789 All other options (arguments beginning with \`-') are ignored.
alpar@9 1790
alpar@9 1791 Every other argument is treated as a filename. Files ending in \`.la' are
alpar@9 1792 treated as uninstalled libtool libraries, other files are standard or library
alpar@9 1793 object files.
alpar@9 1794
alpar@9 1795 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
alpar@9 1796 only library objects (\`.lo' files) may be specified, and \`-rpath' is
alpar@9 1797 required, except when creating a convenience library.
alpar@9 1798
alpar@9 1799 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
alpar@9 1800 using \`ar' and \`ranlib', or on Windows using \`lib'.
alpar@9 1801
alpar@9 1802 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
alpar@9 1803 is created, otherwise an executable program is created."
alpar@9 1804 ;;
alpar@9 1805
alpar@9 1806 uninstall)
alpar@9 1807 $ECHO \
alpar@9 1808 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
alpar@9 1809
alpar@9 1810 Remove libraries from an installation directory.
alpar@9 1811
alpar@9 1812 RM is the name of the program to use to delete files associated with each FILE
alpar@9 1813 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
alpar@9 1814 to RM.
alpar@9 1815
alpar@9 1816 If FILE is a libtool library, all the files associated with it are deleted.
alpar@9 1817 Otherwise, only FILE itself is deleted using RM."
alpar@9 1818 ;;
alpar@9 1819
alpar@9 1820 *)
alpar@9 1821 func_fatal_help "invalid operation mode \`$mode'"
alpar@9 1822 ;;
alpar@9 1823 esac
alpar@9 1824
alpar@9 1825 echo
alpar@9 1826 $ECHO "Try \`$progname --help' for more information about other modes."
alpar@9 1827 }
alpar@9 1828
alpar@9 1829 # Now that we've collected a possible --mode arg, show help if necessary
alpar@9 1830 if $opt_help; then
alpar@9 1831 if test "$opt_help" = :; then
alpar@9 1832 func_mode_help
alpar@9 1833 else
alpar@9 1834 {
alpar@9 1835 func_help noexit
alpar@9 1836 for mode in compile link execute install finish uninstall clean; do
alpar@9 1837 func_mode_help
alpar@9 1838 done
alpar@9 1839 } | sed -n '1p; 2,$s/^Usage:/ or: /p'
alpar@9 1840 {
alpar@9 1841 func_help noexit
alpar@9 1842 for mode in compile link execute install finish uninstall clean; do
alpar@9 1843 echo
alpar@9 1844 func_mode_help
alpar@9 1845 done
alpar@9 1846 } |
alpar@9 1847 sed '1d
alpar@9 1848 /^When reporting/,/^Report/{
alpar@9 1849 H
alpar@9 1850 d
alpar@9 1851 }
alpar@9 1852 $x
alpar@9 1853 /information about other modes/d
alpar@9 1854 /more detailed .*MODE/d
alpar@9 1855 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
alpar@9 1856 fi
alpar@9 1857 exit $?
alpar@9 1858 fi
alpar@9 1859
alpar@9 1860
alpar@9 1861 # func_mode_execute arg...
alpar@9 1862 func_mode_execute ()
alpar@9 1863 {
alpar@9 1864 $opt_debug
alpar@9 1865 # The first argument is the command name.
alpar@9 1866 cmd="$nonopt"
alpar@9 1867 test -z "$cmd" && \
alpar@9 1868 func_fatal_help "you must specify a COMMAND"
alpar@9 1869
alpar@9 1870 # Handle -dlopen flags immediately.
alpar@9 1871 for file in $execute_dlfiles; do
alpar@9 1872 test -f "$file" \
alpar@9 1873 || func_fatal_help "\`$file' is not a file"
alpar@9 1874
alpar@9 1875 dir=
alpar@9 1876 case $file in
alpar@9 1877 *.la)
alpar@9 1878 # Check to see that this really is a libtool archive.
alpar@9 1879 func_lalib_unsafe_p "$file" \
alpar@9 1880 || func_fatal_help "\`$lib' is not a valid libtool archive"
alpar@9 1881
alpar@9 1882 # Read the libtool library.
alpar@9 1883 dlname=
alpar@9 1884 library_names=
alpar@9 1885 func_source "$file"
alpar@9 1886
alpar@9 1887 # Skip this library if it cannot be dlopened.
alpar@9 1888 if test -z "$dlname"; then
alpar@9 1889 # Warn if it was a shared library.
alpar@9 1890 test -n "$library_names" && \
alpar@9 1891 func_warning "\`$file' was not linked with \`-export-dynamic'"
alpar@9 1892 continue
alpar@9 1893 fi
alpar@9 1894
alpar@9 1895 func_dirname "$file" "" "."
alpar@9 1896 dir="$func_dirname_result"
alpar@9 1897
alpar@9 1898 if test -f "$dir/$objdir/$dlname"; then
alpar@9 1899 dir="$dir/$objdir"
alpar@9 1900 else
alpar@9 1901 if test ! -f "$dir/$dlname"; then
alpar@9 1902 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
alpar@9 1903 fi
alpar@9 1904 fi
alpar@9 1905 ;;
alpar@9 1906
alpar@9 1907 *.lo)
alpar@9 1908 # Just add the directory containing the .lo file.
alpar@9 1909 func_dirname "$file" "" "."
alpar@9 1910 dir="$func_dirname_result"
alpar@9 1911 ;;
alpar@9 1912
alpar@9 1913 *)
alpar@9 1914 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
alpar@9 1915 continue
alpar@9 1916 ;;
alpar@9 1917 esac
alpar@9 1918
alpar@9 1919 # Get the absolute pathname.
alpar@9 1920 absdir=`cd "$dir" && pwd`
alpar@9 1921 test -n "$absdir" && dir="$absdir"
alpar@9 1922
alpar@9 1923 # Now add the directory to shlibpath_var.
alpar@9 1924 if eval "test -z \"\$$shlibpath_var\""; then
alpar@9 1925 eval "$shlibpath_var=\"\$dir\""
alpar@9 1926 else
alpar@9 1927 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
alpar@9 1928 fi
alpar@9 1929 done
alpar@9 1930
alpar@9 1931 # This variable tells wrapper scripts just to set shlibpath_var
alpar@9 1932 # rather than running their programs.
alpar@9 1933 libtool_execute_magic="$magic"
alpar@9 1934
alpar@9 1935 # Check if any of the arguments is a wrapper script.
alpar@9 1936 args=
alpar@9 1937 for file
alpar@9 1938 do
alpar@9 1939 case $file in
alpar@9 1940 -* | *.la | *.lo ) ;;
alpar@9 1941 *)
alpar@9 1942 # Do a test to see if this is really a libtool program.
alpar@9 1943 if func_ltwrapper_script_p "$file"; then
alpar@9 1944 func_source "$file"
alpar@9 1945 # Transform arg to wrapped name.
alpar@9 1946 file="$progdir/$program"
alpar@9 1947 elif func_ltwrapper_executable_p "$file"; then
alpar@9 1948 func_ltwrapper_scriptname "$file"
alpar@9 1949 func_source "$func_ltwrapper_scriptname_result"
alpar@9 1950 # Transform arg to wrapped name.
alpar@9 1951 file="$progdir/$program"
alpar@9 1952 fi
alpar@9 1953 ;;
alpar@9 1954 esac
alpar@9 1955 # Quote arguments (to preserve shell metacharacters).
alpar@9 1956 func_quote_for_eval "$file"
alpar@9 1957 args="$args $func_quote_for_eval_result"
alpar@9 1958 done
alpar@9 1959
alpar@9 1960 if test "X$opt_dry_run" = Xfalse; then
alpar@9 1961 if test -n "$shlibpath_var"; then
alpar@9 1962 # Export the shlibpath_var.
alpar@9 1963 eval "export $shlibpath_var"
alpar@9 1964 fi
alpar@9 1965
alpar@9 1966 # Restore saved environment variables
alpar@9 1967 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
alpar@9 1968 do
alpar@9 1969 eval "if test \"\${save_$lt_var+set}\" = set; then
alpar@9 1970 $lt_var=\$save_$lt_var; export $lt_var
alpar@9 1971 else
alpar@9 1972 $lt_unset $lt_var
alpar@9 1973 fi"
alpar@9 1974 done
alpar@9 1975
alpar@9 1976 # Now prepare to actually exec the command.
alpar@9 1977 exec_cmd="\$cmd$args"
alpar@9 1978 else
alpar@9 1979 # Display what would be done.
alpar@9 1980 if test -n "$shlibpath_var"; then
alpar@9 1981 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
alpar@9 1982 echo "export $shlibpath_var"
alpar@9 1983 fi
alpar@9 1984 $ECHO "$cmd$args"
alpar@9 1985 exit $EXIT_SUCCESS
alpar@9 1986 fi
alpar@9 1987 }
alpar@9 1988
alpar@9 1989 test "$mode" = execute && func_mode_execute ${1+"$@"}
alpar@9 1990
alpar@9 1991
alpar@9 1992 # func_mode_finish arg...
alpar@9 1993 func_mode_finish ()
alpar@9 1994 {
alpar@9 1995 $opt_debug
alpar@9 1996 libdirs="$nonopt"
alpar@9 1997 admincmds=
alpar@9 1998
alpar@9 1999 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
alpar@9 2000 for dir
alpar@9 2001 do
alpar@9 2002 libdirs="$libdirs $dir"
alpar@9 2003 done
alpar@9 2004
alpar@9 2005 for libdir in $libdirs; do
alpar@9 2006 if test -n "$finish_cmds"; then
alpar@9 2007 # Do each command in the finish commands.
alpar@9 2008 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
alpar@9 2009 '"$cmd"'"'
alpar@9 2010 fi
alpar@9 2011 if test -n "$finish_eval"; then
alpar@9 2012 # Do the single finish_eval.
alpar@9 2013 eval cmds=\"$finish_eval\"
alpar@9 2014 $opt_dry_run || eval "$cmds" || admincmds="$admincmds
alpar@9 2015 $cmds"
alpar@9 2016 fi
alpar@9 2017 done
alpar@9 2018 fi
alpar@9 2019
alpar@9 2020 # Exit here if they wanted silent mode.
alpar@9 2021 $opt_silent && exit $EXIT_SUCCESS
alpar@9 2022
alpar@9 2023 echo "----------------------------------------------------------------------"
alpar@9 2024 echo "Libraries have been installed in:"
alpar@9 2025 for libdir in $libdirs; do
alpar@9 2026 $ECHO " $libdir"
alpar@9 2027 done
alpar@9 2028 echo
alpar@9 2029 echo "If you ever happen to want to link against installed libraries"
alpar@9 2030 echo "in a given directory, LIBDIR, you must either use libtool, and"
alpar@9 2031 echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
alpar@9 2032 echo "flag during linking and do at least one of the following:"
alpar@9 2033 if test -n "$shlibpath_var"; then
alpar@9 2034 echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
alpar@9 2035 echo " during execution"
alpar@9 2036 fi
alpar@9 2037 if test -n "$runpath_var"; then
alpar@9 2038 echo " - add LIBDIR to the \`$runpath_var' environment variable"
alpar@9 2039 echo " during linking"
alpar@9 2040 fi
alpar@9 2041 if test -n "$hardcode_libdir_flag_spec"; then
alpar@9 2042 libdir=LIBDIR
alpar@9 2043 eval flag=\"$hardcode_libdir_flag_spec\"
alpar@9 2044
alpar@9 2045 $ECHO " - use the \`$flag' linker flag"
alpar@9 2046 fi
alpar@9 2047 if test -n "$admincmds"; then
alpar@9 2048 $ECHO " - have your system administrator run these commands:$admincmds"
alpar@9 2049 fi
alpar@9 2050 if test -f /etc/ld.so.conf; then
alpar@9 2051 echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
alpar@9 2052 fi
alpar@9 2053 echo
alpar@9 2054
alpar@9 2055 echo "See any operating system documentation about shared libraries for"
alpar@9 2056 case $host in
alpar@9 2057 solaris2.[6789]|solaris2.1[0-9])
alpar@9 2058 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
alpar@9 2059 echo "pages."
alpar@9 2060 ;;
alpar@9 2061 *)
alpar@9 2062 echo "more information, such as the ld(1) and ld.so(8) manual pages."
alpar@9 2063 ;;
alpar@9 2064 esac
alpar@9 2065 echo "----------------------------------------------------------------------"
alpar@9 2066 exit $EXIT_SUCCESS
alpar@9 2067 }
alpar@9 2068
alpar@9 2069 test "$mode" = finish && func_mode_finish ${1+"$@"}
alpar@9 2070
alpar@9 2071
alpar@9 2072 # func_mode_install arg...
alpar@9 2073 func_mode_install ()
alpar@9 2074 {
alpar@9 2075 $opt_debug
alpar@9 2076 # There may be an optional sh(1) argument at the beginning of
alpar@9 2077 # install_prog (especially on Windows NT).
alpar@9 2078 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
alpar@9 2079 # Allow the use of GNU shtool's install command.
alpar@9 2080 case $nonopt in *shtool*) :;; *) false;; esac; then
alpar@9 2081 # Aesthetically quote it.
alpar@9 2082 func_quote_for_eval "$nonopt"
alpar@9 2083 install_prog="$func_quote_for_eval_result "
alpar@9 2084 arg=$1
alpar@9 2085 shift
alpar@9 2086 else
alpar@9 2087 install_prog=
alpar@9 2088 arg=$nonopt
alpar@9 2089 fi
alpar@9 2090
alpar@9 2091 # The real first argument should be the name of the installation program.
alpar@9 2092 # Aesthetically quote it.
alpar@9 2093 func_quote_for_eval "$arg"
alpar@9 2094 install_prog="$install_prog$func_quote_for_eval_result"
alpar@9 2095 install_shared_prog=$install_prog
alpar@9 2096 case " $install_prog " in
alpar@9 2097 *[\\\ /]cp\ *) install_cp=: ;;
alpar@9 2098 *) install_cp=false ;;
alpar@9 2099 esac
alpar@9 2100
alpar@9 2101 # We need to accept at least all the BSD install flags.
alpar@9 2102 dest=
alpar@9 2103 files=
alpar@9 2104 opts=
alpar@9 2105 prev=
alpar@9 2106 install_type=
alpar@9 2107 isdir=no
alpar@9 2108 stripme=
alpar@9 2109 no_mode=:
alpar@9 2110 for arg
alpar@9 2111 do
alpar@9 2112 arg2=
alpar@9 2113 if test -n "$dest"; then
alpar@9 2114 files="$files $dest"
alpar@9 2115 dest=$arg
alpar@9 2116 continue
alpar@9 2117 fi
alpar@9 2118
alpar@9 2119 case $arg in
alpar@9 2120 -d) isdir=yes ;;
alpar@9 2121 -f)
alpar@9 2122 if $install_cp; then :; else
alpar@9 2123 prev=$arg
alpar@9 2124 fi
alpar@9 2125 ;;
alpar@9 2126 -g | -m | -o)
alpar@9 2127 prev=$arg
alpar@9 2128 ;;
alpar@9 2129 -s)
alpar@9 2130 stripme=" -s"
alpar@9 2131 continue
alpar@9 2132 ;;
alpar@9 2133 -*)
alpar@9 2134 ;;
alpar@9 2135 *)
alpar@9 2136 # If the previous option needed an argument, then skip it.
alpar@9 2137 if test -n "$prev"; then
alpar@9 2138 if test "x$prev" = x-m && test -n "$install_override_mode"; then
alpar@9 2139 arg2=$install_override_mode
alpar@9 2140 no_mode=false
alpar@9 2141 fi
alpar@9 2142 prev=
alpar@9 2143 else
alpar@9 2144 dest=$arg
alpar@9 2145 continue
alpar@9 2146 fi
alpar@9 2147 ;;
alpar@9 2148 esac
alpar@9 2149
alpar@9 2150 # Aesthetically quote the argument.
alpar@9 2151 func_quote_for_eval "$arg"
alpar@9 2152 install_prog="$install_prog $func_quote_for_eval_result"
alpar@9 2153 if test -n "$arg2"; then
alpar@9 2154 func_quote_for_eval "$arg2"
alpar@9 2155 fi
alpar@9 2156 install_shared_prog="$install_shared_prog $func_quote_for_eval_result"
alpar@9 2157 done
alpar@9 2158
alpar@9 2159 test -z "$install_prog" && \
alpar@9 2160 func_fatal_help "you must specify an install program"
alpar@9 2161
alpar@9 2162 test -n "$prev" && \
alpar@9 2163 func_fatal_help "the \`$prev' option requires an argument"
alpar@9 2164
alpar@9 2165 if test -n "$install_override_mode" && $no_mode; then
alpar@9 2166 if $install_cp; then :; else
alpar@9 2167 func_quote_for_eval "$install_override_mode"
alpar@9 2168 install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result"
alpar@9 2169 fi
alpar@9 2170 fi
alpar@9 2171
alpar@9 2172 if test -z "$files"; then
alpar@9 2173 if test -z "$dest"; then
alpar@9 2174 func_fatal_help "no file or destination specified"
alpar@9 2175 else
alpar@9 2176 func_fatal_help "you must specify a destination"
alpar@9 2177 fi
alpar@9 2178 fi
alpar@9 2179
alpar@9 2180 # Strip any trailing slash from the destination.
alpar@9 2181 func_stripname '' '/' "$dest"
alpar@9 2182 dest=$func_stripname_result
alpar@9 2183
alpar@9 2184 # Check to see that the destination is a directory.
alpar@9 2185 test -d "$dest" && isdir=yes
alpar@9 2186 if test "$isdir" = yes; then
alpar@9 2187 destdir="$dest"
alpar@9 2188 destname=
alpar@9 2189 else
alpar@9 2190 func_dirname_and_basename "$dest" "" "."
alpar@9 2191 destdir="$func_dirname_result"
alpar@9 2192 destname="$func_basename_result"
alpar@9 2193
alpar@9 2194 # Not a directory, so check to see that there is only one file specified.
alpar@9 2195 set dummy $files; shift
alpar@9 2196 test "$#" -gt 1 && \
alpar@9 2197 func_fatal_help "\`$dest' is not a directory"
alpar@9 2198 fi
alpar@9 2199 case $destdir in
alpar@9 2200 [\\/]* | [A-Za-z]:[\\/]*) ;;
alpar@9 2201 *)
alpar@9 2202 for file in $files; do
alpar@9 2203 case $file in
alpar@9 2204 *.lo) ;;
alpar@9 2205 *)
alpar@9 2206 func_fatal_help "\`$destdir' must be an absolute directory name"
alpar@9 2207 ;;
alpar@9 2208 esac
alpar@9 2209 done
alpar@9 2210 ;;
alpar@9 2211 esac
alpar@9 2212
alpar@9 2213 # This variable tells wrapper scripts just to set variables rather
alpar@9 2214 # than running their programs.
alpar@9 2215 libtool_install_magic="$magic"
alpar@9 2216
alpar@9 2217 staticlibs=
alpar@9 2218 future_libdirs=
alpar@9 2219 current_libdirs=
alpar@9 2220 for file in $files; do
alpar@9 2221
alpar@9 2222 # Do each installation.
alpar@9 2223 case $file in
alpar@9 2224 *.$libext)
alpar@9 2225 # Do the static libraries later.
alpar@9 2226 staticlibs="$staticlibs $file"
alpar@9 2227 ;;
alpar@9 2228
alpar@9 2229 *.la)
alpar@9 2230 # Check to see that this really is a libtool archive.
alpar@9 2231 func_lalib_unsafe_p "$file" \
alpar@9 2232 || func_fatal_help "\`$file' is not a valid libtool archive"
alpar@9 2233
alpar@9 2234 library_names=
alpar@9 2235 old_library=
alpar@9 2236 relink_command=
alpar@9 2237 func_source "$file"
alpar@9 2238
alpar@9 2239 # Add the libdir to current_libdirs if it is the destination.
alpar@9 2240 if test "X$destdir" = "X$libdir"; then
alpar@9 2241 case "$current_libdirs " in
alpar@9 2242 *" $libdir "*) ;;
alpar@9 2243 *) current_libdirs="$current_libdirs $libdir" ;;
alpar@9 2244 esac
alpar@9 2245 else
alpar@9 2246 # Note the libdir as a future libdir.
alpar@9 2247 case "$future_libdirs " in
alpar@9 2248 *" $libdir "*) ;;
alpar@9 2249 *) future_libdirs="$future_libdirs $libdir" ;;
alpar@9 2250 esac
alpar@9 2251 fi
alpar@9 2252
alpar@9 2253 func_dirname "$file" "/" ""
alpar@9 2254 dir="$func_dirname_result"
alpar@9 2255 dir="$dir$objdir"
alpar@9 2256
alpar@9 2257 if test -n "$relink_command"; then
alpar@9 2258 # Determine the prefix the user has applied to our future dir.
alpar@9 2259 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
alpar@9 2260
alpar@9 2261 # Don't allow the user to place us outside of our expected
alpar@9 2262 # location b/c this prevents finding dependent libraries that
alpar@9 2263 # are installed to the same prefix.
alpar@9 2264 # At present, this check doesn't affect windows .dll's that
alpar@9 2265 # are installed into $libdir/../bin (currently, that works fine)
alpar@9 2266 # but it's something to keep an eye on.
alpar@9 2267 test "$inst_prefix_dir" = "$destdir" && \
alpar@9 2268 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
alpar@9 2269
alpar@9 2270 if test -n "$inst_prefix_dir"; then
alpar@9 2271 # Stick the inst_prefix_dir data into the link command.
alpar@9 2272 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
alpar@9 2273 else
alpar@9 2274 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
alpar@9 2275 fi
alpar@9 2276
alpar@9 2277 func_warning "relinking \`$file'"
alpar@9 2278 func_show_eval "$relink_command" \
alpar@9 2279 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
alpar@9 2280 fi
alpar@9 2281
alpar@9 2282 # See the names of the shared library.
alpar@9 2283 set dummy $library_names; shift
alpar@9 2284 if test -n "$1"; then
alpar@9 2285 realname="$1"
alpar@9 2286 shift
alpar@9 2287
alpar@9 2288 srcname="$realname"
alpar@9 2289 test -n "$relink_command" && srcname="$realname"T
alpar@9 2290
alpar@9 2291 # Install the shared library and build the symlinks.
alpar@9 2292 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
alpar@9 2293 'exit $?'
alpar@9 2294 tstripme="$stripme"
alpar@9 2295 case $host_os in
alpar@9 2296 cygwin* | mingw* | pw32* | cegcc*)
alpar@9 2297 case $realname in
alpar@9 2298 *.dll.a)
alpar@9 2299 tstripme=""
alpar@9 2300 ;;
alpar@9 2301 esac
alpar@9 2302 ;;
alpar@9 2303 esac
alpar@9 2304 if test -n "$tstripme" && test -n "$striplib"; then
alpar@9 2305 func_show_eval "$striplib $destdir/$realname" 'exit $?'
alpar@9 2306 fi
alpar@9 2307
alpar@9 2308 if test "$#" -gt 0; then
alpar@9 2309 # Delete the old symlinks, and create new ones.
alpar@9 2310 # Try `ln -sf' first, because the `ln' binary might depend on
alpar@9 2311 # the symlink we replace! Solaris /bin/ln does not understand -f,
alpar@9 2312 # so we also need to try rm && ln -s.
alpar@9 2313 for linkname
alpar@9 2314 do
alpar@9 2315 test "$linkname" != "$realname" \
alpar@9 2316 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
alpar@9 2317 done
alpar@9 2318 fi
alpar@9 2319
alpar@9 2320 # Do each command in the postinstall commands.
alpar@9 2321 lib="$destdir/$realname"
alpar@9 2322 func_execute_cmds "$postinstall_cmds" 'exit $?'
alpar@9 2323 fi
alpar@9 2324
alpar@9 2325 # Install the pseudo-library for information purposes.
alpar@9 2326 func_basename "$file"
alpar@9 2327 name="$func_basename_result"
alpar@9 2328 instname="$dir/$name"i
alpar@9 2329 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
alpar@9 2330
alpar@9 2331 # Maybe install the static library, too.
alpar@9 2332 test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
alpar@9 2333 ;;
alpar@9 2334
alpar@9 2335 *.lo)
alpar@9 2336 # Install (i.e. copy) a libtool object.
alpar@9 2337
alpar@9 2338 # Figure out destination file name, if it wasn't already specified.
alpar@9 2339 if test -n "$destname"; then
alpar@9 2340 destfile="$destdir/$destname"
alpar@9 2341 else
alpar@9 2342 func_basename "$file"
alpar@9 2343 destfile="$func_basename_result"
alpar@9 2344 destfile="$destdir/$destfile"
alpar@9 2345 fi
alpar@9 2346
alpar@9 2347 # Deduce the name of the destination old-style object file.
alpar@9 2348 case $destfile in
alpar@9 2349 *.lo)
alpar@9 2350 func_lo2o "$destfile"
alpar@9 2351 staticdest=$func_lo2o_result
alpar@9 2352 ;;
alpar@9 2353 *.$objext)
alpar@9 2354 staticdest="$destfile"
alpar@9 2355 destfile=
alpar@9 2356 ;;
alpar@9 2357 *)
alpar@9 2358 func_fatal_help "cannot copy a libtool object to \`$destfile'"
alpar@9 2359 ;;
alpar@9 2360 esac
alpar@9 2361
alpar@9 2362 # Install the libtool object if requested.
alpar@9 2363 test -n "$destfile" && \
alpar@9 2364 func_show_eval "$install_prog $file $destfile" 'exit $?'
alpar@9 2365
alpar@9 2366 # Install the old object if enabled.
alpar@9 2367 if test "$build_old_libs" = yes; then
alpar@9 2368 # Deduce the name of the old-style object file.
alpar@9 2369 func_lo2o "$file"
alpar@9 2370 staticobj=$func_lo2o_result
alpar@9 2371 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
alpar@9 2372 fi
alpar@9 2373 exit $EXIT_SUCCESS
alpar@9 2374 ;;
alpar@9 2375
alpar@9 2376 *)
alpar@9 2377 # Figure out destination file name, if it wasn't already specified.
alpar@9 2378 if test -n "$destname"; then
alpar@9 2379 destfile="$destdir/$destname"
alpar@9 2380 else
alpar@9 2381 func_basename "$file"
alpar@9 2382 destfile="$func_basename_result"
alpar@9 2383 destfile="$destdir/$destfile"
alpar@9 2384 fi
alpar@9 2385
alpar@9 2386 # If the file is missing, and there is a .exe on the end, strip it
alpar@9 2387 # because it is most likely a libtool script we actually want to
alpar@9 2388 # install
alpar@9 2389 stripped_ext=""
alpar@9 2390 case $file in
alpar@9 2391 *.exe)
alpar@9 2392 if test ! -f "$file"; then
alpar@9 2393 func_stripname '' '.exe' "$file"
alpar@9 2394 file=$func_stripname_result
alpar@9 2395 stripped_ext=".exe"
alpar@9 2396 fi
alpar@9 2397 ;;
alpar@9 2398 esac
alpar@9 2399
alpar@9 2400 # Do a test to see if this is really a libtool program.
alpar@9 2401 case $host in
alpar@9 2402 *cygwin* | *mingw*)
alpar@9 2403 if func_ltwrapper_executable_p "$file"; then
alpar@9 2404 func_ltwrapper_scriptname "$file"
alpar@9 2405 wrapper=$func_ltwrapper_scriptname_result
alpar@9 2406 else
alpar@9 2407 func_stripname '' '.exe' "$file"
alpar@9 2408 wrapper=$func_stripname_result
alpar@9 2409 fi
alpar@9 2410 ;;
alpar@9 2411 *)
alpar@9 2412 wrapper=$file
alpar@9 2413 ;;
alpar@9 2414 esac
alpar@9 2415 if func_ltwrapper_script_p "$wrapper"; then
alpar@9 2416 notinst_deplibs=
alpar@9 2417 relink_command=
alpar@9 2418
alpar@9 2419 func_source "$wrapper"
alpar@9 2420
alpar@9 2421 # Check the variables that should have been set.
alpar@9 2422 test -z "$generated_by_libtool_version" && \
alpar@9 2423 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
alpar@9 2424
alpar@9 2425 finalize=yes
alpar@9 2426 for lib in $notinst_deplibs; do
alpar@9 2427 # Check to see that each library is installed.
alpar@9 2428 libdir=
alpar@9 2429 if test -f "$lib"; then
alpar@9 2430 func_source "$lib"
alpar@9 2431 fi
alpar@9 2432 libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
alpar@9 2433 if test -n "$libdir" && test ! -f "$libfile"; then
alpar@9 2434 func_warning "\`$lib' has not been installed in \`$libdir'"
alpar@9 2435 finalize=no
alpar@9 2436 fi
alpar@9 2437 done
alpar@9 2438
alpar@9 2439 relink_command=
alpar@9 2440 func_source "$wrapper"
alpar@9 2441
alpar@9 2442 outputname=
alpar@9 2443 if test "$fast_install" = no && test -n "$relink_command"; then
alpar@9 2444 $opt_dry_run || {
alpar@9 2445 if test "$finalize" = yes; then
alpar@9 2446 tmpdir=`func_mktempdir`
alpar@9 2447 func_basename "$file$stripped_ext"
alpar@9 2448 file="$func_basename_result"
alpar@9 2449 outputname="$tmpdir/$file"
alpar@9 2450 # Replace the output file specification.
alpar@9 2451 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
alpar@9 2452
alpar@9 2453 $opt_silent || {
alpar@9 2454 func_quote_for_expand "$relink_command"
alpar@9 2455 eval "func_echo $func_quote_for_expand_result"
alpar@9 2456 }
alpar@9 2457 if eval "$relink_command"; then :
alpar@9 2458 else
alpar@9 2459 func_error "error: relink \`$file' with the above command before installing it"
alpar@9 2460 $opt_dry_run || ${RM}r "$tmpdir"
alpar@9 2461 continue
alpar@9 2462 fi
alpar@9 2463 file="$outputname"
alpar@9 2464 else
alpar@9 2465 func_warning "cannot relink \`$file'"
alpar@9 2466 fi
alpar@9 2467 }
alpar@9 2468 else
alpar@9 2469 # Install the binary that we compiled earlier.
alpar@9 2470 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
alpar@9 2471 fi
alpar@9 2472 fi
alpar@9 2473
alpar@9 2474 # remove .exe since cygwin /usr/bin/install will append another
alpar@9 2475 # one anyway
alpar@9 2476 case $install_prog,$host in
alpar@9 2477 */usr/bin/install*,*cygwin*)
alpar@9 2478 case $file:$destfile in
alpar@9 2479 *.exe:*.exe)
alpar@9 2480 # this is ok
alpar@9 2481 ;;
alpar@9 2482 *.exe:*)
alpar@9 2483 destfile=$destfile.exe
alpar@9 2484 ;;
alpar@9 2485 *:*.exe)
alpar@9 2486 func_stripname '' '.exe' "$destfile"
alpar@9 2487 destfile=$func_stripname_result
alpar@9 2488 ;;
alpar@9 2489 esac
alpar@9 2490 ;;
alpar@9 2491 esac
alpar@9 2492 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
alpar@9 2493 $opt_dry_run || if test -n "$outputname"; then
alpar@9 2494 ${RM}r "$tmpdir"
alpar@9 2495 fi
alpar@9 2496 ;;
alpar@9 2497 esac
alpar@9 2498 done
alpar@9 2499
alpar@9 2500 for file in $staticlibs; do
alpar@9 2501 func_basename "$file"
alpar@9 2502 name="$func_basename_result"
alpar@9 2503
alpar@9 2504 # Set up the ranlib parameters.
alpar@9 2505 oldlib="$destdir/$name"
alpar@9 2506
alpar@9 2507 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
alpar@9 2508
alpar@9 2509 if test -n "$stripme" && test -n "$old_striplib"; then
alpar@9 2510 func_show_eval "$old_striplib $oldlib" 'exit $?'
alpar@9 2511 fi
alpar@9 2512
alpar@9 2513 # Do each command in the postinstall commands.
alpar@9 2514 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
alpar@9 2515 done
alpar@9 2516
alpar@9 2517 test -n "$future_libdirs" && \
alpar@9 2518 func_warning "remember to run \`$progname --finish$future_libdirs'"
alpar@9 2519
alpar@9 2520 if test -n "$current_libdirs"; then
alpar@9 2521 # Maybe just do a dry run.
alpar@9 2522 $opt_dry_run && current_libdirs=" -n$current_libdirs"
alpar@9 2523 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
alpar@9 2524 else
alpar@9 2525 exit $EXIT_SUCCESS
alpar@9 2526 fi
alpar@9 2527 }
alpar@9 2528
alpar@9 2529 test "$mode" = install && func_mode_install ${1+"$@"}
alpar@9 2530
alpar@9 2531
alpar@9 2532 # func_generate_dlsyms outputname originator pic_p
alpar@9 2533 # Extract symbols from dlprefiles and create ${outputname}S.o with
alpar@9 2534 # a dlpreopen symbol table.
alpar@9 2535 func_generate_dlsyms ()
alpar@9 2536 {
alpar@9 2537 $opt_debug
alpar@9 2538 my_outputname="$1"
alpar@9 2539 my_originator="$2"
alpar@9 2540 my_pic_p="${3-no}"
alpar@9 2541 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
alpar@9 2542 my_dlsyms=
alpar@9 2543
alpar@9 2544 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
alpar@9 2545 if test -n "$NM" && test -n "$global_symbol_pipe"; then
alpar@9 2546 my_dlsyms="${my_outputname}S.c"
alpar@9 2547 else
alpar@9 2548 func_error "not configured to extract global symbols from dlpreopened files"
alpar@9 2549 fi
alpar@9 2550 fi
alpar@9 2551
alpar@9 2552 if test -n "$my_dlsyms"; then
alpar@9 2553 case $my_dlsyms in
alpar@9 2554 "") ;;
alpar@9 2555 *.c)
alpar@9 2556 # Discover the nlist of each of the dlfiles.
alpar@9 2557 nlist="$output_objdir/${my_outputname}.nm"
alpar@9 2558
alpar@9 2559 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
alpar@9 2560
alpar@9 2561 # Parse the name list into a source file.
alpar@9 2562 func_verbose "creating $output_objdir/$my_dlsyms"
alpar@9 2563
alpar@9 2564 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
alpar@9 2565 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
alpar@9 2566 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
alpar@9 2567
alpar@9 2568 #ifdef __cplusplus
alpar@9 2569 extern \"C\" {
alpar@9 2570 #endif
alpar@9 2571
alpar@9 2572 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
alpar@9 2573 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
alpar@9 2574 #endif
alpar@9 2575
alpar@9 2576 /* External symbol declarations for the compiler. */\
alpar@9 2577 "
alpar@9 2578
alpar@9 2579 if test "$dlself" = yes; then
alpar@9 2580 func_verbose "generating symbol list for \`$output'"
alpar@9 2581
alpar@9 2582 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
alpar@9 2583
alpar@9 2584 # Add our own program objects to the symbol list.
alpar@9 2585 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
alpar@9 2586 for progfile in $progfiles; do
alpar@9 2587 func_verbose "extracting global C symbols from \`$progfile'"
alpar@9 2588 $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
alpar@9 2589 done
alpar@9 2590
alpar@9 2591 if test -n "$exclude_expsyms"; then
alpar@9 2592 $opt_dry_run || {
alpar@9 2593 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
alpar@9 2594 eval '$MV "$nlist"T "$nlist"'
alpar@9 2595 }
alpar@9 2596 fi
alpar@9 2597
alpar@9 2598 if test -n "$export_symbols_regex"; then
alpar@9 2599 $opt_dry_run || {
alpar@9 2600 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
alpar@9 2601 eval '$MV "$nlist"T "$nlist"'
alpar@9 2602 }
alpar@9 2603 fi
alpar@9 2604
alpar@9 2605 # Prepare the list of exported symbols
alpar@9 2606 if test -z "$export_symbols"; then
alpar@9 2607 export_symbols="$output_objdir/$outputname.exp"
alpar@9 2608 $opt_dry_run || {
alpar@9 2609 $RM $export_symbols
alpar@9 2610 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
alpar@9 2611 case $host in
alpar@9 2612 *cygwin* | *mingw* | *cegcc* )
alpar@9 2613 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
alpar@9 2614 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
alpar@9 2615 ;;
alpar@9 2616 esac
alpar@9 2617 }
alpar@9 2618 else
alpar@9 2619 $opt_dry_run || {
alpar@9 2620 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
alpar@9 2621 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
alpar@9 2622 eval '$MV "$nlist"T "$nlist"'
alpar@9 2623 case $host in
alpar@9 2624 *cygwin* | *mingw* | *cegcc* )
alpar@9 2625 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
alpar@9 2626 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
alpar@9 2627 ;;
alpar@9 2628 esac
alpar@9 2629 }
alpar@9 2630 fi
alpar@9 2631 fi
alpar@9 2632
alpar@9 2633 for dlprefile in $dlprefiles; do
alpar@9 2634 func_verbose "extracting global C symbols from \`$dlprefile'"
alpar@9 2635 func_basename "$dlprefile"
alpar@9 2636 name="$func_basename_result"
alpar@9 2637 case $host in
alpar@9 2638 *cygwin* | *mingw* | *cegcc* )
alpar@9 2639 # if an import library, we need to obtain dlname
alpar@9 2640 if func_win32_import_lib_p "$dlprefile"; then
alpar@9 2641 func_tr_sh "$dlprefile"
alpar@9 2642 eval "curr_lafile=\$libfile_$func_tr_sh_result"
alpar@9 2643 dlprefile_dlbasename=""
alpar@9 2644 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
alpar@9 2645 # Use subshell, to avoid clobbering current variable values
alpar@9 2646 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
alpar@9 2647 if test -n "$dlprefile_dlname" ; then
alpar@9 2648 func_basename "$dlprefile_dlname"
alpar@9 2649 dlprefile_dlbasename="$func_basename_result"
alpar@9 2650 else
alpar@9 2651 # no lafile. user explicitly requested -dlpreopen <import library>.
alpar@9 2652 eval '$sharedlib_from_linklib "$dlprefile"'
alpar@9 2653 dlprefile_dlbasename=$sharedlib_from_linklib_result
alpar@9 2654 fi
alpar@9 2655 fi
alpar@9 2656 $opt_dry_run || {
alpar@9 2657 if test -n "$dlprefile_dlbasename" ; then
alpar@9 2658 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
alpar@9 2659 else
alpar@9 2660 func_warning "Could not compute DLL name from $name"
alpar@9 2661 eval '$ECHO ": $name " >> "$nlist"'
alpar@9 2662 fi
alpar@9 2663 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe |
alpar@9 2664 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
alpar@9 2665 }
alpar@9 2666 else # not an import lib
alpar@9 2667 $opt_dry_run || {
alpar@9 2668 eval '$ECHO ": $name " >> "$nlist"'
alpar@9 2669 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
alpar@9 2670 }
alpar@9 2671 fi
alpar@9 2672 ;;
alpar@9 2673 *)
alpar@9 2674 $opt_dry_run || {
alpar@9 2675 eval '$ECHO ": $name " >> "$nlist"'
alpar@9 2676 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
alpar@9 2677 }
alpar@9 2678 ;;
alpar@9 2679 esac
alpar@9 2680 done
alpar@9 2681
alpar@9 2682 $opt_dry_run || {
alpar@9 2683 # Make sure we have at least an empty file.
alpar@9 2684 test -f "$nlist" || : > "$nlist"
alpar@9 2685
alpar@9 2686 if test -n "$exclude_expsyms"; then
alpar@9 2687 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
alpar@9 2688 $MV "$nlist"T "$nlist"
alpar@9 2689 fi
alpar@9 2690
alpar@9 2691 # Try sorting and uniquifying the output.
alpar@9 2692 if $GREP -v "^: " < "$nlist" |
alpar@9 2693 if sort -k 3 </dev/null >/dev/null 2>&1; then
alpar@9 2694 sort -k 3
alpar@9 2695 else
alpar@9 2696 sort +2
alpar@9 2697 fi |
alpar@9 2698 uniq > "$nlist"S; then
alpar@9 2699 :
alpar@9 2700 else
alpar@9 2701 $GREP -v "^: " < "$nlist" > "$nlist"S
alpar@9 2702 fi
alpar@9 2703
alpar@9 2704 if test -f "$nlist"S; then
alpar@9 2705 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
alpar@9 2706 else
alpar@9 2707 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
alpar@9 2708 fi
alpar@9 2709
alpar@9 2710 echo >> "$output_objdir/$my_dlsyms" "\
alpar@9 2711
alpar@9 2712 /* The mapping between symbol names and symbols. */
alpar@9 2713 typedef struct {
alpar@9 2714 const char *name;
alpar@9 2715 void *address;
alpar@9 2716 } lt_dlsymlist;
alpar@9 2717 "
alpar@9 2718 case $host in
alpar@9 2719 *cygwin* | *mingw* | *cegcc* )
alpar@9 2720 echo >> "$output_objdir/$my_dlsyms" "\
alpar@9 2721 /* DATA imports from DLLs on WIN32 con't be const, because
alpar@9 2722 runtime relocations are performed -- see ld's documentation
alpar@9 2723 on pseudo-relocs. */"
alpar@9 2724 lt_dlsym_const= ;;
alpar@9 2725 *osf5*)
alpar@9 2726 echo >> "$output_objdir/$my_dlsyms" "\
alpar@9 2727 /* This system does not cope well with relocations in const data */"
alpar@9 2728 lt_dlsym_const= ;;
alpar@9 2729 *)
alpar@9 2730 lt_dlsym_const=const ;;
alpar@9 2731 esac
alpar@9 2732
alpar@9 2733 echo >> "$output_objdir/$my_dlsyms" "\
alpar@9 2734 extern $lt_dlsym_const lt_dlsymlist
alpar@9 2735 lt_${my_prefix}_LTX_preloaded_symbols[];
alpar@9 2736 $lt_dlsym_const lt_dlsymlist
alpar@9 2737 lt_${my_prefix}_LTX_preloaded_symbols[] =
alpar@9 2738 {\
alpar@9 2739 { \"$my_originator\", (void *) 0 },"
alpar@9 2740
alpar@9 2741 case $need_lib_prefix in
alpar@9 2742 no)
alpar@9 2743 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
alpar@9 2744 ;;
alpar@9 2745 *)
alpar@9 2746 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
alpar@9 2747 ;;
alpar@9 2748 esac
alpar@9 2749 echo >> "$output_objdir/$my_dlsyms" "\
alpar@9 2750 {0, (void *) 0}
alpar@9 2751 };
alpar@9 2752
alpar@9 2753 /* This works around a problem in FreeBSD linker */
alpar@9 2754 #ifdef FREEBSD_WORKAROUND
alpar@9 2755 static const void *lt_preloaded_setup() {
alpar@9 2756 return lt_${my_prefix}_LTX_preloaded_symbols;
alpar@9 2757 }
alpar@9 2758 #endif
alpar@9 2759
alpar@9 2760 #ifdef __cplusplus
alpar@9 2761 }
alpar@9 2762 #endif\
alpar@9 2763 "
alpar@9 2764 } # !$opt_dry_run
alpar@9 2765
alpar@9 2766 pic_flag_for_symtable=
alpar@9 2767 case "$compile_command " in
alpar@9 2768 *" -static "*) ;;
alpar@9 2769 *)
alpar@9 2770 case $host in
alpar@9 2771 # compiling the symbol table file with pic_flag works around
alpar@9 2772 # a FreeBSD bug that causes programs to crash when -lm is
alpar@9 2773 # linked before any other PIC object. But we must not use
alpar@9 2774 # pic_flag when linking with -static. The problem exists in
alpar@9 2775 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
alpar@9 2776 *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
alpar@9 2777 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
alpar@9 2778 *-*-hpux*)
alpar@9 2779 pic_flag_for_symtable=" $pic_flag" ;;
alpar@9 2780 *)
alpar@9 2781 if test "X$my_pic_p" != Xno; then
alpar@9 2782 pic_flag_for_symtable=" $pic_flag"
alpar@9 2783 fi
alpar@9 2784 ;;
alpar@9 2785 esac
alpar@9 2786 ;;
alpar@9 2787 esac
alpar@9 2788 symtab_cflags=
alpar@9 2789 for arg in $LTCFLAGS; do
alpar@9 2790 case $arg in
alpar@9 2791 -pie | -fpie | -fPIE) ;;
alpar@9 2792 *) symtab_cflags="$symtab_cflags $arg" ;;
alpar@9 2793 esac
alpar@9 2794 done
alpar@9 2795
alpar@9 2796 # Now compile the dynamic symbol file.
alpar@9 2797 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
alpar@9 2798
alpar@9 2799 # Clean up the generated files.
alpar@9 2800 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
alpar@9 2801
alpar@9 2802 # Transform the symbol file into the correct name.
alpar@9 2803 symfileobj="$output_objdir/${my_outputname}S.$objext"
alpar@9 2804 case $host in
alpar@9 2805 *cygwin* | *mingw* | *cegcc* )
alpar@9 2806 if test -f "$output_objdir/$my_outputname.def"; then
alpar@9 2807 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
alpar@9 2808 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
alpar@9 2809 else
alpar@9 2810 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
alpar@9 2811 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
alpar@9 2812 fi
alpar@9 2813 ;;
alpar@9 2814 *)
alpar@9 2815 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
alpar@9 2816 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
alpar@9 2817 ;;
alpar@9 2818 esac
alpar@9 2819 ;;
alpar@9 2820 *)
alpar@9 2821 func_fatal_error "unknown suffix for \`$my_dlsyms'"
alpar@9 2822 ;;
alpar@9 2823 esac
alpar@9 2824 else
alpar@9 2825 # We keep going just in case the user didn't refer to
alpar@9 2826 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
alpar@9 2827 # really was required.
alpar@9 2828
alpar@9 2829 # Nullify the symbol file.
alpar@9 2830 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
alpar@9 2831 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
alpar@9 2832 fi
alpar@9 2833 }
alpar@9 2834
alpar@9 2835 # func_win32_libid arg
alpar@9 2836 # return the library type of file 'arg'
alpar@9 2837 #
alpar@9 2838 # Need a lot of goo to handle *both* DLLs and import libs
alpar@9 2839 # Has to be a shell function in order to 'eat' the argument
alpar@9 2840 # that is supplied when $file_magic_command is called.
alpar@9 2841 # Despite the name, also deal with 64 bit binaries.
alpar@9 2842 func_win32_libid ()
alpar@9 2843 {
alpar@9 2844 $opt_debug
alpar@9 2845 win32_libid_type="unknown"
alpar@9 2846 win32_fileres=`file -L $1 2>/dev/null`
alpar@9 2847 case $win32_fileres in
alpar@9 2848 *ar\ archive\ import\ library*) # definitely import
alpar@9 2849 win32_libid_type="x86 archive import"
alpar@9 2850 ;;
alpar@9 2851 *ar\ archive*) # could be an import, or static
alpar@9 2852 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
alpar@9 2853 $EGREP 'file format (pei?-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
alpar@9 2854 win32_nmres=`eval $NM -f posix -A $1 |
alpar@9 2855 $SED -n -e '
alpar@9 2856 1,100{
alpar@9 2857 / I /{
alpar@9 2858 s,.*,import,
alpar@9 2859 p
alpar@9 2860 q
alpar@9 2861 }
alpar@9 2862 }'`
alpar@9 2863 case $win32_nmres in
alpar@9 2864 import*) win32_libid_type="x86 archive import";;
alpar@9 2865 *) win32_libid_type="x86 archive static";;
alpar@9 2866 esac
alpar@9 2867 fi
alpar@9 2868 ;;
alpar@9 2869 *DLL*)
alpar@9 2870 win32_libid_type="x86 DLL"
alpar@9 2871 ;;
alpar@9 2872 *executable*) # but shell scripts are "executable" too...
alpar@9 2873 case $win32_fileres in
alpar@9 2874 *MS\ Windows\ PE\ Intel*)
alpar@9 2875 win32_libid_type="x86 DLL"
alpar@9 2876 ;;
alpar@9 2877 esac
alpar@9 2878 ;;
alpar@9 2879 esac
alpar@9 2880 $ECHO "$win32_libid_type"
alpar@9 2881 }
alpar@9 2882
alpar@9 2883 # func_cygming_dll_for_implib ARG
alpar@9 2884 #
alpar@9 2885 # Platform-specific function to extract the
alpar@9 2886 # name of the DLL associated with the specified
alpar@9 2887 # import library ARG.
alpar@9 2888 # Invoked by eval'ing the libtool variable
alpar@9 2889 # $sharedlib_from_linklib_cmd
alpar@9 2890 # Result is available in the variable
alpar@9 2891 # $sharedlib_from_linklib_result
alpar@9 2892 func_cygming_dll_for_implib ()
alpar@9 2893 {
alpar@9 2894 $opt_debug
alpar@9 2895 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
alpar@9 2896 }
alpar@9 2897
alpar@9 2898 # func_cygming_dll_for_implib_core SECTION_NAME LIBNAMEs
alpar@9 2899 #
alpar@9 2900 # The is the core of a fallback implementation of a
alpar@9 2901 # platform-specific function to extract the name of the
alpar@9 2902 # DLL associated with the specified import library LIBNAME.
alpar@9 2903 #
alpar@9 2904 # SECTION_NAME is either .idata$6 or .idata$7, depending
alpar@9 2905 # on the platform and compiler that created the implib.
alpar@9 2906 #
alpar@9 2907 # Echos the name of the DLL associated with the
alpar@9 2908 # specified import library.
alpar@9 2909 func_cygming_dll_for_implib_fallback_core ()
alpar@9 2910 {
alpar@9 2911 $opt_debug
alpar@9 2912 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
alpar@9 2913 sed '/^Contents of section '"$1"':/{
alpar@9 2914 # Place marker at beginning of archive member dllname section
alpar@9 2915 s/.*/====MARK====/
alpar@9 2916 p
alpar@9 2917 d
alpar@9 2918 }
alpar@9 2919 # These lines can sometimes be longer than 43 characters, but
alpar@9 2920 # are always uninteresting
alpar@9 2921 /:[ \t]*file format pe[i]\{,1\}-i386$/d
alpar@9 2922 /^In archive [^:]*:/d
alpar@9 2923 # Ensure marker is printed
alpar@9 2924 /^====MARK====/p
alpar@9 2925 # Remove all lines with less than 43 characters
alpar@9 2926 /^.\{43\}/!d
alpar@9 2927 # From remoaining lines, remove first 43 characters
alpar@9 2928 s/^.\{43\}//' |
alpar@9 2929 sed -n '
alpar@9 2930 # Join marker and all lines until next marker into a single line
alpar@9 2931 /^====MARK====/ b para
alpar@9 2932 H
alpar@9 2933 $ b para
alpar@9 2934 b
alpar@9 2935 :para
alpar@9 2936 x
alpar@9 2937 s/\n//g
alpar@9 2938 # Remove the marker
alpar@9 2939 s/^====MARK====//
alpar@9 2940 # Remove trailing dots and whitespace
alpar@9 2941 s/[\. \t]*$//
alpar@9 2942 # Print
alpar@9 2943 /./p
alpar@9 2944 ' |
alpar@9 2945 # we now have a list, one entry per line, of the stringified
alpar@9 2946 # contents of the appropriate section of all members of the
alpar@9 2947 # archive which possess that section. Heuristic: eliminate
alpar@9 2948 # all those which have a first or second character that is
alpar@9 2949 # a '.' (that is, objdump's representation of an unprintable
alpar@9 2950 # character.) This should work for all archives with less than
alpar@9 2951 # 0x302f exports -- but will fail for DLLs whose name actually
alpar@9 2952 # begins with a literal '.' or a single character followed by
alpar@9 2953 # a '.'.
alpar@9 2954 #
alpar@9 2955 # Of those that remain, print the first one.
alpar@9 2956 sed -e '/^\./d' -e '/^.\./d' | sed -n -e '1p'
alpar@9 2957 }
alpar@9 2958
alpar@9 2959 # func_cygming_gnu_implib_p ARG
alpar@9 2960 # This predicate returns with zero status (TRUE) if
alpar@9 2961 # ARG is a GNU/binutils-style import library. Returns
alpar@9 2962 # with nonzero status (FALSE) otherwise.
alpar@9 2963 func_cygming_gnu_implib_p ()
alpar@9 2964 {
alpar@9 2965 $opt_debug
alpar@9 2966 func_cygming_gnu_implib_tmp=`eval "\$NM \$1 | \$global_symbol_pipe | \$EGREP ' (_head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname)\\\$'"`
alpar@9 2967 test -n "$func_cygming_gnu_implib_tmp"
alpar@9 2968 }
alpar@9 2969
alpar@9 2970 # func_cygming_ms_implib_p ARG
alpar@9 2971 # This predicate returns with zero status (TRUE) if
alpar@9 2972 # ARG is an MS-style import library. Returns
alpar@9 2973 # with nonzero status (FALSE) otherwise.
alpar@9 2974 func_cygming_ms_implib_p ()
alpar@9 2975 {
alpar@9 2976 $opt_debug
alpar@9 2977 func_cygming_ms_implib_tmp=`eval "\$NM \$1 | \$global_symbol_pipe | grep '_NULL_IMPORT_DESCRIPTOR'"`
alpar@9 2978 test -n "$func_cygming_ms_implib_tmp"
alpar@9 2979 }
alpar@9 2980
alpar@9 2981 # func_cygming_dll_for_implib_fallback ARG
alpar@9 2982 # Platform-specific function to extract the
alpar@9 2983 # name of the DLL associated with the specified
alpar@9 2984 # import library ARG.
alpar@9 2985 #
alpar@9 2986 # This fallback implementation is for use when $DLLTOOL
alpar@9 2987 # does not support the --identify-strict option.
alpar@9 2988 # Invoked by eval'ing the libtool variable
alpar@9 2989 # $sharedlib_from_linklib_cmd
alpar@9 2990 # Result is available in the variable
alpar@9 2991 # $sharedlib_from_linklib_result
alpar@9 2992 func_cygming_dll_for_implib_fallback ()
alpar@9 2993 {
alpar@9 2994 $opt_debug
alpar@9 2995 if func_cygming_gnu_implib_p "$1" ; then
alpar@9 2996 # binutils import library
alpar@9 2997 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
alpar@9 2998 elif func_cygming_ms_implib_p "$1" ; then
alpar@9 2999 # ms-generated import library
alpar@9 3000 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
alpar@9 3001 else
alpar@9 3002 # unknown
alpar@9 3003 sharedlib_from_linklib_result=""
alpar@9 3004 fi
alpar@9 3005 }
alpar@9 3006
alpar@9 3007
alpar@9 3008 # func_extract_an_archive dir oldlib
alpar@9 3009 func_extract_an_archive ()
alpar@9 3010 {
alpar@9 3011 $opt_debug
alpar@9 3012 f_ex_an_ar_dir="$1"; shift
alpar@9 3013 f_ex_an_ar_oldlib="$1"
alpar@9 3014 if test "$lock_old_archive_extraction" = yes; then
alpar@9 3015 lockfile=$f_ex_an_ar_oldlib.lock
alpar@9 3016 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
alpar@9 3017 func_echo "Waiting for $lockfile to be removed"
alpar@9 3018 sleep 2
alpar@9 3019 done
alpar@9 3020 fi
alpar@9 3021 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
alpar@9 3022 'stat=$?; rm -f "$lockfile"; exit $stat'
alpar@9 3023 if test "$lock_old_archive_extraction" = yes; then
alpar@9 3024 $opt_dry_run || rm -f "$lockfile"
alpar@9 3025 fi
alpar@9 3026 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
alpar@9 3027 :
alpar@9 3028 else
alpar@9 3029 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
alpar@9 3030 fi
alpar@9 3031 }
alpar@9 3032
alpar@9 3033
alpar@9 3034 # func_extract_archives gentop oldlib ...
alpar@9 3035 func_extract_archives ()
alpar@9 3036 {
alpar@9 3037 $opt_debug
alpar@9 3038 my_gentop="$1"; shift
alpar@9 3039 my_oldlibs=${1+"$@"}
alpar@9 3040 my_oldobjs=""
alpar@9 3041 my_xlib=""
alpar@9 3042 my_xabs=""
alpar@9 3043 my_xdir=""
alpar@9 3044
alpar@9 3045 for my_xlib in $my_oldlibs; do
alpar@9 3046 # Extract the objects.
alpar@9 3047 case $my_xlib in
alpar@9 3048 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
alpar@9 3049 *) my_xabs=`pwd`"/$my_xlib" ;;
alpar@9 3050 esac
alpar@9 3051 func_basename "$my_xlib"
alpar@9 3052 my_xlib="$func_basename_result"
alpar@9 3053 my_xlib_u=$my_xlib
alpar@9 3054 while :; do
alpar@9 3055 case " $extracted_archives " in
alpar@9 3056 *" $my_xlib_u "*)
alpar@9 3057 func_arith $extracted_serial + 1
alpar@9 3058 extracted_serial=$func_arith_result
alpar@9 3059 my_xlib_u=lt$extracted_serial-$my_xlib ;;
alpar@9 3060 *) break ;;
alpar@9 3061 esac
alpar@9 3062 done
alpar@9 3063 extracted_archives="$extracted_archives $my_xlib_u"
alpar@9 3064 my_xdir="$my_gentop/$my_xlib_u"
alpar@9 3065
alpar@9 3066 func_mkdir_p "$my_xdir"
alpar@9 3067
alpar@9 3068 case $host in
alpar@9 3069 *-darwin*)
alpar@9 3070 func_verbose "Extracting $my_xabs"
alpar@9 3071 # Do not bother doing anything if just a dry run
alpar@9 3072 $opt_dry_run || {
alpar@9 3073 darwin_orig_dir=`pwd`
alpar@9 3074 cd $my_xdir || exit $?
alpar@9 3075 darwin_archive=$my_xabs
alpar@9 3076 darwin_curdir=`pwd`
alpar@9 3077 darwin_base_archive=`basename "$darwin_archive"`
alpar@9 3078 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
alpar@9 3079 if test -n "$darwin_arches"; then
alpar@9 3080 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
alpar@9 3081 darwin_arch=
alpar@9 3082 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
alpar@9 3083 for darwin_arch in $darwin_arches ; do
alpar@9 3084 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
alpar@9 3085 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
alpar@9 3086 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
alpar@9 3087 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
alpar@9 3088 cd "$darwin_curdir"
alpar@9 3089 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
alpar@9 3090 done # $darwin_arches
alpar@9 3091 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
alpar@9 3092 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
alpar@9 3093 darwin_file=
alpar@9 3094 darwin_files=
alpar@9 3095 for darwin_file in $darwin_filelist; do
alpar@9 3096 darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
alpar@9 3097 $LIPO -create -output "$darwin_file" $darwin_files
alpar@9 3098 done # $darwin_filelist
alpar@9 3099 $RM -rf unfat-$$
alpar@9 3100 cd "$darwin_orig_dir"
alpar@9 3101 else
alpar@9 3102 cd $darwin_orig_dir
alpar@9 3103 func_extract_an_archive "$my_xdir" "$my_xabs"
alpar@9 3104 fi # $darwin_arches
alpar@9 3105 } # !$opt_dry_run
alpar@9 3106 ;;
alpar@9 3107 *)
alpar@9 3108 func_extract_an_archive "$my_xdir" "$my_xabs"
alpar@9 3109 ;;
alpar@9 3110 esac
alpar@9 3111 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
alpar@9 3112 done
alpar@9 3113
alpar@9 3114 func_extract_archives_result="$my_oldobjs"
alpar@9 3115 }
alpar@9 3116
alpar@9 3117
alpar@9 3118 # func_emit_wrapper [arg=no]
alpar@9 3119 #
alpar@9 3120 # Emit a libtool wrapper script on stdout.
alpar@9 3121 # Don't directly open a file because we may want to
alpar@9 3122 # incorporate the script contents within a cygwin/mingw
alpar@9 3123 # wrapper executable. Must ONLY be called from within
alpar@9 3124 # func_mode_link because it depends on a number of variables
alpar@9 3125 # set therein.
alpar@9 3126 #
alpar@9 3127 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
alpar@9 3128 # variable will take. If 'yes', then the emitted script
alpar@9 3129 # will assume that the directory in which it is stored is
alpar@9 3130 # the $objdir directory. This is a cygwin/mingw-specific
alpar@9 3131 # behavior.
alpar@9 3132 func_emit_wrapper ()
alpar@9 3133 {
alpar@9 3134 func_emit_wrapper_arg1=${1-no}
alpar@9 3135
alpar@9 3136 $ECHO "\
alpar@9 3137 #! $SHELL
alpar@9 3138
alpar@9 3139 # $output - temporary wrapper script for $objdir/$outputname
alpar@9 3140 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
alpar@9 3141 #
alpar@9 3142 # The $output program cannot be directly executed until all the libtool
alpar@9 3143 # libraries that it depends on are installed.
alpar@9 3144 #
alpar@9 3145 # This wrapper script should never be moved out of the build directory.
alpar@9 3146 # If it is, it will not operate correctly.
alpar@9 3147
alpar@9 3148 # Sed substitution that helps us do robust quoting. It backslashifies
alpar@9 3149 # metacharacters that are still active within double-quoted strings.
alpar@9 3150 sed_quote_subst='$sed_quote_subst'
alpar@9 3151
alpar@9 3152 # Be Bourne compatible
alpar@9 3153 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
alpar@9 3154 emulate sh
alpar@9 3155 NULLCMD=:
alpar@9 3156 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
alpar@9 3157 # is contrary to our usage. Disable this feature.
alpar@9 3158 alias -g '\${1+\"\$@\"}'='\"\$@\"'
alpar@9 3159 setopt NO_GLOB_SUBST
alpar@9 3160 else
alpar@9 3161 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
alpar@9 3162 fi
alpar@9 3163 BIN_SH=xpg4; export BIN_SH # for Tru64
alpar@9 3164 DUALCASE=1; export DUALCASE # for MKS sh
alpar@9 3165
alpar@9 3166 # The HP-UX ksh and POSIX shell print the target directory to stdout
alpar@9 3167 # if CDPATH is set.
alpar@9 3168 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
alpar@9 3169
alpar@9 3170 relink_command=\"$relink_command\"
alpar@9 3171
alpar@9 3172 # This environment variable determines our operation mode.
alpar@9 3173 if test \"\$libtool_install_magic\" = \"$magic\"; then
alpar@9 3174 # install mode needs the following variables:
alpar@9 3175 generated_by_libtool_version='$macro_version'
alpar@9 3176 notinst_deplibs='$notinst_deplibs'
alpar@9 3177 else
alpar@9 3178 # When we are sourced in execute mode, \$file and \$ECHO are already set.
alpar@9 3179 if test \"\$libtool_execute_magic\" != \"$magic\"; then
alpar@9 3180 file=\"\$0\""
alpar@9 3181
alpar@9 3182 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
alpar@9 3183 $ECHO "\
alpar@9 3184
alpar@9 3185 # A function that is used when there is no print builtin or printf.
alpar@9 3186 func_fallback_echo ()
alpar@9 3187 {
alpar@9 3188 eval 'cat <<_LTECHO_EOF
alpar@9 3189 \$1
alpar@9 3190 _LTECHO_EOF'
alpar@9 3191 }
alpar@9 3192 ECHO=\"$qECHO\"
alpar@9 3193 fi
alpar@9 3194
alpar@9 3195 # Very basic option parsing. These options are (a) specific to
alpar@9 3196 # the libtool wrapper, (b) are identical between the wrapper
alpar@9 3197 # /script/ and the wrapper /executable/ which is used only on
alpar@9 3198 # windows platforms, and (c) all exist in the "--lt-" namespace
alpar@9 3199 # (application programs are unlikely to have options which match
alpar@9 3200 # this pattern).
alpar@9 3201 #
alpar@9 3202 # There are only two supported options: --lt-debug and
alpar@9 3203 # --lt-dump-script. There is, deliberately, no --lt-help.
alpar@9 3204 #
alpar@9 3205 # The first argument to this parsing function should be the
alpar@9 3206 # script's $0 value, followed by "$@".
alpar@9 3207 lt_option_debug=
alpar@9 3208 func_parse_lt_options ()
alpar@9 3209 {
alpar@9 3210 lt_script_arg0=\$0
alpar@9 3211 shift
alpar@9 3212 for lt_opt
alpar@9 3213 do
alpar@9 3214 case \"\$lt_opt\" in
alpar@9 3215 --lt-debug) lt_option_debug=1 ;;
alpar@9 3216 --lt-dump-script)
alpar@9 3217 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
alpar@9 3218 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
alpar@9 3219 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
alpar@9 3220 cat \"\$lt_dump_D/\$lt_dump_F\"
alpar@9 3221 exit 0
alpar@9 3222 ;;
alpar@9 3223 --lt-*)
alpar@9 3224 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
alpar@9 3225 exit 1
alpar@9 3226 ;;
alpar@9 3227 esac
alpar@9 3228 done
alpar@9 3229 }
alpar@9 3230
alpar@9 3231 # Sets opts_contain_lt_result to \"yes\" if the
alpar@9 3232 # supplied arguments contain any elements in the
alpar@9 3233 # --lt-* namespace. Empty otherwise.
alpar@9 3234 opts_contain_lt_result=
alpar@9 3235 func_opts_contain_lt ()
alpar@9 3236 {
alpar@9 3237 opts_contain_lt_result=
alpar@9 3238 for lt_option
alpar@9 3239 do
alpar@9 3240 case \"\$lt_option\" in
alpar@9 3241 --lt-*) opts_contain_lt_result=yes
alpar@9 3242 break ;;
alpar@9 3243 *) ;;
alpar@9 3244 esac
alpar@9 3245 done
alpar@9 3246 }
alpar@9 3247
alpar@9 3248 # Used when --lt-debug. Prints its arguments to stdout
alpar@9 3249 # (redirection is the responsibility of the caller)
alpar@9 3250 func_lt_dump_args ()
alpar@9 3251 {
alpar@9 3252 lt_dump_args_N=1;
alpar@9 3253 for lt_arg
alpar@9 3254 do
alpar@9 3255 \$ECHO \"(main) newargz[\$lt_dump_args_N] : \$lt_arg\"
alpar@9 3256 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
alpar@9 3257 done
alpar@9 3258 }
alpar@9 3259
alpar@9 3260 # Core function for launching the target application
alpar@9 3261 func_exec_program_core ()
alpar@9 3262 {
alpar@9 3263 "
alpar@9 3264 case $host in
alpar@9 3265 # Backslashes separate directories on plain windows
alpar@9 3266 *-*-mingw | *-*-os2* | *-cegcc*)
alpar@9 3267 $ECHO "\
alpar@9 3268 if test -n \"\$lt_option_debug\"; then
alpar@9 3269 \$ECHO \"(main) lt_argv_zero : \$progdir\\\\\$program\" 1>&2
alpar@9 3270 func_lt_dump_args \${1+\"\$@\"} 1>&2
alpar@9 3271 fi
alpar@9 3272 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
alpar@9 3273 "
alpar@9 3274 ;;
alpar@9 3275
alpar@9 3276 *)
alpar@9 3277 $ECHO "\
alpar@9 3278 if test -n \"\$lt_option_debug\"; then
alpar@9 3279 \$ECHO \"(main) lt_argv_zero : \$progdir/\$program\" 1>&2
alpar@9 3280 func_lt_dump_args \${1+\"\$@\"} 1>&2
alpar@9 3281 fi
alpar@9 3282 exec \"\$progdir/\$program\" \${1+\"\$@\"}
alpar@9 3283 "
alpar@9 3284 ;;
alpar@9 3285 esac
alpar@9 3286 $ECHO "\
alpar@9 3287 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
alpar@9 3288 exit 1
alpar@9 3289 }
alpar@9 3290
alpar@9 3291 # A function to encapsulate launching the target application
alpar@9 3292 # Strips options in the --lt-* namespace from \$@ and
alpar@9 3293 # launches target application with the remaining arguments.
alpar@9 3294 func_exec_program ()
alpar@9 3295 {
alpar@9 3296 func_opts_contain_lt \${1+\"\$@\"}
alpar@9 3297 if test -n \"\$opts_contain_lt_result\"; then
alpar@9 3298 # the following is adapted from _AC_INIT_PREPARE, except
alpar@9 3299 # (1) we don't care about duplicates, and
alpar@9 3300 # (2) we strip out --lt-*, not --no-create/--no-recursion/--silent
alpar@9 3301 lt_wrapper_args=
alpar@9 3302 for lt_wr_arg
alpar@9 3303 do
alpar@9 3304 case \$lt_wr_arg in
alpar@9 3305 --lt-*) continue ;;
alpar@9 3306 *\\'*)
alpar@9 3307 lt_wr_arg=\`\$ECHO \"X\$lt_wr_arg\" |
alpar@9 3308 $SED -e \"s/^X//\" -e \"s/'/'\\\\\\\\\\\\\\\\''/g\"\`
alpar@9 3309 ;;
alpar@9 3310 esac
alpar@9 3311 lt_wrapper_args=\"\$lt_wrapper_args '\$lt_wr_arg'\"
alpar@9 3312 done
alpar@9 3313 eval func_exec_program_core \$lt_wrapper_args
alpar@9 3314 else
alpar@9 3315 func_exec_program_core \${1+\"\$@\"}
alpar@9 3316 fi
alpar@9 3317 }
alpar@9 3318
alpar@9 3319 # Parse options
alpar@9 3320 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
alpar@9 3321
alpar@9 3322 # Find the directory that this script lives in.
alpar@9 3323 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
alpar@9 3324 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
alpar@9 3325
alpar@9 3326 # Follow symbolic links until we get to the real thisdir.
alpar@9 3327 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
alpar@9 3328 while test -n \"\$file\"; do
alpar@9 3329 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
alpar@9 3330
alpar@9 3331 # If there was a directory component, then change thisdir.
alpar@9 3332 if test \"x\$destdir\" != \"x\$file\"; then
alpar@9 3333 case \"\$destdir\" in
alpar@9 3334 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
alpar@9 3335 *) thisdir=\"\$thisdir/\$destdir\" ;;
alpar@9 3336 esac
alpar@9 3337 fi
alpar@9 3338
alpar@9 3339 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
alpar@9 3340 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
alpar@9 3341 done
alpar@9 3342
alpar@9 3343 # Usually 'no', except on cygwin/mingw when embedded into
alpar@9 3344 # the cwrapper.
alpar@9 3345 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
alpar@9 3346 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
alpar@9 3347 # special case for '.'
alpar@9 3348 if test \"\$thisdir\" = \".\"; then
alpar@9 3349 thisdir=\`pwd\`
alpar@9 3350 fi
alpar@9 3351 # remove .libs from thisdir
alpar@9 3352 case \"\$thisdir\" in
alpar@9 3353 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
alpar@9 3354 $objdir ) thisdir=. ;;
alpar@9 3355 esac
alpar@9 3356 fi
alpar@9 3357
alpar@9 3358 # Try to get the absolute directory name.
alpar@9 3359 absdir=\`cd \"\$thisdir\" && pwd\`
alpar@9 3360 test -n \"\$absdir\" && thisdir=\"\$absdir\"
alpar@9 3361 "
alpar@9 3362
alpar@9 3363 if test "$fast_install" = yes; then
alpar@9 3364 $ECHO "\
alpar@9 3365 program=lt-'$outputname'$exeext
alpar@9 3366 progdir=\"\$thisdir/$objdir\"
alpar@9 3367
alpar@9 3368 if test ! -f \"\$progdir/\$program\" ||
alpar@9 3369 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
alpar@9 3370 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
alpar@9 3371
alpar@9 3372 file=\"\$\$-\$program\"
alpar@9 3373
alpar@9 3374 if test ! -d \"\$progdir\"; then
alpar@9 3375 $MKDIR \"\$progdir\"
alpar@9 3376 else
alpar@9 3377 $RM \"\$progdir/\$file\"
alpar@9 3378 fi"
alpar@9 3379
alpar@9 3380 $ECHO "\
alpar@9 3381
alpar@9 3382 # relink executable if necessary
alpar@9 3383 if test -n \"\$relink_command\"; then
alpar@9 3384 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
alpar@9 3385 else
alpar@9 3386 $ECHO \"\$relink_command_output\" >&2
alpar@9 3387 $RM \"\$progdir/\$file\"
alpar@9 3388 exit 1
alpar@9 3389 fi
alpar@9 3390 fi
alpar@9 3391
alpar@9 3392 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
alpar@9 3393 { $RM \"\$progdir/\$program\";
alpar@9 3394 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
alpar@9 3395 $RM \"\$progdir/\$file\"
alpar@9 3396 fi"
alpar@9 3397 else
alpar@9 3398 $ECHO "\
alpar@9 3399 program='$outputname'
alpar@9 3400 progdir=\"\$thisdir/$objdir\"
alpar@9 3401 "
alpar@9 3402 fi
alpar@9 3403
alpar@9 3404 $ECHO "\
alpar@9 3405
alpar@9 3406 if test -f \"\$progdir/\$program\"; then"
alpar@9 3407
alpar@9 3408 # Export our shlibpath_var if we have one.
alpar@9 3409 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
alpar@9 3410 $ECHO "\
alpar@9 3411 # Add our own library path to $shlibpath_var
alpar@9 3412 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
alpar@9 3413
alpar@9 3414 # Some systems cannot cope with colon-terminated $shlibpath_var
alpar@9 3415 # The second colon is a workaround for a bug in BeOS R4 sed
alpar@9 3416 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
alpar@9 3417
alpar@9 3418 export $shlibpath_var
alpar@9 3419 "
alpar@9 3420 fi
alpar@9 3421
alpar@9 3422 # fixup the dll searchpath if we need to.
alpar@9 3423 if test -n "$dllsearchpath"; then
alpar@9 3424 $ECHO "\
alpar@9 3425 # Add the dll search path components to the executable PATH
alpar@9 3426 PATH=$dllsearchpath:\$PATH
alpar@9 3427 "
alpar@9 3428 fi
alpar@9 3429
alpar@9 3430 $ECHO "\
alpar@9 3431 if test \"\$libtool_execute_magic\" != \"$magic\"; then
alpar@9 3432 # Run the actual program with our arguments.
alpar@9 3433 func_exec_program \${1+\"\$@\"}
alpar@9 3434 fi
alpar@9 3435 else
alpar@9 3436 # The program doesn't exist.
alpar@9 3437 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
alpar@9 3438 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
alpar@9 3439 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
alpar@9 3440 exit 1
alpar@9 3441 fi
alpar@9 3442 fi\
alpar@9 3443 "
alpar@9 3444 }
alpar@9 3445
alpar@9 3446 ####################################
alpar@9 3447 # PATH CONVERSION HELPER FUNCTIONS #
alpar@9 3448 ####################################
alpar@9 3449
alpar@9 3450 # func_wine_to_win32_path ARG
alpar@9 3451 # Helper function used by path conversion functions
alpar@9 3452 # when $build is *nix, and $host is mingw, cygwin,
alpar@9 3453 # or some other win32 environment. Relies on a
alpar@9 3454 # correctly configured wine environment available,
alpar@9 3455 # with the winepath program in $build's $PATH.
alpar@9 3456 #
alpar@9 3457 # ARG is the $build path to be converted to win32 format.
alpar@9 3458 # result is available in $func_wine_to_win32_path_result
alpar@9 3459 # result is empty on error (or when arg is empty)
alpar@9 3460 func_wine_to_win32_path ()
alpar@9 3461 {
alpar@9 3462 $opt_debug
alpar@9 3463 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
alpar@9 3464 func_wine_to_win32_path_result="$1"
alpar@9 3465 if test -n "$1"; then
alpar@9 3466 # Unfortunately, winepath does not exit with a non-zero
alpar@9 3467 # error code, so we are forced to check the contents of
alpar@9 3468 # stdout. On the other hand, if the command is not
alpar@9 3469 # found, the shell will set an exit code of 127 and print
alpar@9 3470 # *an error message* to stdout. So we must check for both
alpar@9 3471 # error code of zero AND non-empty stdout, which explains
alpar@9 3472 # the odd construction:
alpar@9 3473 func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
alpar@9 3474 if test "$?" -eq 0 && test -n "${func_wine_to_win32_path_tmp}"; then
alpar@9 3475 func_to_host_path_result=`$ECHO "$func_wine_to_win32_path_tmp" |
alpar@9 3476 $SED -e "$lt_sed_naive_backslashify"`
alpar@9 3477 else
alpar@9 3478 func_wine_to_win32_path_result=
alpar@9 3479 fi
alpar@9 3480 fi
alpar@9 3481 }
alpar@9 3482 # end: func_wine_to_win32_path
alpar@9 3483
alpar@9 3484
alpar@9 3485 # func_wine_to_win32_pathlist ARG
alpar@9 3486 # Helper function used by path conversion functions
alpar@9 3487 # when $build is *nix, and $host is mingw, cygwin,
alpar@9 3488 # or some other win32 environment. Relies on a
alpar@9 3489 # correctly configured wine environment available,
alpar@9 3490 # with the winepath program in $build's $PATH.
alpar@9 3491 # Assumes ARG has no leading or trailing path separator
alpar@9 3492 # characters.
alpar@9 3493 #
alpar@9 3494 # ARG is pathlist to be converted from $build format to win32.
alpar@9 3495 # Result is available in $func_wine_to_win32_pathlist_result
alpar@9 3496 # Unconvertible paths in pathlist are skipped; if no paths
alpar@9 3497 # are convertible, result may be empty.
alpar@9 3498 func_wine_to_win32_pathlist ()
alpar@9 3499 {
alpar@9 3500 $opt_debug
alpar@9 3501 # unfortunately, winepath doesn't convert pathlists
alpar@9 3502 func_wine_to_win32_pathlist_result=""
alpar@9 3503 if test -n "$1"; then
alpar@9 3504 func_wine_to_win32_pathlist_oldIFS=$IFS
alpar@9 3505 IFS=:
alpar@9 3506 for func_wine_to_win32_pathlist_f in $1; do
alpar@9 3507 IFS=$func_wine_to_win32_pathlist_oldIFS
alpar@9 3508 if test -n "$func_wine_to_win32_pathlist_f" ; then
alpar@9 3509 func_wine_to_win32_path "$func_wine_to_win32_pathlist_f"
alpar@9 3510 if test -n "$func_wine_to_win32_path_result" ; then
alpar@9 3511 if test -z "$func_wine_to_win32_pathlist_result"; then
alpar@9 3512 func_wine_to_win32_pathlist_result="$func_wine_to_win32_path_result"
alpar@9 3513 else
alpar@9 3514 func_append func_wine_to_win32_pathlist_result ";$func_wine_to_win32_path_result"
alpar@9 3515 fi
alpar@9 3516 fi
alpar@9 3517 fi
alpar@9 3518 done
alpar@9 3519 IFS=$func_wine_to_win32_pathlist_oldIFS
alpar@9 3520 fi
alpar@9 3521 }
alpar@9 3522 # end: func_wine_to_win32_pathlist
alpar@9 3523
alpar@9 3524
alpar@9 3525 # func_cygpath ARGS...
alpar@9 3526 # a wrapper around calling the cygpath program via
alpar@9 3527 # LT_CYGPATH, when $host is *nix and cygwin is
alpar@9 3528 # hosted via a wine environment (or, rarely, when
alpar@9 3529 # host is mingw -- that is, msys).
alpar@9 3530 #
alpar@9 3531 # Result is available in func_cygpath_result, which
alpar@9 3532 # may be empty on error. Can accomodate both paths
alpar@9 3533 # and pathlists (with appropriate options).
alpar@9 3534 #
alpar@9 3535 # ARGS are the typical arguments and options for
alpar@9 3536 # the cygpath program. Usually, the last argument
alpar@9 3537 # is the path or pathlist to be converted.
alpar@9 3538 #
alpar@9 3539 # The full *nix (or msys) path to the cygpath program must be
alpar@9 3540 # specified in the LT_CYGPATH environment variable. This
alpar@9 3541 # is because (a) the cygpath program shouldn't be in $PATH,
alpar@9 3542 # because it usually lives in cygwin's bin/ directory --
alpar@9 3543 # along with *cygwin* versions of sed, id, cp. If the *nix (or
alpar@9 3544 # msys) host environment had those programs in its $PATH, many
alpar@9 3545 # bad things could happen. (b) especially in cygwin-1.7, multiple
alpar@9 3546 # installations (with separate "mount tables" in
alpar@9 3547 # <CYGROOT-N>/etc/fstab) can coexist on the same Win32
alpar@9 3548 # instance. The cygpath.exe for cygwin installation #N in
alpar@9 3549 # <CYGROOT-N>/bin automatically deduces the appropriate
alpar@9 3550 # ../etc/fstab file. Therefore, it matters which cygpath.exe
alpar@9 3551 # is used. LT_CYGPATH may be replaced or supplemented by an
alpar@9 3552 # LT_INIT-activated configure option in the future.
alpar@9 3553 func_cygpath ()
alpar@9 3554 {
alpar@9 3555 $opt_debug
alpar@9 3556 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
alpar@9 3557 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
alpar@9 3558 if test "$?" -ne 0; then
alpar@9 3559 # on failure, ensure result is empty
alpar@9 3560 func_cygpath_result=
alpar@9 3561 fi
alpar@9 3562 else
alpar@9 3563 func_cygpath_result=
alpar@9 3564 func_error "LT_CYGPATH is empty or specifies non-existant file: \`$LT_CYGPATH'"
alpar@9 3565 fi
alpar@9 3566 }
alpar@9 3567 #end: func_cygpath
alpar@9 3568
alpar@9 3569
alpar@9 3570 # func_msys_to_win32 ARG
alpar@9 3571 # Converts ARG from msys (unix-ish) format to
alpar@9 3572 # win32 format. Can accomodate both paths and pathlists.
alpar@9 3573 # Result is available in func_msys_to_win32_result.
alpar@9 3574 func_msys_to_win32 ()
alpar@9 3575 {
alpar@9 3576 $opt_debug
alpar@9 3577 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
alpar@9 3578 # awkward: cmd appends spaces to result
alpar@9 3579 func_msys_to_win32_result=`( cmd //c echo "$1" ) 2>/dev/null |
alpar@9 3580 $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
alpar@9 3581 }
alpar@9 3582 #end: func_msys_to_win32
alpar@9 3583
alpar@9 3584
alpar@9 3585 # func_path_convert_check ARG1 ARG2
alpar@9 3586 # Verify that ARG1 (a path in $build format) was
alpar@9 3587 # converted to $host format in ARG2. Otherwise, emit
alpar@9 3588 # an error message, but continue (resetting
alpar@9 3589 # func_to_host_path_result to ARG1).
alpar@9 3590 func_path_convert_check ()
alpar@9 3591 {
alpar@9 3592 $opt_debug
alpar@9 3593 if test -z "$2" && test -n "$1" ; then
alpar@9 3594 func_error "Could not determine host path corresponding to"
alpar@9 3595 func_error " \`$1'"
alpar@9 3596 func_error "Continuing, but uninstalled executables may not work."
alpar@9 3597 # Fallback:
alpar@9 3598 func_to_host_path_result="$1"
alpar@9 3599 fi
alpar@9 3600 }
alpar@9 3601 # end func_path_convert_check
alpar@9 3602
alpar@9 3603
alpar@9 3604 # func_pathlist_convert_check FROM_PATHSEP TO_PATHSEP FROM_PATHLIST TO_PATHLIST
alpar@9 3605 # Verify that FROM_PATHLIST (a path in $build format) was converted
alpar@9 3606 # $host format in TO_PATHLIST. Otherwise, emit an error message, but
alpar@9 3607 # continue, resetting func_to_host_path_result to a simplistic
alpar@9 3608 # fallback value (see below).
alpar@9 3609 func_pathlist_convert_check ()
alpar@9 3610 {
alpar@9 3611 $opt_debug
alpar@9 3612 if test -z "$4" && test -n "$3"; then
alpar@9 3613 func_error "Could not determine the host path(s) corresponding to"
alpar@9 3614 func_error " \`$3'"
alpar@9 3615 func_error "Continuing, but uninstalled executables may not work."
alpar@9 3616 # Fallback. If even this fallback fails, the fix is not to
alpar@9 3617 # complicate the expression below, but for the user to provide,
alpar@9 3618 # in that situation, whatever elements are missing from the
alpar@9 3619 # environment so that the actual pathlist conversion functions
alpar@9 3620 # work properly (for instance, a working wine installation
alpar@9 3621 # with winepath so that path translation in the cross-to-mingw
alpar@9 3622 # case works).
alpar@9 3623 if test "x$1" != "x$2"; then
alpar@9 3624 lt_replace_pathsep_chars="s|$1|$2|g"
alpar@9 3625 func_to_host_pathlist_result=`echo "$3" |\
alpar@9 3626 $SED -e "$lt_replace_pathsep_chars"`
alpar@9 3627 else
alpar@9 3628 func_to_host_pathlist_result="$3"
alpar@9 3629 fi
alpar@9 3630 fi
alpar@9 3631 }
alpar@9 3632 # end func_pathlist_convert_check
alpar@9 3633
alpar@9 3634
alpar@9 3635 # func_pathlist_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
alpar@9 3636 # Modifies func_to_host_pathlist_result by prepending REPL
alpar@9 3637 # if ORIG matches FRONTPAT and appending REPL if ORIG matches
alpar@9 3638 # BACKPAT.
alpar@9 3639 func_pathlist_front_back_pathsep ()
alpar@9 3640 {
alpar@9 3641 $opt_debug
alpar@9 3642 case "$4" in
alpar@9 3643 $1 ) func_to_host_pathlist_result="$3$func_to_host_pathlist_result"
alpar@9 3644 ;;
alpar@9 3645 esac
alpar@9 3646 case "$4" in
alpar@9 3647 $2 ) func_append func_to_host_pathlist_result "$3"
alpar@9 3648 ;;
alpar@9 3649 esac
alpar@9 3650 }
alpar@9 3651 # end func_pathlist_front_back_pathsep
alpar@9 3652
alpar@9 3653
alpar@9 3654 #############################################
alpar@9 3655 # $build to $host PATH CONVERSION FUNCTIONS #
alpar@9 3656 #############################################
alpar@9 3657 # invoked via `eval $to_host_path_cmd ARG'
alpar@9 3658 #
alpar@9 3659 # At present, the following path conversions are supported:
alpar@9 3660 # $build $host
alpar@9 3661 # mingw (msys) mingw [e.g. native]
alpar@9 3662 # cygwin mingw
alpar@9 3663 # *nix + wine mingw
alpar@9 3664 # mingw (msys) cygwin [*] [**]
alpar@9 3665 # *nix + wine cygwin [**]
alpar@9 3666 # where wine is equipped with the `winepath' executable.
alpar@9 3667 # [*] available, but not officially supported. See comments with
alpar@9 3668 # func_msys_to_cygwin_path_convert.
alpar@9 3669 # [**] requires environment variable $LT_CYGPATH. See comments
alpar@9 3670 # with func_cygpath.
alpar@9 3671 # In each case, ARG is the path to be converted from $build
alpar@9 3672 # to $host format. the result will be available in
alpar@9 3673 # $func_to_host_path_result.
alpar@9 3674
alpar@9 3675
alpar@9 3676 # func_to_host_path ARG
alpar@9 3677 # converts the path ARG from $build format to $host
alpar@9 3678 # format.
alpar@9 3679 func_to_host_path ()
alpar@9 3680 {
alpar@9 3681 $opt_debug
alpar@9 3682 eval '$to_host_path_cmd "$1"'
alpar@9 3683 }
alpar@9 3684 # end func_to_host_path
alpar@9 3685
alpar@9 3686
alpar@9 3687 # func_noop_path_convert ARG
alpar@9 3688 # A no-op path conversion function for use when $build == $host.
alpar@9 3689 # or when there is no required (or known) conversion function
alpar@9 3690 # between $build and $host.
alpar@9 3691 func_noop_path_convert ()
alpar@9 3692 {
alpar@9 3693 $opt_debug
alpar@9 3694 func_to_host_path_result="$1"
alpar@9 3695 }
alpar@9 3696 # end func_noop_path_convert
alpar@9 3697
alpar@9 3698
alpar@9 3699 # func_msys_to_mingw_path_convert ARG
alpar@9 3700 # A path conversion function for use with "native" mingw
alpar@9 3701 # builds -- that is, when $host is *mingw*, and $build
alpar@9 3702 # is *mingw* (which is to say, msys). In this case, the
alpar@9 3703 # msys shell automatically converts paths for any non-msys
alpar@9 3704 # applications it launches, but that facility isn't available
alpar@9 3705 # from inside the cwrapper.
alpar@9 3706 #
alpar@9 3707 # ARG is the path to be converted; the result is available
alpar@9 3708 # in func_to_host_path_result.
alpar@9 3709 func_msys_to_mingw_path_convert ()
alpar@9 3710 {
alpar@9 3711 $opt_debug
alpar@9 3712 func_to_host_path_result="$1"
alpar@9 3713 if test -n "$1"; then
alpar@9 3714 func_msys_to_win32 "$1"
alpar@9 3715 func_to_host_path_result="$func_msys_to_win32_result"
alpar@9 3716 fi
alpar@9 3717 func_path_convert_check "$1" "$func_to_host_path_result"
alpar@9 3718 }
alpar@9 3719 # end func_msys_to_mingw_path_convert
alpar@9 3720
alpar@9 3721
alpar@9 3722 # func_cygwin_to_mingw_path_convert ARG
alpar@9 3723 # A path conversion function for use when $host is *mingw*
alpar@9 3724 # but $build is *cygwin*. In this case, the cygpath program
alpar@9 3725 # provided by the $build environment is sufficient for all
alpar@9 3726 # conversions.
alpar@9 3727 #
alpar@9 3728 # ARG is the path to be converted; the result is available
alpar@9 3729 # in func_to_host_path_result.
alpar@9 3730 func_cygwin_to_mingw_path_convert ()
alpar@9 3731 {
alpar@9 3732 $opt_debug
alpar@9 3733 func_to_host_path_result="$1"
alpar@9 3734 if test -n "$1"; then
alpar@9 3735 # because $build is cygwin, we call "the" cygpath
alpar@9 3736 # in $PATH; no need to use LT_CYGPATH in this case.
alpar@9 3737 func_to_host_path_result=`cygpath -m "$1"`
alpar@9 3738 fi
alpar@9 3739 func_path_convert_check "$1" "$func_to_host_path_result"
alpar@9 3740 }
alpar@9 3741 # end func_cygwin_to_mingw_path_convert
alpar@9 3742
alpar@9 3743
alpar@9 3744 # func_nix_to_mingw_path_convert ARG
alpar@9 3745 # A path conversion function for use when $host is *mingw*
alpar@9 3746 # but $build is some *nix variant. In this case, we assume
alpar@9 3747 # that a wine environment with a working winepath executable
alpar@9 3748 # is available in $build's $PATH.
alpar@9 3749 #
alpar@9 3750 # ARG is the path to be converted; the result is available
alpar@9 3751 # in func_to_host_path_result.
alpar@9 3752 func_nix_to_mingw_path_convert ()
alpar@9 3753 {
alpar@9 3754 $opt_debug
alpar@9 3755 func_to_host_path_result="$1"
alpar@9 3756 if test -n "$1"; then
alpar@9 3757 func_wine_to_win32_path "$1"
alpar@9 3758 func_to_host_path_result="$func_wine_to_win32_path_result"
alpar@9 3759 fi
alpar@9 3760 func_path_convert_check "$1" "$func_to_host_path_result"
alpar@9 3761 }
alpar@9 3762 # end func_nix_to_mingw_path_convert
alpar@9 3763
alpar@9 3764
alpar@9 3765 # func_msys_to_cygwin_path_convert ARG
alpar@9 3766 # A path conversion function for use when $host is *cygwin*
alpar@9 3767 # but $build is *mingw* (that is, msys). This implies running
alpar@9 3768 # a cross build from msys to cygwin -- but msys has notorious
alpar@9 3769 # problems executing cygwin apps, because of conflicts between
alpar@9 3770 # cygwin1.dll and msys-1.0.dll. However, we'll try it. First,
alpar@9 3771 # convert from msys to win32, then use func_cygpath to convert
alpar@9 3772 # from win32 to cygwin. Requires LT_CYGPATH.
alpar@9 3773 #
alpar@9 3774 # ARG is the path to be converted; the result is available
alpar@9 3775 # in func_to_host_path_result.
alpar@9 3776 func_msys_to_cygwin_path_convert ()
alpar@9 3777 {
alpar@9 3778 $opt_debug
alpar@9 3779 func_to_host_path_result="$1"
alpar@9 3780 if test -n "$1"; then
alpar@9 3781 func_msys_to_win32 "$1"
alpar@9 3782 func_cygpath -u "$func_msys_to_win32_result"
alpar@9 3783 func_to_host_path_result="$func_cygpath_result"
alpar@9 3784 fi
alpar@9 3785 func_path_convert_check "$1" "$func_to_host_path_result"
alpar@9 3786 }
alpar@9 3787 # end func_msys_to_cygwin_path_convert
alpar@9 3788
alpar@9 3789 # func_nix_to_cygwin_path_convert ARG
alpar@9 3790 # A path conversion function for use when $host is *cygwin*
alpar@9 3791 # but $build is some *nix variant. In this case, we assume
alpar@9 3792 # that a wine environment with a working winepath executable
alpar@9 3793 # is available in $build's $PATH, and that cygwin is installed
alpar@9 3794 # within that wine environment. Requires LT_CYGPATH (see
alpar@9 3795 # func_cygpath).
alpar@9 3796 #
alpar@9 3797 # ARG is the path to be converted; the result is available
alpar@9 3798 # in func_to_host_path_result.
alpar@9 3799 func_nix_to_cygwin_path_convert ()
alpar@9 3800 {
alpar@9 3801 $opt_debug
alpar@9 3802 func_to_host_path_result="$1"
alpar@9 3803 if test -n "$1"; then
alpar@9 3804 # convert from *nix to win32, then use cygpath to
alpar@9 3805 # convert from win32 to cygwin.
alpar@9 3806 func_wine_to_win32_path "$1"
alpar@9 3807 func_cygpath -u "$func_wine_to_win32_path_result"
alpar@9 3808 func_to_host_path_result="$func_cygpath_result"
alpar@9 3809 fi
alpar@9 3810 func_path_convert_check "$1" "$func_to_host_path_result"
alpar@9 3811 }
alpar@9 3812 # end func_nix_to_cygwin_path_convert
alpar@9 3813
alpar@9 3814
alpar@9 3815 #################################################
alpar@9 3816 # $build to $host PATHLIST CONVERSION FUNCTIONS #
alpar@9 3817 #################################################
alpar@9 3818 # invoked via `eval $to_host_pathlist_cmd ARG'
alpar@9 3819 #
alpar@9 3820 # At present, the following pathlist conversions are supported:
alpar@9 3821 # $build $host
alpar@9 3822 # mingw (msys) mingw [e.g. native]
alpar@9 3823 # cygwin mingw
alpar@9 3824 # *nix + wine mingw
alpar@9 3825 # mingw (msys) cygwin [*] [**]
alpar@9 3826 # *nix + wine cygwin [**]
alpar@9 3827 # where wine is equipped with the `winepath' executable.
alpar@9 3828 # [*] available, but not officially supported. See comments with
alpar@9 3829 # func_msys_to_cygwin_pathlist_convert.
alpar@9 3830 # [**] requires environment variable $LT_CYGPATH. See comments
alpar@9 3831 # with func_cygpath.
alpar@9 3832 # In each case, ARG is the pathlist to be converted from
alpar@9 3833 # $build to $host format. the result will be available in
alpar@9 3834 # $func_to_host_pathlist_result.
alpar@9 3835 #
alpar@9 3836 # Path separators are also converted from $build format to
alpar@9 3837 # $host format. If ARG begins or ends with a path separator
alpar@9 3838 # character, it is preserved (but converted to $host format)
alpar@9 3839 # on output.
alpar@9 3840
alpar@9 3841
alpar@9 3842 # func_init_to_host_pathlist_cmd
alpar@9 3843 # Ensures that function "pointer" variable
alpar@9 3844 # $to_host_pathlist_cmd is set to the appropriate
alpar@9 3845 # value, based on the value of $to_host_path_cmd.
alpar@9 3846 #
alpar@9 3847 # ASSUMPTIONS: all such conversion functions are
alpar@9 3848 # named using the following convention:
alpar@9 3849 # path conversion function : xxxxxx_path_convert ()
alpar@9 3850 # pathlist conversion function: xxxxxx_pathlist_convert ()
alpar@9 3851 # where, for any given $build/$host combination the 'xxxxxx'
alpar@9 3852 # value is the same.
alpar@9 3853 to_host_pathlist_cmd=
alpar@9 3854 func_init_to_host_pathlist_cmd ()
alpar@9 3855 {
alpar@9 3856 $opt_debug
alpar@9 3857 if test -z "$to_host_pathlist_cmd"; then
alpar@9 3858 func_stripname '' '_path_convert' "$to_host_path_cmd"
alpar@9 3859 to_host_pathlist_cmd="${func_stripname_result}_pathlist_convert"
alpar@9 3860 fi
alpar@9 3861 }
alpar@9 3862
alpar@9 3863
alpar@9 3864 # func_to_host_pathlist ARG
alpar@9 3865 # converts the pathlist ARG from $build format to $host
alpar@9 3866 # format.
alpar@9 3867 func_to_host_pathlist ()
alpar@9 3868 {
alpar@9 3869 $opt_debug
alpar@9 3870 func_init_to_host_pathlist_cmd
alpar@9 3871 eval '$to_host_pathlist_cmd "$1"'
alpar@9 3872 }
alpar@9 3873 # end func_to_host_pathlist
alpar@9 3874
alpar@9 3875
alpar@9 3876 # func_noop_pathlist_convert ARG
alpar@9 3877 # A no-op pathlist conversion function for use when $build == $host,
alpar@9 3878 # or when there is no required (or known) conversion function
alpar@9 3879 # between $build and $host.
alpar@9 3880 func_noop_pathlist_convert ()
alpar@9 3881 {
alpar@9 3882 $opt_debug
alpar@9 3883 func_to_host_pathlist_result="$1"
alpar@9 3884 }
alpar@9 3885 # end func_noop_pathlist_convert
alpar@9 3886
alpar@9 3887
alpar@9 3888 # func_msys_to_mingw_pathlist_convert ARG
alpar@9 3889 # A pathlist conversion function for use with "native" mingw
alpar@9 3890 # builds -- that is, when $host is *mingw*, and $build
alpar@9 3891 # is *mingw* (which is to say, msys). In this case, the
alpar@9 3892 # msys shell automatically converts pathlists for any non-msys
alpar@9 3893 # applications it launches, but that facility isn't available
alpar@9 3894 # from inside the cwrapper.
alpar@9 3895 #
alpar@9 3896 # ARG is the pathlist to be converted; the result is available
alpar@9 3897 # in func_to_host_pathlist_result.
alpar@9 3898 func_msys_to_mingw_pathlist_convert ()
alpar@9 3899 {
alpar@9 3900 $opt_debug
alpar@9 3901 func_to_host_pathlist_result="$1"
alpar@9 3902 if test -n "$1"; then
alpar@9 3903 # Remove leading and trailing path separator characters from
alpar@9 3904 # ARG. msys behavior is inconsistent here, cygpath turns them
alpar@9 3905 # into '.;' and ';.', and winepath ignores them completely.
alpar@9 3906 func_stripname : : "$1"
alpar@9 3907 func_to_host_pathlist_tmp1=$func_stripname_result
alpar@9 3908 func_msys_to_win32 "$func_to_host_pathlist_tmp1"
alpar@9 3909 func_to_host_pathlist_result="$func_msys_to_win32_result"
alpar@9 3910 func_pathlist_convert_check ":" ";" \
alpar@9 3911 "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
alpar@9 3912 func_pathlist_front_back_pathsep ":*" "*:" ";" "$1"
alpar@9 3913 fi
alpar@9 3914 }
alpar@9 3915 # end func_msys_to_mingw_pathlist_convert
alpar@9 3916
alpar@9 3917
alpar@9 3918 # func_cygwin_to_mingw_pathlist_convert ARG
alpar@9 3919 # A pathlist conversion function for use when $host is *mingw*
alpar@9 3920 # but $build is *cygwin*. In this case, the cygpath program
alpar@9 3921 # provided by the $build environment is sufficient for all
alpar@9 3922 # conversions.
alpar@9 3923 #
alpar@9 3924 # ARG is the pathlist to be converted; the result is available
alpar@9 3925 # in func_to_host_pathlist_result.
alpar@9 3926 func_cygwin_to_mingw_pathlist_convert ()
alpar@9 3927 {
alpar@9 3928 $opt_debug
alpar@9 3929 func_to_host_pathlist_result="$1"
alpar@9 3930 if test -n "$1"; then
alpar@9 3931 # Remove leading and trailing path separator characters from
alpar@9 3932 # ARG. msys behavior is inconsistent here, cygpath turns them
alpar@9 3933 # into '.;' and ';.', and winepath ignores them completely.
alpar@9 3934 func_stripname : : "$1"
alpar@9 3935 func_to_host_pathlist_tmp1=$func_stripname_result
alpar@9 3936 func_to_host_pathlist_result=`cygpath -m -p "$func_to_host_pathlist_tmp1"`
alpar@9 3937 func_pathlist_convert_check ":" ";" \
alpar@9 3938 "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
alpar@9 3939 func_pathlist_front_back_pathsep ":*" "*:" ";" "$1"
alpar@9 3940 fi
alpar@9 3941 }
alpar@9 3942 # end func_cygwin_to_mingw_pathlist_convert
alpar@9 3943
alpar@9 3944
alpar@9 3945 # func_nix_to_mingw_pathlist_convert ARG
alpar@9 3946 # A pathlist conversion function for use when $host is *mingw*
alpar@9 3947 # but $build is some *nix variant. In this case, we assume
alpar@9 3948 # that a wine environment with a working winepath executable
alpar@9 3949 # is available in $build's $PATH.
alpar@9 3950 #
alpar@9 3951 # ARG is the pathlist to be converted; the result is available
alpar@9 3952 # in func_to_host_pathlist_result.
alpar@9 3953 func_nix_to_mingw_pathlist_convert ()
alpar@9 3954 {
alpar@9 3955 $opt_debug
alpar@9 3956 func_to_host_pathlist_result="$1"
alpar@9 3957 if test -n "$1"; then
alpar@9 3958 # Remove leading and trailing path separator characters from
alpar@9 3959 # ARG. msys behavior is inconsistent here, cygpath turns them
alpar@9 3960 # into '.;' and ';.', and winepath ignores them completely.
alpar@9 3961 func_stripname : : "$1"
alpar@9 3962 func_to_host_pathlist_tmp1=$func_stripname_result
alpar@9 3963 func_wine_to_win32_pathlist "$func_to_host_pathlist_tmp1"
alpar@9 3964 func_to_host_pathlist_result="$func_wine_to_win32_pathlist_result"
alpar@9 3965 func_pathlist_convert_check ":" ";" \
alpar@9 3966 "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
alpar@9 3967 func_pathlist_front_back_pathsep ":*" "*:" ";" "$1"
alpar@9 3968 fi
alpar@9 3969 }
alpar@9 3970 # end func_nix_to_mingw_pathlist_convert
alpar@9 3971
alpar@9 3972
alpar@9 3973 # func_msys_to_cygwin_pathlist_convert ARG
alpar@9 3974 # A pathlist conversion function for use when $host is *cygwin*
alpar@9 3975 # but $build is *mingw* (that is, msys). This implies running
alpar@9 3976 # a cross build from msys to cygwin -- but msys has notorious
alpar@9 3977 # problems executing cygwin apps, because of conflicts between
alpar@9 3978 # cygwin1.dll and msys-1.0.dll. However, we'll try it. First,
alpar@9 3979 # convert from msys to win32, then use func_cygpath to convert
alpar@9 3980 # from win32 to cygwin. Requires LT_CYGPATH.
alpar@9 3981 #
alpar@9 3982 # ARG is the pathlist to be converted; the result is available
alpar@9 3983 # in func_to_host_pathlist_result.
alpar@9 3984 func_msys_to_cygwin_pathlist_convert ()
alpar@9 3985 {
alpar@9 3986 $opt_debug
alpar@9 3987 func_to_host_pathlist_result="$1"
alpar@9 3988 if test -n "$1"; then
alpar@9 3989 # Remove leading and trailing path separator characters from
alpar@9 3990 # ARG. msys behavior is inconsistent here, cygpath turns them
alpar@9 3991 # into '.;' and ';.', and winepath ignores them completely.
alpar@9 3992 func_stripname : : "$1"
alpar@9 3993 func_to_host_pathlist_tmp1=$func_stripname_result
alpar@9 3994 func_msys_to_win32 "$func_to_host_pathlist_tmp1"
alpar@9 3995 func_cygpath -u -p "$func_msys_to_win32_result"
alpar@9 3996 func_to_host_pathlist_result="$func_cygpath_result"
alpar@9 3997 func_pathlist_convert_check ":" ":" \
alpar@9 3998 "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
alpar@9 3999 func_pathlist_front_back_pathsep ":*" "*:" ":" "$1"
alpar@9 4000 fi
alpar@9 4001 }
alpar@9 4002 # end func_msys_to_cygwin_pathlist_convert
alpar@9 4003
alpar@9 4004
alpar@9 4005 # func_nix_to_cygwin_pathlist_convert ARG
alpar@9 4006 # A pathlist conversion function for use when $host is *cygwin*
alpar@9 4007 # but $build is some *nix variant. In this case, we assume
alpar@9 4008 # that a wine environment with a working winepath executable
alpar@9 4009 # is available in $build's $PATH, and that cygwin is installed
alpar@9 4010 # within that wine environment. Requires LT_CYGPATH (see
alpar@9 4011 # func_cygpath).
alpar@9 4012 #
alpar@9 4013 # ARG is the pathlist to be converted; the result is available
alpar@9 4014 # in func_to_host_pathlist_result.
alpar@9 4015 func_nix_to_cygwin_pathlist_convert ()
alpar@9 4016 {
alpar@9 4017 $opt_debug
alpar@9 4018 func_to_host_pathlist_result="$1"
alpar@9 4019 if test -n "$1"; then
alpar@9 4020 # Remove leading and trailing path separator characters from
alpar@9 4021 # ARG. msys behavior is inconsistent here, cygpath turns them
alpar@9 4022 # into '.;' and ';.', and winepath ignores them completely.
alpar@9 4023 func_stripname : : "$1"
alpar@9 4024 func_to_host_pathlist_tmp1=$func_stripname_result
alpar@9 4025 func_wine_to_win32_pathlist "$func_to_host_pathlist_tmp1"
alpar@9 4026 func_cygpath -u -p "$func_wine_to_win32_pathlist_result"
alpar@9 4027 func_to_host_pathlist_result="$func_cygpath_result"
alpar@9 4028 func_pathlist_convert_check ":" ":" \
alpar@9 4029 "$func_to_host_pathlist_tmp1" "$func_to_host_pathlist_result"
alpar@9 4030 func_pathlist_front_back_pathsep ":*" "*:" ":" "$1"
alpar@9 4031 fi
alpar@9 4032 }
alpar@9 4033 # end func_nix_to_cygwin_pathlist_convert
alpar@9 4034
alpar@9 4035
alpar@9 4036 # func_emit_cwrapperexe_src
alpar@9 4037 # emit the source code for a wrapper executable on stdout
alpar@9 4038 # Must ONLY be called from within func_mode_link because
alpar@9 4039 # it depends on a number of variable set therein.
alpar@9 4040 func_emit_cwrapperexe_src ()
alpar@9 4041 {
alpar@9 4042 cat <<EOF
alpar@9 4043
alpar@9 4044 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
alpar@9 4045 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
alpar@9 4046
alpar@9 4047 The $output program cannot be directly executed until all the libtool
alpar@9 4048 libraries that it depends on are installed.
alpar@9 4049
alpar@9 4050 This wrapper executable should never be moved out of the build directory.
alpar@9 4051 If it is, it will not operate correctly.
alpar@9 4052
alpar@9 4053 Currently, it simply execs the wrapper *script* "$SHELL $output",
alpar@9 4054 but could eventually absorb all of the scripts functionality and
alpar@9 4055 exec $objdir/$outputname directly.
alpar@9 4056 */
alpar@9 4057 EOF
alpar@9 4058 cat <<"EOF"
alpar@9 4059 #ifdef _MSC_VER
alpar@9 4060 # define _CRT_SECURE_NO_DEPRECATE 1
alpar@9 4061 #endif
alpar@9 4062 #include <stdio.h>
alpar@9 4063 #include <stdlib.h>
alpar@9 4064 #ifdef _MSC_VER
alpar@9 4065 # include <direct.h>
alpar@9 4066 # include <process.h>
alpar@9 4067 # include <io.h>
alpar@9 4068 #else
alpar@9 4069 # include <unistd.h>
alpar@9 4070 # include <stdint.h>
alpar@9 4071 # ifdef __CYGWIN__
alpar@9 4072 # include <io.h>
alpar@9 4073 # endif
alpar@9 4074 #endif
alpar@9 4075 #include <malloc.h>
alpar@9 4076 #include <stdarg.h>
alpar@9 4077 #include <assert.h>
alpar@9 4078 #include <string.h>
alpar@9 4079 #include <ctype.h>
alpar@9 4080 #include <errno.h>
alpar@9 4081 #include <fcntl.h>
alpar@9 4082 #include <sys/stat.h>
alpar@9 4083
alpar@9 4084 /* declarations of non-ANSI functions */
alpar@9 4085 #if defined(__MINGW32__)
alpar@9 4086 # ifdef __STRICT_ANSI__
alpar@9 4087 int _putenv (const char *);
alpar@9 4088 # endif
alpar@9 4089 #elif defined(__CYGWIN__)
alpar@9 4090 # ifdef __STRICT_ANSI__
alpar@9 4091 char *realpath (const char *, char *);
alpar@9 4092 int putenv (char *);
alpar@9 4093 int setenv (const char *, const char *, int);
alpar@9 4094 # endif
alpar@9 4095 /* #elif defined (other platforms) ... */
alpar@9 4096 #endif
alpar@9 4097
alpar@9 4098 /* portability defines, excluding path handling macros */
alpar@9 4099 #if defined(_MSC_VER)
alpar@9 4100 # define setmode _setmode
alpar@9 4101 # define stat _stat
alpar@9 4102 # define chmod _chmod
alpar@9 4103 # define getcwd _getcwd
alpar@9 4104 # define putenv _putenv
alpar@9 4105 # define S_IXUSR _S_IEXEC
alpar@9 4106 # ifndef _INTPTR_T_DEFINED
alpar@9 4107 # define _INTPTR_T_DEFINED
alpar@9 4108 # define intptr_t int
alpar@9 4109 # endif
alpar@9 4110 #elif defined(__MINGW32__)
alpar@9 4111 # define setmode _setmode
alpar@9 4112 # define stat _stat
alpar@9 4113 # define chmod _chmod
alpar@9 4114 # define getcwd _getcwd
alpar@9 4115 # define putenv _putenv
alpar@9 4116 #elif defined(__CYGWIN__)
alpar@9 4117 # define HAVE_SETENV
alpar@9 4118 # define FOPEN_WB "wb"
alpar@9 4119 /* #elif defined (other platforms) ... */
alpar@9 4120 #endif
alpar@9 4121
alpar@9 4122 #if defined(PATH_MAX)
alpar@9 4123 # define LT_PATHMAX PATH_MAX
alpar@9 4124 #elif defined(MAXPATHLEN)
alpar@9 4125 # define LT_PATHMAX MAXPATHLEN
alpar@9 4126 #else
alpar@9 4127 # define LT_PATHMAX 1024
alpar@9 4128 #endif
alpar@9 4129
alpar@9 4130 #ifndef S_IXOTH
alpar@9 4131 # define S_IXOTH 0
alpar@9 4132 #endif
alpar@9 4133 #ifndef S_IXGRP
alpar@9 4134 # define S_IXGRP 0
alpar@9 4135 #endif
alpar@9 4136
alpar@9 4137 /* path handling portability macros */
alpar@9 4138 #ifndef DIR_SEPARATOR
alpar@9 4139 # define DIR_SEPARATOR '/'
alpar@9 4140 # define PATH_SEPARATOR ':'
alpar@9 4141 #endif
alpar@9 4142
alpar@9 4143 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
alpar@9 4144 defined (__OS2__)
alpar@9 4145 # define HAVE_DOS_BASED_FILE_SYSTEM
alpar@9 4146 # define FOPEN_WB "wb"
alpar@9 4147 # ifndef DIR_SEPARATOR_2
alpar@9 4148 # define DIR_SEPARATOR_2 '\\'
alpar@9 4149 # endif
alpar@9 4150 # ifndef PATH_SEPARATOR_2
alpar@9 4151 # define PATH_SEPARATOR_2 ';'
alpar@9 4152 # endif
alpar@9 4153 #endif
alpar@9 4154
alpar@9 4155 #ifndef DIR_SEPARATOR_2
alpar@9 4156 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
alpar@9 4157 #else /* DIR_SEPARATOR_2 */
alpar@9 4158 # define IS_DIR_SEPARATOR(ch) \
alpar@9 4159 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
alpar@9 4160 #endif /* DIR_SEPARATOR_2 */
alpar@9 4161
alpar@9 4162 #ifndef PATH_SEPARATOR_2
alpar@9 4163 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
alpar@9 4164 #else /* PATH_SEPARATOR_2 */
alpar@9 4165 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
alpar@9 4166 #endif /* PATH_SEPARATOR_2 */
alpar@9 4167
alpar@9 4168 #ifndef FOPEN_WB
alpar@9 4169 # define FOPEN_WB "w"
alpar@9 4170 #endif
alpar@9 4171 #ifndef _O_BINARY
alpar@9 4172 # define _O_BINARY 0
alpar@9 4173 #endif
alpar@9 4174
alpar@9 4175 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
alpar@9 4176 #define XFREE(stale) do { \
alpar@9 4177 if (stale) { free ((void *) stale); stale = 0; } \
alpar@9 4178 } while (0)
alpar@9 4179
alpar@9 4180 #if defined(LT_DEBUGWRAPPER)
alpar@9 4181 static int lt_debug = 1;
alpar@9 4182 #else
alpar@9 4183 static int lt_debug = 0;
alpar@9 4184 #endif
alpar@9 4185
alpar@9 4186 const char *program_name = NULL;
alpar@9 4187
alpar@9 4188 void *xmalloc (size_t num);
alpar@9 4189 char *xstrdup (const char *string);
alpar@9 4190 const char *base_name (const char *name);
alpar@9 4191 char *find_executable (const char *wrapper);
alpar@9 4192 char *chase_symlinks (const char *pathspec);
alpar@9 4193 int make_executable (const char *path);
alpar@9 4194 int check_executable (const char *path);
alpar@9 4195 char *strendzap (char *str, const char *pat);
alpar@9 4196 void lt_debugprintf (const char *fmt, ...);
alpar@9 4197 void lt_fatal (const char *message, ...);
alpar@9 4198 void lt_setenv (const char *name, const char *value);
alpar@9 4199 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
alpar@9 4200 void lt_update_exe_path (const char *name, const char *value);
alpar@9 4201 void lt_update_lib_path (const char *name, const char *value);
alpar@9 4202 char **prepare_spawn (char **argv);
alpar@9 4203 void lt_dump_script (FILE *f);
alpar@9 4204
alpar@9 4205 EOF
alpar@9 4206
alpar@9 4207 cat <<EOF
alpar@9 4208 const char * MAGIC_EXE = "$magic_exe";
alpar@9 4209 const char * LIB_PATH_VARNAME = "$shlibpath_var";
alpar@9 4210 EOF
alpar@9 4211
alpar@9 4212 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
alpar@9 4213 func_to_host_pathlist "$temp_rpath"
alpar@9 4214 cat <<EOF
alpar@9 4215 const char * LIB_PATH_VALUE = "$func_to_host_pathlist_result";
alpar@9 4216 EOF
alpar@9 4217 else
alpar@9 4218 cat <<"EOF"
alpar@9 4219 const char * LIB_PATH_VALUE = "";
alpar@9 4220 EOF
alpar@9 4221 fi
alpar@9 4222
alpar@9 4223 if test -n "$dllsearchpath"; then
alpar@9 4224 func_to_host_pathlist "$dllsearchpath:"
alpar@9 4225 cat <<EOF
alpar@9 4226 const char * EXE_PATH_VARNAME = "PATH";
alpar@9 4227 const char * EXE_PATH_VALUE = "$func_to_host_pathlist_result";
alpar@9 4228 EOF
alpar@9 4229 else
alpar@9 4230 cat <<"EOF"
alpar@9 4231 const char * EXE_PATH_VARNAME = "";
alpar@9 4232 const char * EXE_PATH_VALUE = "";
alpar@9 4233 EOF
alpar@9 4234 fi
alpar@9 4235
alpar@9 4236 if test "$fast_install" = yes; then
alpar@9 4237 cat <<EOF
alpar@9 4238 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
alpar@9 4239 EOF
alpar@9 4240 else
alpar@9 4241 cat <<EOF
alpar@9 4242 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
alpar@9 4243 EOF
alpar@9 4244 fi
alpar@9 4245
alpar@9 4246
alpar@9 4247 cat <<"EOF"
alpar@9 4248
alpar@9 4249 #define LTWRAPPER_OPTION_PREFIX "--lt-"
alpar@9 4250 #define LTWRAPPER_OPTION_PREFIX_LENGTH 5
alpar@9 4251
alpar@9 4252 static const size_t opt_prefix_len = LTWRAPPER_OPTION_PREFIX_LENGTH;
alpar@9 4253 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
alpar@9 4254
alpar@9 4255 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
alpar@9 4256 static const size_t dumpscript_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
alpar@9 4257
alpar@9 4258 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
alpar@9 4259 static const size_t debug_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 5;
alpar@9 4260
alpar@9 4261 int
alpar@9 4262 main (int argc, char *argv[])
alpar@9 4263 {
alpar@9 4264 char **newargz;
alpar@9 4265 int newargc;
alpar@9 4266 char *tmp_pathspec;
alpar@9 4267 char *actual_cwrapper_path;
alpar@9 4268 char *actual_cwrapper_name;
alpar@9 4269 char *target_name;
alpar@9 4270 char *lt_argv_zero;
alpar@9 4271 intptr_t rval = 127;
alpar@9 4272
alpar@9 4273 int i;
alpar@9 4274
alpar@9 4275 program_name = (char *) xstrdup (base_name (argv[0]));
alpar@9 4276 newargz = XMALLOC (char *, argc + 1);
alpar@9 4277
alpar@9 4278 /* very simple arg parsing; don't want to rely on getopt
alpar@9 4279 * also, copy all non cwrapper options to newargz, except
alpar@9 4280 * argz[0], which is handled differently
alpar@9 4281 */
alpar@9 4282 newargc=0;
alpar@9 4283 for (i = 1; i < argc; i++)
alpar@9 4284 {
alpar@9 4285 if (strncmp (argv[i], dumpscript_opt, dumpscript_opt_len) == 0)
alpar@9 4286 {
alpar@9 4287 EOF
alpar@9 4288 case "$host" in
alpar@9 4289 *mingw* | *cygwin* )
alpar@9 4290 # make stdout use "unix" line endings
alpar@9 4291 echo " setmode(1,_O_BINARY);"
alpar@9 4292 ;;
alpar@9 4293 esac
alpar@9 4294
alpar@9 4295 cat <<"EOF"
alpar@9 4296 lt_dump_script (stdout);
alpar@9 4297 return 0;
alpar@9 4298 }
alpar@9 4299 if (strncmp (argv[i], debug_opt, debug_opt_len) == 0)
alpar@9 4300 {
alpar@9 4301 lt_debug = 1;
alpar@9 4302 continue;
alpar@9 4303 }
alpar@9 4304 if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
alpar@9 4305 {
alpar@9 4306 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
alpar@9 4307 namespace, but it is not one of the ones we know about and
alpar@9 4308 have already dealt with, above (inluding dump-script), then
alpar@9 4309 report an error. Otherwise, targets might begin to believe
alpar@9 4310 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
alpar@9 4311 namespace. The first time any user complains about this, we'll
alpar@9 4312 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
alpar@9 4313 or a configure.ac-settable value.
alpar@9 4314 */
alpar@9 4315 lt_fatal ("Unrecognized %s option: '%s'",
alpar@9 4316 ltwrapper_option_prefix, argv[i]);
alpar@9 4317 }
alpar@9 4318 /* otherwise ... */
alpar@9 4319 newargz[++newargc] = xstrdup (argv[i]);
alpar@9 4320 }
alpar@9 4321 newargz[++newargc] = NULL;
alpar@9 4322
alpar@9 4323 /* first use of lt_debugprintf AFTER parsing options */
alpar@9 4324 lt_debugprintf ("(main) argv[0] : %s\n", argv[0]);
alpar@9 4325 lt_debugprintf ("(main) program_name : %s\n", program_name);
alpar@9 4326
alpar@9 4327 tmp_pathspec = find_executable (argv[0]);
alpar@9 4328 if (tmp_pathspec == NULL)
alpar@9 4329 lt_fatal ("Couldn't find %s", argv[0]);
alpar@9 4330 lt_debugprintf ("(main) found exe (before symlink chase) at : %s\n",
alpar@9 4331 tmp_pathspec);
alpar@9 4332
alpar@9 4333 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
alpar@9 4334 lt_debugprintf ("(main) found exe (after symlink chase) at : %s\n",
alpar@9 4335 actual_cwrapper_path);
alpar@9 4336 XFREE (tmp_pathspec);
alpar@9 4337
alpar@9 4338 actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
alpar@9 4339 strendzap (actual_cwrapper_path, actual_cwrapper_name);
alpar@9 4340
alpar@9 4341 /* wrapper name transforms */
alpar@9 4342 strendzap (actual_cwrapper_name, ".exe");
alpar@9 4343 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
alpar@9 4344 XFREE (actual_cwrapper_name);
alpar@9 4345 actual_cwrapper_name = tmp_pathspec;
alpar@9 4346 tmp_pathspec = 0;
alpar@9 4347
alpar@9 4348 /* target_name transforms -- use actual target program name; might have lt- prefix */
alpar@9 4349 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
alpar@9 4350 strendzap (target_name, ".exe");
alpar@9 4351 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
alpar@9 4352 XFREE (target_name);
alpar@9 4353 target_name = tmp_pathspec;
alpar@9 4354 tmp_pathspec = 0;
alpar@9 4355
alpar@9 4356 lt_debugprintf ("(main) libtool target name: %s\n",
alpar@9 4357 target_name);
alpar@9 4358 EOF
alpar@9 4359
alpar@9 4360 cat <<EOF
alpar@9 4361 newargz[0] =
alpar@9 4362 XMALLOC (char, (strlen (actual_cwrapper_path) +
alpar@9 4363 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
alpar@9 4364 strcpy (newargz[0], actual_cwrapper_path);
alpar@9 4365 strcat (newargz[0], "$objdir");
alpar@9 4366 strcat (newargz[0], "/");
alpar@9 4367 EOF
alpar@9 4368
alpar@9 4369 cat <<"EOF"
alpar@9 4370 /* stop here, and copy so we don't have to do this twice */
alpar@9 4371 tmp_pathspec = xstrdup (newargz[0]);
alpar@9 4372
alpar@9 4373 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
alpar@9 4374 strcat (newargz[0], actual_cwrapper_name);
alpar@9 4375
alpar@9 4376 /* DO want the lt- prefix here if it exists, so use target_name */
alpar@9 4377 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
alpar@9 4378 XFREE (tmp_pathspec);
alpar@9 4379 tmp_pathspec = NULL;
alpar@9 4380 EOF
alpar@9 4381
alpar@9 4382 case $host_os in
alpar@9 4383 mingw*)
alpar@9 4384 cat <<"EOF"
alpar@9 4385 {
alpar@9 4386 char* p;
alpar@9 4387 while ((p = strchr (newargz[0], '\\')) != NULL)
alpar@9 4388 {
alpar@9 4389 *p = '/';
alpar@9 4390 }
alpar@9 4391 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
alpar@9 4392 {
alpar@9 4393 *p = '/';
alpar@9 4394 }
alpar@9 4395 }
alpar@9 4396 EOF
alpar@9 4397 ;;
alpar@9 4398 esac
alpar@9 4399
alpar@9 4400 cat <<"EOF"
alpar@9 4401 XFREE (target_name);
alpar@9 4402 XFREE (actual_cwrapper_path);
alpar@9 4403 XFREE (actual_cwrapper_name);
alpar@9 4404
alpar@9 4405 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
alpar@9 4406 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
alpar@9 4407 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
alpar@9 4408 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
alpar@9 4409
alpar@9 4410 lt_debugprintf ("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>"));
alpar@9 4411 for (i = 0; i < newargc; i++)
alpar@9 4412 {
alpar@9 4413 lt_debugprintf ("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>"));
alpar@9 4414 }
alpar@9 4415
alpar@9 4416 EOF
alpar@9 4417
alpar@9 4418 case $host_os in
alpar@9 4419 mingw*)
alpar@9 4420 cat <<"EOF"
alpar@9 4421 /* execv doesn't actually work on mingw as expected on unix */
alpar@9 4422 newargz = prepare_spawn (newargz);
alpar@9 4423 rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
alpar@9 4424 if (rval == -1)
alpar@9 4425 {
alpar@9 4426 /* failed to start process */
alpar@9 4427 lt_debugprintf ("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno);
alpar@9 4428 return 127;
alpar@9 4429 }
alpar@9 4430 return rval;
alpar@9 4431 EOF
alpar@9 4432 ;;
alpar@9 4433 *)
alpar@9 4434 cat <<"EOF"
alpar@9 4435 execv (lt_argv_zero, newargz);
alpar@9 4436 return rval; /* =127, but avoids unused variable warning */
alpar@9 4437 EOF
alpar@9 4438 ;;
alpar@9 4439 esac
alpar@9 4440
alpar@9 4441 cat <<"EOF"
alpar@9 4442 }
alpar@9 4443
alpar@9 4444 void *
alpar@9 4445 xmalloc (size_t num)
alpar@9 4446 {
alpar@9 4447 void *p = (void *) malloc (num);
alpar@9 4448 if (!p)
alpar@9 4449 lt_fatal ("Memory exhausted");
alpar@9 4450
alpar@9 4451 return p;
alpar@9 4452 }
alpar@9 4453
alpar@9 4454 char *
alpar@9 4455 xstrdup (const char *string)
alpar@9 4456 {
alpar@9 4457 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
alpar@9 4458 string) : NULL;
alpar@9 4459 }
alpar@9 4460
alpar@9 4461 const char *
alpar@9 4462 base_name (const char *name)
alpar@9 4463 {
alpar@9 4464 const char *base;
alpar@9 4465
alpar@9 4466 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
alpar@9 4467 /* Skip over the disk name in MSDOS pathnames. */
alpar@9 4468 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
alpar@9 4469 name += 2;
alpar@9 4470 #endif
alpar@9 4471
alpar@9 4472 for (base = name; *name; name++)
alpar@9 4473 if (IS_DIR_SEPARATOR (*name))
alpar@9 4474 base = name + 1;
alpar@9 4475 return base;
alpar@9 4476 }
alpar@9 4477
alpar@9 4478 int
alpar@9 4479 check_executable (const char *path)
alpar@9 4480 {
alpar@9 4481 struct stat st;
alpar@9 4482
alpar@9 4483 lt_debugprintf ("(check_executable) : %s\n",
alpar@9 4484 path ? (*path ? path : "EMPTY!") : "NULL!");
alpar@9 4485 if ((!path) || (!*path))
alpar@9 4486 return 0;
alpar@9 4487
alpar@9 4488 if ((stat (path, &st) >= 0)
alpar@9 4489 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
alpar@9 4490 return 1;
alpar@9 4491 else
alpar@9 4492 return 0;
alpar@9 4493 }
alpar@9 4494
alpar@9 4495 int
alpar@9 4496 make_executable (const char *path)
alpar@9 4497 {
alpar@9 4498 int rval = 0;
alpar@9 4499 struct stat st;
alpar@9 4500
alpar@9 4501 lt_debugprintf ("(make_executable) : %s\n",
alpar@9 4502 path ? (*path ? path : "EMPTY!") : "NULL!");
alpar@9 4503 if ((!path) || (!*path))
alpar@9 4504 return 0;
alpar@9 4505
alpar@9 4506 if (stat (path, &st) >= 0)
alpar@9 4507 {
alpar@9 4508 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
alpar@9 4509 }
alpar@9 4510 return rval;
alpar@9 4511 }
alpar@9 4512
alpar@9 4513 /* Searches for the full path of the wrapper. Returns
alpar@9 4514 newly allocated full path name if found, NULL otherwise
alpar@9 4515 Does not chase symlinks, even on platforms that support them.
alpar@9 4516 */
alpar@9 4517 char *
alpar@9 4518 find_executable (const char *wrapper)
alpar@9 4519 {
alpar@9 4520 int has_slash = 0;
alpar@9 4521 const char *p;
alpar@9 4522 const char *p_next;
alpar@9 4523 /* static buffer for getcwd */
alpar@9 4524 char tmp[LT_PATHMAX + 1];
alpar@9 4525 int tmp_len;
alpar@9 4526 char *concat_name;
alpar@9 4527
alpar@9 4528 lt_debugprintf ("(find_executable) : %s\n",
alpar@9 4529 wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
alpar@9 4530
alpar@9 4531 if ((wrapper == NULL) || (*wrapper == '\0'))
alpar@9 4532 return NULL;
alpar@9 4533
alpar@9 4534 /* Absolute path? */
alpar@9 4535 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
alpar@9 4536 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
alpar@9 4537 {
alpar@9 4538 concat_name = xstrdup (wrapper);
alpar@9 4539 if (check_executable (concat_name))
alpar@9 4540 return concat_name;
alpar@9 4541 XFREE (concat_name);
alpar@9 4542 }
alpar@9 4543 else
alpar@9 4544 {
alpar@9 4545 #endif
alpar@9 4546 if (IS_DIR_SEPARATOR (wrapper[0]))
alpar@9 4547 {
alpar@9 4548 concat_name = xstrdup (wrapper);
alpar@9 4549 if (check_executable (concat_name))
alpar@9 4550 return concat_name;
alpar@9 4551 XFREE (concat_name);
alpar@9 4552 }
alpar@9 4553 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
alpar@9 4554 }
alpar@9 4555 #endif
alpar@9 4556
alpar@9 4557 for (p = wrapper; *p; p++)
alpar@9 4558 if (*p == '/')
alpar@9 4559 {
alpar@9 4560 has_slash = 1;
alpar@9 4561 break;
alpar@9 4562 }
alpar@9 4563 if (!has_slash)
alpar@9 4564 {
alpar@9 4565 /* no slashes; search PATH */
alpar@9 4566 const char *path = getenv ("PATH");
alpar@9 4567 if (path != NULL)
alpar@9 4568 {
alpar@9 4569 for (p = path; *p; p = p_next)
alpar@9 4570 {
alpar@9 4571 const char *q;
alpar@9 4572 size_t p_len;
alpar@9 4573 for (q = p; *q; q++)
alpar@9 4574 if (IS_PATH_SEPARATOR (*q))
alpar@9 4575 break;
alpar@9 4576 p_len = q - p;
alpar@9 4577 p_next = (*q == '\0' ? q : q + 1);
alpar@9 4578 if (p_len == 0)
alpar@9 4579 {
alpar@9 4580 /* empty path: current directory */
alpar@9 4581 if (getcwd (tmp, LT_PATHMAX) == NULL)
alpar@9 4582 lt_fatal ("getcwd failed");
alpar@9 4583 tmp_len = strlen (tmp);
alpar@9 4584 concat_name =
alpar@9 4585 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
alpar@9 4586 memcpy (concat_name, tmp, tmp_len);
alpar@9 4587 concat_name[tmp_len] = '/';
alpar@9 4588 strcpy (concat_name + tmp_len + 1, wrapper);
alpar@9 4589 }
alpar@9 4590 else
alpar@9 4591 {
alpar@9 4592 concat_name =
alpar@9 4593 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
alpar@9 4594 memcpy (concat_name, p, p_len);
alpar@9 4595 concat_name[p_len] = '/';
alpar@9 4596 strcpy (concat_name + p_len + 1, wrapper);
alpar@9 4597 }
alpar@9 4598 if (check_executable (concat_name))
alpar@9 4599 return concat_name;
alpar@9 4600 XFREE (concat_name);
alpar@9 4601 }
alpar@9 4602 }
alpar@9 4603 /* not found in PATH; assume curdir */
alpar@9 4604 }
alpar@9 4605 /* Relative path | not found in path: prepend cwd */
alpar@9 4606 if (getcwd (tmp, LT_PATHMAX) == NULL)
alpar@9 4607 lt_fatal ("getcwd failed");
alpar@9 4608 tmp_len = strlen (tmp);
alpar@9 4609 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
alpar@9 4610 memcpy (concat_name, tmp, tmp_len);
alpar@9 4611 concat_name[tmp_len] = '/';
alpar@9 4612 strcpy (concat_name + tmp_len + 1, wrapper);
alpar@9 4613
alpar@9 4614 if (check_executable (concat_name))
alpar@9 4615 return concat_name;
alpar@9 4616 XFREE (concat_name);
alpar@9 4617 return NULL;
alpar@9 4618 }
alpar@9 4619
alpar@9 4620 char *
alpar@9 4621 chase_symlinks (const char *pathspec)
alpar@9 4622 {
alpar@9 4623 #ifndef S_ISLNK
alpar@9 4624 return xstrdup (pathspec);
alpar@9 4625 #else
alpar@9 4626 char buf[LT_PATHMAX];
alpar@9 4627 struct stat s;
alpar@9 4628 char *tmp_pathspec = xstrdup (pathspec);
alpar@9 4629 char *p;
alpar@9 4630 int has_symlinks = 0;
alpar@9 4631 while (strlen (tmp_pathspec) && !has_symlinks)
alpar@9 4632 {
alpar@9 4633 lt_debugprintf ("checking path component for symlinks: %s\n",
alpar@9 4634 tmp_pathspec);
alpar@9 4635 if (lstat (tmp_pathspec, &s) == 0)
alpar@9 4636 {
alpar@9 4637 if (S_ISLNK (s.st_mode) != 0)
alpar@9 4638 {
alpar@9 4639 has_symlinks = 1;
alpar@9 4640 break;
alpar@9 4641 }
alpar@9 4642
alpar@9 4643 /* search backwards for last DIR_SEPARATOR */
alpar@9 4644 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
alpar@9 4645 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
alpar@9 4646 p--;
alpar@9 4647 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
alpar@9 4648 {
alpar@9 4649 /* no more DIR_SEPARATORS left */
alpar@9 4650 break;
alpar@9 4651 }
alpar@9 4652 *p = '\0';
alpar@9 4653 }
alpar@9 4654 else
alpar@9 4655 {
alpar@9 4656 char *errstr = strerror (errno);
alpar@9 4657 lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
alpar@9 4658 }
alpar@9 4659 }
alpar@9 4660 XFREE (tmp_pathspec);
alpar@9 4661
alpar@9 4662 if (!has_symlinks)
alpar@9 4663 {
alpar@9 4664 return xstrdup (pathspec);
alpar@9 4665 }
alpar@9 4666
alpar@9 4667 tmp_pathspec = realpath (pathspec, buf);
alpar@9 4668 if (tmp_pathspec == 0)
alpar@9 4669 {
alpar@9 4670 lt_fatal ("Could not follow symlinks for %s", pathspec);
alpar@9 4671 }
alpar@9 4672 return xstrdup (tmp_pathspec);
alpar@9 4673 #endif
alpar@9 4674 }
alpar@9 4675
alpar@9 4676 char *
alpar@9 4677 strendzap (char *str, const char *pat)
alpar@9 4678 {
alpar@9 4679 size_t len, patlen;
alpar@9 4680
alpar@9 4681 assert (str != NULL);
alpar@9 4682 assert (pat != NULL);
alpar@9 4683
alpar@9 4684 len = strlen (str);
alpar@9 4685 patlen = strlen (pat);
alpar@9 4686
alpar@9 4687 if (patlen <= len)
alpar@9 4688 {
alpar@9 4689 str += len - patlen;
alpar@9 4690 if (strcmp (str, pat) == 0)
alpar@9 4691 *str = '\0';
alpar@9 4692 }
alpar@9 4693 return str;
alpar@9 4694 }
alpar@9 4695
alpar@9 4696 void
alpar@9 4697 lt_debugprintf (const char *fmt, ...)
alpar@9 4698 {
alpar@9 4699 va_list args;
alpar@9 4700 if (lt_debug)
alpar@9 4701 {
alpar@9 4702 va_start (args, fmt);
alpar@9 4703 (void) vfprintf (stderr, fmt, args);
alpar@9 4704 va_end (args);
alpar@9 4705 }
alpar@9 4706 }
alpar@9 4707
alpar@9 4708 static void
alpar@9 4709 lt_error_core (int exit_status, const char *mode,
alpar@9 4710 const char *message, va_list ap)
alpar@9 4711 {
alpar@9 4712 fprintf (stderr, "%s: %s: ", program_name, mode);
alpar@9 4713 vfprintf (stderr, message, ap);
alpar@9 4714 fprintf (stderr, ".\n");
alpar@9 4715
alpar@9 4716 if (exit_status >= 0)
alpar@9 4717 exit (exit_status);
alpar@9 4718 }
alpar@9 4719
alpar@9 4720 void
alpar@9 4721 lt_fatal (const char *message, ...)
alpar@9 4722 {
alpar@9 4723 va_list ap;
alpar@9 4724 va_start (ap, message);
alpar@9 4725 lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
alpar@9 4726 va_end (ap);
alpar@9 4727 }
alpar@9 4728
alpar@9 4729 void
alpar@9 4730 lt_setenv (const char *name, const char *value)
alpar@9 4731 {
alpar@9 4732 lt_debugprintf ("(lt_setenv) setting '%s' to '%s'\n",
alpar@9 4733 (name ? name : "<NULL>"),
alpar@9 4734 (value ? value : "<NULL>"));
alpar@9 4735 {
alpar@9 4736 #ifdef HAVE_SETENV
alpar@9 4737 /* always make a copy, for consistency with !HAVE_SETENV */
alpar@9 4738 char *str = xstrdup (value);
alpar@9 4739 setenv (name, str, 1);
alpar@9 4740 #else
alpar@9 4741 int len = strlen (name) + 1 + strlen (value) + 1;
alpar@9 4742 char *str = XMALLOC (char, len);
alpar@9 4743 sprintf (str, "%s=%s", name, value);
alpar@9 4744 if (putenv (str) != EXIT_SUCCESS)
alpar@9 4745 {
alpar@9 4746 XFREE (str);
alpar@9 4747 }
alpar@9 4748 #endif
alpar@9 4749 }
alpar@9 4750 }
alpar@9 4751
alpar@9 4752 char *
alpar@9 4753 lt_extend_str (const char *orig_value, const char *add, int to_end)
alpar@9 4754 {
alpar@9 4755 char *new_value;
alpar@9 4756 if (orig_value && *orig_value)
alpar@9 4757 {
alpar@9 4758 int orig_value_len = strlen (orig_value);
alpar@9 4759 int add_len = strlen (add);
alpar@9 4760 new_value = XMALLOC (char, add_len + orig_value_len + 1);
alpar@9 4761 if (to_end)
alpar@9 4762 {
alpar@9 4763 strcpy (new_value, orig_value);
alpar@9 4764 strcpy (new_value + orig_value_len, add);
alpar@9 4765 }
alpar@9 4766 else
alpar@9 4767 {
alpar@9 4768 strcpy (new_value, add);
alpar@9 4769 strcpy (new_value + add_len, orig_value);
alpar@9 4770 }
alpar@9 4771 }
alpar@9 4772 else
alpar@9 4773 {
alpar@9 4774 new_value = xstrdup (add);
alpar@9 4775 }
alpar@9 4776 return new_value;
alpar@9 4777 }
alpar@9 4778
alpar@9 4779 void
alpar@9 4780 lt_update_exe_path (const char *name, const char *value)
alpar@9 4781 {
alpar@9 4782 lt_debugprintf ("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
alpar@9 4783 (name ? name : "<NULL>"),
alpar@9 4784 (value ? value : "<NULL>"));
alpar@9 4785
alpar@9 4786 if (name && *name && value && *value)
alpar@9 4787 {
alpar@9 4788 char *new_value = lt_extend_str (getenv (name), value, 0);
alpar@9 4789 /* some systems can't cope with a ':'-terminated path #' */
alpar@9 4790 int len = strlen (new_value);
alpar@9 4791 while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
alpar@9 4792 {
alpar@9 4793 new_value[len-1] = '\0';
alpar@9 4794 }
alpar@9 4795 lt_setenv (name, new_value);
alpar@9 4796 XFREE (new_value);
alpar@9 4797 }
alpar@9 4798 }
alpar@9 4799
alpar@9 4800 void
alpar@9 4801 lt_update_lib_path (const char *name, const char *value)
alpar@9 4802 {
alpar@9 4803 lt_debugprintf ("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
alpar@9 4804 (name ? name : "<NULL>"),
alpar@9 4805 (value ? value : "<NULL>"));
alpar@9 4806
alpar@9 4807 if (name && *name && value && *value)
alpar@9 4808 {
alpar@9 4809 char *new_value = lt_extend_str (getenv (name), value, 0);
alpar@9 4810 lt_setenv (name, new_value);
alpar@9 4811 XFREE (new_value);
alpar@9 4812 }
alpar@9 4813 }
alpar@9 4814
alpar@9 4815 EOF
alpar@9 4816 case $host_os in
alpar@9 4817 mingw*)
alpar@9 4818 cat <<"EOF"
alpar@9 4819
alpar@9 4820 /* Prepares an argument vector before calling spawn().
alpar@9 4821 Note that spawn() does not by itself call the command interpreter
alpar@9 4822 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
alpar@9 4823 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
alpar@9 4824 GetVersionEx(&v);
alpar@9 4825 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
alpar@9 4826 }) ? "cmd.exe" : "command.com").
alpar@9 4827 Instead it simply concatenates the arguments, separated by ' ', and calls
alpar@9 4828 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
alpar@9 4829 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
alpar@9 4830 special way:
alpar@9 4831 - Space and tab are interpreted as delimiters. They are not treated as
alpar@9 4832 delimiters if they are surrounded by double quotes: "...".
alpar@9 4833 - Unescaped double quotes are removed from the input. Their only effect is
alpar@9 4834 that within double quotes, space and tab are treated like normal
alpar@9 4835 characters.
alpar@9 4836 - Backslashes not followed by double quotes are not special.
alpar@9 4837 - But 2*n+1 backslashes followed by a double quote become
alpar@9 4838 n backslashes followed by a double quote (n >= 0):
alpar@9 4839 \" -> "
alpar@9 4840 \\\" -> \"
alpar@9 4841 \\\\\" -> \\"
alpar@9 4842 */
alpar@9 4843 #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"
alpar@9 4844 #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"
alpar@9 4845 char **
alpar@9 4846 prepare_spawn (char **argv)
alpar@9 4847 {
alpar@9 4848 size_t argc;
alpar@9 4849 char **new_argv;
alpar@9 4850 size_t i;
alpar@9 4851
alpar@9 4852 /* Count number of arguments. */
alpar@9 4853 for (argc = 0; argv[argc] != NULL; argc++)
alpar@9 4854 ;
alpar@9 4855
alpar@9 4856 /* Allocate new argument vector. */
alpar@9 4857 new_argv = XMALLOC (char *, argc + 1);
alpar@9 4858
alpar@9 4859 /* Put quoted arguments into the new argument vector. */
alpar@9 4860 for (i = 0; i < argc; i++)
alpar@9 4861 {
alpar@9 4862 const char *string = argv[i];
alpar@9 4863
alpar@9 4864 if (string[0] == '\0')
alpar@9 4865 new_argv[i] = xstrdup ("\"\"");
alpar@9 4866 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
alpar@9 4867 {
alpar@9 4868 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
alpar@9 4869 size_t length;
alpar@9 4870 unsigned int backslashes;
alpar@9 4871 const char *s;
alpar@9 4872 char *quoted_string;
alpar@9 4873 char *p;
alpar@9 4874
alpar@9 4875 length = 0;
alpar@9 4876 backslashes = 0;
alpar@9 4877 if (quote_around)
alpar@9 4878 length++;
alpar@9 4879 for (s = string; *s != '\0'; s++)
alpar@9 4880 {
alpar@9 4881 char c = *s;
alpar@9 4882 if (c == '"')
alpar@9 4883 length += backslashes + 1;
alpar@9 4884 length++;
alpar@9 4885 if (c == '\\')
alpar@9 4886 backslashes++;
alpar@9 4887 else
alpar@9 4888 backslashes = 0;
alpar@9 4889 }
alpar@9 4890 if (quote_around)
alpar@9 4891 length += backslashes + 1;
alpar@9 4892
alpar@9 4893 quoted_string = XMALLOC (char, length + 1);
alpar@9 4894
alpar@9 4895 p = quoted_string;
alpar@9 4896 backslashes = 0;
alpar@9 4897 if (quote_around)
alpar@9 4898 *p++ = '"';
alpar@9 4899 for (s = string; *s != '\0'; s++)
alpar@9 4900 {
alpar@9 4901 char c = *s;
alpar@9 4902 if (c == '"')
alpar@9 4903 {
alpar@9 4904 unsigned int j;
alpar@9 4905 for (j = backslashes + 1; j > 0; j--)
alpar@9 4906 *p++ = '\\';
alpar@9 4907 }
alpar@9 4908 *p++ = c;
alpar@9 4909 if (c == '\\')
alpar@9 4910 backslashes++;
alpar@9 4911 else
alpar@9 4912 backslashes = 0;
alpar@9 4913 }
alpar@9 4914 if (quote_around)
alpar@9 4915 {
alpar@9 4916 unsigned int j;
alpar@9 4917 for (j = backslashes; j > 0; j--)
alpar@9 4918 *p++ = '\\';
alpar@9 4919 *p++ = '"';
alpar@9 4920 }
alpar@9 4921 *p = '\0';
alpar@9 4922
alpar@9 4923 new_argv[i] = quoted_string;
alpar@9 4924 }
alpar@9 4925 else
alpar@9 4926 new_argv[i] = (char *) string;
alpar@9 4927 }
alpar@9 4928 new_argv[argc] = NULL;
alpar@9 4929
alpar@9 4930 return new_argv;
alpar@9 4931 }
alpar@9 4932 EOF
alpar@9 4933 ;;
alpar@9 4934 esac
alpar@9 4935
alpar@9 4936 cat <<"EOF"
alpar@9 4937 void lt_dump_script (FILE* f)
alpar@9 4938 {
alpar@9 4939 EOF
alpar@9 4940 func_emit_wrapper yes |
alpar@9 4941 $SED -e 's/\([\\"]\)/\\\1/g' \
alpar@9 4942 -e 's/^/ fputs ("/' -e 's/$/\\n", f);/'
alpar@9 4943
alpar@9 4944 cat <<"EOF"
alpar@9 4945 }
alpar@9 4946 EOF
alpar@9 4947 }
alpar@9 4948 # end: func_emit_cwrapperexe_src
alpar@9 4949
alpar@9 4950 # func_emit_exe_manifest
alpar@9 4951 # emit a Win32 UAC manifest for executable on stdout
alpar@9 4952 # Must ONLY be called from within func_mode_link because
alpar@9 4953 # it depends on a number of variable set therein.
alpar@9 4954 func_emit_exe_manifest ()
alpar@9 4955 {
alpar@9 4956 cat <<EOF
alpar@9 4957 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
alpar@9 4958 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
alpar@9 4959 <assemblyIdentity version="1.0.0.0"
alpar@9 4960 EOF
alpar@9 4961
alpar@9 4962 case $host in
alpar@9 4963 i?86-*-* ) echo ' processorArchitecture="x86"' ;;
alpar@9 4964 ia64-*-* ) echo ' processorArchitecture="ia64"' ;;
alpar@9 4965 x86_64-*-* ) echo ' processorArchitecture="amd64"' ;;
alpar@9 4966 *) echo ' processorArchitecture="*"' ;;
alpar@9 4967 esac
alpar@9 4968
alpar@9 4969 cat <<EOF
alpar@9 4970 name="$host_os.$PROGRAM.$outputname"
alpar@9 4971 type="win32"/>
alpar@9 4972
alpar@9 4973 <!-- Identify the application security requirements. -->
alpar@9 4974 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
alpar@9 4975 <security>
alpar@9 4976 <requestedPrivileges>
alpar@9 4977 <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
alpar@9 4978 </requestedPrivileges>
alpar@9 4979 </security>
alpar@9 4980 </trustInfo>
alpar@9 4981 </assembly>
alpar@9 4982 EOF
alpar@9 4983 }
alpar@9 4984
alpar@9 4985 # func_win32_import_lib_p ARG
alpar@9 4986 # True if ARG is an import lib, as indicated by $file_magic_cmd
alpar@9 4987 func_win32_import_lib_p ()
alpar@9 4988 {
alpar@9 4989 $opt_debug
alpar@9 4990 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
alpar@9 4991 *import*) : ;;
alpar@9 4992 *) false ;;
alpar@9 4993 esac
alpar@9 4994 }
alpar@9 4995
alpar@9 4996 # func_mode_link arg...
alpar@9 4997 func_mode_link ()
alpar@9 4998 {
alpar@9 4999 $opt_debug
alpar@9 5000 case $host in
alpar@9 5001 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
alpar@9 5002 # It is impossible to link a dll without this setting, and
alpar@9 5003 # we shouldn't force the makefile maintainer to figure out
alpar@9 5004 # which system we are compiling for in order to pass an extra
alpar@9 5005 # flag for every libtool invocation.
alpar@9 5006 # allow_undefined=no
alpar@9 5007
alpar@9 5008 # FIXME: Unfortunately, there are problems with the above when trying
alpar@9 5009 # to make a dll which has undefined symbols, in which case not
alpar@9 5010 # even a static library is built. For now, we need to specify
alpar@9 5011 # -no-undefined on the libtool link line when we can be certain
alpar@9 5012 # that all symbols are satisfied, otherwise we get a static library.
alpar@9 5013 allow_undefined=yes
alpar@9 5014 ;;
alpar@9 5015 *)
alpar@9 5016 allow_undefined=yes
alpar@9 5017 ;;
alpar@9 5018 esac
alpar@9 5019 libtool_args=$nonopt
alpar@9 5020 base_compile="$nonopt $@"
alpar@9 5021 compile_command=$nonopt
alpar@9 5022 finalize_command=$nonopt
alpar@9 5023
alpar@9 5024 compile_rpath=
alpar@9 5025 finalize_rpath=
alpar@9 5026 compile_shlibpath=
alpar@9 5027 finalize_shlibpath=
alpar@9 5028 convenience=
alpar@9 5029 old_convenience=
alpar@9 5030 deplibs=
alpar@9 5031 old_deplibs=
alpar@9 5032 compiler_flags=
alpar@9 5033 linker_flags=
alpar@9 5034 dllsearchpath=
alpar@9 5035 lib_search_path=`pwd`
alpar@9 5036 inst_prefix_dir=
alpar@9 5037 new_inherited_linker_flags=
alpar@9 5038
alpar@9 5039 avoid_version=no
alpar@9 5040 bindir=
alpar@9 5041 dlfiles=
alpar@9 5042 dlprefiles=
alpar@9 5043 dlself=no
alpar@9 5044 export_dynamic=no
alpar@9 5045 export_symbols=
alpar@9 5046 export_symbols_regex=
alpar@9 5047 generated=
alpar@9 5048 libobjs=
alpar@9 5049 ltlibs=
alpar@9 5050 module=no
alpar@9 5051 no_install=no
alpar@9 5052 objs=
alpar@9 5053 non_pic_objects=
alpar@9 5054 precious_files_regex=
alpar@9 5055 prefer_static_libs=no
alpar@9 5056 preload=no
alpar@9 5057 prev=
alpar@9 5058 prevarg=
alpar@9 5059 release=
alpar@9 5060 rpath=
alpar@9 5061 xrpath=
alpar@9 5062 perm_rpath=
alpar@9 5063 temp_rpath=
alpar@9 5064 thread_safe=no
alpar@9 5065 vinfo=
alpar@9 5066 vinfo_number=no
alpar@9 5067 weak_libs=
alpar@9 5068 single_module="${wl}-single_module"
alpar@9 5069 func_infer_tag $base_compile
alpar@9 5070
alpar@9 5071 # We need to know -static, to get the right output filenames.
alpar@9 5072 for arg
alpar@9 5073 do
alpar@9 5074 case $arg in
alpar@9 5075 -shared)
alpar@9 5076 test "$build_libtool_libs" != yes && \
alpar@9 5077 func_fatal_configuration "can not build a shared library"
alpar@9 5078 build_old_libs=no
alpar@9 5079 break
alpar@9 5080 ;;
alpar@9 5081 -all-static | -static | -static-libtool-libs)
alpar@9 5082 case $arg in
alpar@9 5083 -all-static)
alpar@9 5084 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
alpar@9 5085 func_warning "complete static linking is impossible in this configuration"
alpar@9 5086 fi
alpar@9 5087 if test -n "$link_static_flag"; then
alpar@9 5088 dlopen_self=$dlopen_self_static
alpar@9 5089 fi
alpar@9 5090 prefer_static_libs=yes
alpar@9 5091 ;;
alpar@9 5092 -static)
alpar@9 5093 if test -z "$pic_flag" && test -n "$link_static_flag"; then
alpar@9 5094 dlopen_self=$dlopen_self_static
alpar@9 5095 fi
alpar@9 5096 prefer_static_libs=built
alpar@9 5097 ;;
alpar@9 5098 -static-libtool-libs)
alpar@9 5099 if test -z "$pic_flag" && test -n "$link_static_flag"; then
alpar@9 5100 dlopen_self=$dlopen_self_static
alpar@9 5101 fi
alpar@9 5102 prefer_static_libs=yes
alpar@9 5103 ;;
alpar@9 5104 esac
alpar@9 5105 build_libtool_libs=no
alpar@9 5106 build_old_libs=yes
alpar@9 5107 break
alpar@9 5108 ;;
alpar@9 5109 esac
alpar@9 5110 done
alpar@9 5111
alpar@9 5112 # See if our shared archives depend on static archives.
alpar@9 5113 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
alpar@9 5114
alpar@9 5115 # Go through the arguments, transforming them on the way.
alpar@9 5116 while test "$#" -gt 0; do
alpar@9 5117 arg="$1"
alpar@9 5118 shift
alpar@9 5119 func_quote_for_eval "$arg"
alpar@9 5120 qarg=$func_quote_for_eval_unquoted_result
alpar@9 5121 func_append libtool_args " $func_quote_for_eval_result"
alpar@9 5122
alpar@9 5123 # If the previous option needs an argument, assign it.
alpar@9 5124 if test -n "$prev"; then
alpar@9 5125 case $prev in
alpar@9 5126 output)
alpar@9 5127 func_append compile_command " @OUTPUT@"
alpar@9 5128 func_append finalize_command " @OUTPUT@"
alpar@9 5129 ;;
alpar@9 5130 esac
alpar@9 5131
alpar@9 5132 case $prev in
alpar@9 5133 bindir)
alpar@9 5134 bindir="$arg"
alpar@9 5135 prev=
alpar@9 5136 continue
alpar@9 5137 ;;
alpar@9 5138 dlfiles|dlprefiles)
alpar@9 5139 if test "$preload" = no; then
alpar@9 5140 # Add the symbol object into the linking commands.
alpar@9 5141 func_append compile_command " @SYMFILE@"
alpar@9 5142 func_append finalize_command " @SYMFILE@"
alpar@9 5143 preload=yes
alpar@9 5144 fi
alpar@9 5145 case $arg in
alpar@9 5146 *.la | *.lo) ;; # We handle these cases below.
alpar@9 5147 force)
alpar@9 5148 if test "$dlself" = no; then
alpar@9 5149 dlself=needless
alpar@9 5150 export_dynamic=yes
alpar@9 5151 fi
alpar@9 5152 prev=
alpar@9 5153 continue
alpar@9 5154 ;;
alpar@9 5155 self)
alpar@9 5156 if test "$prev" = dlprefiles; then
alpar@9 5157 dlself=yes
alpar@9 5158 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
alpar@9 5159 dlself=yes
alpar@9 5160 else
alpar@9 5161 dlself=needless
alpar@9 5162 export_dynamic=yes
alpar@9 5163 fi
alpar@9 5164 prev=
alpar@9 5165 continue
alpar@9 5166 ;;
alpar@9 5167 *)
alpar@9 5168 if test "$prev" = dlfiles; then
alpar@9 5169 dlfiles="$dlfiles $arg"
alpar@9 5170 else
alpar@9 5171 dlprefiles="$dlprefiles $arg"
alpar@9 5172 fi
alpar@9 5173 prev=
alpar@9 5174 continue
alpar@9 5175 ;;
alpar@9 5176 esac
alpar@9 5177 ;;
alpar@9 5178 expsyms)
alpar@9 5179 export_symbols="$arg"
alpar@9 5180 test -f "$arg" \
alpar@9 5181 || func_fatal_error "symbol file \`$arg' does not exist"
alpar@9 5182 prev=
alpar@9 5183 continue
alpar@9 5184 ;;
alpar@9 5185 expsyms_regex)
alpar@9 5186 export_symbols_regex="$arg"
alpar@9 5187 prev=
alpar@9 5188 continue
alpar@9 5189 ;;
alpar@9 5190 framework)
alpar@9 5191 case $host in
alpar@9 5192 *-*-darwin*)
alpar@9 5193 case "$deplibs " in
alpar@9 5194 *" $qarg.ltframework "*) ;;
alpar@9 5195 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
alpar@9 5196 ;;
alpar@9 5197 esac
alpar@9 5198 ;;
alpar@9 5199 esac
alpar@9 5200 prev=
alpar@9 5201 continue
alpar@9 5202 ;;
alpar@9 5203 inst_prefix)
alpar@9 5204 inst_prefix_dir="$arg"
alpar@9 5205 prev=
alpar@9 5206 continue
alpar@9 5207 ;;
alpar@9 5208 objectlist)
alpar@9 5209 if test -f "$arg"; then
alpar@9 5210 save_arg=$arg
alpar@9 5211 moreargs=
alpar@9 5212 for fil in `cat "$save_arg"`
alpar@9 5213 do
alpar@9 5214 # moreargs="$moreargs $fil"
alpar@9 5215 arg=$fil
alpar@9 5216 # A libtool-controlled object.
alpar@9 5217
alpar@9 5218 # Check to see that this really is a libtool object.
alpar@9 5219 if func_lalib_unsafe_p "$arg"; then
alpar@9 5220 pic_object=
alpar@9 5221 non_pic_object=
alpar@9 5222
alpar@9 5223 # Read the .lo file
alpar@9 5224 func_source "$arg"
alpar@9 5225
alpar@9 5226 if test -z "$pic_object" ||
alpar@9 5227 test -z "$non_pic_object" ||
alpar@9 5228 test "$pic_object" = none &&
alpar@9 5229 test "$non_pic_object" = none; then
alpar@9 5230 func_fatal_error "cannot find name of object for \`$arg'"
alpar@9 5231 fi
alpar@9 5232
alpar@9 5233 # Extract subdirectory from the argument.
alpar@9 5234 func_dirname "$arg" "/" ""
alpar@9 5235 xdir="$func_dirname_result"
alpar@9 5236
alpar@9 5237 if test "$pic_object" != none; then
alpar@9 5238 # Prepend the subdirectory the object is found in.
alpar@9 5239 pic_object="$xdir$pic_object"
alpar@9 5240
alpar@9 5241 if test "$prev" = dlfiles; then
alpar@9 5242 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
alpar@9 5243 dlfiles="$dlfiles $pic_object"
alpar@9 5244 prev=
alpar@9 5245 continue
alpar@9 5246 else
alpar@9 5247 # If libtool objects are unsupported, then we need to preload.
alpar@9 5248 prev=dlprefiles
alpar@9 5249 fi
alpar@9 5250 fi
alpar@9 5251
alpar@9 5252 # CHECK ME: I think I busted this. -Ossama
alpar@9 5253 if test "$prev" = dlprefiles; then
alpar@9 5254 # Preload the old-style object.
alpar@9 5255 dlprefiles="$dlprefiles $pic_object"
alpar@9 5256 prev=
alpar@9 5257 fi
alpar@9 5258
alpar@9 5259 # A PIC object.
alpar@9 5260 func_append libobjs " $pic_object"
alpar@9 5261 arg="$pic_object"
alpar@9 5262 fi
alpar@9 5263
alpar@9 5264 # Non-PIC object.
alpar@9 5265 if test "$non_pic_object" != none; then
alpar@9 5266 # Prepend the subdirectory the object is found in.
alpar@9 5267 non_pic_object="$xdir$non_pic_object"
alpar@9 5268
alpar@9 5269 # A standard non-PIC object
alpar@9 5270 func_append non_pic_objects " $non_pic_object"
alpar@9 5271 if test -z "$pic_object" || test "$pic_object" = none ; then
alpar@9 5272 arg="$non_pic_object"
alpar@9 5273 fi
alpar@9 5274 else
alpar@9 5275 # If the PIC object exists, use it instead.
alpar@9 5276 # $xdir was prepended to $pic_object above.
alpar@9 5277 non_pic_object="$pic_object"
alpar@9 5278 func_append non_pic_objects " $non_pic_object"
alpar@9 5279 fi
alpar@9 5280 else
alpar@9 5281 # Only an error if not doing a dry-run.
alpar@9 5282 if $opt_dry_run; then
alpar@9 5283 # Extract subdirectory from the argument.
alpar@9 5284 func_dirname "$arg" "/" ""
alpar@9 5285 xdir="$func_dirname_result"
alpar@9 5286
alpar@9 5287 func_lo2o "$arg"
alpar@9 5288 pic_object=$xdir$objdir/$func_lo2o_result
alpar@9 5289 non_pic_object=$xdir$func_lo2o_result
alpar@9 5290 func_append libobjs " $pic_object"
alpar@9 5291 func_append non_pic_objects " $non_pic_object"
alpar@9 5292 else
alpar@9 5293 func_fatal_error "\`$arg' is not a valid libtool object"
alpar@9 5294 fi
alpar@9 5295 fi
alpar@9 5296 done
alpar@9 5297 else
alpar@9 5298 func_fatal_error "link input file \`$arg' does not exist"
alpar@9 5299 fi
alpar@9 5300 arg=$save_arg
alpar@9 5301 prev=
alpar@9 5302 continue
alpar@9 5303 ;;
alpar@9 5304 precious_regex)
alpar@9 5305 precious_files_regex="$arg"
alpar@9 5306 prev=
alpar@9 5307 continue
alpar@9 5308 ;;
alpar@9 5309 release)
alpar@9 5310 release="-$arg"
alpar@9 5311 prev=
alpar@9 5312 continue
alpar@9 5313 ;;
alpar@9 5314 rpath | xrpath)
alpar@9 5315 # We need an absolute path.
alpar@9 5316 case $arg in
alpar@9 5317 [\\/]* | [A-Za-z]:[\\/]*) ;;
alpar@9 5318 *)
alpar@9 5319 func_fatal_error "only absolute run-paths are allowed"
alpar@9 5320 ;;
alpar@9 5321 esac
alpar@9 5322 if test "$prev" = rpath; then
alpar@9 5323 case "$rpath " in
alpar@9 5324 *" $arg "*) ;;
alpar@9 5325 *) rpath="$rpath $arg" ;;
alpar@9 5326 esac
alpar@9 5327 else
alpar@9 5328 case "$xrpath " in
alpar@9 5329 *" $arg "*) ;;
alpar@9 5330 *) xrpath="$xrpath $arg" ;;
alpar@9 5331 esac
alpar@9 5332 fi
alpar@9 5333 prev=
alpar@9 5334 continue
alpar@9 5335 ;;
alpar@9 5336 shrext)
alpar@9 5337 shrext_cmds="$arg"
alpar@9 5338 prev=
alpar@9 5339 continue
alpar@9 5340 ;;
alpar@9 5341 weak)
alpar@9 5342 weak_libs="$weak_libs $arg"
alpar@9 5343 prev=
alpar@9 5344 continue
alpar@9 5345 ;;
alpar@9 5346 xcclinker)
alpar@9 5347 linker_flags="$linker_flags $qarg"
alpar@9 5348 compiler_flags="$compiler_flags $qarg"
alpar@9 5349 prev=
alpar@9 5350 func_append compile_command " $qarg"
alpar@9 5351 func_append finalize_command " $qarg"
alpar@9 5352 continue
alpar@9 5353 ;;
alpar@9 5354 xcompiler)
alpar@9 5355 compiler_flags="$compiler_flags $qarg"
alpar@9 5356 prev=
alpar@9 5357 func_append compile_command " $qarg"
alpar@9 5358 func_append finalize_command " $qarg"
alpar@9 5359 continue
alpar@9 5360 ;;
alpar@9 5361 xlinker)
alpar@9 5362 linker_flags="$linker_flags $qarg"
alpar@9 5363 compiler_flags="$compiler_flags $wl$qarg"
alpar@9 5364 prev=
alpar@9 5365 func_append compile_command " $wl$qarg"
alpar@9 5366 func_append finalize_command " $wl$qarg"
alpar@9 5367 continue
alpar@9 5368 ;;
alpar@9 5369 *)
alpar@9 5370 eval "$prev=\"\$arg\""
alpar@9 5371 prev=
alpar@9 5372 continue
alpar@9 5373 ;;
alpar@9 5374 esac
alpar@9 5375 fi # test -n "$prev"
alpar@9 5376
alpar@9 5377 prevarg="$arg"
alpar@9 5378
alpar@9 5379 case $arg in
alpar@9 5380 -all-static)
alpar@9 5381 if test -n "$link_static_flag"; then
alpar@9 5382 # See comment for -static flag below, for more details.
alpar@9 5383 func_append compile_command " $link_static_flag"
alpar@9 5384 func_append finalize_command " $link_static_flag"
alpar@9 5385 fi
alpar@9 5386 continue
alpar@9 5387 ;;
alpar@9 5388
alpar@9 5389 -allow-undefined)
alpar@9 5390 # FIXME: remove this flag sometime in the future.
alpar@9 5391 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
alpar@9 5392 ;;
alpar@9 5393
alpar@9 5394 -avoid-version)
alpar@9 5395 avoid_version=yes
alpar@9 5396 continue
alpar@9 5397 ;;
alpar@9 5398
alpar@9 5399 -bindir)
alpar@9 5400 prev=bindir
alpar@9 5401 continue
alpar@9 5402 ;;
alpar@9 5403
alpar@9 5404 -dlopen)
alpar@9 5405 prev=dlfiles
alpar@9 5406 continue
alpar@9 5407 ;;
alpar@9 5408
alpar@9 5409 -dlpreopen)
alpar@9 5410 prev=dlprefiles
alpar@9 5411 continue
alpar@9 5412 ;;
alpar@9 5413
alpar@9 5414 -export-dynamic)
alpar@9 5415 export_dynamic=yes
alpar@9 5416 continue
alpar@9 5417 ;;
alpar@9 5418
alpar@9 5419 -export-symbols | -export-symbols-regex)
alpar@9 5420 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
alpar@9 5421 func_fatal_error "more than one -exported-symbols argument is not allowed"
alpar@9 5422 fi
alpar@9 5423 if test "X$arg" = "X-export-symbols"; then
alpar@9 5424 prev=expsyms
alpar@9 5425 else
alpar@9 5426 prev=expsyms_regex
alpar@9 5427 fi
alpar@9 5428 continue
alpar@9 5429 ;;
alpar@9 5430
alpar@9 5431 -framework)
alpar@9 5432 prev=framework
alpar@9 5433 continue
alpar@9 5434 ;;
alpar@9 5435
alpar@9 5436 -inst-prefix-dir)
alpar@9 5437 prev=inst_prefix
alpar@9 5438 continue
alpar@9 5439 ;;
alpar@9 5440
alpar@9 5441 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
alpar@9 5442 # so, if we see these flags be careful not to treat them like -L
alpar@9 5443 -L[A-Z][A-Z]*:*)
alpar@9 5444 case $with_gcc/$host in
alpar@9 5445 no/*-*-irix* | /*-*-irix*)
alpar@9 5446 func_append compile_command " $arg"
alpar@9 5447 func_append finalize_command " $arg"
alpar@9 5448 ;;
alpar@9 5449 esac
alpar@9 5450 continue
alpar@9 5451 ;;
alpar@9 5452
alpar@9 5453 -L*)
alpar@9 5454 func_stripname '-L' '' "$arg"
alpar@9 5455 dir=$func_stripname_result
alpar@9 5456 if test -z "$dir"; then
alpar@9 5457 if test "$#" -gt 0; then
alpar@9 5458 func_fatal_error "require no space between \`-L' and \`$1'"
alpar@9 5459 else
alpar@9 5460 func_fatal_error "need path for \`-L' option"
alpar@9 5461 fi
alpar@9 5462 fi
alpar@9 5463 # We need an absolute path.
alpar@9 5464 case $dir in
alpar@9 5465 [\\/]* | [A-Za-z]:[\\/]*) ;;
alpar@9 5466 *)
alpar@9 5467 absdir=`cd "$dir" && pwd`
alpar@9 5468 test -z "$absdir" && \
alpar@9 5469 func_fatal_error "cannot determine absolute directory name of \`$dir'"
alpar@9 5470 dir="$absdir"
alpar@9 5471 ;;
alpar@9 5472 esac
alpar@9 5473 case "$deplibs " in
alpar@9 5474 *" -L$dir "*) ;;
alpar@9 5475 *)
alpar@9 5476 deplibs="$deplibs -L$dir"
alpar@9 5477 lib_search_path="$lib_search_path $dir"
alpar@9 5478 ;;
alpar@9 5479 esac
alpar@9 5480 case $host in
alpar@9 5481 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
alpar@9 5482 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
alpar@9 5483 case :$dllsearchpath: in
alpar@9 5484 *":$dir:"*) ;;
alpar@9 5485 ::) dllsearchpath=$dir;;
alpar@9 5486 *) dllsearchpath="$dllsearchpath:$dir";;
alpar@9 5487 esac
alpar@9 5488 case :$dllsearchpath: in
alpar@9 5489 *":$testbindir:"*) ;;
alpar@9 5490 ::) dllsearchpath=$testbindir;;
alpar@9 5491 *) dllsearchpath="$dllsearchpath:$testbindir";;
alpar@9 5492 esac
alpar@9 5493 ;;
alpar@9 5494 esac
alpar@9 5495 continue
alpar@9 5496 ;;
alpar@9 5497
alpar@9 5498 -l*)
alpar@9 5499 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
alpar@9 5500 case $host in
alpar@9 5501 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
alpar@9 5502 # These systems don't actually have a C or math library (as such)
alpar@9 5503 continue
alpar@9 5504 ;;
alpar@9 5505 *-*-os2*)
alpar@9 5506 # These systems don't actually have a C library (as such)
alpar@9 5507 test "X$arg" = "X-lc" && continue
alpar@9 5508 ;;
alpar@9 5509 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
alpar@9 5510 # Do not include libc due to us having libc/libc_r.
alpar@9 5511 test "X$arg" = "X-lc" && continue
alpar@9 5512 ;;
alpar@9 5513 *-*-rhapsody* | *-*-darwin1.[012])
alpar@9 5514 # Rhapsody C and math libraries are in the System framework
alpar@9 5515 deplibs="$deplibs System.ltframework"
alpar@9 5516 continue
alpar@9 5517 ;;
alpar@9 5518 *-*-sco3.2v5* | *-*-sco5v6*)
alpar@9 5519 # Causes problems with __ctype
alpar@9 5520 test "X$arg" = "X-lc" && continue
alpar@9 5521 ;;
alpar@9 5522 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
alpar@9 5523 # Compiler inserts libc in the correct place for threads to work
alpar@9 5524 test "X$arg" = "X-lc" && continue
alpar@9 5525 ;;
alpar@9 5526 esac
alpar@9 5527 elif test "X$arg" = "X-lc_r"; then
alpar@9 5528 case $host in
alpar@9 5529 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
alpar@9 5530 # Do not include libc_r directly, use -pthread flag.
alpar@9 5531 continue
alpar@9 5532 ;;
alpar@9 5533 esac
alpar@9 5534 fi
alpar@9 5535 deplibs="$deplibs $arg"
alpar@9 5536 continue
alpar@9 5537 ;;
alpar@9 5538
alpar@9 5539 -module)
alpar@9 5540 module=yes
alpar@9 5541 continue
alpar@9 5542 ;;
alpar@9 5543
alpar@9 5544 # Tru64 UNIX uses -model [arg] to determine the layout of C++
alpar@9 5545 # classes, name mangling, and exception handling.
alpar@9 5546 # Darwin uses the -arch flag to determine output architecture.
alpar@9 5547 -model|-arch|-isysroot)
alpar@9 5548 compiler_flags="$compiler_flags $arg"
alpar@9 5549 func_append compile_command " $arg"
alpar@9 5550 func_append finalize_command " $arg"
alpar@9 5551 prev=xcompiler
alpar@9 5552 continue
alpar@9 5553 ;;
alpar@9 5554
alpar@9 5555 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
alpar@9 5556 compiler_flags="$compiler_flags $arg"
alpar@9 5557 func_append compile_command " $arg"
alpar@9 5558 func_append finalize_command " $arg"
alpar@9 5559 case "$new_inherited_linker_flags " in
alpar@9 5560 *" $arg "*) ;;
alpar@9 5561 * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
alpar@9 5562 esac
alpar@9 5563 continue
alpar@9 5564 ;;
alpar@9 5565
alpar@9 5566 -multi_module)
alpar@9 5567 single_module="${wl}-multi_module"
alpar@9 5568 continue
alpar@9 5569 ;;
alpar@9 5570
alpar@9 5571 -no-fast-install)
alpar@9 5572 fast_install=no
alpar@9 5573 continue
alpar@9 5574 ;;
alpar@9 5575
alpar@9 5576 -no-install)
alpar@9 5577 case $host in
alpar@9 5578 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
alpar@9 5579 # The PATH hackery in wrapper scripts is required on Windows
alpar@9 5580 # and Darwin in order for the loader to find any dlls it needs.
alpar@9 5581 func_warning "\`-no-install' is ignored for $host"
alpar@9 5582 func_warning "assuming \`-no-fast-install' instead"
alpar@9 5583 fast_install=no
alpar@9 5584 ;;
alpar@9 5585 *) no_install=yes ;;
alpar@9 5586 esac
alpar@9 5587 continue
alpar@9 5588 ;;
alpar@9 5589
alpar@9 5590 -no-undefined)
alpar@9 5591 allow_undefined=no
alpar@9 5592 continue
alpar@9 5593 ;;
alpar@9 5594
alpar@9 5595 -objectlist)
alpar@9 5596 prev=objectlist
alpar@9 5597 continue
alpar@9 5598 ;;
alpar@9 5599
alpar@9 5600 -o) prev=output ;;
alpar@9 5601
alpar@9 5602 -precious-files-regex)
alpar@9 5603 prev=precious_regex
alpar@9 5604 continue
alpar@9 5605 ;;
alpar@9 5606
alpar@9 5607 -release)
alpar@9 5608 prev=release
alpar@9 5609 continue
alpar@9 5610 ;;
alpar@9 5611
alpar@9 5612 -rpath)
alpar@9 5613 prev=rpath
alpar@9 5614 continue
alpar@9 5615 ;;
alpar@9 5616
alpar@9 5617 -R)
alpar@9 5618 prev=xrpath
alpar@9 5619 continue
alpar@9 5620 ;;
alpar@9 5621
alpar@9 5622 -R*)
alpar@9 5623 func_stripname '-R' '' "$arg"
alpar@9 5624 dir=$func_stripname_result
alpar@9 5625 # We need an absolute path.
alpar@9 5626 case $dir in
alpar@9 5627 [\\/]* | [A-Za-z]:[\\/]*) ;;
alpar@9 5628 *)
alpar@9 5629 func_fatal_error "only absolute run-paths are allowed"
alpar@9 5630 ;;
alpar@9 5631 esac
alpar@9 5632 case "$xrpath " in
alpar@9 5633 *" $dir "*) ;;
alpar@9 5634 *) xrpath="$xrpath $dir" ;;
alpar@9 5635 esac
alpar@9 5636 continue
alpar@9 5637 ;;
alpar@9 5638
alpar@9 5639 -shared)
alpar@9 5640 # The effects of -shared are defined in a previous loop.
alpar@9 5641 continue
alpar@9 5642 ;;
alpar@9 5643
alpar@9 5644 -shrext)
alpar@9 5645 prev=shrext
alpar@9 5646 continue
alpar@9 5647 ;;
alpar@9 5648
alpar@9 5649 -static | -static-libtool-libs)
alpar@9 5650 # The effects of -static are defined in a previous loop.
alpar@9 5651 # We used to do the same as -all-static on platforms that
alpar@9 5652 # didn't have a PIC flag, but the assumption that the effects
alpar@9 5653 # would be equivalent was wrong. It would break on at least
alpar@9 5654 # Digital Unix and AIX.
alpar@9 5655 continue
alpar@9 5656 ;;
alpar@9 5657
alpar@9 5658 -thread-safe)
alpar@9 5659 thread_safe=yes
alpar@9 5660 continue
alpar@9 5661 ;;
alpar@9 5662
alpar@9 5663 -version-info)
alpar@9 5664 prev=vinfo
alpar@9 5665 continue
alpar@9 5666 ;;
alpar@9 5667
alpar@9 5668 -version-number)
alpar@9 5669 prev=vinfo
alpar@9 5670 vinfo_number=yes
alpar@9 5671 continue
alpar@9 5672 ;;
alpar@9 5673
alpar@9 5674 -weak)
alpar@9 5675 prev=weak
alpar@9 5676 continue
alpar@9 5677 ;;
alpar@9 5678
alpar@9 5679 -Wc,*)
alpar@9 5680 func_stripname '-Wc,' '' "$arg"
alpar@9 5681 args=$func_stripname_result
alpar@9 5682 arg=
alpar@9 5683 save_ifs="$IFS"; IFS=','
alpar@9 5684 for flag in $args; do
alpar@9 5685 IFS="$save_ifs"
alpar@9 5686 func_quote_for_eval "$flag"
alpar@9 5687 arg="$arg $func_quote_for_eval_result"
alpar@9 5688 compiler_flags="$compiler_flags $func_quote_for_eval_result"
alpar@9 5689 done
alpar@9 5690 IFS="$save_ifs"
alpar@9 5691 func_stripname ' ' '' "$arg"
alpar@9 5692 arg=$func_stripname_result
alpar@9 5693 ;;
alpar@9 5694
alpar@9 5695 -Wl,*)
alpar@9 5696 func_stripname '-Wl,' '' "$arg"
alpar@9 5697 args=$func_stripname_result
alpar@9 5698 arg=
alpar@9 5699 save_ifs="$IFS"; IFS=','
alpar@9 5700 for flag in $args; do
alpar@9 5701 IFS="$save_ifs"
alpar@9 5702 func_quote_for_eval "$flag"
alpar@9 5703 arg="$arg $wl$func_quote_for_eval_result"
alpar@9 5704 compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
alpar@9 5705 linker_flags="$linker_flags $func_quote_for_eval_result"
alpar@9 5706 done
alpar@9 5707 IFS="$save_ifs"
alpar@9 5708 func_stripname ' ' '' "$arg"
alpar@9 5709 arg=$func_stripname_result
alpar@9 5710 ;;
alpar@9 5711
alpar@9 5712 -Xcompiler)
alpar@9 5713 prev=xcompiler
alpar@9 5714 continue
alpar@9 5715 ;;
alpar@9 5716
alpar@9 5717 -Xlinker)
alpar@9 5718 prev=xlinker
alpar@9 5719 continue
alpar@9 5720 ;;
alpar@9 5721
alpar@9 5722 -XCClinker)
alpar@9 5723 prev=xcclinker
alpar@9 5724 continue
alpar@9 5725 ;;
alpar@9 5726
alpar@9 5727 # -msg_* for osf cc
alpar@9 5728 -msg_*)
alpar@9 5729 func_quote_for_eval "$arg"
alpar@9 5730 arg="$func_quote_for_eval_result"
alpar@9 5731 ;;
alpar@9 5732
alpar@9 5733 # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
alpar@9 5734 # -r[0-9][0-9]* specifies the processor on the SGI compiler
alpar@9 5735 # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
alpar@9 5736 # +DA*, +DD* enable 64-bit mode on the HP compiler
alpar@9 5737 # -q* pass through compiler args for the IBM compiler
alpar@9 5738 # -m*, -t[45]*, -txscale* pass through architecture-specific
alpar@9 5739 # compiler args for GCC
alpar@9 5740 # -F/path gives path to uninstalled frameworks, gcc on darwin
alpar@9 5741 # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
alpar@9 5742 # @file GCC response files
alpar@9 5743 # -tp=* Portland pgcc target processor selection
alpar@9 5744 # -{shared,static}-libgcc, -static-{libgfortran|libstdc++}: force GCC
alpar@9 5745 # to link against specified runtime library.
alpar@9 5746 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
alpar@9 5747 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*| \
alpar@9 5748 -shared-libgcc|-static-libgcc|-static-libgfortran|-static-libstdc++)
alpar@9 5749 func_quote_for_eval "$arg"
alpar@9 5750 arg="$func_quote_for_eval_result"
alpar@9 5751 func_append compile_command " $arg"
alpar@9 5752 func_append finalize_command " $arg"
alpar@9 5753 compiler_flags="$compiler_flags $arg"
alpar@9 5754 continue
alpar@9 5755 ;;
alpar@9 5756
alpar@9 5757 # Some other compiler flag.
alpar@9 5758 -* | +*)
alpar@9 5759 func_quote_for_eval "$arg"
alpar@9 5760 arg="$func_quote_for_eval_result"
alpar@9 5761 ;;
alpar@9 5762
alpar@9 5763 *.$objext)
alpar@9 5764 # A standard object.
alpar@9 5765 objs="$objs $arg"
alpar@9 5766 ;;
alpar@9 5767
alpar@9 5768 *.lo)
alpar@9 5769 # A libtool-controlled object.
alpar@9 5770
alpar@9 5771 # Check to see that this really is a libtool object.
alpar@9 5772 if func_lalib_unsafe_p "$arg"; then
alpar@9 5773 pic_object=
alpar@9 5774 non_pic_object=
alpar@9 5775
alpar@9 5776 # Read the .lo file
alpar@9 5777 func_source "$arg"
alpar@9 5778
alpar@9 5779 if test -z "$pic_object" ||
alpar@9 5780 test -z "$non_pic_object" ||
alpar@9 5781 test "$pic_object" = none &&
alpar@9 5782 test "$non_pic_object" = none; then
alpar@9 5783 func_fatal_error "cannot find name of object for \`$arg'"
alpar@9 5784 fi
alpar@9 5785
alpar@9 5786 # Extract subdirectory from the argument.
alpar@9 5787 func_dirname "$arg" "/" ""
alpar@9 5788 xdir="$func_dirname_result"
alpar@9 5789
alpar@9 5790 if test "$pic_object" != none; then
alpar@9 5791 # Prepend the subdirectory the object is found in.
alpar@9 5792 pic_object="$xdir$pic_object"
alpar@9 5793
alpar@9 5794 if test "$prev" = dlfiles; then
alpar@9 5795 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
alpar@9 5796 dlfiles="$dlfiles $pic_object"
alpar@9 5797 prev=
alpar@9 5798 continue
alpar@9 5799 else
alpar@9 5800 # If libtool objects are unsupported, then we need to preload.
alpar@9 5801 prev=dlprefiles
alpar@9 5802 fi
alpar@9 5803 fi
alpar@9 5804
alpar@9 5805 # CHECK ME: I think I busted this. -Ossama
alpar@9 5806 if test "$prev" = dlprefiles; then
alpar@9 5807 # Preload the old-style object.
alpar@9 5808 dlprefiles="$dlprefiles $pic_object"
alpar@9 5809 prev=
alpar@9 5810 fi
alpar@9 5811
alpar@9 5812 # A PIC object.
alpar@9 5813 func_append libobjs " $pic_object"
alpar@9 5814 arg="$pic_object"
alpar@9 5815 fi
alpar@9 5816
alpar@9 5817 # Non-PIC object.
alpar@9 5818 if test "$non_pic_object" != none; then
alpar@9 5819 # Prepend the subdirectory the object is found in.
alpar@9 5820 non_pic_object="$xdir$non_pic_object"
alpar@9 5821
alpar@9 5822 # A standard non-PIC object
alpar@9 5823 func_append non_pic_objects " $non_pic_object"
alpar@9 5824 if test -z "$pic_object" || test "$pic_object" = none ; then
alpar@9 5825 arg="$non_pic_object"
alpar@9 5826 fi
alpar@9 5827 else
alpar@9 5828 # If the PIC object exists, use it instead.
alpar@9 5829 # $xdir was prepended to $pic_object above.
alpar@9 5830 non_pic_object="$pic_object"
alpar@9 5831 func_append non_pic_objects " $non_pic_object"
alpar@9 5832 fi
alpar@9 5833 else
alpar@9 5834 # Only an error if not doing a dry-run.
alpar@9 5835 if $opt_dry_run; then
alpar@9 5836 # Extract subdirectory from the argument.
alpar@9 5837 func_dirname "$arg" "/" ""
alpar@9 5838 xdir="$func_dirname_result"
alpar@9 5839
alpar@9 5840 func_lo2o "$arg"
alpar@9 5841 pic_object=$xdir$objdir/$func_lo2o_result
alpar@9 5842 non_pic_object=$xdir$func_lo2o_result
alpar@9 5843 func_append libobjs " $pic_object"
alpar@9 5844 func_append non_pic_objects " $non_pic_object"
alpar@9 5845 else
alpar@9 5846 func_fatal_error "\`$arg' is not a valid libtool object"
alpar@9 5847 fi
alpar@9 5848 fi
alpar@9 5849 ;;
alpar@9 5850
alpar@9 5851 *.$libext)
alpar@9 5852 # An archive.
alpar@9 5853 deplibs="$deplibs $arg"
alpar@9 5854 old_deplibs="$old_deplibs $arg"
alpar@9 5855 continue
alpar@9 5856 ;;
alpar@9 5857
alpar@9 5858 *.la)
alpar@9 5859 # A libtool-controlled library.
alpar@9 5860
alpar@9 5861 if test "$prev" = dlfiles; then
alpar@9 5862 # This library was specified with -dlopen.
alpar@9 5863 dlfiles="$dlfiles $arg"
alpar@9 5864 prev=
alpar@9 5865 elif test "$prev" = dlprefiles; then
alpar@9 5866 # The library was specified with -dlpreopen.
alpar@9 5867 dlprefiles="$dlprefiles $arg"
alpar@9 5868 prev=
alpar@9 5869 else
alpar@9 5870 deplibs="$deplibs $arg"
alpar@9 5871 fi
alpar@9 5872 continue
alpar@9 5873 ;;
alpar@9 5874
alpar@9 5875 # Some other compiler argument.
alpar@9 5876 *)
alpar@9 5877 # Unknown arguments in both finalize_command and compile_command need
alpar@9 5878 # to be aesthetically quoted because they are evaled later.
alpar@9 5879 func_quote_for_eval "$arg"
alpar@9 5880 arg="$func_quote_for_eval_result"
alpar@9 5881 ;;
alpar@9 5882 esac # arg
alpar@9 5883
alpar@9 5884 # Now actually substitute the argument into the commands.
alpar@9 5885 if test -n "$arg"; then
alpar@9 5886 func_append compile_command " $arg"
alpar@9 5887 func_append finalize_command " $arg"
alpar@9 5888 fi
alpar@9 5889 done # argument parsing loop
alpar@9 5890
alpar@9 5891 test -n "$prev" && \
alpar@9 5892 func_fatal_help "the \`$prevarg' option requires an argument"
alpar@9 5893
alpar@9 5894 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
alpar@9 5895 eval arg=\"$export_dynamic_flag_spec\"
alpar@9 5896 func_append compile_command " $arg"
alpar@9 5897 func_append finalize_command " $arg"
alpar@9 5898 fi
alpar@9 5899
alpar@9 5900 oldlibs=
alpar@9 5901 # calculate the name of the file, without its directory
alpar@9 5902 func_basename "$output"
alpar@9 5903 outputname="$func_basename_result"
alpar@9 5904 libobjs_save="$libobjs"
alpar@9 5905
alpar@9 5906 if test -n "$shlibpath_var"; then
alpar@9 5907 # get the directories listed in $shlibpath_var
alpar@9 5908 eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
alpar@9 5909 else
alpar@9 5910 shlib_search_path=
alpar@9 5911 fi
alpar@9 5912 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
alpar@9 5913 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
alpar@9 5914
alpar@9 5915 func_dirname "$output" "/" ""
alpar@9 5916 output_objdir="$func_dirname_result$objdir"
alpar@9 5917 # Create the object directory.
alpar@9 5918 func_mkdir_p "$output_objdir"
alpar@9 5919
alpar@9 5920 # Determine the type of output
alpar@9 5921 case $output in
alpar@9 5922 "")
alpar@9 5923 func_fatal_help "you must specify an output file"
alpar@9 5924 ;;
alpar@9 5925 *.$libext) linkmode=oldlib ;;
alpar@9 5926 *.lo | *.$objext) linkmode=obj ;;
alpar@9 5927 *.la) linkmode=lib ;;
alpar@9 5928 *) linkmode=prog ;; # Anything else should be a program.
alpar@9 5929 esac
alpar@9 5930
alpar@9 5931 specialdeplibs=
alpar@9 5932
alpar@9 5933 libs=
alpar@9 5934 # Find all interdependent deplibs by searching for libraries
alpar@9 5935 # that are linked more than once (e.g. -la -lb -la)
alpar@9 5936 for deplib in $deplibs; do
alpar@9 5937 if $opt_duplicate_deps ; then
alpar@9 5938 case "$libs " in
alpar@9 5939 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
alpar@9 5940 esac
alpar@9 5941 fi
alpar@9 5942 libs="$libs $deplib"
alpar@9 5943 done
alpar@9 5944
alpar@9 5945 if test "$linkmode" = lib; then
alpar@9 5946 libs="$predeps $libs $compiler_lib_search_path $postdeps"
alpar@9 5947
alpar@9 5948 # Compute libraries that are listed more than once in $predeps
alpar@9 5949 # $postdeps and mark them as special (i.e., whose duplicates are
alpar@9 5950 # not to be eliminated).
alpar@9 5951 pre_post_deps=
alpar@9 5952 if $opt_duplicate_compiler_generated_deps; then
alpar@9 5953 for pre_post_dep in $predeps $postdeps; do
alpar@9 5954 case "$pre_post_deps " in
alpar@9 5955 *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
alpar@9 5956 esac
alpar@9 5957 pre_post_deps="$pre_post_deps $pre_post_dep"
alpar@9 5958 done
alpar@9 5959 fi
alpar@9 5960 pre_post_deps=
alpar@9 5961 fi
alpar@9 5962
alpar@9 5963 deplibs=
alpar@9 5964 newdependency_libs=
alpar@9 5965 newlib_search_path=
alpar@9 5966 need_relink=no # whether we're linking any uninstalled libtool libraries
alpar@9 5967 notinst_deplibs= # not-installed libtool libraries
alpar@9 5968 notinst_path= # paths that contain not-installed libtool libraries
alpar@9 5969
alpar@9 5970 case $linkmode in
alpar@9 5971 lib)
alpar@9 5972 passes="conv dlpreopen link"
alpar@9 5973 for file in $dlfiles $dlprefiles; do
alpar@9 5974 case $file in
alpar@9 5975 *.la) ;;
alpar@9 5976 *)
alpar@9 5977 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
alpar@9 5978 ;;
alpar@9 5979 esac
alpar@9 5980 done
alpar@9 5981 ;;
alpar@9 5982 prog)
alpar@9 5983 compile_deplibs=
alpar@9 5984 finalize_deplibs=
alpar@9 5985 alldeplibs=no
alpar@9 5986 newdlfiles=
alpar@9 5987 newdlprefiles=
alpar@9 5988 passes="conv scan dlopen dlpreopen link"
alpar@9 5989 ;;
alpar@9 5990 *) passes="conv"
alpar@9 5991 ;;
alpar@9 5992 esac
alpar@9 5993
alpar@9 5994 for pass in $passes; do
alpar@9 5995 # The preopen pass in lib mode reverses $deplibs; put it back here
alpar@9 5996 # so that -L comes before libs that need it for instance...
alpar@9 5997 if test "$linkmode,$pass" = "lib,link"; then
alpar@9 5998 ## FIXME: Find the place where the list is rebuilt in the wrong
alpar@9 5999 ## order, and fix it there properly
alpar@9 6000 tmp_deplibs=
alpar@9 6001 for deplib in $deplibs; do
alpar@9 6002 tmp_deplibs="$deplib $tmp_deplibs"
alpar@9 6003 done
alpar@9 6004 deplibs="$tmp_deplibs"
alpar@9 6005 fi
alpar@9 6006
alpar@9 6007 if test "$linkmode,$pass" = "lib,link" ||
alpar@9 6008 test "$linkmode,$pass" = "prog,scan"; then
alpar@9 6009 libs="$deplibs"
alpar@9 6010 deplibs=
alpar@9 6011 fi
alpar@9 6012 if test "$linkmode" = prog; then
alpar@9 6013 case $pass in
alpar@9 6014 dlopen) libs="$dlfiles" ;;
alpar@9 6015 dlpreopen) libs="$dlprefiles" ;;
alpar@9 6016 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
alpar@9 6017 esac
alpar@9 6018 fi
alpar@9 6019 if test "$linkmode,$pass" = "lib,dlpreopen"; then
alpar@9 6020 # Collect and forward deplibs of preopened libtool libs
alpar@9 6021 for lib in $dlprefiles; do
alpar@9 6022 # Ignore non-libtool-libs
alpar@9 6023 dependency_libs=
alpar@9 6024 case $lib in
alpar@9 6025 *.la) func_source "$lib" ;;
alpar@9 6026 esac
alpar@9 6027
alpar@9 6028 # Collect preopened libtool deplibs, except any this library
alpar@9 6029 # has declared as weak libs
alpar@9 6030 for deplib in $dependency_libs; do
alpar@9 6031 func_basename "$deplib"
alpar@9 6032 deplib_base=$func_basename_result
alpar@9 6033 case " $weak_libs " in
alpar@9 6034 *" $deplib_base "*) ;;
alpar@9 6035 *) deplibs="$deplibs $deplib" ;;
alpar@9 6036 esac
alpar@9 6037 done
alpar@9 6038 done
alpar@9 6039 libs="$dlprefiles"
alpar@9 6040 fi
alpar@9 6041 if test "$pass" = dlopen; then
alpar@9 6042 # Collect dlpreopened libraries
alpar@9 6043 save_deplibs="$deplibs"
alpar@9 6044 deplibs=
alpar@9 6045 fi
alpar@9 6046
alpar@9 6047 for deplib in $libs; do
alpar@9 6048 lib=
alpar@9 6049 found=no
alpar@9 6050 case $deplib in
alpar@9 6051 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
alpar@9 6052 if test "$linkmode,$pass" = "prog,link"; then
alpar@9 6053 compile_deplibs="$deplib $compile_deplibs"
alpar@9 6054 finalize_deplibs="$deplib $finalize_deplibs"
alpar@9 6055 else
alpar@9 6056 compiler_flags="$compiler_flags $deplib"
alpar@9 6057 if test "$linkmode" = lib ; then
alpar@9 6058 case "$new_inherited_linker_flags " in
alpar@9 6059 *" $deplib "*) ;;
alpar@9 6060 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
alpar@9 6061 esac
alpar@9 6062 fi
alpar@9 6063 fi
alpar@9 6064 continue
alpar@9 6065 ;;
alpar@9 6066 -l*)
alpar@9 6067 if test "$linkmode" != lib && test "$linkmode" != prog; then
alpar@9 6068 func_warning "\`-l' is ignored for archives/objects"
alpar@9 6069 continue
alpar@9 6070 fi
alpar@9 6071 func_stripname '-l' '' "$deplib"
alpar@9 6072 name=$func_stripname_result
alpar@9 6073 if test "$linkmode" = lib; then
alpar@9 6074 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
alpar@9 6075 else
alpar@9 6076 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
alpar@9 6077 fi
alpar@9 6078 for searchdir in $searchdirs; do
alpar@9 6079 for search_ext in .la $std_shrext .so .a; do
alpar@9 6080 # Search the libtool library
alpar@9 6081 lib="$searchdir/lib${name}${search_ext}"
alpar@9 6082 if test -f "$lib"; then
alpar@9 6083 if test "$search_ext" = ".la"; then
alpar@9 6084 found=yes
alpar@9 6085 else
alpar@9 6086 found=no
alpar@9 6087 fi
alpar@9 6088 break 2
alpar@9 6089 fi
alpar@9 6090 done
alpar@9 6091 done
alpar@9 6092 if test "$found" != yes; then
alpar@9 6093 # deplib doesn't seem to be a libtool library
alpar@9 6094 if test "$linkmode,$pass" = "prog,link"; then
alpar@9 6095 compile_deplibs="$deplib $compile_deplibs"
alpar@9 6096 finalize_deplibs="$deplib $finalize_deplibs"
alpar@9 6097 else
alpar@9 6098 deplibs="$deplib $deplibs"
alpar@9 6099 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
alpar@9 6100 fi
alpar@9 6101 continue
alpar@9 6102 else # deplib is a libtool library
alpar@9 6103 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
alpar@9 6104 # We need to do some special things here, and not later.
alpar@9 6105 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
alpar@9 6106 case " $predeps $postdeps " in
alpar@9 6107 *" $deplib "*)
alpar@9 6108 if func_lalib_p "$lib"; then
alpar@9 6109 library_names=
alpar@9 6110 old_library=
alpar@9 6111 func_source "$lib"
alpar@9 6112 for l in $old_library $library_names; do
alpar@9 6113 ll="$l"
alpar@9 6114 done
alpar@9 6115 if test "X$ll" = "X$old_library" ; then # only static version available
alpar@9 6116 found=no
alpar@9 6117 func_dirname "$lib" "" "."
alpar@9 6118 ladir="$func_dirname_result"
alpar@9 6119 lib=$ladir/$old_library
alpar@9 6120 if test "$linkmode,$pass" = "prog,link"; then
alpar@9 6121 compile_deplibs="$deplib $compile_deplibs"
alpar@9 6122 finalize_deplibs="$deplib $finalize_deplibs"
alpar@9 6123 else
alpar@9 6124 deplibs="$deplib $deplibs"
alpar@9 6125 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
alpar@9 6126 fi
alpar@9 6127 continue
alpar@9 6128 fi
alpar@9 6129 fi
alpar@9 6130 ;;
alpar@9 6131 *) ;;
alpar@9 6132 esac
alpar@9 6133 fi
alpar@9 6134 fi
alpar@9 6135 ;; # -l
alpar@9 6136 *.ltframework)
alpar@9 6137 if test "$linkmode,$pass" = "prog,link"; then
alpar@9 6138 compile_deplibs="$deplib $compile_deplibs"
alpar@9 6139 finalize_deplibs="$deplib $finalize_deplibs"
alpar@9 6140 else
alpar@9 6141 deplibs="$deplib $deplibs"
alpar@9 6142 if test "$linkmode" = lib ; then
alpar@9 6143 case "$new_inherited_linker_flags " in
alpar@9 6144 *" $deplib "*) ;;
alpar@9 6145 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
alpar@9 6146 esac
alpar@9 6147 fi
alpar@9 6148 fi
alpar@9 6149 continue
alpar@9 6150 ;;
alpar@9 6151 -L*)
alpar@9 6152 case $linkmode in
alpar@9 6153 lib)
alpar@9 6154 deplibs="$deplib $deplibs"
alpar@9 6155 test "$pass" = conv && continue
alpar@9 6156 newdependency_libs="$deplib $newdependency_libs"
alpar@9 6157 func_stripname '-L' '' "$deplib"
alpar@9 6158 newlib_search_path="$newlib_search_path $func_stripname_result"
alpar@9 6159 ;;
alpar@9 6160 prog)
alpar@9 6161 if test "$pass" = conv; then
alpar@9 6162 deplibs="$deplib $deplibs"
alpar@9 6163 continue
alpar@9 6164 fi
alpar@9 6165 if test "$pass" = scan; then
alpar@9 6166 deplibs="$deplib $deplibs"
alpar@9 6167 else
alpar@9 6168 compile_deplibs="$deplib $compile_deplibs"
alpar@9 6169 finalize_deplibs="$deplib $finalize_deplibs"
alpar@9 6170 fi
alpar@9 6171 func_stripname '-L' '' "$deplib"
alpar@9 6172 newlib_search_path="$newlib_search_path $func_stripname_result"
alpar@9 6173 ;;
alpar@9 6174 *)
alpar@9 6175 func_warning "\`-L' is ignored for archives/objects"
alpar@9 6176 ;;
alpar@9 6177 esac # linkmode
alpar@9 6178 continue
alpar@9 6179 ;; # -L
alpar@9 6180 -R*)
alpar@9 6181 if test "$pass" = link; then
alpar@9 6182 func_stripname '-R' '' "$deplib"
alpar@9 6183 dir=$func_stripname_result
alpar@9 6184 # Make sure the xrpath contains only unique directories.
alpar@9 6185 case "$xrpath " in
alpar@9 6186 *" $dir "*) ;;
alpar@9 6187 *) xrpath="$xrpath $dir" ;;
alpar@9 6188 esac
alpar@9 6189 fi
alpar@9 6190 deplibs="$deplib $deplibs"
alpar@9 6191 continue
alpar@9 6192 ;;
alpar@9 6193 *.la) lib="$deplib" ;;
alpar@9 6194 *.$libext)
alpar@9 6195 if test "$pass" = conv; then
alpar@9 6196 deplibs="$deplib $deplibs"
alpar@9 6197 continue
alpar@9 6198 fi
alpar@9 6199 case $linkmode in
alpar@9 6200 lib)
alpar@9 6201 # Linking convenience modules into shared libraries is allowed,
alpar@9 6202 # but linking other static libraries is non-portable.
alpar@9 6203 case " $dlpreconveniencelibs " in
alpar@9 6204 *" $deplib "*) ;;
alpar@9 6205 *)
alpar@9 6206 valid_a_lib=no
alpar@9 6207 case $deplibs_check_method in
alpar@9 6208 match_pattern*)
alpar@9 6209 set dummy $deplibs_check_method; shift
alpar@9 6210 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
alpar@9 6211 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
alpar@9 6212 | $EGREP "$match_pattern_regex" > /dev/null; then
alpar@9 6213 valid_a_lib=yes
alpar@9 6214 fi
alpar@9 6215 ;;
alpar@9 6216 pass_all)
alpar@9 6217 valid_a_lib=yes
alpar@9 6218 ;;
alpar@9 6219 esac
alpar@9 6220 if test "$valid_a_lib" != yes; then
alpar@9 6221 echo
alpar@9 6222 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
alpar@9 6223 echo "*** I have the capability to make that library automatically link in when"
alpar@9 6224 echo "*** you link to this library. But I can only do this if you have a"
alpar@9 6225 echo "*** shared version of the library, which you do not appear to have"
alpar@9 6226 echo "*** because the file extensions .$libext of this argument makes me believe"
alpar@9 6227 echo "*** that it is just a static archive that I should not use here."
alpar@9 6228 else
alpar@9 6229 echo
alpar@9 6230 $ECHO "*** Warning: Linking the shared library $output against the"
alpar@9 6231 $ECHO "*** static library $deplib is not portable!"
alpar@9 6232 deplibs="$deplib $deplibs"
alpar@9 6233 fi
alpar@9 6234 ;;
alpar@9 6235 esac
alpar@9 6236 continue
alpar@9 6237 ;;
alpar@9 6238 prog)
alpar@9 6239 if test "$pass" != link; then
alpar@9 6240 deplibs="$deplib $deplibs"
alpar@9 6241 else
alpar@9 6242 compile_deplibs="$deplib $compile_deplibs"
alpar@9 6243 finalize_deplibs="$deplib $finalize_deplibs"
alpar@9 6244 fi
alpar@9 6245 continue
alpar@9 6246 ;;
alpar@9 6247 esac # linkmode
alpar@9 6248 ;; # *.$libext
alpar@9 6249 *.lo | *.$objext)
alpar@9 6250 if test "$pass" = conv; then
alpar@9 6251 deplibs="$deplib $deplibs"
alpar@9 6252 elif test "$linkmode" = prog; then
alpar@9 6253 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
alpar@9 6254 # If there is no dlopen support or we're linking statically,
alpar@9 6255 # we need to preload.
alpar@9 6256 newdlprefiles="$newdlprefiles $deplib"
alpar@9 6257 compile_deplibs="$deplib $compile_deplibs"
alpar@9 6258 finalize_deplibs="$deplib $finalize_deplibs"
alpar@9 6259 else
alpar@9 6260 newdlfiles="$newdlfiles $deplib"
alpar@9 6261 fi
alpar@9 6262 fi
alpar@9 6263 continue
alpar@9 6264 ;;
alpar@9 6265 %DEPLIBS%)
alpar@9 6266 alldeplibs=yes
alpar@9 6267 continue
alpar@9 6268 ;;
alpar@9 6269 esac # case $deplib
alpar@9 6270
alpar@9 6271 if test "$found" = yes || test -f "$lib"; then :
alpar@9 6272 else
alpar@9 6273 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
alpar@9 6274 fi
alpar@9 6275
alpar@9 6276 # Check to see that this really is a libtool archive.
alpar@9 6277 func_lalib_unsafe_p "$lib" \
alpar@9 6278 || func_fatal_error "\`$lib' is not a valid libtool archive"
alpar@9 6279
alpar@9 6280 func_dirname "$lib" "" "."
alpar@9 6281 ladir="$func_dirname_result"
alpar@9 6282
alpar@9 6283 dlname=
alpar@9 6284 dlopen=
alpar@9 6285 dlpreopen=
alpar@9 6286 libdir=
alpar@9 6287 library_names=
alpar@9 6288 old_library=
alpar@9 6289 inherited_linker_flags=
alpar@9 6290 # If the library was installed with an old release of libtool,
alpar@9 6291 # it will not redefine variables installed, or shouldnotlink
alpar@9 6292 installed=yes
alpar@9 6293 shouldnotlink=no
alpar@9 6294 avoidtemprpath=
alpar@9 6295
alpar@9 6296
alpar@9 6297 # Read the .la file
alpar@9 6298 func_source "$lib"
alpar@9 6299
alpar@9 6300 # Convert "-framework foo" to "foo.ltframework"
alpar@9 6301 if test -n "$inherited_linker_flags"; then
alpar@9 6302 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
alpar@9 6303 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
alpar@9 6304 case " $new_inherited_linker_flags " in
alpar@9 6305 *" $tmp_inherited_linker_flag "*) ;;
alpar@9 6306 *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
alpar@9 6307 esac
alpar@9 6308 done
alpar@9 6309 fi
alpar@9 6310 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
alpar@9 6311 if test "$linkmode,$pass" = "lib,link" ||
alpar@9 6312 test "$linkmode,$pass" = "prog,scan" ||
alpar@9 6313 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
alpar@9 6314 test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
alpar@9 6315 test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
alpar@9 6316 fi
alpar@9 6317
alpar@9 6318 if test "$pass" = conv; then
alpar@9 6319 # Only check for convenience libraries
alpar@9 6320 deplibs="$lib $deplibs"
alpar@9 6321 if test -z "$libdir"; then
alpar@9 6322 if test -z "$old_library"; then
alpar@9 6323 func_fatal_error "cannot find name of link library for \`$lib'"
alpar@9 6324 fi
alpar@9 6325 # It is a libtool convenience library, so add in its objects.
alpar@9 6326 convenience="$convenience $ladir/$objdir/$old_library"
alpar@9 6327 old_convenience="$old_convenience $ladir/$objdir/$old_library"
alpar@9 6328 elif test "$linkmode" != prog && test "$linkmode" != lib; then
alpar@9 6329 func_fatal_error "\`$lib' is not a convenience library"
alpar@9 6330 fi
alpar@9 6331 tmp_libs=
alpar@9 6332 for deplib in $dependency_libs; do
alpar@9 6333 deplibs="$deplib $deplibs"
alpar@9 6334 if $opt_duplicate_deps ; then
alpar@9 6335 case "$tmp_libs " in
alpar@9 6336 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
alpar@9 6337 esac
alpar@9 6338 fi
alpar@9 6339 tmp_libs="$tmp_libs $deplib"
alpar@9 6340 done
alpar@9 6341 continue
alpar@9 6342 fi # $pass = conv
alpar@9 6343
alpar@9 6344
alpar@9 6345 # Get the name of the library we link against.
alpar@9 6346 linklib=
alpar@9 6347 for l in $old_library $library_names; do
alpar@9 6348 linklib="$l"
alpar@9 6349 done
alpar@9 6350 if test -z "$linklib"; then
alpar@9 6351 func_fatal_error "cannot find name of link library for \`$lib'"
alpar@9 6352 fi
alpar@9 6353
alpar@9 6354 # This library was specified with -dlopen.
alpar@9 6355 if test "$pass" = dlopen; then
alpar@9 6356 if test -z "$libdir"; then
alpar@9 6357 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
alpar@9 6358 fi
alpar@9 6359 if test -z "$dlname" ||
alpar@9 6360 test "$dlopen_support" != yes ||
alpar@9 6361 test "$build_libtool_libs" = no; then
alpar@9 6362 # If there is no dlname, no dlopen support or we're linking
alpar@9 6363 # statically, we need to preload. We also need to preload any
alpar@9 6364 # dependent libraries so libltdl's deplib preloader doesn't
alpar@9 6365 # bomb out in the load deplibs phase.
alpar@9 6366 dlprefiles="$dlprefiles $lib $dependency_libs"
alpar@9 6367 else
alpar@9 6368 newdlfiles="$newdlfiles $lib"
alpar@9 6369 fi
alpar@9 6370 continue
alpar@9 6371 fi # $pass = dlopen
alpar@9 6372
alpar@9 6373 # We need an absolute path.
alpar@9 6374 case $ladir in
alpar@9 6375 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
alpar@9 6376 *)
alpar@9 6377 abs_ladir=`cd "$ladir" && pwd`
alpar@9 6378 if test -z "$abs_ladir"; then
alpar@9 6379 func_warning "cannot determine absolute directory name of \`$ladir'"
alpar@9 6380 func_warning "passing it literally to the linker, although it might fail"
alpar@9 6381 abs_ladir="$ladir"
alpar@9 6382 fi
alpar@9 6383 ;;
alpar@9 6384 esac
alpar@9 6385 func_basename "$lib"
alpar@9 6386 laname="$func_basename_result"
alpar@9 6387
alpar@9 6388 # Find the relevant object directory and library name.
alpar@9 6389 if test "X$installed" = Xyes; then
alpar@9 6390 if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
alpar@9 6391 func_warning "library \`$lib' was moved."
alpar@9 6392 dir="$ladir"
alpar@9 6393 absdir="$abs_ladir"
alpar@9 6394 libdir="$abs_ladir"
alpar@9 6395 else
alpar@9 6396 dir="$libdir"
alpar@9 6397 absdir="$libdir"
alpar@9 6398 fi
alpar@9 6399 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
alpar@9 6400 else
alpar@9 6401 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
alpar@9 6402 dir="$ladir"
alpar@9 6403 absdir="$abs_ladir"
alpar@9 6404 # Remove this search path later
alpar@9 6405 notinst_path="$notinst_path $abs_ladir"
alpar@9 6406 else
alpar@9 6407 dir="$ladir/$objdir"
alpar@9 6408 absdir="$abs_ladir/$objdir"
alpar@9 6409 # Remove this search path later
alpar@9 6410 notinst_path="$notinst_path $abs_ladir"
alpar@9 6411 fi
alpar@9 6412 fi # $installed = yes
alpar@9 6413 func_stripname 'lib' '.la' "$laname"
alpar@9 6414 name=$func_stripname_result
alpar@9 6415
alpar@9 6416 # This library was specified with -dlpreopen.
alpar@9 6417 if test "$pass" = dlpreopen; then
alpar@9 6418 if test -z "$libdir" && test "$linkmode" = prog; then
alpar@9 6419 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
alpar@9 6420 fi
alpar@9 6421 case "$host" in
alpar@9 6422 # special handling for platforms with PE-DLLs.
alpar@9 6423 *cygwin* | *mingw* | *cegcc* )
alpar@9 6424 # Linker will automatically link against shared library if both
alpar@9 6425 # static and shared are present. Therefore, ensure we extract
alpar@9 6426 # symbols from the import library if a shared library is present
alpar@9 6427 # (otherwise, the dlopen module name will be incorrect). We do
alpar@9 6428 # this by putting the import library name into $newdlprefiles.
alpar@9 6429 # We recover the dlopen module name by 'saving' the la file
alpar@9 6430 # name in a special purpose variable, and (later) extracting the
alpar@9 6431 # dlname from the la file.
alpar@9 6432 if test -n "$dlname"; then
alpar@9 6433 func_tr_sh "$dir/$linklib"
alpar@9 6434 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
alpar@9 6435 newdlprefiles="$newdlprefiles $dir/$linklib"
alpar@9 6436 else
alpar@9 6437 newdlprefiles="$newdlprefiles $dir/$old_library"
alpar@9 6438 # Keep a list of preopened convenience libraries to check
alpar@9 6439 # that they are being used correctly in the link pass.
alpar@9 6440 test -z "$libdir" && \
alpar@9 6441 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
alpar@9 6442 fi
alpar@9 6443 ;;
alpar@9 6444 * )
alpar@9 6445 # Prefer using a static library (so that no silly _DYNAMIC symbols
alpar@9 6446 # are required to link).
alpar@9 6447 if test -n "$old_library"; then
alpar@9 6448 newdlprefiles="$newdlprefiles $dir/$old_library"
alpar@9 6449 # Keep a list of preopened convenience libraries to check
alpar@9 6450 # that they are being used correctly in the link pass.
alpar@9 6451 test -z "$libdir" && \
alpar@9 6452 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
alpar@9 6453 # Otherwise, use the dlname, so that lt_dlopen finds it.
alpar@9 6454 elif test -n "$dlname"; then
alpar@9 6455 newdlprefiles="$newdlprefiles $dir/$dlname"
alpar@9 6456 else
alpar@9 6457 newdlprefiles="$newdlprefiles $dir/$linklib"
alpar@9 6458 fi
alpar@9 6459 ;;
alpar@9 6460 esac
alpar@9 6461 fi # $pass = dlpreopen
alpar@9 6462
alpar@9 6463 if test -z "$libdir"; then
alpar@9 6464 # Link the convenience library
alpar@9 6465 if test "$linkmode" = lib; then
alpar@9 6466 deplibs="$dir/$old_library $deplibs"
alpar@9 6467 elif test "$linkmode,$pass" = "prog,link"; then
alpar@9 6468 compile_deplibs="$dir/$old_library $compile_deplibs"
alpar@9 6469 finalize_deplibs="$dir/$old_library $finalize_deplibs"
alpar@9 6470 else
alpar@9 6471 deplibs="$lib $deplibs" # used for prog,scan pass
alpar@9 6472 fi
alpar@9 6473 continue
alpar@9 6474 fi
alpar@9 6475
alpar@9 6476
alpar@9 6477 if test "$linkmode" = prog && test "$pass" != link; then
alpar@9 6478 newlib_search_path="$newlib_search_path $ladir"
alpar@9 6479 deplibs="$lib $deplibs"
alpar@9 6480
alpar@9 6481 linkalldeplibs=no
alpar@9 6482 if test "$link_all_deplibs" != no || test -z "$library_names" ||
alpar@9 6483 test "$build_libtool_libs" = no; then
alpar@9 6484 linkalldeplibs=yes
alpar@9 6485 fi
alpar@9 6486
alpar@9 6487 tmp_libs=
alpar@9 6488 for deplib in $dependency_libs; do
alpar@9 6489 case $deplib in
alpar@9 6490 -L*) func_stripname '-L' '' "$deplib"
alpar@9 6491 newlib_search_path="$newlib_search_path $func_stripname_result"
alpar@9 6492 ;;
alpar@9 6493 esac
alpar@9 6494 # Need to link against all dependency_libs?
alpar@9 6495 if test "$linkalldeplibs" = yes; then
alpar@9 6496 deplibs="$deplib $deplibs"
alpar@9 6497 else
alpar@9 6498 # Need to hardcode shared library paths
alpar@9 6499 # or/and link against static libraries
alpar@9 6500 newdependency_libs="$deplib $newdependency_libs"
alpar@9 6501 fi
alpar@9 6502 if $opt_duplicate_deps ; then
alpar@9 6503 case "$tmp_libs " in
alpar@9 6504 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
alpar@9 6505 esac
alpar@9 6506 fi
alpar@9 6507 tmp_libs="$tmp_libs $deplib"
alpar@9 6508 done # for deplib
alpar@9 6509 continue
alpar@9 6510 fi # $linkmode = prog...
alpar@9 6511
alpar@9 6512 if test "$linkmode,$pass" = "prog,link"; then
alpar@9 6513 if test -n "$library_names" &&
alpar@9 6514 { { test "$prefer_static_libs" = no ||
alpar@9 6515 test "$prefer_static_libs,$installed" = "built,yes"; } ||
alpar@9 6516 test -z "$old_library"; }; then
alpar@9 6517 # We need to hardcode the library path
alpar@9 6518 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
alpar@9 6519 # Make sure the rpath contains only unique directories.
alpar@9 6520 case "$temp_rpath:" in
alpar@9 6521 *"$absdir:"*) ;;
alpar@9 6522 *) temp_rpath="$temp_rpath$absdir:" ;;
alpar@9 6523 esac
alpar@9 6524 fi
alpar@9 6525
alpar@9 6526 # Hardcode the library path.
alpar@9 6527 # Skip directories that are in the system default run-time
alpar@9 6528 # search path.
alpar@9 6529 case " $sys_lib_dlsearch_path " in
alpar@9 6530 *" $absdir "*) ;;
alpar@9 6531 *)
alpar@9 6532 case "$compile_rpath " in
alpar@9 6533 *" $absdir "*) ;;
alpar@9 6534 *) compile_rpath="$compile_rpath $absdir"
alpar@9 6535 esac
alpar@9 6536 ;;
alpar@9 6537 esac
alpar@9 6538 case " $sys_lib_dlsearch_path " in
alpar@9 6539 *" $libdir "*) ;;
alpar@9 6540 *)
alpar@9 6541 case "$finalize_rpath " in
alpar@9 6542 *" $libdir "*) ;;
alpar@9 6543 *) finalize_rpath="$finalize_rpath $libdir"
alpar@9 6544 esac
alpar@9 6545 ;;
alpar@9 6546 esac
alpar@9 6547 fi # $linkmode,$pass = prog,link...
alpar@9 6548
alpar@9 6549 if test "$alldeplibs" = yes &&
alpar@9 6550 { test "$deplibs_check_method" = pass_all ||
alpar@9 6551 { test "$build_libtool_libs" = yes &&
alpar@9 6552 test -n "$library_names"; }; }; then
alpar@9 6553 # We only need to search for static libraries
alpar@9 6554 continue
alpar@9 6555 fi
alpar@9 6556 fi
alpar@9 6557
alpar@9 6558 link_static=no # Whether the deplib will be linked statically
alpar@9 6559 use_static_libs=$prefer_static_libs
alpar@9 6560 if test "$use_static_libs" = built && test "$installed" = yes; then
alpar@9 6561 use_static_libs=no
alpar@9 6562 fi
alpar@9 6563 if test -n "$library_names" &&
alpar@9 6564 { test "$use_static_libs" = no || test -z "$old_library"; }; then
alpar@9 6565 case $host in
alpar@9 6566 *cygwin* | *mingw* | *cegcc*)
alpar@9 6567 # No point in relinking DLLs because paths are not encoded
alpar@9 6568 notinst_deplibs="$notinst_deplibs $lib"
alpar@9 6569 need_relink=no
alpar@9 6570 ;;
alpar@9 6571 *)
alpar@9 6572 if test "$installed" = no; then
alpar@9 6573 notinst_deplibs="$notinst_deplibs $lib"
alpar@9 6574 need_relink=yes
alpar@9 6575 fi
alpar@9 6576 ;;
alpar@9 6577 esac
alpar@9 6578 # This is a shared library
alpar@9 6579
alpar@9 6580 # Warn about portability, can't link against -module's on some
alpar@9 6581 # systems (darwin). Don't bleat about dlopened modules though!
alpar@9 6582 dlopenmodule=""
alpar@9 6583 for dlpremoduletest in $dlprefiles; do
alpar@9 6584 if test "X$dlpremoduletest" = "X$lib"; then
alpar@9 6585 dlopenmodule="$dlpremoduletest"
alpar@9 6586 break
alpar@9 6587 fi
alpar@9 6588 done
alpar@9 6589 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
alpar@9 6590 echo
alpar@9 6591 if test "$linkmode" = prog; then
alpar@9 6592 $ECHO "*** Warning: Linking the executable $output against the loadable module"
alpar@9 6593 else
alpar@9 6594 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
alpar@9 6595 fi
alpar@9 6596 $ECHO "*** $linklib is not portable!"
alpar@9 6597 fi
alpar@9 6598 if test "$linkmode" = lib &&
alpar@9 6599 test "$hardcode_into_libs" = yes; then
alpar@9 6600 # Hardcode the library path.
alpar@9 6601 # Skip directories that are in the system default run-time
alpar@9 6602 # search path.
alpar@9 6603 case " $sys_lib_dlsearch_path " in
alpar@9 6604 *" $absdir "*) ;;
alpar@9 6605 *)
alpar@9 6606 case "$compile_rpath " in
alpar@9 6607 *" $absdir "*) ;;
alpar@9 6608 *) compile_rpath="$compile_rpath $absdir"
alpar@9 6609 esac
alpar@9 6610 ;;
alpar@9 6611 esac
alpar@9 6612 case " $sys_lib_dlsearch_path " in
alpar@9 6613 *" $libdir "*) ;;
alpar@9 6614 *)
alpar@9 6615 case "$finalize_rpath " in
alpar@9 6616 *" $libdir "*) ;;
alpar@9 6617 *) finalize_rpath="$finalize_rpath $libdir"
alpar@9 6618 esac
alpar@9 6619 ;;
alpar@9 6620 esac
alpar@9 6621 fi
alpar@9 6622
alpar@9 6623 if test -n "$old_archive_from_expsyms_cmds"; then
alpar@9 6624 # figure out the soname
alpar@9 6625 set dummy $library_names
alpar@9 6626 shift
alpar@9 6627 realname="$1"
alpar@9 6628 shift
alpar@9 6629 libname=`eval "\\$ECHO \"$libname_spec\""`
alpar@9 6630 # use dlname if we got it. it's perfectly good, no?
alpar@9 6631 if test -n "$dlname"; then
alpar@9 6632 soname="$dlname"
alpar@9 6633 elif test -n "$soname_spec"; then
alpar@9 6634 # bleh windows
alpar@9 6635 case $host in
alpar@9 6636 *cygwin* | mingw* | *cegcc*)
alpar@9 6637 func_arith $current - $age
alpar@9 6638 major=$func_arith_result
alpar@9 6639 versuffix="-$major"
alpar@9 6640 ;;
alpar@9 6641 esac
alpar@9 6642 eval soname=\"$soname_spec\"
alpar@9 6643 else
alpar@9 6644 soname="$realname"
alpar@9 6645 fi
alpar@9 6646
alpar@9 6647 # Make a new name for the extract_expsyms_cmds to use
alpar@9 6648 soroot="$soname"
alpar@9 6649 func_basename "$soroot"
alpar@9 6650 soname="$func_basename_result"
alpar@9 6651 func_stripname 'lib' '.dll' "$soname"
alpar@9 6652 newlib=libimp-$func_stripname_result.a
alpar@9 6653
alpar@9 6654 # If the library has no export list, then create one now
alpar@9 6655 if test -f "$output_objdir/$soname-def"; then :
alpar@9 6656 else
alpar@9 6657 func_verbose "extracting exported symbol list from \`$soname'"
alpar@9 6658 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
alpar@9 6659 fi
alpar@9 6660
alpar@9 6661 # Create $newlib
alpar@9 6662 if test -f "$output_objdir/$newlib"; then :; else
alpar@9 6663 func_verbose "generating import library for \`$soname'"
alpar@9 6664 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
alpar@9 6665 fi
alpar@9 6666 # make sure the library variables are pointing to the new library
alpar@9 6667 dir=$output_objdir
alpar@9 6668 linklib=$newlib
alpar@9 6669 fi # test -n "$old_archive_from_expsyms_cmds"
alpar@9 6670
alpar@9 6671 if test "$linkmode" = prog || test "$mode" != relink; then
alpar@9 6672 add_shlibpath=
alpar@9 6673 add_dir=
alpar@9 6674 add=
alpar@9 6675 lib_linked=yes
alpar@9 6676 case $hardcode_action in
alpar@9 6677 immediate | unsupported)
alpar@9 6678 if test "$hardcode_direct" = no; then
alpar@9 6679 add="$dir/$linklib"
alpar@9 6680 case $host in
alpar@9 6681 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
alpar@9 6682 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
alpar@9 6683 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
alpar@9 6684 *-*-unixware7*) add_dir="-L$dir" ;;
alpar@9 6685 *-*-darwin* )
alpar@9 6686 # if the lib is a (non-dlopened) module then we can not
alpar@9 6687 # link against it, someone is ignoring the earlier warnings
alpar@9 6688 if /usr/bin/file -L $add 2> /dev/null |
alpar@9 6689 $GREP ": [^:]* bundle" >/dev/null ; then
alpar@9 6690 if test "X$dlopenmodule" != "X$lib"; then
alpar@9 6691 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
alpar@9 6692 if test -z "$old_library" ; then
alpar@9 6693 echo
alpar@9 6694 echo "*** And there doesn't seem to be a static archive available"
alpar@9 6695 echo "*** The link will probably fail, sorry"
alpar@9 6696 else
alpar@9 6697 add="$dir/$old_library"
alpar@9 6698 fi
alpar@9 6699 elif test -n "$old_library"; then
alpar@9 6700 add="$dir/$old_library"
alpar@9 6701 fi
alpar@9 6702 fi
alpar@9 6703 esac
alpar@9 6704 elif test "$hardcode_minus_L" = no; then
alpar@9 6705 case $host in
alpar@9 6706 *-*-sunos*) add_shlibpath="$dir" ;;
alpar@9 6707 esac
alpar@9 6708 add_dir="-L$dir"
alpar@9 6709 add="-l$name"
alpar@9 6710 elif test "$hardcode_shlibpath_var" = no; then
alpar@9 6711 add_shlibpath="$dir"
alpar@9 6712 add="-l$name"
alpar@9 6713 else
alpar@9 6714 lib_linked=no
alpar@9 6715 fi
alpar@9 6716 ;;
alpar@9 6717 relink)
alpar@9 6718 if test "$hardcode_direct" = yes &&
alpar@9 6719 test "$hardcode_direct_absolute" = no; then
alpar@9 6720 add="$dir/$linklib"
alpar@9 6721 elif test "$hardcode_minus_L" = yes; then
alpar@9 6722 add_dir="-L$dir"
alpar@9 6723 # Try looking first in the location we're being installed to.
alpar@9 6724 if test -n "$inst_prefix_dir"; then
alpar@9 6725 case $libdir in
alpar@9 6726 [\\/]*)
alpar@9 6727 add_dir="$add_dir -L$inst_prefix_dir$libdir"
alpar@9 6728 ;;
alpar@9 6729 esac
alpar@9 6730 fi
alpar@9 6731 add="-l$name"
alpar@9 6732 elif test "$hardcode_shlibpath_var" = yes; then
alpar@9 6733 add_shlibpath="$dir"
alpar@9 6734 add="-l$name"
alpar@9 6735 else
alpar@9 6736 lib_linked=no
alpar@9 6737 fi
alpar@9 6738 ;;
alpar@9 6739 *) lib_linked=no ;;
alpar@9 6740 esac
alpar@9 6741
alpar@9 6742 if test "$lib_linked" != yes; then
alpar@9 6743 func_fatal_configuration "unsupported hardcode properties"
alpar@9 6744 fi
alpar@9 6745
alpar@9 6746 if test -n "$add_shlibpath"; then
alpar@9 6747 case :$compile_shlibpath: in
alpar@9 6748 *":$add_shlibpath:"*) ;;
alpar@9 6749 *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
alpar@9 6750 esac
alpar@9 6751 fi
alpar@9 6752 if test "$linkmode" = prog; then
alpar@9 6753 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
alpar@9 6754 test -n "$add" && compile_deplibs="$add $compile_deplibs"
alpar@9 6755 else
alpar@9 6756 test -n "$add_dir" && deplibs="$add_dir $deplibs"
alpar@9 6757 test -n "$add" && deplibs="$add $deplibs"
alpar@9 6758 if test "$hardcode_direct" != yes &&
alpar@9 6759 test "$hardcode_minus_L" != yes &&
alpar@9 6760 test "$hardcode_shlibpath_var" = yes; then
alpar@9 6761 case :$finalize_shlibpath: in
alpar@9 6762 *":$libdir:"*) ;;
alpar@9 6763 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
alpar@9 6764 esac
alpar@9 6765 fi
alpar@9 6766 fi
alpar@9 6767 fi
alpar@9 6768
alpar@9 6769 if test "$linkmode" = prog || test "$mode" = relink; then
alpar@9 6770 add_shlibpath=
alpar@9 6771 add_dir=
alpar@9 6772 add=
alpar@9 6773 # Finalize command for both is simple: just hardcode it.
alpar@9 6774 if test "$hardcode_direct" = yes &&
alpar@9 6775 test "$hardcode_direct_absolute" = no; then
alpar@9 6776 add="$libdir/$linklib"
alpar@9 6777 elif test "$hardcode_minus_L" = yes; then
alpar@9 6778 add_dir="-L$libdir"
alpar@9 6779 add="-l$name"
alpar@9 6780 elif test "$hardcode_shlibpath_var" = yes; then
alpar@9 6781 case :$finalize_shlibpath: in
alpar@9 6782 *":$libdir:"*) ;;
alpar@9 6783 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
alpar@9 6784 esac
alpar@9 6785 add="-l$name"
alpar@9 6786 elif test "$hardcode_automatic" = yes; then
alpar@9 6787 if test -n "$inst_prefix_dir" &&
alpar@9 6788 test -f "$inst_prefix_dir$libdir/$linklib" ; then
alpar@9 6789 add="$inst_prefix_dir$libdir/$linklib"
alpar@9 6790 else
alpar@9 6791 add="$libdir/$linklib"
alpar@9 6792 fi
alpar@9 6793 else
alpar@9 6794 # We cannot seem to hardcode it, guess we'll fake it.
alpar@9 6795 add_dir="-L$libdir"
alpar@9 6796 # Try looking first in the location we're being installed to.
alpar@9 6797 if test -n "$inst_prefix_dir"; then
alpar@9 6798 case $libdir in
alpar@9 6799 [\\/]*)
alpar@9 6800 add_dir="$add_dir -L$inst_prefix_dir$libdir"
alpar@9 6801 ;;
alpar@9 6802 esac
alpar@9 6803 fi
alpar@9 6804 add="-l$name"
alpar@9 6805 fi
alpar@9 6806
alpar@9 6807 if test "$linkmode" = prog; then
alpar@9 6808 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
alpar@9 6809 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
alpar@9 6810 else
alpar@9 6811 test -n "$add_dir" && deplibs="$add_dir $deplibs"
alpar@9 6812 test -n "$add" && deplibs="$add $deplibs"
alpar@9 6813 fi
alpar@9 6814 fi
alpar@9 6815 elif test "$linkmode" = prog; then
alpar@9 6816 # Here we assume that one of hardcode_direct or hardcode_minus_L
alpar@9 6817 # is not unsupported. This is valid on all known static and
alpar@9 6818 # shared platforms.
alpar@9 6819 if test "$hardcode_direct" != unsupported; then
alpar@9 6820 test -n "$old_library" && linklib="$old_library"
alpar@9 6821 compile_deplibs="$dir/$linklib $compile_deplibs"
alpar@9 6822 finalize_deplibs="$dir/$linklib $finalize_deplibs"
alpar@9 6823 else
alpar@9 6824 compile_deplibs="-l$name -L$dir $compile_deplibs"
alpar@9 6825 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
alpar@9 6826 fi
alpar@9 6827 elif test "$build_libtool_libs" = yes; then
alpar@9 6828 # Not a shared library
alpar@9 6829 if test "$deplibs_check_method" != pass_all; then
alpar@9 6830 # We're trying link a shared library against a static one
alpar@9 6831 # but the system doesn't support it.
alpar@9 6832
alpar@9 6833 # Just print a warning and add the library to dependency_libs so
alpar@9 6834 # that the program can be linked against the static library.
alpar@9 6835 echo
alpar@9 6836 $ECHO "*** Warning: This system can not link to static lib archive $lib."
alpar@9 6837 echo "*** I have the capability to make that library automatically link in when"
alpar@9 6838 echo "*** you link to this library. But I can only do this if you have a"
alpar@9 6839 echo "*** shared version of the library, which you do not appear to have."
alpar@9 6840 if test "$module" = yes; then
alpar@9 6841 echo "*** But as you try to build a module library, libtool will still create "
alpar@9 6842 echo "*** a static module, that should work as long as the dlopening application"
alpar@9 6843 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
alpar@9 6844 if test -z "$global_symbol_pipe"; then
alpar@9 6845 echo
alpar@9 6846 echo "*** However, this would only work if libtool was able to extract symbol"
alpar@9 6847 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
alpar@9 6848 echo "*** not find such a program. So, this module is probably useless."
alpar@9 6849 echo "*** \`nm' from GNU binutils and a full rebuild may help."
alpar@9 6850 fi
alpar@9 6851 if test "$build_old_libs" = no; then
alpar@9 6852 build_libtool_libs=module
alpar@9 6853 build_old_libs=yes
alpar@9 6854 else
alpar@9 6855 build_libtool_libs=no
alpar@9 6856 fi
alpar@9 6857 fi
alpar@9 6858 else
alpar@9 6859 deplibs="$dir/$old_library $deplibs"
alpar@9 6860 link_static=yes
alpar@9 6861 fi
alpar@9 6862 fi # link shared/static library?
alpar@9 6863
alpar@9 6864 if test "$linkmode" = lib; then
alpar@9 6865 if test -n "$dependency_libs" &&
alpar@9 6866 { test "$hardcode_into_libs" != yes ||
alpar@9 6867 test "$build_old_libs" = yes ||
alpar@9 6868 test "$link_static" = yes; }; then
alpar@9 6869 # Extract -R from dependency_libs
alpar@9 6870 temp_deplibs=
alpar@9 6871 for libdir in $dependency_libs; do
alpar@9 6872 case $libdir in
alpar@9 6873 -R*) func_stripname '-R' '' "$libdir"
alpar@9 6874 temp_xrpath=$func_stripname_result
alpar@9 6875 case " $xrpath " in
alpar@9 6876 *" $temp_xrpath "*) ;;
alpar@9 6877 *) xrpath="$xrpath $temp_xrpath";;
alpar@9 6878 esac;;
alpar@9 6879 *) temp_deplibs="$temp_deplibs $libdir";;
alpar@9 6880 esac
alpar@9 6881 done
alpar@9 6882 dependency_libs="$temp_deplibs"
alpar@9 6883 fi
alpar@9 6884
alpar@9 6885 newlib_search_path="$newlib_search_path $absdir"
alpar@9 6886 # Link against this library
alpar@9 6887 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
alpar@9 6888 # ... and its dependency_libs
alpar@9 6889 tmp_libs=
alpar@9 6890 for deplib in $dependency_libs; do
alpar@9 6891 newdependency_libs="$deplib $newdependency_libs"
alpar@9 6892 if $opt_duplicate_deps ; then
alpar@9 6893 case "$tmp_libs " in
alpar@9 6894 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
alpar@9 6895 esac
alpar@9 6896 fi
alpar@9 6897 tmp_libs="$tmp_libs $deplib"
alpar@9 6898 done
alpar@9 6899
alpar@9 6900 if test "$link_all_deplibs" != no; then
alpar@9 6901 # Add the search paths of all dependency libraries
alpar@9 6902 for deplib in $dependency_libs; do
alpar@9 6903 path=
alpar@9 6904 case $deplib in
alpar@9 6905 -L*) path="$deplib" ;;
alpar@9 6906 *.la)
alpar@9 6907 func_dirname "$deplib" "" "."
alpar@9 6908 dir="$func_dirname_result"
alpar@9 6909 # We need an absolute path.
alpar@9 6910 case $dir in
alpar@9 6911 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
alpar@9 6912 *)
alpar@9 6913 absdir=`cd "$dir" && pwd`
alpar@9 6914 if test -z "$absdir"; then
alpar@9 6915 func_warning "cannot determine absolute directory name of \`$dir'"
alpar@9 6916 absdir="$dir"
alpar@9 6917 fi
alpar@9 6918 ;;
alpar@9 6919 esac
alpar@9 6920 if $GREP "^installed=no" $deplib > /dev/null; then
alpar@9 6921 case $host in
alpar@9 6922 *-*-darwin*)
alpar@9 6923 depdepl=
alpar@9 6924 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
alpar@9 6925 if test -n "$deplibrary_names" ; then
alpar@9 6926 for tmp in $deplibrary_names ; do
alpar@9 6927 depdepl=$tmp
alpar@9 6928 done
alpar@9 6929 if test -f "$absdir/$objdir/$depdepl" ; then
alpar@9 6930 depdepl="$absdir/$objdir/$depdepl"
alpar@9 6931 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
alpar@9 6932 if test -z "$darwin_install_name"; then
alpar@9 6933 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
alpar@9 6934 fi
alpar@9 6935 compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
alpar@9 6936 linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
alpar@9 6937 path=
alpar@9 6938 fi
alpar@9 6939 fi
alpar@9 6940 ;;
alpar@9 6941 *)
alpar@9 6942 path="-L$absdir/$objdir"
alpar@9 6943 ;;
alpar@9 6944 esac
alpar@9 6945 else
alpar@9 6946 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
alpar@9 6947 test -z "$libdir" && \
alpar@9 6948 func_fatal_error "\`$deplib' is not a valid libtool archive"
alpar@9 6949 test "$absdir" != "$libdir" && \
alpar@9 6950 func_warning "\`$deplib' seems to be moved"
alpar@9 6951
alpar@9 6952 path="-L$absdir"
alpar@9 6953 fi
alpar@9 6954 ;;
alpar@9 6955 esac
alpar@9 6956 case " $deplibs " in
alpar@9 6957 *" $path "*) ;;
alpar@9 6958 *) deplibs="$path $deplibs" ;;
alpar@9 6959 esac
alpar@9 6960 done
alpar@9 6961 fi # link_all_deplibs != no
alpar@9 6962 fi # linkmode = lib
alpar@9 6963 done # for deplib in $libs
alpar@9 6964 if test "$pass" = link; then
alpar@9 6965 if test "$linkmode" = "prog"; then
alpar@9 6966 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
alpar@9 6967 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
alpar@9 6968 else
alpar@9 6969 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
alpar@9 6970 fi
alpar@9 6971 fi
alpar@9 6972 dependency_libs="$newdependency_libs"
alpar@9 6973 if test "$pass" = dlpreopen; then
alpar@9 6974 # Link the dlpreopened libraries before other libraries
alpar@9 6975 for deplib in $save_deplibs; do
alpar@9 6976 deplibs="$deplib $deplibs"
alpar@9 6977 done
alpar@9 6978 fi
alpar@9 6979 if test "$pass" != dlopen; then
alpar@9 6980 if test "$pass" != conv; then
alpar@9 6981 # Make sure lib_search_path contains only unique directories.
alpar@9 6982 lib_search_path=
alpar@9 6983 for dir in $newlib_search_path; do
alpar@9 6984 case "$lib_search_path " in
alpar@9 6985 *" $dir "*) ;;
alpar@9 6986 *) lib_search_path="$lib_search_path $dir" ;;
alpar@9 6987 esac
alpar@9 6988 done
alpar@9 6989 newlib_search_path=
alpar@9 6990 fi
alpar@9 6991
alpar@9 6992 if test "$linkmode,$pass" != "prog,link"; then
alpar@9 6993 vars="deplibs"
alpar@9 6994 else
alpar@9 6995 vars="compile_deplibs finalize_deplibs"
alpar@9 6996 fi
alpar@9 6997 for var in $vars dependency_libs; do
alpar@9 6998 # Add libraries to $var in reverse order
alpar@9 6999 eval tmp_libs=\"\$$var\"
alpar@9 7000 new_libs=
alpar@9 7001 for deplib in $tmp_libs; do
alpar@9 7002 # FIXME: Pedantically, this is the right thing to do, so
alpar@9 7003 # that some nasty dependency loop isn't accidentally
alpar@9 7004 # broken:
alpar@9 7005 #new_libs="$deplib $new_libs"
alpar@9 7006 # Pragmatically, this seems to cause very few problems in
alpar@9 7007 # practice:
alpar@9 7008 case $deplib in
alpar@9 7009 -L*) new_libs="$deplib $new_libs" ;;
alpar@9 7010 -R*) ;;
alpar@9 7011 *)
alpar@9 7012 # And here is the reason: when a library appears more
alpar@9 7013 # than once as an explicit dependence of a library, or
alpar@9 7014 # is implicitly linked in more than once by the
alpar@9 7015 # compiler, it is considered special, and multiple
alpar@9 7016 # occurrences thereof are not removed. Compare this
alpar@9 7017 # with having the same library being listed as a
alpar@9 7018 # dependency of multiple other libraries: in this case,
alpar@9 7019 # we know (pedantically, we assume) the library does not
alpar@9 7020 # need to be listed more than once, so we keep only the
alpar@9 7021 # last copy. This is not always right, but it is rare
alpar@9 7022 # enough that we require users that really mean to play
alpar@9 7023 # such unportable linking tricks to link the library
alpar@9 7024 # using -Wl,-lname, so that libtool does not consider it
alpar@9 7025 # for duplicate removal.
alpar@9 7026 case " $specialdeplibs " in
alpar@9 7027 *" $deplib "*) new_libs="$deplib $new_libs" ;;
alpar@9 7028 *)
alpar@9 7029 case " $new_libs " in
alpar@9 7030 *" $deplib "*) ;;
alpar@9 7031 *) new_libs="$deplib $new_libs" ;;
alpar@9 7032 esac
alpar@9 7033 ;;
alpar@9 7034 esac
alpar@9 7035 ;;
alpar@9 7036 esac
alpar@9 7037 done
alpar@9 7038 tmp_libs=
alpar@9 7039 for deplib in $new_libs; do
alpar@9 7040 case $deplib in
alpar@9 7041 -L*)
alpar@9 7042 case " $tmp_libs " in
alpar@9 7043 *" $deplib "*) ;;
alpar@9 7044 *) tmp_libs="$tmp_libs $deplib" ;;
alpar@9 7045 esac
alpar@9 7046 ;;
alpar@9 7047 *) tmp_libs="$tmp_libs $deplib" ;;
alpar@9 7048 esac
alpar@9 7049 done
alpar@9 7050 eval $var=\"$tmp_libs\"
alpar@9 7051 done # for var
alpar@9 7052 fi
alpar@9 7053 # Last step: remove runtime libs from dependency_libs
alpar@9 7054 # (they stay in deplibs)
alpar@9 7055 tmp_libs=
alpar@9 7056 for i in $dependency_libs ; do
alpar@9 7057 case " $predeps $postdeps $compiler_lib_search_path " in
alpar@9 7058 *" $i "*)
alpar@9 7059 i=""
alpar@9 7060 ;;
alpar@9 7061 esac
alpar@9 7062 if test -n "$i" ; then
alpar@9 7063 tmp_libs="$tmp_libs $i"
alpar@9 7064 fi
alpar@9 7065 done
alpar@9 7066 dependency_libs=$tmp_libs
alpar@9 7067 done # for pass
alpar@9 7068 if test "$linkmode" = prog; then
alpar@9 7069 dlfiles="$newdlfiles"
alpar@9 7070 fi
alpar@9 7071 if test "$linkmode" = prog || test "$linkmode" = lib; then
alpar@9 7072 dlprefiles="$newdlprefiles"
alpar@9 7073 fi
alpar@9 7074
alpar@9 7075 case $linkmode in
alpar@9 7076 oldlib)
alpar@9 7077 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
alpar@9 7078 func_warning "\`-dlopen' is ignored for archives"
alpar@9 7079 fi
alpar@9 7080
alpar@9 7081 case " $deplibs" in
alpar@9 7082 *\ -l* | *\ -L*)
alpar@9 7083 func_warning "\`-l' and \`-L' are ignored for archives" ;;
alpar@9 7084 esac
alpar@9 7085
alpar@9 7086 test -n "$rpath" && \
alpar@9 7087 func_warning "\`-rpath' is ignored for archives"
alpar@9 7088
alpar@9 7089 test -n "$xrpath" && \
alpar@9 7090 func_warning "\`-R' is ignored for archives"
alpar@9 7091
alpar@9 7092 test -n "$vinfo" && \
alpar@9 7093 func_warning "\`-version-info/-version-number' is ignored for archives"
alpar@9 7094
alpar@9 7095 test -n "$release" && \
alpar@9 7096 func_warning "\`-release' is ignored for archives"
alpar@9 7097
alpar@9 7098 test -n "$export_symbols$export_symbols_regex" && \
alpar@9 7099 func_warning "\`-export-symbols' is ignored for archives"
alpar@9 7100
alpar@9 7101 # Now set the variables for building old libraries.
alpar@9 7102 build_libtool_libs=no
alpar@9 7103 oldlibs="$output"
alpar@9 7104 objs="$objs$old_deplibs"
alpar@9 7105 ;;
alpar@9 7106
alpar@9 7107 lib)
alpar@9 7108 # Make sure we only generate libraries of the form `libNAME.la'.
alpar@9 7109 case $outputname in
alpar@9 7110 lib*)
alpar@9 7111 func_stripname 'lib' '.la' "$outputname"
alpar@9 7112 name=$func_stripname_result
alpar@9 7113 eval shared_ext=\"$shrext_cmds\"
alpar@9 7114 eval libname=\"$libname_spec\"
alpar@9 7115 ;;
alpar@9 7116 *)
alpar@9 7117 test "$module" = no && \
alpar@9 7118 func_fatal_help "libtool library \`$output' must begin with \`lib'"
alpar@9 7119
alpar@9 7120 if test "$need_lib_prefix" != no; then
alpar@9 7121 # Add the "lib" prefix for modules if required
alpar@9 7122 func_stripname '' '.la' "$outputname"
alpar@9 7123 name=$func_stripname_result
alpar@9 7124 eval shared_ext=\"$shrext_cmds\"
alpar@9 7125 eval libname=\"$libname_spec\"
alpar@9 7126 else
alpar@9 7127 func_stripname '' '.la' "$outputname"
alpar@9 7128 libname=$func_stripname_result
alpar@9 7129 fi
alpar@9 7130 ;;
alpar@9 7131 esac
alpar@9 7132
alpar@9 7133 if test -n "$objs"; then
alpar@9 7134 if test "$deplibs_check_method" != pass_all; then
alpar@9 7135 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
alpar@9 7136 else
alpar@9 7137 echo
alpar@9 7138 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
alpar@9 7139 $ECHO "*** objects $objs is not portable!"
alpar@9 7140 libobjs="$libobjs $objs"
alpar@9 7141 fi
alpar@9 7142 fi
alpar@9 7143
alpar@9 7144 test "$dlself" != no && \
alpar@9 7145 func_warning "\`-dlopen self' is ignored for libtool libraries"
alpar@9 7146
alpar@9 7147 set dummy $rpath
alpar@9 7148 shift
alpar@9 7149 test "$#" -gt 1 && \
alpar@9 7150 func_warning "ignoring multiple \`-rpath's for a libtool library"
alpar@9 7151
alpar@9 7152 install_libdir="$1"
alpar@9 7153
alpar@9 7154 oldlibs=
alpar@9 7155 if test -z "$rpath"; then
alpar@9 7156 if test "$build_libtool_libs" = yes; then
alpar@9 7157 # Building a libtool convenience library.
alpar@9 7158 # Some compilers have problems with a `.al' extension so
alpar@9 7159 # convenience libraries should have the same extension an
alpar@9 7160 # archive normally would.
alpar@9 7161 oldlibs="$output_objdir/$libname.$libext $oldlibs"
alpar@9 7162 build_libtool_libs=convenience
alpar@9 7163 build_old_libs=yes
alpar@9 7164 fi
alpar@9 7165
alpar@9 7166 test -n "$vinfo" && \
alpar@9 7167 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
alpar@9 7168
alpar@9 7169 test -n "$release" && \
alpar@9 7170 func_warning "\`-release' is ignored for convenience libraries"
alpar@9 7171 else
alpar@9 7172
alpar@9 7173 # Parse the version information argument.
alpar@9 7174 save_ifs="$IFS"; IFS=':'
alpar@9 7175 set dummy $vinfo 0 0 0
alpar@9 7176 shift
alpar@9 7177 IFS="$save_ifs"
alpar@9 7178
alpar@9 7179 test -n "$7" && \
alpar@9 7180 func_fatal_help "too many parameters to \`-version-info'"
alpar@9 7181
alpar@9 7182 # convert absolute version numbers to libtool ages
alpar@9 7183 # this retains compatibility with .la files and attempts
alpar@9 7184 # to make the code below a bit more comprehensible
alpar@9 7185
alpar@9 7186 case $vinfo_number in
alpar@9 7187 yes)
alpar@9 7188 number_major="$1"
alpar@9 7189 number_minor="$2"
alpar@9 7190 number_revision="$3"
alpar@9 7191 #
alpar@9 7192 # There are really only two kinds -- those that
alpar@9 7193 # use the current revision as the major version
alpar@9 7194 # and those that subtract age and use age as
alpar@9 7195 # a minor version. But, then there is irix
alpar@9 7196 # which has an extra 1 added just for fun
alpar@9 7197 #
alpar@9 7198 case $version_type in
alpar@9 7199 darwin|linux|osf|windows|none)
alpar@9 7200 func_arith $number_major + $number_minor
alpar@9 7201 current=$func_arith_result
alpar@9 7202 age="$number_minor"
alpar@9 7203 revision="$number_revision"
alpar@9 7204 ;;
alpar@9 7205 freebsd-aout|freebsd-elf|qnx|sunos)
alpar@9 7206 current="$number_major"
alpar@9 7207 revision="$number_minor"
alpar@9 7208 age="0"
alpar@9 7209 ;;
alpar@9 7210 irix|nonstopux)
alpar@9 7211 func_arith $number_major + $number_minor
alpar@9 7212 current=$func_arith_result
alpar@9 7213 age="$number_minor"
alpar@9 7214 revision="$number_minor"
alpar@9 7215 lt_irix_increment=no
alpar@9 7216 ;;
alpar@9 7217 esac
alpar@9 7218 ;;
alpar@9 7219 no)
alpar@9 7220 current="$1"
alpar@9 7221 revision="$2"
alpar@9 7222 age="$3"
alpar@9 7223 ;;
alpar@9 7224 esac
alpar@9 7225
alpar@9 7226 # Check that each of the things are valid numbers.
alpar@9 7227 case $current in
alpar@9 7228 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]) ;;
alpar@9 7229 *)
alpar@9 7230 func_error "CURRENT \`$current' must be a nonnegative integer"
alpar@9 7231 func_fatal_error "\`$vinfo' is not valid version information"
alpar@9 7232 ;;
alpar@9 7233 esac
alpar@9 7234
alpar@9 7235 case $revision in
alpar@9 7236 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]) ;;
alpar@9 7237 *)
alpar@9 7238 func_error "REVISION \`$revision' must be a nonnegative integer"
alpar@9 7239 func_fatal_error "\`$vinfo' is not valid version information"
alpar@9 7240 ;;
alpar@9 7241 esac
alpar@9 7242
alpar@9 7243 case $age in
alpar@9 7244 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]) ;;
alpar@9 7245 *)
alpar@9 7246 func_error "AGE \`$age' must be a nonnegative integer"
alpar@9 7247 func_fatal_error "\`$vinfo' is not valid version information"
alpar@9 7248 ;;
alpar@9 7249 esac
alpar@9 7250
alpar@9 7251 if test "$age" -gt "$current"; then
alpar@9 7252 func_error "AGE \`$age' is greater than the current interface number \`$current'"
alpar@9 7253 func_fatal_error "\`$vinfo' is not valid version information"
alpar@9 7254 fi
alpar@9 7255
alpar@9 7256 # Calculate the version variables.
alpar@9 7257 major=
alpar@9 7258 versuffix=
alpar@9 7259 verstring=
alpar@9 7260 case $version_type in
alpar@9 7261 none) ;;
alpar@9 7262
alpar@9 7263 darwin)
alpar@9 7264 # Like Linux, but with the current version available in
alpar@9 7265 # verstring for coding it into the library header
alpar@9 7266 func_arith $current - $age
alpar@9 7267 major=.$func_arith_result
alpar@9 7268 versuffix="$major.$age.$revision"
alpar@9 7269 # Darwin ld doesn't like 0 for these options...
alpar@9 7270 func_arith $current + 1
alpar@9 7271 minor_current=$func_arith_result
alpar@9 7272 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
alpar@9 7273 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
alpar@9 7274 ;;
alpar@9 7275
alpar@9 7276 freebsd-aout)
alpar@9 7277 major=".$current"
alpar@9 7278 versuffix=".$current.$revision";
alpar@9 7279 ;;
alpar@9 7280
alpar@9 7281 freebsd-elf)
alpar@9 7282 major=".$current"
alpar@9 7283 versuffix=".$current"
alpar@9 7284 ;;
alpar@9 7285
alpar@9 7286 irix | nonstopux)
alpar@9 7287 if test "X$lt_irix_increment" = "Xno"; then
alpar@9 7288 func_arith $current - $age
alpar@9 7289 else
alpar@9 7290 func_arith $current - $age + 1
alpar@9 7291 fi
alpar@9 7292 major=$func_arith_result
alpar@9 7293
alpar@9 7294 case $version_type in
alpar@9 7295 nonstopux) verstring_prefix=nonstopux ;;
alpar@9 7296 *) verstring_prefix=sgi ;;
alpar@9 7297 esac
alpar@9 7298 verstring="$verstring_prefix$major.$revision"
alpar@9 7299
alpar@9 7300 # Add in all the interfaces that we are compatible with.
alpar@9 7301 loop=$revision
alpar@9 7302 while test "$loop" -ne 0; do
alpar@9 7303 func_arith $revision - $loop
alpar@9 7304 iface=$func_arith_result
alpar@9 7305 func_arith $loop - 1
alpar@9 7306 loop=$func_arith_result
alpar@9 7307 verstring="$verstring_prefix$major.$iface:$verstring"
alpar@9 7308 done
alpar@9 7309
alpar@9 7310 # Before this point, $major must not contain `.'.
alpar@9 7311 major=.$major
alpar@9 7312 versuffix="$major.$revision"
alpar@9 7313 ;;
alpar@9 7314
alpar@9 7315 linux)
alpar@9 7316 func_arith $current - $age
alpar@9 7317 major=.$func_arith_result
alpar@9 7318 versuffix="$major.$age.$revision"
alpar@9 7319 ;;
alpar@9 7320
alpar@9 7321 osf)
alpar@9 7322 func_arith $current - $age
alpar@9 7323 major=.$func_arith_result
alpar@9 7324 versuffix=".$current.$age.$revision"
alpar@9 7325 verstring="$current.$age.$revision"
alpar@9 7326
alpar@9 7327 # Add in all the interfaces that we are compatible with.
alpar@9 7328 loop=$age
alpar@9 7329 while test "$loop" -ne 0; do
alpar@9 7330 func_arith $current - $loop
alpar@9 7331 iface=$func_arith_result
alpar@9 7332 func_arith $loop - 1
alpar@9 7333 loop=$func_arith_result
alpar@9 7334 verstring="$verstring:${iface}.0"
alpar@9 7335 done
alpar@9 7336
alpar@9 7337 # Make executables depend on our current version.
alpar@9 7338 verstring="$verstring:${current}.0"
alpar@9 7339 ;;
alpar@9 7340
alpar@9 7341 qnx)
alpar@9 7342 major=".$current"
alpar@9 7343 versuffix=".$current"
alpar@9 7344 ;;
alpar@9 7345
alpar@9 7346 sunos)
alpar@9 7347 major=".$current"
alpar@9 7348 versuffix=".$current.$revision"
alpar@9 7349 ;;
alpar@9 7350
alpar@9 7351 windows)
alpar@9 7352 # Use '-' rather than '.', since we only want one
alpar@9 7353 # extension on DOS 8.3 filesystems.
alpar@9 7354 func_arith $current - $age
alpar@9 7355 major=$func_arith_result
alpar@9 7356 versuffix="-$major"
alpar@9 7357 ;;
alpar@9 7358
alpar@9 7359 *)
alpar@9 7360 func_fatal_configuration "unknown library version type \`$version_type'"
alpar@9 7361 ;;
alpar@9 7362 esac
alpar@9 7363
alpar@9 7364 # Clear the version info if we defaulted, and they specified a release.
alpar@9 7365 if test -z "$vinfo" && test -n "$release"; then
alpar@9 7366 major=
alpar@9 7367 case $version_type in
alpar@9 7368 darwin)
alpar@9 7369 # we can't check for "0.0" in archive_cmds due to quoting
alpar@9 7370 # problems, so we reset it completely
alpar@9 7371 verstring=
alpar@9 7372 ;;
alpar@9 7373 *)
alpar@9 7374 verstring="0.0"
alpar@9 7375 ;;
alpar@9 7376 esac
alpar@9 7377 if test "$need_version" = no; then
alpar@9 7378 versuffix=
alpar@9 7379 else
alpar@9 7380 versuffix=".0.0"
alpar@9 7381 fi
alpar@9 7382 fi
alpar@9 7383
alpar@9 7384 # Remove version info from name if versioning should be avoided
alpar@9 7385 if test "$avoid_version" = yes && test "$need_version" = no; then
alpar@9 7386 major=
alpar@9 7387 versuffix=
alpar@9 7388 verstring=""
alpar@9 7389 fi
alpar@9 7390
alpar@9 7391 # Check to see if the archive will have undefined symbols.
alpar@9 7392 if test "$allow_undefined" = yes; then
alpar@9 7393 if test "$allow_undefined_flag" = unsupported; then
alpar@9 7394 func_warning "undefined symbols not allowed in $host shared libraries"
alpar@9 7395 build_libtool_libs=no
alpar@9 7396 build_old_libs=yes
alpar@9 7397 fi
alpar@9 7398 else
alpar@9 7399 # Don't allow undefined symbols.
alpar@9 7400 allow_undefined_flag="$no_undefined_flag"
alpar@9 7401 fi
alpar@9 7402
alpar@9 7403 fi
alpar@9 7404
alpar@9 7405 func_generate_dlsyms "$libname" "$libname" "yes"
alpar@9 7406 libobjs="$libobjs $symfileobj"
alpar@9 7407 test "X$libobjs" = "X " && libobjs=
alpar@9 7408
alpar@9 7409 if test "$mode" != relink; then
alpar@9 7410 # Remove our outputs, but don't remove object files since they
alpar@9 7411 # may have been created when compiling PIC objects.
alpar@9 7412 removelist=
alpar@9 7413 tempremovelist=`$ECHO "$output_objdir/*"`
alpar@9 7414 for p in $tempremovelist; do
alpar@9 7415 case $p in
alpar@9 7416 *.$objext | *.gcno)
alpar@9 7417 ;;
alpar@9 7418 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
alpar@9 7419 if test "X$precious_files_regex" != "X"; then
alpar@9 7420 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
alpar@9 7421 then
alpar@9 7422 continue
alpar@9 7423 fi
alpar@9 7424 fi
alpar@9 7425 removelist="$removelist $p"
alpar@9 7426 ;;
alpar@9 7427 *) ;;
alpar@9 7428 esac
alpar@9 7429 done
alpar@9 7430 test -n "$removelist" && \
alpar@9 7431 func_show_eval "${RM}r \$removelist"
alpar@9 7432 fi
alpar@9 7433
alpar@9 7434 # Now set the variables for building old libraries.
alpar@9 7435 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
alpar@9 7436 oldlibs="$oldlibs $output_objdir/$libname.$libext"
alpar@9 7437
alpar@9 7438 # Transform .lo files to .o files.
alpar@9 7439 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
alpar@9 7440 fi
alpar@9 7441
alpar@9 7442 # Eliminate all temporary directories.
alpar@9 7443 #for path in $notinst_path; do
alpar@9 7444 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
alpar@9 7445 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
alpar@9 7446 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
alpar@9 7447 #done
alpar@9 7448
alpar@9 7449 if test -n "$xrpath"; then
alpar@9 7450 # If the user specified any rpath flags, then add them.
alpar@9 7451 temp_xrpath=
alpar@9 7452 for libdir in $xrpath; do
alpar@9 7453 temp_xrpath="$temp_xrpath -R$libdir"
alpar@9 7454 case "$finalize_rpath " in
alpar@9 7455 *" $libdir "*) ;;
alpar@9 7456 *) finalize_rpath="$finalize_rpath $libdir" ;;
alpar@9 7457 esac
alpar@9 7458 done
alpar@9 7459 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
alpar@9 7460 dependency_libs="$temp_xrpath $dependency_libs"
alpar@9 7461 fi
alpar@9 7462 fi
alpar@9 7463
alpar@9 7464 # Make sure dlfiles contains only unique files that won't be dlpreopened
alpar@9 7465 old_dlfiles="$dlfiles"
alpar@9 7466 dlfiles=
alpar@9 7467 for lib in $old_dlfiles; do
alpar@9 7468 case " $dlprefiles $dlfiles " in
alpar@9 7469 *" $lib "*) ;;
alpar@9 7470 *) dlfiles="$dlfiles $lib" ;;
alpar@9 7471 esac
alpar@9 7472 done
alpar@9 7473
alpar@9 7474 # Make sure dlprefiles contains only unique files
alpar@9 7475 old_dlprefiles="$dlprefiles"
alpar@9 7476 dlprefiles=
alpar@9 7477 for lib in $old_dlprefiles; do
alpar@9 7478 case "$dlprefiles " in
alpar@9 7479 *" $lib "*) ;;
alpar@9 7480 *) dlprefiles="$dlprefiles $lib" ;;
alpar@9 7481 esac
alpar@9 7482 done
alpar@9 7483
alpar@9 7484 if test "$build_libtool_libs" = yes; then
alpar@9 7485 if test -n "$rpath"; then
alpar@9 7486 case $host in
alpar@9 7487 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
alpar@9 7488 # these systems don't actually have a c library (as such)!
alpar@9 7489 ;;
alpar@9 7490 *-*-rhapsody* | *-*-darwin1.[012])
alpar@9 7491 # Rhapsody C library is in the System framework
alpar@9 7492 deplibs="$deplibs System.ltframework"
alpar@9 7493 ;;
alpar@9 7494 *-*-netbsd*)
alpar@9 7495 # Don't link with libc until the a.out ld.so is fixed.
alpar@9 7496 ;;
alpar@9 7497 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
alpar@9 7498 # Do not include libc due to us having libc/libc_r.
alpar@9 7499 ;;
alpar@9 7500 *-*-sco3.2v5* | *-*-sco5v6*)
alpar@9 7501 # Causes problems with __ctype
alpar@9 7502 ;;
alpar@9 7503 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
alpar@9 7504 # Compiler inserts libc in the correct place for threads to work
alpar@9 7505 ;;
alpar@9 7506 *)
alpar@9 7507 # Add libc to deplibs on all other systems if necessary.
alpar@9 7508 if test "$build_libtool_need_lc" = "yes"; then
alpar@9 7509 deplibs="$deplibs -lc"
alpar@9 7510 fi
alpar@9 7511 ;;
alpar@9 7512 esac
alpar@9 7513 fi
alpar@9 7514
alpar@9 7515 # Transform deplibs into only deplibs that can be linked in shared.
alpar@9 7516 name_save=$name
alpar@9 7517 libname_save=$libname
alpar@9 7518 release_save=$release
alpar@9 7519 versuffix_save=$versuffix
alpar@9 7520 major_save=$major
alpar@9 7521 # I'm not sure if I'm treating the release correctly. I think
alpar@9 7522 # release should show up in the -l (ie -lgmp5) so we don't want to
alpar@9 7523 # add it in twice. Is that correct?
alpar@9 7524 release=""
alpar@9 7525 versuffix=""
alpar@9 7526 major=""
alpar@9 7527 newdeplibs=
alpar@9 7528 droppeddeps=no
alpar@9 7529 case $deplibs_check_method in
alpar@9 7530 pass_all)
alpar@9 7531 # Don't check for shared/static. Everything works.
alpar@9 7532 # This might be a little naive. We might want to check
alpar@9 7533 # whether the library exists or not. But this is on
alpar@9 7534 # osf3 & osf4 and I'm not really sure... Just
alpar@9 7535 # implementing what was already the behavior.
alpar@9 7536 newdeplibs=$deplibs
alpar@9 7537 ;;
alpar@9 7538 test_compile)
alpar@9 7539 # This code stresses the "libraries are programs" paradigm to its
alpar@9 7540 # limits. Maybe even breaks it. We compile a program, linking it
alpar@9 7541 # against the deplibs as a proxy for the library. Then we can check
alpar@9 7542 # whether they linked in statically or dynamically with ldd.
alpar@9 7543 $opt_dry_run || $RM conftest.c
alpar@9 7544 cat > conftest.c <<EOF
alpar@9 7545 int main() { return 0; }
alpar@9 7546 EOF
alpar@9 7547 $opt_dry_run || $RM conftest
alpar@9 7548 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
alpar@9 7549 ldd_output=`ldd conftest`
alpar@9 7550 for i in $deplibs; do
alpar@9 7551 case $i in
alpar@9 7552 -l*)
alpar@9 7553 func_stripname -l '' "$i"
alpar@9 7554 name=$func_stripname_result
alpar@9 7555 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
alpar@9 7556 case " $predeps $postdeps " in
alpar@9 7557 *" $i "*)
alpar@9 7558 newdeplibs="$newdeplibs $i"
alpar@9 7559 i=""
alpar@9 7560 ;;
alpar@9 7561 esac
alpar@9 7562 fi
alpar@9 7563 if test -n "$i" ; then
alpar@9 7564 libname=`eval "\\$ECHO \"$libname_spec\""`
alpar@9 7565 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
alpar@9 7566 set dummy $deplib_matches; shift
alpar@9 7567 deplib_match=$1
alpar@9 7568 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
alpar@9 7569 newdeplibs="$newdeplibs $i"
alpar@9 7570 else
alpar@9 7571 droppeddeps=yes
alpar@9 7572 echo
alpar@9 7573 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
alpar@9 7574 echo "*** I have the capability to make that library automatically link in when"
alpar@9 7575 echo "*** you link to this library. But I can only do this if you have a"
alpar@9 7576 echo "*** shared version of the library, which I believe you do not have"
alpar@9 7577 echo "*** because a test_compile did reveal that the linker did not use it for"
alpar@9 7578 echo "*** its dynamic dependency list that programs get resolved with at runtime."
alpar@9 7579 fi
alpar@9 7580 fi
alpar@9 7581 ;;
alpar@9 7582 *)
alpar@9 7583 newdeplibs="$newdeplibs $i"
alpar@9 7584 ;;
alpar@9 7585 esac
alpar@9 7586 done
alpar@9 7587 else
alpar@9 7588 # Error occurred in the first compile. Let's try to salvage
alpar@9 7589 # the situation: Compile a separate program for each library.
alpar@9 7590 for i in $deplibs; do
alpar@9 7591 case $i in
alpar@9 7592 -l*)
alpar@9 7593 func_stripname -l '' "$i"
alpar@9 7594 name=$func_stripname_result
alpar@9 7595 $opt_dry_run || $RM conftest
alpar@9 7596 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
alpar@9 7597 ldd_output=`ldd conftest`
alpar@9 7598 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
alpar@9 7599 case " $predeps $postdeps " in
alpar@9 7600 *" $i "*)
alpar@9 7601 newdeplibs="$newdeplibs $i"
alpar@9 7602 i=""
alpar@9 7603 ;;
alpar@9 7604 esac
alpar@9 7605 fi
alpar@9 7606 if test -n "$i" ; then
alpar@9 7607 libname=`eval "\\$ECHO \"$libname_spec\""`
alpar@9 7608 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
alpar@9 7609 set dummy $deplib_matches; shift
alpar@9 7610 deplib_match=$1
alpar@9 7611 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
alpar@9 7612 newdeplibs="$newdeplibs $i"
alpar@9 7613 else
alpar@9 7614 droppeddeps=yes
alpar@9 7615 echo
alpar@9 7616 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
alpar@9 7617 echo "*** I have the capability to make that library automatically link in when"
alpar@9 7618 echo "*** you link to this library. But I can only do this if you have a"
alpar@9 7619 echo "*** shared version of the library, which you do not appear to have"
alpar@9 7620 echo "*** because a test_compile did reveal that the linker did not use this one"
alpar@9 7621 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
alpar@9 7622 fi
alpar@9 7623 fi
alpar@9 7624 else
alpar@9 7625 droppeddeps=yes
alpar@9 7626 echo
alpar@9 7627 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
alpar@9 7628 echo "*** make it link in! You will probably need to install it or some"
alpar@9 7629 echo "*** library that it depends on before this library will be fully"
alpar@9 7630 echo "*** functional. Installing it before continuing would be even better."
alpar@9 7631 fi
alpar@9 7632 ;;
alpar@9 7633 *)
alpar@9 7634 newdeplibs="$newdeplibs $i"
alpar@9 7635 ;;
alpar@9 7636 esac
alpar@9 7637 done
alpar@9 7638 fi
alpar@9 7639 ;;
alpar@9 7640 file_magic*)
alpar@9 7641 set dummy $deplibs_check_method; shift
alpar@9 7642 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
alpar@9 7643 for a_deplib in $deplibs; do
alpar@9 7644 case $a_deplib in
alpar@9 7645 -l*)
alpar@9 7646 func_stripname -l '' "$a_deplib"
alpar@9 7647 name=$func_stripname_result
alpar@9 7648 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
alpar@9 7649 case " $predeps $postdeps " in
alpar@9 7650 *" $a_deplib "*)
alpar@9 7651 newdeplibs="$newdeplibs $a_deplib"
alpar@9 7652 a_deplib=""
alpar@9 7653 ;;
alpar@9 7654 esac
alpar@9 7655 fi
alpar@9 7656 if test -n "$a_deplib" ; then
alpar@9 7657 libname=`eval "\\$ECHO \"$libname_spec\""`
alpar@9 7658 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
alpar@9 7659 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
alpar@9 7660 for potent_lib in $potential_libs; do
alpar@9 7661 # Follow soft links.
alpar@9 7662 if ls -lLd "$potent_lib" 2>/dev/null |
alpar@9 7663 $GREP " -> " >/dev/null; then
alpar@9 7664 continue
alpar@9 7665 fi
alpar@9 7666 # The statement above tries to avoid entering an
alpar@9 7667 # endless loop below, in case of cyclic links.
alpar@9 7668 # We might still enter an endless loop, since a link
alpar@9 7669 # loop can be closed while we follow links,
alpar@9 7670 # but so what?
alpar@9 7671 potlib="$potent_lib"
alpar@9 7672 while test -h "$potlib" 2>/dev/null; do
alpar@9 7673 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
alpar@9 7674 case $potliblink in
alpar@9 7675 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
alpar@9 7676 *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
alpar@9 7677 esac
alpar@9 7678 done
alpar@9 7679 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
alpar@9 7680 $SED -e 10q |
alpar@9 7681 $EGREP "$file_magic_regex" > /dev/null; then
alpar@9 7682 newdeplibs="$newdeplibs $a_deplib"
alpar@9 7683 a_deplib=""
alpar@9 7684 break 2
alpar@9 7685 fi
alpar@9 7686 done
alpar@9 7687 done
alpar@9 7688 fi
alpar@9 7689 if test -n "$a_deplib" ; then
alpar@9 7690 droppeddeps=yes
alpar@9 7691 echo
alpar@9 7692 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
alpar@9 7693 echo "*** I have the capability to make that library automatically link in when"
alpar@9 7694 echo "*** you link to this library. But I can only do this if you have a"
alpar@9 7695 echo "*** shared version of the library, which you do not appear to have"
alpar@9 7696 echo "*** because I did check the linker path looking for a file starting"
alpar@9 7697 if test -z "$potlib" ; then
alpar@9 7698 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
alpar@9 7699 else
alpar@9 7700 $ECHO "*** with $libname and none of the candidates passed a file format test"
alpar@9 7701 $ECHO "*** using a file magic. Last file checked: $potlib"
alpar@9 7702 fi
alpar@9 7703 fi
alpar@9 7704 ;;
alpar@9 7705 *)
alpar@9 7706 # Add a -L argument.
alpar@9 7707 newdeplibs="$newdeplibs $a_deplib"
alpar@9 7708 ;;
alpar@9 7709 esac
alpar@9 7710 done # Gone through all deplibs.
alpar@9 7711 ;;
alpar@9 7712 match_pattern*)
alpar@9 7713 set dummy $deplibs_check_method; shift
alpar@9 7714 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
alpar@9 7715 for a_deplib in $deplibs; do
alpar@9 7716 case $a_deplib in
alpar@9 7717 -l*)
alpar@9 7718 func_stripname -l '' "$a_deplib"
alpar@9 7719 name=$func_stripname_result
alpar@9 7720 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
alpar@9 7721 case " $predeps $postdeps " in
alpar@9 7722 *" $a_deplib "*)
alpar@9 7723 newdeplibs="$newdeplibs $a_deplib"
alpar@9 7724 a_deplib=""
alpar@9 7725 ;;
alpar@9 7726 esac
alpar@9 7727 fi
alpar@9 7728 if test -n "$a_deplib" ; then
alpar@9 7729 libname=`eval "\\$ECHO \"$libname_spec\""`
alpar@9 7730 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
alpar@9 7731 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
alpar@9 7732 for potent_lib in $potential_libs; do
alpar@9 7733 potlib="$potent_lib" # see symlink-check above in file_magic test
alpar@9 7734 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
alpar@9 7735 $EGREP "$match_pattern_regex" > /dev/null; then
alpar@9 7736 newdeplibs="$newdeplibs $a_deplib"
alpar@9 7737 a_deplib=""
alpar@9 7738 break 2
alpar@9 7739 fi
alpar@9 7740 done
alpar@9 7741 done
alpar@9 7742 fi
alpar@9 7743 if test -n "$a_deplib" ; then
alpar@9 7744 droppeddeps=yes
alpar@9 7745 echo
alpar@9 7746 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
alpar@9 7747 echo "*** I have the capability to make that library automatically link in when"
alpar@9 7748 echo "*** you link to this library. But I can only do this if you have a"
alpar@9 7749 echo "*** shared version of the library, which you do not appear to have"
alpar@9 7750 echo "*** because I did check the linker path looking for a file starting"
alpar@9 7751 if test -z "$potlib" ; then
alpar@9 7752 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
alpar@9 7753 else
alpar@9 7754 $ECHO "*** with $libname and none of the candidates passed a file format test"
alpar@9 7755 $ECHO "*** using a regex pattern. Last file checked: $potlib"
alpar@9 7756 fi
alpar@9 7757 fi
alpar@9 7758 ;;
alpar@9 7759 *)
alpar@9 7760 # Add a -L argument.
alpar@9 7761 newdeplibs="$newdeplibs $a_deplib"
alpar@9 7762 ;;
alpar@9 7763 esac
alpar@9 7764 done # Gone through all deplibs.
alpar@9 7765 ;;
alpar@9 7766 none | unknown | *)
alpar@9 7767 newdeplibs=""
alpar@9 7768 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
alpar@9 7769 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
alpar@9 7770 for i in $predeps $postdeps ; do
alpar@9 7771 # can't use Xsed below, because $i might contain '/'
alpar@9 7772 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
alpar@9 7773 done
alpar@9 7774 fi
alpar@9 7775 case $tmp_deplibs in
alpar@9 7776 *[!\ \ ]*)
alpar@9 7777 echo
alpar@9 7778 if test "X$deplibs_check_method" = "Xnone"; then
alpar@9 7779 echo "*** Warning: inter-library dependencies are not supported in this platform."
alpar@9 7780 else
alpar@9 7781 echo "*** Warning: inter-library dependencies are not known to be supported."
alpar@9 7782 fi
alpar@9 7783 echo "*** All declared inter-library dependencies are being dropped."
alpar@9 7784 droppeddeps=yes
alpar@9 7785 ;;
alpar@9 7786 esac
alpar@9 7787 ;;
alpar@9 7788 esac
alpar@9 7789 versuffix=$versuffix_save
alpar@9 7790 major=$major_save
alpar@9 7791 release=$release_save
alpar@9 7792 libname=$libname_save
alpar@9 7793 name=$name_save
alpar@9 7794
alpar@9 7795 case $host in
alpar@9 7796 *-*-rhapsody* | *-*-darwin1.[012])
alpar@9 7797 # On Rhapsody replace the C library with the System framework
alpar@9 7798 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
alpar@9 7799 ;;
alpar@9 7800 esac
alpar@9 7801
alpar@9 7802 if test "$droppeddeps" = yes; then
alpar@9 7803 if test "$module" = yes; then
alpar@9 7804 echo
alpar@9 7805 echo "*** Warning: libtool could not satisfy all declared inter-library"
alpar@9 7806 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
alpar@9 7807 echo "*** a static module, that should work as long as the dlopening"
alpar@9 7808 echo "*** application is linked with the -dlopen flag."
alpar@9 7809 if test -z "$global_symbol_pipe"; then
alpar@9 7810 echo
alpar@9 7811 echo "*** However, this would only work if libtool was able to extract symbol"
alpar@9 7812 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
alpar@9 7813 echo "*** not find such a program. So, this module is probably useless."
alpar@9 7814 echo "*** \`nm' from GNU binutils and a full rebuild may help."
alpar@9 7815 fi
alpar@9 7816 if test "$build_old_libs" = no; then
alpar@9 7817 oldlibs="$output_objdir/$libname.$libext"
alpar@9 7818 build_libtool_libs=module
alpar@9 7819 build_old_libs=yes
alpar@9 7820 else
alpar@9 7821 build_libtool_libs=no
alpar@9 7822 fi
alpar@9 7823 else
alpar@9 7824 echo "*** The inter-library dependencies that have been dropped here will be"
alpar@9 7825 echo "*** automatically added whenever a program is linked with this library"
alpar@9 7826 echo "*** or is declared to -dlopen it."
alpar@9 7827
alpar@9 7828 if test "$allow_undefined" = no; then
alpar@9 7829 echo
alpar@9 7830 echo "*** Since this library must not contain undefined symbols,"
alpar@9 7831 echo "*** because either the platform does not support them or"
alpar@9 7832 echo "*** it was explicitly requested with -no-undefined,"
alpar@9 7833 echo "*** libtool will only create a static version of it."
alpar@9 7834 if test "$build_old_libs" = no; then
alpar@9 7835 oldlibs="$output_objdir/$libname.$libext"
alpar@9 7836 build_libtool_libs=module
alpar@9 7837 build_old_libs=yes
alpar@9 7838 else
alpar@9 7839 build_libtool_libs=no
alpar@9 7840 fi
alpar@9 7841 fi
alpar@9 7842 fi
alpar@9 7843 fi
alpar@9 7844 # Done checking deplibs!
alpar@9 7845 deplibs=$newdeplibs
alpar@9 7846 fi
alpar@9 7847 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
alpar@9 7848 case $host in
alpar@9 7849 *-*-darwin*)
alpar@9 7850 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
alpar@9 7851 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
alpar@9 7852 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
alpar@9 7853 ;;
alpar@9 7854 esac
alpar@9 7855
alpar@9 7856 # move library search paths that coincide with paths to not yet
alpar@9 7857 # installed libraries to the beginning of the library search list
alpar@9 7858 new_libs=
alpar@9 7859 for path in $notinst_path; do
alpar@9 7860 case " $new_libs " in
alpar@9 7861 *" -L$path/$objdir "*) ;;
alpar@9 7862 *)
alpar@9 7863 case " $deplibs " in
alpar@9 7864 *" -L$path/$objdir "*)
alpar@9 7865 new_libs="$new_libs -L$path/$objdir" ;;
alpar@9 7866 esac
alpar@9 7867 ;;
alpar@9 7868 esac
alpar@9 7869 done
alpar@9 7870 for deplib in $deplibs; do
alpar@9 7871 case $deplib in
alpar@9 7872 -L*)
alpar@9 7873 case " $new_libs " in
alpar@9 7874 *" $deplib "*) ;;
alpar@9 7875 *) new_libs="$new_libs $deplib" ;;
alpar@9 7876 esac
alpar@9 7877 ;;
alpar@9 7878 *) new_libs="$new_libs $deplib" ;;
alpar@9 7879 esac
alpar@9 7880 done
alpar@9 7881 deplibs="$new_libs"
alpar@9 7882
alpar@9 7883 # All the library-specific variables (install_libdir is set above).
alpar@9 7884 library_names=
alpar@9 7885 old_library=
alpar@9 7886 dlname=
alpar@9 7887
alpar@9 7888 # Test again, we may have decided not to build it any more
alpar@9 7889 if test "$build_libtool_libs" = yes; then
alpar@9 7890 if test "$hardcode_into_libs" = yes; then
alpar@9 7891 # Hardcode the library paths
alpar@9 7892 hardcode_libdirs=
alpar@9 7893 dep_rpath=
alpar@9 7894 rpath="$finalize_rpath"
alpar@9 7895 test "$mode" != relink && rpath="$compile_rpath$rpath"
alpar@9 7896 for libdir in $rpath; do
alpar@9 7897 if test -n "$hardcode_libdir_flag_spec"; then
alpar@9 7898 if test -n "$hardcode_libdir_separator"; then
alpar@9 7899 if test -z "$hardcode_libdirs"; then
alpar@9 7900 hardcode_libdirs="$libdir"
alpar@9 7901 else
alpar@9 7902 # Just accumulate the unique libdirs.
alpar@9 7903 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
alpar@9 7904 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
alpar@9 7905 ;;
alpar@9 7906 *)
alpar@9 7907 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
alpar@9 7908 ;;
alpar@9 7909 esac
alpar@9 7910 fi
alpar@9 7911 else
alpar@9 7912 eval flag=\"$hardcode_libdir_flag_spec\"
alpar@9 7913 dep_rpath="$dep_rpath $flag"
alpar@9 7914 fi
alpar@9 7915 elif test -n "$runpath_var"; then
alpar@9 7916 case "$perm_rpath " in
alpar@9 7917 *" $libdir "*) ;;
alpar@9 7918 *) perm_rpath="$perm_rpath $libdir" ;;
alpar@9 7919 esac
alpar@9 7920 fi
alpar@9 7921 done
alpar@9 7922 # Substitute the hardcoded libdirs into the rpath.
alpar@9 7923 if test -n "$hardcode_libdir_separator" &&
alpar@9 7924 test -n "$hardcode_libdirs"; then
alpar@9 7925 libdir="$hardcode_libdirs"
alpar@9 7926 if test -n "$hardcode_libdir_flag_spec_ld"; then
alpar@9 7927 eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
alpar@9 7928 else
alpar@9 7929 eval dep_rpath=\"$hardcode_libdir_flag_spec\"
alpar@9 7930 fi
alpar@9 7931 fi
alpar@9 7932 if test -n "$runpath_var" && test -n "$perm_rpath"; then
alpar@9 7933 # We should set the runpath_var.
alpar@9 7934 rpath=
alpar@9 7935 for dir in $perm_rpath; do
alpar@9 7936 rpath="$rpath$dir:"
alpar@9 7937 done
alpar@9 7938 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
alpar@9 7939 fi
alpar@9 7940 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
alpar@9 7941 fi
alpar@9 7942
alpar@9 7943 shlibpath="$finalize_shlibpath"
alpar@9 7944 test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
alpar@9 7945 if test -n "$shlibpath"; then
alpar@9 7946 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
alpar@9 7947 fi
alpar@9 7948
alpar@9 7949 # Get the real and link names of the library.
alpar@9 7950 eval shared_ext=\"$shrext_cmds\"
alpar@9 7951 eval library_names=\"$library_names_spec\"
alpar@9 7952 set dummy $library_names
alpar@9 7953 shift
alpar@9 7954 realname="$1"
alpar@9 7955 shift
alpar@9 7956
alpar@9 7957 if test -n "$soname_spec"; then
alpar@9 7958 eval soname=\"$soname_spec\"
alpar@9 7959 else
alpar@9 7960 soname="$realname"
alpar@9 7961 fi
alpar@9 7962 if test -z "$dlname"; then
alpar@9 7963 dlname=$soname
alpar@9 7964 fi
alpar@9 7965
alpar@9 7966 lib="$output_objdir/$realname"
alpar@9 7967 linknames=
alpar@9 7968 for link
alpar@9 7969 do
alpar@9 7970 linknames="$linknames $link"
alpar@9 7971 done
alpar@9 7972
alpar@9 7973 # Use standard objects if they are pic
alpar@9 7974 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
alpar@9 7975 test "X$libobjs" = "X " && libobjs=
alpar@9 7976
alpar@9 7977 delfiles=
alpar@9 7978 if test -n "$export_symbols" && test -n "$include_expsyms"; then
alpar@9 7979 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
alpar@9 7980 export_symbols="$output_objdir/$libname.uexp"
alpar@9 7981 delfiles="$delfiles $export_symbols"
alpar@9 7982 fi
alpar@9 7983
alpar@9 7984 orig_export_symbols=
alpar@9 7985 case $host_os in
alpar@9 7986 cygwin* | mingw* | cegcc*)
alpar@9 7987 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
alpar@9 7988 # exporting using user supplied symfile
alpar@9 7989 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
alpar@9 7990 # and it's NOT already a .def file. Must figure out
alpar@9 7991 # which of the given symbols are data symbols and tag
alpar@9 7992 # them as such. So, trigger use of export_symbols_cmds.
alpar@9 7993 # export_symbols gets reassigned inside the "prepare
alpar@9 7994 # the list of exported symbols" if statement, so the
alpar@9 7995 # include_expsyms logic still works.
alpar@9 7996 orig_export_symbols="$export_symbols"
alpar@9 7997 export_symbols=
alpar@9 7998 always_export_symbols=yes
alpar@9 7999 fi
alpar@9 8000 fi
alpar@9 8001 ;;
alpar@9 8002 esac
alpar@9 8003
alpar@9 8004 # Prepare the list of exported symbols
alpar@9 8005 if test -z "$export_symbols"; then
alpar@9 8006 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
alpar@9 8007 func_verbose "generating symbol list for \`$libname.la'"
alpar@9 8008 export_symbols="$output_objdir/$libname.exp"
alpar@9 8009 $opt_dry_run || $RM $export_symbols
alpar@9 8010 cmds=$export_symbols_cmds
alpar@9 8011 save_ifs="$IFS"; IFS='~'
alpar@9 8012 for cmd in $cmds; do
alpar@9 8013 IFS="$save_ifs"
alpar@9 8014 eval cmd=\"$cmd\"
alpar@9 8015 func_len " $cmd"
alpar@9 8016 len=$func_len_result
alpar@9 8017 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
alpar@9 8018 func_show_eval "$cmd" 'exit $?'
alpar@9 8019 skipped_export=false
alpar@9 8020 else
alpar@9 8021 # The command line is too long to execute in one step.
alpar@9 8022 func_verbose "using reloadable object file for export list..."
alpar@9 8023 skipped_export=:
alpar@9 8024 # Break out early, otherwise skipped_export may be
alpar@9 8025 # set to false by a later but shorter cmd.
alpar@9 8026 break
alpar@9 8027 fi
alpar@9 8028 done
alpar@9 8029 IFS="$save_ifs"
alpar@9 8030 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
alpar@9 8031 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
alpar@9 8032 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
alpar@9 8033 fi
alpar@9 8034 fi
alpar@9 8035 fi
alpar@9 8036
alpar@9 8037 if test -n "$export_symbols" && test -n "$include_expsyms"; then
alpar@9 8038 tmp_export_symbols="$export_symbols"
alpar@9 8039 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
alpar@9 8040 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
alpar@9 8041 fi
alpar@9 8042
alpar@9 8043 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
alpar@9 8044 # The given exports_symbols file has to be filtered, so filter it.
alpar@9 8045 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
alpar@9 8046 # FIXME: $output_objdir/$libname.filter potentially contains lots of
alpar@9 8047 # 's' commands which not all seds can handle. GNU sed should be fine
alpar@9 8048 # though. Also, the filter scales superlinearly with the number of
alpar@9 8049 # global variables. join(1) would be nice here, but unfortunately
alpar@9 8050 # isn't a blessed tool.
alpar@9 8051 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
alpar@9 8052 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
alpar@9 8053 export_symbols=$output_objdir/$libname.def
alpar@9 8054 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
alpar@9 8055 fi
alpar@9 8056
alpar@9 8057 tmp_deplibs=
alpar@9 8058 for test_deplib in $deplibs; do
alpar@9 8059 case " $convenience " in
alpar@9 8060 *" $test_deplib "*) ;;
alpar@9 8061 *)
alpar@9 8062 tmp_deplibs="$tmp_deplibs $test_deplib"
alpar@9 8063 ;;
alpar@9 8064 esac
alpar@9 8065 done
alpar@9 8066 deplibs="$tmp_deplibs"
alpar@9 8067
alpar@9 8068 if test -n "$convenience"; then
alpar@9 8069 if test -n "$whole_archive_flag_spec" &&
alpar@9 8070 test "$compiler_needs_object" = yes &&
alpar@9 8071 test -z "$libobjs"; then
alpar@9 8072 # extract the archives, so we have objects to list.
alpar@9 8073 # TODO: could optimize this to just extract one archive.
alpar@9 8074 whole_archive_flag_spec=
alpar@9 8075 fi
alpar@9 8076 if test -n "$whole_archive_flag_spec"; then
alpar@9 8077 save_libobjs=$libobjs
alpar@9 8078 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
alpar@9 8079 test "X$libobjs" = "X " && libobjs=
alpar@9 8080 else
alpar@9 8081 gentop="$output_objdir/${outputname}x"
alpar@9 8082 generated="$generated $gentop"
alpar@9 8083
alpar@9 8084 func_extract_archives $gentop $convenience
alpar@9 8085 libobjs="$libobjs $func_extract_archives_result"
alpar@9 8086 test "X$libobjs" = "X " && libobjs=
alpar@9 8087 fi
alpar@9 8088 fi
alpar@9 8089
alpar@9 8090 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
alpar@9 8091 eval flag=\"$thread_safe_flag_spec\"
alpar@9 8092 linker_flags="$linker_flags $flag"
alpar@9 8093 fi
alpar@9 8094
alpar@9 8095 # Make a backup of the uninstalled library when relinking
alpar@9 8096 if test "$mode" = relink; then
alpar@9 8097 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
alpar@9 8098 fi
alpar@9 8099
alpar@9 8100 # Do each of the archive commands.
alpar@9 8101 if test "$module" = yes && test -n "$module_cmds" ; then
alpar@9 8102 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
alpar@9 8103 eval test_cmds=\"$module_expsym_cmds\"
alpar@9 8104 cmds=$module_expsym_cmds
alpar@9 8105 else
alpar@9 8106 eval test_cmds=\"$module_cmds\"
alpar@9 8107 cmds=$module_cmds
alpar@9 8108 fi
alpar@9 8109 else
alpar@9 8110 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
alpar@9 8111 eval test_cmds=\"$archive_expsym_cmds\"
alpar@9 8112 cmds=$archive_expsym_cmds
alpar@9 8113 else
alpar@9 8114 eval test_cmds=\"$archive_cmds\"
alpar@9 8115 cmds=$archive_cmds
alpar@9 8116 fi
alpar@9 8117 fi
alpar@9 8118
alpar@9 8119 if test "X$skipped_export" != "X:" &&
alpar@9 8120 func_len " $test_cmds" &&
alpar@9 8121 len=$func_len_result &&
alpar@9 8122 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
alpar@9 8123 :
alpar@9 8124 else
alpar@9 8125 # The command line is too long to link in one step, link piecewise
alpar@9 8126 # or, if using GNU ld and skipped_export is not :, use a linker
alpar@9 8127 # script.
alpar@9 8128
alpar@9 8129 # Save the value of $output and $libobjs because we want to
alpar@9 8130 # use them later. If we have whole_archive_flag_spec, we
alpar@9 8131 # want to use save_libobjs as it was before
alpar@9 8132 # whole_archive_flag_spec was expanded, because we can't
alpar@9 8133 # assume the linker understands whole_archive_flag_spec.
alpar@9 8134 # This may have to be revisited, in case too many
alpar@9 8135 # convenience libraries get linked in and end up exceeding
alpar@9 8136 # the spec.
alpar@9 8137 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
alpar@9 8138 save_libobjs=$libobjs
alpar@9 8139 fi
alpar@9 8140 save_output=$output
alpar@9 8141 func_basename "$output"
alpar@9 8142 output_la=$func_basename_result
alpar@9 8143
alpar@9 8144 # Clear the reloadable object creation command queue and
alpar@9 8145 # initialize k to one.
alpar@9 8146 test_cmds=
alpar@9 8147 concat_cmds=
alpar@9 8148 objlist=
alpar@9 8149 last_robj=
alpar@9 8150 k=1
alpar@9 8151
alpar@9 8152 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
alpar@9 8153 output=${output_objdir}/${output_la}.lnkscript
alpar@9 8154 func_verbose "creating GNU ld script: $output"
alpar@9 8155 echo 'INPUT (' > $output
alpar@9 8156 for obj in $save_libobjs
alpar@9 8157 do
alpar@9 8158 $ECHO "$obj" >> $output
alpar@9 8159 done
alpar@9 8160 echo ')' >> $output
alpar@9 8161 delfiles="$delfiles $output"
alpar@9 8162 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
alpar@9 8163 output=${output_objdir}/${output_la}.lnk
alpar@9 8164 func_verbose "creating linker input file list: $output"
alpar@9 8165 : > $output
alpar@9 8166 set x $save_libobjs
alpar@9 8167 shift
alpar@9 8168 firstobj=
alpar@9 8169 if test "$compiler_needs_object" = yes; then
alpar@9 8170 firstobj="$1 "
alpar@9 8171 shift
alpar@9 8172 fi
alpar@9 8173 for obj
alpar@9 8174 do
alpar@9 8175 $ECHO "$obj" >> $output
alpar@9 8176 done
alpar@9 8177 delfiles="$delfiles $output"
alpar@9 8178 output=$firstobj\"$file_list_spec$output\"
alpar@9 8179 else
alpar@9 8180 if test -n "$save_libobjs"; then
alpar@9 8181 func_verbose "creating reloadable object files..."
alpar@9 8182 output=$output_objdir/$output_la-${k}.$objext
alpar@9 8183 eval test_cmds=\"$reload_cmds\"
alpar@9 8184 func_len " $test_cmds"
alpar@9 8185 len0=$func_len_result
alpar@9 8186 len=$len0
alpar@9 8187
alpar@9 8188 # Loop over the list of objects to be linked.
alpar@9 8189 for obj in $save_libobjs
alpar@9 8190 do
alpar@9 8191 func_len " $obj"
alpar@9 8192 func_arith $len + $func_len_result
alpar@9 8193 len=$func_arith_result
alpar@9 8194 if test "X$objlist" = X ||
alpar@9 8195 test "$len" -lt "$max_cmd_len"; then
alpar@9 8196 func_append objlist " $obj"
alpar@9 8197 else
alpar@9 8198 # The command $test_cmds is almost too long, add a
alpar@9 8199 # command to the queue.
alpar@9 8200 if test "$k" -eq 1 ; then
alpar@9 8201 # The first file doesn't have a previous command to add.
alpar@9 8202 reload_objs=$objlist
alpar@9 8203 eval concat_cmds=\"$reload_cmds\"
alpar@9 8204 else
alpar@9 8205 # All subsequent reloadable object files will link in
alpar@9 8206 # the last one created.
alpar@9 8207 reload_objs="$objlist $last_robj"
alpar@9 8208 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
alpar@9 8209 fi
alpar@9 8210 last_robj=$output_objdir/$output_la-${k}.$objext
alpar@9 8211 func_arith $k + 1
alpar@9 8212 k=$func_arith_result
alpar@9 8213 output=$output_objdir/$output_la-${k}.$objext
alpar@9 8214 objlist=" $obj"
alpar@9 8215 func_len " $last_robj"
alpar@9 8216 func_arith $len0 + $func_len_result
alpar@9 8217 len=$func_arith_result
alpar@9 8218 fi
alpar@9 8219 done
alpar@9 8220 # Handle the remaining objects by creating one last
alpar@9 8221 # reloadable object file. All subsequent reloadable object
alpar@9 8222 # files will link in the last one created.
alpar@9 8223 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
alpar@9 8224 reload_objs="$objlist $last_robj"
alpar@9 8225 eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
alpar@9 8226 if test -n "$last_robj"; then
alpar@9 8227 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
alpar@9 8228 fi
alpar@9 8229 delfiles="$delfiles $output"
alpar@9 8230
alpar@9 8231 else
alpar@9 8232 output=
alpar@9 8233 fi
alpar@9 8234
alpar@9 8235 if ${skipped_export-false}; then
alpar@9 8236 func_verbose "generating symbol list for \`$libname.la'"
alpar@9 8237 export_symbols="$output_objdir/$libname.exp"
alpar@9 8238 $opt_dry_run || $RM $export_symbols
alpar@9 8239 libobjs=$output
alpar@9 8240 # Append the command to create the export file.
alpar@9 8241 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
alpar@9 8242 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
alpar@9 8243 if test -n "$last_robj"; then
alpar@9 8244 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
alpar@9 8245 fi
alpar@9 8246 fi
alpar@9 8247
alpar@9 8248 test -n "$save_libobjs" &&
alpar@9 8249 func_verbose "creating a temporary reloadable object file: $output"
alpar@9 8250
alpar@9 8251 # Loop through the commands generated above and execute them.
alpar@9 8252 save_ifs="$IFS"; IFS='~'
alpar@9 8253 for cmd in $concat_cmds; do
alpar@9 8254 IFS="$save_ifs"
alpar@9 8255 $opt_silent || {
alpar@9 8256 func_quote_for_expand "$cmd"
alpar@9 8257 eval "func_echo $func_quote_for_expand_result"
alpar@9 8258 }
alpar@9 8259 $opt_dry_run || eval "$cmd" || {
alpar@9 8260 lt_exit=$?
alpar@9 8261
alpar@9 8262 # Restore the uninstalled library and exit
alpar@9 8263 if test "$mode" = relink; then
alpar@9 8264 ( cd "$output_objdir" && \
alpar@9 8265 $RM "${realname}T" && \
alpar@9 8266 $MV "${realname}U" "$realname" )
alpar@9 8267 fi
alpar@9 8268
alpar@9 8269 exit $lt_exit
alpar@9 8270 }
alpar@9 8271 done
alpar@9 8272 IFS="$save_ifs"
alpar@9 8273
alpar@9 8274 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
alpar@9 8275 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
alpar@9 8276 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
alpar@9 8277 fi
alpar@9 8278 fi
alpar@9 8279
alpar@9 8280 if ${skipped_export-false}; then
alpar@9 8281 if test -n "$export_symbols" && test -n "$include_expsyms"; then
alpar@9 8282 tmp_export_symbols="$export_symbols"
alpar@9 8283 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
alpar@9 8284 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
alpar@9 8285 fi
alpar@9 8286
alpar@9 8287 if test -n "$orig_export_symbols"; then
alpar@9 8288 # The given exports_symbols file has to be filtered, so filter it.
alpar@9 8289 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
alpar@9 8290 # FIXME: $output_objdir/$libname.filter potentially contains lots of
alpar@9 8291 # 's' commands which not all seds can handle. GNU sed should be fine
alpar@9 8292 # though. Also, the filter scales superlinearly with the number of
alpar@9 8293 # global variables. join(1) would be nice here, but unfortunately
alpar@9 8294 # isn't a blessed tool.
alpar@9 8295 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
alpar@9 8296 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
alpar@9 8297 export_symbols=$output_objdir/$libname.def
alpar@9 8298 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
alpar@9 8299 fi
alpar@9 8300 fi
alpar@9 8301
alpar@9 8302 libobjs=$output
alpar@9 8303 # Restore the value of output.
alpar@9 8304 output=$save_output
alpar@9 8305
alpar@9 8306 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
alpar@9 8307 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
alpar@9 8308 test "X$libobjs" = "X " && libobjs=
alpar@9 8309 fi
alpar@9 8310 # Expand the library linking commands again to reset the
alpar@9 8311 # value of $libobjs for piecewise linking.
alpar@9 8312
alpar@9 8313 # Do each of the archive commands.
alpar@9 8314 if test "$module" = yes && test -n "$module_cmds" ; then
alpar@9 8315 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
alpar@9 8316 cmds=$module_expsym_cmds
alpar@9 8317 else
alpar@9 8318 cmds=$module_cmds
alpar@9 8319 fi
alpar@9 8320 else
alpar@9 8321 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
alpar@9 8322 cmds=$archive_expsym_cmds
alpar@9 8323 else
alpar@9 8324 cmds=$archive_cmds
alpar@9 8325 fi
alpar@9 8326 fi
alpar@9 8327 fi
alpar@9 8328
alpar@9 8329 if test -n "$delfiles"; then
alpar@9 8330 # Append the command to remove temporary files to $cmds.
alpar@9 8331 eval cmds=\"\$cmds~\$RM $delfiles\"
alpar@9 8332 fi
alpar@9 8333
alpar@9 8334 # Add any objects from preloaded convenience libraries
alpar@9 8335 if test -n "$dlprefiles"; then
alpar@9 8336 gentop="$output_objdir/${outputname}x"
alpar@9 8337 generated="$generated $gentop"
alpar@9 8338
alpar@9 8339 func_extract_archives $gentop $dlprefiles
alpar@9 8340 libobjs="$libobjs $func_extract_archives_result"
alpar@9 8341 test "X$libobjs" = "X " && libobjs=
alpar@9 8342 fi
alpar@9 8343
alpar@9 8344 save_ifs="$IFS"; IFS='~'
alpar@9 8345 for cmd in $cmds; do
alpar@9 8346 IFS="$save_ifs"
alpar@9 8347 eval cmd=\"$cmd\"
alpar@9 8348 $opt_silent || {
alpar@9 8349 func_quote_for_expand "$cmd"
alpar@9 8350 eval "func_echo $func_quote_for_expand_result"
alpar@9 8351 }
alpar@9 8352 $opt_dry_run || eval "$cmd" || {
alpar@9 8353 lt_exit=$?
alpar@9 8354
alpar@9 8355 # Restore the uninstalled library and exit
alpar@9 8356 if test "$mode" = relink; then
alpar@9 8357 ( cd "$output_objdir" && \
alpar@9 8358 $RM "${realname}T" && \
alpar@9 8359 $MV "${realname}U" "$realname" )
alpar@9 8360 fi
alpar@9 8361
alpar@9 8362 exit $lt_exit
alpar@9 8363 }
alpar@9 8364 done
alpar@9 8365 IFS="$save_ifs"
alpar@9 8366
alpar@9 8367 # Restore the uninstalled library and exit
alpar@9 8368 if test "$mode" = relink; then
alpar@9 8369 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
alpar@9 8370
alpar@9 8371 if test -n "$convenience"; then
alpar@9 8372 if test -z "$whole_archive_flag_spec"; then
alpar@9 8373 func_show_eval '${RM}r "$gentop"'
alpar@9 8374 fi
alpar@9 8375 fi
alpar@9 8376
alpar@9 8377 exit $EXIT_SUCCESS
alpar@9 8378 fi
alpar@9 8379
alpar@9 8380 # Create links to the real library.
alpar@9 8381 for linkname in $linknames; do
alpar@9 8382 if test "$realname" != "$linkname"; then
alpar@9 8383 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
alpar@9 8384 fi
alpar@9 8385 done
alpar@9 8386
alpar@9 8387 # If -module or -export-dynamic was specified, set the dlname.
alpar@9 8388 if test "$module" = yes || test "$export_dynamic" = yes; then
alpar@9 8389 # On all known operating systems, these are identical.
alpar@9 8390 dlname="$soname"
alpar@9 8391 fi
alpar@9 8392 fi
alpar@9 8393 ;;
alpar@9 8394
alpar@9 8395 obj)
alpar@9 8396 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
alpar@9 8397 func_warning "\`-dlopen' is ignored for objects"
alpar@9 8398 fi
alpar@9 8399
alpar@9 8400 case " $deplibs" in
alpar@9 8401 *\ -l* | *\ -L*)
alpar@9 8402 func_warning "\`-l' and \`-L' are ignored for objects" ;;
alpar@9 8403 esac
alpar@9 8404
alpar@9 8405 test -n "$rpath" && \
alpar@9 8406 func_warning "\`-rpath' is ignored for objects"
alpar@9 8407
alpar@9 8408 test -n "$xrpath" && \
alpar@9 8409 func_warning "\`-R' is ignored for objects"
alpar@9 8410
alpar@9 8411 test -n "$vinfo" && \
alpar@9 8412 func_warning "\`-version-info' is ignored for objects"
alpar@9 8413
alpar@9 8414 test -n "$release" && \
alpar@9 8415 func_warning "\`-release' is ignored for objects"
alpar@9 8416
alpar@9 8417 case $output in
alpar@9 8418 *.lo)
alpar@9 8419 test -n "$objs$old_deplibs" && \
alpar@9 8420 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
alpar@9 8421
alpar@9 8422 libobj=$output
alpar@9 8423 func_lo2o "$libobj"
alpar@9 8424 obj=$func_lo2o_result
alpar@9 8425 ;;
alpar@9 8426 *)
alpar@9 8427 libobj=
alpar@9 8428 obj="$output"
alpar@9 8429 ;;
alpar@9 8430 esac
alpar@9 8431
alpar@9 8432 # Delete the old objects.
alpar@9 8433 $opt_dry_run || $RM $obj $libobj
alpar@9 8434
alpar@9 8435 # Objects from convenience libraries. This assumes
alpar@9 8436 # single-version convenience libraries. Whenever we create
alpar@9 8437 # different ones for PIC/non-PIC, this we'll have to duplicate
alpar@9 8438 # the extraction.
alpar@9 8439 reload_conv_objs=
alpar@9 8440 gentop=
alpar@9 8441 # reload_cmds runs $LD directly, so let us get rid of
alpar@9 8442 # -Wl from whole_archive_flag_spec and hope we can get by with
alpar@9 8443 # turning comma into space..
alpar@9 8444 wl=
alpar@9 8445
alpar@9 8446 if test -n "$convenience"; then
alpar@9 8447 if test -n "$whole_archive_flag_spec"; then
alpar@9 8448 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
alpar@9 8449 reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
alpar@9 8450 else
alpar@9 8451 gentop="$output_objdir/${obj}x"
alpar@9 8452 generated="$generated $gentop"
alpar@9 8453
alpar@9 8454 func_extract_archives $gentop $convenience
alpar@9 8455 reload_conv_objs="$reload_objs $func_extract_archives_result"
alpar@9 8456 fi
alpar@9 8457 fi
alpar@9 8458
alpar@9 8459 # Create the old-style object.
alpar@9 8460 reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
alpar@9 8461
alpar@9 8462 output="$obj"
alpar@9 8463 func_execute_cmds "$reload_cmds" 'exit $?'
alpar@9 8464
alpar@9 8465 # Exit if we aren't doing a library object file.
alpar@9 8466 if test -z "$libobj"; then
alpar@9 8467 if test -n "$gentop"; then
alpar@9 8468 func_show_eval '${RM}r "$gentop"'
alpar@9 8469 fi
alpar@9 8470
alpar@9 8471 exit $EXIT_SUCCESS
alpar@9 8472 fi
alpar@9 8473
alpar@9 8474 if test "$build_libtool_libs" != yes; then
alpar@9 8475 if test -n "$gentop"; then
alpar@9 8476 func_show_eval '${RM}r "$gentop"'
alpar@9 8477 fi
alpar@9 8478
alpar@9 8479 # Create an invalid libtool object if no PIC, so that we don't
alpar@9 8480 # accidentally link it into a program.
alpar@9 8481 # $show "echo timestamp > $libobj"
alpar@9 8482 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
alpar@9 8483 exit $EXIT_SUCCESS
alpar@9 8484 fi
alpar@9 8485
alpar@9 8486 if test -n "$pic_flag" || test "$pic_mode" != default; then
alpar@9 8487 # Only do commands if we really have different PIC objects.
alpar@9 8488 reload_objs="$libobjs $reload_conv_objs"
alpar@9 8489 output="$libobj"
alpar@9 8490 func_execute_cmds "$reload_cmds" 'exit $?'
alpar@9 8491 fi
alpar@9 8492
alpar@9 8493 if test -n "$gentop"; then
alpar@9 8494 func_show_eval '${RM}r "$gentop"'
alpar@9 8495 fi
alpar@9 8496
alpar@9 8497 exit $EXIT_SUCCESS
alpar@9 8498 ;;
alpar@9 8499
alpar@9 8500 prog)
alpar@9 8501 case $host in
alpar@9 8502 *cygwin*) func_stripname '' '.exe' "$output"
alpar@9 8503 output=$func_stripname_result.exe;;
alpar@9 8504 esac
alpar@9 8505 test -n "$vinfo" && \
alpar@9 8506 func_warning "\`-version-info' is ignored for programs"
alpar@9 8507
alpar@9 8508 test -n "$release" && \
alpar@9 8509 func_warning "\`-release' is ignored for programs"
alpar@9 8510
alpar@9 8511 test "$preload" = yes \
alpar@9 8512 && test "$dlopen_support" = unknown \
alpar@9 8513 && test "$dlopen_self" = unknown \
alpar@9 8514 && test "$dlopen_self_static" = unknown && \
alpar@9 8515 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
alpar@9 8516
alpar@9 8517 case $host in
alpar@9 8518 *-*-rhapsody* | *-*-darwin1.[012])
alpar@9 8519 # On Rhapsody replace the C library is the System framework
alpar@9 8520 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
alpar@9 8521 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
alpar@9 8522 ;;
alpar@9 8523 esac
alpar@9 8524
alpar@9 8525 case $host in
alpar@9 8526 *-*-darwin*)
alpar@9 8527 # Don't allow lazy linking, it breaks C++ global constructors
alpar@9 8528 # But is supposedly fixed on 10.4 or later (yay!).
alpar@9 8529 if test "$tagname" = CXX ; then
alpar@9 8530 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
alpar@9 8531 10.[0123])
alpar@9 8532 compile_command="$compile_command ${wl}-bind_at_load"
alpar@9 8533 finalize_command="$finalize_command ${wl}-bind_at_load"
alpar@9 8534 ;;
alpar@9 8535 esac
alpar@9 8536 fi
alpar@9 8537 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
alpar@9 8538 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
alpar@9 8539 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
alpar@9 8540 ;;
alpar@9 8541 esac
alpar@9 8542
alpar@9 8543
alpar@9 8544 # move library search paths that coincide with paths to not yet
alpar@9 8545 # installed libraries to the beginning of the library search list
alpar@9 8546 new_libs=
alpar@9 8547 for path in $notinst_path; do
alpar@9 8548 case " $new_libs " in
alpar@9 8549 *" -L$path/$objdir "*) ;;
alpar@9 8550 *)
alpar@9 8551 case " $compile_deplibs " in
alpar@9 8552 *" -L$path/$objdir "*)
alpar@9 8553 new_libs="$new_libs -L$path/$objdir" ;;
alpar@9 8554 esac
alpar@9 8555 ;;
alpar@9 8556 esac
alpar@9 8557 done
alpar@9 8558 for deplib in $compile_deplibs; do
alpar@9 8559 case $deplib in
alpar@9 8560 -L*)
alpar@9 8561 case " $new_libs " in
alpar@9 8562 *" $deplib "*) ;;
alpar@9 8563 *) new_libs="$new_libs $deplib" ;;
alpar@9 8564 esac
alpar@9 8565 ;;
alpar@9 8566 *) new_libs="$new_libs $deplib" ;;
alpar@9 8567 esac
alpar@9 8568 done
alpar@9 8569 compile_deplibs="$new_libs"
alpar@9 8570
alpar@9 8571
alpar@9 8572 compile_command="$compile_command $compile_deplibs"
alpar@9 8573 finalize_command="$finalize_command $finalize_deplibs"
alpar@9 8574
alpar@9 8575 if test -n "$rpath$xrpath"; then
alpar@9 8576 # If the user specified any rpath flags, then add them.
alpar@9 8577 for libdir in $rpath $xrpath; do
alpar@9 8578 # This is the magic to use -rpath.
alpar@9 8579 case "$finalize_rpath " in
alpar@9 8580 *" $libdir "*) ;;
alpar@9 8581 *) finalize_rpath="$finalize_rpath $libdir" ;;
alpar@9 8582 esac
alpar@9 8583 done
alpar@9 8584 fi
alpar@9 8585
alpar@9 8586 # Now hardcode the library paths
alpar@9 8587 rpath=
alpar@9 8588 hardcode_libdirs=
alpar@9 8589 for libdir in $compile_rpath $finalize_rpath; do
alpar@9 8590 if test -n "$hardcode_libdir_flag_spec"; then
alpar@9 8591 if test -n "$hardcode_libdir_separator"; then
alpar@9 8592 if test -z "$hardcode_libdirs"; then
alpar@9 8593 hardcode_libdirs="$libdir"
alpar@9 8594 else
alpar@9 8595 # Just accumulate the unique libdirs.
alpar@9 8596 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
alpar@9 8597 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
alpar@9 8598 ;;
alpar@9 8599 *)
alpar@9 8600 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
alpar@9 8601 ;;
alpar@9 8602 esac
alpar@9 8603 fi
alpar@9 8604 else
alpar@9 8605 eval flag=\"$hardcode_libdir_flag_spec\"
alpar@9 8606 rpath="$rpath $flag"
alpar@9 8607 fi
alpar@9 8608 elif test -n "$runpath_var"; then
alpar@9 8609 case "$perm_rpath " in
alpar@9 8610 *" $libdir "*) ;;
alpar@9 8611 *) perm_rpath="$perm_rpath $libdir" ;;
alpar@9 8612 esac
alpar@9 8613 fi
alpar@9 8614 case $host in
alpar@9 8615 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
alpar@9 8616 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
alpar@9 8617 case :$dllsearchpath: in
alpar@9 8618 *":$libdir:"*) ;;
alpar@9 8619 ::) dllsearchpath=$libdir;;
alpar@9 8620 *) dllsearchpath="$dllsearchpath:$libdir";;
alpar@9 8621 esac
alpar@9 8622 case :$dllsearchpath: in
alpar@9 8623 *":$testbindir:"*) ;;
alpar@9 8624 ::) dllsearchpath=$testbindir;;
alpar@9 8625 *) dllsearchpath="$dllsearchpath:$testbindir";;
alpar@9 8626 esac
alpar@9 8627 ;;
alpar@9 8628 esac
alpar@9 8629 done
alpar@9 8630 # Substitute the hardcoded libdirs into the rpath.
alpar@9 8631 if test -n "$hardcode_libdir_separator" &&
alpar@9 8632 test -n "$hardcode_libdirs"; then
alpar@9 8633 libdir="$hardcode_libdirs"
alpar@9 8634 eval rpath=\" $hardcode_libdir_flag_spec\"
alpar@9 8635 fi
alpar@9 8636 compile_rpath="$rpath"
alpar@9 8637
alpar@9 8638 rpath=
alpar@9 8639 hardcode_libdirs=
alpar@9 8640 for libdir in $finalize_rpath; do
alpar@9 8641 if test -n "$hardcode_libdir_flag_spec"; then
alpar@9 8642 if test -n "$hardcode_libdir_separator"; then
alpar@9 8643 if test -z "$hardcode_libdirs"; then
alpar@9 8644 hardcode_libdirs="$libdir"
alpar@9 8645 else
alpar@9 8646 # Just accumulate the unique libdirs.
alpar@9 8647 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
alpar@9 8648 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
alpar@9 8649 ;;
alpar@9 8650 *)
alpar@9 8651 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
alpar@9 8652 ;;
alpar@9 8653 esac
alpar@9 8654 fi
alpar@9 8655 else
alpar@9 8656 eval flag=\"$hardcode_libdir_flag_spec\"
alpar@9 8657 rpath="$rpath $flag"
alpar@9 8658 fi
alpar@9 8659 elif test -n "$runpath_var"; then
alpar@9 8660 case "$finalize_perm_rpath " in
alpar@9 8661 *" $libdir "*) ;;
alpar@9 8662 *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
alpar@9 8663 esac
alpar@9 8664 fi
alpar@9 8665 done
alpar@9 8666 # Substitute the hardcoded libdirs into the rpath.
alpar@9 8667 if test -n "$hardcode_libdir_separator" &&
alpar@9 8668 test -n "$hardcode_libdirs"; then
alpar@9 8669 libdir="$hardcode_libdirs"
alpar@9 8670 eval rpath=\" $hardcode_libdir_flag_spec\"
alpar@9 8671 fi
alpar@9 8672 finalize_rpath="$rpath"
alpar@9 8673
alpar@9 8674 if test -n "$libobjs" && test "$build_old_libs" = yes; then
alpar@9 8675 # Transform all the library objects into standard objects.
alpar@9 8676 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
alpar@9 8677 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
alpar@9 8678 fi
alpar@9 8679
alpar@9 8680 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
alpar@9 8681
alpar@9 8682 # template prelinking step
alpar@9 8683 if test -n "$prelink_cmds"; then
alpar@9 8684 func_execute_cmds "$prelink_cmds" 'exit $?'
alpar@9 8685 fi
alpar@9 8686
alpar@9 8687 wrappers_required=yes
alpar@9 8688 case $host in
alpar@9 8689 *cegcc* | *mingw32ce*)
alpar@9 8690 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
alpar@9 8691 wrappers_required=no
alpar@9 8692 ;;
alpar@9 8693 *cygwin* | *mingw* )
alpar@9 8694 if test "$build_libtool_libs" != yes; then
alpar@9 8695 wrappers_required=no
alpar@9 8696 fi
alpar@9 8697 ;;
alpar@9 8698 *)
alpar@9 8699 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
alpar@9 8700 wrappers_required=no
alpar@9 8701 fi
alpar@9 8702 ;;
alpar@9 8703 esac
alpar@9 8704 if test "$wrappers_required" = no; then
alpar@9 8705 # Replace the output file specification.
alpar@9 8706 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
alpar@9 8707 link_command="$compile_command$compile_rpath"
alpar@9 8708
alpar@9 8709 # We have no uninstalled library dependencies, so finalize right now.
alpar@9 8710 exit_status=0
alpar@9 8711 func_show_eval "$link_command" 'exit_status=$?'
alpar@9 8712
alpar@9 8713 # Delete the generated files.
alpar@9 8714 if test -f "$output_objdir/${outputname}S.${objext}"; then
alpar@9 8715 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
alpar@9 8716 fi
alpar@9 8717
alpar@9 8718 exit $exit_status
alpar@9 8719 fi
alpar@9 8720
alpar@9 8721 if test -n "$compile_shlibpath$finalize_shlibpath"; then
alpar@9 8722 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
alpar@9 8723 fi
alpar@9 8724 if test -n "$finalize_shlibpath"; then
alpar@9 8725 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
alpar@9 8726 fi
alpar@9 8727
alpar@9 8728 compile_var=
alpar@9 8729 finalize_var=
alpar@9 8730 if test -n "$runpath_var"; then
alpar@9 8731 if test -n "$perm_rpath"; then
alpar@9 8732 # We should set the runpath_var.
alpar@9 8733 rpath=
alpar@9 8734 for dir in $perm_rpath; do
alpar@9 8735 rpath="$rpath$dir:"
alpar@9 8736 done
alpar@9 8737 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
alpar@9 8738 fi
alpar@9 8739 if test -n "$finalize_perm_rpath"; then
alpar@9 8740 # We should set the runpath_var.
alpar@9 8741 rpath=
alpar@9 8742 for dir in $finalize_perm_rpath; do
alpar@9 8743 rpath="$rpath$dir:"
alpar@9 8744 done
alpar@9 8745 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
alpar@9 8746 fi
alpar@9 8747 fi
alpar@9 8748
alpar@9 8749 if test "$no_install" = yes; then
alpar@9 8750 # We don't need to create a wrapper script.
alpar@9 8751 link_command="$compile_var$compile_command$compile_rpath"
alpar@9 8752 # Replace the output file specification.
alpar@9 8753 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
alpar@9 8754 # Delete the old output file.
alpar@9 8755 $opt_dry_run || $RM $output
alpar@9 8756 # Link the executable and exit
alpar@9 8757 func_show_eval "$link_command" 'exit $?'
alpar@9 8758 exit $EXIT_SUCCESS
alpar@9 8759 fi
alpar@9 8760
alpar@9 8761 if test "$hardcode_action" = relink; then
alpar@9 8762 # Fast installation is not supported
alpar@9 8763 link_command="$compile_var$compile_command$compile_rpath"
alpar@9 8764 relink_command="$finalize_var$finalize_command$finalize_rpath"
alpar@9 8765
alpar@9 8766 func_warning "this platform does not like uninstalled shared libraries"
alpar@9 8767 func_warning "\`$output' will be relinked during installation"
alpar@9 8768 else
alpar@9 8769 if test "$fast_install" != no; then
alpar@9 8770 link_command="$finalize_var$compile_command$finalize_rpath"
alpar@9 8771 if test "$fast_install" = yes; then
alpar@9 8772 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
alpar@9 8773 else
alpar@9 8774 # fast_install is set to needless
alpar@9 8775 relink_command=
alpar@9 8776 fi
alpar@9 8777 else
alpar@9 8778 link_command="$compile_var$compile_command$compile_rpath"
alpar@9 8779 relink_command="$finalize_var$finalize_command$finalize_rpath"
alpar@9 8780 fi
alpar@9 8781 fi
alpar@9 8782
alpar@9 8783 # Replace the output file specification.
alpar@9 8784 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
alpar@9 8785
alpar@9 8786 # Delete the old output files.
alpar@9 8787 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
alpar@9 8788
alpar@9 8789 func_show_eval "$link_command" 'exit $?'
alpar@9 8790
alpar@9 8791 # Now create the wrapper script.
alpar@9 8792 func_verbose "creating $output"
alpar@9 8793
alpar@9 8794 # Quote the relink command for shipping.
alpar@9 8795 if test -n "$relink_command"; then
alpar@9 8796 # Preserve any variables that may affect compiler behavior
alpar@9 8797 for var in $variables_saved_for_relink; do
alpar@9 8798 if eval test -z \"\${$var+set}\"; then
alpar@9 8799 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
alpar@9 8800 elif eval var_value=\$$var; test -z "$var_value"; then
alpar@9 8801 relink_command="$var=; export $var; $relink_command"
alpar@9 8802 else
alpar@9 8803 func_quote_for_eval "$var_value"
alpar@9 8804 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
alpar@9 8805 fi
alpar@9 8806 done
alpar@9 8807 relink_command="(cd `pwd`; $relink_command)"
alpar@9 8808 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
alpar@9 8809 fi
alpar@9 8810
alpar@9 8811 # Only actually do things if not in dry run mode.
alpar@9 8812 $opt_dry_run || {
alpar@9 8813 # win32 will think the script is a binary if it has
alpar@9 8814 # a .exe suffix, so we strip it off here.
alpar@9 8815 case $output in
alpar@9 8816 *.exe) func_stripname '' '.exe' "$output"
alpar@9 8817 output=$func_stripname_result ;;
alpar@9 8818 esac
alpar@9 8819 # test for cygwin because mv fails w/o .exe extensions
alpar@9 8820 case $host in
alpar@9 8821 *cygwin*)
alpar@9 8822 exeext=.exe
alpar@9 8823 func_stripname '' '.exe' "$outputname"
alpar@9 8824 outputname=$func_stripname_result ;;
alpar@9 8825 *) exeext= ;;
alpar@9 8826 esac
alpar@9 8827 case $host in
alpar@9 8828 *cygwin* | *mingw* )
alpar@9 8829 func_dirname_and_basename "$output" "" "."
alpar@9 8830 output_name=$func_basename_result
alpar@9 8831 output_path=$func_dirname_result
alpar@9 8832 cwrappersource="$output_path/$objdir/lt-$output_name.c"
alpar@9 8833 cwrapper="$output_path/$output_name.exe"
alpar@9 8834 $RM $cwrappersource $cwrapper
alpar@9 8835 trap "$RM $cwrappersource $cwrapper $cwrapper.manifest; exit $EXIT_FAILURE" 1 2 15
alpar@9 8836
alpar@9 8837 func_emit_cwrapperexe_src > $cwrappersource
alpar@9 8838
alpar@9 8839 # The wrapper executable is built using the $host compiler,
alpar@9 8840 # because it contains $host paths and files. If cross-
alpar@9 8841 # compiling, it, like the target executable, must be
alpar@9 8842 # executed on the $host or under an emulation environment.
alpar@9 8843 $opt_dry_run || {
alpar@9 8844 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
alpar@9 8845 $STRIP $cwrapper
alpar@9 8846 }
alpar@9 8847
alpar@9 8848 # Now, create the wrapper script for func_source use:
alpar@9 8849 func_ltwrapper_scriptname $cwrapper
alpar@9 8850 $RM $func_ltwrapper_scriptname_result
alpar@9 8851 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
alpar@9 8852 $opt_dry_run || {
alpar@9 8853 # note: this script will not be executed, so do not chmod.
alpar@9 8854 if test "x$build" = "x$host" ; then
alpar@9 8855 # Create the UAC manifests first if necessary (but the
alpar@9 8856 # manifest files must have executable permission regardless).
alpar@9 8857 case $output_name in
alpar@9 8858 *instal*|*patch*|*setup*|*update*)
alpar@9 8859 func_emit_exe_manifest > $cwrapper.manifest
alpar@9 8860 func_emit_exe_manifest > $output_path/$objdir/$output_name.exe.manifest
alpar@9 8861 chmod +x $cwrapper.manifest
alpar@9 8862 chmod +x $output_path/$objdir/$output_name.exe.manifest
alpar@9 8863 ;;
alpar@9 8864 esac
alpar@9 8865 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
alpar@9 8866 else
alpar@9 8867 func_emit_wrapper no > $func_ltwrapper_scriptname_result
alpar@9 8868 fi
alpar@9 8869 }
alpar@9 8870 ;;
alpar@9 8871 * )
alpar@9 8872 $RM $output
alpar@9 8873 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
alpar@9 8874
alpar@9 8875 func_emit_wrapper no > $output
alpar@9 8876 chmod +x $output
alpar@9 8877 ;;
alpar@9 8878 esac
alpar@9 8879 }
alpar@9 8880 exit $EXIT_SUCCESS
alpar@9 8881 ;;
alpar@9 8882 esac
alpar@9 8883
alpar@9 8884 # See if we need to build an old-fashioned archive.
alpar@9 8885 for oldlib in $oldlibs; do
alpar@9 8886
alpar@9 8887 if test "$build_libtool_libs" = convenience; then
alpar@9 8888 oldobjs="$libobjs_save $symfileobj"
alpar@9 8889 addlibs="$convenience"
alpar@9 8890 build_libtool_libs=no
alpar@9 8891 else
alpar@9 8892 if test "$build_libtool_libs" = module; then
alpar@9 8893 oldobjs="$libobjs_save"
alpar@9 8894 build_libtool_libs=no
alpar@9 8895 else
alpar@9 8896 oldobjs="$old_deplibs $non_pic_objects"
alpar@9 8897 if test "$preload" = yes && test -f "$symfileobj"; then
alpar@9 8898 oldobjs="$oldobjs $symfileobj"
alpar@9 8899 fi
alpar@9 8900 fi
alpar@9 8901 addlibs="$old_convenience"
alpar@9 8902 fi
alpar@9 8903
alpar@9 8904 if test -n "$addlibs"; then
alpar@9 8905 gentop="$output_objdir/${outputname}x"
alpar@9 8906 generated="$generated $gentop"
alpar@9 8907
alpar@9 8908 func_extract_archives $gentop $addlibs
alpar@9 8909 oldobjs="$oldobjs $func_extract_archives_result"
alpar@9 8910 fi
alpar@9 8911
alpar@9 8912 # Do each command in the archive commands.
alpar@9 8913 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
alpar@9 8914 cmds=$old_archive_from_new_cmds
alpar@9 8915 else
alpar@9 8916
alpar@9 8917 # Add any objects from preloaded convenience libraries
alpar@9 8918 if test -n "$dlprefiles"; then
alpar@9 8919 gentop="$output_objdir/${outputname}x"
alpar@9 8920 generated="$generated $gentop"
alpar@9 8921
alpar@9 8922 func_extract_archives $gentop $dlprefiles
alpar@9 8923 oldobjs="$oldobjs $func_extract_archives_result"
alpar@9 8924 fi
alpar@9 8925
alpar@9 8926 # POSIX demands no paths to be encoded in archives. We have
alpar@9 8927 # to avoid creating archives with duplicate basenames if we
alpar@9 8928 # might have to extract them afterwards, e.g., when creating a
alpar@9 8929 # static archive out of a convenience library, or when linking
alpar@9 8930 # the entirety of a libtool archive into another (currently
alpar@9 8931 # not supported by libtool).
alpar@9 8932 if (for obj in $oldobjs
alpar@9 8933 do
alpar@9 8934 func_basename "$obj"
alpar@9 8935 $ECHO "$func_basename_result"
alpar@9 8936 done | sort | sort -uc >/dev/null 2>&1); then
alpar@9 8937 :
alpar@9 8938 else
alpar@9 8939 echo "copying selected object files to avoid basename conflicts..."
alpar@9 8940 gentop="$output_objdir/${outputname}x"
alpar@9 8941 generated="$generated $gentop"
alpar@9 8942 func_mkdir_p "$gentop"
alpar@9 8943 save_oldobjs=$oldobjs
alpar@9 8944 oldobjs=
alpar@9 8945 counter=1
alpar@9 8946 for obj in $save_oldobjs
alpar@9 8947 do
alpar@9 8948 func_basename "$obj"
alpar@9 8949 objbase="$func_basename_result"
alpar@9 8950 case " $oldobjs " in
alpar@9 8951 " ") oldobjs=$obj ;;
alpar@9 8952 *[\ /]"$objbase "*)
alpar@9 8953 while :; do
alpar@9 8954 # Make sure we don't pick an alternate name that also
alpar@9 8955 # overlaps.
alpar@9 8956 newobj=lt$counter-$objbase
alpar@9 8957 func_arith $counter + 1
alpar@9 8958 counter=$func_arith_result
alpar@9 8959 case " $oldobjs " in
alpar@9 8960 *[\ /]"$newobj "*) ;;
alpar@9 8961 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
alpar@9 8962 esac
alpar@9 8963 done
alpar@9 8964 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
alpar@9 8965 oldobjs="$oldobjs $gentop/$newobj"
alpar@9 8966 ;;
alpar@9 8967 *) oldobjs="$oldobjs $obj" ;;
alpar@9 8968 esac
alpar@9 8969 done
alpar@9 8970 fi
alpar@9 8971 eval cmds=\"$old_archive_cmds\"
alpar@9 8972
alpar@9 8973 func_len " $cmds"
alpar@9 8974 len=$func_len_result
alpar@9 8975 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
alpar@9 8976 cmds=$old_archive_cmds
alpar@9 8977 else
alpar@9 8978 # the command line is too long to link in one step, link in parts
alpar@9 8979 func_verbose "using piecewise archive linking..."
alpar@9 8980 save_RANLIB=$RANLIB
alpar@9 8981 RANLIB=:
alpar@9 8982 objlist=
alpar@9 8983 concat_cmds=
alpar@9 8984 save_oldobjs=$oldobjs
alpar@9 8985 oldobjs=
alpar@9 8986 # Is there a better way of finding the last object in the list?
alpar@9 8987 for obj in $save_oldobjs
alpar@9 8988 do
alpar@9 8989 last_oldobj=$obj
alpar@9 8990 done
alpar@9 8991 eval test_cmds=\"$old_archive_cmds\"
alpar@9 8992 func_len " $test_cmds"
alpar@9 8993 len0=$func_len_result
alpar@9 8994 len=$len0
alpar@9 8995 for obj in $save_oldobjs
alpar@9 8996 do
alpar@9 8997 func_len " $obj"
alpar@9 8998 func_arith $len + $func_len_result
alpar@9 8999 len=$func_arith_result
alpar@9 9000 func_append objlist " $obj"
alpar@9 9001 if test "$len" -lt "$max_cmd_len"; then
alpar@9 9002 :
alpar@9 9003 else
alpar@9 9004 # the above command should be used before it gets too long
alpar@9 9005 oldobjs=$objlist
alpar@9 9006 if test "$obj" = "$last_oldobj" ; then
alpar@9 9007 RANLIB=$save_RANLIB
alpar@9 9008 fi
alpar@9 9009 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
alpar@9 9010 eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
alpar@9 9011 objlist=
alpar@9 9012 len=$len0
alpar@9 9013 fi
alpar@9 9014 done
alpar@9 9015 RANLIB=$save_RANLIB
alpar@9 9016 oldobjs=$objlist
alpar@9 9017 if test "X$oldobjs" = "X" ; then
alpar@9 9018 eval cmds=\"\$concat_cmds\"
alpar@9 9019 else
alpar@9 9020 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
alpar@9 9021 fi
alpar@9 9022 fi
alpar@9 9023 fi
alpar@9 9024 func_execute_cmds "$cmds" 'exit $?'
alpar@9 9025 done
alpar@9 9026
alpar@9 9027 test -n "$generated" && \
alpar@9 9028 func_show_eval "${RM}r$generated"
alpar@9 9029
alpar@9 9030 # Now create the libtool archive.
alpar@9 9031 case $output in
alpar@9 9032 *.la)
alpar@9 9033 old_library=
alpar@9 9034 test "$build_old_libs" = yes && old_library="$libname.$libext"
alpar@9 9035 func_verbose "creating $output"
alpar@9 9036
alpar@9 9037 # Preserve any variables that may affect compiler behavior
alpar@9 9038 for var in $variables_saved_for_relink; do
alpar@9 9039 if eval test -z \"\${$var+set}\"; then
alpar@9 9040 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
alpar@9 9041 elif eval var_value=\$$var; test -z "$var_value"; then
alpar@9 9042 relink_command="$var=; export $var; $relink_command"
alpar@9 9043 else
alpar@9 9044 func_quote_for_eval "$var_value"
alpar@9 9045 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
alpar@9 9046 fi
alpar@9 9047 done
alpar@9 9048 # Quote the link command for shipping.
alpar@9 9049 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
alpar@9 9050 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
alpar@9 9051 if test "$hardcode_automatic" = yes ; then
alpar@9 9052 relink_command=
alpar@9 9053 fi
alpar@9 9054
alpar@9 9055 # Only create the output if not a dry run.
alpar@9 9056 $opt_dry_run || {
alpar@9 9057 for installed in no yes; do
alpar@9 9058 if test "$installed" = yes; then
alpar@9 9059 if test -z "$install_libdir"; then
alpar@9 9060 break
alpar@9 9061 fi
alpar@9 9062 output="$output_objdir/$outputname"i
alpar@9 9063 # Replace all uninstalled libtool libraries with the installed ones
alpar@9 9064 newdependency_libs=
alpar@9 9065 for deplib in $dependency_libs; do
alpar@9 9066 case $deplib in
alpar@9 9067 *.la)
alpar@9 9068 func_basename "$deplib"
alpar@9 9069 name="$func_basename_result"
alpar@9 9070 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
alpar@9 9071 test -z "$libdir" && \
alpar@9 9072 func_fatal_error "\`$deplib' is not a valid libtool archive"
alpar@9 9073 newdependency_libs="$newdependency_libs $libdir/$name"
alpar@9 9074 ;;
alpar@9 9075 *) newdependency_libs="$newdependency_libs $deplib" ;;
alpar@9 9076 esac
alpar@9 9077 done
alpar@9 9078 dependency_libs="$newdependency_libs"
alpar@9 9079 newdlfiles=
alpar@9 9080
alpar@9 9081 for lib in $dlfiles; do
alpar@9 9082 case $lib in
alpar@9 9083 *.la)
alpar@9 9084 func_basename "$lib"
alpar@9 9085 name="$func_basename_result"
alpar@9 9086 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
alpar@9 9087 test -z "$libdir" && \
alpar@9 9088 func_fatal_error "\`$lib' is not a valid libtool archive"
alpar@9 9089 newdlfiles="$newdlfiles $libdir/$name"
alpar@9 9090 ;;
alpar@9 9091 *) newdlfiles="$newdlfiles $lib" ;;
alpar@9 9092 esac
alpar@9 9093 done
alpar@9 9094 dlfiles="$newdlfiles"
alpar@9 9095 newdlprefiles=
alpar@9 9096 for lib in $dlprefiles; do
alpar@9 9097 case $lib in
alpar@9 9098 *.la)
alpar@9 9099 # Only pass preopened files to the pseudo-archive (for
alpar@9 9100 # eventual linking with the app. that links it) if we
alpar@9 9101 # didn't already link the preopened objects directly into
alpar@9 9102 # the library:
alpar@9 9103 func_basename "$lib"
alpar@9 9104 name="$func_basename_result"
alpar@9 9105 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
alpar@9 9106 test -z "$libdir" && \
alpar@9 9107 func_fatal_error "\`$lib' is not a valid libtool archive"
alpar@9 9108 newdlprefiles="$newdlprefiles $libdir/$name"
alpar@9 9109 ;;
alpar@9 9110 esac
alpar@9 9111 done
alpar@9 9112 dlprefiles="$newdlprefiles"
alpar@9 9113 else
alpar@9 9114 newdlfiles=
alpar@9 9115 for lib in $dlfiles; do
alpar@9 9116 case $lib in
alpar@9 9117 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
alpar@9 9118 *) abs=`pwd`"/$lib" ;;
alpar@9 9119 esac
alpar@9 9120 newdlfiles="$newdlfiles $abs"
alpar@9 9121 done
alpar@9 9122 dlfiles="$newdlfiles"
alpar@9 9123 newdlprefiles=
alpar@9 9124 for lib in $dlprefiles; do
alpar@9 9125 case $lib in
alpar@9 9126 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
alpar@9 9127 *) abs=`pwd`"/$lib" ;;
alpar@9 9128 esac
alpar@9 9129 newdlprefiles="$newdlprefiles $abs"
alpar@9 9130 done
alpar@9 9131 dlprefiles="$newdlprefiles"
alpar@9 9132 fi
alpar@9 9133 $RM $output
alpar@9 9134 # place dlname in correct position for cygwin
alpar@9 9135 # In fact, it would be nice if we could use this code for all target
alpar@9 9136 # systems that can't hard-code library paths into their executables
alpar@9 9137 # and that have no shared library path variable independent of PATH,
alpar@9 9138 # but it turns out we can't easily determine that from inspecting
alpar@9 9139 # libtool variables, so we have to hard-code the OSs to which it
alpar@9 9140 # applies here; at the moment, that means platforms that use the PE
alpar@9 9141 # object format with DLL files. See the long comment at the top of
alpar@9 9142 # tests/bindir.at for full details.
alpar@9 9143 tdlname=$dlname
alpar@9 9144 case $host,$output,$installed,$module,$dlname in
alpar@9 9145 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
alpar@9 9146 # If a -bindir argument was supplied, place the dll there.
alpar@9 9147 if test "x$bindir" != x ;
alpar@9 9148 then
alpar@9 9149 func_relative_path "$install_libdir" "$bindir"
alpar@9 9150 tdlname=$func_relative_path_result$dlname
alpar@9 9151 else
alpar@9 9152 # Otherwise fall back on heuristic.
alpar@9 9153 tdlname=../bin/$dlname
alpar@9 9154 fi
alpar@9 9155 ;;
alpar@9 9156 esac
alpar@9 9157 $ECHO > $output "\
alpar@9 9158 # $outputname - a libtool library file
alpar@9 9159 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
alpar@9 9160 #
alpar@9 9161 # Please DO NOT delete this file!
alpar@9 9162 # It is necessary for linking the library.
alpar@9 9163
alpar@9 9164 # The name that we can dlopen(3).
alpar@9 9165 dlname='$tdlname'
alpar@9 9166
alpar@9 9167 # Names of this library.
alpar@9 9168 library_names='$library_names'
alpar@9 9169
alpar@9 9170 # The name of the static archive.
alpar@9 9171 old_library='$old_library'
alpar@9 9172
alpar@9 9173 # Linker flags that can not go in dependency_libs.
alpar@9 9174 inherited_linker_flags='$new_inherited_linker_flags'
alpar@9 9175
alpar@9 9176 # Libraries that this one depends upon.
alpar@9 9177 dependency_libs='$dependency_libs'
alpar@9 9178
alpar@9 9179 # Names of additional weak libraries provided by this library
alpar@9 9180 weak_library_names='$weak_libs'
alpar@9 9181
alpar@9 9182 # Version information for $libname.
alpar@9 9183 current=$current
alpar@9 9184 age=$age
alpar@9 9185 revision=$revision
alpar@9 9186
alpar@9 9187 # Is this an already installed library?
alpar@9 9188 installed=$installed
alpar@9 9189
alpar@9 9190 # Should we warn about portability when linking against -modules?
alpar@9 9191 shouldnotlink=$module
alpar@9 9192
alpar@9 9193 # Files to dlopen/dlpreopen
alpar@9 9194 dlopen='$dlfiles'
alpar@9 9195 dlpreopen='$dlprefiles'
alpar@9 9196
alpar@9 9197 # Directory that this library needs to be installed in:
alpar@9 9198 libdir='$install_libdir'"
alpar@9 9199 if test "$installed" = no && test "$need_relink" = yes; then
alpar@9 9200 $ECHO >> $output "\
alpar@9 9201 relink_command=\"$relink_command\""
alpar@9 9202 fi
alpar@9 9203 done
alpar@9 9204 }
alpar@9 9205
alpar@9 9206 # Do a symbolic link so that the libtool archive can be found in
alpar@9 9207 # LD_LIBRARY_PATH before the program is installed.
alpar@9 9208 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
alpar@9 9209 ;;
alpar@9 9210 esac
alpar@9 9211 exit $EXIT_SUCCESS
alpar@9 9212 }
alpar@9 9213
alpar@9 9214 { test "$mode" = link || test "$mode" = relink; } &&
alpar@9 9215 func_mode_link ${1+"$@"}
alpar@9 9216
alpar@9 9217
alpar@9 9218 # func_mode_uninstall arg...
alpar@9 9219 func_mode_uninstall ()
alpar@9 9220 {
alpar@9 9221 $opt_debug
alpar@9 9222 RM="$nonopt"
alpar@9 9223 files=
alpar@9 9224 rmforce=
alpar@9 9225 exit_status=0
alpar@9 9226
alpar@9 9227 # This variable tells wrapper scripts just to set variables rather
alpar@9 9228 # than running their programs.
alpar@9 9229 libtool_install_magic="$magic"
alpar@9 9230
alpar@9 9231 for arg
alpar@9 9232 do
alpar@9 9233 case $arg in
alpar@9 9234 -f) RM="$RM $arg"; rmforce=yes ;;
alpar@9 9235 -*) RM="$RM $arg" ;;
alpar@9 9236 *) files="$files $arg" ;;
alpar@9 9237 esac
alpar@9 9238 done
alpar@9 9239
alpar@9 9240 test -z "$RM" && \
alpar@9 9241 func_fatal_help "you must specify an RM program"
alpar@9 9242
alpar@9 9243 rmdirs=
alpar@9 9244
alpar@9 9245 origobjdir="$objdir"
alpar@9 9246 for file in $files; do
alpar@9 9247 func_dirname "$file" "" "."
alpar@9 9248 dir="$func_dirname_result"
alpar@9 9249 if test "X$dir" = X.; then
alpar@9 9250 objdir="$origobjdir"
alpar@9 9251 else
alpar@9 9252 objdir="$dir/$origobjdir"
alpar@9 9253 fi
alpar@9 9254 func_basename "$file"
alpar@9 9255 name="$func_basename_result"
alpar@9 9256 test "$mode" = uninstall && objdir="$dir"
alpar@9 9257
alpar@9 9258 # Remember objdir for removal later, being careful to avoid duplicates
alpar@9 9259 if test "$mode" = clean; then
alpar@9 9260 case " $rmdirs " in
alpar@9 9261 *" $objdir "*) ;;
alpar@9 9262 *) rmdirs="$rmdirs $objdir" ;;
alpar@9 9263 esac
alpar@9 9264 fi
alpar@9 9265
alpar@9 9266 # Don't error if the file doesn't exist and rm -f was used.
alpar@9 9267 if { test -L "$file"; } >/dev/null 2>&1 ||
alpar@9 9268 { test -h "$file"; } >/dev/null 2>&1 ||
alpar@9 9269 test -f "$file"; then
alpar@9 9270 :
alpar@9 9271 elif test -d "$file"; then
alpar@9 9272 exit_status=1
alpar@9 9273 continue
alpar@9 9274 elif test "$rmforce" = yes; then
alpar@9 9275 continue
alpar@9 9276 fi
alpar@9 9277
alpar@9 9278 rmfiles="$file"
alpar@9 9279
alpar@9 9280 case $name in
alpar@9 9281 *.la)
alpar@9 9282 # Possibly a libtool archive, so verify it.
alpar@9 9283 if func_lalib_p "$file"; then
alpar@9 9284 func_source $dir/$name
alpar@9 9285
alpar@9 9286 # Delete the libtool libraries and symlinks.
alpar@9 9287 for n in $library_names; do
alpar@9 9288 rmfiles="$rmfiles $objdir/$n"
alpar@9 9289 done
alpar@9 9290 test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
alpar@9 9291
alpar@9 9292 case "$mode" in
alpar@9 9293 clean)
alpar@9 9294 case " $library_names " in
alpar@9 9295 # " " in the beginning catches empty $dlname
alpar@9 9296 *" $dlname "*) ;;
alpar@9 9297 *) rmfiles="$rmfiles $objdir/$dlname" ;;
alpar@9 9298 esac
alpar@9 9299 test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
alpar@9 9300 ;;
alpar@9 9301 uninstall)
alpar@9 9302 if test -n "$library_names"; then
alpar@9 9303 # Do each command in the postuninstall commands.
alpar@9 9304 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
alpar@9 9305 fi
alpar@9 9306
alpar@9 9307 if test -n "$old_library"; then
alpar@9 9308 # Do each command in the old_postuninstall commands.
alpar@9 9309 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
alpar@9 9310 fi
alpar@9 9311 # FIXME: should reinstall the best remaining shared library.
alpar@9 9312 ;;
alpar@9 9313 esac
alpar@9 9314 fi
alpar@9 9315 ;;
alpar@9 9316
alpar@9 9317 *.lo)
alpar@9 9318 # Possibly a libtool object, so verify it.
alpar@9 9319 if func_lalib_p "$file"; then
alpar@9 9320
alpar@9 9321 # Read the .lo file
alpar@9 9322 func_source $dir/$name
alpar@9 9323
alpar@9 9324 # Add PIC object to the list of files to remove.
alpar@9 9325 if test -n "$pic_object" &&
alpar@9 9326 test "$pic_object" != none; then
alpar@9 9327 rmfiles="$rmfiles $dir/$pic_object"
alpar@9 9328 fi
alpar@9 9329
alpar@9 9330 # Add non-PIC object to the list of files to remove.
alpar@9 9331 if test -n "$non_pic_object" &&
alpar@9 9332 test "$non_pic_object" != none; then
alpar@9 9333 rmfiles="$rmfiles $dir/$non_pic_object"
alpar@9 9334 fi
alpar@9 9335 fi
alpar@9 9336 ;;
alpar@9 9337
alpar@9 9338 *)
alpar@9 9339 if test "$mode" = clean ; then
alpar@9 9340 noexename=$name
alpar@9 9341 case $file in
alpar@9 9342 *.exe)
alpar@9 9343 func_stripname '' '.exe' "$file"
alpar@9 9344 file=$func_stripname_result
alpar@9 9345 func_stripname '' '.exe' "$name"
alpar@9 9346 noexename=$func_stripname_result
alpar@9 9347 # $file with .exe has already been added to rmfiles,
alpar@9 9348 # add $file without .exe
alpar@9 9349 rmfiles="$rmfiles $file"
alpar@9 9350 ;;
alpar@9 9351 esac
alpar@9 9352 # Do a test to see if this is a libtool program.
alpar@9 9353 if func_ltwrapper_p "$file"; then
alpar@9 9354 if func_ltwrapper_executable_p "$file"; then
alpar@9 9355 func_ltwrapper_scriptname "$file"
alpar@9 9356 relink_command=
alpar@9 9357 func_source $func_ltwrapper_scriptname_result
alpar@9 9358 rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
alpar@9 9359 else
alpar@9 9360 relink_command=
alpar@9 9361 func_source $dir/$noexename
alpar@9 9362 fi
alpar@9 9363
alpar@9 9364 # note $name still contains .exe if it was in $file originally
alpar@9 9365 # as does the version of $file that was added into $rmfiles
alpar@9 9366 rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
alpar@9 9367 rmfiles="$rmfiles ${name}.manifest $objdir/${name}.manifest"
alpar@9 9368 if test "$fast_install" = yes && test -n "$relink_command"; then
alpar@9 9369 rmfiles="$rmfiles $objdir/lt-$name $objdir/lt-${name}.manifest"
alpar@9 9370 fi
alpar@9 9371 if test "X$noexename" != "X$name" ; then
alpar@9 9372 rmfiles="$rmfiles $objdir/lt-${noexename}.c"
alpar@9 9373 fi
alpar@9 9374 fi
alpar@9 9375 fi
alpar@9 9376 ;;
alpar@9 9377 esac
alpar@9 9378 func_show_eval "$RM $rmfiles" 'exit_status=1'
alpar@9 9379 done
alpar@9 9380 objdir="$origobjdir"
alpar@9 9381
alpar@9 9382 # Try to remove the ${objdir}s in the directories where we deleted files
alpar@9 9383 for dir in $rmdirs; do
alpar@9 9384 if test -d "$dir"; then
alpar@9 9385 func_show_eval "rmdir $dir >/dev/null 2>&1"
alpar@9 9386 fi
alpar@9 9387 done
alpar@9 9388
alpar@9 9389 exit $exit_status
alpar@9 9390 }
alpar@9 9391
alpar@9 9392 { test "$mode" = uninstall || test "$mode" = clean; } &&
alpar@9 9393 func_mode_uninstall ${1+"$@"}
alpar@9 9394
alpar@9 9395 test -z "$mode" && {
alpar@9 9396 help="$generic_help"
alpar@9 9397 func_fatal_help "you must specify a MODE"
alpar@9 9398 }
alpar@9 9399
alpar@9 9400 test -z "$exec_cmd" && \
alpar@9 9401 func_fatal_help "invalid operation mode \`$mode'"
alpar@9 9402
alpar@9 9403 if test -n "$exec_cmd"; then
alpar@9 9404 eval exec "$exec_cmd"
alpar@9 9405 exit $EXIT_FAILURE
alpar@9 9406 fi
alpar@9 9407
alpar@9 9408 exit $exit_status
alpar@9 9409
alpar@9 9410
alpar@9 9411 # The TAGs below are defined such that we never get into a situation
alpar@9 9412 # in which we disable both kinds of libraries. Given conflicting
alpar@9 9413 # choices, we go for a static library, that is the most portable,
alpar@9 9414 # since we can't tell whether shared libraries were disabled because
alpar@9 9415 # the user asked for that or because the platform doesn't support
alpar@9 9416 # them. This is particularly important on AIX, because we don't
alpar@9 9417 # support having both static and shared libraries enabled at the same
alpar@9 9418 # time on that platform, so we default to a shared-only configuration.
alpar@9 9419 # If a disable-shared tag is given, we'll fallback to a static-only
alpar@9 9420 # configuration. But we'll never go from static-only to shared-only.
alpar@9 9421
alpar@9 9422 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
alpar@9 9423 build_libtool_libs=no
alpar@9 9424 build_old_libs=yes
alpar@9 9425 # ### END LIBTOOL TAG CONFIG: disable-shared
alpar@9 9426
alpar@9 9427 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
alpar@9 9428 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
alpar@9 9429 # ### END LIBTOOL TAG CONFIG: disable-static
alpar@9 9430
alpar@9 9431 # Local Variables:
alpar@9 9432 # mode:shell-script
alpar@9 9433 # sh-indentation:2
alpar@9 9434 # End:
alpar@9 9435 # vi:sw=2
alpar@9 9436