1296415Sdes#! /bin/sh 2296415Sdes## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3296415Sdes## by inline-source v2014-01-03.01 4238106Sdes 5296415Sdes# libtool (GNU libtool) 2.4.6 6296415Sdes# Provide generalized library-building support services. 7238106Sdes# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8238106Sdes 9296415Sdes# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10238106Sdes# This is free software; see the source for copying conditions. There is NO 11238106Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12238106Sdes 13238106Sdes# GNU Libtool is free software; you can redistribute it and/or modify 14238106Sdes# it under the terms of the GNU General Public License as published by 15238106Sdes# the Free Software Foundation; either version 2 of the License, or 16238106Sdes# (at your option) any later version. 17238106Sdes# 18238106Sdes# As a special exception to the GNU General Public License, 19238106Sdes# if you distribute this file as part of a program or library that 20238106Sdes# is built using GNU Libtool, you may include this file under the 21238106Sdes# same distribution terms that you use for the rest of that program. 22238106Sdes# 23238106Sdes# GNU Libtool is distributed in the hope that it will be useful, but 24238106Sdes# WITHOUT ANY WARRANTY; without even the implied warranty of 25238106Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26238106Sdes# General Public License for more details. 27238106Sdes# 28238106Sdes# You should have received a copy of the GNU General Public License 29296415Sdes# along with this program. If not, see <http://www.gnu.org/licenses/>. 30238106Sdes 31238106Sdes 32238106SdesPROGRAM=libtool 33238106SdesPACKAGE=libtool 34296415SdesVERSION=2.4.6 35296415Sdespackage_revision=2.4.6 36238106Sdes 37296415Sdes 38296415Sdes## ------ ## 39296415Sdes## Usage. ## 40296415Sdes## ------ ## 41296415Sdes 42296415Sdes# Run './libtool --help' for help with using this script from the 43296415Sdes# command line. 44296415Sdes 45296415Sdes 46296415Sdes## ------------------------------- ## 47296415Sdes## User overridable command paths. ## 48296415Sdes## ------------------------------- ## 49296415Sdes 50296415Sdes# After configure completes, it has a better idea of some of the 51296415Sdes# shell tools we need than the defaults used by the functions shared 52296415Sdes# with bootstrap, so set those here where they can still be over- 53296415Sdes# ridden by the user, but otherwise take precedence. 54296415Sdes 55296415Sdes: ${AUTOCONF="autoconf"} 56296415Sdes: ${AUTOMAKE="automake"} 57296415Sdes 58296415Sdes 59296415Sdes## -------------------------- ## 60296415Sdes## Source external libraries. ## 61296415Sdes## -------------------------- ## 62296415Sdes 63296415Sdes# Much of our low-level functionality needs to be sourced from external 64296415Sdes# libraries, which are installed to $pkgauxdir. 65296415Sdes 66296415Sdes# Set a version string for this script. 67296415Sdesscriptversion=2015-01-20.17; # UTC 68296415Sdes 69296415Sdes# General shell script boiler plate, and helper functions. 70296415Sdes# Written by Gary V. Vaughan, 2004 71296415Sdes 72296415Sdes# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73296415Sdes# This is free software; see the source for copying conditions. There is NO 74296415Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75296415Sdes 76296415Sdes# This program is free software; you can redistribute it and/or modify 77296415Sdes# it under the terms of the GNU General Public License as published by 78296415Sdes# the Free Software Foundation; either version 3 of the License, or 79296415Sdes# (at your option) any later version. 80296415Sdes 81296415Sdes# As a special exception to the GNU General Public License, if you distribute 82296415Sdes# this file as part of a program or library that is built using GNU Libtool, 83296415Sdes# you may include this file under the same distribution terms that you use 84296415Sdes# for the rest of that program. 85296415Sdes 86296415Sdes# This program is distributed in the hope that it will be useful, 87296415Sdes# but WITHOUT ANY WARRANTY; without even the implied warranty of 88296415Sdes# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89296415Sdes# General Public License for more details. 90296415Sdes 91296415Sdes# You should have received a copy of the GNU General Public License 92296415Sdes# along with this program. If not, see <http://www.gnu.org/licenses/>. 93296415Sdes 94296415Sdes# Please report bugs or propose patches to gary@gnu.org. 95296415Sdes 96296415Sdes 97296415Sdes## ------ ## 98296415Sdes## Usage. ## 99296415Sdes## ------ ## 100296415Sdes 101296415Sdes# Evaluate this file near the top of your script to gain access to 102296415Sdes# the functions and variables defined here: 103296415Sdes# 104296415Sdes# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105296415Sdes# 106296415Sdes# If you need to override any of the default environment variable 107296415Sdes# settings, do that before evaluating this file. 108296415Sdes 109296415Sdes 110296415Sdes## -------------------- ## 111296415Sdes## Shell normalisation. ## 112296415Sdes## -------------------- ## 113296415Sdes 114296415Sdes# Some shells need a little help to be as Bourne compatible as possible. 115296415Sdes# Before doing anything else, make sure all that help has been provided! 116296415Sdes 117296415SdesDUALCASE=1; export DUALCASE # for MKS sh 118296415Sdesif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119238106Sdes emulate sh 120238106Sdes NULLCMD=: 121296415Sdes # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122238106Sdes # is contrary to our usage. Disable this feature. 123238106Sdes alias -g '${1+"$@"}'='"$@"' 124238106Sdes setopt NO_GLOB_SUBST 125238106Sdeselse 126296415Sdes case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127238106Sdesfi 128238106Sdes 129296415Sdes# NLS nuisances: We save the old values in case they are required later. 130296415Sdes_G_user_locale= 131296415Sdes_G_safe_locale= 132296415Sdesfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133238106Sdesdo 134296415Sdes eval "if test set = \"\${$_G_var+set}\"; then 135296415Sdes save_$_G_var=\$$_G_var 136296415Sdes $_G_var=C 137296415Sdes export $_G_var 138296415Sdes _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139296415Sdes _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140238106Sdes fi" 141238106Sdesdone 142238106Sdes 143296415Sdes# CDPATH. 144296415Sdes(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145238106Sdes 146296415Sdes# Make sure IFS has a sensible default 147296415Sdessp=' ' 148296415Sdesnl=' 149296415Sdes' 150296415SdesIFS="$sp $nl" 151238106Sdes 152296415Sdes# There are apparently some retarded systems that use ';' as a PATH separator! 153296415Sdesif test "${PATH_SEPARATOR+set}" != set; then 154296415Sdes PATH_SEPARATOR=: 155296415Sdes (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156296415Sdes (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157296415Sdes PATH_SEPARATOR=';' 158296415Sdes } 159296415Sdesfi 160238106Sdes 161238106Sdes 162238106Sdes 163296415Sdes## ------------------------- ## 164296415Sdes## Locate command utilities. ## 165296415Sdes## ------------------------- ## 166296415Sdes 167296415Sdes 168296415Sdes# func_executable_p FILE 169296415Sdes# ---------------------- 170296415Sdes# Check that FILE is an executable regular file. 171296415Sdesfunc_executable_p () 172296415Sdes{ 173296415Sdes test -f "$1" && test -x "$1" 174296415Sdes} 175296415Sdes 176296415Sdes 177296415Sdes# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178296415Sdes# -------------------------------------------- 179296415Sdes# Search for either a program that responds to --version with output 180296415Sdes# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181296415Sdes# trying all the directories in PATH with each of the elements of 182296415Sdes# PROGS_LIST. 183296415Sdes# 184296415Sdes# CHECK_FUNC should accept the path to a candidate program, and 185296415Sdes# set $func_check_prog_result if it truncates its output less than 186296415Sdes# $_G_path_prog_max characters. 187296415Sdesfunc_path_progs () 188296415Sdes{ 189296415Sdes _G_progs_list=$1 190296415Sdes _G_check_func=$2 191296415Sdes _G_PATH=${3-"$PATH"} 192296415Sdes 193296415Sdes _G_path_prog_max=0 194296415Sdes _G_path_prog_found=false 195296415Sdes _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196296415Sdes for _G_dir in $_G_PATH; do 197296415Sdes IFS=$_G_save_IFS 198296415Sdes test -z "$_G_dir" && _G_dir=. 199296415Sdes for _G_prog_name in $_G_progs_list; do 200296415Sdes for _exeext in '' .EXE; do 201296415Sdes _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202296415Sdes func_executable_p "$_G_path_prog" || continue 203296415Sdes case `"$_G_path_prog" --version 2>&1` in 204296415Sdes *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205296415Sdes *) $_G_check_func $_G_path_prog 206296415Sdes func_path_progs_result=$func_check_prog_result 207296415Sdes ;; 208296415Sdes esac 209296415Sdes $_G_path_prog_found && break 3 210296415Sdes done 211296415Sdes done 212296415Sdes done 213296415Sdes IFS=$_G_save_IFS 214296415Sdes test -z "$func_path_progs_result" && { 215296415Sdes echo "no acceptable sed could be found in \$PATH" >&2 216296415Sdes exit 1 217296415Sdes } 218296415Sdes} 219296415Sdes 220296415Sdes 221296415Sdes# We want to be able to use the functions in this file before configure 222296415Sdes# has figured out where the best binaries are kept, which means we have 223296415Sdes# to search for them ourselves - except when the results are already set 224296415Sdes# where we skip the searches. 225296415Sdes 226296415Sdes# Unless the user overrides by setting SED, search the path for either GNU 227296415Sdes# sed, or the sed that truncates its output the least. 228296415Sdestest -z "$SED" && { 229296415Sdes _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230296415Sdes for _G_i in 1 2 3 4 5 6 7; do 231296415Sdes _G_sed_script=$_G_sed_script$nl$_G_sed_script 232296415Sdes done 233296415Sdes echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234296415Sdes _G_sed_script= 235296415Sdes 236296415Sdes func_check_prog_sed () 237296415Sdes { 238296415Sdes _G_path_prog=$1 239296415Sdes 240296415Sdes _G_count=0 241296415Sdes printf 0123456789 >conftest.in 242296415Sdes while : 243296415Sdes do 244296415Sdes cat conftest.in conftest.in >conftest.tmp 245296415Sdes mv conftest.tmp conftest.in 246296415Sdes cp conftest.in conftest.nl 247296415Sdes echo '' >> conftest.nl 248296415Sdes "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249296415Sdes diff conftest.out conftest.nl >/dev/null 2>&1 || break 250296415Sdes _G_count=`expr $_G_count + 1` 251296415Sdes if test "$_G_count" -gt "$_G_path_prog_max"; then 252296415Sdes # Best one so far, save it but keep looking for a better one 253296415Sdes func_check_prog_result=$_G_path_prog 254296415Sdes _G_path_prog_max=$_G_count 255296415Sdes fi 256296415Sdes # 10*(2^10) chars as input seems more than enough 257296415Sdes test 10 -lt "$_G_count" && break 258296415Sdes done 259296415Sdes rm -f conftest.in conftest.tmp conftest.nl conftest.out 260296415Sdes } 261296415Sdes 262296415Sdes func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263296415Sdes rm -f conftest.sed 264296415Sdes SED=$func_path_progs_result 265296415Sdes} 266296415Sdes 267296415Sdes 268296415Sdes# Unless the user overrides by setting GREP, search the path for either GNU 269296415Sdes# grep, or the grep that truncates its output the least. 270296415Sdestest -z "$GREP" && { 271296415Sdes func_check_prog_grep () 272296415Sdes { 273296415Sdes _G_path_prog=$1 274296415Sdes 275296415Sdes _G_count=0 276296415Sdes _G_path_prog_max=0 277296415Sdes printf 0123456789 >conftest.in 278296415Sdes while : 279296415Sdes do 280296415Sdes cat conftest.in conftest.in >conftest.tmp 281296415Sdes mv conftest.tmp conftest.in 282296415Sdes cp conftest.in conftest.nl 283296415Sdes echo 'GREP' >> conftest.nl 284296415Sdes "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285296415Sdes diff conftest.out conftest.nl >/dev/null 2>&1 || break 286296415Sdes _G_count=`expr $_G_count + 1` 287296415Sdes if test "$_G_count" -gt "$_G_path_prog_max"; then 288296415Sdes # Best one so far, save it but keep looking for a better one 289296415Sdes func_check_prog_result=$_G_path_prog 290296415Sdes _G_path_prog_max=$_G_count 291296415Sdes fi 292296415Sdes # 10*(2^10) chars as input seems more than enough 293296415Sdes test 10 -lt "$_G_count" && break 294296415Sdes done 295296415Sdes rm -f conftest.in conftest.tmp conftest.nl conftest.out 296296415Sdes } 297296415Sdes 298296415Sdes func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299296415Sdes GREP=$func_path_progs_result 300296415Sdes} 301296415Sdes 302296415Sdes 303296415Sdes## ------------------------------- ## 304296415Sdes## User overridable command paths. ## 305296415Sdes## ------------------------------- ## 306296415Sdes 307296415Sdes# All uppercase variable names are used for environment variables. These 308296415Sdes# variables can be overridden by the user before calling a script that 309296415Sdes# uses them if a suitable command of that name is not already available 310296415Sdes# in the command search PATH. 311296415Sdes 312238106Sdes: ${CP="cp -f"} 313296415Sdes: ${ECHO="printf %s\n"} 314296415Sdes: ${EGREP="$GREP -E"} 315296415Sdes: ${FGREP="$GREP -F"} 316296415Sdes: ${LN_S="ln -s"} 317238106Sdes: ${MAKE="make"} 318238106Sdes: ${MKDIR="mkdir"} 319238106Sdes: ${MV="mv -f"} 320238106Sdes: ${RM="rm -f"} 321238106Sdes: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322238106Sdes 323238106Sdes 324296415Sdes## -------------------- ## 325296415Sdes## Useful sed snippets. ## 326296415Sdes## -------------------- ## 327238106Sdes 328296415Sdessed_dirname='s|/[^/]*$||' 329296415Sdessed_basename='s|^.*/||' 330238106Sdes 331296415Sdes# Sed substitution that helps us do robust quoting. It backslashifies 332296415Sdes# metacharacters that are still active within double-quoted strings. 333296415Sdessed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334238106Sdes 335296415Sdes# Same as above, but do not quote variable references. 336296415Sdessed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337238106Sdes 338296415Sdes# Sed substitution that turns a string into a regex matching for the 339296415Sdes# string literally. 340296415Sdessed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341238106Sdes 342296415Sdes# Sed substitution that converts a w32 file name or path 343296415Sdes# that contains forward slashes, into one that contains 344296415Sdes# (escaped) backslashes. A very naive implementation. 345296415Sdessed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346238106Sdes 347296415Sdes# Re-'\' parameter expansions in output of sed_double_quote_subst that 348296415Sdes# were '\'-ed in input to the same. If an odd number of '\' preceded a 349296415Sdes# '$' in input to sed_double_quote_subst, that '$' was protected from 350296415Sdes# expansion. Since each input '\' is now two '\'s, look for any number 351296415Sdes# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352296415Sdes_G_bs='\\' 353296415Sdes_G_bs2='\\\\' 354296415Sdes_G_bs4='\\\\\\\\' 355296415Sdes_G_dollar='\$' 356296415Sdessed_double_backslash="\ 357296415Sdes s/$_G_bs4/&\\ 358296415Sdes/g 359296415Sdes s/^$_G_bs2$_G_dollar/$_G_bs&/ 360296415Sdes s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361296415Sdes s/\n//g" 362238106Sdes 363238106Sdes 364296415Sdes## ----------------- ## 365296415Sdes## Global variables. ## 366296415Sdes## ----------------- ## 367238106Sdes 368296415Sdes# Except for the global variables explicitly listed below, the following 369296415Sdes# functions in the '^func_' namespace, and the '^require_' namespace 370296415Sdes# variables initialised in the 'Resource management' section, sourcing 371296415Sdes# this file will not pollute your global namespace with anything 372296415Sdes# else. There's no portable way to scope variables in Bourne shell 373296415Sdes# though, so actually running these functions will sometimes place 374296415Sdes# results into a variable named after the function, and often use 375296415Sdes# temporary variables in the '^_G_' namespace. If you are careful to 376296415Sdes# avoid using those namespaces casually in your sourcing script, things 377296415Sdes# should continue to work as you expect. And, of course, you can freely 378296415Sdes# overwrite any of the functions or variables defined here before 379296415Sdes# calling anything to customize them. 380238106Sdes 381296415SdesEXIT_SUCCESS=0 382296415SdesEXIT_FAILURE=1 383296415SdesEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384296415SdesEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385238106Sdes 386296415Sdes# Allow overriding, eg assuming that you follow the convention of 387296415Sdes# putting '$debug_cmd' at the start of all your functions, you can get 388296415Sdes# bash to show function call trace with: 389296415Sdes# 390296415Sdes# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391296415Sdesdebug_cmd=${debug_cmd-":"} 392296415Sdesexit_cmd=: 393238106Sdes 394296415Sdes# By convention, finish your script with: 395296415Sdes# 396296415Sdes# exit $exit_status 397296415Sdes# 398296415Sdes# so that you can set exit_status to non-zero if you want to indicate 399296415Sdes# something went wrong during execution without actually bailing out at 400296415Sdes# the point of failure. 401296415Sdesexit_status=$EXIT_SUCCESS 402238106Sdes 403296415Sdes# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404296415Sdes# is ksh but when the shell is invoked as "sh" and the current value of 405296415Sdes# the _XPG environment variable is not equal to 1 (one), the special 406296415Sdes# positional parameter $0, within a function call, is the name of the 407296415Sdes# function. 408296415Sdesprogpath=$0 409238106Sdes 410296415Sdes# The name of this program. 411296415Sdesprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412238106Sdes 413296415Sdes# Make sure we have an absolute progpath for reexecution: 414238106Sdescase $progpath in 415238106Sdes [\\/]*|[A-Za-z]:\\*) ;; 416238106Sdes *[\\/]*) 417296415Sdes progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418238106Sdes progdir=`cd "$progdir" && pwd` 419296415Sdes progpath=$progdir/$progname 420238106Sdes ;; 421238106Sdes *) 422296415Sdes _G_IFS=$IFS 423249141Sdes IFS=${PATH_SEPARATOR-:} 424238106Sdes for progdir in $PATH; do 425296415Sdes IFS=$_G_IFS 426238106Sdes test -x "$progdir/$progname" && break 427238106Sdes done 428296415Sdes IFS=$_G_IFS 429238106Sdes test -n "$progdir" || progdir=`pwd` 430296415Sdes progpath=$progdir/$progname 431238106Sdes ;; 432238106Sdesesac 433238106Sdes 434238106Sdes 435296415Sdes## ----------------- ## 436296415Sdes## Standard options. ## 437296415Sdes## ----------------- ## 438238106Sdes 439296415Sdes# The following options affect the operation of the functions defined 440296415Sdes# below, and should be set appropriately depending on run-time para- 441296415Sdes# meters passed on the command line. 442238106Sdes 443238106Sdesopt_dry_run=false 444238106Sdesopt_quiet=false 445238106Sdesopt_verbose=false 446238106Sdes 447296415Sdes# Categories 'all' and 'none' are always available. Append any others 448296415Sdes# you will pass as the first argument to func_warning from your own 449296415Sdes# code. 450296415Sdeswarning_categories= 451296415Sdes 452296415Sdes# By default, display warnings according to 'opt_warning_types'. Set 453296415Sdes# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454296415Sdes# treat the next displayed warning as a fatal error. 455296415Sdeswarning_func=func_warn_and_continue 456296415Sdes 457296415Sdes# Set to 'all' to display all warnings, 'none' to suppress all 458296415Sdes# warnings, or a space delimited list of some subset of 459296415Sdes# 'warning_categories' to display only the listed warnings. 460296415Sdesopt_warning_types=all 461296415Sdes 462296415Sdes 463296415Sdes## -------------------- ## 464296415Sdes## Resource management. ## 465296415Sdes## -------------------- ## 466296415Sdes 467296415Sdes# This section contains definitions for functions that each ensure a 468296415Sdes# particular resource (a file, or a non-empty configuration variable for 469296415Sdes# example) is available, and if appropriate to extract default values 470296415Sdes# from pertinent package files. Call them using their associated 471296415Sdes# 'require_*' variable to ensure that they are executed, at most, once. 472296415Sdes# 473296415Sdes# It's entirely deliberate that calling these functions can set 474296415Sdes# variables that don't obey the namespace limitations obeyed by the rest 475296415Sdes# of this file, in order that that they be as useful as possible to 476296415Sdes# callers. 477296415Sdes 478296415Sdes 479296415Sdes# require_term_colors 480296415Sdes# ------------------- 481296415Sdes# Allow display of bold text on terminals that support it. 482296415Sdesrequire_term_colors=func_require_term_colors 483296415Sdesfunc_require_term_colors () 484238106Sdes{ 485296415Sdes $debug_cmd 486296415Sdes 487296415Sdes test -t 1 && { 488296415Sdes # COLORTERM and USE_ANSI_COLORS environment variables take 489296415Sdes # precedence, because most terminfo databases neglect to describe 490296415Sdes # whether color sequences are supported. 491296415Sdes test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492296415Sdes 493296415Sdes if test 1 = "$USE_ANSI_COLORS"; then 494296415Sdes # Standard ANSI escape sequences 495296415Sdes tc_reset='[0m' 496296415Sdes tc_bold='[1m'; tc_standout='[7m' 497296415Sdes tc_red='[31m'; tc_green='[32m' 498296415Sdes tc_blue='[34m'; tc_cyan='[36m' 499296415Sdes else 500296415Sdes # Otherwise trust the terminfo database after all. 501296415Sdes test -n "`tput sgr0 2>/dev/null`" && { 502296415Sdes tc_reset=`tput sgr0` 503296415Sdes test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504296415Sdes tc_standout=$tc_bold 505296415Sdes test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506296415Sdes test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507296415Sdes test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508296415Sdes test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509296415Sdes test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510296415Sdes } 511296415Sdes fi 512296415Sdes } 513296415Sdes 514296415Sdes require_term_colors=: 515238106Sdes} 516238106Sdes 517296415Sdes 518296415Sdes## ----------------- ## 519296415Sdes## Function library. ## 520296415Sdes## ----------------- ## 521296415Sdes 522296415Sdes# This section contains a variety of useful functions to call in your 523296415Sdes# scripts. Take note of the portable wrappers for features provided by 524296415Sdes# some modern shells, which will fall back to slower equivalents on 525296415Sdes# less featureful shells. 526296415Sdes 527296415Sdes 528296415Sdes# func_append VAR VALUE 529296415Sdes# --------------------- 530296415Sdes# Append VALUE onto the existing contents of VAR. 531296415Sdes 532296415Sdes # We should try to minimise forks, especially on Windows where they are 533296415Sdes # unreasonably slow, so skip the feature probes when bash or zsh are 534296415Sdes # being used: 535296415Sdes if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536296415Sdes : ${_G_HAVE_ARITH_OP="yes"} 537296415Sdes : ${_G_HAVE_XSI_OPS="yes"} 538296415Sdes # The += operator was introduced in bash 3.1 539296415Sdes case $BASH_VERSION in 540296415Sdes [12].* | 3.0 | 3.0*) ;; 541296415Sdes *) 542296415Sdes : ${_G_HAVE_PLUSEQ_OP="yes"} 543296415Sdes ;; 544296415Sdes esac 545296415Sdes fi 546296415Sdes 547296415Sdes # _G_HAVE_PLUSEQ_OP 548296415Sdes # Can be empty, in which case the shell is probed, "yes" if += is 549296415Sdes # useable or anything else if it does not work. 550296415Sdes test -z "$_G_HAVE_PLUSEQ_OP" \ 551296415Sdes && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552296415Sdes && _G_HAVE_PLUSEQ_OP=yes 553296415Sdes 554296415Sdesif test yes = "$_G_HAVE_PLUSEQ_OP" 555296415Sdesthen 556296415Sdes # This is an XSI compatible shell, allowing a faster implementation... 557296415Sdes eval 'func_append () 558296415Sdes { 559296415Sdes $debug_cmd 560296415Sdes 561296415Sdes eval "$1+=\$2" 562296415Sdes }' 563296415Sdeselse 564296415Sdes # ...otherwise fall back to using expr, which is often a shell builtin. 565296415Sdes func_append () 566296415Sdes { 567296415Sdes $debug_cmd 568296415Sdes 569296415Sdes eval "$1=\$$1\$2" 570296415Sdes } 571296415Sdesfi 572296415Sdes 573296415Sdes 574296415Sdes# func_append_quoted VAR VALUE 575296415Sdes# ---------------------------- 576296415Sdes# Quote VALUE and append to the end of shell variable VAR, separated 577296415Sdes# by a space. 578296415Sdesif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579296415Sdes eval 'func_append_quoted () 580296415Sdes { 581296415Sdes $debug_cmd 582296415Sdes 583296415Sdes func_quote_for_eval "$2" 584296415Sdes eval "$1+=\\ \$func_quote_for_eval_result" 585296415Sdes }' 586296415Sdeselse 587296415Sdes func_append_quoted () 588296415Sdes { 589296415Sdes $debug_cmd 590296415Sdes 591296415Sdes func_quote_for_eval "$2" 592296415Sdes eval "$1=\$$1\\ \$func_quote_for_eval_result" 593296415Sdes } 594296415Sdesfi 595296415Sdes 596296415Sdes 597296415Sdes# func_append_uniq VAR VALUE 598296415Sdes# -------------------------- 599296415Sdes# Append unique VALUE onto the existing contents of VAR, assuming 600296415Sdes# entries are delimited by the first character of VALUE. For example: 601296415Sdes# 602296415Sdes# func_append_uniq options " --another-option option-argument" 603296415Sdes# 604296415Sdes# will only append to $options if " --another-option option-argument " 605296415Sdes# is not already present somewhere in $options already (note spaces at 606296415Sdes# each end implied by leading space in second argument). 607296415Sdesfunc_append_uniq () 608238106Sdes{ 609296415Sdes $debug_cmd 610238106Sdes 611296415Sdes eval _G_current_value='`$ECHO $'$1'`' 612296415Sdes _G_delim=`expr "$2" : '\(.\)'` 613296415Sdes 614296415Sdes case $_G_delim$_G_current_value$_G_delim in 615296415Sdes *"$2$_G_delim"*) ;; 616296415Sdes *) func_append "$@" ;; 617296415Sdes esac 618238106Sdes} 619238106Sdes 620296415Sdes 621296415Sdes# func_arith TERM... 622296415Sdes# ------------------ 623296415Sdes# Set func_arith_result to the result of evaluating TERMs. 624296415Sdes test -z "$_G_HAVE_ARITH_OP" \ 625296415Sdes && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626296415Sdes && _G_HAVE_ARITH_OP=yes 627296415Sdes 628296415Sdesif test yes = "$_G_HAVE_ARITH_OP"; then 629296415Sdes eval 'func_arith () 630296415Sdes { 631296415Sdes $debug_cmd 632296415Sdes 633296415Sdes func_arith_result=$(( $* )) 634296415Sdes }' 635296415Sdeselse 636296415Sdes func_arith () 637296415Sdes { 638296415Sdes $debug_cmd 639296415Sdes 640296415Sdes func_arith_result=`expr "$@"` 641296415Sdes } 642296415Sdesfi 643296415Sdes 644296415Sdes 645296415Sdes# func_basename FILE 646296415Sdes# ------------------ 647296415Sdes# Set func_basename_result to FILE with everything up to and including 648296415Sdes# the last / stripped. 649296415Sdesif test yes = "$_G_HAVE_XSI_OPS"; then 650296415Sdes # If this shell supports suffix pattern removal, then use it to avoid 651296415Sdes # forking. Hide the definitions single quotes in case the shell chokes 652296415Sdes # on unsupported syntax... 653296415Sdes _b='func_basename_result=${1##*/}' 654296415Sdes _d='case $1 in 655296415Sdes */*) func_dirname_result=${1%/*}$2 ;; 656296415Sdes * ) func_dirname_result=$3 ;; 657296415Sdes esac' 658296415Sdes 659296415Sdeselse 660296415Sdes # ...otherwise fall back to using sed. 661296415Sdes _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662296415Sdes _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663296415Sdes if test "X$func_dirname_result" = "X$1"; then 664296415Sdes func_dirname_result=$3 665296415Sdes else 666296415Sdes func_append func_dirname_result "$2" 667296415Sdes fi' 668296415Sdesfi 669296415Sdes 670296415Sdeseval 'func_basename () 671296415Sdes{ 672296415Sdes $debug_cmd 673296415Sdes 674296415Sdes '"$_b"' 675296415Sdes}' 676296415Sdes 677296415Sdes 678296415Sdes# func_dirname FILE APPEND NONDIR_REPLACEMENT 679296415Sdes# ------------------------------------------- 680296415Sdes# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681296415Sdes# otherwise set result to NONDIR_REPLACEMENT. 682296415Sdeseval 'func_dirname () 683296415Sdes{ 684296415Sdes $debug_cmd 685296415Sdes 686296415Sdes '"$_d"' 687296415Sdes}' 688296415Sdes 689296415Sdes 690296415Sdes# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691296415Sdes# -------------------------------------------------------- 692296415Sdes# Perform func_basename and func_dirname in a single function 693296415Sdes# call: 694296415Sdes# dirname: Compute the dirname of FILE. If nonempty, 695296415Sdes# add APPEND to the result, otherwise set result 696296415Sdes# to NONDIR_REPLACEMENT. 697296415Sdes# value returned in "$func_dirname_result" 698296415Sdes# basename: Compute filename of FILE. 699296415Sdes# value retuned in "$func_basename_result" 700296415Sdes# For efficiency, we do not delegate to the functions above but instead 701296415Sdes# duplicate the functionality here. 702296415Sdeseval 'func_dirname_and_basename () 703296415Sdes{ 704296415Sdes $debug_cmd 705296415Sdes 706296415Sdes '"$_b"' 707296415Sdes '"$_d"' 708296415Sdes}' 709296415Sdes 710296415Sdes 711296415Sdes# func_echo ARG... 712296415Sdes# ---------------- 713296415Sdes# Echo program name prefixed message. 714296415Sdesfunc_echo () 715296415Sdes{ 716296415Sdes $debug_cmd 717296415Sdes 718296415Sdes _G_message=$* 719296415Sdes 720296415Sdes func_echo_IFS=$IFS 721296415Sdes IFS=$nl 722296415Sdes for _G_line in $_G_message; do 723296415Sdes IFS=$func_echo_IFS 724296415Sdes $ECHO "$progname: $_G_line" 725296415Sdes done 726296415Sdes IFS=$func_echo_IFS 727296415Sdes} 728296415Sdes 729296415Sdes 730296415Sdes# func_echo_all ARG... 731296415Sdes# -------------------- 732238106Sdes# Invoke $ECHO with all args, space-separated. 733238106Sdesfunc_echo_all () 734238106Sdes{ 735238106Sdes $ECHO "$*" 736238106Sdes} 737238106Sdes 738296415Sdes 739296415Sdes# func_echo_infix_1 INFIX ARG... 740296415Sdes# ------------------------------ 741296415Sdes# Echo program name, followed by INFIX on the first line, with any 742296415Sdes# additional lines not showing INFIX. 743296415Sdesfunc_echo_infix_1 () 744238106Sdes{ 745296415Sdes $debug_cmd 746296415Sdes 747296415Sdes $require_term_colors 748296415Sdes 749296415Sdes _G_infix=$1; shift 750296415Sdes _G_indent=$_G_infix 751296415Sdes _G_prefix="$progname: $_G_infix: " 752296415Sdes _G_message=$* 753296415Sdes 754296415Sdes # Strip color escape sequences before counting printable length 755296415Sdes for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756296415Sdes do 757296415Sdes test -n "$_G_tc" && { 758296415Sdes _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759296415Sdes _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760296415Sdes } 761296415Sdes done 762296415Sdes _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763296415Sdes 764296415Sdes func_echo_infix_1_IFS=$IFS 765296415Sdes IFS=$nl 766296415Sdes for _G_line in $_G_message; do 767296415Sdes IFS=$func_echo_infix_1_IFS 768296415Sdes $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769296415Sdes _G_prefix=$_G_indent 770296415Sdes done 771296415Sdes IFS=$func_echo_infix_1_IFS 772238106Sdes} 773238106Sdes 774296415Sdes 775296415Sdes# func_error ARG... 776296415Sdes# ----------------- 777296415Sdes# Echo program name prefixed message to standard error. 778296415Sdesfunc_error () 779238106Sdes{ 780296415Sdes $debug_cmd 781238106Sdes 782296415Sdes $require_term_colors 783296415Sdes 784296415Sdes func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785238106Sdes} 786238106Sdes 787296415Sdes 788296415Sdes# func_fatal_error ARG... 789296415Sdes# ----------------------- 790238106Sdes# Echo program name prefixed message to standard error, and exit. 791238106Sdesfunc_fatal_error () 792238106Sdes{ 793296415Sdes $debug_cmd 794296415Sdes 795296415Sdes func_error "$*" 796238106Sdes exit $EXIT_FAILURE 797238106Sdes} 798238106Sdes 799238106Sdes 800296415Sdes# func_grep EXPRESSION FILENAME 801296415Sdes# ----------------------------- 802238106Sdes# Check whether EXPRESSION matches any line of FILENAME, without output. 803238106Sdesfunc_grep () 804238106Sdes{ 805296415Sdes $debug_cmd 806296415Sdes 807238106Sdes $GREP "$1" "$2" >/dev/null 2>&1 808238106Sdes} 809238106Sdes 810238106Sdes 811296415Sdes# func_len STRING 812296415Sdes# --------------- 813296415Sdes# Set func_len_result to the length of STRING. STRING may not 814296415Sdes# start with a hyphen. 815296415Sdes test -z "$_G_HAVE_XSI_OPS" \ 816296415Sdes && (eval 'x=a/b/c; 817296415Sdes test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818296415Sdes && _G_HAVE_XSI_OPS=yes 819296415Sdes 820296415Sdesif test yes = "$_G_HAVE_XSI_OPS"; then 821296415Sdes eval 'func_len () 822296415Sdes { 823296415Sdes $debug_cmd 824296415Sdes 825296415Sdes func_len_result=${#1} 826296415Sdes }' 827296415Sdeselse 828296415Sdes func_len () 829296415Sdes { 830296415Sdes $debug_cmd 831296415Sdes 832296415Sdes func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833296415Sdes } 834296415Sdesfi 835296415Sdes 836296415Sdes 837296415Sdes# func_mkdir_p DIRECTORY-PATH 838296415Sdes# --------------------------- 839238106Sdes# Make sure the entire path to DIRECTORY-PATH is available. 840238106Sdesfunc_mkdir_p () 841238106Sdes{ 842296415Sdes $debug_cmd 843238106Sdes 844296415Sdes _G_directory_path=$1 845296415Sdes _G_dir_list= 846238106Sdes 847296415Sdes if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848296415Sdes 849296415Sdes # Protect directory names starting with '-' 850296415Sdes case $_G_directory_path in 851296415Sdes -*) _G_directory_path=./$_G_directory_path ;; 852238106Sdes esac 853238106Sdes 854238106Sdes # While some portion of DIR does not yet exist... 855296415Sdes while test ! -d "$_G_directory_path"; do 856238106Sdes # ...make a list in topmost first order. Use a colon delimited 857238106Sdes # list incase some portion of path contains whitespace. 858296415Sdes _G_dir_list=$_G_directory_path:$_G_dir_list 859238106Sdes 860238106Sdes # If the last portion added has no slash in it, the list is done 861296415Sdes case $_G_directory_path in */*) ;; *) break ;; esac 862238106Sdes 863238106Sdes # ...otherwise throw away the child directory and loop 864296415Sdes _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865238106Sdes done 866296415Sdes _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867238106Sdes 868296415Sdes func_mkdir_p_IFS=$IFS; IFS=: 869296415Sdes for _G_dir in $_G_dir_list; do 870296415Sdes IFS=$func_mkdir_p_IFS 871296415Sdes # mkdir can fail with a 'File exist' error if two processes 872238106Sdes # try to create one of the directories concurrently. Don't 873238106Sdes # stop in that case! 874296415Sdes $MKDIR "$_G_dir" 2>/dev/null || : 875238106Sdes done 876296415Sdes IFS=$func_mkdir_p_IFS 877238106Sdes 878238106Sdes # Bail out if we (or some other process) failed to create a directory. 879296415Sdes test -d "$_G_directory_path" || \ 880296415Sdes func_fatal_error "Failed to create '$1'" 881238106Sdes fi 882238106Sdes} 883238106Sdes 884238106Sdes 885296415Sdes# func_mktempdir [BASENAME] 886296415Sdes# ------------------------- 887238106Sdes# Make a temporary directory that won't clash with other running 888238106Sdes# libtool processes, and avoids race conditions if possible. If 889296415Sdes# given, BASENAME is the basename for that directory. 890238106Sdesfunc_mktempdir () 891238106Sdes{ 892296415Sdes $debug_cmd 893238106Sdes 894296415Sdes _G_template=${TMPDIR-/tmp}/${1-$progname} 895296415Sdes 896296415Sdes if test : = "$opt_dry_run"; then 897238106Sdes # Return a directory name, but don't create it in dry-run mode 898296415Sdes _G_tmpdir=$_G_template-$$ 899238106Sdes else 900238106Sdes 901238106Sdes # If mktemp works, use that first and foremost 902296415Sdes _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903238106Sdes 904296415Sdes if test ! -d "$_G_tmpdir"; then 905238106Sdes # Failing that, at least try and use $RANDOM to avoid a race 906296415Sdes _G_tmpdir=$_G_template-${RANDOM-0}$$ 907238106Sdes 908296415Sdes func_mktempdir_umask=`umask` 909238106Sdes umask 0077 910296415Sdes $MKDIR "$_G_tmpdir" 911296415Sdes umask $func_mktempdir_umask 912238106Sdes fi 913238106Sdes 914238106Sdes # If we're not in dry-run mode, bomb out on failure 915296415Sdes test -d "$_G_tmpdir" || \ 916296415Sdes func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917238106Sdes fi 918238106Sdes 919296415Sdes $ECHO "$_G_tmpdir" 920238106Sdes} 921238106Sdes 922238106Sdes 923296415Sdes# func_normal_abspath PATH 924296415Sdes# ------------------------ 925296415Sdes# Remove doubled-up and trailing slashes, "." path components, 926296415Sdes# and cancel out any ".." path components in PATH after making 927296415Sdes# it an absolute path. 928296415Sdesfunc_normal_abspath () 929238106Sdes{ 930296415Sdes $debug_cmd 931238106Sdes 932296415Sdes # These SED scripts presuppose an absolute path with a trailing slash. 933296415Sdes _G_pathcar='s|^/\([^/]*\).*$|\1|' 934296415Sdes _G_pathcdr='s|^/[^/]*||' 935296415Sdes _G_removedotparts=':dotsl 936296415Sdes s|/\./|/|g 937296415Sdes t dotsl 938296415Sdes s|/\.$|/|' 939296415Sdes _G_collapseslashes='s|/\{1,\}|/|g' 940296415Sdes _G_finalslash='s|/*$|/|' 941296415Sdes 942296415Sdes # Start from root dir and reassemble the path. 943296415Sdes func_normal_abspath_result= 944296415Sdes func_normal_abspath_tpath=$1 945296415Sdes func_normal_abspath_altnamespace= 946296415Sdes case $func_normal_abspath_tpath in 947296415Sdes "") 948296415Sdes # Empty path, that just means $cwd. 949296415Sdes func_stripname '' '/' "`pwd`" 950296415Sdes func_normal_abspath_result=$func_stripname_result 951296415Sdes return 952238106Sdes ;; 953296415Sdes # The next three entries are used to spot a run of precisely 954296415Sdes # two leading slashes without using negated character classes; 955296415Sdes # we take advantage of case's first-match behaviour. 956296415Sdes ///*) 957296415Sdes # Unusual form of absolute path, do nothing. 958296415Sdes ;; 959296415Sdes //*) 960296415Sdes # Not necessarily an ordinary path; POSIX reserves leading '//' 961296415Sdes # and for example Cygwin uses it to access remote file shares 962296415Sdes # over CIFS/SMB, so we conserve a leading double slash if found. 963296415Sdes func_normal_abspath_altnamespace=/ 964296415Sdes ;; 965296415Sdes /*) 966296415Sdes # Absolute path, do nothing. 967296415Sdes ;; 968238106Sdes *) 969296415Sdes # Relative path, prepend $cwd. 970296415Sdes func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971296415Sdes ;; 972238106Sdes esac 973296415Sdes 974296415Sdes # Cancel out all the simple stuff to save iterations. We also want 975296415Sdes # the path to end with a slash for ease of parsing, so make sure 976296415Sdes # there is one (and only one) here. 977296415Sdes func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978296415Sdes -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979296415Sdes while :; do 980296415Sdes # Processed it all yet? 981296415Sdes if test / = "$func_normal_abspath_tpath"; then 982296415Sdes # If we ascended to the root using ".." the result may be empty now. 983296415Sdes if test -z "$func_normal_abspath_result"; then 984296415Sdes func_normal_abspath_result=/ 985296415Sdes fi 986296415Sdes break 987296415Sdes fi 988296415Sdes func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989296415Sdes -e "$_G_pathcar"` 990296415Sdes func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991296415Sdes -e "$_G_pathcdr"` 992296415Sdes # Figure out what to do with it 993296415Sdes case $func_normal_abspath_tcomponent in 994296415Sdes "") 995296415Sdes # Trailing empty path component, ignore it. 996296415Sdes ;; 997296415Sdes ..) 998296415Sdes # Parent dir; strip last assembled component from result. 999296415Sdes func_dirname "$func_normal_abspath_result" 1000296415Sdes func_normal_abspath_result=$func_dirname_result 1001296415Sdes ;; 1002296415Sdes *) 1003296415Sdes # Actual path component, append it. 1004296415Sdes func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005296415Sdes ;; 1006296415Sdes esac 1007296415Sdes done 1008296415Sdes # Restore leading double-slash if one was found on entry. 1009296415Sdes func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010238106Sdes} 1011238106Sdes 1012238106Sdes 1013296415Sdes# func_notquiet ARG... 1014296415Sdes# -------------------- 1015296415Sdes# Echo program name prefixed message only when not in quiet mode. 1016296415Sdesfunc_notquiet () 1017296415Sdes{ 1018296415Sdes $debug_cmd 1019296415Sdes 1020296415Sdes $opt_quiet || func_echo ${1+"$@"} 1021296415Sdes 1022296415Sdes # A bug in bash halts the script if the last line of a function 1023296415Sdes # fails when set -e is in force, so we need another command to 1024296415Sdes # work around that: 1025296415Sdes : 1026296415Sdes} 1027296415Sdes 1028296415Sdes 1029296415Sdes# func_relative_path SRCDIR DSTDIR 1030296415Sdes# -------------------------------- 1031296415Sdes# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032296415Sdesfunc_relative_path () 1033296415Sdes{ 1034296415Sdes $debug_cmd 1035296415Sdes 1036296415Sdes func_relative_path_result= 1037296415Sdes func_normal_abspath "$1" 1038296415Sdes func_relative_path_tlibdir=$func_normal_abspath_result 1039296415Sdes func_normal_abspath "$2" 1040296415Sdes func_relative_path_tbindir=$func_normal_abspath_result 1041296415Sdes 1042296415Sdes # Ascend the tree starting from libdir 1043296415Sdes while :; do 1044296415Sdes # check if we have found a prefix of bindir 1045296415Sdes case $func_relative_path_tbindir in 1046296415Sdes $func_relative_path_tlibdir) 1047296415Sdes # found an exact match 1048296415Sdes func_relative_path_tcancelled= 1049296415Sdes break 1050296415Sdes ;; 1051296415Sdes $func_relative_path_tlibdir*) 1052296415Sdes # found a matching prefix 1053296415Sdes func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054296415Sdes func_relative_path_tcancelled=$func_stripname_result 1055296415Sdes if test -z "$func_relative_path_result"; then 1056296415Sdes func_relative_path_result=. 1057296415Sdes fi 1058296415Sdes break 1059296415Sdes ;; 1060296415Sdes *) 1061296415Sdes func_dirname $func_relative_path_tlibdir 1062296415Sdes func_relative_path_tlibdir=$func_dirname_result 1063296415Sdes if test -z "$func_relative_path_tlibdir"; then 1064296415Sdes # Have to descend all the way to the root! 1065296415Sdes func_relative_path_result=../$func_relative_path_result 1066296415Sdes func_relative_path_tcancelled=$func_relative_path_tbindir 1067296415Sdes break 1068296415Sdes fi 1069296415Sdes func_relative_path_result=../$func_relative_path_result 1070296415Sdes ;; 1071296415Sdes esac 1072296415Sdes done 1073296415Sdes 1074296415Sdes # Now calculate path; take care to avoid doubling-up slashes. 1075296415Sdes func_stripname '' '/' "$func_relative_path_result" 1076296415Sdes func_relative_path_result=$func_stripname_result 1077296415Sdes func_stripname '/' '/' "$func_relative_path_tcancelled" 1078296415Sdes if test -n "$func_stripname_result"; then 1079296415Sdes func_append func_relative_path_result "/$func_stripname_result" 1080296415Sdes fi 1081296415Sdes 1082296415Sdes # Normalisation. If bindir is libdir, return '.' else relative path. 1083296415Sdes if test -n "$func_relative_path_result"; then 1084296415Sdes func_stripname './' '' "$func_relative_path_result" 1085296415Sdes func_relative_path_result=$func_stripname_result 1086296415Sdes fi 1087296415Sdes 1088296415Sdes test -n "$func_relative_path_result" || func_relative_path_result=. 1089296415Sdes 1090296415Sdes : 1091296415Sdes} 1092296415Sdes 1093296415Sdes 1094296415Sdes# func_quote_for_eval ARG... 1095296415Sdes# -------------------------- 1096296415Sdes# Aesthetically quote ARGs to be evaled later. 1097296415Sdes# This function returns two values: 1098296415Sdes# i) func_quote_for_eval_result 1099296415Sdes# double-quoted, suitable for a subsequent eval 1100296415Sdes# ii) func_quote_for_eval_unquoted_result 1101296415Sdes# has all characters that are still active within double 1102296415Sdes# quotes backslashified. 1103296415Sdesfunc_quote_for_eval () 1104296415Sdes{ 1105296415Sdes $debug_cmd 1106296415Sdes 1107296415Sdes func_quote_for_eval_unquoted_result= 1108296415Sdes func_quote_for_eval_result= 1109296415Sdes while test 0 -lt $#; do 1110296415Sdes case $1 in 1111296415Sdes *[\\\`\"\$]*) 1112296415Sdes _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113296415Sdes *) 1114296415Sdes _G_unquoted_arg=$1 ;; 1115296415Sdes esac 1116296415Sdes if test -n "$func_quote_for_eval_unquoted_result"; then 1117296415Sdes func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118296415Sdes else 1119296415Sdes func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120296415Sdes fi 1121296415Sdes 1122296415Sdes case $_G_unquoted_arg in 1123296415Sdes # Double-quote args containing shell metacharacters to delay 1124296415Sdes # word splitting, command substitution and variable expansion 1125296415Sdes # for a subsequent eval. 1126296415Sdes # Many Bourne shells cannot handle close brackets correctly 1127296415Sdes # in scan sets, so we specify it separately. 1128296415Sdes *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129296415Sdes _G_quoted_arg=\"$_G_unquoted_arg\" 1130296415Sdes ;; 1131296415Sdes *) 1132296415Sdes _G_quoted_arg=$_G_unquoted_arg 1133296415Sdes ;; 1134296415Sdes esac 1135296415Sdes 1136296415Sdes if test -n "$func_quote_for_eval_result"; then 1137296415Sdes func_append func_quote_for_eval_result " $_G_quoted_arg" 1138296415Sdes else 1139296415Sdes func_append func_quote_for_eval_result "$_G_quoted_arg" 1140296415Sdes fi 1141296415Sdes shift 1142296415Sdes done 1143296415Sdes} 1144296415Sdes 1145296415Sdes 1146296415Sdes# func_quote_for_expand ARG 1147296415Sdes# ------------------------- 1148238106Sdes# Aesthetically quote ARG to be evaled later; same as above, 1149238106Sdes# but do not quote variable references. 1150238106Sdesfunc_quote_for_expand () 1151238106Sdes{ 1152296415Sdes $debug_cmd 1153296415Sdes 1154238106Sdes case $1 in 1155238106Sdes *[\\\`\"]*) 1156296415Sdes _G_arg=`$ECHO "$1" | $SED \ 1157296415Sdes -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1158238106Sdes *) 1159296415Sdes _G_arg=$1 ;; 1160238106Sdes esac 1161238106Sdes 1162296415Sdes case $_G_arg in 1163238106Sdes # Double-quote args containing shell metacharacters to delay 1164238106Sdes # word splitting and command substitution for a subsequent eval. 1165238106Sdes # Many Bourne shells cannot handle close brackets correctly 1166238106Sdes # in scan sets, so we specify it separately. 1167238106Sdes *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168296415Sdes _G_arg=\"$_G_arg\" 1169238106Sdes ;; 1170238106Sdes esac 1171238106Sdes 1172296415Sdes func_quote_for_expand_result=$_G_arg 1173238106Sdes} 1174238106Sdes 1175238106Sdes 1176296415Sdes# func_stripname PREFIX SUFFIX NAME 1177296415Sdes# --------------------------------- 1178296415Sdes# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179296415Sdes# PREFIX and SUFFIX must not contain globbing or regex special 1180296415Sdes# characters, hashes, percent signs, but SUFFIX may contain a leading 1181296415Sdes# dot (in which case that matches only a dot). 1182296415Sdesif test yes = "$_G_HAVE_XSI_OPS"; then 1183296415Sdes eval 'func_stripname () 1184296415Sdes { 1185296415Sdes $debug_cmd 1186296415Sdes 1187296415Sdes # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188296415Sdes # positional parameters, so assign one to ordinary variable first. 1189296415Sdes func_stripname_result=$3 1190296415Sdes func_stripname_result=${func_stripname_result#"$1"} 1191296415Sdes func_stripname_result=${func_stripname_result%"$2"} 1192296415Sdes }' 1193296415Sdeselse 1194296415Sdes func_stripname () 1195296415Sdes { 1196296415Sdes $debug_cmd 1197296415Sdes 1198296415Sdes case $2 in 1199296415Sdes .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200296415Sdes *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201296415Sdes esac 1202296415Sdes } 1203296415Sdesfi 1204296415Sdes 1205296415Sdes 1206296415Sdes# func_show_eval CMD [FAIL_EXP] 1207296415Sdes# ----------------------------- 1208296415Sdes# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209238106Sdes# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210238106Sdes# is given, then evaluate it. 1211238106Sdesfunc_show_eval () 1212238106Sdes{ 1213296415Sdes $debug_cmd 1214238106Sdes 1215296415Sdes _G_cmd=$1 1216296415Sdes _G_fail_exp=${2-':'} 1217238106Sdes 1218296415Sdes func_quote_for_expand "$_G_cmd" 1219296415Sdes eval "func_notquiet $func_quote_for_expand_result" 1220296415Sdes 1221296415Sdes $opt_dry_run || { 1222296415Sdes eval "$_G_cmd" 1223296415Sdes _G_status=$? 1224296415Sdes if test 0 -ne "$_G_status"; then 1225296415Sdes eval "(exit $_G_status); $_G_fail_exp" 1226238106Sdes fi 1227296415Sdes } 1228238106Sdes} 1229238106Sdes 1230238106Sdes 1231296415Sdes# func_show_eval_locale CMD [FAIL_EXP] 1232296415Sdes# ------------------------------------ 1233296415Sdes# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234238106Sdes# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235238106Sdes# is given, then evaluate it. Use the saved locale for evaluation. 1236238106Sdesfunc_show_eval_locale () 1237238106Sdes{ 1238296415Sdes $debug_cmd 1239238106Sdes 1240296415Sdes _G_cmd=$1 1241296415Sdes _G_fail_exp=${2-':'} 1242296415Sdes 1243296415Sdes $opt_quiet || { 1244296415Sdes func_quote_for_expand "$_G_cmd" 1245238106Sdes eval "func_echo $func_quote_for_expand_result" 1246238106Sdes } 1247238106Sdes 1248296415Sdes $opt_dry_run || { 1249296415Sdes eval "$_G_user_locale 1250296415Sdes $_G_cmd" 1251296415Sdes _G_status=$? 1252296415Sdes eval "$_G_safe_locale" 1253296415Sdes if test 0 -ne "$_G_status"; then 1254296415Sdes eval "(exit $_G_status); $_G_fail_exp" 1255238106Sdes fi 1256296415Sdes } 1257238106Sdes} 1258238106Sdes 1259296415Sdes 1260238106Sdes# func_tr_sh 1261296415Sdes# ---------- 1262238106Sdes# Turn $1 into a string suitable for a shell variable name. 1263238106Sdes# Result is stored in $func_tr_sh_result. All characters 1264238106Sdes# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265238106Sdes# if $1 begins with a digit, a '_' is prepended as well. 1266238106Sdesfunc_tr_sh () 1267238106Sdes{ 1268296415Sdes $debug_cmd 1269296415Sdes 1270296415Sdes case $1 in 1271296415Sdes [0-9]* | *[!a-zA-Z0-9_]*) 1272296415Sdes func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273296415Sdes ;; 1274296415Sdes * ) 1275296415Sdes func_tr_sh_result=$1 1276296415Sdes ;; 1277296415Sdes esac 1278238106Sdes} 1279238106Sdes 1280238106Sdes 1281296415Sdes# func_verbose ARG... 1282296415Sdes# ------------------- 1283296415Sdes# Echo program name prefixed message in verbose mode only. 1284296415Sdesfunc_verbose () 1285238106Sdes{ 1286296415Sdes $debug_cmd 1287238106Sdes 1288296415Sdes $opt_verbose && func_echo "$*" 1289296415Sdes 1290296415Sdes : 1291238106Sdes} 1292238106Sdes 1293296415Sdes 1294296415Sdes# func_warn_and_continue ARG... 1295296415Sdes# ----------------------------- 1296296415Sdes# Echo program name prefixed warning message to standard error. 1297296415Sdesfunc_warn_and_continue () 1298238106Sdes{ 1299296415Sdes $debug_cmd 1300238106Sdes 1301296415Sdes $require_term_colors 1302296415Sdes 1303296415Sdes func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304238106Sdes} 1305238106Sdes 1306296415Sdes 1307296415Sdes# func_warning CATEGORY ARG... 1308296415Sdes# ---------------------------- 1309296415Sdes# Echo program name prefixed warning message to standard error. Warning 1310296415Sdes# messages can be filtered according to CATEGORY, where this function 1311296415Sdes# elides messages where CATEGORY is not listed in the global variable 1312296415Sdes# 'opt_warning_types'. 1313296415Sdesfunc_warning () 1314296415Sdes{ 1315296415Sdes $debug_cmd 1316296415Sdes 1317296415Sdes # CATEGORY must be in the warning_categories list! 1318296415Sdes case " $warning_categories " in 1319296415Sdes *" $1 "*) ;; 1320296415Sdes *) func_internal_error "invalid warning category '$1'" ;; 1321296415Sdes esac 1322296415Sdes 1323296415Sdes _G_category=$1 1324296415Sdes shift 1325296415Sdes 1326296415Sdes case " $opt_warning_types " in 1327296415Sdes *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328296415Sdes esac 1329296415Sdes} 1330296415Sdes 1331296415Sdes 1332296415Sdes# func_sort_ver VER1 VER2 1333296415Sdes# ----------------------- 1334296415Sdes# 'sort -V' is not generally available. 1335296415Sdes# Note this deviates from the version comparison in automake 1336296415Sdes# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337296415Sdes# but this should suffice as we won't be specifying old 1338296415Sdes# version formats or redundant trailing .0 in bootstrap.conf. 1339296415Sdes# If we did want full compatibility then we should probably 1340296415Sdes# use m4_version_compare from autoconf. 1341296415Sdesfunc_sort_ver () 1342296415Sdes{ 1343296415Sdes $debug_cmd 1344296415Sdes 1345296415Sdes printf '%s\n%s\n' "$1" "$2" \ 1346296415Sdes | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n 1347296415Sdes} 1348296415Sdes 1349296415Sdes# func_lt_ver PREV CURR 1350296415Sdes# --------------------- 1351296415Sdes# Return true if PREV and CURR are in the correct order according to 1352296415Sdes# func_sort_ver, otherwise false. Use it like this: 1353296415Sdes# 1354296415Sdes# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355296415Sdesfunc_lt_ver () 1356296415Sdes{ 1357296415Sdes $debug_cmd 1358296415Sdes 1359296415Sdes test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360296415Sdes} 1361296415Sdes 1362296415Sdes 1363296415Sdes# Local variables: 1364296415Sdes# mode: shell-script 1365296415Sdes# sh-indentation: 2 1366296415Sdes# eval: (add-hook 'before-save-hook 'time-stamp) 1367296415Sdes# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368296415Sdes# time-stamp-time-zone: "UTC" 1369296415Sdes# End: 1370296415Sdes#! /bin/sh 1371296415Sdes 1372296415Sdes# Set a version string for this script. 1373296415Sdesscriptversion=2014-01-07.03; # UTC 1374296415Sdes 1375296415Sdes# A portable, pluggable option parser for Bourne shell. 1376296415Sdes# Written by Gary V. Vaughan, 2010 1377296415Sdes 1378296415Sdes# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379296415Sdes# This is free software; see the source for copying conditions. There is NO 1380296415Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381296415Sdes 1382296415Sdes# This program is free software: you can redistribute it and/or modify 1383296415Sdes# it under the terms of the GNU General Public License as published by 1384296415Sdes# the Free Software Foundation, either version 3 of the License, or 1385296415Sdes# (at your option) any later version. 1386296415Sdes 1387296415Sdes# This program is distributed in the hope that it will be useful, 1388296415Sdes# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389296415Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390296415Sdes# GNU General Public License for more details. 1391296415Sdes 1392296415Sdes# You should have received a copy of the GNU General Public License 1393296415Sdes# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394296415Sdes 1395296415Sdes# Please report bugs or propose patches to gary@gnu.org. 1396296415Sdes 1397296415Sdes 1398296415Sdes## ------ ## 1399296415Sdes## Usage. ## 1400296415Sdes## ------ ## 1401296415Sdes 1402296415Sdes# This file is a library for parsing options in your shell scripts along 1403296415Sdes# with assorted other useful supporting features that you can make use 1404296415Sdes# of too. 1405296415Sdes# 1406296415Sdes# For the simplest scripts you might need only: 1407296415Sdes# 1408296415Sdes# #!/bin/sh 1409296415Sdes# . relative/path/to/funclib.sh 1410296415Sdes# . relative/path/to/options-parser 1411296415Sdes# scriptversion=1.0 1412296415Sdes# func_options ${1+"$@"} 1413296415Sdes# eval set dummy "$func_options_result"; shift 1414296415Sdes# ...rest of your script... 1415296415Sdes# 1416296415Sdes# In order for the '--version' option to work, you will need to have a 1417296415Sdes# suitably formatted comment like the one at the top of this file 1418296415Sdes# starting with '# Written by ' and ending with '# warranty; '. 1419296415Sdes# 1420296415Sdes# For '-h' and '--help' to work, you will also need a one line 1421296415Sdes# description of your script's purpose in a comment directly above the 1422296415Sdes# '# Written by ' line, like the one at the top of this file. 1423296415Sdes# 1424296415Sdes# The default options also support '--debug', which will turn on shell 1425296415Sdes# execution tracing (see the comment above debug_cmd below for another 1426296415Sdes# use), and '--verbose' and the func_verbose function to allow your script 1427296415Sdes# to display verbose messages only when your user has specified 1428296415Sdes# '--verbose'. 1429296415Sdes# 1430296415Sdes# After sourcing this file, you can plug processing for additional 1431296415Sdes# options by amending the variables from the 'Configuration' section 1432296415Sdes# below, and following the instructions in the 'Option parsing' 1433296415Sdes# section further down. 1434296415Sdes 1435296415Sdes## -------------- ## 1436296415Sdes## Configuration. ## 1437296415Sdes## -------------- ## 1438296415Sdes 1439296415Sdes# You should override these variables in your script after sourcing this 1440296415Sdes# file so that they reflect the customisations you have added to the 1441296415Sdes# option parser. 1442296415Sdes 1443296415Sdes# The usage line for option parsing errors and the start of '-h' and 1444296415Sdes# '--help' output messages. You can embed shell variables for delayed 1445296415Sdes# expansion at the time the message is displayed, but you will need to 1446296415Sdes# quote other shell meta-characters carefully to prevent them being 1447296415Sdes# expanded when the contents are evaled. 1448296415Sdesusage='$progpath [OPTION]...' 1449296415Sdes 1450296415Sdes# Short help message in response to '-h' and '--help'. Add to this or 1451296415Sdes# override it after sourcing this library to reflect the full set of 1452296415Sdes# options your script accepts. 1453296415Sdesusage_message="\ 1454296415Sdes --debug enable verbose shell tracing 1455296415Sdes -W, --warnings=CATEGORY 1456296415Sdes report the warnings falling in CATEGORY [all] 1457296415Sdes -v, --verbose verbosely report processing 1458296415Sdes --version print version information and exit 1459296415Sdes -h, --help print short or long help message and exit 1460296415Sdes" 1461296415Sdes 1462296415Sdes# Additional text appended to 'usage_message' in response to '--help'. 1463296415Sdeslong_help_message=" 1464296415SdesWarning categories include: 1465296415Sdes 'all' show all warnings 1466296415Sdes 'none' turn off all the warnings 1467296415Sdes 'error' warnings are treated as fatal errors" 1468296415Sdes 1469296415Sdes# Help message printed before fatal option parsing errors. 1470296415Sdesfatal_help="Try '\$progname --help' for more information." 1471296415Sdes 1472296415Sdes 1473296415Sdes 1474296415Sdes## ------------------------- ## 1475296415Sdes## Hook function management. ## 1476296415Sdes## ------------------------- ## 1477296415Sdes 1478296415Sdes# This section contains functions for adding, removing, and running hooks 1479296415Sdes# to the main code. A hook is just a named list of of function, that can 1480296415Sdes# be run in order later on. 1481296415Sdes 1482296415Sdes# func_hookable FUNC_NAME 1483296415Sdes# ----------------------- 1484296415Sdes# Declare that FUNC_NAME will run hooks added with 1485296415Sdes# 'func_add_hook FUNC_NAME ...'. 1486296415Sdesfunc_hookable () 1487296415Sdes{ 1488296415Sdes $debug_cmd 1489296415Sdes 1490296415Sdes func_append hookable_fns " $1" 1491296415Sdes} 1492296415Sdes 1493296415Sdes 1494296415Sdes# func_add_hook FUNC_NAME HOOK_FUNC 1495296415Sdes# --------------------------------- 1496296415Sdes# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497296415Sdes# first have been declared "hookable" by a call to 'func_hookable'. 1498296415Sdesfunc_add_hook () 1499296415Sdes{ 1500296415Sdes $debug_cmd 1501296415Sdes 1502296415Sdes case " $hookable_fns " in 1503296415Sdes *" $1 "*) ;; 1504296415Sdes *) func_fatal_error "'$1' does not accept hook functions." ;; 1505296415Sdes esac 1506296415Sdes 1507296415Sdes eval func_append ${1}_hooks '" $2"' 1508296415Sdes} 1509296415Sdes 1510296415Sdes 1511296415Sdes# func_remove_hook FUNC_NAME HOOK_FUNC 1512296415Sdes# ------------------------------------ 1513296415Sdes# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514296415Sdesfunc_remove_hook () 1515296415Sdes{ 1516296415Sdes $debug_cmd 1517296415Sdes 1518296415Sdes eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519296415Sdes} 1520296415Sdes 1521296415Sdes 1522296415Sdes# func_run_hooks FUNC_NAME [ARG]... 1523296415Sdes# --------------------------------- 1524296415Sdes# Run all hook functions registered to FUNC_NAME. 1525296415Sdes# It is assumed that the list of hook functions contains nothing more 1526296415Sdes# than a whitespace-delimited list of legal shell function names, and 1527296415Sdes# no effort is wasted trying to catch shell meta-characters or preserve 1528296415Sdes# whitespace. 1529296415Sdesfunc_run_hooks () 1530296415Sdes{ 1531296415Sdes $debug_cmd 1532296415Sdes 1533296415Sdes case " $hookable_fns " in 1534296415Sdes *" $1 "*) ;; 1535296415Sdes *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536296415Sdes esac 1537296415Sdes 1538296415Sdes eval _G_hook_fns=\$$1_hooks; shift 1539296415Sdes 1540296415Sdes for _G_hook in $_G_hook_fns; do 1541296415Sdes eval $_G_hook '"$@"' 1542296415Sdes 1543296415Sdes # store returned options list back into positional 1544296415Sdes # parameters for next 'cmd' execution. 1545296415Sdes eval _G_hook_result=\$${_G_hook}_result 1546296415Sdes eval set dummy "$_G_hook_result"; shift 1547296415Sdes done 1548296415Sdes 1549296415Sdes func_quote_for_eval ${1+"$@"} 1550296415Sdes func_run_hooks_result=$func_quote_for_eval_result 1551296415Sdes} 1552296415Sdes 1553296415Sdes 1554296415Sdes 1555296415Sdes## --------------- ## 1556296415Sdes## Option parsing. ## 1557296415Sdes## --------------- ## 1558296415Sdes 1559296415Sdes# In order to add your own option parsing hooks, you must accept the 1560296415Sdes# full positional parameter list in your hook function, remove any 1561296415Sdes# options that you action, and then pass back the remaining unprocessed 1562296415Sdes# options in '<hooked_function_name>_result', escaped suitably for 1563296415Sdes# 'eval'. Like this: 1564296415Sdes# 1565296415Sdes# my_options_prep () 1566296415Sdes# { 1567296415Sdes# $debug_cmd 1568296415Sdes# 1569296415Sdes# # Extend the existing usage message. 1570296415Sdes# usage_message=$usage_message' 1571296415Sdes# -s, --silent don'\''t print informational messages 1572296415Sdes# ' 1573296415Sdes# 1574296415Sdes# func_quote_for_eval ${1+"$@"} 1575296415Sdes# my_options_prep_result=$func_quote_for_eval_result 1576296415Sdes# } 1577296415Sdes# func_add_hook func_options_prep my_options_prep 1578296415Sdes# 1579296415Sdes# 1580296415Sdes# my_silent_option () 1581296415Sdes# { 1582296415Sdes# $debug_cmd 1583296415Sdes# 1584296415Sdes# # Note that for efficiency, we parse as many options as we can 1585296415Sdes# # recognise in a loop before passing the remainder back to the 1586296415Sdes# # caller on the first unrecognised argument we encounter. 1587296415Sdes# while test $# -gt 0; do 1588296415Sdes# opt=$1; shift 1589296415Sdes# case $opt in 1590296415Sdes# --silent|-s) opt_silent=: ;; 1591296415Sdes# # Separate non-argument short options: 1592296415Sdes# -s*) func_split_short_opt "$_G_opt" 1593296415Sdes# set dummy "$func_split_short_opt_name" \ 1594296415Sdes# "-$func_split_short_opt_arg" ${1+"$@"} 1595296415Sdes# shift 1596296415Sdes# ;; 1597296415Sdes# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598296415Sdes# esac 1599296415Sdes# done 1600296415Sdes# 1601296415Sdes# func_quote_for_eval ${1+"$@"} 1602296415Sdes# my_silent_option_result=$func_quote_for_eval_result 1603296415Sdes# } 1604296415Sdes# func_add_hook func_parse_options my_silent_option 1605296415Sdes# 1606296415Sdes# 1607296415Sdes# my_option_validation () 1608296415Sdes# { 1609296415Sdes# $debug_cmd 1610296415Sdes# 1611296415Sdes# $opt_silent && $opt_verbose && func_fatal_help "\ 1612296415Sdes# '--silent' and '--verbose' options are mutually exclusive." 1613296415Sdes# 1614296415Sdes# func_quote_for_eval ${1+"$@"} 1615296415Sdes# my_option_validation_result=$func_quote_for_eval_result 1616296415Sdes# } 1617296415Sdes# func_add_hook func_validate_options my_option_validation 1618296415Sdes# 1619296415Sdes# You'll alse need to manually amend $usage_message to reflect the extra 1620296415Sdes# options you parse. It's preferable to append if you can, so that 1621296415Sdes# multiple option parsing hooks can be added safely. 1622296415Sdes 1623296415Sdes 1624296415Sdes# func_options [ARG]... 1625296415Sdes# --------------------- 1626296415Sdes# All the functions called inside func_options are hookable. See the 1627296415Sdes# individual implementations for details. 1628296415Sdesfunc_hookable func_options 1629296415Sdesfunc_options () 1630296415Sdes{ 1631296415Sdes $debug_cmd 1632296415Sdes 1633296415Sdes func_options_prep ${1+"$@"} 1634296415Sdes eval func_parse_options \ 1635296415Sdes ${func_options_prep_result+"$func_options_prep_result"} 1636296415Sdes eval func_validate_options \ 1637296415Sdes ${func_parse_options_result+"$func_parse_options_result"} 1638296415Sdes 1639296415Sdes eval func_run_hooks func_options \ 1640296415Sdes ${func_validate_options_result+"$func_validate_options_result"} 1641296415Sdes 1642296415Sdes # save modified positional parameters for caller 1643296415Sdes func_options_result=$func_run_hooks_result 1644296415Sdes} 1645296415Sdes 1646296415Sdes 1647296415Sdes# func_options_prep [ARG]... 1648296415Sdes# -------------------------- 1649296415Sdes# All initialisations required before starting the option parse loop. 1650296415Sdes# Note that when calling hook functions, we pass through the list of 1651296415Sdes# positional parameters. If a hook function modifies that list, and 1652296415Sdes# needs to propogate that back to rest of this script, then the complete 1653296415Sdes# modified list must be put in 'func_run_hooks_result' before 1654296415Sdes# returning. 1655296415Sdesfunc_hookable func_options_prep 1656296415Sdesfunc_options_prep () 1657296415Sdes{ 1658296415Sdes $debug_cmd 1659296415Sdes 1660296415Sdes # Option defaults: 1661296415Sdes opt_verbose=false 1662296415Sdes opt_warning_types= 1663296415Sdes 1664296415Sdes func_run_hooks func_options_prep ${1+"$@"} 1665296415Sdes 1666296415Sdes # save modified positional parameters for caller 1667296415Sdes func_options_prep_result=$func_run_hooks_result 1668296415Sdes} 1669296415Sdes 1670296415Sdes 1671296415Sdes# func_parse_options [ARG]... 1672296415Sdes# --------------------------- 1673296415Sdes# The main option parsing loop. 1674296415Sdesfunc_hookable func_parse_options 1675296415Sdesfunc_parse_options () 1676296415Sdes{ 1677296415Sdes $debug_cmd 1678296415Sdes 1679296415Sdes func_parse_options_result= 1680296415Sdes 1681296415Sdes # this just eases exit handling 1682296415Sdes while test $# -gt 0; do 1683296415Sdes # Defer to hook functions for initial option parsing, so they 1684296415Sdes # get priority in the event of reusing an option name. 1685296415Sdes func_run_hooks func_parse_options ${1+"$@"} 1686296415Sdes 1687296415Sdes # Adjust func_parse_options positional parameters to match 1688296415Sdes eval set dummy "$func_run_hooks_result"; shift 1689296415Sdes 1690296415Sdes # Break out of the loop if we already parsed every option. 1691296415Sdes test $# -gt 0 || break 1692296415Sdes 1693296415Sdes _G_opt=$1 1694296415Sdes shift 1695296415Sdes case $_G_opt in 1696296415Sdes --debug|-x) debug_cmd='set -x' 1697296415Sdes func_echo "enabling shell trace mode" 1698296415Sdes $debug_cmd 1699296415Sdes ;; 1700296415Sdes 1701296415Sdes --no-warnings|--no-warning|--no-warn) 1702296415Sdes set dummy --warnings none ${1+"$@"} 1703296415Sdes shift 1704296415Sdes ;; 1705296415Sdes 1706296415Sdes --warnings|--warning|-W) 1707296415Sdes test $# = 0 && func_missing_arg $_G_opt && break 1708296415Sdes case " $warning_categories $1" in 1709296415Sdes *" $1 "*) 1710296415Sdes # trailing space prevents matching last $1 above 1711296415Sdes func_append_uniq opt_warning_types " $1" 1712296415Sdes ;; 1713296415Sdes *all) 1714296415Sdes opt_warning_types=$warning_categories 1715296415Sdes ;; 1716296415Sdes *none) 1717296415Sdes opt_warning_types=none 1718296415Sdes warning_func=: 1719296415Sdes ;; 1720296415Sdes *error) 1721296415Sdes opt_warning_types=$warning_categories 1722296415Sdes warning_func=func_fatal_error 1723296415Sdes ;; 1724296415Sdes *) 1725296415Sdes func_fatal_error \ 1726296415Sdes "unsupported warning category: '$1'" 1727296415Sdes ;; 1728296415Sdes esac 1729296415Sdes shift 1730296415Sdes ;; 1731296415Sdes 1732296415Sdes --verbose|-v) opt_verbose=: ;; 1733296415Sdes --version) func_version ;; 1734296415Sdes -\?|-h) func_usage ;; 1735296415Sdes --help) func_help ;; 1736296415Sdes 1737296415Sdes # Separate optargs to long options (plugins may need this): 1738296415Sdes --*=*) func_split_equals "$_G_opt" 1739296415Sdes set dummy "$func_split_equals_lhs" \ 1740296415Sdes "$func_split_equals_rhs" ${1+"$@"} 1741296415Sdes shift 1742296415Sdes ;; 1743296415Sdes 1744296415Sdes # Separate optargs to short options: 1745296415Sdes -W*) 1746296415Sdes func_split_short_opt "$_G_opt" 1747296415Sdes set dummy "$func_split_short_opt_name" \ 1748296415Sdes "$func_split_short_opt_arg" ${1+"$@"} 1749296415Sdes shift 1750296415Sdes ;; 1751296415Sdes 1752296415Sdes # Separate non-argument short options: 1753296415Sdes -\?*|-h*|-v*|-x*) 1754296415Sdes func_split_short_opt "$_G_opt" 1755296415Sdes set dummy "$func_split_short_opt_name" \ 1756296415Sdes "-$func_split_short_opt_arg" ${1+"$@"} 1757296415Sdes shift 1758296415Sdes ;; 1759296415Sdes 1760296415Sdes --) break ;; 1761296415Sdes -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762296415Sdes *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763296415Sdes esac 1764296415Sdes done 1765296415Sdes 1766296415Sdes # save modified positional parameters for caller 1767296415Sdes func_quote_for_eval ${1+"$@"} 1768296415Sdes func_parse_options_result=$func_quote_for_eval_result 1769296415Sdes} 1770296415Sdes 1771296415Sdes 1772296415Sdes# func_validate_options [ARG]... 1773296415Sdes# ------------------------------ 1774296415Sdes# Perform any sanity checks on option settings and/or unconsumed 1775296415Sdes# arguments. 1776296415Sdesfunc_hookable func_validate_options 1777296415Sdesfunc_validate_options () 1778296415Sdes{ 1779296415Sdes $debug_cmd 1780296415Sdes 1781296415Sdes # Display all warnings if -W was not given. 1782296415Sdes test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783296415Sdes 1784296415Sdes func_run_hooks func_validate_options ${1+"$@"} 1785296415Sdes 1786296415Sdes # Bail if the options were screwed! 1787296415Sdes $exit_cmd $EXIT_FAILURE 1788296415Sdes 1789296415Sdes # save modified positional parameters for caller 1790296415Sdes func_validate_options_result=$func_run_hooks_result 1791296415Sdes} 1792296415Sdes 1793296415Sdes 1794296415Sdes 1795296415Sdes## ----------------- ## 1796296415Sdes## Helper functions. ## 1797296415Sdes## ----------------- ## 1798296415Sdes 1799296415Sdes# This section contains the helper functions used by the rest of the 1800296415Sdes# hookable option parser framework in ascii-betical order. 1801296415Sdes 1802296415Sdes 1803296415Sdes# func_fatal_help ARG... 1804296415Sdes# ---------------------- 1805296415Sdes# Echo program name prefixed message to standard error, followed by 1806296415Sdes# a help hint, and exit. 1807296415Sdesfunc_fatal_help () 1808296415Sdes{ 1809296415Sdes $debug_cmd 1810296415Sdes 1811296415Sdes eval \$ECHO \""Usage: $usage"\" 1812296415Sdes eval \$ECHO \""$fatal_help"\" 1813296415Sdes func_error ${1+"$@"} 1814296415Sdes exit $EXIT_FAILURE 1815296415Sdes} 1816296415Sdes 1817296415Sdes 1818296415Sdes# func_help 1819296415Sdes# --------- 1820296415Sdes# Echo long help message to standard output and exit. 1821238106Sdesfunc_help () 1822238106Sdes{ 1823296415Sdes $debug_cmd 1824238106Sdes 1825296415Sdes func_usage_message 1826296415Sdes $ECHO "$long_help_message" 1827296415Sdes exit 0 1828238106Sdes} 1829238106Sdes 1830296415Sdes 1831296415Sdes# func_missing_arg ARGNAME 1832296415Sdes# ------------------------ 1833238106Sdes# Echo program name prefixed message to standard error and set global 1834238106Sdes# exit_cmd. 1835238106Sdesfunc_missing_arg () 1836238106Sdes{ 1837296415Sdes $debug_cmd 1838238106Sdes 1839296415Sdes func_error "Missing argument for '$1'." 1840238106Sdes exit_cmd=exit 1841238106Sdes} 1842238106Sdes 1843238106Sdes 1844296415Sdes# func_split_equals STRING 1845296415Sdes# ------------------------ 1846296415Sdes# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847296415Sdes# splitting STRING at the '=' sign. 1848296415Sdestest -z "$_G_HAVE_XSI_OPS" \ 1849296415Sdes && (eval 'x=a/b/c; 1850296415Sdes test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851296415Sdes && _G_HAVE_XSI_OPS=yes 1852296415Sdes 1853296415Sdesif test yes = "$_G_HAVE_XSI_OPS" 1854296415Sdesthen 1855296415Sdes # This is an XSI compatible shell, allowing a faster implementation... 1856296415Sdes eval 'func_split_equals () 1857296415Sdes { 1858296415Sdes $debug_cmd 1859296415Sdes 1860296415Sdes func_split_equals_lhs=${1%%=*} 1861296415Sdes func_split_equals_rhs=${1#*=} 1862296415Sdes test "x$func_split_equals_lhs" = "x$1" \ 1863296415Sdes && func_split_equals_rhs= 1864296415Sdes }' 1865296415Sdeselse 1866296415Sdes # ...otherwise fall back to using expr, which is often a shell builtin. 1867296415Sdes func_split_equals () 1868296415Sdes { 1869296415Sdes $debug_cmd 1870296415Sdes 1871296415Sdes func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872296415Sdes func_split_equals_rhs= 1873296415Sdes test "x$func_split_equals_lhs" = "x$1" \ 1874296415Sdes || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875296415Sdes } 1876296415Sdesfi #func_split_equals 1877296415Sdes 1878296415Sdes 1879296415Sdes# func_split_short_opt SHORTOPT 1880296415Sdes# ----------------------------- 1881238106Sdes# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882238106Sdes# variables after splitting SHORTOPT after the 2nd character. 1883296415Sdesif test yes = "$_G_HAVE_XSI_OPS" 1884296415Sdesthen 1885296415Sdes # This is an XSI compatible shell, allowing a faster implementation... 1886296415Sdes eval 'func_split_short_opt () 1887296415Sdes { 1888296415Sdes $debug_cmd 1889296415Sdes 1890296415Sdes func_split_short_opt_arg=${1#??} 1891296415Sdes func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892296415Sdes }' 1893296415Sdeselse 1894296415Sdes # ...otherwise fall back to using expr, which is often a shell builtin. 1895296415Sdes func_split_short_opt () 1896296415Sdes { 1897296415Sdes $debug_cmd 1898296415Sdes 1899296415Sdes func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900296415Sdes func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901296415Sdes } 1902296415Sdesfi #func_split_short_opt 1903296415Sdes 1904296415Sdes 1905296415Sdes# func_usage 1906296415Sdes# ---------- 1907296415Sdes# Echo short help message to standard output and exit. 1908296415Sdesfunc_usage () 1909238106Sdes{ 1910296415Sdes $debug_cmd 1911238106Sdes 1912296415Sdes func_usage_message 1913296415Sdes $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914296415Sdes exit 0 1915296415Sdes} 1916238106Sdes 1917238106Sdes 1918296415Sdes# func_usage_message 1919296415Sdes# ------------------ 1920296415Sdes# Echo short help message to standard output. 1921296415Sdesfunc_usage_message () 1922238106Sdes{ 1923296415Sdes $debug_cmd 1924238106Sdes 1925296415Sdes eval \$ECHO \""Usage: $usage"\" 1926296415Sdes echo 1927296415Sdes $SED -n 's|^# || 1928296415Sdes /^Written by/{ 1929296415Sdes x;p;x 1930296415Sdes } 1931296415Sdes h 1932296415Sdes /^Written by/q' < "$progpath" 1933296415Sdes echo 1934296415Sdes eval \$ECHO \""$usage_message"\" 1935296415Sdes} 1936238106Sdes 1937238106Sdes 1938296415Sdes# func_version 1939296415Sdes# ------------ 1940296415Sdes# Echo version message to standard output and exit. 1941296415Sdesfunc_version () 1942296415Sdes{ 1943296415Sdes $debug_cmd 1944238106Sdes 1945296415Sdes printf '%s\n' "$progname $scriptversion" 1946296415Sdes $SED -n ' 1947296415Sdes /(C)/!b go 1948296415Sdes :more 1949296415Sdes /\./!{ 1950296415Sdes N 1951296415Sdes s|\n# | | 1952296415Sdes b more 1953296415Sdes } 1954296415Sdes :go 1955296415Sdes /^# Written by /,/# warranty; / { 1956296415Sdes s|^# || 1957296415Sdes s|^# *$|| 1958296415Sdes s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959296415Sdes p 1960296415Sdes } 1961296415Sdes /^# Written by / { 1962296415Sdes s|^# || 1963296415Sdes p 1964296415Sdes } 1965296415Sdes /^warranty; /q' < "$progpath" 1966238106Sdes 1967296415Sdes exit $? 1968296415Sdes} 1969238106Sdes 1970238106Sdes 1971296415Sdes# Local variables: 1972296415Sdes# mode: shell-script 1973296415Sdes# sh-indentation: 2 1974296415Sdes# eval: (add-hook 'before-save-hook 'time-stamp) 1975296415Sdes# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976296415Sdes# time-stamp-time-zone: "UTC" 1977296415Sdes# End: 1978238106Sdes 1979296415Sdes# Set a version string. 1980296415Sdesscriptversion='(GNU libtool) 2.4.6' 1981238106Sdes 1982238106Sdes 1983296415Sdes# func_echo ARG... 1984296415Sdes# ---------------- 1985296415Sdes# Libtool also displays the current mode in messages, so override 1986296415Sdes# funclib.sh func_echo with this custom definition. 1987296415Sdesfunc_echo () 1988238106Sdes{ 1989296415Sdes $debug_cmd 1990238106Sdes 1991296415Sdes _G_message=$* 1992238106Sdes 1993296415Sdes func_echo_IFS=$IFS 1994296415Sdes IFS=$nl 1995296415Sdes for _G_line in $_G_message; do 1996296415Sdes IFS=$func_echo_IFS 1997296415Sdes $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998296415Sdes done 1999296415Sdes IFS=$func_echo_IFS 2000296415Sdes} 2001238106Sdes 2002296415Sdes 2003296415Sdes# func_warning ARG... 2004296415Sdes# ------------------- 2005296415Sdes# Libtool warnings are not categorized, so override funclib.sh 2006296415Sdes# func_warning with this simpler definition. 2007296415Sdesfunc_warning () 2008238106Sdes{ 2009296415Sdes $debug_cmd 2010238106Sdes 2011296415Sdes $warning_func ${1+"$@"} 2012296415Sdes} 2013238106Sdes 2014238106Sdes 2015296415Sdes## ---------------- ## 2016296415Sdes## Options parsing. ## 2017296415Sdes## ---------------- ## 2018238106Sdes 2019296415Sdes# Hook in the functions to make sure our own options are parsed during 2020296415Sdes# the option parsing loop. 2021238106Sdes 2022296415Sdesusage='$progpath [OPTION]... [MODE-ARG]...' 2023238106Sdes 2024296415Sdes# Short help message in response to '-h'. 2025296415Sdesusage_message="Options: 2026296415Sdes --config show all configuration variables 2027296415Sdes --debug enable verbose shell tracing 2028296415Sdes -n, --dry-run display commands without modifying any files 2029296415Sdes --features display basic configuration information and exit 2030296415Sdes --mode=MODE use operation mode MODE 2031296415Sdes --no-warnings equivalent to '-Wnone' 2032296415Sdes --preserve-dup-deps don't remove duplicate dependency libraries 2033296415Sdes --quiet, --silent don't print informational messages 2034296415Sdes --tag=TAG use configuration variables from tag TAG 2035296415Sdes -v, --verbose print more informational messages than default 2036296415Sdes --version print version information 2037296415Sdes -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038296415Sdes -h, --help, --help-all print short, long, or detailed help message 2039296415Sdes" 2040296415Sdes 2041296415Sdes# Additional text appended to 'usage_message' in response to '--help'. 2042296415Sdesfunc_help () 2043238106Sdes{ 2044296415Sdes $debug_cmd 2045238106Sdes 2046296415Sdes func_usage_message 2047296415Sdes $ECHO "$long_help_message 2048238106Sdes 2049296415SdesMODE must be one of the following: 2050296415Sdes 2051296415Sdes clean remove files from the build directory 2052296415Sdes compile compile a source file into a libtool object 2053296415Sdes execute automatically set library path, then run a program 2054296415Sdes finish complete the installation of libtool libraries 2055296415Sdes install install libraries or executables 2056296415Sdes link create a library or an executable 2057296415Sdes uninstall remove libraries from an installed directory 2058296415Sdes 2059296415SdesMODE-ARGS vary depending on the MODE. When passed as first option, 2060296415Sdes'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061296415SdesTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062296415Sdes 2063296415SdesWhen reporting a bug, please describe a test case to reproduce it and 2064296415Sdesinclude the following information: 2065296415Sdes 2066296415Sdes host-triplet: $host 2067296415Sdes shell: $SHELL 2068296415Sdes compiler: $LTCC 2069296415Sdes compiler flags: $LTCFLAGS 2070296415Sdes linker: $LD (gnu? $with_gnu_ld) 2071296415Sdes version: $progname (GNU libtool) 2.4.6 2072296415Sdes automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073296415Sdes autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074296415Sdes 2075296415SdesReport bugs to <bug-libtool@gnu.org>. 2076296415SdesGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2077296415SdesGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078296415Sdes exit 0 2079296415Sdes} 2080296415Sdes 2081296415Sdes 2082296415Sdes# func_lo2o OBJECT-NAME 2083296415Sdes# --------------------- 2084296415Sdes# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085296415Sdes# object suffix. 2086296415Sdes 2087296415Sdeslo2o=s/\\.lo\$/.$objext/ 2088296415Sdeso2lo=s/\\.$objext\$/.lo/ 2089296415Sdes 2090296415Sdesif test yes = "$_G_HAVE_XSI_OPS"; then 2091296415Sdes eval 'func_lo2o () 2092296415Sdes { 2093296415Sdes case $1 in 2094296415Sdes *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095296415Sdes * ) func_lo2o_result=$1 ;; 2096296415Sdes esac 2097296415Sdes }' 2098296415Sdes 2099296415Sdes # func_xform LIBOBJ-OR-SOURCE 2100296415Sdes # --------------------------- 2101296415Sdes # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102296415Sdes # suffix to a '.lo' libtool-object suffix. 2103296415Sdes eval 'func_xform () 2104296415Sdes { 2105296415Sdes func_xform_result=${1%.*}.lo 2106296415Sdes }' 2107296415Sdeselse 2108296415Sdes # ...otherwise fall back to using sed. 2109296415Sdes func_lo2o () 2110296415Sdes { 2111296415Sdes func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112296415Sdes } 2113296415Sdes 2114296415Sdes func_xform () 2115296415Sdes { 2116296415Sdes func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117296415Sdes } 2118296415Sdesfi 2119296415Sdes 2120296415Sdes 2121296415Sdes# func_fatal_configuration ARG... 2122296415Sdes# ------------------------------- 2123238106Sdes# Echo program name prefixed message to standard error, followed by 2124238106Sdes# a configuration failure hint, and exit. 2125238106Sdesfunc_fatal_configuration () 2126238106Sdes{ 2127356345Scy func_fatal_error ${1+"$@"} \ 2128296415Sdes "See the $PACKAGE documentation for more information." \ 2129296415Sdes "Fatal configuration error." 2130238106Sdes} 2131238106Sdes 2132238106Sdes 2133238106Sdes# func_config 2134296415Sdes# ----------- 2135238106Sdes# Display the configuration for all the tags in this script. 2136238106Sdesfunc_config () 2137238106Sdes{ 2138238106Sdes re_begincf='^# ### BEGIN LIBTOOL' 2139238106Sdes re_endcf='^# ### END LIBTOOL' 2140238106Sdes 2141238106Sdes # Default configuration. 2142238106Sdes $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143238106Sdes 2144238106Sdes # Now print the configurations for the tags. 2145238106Sdes for tagname in $taglist; do 2146238106Sdes $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147238106Sdes done 2148238106Sdes 2149238106Sdes exit $? 2150238106Sdes} 2151238106Sdes 2152296415Sdes 2153238106Sdes# func_features 2154296415Sdes# ------------- 2155238106Sdes# Display the features supported by this script. 2156238106Sdesfunc_features () 2157238106Sdes{ 2158238106Sdes echo "host: $host" 2159296415Sdes if test yes = "$build_libtool_libs"; then 2160238106Sdes echo "enable shared libraries" 2161238106Sdes else 2162238106Sdes echo "disable shared libraries" 2163238106Sdes fi 2164296415Sdes if test yes = "$build_old_libs"; then 2165238106Sdes echo "enable static libraries" 2166238106Sdes else 2167238106Sdes echo "disable static libraries" 2168238106Sdes fi 2169238106Sdes 2170238106Sdes exit $? 2171238106Sdes} 2172238106Sdes 2173296415Sdes 2174296415Sdes# func_enable_tag TAGNAME 2175296415Sdes# ----------------------- 2176238106Sdes# Verify that TAGNAME is valid, and either flag an error and exit, or 2177238106Sdes# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178238106Sdes# variable here. 2179238106Sdesfunc_enable_tag () 2180238106Sdes{ 2181296415Sdes # Global variable: 2182296415Sdes tagname=$1 2183238106Sdes 2184296415Sdes re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185296415Sdes re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186296415Sdes sed_extractcf=/$re_begincf/,/$re_endcf/p 2187238106Sdes 2188296415Sdes # Validate tagname. 2189296415Sdes case $tagname in 2190296415Sdes *[!-_A-Za-z0-9,/]*) 2191296415Sdes func_fatal_error "invalid tag name: $tagname" 2192296415Sdes ;; 2193296415Sdes esac 2194238106Sdes 2195296415Sdes # Don't test for the "default" C tag, as we know it's 2196296415Sdes # there but not specially marked. 2197296415Sdes case $tagname in 2198296415Sdes CC) ;; 2199238106Sdes *) 2200296415Sdes if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201296415Sdes taglist="$taglist $tagname" 2202238106Sdes 2203296415Sdes # Evaluate the configuration. Be careful to quote the path 2204296415Sdes # and the sed script, to avoid splitting on whitespace, but 2205296415Sdes # also don't use non-portable quotes within backquotes within 2206296415Sdes # quotes we have to do it in 2 steps: 2207296415Sdes extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208296415Sdes eval "$extractedcf" 2209296415Sdes else 2210296415Sdes func_error "ignoring unknown tag $tagname" 2211296415Sdes fi 2212296415Sdes ;; 2213296415Sdes esac 2214238106Sdes} 2215238106Sdes 2216296415Sdes 2217238106Sdes# func_check_version_match 2218296415Sdes# ------------------------ 2219238106Sdes# Ensure that we are using m4 macros, and libtool script from the same 2220238106Sdes# release of libtool. 2221238106Sdesfunc_check_version_match () 2222238106Sdes{ 2223296415Sdes if test "$package_revision" != "$macro_revision"; then 2224296415Sdes if test "$VERSION" != "$macro_version"; then 2225296415Sdes if test -z "$macro_version"; then 2226296415Sdes cat >&2 <<_LT_EOF 2227238106Sdes$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228238106Sdes$progname: definition of this LT_INIT comes from an older release. 2229238106Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230238106Sdes$progname: and run autoconf again. 2231238106Sdes_LT_EOF 2232296415Sdes else 2233296415Sdes cat >&2 <<_LT_EOF 2234238106Sdes$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235238106Sdes$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236238106Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237238106Sdes$progname: and run autoconf again. 2238238106Sdes_LT_EOF 2239296415Sdes fi 2240296415Sdes else 2241296415Sdes cat >&2 <<_LT_EOF 2242238106Sdes$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243238106Sdes$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244238106Sdes$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245238106Sdes$progname: of $PACKAGE $VERSION and run autoconf again. 2246238106Sdes_LT_EOF 2247296415Sdes fi 2248296415Sdes 2249296415Sdes exit $EXIT_MISMATCH 2250238106Sdes fi 2251238106Sdes} 2252238106Sdes 2253238106Sdes 2254296415Sdes# libtool_options_prep [ARG]... 2255296415Sdes# ----------------------------- 2256296415Sdes# Preparation for options parsed by libtool. 2257296415Sdeslibtool_options_prep () 2258296415Sdes{ 2259296415Sdes $debug_mode 2260238106Sdes 2261296415Sdes # Option defaults: 2262296415Sdes opt_config=false 2263296415Sdes opt_dlopen= 2264296415Sdes opt_dry_run=false 2265296415Sdes opt_help=false 2266296415Sdes opt_mode= 2267296415Sdes opt_preserve_dup_deps=false 2268296415Sdes opt_quiet=false 2269238106Sdes 2270296415Sdes nonopt= 2271296415Sdes preserve_args= 2272238106Sdes 2273296415Sdes # Shorthand for --mode=foo, only valid as the first argument 2274296415Sdes case $1 in 2275296415Sdes clean|clea|cle|cl) 2276296415Sdes shift; set dummy --mode clean ${1+"$@"}; shift 2277296415Sdes ;; 2278296415Sdes compile|compil|compi|comp|com|co|c) 2279296415Sdes shift; set dummy --mode compile ${1+"$@"}; shift 2280296415Sdes ;; 2281296415Sdes execute|execut|execu|exec|exe|ex|e) 2282296415Sdes shift; set dummy --mode execute ${1+"$@"}; shift 2283296415Sdes ;; 2284296415Sdes finish|finis|fini|fin|fi|f) 2285296415Sdes shift; set dummy --mode finish ${1+"$@"}; shift 2286296415Sdes ;; 2287296415Sdes install|instal|insta|inst|ins|in|i) 2288296415Sdes shift; set dummy --mode install ${1+"$@"}; shift 2289296415Sdes ;; 2290296415Sdes link|lin|li|l) 2291296415Sdes shift; set dummy --mode link ${1+"$@"}; shift 2292296415Sdes ;; 2293296415Sdes uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294296415Sdes shift; set dummy --mode uninstall ${1+"$@"}; shift 2295296415Sdes ;; 2296296415Sdes esac 2297238106Sdes 2298296415Sdes # Pass back the list of options. 2299296415Sdes func_quote_for_eval ${1+"$@"} 2300296415Sdes libtool_options_prep_result=$func_quote_for_eval_result 2301296415Sdes} 2302296415Sdesfunc_add_hook func_options_prep libtool_options_prep 2303238106Sdes 2304296415Sdes 2305296415Sdes# libtool_parse_options [ARG]... 2306296415Sdes# --------------------------------- 2307296415Sdes# Provide handling for libtool specific options. 2308296415Sdeslibtool_parse_options () 2309238106Sdes{ 2310296415Sdes $debug_cmd 2311238106Sdes 2312296415Sdes # Perform our own loop to consume as many options as possible in 2313296415Sdes # each iteration. 2314296415Sdes while test $# -gt 0; do 2315296415Sdes _G_opt=$1 2316296415Sdes shift 2317296415Sdes case $_G_opt in 2318296415Sdes --dry-run|--dryrun|-n) 2319296415Sdes opt_dry_run=: 2320296415Sdes ;; 2321238106Sdes 2322296415Sdes --config) func_config ;; 2323238106Sdes 2324296415Sdes --dlopen|-dlopen) 2325296415Sdes opt_dlopen="${opt_dlopen+$opt_dlopen 2326296415Sdes}$1" 2327296415Sdes shift 2328296415Sdes ;; 2329238106Sdes 2330296415Sdes --preserve-dup-deps) 2331296415Sdes opt_preserve_dup_deps=: ;; 2332238106Sdes 2333296415Sdes --features) func_features ;; 2334238106Sdes 2335296415Sdes --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336238106Sdes 2337296415Sdes --help) opt_help=: ;; 2338238106Sdes 2339296415Sdes --help-all) opt_help=': help-all' ;; 2340238106Sdes 2341296415Sdes --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342296415Sdes opt_mode=$1 2343296415Sdes case $1 in 2344296415Sdes # Valid mode arguments: 2345296415Sdes clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346238106Sdes 2347296415Sdes # Catch anything else as an error 2348296415Sdes *) func_error "invalid argument for $_G_opt" 2349296415Sdes exit_cmd=exit 2350296415Sdes break 2351296415Sdes ;; 2352296415Sdes esac 2353296415Sdes shift 2354296415Sdes ;; 2355238106Sdes 2356296415Sdes --no-silent|--no-quiet) 2357296415Sdes opt_quiet=false 2358296415Sdes func_append preserve_args " $_G_opt" 2359296415Sdes ;; 2360238106Sdes 2361296415Sdes --no-warnings|--no-warning|--no-warn) 2362296415Sdes opt_warning=false 2363296415Sdes func_append preserve_args " $_G_opt" 2364296415Sdes ;; 2365238106Sdes 2366296415Sdes --no-verbose) 2367296415Sdes opt_verbose=false 2368296415Sdes func_append preserve_args " $_G_opt" 2369296415Sdes ;; 2370296415Sdes 2371296415Sdes --silent|--quiet) 2372296415Sdes opt_quiet=: 2373296415Sdes opt_verbose=false 2374296415Sdes func_append preserve_args " $_G_opt" 2375296415Sdes ;; 2376296415Sdes 2377296415Sdes --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378296415Sdes opt_tag=$1 2379296415Sdes func_append preserve_args " $_G_opt $1" 2380296415Sdes func_enable_tag "$1" 2381296415Sdes shift 2382296415Sdes ;; 2383296415Sdes 2384296415Sdes --verbose|-v) opt_quiet=false 2385296415Sdes opt_verbose=: 2386296415Sdes func_append preserve_args " $_G_opt" 2387296415Sdes ;; 2388296415Sdes 2389296415Sdes # An option not handled by this hook function: 2390296415Sdes *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391296415Sdes esac 2392296415Sdes done 2393296415Sdes 2394296415Sdes 2395296415Sdes # save modified positional parameters for caller 2396296415Sdes func_quote_for_eval ${1+"$@"} 2397296415Sdes libtool_parse_options_result=$func_quote_for_eval_result 2398296415Sdes} 2399296415Sdesfunc_add_hook func_parse_options libtool_parse_options 2400296415Sdes 2401296415Sdes 2402296415Sdes 2403296415Sdes# libtool_validate_options [ARG]... 2404296415Sdes# --------------------------------- 2405296415Sdes# Perform any sanity checks on option settings and/or unconsumed 2406296415Sdes# arguments. 2407296415Sdeslibtool_validate_options () 2408296415Sdes{ 2409296415Sdes # save first non-option argument 2410296415Sdes if test 0 -lt $#; then 2411296415Sdes nonopt=$1 2412296415Sdes shift 2413238106Sdes fi 2414238106Sdes 2415296415Sdes # preserve --debug 2416296415Sdes test : = "$debug_cmd" || func_append preserve_args " --debug" 2417238106Sdes 2418296415Sdes case $host in 2419296415Sdes # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420296415Sdes # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421296415Sdes *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422296415Sdes # don't eliminate duplications in $postdeps and $predeps 2423296415Sdes opt_duplicate_compiler_generated_deps=: 2424296415Sdes ;; 2425296415Sdes *) 2426296415Sdes opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427296415Sdes ;; 2428296415Sdes esac 2429238106Sdes 2430296415Sdes $opt_help || { 2431296415Sdes # Sanity checks first: 2432296415Sdes func_check_version_match 2433296415Sdes 2434296415Sdes test yes != "$build_libtool_libs" \ 2435296415Sdes && test yes != "$build_old_libs" \ 2436296415Sdes && func_fatal_configuration "not configured to build any kind of library" 2437296415Sdes 2438296415Sdes # Darwin sucks 2439296415Sdes eval std_shrext=\"$shrext_cmds\" 2440296415Sdes 2441296415Sdes # Only execute mode is allowed to have -dlopen flags. 2442296415Sdes if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443296415Sdes func_error "unrecognized option '-dlopen'" 2444296415Sdes $ECHO "$help" 1>&2 2445296415Sdes exit $EXIT_FAILURE 2446296415Sdes fi 2447296415Sdes 2448296415Sdes # Change the help message to a mode-specific one. 2449296415Sdes generic_help=$help 2450296415Sdes help="Try '$progname --help --mode=$opt_mode' for more information." 2451296415Sdes } 2452296415Sdes 2453296415Sdes # Pass back the unparsed argument list 2454296415Sdes func_quote_for_eval ${1+"$@"} 2455296415Sdes libtool_validate_options_result=$func_quote_for_eval_result 2456238106Sdes} 2457296415Sdesfunc_add_hook func_validate_options libtool_validate_options 2458238106Sdes 2459238106Sdes 2460296415Sdes# Process options as early as possible so that --help and --version 2461296415Sdes# can return quickly. 2462296415Sdesfunc_options ${1+"$@"} 2463296415Sdeseval set dummy "$func_options_result"; shift 2464238106Sdes 2465238106Sdes 2466296415Sdes 2467238106Sdes## ----------- ## 2468238106Sdes## Main. ## 2469238106Sdes## ----------- ## 2470238106Sdes 2471296415Sdesmagic='%%%MAGIC variable%%%' 2472296415Sdesmagic_exe='%%%MAGIC EXE variable%%%' 2473296415Sdes 2474296415Sdes# Global variables. 2475296415Sdesextracted_archives= 2476296415Sdesextracted_serial=0 2477296415Sdes 2478296415Sdes# If this variable is set in any of the actions, the command in it 2479296415Sdes# will be execed at the end. This prevents here-documents from being 2480296415Sdes# left over by shells. 2481296415Sdesexec_cmd= 2482296415Sdes 2483296415Sdes 2484296415Sdes# A function that is used when there is no print builtin or printf. 2485296415Sdesfunc_fallback_echo () 2486296415Sdes{ 2487296415Sdes eval 'cat <<_LTECHO_EOF 2488296415Sdes$1 2489296415Sdes_LTECHO_EOF' 2490296415Sdes} 2491296415Sdes 2492296415Sdes# func_generated_by_libtool 2493296415Sdes# True iff stdin has been generated by Libtool. This function is only 2494296415Sdes# a basic sanity check; it will hardly flush out determined imposters. 2495296415Sdesfunc_generated_by_libtool_p () 2496296415Sdes{ 2497296415Sdes $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498296415Sdes} 2499296415Sdes 2500238106Sdes# func_lalib_p file 2501296415Sdes# True iff FILE is a libtool '.la' library or '.lo' object file. 2502238106Sdes# This function is only a basic sanity check; it will hardly flush out 2503238106Sdes# determined imposters. 2504238106Sdesfunc_lalib_p () 2505238106Sdes{ 2506238106Sdes test -f "$1" && 2507296415Sdes $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508238106Sdes} 2509238106Sdes 2510238106Sdes# func_lalib_unsafe_p file 2511296415Sdes# True iff FILE is a libtool '.la' library or '.lo' object file. 2512238106Sdes# This function implements the same check as func_lalib_p without 2513238106Sdes# resorting to external programs. To this end, it redirects stdin and 2514238106Sdes# closes it afterwards, without saving the original file descriptor. 2515238106Sdes# As a safety measure, use it only where a negative result would be 2516296415Sdes# fatal anyway. Works if 'file' does not exist. 2517238106Sdesfunc_lalib_unsafe_p () 2518238106Sdes{ 2519238106Sdes lalib_p=no 2520238106Sdes if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521238106Sdes for lalib_p_l in 1 2 3 4 2522238106Sdes do 2523238106Sdes read lalib_p_line 2524296415Sdes case $lalib_p_line in 2525238106Sdes \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526238106Sdes esac 2527238106Sdes done 2528238106Sdes exec 0<&5 5<&- 2529238106Sdes fi 2530296415Sdes test yes = "$lalib_p" 2531238106Sdes} 2532238106Sdes 2533238106Sdes# func_ltwrapper_script_p file 2534238106Sdes# True iff FILE is a libtool wrapper script 2535238106Sdes# This function is only a basic sanity check; it will hardly flush out 2536238106Sdes# determined imposters. 2537238106Sdesfunc_ltwrapper_script_p () 2538238106Sdes{ 2539296415Sdes test -f "$1" && 2540296415Sdes $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541238106Sdes} 2542238106Sdes 2543238106Sdes# func_ltwrapper_executable_p file 2544238106Sdes# True iff FILE is a libtool wrapper executable 2545238106Sdes# This function is only a basic sanity check; it will hardly flush out 2546238106Sdes# determined imposters. 2547238106Sdesfunc_ltwrapper_executable_p () 2548238106Sdes{ 2549238106Sdes func_ltwrapper_exec_suffix= 2550238106Sdes case $1 in 2551238106Sdes *.exe) ;; 2552238106Sdes *) func_ltwrapper_exec_suffix=.exe ;; 2553238106Sdes esac 2554238106Sdes $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555238106Sdes} 2556238106Sdes 2557238106Sdes# func_ltwrapper_scriptname file 2558238106Sdes# Assumes file is an ltwrapper_executable 2559238106Sdes# uses $file to determine the appropriate filename for a 2560238106Sdes# temporary ltwrapper_script. 2561238106Sdesfunc_ltwrapper_scriptname () 2562238106Sdes{ 2563238106Sdes func_dirname_and_basename "$1" "" "." 2564238106Sdes func_stripname '' '.exe' "$func_basename_result" 2565296415Sdes func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566238106Sdes} 2567238106Sdes 2568238106Sdes# func_ltwrapper_p file 2569238106Sdes# True iff FILE is a libtool wrapper script or wrapper executable 2570238106Sdes# This function is only a basic sanity check; it will hardly flush out 2571238106Sdes# determined imposters. 2572238106Sdesfunc_ltwrapper_p () 2573238106Sdes{ 2574238106Sdes func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575238106Sdes} 2576238106Sdes 2577238106Sdes 2578238106Sdes# func_execute_cmds commands fail_cmd 2579238106Sdes# Execute tilde-delimited COMMANDS. 2580238106Sdes# If FAIL_CMD is given, eval that upon failure. 2581238106Sdes# FAIL_CMD may read-access the current command in variable CMD! 2582238106Sdesfunc_execute_cmds () 2583238106Sdes{ 2584296415Sdes $debug_cmd 2585296415Sdes 2586238106Sdes save_ifs=$IFS; IFS='~' 2587238106Sdes for cmd in $1; do 2588296415Sdes IFS=$sp$nl 2589296415Sdes eval cmd=\"$cmd\" 2590238106Sdes IFS=$save_ifs 2591238106Sdes func_show_eval "$cmd" "${2-:}" 2592238106Sdes done 2593238106Sdes IFS=$save_ifs 2594238106Sdes} 2595238106Sdes 2596238106Sdes 2597238106Sdes# func_source file 2598238106Sdes# Source FILE, adding directory component if necessary. 2599238106Sdes# Note that it is not necessary on cygwin/mingw to append a dot to 2600238106Sdes# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601238106Sdes# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602296415Sdes# 'FILE.' does not work on cygwin managed mounts. 2603238106Sdesfunc_source () 2604238106Sdes{ 2605296415Sdes $debug_cmd 2606296415Sdes 2607238106Sdes case $1 in 2608238106Sdes */* | *\\*) . "$1" ;; 2609238106Sdes *) . "./$1" ;; 2610238106Sdes esac 2611238106Sdes} 2612238106Sdes 2613238106Sdes 2614238106Sdes# func_resolve_sysroot PATH 2615238106Sdes# Replace a leading = in PATH with a sysroot. Store the result into 2616238106Sdes# func_resolve_sysroot_result 2617238106Sdesfunc_resolve_sysroot () 2618238106Sdes{ 2619238106Sdes func_resolve_sysroot_result=$1 2620238106Sdes case $func_resolve_sysroot_result in 2621238106Sdes =*) 2622238106Sdes func_stripname '=' '' "$func_resolve_sysroot_result" 2623238106Sdes func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624238106Sdes ;; 2625238106Sdes esac 2626238106Sdes} 2627238106Sdes 2628238106Sdes# func_replace_sysroot PATH 2629238106Sdes# If PATH begins with the sysroot, replace it with = and 2630238106Sdes# store the result into func_replace_sysroot_result. 2631238106Sdesfunc_replace_sysroot () 2632238106Sdes{ 2633296415Sdes case $lt_sysroot:$1 in 2634238106Sdes ?*:"$lt_sysroot"*) 2635238106Sdes func_stripname "$lt_sysroot" '' "$1" 2636296415Sdes func_replace_sysroot_result='='$func_stripname_result 2637238106Sdes ;; 2638238106Sdes *) 2639238106Sdes # Including no sysroot. 2640238106Sdes func_replace_sysroot_result=$1 2641238106Sdes ;; 2642238106Sdes esac 2643238106Sdes} 2644238106Sdes 2645238106Sdes# func_infer_tag arg 2646238106Sdes# Infer tagged configuration to use if any are available and 2647238106Sdes# if one wasn't chosen via the "--tag" command line option. 2648238106Sdes# Only attempt this if the compiler in the base compile 2649238106Sdes# command doesn't match the default compiler. 2650238106Sdes# arg is usually of the form 'gcc ...' 2651238106Sdesfunc_infer_tag () 2652238106Sdes{ 2653296415Sdes $debug_cmd 2654296415Sdes 2655238106Sdes if test -n "$available_tags" && test -z "$tagname"; then 2656238106Sdes CC_quoted= 2657238106Sdes for arg in $CC; do 2658238106Sdes func_append_quoted CC_quoted "$arg" 2659238106Sdes done 2660238106Sdes CC_expanded=`func_echo_all $CC` 2661238106Sdes CC_quoted_expanded=`func_echo_all $CC_quoted` 2662238106Sdes case $@ in 2663238106Sdes # Blanks in the command may have been stripped by the calling shell, 2664238106Sdes # but not from the CC environment variable when configure was run. 2665238106Sdes " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666238106Sdes " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667238106Sdes # Blanks at the start of $base_compile will cause this to fail 2668238106Sdes # if we don't check for them as well. 2669238106Sdes *) 2670238106Sdes for z in $available_tags; do 2671238106Sdes if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672238106Sdes # Evaluate the configuration. 2673296415Sdes eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674238106Sdes CC_quoted= 2675238106Sdes for arg in $CC; do 2676238106Sdes # Double-quote args containing other shell metacharacters. 2677238106Sdes func_append_quoted CC_quoted "$arg" 2678238106Sdes done 2679238106Sdes CC_expanded=`func_echo_all $CC` 2680238106Sdes CC_quoted_expanded=`func_echo_all $CC_quoted` 2681238106Sdes case "$@ " in 2682238106Sdes " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683238106Sdes " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684238106Sdes # The compiler in the base compile command matches 2685238106Sdes # the one in the tagged configuration. 2686238106Sdes # Assume this is the tagged configuration we want. 2687238106Sdes tagname=$z 2688238106Sdes break 2689238106Sdes ;; 2690238106Sdes esac 2691238106Sdes fi 2692238106Sdes done 2693238106Sdes # If $tagname still isn't set, then no tagged configuration 2694238106Sdes # was found and let the user know that the "--tag" command 2695238106Sdes # line option must be used. 2696238106Sdes if test -z "$tagname"; then 2697238106Sdes func_echo "unable to infer tagged configuration" 2698296415Sdes func_fatal_error "specify a tag with '--tag'" 2699238106Sdes# else 2700238106Sdes# func_verbose "using $tagname tagged configuration" 2701238106Sdes fi 2702238106Sdes ;; 2703238106Sdes esac 2704238106Sdes fi 2705238106Sdes} 2706238106Sdes 2707238106Sdes 2708238106Sdes 2709238106Sdes# func_write_libtool_object output_name pic_name nonpic_name 2710238106Sdes# Create a libtool object file (analogous to a ".la" file), 2711238106Sdes# but don't create it if we're doing a dry run. 2712238106Sdesfunc_write_libtool_object () 2713238106Sdes{ 2714296415Sdes write_libobj=$1 2715296415Sdes if test yes = "$build_libtool_libs"; then 2716296415Sdes write_lobj=\'$2\' 2717238106Sdes else 2718238106Sdes write_lobj=none 2719238106Sdes fi 2720238106Sdes 2721296415Sdes if test yes = "$build_old_libs"; then 2722296415Sdes write_oldobj=\'$3\' 2723238106Sdes else 2724238106Sdes write_oldobj=none 2725238106Sdes fi 2726238106Sdes 2727238106Sdes $opt_dry_run || { 2728238106Sdes cat >${write_libobj}T <<EOF 2729238106Sdes# $write_libobj - a libtool object file 2730296415Sdes# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731238106Sdes# 2732238106Sdes# Please DO NOT delete this file! 2733238106Sdes# It is necessary for linking the library. 2734238106Sdes 2735238106Sdes# Name of the PIC object. 2736238106Sdespic_object=$write_lobj 2737238106Sdes 2738238106Sdes# Name of the non-PIC object 2739238106Sdesnon_pic_object=$write_oldobj 2740238106Sdes 2741238106SdesEOF 2742296415Sdes $MV "${write_libobj}T" "$write_libobj" 2743238106Sdes } 2744238106Sdes} 2745238106Sdes 2746238106Sdes 2747238106Sdes################################################## 2748238106Sdes# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749238106Sdes################################################## 2750238106Sdes 2751238106Sdes# func_convert_core_file_wine_to_w32 ARG 2752238106Sdes# Helper function used by file name conversion functions when $build is *nix, 2753238106Sdes# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754238106Sdes# correctly configured wine environment available, with the winepath program 2755238106Sdes# in $build's $PATH. 2756238106Sdes# 2757238106Sdes# ARG is the $build file name to be converted to w32 format. 2758238106Sdes# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759238106Sdes# be empty on error (or when ARG is empty) 2760238106Sdesfunc_convert_core_file_wine_to_w32 () 2761238106Sdes{ 2762296415Sdes $debug_cmd 2763296415Sdes 2764296415Sdes func_convert_core_file_wine_to_w32_result=$1 2765238106Sdes if test -n "$1"; then 2766238106Sdes # Unfortunately, winepath does not exit with a non-zero error code, so we 2767238106Sdes # are forced to check the contents of stdout. On the other hand, if the 2768238106Sdes # command is not found, the shell will set an exit code of 127 and print 2769238106Sdes # *an error message* to stdout. So we must check for both error code of 2770238106Sdes # zero AND non-empty stdout, which explains the odd construction: 2771238106Sdes func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772296415Sdes if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773238106Sdes func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774296415Sdes $SED -e "$sed_naive_backslashify"` 2775238106Sdes else 2776238106Sdes func_convert_core_file_wine_to_w32_result= 2777238106Sdes fi 2778238106Sdes fi 2779238106Sdes} 2780238106Sdes# end: func_convert_core_file_wine_to_w32 2781238106Sdes 2782238106Sdes 2783238106Sdes# func_convert_core_path_wine_to_w32 ARG 2784238106Sdes# Helper function used by path conversion functions when $build is *nix, and 2785238106Sdes# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786238106Sdes# configured wine environment available, with the winepath program in $build's 2787238106Sdes# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788238106Sdes# 2789238106Sdes# ARG is path to be converted from $build format to win32. 2790238106Sdes# Result is available in $func_convert_core_path_wine_to_w32_result. 2791238106Sdes# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792238106Sdes# are convertible, then the result may be empty. 2793238106Sdesfunc_convert_core_path_wine_to_w32 () 2794238106Sdes{ 2795296415Sdes $debug_cmd 2796296415Sdes 2797238106Sdes # unfortunately, winepath doesn't convert paths, only file names 2798296415Sdes func_convert_core_path_wine_to_w32_result= 2799238106Sdes if test -n "$1"; then 2800238106Sdes oldIFS=$IFS 2801238106Sdes IFS=: 2802238106Sdes for func_convert_core_path_wine_to_w32_f in $1; do 2803238106Sdes IFS=$oldIFS 2804238106Sdes func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805296415Sdes if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806238106Sdes if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807296415Sdes func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808238106Sdes else 2809238106Sdes func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810238106Sdes fi 2811238106Sdes fi 2812238106Sdes done 2813238106Sdes IFS=$oldIFS 2814238106Sdes fi 2815238106Sdes} 2816238106Sdes# end: func_convert_core_path_wine_to_w32 2817238106Sdes 2818238106Sdes 2819238106Sdes# func_cygpath ARGS... 2820238106Sdes# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821238106Sdes# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822238106Sdes# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823238106Sdes# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824238106Sdes# file name or path is assumed to be in w32 format, as previously converted 2825238106Sdes# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826238106Sdes# or path in func_cygpath_result (input file name or path is assumed to be in 2827238106Sdes# Cygwin format). Returns an empty string on error. 2828238106Sdes# 2829238106Sdes# ARGS are passed to cygpath, with the last one being the file name or path to 2830238106Sdes# be converted. 2831238106Sdes# 2832238106Sdes# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833238106Sdes# environment variable; do not put it in $PATH. 2834238106Sdesfunc_cygpath () 2835238106Sdes{ 2836296415Sdes $debug_cmd 2837296415Sdes 2838238106Sdes if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839238106Sdes func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840238106Sdes if test "$?" -ne 0; then 2841238106Sdes # on failure, ensure result is empty 2842238106Sdes func_cygpath_result= 2843238106Sdes fi 2844238106Sdes else 2845238106Sdes func_cygpath_result= 2846296415Sdes func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847238106Sdes fi 2848238106Sdes} 2849238106Sdes#end: func_cygpath 2850238106Sdes 2851238106Sdes 2852238106Sdes# func_convert_core_msys_to_w32 ARG 2853238106Sdes# Convert file name or path ARG from MSYS format to w32 format. Return 2854238106Sdes# result in func_convert_core_msys_to_w32_result. 2855238106Sdesfunc_convert_core_msys_to_w32 () 2856238106Sdes{ 2857296415Sdes $debug_cmd 2858296415Sdes 2859238106Sdes # awkward: cmd appends spaces to result 2860238106Sdes func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861296415Sdes $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862238106Sdes} 2863238106Sdes#end: func_convert_core_msys_to_w32 2864238106Sdes 2865238106Sdes 2866238106Sdes# func_convert_file_check ARG1 ARG2 2867238106Sdes# Verify that ARG1 (a file name in $build format) was converted to $host 2868238106Sdes# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869238106Sdes# func_to_host_file_result to ARG1). 2870238106Sdesfunc_convert_file_check () 2871238106Sdes{ 2872296415Sdes $debug_cmd 2873296415Sdes 2874296415Sdes if test -z "$2" && test -n "$1"; then 2875238106Sdes func_error "Could not determine host file name corresponding to" 2876296415Sdes func_error " '$1'" 2877238106Sdes func_error "Continuing, but uninstalled executables may not work." 2878238106Sdes # Fallback: 2879296415Sdes func_to_host_file_result=$1 2880238106Sdes fi 2881238106Sdes} 2882238106Sdes# end func_convert_file_check 2883238106Sdes 2884238106Sdes 2885238106Sdes# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886238106Sdes# Verify that FROM_PATH (a path in $build format) was converted to $host 2887238106Sdes# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888238106Sdes# func_to_host_file_result to a simplistic fallback value (see below). 2889238106Sdesfunc_convert_path_check () 2890238106Sdes{ 2891296415Sdes $debug_cmd 2892296415Sdes 2893238106Sdes if test -z "$4" && test -n "$3"; then 2894238106Sdes func_error "Could not determine the host path corresponding to" 2895296415Sdes func_error " '$3'" 2896238106Sdes func_error "Continuing, but uninstalled executables may not work." 2897238106Sdes # Fallback. This is a deliberately simplistic "conversion" and 2898238106Sdes # should not be "improved". See libtool.info. 2899238106Sdes if test "x$1" != "x$2"; then 2900238106Sdes lt_replace_pathsep_chars="s|$1|$2|g" 2901238106Sdes func_to_host_path_result=`echo "$3" | 2902238106Sdes $SED -e "$lt_replace_pathsep_chars"` 2903238106Sdes else 2904296415Sdes func_to_host_path_result=$3 2905238106Sdes fi 2906238106Sdes fi 2907238106Sdes} 2908238106Sdes# end func_convert_path_check 2909238106Sdes 2910238106Sdes 2911238106Sdes# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912238106Sdes# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913238106Sdes# and appending REPL if ORIG matches BACKPAT. 2914238106Sdesfunc_convert_path_front_back_pathsep () 2915238106Sdes{ 2916296415Sdes $debug_cmd 2917296415Sdes 2918238106Sdes case $4 in 2919296415Sdes $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920238106Sdes ;; 2921238106Sdes esac 2922238106Sdes case $4 in 2923238106Sdes $2 ) func_append func_to_host_path_result "$3" 2924238106Sdes ;; 2925238106Sdes esac 2926238106Sdes} 2927238106Sdes# end func_convert_path_front_back_pathsep 2928238106Sdes 2929238106Sdes 2930238106Sdes################################################## 2931238106Sdes# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932238106Sdes################################################## 2933296415Sdes# invoked via '$to_host_file_cmd ARG' 2934238106Sdes# 2935238106Sdes# In each case, ARG is the path to be converted from $build to $host format. 2936238106Sdes# Result will be available in $func_to_host_file_result. 2937238106Sdes 2938238106Sdes 2939238106Sdes# func_to_host_file ARG 2940238106Sdes# Converts the file name ARG from $build format to $host format. Return result 2941238106Sdes# in func_to_host_file_result. 2942238106Sdesfunc_to_host_file () 2943238106Sdes{ 2944296415Sdes $debug_cmd 2945296415Sdes 2946238106Sdes $to_host_file_cmd "$1" 2947238106Sdes} 2948238106Sdes# end func_to_host_file 2949238106Sdes 2950238106Sdes 2951238106Sdes# func_to_tool_file ARG LAZY 2952238106Sdes# converts the file name ARG from $build format to toolchain format. Return 2953238106Sdes# result in func_to_tool_file_result. If the conversion in use is listed 2954238106Sdes# in (the comma separated) LAZY, no conversion takes place. 2955238106Sdesfunc_to_tool_file () 2956238106Sdes{ 2957296415Sdes $debug_cmd 2958296415Sdes 2959238106Sdes case ,$2, in 2960238106Sdes *,"$to_tool_file_cmd",*) 2961238106Sdes func_to_tool_file_result=$1 2962238106Sdes ;; 2963238106Sdes *) 2964238106Sdes $to_tool_file_cmd "$1" 2965238106Sdes func_to_tool_file_result=$func_to_host_file_result 2966238106Sdes ;; 2967238106Sdes esac 2968238106Sdes} 2969238106Sdes# end func_to_tool_file 2970238106Sdes 2971238106Sdes 2972238106Sdes# func_convert_file_noop ARG 2973238106Sdes# Copy ARG to func_to_host_file_result. 2974238106Sdesfunc_convert_file_noop () 2975238106Sdes{ 2976296415Sdes func_to_host_file_result=$1 2977238106Sdes} 2978238106Sdes# end func_convert_file_noop 2979238106Sdes 2980238106Sdes 2981238106Sdes# func_convert_file_msys_to_w32 ARG 2982238106Sdes# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983238106Sdes# conversion to w32 is not available inside the cwrapper. Returns result in 2984238106Sdes# func_to_host_file_result. 2985238106Sdesfunc_convert_file_msys_to_w32 () 2986238106Sdes{ 2987296415Sdes $debug_cmd 2988296415Sdes 2989296415Sdes func_to_host_file_result=$1 2990238106Sdes if test -n "$1"; then 2991238106Sdes func_convert_core_msys_to_w32 "$1" 2992296415Sdes func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993238106Sdes fi 2994238106Sdes func_convert_file_check "$1" "$func_to_host_file_result" 2995238106Sdes} 2996238106Sdes# end func_convert_file_msys_to_w32 2997238106Sdes 2998238106Sdes 2999238106Sdes# func_convert_file_cygwin_to_w32 ARG 3000238106Sdes# Convert file name ARG from Cygwin to w32 format. Returns result in 3001238106Sdes# func_to_host_file_result. 3002238106Sdesfunc_convert_file_cygwin_to_w32 () 3003238106Sdes{ 3004296415Sdes $debug_cmd 3005296415Sdes 3006296415Sdes func_to_host_file_result=$1 3007238106Sdes if test -n "$1"; then 3008238106Sdes # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009238106Sdes # LT_CYGPATH in this case. 3010238106Sdes func_to_host_file_result=`cygpath -m "$1"` 3011238106Sdes fi 3012238106Sdes func_convert_file_check "$1" "$func_to_host_file_result" 3013238106Sdes} 3014238106Sdes# end func_convert_file_cygwin_to_w32 3015238106Sdes 3016238106Sdes 3017238106Sdes# func_convert_file_nix_to_w32 ARG 3018238106Sdes# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019238106Sdes# and a working winepath. Returns result in func_to_host_file_result. 3020238106Sdesfunc_convert_file_nix_to_w32 () 3021238106Sdes{ 3022296415Sdes $debug_cmd 3023296415Sdes 3024296415Sdes func_to_host_file_result=$1 3025238106Sdes if test -n "$1"; then 3026238106Sdes func_convert_core_file_wine_to_w32 "$1" 3027296415Sdes func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028238106Sdes fi 3029238106Sdes func_convert_file_check "$1" "$func_to_host_file_result" 3030238106Sdes} 3031238106Sdes# end func_convert_file_nix_to_w32 3032238106Sdes 3033238106Sdes 3034238106Sdes# func_convert_file_msys_to_cygwin ARG 3035238106Sdes# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036238106Sdes# Returns result in func_to_host_file_result. 3037238106Sdesfunc_convert_file_msys_to_cygwin () 3038238106Sdes{ 3039296415Sdes $debug_cmd 3040296415Sdes 3041296415Sdes func_to_host_file_result=$1 3042238106Sdes if test -n "$1"; then 3043238106Sdes func_convert_core_msys_to_w32 "$1" 3044238106Sdes func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045296415Sdes func_to_host_file_result=$func_cygpath_result 3046238106Sdes fi 3047238106Sdes func_convert_file_check "$1" "$func_to_host_file_result" 3048238106Sdes} 3049238106Sdes# end func_convert_file_msys_to_cygwin 3050238106Sdes 3051238106Sdes 3052238106Sdes# func_convert_file_nix_to_cygwin ARG 3053238106Sdes# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054238106Sdes# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055238106Sdes# in func_to_host_file_result. 3056238106Sdesfunc_convert_file_nix_to_cygwin () 3057238106Sdes{ 3058296415Sdes $debug_cmd 3059296415Sdes 3060296415Sdes func_to_host_file_result=$1 3061238106Sdes if test -n "$1"; then 3062238106Sdes # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063238106Sdes func_convert_core_file_wine_to_w32 "$1" 3064238106Sdes func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065296415Sdes func_to_host_file_result=$func_cygpath_result 3066238106Sdes fi 3067238106Sdes func_convert_file_check "$1" "$func_to_host_file_result" 3068238106Sdes} 3069238106Sdes# end func_convert_file_nix_to_cygwin 3070238106Sdes 3071238106Sdes 3072238106Sdes############################################# 3073238106Sdes# $build to $host PATH CONVERSION FUNCTIONS # 3074238106Sdes############################################# 3075296415Sdes# invoked via '$to_host_path_cmd ARG' 3076238106Sdes# 3077238106Sdes# In each case, ARG is the path to be converted from $build to $host format. 3078238106Sdes# The result will be available in $func_to_host_path_result. 3079238106Sdes# 3080238106Sdes# Path separators are also converted from $build format to $host format. If 3081238106Sdes# ARG begins or ends with a path separator character, it is preserved (but 3082238106Sdes# converted to $host format) on output. 3083238106Sdes# 3084238106Sdes# All path conversion functions are named using the following convention: 3085238106Sdes# file name conversion function : func_convert_file_X_to_Y () 3086238106Sdes# path conversion function : func_convert_path_X_to_Y () 3087238106Sdes# where, for any given $build/$host combination the 'X_to_Y' value is the 3088238106Sdes# same. If conversion functions are added for new $build/$host combinations, 3089238106Sdes# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090238106Sdes# will break. 3091238106Sdes 3092238106Sdes 3093238106Sdes# func_init_to_host_path_cmd 3094238106Sdes# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095238106Sdes# appropriate value, based on the value of $to_host_file_cmd. 3096238106Sdesto_host_path_cmd= 3097238106Sdesfunc_init_to_host_path_cmd () 3098238106Sdes{ 3099296415Sdes $debug_cmd 3100296415Sdes 3101238106Sdes if test -z "$to_host_path_cmd"; then 3102238106Sdes func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103296415Sdes to_host_path_cmd=func_convert_path_$func_stripname_result 3104238106Sdes fi 3105238106Sdes} 3106238106Sdes 3107238106Sdes 3108238106Sdes# func_to_host_path ARG 3109238106Sdes# Converts the path ARG from $build format to $host format. Return result 3110238106Sdes# in func_to_host_path_result. 3111238106Sdesfunc_to_host_path () 3112238106Sdes{ 3113296415Sdes $debug_cmd 3114296415Sdes 3115238106Sdes func_init_to_host_path_cmd 3116238106Sdes $to_host_path_cmd "$1" 3117238106Sdes} 3118238106Sdes# end func_to_host_path 3119238106Sdes 3120238106Sdes 3121238106Sdes# func_convert_path_noop ARG 3122238106Sdes# Copy ARG to func_to_host_path_result. 3123238106Sdesfunc_convert_path_noop () 3124238106Sdes{ 3125296415Sdes func_to_host_path_result=$1 3126238106Sdes} 3127238106Sdes# end func_convert_path_noop 3128238106Sdes 3129238106Sdes 3130238106Sdes# func_convert_path_msys_to_w32 ARG 3131238106Sdes# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132238106Sdes# conversion to w32 is not available inside the cwrapper. Returns result in 3133238106Sdes# func_to_host_path_result. 3134238106Sdesfunc_convert_path_msys_to_w32 () 3135238106Sdes{ 3136296415Sdes $debug_cmd 3137296415Sdes 3138296415Sdes func_to_host_path_result=$1 3139238106Sdes if test -n "$1"; then 3140238106Sdes # Remove leading and trailing path separator characters from ARG. MSYS 3141238106Sdes # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142238106Sdes # and winepath ignores them completely. 3143238106Sdes func_stripname : : "$1" 3144238106Sdes func_to_host_path_tmp1=$func_stripname_result 3145238106Sdes func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146296415Sdes func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147238106Sdes func_convert_path_check : ";" \ 3148238106Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149238106Sdes func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150238106Sdes fi 3151238106Sdes} 3152238106Sdes# end func_convert_path_msys_to_w32 3153238106Sdes 3154238106Sdes 3155238106Sdes# func_convert_path_cygwin_to_w32 ARG 3156238106Sdes# Convert path ARG from Cygwin to w32 format. Returns result in 3157238106Sdes# func_to_host_file_result. 3158238106Sdesfunc_convert_path_cygwin_to_w32 () 3159238106Sdes{ 3160296415Sdes $debug_cmd 3161296415Sdes 3162296415Sdes func_to_host_path_result=$1 3163238106Sdes if test -n "$1"; then 3164238106Sdes # See func_convert_path_msys_to_w32: 3165238106Sdes func_stripname : : "$1" 3166238106Sdes func_to_host_path_tmp1=$func_stripname_result 3167238106Sdes func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168238106Sdes func_convert_path_check : ";" \ 3169238106Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170238106Sdes func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171238106Sdes fi 3172238106Sdes} 3173238106Sdes# end func_convert_path_cygwin_to_w32 3174238106Sdes 3175238106Sdes 3176238106Sdes# func_convert_path_nix_to_w32 ARG 3177238106Sdes# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178238106Sdes# a working winepath. Returns result in func_to_host_file_result. 3179238106Sdesfunc_convert_path_nix_to_w32 () 3180238106Sdes{ 3181296415Sdes $debug_cmd 3182296415Sdes 3183296415Sdes func_to_host_path_result=$1 3184238106Sdes if test -n "$1"; then 3185238106Sdes # See func_convert_path_msys_to_w32: 3186238106Sdes func_stripname : : "$1" 3187238106Sdes func_to_host_path_tmp1=$func_stripname_result 3188238106Sdes func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189296415Sdes func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190238106Sdes func_convert_path_check : ";" \ 3191238106Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192238106Sdes func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193238106Sdes fi 3194238106Sdes} 3195238106Sdes# end func_convert_path_nix_to_w32 3196238106Sdes 3197238106Sdes 3198238106Sdes# func_convert_path_msys_to_cygwin ARG 3199238106Sdes# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200238106Sdes# Returns result in func_to_host_file_result. 3201238106Sdesfunc_convert_path_msys_to_cygwin () 3202238106Sdes{ 3203296415Sdes $debug_cmd 3204296415Sdes 3205296415Sdes func_to_host_path_result=$1 3206238106Sdes if test -n "$1"; then 3207238106Sdes # See func_convert_path_msys_to_w32: 3208238106Sdes func_stripname : : "$1" 3209238106Sdes func_to_host_path_tmp1=$func_stripname_result 3210238106Sdes func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211238106Sdes func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212296415Sdes func_to_host_path_result=$func_cygpath_result 3213238106Sdes func_convert_path_check : : \ 3214238106Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215238106Sdes func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216238106Sdes fi 3217238106Sdes} 3218238106Sdes# end func_convert_path_msys_to_cygwin 3219238106Sdes 3220238106Sdes 3221238106Sdes# func_convert_path_nix_to_cygwin ARG 3222238106Sdes# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223238106Sdes# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224238106Sdes# func_to_host_file_result. 3225238106Sdesfunc_convert_path_nix_to_cygwin () 3226238106Sdes{ 3227296415Sdes $debug_cmd 3228296415Sdes 3229296415Sdes func_to_host_path_result=$1 3230238106Sdes if test -n "$1"; then 3231238106Sdes # Remove leading and trailing path separator characters from 3232238106Sdes # ARG. msys behavior is inconsistent here, cygpath turns them 3233238106Sdes # into '.;' and ';.', and winepath ignores them completely. 3234238106Sdes func_stripname : : "$1" 3235238106Sdes func_to_host_path_tmp1=$func_stripname_result 3236238106Sdes func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237238106Sdes func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238296415Sdes func_to_host_path_result=$func_cygpath_result 3239238106Sdes func_convert_path_check : : \ 3240238106Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241238106Sdes func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242238106Sdes fi 3243238106Sdes} 3244238106Sdes# end func_convert_path_nix_to_cygwin 3245238106Sdes 3246238106Sdes 3247296415Sdes# func_dll_def_p FILE 3248296415Sdes# True iff FILE is a Windows DLL '.def' file. 3249296415Sdes# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250296415Sdesfunc_dll_def_p () 3251296415Sdes{ 3252296415Sdes $debug_cmd 3253296415Sdes 3254296415Sdes func_dll_def_p_tmp=`$SED -n \ 3255296415Sdes -e 's/^[ ]*//' \ 3256296415Sdes -e '/^\(;.*\)*$/d' \ 3257296415Sdes -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258296415Sdes -e q \ 3259296415Sdes "$1"` 3260296415Sdes test DEF = "$func_dll_def_p_tmp" 3261296415Sdes} 3262296415Sdes 3263296415Sdes 3264238106Sdes# func_mode_compile arg... 3265238106Sdesfunc_mode_compile () 3266238106Sdes{ 3267296415Sdes $debug_cmd 3268296415Sdes 3269238106Sdes # Get the compilation command and the source file. 3270238106Sdes base_compile= 3271296415Sdes srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272238106Sdes suppress_opt=yes 3273238106Sdes suppress_output= 3274238106Sdes arg_mode=normal 3275238106Sdes libobj= 3276238106Sdes later= 3277238106Sdes pie_flag= 3278238106Sdes 3279238106Sdes for arg 3280238106Sdes do 3281238106Sdes case $arg_mode in 3282238106Sdes arg ) 3283238106Sdes # do not "continue". Instead, add this to base_compile 3284296415Sdes lastarg=$arg 3285238106Sdes arg_mode=normal 3286238106Sdes ;; 3287238106Sdes 3288238106Sdes target ) 3289296415Sdes libobj=$arg 3290238106Sdes arg_mode=normal 3291238106Sdes continue 3292238106Sdes ;; 3293238106Sdes 3294238106Sdes normal ) 3295238106Sdes # Accept any command-line options. 3296238106Sdes case $arg in 3297238106Sdes -o) 3298238106Sdes test -n "$libobj" && \ 3299296415Sdes func_fatal_error "you cannot specify '-o' more than once" 3300238106Sdes arg_mode=target 3301238106Sdes continue 3302238106Sdes ;; 3303238106Sdes 3304238106Sdes -pie | -fpie | -fPIE) 3305238106Sdes func_append pie_flag " $arg" 3306238106Sdes continue 3307238106Sdes ;; 3308238106Sdes 3309238106Sdes -shared | -static | -prefer-pic | -prefer-non-pic) 3310238106Sdes func_append later " $arg" 3311238106Sdes continue 3312238106Sdes ;; 3313238106Sdes 3314238106Sdes -no-suppress) 3315238106Sdes suppress_opt=no 3316238106Sdes continue 3317238106Sdes ;; 3318238106Sdes 3319238106Sdes -Xcompiler) 3320238106Sdes arg_mode=arg # the next one goes into the "base_compile" arg list 3321238106Sdes continue # The current "srcfile" will either be retained or 3322238106Sdes ;; # replaced later. I would guess that would be a bug. 3323238106Sdes 3324238106Sdes -Wc,*) 3325238106Sdes func_stripname '-Wc,' '' "$arg" 3326238106Sdes args=$func_stripname_result 3327238106Sdes lastarg= 3328296415Sdes save_ifs=$IFS; IFS=, 3329238106Sdes for arg in $args; do 3330296415Sdes IFS=$save_ifs 3331238106Sdes func_append_quoted lastarg "$arg" 3332238106Sdes done 3333296415Sdes IFS=$save_ifs 3334238106Sdes func_stripname ' ' '' "$lastarg" 3335238106Sdes lastarg=$func_stripname_result 3336238106Sdes 3337238106Sdes # Add the arguments to base_compile. 3338238106Sdes func_append base_compile " $lastarg" 3339238106Sdes continue 3340238106Sdes ;; 3341238106Sdes 3342238106Sdes *) 3343238106Sdes # Accept the current argument as the source file. 3344238106Sdes # The previous "srcfile" becomes the current argument. 3345238106Sdes # 3346296415Sdes lastarg=$srcfile 3347296415Sdes srcfile=$arg 3348238106Sdes ;; 3349238106Sdes esac # case $arg 3350238106Sdes ;; 3351238106Sdes esac # case $arg_mode 3352238106Sdes 3353238106Sdes # Aesthetically quote the previous argument. 3354238106Sdes func_append_quoted base_compile "$lastarg" 3355238106Sdes done # for arg 3356238106Sdes 3357238106Sdes case $arg_mode in 3358238106Sdes arg) 3359238106Sdes func_fatal_error "you must specify an argument for -Xcompile" 3360238106Sdes ;; 3361238106Sdes target) 3362296415Sdes func_fatal_error "you must specify a target with '-o'" 3363238106Sdes ;; 3364238106Sdes *) 3365238106Sdes # Get the name of the library object. 3366238106Sdes test -z "$libobj" && { 3367238106Sdes func_basename "$srcfile" 3368296415Sdes libobj=$func_basename_result 3369238106Sdes } 3370238106Sdes ;; 3371238106Sdes esac 3372238106Sdes 3373238106Sdes # Recognize several different file suffixes. 3374238106Sdes # If the user specifies -o file.o, it is replaced with file.lo 3375238106Sdes case $libobj in 3376238106Sdes *.[cCFSifmso] | \ 3377238106Sdes *.ada | *.adb | *.ads | *.asm | \ 3378238106Sdes *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379249141Sdes *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380238106Sdes func_xform "$libobj" 3381238106Sdes libobj=$func_xform_result 3382238106Sdes ;; 3383238106Sdes esac 3384238106Sdes 3385238106Sdes case $libobj in 3386238106Sdes *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387238106Sdes *) 3388296415Sdes func_fatal_error "cannot determine name of library object from '$libobj'" 3389238106Sdes ;; 3390238106Sdes esac 3391238106Sdes 3392238106Sdes func_infer_tag $base_compile 3393238106Sdes 3394238106Sdes for arg in $later; do 3395238106Sdes case $arg in 3396238106Sdes -shared) 3397296415Sdes test yes = "$build_libtool_libs" \ 3398296415Sdes || func_fatal_configuration "cannot build a shared library" 3399238106Sdes build_old_libs=no 3400238106Sdes continue 3401238106Sdes ;; 3402238106Sdes 3403238106Sdes -static) 3404238106Sdes build_libtool_libs=no 3405238106Sdes build_old_libs=yes 3406238106Sdes continue 3407238106Sdes ;; 3408238106Sdes 3409238106Sdes -prefer-pic) 3410238106Sdes pic_mode=yes 3411238106Sdes continue 3412238106Sdes ;; 3413238106Sdes 3414238106Sdes -prefer-non-pic) 3415238106Sdes pic_mode=no 3416238106Sdes continue 3417238106Sdes ;; 3418238106Sdes esac 3419238106Sdes done 3420238106Sdes 3421238106Sdes func_quote_for_eval "$libobj" 3422238106Sdes test "X$libobj" != "X$func_quote_for_eval_result" \ 3423238106Sdes && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424296415Sdes && func_warning "libobj name '$libobj' may not contain shell special characters." 3425238106Sdes func_dirname_and_basename "$obj" "/" "" 3426296415Sdes objname=$func_basename_result 3427296415Sdes xdir=$func_dirname_result 3428296415Sdes lobj=$xdir$objdir/$objname 3429238106Sdes 3430238106Sdes test -z "$base_compile" && \ 3431238106Sdes func_fatal_help "you must specify a compilation command" 3432238106Sdes 3433238106Sdes # Delete any leftover library objects. 3434296415Sdes if test yes = "$build_old_libs"; then 3435238106Sdes removelist="$obj $lobj $libobj ${libobj}T" 3436238106Sdes else 3437238106Sdes removelist="$lobj $libobj ${libobj}T" 3438238106Sdes fi 3439238106Sdes 3440238106Sdes # On Cygwin there's no "real" PIC flag so we must build both object types 3441238106Sdes case $host_os in 3442238106Sdes cygwin* | mingw* | pw32* | os2* | cegcc*) 3443238106Sdes pic_mode=default 3444238106Sdes ;; 3445238106Sdes esac 3446296415Sdes if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447238106Sdes # non-PIC code in shared libraries is not supported 3448238106Sdes pic_mode=default 3449238106Sdes fi 3450238106Sdes 3451238106Sdes # Calculate the filename of the output object if compiler does 3452238106Sdes # not support -o with -c 3453296415Sdes if test no = "$compiler_c_o"; then 3454296415Sdes output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455296415Sdes lockfile=$output_obj.lock 3456238106Sdes else 3457238106Sdes output_obj= 3458238106Sdes need_locks=no 3459238106Sdes lockfile= 3460238106Sdes fi 3461238106Sdes 3462238106Sdes # Lock this critical section if it is needed 3463238106Sdes # We use this script file to make the link, it avoids creating a new file 3464296415Sdes if test yes = "$need_locks"; then 3465238106Sdes until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466238106Sdes func_echo "Waiting for $lockfile to be removed" 3467238106Sdes sleep 2 3468238106Sdes done 3469296415Sdes elif test warn = "$need_locks"; then 3470238106Sdes if test -f "$lockfile"; then 3471238106Sdes $ECHO "\ 3472238106Sdes*** ERROR, $lockfile exists and contains: 3473238106Sdes`cat $lockfile 2>/dev/null` 3474238106Sdes 3475238106SdesThis indicates that another process is trying to use the same 3476238106Sdestemporary object file, and libtool could not work around it because 3477296415Sdesyour compiler does not support '-c' and '-o' together. If you 3478238106Sdesrepeat this compilation, it may succeed, by chance, but you had better 3479238106Sdesavoid parallel builds (make -j) in this platform, or get a better 3480238106Sdescompiler." 3481238106Sdes 3482238106Sdes $opt_dry_run || $RM $removelist 3483238106Sdes exit $EXIT_FAILURE 3484238106Sdes fi 3485238106Sdes func_append removelist " $output_obj" 3486238106Sdes $ECHO "$srcfile" > "$lockfile" 3487238106Sdes fi 3488238106Sdes 3489238106Sdes $opt_dry_run || $RM $removelist 3490238106Sdes func_append removelist " $lockfile" 3491238106Sdes trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492238106Sdes 3493238106Sdes func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494238106Sdes srcfile=$func_to_tool_file_result 3495238106Sdes func_quote_for_eval "$srcfile" 3496238106Sdes qsrcfile=$func_quote_for_eval_result 3497238106Sdes 3498238106Sdes # Only build a PIC object if we are building libtool libraries. 3499296415Sdes if test yes = "$build_libtool_libs"; then 3500238106Sdes # Without this assignment, base_compile gets emptied. 3501238106Sdes fbsd_hideous_sh_bug=$base_compile 3502238106Sdes 3503296415Sdes if test no != "$pic_mode"; then 3504238106Sdes command="$base_compile $qsrcfile $pic_flag" 3505238106Sdes else 3506238106Sdes # Don't build PIC code 3507238106Sdes command="$base_compile $qsrcfile" 3508238106Sdes fi 3509238106Sdes 3510238106Sdes func_mkdir_p "$xdir$objdir" 3511238106Sdes 3512238106Sdes if test -z "$output_obj"; then 3513238106Sdes # Place PIC objects in $objdir 3514238106Sdes func_append command " -o $lobj" 3515238106Sdes fi 3516238106Sdes 3517238106Sdes func_show_eval_locale "$command" \ 3518238106Sdes 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519238106Sdes 3520296415Sdes if test warn = "$need_locks" && 3521238106Sdes test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522238106Sdes $ECHO "\ 3523238106Sdes*** ERROR, $lockfile contains: 3524238106Sdes`cat $lockfile 2>/dev/null` 3525238106Sdes 3526238106Sdesbut it should contain: 3527238106Sdes$srcfile 3528238106Sdes 3529238106SdesThis indicates that another process is trying to use the same 3530238106Sdestemporary object file, and libtool could not work around it because 3531296415Sdesyour compiler does not support '-c' and '-o' together. If you 3532238106Sdesrepeat this compilation, it may succeed, by chance, but you had better 3533238106Sdesavoid parallel builds (make -j) in this platform, or get a better 3534238106Sdescompiler." 3535238106Sdes 3536238106Sdes $opt_dry_run || $RM $removelist 3537238106Sdes exit $EXIT_FAILURE 3538238106Sdes fi 3539238106Sdes 3540238106Sdes # Just move the object if needed, then go on to compile the next one 3541238106Sdes if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542238106Sdes func_show_eval '$MV "$output_obj" "$lobj"' \ 3543238106Sdes 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544238106Sdes fi 3545238106Sdes 3546238106Sdes # Allow error messages only from the first compilation. 3547296415Sdes if test yes = "$suppress_opt"; then 3548238106Sdes suppress_output=' >/dev/null 2>&1' 3549238106Sdes fi 3550238106Sdes fi 3551238106Sdes 3552238106Sdes # Only build a position-dependent object if we build old libraries. 3553296415Sdes if test yes = "$build_old_libs"; then 3554296415Sdes if test yes != "$pic_mode"; then 3555238106Sdes # Don't build PIC code 3556238106Sdes command="$base_compile $qsrcfile$pie_flag" 3557238106Sdes else 3558238106Sdes command="$base_compile $qsrcfile $pic_flag" 3559238106Sdes fi 3560296415Sdes if test yes = "$compiler_c_o"; then 3561238106Sdes func_append command " -o $obj" 3562238106Sdes fi 3563238106Sdes 3564238106Sdes # Suppress compiler output if we already did a PIC compilation. 3565238106Sdes func_append command "$suppress_output" 3566238106Sdes func_show_eval_locale "$command" \ 3567238106Sdes '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568238106Sdes 3569296415Sdes if test warn = "$need_locks" && 3570238106Sdes test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571238106Sdes $ECHO "\ 3572238106Sdes*** ERROR, $lockfile contains: 3573238106Sdes`cat $lockfile 2>/dev/null` 3574238106Sdes 3575238106Sdesbut it should contain: 3576238106Sdes$srcfile 3577238106Sdes 3578238106SdesThis indicates that another process is trying to use the same 3579238106Sdestemporary object file, and libtool could not work around it because 3580296415Sdesyour compiler does not support '-c' and '-o' together. If you 3581238106Sdesrepeat this compilation, it may succeed, by chance, but you had better 3582238106Sdesavoid parallel builds (make -j) in this platform, or get a better 3583238106Sdescompiler." 3584238106Sdes 3585238106Sdes $opt_dry_run || $RM $removelist 3586238106Sdes exit $EXIT_FAILURE 3587238106Sdes fi 3588238106Sdes 3589238106Sdes # Just move the object if needed 3590238106Sdes if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591238106Sdes func_show_eval '$MV "$output_obj" "$obj"' \ 3592238106Sdes 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593238106Sdes fi 3594238106Sdes fi 3595238106Sdes 3596238106Sdes $opt_dry_run || { 3597238106Sdes func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598238106Sdes 3599238106Sdes # Unlock the critical section if it was locked 3600296415Sdes if test no != "$need_locks"; then 3601238106Sdes removelist=$lockfile 3602238106Sdes $RM "$lockfile" 3603238106Sdes fi 3604238106Sdes } 3605238106Sdes 3606238106Sdes exit $EXIT_SUCCESS 3607238106Sdes} 3608238106Sdes 3609238106Sdes$opt_help || { 3610296415Sdes test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611238106Sdes} 3612238106Sdes 3613238106Sdesfunc_mode_help () 3614238106Sdes{ 3615238106Sdes # We need to display help for each of the modes. 3616238106Sdes case $opt_mode in 3617238106Sdes "") 3618238106Sdes # Generic help is extracted from the usage comments 3619238106Sdes # at the start of this file. 3620238106Sdes func_help 3621238106Sdes ;; 3622238106Sdes 3623238106Sdes clean) 3624238106Sdes $ECHO \ 3625238106Sdes"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626238106Sdes 3627238106SdesRemove files from the build directory. 3628238106Sdes 3629238106SdesRM is the name of the program to use to delete files associated with each FILE 3630296415Sdes(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631238106Sdesto RM. 3632238106Sdes 3633238106SdesIf FILE is a libtool library, object or program, all the files associated 3634238106Sdeswith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635238106Sdes ;; 3636238106Sdes 3637238106Sdes compile) 3638238106Sdes $ECHO \ 3639238106Sdes"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640238106Sdes 3641238106SdesCompile a source file into a libtool library object. 3642238106Sdes 3643238106SdesThis mode accepts the following additional options: 3644238106Sdes 3645238106Sdes -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646238106Sdes -no-suppress do not suppress compiler output for multiple passes 3647238106Sdes -prefer-pic try to build PIC objects only 3648238106Sdes -prefer-non-pic try to build non-PIC objects only 3649296415Sdes -shared do not build a '.o' file suitable for static linking 3650296415Sdes -static only build a '.o' file suitable for static linking 3651238106Sdes -Wc,FLAG pass FLAG directly to the compiler 3652238106Sdes 3653296415SdesCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654238106Sdesfrom the given SOURCEFILE. 3655238106Sdes 3656238106SdesThe output file name is determined by removing the directory component from 3657296415SdesSOURCEFILE, then substituting the C source code suffix '.c' with the 3658296415Sdeslibrary object suffix, '.lo'." 3659238106Sdes ;; 3660238106Sdes 3661238106Sdes execute) 3662238106Sdes $ECHO \ 3663238106Sdes"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664238106Sdes 3665238106SdesAutomatically set library path, then run a program. 3666238106Sdes 3667238106SdesThis mode accepts the following additional options: 3668238106Sdes 3669238106Sdes -dlopen FILE add the directory containing FILE to the library path 3670238106Sdes 3671296415SdesThis mode sets the library path environment variable according to '-dlopen' 3672238106Sdesflags. 3673238106Sdes 3674238106SdesIf any of the ARGS are libtool executable wrappers, then they are translated 3675238106Sdesinto their corresponding uninstalled binary, and any of their required library 3676238106Sdesdirectories are added to the library path. 3677238106Sdes 3678238106SdesThen, COMMAND is executed, with ARGS as arguments." 3679238106Sdes ;; 3680238106Sdes 3681238106Sdes finish) 3682238106Sdes $ECHO \ 3683238106Sdes"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684238106Sdes 3685238106SdesComplete the installation of libtool libraries. 3686238106Sdes 3687238106SdesEach LIBDIR is a directory that contains libtool libraries. 3688238106Sdes 3689238106SdesThe commands that this mode executes may require superuser privileges. Use 3690296415Sdesthe '--dry-run' option if you just want to see what would be executed." 3691238106Sdes ;; 3692238106Sdes 3693238106Sdes install) 3694238106Sdes $ECHO \ 3695238106Sdes"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696238106Sdes 3697238106SdesInstall executables or libraries. 3698238106Sdes 3699238106SdesINSTALL-COMMAND is the installation command. The first component should be 3700296415Sdeseither the 'install' or 'cp' program. 3701238106Sdes 3702238106SdesThe following components of INSTALL-COMMAND are treated specially: 3703238106Sdes 3704238106Sdes -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705238106Sdes 3706238106SdesThe rest of the components are interpreted as arguments to that command (only 3707238106SdesBSD-compatible install options are recognized)." 3708238106Sdes ;; 3709238106Sdes 3710238106Sdes link) 3711238106Sdes $ECHO \ 3712238106Sdes"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713238106Sdes 3714238106SdesLink object files or libraries together to form another library, or to 3715238106Sdescreate an executable program. 3716238106Sdes 3717238106SdesLINK-COMMAND is a command using the C compiler that you would use to create 3718238106Sdesa program from several object files. 3719238106Sdes 3720238106SdesThe following components of LINK-COMMAND are treated specially: 3721238106Sdes 3722238106Sdes -all-static do not do any dynamic linking at all 3723238106Sdes -avoid-version do not add a version suffix if possible 3724238106Sdes -bindir BINDIR specify path to binaries directory (for systems where 3725238106Sdes libraries must be found in the PATH setting at runtime) 3726296415Sdes -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727238106Sdes -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728238106Sdes -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729238106Sdes -export-symbols SYMFILE 3730238106Sdes try to export only the symbols listed in SYMFILE 3731238106Sdes -export-symbols-regex REGEX 3732238106Sdes try to export only the symbols matching REGEX 3733238106Sdes -LLIBDIR search LIBDIR for required installed libraries 3734238106Sdes -lNAME OUTPUT-FILE requires the installed library libNAME 3735238106Sdes -module build a library that can dlopened 3736238106Sdes -no-fast-install disable the fast-install mode 3737238106Sdes -no-install link a not-installable executable 3738238106Sdes -no-undefined declare that a library does not refer to external symbols 3739238106Sdes -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740296415Sdes -objectlist FILE use a list of object files found in FILE to specify objects 3741296415Sdes -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742238106Sdes -precious-files-regex REGEX 3743238106Sdes don't remove output files matching REGEX 3744238106Sdes -release RELEASE specify package release information 3745238106Sdes -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746238106Sdes -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747238106Sdes -shared only do dynamic linking of libtool libraries 3748238106Sdes -shrext SUFFIX override the standard shared library file extension 3749238106Sdes -static do not do any dynamic linking of uninstalled libtool libraries 3750238106Sdes -static-libtool-libs 3751238106Sdes do not do any dynamic linking of libtool libraries 3752238106Sdes -version-info CURRENT[:REVISION[:AGE]] 3753238106Sdes specify library version info [each variable defaults to 0] 3754238106Sdes -weak LIBNAME declare that the target provides the LIBNAME interface 3755238106Sdes -Wc,FLAG 3756238106Sdes -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757238106Sdes -Wl,FLAG 3758238106Sdes -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759238106Sdes -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760238106Sdes 3761296415SdesAll other options (arguments beginning with '-') are ignored. 3762238106Sdes 3763296415SdesEvery other argument is treated as a filename. Files ending in '.la' are 3764238106Sdestreated as uninstalled libtool libraries, other files are standard or library 3765238106Sdesobject files. 3766238106Sdes 3767296415SdesIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768296415Sdesonly library objects ('.lo' files) may be specified, and '-rpath' is 3769238106Sdesrequired, except when creating a convenience library. 3770238106Sdes 3771296415SdesIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772296415Sdesusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773238106Sdes 3774296415SdesIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775238106Sdesis created, otherwise an executable program is created." 3776238106Sdes ;; 3777238106Sdes 3778238106Sdes uninstall) 3779238106Sdes $ECHO \ 3780238106Sdes"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781238106Sdes 3782238106SdesRemove libraries from an installation directory. 3783238106Sdes 3784238106SdesRM is the name of the program to use to delete files associated with each FILE 3785296415Sdes(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786238106Sdesto RM. 3787238106Sdes 3788238106SdesIf FILE is a libtool library, all the files associated with it are deleted. 3789238106SdesOtherwise, only FILE itself is deleted using RM." 3790238106Sdes ;; 3791238106Sdes 3792238106Sdes *) 3793296415Sdes func_fatal_help "invalid operation mode '$opt_mode'" 3794238106Sdes ;; 3795238106Sdes esac 3796238106Sdes 3797238106Sdes echo 3798296415Sdes $ECHO "Try '$progname --help' for more information about other modes." 3799238106Sdes} 3800238106Sdes 3801238106Sdes# Now that we've collected a possible --mode arg, show help if necessary 3802238106Sdesif $opt_help; then 3803296415Sdes if test : = "$opt_help"; then 3804238106Sdes func_mode_help 3805238106Sdes else 3806238106Sdes { 3807238106Sdes func_help noexit 3808238106Sdes for opt_mode in compile link execute install finish uninstall clean; do 3809238106Sdes func_mode_help 3810238106Sdes done 3811296415Sdes } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812238106Sdes { 3813238106Sdes func_help noexit 3814238106Sdes for opt_mode in compile link execute install finish uninstall clean; do 3815238106Sdes echo 3816238106Sdes func_mode_help 3817238106Sdes done 3818238106Sdes } | 3819296415Sdes $SED '1d 3820238106Sdes /^When reporting/,/^Report/{ 3821238106Sdes H 3822238106Sdes d 3823238106Sdes } 3824238106Sdes $x 3825238106Sdes /information about other modes/d 3826238106Sdes /more detailed .*MODE/d 3827238106Sdes s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828238106Sdes fi 3829238106Sdes exit $? 3830238106Sdesfi 3831238106Sdes 3832238106Sdes 3833238106Sdes# func_mode_execute arg... 3834238106Sdesfunc_mode_execute () 3835238106Sdes{ 3836296415Sdes $debug_cmd 3837296415Sdes 3838238106Sdes # The first argument is the command name. 3839296415Sdes cmd=$nonopt 3840238106Sdes test -z "$cmd" && \ 3841238106Sdes func_fatal_help "you must specify a COMMAND" 3842238106Sdes 3843238106Sdes # Handle -dlopen flags immediately. 3844238106Sdes for file in $opt_dlopen; do 3845238106Sdes test -f "$file" \ 3846296415Sdes || func_fatal_help "'$file' is not a file" 3847238106Sdes 3848238106Sdes dir= 3849238106Sdes case $file in 3850238106Sdes *.la) 3851238106Sdes func_resolve_sysroot "$file" 3852238106Sdes file=$func_resolve_sysroot_result 3853238106Sdes 3854238106Sdes # Check to see that this really is a libtool archive. 3855238106Sdes func_lalib_unsafe_p "$file" \ 3856296415Sdes || func_fatal_help "'$lib' is not a valid libtool archive" 3857238106Sdes 3858238106Sdes # Read the libtool library. 3859238106Sdes dlname= 3860238106Sdes library_names= 3861238106Sdes func_source "$file" 3862238106Sdes 3863238106Sdes # Skip this library if it cannot be dlopened. 3864238106Sdes if test -z "$dlname"; then 3865238106Sdes # Warn if it was a shared library. 3866238106Sdes test -n "$library_names" && \ 3867296415Sdes func_warning "'$file' was not linked with '-export-dynamic'" 3868238106Sdes continue 3869238106Sdes fi 3870238106Sdes 3871238106Sdes func_dirname "$file" "" "." 3872296415Sdes dir=$func_dirname_result 3873238106Sdes 3874238106Sdes if test -f "$dir/$objdir/$dlname"; then 3875238106Sdes func_append dir "/$objdir" 3876238106Sdes else 3877238106Sdes if test ! -f "$dir/$dlname"; then 3878296415Sdes func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879238106Sdes fi 3880238106Sdes fi 3881238106Sdes ;; 3882238106Sdes 3883238106Sdes *.lo) 3884238106Sdes # Just add the directory containing the .lo file. 3885238106Sdes func_dirname "$file" "" "." 3886296415Sdes dir=$func_dirname_result 3887238106Sdes ;; 3888238106Sdes 3889238106Sdes *) 3890296415Sdes func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891238106Sdes continue 3892238106Sdes ;; 3893238106Sdes esac 3894238106Sdes 3895238106Sdes # Get the absolute pathname. 3896238106Sdes absdir=`cd "$dir" && pwd` 3897296415Sdes test -n "$absdir" && dir=$absdir 3898238106Sdes 3899238106Sdes # Now add the directory to shlibpath_var. 3900238106Sdes if eval "test -z \"\$$shlibpath_var\""; then 3901238106Sdes eval "$shlibpath_var=\"\$dir\"" 3902238106Sdes else 3903238106Sdes eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904238106Sdes fi 3905238106Sdes done 3906238106Sdes 3907238106Sdes # This variable tells wrapper scripts just to set shlibpath_var 3908238106Sdes # rather than running their programs. 3909296415Sdes libtool_execute_magic=$magic 3910238106Sdes 3911238106Sdes # Check if any of the arguments is a wrapper script. 3912238106Sdes args= 3913238106Sdes for file 3914238106Sdes do 3915238106Sdes case $file in 3916238106Sdes -* | *.la | *.lo ) ;; 3917238106Sdes *) 3918238106Sdes # Do a test to see if this is really a libtool program. 3919238106Sdes if func_ltwrapper_script_p "$file"; then 3920238106Sdes func_source "$file" 3921238106Sdes # Transform arg to wrapped name. 3922296415Sdes file=$progdir/$program 3923238106Sdes elif func_ltwrapper_executable_p "$file"; then 3924238106Sdes func_ltwrapper_scriptname "$file" 3925238106Sdes func_source "$func_ltwrapper_scriptname_result" 3926238106Sdes # Transform arg to wrapped name. 3927296415Sdes file=$progdir/$program 3928238106Sdes fi 3929238106Sdes ;; 3930238106Sdes esac 3931238106Sdes # Quote arguments (to preserve shell metacharacters). 3932238106Sdes func_append_quoted args "$file" 3933238106Sdes done 3934238106Sdes 3935296415Sdes if $opt_dry_run; then 3936296415Sdes # Display what would be done. 3937238106Sdes if test -n "$shlibpath_var"; then 3938296415Sdes eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939296415Sdes echo "export $shlibpath_var" 3940296415Sdes fi 3941296415Sdes $ECHO "$cmd$args" 3942296415Sdes exit $EXIT_SUCCESS 3943296415Sdes else 3944296415Sdes if test -n "$shlibpath_var"; then 3945238106Sdes # Export the shlibpath_var. 3946238106Sdes eval "export $shlibpath_var" 3947238106Sdes fi 3948238106Sdes 3949238106Sdes # Restore saved environment variables 3950238106Sdes for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951238106Sdes do 3952238106Sdes eval "if test \"\${save_$lt_var+set}\" = set; then 3953238106Sdes $lt_var=\$save_$lt_var; export $lt_var 3954238106Sdes else 3955238106Sdes $lt_unset $lt_var 3956238106Sdes fi" 3957238106Sdes done 3958238106Sdes 3959238106Sdes # Now prepare to actually exec the command. 3960296415Sdes exec_cmd=\$cmd$args 3961238106Sdes fi 3962238106Sdes} 3963238106Sdes 3964296415Sdestest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965238106Sdes 3966238106Sdes 3967238106Sdes# func_mode_finish arg... 3968238106Sdesfunc_mode_finish () 3969238106Sdes{ 3970296415Sdes $debug_cmd 3971296415Sdes 3972238106Sdes libs= 3973238106Sdes libdirs= 3974238106Sdes admincmds= 3975238106Sdes 3976238106Sdes for opt in "$nonopt" ${1+"$@"} 3977238106Sdes do 3978238106Sdes if test -d "$opt"; then 3979238106Sdes func_append libdirs " $opt" 3980238106Sdes 3981238106Sdes elif test -f "$opt"; then 3982238106Sdes if func_lalib_unsafe_p "$opt"; then 3983238106Sdes func_append libs " $opt" 3984238106Sdes else 3985296415Sdes func_warning "'$opt' is not a valid libtool archive" 3986238106Sdes fi 3987238106Sdes 3988238106Sdes else 3989296415Sdes func_fatal_error "invalid argument '$opt'" 3990238106Sdes fi 3991238106Sdes done 3992238106Sdes 3993238106Sdes if test -n "$libs"; then 3994238106Sdes if test -n "$lt_sysroot"; then 3995238106Sdes sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996238106Sdes sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997238106Sdes else 3998238106Sdes sysroot_cmd= 3999238106Sdes fi 4000238106Sdes 4001238106Sdes # Remove sysroot references 4002238106Sdes if $opt_dry_run; then 4003238106Sdes for lib in $libs; do 4004296415Sdes echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005238106Sdes done 4006238106Sdes else 4007238106Sdes tmpdir=`func_mktempdir` 4008238106Sdes for lib in $libs; do 4009296415Sdes $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010238106Sdes > $tmpdir/tmp-la 4011238106Sdes mv -f $tmpdir/tmp-la $lib 4012238106Sdes done 4013238106Sdes ${RM}r "$tmpdir" 4014238106Sdes fi 4015238106Sdes fi 4016238106Sdes 4017238106Sdes if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018238106Sdes for libdir in $libdirs; do 4019238106Sdes if test -n "$finish_cmds"; then 4020238106Sdes # Do each command in the finish commands. 4021238106Sdes func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022238106Sdes'"$cmd"'"' 4023238106Sdes fi 4024238106Sdes if test -n "$finish_eval"; then 4025238106Sdes # Do the single finish_eval. 4026238106Sdes eval cmds=\"$finish_eval\" 4027238106Sdes $opt_dry_run || eval "$cmds" || func_append admincmds " 4028238106Sdes $cmds" 4029238106Sdes fi 4030238106Sdes done 4031238106Sdes fi 4032238106Sdes 4033238106Sdes # Exit here if they wanted silent mode. 4034296415Sdes $opt_quiet && exit $EXIT_SUCCESS 4035238106Sdes 4036238106Sdes if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037238106Sdes echo "----------------------------------------------------------------------" 4038238106Sdes echo "Libraries have been installed in:" 4039238106Sdes for libdir in $libdirs; do 4040238106Sdes $ECHO " $libdir" 4041238106Sdes done 4042238106Sdes echo 4043238106Sdes echo "If you ever happen to want to link against installed libraries" 4044238106Sdes echo "in a given directory, LIBDIR, you must either use libtool, and" 4045296415Sdes echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046238106Sdes echo "flag during linking and do at least one of the following:" 4047238106Sdes if test -n "$shlibpath_var"; then 4048296415Sdes echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049238106Sdes echo " during execution" 4050238106Sdes fi 4051238106Sdes if test -n "$runpath_var"; then 4052296415Sdes echo " - add LIBDIR to the '$runpath_var' environment variable" 4053238106Sdes echo " during linking" 4054238106Sdes fi 4055238106Sdes if test -n "$hardcode_libdir_flag_spec"; then 4056238106Sdes libdir=LIBDIR 4057238106Sdes eval flag=\"$hardcode_libdir_flag_spec\" 4058238106Sdes 4059296415Sdes $ECHO " - use the '$flag' linker flag" 4060238106Sdes fi 4061238106Sdes if test -n "$admincmds"; then 4062238106Sdes $ECHO " - have your system administrator run these commands:$admincmds" 4063238106Sdes fi 4064238106Sdes if test -f /etc/ld.so.conf; then 4065296415Sdes echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066238106Sdes fi 4067238106Sdes echo 4068238106Sdes 4069238106Sdes echo "See any operating system documentation about shared libraries for" 4070238106Sdes case $host in 4071238106Sdes solaris2.[6789]|solaris2.1[0-9]) 4072238106Sdes echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073238106Sdes echo "pages." 4074238106Sdes ;; 4075238106Sdes *) 4076238106Sdes echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077238106Sdes ;; 4078238106Sdes esac 4079238106Sdes echo "----------------------------------------------------------------------" 4080238106Sdes fi 4081238106Sdes exit $EXIT_SUCCESS 4082238106Sdes} 4083238106Sdes 4084296415Sdestest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085238106Sdes 4086238106Sdes 4087238106Sdes# func_mode_install arg... 4088238106Sdesfunc_mode_install () 4089238106Sdes{ 4090296415Sdes $debug_cmd 4091296415Sdes 4092238106Sdes # There may be an optional sh(1) argument at the beginning of 4093238106Sdes # install_prog (especially on Windows NT). 4094296415Sdes if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095238106Sdes # Allow the use of GNU shtool's install command. 4096296415Sdes case $nonopt in *shtool*) :;; *) false;; esac 4097296415Sdes then 4098238106Sdes # Aesthetically quote it. 4099238106Sdes func_quote_for_eval "$nonopt" 4100238106Sdes install_prog="$func_quote_for_eval_result " 4101238106Sdes arg=$1 4102238106Sdes shift 4103238106Sdes else 4104238106Sdes install_prog= 4105238106Sdes arg=$nonopt 4106238106Sdes fi 4107238106Sdes 4108238106Sdes # The real first argument should be the name of the installation program. 4109238106Sdes # Aesthetically quote it. 4110238106Sdes func_quote_for_eval "$arg" 4111238106Sdes func_append install_prog "$func_quote_for_eval_result" 4112238106Sdes install_shared_prog=$install_prog 4113238106Sdes case " $install_prog " in 4114238106Sdes *[\\\ /]cp\ *) install_cp=: ;; 4115238106Sdes *) install_cp=false ;; 4116238106Sdes esac 4117238106Sdes 4118238106Sdes # We need to accept at least all the BSD install flags. 4119238106Sdes dest= 4120238106Sdes files= 4121238106Sdes opts= 4122238106Sdes prev= 4123238106Sdes install_type= 4124296415Sdes isdir=false 4125238106Sdes stripme= 4126238106Sdes no_mode=: 4127238106Sdes for arg 4128238106Sdes do 4129238106Sdes arg2= 4130238106Sdes if test -n "$dest"; then 4131238106Sdes func_append files " $dest" 4132238106Sdes dest=$arg 4133238106Sdes continue 4134238106Sdes fi 4135238106Sdes 4136238106Sdes case $arg in 4137296415Sdes -d) isdir=: ;; 4138238106Sdes -f) 4139238106Sdes if $install_cp; then :; else 4140238106Sdes prev=$arg 4141238106Sdes fi 4142238106Sdes ;; 4143238106Sdes -g | -m | -o) 4144238106Sdes prev=$arg 4145238106Sdes ;; 4146238106Sdes -s) 4147238106Sdes stripme=" -s" 4148238106Sdes continue 4149238106Sdes ;; 4150238106Sdes -*) 4151238106Sdes ;; 4152238106Sdes *) 4153238106Sdes # If the previous option needed an argument, then skip it. 4154238106Sdes if test -n "$prev"; then 4155296415Sdes if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156238106Sdes arg2=$install_override_mode 4157238106Sdes no_mode=false 4158238106Sdes fi 4159238106Sdes prev= 4160238106Sdes else 4161238106Sdes dest=$arg 4162238106Sdes continue 4163238106Sdes fi 4164238106Sdes ;; 4165238106Sdes esac 4166238106Sdes 4167238106Sdes # Aesthetically quote the argument. 4168238106Sdes func_quote_for_eval "$arg" 4169238106Sdes func_append install_prog " $func_quote_for_eval_result" 4170238106Sdes if test -n "$arg2"; then 4171238106Sdes func_quote_for_eval "$arg2" 4172238106Sdes fi 4173238106Sdes func_append install_shared_prog " $func_quote_for_eval_result" 4174238106Sdes done 4175238106Sdes 4176238106Sdes test -z "$install_prog" && \ 4177238106Sdes func_fatal_help "you must specify an install program" 4178238106Sdes 4179238106Sdes test -n "$prev" && \ 4180296415Sdes func_fatal_help "the '$prev' option requires an argument" 4181238106Sdes 4182238106Sdes if test -n "$install_override_mode" && $no_mode; then 4183238106Sdes if $install_cp; then :; else 4184238106Sdes func_quote_for_eval "$install_override_mode" 4185238106Sdes func_append install_shared_prog " -m $func_quote_for_eval_result" 4186238106Sdes fi 4187238106Sdes fi 4188238106Sdes 4189238106Sdes if test -z "$files"; then 4190238106Sdes if test -z "$dest"; then 4191238106Sdes func_fatal_help "no file or destination specified" 4192238106Sdes else 4193238106Sdes func_fatal_help "you must specify a destination" 4194238106Sdes fi 4195238106Sdes fi 4196238106Sdes 4197238106Sdes # Strip any trailing slash from the destination. 4198238106Sdes func_stripname '' '/' "$dest" 4199238106Sdes dest=$func_stripname_result 4200238106Sdes 4201238106Sdes # Check to see that the destination is a directory. 4202296415Sdes test -d "$dest" && isdir=: 4203296415Sdes if $isdir; then 4204296415Sdes destdir=$dest 4205238106Sdes destname= 4206238106Sdes else 4207238106Sdes func_dirname_and_basename "$dest" "" "." 4208296415Sdes destdir=$func_dirname_result 4209296415Sdes destname=$func_basename_result 4210238106Sdes 4211238106Sdes # Not a directory, so check to see that there is only one file specified. 4212238106Sdes set dummy $files; shift 4213238106Sdes test "$#" -gt 1 && \ 4214296415Sdes func_fatal_help "'$dest' is not a directory" 4215238106Sdes fi 4216238106Sdes case $destdir in 4217238106Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 4218238106Sdes *) 4219238106Sdes for file in $files; do 4220238106Sdes case $file in 4221238106Sdes *.lo) ;; 4222238106Sdes *) 4223296415Sdes func_fatal_help "'$destdir' must be an absolute directory name" 4224238106Sdes ;; 4225238106Sdes esac 4226238106Sdes done 4227238106Sdes ;; 4228238106Sdes esac 4229238106Sdes 4230238106Sdes # This variable tells wrapper scripts just to set variables rather 4231238106Sdes # than running their programs. 4232296415Sdes libtool_install_magic=$magic 4233238106Sdes 4234238106Sdes staticlibs= 4235238106Sdes future_libdirs= 4236238106Sdes current_libdirs= 4237238106Sdes for file in $files; do 4238238106Sdes 4239238106Sdes # Do each installation. 4240238106Sdes case $file in 4241238106Sdes *.$libext) 4242238106Sdes # Do the static libraries later. 4243238106Sdes func_append staticlibs " $file" 4244238106Sdes ;; 4245238106Sdes 4246238106Sdes *.la) 4247238106Sdes func_resolve_sysroot "$file" 4248238106Sdes file=$func_resolve_sysroot_result 4249238106Sdes 4250238106Sdes # Check to see that this really is a libtool archive. 4251238106Sdes func_lalib_unsafe_p "$file" \ 4252296415Sdes || func_fatal_help "'$file' is not a valid libtool archive" 4253238106Sdes 4254238106Sdes library_names= 4255238106Sdes old_library= 4256238106Sdes relink_command= 4257238106Sdes func_source "$file" 4258238106Sdes 4259238106Sdes # Add the libdir to current_libdirs if it is the destination. 4260238106Sdes if test "X$destdir" = "X$libdir"; then 4261238106Sdes case "$current_libdirs " in 4262238106Sdes *" $libdir "*) ;; 4263238106Sdes *) func_append current_libdirs " $libdir" ;; 4264238106Sdes esac 4265238106Sdes else 4266238106Sdes # Note the libdir as a future libdir. 4267238106Sdes case "$future_libdirs " in 4268238106Sdes *" $libdir "*) ;; 4269238106Sdes *) func_append future_libdirs " $libdir" ;; 4270238106Sdes esac 4271238106Sdes fi 4272238106Sdes 4273238106Sdes func_dirname "$file" "/" "" 4274296415Sdes dir=$func_dirname_result 4275238106Sdes func_append dir "$objdir" 4276238106Sdes 4277238106Sdes if test -n "$relink_command"; then 4278238106Sdes # Determine the prefix the user has applied to our future dir. 4279238106Sdes inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280238106Sdes 4281238106Sdes # Don't allow the user to place us outside of our expected 4282238106Sdes # location b/c this prevents finding dependent libraries that 4283238106Sdes # are installed to the same prefix. 4284238106Sdes # At present, this check doesn't affect windows .dll's that 4285238106Sdes # are installed into $libdir/../bin (currently, that works fine) 4286238106Sdes # but it's something to keep an eye on. 4287238106Sdes test "$inst_prefix_dir" = "$destdir" && \ 4288296415Sdes func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289238106Sdes 4290238106Sdes if test -n "$inst_prefix_dir"; then 4291238106Sdes # Stick the inst_prefix_dir data into the link command. 4292238106Sdes relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293238106Sdes else 4294238106Sdes relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295238106Sdes fi 4296238106Sdes 4297296415Sdes func_warning "relinking '$file'" 4298238106Sdes func_show_eval "$relink_command" \ 4299296415Sdes 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300238106Sdes fi 4301238106Sdes 4302238106Sdes # See the names of the shared library. 4303238106Sdes set dummy $library_names; shift 4304238106Sdes if test -n "$1"; then 4305296415Sdes realname=$1 4306238106Sdes shift 4307238106Sdes 4308296415Sdes srcname=$realname 4309296415Sdes test -n "$relink_command" && srcname=${realname}T 4310238106Sdes 4311238106Sdes # Install the shared library and build the symlinks. 4312238106Sdes func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313238106Sdes 'exit $?' 4314296415Sdes tstripme=$stripme 4315238106Sdes case $host_os in 4316238106Sdes cygwin* | mingw* | pw32* | cegcc*) 4317238106Sdes case $realname in 4318238106Sdes *.dll.a) 4319296415Sdes tstripme= 4320238106Sdes ;; 4321238106Sdes esac 4322238106Sdes ;; 4323296415Sdes os2*) 4324296415Sdes case $realname in 4325296415Sdes *_dll.a) 4326296415Sdes tstripme= 4327296415Sdes ;; 4328296415Sdes esac 4329296415Sdes ;; 4330238106Sdes esac 4331238106Sdes if test -n "$tstripme" && test -n "$striplib"; then 4332238106Sdes func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333238106Sdes fi 4334238106Sdes 4335238106Sdes if test "$#" -gt 0; then 4336238106Sdes # Delete the old symlinks, and create new ones. 4337296415Sdes # Try 'ln -sf' first, because the 'ln' binary might depend on 4338238106Sdes # the symlink we replace! Solaris /bin/ln does not understand -f, 4339238106Sdes # so we also need to try rm && ln -s. 4340238106Sdes for linkname 4341238106Sdes do 4342238106Sdes test "$linkname" != "$realname" \ 4343238106Sdes && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344238106Sdes done 4345238106Sdes fi 4346238106Sdes 4347238106Sdes # Do each command in the postinstall commands. 4348296415Sdes lib=$destdir/$realname 4349238106Sdes func_execute_cmds "$postinstall_cmds" 'exit $?' 4350238106Sdes fi 4351238106Sdes 4352238106Sdes # Install the pseudo-library for information purposes. 4353238106Sdes func_basename "$file" 4354296415Sdes name=$func_basename_result 4355296415Sdes instname=$dir/${name}i 4356238106Sdes func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357238106Sdes 4358238106Sdes # Maybe install the static library, too. 4359238106Sdes test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360238106Sdes ;; 4361238106Sdes 4362238106Sdes *.lo) 4363238106Sdes # Install (i.e. copy) a libtool object. 4364238106Sdes 4365238106Sdes # Figure out destination file name, if it wasn't already specified. 4366238106Sdes if test -n "$destname"; then 4367296415Sdes destfile=$destdir/$destname 4368238106Sdes else 4369238106Sdes func_basename "$file" 4370296415Sdes destfile=$func_basename_result 4371296415Sdes destfile=$destdir/$destfile 4372238106Sdes fi 4373238106Sdes 4374238106Sdes # Deduce the name of the destination old-style object file. 4375238106Sdes case $destfile in 4376238106Sdes *.lo) 4377238106Sdes func_lo2o "$destfile" 4378238106Sdes staticdest=$func_lo2o_result 4379238106Sdes ;; 4380238106Sdes *.$objext) 4381296415Sdes staticdest=$destfile 4382238106Sdes destfile= 4383238106Sdes ;; 4384238106Sdes *) 4385296415Sdes func_fatal_help "cannot copy a libtool object to '$destfile'" 4386238106Sdes ;; 4387238106Sdes esac 4388238106Sdes 4389238106Sdes # Install the libtool object if requested. 4390238106Sdes test -n "$destfile" && \ 4391238106Sdes func_show_eval "$install_prog $file $destfile" 'exit $?' 4392238106Sdes 4393238106Sdes # Install the old object if enabled. 4394296415Sdes if test yes = "$build_old_libs"; then 4395238106Sdes # Deduce the name of the old-style object file. 4396238106Sdes func_lo2o "$file" 4397238106Sdes staticobj=$func_lo2o_result 4398238106Sdes func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399238106Sdes fi 4400238106Sdes exit $EXIT_SUCCESS 4401238106Sdes ;; 4402238106Sdes 4403238106Sdes *) 4404238106Sdes # Figure out destination file name, if it wasn't already specified. 4405238106Sdes if test -n "$destname"; then 4406296415Sdes destfile=$destdir/$destname 4407238106Sdes else 4408238106Sdes func_basename "$file" 4409296415Sdes destfile=$func_basename_result 4410296415Sdes destfile=$destdir/$destfile 4411238106Sdes fi 4412238106Sdes 4413238106Sdes # If the file is missing, and there is a .exe on the end, strip it 4414238106Sdes # because it is most likely a libtool script we actually want to 4415238106Sdes # install 4416296415Sdes stripped_ext= 4417238106Sdes case $file in 4418238106Sdes *.exe) 4419238106Sdes if test ! -f "$file"; then 4420238106Sdes func_stripname '' '.exe' "$file" 4421238106Sdes file=$func_stripname_result 4422296415Sdes stripped_ext=.exe 4423238106Sdes fi 4424238106Sdes ;; 4425238106Sdes esac 4426238106Sdes 4427238106Sdes # Do a test to see if this is really a libtool program. 4428238106Sdes case $host in 4429238106Sdes *cygwin* | *mingw*) 4430238106Sdes if func_ltwrapper_executable_p "$file"; then 4431238106Sdes func_ltwrapper_scriptname "$file" 4432238106Sdes wrapper=$func_ltwrapper_scriptname_result 4433238106Sdes else 4434238106Sdes func_stripname '' '.exe' "$file" 4435238106Sdes wrapper=$func_stripname_result 4436238106Sdes fi 4437238106Sdes ;; 4438238106Sdes *) 4439238106Sdes wrapper=$file 4440238106Sdes ;; 4441238106Sdes esac 4442238106Sdes if func_ltwrapper_script_p "$wrapper"; then 4443238106Sdes notinst_deplibs= 4444238106Sdes relink_command= 4445238106Sdes 4446238106Sdes func_source "$wrapper" 4447238106Sdes 4448238106Sdes # Check the variables that should have been set. 4449238106Sdes test -z "$generated_by_libtool_version" && \ 4450296415Sdes func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451238106Sdes 4452296415Sdes finalize=: 4453238106Sdes for lib in $notinst_deplibs; do 4454238106Sdes # Check to see that each library is installed. 4455238106Sdes libdir= 4456238106Sdes if test -f "$lib"; then 4457238106Sdes func_source "$lib" 4458238106Sdes fi 4459296415Sdes libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460238106Sdes if test -n "$libdir" && test ! -f "$libfile"; then 4461296415Sdes func_warning "'$lib' has not been installed in '$libdir'" 4462296415Sdes finalize=false 4463238106Sdes fi 4464238106Sdes done 4465238106Sdes 4466238106Sdes relink_command= 4467238106Sdes func_source "$wrapper" 4468238106Sdes 4469238106Sdes outputname= 4470296415Sdes if test no = "$fast_install" && test -n "$relink_command"; then 4471238106Sdes $opt_dry_run || { 4472296415Sdes if $finalize; then 4473238106Sdes tmpdir=`func_mktempdir` 4474238106Sdes func_basename "$file$stripped_ext" 4475296415Sdes file=$func_basename_result 4476296415Sdes outputname=$tmpdir/$file 4477238106Sdes # Replace the output file specification. 4478238106Sdes relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479238106Sdes 4480296415Sdes $opt_quiet || { 4481238106Sdes func_quote_for_expand "$relink_command" 4482238106Sdes eval "func_echo $func_quote_for_expand_result" 4483238106Sdes } 4484238106Sdes if eval "$relink_command"; then : 4485238106Sdes else 4486296415Sdes func_error "error: relink '$file' with the above command before installing it" 4487238106Sdes $opt_dry_run || ${RM}r "$tmpdir" 4488238106Sdes continue 4489238106Sdes fi 4490296415Sdes file=$outputname 4491238106Sdes else 4492296415Sdes func_warning "cannot relink '$file'" 4493238106Sdes fi 4494238106Sdes } 4495238106Sdes else 4496238106Sdes # Install the binary that we compiled earlier. 4497238106Sdes file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498238106Sdes fi 4499238106Sdes fi 4500238106Sdes 4501238106Sdes # remove .exe since cygwin /usr/bin/install will append another 4502238106Sdes # one anyway 4503238106Sdes case $install_prog,$host in 4504238106Sdes */usr/bin/install*,*cygwin*) 4505238106Sdes case $file:$destfile in 4506238106Sdes *.exe:*.exe) 4507238106Sdes # this is ok 4508238106Sdes ;; 4509238106Sdes *.exe:*) 4510238106Sdes destfile=$destfile.exe 4511238106Sdes ;; 4512238106Sdes *:*.exe) 4513238106Sdes func_stripname '' '.exe' "$destfile" 4514238106Sdes destfile=$func_stripname_result 4515238106Sdes ;; 4516238106Sdes esac 4517238106Sdes ;; 4518238106Sdes esac 4519238106Sdes func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520238106Sdes $opt_dry_run || if test -n "$outputname"; then 4521238106Sdes ${RM}r "$tmpdir" 4522238106Sdes fi 4523238106Sdes ;; 4524238106Sdes esac 4525238106Sdes done 4526238106Sdes 4527238106Sdes for file in $staticlibs; do 4528238106Sdes func_basename "$file" 4529296415Sdes name=$func_basename_result 4530238106Sdes 4531238106Sdes # Set up the ranlib parameters. 4532296415Sdes oldlib=$destdir/$name 4533249141Sdes func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534249141Sdes tool_oldlib=$func_to_tool_file_result 4535238106Sdes 4536238106Sdes func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537238106Sdes 4538238106Sdes if test -n "$stripme" && test -n "$old_striplib"; then 4539249141Sdes func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540238106Sdes fi 4541238106Sdes 4542238106Sdes # Do each command in the postinstall commands. 4543238106Sdes func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544238106Sdes done 4545238106Sdes 4546238106Sdes test -n "$future_libdirs" && \ 4547296415Sdes func_warning "remember to run '$progname --finish$future_libdirs'" 4548238106Sdes 4549238106Sdes if test -n "$current_libdirs"; then 4550238106Sdes # Maybe just do a dry run. 4551238106Sdes $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552296415Sdes exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553238106Sdes else 4554238106Sdes exit $EXIT_SUCCESS 4555238106Sdes fi 4556238106Sdes} 4557238106Sdes 4558296415Sdestest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559238106Sdes 4560238106Sdes 4561238106Sdes# func_generate_dlsyms outputname originator pic_p 4562238106Sdes# Extract symbols from dlprefiles and create ${outputname}S.o with 4563238106Sdes# a dlpreopen symbol table. 4564238106Sdesfunc_generate_dlsyms () 4565238106Sdes{ 4566296415Sdes $debug_cmd 4567296415Sdes 4568296415Sdes my_outputname=$1 4569296415Sdes my_originator=$2 4570296415Sdes my_pic_p=${3-false} 4571296415Sdes my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572238106Sdes my_dlsyms= 4573238106Sdes 4574296415Sdes if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575238106Sdes if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576296415Sdes my_dlsyms=${my_outputname}S.c 4577238106Sdes else 4578238106Sdes func_error "not configured to extract global symbols from dlpreopened files" 4579238106Sdes fi 4580238106Sdes fi 4581238106Sdes 4582238106Sdes if test -n "$my_dlsyms"; then 4583238106Sdes case $my_dlsyms in 4584238106Sdes "") ;; 4585238106Sdes *.c) 4586238106Sdes # Discover the nlist of each of the dlfiles. 4587296415Sdes nlist=$output_objdir/$my_outputname.nm 4588238106Sdes 4589238106Sdes func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590238106Sdes 4591238106Sdes # Parse the name list into a source file. 4592238106Sdes func_verbose "creating $output_objdir/$my_dlsyms" 4593238106Sdes 4594238106Sdes $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595296415Sdes/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596296415Sdes/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597238106Sdes 4598238106Sdes#ifdef __cplusplus 4599238106Sdesextern \"C\" { 4600238106Sdes#endif 4601238106Sdes 4602296415Sdes#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603238106Sdes#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604238106Sdes#endif 4605238106Sdes 4606238106Sdes/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607296415Sdes#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608296415Sdes/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609238106Sdes relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610238106Sdes# define LT_DLSYM_CONST 4611296415Sdes#elif defined __osf__ 4612238106Sdes/* This system does not cope well with relocations in const data. */ 4613238106Sdes# define LT_DLSYM_CONST 4614238106Sdes#else 4615238106Sdes# define LT_DLSYM_CONST const 4616238106Sdes#endif 4617238106Sdes 4618296415Sdes#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619296415Sdes 4620238106Sdes/* External symbol declarations for the compiler. */\ 4621238106Sdes" 4622238106Sdes 4623296415Sdes if test yes = "$dlself"; then 4624296415Sdes func_verbose "generating symbol list for '$output'" 4625238106Sdes 4626238106Sdes $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627238106Sdes 4628238106Sdes # Add our own program objects to the symbol list. 4629238106Sdes progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630238106Sdes for progfile in $progfiles; do 4631238106Sdes func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632296415Sdes func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633238106Sdes $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634238106Sdes done 4635238106Sdes 4636238106Sdes if test -n "$exclude_expsyms"; then 4637238106Sdes $opt_dry_run || { 4638238106Sdes eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639238106Sdes eval '$MV "$nlist"T "$nlist"' 4640238106Sdes } 4641238106Sdes fi 4642238106Sdes 4643238106Sdes if test -n "$export_symbols_regex"; then 4644238106Sdes $opt_dry_run || { 4645238106Sdes eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646238106Sdes eval '$MV "$nlist"T "$nlist"' 4647238106Sdes } 4648238106Sdes fi 4649238106Sdes 4650238106Sdes # Prepare the list of exported symbols 4651238106Sdes if test -z "$export_symbols"; then 4652296415Sdes export_symbols=$output_objdir/$outputname.exp 4653238106Sdes $opt_dry_run || { 4654238106Sdes $RM $export_symbols 4655296415Sdes eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656238106Sdes case $host in 4657238106Sdes *cygwin* | *mingw* | *cegcc* ) 4658238106Sdes eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659238106Sdes eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660238106Sdes ;; 4661238106Sdes esac 4662238106Sdes } 4663238106Sdes else 4664238106Sdes $opt_dry_run || { 4665296415Sdes eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666238106Sdes eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667238106Sdes eval '$MV "$nlist"T "$nlist"' 4668238106Sdes case $host in 4669238106Sdes *cygwin* | *mingw* | *cegcc* ) 4670238106Sdes eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671238106Sdes eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672238106Sdes ;; 4673238106Sdes esac 4674238106Sdes } 4675238106Sdes fi 4676238106Sdes fi 4677238106Sdes 4678238106Sdes for dlprefile in $dlprefiles; do 4679296415Sdes func_verbose "extracting global C symbols from '$dlprefile'" 4680238106Sdes func_basename "$dlprefile" 4681296415Sdes name=$func_basename_result 4682238106Sdes case $host in 4683238106Sdes *cygwin* | *mingw* | *cegcc* ) 4684238106Sdes # if an import library, we need to obtain dlname 4685238106Sdes if func_win32_import_lib_p "$dlprefile"; then 4686238106Sdes func_tr_sh "$dlprefile" 4687238106Sdes eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688296415Sdes dlprefile_dlbasename= 4689238106Sdes if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690238106Sdes # Use subshell, to avoid clobbering current variable values 4691238106Sdes dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692296415Sdes if test -n "$dlprefile_dlname"; then 4693238106Sdes func_basename "$dlprefile_dlname" 4694296415Sdes dlprefile_dlbasename=$func_basename_result 4695238106Sdes else 4696238106Sdes # no lafile. user explicitly requested -dlpreopen <import library>. 4697238106Sdes $sharedlib_from_linklib_cmd "$dlprefile" 4698238106Sdes dlprefile_dlbasename=$sharedlib_from_linklib_result 4699238106Sdes fi 4700238106Sdes fi 4701238106Sdes $opt_dry_run || { 4702296415Sdes if test -n "$dlprefile_dlbasename"; then 4703238106Sdes eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704238106Sdes else 4705238106Sdes func_warning "Could not compute DLL name from $name" 4706238106Sdes eval '$ECHO ": $name " >> "$nlist"' 4707238106Sdes fi 4708238106Sdes func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709238106Sdes eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710238106Sdes $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711238106Sdes } 4712238106Sdes else # not an import lib 4713238106Sdes $opt_dry_run || { 4714238106Sdes eval '$ECHO ": $name " >> "$nlist"' 4715238106Sdes func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716238106Sdes eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717238106Sdes } 4718238106Sdes fi 4719238106Sdes ;; 4720238106Sdes *) 4721238106Sdes $opt_dry_run || { 4722238106Sdes eval '$ECHO ": $name " >> "$nlist"' 4723238106Sdes func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724238106Sdes eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725238106Sdes } 4726238106Sdes ;; 4727238106Sdes esac 4728238106Sdes done 4729238106Sdes 4730238106Sdes $opt_dry_run || { 4731238106Sdes # Make sure we have at least an empty file. 4732238106Sdes test -f "$nlist" || : > "$nlist" 4733238106Sdes 4734238106Sdes if test -n "$exclude_expsyms"; then 4735238106Sdes $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736238106Sdes $MV "$nlist"T "$nlist" 4737238106Sdes fi 4738238106Sdes 4739238106Sdes # Try sorting and uniquifying the output. 4740238106Sdes if $GREP -v "^: " < "$nlist" | 4741238106Sdes if sort -k 3 </dev/null >/dev/null 2>&1; then 4742238106Sdes sort -k 3 4743238106Sdes else 4744238106Sdes sort +2 4745238106Sdes fi | 4746238106Sdes uniq > "$nlist"S; then 4747238106Sdes : 4748238106Sdes else 4749238106Sdes $GREP -v "^: " < "$nlist" > "$nlist"S 4750238106Sdes fi 4751238106Sdes 4752238106Sdes if test -f "$nlist"S; then 4753238106Sdes eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754238106Sdes else 4755238106Sdes echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756238106Sdes fi 4757238106Sdes 4758296415Sdes func_show_eval '$RM "${nlist}I"' 4759296415Sdes if test -n "$global_symbol_to_import"; then 4760296415Sdes eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761296415Sdes fi 4762296415Sdes 4763238106Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4764238106Sdes 4765238106Sdes/* The mapping between symbol names and symbols. */ 4766238106Sdestypedef struct { 4767238106Sdes const char *name; 4768238106Sdes void *address; 4769238106Sdes} lt_dlsymlist; 4770238106Sdesextern LT_DLSYM_CONST lt_dlsymlist 4771296415Sdeslt_${my_prefix}_LTX_preloaded_symbols[];\ 4772296415Sdes" 4773296415Sdes 4774296415Sdes if test -s "$nlist"I; then 4775296415Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4776296415Sdesstatic void lt_syminit(void) 4777296415Sdes{ 4778296415Sdes LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779296415Sdes for (; symbol->name; ++symbol) 4780296415Sdes {" 4781296415Sdes $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782296415Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4783296415Sdes } 4784296415Sdes}" 4785296415Sdes fi 4786296415Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4787238106SdesLT_DLSYM_CONST lt_dlsymlist 4788238106Sdeslt_${my_prefix}_LTX_preloaded_symbols[] = 4789296415Sdes{ {\"$my_originator\", (void *) 0}," 4790238106Sdes 4791296415Sdes if test -s "$nlist"I; then 4792296415Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4793296415Sdes {\"@INIT@\", (void *) <_syminit}," 4794296415Sdes fi 4795296415Sdes 4796238106Sdes case $need_lib_prefix in 4797238106Sdes no) 4798238106Sdes eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799238106Sdes ;; 4800238106Sdes *) 4801238106Sdes eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802238106Sdes ;; 4803238106Sdes esac 4804238106Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4805238106Sdes {0, (void *) 0} 4806238106Sdes}; 4807238106Sdes 4808238106Sdes/* This works around a problem in FreeBSD linker */ 4809238106Sdes#ifdef FREEBSD_WORKAROUND 4810238106Sdesstatic const void *lt_preloaded_setup() { 4811238106Sdes return lt_${my_prefix}_LTX_preloaded_symbols; 4812238106Sdes} 4813238106Sdes#endif 4814238106Sdes 4815238106Sdes#ifdef __cplusplus 4816238106Sdes} 4817238106Sdes#endif\ 4818238106Sdes" 4819238106Sdes } # !$opt_dry_run 4820238106Sdes 4821238106Sdes pic_flag_for_symtable= 4822238106Sdes case "$compile_command " in 4823238106Sdes *" -static "*) ;; 4824238106Sdes *) 4825238106Sdes case $host in 4826238106Sdes # compiling the symbol table file with pic_flag works around 4827238106Sdes # a FreeBSD bug that causes programs to crash when -lm is 4828238106Sdes # linked before any other PIC object. But we must not use 4829238106Sdes # pic_flag when linking with -static. The problem exists in 4830238106Sdes # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831249141Sdes *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832238106Sdes pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833238106Sdes *-*-hpux*) 4834238106Sdes pic_flag_for_symtable=" $pic_flag" ;; 4835238106Sdes *) 4836296415Sdes $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837238106Sdes ;; 4838238106Sdes esac 4839238106Sdes ;; 4840238106Sdes esac 4841238106Sdes symtab_cflags= 4842238106Sdes for arg in $LTCFLAGS; do 4843238106Sdes case $arg in 4844238106Sdes -pie | -fpie | -fPIE) ;; 4845238106Sdes *) func_append symtab_cflags " $arg" ;; 4846238106Sdes esac 4847238106Sdes done 4848238106Sdes 4849238106Sdes # Now compile the dynamic symbol file. 4850238106Sdes func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851238106Sdes 4852238106Sdes # Clean up the generated files. 4853296415Sdes func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854238106Sdes 4855238106Sdes # Transform the symbol file into the correct name. 4856296415Sdes symfileobj=$output_objdir/${my_outputname}S.$objext 4857238106Sdes case $host in 4858238106Sdes *cygwin* | *mingw* | *cegcc* ) 4859238106Sdes if test -f "$output_objdir/$my_outputname.def"; then 4860238106Sdes compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861238106Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862238106Sdes else 4863238106Sdes compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864238106Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865238106Sdes fi 4866238106Sdes ;; 4867238106Sdes *) 4868238106Sdes compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869238106Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870238106Sdes ;; 4871238106Sdes esac 4872238106Sdes ;; 4873238106Sdes *) 4874296415Sdes func_fatal_error "unknown suffix for '$my_dlsyms'" 4875238106Sdes ;; 4876238106Sdes esac 4877238106Sdes else 4878238106Sdes # We keep going just in case the user didn't refer to 4879238106Sdes # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880238106Sdes # really was required. 4881238106Sdes 4882238106Sdes # Nullify the symbol file. 4883238106Sdes compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884238106Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885238106Sdes fi 4886238106Sdes} 4887238106Sdes 4888296415Sdes# func_cygming_gnu_implib_p ARG 4889296415Sdes# This predicate returns with zero status (TRUE) if 4890296415Sdes# ARG is a GNU/binutils-style import library. Returns 4891296415Sdes# with nonzero status (FALSE) otherwise. 4892296415Sdesfunc_cygming_gnu_implib_p () 4893296415Sdes{ 4894296415Sdes $debug_cmd 4895296415Sdes 4896296415Sdes func_to_tool_file "$1" func_convert_file_msys_to_w32 4897296415Sdes func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` 4898296415Sdes test -n "$func_cygming_gnu_implib_tmp" 4899296415Sdes} 4900296415Sdes 4901296415Sdes# func_cygming_ms_implib_p ARG 4902296415Sdes# This predicate returns with zero status (TRUE) if 4903296415Sdes# ARG is an MS-style import library. Returns 4904296415Sdes# with nonzero status (FALSE) otherwise. 4905296415Sdesfunc_cygming_ms_implib_p () 4906296415Sdes{ 4907296415Sdes $debug_cmd 4908296415Sdes 4909296415Sdes func_to_tool_file "$1" func_convert_file_msys_to_w32 4910296415Sdes func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911296415Sdes test -n "$func_cygming_ms_implib_tmp" 4912296415Sdes} 4913296415Sdes 4914238106Sdes# func_win32_libid arg 4915238106Sdes# return the library type of file 'arg' 4916238106Sdes# 4917238106Sdes# Need a lot of goo to handle *both* DLLs and import libs 4918238106Sdes# Has to be a shell function in order to 'eat' the argument 4919238106Sdes# that is supplied when $file_magic_command is called. 4920238106Sdes# Despite the name, also deal with 64 bit binaries. 4921238106Sdesfunc_win32_libid () 4922238106Sdes{ 4923296415Sdes $debug_cmd 4924296415Sdes 4925296415Sdes win32_libid_type=unknown 4926238106Sdes win32_fileres=`file -L $1 2>/dev/null` 4927238106Sdes case $win32_fileres in 4928238106Sdes *ar\ archive\ import\ library*) # definitely import 4929238106Sdes win32_libid_type="x86 archive import" 4930238106Sdes ;; 4931238106Sdes *ar\ archive*) # could be an import, or static 4932238106Sdes # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933238106Sdes if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934238106Sdes $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935296415Sdes case $nm_interface in 4936296415Sdes "MS dumpbin") 4937296415Sdes if func_cygming_ms_implib_p "$1" || 4938296415Sdes func_cygming_gnu_implib_p "$1" 4939296415Sdes then 4940296415Sdes win32_nmres=import 4941296415Sdes else 4942296415Sdes win32_nmres= 4943296415Sdes fi 4944296415Sdes ;; 4945296415Sdes *) 4946296415Sdes func_to_tool_file "$1" func_convert_file_msys_to_w32 4947296415Sdes win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948296415Sdes $SED -n -e ' 4949238106Sdes 1,100{ 4950238106Sdes / I /{ 4951296415Sdes s|.*|import| 4952238106Sdes p 4953238106Sdes q 4954238106Sdes } 4955238106Sdes }'` 4956296415Sdes ;; 4957296415Sdes esac 4958238106Sdes case $win32_nmres in 4959238106Sdes import*) win32_libid_type="x86 archive import";; 4960238106Sdes *) win32_libid_type="x86 archive static";; 4961238106Sdes esac 4962238106Sdes fi 4963238106Sdes ;; 4964238106Sdes *DLL*) 4965238106Sdes win32_libid_type="x86 DLL" 4966238106Sdes ;; 4967238106Sdes *executable*) # but shell scripts are "executable" too... 4968238106Sdes case $win32_fileres in 4969238106Sdes *MS\ Windows\ PE\ Intel*) 4970238106Sdes win32_libid_type="x86 DLL" 4971238106Sdes ;; 4972238106Sdes esac 4973238106Sdes ;; 4974238106Sdes esac 4975238106Sdes $ECHO "$win32_libid_type" 4976238106Sdes} 4977238106Sdes 4978238106Sdes# func_cygming_dll_for_implib ARG 4979238106Sdes# 4980238106Sdes# Platform-specific function to extract the 4981238106Sdes# name of the DLL associated with the specified 4982238106Sdes# import library ARG. 4983238106Sdes# Invoked by eval'ing the libtool variable 4984238106Sdes# $sharedlib_from_linklib_cmd 4985238106Sdes# Result is available in the variable 4986238106Sdes# $sharedlib_from_linklib_result 4987238106Sdesfunc_cygming_dll_for_implib () 4988238106Sdes{ 4989296415Sdes $debug_cmd 4990296415Sdes 4991238106Sdes sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992238106Sdes} 4993238106Sdes 4994238106Sdes# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995238106Sdes# 4996238106Sdes# The is the core of a fallback implementation of a 4997238106Sdes# platform-specific function to extract the name of the 4998238106Sdes# DLL associated with the specified import library LIBNAME. 4999238106Sdes# 5000238106Sdes# SECTION_NAME is either .idata$6 or .idata$7, depending 5001238106Sdes# on the platform and compiler that created the implib. 5002238106Sdes# 5003238106Sdes# Echos the name of the DLL associated with the 5004238106Sdes# specified import library. 5005238106Sdesfunc_cygming_dll_for_implib_fallback_core () 5006238106Sdes{ 5007296415Sdes $debug_cmd 5008296415Sdes 5009238106Sdes match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010238106Sdes $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011238106Sdes $SED '/^Contents of section '"$match_literal"':/{ 5012238106Sdes # Place marker at beginning of archive member dllname section 5013238106Sdes s/.*/====MARK====/ 5014238106Sdes p 5015238106Sdes d 5016238106Sdes } 5017238106Sdes # These lines can sometimes be longer than 43 characters, but 5018238106Sdes # are always uninteresting 5019238106Sdes /:[ ]*file format pe[i]\{,1\}-/d 5020238106Sdes /^In archive [^:]*:/d 5021238106Sdes # Ensure marker is printed 5022238106Sdes /^====MARK====/p 5023238106Sdes # Remove all lines with less than 43 characters 5024238106Sdes /^.\{43\}/!d 5025238106Sdes # From remaining lines, remove first 43 characters 5026238106Sdes s/^.\{43\}//' | 5027238106Sdes $SED -n ' 5028238106Sdes # Join marker and all lines until next marker into a single line 5029238106Sdes /^====MARK====/ b para 5030238106Sdes H 5031238106Sdes $ b para 5032238106Sdes b 5033238106Sdes :para 5034238106Sdes x 5035238106Sdes s/\n//g 5036238106Sdes # Remove the marker 5037238106Sdes s/^====MARK====// 5038238106Sdes # Remove trailing dots and whitespace 5039238106Sdes s/[\. \t]*$// 5040238106Sdes # Print 5041238106Sdes /./p' | 5042238106Sdes # we now have a list, one entry per line, of the stringified 5043238106Sdes # contents of the appropriate section of all members of the 5044296415Sdes # archive that possess that section. Heuristic: eliminate 5045296415Sdes # all those that have a first or second character that is 5046238106Sdes # a '.' (that is, objdump's representation of an unprintable 5047238106Sdes # character.) This should work for all archives with less than 5048238106Sdes # 0x302f exports -- but will fail for DLLs whose name actually 5049238106Sdes # begins with a literal '.' or a single character followed by 5050238106Sdes # a '.'. 5051238106Sdes # 5052238106Sdes # Of those that remain, print the first one. 5053238106Sdes $SED -e '/^\./d;/^.\./d;q' 5054238106Sdes} 5055238106Sdes 5056238106Sdes# func_cygming_dll_for_implib_fallback ARG 5057238106Sdes# Platform-specific function to extract the 5058238106Sdes# name of the DLL associated with the specified 5059238106Sdes# import library ARG. 5060238106Sdes# 5061238106Sdes# This fallback implementation is for use when $DLLTOOL 5062238106Sdes# does not support the --identify-strict option. 5063238106Sdes# Invoked by eval'ing the libtool variable 5064238106Sdes# $sharedlib_from_linklib_cmd 5065238106Sdes# Result is available in the variable 5066238106Sdes# $sharedlib_from_linklib_result 5067238106Sdesfunc_cygming_dll_for_implib_fallback () 5068238106Sdes{ 5069296415Sdes $debug_cmd 5070296415Sdes 5071296415Sdes if func_cygming_gnu_implib_p "$1"; then 5072238106Sdes # binutils import library 5073238106Sdes sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074296415Sdes elif func_cygming_ms_implib_p "$1"; then 5075238106Sdes # ms-generated import library 5076238106Sdes sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077238106Sdes else 5078238106Sdes # unknown 5079296415Sdes sharedlib_from_linklib_result= 5080238106Sdes fi 5081238106Sdes} 5082238106Sdes 5083238106Sdes 5084238106Sdes# func_extract_an_archive dir oldlib 5085238106Sdesfunc_extract_an_archive () 5086238106Sdes{ 5087296415Sdes $debug_cmd 5088296415Sdes 5089296415Sdes f_ex_an_ar_dir=$1; shift 5090296415Sdes f_ex_an_ar_oldlib=$1 5091296415Sdes if test yes = "$lock_old_archive_extraction"; then 5092238106Sdes lockfile=$f_ex_an_ar_oldlib.lock 5093238106Sdes until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094238106Sdes func_echo "Waiting for $lockfile to be removed" 5095238106Sdes sleep 2 5096238106Sdes done 5097238106Sdes fi 5098238106Sdes func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099238106Sdes 'stat=$?; rm -f "$lockfile"; exit $stat' 5100296415Sdes if test yes = "$lock_old_archive_extraction"; then 5101238106Sdes $opt_dry_run || rm -f "$lockfile" 5102238106Sdes fi 5103238106Sdes if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104238106Sdes : 5105238106Sdes else 5106238106Sdes func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107238106Sdes fi 5108238106Sdes} 5109238106Sdes 5110238106Sdes 5111238106Sdes# func_extract_archives gentop oldlib ... 5112238106Sdesfunc_extract_archives () 5113238106Sdes{ 5114296415Sdes $debug_cmd 5115296415Sdes 5116296415Sdes my_gentop=$1; shift 5117238106Sdes my_oldlibs=${1+"$@"} 5118296415Sdes my_oldobjs= 5119296415Sdes my_xlib= 5120296415Sdes my_xabs= 5121296415Sdes my_xdir= 5122238106Sdes 5123238106Sdes for my_xlib in $my_oldlibs; do 5124238106Sdes # Extract the objects. 5125238106Sdes case $my_xlib in 5126296415Sdes [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127238106Sdes *) my_xabs=`pwd`"/$my_xlib" ;; 5128238106Sdes esac 5129238106Sdes func_basename "$my_xlib" 5130296415Sdes my_xlib=$func_basename_result 5131238106Sdes my_xlib_u=$my_xlib 5132238106Sdes while :; do 5133238106Sdes case " $extracted_archives " in 5134238106Sdes *" $my_xlib_u "*) 5135238106Sdes func_arith $extracted_serial + 1 5136238106Sdes extracted_serial=$func_arith_result 5137238106Sdes my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138238106Sdes *) break ;; 5139238106Sdes esac 5140238106Sdes done 5141238106Sdes extracted_archives="$extracted_archives $my_xlib_u" 5142296415Sdes my_xdir=$my_gentop/$my_xlib_u 5143238106Sdes 5144238106Sdes func_mkdir_p "$my_xdir" 5145238106Sdes 5146238106Sdes case $host in 5147238106Sdes *-darwin*) 5148238106Sdes func_verbose "Extracting $my_xabs" 5149238106Sdes # Do not bother doing anything if just a dry run 5150238106Sdes $opt_dry_run || { 5151238106Sdes darwin_orig_dir=`pwd` 5152238106Sdes cd $my_xdir || exit $? 5153238106Sdes darwin_archive=$my_xabs 5154238106Sdes darwin_curdir=`pwd` 5155296415Sdes func_basename "$darwin_archive" 5156296415Sdes darwin_base_archive=$func_basename_result 5157238106Sdes darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158238106Sdes if test -n "$darwin_arches"; then 5159238106Sdes darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160238106Sdes darwin_arch= 5161238106Sdes func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162296415Sdes for darwin_arch in $darwin_arches; do 5163296415Sdes func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164296415Sdes $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165296415Sdes cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166296415Sdes func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167238106Sdes cd "$darwin_curdir" 5168296415Sdes $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169238106Sdes done # $darwin_arches 5170238106Sdes ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171296415Sdes darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172238106Sdes darwin_file= 5173238106Sdes darwin_files= 5174238106Sdes for darwin_file in $darwin_filelist; do 5175238106Sdes darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176238106Sdes $LIPO -create -output "$darwin_file" $darwin_files 5177238106Sdes done # $darwin_filelist 5178238106Sdes $RM -rf unfat-$$ 5179238106Sdes cd "$darwin_orig_dir" 5180238106Sdes else 5181238106Sdes cd $darwin_orig_dir 5182238106Sdes func_extract_an_archive "$my_xdir" "$my_xabs" 5183238106Sdes fi # $darwin_arches 5184238106Sdes } # !$opt_dry_run 5185238106Sdes ;; 5186238106Sdes *) 5187238106Sdes func_extract_an_archive "$my_xdir" "$my_xabs" 5188238106Sdes ;; 5189238106Sdes esac 5190238106Sdes my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191238106Sdes done 5192238106Sdes 5193296415Sdes func_extract_archives_result=$my_oldobjs 5194238106Sdes} 5195238106Sdes 5196238106Sdes 5197238106Sdes# func_emit_wrapper [arg=no] 5198238106Sdes# 5199238106Sdes# Emit a libtool wrapper script on stdout. 5200238106Sdes# Don't directly open a file because we may want to 5201238106Sdes# incorporate the script contents within a cygwin/mingw 5202238106Sdes# wrapper executable. Must ONLY be called from within 5203238106Sdes# func_mode_link because it depends on a number of variables 5204238106Sdes# set therein. 5205238106Sdes# 5206238106Sdes# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207238106Sdes# variable will take. If 'yes', then the emitted script 5208296415Sdes# will assume that the directory where it is stored is 5209238106Sdes# the $objdir directory. This is a cygwin/mingw-specific 5210238106Sdes# behavior. 5211238106Sdesfunc_emit_wrapper () 5212238106Sdes{ 5213238106Sdes func_emit_wrapper_arg1=${1-no} 5214238106Sdes 5215238106Sdes $ECHO "\ 5216238106Sdes#! $SHELL 5217238106Sdes 5218238106Sdes# $output - temporary wrapper script for $objdir/$outputname 5219296415Sdes# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220238106Sdes# 5221238106Sdes# The $output program cannot be directly executed until all the libtool 5222238106Sdes# libraries that it depends on are installed. 5223238106Sdes# 5224238106Sdes# This wrapper script should never be moved out of the build directory. 5225238106Sdes# If it is, it will not operate correctly. 5226238106Sdes 5227238106Sdes# Sed substitution that helps us do robust quoting. It backslashifies 5228238106Sdes# metacharacters that are still active within double-quoted strings. 5229238106Sdessed_quote_subst='$sed_quote_subst' 5230238106Sdes 5231238106Sdes# Be Bourne compatible 5232238106Sdesif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233238106Sdes emulate sh 5234238106Sdes NULLCMD=: 5235238106Sdes # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236238106Sdes # is contrary to our usage. Disable this feature. 5237238106Sdes alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238238106Sdes setopt NO_GLOB_SUBST 5239238106Sdeselse 5240238106Sdes case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241238106Sdesfi 5242238106SdesBIN_SH=xpg4; export BIN_SH # for Tru64 5243238106SdesDUALCASE=1; export DUALCASE # for MKS sh 5244238106Sdes 5245238106Sdes# The HP-UX ksh and POSIX shell print the target directory to stdout 5246238106Sdes# if CDPATH is set. 5247238106Sdes(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248238106Sdes 5249238106Sdesrelink_command=\"$relink_command\" 5250238106Sdes 5251238106Sdes# This environment variable determines our operation mode. 5252238106Sdesif test \"\$libtool_install_magic\" = \"$magic\"; then 5253238106Sdes # install mode needs the following variables: 5254238106Sdes generated_by_libtool_version='$macro_version' 5255238106Sdes notinst_deplibs='$notinst_deplibs' 5256238106Sdeselse 5257238106Sdes # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258238106Sdes if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259238106Sdes file=\"\$0\"" 5260238106Sdes 5261238106Sdes qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262238106Sdes $ECHO "\ 5263238106Sdes 5264238106Sdes# A function that is used when there is no print builtin or printf. 5265238106Sdesfunc_fallback_echo () 5266238106Sdes{ 5267238106Sdes eval 'cat <<_LTECHO_EOF 5268238106Sdes\$1 5269238106Sdes_LTECHO_EOF' 5270238106Sdes} 5271238106Sdes ECHO=\"$qECHO\" 5272238106Sdes fi 5273238106Sdes 5274238106Sdes# Very basic option parsing. These options are (a) specific to 5275238106Sdes# the libtool wrapper, (b) are identical between the wrapper 5276296415Sdes# /script/ and the wrapper /executable/ that is used only on 5277238106Sdes# windows platforms, and (c) all begin with the string "--lt-" 5278296415Sdes# (application programs are unlikely to have options that match 5279238106Sdes# this pattern). 5280238106Sdes# 5281238106Sdes# There are only two supported options: --lt-debug and 5282238106Sdes# --lt-dump-script. There is, deliberately, no --lt-help. 5283238106Sdes# 5284238106Sdes# The first argument to this parsing function should be the 5285238106Sdes# script's $0 value, followed by "$@". 5286238106Sdeslt_option_debug= 5287238106Sdesfunc_parse_lt_options () 5288238106Sdes{ 5289238106Sdes lt_script_arg0=\$0 5290238106Sdes shift 5291238106Sdes for lt_opt 5292238106Sdes do 5293238106Sdes case \"\$lt_opt\" in 5294238106Sdes --lt-debug) lt_option_debug=1 ;; 5295238106Sdes --lt-dump-script) 5296238106Sdes lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297238106Sdes test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298238106Sdes lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299238106Sdes cat \"\$lt_dump_D/\$lt_dump_F\" 5300238106Sdes exit 0 5301238106Sdes ;; 5302238106Sdes --lt-*) 5303238106Sdes \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304238106Sdes exit 1 5305238106Sdes ;; 5306238106Sdes esac 5307238106Sdes done 5308238106Sdes 5309238106Sdes # Print the debug banner immediately: 5310238106Sdes if test -n \"\$lt_option_debug\"; then 5311296415Sdes echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312238106Sdes fi 5313238106Sdes} 5314238106Sdes 5315238106Sdes# Used when --lt-debug. Prints its arguments to stdout 5316238106Sdes# (redirection is the responsibility of the caller) 5317238106Sdesfunc_lt_dump_args () 5318238106Sdes{ 5319238106Sdes lt_dump_args_N=1; 5320238106Sdes for lt_arg 5321238106Sdes do 5322296415Sdes \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323238106Sdes lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324238106Sdes done 5325238106Sdes} 5326238106Sdes 5327238106Sdes# Core function for launching the target application 5328238106Sdesfunc_exec_program_core () 5329238106Sdes{ 5330238106Sdes" 5331238106Sdes case $host in 5332238106Sdes # Backslashes separate directories on plain windows 5333238106Sdes *-*-mingw | *-*-os2* | *-cegcc*) 5334238106Sdes $ECHO "\ 5335238106Sdes if test -n \"\$lt_option_debug\"; then 5336296415Sdes \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337238106Sdes func_lt_dump_args \${1+\"\$@\"} 1>&2 5338238106Sdes fi 5339238106Sdes exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340238106Sdes" 5341238106Sdes ;; 5342238106Sdes 5343238106Sdes *) 5344238106Sdes $ECHO "\ 5345238106Sdes if test -n \"\$lt_option_debug\"; then 5346296415Sdes \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347238106Sdes func_lt_dump_args \${1+\"\$@\"} 1>&2 5348238106Sdes fi 5349238106Sdes exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350238106Sdes" 5351238106Sdes ;; 5352238106Sdes esac 5353238106Sdes $ECHO "\ 5354238106Sdes \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355238106Sdes exit 1 5356238106Sdes} 5357238106Sdes 5358238106Sdes# A function to encapsulate launching the target application 5359238106Sdes# Strips options in the --lt-* namespace from \$@ and 5360238106Sdes# launches target application with the remaining arguments. 5361238106Sdesfunc_exec_program () 5362238106Sdes{ 5363249141Sdes case \" \$* \" in 5364249141Sdes *\\ --lt-*) 5365249141Sdes for lt_wr_arg 5366249141Sdes do 5367249141Sdes case \$lt_wr_arg in 5368249141Sdes --lt-*) ;; 5369249141Sdes *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370249141Sdes esac 5371249141Sdes shift 5372249141Sdes done ;; 5373249141Sdes esac 5374238106Sdes func_exec_program_core \${1+\"\$@\"} 5375238106Sdes} 5376238106Sdes 5377238106Sdes # Parse options 5378238106Sdes func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379238106Sdes 5380238106Sdes # Find the directory that this script lives in. 5381238106Sdes thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382238106Sdes test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383238106Sdes 5384238106Sdes # Follow symbolic links until we get to the real thisdir. 5385238106Sdes file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386238106Sdes while test -n \"\$file\"; do 5387238106Sdes destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388238106Sdes 5389238106Sdes # If there was a directory component, then change thisdir. 5390238106Sdes if test \"x\$destdir\" != \"x\$file\"; then 5391238106Sdes case \"\$destdir\" in 5392238106Sdes [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393238106Sdes *) thisdir=\"\$thisdir/\$destdir\" ;; 5394238106Sdes esac 5395238106Sdes fi 5396238106Sdes 5397238106Sdes file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398238106Sdes file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399238106Sdes done 5400238106Sdes 5401238106Sdes # Usually 'no', except on cygwin/mingw when embedded into 5402238106Sdes # the cwrapper. 5403238106Sdes WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404238106Sdes if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405238106Sdes # special case for '.' 5406238106Sdes if test \"\$thisdir\" = \".\"; then 5407238106Sdes thisdir=\`pwd\` 5408238106Sdes fi 5409238106Sdes # remove .libs from thisdir 5410238106Sdes case \"\$thisdir\" in 5411238106Sdes *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412238106Sdes $objdir ) thisdir=. ;; 5413238106Sdes esac 5414238106Sdes fi 5415238106Sdes 5416238106Sdes # Try to get the absolute directory name. 5417238106Sdes absdir=\`cd \"\$thisdir\" && pwd\` 5418238106Sdes test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419238106Sdes" 5420238106Sdes 5421296415Sdes if test yes = "$fast_install"; then 5422238106Sdes $ECHO "\ 5423238106Sdes program=lt-'$outputname'$exeext 5424238106Sdes progdir=\"\$thisdir/$objdir\" 5425238106Sdes 5426238106Sdes if test ! -f \"\$progdir/\$program\" || 5427296415Sdes { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428238106Sdes test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429238106Sdes 5430238106Sdes file=\"\$\$-\$program\" 5431238106Sdes 5432238106Sdes if test ! -d \"\$progdir\"; then 5433238106Sdes $MKDIR \"\$progdir\" 5434238106Sdes else 5435238106Sdes $RM \"\$progdir/\$file\" 5436238106Sdes fi" 5437238106Sdes 5438238106Sdes $ECHO "\ 5439238106Sdes 5440238106Sdes # relink executable if necessary 5441238106Sdes if test -n \"\$relink_command\"; then 5442238106Sdes if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443238106Sdes else 5444296415Sdes \$ECHO \"\$relink_command_output\" >&2 5445238106Sdes $RM \"\$progdir/\$file\" 5446238106Sdes exit 1 5447238106Sdes fi 5448238106Sdes fi 5449238106Sdes 5450238106Sdes $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451238106Sdes { $RM \"\$progdir/\$program\"; 5452238106Sdes $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453238106Sdes $RM \"\$progdir/\$file\" 5454238106Sdes fi" 5455238106Sdes else 5456238106Sdes $ECHO "\ 5457238106Sdes program='$outputname' 5458238106Sdes progdir=\"\$thisdir/$objdir\" 5459238106Sdes" 5460238106Sdes fi 5461238106Sdes 5462238106Sdes $ECHO "\ 5463238106Sdes 5464238106Sdes if test -f \"\$progdir/\$program\"; then" 5465238106Sdes 5466238106Sdes # fixup the dll searchpath if we need to. 5467238106Sdes # 5468238106Sdes # Fix the DLL searchpath if we need to. Do this before prepending 5469238106Sdes # to shlibpath, because on Windows, both are PATH and uninstalled 5470238106Sdes # libraries must come first. 5471238106Sdes if test -n "$dllsearchpath"; then 5472238106Sdes $ECHO "\ 5473238106Sdes # Add the dll search path components to the executable PATH 5474238106Sdes PATH=$dllsearchpath:\$PATH 5475238106Sdes" 5476238106Sdes fi 5477238106Sdes 5478238106Sdes # Export our shlibpath_var if we have one. 5479296415Sdes if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480238106Sdes $ECHO "\ 5481238106Sdes # Add our own library path to $shlibpath_var 5482238106Sdes $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483238106Sdes 5484238106Sdes # Some systems cannot cope with colon-terminated $shlibpath_var 5485238106Sdes # The second colon is a workaround for a bug in BeOS R4 sed 5486238106Sdes $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487238106Sdes 5488238106Sdes export $shlibpath_var 5489238106Sdes" 5490238106Sdes fi 5491238106Sdes 5492238106Sdes $ECHO "\ 5493238106Sdes if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494238106Sdes # Run the actual program with our arguments. 5495238106Sdes func_exec_program \${1+\"\$@\"} 5496238106Sdes fi 5497238106Sdes else 5498238106Sdes # The program doesn't exist. 5499296415Sdes \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500238106Sdes \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501238106Sdes \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502238106Sdes exit 1 5503238106Sdes fi 5504238106Sdesfi\ 5505238106Sdes" 5506238106Sdes} 5507238106Sdes 5508238106Sdes 5509238106Sdes# func_emit_cwrapperexe_src 5510238106Sdes# emit the source code for a wrapper executable on stdout 5511238106Sdes# Must ONLY be called from within func_mode_link because 5512238106Sdes# it depends on a number of variable set therein. 5513238106Sdesfunc_emit_cwrapperexe_src () 5514238106Sdes{ 5515238106Sdes cat <<EOF 5516238106Sdes 5517238106Sdes/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518296415Sdes Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519238106Sdes 5520238106Sdes The $output program cannot be directly executed until all the libtool 5521238106Sdes libraries that it depends on are installed. 5522238106Sdes 5523238106Sdes This wrapper executable should never be moved out of the build directory. 5524238106Sdes If it is, it will not operate correctly. 5525238106Sdes*/ 5526238106SdesEOF 5527238106Sdes cat <<"EOF" 5528238106Sdes#ifdef _MSC_VER 5529238106Sdes# define _CRT_SECURE_NO_DEPRECATE 1 5530238106Sdes#endif 5531238106Sdes#include <stdio.h> 5532238106Sdes#include <stdlib.h> 5533238106Sdes#ifdef _MSC_VER 5534238106Sdes# include <direct.h> 5535238106Sdes# include <process.h> 5536238106Sdes# include <io.h> 5537238106Sdes#else 5538238106Sdes# include <unistd.h> 5539238106Sdes# include <stdint.h> 5540238106Sdes# ifdef __CYGWIN__ 5541238106Sdes# include <io.h> 5542238106Sdes# endif 5543238106Sdes#endif 5544238106Sdes#include <malloc.h> 5545238106Sdes#include <stdarg.h> 5546238106Sdes#include <assert.h> 5547238106Sdes#include <string.h> 5548238106Sdes#include <ctype.h> 5549238106Sdes#include <errno.h> 5550238106Sdes#include <fcntl.h> 5551238106Sdes#include <sys/stat.h> 5552238106Sdes 5553296415Sdes#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554296415Sdes 5555238106Sdes/* declarations of non-ANSI functions */ 5556296415Sdes#if defined __MINGW32__ 5557238106Sdes# ifdef __STRICT_ANSI__ 5558238106Sdesint _putenv (const char *); 5559238106Sdes# endif 5560296415Sdes#elif defined __CYGWIN__ 5561238106Sdes# ifdef __STRICT_ANSI__ 5562238106Sdeschar *realpath (const char *, char *); 5563238106Sdesint putenv (char *); 5564238106Sdesint setenv (const char *, const char *, int); 5565238106Sdes# endif 5566296415Sdes/* #elif defined other_platform || defined ... */ 5567238106Sdes#endif 5568238106Sdes 5569238106Sdes/* portability defines, excluding path handling macros */ 5570296415Sdes#if defined _MSC_VER 5571238106Sdes# define setmode _setmode 5572238106Sdes# define stat _stat 5573238106Sdes# define chmod _chmod 5574238106Sdes# define getcwd _getcwd 5575238106Sdes# define putenv _putenv 5576238106Sdes# define S_IXUSR _S_IEXEC 5577296415Sdes#elif defined __MINGW32__ 5578238106Sdes# define setmode _setmode 5579238106Sdes# define stat _stat 5580238106Sdes# define chmod _chmod 5581238106Sdes# define getcwd _getcwd 5582238106Sdes# define putenv _putenv 5583296415Sdes#elif defined __CYGWIN__ 5584238106Sdes# define HAVE_SETENV 5585238106Sdes# define FOPEN_WB "wb" 5586296415Sdes/* #elif defined other platforms ... */ 5587238106Sdes#endif 5588238106Sdes 5589296415Sdes#if defined PATH_MAX 5590238106Sdes# define LT_PATHMAX PATH_MAX 5591296415Sdes#elif defined MAXPATHLEN 5592238106Sdes# define LT_PATHMAX MAXPATHLEN 5593238106Sdes#else 5594238106Sdes# define LT_PATHMAX 1024 5595238106Sdes#endif 5596238106Sdes 5597238106Sdes#ifndef S_IXOTH 5598238106Sdes# define S_IXOTH 0 5599238106Sdes#endif 5600238106Sdes#ifndef S_IXGRP 5601238106Sdes# define S_IXGRP 0 5602238106Sdes#endif 5603238106Sdes 5604238106Sdes/* path handling portability macros */ 5605238106Sdes#ifndef DIR_SEPARATOR 5606238106Sdes# define DIR_SEPARATOR '/' 5607238106Sdes# define PATH_SEPARATOR ':' 5608238106Sdes#endif 5609238106Sdes 5610296415Sdes#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611296415Sdes defined __OS2__ 5612238106Sdes# define HAVE_DOS_BASED_FILE_SYSTEM 5613238106Sdes# define FOPEN_WB "wb" 5614238106Sdes# ifndef DIR_SEPARATOR_2 5615238106Sdes# define DIR_SEPARATOR_2 '\\' 5616238106Sdes# endif 5617238106Sdes# ifndef PATH_SEPARATOR_2 5618238106Sdes# define PATH_SEPARATOR_2 ';' 5619238106Sdes# endif 5620238106Sdes#endif 5621238106Sdes 5622238106Sdes#ifndef DIR_SEPARATOR_2 5623238106Sdes# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624238106Sdes#else /* DIR_SEPARATOR_2 */ 5625238106Sdes# define IS_DIR_SEPARATOR(ch) \ 5626238106Sdes (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627238106Sdes#endif /* DIR_SEPARATOR_2 */ 5628238106Sdes 5629238106Sdes#ifndef PATH_SEPARATOR_2 5630238106Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631238106Sdes#else /* PATH_SEPARATOR_2 */ 5632238106Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633238106Sdes#endif /* PATH_SEPARATOR_2 */ 5634238106Sdes 5635238106Sdes#ifndef FOPEN_WB 5636238106Sdes# define FOPEN_WB "w" 5637238106Sdes#endif 5638238106Sdes#ifndef _O_BINARY 5639238106Sdes# define _O_BINARY 0 5640238106Sdes#endif 5641238106Sdes 5642238106Sdes#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643238106Sdes#define XFREE(stale) do { \ 5644296415Sdes if (stale) { free (stale); stale = 0; } \ 5645238106Sdes} while (0) 5646238106Sdes 5647296415Sdes#if defined LT_DEBUGWRAPPER 5648238106Sdesstatic int lt_debug = 1; 5649238106Sdes#else 5650238106Sdesstatic int lt_debug = 0; 5651238106Sdes#endif 5652238106Sdes 5653238106Sdesconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654238106Sdes 5655238106Sdesvoid *xmalloc (size_t num); 5656238106Sdeschar *xstrdup (const char *string); 5657238106Sdesconst char *base_name (const char *name); 5658238106Sdeschar *find_executable (const char *wrapper); 5659238106Sdeschar *chase_symlinks (const char *pathspec); 5660238106Sdesint make_executable (const char *path); 5661238106Sdesint check_executable (const char *path); 5662238106Sdeschar *strendzap (char *str, const char *pat); 5663238106Sdesvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664238106Sdesvoid lt_fatal (const char *file, int line, const char *message, ...); 5665238106Sdesstatic const char *nonnull (const char *s); 5666238106Sdesstatic const char *nonempty (const char *s); 5667238106Sdesvoid lt_setenv (const char *name, const char *value); 5668238106Sdeschar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669238106Sdesvoid lt_update_exe_path (const char *name, const char *value); 5670238106Sdesvoid lt_update_lib_path (const char *name, const char *value); 5671238106Sdeschar **prepare_spawn (char **argv); 5672238106Sdesvoid lt_dump_script (FILE *f); 5673238106SdesEOF 5674238106Sdes 5675238106Sdes cat <<EOF 5676296415Sdes#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677296415Sdes# define externally_visible volatile 5678296415Sdes#else 5679296415Sdes# define externally_visible __attribute__((externally_visible)) volatile 5680296415Sdes#endif 5681296415Sdesexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682238106Sdesconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683238106SdesEOF 5684238106Sdes 5685296415Sdes if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686238106Sdes func_to_host_path "$temp_rpath" 5687238106Sdes cat <<EOF 5688238106Sdesconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689238106SdesEOF 5690238106Sdes else 5691238106Sdes cat <<"EOF" 5692238106Sdesconst char * LIB_PATH_VALUE = ""; 5693238106SdesEOF 5694238106Sdes fi 5695238106Sdes 5696238106Sdes if test -n "$dllsearchpath"; then 5697238106Sdes func_to_host_path "$dllsearchpath:" 5698238106Sdes cat <<EOF 5699238106Sdesconst char * EXE_PATH_VARNAME = "PATH"; 5700238106Sdesconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701238106SdesEOF 5702238106Sdes else 5703238106Sdes cat <<"EOF" 5704238106Sdesconst char * EXE_PATH_VARNAME = ""; 5705238106Sdesconst char * EXE_PATH_VALUE = ""; 5706238106SdesEOF 5707238106Sdes fi 5708238106Sdes 5709296415Sdes if test yes = "$fast_install"; then 5710238106Sdes cat <<EOF 5711238106Sdesconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712238106SdesEOF 5713238106Sdes else 5714238106Sdes cat <<EOF 5715238106Sdesconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716238106SdesEOF 5717238106Sdes fi 5718238106Sdes 5719238106Sdes 5720238106Sdes cat <<"EOF" 5721238106Sdes 5722238106Sdes#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723238106Sdes 5724238106Sdesstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725238106Sdesstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726238106Sdesstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727238106Sdes 5728238106Sdesint 5729238106Sdesmain (int argc, char *argv[]) 5730238106Sdes{ 5731238106Sdes char **newargz; 5732238106Sdes int newargc; 5733238106Sdes char *tmp_pathspec; 5734238106Sdes char *actual_cwrapper_path; 5735238106Sdes char *actual_cwrapper_name; 5736238106Sdes char *target_name; 5737238106Sdes char *lt_argv_zero; 5738296415Sdes int rval = 127; 5739238106Sdes 5740238106Sdes int i; 5741238106Sdes 5742238106Sdes program_name = (char *) xstrdup (base_name (argv[0])); 5743296415Sdes newargz = XMALLOC (char *, (size_t) argc + 1); 5744238106Sdes 5745238106Sdes /* very simple arg parsing; don't want to rely on getopt 5746238106Sdes * also, copy all non cwrapper options to newargz, except 5747238106Sdes * argz[0], which is handled differently 5748238106Sdes */ 5749238106Sdes newargc=0; 5750238106Sdes for (i = 1; i < argc; i++) 5751238106Sdes { 5752296415Sdes if (STREQ (argv[i], dumpscript_opt)) 5753238106Sdes { 5754238106SdesEOF 5755296415Sdes case $host in 5756238106Sdes *mingw* | *cygwin* ) 5757238106Sdes # make stdout use "unix" line endings 5758238106Sdes echo " setmode(1,_O_BINARY);" 5759238106Sdes ;; 5760238106Sdes esac 5761238106Sdes 5762238106Sdes cat <<"EOF" 5763238106Sdes lt_dump_script (stdout); 5764238106Sdes return 0; 5765238106Sdes } 5766296415Sdes if (STREQ (argv[i], debug_opt)) 5767238106Sdes { 5768238106Sdes lt_debug = 1; 5769238106Sdes continue; 5770238106Sdes } 5771296415Sdes if (STREQ (argv[i], ltwrapper_option_prefix)) 5772238106Sdes { 5773238106Sdes /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774238106Sdes namespace, but it is not one of the ones we know about and 5775296415Sdes have already dealt with, above (inluding dump-script), then 5776238106Sdes report an error. Otherwise, targets might begin to believe 5777238106Sdes they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778238106Sdes namespace. The first time any user complains about this, we'll 5779238106Sdes need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780238106Sdes or a configure.ac-settable value. 5781238106Sdes */ 5782238106Sdes lt_fatal (__FILE__, __LINE__, 5783238106Sdes "unrecognized %s option: '%s'", 5784238106Sdes ltwrapper_option_prefix, argv[i]); 5785238106Sdes } 5786238106Sdes /* otherwise ... */ 5787238106Sdes newargz[++newargc] = xstrdup (argv[i]); 5788238106Sdes } 5789238106Sdes newargz[++newargc] = NULL; 5790238106Sdes 5791238106SdesEOF 5792238106Sdes cat <<EOF 5793238106Sdes /* The GNU banner must be the first non-error debug message */ 5794296415Sdes lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795238106SdesEOF 5796238106Sdes cat <<"EOF" 5797238106Sdes lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798238106Sdes lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799238106Sdes 5800238106Sdes tmp_pathspec = find_executable (argv[0]); 5801238106Sdes if (tmp_pathspec == NULL) 5802238106Sdes lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803238106Sdes lt_debugprintf (__FILE__, __LINE__, 5804238106Sdes "(main) found exe (before symlink chase) at: %s\n", 5805238106Sdes tmp_pathspec); 5806238106Sdes 5807238106Sdes actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808238106Sdes lt_debugprintf (__FILE__, __LINE__, 5809238106Sdes "(main) found exe (after symlink chase) at: %s\n", 5810238106Sdes actual_cwrapper_path); 5811238106Sdes XFREE (tmp_pathspec); 5812238106Sdes 5813238106Sdes actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814238106Sdes strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815238106Sdes 5816238106Sdes /* wrapper name transforms */ 5817238106Sdes strendzap (actual_cwrapper_name, ".exe"); 5818238106Sdes tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819238106Sdes XFREE (actual_cwrapper_name); 5820238106Sdes actual_cwrapper_name = tmp_pathspec; 5821238106Sdes tmp_pathspec = 0; 5822238106Sdes 5823238106Sdes /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824238106Sdes target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825238106Sdes strendzap (target_name, ".exe"); 5826238106Sdes tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827238106Sdes XFREE (target_name); 5828238106Sdes target_name = tmp_pathspec; 5829238106Sdes tmp_pathspec = 0; 5830238106Sdes 5831238106Sdes lt_debugprintf (__FILE__, __LINE__, 5832238106Sdes "(main) libtool target name: %s\n", 5833238106Sdes target_name); 5834238106SdesEOF 5835238106Sdes 5836238106Sdes cat <<EOF 5837238106Sdes newargz[0] = 5838238106Sdes XMALLOC (char, (strlen (actual_cwrapper_path) + 5839238106Sdes strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840238106Sdes strcpy (newargz[0], actual_cwrapper_path); 5841238106Sdes strcat (newargz[0], "$objdir"); 5842238106Sdes strcat (newargz[0], "/"); 5843238106SdesEOF 5844238106Sdes 5845238106Sdes cat <<"EOF" 5846238106Sdes /* stop here, and copy so we don't have to do this twice */ 5847238106Sdes tmp_pathspec = xstrdup (newargz[0]); 5848238106Sdes 5849238106Sdes /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850238106Sdes strcat (newargz[0], actual_cwrapper_name); 5851238106Sdes 5852238106Sdes /* DO want the lt- prefix here if it exists, so use target_name */ 5853238106Sdes lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854238106Sdes XFREE (tmp_pathspec); 5855238106Sdes tmp_pathspec = NULL; 5856238106SdesEOF 5857238106Sdes 5858238106Sdes case $host_os in 5859238106Sdes mingw*) 5860238106Sdes cat <<"EOF" 5861238106Sdes { 5862238106Sdes char* p; 5863238106Sdes while ((p = strchr (newargz[0], '\\')) != NULL) 5864238106Sdes { 5865238106Sdes *p = '/'; 5866238106Sdes } 5867238106Sdes while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868238106Sdes { 5869238106Sdes *p = '/'; 5870238106Sdes } 5871238106Sdes } 5872238106SdesEOF 5873238106Sdes ;; 5874238106Sdes esac 5875238106Sdes 5876238106Sdes cat <<"EOF" 5877238106Sdes XFREE (target_name); 5878238106Sdes XFREE (actual_cwrapper_path); 5879238106Sdes XFREE (actual_cwrapper_name); 5880238106Sdes 5881238106Sdes lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882238106Sdes lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883238106Sdes /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884238106Sdes be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885238106Sdes because on Windows, both *_VARNAMEs are PATH but uninstalled 5886238106Sdes libraries must come first. */ 5887238106Sdes lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888238106Sdes lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889238106Sdes 5890238106Sdes lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891238106Sdes nonnull (lt_argv_zero)); 5892238106Sdes for (i = 0; i < newargc; i++) 5893238106Sdes { 5894238106Sdes lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895238106Sdes i, nonnull (newargz[i])); 5896238106Sdes } 5897238106Sdes 5898238106SdesEOF 5899238106Sdes 5900238106Sdes case $host_os in 5901238106Sdes mingw*) 5902238106Sdes cat <<"EOF" 5903238106Sdes /* execv doesn't actually work on mingw as expected on unix */ 5904238106Sdes newargz = prepare_spawn (newargz); 5905296415Sdes rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906238106Sdes if (rval == -1) 5907238106Sdes { 5908238106Sdes /* failed to start process */ 5909238106Sdes lt_debugprintf (__FILE__, __LINE__, 5910238106Sdes "(main) failed to launch target \"%s\": %s\n", 5911238106Sdes lt_argv_zero, nonnull (strerror (errno))); 5912238106Sdes return 127; 5913238106Sdes } 5914238106Sdes return rval; 5915238106SdesEOF 5916238106Sdes ;; 5917238106Sdes *) 5918238106Sdes cat <<"EOF" 5919238106Sdes execv (lt_argv_zero, newargz); 5920238106Sdes return rval; /* =127, but avoids unused variable warning */ 5921238106SdesEOF 5922238106Sdes ;; 5923238106Sdes esac 5924238106Sdes 5925238106Sdes cat <<"EOF" 5926238106Sdes} 5927238106Sdes 5928238106Sdesvoid * 5929238106Sdesxmalloc (size_t num) 5930238106Sdes{ 5931238106Sdes void *p = (void *) malloc (num); 5932238106Sdes if (!p) 5933238106Sdes lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934238106Sdes 5935238106Sdes return p; 5936238106Sdes} 5937238106Sdes 5938238106Sdeschar * 5939238106Sdesxstrdup (const char *string) 5940238106Sdes{ 5941238106Sdes return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942238106Sdes string) : NULL; 5943238106Sdes} 5944238106Sdes 5945238106Sdesconst char * 5946238106Sdesbase_name (const char *name) 5947238106Sdes{ 5948238106Sdes const char *base; 5949238106Sdes 5950296415Sdes#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951238106Sdes /* Skip over the disk name in MSDOS pathnames. */ 5952238106Sdes if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953238106Sdes name += 2; 5954238106Sdes#endif 5955238106Sdes 5956238106Sdes for (base = name; *name; name++) 5957238106Sdes if (IS_DIR_SEPARATOR (*name)) 5958238106Sdes base = name + 1; 5959238106Sdes return base; 5960238106Sdes} 5961238106Sdes 5962238106Sdesint 5963238106Sdescheck_executable (const char *path) 5964238106Sdes{ 5965238106Sdes struct stat st; 5966238106Sdes 5967238106Sdes lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968238106Sdes nonempty (path)); 5969238106Sdes if ((!path) || (!*path)) 5970238106Sdes return 0; 5971238106Sdes 5972238106Sdes if ((stat (path, &st) >= 0) 5973238106Sdes && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974238106Sdes return 1; 5975238106Sdes else 5976238106Sdes return 0; 5977238106Sdes} 5978238106Sdes 5979238106Sdesint 5980238106Sdesmake_executable (const char *path) 5981238106Sdes{ 5982238106Sdes int rval = 0; 5983238106Sdes struct stat st; 5984238106Sdes 5985238106Sdes lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986238106Sdes nonempty (path)); 5987238106Sdes if ((!path) || (!*path)) 5988238106Sdes return 0; 5989238106Sdes 5990238106Sdes if (stat (path, &st) >= 0) 5991238106Sdes { 5992238106Sdes rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993238106Sdes } 5994238106Sdes return rval; 5995238106Sdes} 5996238106Sdes 5997238106Sdes/* Searches for the full path of the wrapper. Returns 5998238106Sdes newly allocated full path name if found, NULL otherwise 5999238106Sdes Does not chase symlinks, even on platforms that support them. 6000238106Sdes*/ 6001238106Sdeschar * 6002238106Sdesfind_executable (const char *wrapper) 6003238106Sdes{ 6004238106Sdes int has_slash = 0; 6005238106Sdes const char *p; 6006238106Sdes const char *p_next; 6007238106Sdes /* static buffer for getcwd */ 6008238106Sdes char tmp[LT_PATHMAX + 1]; 6009296415Sdes size_t tmp_len; 6010238106Sdes char *concat_name; 6011238106Sdes 6012238106Sdes lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013238106Sdes nonempty (wrapper)); 6014238106Sdes 6015238106Sdes if ((wrapper == NULL) || (*wrapper == '\0')) 6016238106Sdes return NULL; 6017238106Sdes 6018238106Sdes /* Absolute path? */ 6019296415Sdes#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020238106Sdes if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021238106Sdes { 6022238106Sdes concat_name = xstrdup (wrapper); 6023238106Sdes if (check_executable (concat_name)) 6024238106Sdes return concat_name; 6025238106Sdes XFREE (concat_name); 6026238106Sdes } 6027238106Sdes else 6028238106Sdes { 6029238106Sdes#endif 6030238106Sdes if (IS_DIR_SEPARATOR (wrapper[0])) 6031238106Sdes { 6032238106Sdes concat_name = xstrdup (wrapper); 6033238106Sdes if (check_executable (concat_name)) 6034238106Sdes return concat_name; 6035238106Sdes XFREE (concat_name); 6036238106Sdes } 6037296415Sdes#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038238106Sdes } 6039238106Sdes#endif 6040238106Sdes 6041238106Sdes for (p = wrapper; *p; p++) 6042238106Sdes if (*p == '/') 6043238106Sdes { 6044238106Sdes has_slash = 1; 6045238106Sdes break; 6046238106Sdes } 6047238106Sdes if (!has_slash) 6048238106Sdes { 6049238106Sdes /* no slashes; search PATH */ 6050238106Sdes const char *path = getenv ("PATH"); 6051238106Sdes if (path != NULL) 6052238106Sdes { 6053238106Sdes for (p = path; *p; p = p_next) 6054238106Sdes { 6055238106Sdes const char *q; 6056238106Sdes size_t p_len; 6057238106Sdes for (q = p; *q; q++) 6058238106Sdes if (IS_PATH_SEPARATOR (*q)) 6059238106Sdes break; 6060296415Sdes p_len = (size_t) (q - p); 6061238106Sdes p_next = (*q == '\0' ? q : q + 1); 6062238106Sdes if (p_len == 0) 6063238106Sdes { 6064238106Sdes /* empty path: current directory */ 6065238106Sdes if (getcwd (tmp, LT_PATHMAX) == NULL) 6066238106Sdes lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067238106Sdes nonnull (strerror (errno))); 6068238106Sdes tmp_len = strlen (tmp); 6069238106Sdes concat_name = 6070238106Sdes XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071238106Sdes memcpy (concat_name, tmp, tmp_len); 6072238106Sdes concat_name[tmp_len] = '/'; 6073238106Sdes strcpy (concat_name + tmp_len + 1, wrapper); 6074238106Sdes } 6075238106Sdes else 6076238106Sdes { 6077238106Sdes concat_name = 6078238106Sdes XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079238106Sdes memcpy (concat_name, p, p_len); 6080238106Sdes concat_name[p_len] = '/'; 6081238106Sdes strcpy (concat_name + p_len + 1, wrapper); 6082238106Sdes } 6083238106Sdes if (check_executable (concat_name)) 6084238106Sdes return concat_name; 6085238106Sdes XFREE (concat_name); 6086238106Sdes } 6087238106Sdes } 6088238106Sdes /* not found in PATH; assume curdir */ 6089238106Sdes } 6090238106Sdes /* Relative path | not found in path: prepend cwd */ 6091238106Sdes if (getcwd (tmp, LT_PATHMAX) == NULL) 6092238106Sdes lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093238106Sdes nonnull (strerror (errno))); 6094238106Sdes tmp_len = strlen (tmp); 6095238106Sdes concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096238106Sdes memcpy (concat_name, tmp, tmp_len); 6097238106Sdes concat_name[tmp_len] = '/'; 6098238106Sdes strcpy (concat_name + tmp_len + 1, wrapper); 6099238106Sdes 6100238106Sdes if (check_executable (concat_name)) 6101238106Sdes return concat_name; 6102238106Sdes XFREE (concat_name); 6103238106Sdes return NULL; 6104238106Sdes} 6105238106Sdes 6106238106Sdeschar * 6107238106Sdeschase_symlinks (const char *pathspec) 6108238106Sdes{ 6109238106Sdes#ifndef S_ISLNK 6110238106Sdes return xstrdup (pathspec); 6111238106Sdes#else 6112238106Sdes char buf[LT_PATHMAX]; 6113238106Sdes struct stat s; 6114238106Sdes char *tmp_pathspec = xstrdup (pathspec); 6115238106Sdes char *p; 6116238106Sdes int has_symlinks = 0; 6117238106Sdes while (strlen (tmp_pathspec) && !has_symlinks) 6118238106Sdes { 6119238106Sdes lt_debugprintf (__FILE__, __LINE__, 6120238106Sdes "checking path component for symlinks: %s\n", 6121238106Sdes tmp_pathspec); 6122238106Sdes if (lstat (tmp_pathspec, &s) == 0) 6123238106Sdes { 6124238106Sdes if (S_ISLNK (s.st_mode) != 0) 6125238106Sdes { 6126238106Sdes has_symlinks = 1; 6127238106Sdes break; 6128238106Sdes } 6129238106Sdes 6130238106Sdes /* search backwards for last DIR_SEPARATOR */ 6131238106Sdes p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132238106Sdes while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133238106Sdes p--; 6134238106Sdes if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135238106Sdes { 6136238106Sdes /* no more DIR_SEPARATORS left */ 6137238106Sdes break; 6138238106Sdes } 6139238106Sdes *p = '\0'; 6140238106Sdes } 6141238106Sdes else 6142238106Sdes { 6143238106Sdes lt_fatal (__FILE__, __LINE__, 6144238106Sdes "error accessing file \"%s\": %s", 6145238106Sdes tmp_pathspec, nonnull (strerror (errno))); 6146238106Sdes } 6147238106Sdes } 6148238106Sdes XFREE (tmp_pathspec); 6149238106Sdes 6150238106Sdes if (!has_symlinks) 6151238106Sdes { 6152238106Sdes return xstrdup (pathspec); 6153238106Sdes } 6154238106Sdes 6155238106Sdes tmp_pathspec = realpath (pathspec, buf); 6156238106Sdes if (tmp_pathspec == 0) 6157238106Sdes { 6158238106Sdes lt_fatal (__FILE__, __LINE__, 6159238106Sdes "could not follow symlinks for %s", pathspec); 6160238106Sdes } 6161238106Sdes return xstrdup (tmp_pathspec); 6162238106Sdes#endif 6163238106Sdes} 6164238106Sdes 6165238106Sdeschar * 6166238106Sdesstrendzap (char *str, const char *pat) 6167238106Sdes{ 6168238106Sdes size_t len, patlen; 6169238106Sdes 6170238106Sdes assert (str != NULL); 6171238106Sdes assert (pat != NULL); 6172238106Sdes 6173238106Sdes len = strlen (str); 6174238106Sdes patlen = strlen (pat); 6175238106Sdes 6176238106Sdes if (patlen <= len) 6177238106Sdes { 6178238106Sdes str += len - patlen; 6179296415Sdes if (STREQ (str, pat)) 6180238106Sdes *str = '\0'; 6181238106Sdes } 6182238106Sdes return str; 6183238106Sdes} 6184238106Sdes 6185238106Sdesvoid 6186238106Sdeslt_debugprintf (const char *file, int line, const char *fmt, ...) 6187238106Sdes{ 6188238106Sdes va_list args; 6189238106Sdes if (lt_debug) 6190238106Sdes { 6191238106Sdes (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192238106Sdes va_start (args, fmt); 6193238106Sdes (void) vfprintf (stderr, fmt, args); 6194238106Sdes va_end (args); 6195238106Sdes } 6196238106Sdes} 6197238106Sdes 6198238106Sdesstatic void 6199238106Sdeslt_error_core (int exit_status, const char *file, 6200238106Sdes int line, const char *mode, 6201238106Sdes const char *message, va_list ap) 6202238106Sdes{ 6203238106Sdes fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204238106Sdes vfprintf (stderr, message, ap); 6205238106Sdes fprintf (stderr, ".\n"); 6206238106Sdes 6207238106Sdes if (exit_status >= 0) 6208238106Sdes exit (exit_status); 6209238106Sdes} 6210238106Sdes 6211238106Sdesvoid 6212238106Sdeslt_fatal (const char *file, int line, const char *message, ...) 6213238106Sdes{ 6214238106Sdes va_list ap; 6215238106Sdes va_start (ap, message); 6216238106Sdes lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217238106Sdes va_end (ap); 6218238106Sdes} 6219238106Sdes 6220238106Sdesstatic const char * 6221238106Sdesnonnull (const char *s) 6222238106Sdes{ 6223238106Sdes return s ? s : "(null)"; 6224238106Sdes} 6225238106Sdes 6226238106Sdesstatic const char * 6227238106Sdesnonempty (const char *s) 6228238106Sdes{ 6229238106Sdes return (s && !*s) ? "(empty)" : nonnull (s); 6230238106Sdes} 6231238106Sdes 6232238106Sdesvoid 6233238106Sdeslt_setenv (const char *name, const char *value) 6234238106Sdes{ 6235238106Sdes lt_debugprintf (__FILE__, __LINE__, 6236238106Sdes "(lt_setenv) setting '%s' to '%s'\n", 6237238106Sdes nonnull (name), nonnull (value)); 6238238106Sdes { 6239238106Sdes#ifdef HAVE_SETENV 6240238106Sdes /* always make a copy, for consistency with !HAVE_SETENV */ 6241238106Sdes char *str = xstrdup (value); 6242238106Sdes setenv (name, str, 1); 6243238106Sdes#else 6244296415Sdes size_t len = strlen (name) + 1 + strlen (value) + 1; 6245238106Sdes char *str = XMALLOC (char, len); 6246238106Sdes sprintf (str, "%s=%s", name, value); 6247238106Sdes if (putenv (str) != EXIT_SUCCESS) 6248238106Sdes { 6249238106Sdes XFREE (str); 6250238106Sdes } 6251238106Sdes#endif 6252238106Sdes } 6253238106Sdes} 6254238106Sdes 6255238106Sdeschar * 6256238106Sdeslt_extend_str (const char *orig_value, const char *add, int to_end) 6257238106Sdes{ 6258238106Sdes char *new_value; 6259238106Sdes if (orig_value && *orig_value) 6260238106Sdes { 6261296415Sdes size_t orig_value_len = strlen (orig_value); 6262296415Sdes size_t add_len = strlen (add); 6263238106Sdes new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264238106Sdes if (to_end) 6265238106Sdes { 6266238106Sdes strcpy (new_value, orig_value); 6267238106Sdes strcpy (new_value + orig_value_len, add); 6268238106Sdes } 6269238106Sdes else 6270238106Sdes { 6271238106Sdes strcpy (new_value, add); 6272238106Sdes strcpy (new_value + add_len, orig_value); 6273238106Sdes } 6274238106Sdes } 6275238106Sdes else 6276238106Sdes { 6277238106Sdes new_value = xstrdup (add); 6278238106Sdes } 6279238106Sdes return new_value; 6280238106Sdes} 6281238106Sdes 6282238106Sdesvoid 6283238106Sdeslt_update_exe_path (const char *name, const char *value) 6284238106Sdes{ 6285238106Sdes lt_debugprintf (__FILE__, __LINE__, 6286238106Sdes "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287238106Sdes nonnull (name), nonnull (value)); 6288238106Sdes 6289238106Sdes if (name && *name && value && *value) 6290238106Sdes { 6291238106Sdes char *new_value = lt_extend_str (getenv (name), value, 0); 6292238106Sdes /* some systems can't cope with a ':'-terminated path #' */ 6293296415Sdes size_t len = strlen (new_value); 6294296415Sdes while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295238106Sdes { 6296296415Sdes new_value[--len] = '\0'; 6297238106Sdes } 6298238106Sdes lt_setenv (name, new_value); 6299238106Sdes XFREE (new_value); 6300238106Sdes } 6301238106Sdes} 6302238106Sdes 6303238106Sdesvoid 6304238106Sdeslt_update_lib_path (const char *name, const char *value) 6305238106Sdes{ 6306238106Sdes lt_debugprintf (__FILE__, __LINE__, 6307238106Sdes "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308238106Sdes nonnull (name), nonnull (value)); 6309238106Sdes 6310238106Sdes if (name && *name && value && *value) 6311238106Sdes { 6312238106Sdes char *new_value = lt_extend_str (getenv (name), value, 0); 6313238106Sdes lt_setenv (name, new_value); 6314238106Sdes XFREE (new_value); 6315238106Sdes } 6316238106Sdes} 6317238106Sdes 6318238106SdesEOF 6319238106Sdes case $host_os in 6320238106Sdes mingw*) 6321238106Sdes cat <<"EOF" 6322238106Sdes 6323238106Sdes/* Prepares an argument vector before calling spawn(). 6324238106Sdes Note that spawn() does not by itself call the command interpreter 6325238106Sdes (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326238106Sdes ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327238106Sdes GetVersionEx(&v); 6328238106Sdes v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329238106Sdes }) ? "cmd.exe" : "command.com"). 6330238106Sdes Instead it simply concatenates the arguments, separated by ' ', and calls 6331238106Sdes CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332238106Sdes interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333238106Sdes special way: 6334238106Sdes - Space and tab are interpreted as delimiters. They are not treated as 6335238106Sdes delimiters if they are surrounded by double quotes: "...". 6336238106Sdes - Unescaped double quotes are removed from the input. Their only effect is 6337238106Sdes that within double quotes, space and tab are treated like normal 6338238106Sdes characters. 6339238106Sdes - Backslashes not followed by double quotes are not special. 6340238106Sdes - But 2*n+1 backslashes followed by a double quote become 6341238106Sdes n backslashes followed by a double quote (n >= 0): 6342238106Sdes \" -> " 6343238106Sdes \\\" -> \" 6344238106Sdes \\\\\" -> \\" 6345238106Sdes */ 6346238106Sdes#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" 6347238106Sdes#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" 6348238106Sdeschar ** 6349238106Sdesprepare_spawn (char **argv) 6350238106Sdes{ 6351238106Sdes size_t argc; 6352238106Sdes char **new_argv; 6353238106Sdes size_t i; 6354238106Sdes 6355238106Sdes /* Count number of arguments. */ 6356238106Sdes for (argc = 0; argv[argc] != NULL; argc++) 6357238106Sdes ; 6358238106Sdes 6359238106Sdes /* Allocate new argument vector. */ 6360238106Sdes new_argv = XMALLOC (char *, argc + 1); 6361238106Sdes 6362238106Sdes /* Put quoted arguments into the new argument vector. */ 6363238106Sdes for (i = 0; i < argc; i++) 6364238106Sdes { 6365238106Sdes const char *string = argv[i]; 6366238106Sdes 6367238106Sdes if (string[0] == '\0') 6368238106Sdes new_argv[i] = xstrdup ("\"\""); 6369238106Sdes else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370238106Sdes { 6371238106Sdes int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372238106Sdes size_t length; 6373238106Sdes unsigned int backslashes; 6374238106Sdes const char *s; 6375238106Sdes char *quoted_string; 6376238106Sdes char *p; 6377238106Sdes 6378238106Sdes length = 0; 6379238106Sdes backslashes = 0; 6380238106Sdes if (quote_around) 6381238106Sdes length++; 6382238106Sdes for (s = string; *s != '\0'; s++) 6383238106Sdes { 6384238106Sdes char c = *s; 6385238106Sdes if (c == '"') 6386238106Sdes length += backslashes + 1; 6387238106Sdes length++; 6388238106Sdes if (c == '\\') 6389238106Sdes backslashes++; 6390238106Sdes else 6391238106Sdes backslashes = 0; 6392238106Sdes } 6393238106Sdes if (quote_around) 6394238106Sdes length += backslashes + 1; 6395238106Sdes 6396238106Sdes quoted_string = XMALLOC (char, length + 1); 6397238106Sdes 6398238106Sdes p = quoted_string; 6399238106Sdes backslashes = 0; 6400238106Sdes if (quote_around) 6401238106Sdes *p++ = '"'; 6402238106Sdes for (s = string; *s != '\0'; s++) 6403238106Sdes { 6404238106Sdes char c = *s; 6405238106Sdes if (c == '"') 6406238106Sdes { 6407238106Sdes unsigned int j; 6408238106Sdes for (j = backslashes + 1; j > 0; j--) 6409238106Sdes *p++ = '\\'; 6410238106Sdes } 6411238106Sdes *p++ = c; 6412238106Sdes if (c == '\\') 6413238106Sdes backslashes++; 6414238106Sdes else 6415238106Sdes backslashes = 0; 6416238106Sdes } 6417238106Sdes if (quote_around) 6418238106Sdes { 6419238106Sdes unsigned int j; 6420238106Sdes for (j = backslashes; j > 0; j--) 6421238106Sdes *p++ = '\\'; 6422238106Sdes *p++ = '"'; 6423238106Sdes } 6424238106Sdes *p = '\0'; 6425238106Sdes 6426238106Sdes new_argv[i] = quoted_string; 6427238106Sdes } 6428238106Sdes else 6429238106Sdes new_argv[i] = (char *) string; 6430238106Sdes } 6431238106Sdes new_argv[argc] = NULL; 6432238106Sdes 6433238106Sdes return new_argv; 6434238106Sdes} 6435238106SdesEOF 6436238106Sdes ;; 6437238106Sdes esac 6438238106Sdes 6439238106Sdes cat <<"EOF" 6440238106Sdesvoid lt_dump_script (FILE* f) 6441238106Sdes{ 6442238106SdesEOF 6443238106Sdes func_emit_wrapper yes | 6444249141Sdes $SED -n -e ' 6445249141Sdess/^\(.\{79\}\)\(..*\)/\1\ 6446249141Sdes\2/ 6447249141Sdesh 6448249141Sdess/\([\\"]\)/\\\1/g 6449249141Sdess/$/\\n/ 6450249141Sdess/\([^\n]*\).*/ fputs ("\1", f);/p 6451249141Sdesg 6452249141SdesD' 6453238106Sdes cat <<"EOF" 6454238106Sdes} 6455238106SdesEOF 6456238106Sdes} 6457238106Sdes# end: func_emit_cwrapperexe_src 6458238106Sdes 6459238106Sdes# func_win32_import_lib_p ARG 6460238106Sdes# True if ARG is an import lib, as indicated by $file_magic_cmd 6461238106Sdesfunc_win32_import_lib_p () 6462238106Sdes{ 6463296415Sdes $debug_cmd 6464296415Sdes 6465238106Sdes case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466238106Sdes *import*) : ;; 6467238106Sdes *) false ;; 6468238106Sdes esac 6469238106Sdes} 6470238106Sdes 6471296415Sdes# func_suncc_cstd_abi 6472296415Sdes# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473296415Sdes# Several compiler flags select an ABI that is incompatible with the 6474296415Sdes# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475296415Sdesfunc_suncc_cstd_abi () 6476296415Sdes{ 6477296415Sdes $debug_cmd 6478296415Sdes 6479296415Sdes case " $compile_command " in 6480296415Sdes *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481296415Sdes suncc_use_cstd_abi=no 6482296415Sdes ;; 6483296415Sdes *) 6484296415Sdes suncc_use_cstd_abi=yes 6485296415Sdes ;; 6486296415Sdes esac 6487296415Sdes} 6488296415Sdes 6489238106Sdes# func_mode_link arg... 6490238106Sdesfunc_mode_link () 6491238106Sdes{ 6492296415Sdes $debug_cmd 6493296415Sdes 6494238106Sdes case $host in 6495238106Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496238106Sdes # It is impossible to link a dll without this setting, and 6497238106Sdes # we shouldn't force the makefile maintainer to figure out 6498296415Sdes # what system we are compiling for in order to pass an extra 6499238106Sdes # flag for every libtool invocation. 6500238106Sdes # allow_undefined=no 6501238106Sdes 6502238106Sdes # FIXME: Unfortunately, there are problems with the above when trying 6503296415Sdes # to make a dll that has undefined symbols, in which case not 6504238106Sdes # even a static library is built. For now, we need to specify 6505238106Sdes # -no-undefined on the libtool link line when we can be certain 6506238106Sdes # that all symbols are satisfied, otherwise we get a static library. 6507238106Sdes allow_undefined=yes 6508238106Sdes ;; 6509238106Sdes *) 6510238106Sdes allow_undefined=yes 6511238106Sdes ;; 6512238106Sdes esac 6513238106Sdes libtool_args=$nonopt 6514238106Sdes base_compile="$nonopt $@" 6515238106Sdes compile_command=$nonopt 6516238106Sdes finalize_command=$nonopt 6517238106Sdes 6518238106Sdes compile_rpath= 6519238106Sdes finalize_rpath= 6520238106Sdes compile_shlibpath= 6521238106Sdes finalize_shlibpath= 6522238106Sdes convenience= 6523238106Sdes old_convenience= 6524238106Sdes deplibs= 6525238106Sdes old_deplibs= 6526238106Sdes compiler_flags= 6527238106Sdes linker_flags= 6528238106Sdes dllsearchpath= 6529238106Sdes lib_search_path=`pwd` 6530238106Sdes inst_prefix_dir= 6531238106Sdes new_inherited_linker_flags= 6532238106Sdes 6533238106Sdes avoid_version=no 6534238106Sdes bindir= 6535238106Sdes dlfiles= 6536238106Sdes dlprefiles= 6537238106Sdes dlself=no 6538238106Sdes export_dynamic=no 6539238106Sdes export_symbols= 6540238106Sdes export_symbols_regex= 6541238106Sdes generated= 6542238106Sdes libobjs= 6543238106Sdes ltlibs= 6544238106Sdes module=no 6545238106Sdes no_install=no 6546238106Sdes objs= 6547296415Sdes os2dllname= 6548238106Sdes non_pic_objects= 6549238106Sdes precious_files_regex= 6550238106Sdes prefer_static_libs=no 6551296415Sdes preload=false 6552238106Sdes prev= 6553238106Sdes prevarg= 6554238106Sdes release= 6555238106Sdes rpath= 6556238106Sdes xrpath= 6557238106Sdes perm_rpath= 6558238106Sdes temp_rpath= 6559238106Sdes thread_safe=no 6560238106Sdes vinfo= 6561238106Sdes vinfo_number=no 6562238106Sdes weak_libs= 6563296415Sdes single_module=$wl-single_module 6564238106Sdes func_infer_tag $base_compile 6565238106Sdes 6566238106Sdes # We need to know -static, to get the right output filenames. 6567238106Sdes for arg 6568238106Sdes do 6569238106Sdes case $arg in 6570238106Sdes -shared) 6571296415Sdes test yes != "$build_libtool_libs" \ 6572296415Sdes && func_fatal_configuration "cannot build a shared library" 6573238106Sdes build_old_libs=no 6574238106Sdes break 6575238106Sdes ;; 6576238106Sdes -all-static | -static | -static-libtool-libs) 6577238106Sdes case $arg in 6578238106Sdes -all-static) 6579296415Sdes if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580238106Sdes func_warning "complete static linking is impossible in this configuration" 6581238106Sdes fi 6582238106Sdes if test -n "$link_static_flag"; then 6583238106Sdes dlopen_self=$dlopen_self_static 6584238106Sdes fi 6585238106Sdes prefer_static_libs=yes 6586238106Sdes ;; 6587238106Sdes -static) 6588238106Sdes if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589238106Sdes dlopen_self=$dlopen_self_static 6590238106Sdes fi 6591238106Sdes prefer_static_libs=built 6592238106Sdes ;; 6593238106Sdes -static-libtool-libs) 6594238106Sdes if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595238106Sdes dlopen_self=$dlopen_self_static 6596238106Sdes fi 6597238106Sdes prefer_static_libs=yes 6598238106Sdes ;; 6599238106Sdes esac 6600238106Sdes build_libtool_libs=no 6601238106Sdes build_old_libs=yes 6602238106Sdes break 6603238106Sdes ;; 6604238106Sdes esac 6605238106Sdes done 6606238106Sdes 6607238106Sdes # See if our shared archives depend on static archives. 6608238106Sdes test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609238106Sdes 6610238106Sdes # Go through the arguments, transforming them on the way. 6611238106Sdes while test "$#" -gt 0; do 6612296415Sdes arg=$1 6613238106Sdes shift 6614238106Sdes func_quote_for_eval "$arg" 6615238106Sdes qarg=$func_quote_for_eval_unquoted_result 6616238106Sdes func_append libtool_args " $func_quote_for_eval_result" 6617238106Sdes 6618238106Sdes # If the previous option needs an argument, assign it. 6619238106Sdes if test -n "$prev"; then 6620238106Sdes case $prev in 6621238106Sdes output) 6622238106Sdes func_append compile_command " @OUTPUT@" 6623238106Sdes func_append finalize_command " @OUTPUT@" 6624238106Sdes ;; 6625238106Sdes esac 6626238106Sdes 6627238106Sdes case $prev in 6628238106Sdes bindir) 6629296415Sdes bindir=$arg 6630238106Sdes prev= 6631238106Sdes continue 6632238106Sdes ;; 6633238106Sdes dlfiles|dlprefiles) 6634296415Sdes $preload || { 6635238106Sdes # Add the symbol object into the linking commands. 6636238106Sdes func_append compile_command " @SYMFILE@" 6637238106Sdes func_append finalize_command " @SYMFILE@" 6638296415Sdes preload=: 6639296415Sdes } 6640238106Sdes case $arg in 6641238106Sdes *.la | *.lo) ;; # We handle these cases below. 6642238106Sdes force) 6643296415Sdes if test no = "$dlself"; then 6644238106Sdes dlself=needless 6645238106Sdes export_dynamic=yes 6646238106Sdes fi 6647238106Sdes prev= 6648238106Sdes continue 6649238106Sdes ;; 6650238106Sdes self) 6651296415Sdes if test dlprefiles = "$prev"; then 6652238106Sdes dlself=yes 6653296415Sdes elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654238106Sdes dlself=yes 6655238106Sdes else 6656238106Sdes dlself=needless 6657238106Sdes export_dynamic=yes 6658238106Sdes fi 6659238106Sdes prev= 6660238106Sdes continue 6661238106Sdes ;; 6662238106Sdes *) 6663296415Sdes if test dlfiles = "$prev"; then 6664238106Sdes func_append dlfiles " $arg" 6665238106Sdes else 6666238106Sdes func_append dlprefiles " $arg" 6667238106Sdes fi 6668238106Sdes prev= 6669238106Sdes continue 6670238106Sdes ;; 6671238106Sdes esac 6672238106Sdes ;; 6673238106Sdes expsyms) 6674296415Sdes export_symbols=$arg 6675238106Sdes test -f "$arg" \ 6676296415Sdes || func_fatal_error "symbol file '$arg' does not exist" 6677238106Sdes prev= 6678238106Sdes continue 6679238106Sdes ;; 6680238106Sdes expsyms_regex) 6681296415Sdes export_symbols_regex=$arg 6682238106Sdes prev= 6683238106Sdes continue 6684238106Sdes ;; 6685238106Sdes framework) 6686238106Sdes case $host in 6687238106Sdes *-*-darwin*) 6688238106Sdes case "$deplibs " in 6689238106Sdes *" $qarg.ltframework "*) ;; 6690238106Sdes *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691238106Sdes ;; 6692238106Sdes esac 6693238106Sdes ;; 6694238106Sdes esac 6695238106Sdes prev= 6696238106Sdes continue 6697238106Sdes ;; 6698238106Sdes inst_prefix) 6699296415Sdes inst_prefix_dir=$arg 6700238106Sdes prev= 6701238106Sdes continue 6702238106Sdes ;; 6703296415Sdes mllvm) 6704296415Sdes # Clang does not use LLVM to link, so we can simply discard any 6705296415Sdes # '-mllvm $arg' options when doing the link step. 6706296415Sdes prev= 6707296415Sdes continue 6708296415Sdes ;; 6709238106Sdes objectlist) 6710238106Sdes if test -f "$arg"; then 6711238106Sdes save_arg=$arg 6712238106Sdes moreargs= 6713238106Sdes for fil in `cat "$save_arg"` 6714238106Sdes do 6715238106Sdes# func_append moreargs " $fil" 6716238106Sdes arg=$fil 6717238106Sdes # A libtool-controlled object. 6718238106Sdes 6719238106Sdes # Check to see that this really is a libtool object. 6720238106Sdes if func_lalib_unsafe_p "$arg"; then 6721238106Sdes pic_object= 6722238106Sdes non_pic_object= 6723238106Sdes 6724238106Sdes # Read the .lo file 6725238106Sdes func_source "$arg" 6726238106Sdes 6727238106Sdes if test -z "$pic_object" || 6728238106Sdes test -z "$non_pic_object" || 6729296415Sdes test none = "$pic_object" && 6730296415Sdes test none = "$non_pic_object"; then 6731296415Sdes func_fatal_error "cannot find name of object for '$arg'" 6732238106Sdes fi 6733238106Sdes 6734238106Sdes # Extract subdirectory from the argument. 6735238106Sdes func_dirname "$arg" "/" "" 6736296415Sdes xdir=$func_dirname_result 6737238106Sdes 6738296415Sdes if test none != "$pic_object"; then 6739238106Sdes # Prepend the subdirectory the object is found in. 6740296415Sdes pic_object=$xdir$pic_object 6741238106Sdes 6742296415Sdes if test dlfiles = "$prev"; then 6743296415Sdes if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744238106Sdes func_append dlfiles " $pic_object" 6745238106Sdes prev= 6746238106Sdes continue 6747238106Sdes else 6748238106Sdes # If libtool objects are unsupported, then we need to preload. 6749238106Sdes prev=dlprefiles 6750238106Sdes fi 6751238106Sdes fi 6752238106Sdes 6753238106Sdes # CHECK ME: I think I busted this. -Ossama 6754296415Sdes if test dlprefiles = "$prev"; then 6755238106Sdes # Preload the old-style object. 6756238106Sdes func_append dlprefiles " $pic_object" 6757238106Sdes prev= 6758238106Sdes fi 6759238106Sdes 6760238106Sdes # A PIC object. 6761238106Sdes func_append libobjs " $pic_object" 6762296415Sdes arg=$pic_object 6763238106Sdes fi 6764238106Sdes 6765238106Sdes # Non-PIC object. 6766296415Sdes if test none != "$non_pic_object"; then 6767238106Sdes # Prepend the subdirectory the object is found in. 6768296415Sdes non_pic_object=$xdir$non_pic_object 6769238106Sdes 6770238106Sdes # A standard non-PIC object 6771238106Sdes func_append non_pic_objects " $non_pic_object" 6772296415Sdes if test -z "$pic_object" || test none = "$pic_object"; then 6773296415Sdes arg=$non_pic_object 6774238106Sdes fi 6775238106Sdes else 6776238106Sdes # If the PIC object exists, use it instead. 6777238106Sdes # $xdir was prepended to $pic_object above. 6778296415Sdes non_pic_object=$pic_object 6779238106Sdes func_append non_pic_objects " $non_pic_object" 6780238106Sdes fi 6781238106Sdes else 6782238106Sdes # Only an error if not doing a dry-run. 6783238106Sdes if $opt_dry_run; then 6784238106Sdes # Extract subdirectory from the argument. 6785238106Sdes func_dirname "$arg" "/" "" 6786296415Sdes xdir=$func_dirname_result 6787238106Sdes 6788238106Sdes func_lo2o "$arg" 6789238106Sdes pic_object=$xdir$objdir/$func_lo2o_result 6790238106Sdes non_pic_object=$xdir$func_lo2o_result 6791238106Sdes func_append libobjs " $pic_object" 6792238106Sdes func_append non_pic_objects " $non_pic_object" 6793238106Sdes else 6794296415Sdes func_fatal_error "'$arg' is not a valid libtool object" 6795238106Sdes fi 6796238106Sdes fi 6797238106Sdes done 6798238106Sdes else 6799296415Sdes func_fatal_error "link input file '$arg' does not exist" 6800238106Sdes fi 6801238106Sdes arg=$save_arg 6802238106Sdes prev= 6803238106Sdes continue 6804238106Sdes ;; 6805296415Sdes os2dllname) 6806296415Sdes os2dllname=$arg 6807296415Sdes prev= 6808296415Sdes continue 6809296415Sdes ;; 6810238106Sdes precious_regex) 6811296415Sdes precious_files_regex=$arg 6812238106Sdes prev= 6813238106Sdes continue 6814238106Sdes ;; 6815238106Sdes release) 6816296415Sdes release=-$arg 6817238106Sdes prev= 6818238106Sdes continue 6819238106Sdes ;; 6820238106Sdes rpath | xrpath) 6821238106Sdes # We need an absolute path. 6822238106Sdes case $arg in 6823238106Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 6824238106Sdes *) 6825238106Sdes func_fatal_error "only absolute run-paths are allowed" 6826238106Sdes ;; 6827238106Sdes esac 6828296415Sdes if test rpath = "$prev"; then 6829238106Sdes case "$rpath " in 6830238106Sdes *" $arg "*) ;; 6831238106Sdes *) func_append rpath " $arg" ;; 6832238106Sdes esac 6833238106Sdes else 6834238106Sdes case "$xrpath " in 6835238106Sdes *" $arg "*) ;; 6836238106Sdes *) func_append xrpath " $arg" ;; 6837238106Sdes esac 6838238106Sdes fi 6839238106Sdes prev= 6840238106Sdes continue 6841238106Sdes ;; 6842238106Sdes shrext) 6843296415Sdes shrext_cmds=$arg 6844238106Sdes prev= 6845238106Sdes continue 6846238106Sdes ;; 6847238106Sdes weak) 6848238106Sdes func_append weak_libs " $arg" 6849238106Sdes prev= 6850238106Sdes continue 6851238106Sdes ;; 6852238106Sdes xcclinker) 6853238106Sdes func_append linker_flags " $qarg" 6854238106Sdes func_append compiler_flags " $qarg" 6855238106Sdes prev= 6856238106Sdes func_append compile_command " $qarg" 6857238106Sdes func_append finalize_command " $qarg" 6858238106Sdes continue 6859238106Sdes ;; 6860238106Sdes xcompiler) 6861238106Sdes func_append compiler_flags " $qarg" 6862238106Sdes prev= 6863238106Sdes func_append compile_command " $qarg" 6864238106Sdes func_append finalize_command " $qarg" 6865238106Sdes continue 6866238106Sdes ;; 6867238106Sdes xlinker) 6868238106Sdes func_append linker_flags " $qarg" 6869238106Sdes func_append compiler_flags " $wl$qarg" 6870238106Sdes prev= 6871238106Sdes func_append compile_command " $wl$qarg" 6872238106Sdes func_append finalize_command " $wl$qarg" 6873238106Sdes continue 6874238106Sdes ;; 6875238106Sdes *) 6876238106Sdes eval "$prev=\"\$arg\"" 6877238106Sdes prev= 6878238106Sdes continue 6879238106Sdes ;; 6880238106Sdes esac 6881238106Sdes fi # test -n "$prev" 6882238106Sdes 6883296415Sdes prevarg=$arg 6884238106Sdes 6885238106Sdes case $arg in 6886238106Sdes -all-static) 6887238106Sdes if test -n "$link_static_flag"; then 6888238106Sdes # See comment for -static flag below, for more details. 6889238106Sdes func_append compile_command " $link_static_flag" 6890238106Sdes func_append finalize_command " $link_static_flag" 6891238106Sdes fi 6892238106Sdes continue 6893238106Sdes ;; 6894238106Sdes 6895238106Sdes -allow-undefined) 6896238106Sdes # FIXME: remove this flag sometime in the future. 6897296415Sdes func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898238106Sdes ;; 6899238106Sdes 6900238106Sdes -avoid-version) 6901238106Sdes avoid_version=yes 6902238106Sdes continue 6903238106Sdes ;; 6904238106Sdes 6905238106Sdes -bindir) 6906238106Sdes prev=bindir 6907238106Sdes continue 6908238106Sdes ;; 6909238106Sdes 6910238106Sdes -dlopen) 6911238106Sdes prev=dlfiles 6912238106Sdes continue 6913238106Sdes ;; 6914238106Sdes 6915238106Sdes -dlpreopen) 6916238106Sdes prev=dlprefiles 6917238106Sdes continue 6918238106Sdes ;; 6919238106Sdes 6920238106Sdes -export-dynamic) 6921238106Sdes export_dynamic=yes 6922238106Sdes continue 6923238106Sdes ;; 6924238106Sdes 6925238106Sdes -export-symbols | -export-symbols-regex) 6926238106Sdes if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927238106Sdes func_fatal_error "more than one -exported-symbols argument is not allowed" 6928238106Sdes fi 6929296415Sdes if test X-export-symbols = "X$arg"; then 6930238106Sdes prev=expsyms 6931238106Sdes else 6932238106Sdes prev=expsyms_regex 6933238106Sdes fi 6934238106Sdes continue 6935238106Sdes ;; 6936238106Sdes 6937238106Sdes -framework) 6938238106Sdes prev=framework 6939238106Sdes continue 6940238106Sdes ;; 6941238106Sdes 6942238106Sdes -inst-prefix-dir) 6943238106Sdes prev=inst_prefix 6944238106Sdes continue 6945238106Sdes ;; 6946238106Sdes 6947238106Sdes # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948238106Sdes # so, if we see these flags be careful not to treat them like -L 6949238106Sdes -L[A-Z][A-Z]*:*) 6950238106Sdes case $with_gcc/$host in 6951238106Sdes no/*-*-irix* | /*-*-irix*) 6952238106Sdes func_append compile_command " $arg" 6953238106Sdes func_append finalize_command " $arg" 6954238106Sdes ;; 6955238106Sdes esac 6956238106Sdes continue 6957238106Sdes ;; 6958238106Sdes 6959238106Sdes -L*) 6960238106Sdes func_stripname "-L" '' "$arg" 6961238106Sdes if test -z "$func_stripname_result"; then 6962238106Sdes if test "$#" -gt 0; then 6963296415Sdes func_fatal_error "require no space between '-L' and '$1'" 6964238106Sdes else 6965296415Sdes func_fatal_error "need path for '-L' option" 6966238106Sdes fi 6967238106Sdes fi 6968238106Sdes func_resolve_sysroot "$func_stripname_result" 6969238106Sdes dir=$func_resolve_sysroot_result 6970238106Sdes # We need an absolute path. 6971238106Sdes case $dir in 6972238106Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 6973238106Sdes *) 6974238106Sdes absdir=`cd "$dir" && pwd` 6975238106Sdes test -z "$absdir" && \ 6976296415Sdes func_fatal_error "cannot determine absolute directory name of '$dir'" 6977296415Sdes dir=$absdir 6978238106Sdes ;; 6979238106Sdes esac 6980238106Sdes case "$deplibs " in 6981238106Sdes *" -L$dir "* | *" $arg "*) 6982238106Sdes # Will only happen for absolute or sysroot arguments 6983238106Sdes ;; 6984238106Sdes *) 6985238106Sdes # Preserve sysroot, but never include relative directories 6986238106Sdes case $dir in 6987238106Sdes [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988238106Sdes *) func_append deplibs " -L$dir" ;; 6989238106Sdes esac 6990238106Sdes func_append lib_search_path " $dir" 6991238106Sdes ;; 6992238106Sdes esac 6993238106Sdes case $host in 6994238106Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995238106Sdes testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996238106Sdes case :$dllsearchpath: in 6997238106Sdes *":$dir:"*) ;; 6998238106Sdes ::) dllsearchpath=$dir;; 6999238106Sdes *) func_append dllsearchpath ":$dir";; 7000238106Sdes esac 7001238106Sdes case :$dllsearchpath: in 7002238106Sdes *":$testbindir:"*) ;; 7003238106Sdes ::) dllsearchpath=$testbindir;; 7004238106Sdes *) func_append dllsearchpath ":$testbindir";; 7005238106Sdes esac 7006238106Sdes ;; 7007238106Sdes esac 7008238106Sdes continue 7009238106Sdes ;; 7010238106Sdes 7011238106Sdes -l*) 7012296415Sdes if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013238106Sdes case $host in 7014238106Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015238106Sdes # These systems don't actually have a C or math library (as such) 7016238106Sdes continue 7017238106Sdes ;; 7018238106Sdes *-*-os2*) 7019238106Sdes # These systems don't actually have a C library (as such) 7020296415Sdes test X-lc = "X$arg" && continue 7021238106Sdes ;; 7022296415Sdes *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023238106Sdes # Do not include libc due to us having libc/libc_r. 7024296415Sdes test X-lc = "X$arg" && continue 7025238106Sdes ;; 7026238106Sdes *-*-rhapsody* | *-*-darwin1.[012]) 7027238106Sdes # Rhapsody C and math libraries are in the System framework 7028238106Sdes func_append deplibs " System.ltframework" 7029238106Sdes continue 7030238106Sdes ;; 7031238106Sdes *-*-sco3.2v5* | *-*-sco5v6*) 7032238106Sdes # Causes problems with __ctype 7033296415Sdes test X-lc = "X$arg" && continue 7034238106Sdes ;; 7035238106Sdes *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036238106Sdes # Compiler inserts libc in the correct place for threads to work 7037296415Sdes test X-lc = "X$arg" && continue 7038238106Sdes ;; 7039238106Sdes esac 7040296415Sdes elif test X-lc_r = "X$arg"; then 7041238106Sdes case $host in 7042296415Sdes *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043238106Sdes # Do not include libc_r directly, use -pthread flag. 7044238106Sdes continue 7045238106Sdes ;; 7046238106Sdes esac 7047238106Sdes fi 7048238106Sdes func_append deplibs " $arg" 7049238106Sdes continue 7050238106Sdes ;; 7051238106Sdes 7052296415Sdes -mllvm) 7053296415Sdes prev=mllvm 7054296415Sdes continue 7055296415Sdes ;; 7056296415Sdes 7057238106Sdes -module) 7058238106Sdes module=yes 7059238106Sdes continue 7060238106Sdes ;; 7061238106Sdes 7062238106Sdes # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063238106Sdes # classes, name mangling, and exception handling. 7064238106Sdes # Darwin uses the -arch flag to determine output architecture. 7065238106Sdes -model|-arch|-isysroot|--sysroot) 7066238106Sdes func_append compiler_flags " $arg" 7067238106Sdes func_append compile_command " $arg" 7068238106Sdes func_append finalize_command " $arg" 7069238106Sdes prev=xcompiler 7070238106Sdes continue 7071238106Sdes ;; 7072238106Sdes 7073249141Sdes -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074249141Sdes |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075238106Sdes func_append compiler_flags " $arg" 7076238106Sdes func_append compile_command " $arg" 7077238106Sdes func_append finalize_command " $arg" 7078238106Sdes case "$new_inherited_linker_flags " in 7079238106Sdes *" $arg "*) ;; 7080238106Sdes * ) func_append new_inherited_linker_flags " $arg" ;; 7081238106Sdes esac 7082238106Sdes continue 7083238106Sdes ;; 7084238106Sdes 7085238106Sdes -multi_module) 7086296415Sdes single_module=$wl-multi_module 7087238106Sdes continue 7088238106Sdes ;; 7089238106Sdes 7090238106Sdes -no-fast-install) 7091238106Sdes fast_install=no 7092238106Sdes continue 7093238106Sdes ;; 7094238106Sdes 7095238106Sdes -no-install) 7096238106Sdes case $host in 7097238106Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098238106Sdes # The PATH hackery in wrapper scripts is required on Windows 7099238106Sdes # and Darwin in order for the loader to find any dlls it needs. 7100296415Sdes func_warning "'-no-install' is ignored for $host" 7101296415Sdes func_warning "assuming '-no-fast-install' instead" 7102238106Sdes fast_install=no 7103238106Sdes ;; 7104238106Sdes *) no_install=yes ;; 7105238106Sdes esac 7106238106Sdes continue 7107238106Sdes ;; 7108238106Sdes 7109238106Sdes -no-undefined) 7110238106Sdes allow_undefined=no 7111238106Sdes continue 7112238106Sdes ;; 7113238106Sdes 7114238106Sdes -objectlist) 7115238106Sdes prev=objectlist 7116238106Sdes continue 7117238106Sdes ;; 7118238106Sdes 7119296415Sdes -os2dllname) 7120296415Sdes prev=os2dllname 7121296415Sdes continue 7122296415Sdes ;; 7123296415Sdes 7124238106Sdes -o) prev=output ;; 7125238106Sdes 7126238106Sdes -precious-files-regex) 7127238106Sdes prev=precious_regex 7128238106Sdes continue 7129238106Sdes ;; 7130238106Sdes 7131238106Sdes -release) 7132238106Sdes prev=release 7133238106Sdes continue 7134238106Sdes ;; 7135238106Sdes 7136238106Sdes -rpath) 7137238106Sdes prev=rpath 7138238106Sdes continue 7139238106Sdes ;; 7140238106Sdes 7141238106Sdes -R) 7142238106Sdes prev=xrpath 7143238106Sdes continue 7144238106Sdes ;; 7145238106Sdes 7146238106Sdes -R*) 7147238106Sdes func_stripname '-R' '' "$arg" 7148238106Sdes dir=$func_stripname_result 7149238106Sdes # We need an absolute path. 7150238106Sdes case $dir in 7151238106Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 7152238106Sdes =*) 7153238106Sdes func_stripname '=' '' "$dir" 7154238106Sdes dir=$lt_sysroot$func_stripname_result 7155238106Sdes ;; 7156238106Sdes *) 7157238106Sdes func_fatal_error "only absolute run-paths are allowed" 7158238106Sdes ;; 7159238106Sdes esac 7160238106Sdes case "$xrpath " in 7161238106Sdes *" $dir "*) ;; 7162238106Sdes *) func_append xrpath " $dir" ;; 7163238106Sdes esac 7164238106Sdes continue 7165238106Sdes ;; 7166238106Sdes 7167238106Sdes -shared) 7168238106Sdes # The effects of -shared are defined in a previous loop. 7169238106Sdes continue 7170238106Sdes ;; 7171238106Sdes 7172238106Sdes -shrext) 7173238106Sdes prev=shrext 7174238106Sdes continue 7175238106Sdes ;; 7176238106Sdes 7177238106Sdes -static | -static-libtool-libs) 7178238106Sdes # The effects of -static are defined in a previous loop. 7179238106Sdes # We used to do the same as -all-static on platforms that 7180238106Sdes # didn't have a PIC flag, but the assumption that the effects 7181238106Sdes # would be equivalent was wrong. It would break on at least 7182238106Sdes # Digital Unix and AIX. 7183238106Sdes continue 7184238106Sdes ;; 7185238106Sdes 7186238106Sdes -thread-safe) 7187238106Sdes thread_safe=yes 7188238106Sdes continue 7189238106Sdes ;; 7190238106Sdes 7191238106Sdes -version-info) 7192238106Sdes prev=vinfo 7193238106Sdes continue 7194238106Sdes ;; 7195238106Sdes 7196238106Sdes -version-number) 7197238106Sdes prev=vinfo 7198238106Sdes vinfo_number=yes 7199238106Sdes continue 7200238106Sdes ;; 7201238106Sdes 7202238106Sdes -weak) 7203238106Sdes prev=weak 7204238106Sdes continue 7205238106Sdes ;; 7206238106Sdes 7207238106Sdes -Wc,*) 7208238106Sdes func_stripname '-Wc,' '' "$arg" 7209238106Sdes args=$func_stripname_result 7210238106Sdes arg= 7211296415Sdes save_ifs=$IFS; IFS=, 7212238106Sdes for flag in $args; do 7213296415Sdes IFS=$save_ifs 7214238106Sdes func_quote_for_eval "$flag" 7215238106Sdes func_append arg " $func_quote_for_eval_result" 7216238106Sdes func_append compiler_flags " $func_quote_for_eval_result" 7217238106Sdes done 7218296415Sdes IFS=$save_ifs 7219238106Sdes func_stripname ' ' '' "$arg" 7220238106Sdes arg=$func_stripname_result 7221238106Sdes ;; 7222238106Sdes 7223238106Sdes -Wl,*) 7224238106Sdes func_stripname '-Wl,' '' "$arg" 7225238106Sdes args=$func_stripname_result 7226238106Sdes arg= 7227296415Sdes save_ifs=$IFS; IFS=, 7228238106Sdes for flag in $args; do 7229296415Sdes IFS=$save_ifs 7230238106Sdes func_quote_for_eval "$flag" 7231238106Sdes func_append arg " $wl$func_quote_for_eval_result" 7232238106Sdes func_append compiler_flags " $wl$func_quote_for_eval_result" 7233238106Sdes func_append linker_flags " $func_quote_for_eval_result" 7234238106Sdes done 7235296415Sdes IFS=$save_ifs 7236238106Sdes func_stripname ' ' '' "$arg" 7237238106Sdes arg=$func_stripname_result 7238238106Sdes ;; 7239238106Sdes 7240238106Sdes -Xcompiler) 7241238106Sdes prev=xcompiler 7242238106Sdes continue 7243238106Sdes ;; 7244238106Sdes 7245238106Sdes -Xlinker) 7246238106Sdes prev=xlinker 7247238106Sdes continue 7248238106Sdes ;; 7249238106Sdes 7250238106Sdes -XCClinker) 7251238106Sdes prev=xcclinker 7252238106Sdes continue 7253238106Sdes ;; 7254238106Sdes 7255238106Sdes # -msg_* for osf cc 7256238106Sdes -msg_*) 7257238106Sdes func_quote_for_eval "$arg" 7258296415Sdes arg=$func_quote_for_eval_result 7259238106Sdes ;; 7260238106Sdes 7261238106Sdes # Flags to be passed through unchanged, with rationale: 7262238106Sdes # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263238106Sdes # -r[0-9][0-9]* specify processor for the SGI compiler 7264238106Sdes # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265238106Sdes # +DA*, +DD* enable 64-bit mode for the HP compiler 7266238106Sdes # -q* compiler args for the IBM compiler 7267238106Sdes # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268238106Sdes # -F/path path to uninstalled frameworks, gcc on darwin 7269238106Sdes # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270296415Sdes # -fstack-protector* stack protector flags for GCC 7271238106Sdes # @file GCC response files 7272238106Sdes # -tp=* Portland pgcc target processor selection 7273238106Sdes # --sysroot=* for sysroot support 7274296415Sdes # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275356345Scy # -specs=* GCC specs files 7276296415Sdes # -stdlib=* select c++ std lib with clang 7277238106Sdes -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7278238106Sdes -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7279356345Scy -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7280356345Scy -specs=*) 7281238106Sdes func_quote_for_eval "$arg" 7282296415Sdes arg=$func_quote_for_eval_result 7283238106Sdes func_append compile_command " $arg" 7284238106Sdes func_append finalize_command " $arg" 7285238106Sdes func_append compiler_flags " $arg" 7286238106Sdes continue 7287238106Sdes ;; 7288238106Sdes 7289296415Sdes -Z*) 7290296415Sdes if test os2 = "`expr $host : '.*\(os2\)'`"; then 7291296415Sdes # OS/2 uses -Zxxx to specify OS/2-specific options 7292296415Sdes compiler_flags="$compiler_flags $arg" 7293296415Sdes func_append compile_command " $arg" 7294296415Sdes func_append finalize_command " $arg" 7295296415Sdes case $arg in 7296296415Sdes -Zlinker | -Zstack) 7297296415Sdes prev=xcompiler 7298296415Sdes ;; 7299296415Sdes esac 7300296415Sdes continue 7301296415Sdes else 7302296415Sdes # Otherwise treat like 'Some other compiler flag' below 7303296415Sdes func_quote_for_eval "$arg" 7304296415Sdes arg=$func_quote_for_eval_result 7305296415Sdes fi 7306296415Sdes ;; 7307296415Sdes 7308238106Sdes # Some other compiler flag. 7309238106Sdes -* | +*) 7310238106Sdes func_quote_for_eval "$arg" 7311296415Sdes arg=$func_quote_for_eval_result 7312238106Sdes ;; 7313238106Sdes 7314238106Sdes *.$objext) 7315238106Sdes # A standard object. 7316238106Sdes func_append objs " $arg" 7317238106Sdes ;; 7318238106Sdes 7319238106Sdes *.lo) 7320238106Sdes # A libtool-controlled object. 7321238106Sdes 7322238106Sdes # Check to see that this really is a libtool object. 7323238106Sdes if func_lalib_unsafe_p "$arg"; then 7324238106Sdes pic_object= 7325238106Sdes non_pic_object= 7326238106Sdes 7327238106Sdes # Read the .lo file 7328238106Sdes func_source "$arg" 7329238106Sdes 7330238106Sdes if test -z "$pic_object" || 7331238106Sdes test -z "$non_pic_object" || 7332296415Sdes test none = "$pic_object" && 7333296415Sdes test none = "$non_pic_object"; then 7334296415Sdes func_fatal_error "cannot find name of object for '$arg'" 7335238106Sdes fi 7336238106Sdes 7337238106Sdes # Extract subdirectory from the argument. 7338238106Sdes func_dirname "$arg" "/" "" 7339296415Sdes xdir=$func_dirname_result 7340238106Sdes 7341296415Sdes test none = "$pic_object" || { 7342238106Sdes # Prepend the subdirectory the object is found in. 7343296415Sdes pic_object=$xdir$pic_object 7344238106Sdes 7345296415Sdes if test dlfiles = "$prev"; then 7346296415Sdes if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7347238106Sdes func_append dlfiles " $pic_object" 7348238106Sdes prev= 7349238106Sdes continue 7350238106Sdes else 7351238106Sdes # If libtool objects are unsupported, then we need to preload. 7352238106Sdes prev=dlprefiles 7353238106Sdes fi 7354238106Sdes fi 7355238106Sdes 7356238106Sdes # CHECK ME: I think I busted this. -Ossama 7357296415Sdes if test dlprefiles = "$prev"; then 7358238106Sdes # Preload the old-style object. 7359238106Sdes func_append dlprefiles " $pic_object" 7360238106Sdes prev= 7361238106Sdes fi 7362238106Sdes 7363238106Sdes # A PIC object. 7364238106Sdes func_append libobjs " $pic_object" 7365296415Sdes arg=$pic_object 7366296415Sdes } 7367238106Sdes 7368238106Sdes # Non-PIC object. 7369296415Sdes if test none != "$non_pic_object"; then 7370238106Sdes # Prepend the subdirectory the object is found in. 7371296415Sdes non_pic_object=$xdir$non_pic_object 7372238106Sdes 7373238106Sdes # A standard non-PIC object 7374238106Sdes func_append non_pic_objects " $non_pic_object" 7375296415Sdes if test -z "$pic_object" || test none = "$pic_object"; then 7376296415Sdes arg=$non_pic_object 7377238106Sdes fi 7378238106Sdes else 7379238106Sdes # If the PIC object exists, use it instead. 7380238106Sdes # $xdir was prepended to $pic_object above. 7381296415Sdes non_pic_object=$pic_object 7382238106Sdes func_append non_pic_objects " $non_pic_object" 7383238106Sdes fi 7384238106Sdes else 7385238106Sdes # Only an error if not doing a dry-run. 7386238106Sdes if $opt_dry_run; then 7387238106Sdes # Extract subdirectory from the argument. 7388238106Sdes func_dirname "$arg" "/" "" 7389296415Sdes xdir=$func_dirname_result 7390238106Sdes 7391238106Sdes func_lo2o "$arg" 7392238106Sdes pic_object=$xdir$objdir/$func_lo2o_result 7393238106Sdes non_pic_object=$xdir$func_lo2o_result 7394238106Sdes func_append libobjs " $pic_object" 7395238106Sdes func_append non_pic_objects " $non_pic_object" 7396238106Sdes else 7397296415Sdes func_fatal_error "'$arg' is not a valid libtool object" 7398238106Sdes fi 7399238106Sdes fi 7400238106Sdes ;; 7401238106Sdes 7402238106Sdes *.$libext) 7403238106Sdes # An archive. 7404238106Sdes func_append deplibs " $arg" 7405238106Sdes func_append old_deplibs " $arg" 7406238106Sdes continue 7407238106Sdes ;; 7408238106Sdes 7409238106Sdes *.la) 7410238106Sdes # A libtool-controlled library. 7411238106Sdes 7412238106Sdes func_resolve_sysroot "$arg" 7413296415Sdes if test dlfiles = "$prev"; then 7414238106Sdes # This library was specified with -dlopen. 7415238106Sdes func_append dlfiles " $func_resolve_sysroot_result" 7416238106Sdes prev= 7417296415Sdes elif test dlprefiles = "$prev"; then 7418238106Sdes # The library was specified with -dlpreopen. 7419238106Sdes func_append dlprefiles " $func_resolve_sysroot_result" 7420238106Sdes prev= 7421238106Sdes else 7422238106Sdes func_append deplibs " $func_resolve_sysroot_result" 7423238106Sdes fi 7424238106Sdes continue 7425238106Sdes ;; 7426238106Sdes 7427238106Sdes # Some other compiler argument. 7428238106Sdes *) 7429238106Sdes # Unknown arguments in both finalize_command and compile_command need 7430238106Sdes # to be aesthetically quoted because they are evaled later. 7431238106Sdes func_quote_for_eval "$arg" 7432296415Sdes arg=$func_quote_for_eval_result 7433238106Sdes ;; 7434238106Sdes esac # arg 7435238106Sdes 7436238106Sdes # Now actually substitute the argument into the commands. 7437238106Sdes if test -n "$arg"; then 7438238106Sdes func_append compile_command " $arg" 7439238106Sdes func_append finalize_command " $arg" 7440238106Sdes fi 7441238106Sdes done # argument parsing loop 7442238106Sdes 7443238106Sdes test -n "$prev" && \ 7444296415Sdes func_fatal_help "the '$prevarg' option requires an argument" 7445238106Sdes 7446296415Sdes if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7447238106Sdes eval arg=\"$export_dynamic_flag_spec\" 7448238106Sdes func_append compile_command " $arg" 7449238106Sdes func_append finalize_command " $arg" 7450238106Sdes fi 7451238106Sdes 7452238106Sdes oldlibs= 7453238106Sdes # calculate the name of the file, without its directory 7454238106Sdes func_basename "$output" 7455296415Sdes outputname=$func_basename_result 7456296415Sdes libobjs_save=$libobjs 7457238106Sdes 7458238106Sdes if test -n "$shlibpath_var"; then 7459238106Sdes # get the directories listed in $shlibpath_var 7460296415Sdes eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7461238106Sdes else 7462238106Sdes shlib_search_path= 7463238106Sdes fi 7464238106Sdes eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7465238106Sdes eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7466238106Sdes 7467296415Sdes # Definition is injected by LT_CONFIG during libtool generation. 7468296415Sdes func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7469296415Sdes 7470238106Sdes func_dirname "$output" "/" "" 7471296415Sdes output_objdir=$func_dirname_result$objdir 7472238106Sdes func_to_tool_file "$output_objdir/" 7473238106Sdes tool_output_objdir=$func_to_tool_file_result 7474238106Sdes # Create the object directory. 7475238106Sdes func_mkdir_p "$output_objdir" 7476238106Sdes 7477238106Sdes # Determine the type of output 7478238106Sdes case $output in 7479238106Sdes "") 7480238106Sdes func_fatal_help "you must specify an output file" 7481238106Sdes ;; 7482238106Sdes *.$libext) linkmode=oldlib ;; 7483238106Sdes *.lo | *.$objext) linkmode=obj ;; 7484238106Sdes *.la) linkmode=lib ;; 7485238106Sdes *) linkmode=prog ;; # Anything else should be a program. 7486238106Sdes esac 7487238106Sdes 7488238106Sdes specialdeplibs= 7489238106Sdes 7490238106Sdes libs= 7491238106Sdes # Find all interdependent deplibs by searching for libraries 7492238106Sdes # that are linked more than once (e.g. -la -lb -la) 7493238106Sdes for deplib in $deplibs; do 7494296415Sdes if $opt_preserve_dup_deps; then 7495238106Sdes case "$libs " in 7496238106Sdes *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7497238106Sdes esac 7498238106Sdes fi 7499238106Sdes func_append libs " $deplib" 7500238106Sdes done 7501238106Sdes 7502296415Sdes if test lib = "$linkmode"; then 7503238106Sdes libs="$predeps $libs $compiler_lib_search_path $postdeps" 7504238106Sdes 7505238106Sdes # Compute libraries that are listed more than once in $predeps 7506238106Sdes # $postdeps and mark them as special (i.e., whose duplicates are 7507238106Sdes # not to be eliminated). 7508238106Sdes pre_post_deps= 7509238106Sdes if $opt_duplicate_compiler_generated_deps; then 7510238106Sdes for pre_post_dep in $predeps $postdeps; do 7511238106Sdes case "$pre_post_deps " in 7512238106Sdes *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7513238106Sdes esac 7514238106Sdes func_append pre_post_deps " $pre_post_dep" 7515238106Sdes done 7516238106Sdes fi 7517238106Sdes pre_post_deps= 7518238106Sdes fi 7519238106Sdes 7520238106Sdes deplibs= 7521238106Sdes newdependency_libs= 7522238106Sdes newlib_search_path= 7523238106Sdes need_relink=no # whether we're linking any uninstalled libtool libraries 7524238106Sdes notinst_deplibs= # not-installed libtool libraries 7525238106Sdes notinst_path= # paths that contain not-installed libtool libraries 7526238106Sdes 7527238106Sdes case $linkmode in 7528238106Sdes lib) 7529238106Sdes passes="conv dlpreopen link" 7530238106Sdes for file in $dlfiles $dlprefiles; do 7531238106Sdes case $file in 7532238106Sdes *.la) ;; 7533238106Sdes *) 7534296415Sdes func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7535238106Sdes ;; 7536238106Sdes esac 7537238106Sdes done 7538238106Sdes ;; 7539238106Sdes prog) 7540238106Sdes compile_deplibs= 7541238106Sdes finalize_deplibs= 7542296415Sdes alldeplibs=false 7543238106Sdes newdlfiles= 7544238106Sdes newdlprefiles= 7545238106Sdes passes="conv scan dlopen dlpreopen link" 7546238106Sdes ;; 7547238106Sdes *) passes="conv" 7548238106Sdes ;; 7549238106Sdes esac 7550238106Sdes 7551238106Sdes for pass in $passes; do 7552238106Sdes # The preopen pass in lib mode reverses $deplibs; put it back here 7553238106Sdes # so that -L comes before libs that need it for instance... 7554296415Sdes if test lib,link = "$linkmode,$pass"; then 7555238106Sdes ## FIXME: Find the place where the list is rebuilt in the wrong 7556238106Sdes ## order, and fix it there properly 7557238106Sdes tmp_deplibs= 7558238106Sdes for deplib in $deplibs; do 7559238106Sdes tmp_deplibs="$deplib $tmp_deplibs" 7560238106Sdes done 7561296415Sdes deplibs=$tmp_deplibs 7562238106Sdes fi 7563238106Sdes 7564296415Sdes if test lib,link = "$linkmode,$pass" || 7565296415Sdes test prog,scan = "$linkmode,$pass"; then 7566296415Sdes libs=$deplibs 7567238106Sdes deplibs= 7568238106Sdes fi 7569296415Sdes if test prog = "$linkmode"; then 7570238106Sdes case $pass in 7571296415Sdes dlopen) libs=$dlfiles ;; 7572296415Sdes dlpreopen) libs=$dlprefiles ;; 7573238106Sdes link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7574238106Sdes esac 7575238106Sdes fi 7576296415Sdes if test lib,dlpreopen = "$linkmode,$pass"; then 7577238106Sdes # Collect and forward deplibs of preopened libtool libs 7578238106Sdes for lib in $dlprefiles; do 7579238106Sdes # Ignore non-libtool-libs 7580238106Sdes dependency_libs= 7581238106Sdes func_resolve_sysroot "$lib" 7582238106Sdes case $lib in 7583238106Sdes *.la) func_source "$func_resolve_sysroot_result" ;; 7584238106Sdes esac 7585238106Sdes 7586238106Sdes # Collect preopened libtool deplibs, except any this library 7587238106Sdes # has declared as weak libs 7588238106Sdes for deplib in $dependency_libs; do 7589238106Sdes func_basename "$deplib" 7590238106Sdes deplib_base=$func_basename_result 7591238106Sdes case " $weak_libs " in 7592238106Sdes *" $deplib_base "*) ;; 7593238106Sdes *) func_append deplibs " $deplib" ;; 7594238106Sdes esac 7595238106Sdes done 7596238106Sdes done 7597296415Sdes libs=$dlprefiles 7598238106Sdes fi 7599296415Sdes if test dlopen = "$pass"; then 7600238106Sdes # Collect dlpreopened libraries 7601296415Sdes save_deplibs=$deplibs 7602238106Sdes deplibs= 7603238106Sdes fi 7604238106Sdes 7605238106Sdes for deplib in $libs; do 7606238106Sdes lib= 7607296415Sdes found=false 7608238106Sdes case $deplib in 7609249141Sdes -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7610249141Sdes |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7611296415Sdes if test prog,link = "$linkmode,$pass"; then 7612238106Sdes compile_deplibs="$deplib $compile_deplibs" 7613238106Sdes finalize_deplibs="$deplib $finalize_deplibs" 7614238106Sdes else 7615238106Sdes func_append compiler_flags " $deplib" 7616296415Sdes if test lib = "$linkmode"; then 7617238106Sdes case "$new_inherited_linker_flags " in 7618238106Sdes *" $deplib "*) ;; 7619238106Sdes * ) func_append new_inherited_linker_flags " $deplib" ;; 7620238106Sdes esac 7621238106Sdes fi 7622238106Sdes fi 7623238106Sdes continue 7624238106Sdes ;; 7625238106Sdes -l*) 7626296415Sdes if test lib != "$linkmode" && test prog != "$linkmode"; then 7627296415Sdes func_warning "'-l' is ignored for archives/objects" 7628238106Sdes continue 7629238106Sdes fi 7630238106Sdes func_stripname '-l' '' "$deplib" 7631238106Sdes name=$func_stripname_result 7632296415Sdes if test lib = "$linkmode"; then 7633238106Sdes searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7634238106Sdes else 7635238106Sdes searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7636238106Sdes fi 7637238106Sdes for searchdir in $searchdirs; do 7638238106Sdes for search_ext in .la $std_shrext .so .a; do 7639238106Sdes # Search the libtool library 7640296415Sdes lib=$searchdir/lib$name$search_ext 7641238106Sdes if test -f "$lib"; then 7642296415Sdes if test .la = "$search_ext"; then 7643296415Sdes found=: 7644238106Sdes else 7645296415Sdes found=false 7646238106Sdes fi 7647238106Sdes break 2 7648238106Sdes fi 7649238106Sdes done 7650238106Sdes done 7651296415Sdes if $found; then 7652296415Sdes # deplib is a libtool library 7653238106Sdes # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7654238106Sdes # We need to do some special things here, and not later. 7655296415Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7656238106Sdes case " $predeps $postdeps " in 7657238106Sdes *" $deplib "*) 7658238106Sdes if func_lalib_p "$lib"; then 7659238106Sdes library_names= 7660238106Sdes old_library= 7661238106Sdes func_source "$lib" 7662238106Sdes for l in $old_library $library_names; do 7663296415Sdes ll=$l 7664238106Sdes done 7665296415Sdes if test "X$ll" = "X$old_library"; then # only static version available 7666296415Sdes found=false 7667238106Sdes func_dirname "$lib" "" "." 7668296415Sdes ladir=$func_dirname_result 7669238106Sdes lib=$ladir/$old_library 7670296415Sdes if test prog,link = "$linkmode,$pass"; then 7671238106Sdes compile_deplibs="$deplib $compile_deplibs" 7672238106Sdes finalize_deplibs="$deplib $finalize_deplibs" 7673238106Sdes else 7674238106Sdes deplibs="$deplib $deplibs" 7675296415Sdes test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7676238106Sdes fi 7677238106Sdes continue 7678238106Sdes fi 7679238106Sdes fi 7680238106Sdes ;; 7681238106Sdes *) ;; 7682238106Sdes esac 7683238106Sdes fi 7684296415Sdes else 7685296415Sdes # deplib doesn't seem to be a libtool library 7686296415Sdes if test prog,link = "$linkmode,$pass"; then 7687296415Sdes compile_deplibs="$deplib $compile_deplibs" 7688296415Sdes finalize_deplibs="$deplib $finalize_deplibs" 7689296415Sdes else 7690296415Sdes deplibs="$deplib $deplibs" 7691296415Sdes test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7692296415Sdes fi 7693296415Sdes continue 7694238106Sdes fi 7695238106Sdes ;; # -l 7696238106Sdes *.ltframework) 7697296415Sdes if test prog,link = "$linkmode,$pass"; then 7698238106Sdes compile_deplibs="$deplib $compile_deplibs" 7699238106Sdes finalize_deplibs="$deplib $finalize_deplibs" 7700238106Sdes else 7701238106Sdes deplibs="$deplib $deplibs" 7702296415Sdes if test lib = "$linkmode"; then 7703238106Sdes case "$new_inherited_linker_flags " in 7704238106Sdes *" $deplib "*) ;; 7705238106Sdes * ) func_append new_inherited_linker_flags " $deplib" ;; 7706238106Sdes esac 7707238106Sdes fi 7708238106Sdes fi 7709238106Sdes continue 7710238106Sdes ;; 7711238106Sdes -L*) 7712238106Sdes case $linkmode in 7713238106Sdes lib) 7714238106Sdes deplibs="$deplib $deplibs" 7715296415Sdes test conv = "$pass" && continue 7716238106Sdes newdependency_libs="$deplib $newdependency_libs" 7717238106Sdes func_stripname '-L' '' "$deplib" 7718238106Sdes func_resolve_sysroot "$func_stripname_result" 7719238106Sdes func_append newlib_search_path " $func_resolve_sysroot_result" 7720238106Sdes ;; 7721238106Sdes prog) 7722296415Sdes if test conv = "$pass"; then 7723238106Sdes deplibs="$deplib $deplibs" 7724238106Sdes continue 7725238106Sdes fi 7726296415Sdes if test scan = "$pass"; then 7727238106Sdes deplibs="$deplib $deplibs" 7728238106Sdes else 7729238106Sdes compile_deplibs="$deplib $compile_deplibs" 7730238106Sdes finalize_deplibs="$deplib $finalize_deplibs" 7731238106Sdes fi 7732238106Sdes func_stripname '-L' '' "$deplib" 7733238106Sdes func_resolve_sysroot "$func_stripname_result" 7734238106Sdes func_append newlib_search_path " $func_resolve_sysroot_result" 7735238106Sdes ;; 7736238106Sdes *) 7737296415Sdes func_warning "'-L' is ignored for archives/objects" 7738238106Sdes ;; 7739238106Sdes esac # linkmode 7740238106Sdes continue 7741238106Sdes ;; # -L 7742238106Sdes -R*) 7743296415Sdes if test link = "$pass"; then 7744238106Sdes func_stripname '-R' '' "$deplib" 7745238106Sdes func_resolve_sysroot "$func_stripname_result" 7746238106Sdes dir=$func_resolve_sysroot_result 7747238106Sdes # Make sure the xrpath contains only unique directories. 7748238106Sdes case "$xrpath " in 7749238106Sdes *" $dir "*) ;; 7750238106Sdes *) func_append xrpath " $dir" ;; 7751238106Sdes esac 7752238106Sdes fi 7753238106Sdes deplibs="$deplib $deplibs" 7754238106Sdes continue 7755238106Sdes ;; 7756238106Sdes *.la) 7757238106Sdes func_resolve_sysroot "$deplib" 7758238106Sdes lib=$func_resolve_sysroot_result 7759238106Sdes ;; 7760238106Sdes *.$libext) 7761296415Sdes if test conv = "$pass"; then 7762238106Sdes deplibs="$deplib $deplibs" 7763238106Sdes continue 7764238106Sdes fi 7765238106Sdes case $linkmode in 7766238106Sdes lib) 7767238106Sdes # Linking convenience modules into shared libraries is allowed, 7768238106Sdes # but linking other static libraries is non-portable. 7769238106Sdes case " $dlpreconveniencelibs " in 7770238106Sdes *" $deplib "*) ;; 7771238106Sdes *) 7772296415Sdes valid_a_lib=false 7773238106Sdes case $deplibs_check_method in 7774238106Sdes match_pattern*) 7775238106Sdes set dummy $deplibs_check_method; shift 7776238106Sdes match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7777238106Sdes if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7778238106Sdes | $EGREP "$match_pattern_regex" > /dev/null; then 7779296415Sdes valid_a_lib=: 7780238106Sdes fi 7781238106Sdes ;; 7782238106Sdes pass_all) 7783296415Sdes valid_a_lib=: 7784238106Sdes ;; 7785238106Sdes esac 7786296415Sdes if $valid_a_lib; then 7787238106Sdes echo 7788296415Sdes $ECHO "*** Warning: Linking the shared library $output against the" 7789296415Sdes $ECHO "*** static library $deplib is not portable!" 7790296415Sdes deplibs="$deplib $deplibs" 7791296415Sdes else 7792296415Sdes echo 7793238106Sdes $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7794238106Sdes echo "*** I have the capability to make that library automatically link in when" 7795238106Sdes echo "*** you link to this library. But I can only do this if you have a" 7796238106Sdes echo "*** shared version of the library, which you do not appear to have" 7797238106Sdes echo "*** because the file extensions .$libext of this argument makes me believe" 7798238106Sdes echo "*** that it is just a static archive that I should not use here." 7799238106Sdes fi 7800238106Sdes ;; 7801238106Sdes esac 7802238106Sdes continue 7803238106Sdes ;; 7804238106Sdes prog) 7805296415Sdes if test link != "$pass"; then 7806238106Sdes deplibs="$deplib $deplibs" 7807238106Sdes else 7808238106Sdes compile_deplibs="$deplib $compile_deplibs" 7809238106Sdes finalize_deplibs="$deplib $finalize_deplibs" 7810238106Sdes fi 7811238106Sdes continue 7812238106Sdes ;; 7813238106Sdes esac # linkmode 7814238106Sdes ;; # *.$libext 7815238106Sdes *.lo | *.$objext) 7816296415Sdes if test conv = "$pass"; then 7817238106Sdes deplibs="$deplib $deplibs" 7818296415Sdes elif test prog = "$linkmode"; then 7819296415Sdes if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7820238106Sdes # If there is no dlopen support or we're linking statically, 7821238106Sdes # we need to preload. 7822238106Sdes func_append newdlprefiles " $deplib" 7823238106Sdes compile_deplibs="$deplib $compile_deplibs" 7824238106Sdes finalize_deplibs="$deplib $finalize_deplibs" 7825238106Sdes else 7826238106Sdes func_append newdlfiles " $deplib" 7827238106Sdes fi 7828238106Sdes fi 7829238106Sdes continue 7830238106Sdes ;; 7831238106Sdes %DEPLIBS%) 7832296415Sdes alldeplibs=: 7833238106Sdes continue 7834238106Sdes ;; 7835238106Sdes esac # case $deplib 7836238106Sdes 7837296415Sdes $found || test -f "$lib" \ 7838296415Sdes || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7839238106Sdes 7840238106Sdes # Check to see that this really is a libtool archive. 7841238106Sdes func_lalib_unsafe_p "$lib" \ 7842296415Sdes || func_fatal_error "'$lib' is not a valid libtool archive" 7843238106Sdes 7844238106Sdes func_dirname "$lib" "" "." 7845296415Sdes ladir=$func_dirname_result 7846238106Sdes 7847238106Sdes dlname= 7848238106Sdes dlopen= 7849238106Sdes dlpreopen= 7850238106Sdes libdir= 7851238106Sdes library_names= 7852238106Sdes old_library= 7853238106Sdes inherited_linker_flags= 7854238106Sdes # If the library was installed with an old release of libtool, 7855238106Sdes # it will not redefine variables installed, or shouldnotlink 7856238106Sdes installed=yes 7857238106Sdes shouldnotlink=no 7858238106Sdes avoidtemprpath= 7859238106Sdes 7860238106Sdes 7861238106Sdes # Read the .la file 7862238106Sdes func_source "$lib" 7863238106Sdes 7864238106Sdes # Convert "-framework foo" to "foo.ltframework" 7865238106Sdes if test -n "$inherited_linker_flags"; then 7866238106Sdes tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7867238106Sdes for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7868238106Sdes case " $new_inherited_linker_flags " in 7869238106Sdes *" $tmp_inherited_linker_flag "*) ;; 7870238106Sdes *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7871238106Sdes esac 7872238106Sdes done 7873238106Sdes fi 7874238106Sdes dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7875296415Sdes if test lib,link = "$linkmode,$pass" || 7876296415Sdes test prog,scan = "$linkmode,$pass" || 7877296415Sdes { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7878238106Sdes test -n "$dlopen" && func_append dlfiles " $dlopen" 7879238106Sdes test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7880238106Sdes fi 7881238106Sdes 7882296415Sdes if test conv = "$pass"; then 7883238106Sdes # Only check for convenience libraries 7884238106Sdes deplibs="$lib $deplibs" 7885238106Sdes if test -z "$libdir"; then 7886238106Sdes if test -z "$old_library"; then 7887296415Sdes func_fatal_error "cannot find name of link library for '$lib'" 7888238106Sdes fi 7889238106Sdes # It is a libtool convenience library, so add in its objects. 7890238106Sdes func_append convenience " $ladir/$objdir/$old_library" 7891238106Sdes func_append old_convenience " $ladir/$objdir/$old_library" 7892296415Sdes elif test prog != "$linkmode" && test lib != "$linkmode"; then 7893296415Sdes func_fatal_error "'$lib' is not a convenience library" 7894238106Sdes fi 7895238106Sdes tmp_libs= 7896238106Sdes for deplib in $dependency_libs; do 7897238106Sdes deplibs="$deplib $deplibs" 7898296415Sdes if $opt_preserve_dup_deps; then 7899238106Sdes case "$tmp_libs " in 7900238106Sdes *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7901238106Sdes esac 7902238106Sdes fi 7903238106Sdes func_append tmp_libs " $deplib" 7904238106Sdes done 7905238106Sdes continue 7906238106Sdes fi # $pass = conv 7907238106Sdes 7908238106Sdes 7909238106Sdes # Get the name of the library we link against. 7910238106Sdes linklib= 7911238106Sdes if test -n "$old_library" && 7912296415Sdes { test yes = "$prefer_static_libs" || 7913296415Sdes test built,no = "$prefer_static_libs,$installed"; }; then 7914238106Sdes linklib=$old_library 7915238106Sdes else 7916238106Sdes for l in $old_library $library_names; do 7917296415Sdes linklib=$l 7918238106Sdes done 7919238106Sdes fi 7920238106Sdes if test -z "$linklib"; then 7921296415Sdes func_fatal_error "cannot find name of link library for '$lib'" 7922238106Sdes fi 7923238106Sdes 7924238106Sdes # This library was specified with -dlopen. 7925296415Sdes if test dlopen = "$pass"; then 7926296415Sdes test -z "$libdir" \ 7927296415Sdes && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7928238106Sdes if test -z "$dlname" || 7929296415Sdes test yes != "$dlopen_support" || 7930296415Sdes test no = "$build_libtool_libs" 7931296415Sdes then 7932238106Sdes # If there is no dlname, no dlopen support or we're linking 7933238106Sdes # statically, we need to preload. We also need to preload any 7934238106Sdes # dependent libraries so libltdl's deplib preloader doesn't 7935238106Sdes # bomb out in the load deplibs phase. 7936238106Sdes func_append dlprefiles " $lib $dependency_libs" 7937238106Sdes else 7938238106Sdes func_append newdlfiles " $lib" 7939238106Sdes fi 7940238106Sdes continue 7941238106Sdes fi # $pass = dlopen 7942238106Sdes 7943238106Sdes # We need an absolute path. 7944238106Sdes case $ladir in 7945296415Sdes [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7946238106Sdes *) 7947238106Sdes abs_ladir=`cd "$ladir" && pwd` 7948238106Sdes if test -z "$abs_ladir"; then 7949296415Sdes func_warning "cannot determine absolute directory name of '$ladir'" 7950238106Sdes func_warning "passing it literally to the linker, although it might fail" 7951296415Sdes abs_ladir=$ladir 7952238106Sdes fi 7953238106Sdes ;; 7954238106Sdes esac 7955238106Sdes func_basename "$lib" 7956296415Sdes laname=$func_basename_result 7957238106Sdes 7958238106Sdes # Find the relevant object directory and library name. 7959296415Sdes if test yes = "$installed"; then 7960238106Sdes if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7961296415Sdes func_warning "library '$lib' was moved." 7962296415Sdes dir=$ladir 7963296415Sdes absdir=$abs_ladir 7964296415Sdes libdir=$abs_ladir 7965238106Sdes else 7966296415Sdes dir=$lt_sysroot$libdir 7967296415Sdes absdir=$lt_sysroot$libdir 7968238106Sdes fi 7969296415Sdes test yes = "$hardcode_automatic" && avoidtemprpath=yes 7970238106Sdes else 7971238106Sdes if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7972296415Sdes dir=$ladir 7973296415Sdes absdir=$abs_ladir 7974238106Sdes # Remove this search path later 7975238106Sdes func_append notinst_path " $abs_ladir" 7976238106Sdes else 7977296415Sdes dir=$ladir/$objdir 7978296415Sdes absdir=$abs_ladir/$objdir 7979238106Sdes # Remove this search path later 7980238106Sdes func_append notinst_path " $abs_ladir" 7981238106Sdes fi 7982238106Sdes fi # $installed = yes 7983238106Sdes func_stripname 'lib' '.la' "$laname" 7984238106Sdes name=$func_stripname_result 7985238106Sdes 7986238106Sdes # This library was specified with -dlpreopen. 7987296415Sdes if test dlpreopen = "$pass"; then 7988296415Sdes if test -z "$libdir" && test prog = "$linkmode"; then 7989296415Sdes func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7990238106Sdes fi 7991296415Sdes case $host in 7992238106Sdes # special handling for platforms with PE-DLLs. 7993238106Sdes *cygwin* | *mingw* | *cegcc* ) 7994238106Sdes # Linker will automatically link against shared library if both 7995238106Sdes # static and shared are present. Therefore, ensure we extract 7996238106Sdes # symbols from the import library if a shared library is present 7997238106Sdes # (otherwise, the dlopen module name will be incorrect). We do 7998238106Sdes # this by putting the import library name into $newdlprefiles. 7999238106Sdes # We recover the dlopen module name by 'saving' the la file 8000238106Sdes # name in a special purpose variable, and (later) extracting the 8001238106Sdes # dlname from the la file. 8002238106Sdes if test -n "$dlname"; then 8003238106Sdes func_tr_sh "$dir/$linklib" 8004238106Sdes eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8005238106Sdes func_append newdlprefiles " $dir/$linklib" 8006238106Sdes else 8007238106Sdes func_append newdlprefiles " $dir/$old_library" 8008238106Sdes # Keep a list of preopened convenience libraries to check 8009238106Sdes # that they are being used correctly in the link pass. 8010238106Sdes test -z "$libdir" && \ 8011238106Sdes func_append dlpreconveniencelibs " $dir/$old_library" 8012238106Sdes fi 8013238106Sdes ;; 8014238106Sdes * ) 8015238106Sdes # Prefer using a static library (so that no silly _DYNAMIC symbols 8016238106Sdes # are required to link). 8017238106Sdes if test -n "$old_library"; then 8018238106Sdes func_append newdlprefiles " $dir/$old_library" 8019238106Sdes # Keep a list of preopened convenience libraries to check 8020238106Sdes # that they are being used correctly in the link pass. 8021238106Sdes test -z "$libdir" && \ 8022238106Sdes func_append dlpreconveniencelibs " $dir/$old_library" 8023238106Sdes # Otherwise, use the dlname, so that lt_dlopen finds it. 8024238106Sdes elif test -n "$dlname"; then 8025238106Sdes func_append newdlprefiles " $dir/$dlname" 8026238106Sdes else 8027238106Sdes func_append newdlprefiles " $dir/$linklib" 8028238106Sdes fi 8029238106Sdes ;; 8030238106Sdes esac 8031238106Sdes fi # $pass = dlpreopen 8032238106Sdes 8033238106Sdes if test -z "$libdir"; then 8034238106Sdes # Link the convenience library 8035296415Sdes if test lib = "$linkmode"; then 8036238106Sdes deplibs="$dir/$old_library $deplibs" 8037296415Sdes elif test prog,link = "$linkmode,$pass"; then 8038238106Sdes compile_deplibs="$dir/$old_library $compile_deplibs" 8039238106Sdes finalize_deplibs="$dir/$old_library $finalize_deplibs" 8040238106Sdes else 8041238106Sdes deplibs="$lib $deplibs" # used for prog,scan pass 8042238106Sdes fi 8043238106Sdes continue 8044238106Sdes fi 8045238106Sdes 8046238106Sdes 8047296415Sdes if test prog = "$linkmode" && test link != "$pass"; then 8048238106Sdes func_append newlib_search_path " $ladir" 8049238106Sdes deplibs="$lib $deplibs" 8050238106Sdes 8051296415Sdes linkalldeplibs=false 8052296415Sdes if test no != "$link_all_deplibs" || test -z "$library_names" || 8053296415Sdes test no = "$build_libtool_libs"; then 8054296415Sdes linkalldeplibs=: 8055238106Sdes fi 8056238106Sdes 8057238106Sdes tmp_libs= 8058238106Sdes for deplib in $dependency_libs; do 8059238106Sdes case $deplib in 8060238106Sdes -L*) func_stripname '-L' '' "$deplib" 8061238106Sdes func_resolve_sysroot "$func_stripname_result" 8062238106Sdes func_append newlib_search_path " $func_resolve_sysroot_result" 8063238106Sdes ;; 8064238106Sdes esac 8065238106Sdes # Need to link against all dependency_libs? 8066296415Sdes if $linkalldeplibs; then 8067238106Sdes deplibs="$deplib $deplibs" 8068238106Sdes else 8069238106Sdes # Need to hardcode shared library paths 8070238106Sdes # or/and link against static libraries 8071238106Sdes newdependency_libs="$deplib $newdependency_libs" 8072238106Sdes fi 8073296415Sdes if $opt_preserve_dup_deps; then 8074238106Sdes case "$tmp_libs " in 8075238106Sdes *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8076238106Sdes esac 8077238106Sdes fi 8078238106Sdes func_append tmp_libs " $deplib" 8079238106Sdes done # for deplib 8080238106Sdes continue 8081238106Sdes fi # $linkmode = prog... 8082238106Sdes 8083296415Sdes if test prog,link = "$linkmode,$pass"; then 8084238106Sdes if test -n "$library_names" && 8085296415Sdes { { test no = "$prefer_static_libs" || 8086296415Sdes test built,yes = "$prefer_static_libs,$installed"; } || 8087238106Sdes test -z "$old_library"; }; then 8088238106Sdes # We need to hardcode the library path 8089296415Sdes if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8090238106Sdes # Make sure the rpath contains only unique directories. 8091296415Sdes case $temp_rpath: in 8092238106Sdes *"$absdir:"*) ;; 8093238106Sdes *) func_append temp_rpath "$absdir:" ;; 8094238106Sdes esac 8095238106Sdes fi 8096238106Sdes 8097238106Sdes # Hardcode the library path. 8098238106Sdes # Skip directories that are in the system default run-time 8099238106Sdes # search path. 8100238106Sdes case " $sys_lib_dlsearch_path " in 8101238106Sdes *" $absdir "*) ;; 8102238106Sdes *) 8103238106Sdes case "$compile_rpath " in 8104238106Sdes *" $absdir "*) ;; 8105238106Sdes *) func_append compile_rpath " $absdir" ;; 8106238106Sdes esac 8107238106Sdes ;; 8108238106Sdes esac 8109238106Sdes case " $sys_lib_dlsearch_path " in 8110238106Sdes *" $libdir "*) ;; 8111238106Sdes *) 8112238106Sdes case "$finalize_rpath " in 8113238106Sdes *" $libdir "*) ;; 8114238106Sdes *) func_append finalize_rpath " $libdir" ;; 8115238106Sdes esac 8116238106Sdes ;; 8117238106Sdes esac 8118238106Sdes fi # $linkmode,$pass = prog,link... 8119238106Sdes 8120296415Sdes if $alldeplibs && 8121296415Sdes { test pass_all = "$deplibs_check_method" || 8122296415Sdes { test yes = "$build_libtool_libs" && 8123238106Sdes test -n "$library_names"; }; }; then 8124238106Sdes # We only need to search for static libraries 8125238106Sdes continue 8126238106Sdes fi 8127238106Sdes fi 8128238106Sdes 8129238106Sdes link_static=no # Whether the deplib will be linked statically 8130238106Sdes use_static_libs=$prefer_static_libs 8131296415Sdes if test built = "$use_static_libs" && test yes = "$installed"; then 8132238106Sdes use_static_libs=no 8133238106Sdes fi 8134238106Sdes if test -n "$library_names" && 8135296415Sdes { test no = "$use_static_libs" || test -z "$old_library"; }; then 8136238106Sdes case $host in 8137296415Sdes *cygwin* | *mingw* | *cegcc* | *os2*) 8138238106Sdes # No point in relinking DLLs because paths are not encoded 8139238106Sdes func_append notinst_deplibs " $lib" 8140238106Sdes need_relink=no 8141238106Sdes ;; 8142238106Sdes *) 8143296415Sdes if test no = "$installed"; then 8144238106Sdes func_append notinst_deplibs " $lib" 8145238106Sdes need_relink=yes 8146238106Sdes fi 8147238106Sdes ;; 8148238106Sdes esac 8149238106Sdes # This is a shared library 8150238106Sdes 8151238106Sdes # Warn about portability, can't link against -module's on some 8152238106Sdes # systems (darwin). Don't bleat about dlopened modules though! 8153296415Sdes dlopenmodule= 8154238106Sdes for dlpremoduletest in $dlprefiles; do 8155238106Sdes if test "X$dlpremoduletest" = "X$lib"; then 8156296415Sdes dlopenmodule=$dlpremoduletest 8157238106Sdes break 8158238106Sdes fi 8159238106Sdes done 8160296415Sdes if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8161238106Sdes echo 8162296415Sdes if test prog = "$linkmode"; then 8163238106Sdes $ECHO "*** Warning: Linking the executable $output against the loadable module" 8164238106Sdes else 8165238106Sdes $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8166238106Sdes fi 8167238106Sdes $ECHO "*** $linklib is not portable!" 8168238106Sdes fi 8169296415Sdes if test lib = "$linkmode" && 8170296415Sdes test yes = "$hardcode_into_libs"; then 8171238106Sdes # Hardcode the library path. 8172238106Sdes # Skip directories that are in the system default run-time 8173238106Sdes # search path. 8174238106Sdes case " $sys_lib_dlsearch_path " in 8175238106Sdes *" $absdir "*) ;; 8176238106Sdes *) 8177238106Sdes case "$compile_rpath " in 8178238106Sdes *" $absdir "*) ;; 8179238106Sdes *) func_append compile_rpath " $absdir" ;; 8180238106Sdes esac 8181238106Sdes ;; 8182238106Sdes esac 8183238106Sdes case " $sys_lib_dlsearch_path " in 8184238106Sdes *" $libdir "*) ;; 8185238106Sdes *) 8186238106Sdes case "$finalize_rpath " in 8187238106Sdes *" $libdir "*) ;; 8188238106Sdes *) func_append finalize_rpath " $libdir" ;; 8189238106Sdes esac 8190238106Sdes ;; 8191238106Sdes esac 8192238106Sdes fi 8193238106Sdes 8194238106Sdes if test -n "$old_archive_from_expsyms_cmds"; then 8195238106Sdes # figure out the soname 8196238106Sdes set dummy $library_names 8197238106Sdes shift 8198296415Sdes realname=$1 8199238106Sdes shift 8200238106Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 8201238106Sdes # use dlname if we got it. it's perfectly good, no? 8202238106Sdes if test -n "$dlname"; then 8203296415Sdes soname=$dlname 8204238106Sdes elif test -n "$soname_spec"; then 8205238106Sdes # bleh windows 8206238106Sdes case $host in 8207296415Sdes *cygwin* | mingw* | *cegcc* | *os2*) 8208238106Sdes func_arith $current - $age 8209238106Sdes major=$func_arith_result 8210296415Sdes versuffix=-$major 8211238106Sdes ;; 8212238106Sdes esac 8213238106Sdes eval soname=\"$soname_spec\" 8214238106Sdes else 8215296415Sdes soname=$realname 8216238106Sdes fi 8217238106Sdes 8218238106Sdes # Make a new name for the extract_expsyms_cmds to use 8219296415Sdes soroot=$soname 8220238106Sdes func_basename "$soroot" 8221296415Sdes soname=$func_basename_result 8222238106Sdes func_stripname 'lib' '.dll' "$soname" 8223238106Sdes newlib=libimp-$func_stripname_result.a 8224238106Sdes 8225238106Sdes # If the library has no export list, then create one now 8226238106Sdes if test -f "$output_objdir/$soname-def"; then : 8227238106Sdes else 8228296415Sdes func_verbose "extracting exported symbol list from '$soname'" 8229238106Sdes func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8230238106Sdes fi 8231238106Sdes 8232238106Sdes # Create $newlib 8233238106Sdes if test -f "$output_objdir/$newlib"; then :; else 8234296415Sdes func_verbose "generating import library for '$soname'" 8235238106Sdes func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8236238106Sdes fi 8237238106Sdes # make sure the library variables are pointing to the new library 8238238106Sdes dir=$output_objdir 8239238106Sdes linklib=$newlib 8240238106Sdes fi # test -n "$old_archive_from_expsyms_cmds" 8241238106Sdes 8242296415Sdes if test prog = "$linkmode" || test relink != "$opt_mode"; then 8243238106Sdes add_shlibpath= 8244238106Sdes add_dir= 8245238106Sdes add= 8246238106Sdes lib_linked=yes 8247238106Sdes case $hardcode_action in 8248238106Sdes immediate | unsupported) 8249296415Sdes if test no = "$hardcode_direct"; then 8250296415Sdes add=$dir/$linklib 8251238106Sdes case $host in 8252296415Sdes *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8253296415Sdes *-*-sysv4*uw2*) add_dir=-L$dir ;; 8254238106Sdes *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8255296415Sdes *-*-unixware7*) add_dir=-L$dir ;; 8256238106Sdes *-*-darwin* ) 8257296415Sdes # if the lib is a (non-dlopened) module then we cannot 8258238106Sdes # link against it, someone is ignoring the earlier warnings 8259238106Sdes if /usr/bin/file -L $add 2> /dev/null | 8260296415Sdes $GREP ": [^:]* bundle" >/dev/null; then 8261238106Sdes if test "X$dlopenmodule" != "X$lib"; then 8262238106Sdes $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8263296415Sdes if test -z "$old_library"; then 8264238106Sdes echo 8265238106Sdes echo "*** And there doesn't seem to be a static archive available" 8266238106Sdes echo "*** The link will probably fail, sorry" 8267238106Sdes else 8268296415Sdes add=$dir/$old_library 8269238106Sdes fi 8270238106Sdes elif test -n "$old_library"; then 8271296415Sdes add=$dir/$old_library 8272238106Sdes fi 8273238106Sdes fi 8274238106Sdes esac 8275296415Sdes elif test no = "$hardcode_minus_L"; then 8276238106Sdes case $host in 8277296415Sdes *-*-sunos*) add_shlibpath=$dir ;; 8278238106Sdes esac 8279296415Sdes add_dir=-L$dir 8280296415Sdes add=-l$name 8281296415Sdes elif test no = "$hardcode_shlibpath_var"; then 8282296415Sdes add_shlibpath=$dir 8283296415Sdes add=-l$name 8284238106Sdes else 8285238106Sdes lib_linked=no 8286238106Sdes fi 8287238106Sdes ;; 8288238106Sdes relink) 8289296415Sdes if test yes = "$hardcode_direct" && 8290296415Sdes test no = "$hardcode_direct_absolute"; then 8291296415Sdes add=$dir/$linklib 8292296415Sdes elif test yes = "$hardcode_minus_L"; then 8293296415Sdes add_dir=-L$absdir 8294238106Sdes # Try looking first in the location we're being installed to. 8295238106Sdes if test -n "$inst_prefix_dir"; then 8296238106Sdes case $libdir in 8297238106Sdes [\\/]*) 8298238106Sdes func_append add_dir " -L$inst_prefix_dir$libdir" 8299238106Sdes ;; 8300238106Sdes esac 8301238106Sdes fi 8302296415Sdes add=-l$name 8303296415Sdes elif test yes = "$hardcode_shlibpath_var"; then 8304296415Sdes add_shlibpath=$dir 8305296415Sdes add=-l$name 8306238106Sdes else 8307238106Sdes lib_linked=no 8308238106Sdes fi 8309238106Sdes ;; 8310238106Sdes *) lib_linked=no ;; 8311238106Sdes esac 8312238106Sdes 8313296415Sdes if test yes != "$lib_linked"; then 8314238106Sdes func_fatal_configuration "unsupported hardcode properties" 8315238106Sdes fi 8316238106Sdes 8317238106Sdes if test -n "$add_shlibpath"; then 8318238106Sdes case :$compile_shlibpath: in 8319238106Sdes *":$add_shlibpath:"*) ;; 8320238106Sdes *) func_append compile_shlibpath "$add_shlibpath:" ;; 8321238106Sdes esac 8322238106Sdes fi 8323296415Sdes if test prog = "$linkmode"; then 8324238106Sdes test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8325238106Sdes test -n "$add" && compile_deplibs="$add $compile_deplibs" 8326238106Sdes else 8327238106Sdes test -n "$add_dir" && deplibs="$add_dir $deplibs" 8328238106Sdes test -n "$add" && deplibs="$add $deplibs" 8329296415Sdes if test yes != "$hardcode_direct" && 8330296415Sdes test yes != "$hardcode_minus_L" && 8331296415Sdes test yes = "$hardcode_shlibpath_var"; then 8332238106Sdes case :$finalize_shlibpath: in 8333238106Sdes *":$libdir:"*) ;; 8334238106Sdes *) func_append finalize_shlibpath "$libdir:" ;; 8335238106Sdes esac 8336238106Sdes fi 8337238106Sdes fi 8338238106Sdes fi 8339238106Sdes 8340296415Sdes if test prog = "$linkmode" || test relink = "$opt_mode"; then 8341238106Sdes add_shlibpath= 8342238106Sdes add_dir= 8343238106Sdes add= 8344238106Sdes # Finalize command for both is simple: just hardcode it. 8345296415Sdes if test yes = "$hardcode_direct" && 8346296415Sdes test no = "$hardcode_direct_absolute"; then 8347296415Sdes add=$libdir/$linklib 8348296415Sdes elif test yes = "$hardcode_minus_L"; then 8349296415Sdes add_dir=-L$libdir 8350296415Sdes add=-l$name 8351296415Sdes elif test yes = "$hardcode_shlibpath_var"; then 8352238106Sdes case :$finalize_shlibpath: in 8353238106Sdes *":$libdir:"*) ;; 8354238106Sdes *) func_append finalize_shlibpath "$libdir:" ;; 8355238106Sdes esac 8356296415Sdes add=-l$name 8357296415Sdes elif test yes = "$hardcode_automatic"; then 8358238106Sdes if test -n "$inst_prefix_dir" && 8359296415Sdes test -f "$inst_prefix_dir$libdir/$linklib"; then 8360296415Sdes add=$inst_prefix_dir$libdir/$linklib 8361238106Sdes else 8362296415Sdes add=$libdir/$linklib 8363238106Sdes fi 8364238106Sdes else 8365238106Sdes # We cannot seem to hardcode it, guess we'll fake it. 8366296415Sdes add_dir=-L$libdir 8367238106Sdes # Try looking first in the location we're being installed to. 8368238106Sdes if test -n "$inst_prefix_dir"; then 8369238106Sdes case $libdir in 8370238106Sdes [\\/]*) 8371238106Sdes func_append add_dir " -L$inst_prefix_dir$libdir" 8372238106Sdes ;; 8373238106Sdes esac 8374238106Sdes fi 8375296415Sdes add=-l$name 8376238106Sdes fi 8377238106Sdes 8378296415Sdes if test prog = "$linkmode"; then 8379238106Sdes test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8380238106Sdes test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8381238106Sdes else 8382238106Sdes test -n "$add_dir" && deplibs="$add_dir $deplibs" 8383238106Sdes test -n "$add" && deplibs="$add $deplibs" 8384238106Sdes fi 8385238106Sdes fi 8386296415Sdes elif test prog = "$linkmode"; then 8387238106Sdes # Here we assume that one of hardcode_direct or hardcode_minus_L 8388238106Sdes # is not unsupported. This is valid on all known static and 8389238106Sdes # shared platforms. 8390296415Sdes if test unsupported != "$hardcode_direct"; then 8391296415Sdes test -n "$old_library" && linklib=$old_library 8392238106Sdes compile_deplibs="$dir/$linklib $compile_deplibs" 8393238106Sdes finalize_deplibs="$dir/$linklib $finalize_deplibs" 8394238106Sdes else 8395238106Sdes compile_deplibs="-l$name -L$dir $compile_deplibs" 8396238106Sdes finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8397238106Sdes fi 8398296415Sdes elif test yes = "$build_libtool_libs"; then 8399238106Sdes # Not a shared library 8400296415Sdes if test pass_all != "$deplibs_check_method"; then 8401238106Sdes # We're trying link a shared library against a static one 8402238106Sdes # but the system doesn't support it. 8403238106Sdes 8404238106Sdes # Just print a warning and add the library to dependency_libs so 8405238106Sdes # that the program can be linked against the static library. 8406238106Sdes echo 8407296415Sdes $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8408238106Sdes echo "*** I have the capability to make that library automatically link in when" 8409238106Sdes echo "*** you link to this library. But I can only do this if you have a" 8410238106Sdes echo "*** shared version of the library, which you do not appear to have." 8411296415Sdes if test yes = "$module"; then 8412238106Sdes echo "*** But as you try to build a module library, libtool will still create " 8413238106Sdes echo "*** a static module, that should work as long as the dlopening application" 8414238106Sdes echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8415238106Sdes if test -z "$global_symbol_pipe"; then 8416238106Sdes echo 8417238106Sdes echo "*** However, this would only work if libtool was able to extract symbol" 8418296415Sdes echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8419238106Sdes echo "*** not find such a program. So, this module is probably useless." 8420296415Sdes echo "*** 'nm' from GNU binutils and a full rebuild may help." 8421238106Sdes fi 8422296415Sdes if test no = "$build_old_libs"; then 8423238106Sdes build_libtool_libs=module 8424238106Sdes build_old_libs=yes 8425238106Sdes else 8426238106Sdes build_libtool_libs=no 8427238106Sdes fi 8428238106Sdes fi 8429238106Sdes else 8430238106Sdes deplibs="$dir/$old_library $deplibs" 8431238106Sdes link_static=yes 8432238106Sdes fi 8433238106Sdes fi # link shared/static library? 8434238106Sdes 8435296415Sdes if test lib = "$linkmode"; then 8436238106Sdes if test -n "$dependency_libs" && 8437296415Sdes { test yes != "$hardcode_into_libs" || 8438296415Sdes test yes = "$build_old_libs" || 8439296415Sdes test yes = "$link_static"; }; then 8440238106Sdes # Extract -R from dependency_libs 8441238106Sdes temp_deplibs= 8442238106Sdes for libdir in $dependency_libs; do 8443238106Sdes case $libdir in 8444238106Sdes -R*) func_stripname '-R' '' "$libdir" 8445238106Sdes temp_xrpath=$func_stripname_result 8446238106Sdes case " $xrpath " in 8447238106Sdes *" $temp_xrpath "*) ;; 8448238106Sdes *) func_append xrpath " $temp_xrpath";; 8449238106Sdes esac;; 8450238106Sdes *) func_append temp_deplibs " $libdir";; 8451238106Sdes esac 8452238106Sdes done 8453296415Sdes dependency_libs=$temp_deplibs 8454238106Sdes fi 8455238106Sdes 8456238106Sdes func_append newlib_search_path " $absdir" 8457238106Sdes # Link against this library 8458296415Sdes test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8459238106Sdes # ... and its dependency_libs 8460238106Sdes tmp_libs= 8461238106Sdes for deplib in $dependency_libs; do 8462238106Sdes newdependency_libs="$deplib $newdependency_libs" 8463238106Sdes case $deplib in 8464238106Sdes -L*) func_stripname '-L' '' "$deplib" 8465238106Sdes func_resolve_sysroot "$func_stripname_result";; 8466238106Sdes *) func_resolve_sysroot "$deplib" ;; 8467238106Sdes esac 8468296415Sdes if $opt_preserve_dup_deps; then 8469238106Sdes case "$tmp_libs " in 8470238106Sdes *" $func_resolve_sysroot_result "*) 8471238106Sdes func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8472238106Sdes esac 8473238106Sdes fi 8474238106Sdes func_append tmp_libs " $func_resolve_sysroot_result" 8475238106Sdes done 8476238106Sdes 8477296415Sdes if test no != "$link_all_deplibs"; then 8478238106Sdes # Add the search paths of all dependency libraries 8479238106Sdes for deplib in $dependency_libs; do 8480238106Sdes path= 8481238106Sdes case $deplib in 8482296415Sdes -L*) path=$deplib ;; 8483238106Sdes *.la) 8484238106Sdes func_resolve_sysroot "$deplib" 8485238106Sdes deplib=$func_resolve_sysroot_result 8486238106Sdes func_dirname "$deplib" "" "." 8487238106Sdes dir=$func_dirname_result 8488238106Sdes # We need an absolute path. 8489238106Sdes case $dir in 8490296415Sdes [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8491238106Sdes *) 8492238106Sdes absdir=`cd "$dir" && pwd` 8493238106Sdes if test -z "$absdir"; then 8494296415Sdes func_warning "cannot determine absolute directory name of '$dir'" 8495296415Sdes absdir=$dir 8496238106Sdes fi 8497238106Sdes ;; 8498238106Sdes esac 8499238106Sdes if $GREP "^installed=no" $deplib > /dev/null; then 8500238106Sdes case $host in 8501238106Sdes *-*-darwin*) 8502238106Sdes depdepl= 8503296415Sdes eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8504296415Sdes if test -n "$deplibrary_names"; then 8505296415Sdes for tmp in $deplibrary_names; do 8506238106Sdes depdepl=$tmp 8507238106Sdes done 8508296415Sdes if test -f "$absdir/$objdir/$depdepl"; then 8509296415Sdes depdepl=$absdir/$objdir/$depdepl 8510296415Sdes darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511238106Sdes if test -z "$darwin_install_name"; then 8512296415Sdes darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8513238106Sdes fi 8514296415Sdes func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8515296415Sdes func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8516238106Sdes path= 8517238106Sdes fi 8518238106Sdes fi 8519238106Sdes ;; 8520238106Sdes *) 8521296415Sdes path=-L$absdir/$objdir 8522238106Sdes ;; 8523238106Sdes esac 8524238106Sdes else 8525296415Sdes eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8526238106Sdes test -z "$libdir" && \ 8527296415Sdes func_fatal_error "'$deplib' is not a valid libtool archive" 8528238106Sdes test "$absdir" != "$libdir" && \ 8529296415Sdes func_warning "'$deplib' seems to be moved" 8530238106Sdes 8531296415Sdes path=-L$absdir 8532238106Sdes fi 8533238106Sdes ;; 8534238106Sdes esac 8535238106Sdes case " $deplibs " in 8536238106Sdes *" $path "*) ;; 8537238106Sdes *) deplibs="$path $deplibs" ;; 8538238106Sdes esac 8539238106Sdes done 8540238106Sdes fi # link_all_deplibs != no 8541238106Sdes fi # linkmode = lib 8542238106Sdes done # for deplib in $libs 8543296415Sdes if test link = "$pass"; then 8544296415Sdes if test prog = "$linkmode"; then 8545238106Sdes compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8546238106Sdes finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8547238106Sdes else 8548238106Sdes compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8549238106Sdes fi 8550238106Sdes fi 8551296415Sdes dependency_libs=$newdependency_libs 8552296415Sdes if test dlpreopen = "$pass"; then 8553238106Sdes # Link the dlpreopened libraries before other libraries 8554238106Sdes for deplib in $save_deplibs; do 8555238106Sdes deplibs="$deplib $deplibs" 8556238106Sdes done 8557238106Sdes fi 8558296415Sdes if test dlopen != "$pass"; then 8559296415Sdes test conv = "$pass" || { 8560238106Sdes # Make sure lib_search_path contains only unique directories. 8561238106Sdes lib_search_path= 8562238106Sdes for dir in $newlib_search_path; do 8563238106Sdes case "$lib_search_path " in 8564238106Sdes *" $dir "*) ;; 8565238106Sdes *) func_append lib_search_path " $dir" ;; 8566238106Sdes esac 8567238106Sdes done 8568238106Sdes newlib_search_path= 8569296415Sdes } 8570238106Sdes 8571296415Sdes if test prog,link = "$linkmode,$pass"; then 8572296415Sdes vars="compile_deplibs finalize_deplibs" 8573238106Sdes else 8574296415Sdes vars=deplibs 8575238106Sdes fi 8576238106Sdes for var in $vars dependency_libs; do 8577238106Sdes # Add libraries to $var in reverse order 8578238106Sdes eval tmp_libs=\"\$$var\" 8579238106Sdes new_libs= 8580238106Sdes for deplib in $tmp_libs; do 8581238106Sdes # FIXME: Pedantically, this is the right thing to do, so 8582238106Sdes # that some nasty dependency loop isn't accidentally 8583238106Sdes # broken: 8584238106Sdes #new_libs="$deplib $new_libs" 8585238106Sdes # Pragmatically, this seems to cause very few problems in 8586238106Sdes # practice: 8587238106Sdes case $deplib in 8588238106Sdes -L*) new_libs="$deplib $new_libs" ;; 8589238106Sdes -R*) ;; 8590238106Sdes *) 8591238106Sdes # And here is the reason: when a library appears more 8592238106Sdes # than once as an explicit dependence of a library, or 8593238106Sdes # is implicitly linked in more than once by the 8594238106Sdes # compiler, it is considered special, and multiple 8595238106Sdes # occurrences thereof are not removed. Compare this 8596238106Sdes # with having the same library being listed as a 8597238106Sdes # dependency of multiple other libraries: in this case, 8598238106Sdes # we know (pedantically, we assume) the library does not 8599238106Sdes # need to be listed more than once, so we keep only the 8600238106Sdes # last copy. This is not always right, but it is rare 8601238106Sdes # enough that we require users that really mean to play 8602238106Sdes # such unportable linking tricks to link the library 8603238106Sdes # using -Wl,-lname, so that libtool does not consider it 8604238106Sdes # for duplicate removal. 8605238106Sdes case " $specialdeplibs " in 8606238106Sdes *" $deplib "*) new_libs="$deplib $new_libs" ;; 8607238106Sdes *) 8608238106Sdes case " $new_libs " in 8609238106Sdes *" $deplib "*) ;; 8610238106Sdes *) new_libs="$deplib $new_libs" ;; 8611238106Sdes esac 8612238106Sdes ;; 8613238106Sdes esac 8614238106Sdes ;; 8615238106Sdes esac 8616238106Sdes done 8617238106Sdes tmp_libs= 8618238106Sdes for deplib in $new_libs; do 8619238106Sdes case $deplib in 8620238106Sdes -L*) 8621238106Sdes case " $tmp_libs " in 8622238106Sdes *" $deplib "*) ;; 8623238106Sdes *) func_append tmp_libs " $deplib" ;; 8624238106Sdes esac 8625238106Sdes ;; 8626238106Sdes *) func_append tmp_libs " $deplib" ;; 8627238106Sdes esac 8628238106Sdes done 8629238106Sdes eval $var=\"$tmp_libs\" 8630238106Sdes done # for var 8631238106Sdes fi 8632296415Sdes 8633296415Sdes # Add Sun CC postdeps if required: 8634296415Sdes test CXX = "$tagname" && { 8635296415Sdes case $host_os in 8636296415Sdes linux*) 8637296415Sdes case `$CC -V 2>&1 | sed 5q` in 8638296415Sdes *Sun\ C*) # Sun C++ 5.9 8639296415Sdes func_suncc_cstd_abi 8640296415Sdes 8641296415Sdes if test no != "$suncc_use_cstd_abi"; then 8642296415Sdes func_append postdeps ' -library=Cstd -library=Crun' 8643296415Sdes fi 8644296415Sdes ;; 8645296415Sdes esac 8646296415Sdes ;; 8647296415Sdes 8648296415Sdes solaris*) 8649296415Sdes func_cc_basename "$CC" 8650296415Sdes case $func_cc_basename_result in 8651296415Sdes CC* | sunCC*) 8652296415Sdes func_suncc_cstd_abi 8653296415Sdes 8654296415Sdes if test no != "$suncc_use_cstd_abi"; then 8655296415Sdes func_append postdeps ' -library=Cstd -library=Crun' 8656296415Sdes fi 8657296415Sdes ;; 8658296415Sdes esac 8659296415Sdes ;; 8660296415Sdes esac 8661296415Sdes } 8662296415Sdes 8663238106Sdes # Last step: remove runtime libs from dependency_libs 8664238106Sdes # (they stay in deplibs) 8665238106Sdes tmp_libs= 8666296415Sdes for i in $dependency_libs; do 8667238106Sdes case " $predeps $postdeps $compiler_lib_search_path " in 8668238106Sdes *" $i "*) 8669296415Sdes i= 8670238106Sdes ;; 8671238106Sdes esac 8672296415Sdes if test -n "$i"; then 8673238106Sdes func_append tmp_libs " $i" 8674238106Sdes fi 8675238106Sdes done 8676238106Sdes dependency_libs=$tmp_libs 8677238106Sdes done # for pass 8678296415Sdes if test prog = "$linkmode"; then 8679296415Sdes dlfiles=$newdlfiles 8680238106Sdes fi 8681296415Sdes if test prog = "$linkmode" || test lib = "$linkmode"; then 8682296415Sdes dlprefiles=$newdlprefiles 8683238106Sdes fi 8684238106Sdes 8685238106Sdes case $linkmode in 8686238106Sdes oldlib) 8687296415Sdes if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8688296415Sdes func_warning "'-dlopen' is ignored for archives" 8689238106Sdes fi 8690238106Sdes 8691238106Sdes case " $deplibs" in 8692238106Sdes *\ -l* | *\ -L*) 8693296415Sdes func_warning "'-l' and '-L' are ignored for archives" ;; 8694238106Sdes esac 8695238106Sdes 8696238106Sdes test -n "$rpath" && \ 8697296415Sdes func_warning "'-rpath' is ignored for archives" 8698238106Sdes 8699238106Sdes test -n "$xrpath" && \ 8700296415Sdes func_warning "'-R' is ignored for archives" 8701238106Sdes 8702238106Sdes test -n "$vinfo" && \ 8703296415Sdes func_warning "'-version-info/-version-number' is ignored for archives" 8704238106Sdes 8705238106Sdes test -n "$release" && \ 8706296415Sdes func_warning "'-release' is ignored for archives" 8707238106Sdes 8708238106Sdes test -n "$export_symbols$export_symbols_regex" && \ 8709296415Sdes func_warning "'-export-symbols' is ignored for archives" 8710238106Sdes 8711238106Sdes # Now set the variables for building old libraries. 8712238106Sdes build_libtool_libs=no 8713296415Sdes oldlibs=$output 8714238106Sdes func_append objs "$old_deplibs" 8715238106Sdes ;; 8716238106Sdes 8717238106Sdes lib) 8718296415Sdes # Make sure we only generate libraries of the form 'libNAME.la'. 8719238106Sdes case $outputname in 8720238106Sdes lib*) 8721238106Sdes func_stripname 'lib' '.la' "$outputname" 8722238106Sdes name=$func_stripname_result 8723238106Sdes eval shared_ext=\"$shrext_cmds\" 8724238106Sdes eval libname=\"$libname_spec\" 8725238106Sdes ;; 8726238106Sdes *) 8727296415Sdes test no = "$module" \ 8728296415Sdes && func_fatal_help "libtool library '$output' must begin with 'lib'" 8729238106Sdes 8730296415Sdes if test no != "$need_lib_prefix"; then 8731238106Sdes # Add the "lib" prefix for modules if required 8732238106Sdes func_stripname '' '.la' "$outputname" 8733238106Sdes name=$func_stripname_result 8734238106Sdes eval shared_ext=\"$shrext_cmds\" 8735238106Sdes eval libname=\"$libname_spec\" 8736238106Sdes else 8737238106Sdes func_stripname '' '.la' "$outputname" 8738238106Sdes libname=$func_stripname_result 8739238106Sdes fi 8740238106Sdes ;; 8741238106Sdes esac 8742238106Sdes 8743238106Sdes if test -n "$objs"; then 8744296415Sdes if test pass_all != "$deplibs_check_method"; then 8745296415Sdes func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8746238106Sdes else 8747238106Sdes echo 8748238106Sdes $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8749238106Sdes $ECHO "*** objects $objs is not portable!" 8750238106Sdes func_append libobjs " $objs" 8751238106Sdes fi 8752238106Sdes fi 8753238106Sdes 8754296415Sdes test no = "$dlself" \ 8755296415Sdes || func_warning "'-dlopen self' is ignored for libtool libraries" 8756238106Sdes 8757238106Sdes set dummy $rpath 8758238106Sdes shift 8759296415Sdes test 1 -lt "$#" \ 8760296415Sdes && func_warning "ignoring multiple '-rpath's for a libtool library" 8761238106Sdes 8762296415Sdes install_libdir=$1 8763238106Sdes 8764238106Sdes oldlibs= 8765238106Sdes if test -z "$rpath"; then 8766296415Sdes if test yes = "$build_libtool_libs"; then 8767238106Sdes # Building a libtool convenience library. 8768296415Sdes # Some compilers have problems with a '.al' extension so 8769238106Sdes # convenience libraries should have the same extension an 8770238106Sdes # archive normally would. 8771238106Sdes oldlibs="$output_objdir/$libname.$libext $oldlibs" 8772238106Sdes build_libtool_libs=convenience 8773238106Sdes build_old_libs=yes 8774238106Sdes fi 8775238106Sdes 8776238106Sdes test -n "$vinfo" && \ 8777296415Sdes func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8778238106Sdes 8779238106Sdes test -n "$release" && \ 8780296415Sdes func_warning "'-release' is ignored for convenience libraries" 8781238106Sdes else 8782238106Sdes 8783238106Sdes # Parse the version information argument. 8784296415Sdes save_ifs=$IFS; IFS=: 8785238106Sdes set dummy $vinfo 0 0 0 8786238106Sdes shift 8787296415Sdes IFS=$save_ifs 8788238106Sdes 8789238106Sdes test -n "$7" && \ 8790296415Sdes func_fatal_help "too many parameters to '-version-info'" 8791238106Sdes 8792238106Sdes # convert absolute version numbers to libtool ages 8793238106Sdes # this retains compatibility with .la files and attempts 8794238106Sdes # to make the code below a bit more comprehensible 8795238106Sdes 8796238106Sdes case $vinfo_number in 8797238106Sdes yes) 8798296415Sdes number_major=$1 8799296415Sdes number_minor=$2 8800296415Sdes number_revision=$3 8801238106Sdes # 8802238106Sdes # There are really only two kinds -- those that 8803238106Sdes # use the current revision as the major version 8804238106Sdes # and those that subtract age and use age as 8805238106Sdes # a minor version. But, then there is irix 8806296415Sdes # that has an extra 1 added just for fun 8807238106Sdes # 8808238106Sdes case $version_type in 8809249141Sdes # correct linux to gnu/linux during the next big refactor 8810296415Sdes darwin|freebsd-elf|linux|osf|windows|none) 8811238106Sdes func_arith $number_major + $number_minor 8812238106Sdes current=$func_arith_result 8813296415Sdes age=$number_minor 8814296415Sdes revision=$number_revision 8815238106Sdes ;; 8816296415Sdes freebsd-aout|qnx|sunos) 8817296415Sdes current=$number_major 8818296415Sdes revision=$number_minor 8819296415Sdes age=0 8820238106Sdes ;; 8821238106Sdes irix|nonstopux) 8822238106Sdes func_arith $number_major + $number_minor 8823238106Sdes current=$func_arith_result 8824296415Sdes age=$number_minor 8825296415Sdes revision=$number_minor 8826238106Sdes lt_irix_increment=no 8827238106Sdes ;; 8828238106Sdes esac 8829238106Sdes ;; 8830238106Sdes no) 8831296415Sdes current=$1 8832296415Sdes revision=$2 8833296415Sdes age=$3 8834238106Sdes ;; 8835238106Sdes esac 8836238106Sdes 8837238106Sdes # Check that each of the things are valid numbers. 8838238106Sdes case $current in 8839238106Sdes 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]) ;; 8840238106Sdes *) 8841296415Sdes func_error "CURRENT '$current' must be a nonnegative integer" 8842296415Sdes func_fatal_error "'$vinfo' is not valid version information" 8843238106Sdes ;; 8844238106Sdes esac 8845238106Sdes 8846238106Sdes case $revision in 8847238106Sdes 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]) ;; 8848238106Sdes *) 8849296415Sdes func_error "REVISION '$revision' must be a nonnegative integer" 8850296415Sdes func_fatal_error "'$vinfo' is not valid version information" 8851238106Sdes ;; 8852238106Sdes esac 8853238106Sdes 8854238106Sdes case $age in 8855238106Sdes 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]) ;; 8856238106Sdes *) 8857296415Sdes func_error "AGE '$age' must be a nonnegative integer" 8858296415Sdes func_fatal_error "'$vinfo' is not valid version information" 8859238106Sdes ;; 8860238106Sdes esac 8861238106Sdes 8862238106Sdes if test "$age" -gt "$current"; then 8863296415Sdes func_error "AGE '$age' is greater than the current interface number '$current'" 8864296415Sdes func_fatal_error "'$vinfo' is not valid version information" 8865238106Sdes fi 8866238106Sdes 8867238106Sdes # Calculate the version variables. 8868238106Sdes major= 8869238106Sdes versuffix= 8870238106Sdes verstring= 8871238106Sdes case $version_type in 8872238106Sdes none) ;; 8873238106Sdes 8874238106Sdes darwin) 8875238106Sdes # Like Linux, but with the current version available in 8876238106Sdes # verstring for coding it into the library header 8877238106Sdes func_arith $current - $age 8878238106Sdes major=.$func_arith_result 8879296415Sdes versuffix=$major.$age.$revision 8880238106Sdes # Darwin ld doesn't like 0 for these options... 8881238106Sdes func_arith $current + 1 8882238106Sdes minor_current=$func_arith_result 8883296415Sdes xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8884238106Sdes verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8885296415Sdes # On Darwin other compilers 8886296415Sdes case $CC in 8887296415Sdes nagfor*) 8888296415Sdes verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8889296415Sdes ;; 8890296415Sdes *) 8891296415Sdes verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8892296415Sdes ;; 8893296415Sdes esac 8894238106Sdes ;; 8895238106Sdes 8896238106Sdes freebsd-aout) 8897296415Sdes major=.$current 8898296415Sdes versuffix=.$current.$revision 8899238106Sdes ;; 8900238106Sdes 8901238106Sdes freebsd-elf) 8902296415Sdes func_arith $current - $age 8903296415Sdes major=.$func_arith_result 8904296415Sdes versuffix=$major.$age.$revision 8905238106Sdes ;; 8906238106Sdes 8907238106Sdes irix | nonstopux) 8908296415Sdes if test no = "$lt_irix_increment"; then 8909238106Sdes func_arith $current - $age 8910238106Sdes else 8911238106Sdes func_arith $current - $age + 1 8912238106Sdes fi 8913238106Sdes major=$func_arith_result 8914238106Sdes 8915238106Sdes case $version_type in 8916238106Sdes nonstopux) verstring_prefix=nonstopux ;; 8917238106Sdes *) verstring_prefix=sgi ;; 8918238106Sdes esac 8919296415Sdes verstring=$verstring_prefix$major.$revision 8920238106Sdes 8921238106Sdes # Add in all the interfaces that we are compatible with. 8922238106Sdes loop=$revision 8923296415Sdes while test 0 -ne "$loop"; do 8924238106Sdes func_arith $revision - $loop 8925238106Sdes iface=$func_arith_result 8926238106Sdes func_arith $loop - 1 8927238106Sdes loop=$func_arith_result 8928296415Sdes verstring=$verstring_prefix$major.$iface:$verstring 8929238106Sdes done 8930238106Sdes 8931296415Sdes # Before this point, $major must not contain '.'. 8932238106Sdes major=.$major 8933296415Sdes versuffix=$major.$revision 8934238106Sdes ;; 8935238106Sdes 8936249141Sdes linux) # correct to gnu/linux during the next big refactor 8937238106Sdes func_arith $current - $age 8938238106Sdes major=.$func_arith_result 8939296415Sdes versuffix=$major.$age.$revision 8940238106Sdes ;; 8941238106Sdes 8942238106Sdes osf) 8943238106Sdes func_arith $current - $age 8944238106Sdes major=.$func_arith_result 8945296415Sdes versuffix=.$current.$age.$revision 8946296415Sdes verstring=$current.$age.$revision 8947238106Sdes 8948238106Sdes # Add in all the interfaces that we are compatible with. 8949238106Sdes loop=$age 8950296415Sdes while test 0 -ne "$loop"; do 8951238106Sdes func_arith $current - $loop 8952238106Sdes iface=$func_arith_result 8953238106Sdes func_arith $loop - 1 8954238106Sdes loop=$func_arith_result 8955296415Sdes verstring=$verstring:$iface.0 8956238106Sdes done 8957238106Sdes 8958238106Sdes # Make executables depend on our current version. 8959296415Sdes func_append verstring ":$current.0" 8960238106Sdes ;; 8961238106Sdes 8962238106Sdes qnx) 8963296415Sdes major=.$current 8964296415Sdes versuffix=.$current 8965238106Sdes ;; 8966238106Sdes 8967296415Sdes sco) 8968296415Sdes major=.$current 8969296415Sdes versuffix=.$current 8970296415Sdes ;; 8971296415Sdes 8972238106Sdes sunos) 8973296415Sdes major=.$current 8974296415Sdes versuffix=.$current.$revision 8975238106Sdes ;; 8976238106Sdes 8977238106Sdes windows) 8978238106Sdes # Use '-' rather than '.', since we only want one 8979296415Sdes # extension on DOS 8.3 file systems. 8980238106Sdes func_arith $current - $age 8981238106Sdes major=$func_arith_result 8982296415Sdes versuffix=-$major 8983238106Sdes ;; 8984238106Sdes 8985238106Sdes *) 8986296415Sdes func_fatal_configuration "unknown library version type '$version_type'" 8987238106Sdes ;; 8988238106Sdes esac 8989238106Sdes 8990238106Sdes # Clear the version info if we defaulted, and they specified a release. 8991238106Sdes if test -z "$vinfo" && test -n "$release"; then 8992238106Sdes major= 8993238106Sdes case $version_type in 8994238106Sdes darwin) 8995238106Sdes # we can't check for "0.0" in archive_cmds due to quoting 8996238106Sdes # problems, so we reset it completely 8997238106Sdes verstring= 8998238106Sdes ;; 8999238106Sdes *) 9000296415Sdes verstring=0.0 9001238106Sdes ;; 9002238106Sdes esac 9003296415Sdes if test no = "$need_version"; then 9004238106Sdes versuffix= 9005238106Sdes else 9006296415Sdes versuffix=.0.0 9007238106Sdes fi 9008238106Sdes fi 9009238106Sdes 9010238106Sdes # Remove version info from name if versioning should be avoided 9011296415Sdes if test yes,no = "$avoid_version,$need_version"; then 9012238106Sdes major= 9013238106Sdes versuffix= 9014296415Sdes verstring= 9015238106Sdes fi 9016238106Sdes 9017238106Sdes # Check to see if the archive will have undefined symbols. 9018296415Sdes if test yes = "$allow_undefined"; then 9019296415Sdes if test unsupported = "$allow_undefined_flag"; then 9020296415Sdes if test yes = "$build_old_libs"; then 9021296415Sdes func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9022296415Sdes build_libtool_libs=no 9023296415Sdes else 9024296415Sdes func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9025296415Sdes fi 9026238106Sdes fi 9027238106Sdes else 9028238106Sdes # Don't allow undefined symbols. 9029296415Sdes allow_undefined_flag=$no_undefined_flag 9030238106Sdes fi 9031238106Sdes 9032238106Sdes fi 9033238106Sdes 9034296415Sdes func_generate_dlsyms "$libname" "$libname" : 9035238106Sdes func_append libobjs " $symfileobj" 9036296415Sdes test " " = "$libobjs" && libobjs= 9037238106Sdes 9038296415Sdes if test relink != "$opt_mode"; then 9039238106Sdes # Remove our outputs, but don't remove object files since they 9040238106Sdes # may have been created when compiling PIC objects. 9041238106Sdes removelist= 9042238106Sdes tempremovelist=`$ECHO "$output_objdir/*"` 9043238106Sdes for p in $tempremovelist; do 9044238106Sdes case $p in 9045238106Sdes *.$objext | *.gcno) 9046238106Sdes ;; 9047296415Sdes $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9048296415Sdes if test -n "$precious_files_regex"; then 9049238106Sdes if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9050238106Sdes then 9051238106Sdes continue 9052238106Sdes fi 9053238106Sdes fi 9054238106Sdes func_append removelist " $p" 9055238106Sdes ;; 9056238106Sdes *) ;; 9057238106Sdes esac 9058238106Sdes done 9059238106Sdes test -n "$removelist" && \ 9060238106Sdes func_show_eval "${RM}r \$removelist" 9061238106Sdes fi 9062238106Sdes 9063238106Sdes # Now set the variables for building old libraries. 9064296415Sdes if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9065238106Sdes func_append oldlibs " $output_objdir/$libname.$libext" 9066238106Sdes 9067238106Sdes # Transform .lo files to .o files. 9068296415Sdes oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9069238106Sdes fi 9070238106Sdes 9071238106Sdes # Eliminate all temporary directories. 9072238106Sdes #for path in $notinst_path; do 9073238106Sdes # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9074238106Sdes # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9075238106Sdes # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9076238106Sdes #done 9077238106Sdes 9078238106Sdes if test -n "$xrpath"; then 9079238106Sdes # If the user specified any rpath flags, then add them. 9080238106Sdes temp_xrpath= 9081238106Sdes for libdir in $xrpath; do 9082238106Sdes func_replace_sysroot "$libdir" 9083238106Sdes func_append temp_xrpath " -R$func_replace_sysroot_result" 9084238106Sdes case "$finalize_rpath " in 9085238106Sdes *" $libdir "*) ;; 9086238106Sdes *) func_append finalize_rpath " $libdir" ;; 9087238106Sdes esac 9088238106Sdes done 9089296415Sdes if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9090238106Sdes dependency_libs="$temp_xrpath $dependency_libs" 9091238106Sdes fi 9092238106Sdes fi 9093238106Sdes 9094238106Sdes # Make sure dlfiles contains only unique files that won't be dlpreopened 9095296415Sdes old_dlfiles=$dlfiles 9096238106Sdes dlfiles= 9097238106Sdes for lib in $old_dlfiles; do 9098238106Sdes case " $dlprefiles $dlfiles " in 9099238106Sdes *" $lib "*) ;; 9100238106Sdes *) func_append dlfiles " $lib" ;; 9101238106Sdes esac 9102238106Sdes done 9103238106Sdes 9104238106Sdes # Make sure dlprefiles contains only unique files 9105296415Sdes old_dlprefiles=$dlprefiles 9106238106Sdes dlprefiles= 9107238106Sdes for lib in $old_dlprefiles; do 9108238106Sdes case "$dlprefiles " in 9109238106Sdes *" $lib "*) ;; 9110238106Sdes *) func_append dlprefiles " $lib" ;; 9111238106Sdes esac 9112238106Sdes done 9113238106Sdes 9114296415Sdes if test yes = "$build_libtool_libs"; then 9115238106Sdes if test -n "$rpath"; then 9116238106Sdes case $host in 9117238106Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9118238106Sdes # these systems don't actually have a c library (as such)! 9119238106Sdes ;; 9120238106Sdes *-*-rhapsody* | *-*-darwin1.[012]) 9121238106Sdes # Rhapsody C library is in the System framework 9122238106Sdes func_append deplibs " System.ltframework" 9123238106Sdes ;; 9124238106Sdes *-*-netbsd*) 9125238106Sdes # Don't link with libc until the a.out ld.so is fixed. 9126238106Sdes ;; 9127238106Sdes *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9128238106Sdes # Do not include libc due to us having libc/libc_r. 9129238106Sdes ;; 9130238106Sdes *-*-sco3.2v5* | *-*-sco5v6*) 9131238106Sdes # Causes problems with __ctype 9132238106Sdes ;; 9133238106Sdes *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9134238106Sdes # Compiler inserts libc in the correct place for threads to work 9135238106Sdes ;; 9136238106Sdes *) 9137238106Sdes # Add libc to deplibs on all other systems if necessary. 9138296415Sdes if test yes = "$build_libtool_need_lc"; then 9139238106Sdes func_append deplibs " -lc" 9140238106Sdes fi 9141238106Sdes ;; 9142238106Sdes esac 9143238106Sdes fi 9144238106Sdes 9145238106Sdes # Transform deplibs into only deplibs that can be linked in shared. 9146238106Sdes name_save=$name 9147238106Sdes libname_save=$libname 9148238106Sdes release_save=$release 9149238106Sdes versuffix_save=$versuffix 9150238106Sdes major_save=$major 9151238106Sdes # I'm not sure if I'm treating the release correctly. I think 9152238106Sdes # release should show up in the -l (ie -lgmp5) so we don't want to 9153238106Sdes # add it in twice. Is that correct? 9154296415Sdes release= 9155296415Sdes versuffix= 9156296415Sdes major= 9157238106Sdes newdeplibs= 9158238106Sdes droppeddeps=no 9159238106Sdes case $deplibs_check_method in 9160238106Sdes pass_all) 9161238106Sdes # Don't check for shared/static. Everything works. 9162238106Sdes # This might be a little naive. We might want to check 9163238106Sdes # whether the library exists or not. But this is on 9164238106Sdes # osf3 & osf4 and I'm not really sure... Just 9165238106Sdes # implementing what was already the behavior. 9166238106Sdes newdeplibs=$deplibs 9167238106Sdes ;; 9168238106Sdes test_compile) 9169238106Sdes # This code stresses the "libraries are programs" paradigm to its 9170238106Sdes # limits. Maybe even breaks it. We compile a program, linking it 9171238106Sdes # against the deplibs as a proxy for the library. Then we can check 9172238106Sdes # whether they linked in statically or dynamically with ldd. 9173238106Sdes $opt_dry_run || $RM conftest.c 9174238106Sdes cat > conftest.c <<EOF 9175238106Sdes int main() { return 0; } 9176238106SdesEOF 9177238106Sdes $opt_dry_run || $RM conftest 9178238106Sdes if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9179238106Sdes ldd_output=`ldd conftest` 9180238106Sdes for i in $deplibs; do 9181238106Sdes case $i in 9182238106Sdes -l*) 9183238106Sdes func_stripname -l '' "$i" 9184238106Sdes name=$func_stripname_result 9185296415Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9186238106Sdes case " $predeps $postdeps " in 9187238106Sdes *" $i "*) 9188238106Sdes func_append newdeplibs " $i" 9189296415Sdes i= 9190238106Sdes ;; 9191238106Sdes esac 9192238106Sdes fi 9193296415Sdes if test -n "$i"; then 9194238106Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 9195238106Sdes deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9196238106Sdes set dummy $deplib_matches; shift 9197238106Sdes deplib_match=$1 9198296415Sdes if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9199238106Sdes func_append newdeplibs " $i" 9200238106Sdes else 9201238106Sdes droppeddeps=yes 9202238106Sdes echo 9203238106Sdes $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9204238106Sdes echo "*** I have the capability to make that library automatically link in when" 9205238106Sdes echo "*** you link to this library. But I can only do this if you have a" 9206238106Sdes echo "*** shared version of the library, which I believe you do not have" 9207238106Sdes echo "*** because a test_compile did reveal that the linker did not use it for" 9208238106Sdes echo "*** its dynamic dependency list that programs get resolved with at runtime." 9209238106Sdes fi 9210238106Sdes fi 9211238106Sdes ;; 9212238106Sdes *) 9213238106Sdes func_append newdeplibs " $i" 9214238106Sdes ;; 9215238106Sdes esac 9216238106Sdes done 9217238106Sdes else 9218238106Sdes # Error occurred in the first compile. Let's try to salvage 9219238106Sdes # the situation: Compile a separate program for each library. 9220238106Sdes for i in $deplibs; do 9221238106Sdes case $i in 9222238106Sdes -l*) 9223238106Sdes func_stripname -l '' "$i" 9224238106Sdes name=$func_stripname_result 9225238106Sdes $opt_dry_run || $RM conftest 9226238106Sdes if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9227238106Sdes ldd_output=`ldd conftest` 9228296415Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9229238106Sdes case " $predeps $postdeps " in 9230238106Sdes *" $i "*) 9231238106Sdes func_append newdeplibs " $i" 9232296415Sdes i= 9233238106Sdes ;; 9234238106Sdes esac 9235238106Sdes fi 9236296415Sdes if test -n "$i"; then 9237238106Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 9238238106Sdes deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9239238106Sdes set dummy $deplib_matches; shift 9240238106Sdes deplib_match=$1 9241296415Sdes if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9242238106Sdes func_append newdeplibs " $i" 9243238106Sdes else 9244238106Sdes droppeddeps=yes 9245238106Sdes echo 9246238106Sdes $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9247238106Sdes echo "*** I have the capability to make that library automatically link in when" 9248238106Sdes echo "*** you link to this library. But I can only do this if you have a" 9249238106Sdes echo "*** shared version of the library, which you do not appear to have" 9250238106Sdes echo "*** because a test_compile did reveal that the linker did not use this one" 9251238106Sdes echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9252238106Sdes fi 9253238106Sdes fi 9254238106Sdes else 9255238106Sdes droppeddeps=yes 9256238106Sdes echo 9257238106Sdes $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9258238106Sdes echo "*** make it link in! You will probably need to install it or some" 9259238106Sdes echo "*** library that it depends on before this library will be fully" 9260238106Sdes echo "*** functional. Installing it before continuing would be even better." 9261238106Sdes fi 9262238106Sdes ;; 9263238106Sdes *) 9264238106Sdes func_append newdeplibs " $i" 9265238106Sdes ;; 9266238106Sdes esac 9267238106Sdes done 9268238106Sdes fi 9269238106Sdes ;; 9270238106Sdes file_magic*) 9271238106Sdes set dummy $deplibs_check_method; shift 9272238106Sdes file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9273238106Sdes for a_deplib in $deplibs; do 9274238106Sdes case $a_deplib in 9275238106Sdes -l*) 9276238106Sdes func_stripname -l '' "$a_deplib" 9277238106Sdes name=$func_stripname_result 9278296415Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9279238106Sdes case " $predeps $postdeps " in 9280238106Sdes *" $a_deplib "*) 9281238106Sdes func_append newdeplibs " $a_deplib" 9282296415Sdes a_deplib= 9283238106Sdes ;; 9284238106Sdes esac 9285238106Sdes fi 9286296415Sdes if test -n "$a_deplib"; then 9287238106Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 9288238106Sdes if test -n "$file_magic_glob"; then 9289238106Sdes libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9290238106Sdes else 9291238106Sdes libnameglob=$libname 9292238106Sdes fi 9293296415Sdes test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9294238106Sdes for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9295296415Sdes if test yes = "$want_nocaseglob"; then 9296238106Sdes shopt -s nocaseglob 9297238106Sdes potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9298238106Sdes $nocaseglob 9299238106Sdes else 9300238106Sdes potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9301238106Sdes fi 9302238106Sdes for potent_lib in $potential_libs; do 9303238106Sdes # Follow soft links. 9304238106Sdes if ls -lLd "$potent_lib" 2>/dev/null | 9305238106Sdes $GREP " -> " >/dev/null; then 9306238106Sdes continue 9307238106Sdes fi 9308238106Sdes # The statement above tries to avoid entering an 9309238106Sdes # endless loop below, in case of cyclic links. 9310238106Sdes # We might still enter an endless loop, since a link 9311238106Sdes # loop can be closed while we follow links, 9312238106Sdes # but so what? 9313296415Sdes potlib=$potent_lib 9314238106Sdes while test -h "$potlib" 2>/dev/null; do 9315296415Sdes potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9316238106Sdes case $potliblink in 9317296415Sdes [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9318296415Sdes *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9319238106Sdes esac 9320238106Sdes done 9321238106Sdes if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9322238106Sdes $SED -e 10q | 9323238106Sdes $EGREP "$file_magic_regex" > /dev/null; then 9324238106Sdes func_append newdeplibs " $a_deplib" 9325296415Sdes a_deplib= 9326238106Sdes break 2 9327238106Sdes fi 9328238106Sdes done 9329238106Sdes done 9330238106Sdes fi 9331296415Sdes if test -n "$a_deplib"; then 9332238106Sdes droppeddeps=yes 9333238106Sdes echo 9334238106Sdes $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9335238106Sdes echo "*** I have the capability to make that library automatically link in when" 9336238106Sdes echo "*** you link to this library. But I can only do this if you have a" 9337238106Sdes echo "*** shared version of the library, which you do not appear to have" 9338238106Sdes echo "*** because I did check the linker path looking for a file starting" 9339296415Sdes if test -z "$potlib"; then 9340238106Sdes $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9341238106Sdes else 9342238106Sdes $ECHO "*** with $libname and none of the candidates passed a file format test" 9343238106Sdes $ECHO "*** using a file magic. Last file checked: $potlib" 9344238106Sdes fi 9345238106Sdes fi 9346238106Sdes ;; 9347238106Sdes *) 9348238106Sdes # Add a -L argument. 9349238106Sdes func_append newdeplibs " $a_deplib" 9350238106Sdes ;; 9351238106Sdes esac 9352238106Sdes done # Gone through all deplibs. 9353238106Sdes ;; 9354238106Sdes match_pattern*) 9355238106Sdes set dummy $deplibs_check_method; shift 9356238106Sdes match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9357238106Sdes for a_deplib in $deplibs; do 9358238106Sdes case $a_deplib in 9359238106Sdes -l*) 9360238106Sdes func_stripname -l '' "$a_deplib" 9361238106Sdes name=$func_stripname_result 9362296415Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9363238106Sdes case " $predeps $postdeps " in 9364238106Sdes *" $a_deplib "*) 9365238106Sdes func_append newdeplibs " $a_deplib" 9366296415Sdes a_deplib= 9367238106Sdes ;; 9368238106Sdes esac 9369238106Sdes fi 9370296415Sdes if test -n "$a_deplib"; then 9371238106Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 9372238106Sdes for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9373238106Sdes potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9374238106Sdes for potent_lib in $potential_libs; do 9375296415Sdes potlib=$potent_lib # see symlink-check above in file_magic test 9376238106Sdes if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9377238106Sdes $EGREP "$match_pattern_regex" > /dev/null; then 9378238106Sdes func_append newdeplibs " $a_deplib" 9379296415Sdes a_deplib= 9380238106Sdes break 2 9381238106Sdes fi 9382238106Sdes done 9383238106Sdes done 9384238106Sdes fi 9385296415Sdes if test -n "$a_deplib"; then 9386238106Sdes droppeddeps=yes 9387238106Sdes echo 9388238106Sdes $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9389238106Sdes echo "*** I have the capability to make that library automatically link in when" 9390238106Sdes echo "*** you link to this library. But I can only do this if you have a" 9391238106Sdes echo "*** shared version of the library, which you do not appear to have" 9392238106Sdes echo "*** because I did check the linker path looking for a file starting" 9393296415Sdes if test -z "$potlib"; then 9394238106Sdes $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9395238106Sdes else 9396238106Sdes $ECHO "*** with $libname and none of the candidates passed a file format test" 9397238106Sdes $ECHO "*** using a regex pattern. Last file checked: $potlib" 9398238106Sdes fi 9399238106Sdes fi 9400238106Sdes ;; 9401238106Sdes *) 9402238106Sdes # Add a -L argument. 9403238106Sdes func_append newdeplibs " $a_deplib" 9404238106Sdes ;; 9405238106Sdes esac 9406238106Sdes done # Gone through all deplibs. 9407238106Sdes ;; 9408238106Sdes none | unknown | *) 9409296415Sdes newdeplibs= 9410238106Sdes tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9411296415Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9412296415Sdes for i in $predeps $postdeps; do 9413238106Sdes # can't use Xsed below, because $i might contain '/' 9414296415Sdes tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9415238106Sdes done 9416238106Sdes fi 9417238106Sdes case $tmp_deplibs in 9418238106Sdes *[!\ \ ]*) 9419238106Sdes echo 9420296415Sdes if test none = "$deplibs_check_method"; then 9421238106Sdes echo "*** Warning: inter-library dependencies are not supported in this platform." 9422238106Sdes else 9423238106Sdes echo "*** Warning: inter-library dependencies are not known to be supported." 9424238106Sdes fi 9425238106Sdes echo "*** All declared inter-library dependencies are being dropped." 9426238106Sdes droppeddeps=yes 9427238106Sdes ;; 9428238106Sdes esac 9429238106Sdes ;; 9430238106Sdes esac 9431238106Sdes versuffix=$versuffix_save 9432238106Sdes major=$major_save 9433238106Sdes release=$release_save 9434238106Sdes libname=$libname_save 9435238106Sdes name=$name_save 9436238106Sdes 9437238106Sdes case $host in 9438238106Sdes *-*-rhapsody* | *-*-darwin1.[012]) 9439238106Sdes # On Rhapsody replace the C library with the System framework 9440238106Sdes newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9441238106Sdes ;; 9442238106Sdes esac 9443238106Sdes 9444296415Sdes if test yes = "$droppeddeps"; then 9445296415Sdes if test yes = "$module"; then 9446238106Sdes echo 9447238106Sdes echo "*** Warning: libtool could not satisfy all declared inter-library" 9448238106Sdes $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9449238106Sdes echo "*** a static module, that should work as long as the dlopening" 9450238106Sdes echo "*** application is linked with the -dlopen flag." 9451238106Sdes if test -z "$global_symbol_pipe"; then 9452238106Sdes echo 9453238106Sdes echo "*** However, this would only work if libtool was able to extract symbol" 9454296415Sdes echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9455238106Sdes echo "*** not find such a program. So, this module is probably useless." 9456296415Sdes echo "*** 'nm' from GNU binutils and a full rebuild may help." 9457238106Sdes fi 9458296415Sdes if test no = "$build_old_libs"; then 9459296415Sdes oldlibs=$output_objdir/$libname.$libext 9460238106Sdes build_libtool_libs=module 9461238106Sdes build_old_libs=yes 9462238106Sdes else 9463238106Sdes build_libtool_libs=no 9464238106Sdes fi 9465238106Sdes else 9466238106Sdes echo "*** The inter-library dependencies that have been dropped here will be" 9467238106Sdes echo "*** automatically added whenever a program is linked with this library" 9468238106Sdes echo "*** or is declared to -dlopen it." 9469238106Sdes 9470296415Sdes if test no = "$allow_undefined"; then 9471238106Sdes echo 9472238106Sdes echo "*** Since this library must not contain undefined symbols," 9473238106Sdes echo "*** because either the platform does not support them or" 9474238106Sdes echo "*** it was explicitly requested with -no-undefined," 9475238106Sdes echo "*** libtool will only create a static version of it." 9476296415Sdes if test no = "$build_old_libs"; then 9477296415Sdes oldlibs=$output_objdir/$libname.$libext 9478238106Sdes build_libtool_libs=module 9479238106Sdes build_old_libs=yes 9480238106Sdes else 9481238106Sdes build_libtool_libs=no 9482238106Sdes fi 9483238106Sdes fi 9484238106Sdes fi 9485238106Sdes fi 9486238106Sdes # Done checking deplibs! 9487238106Sdes deplibs=$newdeplibs 9488238106Sdes fi 9489238106Sdes # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9490238106Sdes case $host in 9491238106Sdes *-*-darwin*) 9492238106Sdes newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493238106Sdes new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9494238106Sdes deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9495238106Sdes ;; 9496238106Sdes esac 9497238106Sdes 9498238106Sdes # move library search paths that coincide with paths to not yet 9499238106Sdes # installed libraries to the beginning of the library search list 9500238106Sdes new_libs= 9501238106Sdes for path in $notinst_path; do 9502238106Sdes case " $new_libs " in 9503238106Sdes *" -L$path/$objdir "*) ;; 9504238106Sdes *) 9505238106Sdes case " $deplibs " in 9506238106Sdes *" -L$path/$objdir "*) 9507238106Sdes func_append new_libs " -L$path/$objdir" ;; 9508238106Sdes esac 9509238106Sdes ;; 9510238106Sdes esac 9511238106Sdes done 9512238106Sdes for deplib in $deplibs; do 9513238106Sdes case $deplib in 9514238106Sdes -L*) 9515238106Sdes case " $new_libs " in 9516238106Sdes *" $deplib "*) ;; 9517238106Sdes *) func_append new_libs " $deplib" ;; 9518238106Sdes esac 9519238106Sdes ;; 9520238106Sdes *) func_append new_libs " $deplib" ;; 9521238106Sdes esac 9522238106Sdes done 9523296415Sdes deplibs=$new_libs 9524238106Sdes 9525238106Sdes # All the library-specific variables (install_libdir is set above). 9526238106Sdes library_names= 9527238106Sdes old_library= 9528238106Sdes dlname= 9529238106Sdes 9530238106Sdes # Test again, we may have decided not to build it any more 9531296415Sdes if test yes = "$build_libtool_libs"; then 9532296415Sdes # Remove $wl instances when linking with ld. 9533249141Sdes # FIXME: should test the right _cmds variable. 9534249141Sdes case $archive_cmds in 9535249141Sdes *\$LD\ *) wl= ;; 9536249141Sdes esac 9537296415Sdes if test yes = "$hardcode_into_libs"; then 9538238106Sdes # Hardcode the library paths 9539238106Sdes hardcode_libdirs= 9540238106Sdes dep_rpath= 9541296415Sdes rpath=$finalize_rpath 9542296415Sdes test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9543238106Sdes for libdir in $rpath; do 9544238106Sdes if test -n "$hardcode_libdir_flag_spec"; then 9545238106Sdes if test -n "$hardcode_libdir_separator"; then 9546238106Sdes func_replace_sysroot "$libdir" 9547238106Sdes libdir=$func_replace_sysroot_result 9548238106Sdes if test -z "$hardcode_libdirs"; then 9549296415Sdes hardcode_libdirs=$libdir 9550238106Sdes else 9551238106Sdes # Just accumulate the unique libdirs. 9552238106Sdes case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9553238106Sdes *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9554238106Sdes ;; 9555238106Sdes *) 9556238106Sdes func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9557238106Sdes ;; 9558238106Sdes esac 9559238106Sdes fi 9560238106Sdes else 9561238106Sdes eval flag=\"$hardcode_libdir_flag_spec\" 9562238106Sdes func_append dep_rpath " $flag" 9563238106Sdes fi 9564238106Sdes elif test -n "$runpath_var"; then 9565238106Sdes case "$perm_rpath " in 9566238106Sdes *" $libdir "*) ;; 9567249141Sdes *) func_append perm_rpath " $libdir" ;; 9568238106Sdes esac 9569238106Sdes fi 9570238106Sdes done 9571238106Sdes # Substitute the hardcoded libdirs into the rpath. 9572238106Sdes if test -n "$hardcode_libdir_separator" && 9573238106Sdes test -n "$hardcode_libdirs"; then 9574296415Sdes libdir=$hardcode_libdirs 9575249141Sdes eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9576238106Sdes fi 9577238106Sdes if test -n "$runpath_var" && test -n "$perm_rpath"; then 9578238106Sdes # We should set the runpath_var. 9579238106Sdes rpath= 9580238106Sdes for dir in $perm_rpath; do 9581238106Sdes func_append rpath "$dir:" 9582238106Sdes done 9583238106Sdes eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9584238106Sdes fi 9585238106Sdes test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9586238106Sdes fi 9587238106Sdes 9588296415Sdes shlibpath=$finalize_shlibpath 9589296415Sdes test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9590238106Sdes if test -n "$shlibpath"; then 9591238106Sdes eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9592238106Sdes fi 9593238106Sdes 9594238106Sdes # Get the real and link names of the library. 9595238106Sdes eval shared_ext=\"$shrext_cmds\" 9596238106Sdes eval library_names=\"$library_names_spec\" 9597238106Sdes set dummy $library_names 9598238106Sdes shift 9599296415Sdes realname=$1 9600238106Sdes shift 9601238106Sdes 9602238106Sdes if test -n "$soname_spec"; then 9603238106Sdes eval soname=\"$soname_spec\" 9604238106Sdes else 9605296415Sdes soname=$realname 9606238106Sdes fi 9607238106Sdes if test -z "$dlname"; then 9608238106Sdes dlname=$soname 9609238106Sdes fi 9610238106Sdes 9611296415Sdes lib=$output_objdir/$realname 9612238106Sdes linknames= 9613238106Sdes for link 9614238106Sdes do 9615238106Sdes func_append linknames " $link" 9616238106Sdes done 9617238106Sdes 9618238106Sdes # Use standard objects if they are pic 9619238106Sdes test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9620238106Sdes test "X$libobjs" = "X " && libobjs= 9621238106Sdes 9622238106Sdes delfiles= 9623238106Sdes if test -n "$export_symbols" && test -n "$include_expsyms"; then 9624238106Sdes $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9625296415Sdes export_symbols=$output_objdir/$libname.uexp 9626238106Sdes func_append delfiles " $export_symbols" 9627238106Sdes fi 9628238106Sdes 9629238106Sdes orig_export_symbols= 9630238106Sdes case $host_os in 9631238106Sdes cygwin* | mingw* | cegcc*) 9632238106Sdes if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9633238106Sdes # exporting using user supplied symfile 9634296415Sdes func_dll_def_p "$export_symbols" || { 9635238106Sdes # and it's NOT already a .def file. Must figure out 9636238106Sdes # which of the given symbols are data symbols and tag 9637238106Sdes # them as such. So, trigger use of export_symbols_cmds. 9638238106Sdes # export_symbols gets reassigned inside the "prepare 9639238106Sdes # the list of exported symbols" if statement, so the 9640238106Sdes # include_expsyms logic still works. 9641296415Sdes orig_export_symbols=$export_symbols 9642238106Sdes export_symbols= 9643238106Sdes always_export_symbols=yes 9644296415Sdes } 9645238106Sdes fi 9646238106Sdes ;; 9647238106Sdes esac 9648238106Sdes 9649238106Sdes # Prepare the list of exported symbols 9650238106Sdes if test -z "$export_symbols"; then 9651296415Sdes if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9652296415Sdes func_verbose "generating symbol list for '$libname.la'" 9653296415Sdes export_symbols=$output_objdir/$libname.exp 9654238106Sdes $opt_dry_run || $RM $export_symbols 9655238106Sdes cmds=$export_symbols_cmds 9656296415Sdes save_ifs=$IFS; IFS='~' 9657238106Sdes for cmd1 in $cmds; do 9658296415Sdes IFS=$save_ifs 9659238106Sdes # Take the normal branch if the nm_file_list_spec branch 9660238106Sdes # doesn't work or if tool conversion is not needed. 9661238106Sdes case $nm_file_list_spec~$to_tool_file_cmd in 9662238106Sdes *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9663238106Sdes try_normal_branch=yes 9664238106Sdes eval cmd=\"$cmd1\" 9665238106Sdes func_len " $cmd" 9666238106Sdes len=$func_len_result 9667238106Sdes ;; 9668238106Sdes *) 9669238106Sdes try_normal_branch=no 9670238106Sdes ;; 9671238106Sdes esac 9672296415Sdes if test yes = "$try_normal_branch" \ 9673238106Sdes && { test "$len" -lt "$max_cmd_len" \ 9674238106Sdes || test "$max_cmd_len" -le -1; } 9675238106Sdes then 9676238106Sdes func_show_eval "$cmd" 'exit $?' 9677238106Sdes skipped_export=false 9678238106Sdes elif test -n "$nm_file_list_spec"; then 9679238106Sdes func_basename "$output" 9680238106Sdes output_la=$func_basename_result 9681238106Sdes save_libobjs=$libobjs 9682238106Sdes save_output=$output 9683296415Sdes output=$output_objdir/$output_la.nm 9684238106Sdes func_to_tool_file "$output" 9685238106Sdes libobjs=$nm_file_list_spec$func_to_tool_file_result 9686238106Sdes func_append delfiles " $output" 9687238106Sdes func_verbose "creating $NM input file list: $output" 9688238106Sdes for obj in $save_libobjs; do 9689238106Sdes func_to_tool_file "$obj" 9690238106Sdes $ECHO "$func_to_tool_file_result" 9691238106Sdes done > "$output" 9692238106Sdes eval cmd=\"$cmd1\" 9693238106Sdes func_show_eval "$cmd" 'exit $?' 9694238106Sdes output=$save_output 9695238106Sdes libobjs=$save_libobjs 9696238106Sdes skipped_export=false 9697238106Sdes else 9698238106Sdes # The command line is too long to execute in one step. 9699238106Sdes func_verbose "using reloadable object file for export list..." 9700238106Sdes skipped_export=: 9701238106Sdes # Break out early, otherwise skipped_export may be 9702238106Sdes # set to false by a later but shorter cmd. 9703238106Sdes break 9704238106Sdes fi 9705238106Sdes done 9706296415Sdes IFS=$save_ifs 9707296415Sdes if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9708238106Sdes func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9709238106Sdes func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9710238106Sdes fi 9711238106Sdes fi 9712238106Sdes fi 9713238106Sdes 9714238106Sdes if test -n "$export_symbols" && test -n "$include_expsyms"; then 9715296415Sdes tmp_export_symbols=$export_symbols 9716296415Sdes test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9717238106Sdes $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9718238106Sdes fi 9719238106Sdes 9720296415Sdes if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9721238106Sdes # The given exports_symbols file has to be filtered, so filter it. 9722296415Sdes func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9723238106Sdes # FIXME: $output_objdir/$libname.filter potentially contains lots of 9724296415Sdes # 's' commands, which not all seds can handle. GNU sed should be fine 9725238106Sdes # though. Also, the filter scales superlinearly with the number of 9726238106Sdes # global variables. join(1) would be nice here, but unfortunately 9727238106Sdes # isn't a blessed tool. 9728238106Sdes $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9729238106Sdes func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9730238106Sdes export_symbols=$output_objdir/$libname.def 9731238106Sdes $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9732238106Sdes fi 9733238106Sdes 9734238106Sdes tmp_deplibs= 9735238106Sdes for test_deplib in $deplibs; do 9736238106Sdes case " $convenience " in 9737238106Sdes *" $test_deplib "*) ;; 9738238106Sdes *) 9739238106Sdes func_append tmp_deplibs " $test_deplib" 9740238106Sdes ;; 9741238106Sdes esac 9742238106Sdes done 9743296415Sdes deplibs=$tmp_deplibs 9744238106Sdes 9745238106Sdes if test -n "$convenience"; then 9746238106Sdes if test -n "$whole_archive_flag_spec" && 9747296415Sdes test yes = "$compiler_needs_object" && 9748238106Sdes test -z "$libobjs"; then 9749238106Sdes # extract the archives, so we have objects to list. 9750238106Sdes # TODO: could optimize this to just extract one archive. 9751238106Sdes whole_archive_flag_spec= 9752238106Sdes fi 9753238106Sdes if test -n "$whole_archive_flag_spec"; then 9754238106Sdes save_libobjs=$libobjs 9755238106Sdes eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9756238106Sdes test "X$libobjs" = "X " && libobjs= 9757238106Sdes else 9758296415Sdes gentop=$output_objdir/${outputname}x 9759238106Sdes func_append generated " $gentop" 9760238106Sdes 9761238106Sdes func_extract_archives $gentop $convenience 9762238106Sdes func_append libobjs " $func_extract_archives_result" 9763238106Sdes test "X$libobjs" = "X " && libobjs= 9764238106Sdes fi 9765238106Sdes fi 9766238106Sdes 9767296415Sdes if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9768238106Sdes eval flag=\"$thread_safe_flag_spec\" 9769238106Sdes func_append linker_flags " $flag" 9770238106Sdes fi 9771238106Sdes 9772238106Sdes # Make a backup of the uninstalled library when relinking 9773296415Sdes if test relink = "$opt_mode"; then 9774238106Sdes $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9775238106Sdes fi 9776238106Sdes 9777238106Sdes # Do each of the archive commands. 9778296415Sdes if test yes = "$module" && test -n "$module_cmds"; then 9779238106Sdes if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9780238106Sdes eval test_cmds=\"$module_expsym_cmds\" 9781238106Sdes cmds=$module_expsym_cmds 9782238106Sdes else 9783238106Sdes eval test_cmds=\"$module_cmds\" 9784238106Sdes cmds=$module_cmds 9785238106Sdes fi 9786238106Sdes else 9787238106Sdes if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9788238106Sdes eval test_cmds=\"$archive_expsym_cmds\" 9789238106Sdes cmds=$archive_expsym_cmds 9790238106Sdes else 9791238106Sdes eval test_cmds=\"$archive_cmds\" 9792238106Sdes cmds=$archive_cmds 9793238106Sdes fi 9794238106Sdes fi 9795238106Sdes 9796296415Sdes if test : != "$skipped_export" && 9797238106Sdes func_len " $test_cmds" && 9798238106Sdes len=$func_len_result && 9799238106Sdes test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9800238106Sdes : 9801238106Sdes else 9802238106Sdes # The command line is too long to link in one step, link piecewise 9803238106Sdes # or, if using GNU ld and skipped_export is not :, use a linker 9804238106Sdes # script. 9805238106Sdes 9806238106Sdes # Save the value of $output and $libobjs because we want to 9807238106Sdes # use them later. If we have whole_archive_flag_spec, we 9808238106Sdes # want to use save_libobjs as it was before 9809238106Sdes # whole_archive_flag_spec was expanded, because we can't 9810238106Sdes # assume the linker understands whole_archive_flag_spec. 9811238106Sdes # This may have to be revisited, in case too many 9812238106Sdes # convenience libraries get linked in and end up exceeding 9813238106Sdes # the spec. 9814238106Sdes if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9815238106Sdes save_libobjs=$libobjs 9816238106Sdes fi 9817238106Sdes save_output=$output 9818238106Sdes func_basename "$output" 9819238106Sdes output_la=$func_basename_result 9820238106Sdes 9821238106Sdes # Clear the reloadable object creation command queue and 9822238106Sdes # initialize k to one. 9823238106Sdes test_cmds= 9824238106Sdes concat_cmds= 9825238106Sdes objlist= 9826238106Sdes last_robj= 9827238106Sdes k=1 9828238106Sdes 9829296415Sdes if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9830296415Sdes output=$output_objdir/$output_la.lnkscript 9831238106Sdes func_verbose "creating GNU ld script: $output" 9832238106Sdes echo 'INPUT (' > $output 9833238106Sdes for obj in $save_libobjs 9834238106Sdes do 9835238106Sdes func_to_tool_file "$obj" 9836238106Sdes $ECHO "$func_to_tool_file_result" >> $output 9837238106Sdes done 9838238106Sdes echo ')' >> $output 9839238106Sdes func_append delfiles " $output" 9840238106Sdes func_to_tool_file "$output" 9841238106Sdes output=$func_to_tool_file_result 9842296415Sdes elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9843296415Sdes output=$output_objdir/$output_la.lnk 9844238106Sdes func_verbose "creating linker input file list: $output" 9845238106Sdes : > $output 9846238106Sdes set x $save_libobjs 9847238106Sdes shift 9848238106Sdes firstobj= 9849296415Sdes if test yes = "$compiler_needs_object"; then 9850238106Sdes firstobj="$1 " 9851238106Sdes shift 9852238106Sdes fi 9853238106Sdes for obj 9854238106Sdes do 9855238106Sdes func_to_tool_file "$obj" 9856238106Sdes $ECHO "$func_to_tool_file_result" >> $output 9857238106Sdes done 9858238106Sdes func_append delfiles " $output" 9859238106Sdes func_to_tool_file "$output" 9860238106Sdes output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9861238106Sdes else 9862238106Sdes if test -n "$save_libobjs"; then 9863238106Sdes func_verbose "creating reloadable object files..." 9864296415Sdes output=$output_objdir/$output_la-$k.$objext 9865238106Sdes eval test_cmds=\"$reload_cmds\" 9866238106Sdes func_len " $test_cmds" 9867238106Sdes len0=$func_len_result 9868238106Sdes len=$len0 9869238106Sdes 9870238106Sdes # Loop over the list of objects to be linked. 9871238106Sdes for obj in $save_libobjs 9872238106Sdes do 9873238106Sdes func_len " $obj" 9874238106Sdes func_arith $len + $func_len_result 9875238106Sdes len=$func_arith_result 9876296415Sdes if test -z "$objlist" || 9877238106Sdes test "$len" -lt "$max_cmd_len"; then 9878238106Sdes func_append objlist " $obj" 9879238106Sdes else 9880238106Sdes # The command $test_cmds is almost too long, add a 9881238106Sdes # command to the queue. 9882296415Sdes if test 1 -eq "$k"; then 9883238106Sdes # The first file doesn't have a previous command to add. 9884238106Sdes reload_objs=$objlist 9885238106Sdes eval concat_cmds=\"$reload_cmds\" 9886238106Sdes else 9887238106Sdes # All subsequent reloadable object files will link in 9888238106Sdes # the last one created. 9889238106Sdes reload_objs="$objlist $last_robj" 9890238106Sdes eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9891238106Sdes fi 9892296415Sdes last_robj=$output_objdir/$output_la-$k.$objext 9893238106Sdes func_arith $k + 1 9894238106Sdes k=$func_arith_result 9895296415Sdes output=$output_objdir/$output_la-$k.$objext 9896238106Sdes objlist=" $obj" 9897238106Sdes func_len " $last_robj" 9898238106Sdes func_arith $len0 + $func_len_result 9899238106Sdes len=$func_arith_result 9900238106Sdes fi 9901238106Sdes done 9902238106Sdes # Handle the remaining objects by creating one last 9903238106Sdes # reloadable object file. All subsequent reloadable object 9904238106Sdes # files will link in the last one created. 9905238106Sdes test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9906238106Sdes reload_objs="$objlist $last_robj" 9907296415Sdes eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9908238106Sdes if test -n "$last_robj"; then 9909296415Sdes eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9910238106Sdes fi 9911238106Sdes func_append delfiles " $output" 9912238106Sdes 9913238106Sdes else 9914238106Sdes output= 9915238106Sdes fi 9916238106Sdes 9917296415Sdes ${skipped_export-false} && { 9918296415Sdes func_verbose "generating symbol list for '$libname.la'" 9919296415Sdes export_symbols=$output_objdir/$libname.exp 9920238106Sdes $opt_dry_run || $RM $export_symbols 9921238106Sdes libobjs=$output 9922238106Sdes # Append the command to create the export file. 9923238106Sdes test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9924238106Sdes eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9925238106Sdes if test -n "$last_robj"; then 9926238106Sdes eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9927238106Sdes fi 9928296415Sdes } 9929238106Sdes 9930238106Sdes test -n "$save_libobjs" && 9931238106Sdes func_verbose "creating a temporary reloadable object file: $output" 9932238106Sdes 9933238106Sdes # Loop through the commands generated above and execute them. 9934296415Sdes save_ifs=$IFS; IFS='~' 9935238106Sdes for cmd in $concat_cmds; do 9936296415Sdes IFS=$save_ifs 9937296415Sdes $opt_quiet || { 9938238106Sdes func_quote_for_expand "$cmd" 9939238106Sdes eval "func_echo $func_quote_for_expand_result" 9940238106Sdes } 9941238106Sdes $opt_dry_run || eval "$cmd" || { 9942238106Sdes lt_exit=$? 9943238106Sdes 9944238106Sdes # Restore the uninstalled library and exit 9945296415Sdes if test relink = "$opt_mode"; then 9946238106Sdes ( cd "$output_objdir" && \ 9947238106Sdes $RM "${realname}T" && \ 9948238106Sdes $MV "${realname}U" "$realname" ) 9949238106Sdes fi 9950238106Sdes 9951238106Sdes exit $lt_exit 9952238106Sdes } 9953238106Sdes done 9954296415Sdes IFS=$save_ifs 9955238106Sdes 9956238106Sdes if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9957238106Sdes func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9958238106Sdes func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9959238106Sdes fi 9960238106Sdes fi 9961238106Sdes 9962296415Sdes ${skipped_export-false} && { 9963238106Sdes if test -n "$export_symbols" && test -n "$include_expsyms"; then 9964296415Sdes tmp_export_symbols=$export_symbols 9965296415Sdes test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9966238106Sdes $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9967238106Sdes fi 9968238106Sdes 9969238106Sdes if test -n "$orig_export_symbols"; then 9970238106Sdes # The given exports_symbols file has to be filtered, so filter it. 9971296415Sdes func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9972238106Sdes # FIXME: $output_objdir/$libname.filter potentially contains lots of 9973296415Sdes # 's' commands, which not all seds can handle. GNU sed should be fine 9974238106Sdes # though. Also, the filter scales superlinearly with the number of 9975238106Sdes # global variables. join(1) would be nice here, but unfortunately 9976238106Sdes # isn't a blessed tool. 9977238106Sdes $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9978238106Sdes func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9979238106Sdes export_symbols=$output_objdir/$libname.def 9980238106Sdes $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9981238106Sdes fi 9982296415Sdes } 9983238106Sdes 9984238106Sdes libobjs=$output 9985238106Sdes # Restore the value of output. 9986238106Sdes output=$save_output 9987238106Sdes 9988238106Sdes if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9989238106Sdes eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9990238106Sdes test "X$libobjs" = "X " && libobjs= 9991238106Sdes fi 9992238106Sdes # Expand the library linking commands again to reset the 9993238106Sdes # value of $libobjs for piecewise linking. 9994238106Sdes 9995238106Sdes # Do each of the archive commands. 9996296415Sdes if test yes = "$module" && test -n "$module_cmds"; then 9997238106Sdes if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9998238106Sdes cmds=$module_expsym_cmds 9999238106Sdes else 10000238106Sdes cmds=$module_cmds 10001238106Sdes fi 10002238106Sdes else 10003238106Sdes if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10004238106Sdes cmds=$archive_expsym_cmds 10005238106Sdes else 10006238106Sdes cmds=$archive_cmds 10007238106Sdes fi 10008238106Sdes fi 10009238106Sdes fi 10010238106Sdes 10011238106Sdes if test -n "$delfiles"; then 10012238106Sdes # Append the command to remove temporary files to $cmds. 10013238106Sdes eval cmds=\"\$cmds~\$RM $delfiles\" 10014238106Sdes fi 10015238106Sdes 10016238106Sdes # Add any objects from preloaded convenience libraries 10017238106Sdes if test -n "$dlprefiles"; then 10018296415Sdes gentop=$output_objdir/${outputname}x 10019238106Sdes func_append generated " $gentop" 10020238106Sdes 10021238106Sdes func_extract_archives $gentop $dlprefiles 10022238106Sdes func_append libobjs " $func_extract_archives_result" 10023238106Sdes test "X$libobjs" = "X " && libobjs= 10024238106Sdes fi 10025238106Sdes 10026296415Sdes save_ifs=$IFS; IFS='~' 10027238106Sdes for cmd in $cmds; do 10028296415Sdes IFS=$sp$nl 10029238106Sdes eval cmd=\"$cmd\" 10030296415Sdes IFS=$save_ifs 10031296415Sdes $opt_quiet || { 10032238106Sdes func_quote_for_expand "$cmd" 10033238106Sdes eval "func_echo $func_quote_for_expand_result" 10034238106Sdes } 10035238106Sdes $opt_dry_run || eval "$cmd" || { 10036238106Sdes lt_exit=$? 10037238106Sdes 10038238106Sdes # Restore the uninstalled library and exit 10039296415Sdes if test relink = "$opt_mode"; then 10040238106Sdes ( cd "$output_objdir" && \ 10041238106Sdes $RM "${realname}T" && \ 10042238106Sdes $MV "${realname}U" "$realname" ) 10043238106Sdes fi 10044238106Sdes 10045238106Sdes exit $lt_exit 10046238106Sdes } 10047238106Sdes done 10048296415Sdes IFS=$save_ifs 10049238106Sdes 10050238106Sdes # Restore the uninstalled library and exit 10051296415Sdes if test relink = "$opt_mode"; then 10052238106Sdes $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10053238106Sdes 10054238106Sdes if test -n "$convenience"; then 10055238106Sdes if test -z "$whole_archive_flag_spec"; then 10056238106Sdes func_show_eval '${RM}r "$gentop"' 10057238106Sdes fi 10058238106Sdes fi 10059238106Sdes 10060238106Sdes exit $EXIT_SUCCESS 10061238106Sdes fi 10062238106Sdes 10063238106Sdes # Create links to the real library. 10064238106Sdes for linkname in $linknames; do 10065238106Sdes if test "$realname" != "$linkname"; then 10066238106Sdes func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10067238106Sdes fi 10068238106Sdes done 10069238106Sdes 10070238106Sdes # If -module or -export-dynamic was specified, set the dlname. 10071296415Sdes if test yes = "$module" || test yes = "$export_dynamic"; then 10072238106Sdes # On all known operating systems, these are identical. 10073296415Sdes dlname=$soname 10074238106Sdes fi 10075238106Sdes fi 10076238106Sdes ;; 10077238106Sdes 10078238106Sdes obj) 10079296415Sdes if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10080296415Sdes func_warning "'-dlopen' is ignored for objects" 10081238106Sdes fi 10082238106Sdes 10083238106Sdes case " $deplibs" in 10084238106Sdes *\ -l* | *\ -L*) 10085296415Sdes func_warning "'-l' and '-L' are ignored for objects" ;; 10086238106Sdes esac 10087238106Sdes 10088238106Sdes test -n "$rpath" && \ 10089296415Sdes func_warning "'-rpath' is ignored for objects" 10090238106Sdes 10091238106Sdes test -n "$xrpath" && \ 10092296415Sdes func_warning "'-R' is ignored for objects" 10093238106Sdes 10094238106Sdes test -n "$vinfo" && \ 10095296415Sdes func_warning "'-version-info' is ignored for objects" 10096238106Sdes 10097238106Sdes test -n "$release" && \ 10098296415Sdes func_warning "'-release' is ignored for objects" 10099238106Sdes 10100238106Sdes case $output in 10101238106Sdes *.lo) 10102238106Sdes test -n "$objs$old_deplibs" && \ 10103296415Sdes func_fatal_error "cannot build library object '$output' from non-libtool objects" 10104238106Sdes 10105238106Sdes libobj=$output 10106238106Sdes func_lo2o "$libobj" 10107238106Sdes obj=$func_lo2o_result 10108238106Sdes ;; 10109238106Sdes *) 10110238106Sdes libobj= 10111296415Sdes obj=$output 10112238106Sdes ;; 10113238106Sdes esac 10114238106Sdes 10115238106Sdes # Delete the old objects. 10116238106Sdes $opt_dry_run || $RM $obj $libobj 10117238106Sdes 10118238106Sdes # Objects from convenience libraries. This assumes 10119238106Sdes # single-version convenience libraries. Whenever we create 10120238106Sdes # different ones for PIC/non-PIC, this we'll have to duplicate 10121238106Sdes # the extraction. 10122238106Sdes reload_conv_objs= 10123238106Sdes gentop= 10124296415Sdes # if reload_cmds runs $LD directly, get rid of -Wl from 10125296415Sdes # whole_archive_flag_spec and hope we can get by with turning comma 10126296415Sdes # into space. 10127296415Sdes case $reload_cmds in 10128296415Sdes *\$LD[\ \$]*) wl= ;; 10129296415Sdes esac 10130238106Sdes if test -n "$convenience"; then 10131238106Sdes if test -n "$whole_archive_flag_spec"; then 10132238106Sdes eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10133296415Sdes test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10134296415Sdes reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10135238106Sdes else 10136296415Sdes gentop=$output_objdir/${obj}x 10137238106Sdes func_append generated " $gentop" 10138238106Sdes 10139238106Sdes func_extract_archives $gentop $convenience 10140238106Sdes reload_conv_objs="$reload_objs $func_extract_archives_result" 10141238106Sdes fi 10142238106Sdes fi 10143238106Sdes 10144238106Sdes # If we're not building shared, we need to use non_pic_objs 10145296415Sdes test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10146238106Sdes 10147238106Sdes # Create the old-style object. 10148296415Sdes reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10149238106Sdes 10150296415Sdes output=$obj 10151238106Sdes func_execute_cmds "$reload_cmds" 'exit $?' 10152238106Sdes 10153238106Sdes # Exit if we aren't doing a library object file. 10154238106Sdes if test -z "$libobj"; then 10155238106Sdes if test -n "$gentop"; then 10156238106Sdes func_show_eval '${RM}r "$gentop"' 10157238106Sdes fi 10158238106Sdes 10159238106Sdes exit $EXIT_SUCCESS 10160238106Sdes fi 10161238106Sdes 10162296415Sdes test yes = "$build_libtool_libs" || { 10163238106Sdes if test -n "$gentop"; then 10164238106Sdes func_show_eval '${RM}r "$gentop"' 10165238106Sdes fi 10166238106Sdes 10167238106Sdes # Create an invalid libtool object if no PIC, so that we don't 10168238106Sdes # accidentally link it into a program. 10169238106Sdes # $show "echo timestamp > $libobj" 10170238106Sdes # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10171238106Sdes exit $EXIT_SUCCESS 10172296415Sdes } 10173238106Sdes 10174296415Sdes if test -n "$pic_flag" || test default != "$pic_mode"; then 10175238106Sdes # Only do commands if we really have different PIC objects. 10176238106Sdes reload_objs="$libobjs $reload_conv_objs" 10177296415Sdes output=$libobj 10178238106Sdes func_execute_cmds "$reload_cmds" 'exit $?' 10179238106Sdes fi 10180238106Sdes 10181238106Sdes if test -n "$gentop"; then 10182238106Sdes func_show_eval '${RM}r "$gentop"' 10183238106Sdes fi 10184238106Sdes 10185238106Sdes exit $EXIT_SUCCESS 10186238106Sdes ;; 10187238106Sdes 10188238106Sdes prog) 10189238106Sdes case $host in 10190238106Sdes *cygwin*) func_stripname '' '.exe' "$output" 10191238106Sdes output=$func_stripname_result.exe;; 10192238106Sdes esac 10193238106Sdes test -n "$vinfo" && \ 10194296415Sdes func_warning "'-version-info' is ignored for programs" 10195238106Sdes 10196238106Sdes test -n "$release" && \ 10197296415Sdes func_warning "'-release' is ignored for programs" 10198238106Sdes 10199296415Sdes $preload \ 10200296415Sdes && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10201296415Sdes && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10202238106Sdes 10203238106Sdes case $host in 10204238106Sdes *-*-rhapsody* | *-*-darwin1.[012]) 10205238106Sdes # On Rhapsody replace the C library is the System framework 10206238106Sdes compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10207238106Sdes finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10208238106Sdes ;; 10209238106Sdes esac 10210238106Sdes 10211238106Sdes case $host in 10212238106Sdes *-*-darwin*) 10213238106Sdes # Don't allow lazy linking, it breaks C++ global constructors 10214238106Sdes # But is supposedly fixed on 10.4 or later (yay!). 10215296415Sdes if test CXX = "$tagname"; then 10216238106Sdes case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10217238106Sdes 10.[0123]) 10218296415Sdes func_append compile_command " $wl-bind_at_load" 10219296415Sdes func_append finalize_command " $wl-bind_at_load" 10220238106Sdes ;; 10221238106Sdes esac 10222238106Sdes fi 10223238106Sdes # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10224238106Sdes compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10225238106Sdes finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10226238106Sdes ;; 10227238106Sdes esac 10228238106Sdes 10229238106Sdes 10230238106Sdes # move library search paths that coincide with paths to not yet 10231238106Sdes # installed libraries to the beginning of the library search list 10232238106Sdes new_libs= 10233238106Sdes for path in $notinst_path; do 10234238106Sdes case " $new_libs " in 10235238106Sdes *" -L$path/$objdir "*) ;; 10236238106Sdes *) 10237238106Sdes case " $compile_deplibs " in 10238238106Sdes *" -L$path/$objdir "*) 10239238106Sdes func_append new_libs " -L$path/$objdir" ;; 10240238106Sdes esac 10241238106Sdes ;; 10242238106Sdes esac 10243238106Sdes done 10244238106Sdes for deplib in $compile_deplibs; do 10245238106Sdes case $deplib in 10246238106Sdes -L*) 10247238106Sdes case " $new_libs " in 10248238106Sdes *" $deplib "*) ;; 10249238106Sdes *) func_append new_libs " $deplib" ;; 10250238106Sdes esac 10251238106Sdes ;; 10252238106Sdes *) func_append new_libs " $deplib" ;; 10253238106Sdes esac 10254238106Sdes done 10255296415Sdes compile_deplibs=$new_libs 10256238106Sdes 10257238106Sdes 10258238106Sdes func_append compile_command " $compile_deplibs" 10259238106Sdes func_append finalize_command " $finalize_deplibs" 10260238106Sdes 10261238106Sdes if test -n "$rpath$xrpath"; then 10262238106Sdes # If the user specified any rpath flags, then add them. 10263238106Sdes for libdir in $rpath $xrpath; do 10264238106Sdes # This is the magic to use -rpath. 10265238106Sdes case "$finalize_rpath " in 10266238106Sdes *" $libdir "*) ;; 10267238106Sdes *) func_append finalize_rpath " $libdir" ;; 10268238106Sdes esac 10269238106Sdes done 10270238106Sdes fi 10271238106Sdes 10272238106Sdes # Now hardcode the library paths 10273238106Sdes rpath= 10274238106Sdes hardcode_libdirs= 10275238106Sdes for libdir in $compile_rpath $finalize_rpath; do 10276238106Sdes if test -n "$hardcode_libdir_flag_spec"; then 10277238106Sdes if test -n "$hardcode_libdir_separator"; then 10278238106Sdes if test -z "$hardcode_libdirs"; then 10279296415Sdes hardcode_libdirs=$libdir 10280238106Sdes else 10281238106Sdes # Just accumulate the unique libdirs. 10282238106Sdes case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10283238106Sdes *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10284238106Sdes ;; 10285238106Sdes *) 10286238106Sdes func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10287238106Sdes ;; 10288238106Sdes esac 10289238106Sdes fi 10290238106Sdes else 10291238106Sdes eval flag=\"$hardcode_libdir_flag_spec\" 10292238106Sdes func_append rpath " $flag" 10293238106Sdes fi 10294238106Sdes elif test -n "$runpath_var"; then 10295238106Sdes case "$perm_rpath " in 10296238106Sdes *" $libdir "*) ;; 10297238106Sdes *) func_append perm_rpath " $libdir" ;; 10298238106Sdes esac 10299238106Sdes fi 10300238106Sdes case $host in 10301238106Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10302296415Sdes testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10303238106Sdes case :$dllsearchpath: in 10304238106Sdes *":$libdir:"*) ;; 10305238106Sdes ::) dllsearchpath=$libdir;; 10306238106Sdes *) func_append dllsearchpath ":$libdir";; 10307238106Sdes esac 10308238106Sdes case :$dllsearchpath: in 10309238106Sdes *":$testbindir:"*) ;; 10310238106Sdes ::) dllsearchpath=$testbindir;; 10311238106Sdes *) func_append dllsearchpath ":$testbindir";; 10312238106Sdes esac 10313238106Sdes ;; 10314238106Sdes esac 10315238106Sdes done 10316238106Sdes # Substitute the hardcoded libdirs into the rpath. 10317238106Sdes if test -n "$hardcode_libdir_separator" && 10318238106Sdes test -n "$hardcode_libdirs"; then 10319296415Sdes libdir=$hardcode_libdirs 10320238106Sdes eval rpath=\" $hardcode_libdir_flag_spec\" 10321238106Sdes fi 10322296415Sdes compile_rpath=$rpath 10323238106Sdes 10324238106Sdes rpath= 10325238106Sdes hardcode_libdirs= 10326238106Sdes for libdir in $finalize_rpath; do 10327238106Sdes if test -n "$hardcode_libdir_flag_spec"; then 10328238106Sdes if test -n "$hardcode_libdir_separator"; then 10329238106Sdes if test -z "$hardcode_libdirs"; then 10330296415Sdes hardcode_libdirs=$libdir 10331238106Sdes else 10332238106Sdes # Just accumulate the unique libdirs. 10333238106Sdes case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10334238106Sdes *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10335238106Sdes ;; 10336238106Sdes *) 10337238106Sdes func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10338238106Sdes ;; 10339238106Sdes esac 10340238106Sdes fi 10341238106Sdes else 10342238106Sdes eval flag=\"$hardcode_libdir_flag_spec\" 10343238106Sdes func_append rpath " $flag" 10344238106Sdes fi 10345238106Sdes elif test -n "$runpath_var"; then 10346238106Sdes case "$finalize_perm_rpath " in 10347238106Sdes *" $libdir "*) ;; 10348238106Sdes *) func_append finalize_perm_rpath " $libdir" ;; 10349238106Sdes esac 10350238106Sdes fi 10351238106Sdes done 10352238106Sdes # Substitute the hardcoded libdirs into the rpath. 10353238106Sdes if test -n "$hardcode_libdir_separator" && 10354238106Sdes test -n "$hardcode_libdirs"; then 10355296415Sdes libdir=$hardcode_libdirs 10356238106Sdes eval rpath=\" $hardcode_libdir_flag_spec\" 10357238106Sdes fi 10358296415Sdes finalize_rpath=$rpath 10359238106Sdes 10360296415Sdes if test -n "$libobjs" && test yes = "$build_old_libs"; then 10361238106Sdes # Transform all the library objects into standard objects. 10362238106Sdes compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10363238106Sdes finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10364238106Sdes fi 10365238106Sdes 10366296415Sdes func_generate_dlsyms "$outputname" "@PROGRAM@" false 10367238106Sdes 10368238106Sdes # template prelinking step 10369238106Sdes if test -n "$prelink_cmds"; then 10370238106Sdes func_execute_cmds "$prelink_cmds" 'exit $?' 10371238106Sdes fi 10372238106Sdes 10373296415Sdes wrappers_required=: 10374238106Sdes case $host in 10375238106Sdes *cegcc* | *mingw32ce*) 10376238106Sdes # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10377296415Sdes wrappers_required=false 10378238106Sdes ;; 10379238106Sdes *cygwin* | *mingw* ) 10380296415Sdes test yes = "$build_libtool_libs" || wrappers_required=false 10381238106Sdes ;; 10382238106Sdes *) 10383296415Sdes if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10384296415Sdes wrappers_required=false 10385238106Sdes fi 10386238106Sdes ;; 10387238106Sdes esac 10388296415Sdes $wrappers_required || { 10389238106Sdes # Replace the output file specification. 10390238106Sdes compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10391296415Sdes link_command=$compile_command$compile_rpath 10392238106Sdes 10393238106Sdes # We have no uninstalled library dependencies, so finalize right now. 10394238106Sdes exit_status=0 10395238106Sdes func_show_eval "$link_command" 'exit_status=$?' 10396238106Sdes 10397238106Sdes if test -n "$postlink_cmds"; then 10398238106Sdes func_to_tool_file "$output" 10399238106Sdes postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10400238106Sdes func_execute_cmds "$postlink_cmds" 'exit $?' 10401238106Sdes fi 10402238106Sdes 10403238106Sdes # Delete the generated files. 10404296415Sdes if test -f "$output_objdir/${outputname}S.$objext"; then 10405296415Sdes func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10406238106Sdes fi 10407238106Sdes 10408238106Sdes exit $exit_status 10409296415Sdes } 10410238106Sdes 10411238106Sdes if test -n "$compile_shlibpath$finalize_shlibpath"; then 10412238106Sdes compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10413238106Sdes fi 10414238106Sdes if test -n "$finalize_shlibpath"; then 10415238106Sdes finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10416238106Sdes fi 10417238106Sdes 10418238106Sdes compile_var= 10419238106Sdes finalize_var= 10420238106Sdes if test -n "$runpath_var"; then 10421238106Sdes if test -n "$perm_rpath"; then 10422238106Sdes # We should set the runpath_var. 10423238106Sdes rpath= 10424238106Sdes for dir in $perm_rpath; do 10425238106Sdes func_append rpath "$dir:" 10426238106Sdes done 10427238106Sdes compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10428238106Sdes fi 10429238106Sdes if test -n "$finalize_perm_rpath"; then 10430238106Sdes # We should set the runpath_var. 10431238106Sdes rpath= 10432238106Sdes for dir in $finalize_perm_rpath; do 10433238106Sdes func_append rpath "$dir:" 10434238106Sdes done 10435238106Sdes finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10436238106Sdes fi 10437238106Sdes fi 10438238106Sdes 10439296415Sdes if test yes = "$no_install"; then 10440238106Sdes # We don't need to create a wrapper script. 10441296415Sdes link_command=$compile_var$compile_command$compile_rpath 10442238106Sdes # Replace the output file specification. 10443238106Sdes link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10444238106Sdes # Delete the old output file. 10445238106Sdes $opt_dry_run || $RM $output 10446238106Sdes # Link the executable and exit 10447238106Sdes func_show_eval "$link_command" 'exit $?' 10448238106Sdes 10449238106Sdes if test -n "$postlink_cmds"; then 10450238106Sdes func_to_tool_file "$output" 10451238106Sdes postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10452238106Sdes func_execute_cmds "$postlink_cmds" 'exit $?' 10453238106Sdes fi 10454238106Sdes 10455238106Sdes exit $EXIT_SUCCESS 10456238106Sdes fi 10457238106Sdes 10458296415Sdes case $hardcode_action,$fast_install in 10459296415Sdes relink,*) 10460296415Sdes # Fast installation is not supported 10461296415Sdes link_command=$compile_var$compile_command$compile_rpath 10462296415Sdes relink_command=$finalize_var$finalize_command$finalize_rpath 10463238106Sdes 10464296415Sdes func_warning "this platform does not like uninstalled shared libraries" 10465296415Sdes func_warning "'$output' will be relinked during installation" 10466296415Sdes ;; 10467296415Sdes *,yes) 10468296415Sdes link_command=$finalize_var$compile_command$finalize_rpath 10469296415Sdes relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10470296415Sdes ;; 10471296415Sdes *,no) 10472296415Sdes link_command=$compile_var$compile_command$compile_rpath 10473296415Sdes relink_command=$finalize_var$finalize_command$finalize_rpath 10474296415Sdes ;; 10475296415Sdes *,needless) 10476296415Sdes link_command=$finalize_var$compile_command$finalize_rpath 10477296415Sdes relink_command= 10478296415Sdes ;; 10479296415Sdes esac 10480238106Sdes 10481238106Sdes # Replace the output file specification. 10482238106Sdes link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10483238106Sdes 10484238106Sdes # Delete the old output files. 10485238106Sdes $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10486238106Sdes 10487238106Sdes func_show_eval "$link_command" 'exit $?' 10488238106Sdes 10489238106Sdes if test -n "$postlink_cmds"; then 10490238106Sdes func_to_tool_file "$output_objdir/$outputname" 10491238106Sdes postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10492238106Sdes func_execute_cmds "$postlink_cmds" 'exit $?' 10493238106Sdes fi 10494238106Sdes 10495238106Sdes # Now create the wrapper script. 10496238106Sdes func_verbose "creating $output" 10497238106Sdes 10498238106Sdes # Quote the relink command for shipping. 10499238106Sdes if test -n "$relink_command"; then 10500238106Sdes # Preserve any variables that may affect compiler behavior 10501238106Sdes for var in $variables_saved_for_relink; do 10502238106Sdes if eval test -z \"\${$var+set}\"; then 10503238106Sdes relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10504238106Sdes elif eval var_value=\$$var; test -z "$var_value"; then 10505238106Sdes relink_command="$var=; export $var; $relink_command" 10506238106Sdes else 10507238106Sdes func_quote_for_eval "$var_value" 10508238106Sdes relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10509238106Sdes fi 10510238106Sdes done 10511238106Sdes relink_command="(cd `pwd`; $relink_command)" 10512238106Sdes relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10513238106Sdes fi 10514238106Sdes 10515238106Sdes # Only actually do things if not in dry run mode. 10516238106Sdes $opt_dry_run || { 10517238106Sdes # win32 will think the script is a binary if it has 10518238106Sdes # a .exe suffix, so we strip it off here. 10519238106Sdes case $output in 10520238106Sdes *.exe) func_stripname '' '.exe' "$output" 10521238106Sdes output=$func_stripname_result ;; 10522238106Sdes esac 10523238106Sdes # test for cygwin because mv fails w/o .exe extensions 10524238106Sdes case $host in 10525238106Sdes *cygwin*) 10526238106Sdes exeext=.exe 10527238106Sdes func_stripname '' '.exe' "$outputname" 10528238106Sdes outputname=$func_stripname_result ;; 10529238106Sdes *) exeext= ;; 10530238106Sdes esac 10531238106Sdes case $host in 10532238106Sdes *cygwin* | *mingw* ) 10533238106Sdes func_dirname_and_basename "$output" "" "." 10534238106Sdes output_name=$func_basename_result 10535238106Sdes output_path=$func_dirname_result 10536296415Sdes cwrappersource=$output_path/$objdir/lt-$output_name.c 10537296415Sdes cwrapper=$output_path/$output_name.exe 10538238106Sdes $RM $cwrappersource $cwrapper 10539238106Sdes trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10540238106Sdes 10541238106Sdes func_emit_cwrapperexe_src > $cwrappersource 10542238106Sdes 10543238106Sdes # The wrapper executable is built using the $host compiler, 10544238106Sdes # because it contains $host paths and files. If cross- 10545238106Sdes # compiling, it, like the target executable, must be 10546238106Sdes # executed on the $host or under an emulation environment. 10547238106Sdes $opt_dry_run || { 10548238106Sdes $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10549238106Sdes $STRIP $cwrapper 10550238106Sdes } 10551238106Sdes 10552238106Sdes # Now, create the wrapper script for func_source use: 10553238106Sdes func_ltwrapper_scriptname $cwrapper 10554238106Sdes $RM $func_ltwrapper_scriptname_result 10555238106Sdes trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10556238106Sdes $opt_dry_run || { 10557238106Sdes # note: this script will not be executed, so do not chmod. 10558296415Sdes if test "x$build" = "x$host"; then 10559238106Sdes $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10560238106Sdes else 10561238106Sdes func_emit_wrapper no > $func_ltwrapper_scriptname_result 10562238106Sdes fi 10563238106Sdes } 10564238106Sdes ;; 10565238106Sdes * ) 10566238106Sdes $RM $output 10567238106Sdes trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10568238106Sdes 10569238106Sdes func_emit_wrapper no > $output 10570238106Sdes chmod +x $output 10571238106Sdes ;; 10572238106Sdes esac 10573238106Sdes } 10574238106Sdes exit $EXIT_SUCCESS 10575238106Sdes ;; 10576238106Sdes esac 10577238106Sdes 10578238106Sdes # See if we need to build an old-fashioned archive. 10579238106Sdes for oldlib in $oldlibs; do 10580238106Sdes 10581296415Sdes case $build_libtool_libs in 10582296415Sdes convenience) 10583296415Sdes oldobjs="$libobjs_save $symfileobj" 10584296415Sdes addlibs=$convenience 10585238106Sdes build_libtool_libs=no 10586296415Sdes ;; 10587296415Sdes module) 10588296415Sdes oldobjs=$libobjs_save 10589296415Sdes addlibs=$old_convenience 10590296415Sdes build_libtool_libs=no 10591296415Sdes ;; 10592296415Sdes *) 10593238106Sdes oldobjs="$old_deplibs $non_pic_objects" 10594296415Sdes $preload && test -f "$symfileobj" \ 10595296415Sdes && func_append oldobjs " $symfileobj" 10596296415Sdes addlibs=$old_convenience 10597296415Sdes ;; 10598296415Sdes esac 10599238106Sdes 10600238106Sdes if test -n "$addlibs"; then 10601296415Sdes gentop=$output_objdir/${outputname}x 10602238106Sdes func_append generated " $gentop" 10603238106Sdes 10604238106Sdes func_extract_archives $gentop $addlibs 10605238106Sdes func_append oldobjs " $func_extract_archives_result" 10606238106Sdes fi 10607238106Sdes 10608238106Sdes # Do each command in the archive commands. 10609296415Sdes if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10610238106Sdes cmds=$old_archive_from_new_cmds 10611238106Sdes else 10612238106Sdes 10613238106Sdes # Add any objects from preloaded convenience libraries 10614238106Sdes if test -n "$dlprefiles"; then 10615296415Sdes gentop=$output_objdir/${outputname}x 10616238106Sdes func_append generated " $gentop" 10617238106Sdes 10618238106Sdes func_extract_archives $gentop $dlprefiles 10619238106Sdes func_append oldobjs " $func_extract_archives_result" 10620238106Sdes fi 10621238106Sdes 10622238106Sdes # POSIX demands no paths to be encoded in archives. We have 10623238106Sdes # to avoid creating archives with duplicate basenames if we 10624238106Sdes # might have to extract them afterwards, e.g., when creating a 10625238106Sdes # static archive out of a convenience library, or when linking 10626238106Sdes # the entirety of a libtool archive into another (currently 10627238106Sdes # not supported by libtool). 10628238106Sdes if (for obj in $oldobjs 10629238106Sdes do 10630238106Sdes func_basename "$obj" 10631238106Sdes $ECHO "$func_basename_result" 10632238106Sdes done | sort | sort -uc >/dev/null 2>&1); then 10633238106Sdes : 10634238106Sdes else 10635238106Sdes echo "copying selected object files to avoid basename conflicts..." 10636296415Sdes gentop=$output_objdir/${outputname}x 10637238106Sdes func_append generated " $gentop" 10638238106Sdes func_mkdir_p "$gentop" 10639238106Sdes save_oldobjs=$oldobjs 10640238106Sdes oldobjs= 10641238106Sdes counter=1 10642238106Sdes for obj in $save_oldobjs 10643238106Sdes do 10644238106Sdes func_basename "$obj" 10645296415Sdes objbase=$func_basename_result 10646238106Sdes case " $oldobjs " in 10647238106Sdes " ") oldobjs=$obj ;; 10648238106Sdes *[\ /]"$objbase "*) 10649238106Sdes while :; do 10650238106Sdes # Make sure we don't pick an alternate name that also 10651238106Sdes # overlaps. 10652238106Sdes newobj=lt$counter-$objbase 10653238106Sdes func_arith $counter + 1 10654238106Sdes counter=$func_arith_result 10655238106Sdes case " $oldobjs " in 10656238106Sdes *[\ /]"$newobj "*) ;; 10657238106Sdes *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10658238106Sdes esac 10659238106Sdes done 10660238106Sdes func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10661238106Sdes func_append oldobjs " $gentop/$newobj" 10662238106Sdes ;; 10663238106Sdes *) func_append oldobjs " $obj" ;; 10664238106Sdes esac 10665238106Sdes done 10666238106Sdes fi 10667249141Sdes func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10668249141Sdes tool_oldlib=$func_to_tool_file_result 10669238106Sdes eval cmds=\"$old_archive_cmds\" 10670238106Sdes 10671238106Sdes func_len " $cmds" 10672238106Sdes len=$func_len_result 10673238106Sdes if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10674238106Sdes cmds=$old_archive_cmds 10675238106Sdes elif test -n "$archiver_list_spec"; then 10676238106Sdes func_verbose "using command file archive linking..." 10677238106Sdes for obj in $oldobjs 10678238106Sdes do 10679238106Sdes func_to_tool_file "$obj" 10680238106Sdes $ECHO "$func_to_tool_file_result" 10681238106Sdes done > $output_objdir/$libname.libcmd 10682238106Sdes func_to_tool_file "$output_objdir/$libname.libcmd" 10683238106Sdes oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10684238106Sdes cmds=$old_archive_cmds 10685238106Sdes else 10686238106Sdes # the command line is too long to link in one step, link in parts 10687238106Sdes func_verbose "using piecewise archive linking..." 10688238106Sdes save_RANLIB=$RANLIB 10689238106Sdes RANLIB=: 10690238106Sdes objlist= 10691238106Sdes concat_cmds= 10692238106Sdes save_oldobjs=$oldobjs 10693238106Sdes oldobjs= 10694238106Sdes # Is there a better way of finding the last object in the list? 10695238106Sdes for obj in $save_oldobjs 10696238106Sdes do 10697238106Sdes last_oldobj=$obj 10698238106Sdes done 10699238106Sdes eval test_cmds=\"$old_archive_cmds\" 10700238106Sdes func_len " $test_cmds" 10701238106Sdes len0=$func_len_result 10702238106Sdes len=$len0 10703238106Sdes for obj in $save_oldobjs 10704238106Sdes do 10705238106Sdes func_len " $obj" 10706238106Sdes func_arith $len + $func_len_result 10707238106Sdes len=$func_arith_result 10708238106Sdes func_append objlist " $obj" 10709238106Sdes if test "$len" -lt "$max_cmd_len"; then 10710238106Sdes : 10711238106Sdes else 10712238106Sdes # the above command should be used before it gets too long 10713238106Sdes oldobjs=$objlist 10714296415Sdes if test "$obj" = "$last_oldobj"; then 10715238106Sdes RANLIB=$save_RANLIB 10716238106Sdes fi 10717238106Sdes test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10718296415Sdes eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10719238106Sdes objlist= 10720238106Sdes len=$len0 10721238106Sdes fi 10722238106Sdes done 10723238106Sdes RANLIB=$save_RANLIB 10724238106Sdes oldobjs=$objlist 10725296415Sdes if test -z "$oldobjs"; then 10726238106Sdes eval cmds=\"\$concat_cmds\" 10727238106Sdes else 10728238106Sdes eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10729238106Sdes fi 10730238106Sdes fi 10731238106Sdes fi 10732238106Sdes func_execute_cmds "$cmds" 'exit $?' 10733238106Sdes done 10734238106Sdes 10735238106Sdes test -n "$generated" && \ 10736238106Sdes func_show_eval "${RM}r$generated" 10737238106Sdes 10738238106Sdes # Now create the libtool archive. 10739238106Sdes case $output in 10740238106Sdes *.la) 10741238106Sdes old_library= 10742296415Sdes test yes = "$build_old_libs" && old_library=$libname.$libext 10743238106Sdes func_verbose "creating $output" 10744238106Sdes 10745238106Sdes # Preserve any variables that may affect compiler behavior 10746238106Sdes for var in $variables_saved_for_relink; do 10747238106Sdes if eval test -z \"\${$var+set}\"; then 10748238106Sdes relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10749238106Sdes elif eval var_value=\$$var; test -z "$var_value"; then 10750238106Sdes relink_command="$var=; export $var; $relink_command" 10751238106Sdes else 10752238106Sdes func_quote_for_eval "$var_value" 10753238106Sdes relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10754238106Sdes fi 10755238106Sdes done 10756238106Sdes # Quote the link command for shipping. 10757296415Sdes relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10758238106Sdes relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10759296415Sdes if test yes = "$hardcode_automatic"; then 10760238106Sdes relink_command= 10761238106Sdes fi 10762238106Sdes 10763238106Sdes # Only create the output if not a dry run. 10764238106Sdes $opt_dry_run || { 10765238106Sdes for installed in no yes; do 10766296415Sdes if test yes = "$installed"; then 10767238106Sdes if test -z "$install_libdir"; then 10768238106Sdes break 10769238106Sdes fi 10770296415Sdes output=$output_objdir/${outputname}i 10771238106Sdes # Replace all uninstalled libtool libraries with the installed ones 10772238106Sdes newdependency_libs= 10773238106Sdes for deplib in $dependency_libs; do 10774238106Sdes case $deplib in 10775238106Sdes *.la) 10776238106Sdes func_basename "$deplib" 10777296415Sdes name=$func_basename_result 10778249141Sdes func_resolve_sysroot "$deplib" 10779296415Sdes eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10780238106Sdes test -z "$libdir" && \ 10781296415Sdes func_fatal_error "'$deplib' is not a valid libtool archive" 10782238106Sdes func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10783238106Sdes ;; 10784238106Sdes -L*) 10785238106Sdes func_stripname -L '' "$deplib" 10786238106Sdes func_replace_sysroot "$func_stripname_result" 10787238106Sdes func_append newdependency_libs " -L$func_replace_sysroot_result" 10788238106Sdes ;; 10789238106Sdes -R*) 10790238106Sdes func_stripname -R '' "$deplib" 10791238106Sdes func_replace_sysroot "$func_stripname_result" 10792238106Sdes func_append newdependency_libs " -R$func_replace_sysroot_result" 10793238106Sdes ;; 10794238106Sdes *) func_append newdependency_libs " $deplib" ;; 10795238106Sdes esac 10796238106Sdes done 10797296415Sdes dependency_libs=$newdependency_libs 10798238106Sdes newdlfiles= 10799238106Sdes 10800238106Sdes for lib in $dlfiles; do 10801238106Sdes case $lib in 10802238106Sdes *.la) 10803238106Sdes func_basename "$lib" 10804296415Sdes name=$func_basename_result 10805296415Sdes eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10806238106Sdes test -z "$libdir" && \ 10807296415Sdes func_fatal_error "'$lib' is not a valid libtool archive" 10808238106Sdes func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10809238106Sdes ;; 10810238106Sdes *) func_append newdlfiles " $lib" ;; 10811238106Sdes esac 10812238106Sdes done 10813296415Sdes dlfiles=$newdlfiles 10814238106Sdes newdlprefiles= 10815238106Sdes for lib in $dlprefiles; do 10816238106Sdes case $lib in 10817238106Sdes *.la) 10818238106Sdes # Only pass preopened files to the pseudo-archive (for 10819238106Sdes # eventual linking with the app. that links it) if we 10820238106Sdes # didn't already link the preopened objects directly into 10821238106Sdes # the library: 10822238106Sdes func_basename "$lib" 10823296415Sdes name=$func_basename_result 10824296415Sdes eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10825238106Sdes test -z "$libdir" && \ 10826296415Sdes func_fatal_error "'$lib' is not a valid libtool archive" 10827238106Sdes func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10828238106Sdes ;; 10829238106Sdes esac 10830238106Sdes done 10831296415Sdes dlprefiles=$newdlprefiles 10832238106Sdes else 10833238106Sdes newdlfiles= 10834238106Sdes for lib in $dlfiles; do 10835238106Sdes case $lib in 10836296415Sdes [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10837238106Sdes *) abs=`pwd`"/$lib" ;; 10838238106Sdes esac 10839238106Sdes func_append newdlfiles " $abs" 10840238106Sdes done 10841296415Sdes dlfiles=$newdlfiles 10842238106Sdes newdlprefiles= 10843238106Sdes for lib in $dlprefiles; do 10844238106Sdes case $lib in 10845296415Sdes [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10846238106Sdes *) abs=`pwd`"/$lib" ;; 10847238106Sdes esac 10848238106Sdes func_append newdlprefiles " $abs" 10849238106Sdes done 10850296415Sdes dlprefiles=$newdlprefiles 10851238106Sdes fi 10852238106Sdes $RM $output 10853238106Sdes # place dlname in correct position for cygwin 10854238106Sdes # In fact, it would be nice if we could use this code for all target 10855238106Sdes # systems that can't hard-code library paths into their executables 10856238106Sdes # and that have no shared library path variable independent of PATH, 10857238106Sdes # but it turns out we can't easily determine that from inspecting 10858238106Sdes # libtool variables, so we have to hard-code the OSs to which it 10859238106Sdes # applies here; at the moment, that means platforms that use the PE 10860238106Sdes # object format with DLL files. See the long comment at the top of 10861238106Sdes # tests/bindir.at for full details. 10862238106Sdes tdlname=$dlname 10863238106Sdes case $host,$output,$installed,$module,$dlname in 10864238106Sdes *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10865238106Sdes # If a -bindir argument was supplied, place the dll there. 10866296415Sdes if test -n "$bindir"; then 10867238106Sdes func_relative_path "$install_libdir" "$bindir" 10868296415Sdes tdlname=$func_relative_path_result/$dlname 10869238106Sdes else 10870238106Sdes # Otherwise fall back on heuristic. 10871238106Sdes tdlname=../bin/$dlname 10872238106Sdes fi 10873238106Sdes ;; 10874238106Sdes esac 10875238106Sdes $ECHO > $output "\ 10876238106Sdes# $outputname - a libtool library file 10877296415Sdes# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10878238106Sdes# 10879238106Sdes# Please DO NOT delete this file! 10880238106Sdes# It is necessary for linking the library. 10881238106Sdes 10882238106Sdes# The name that we can dlopen(3). 10883238106Sdesdlname='$tdlname' 10884238106Sdes 10885238106Sdes# Names of this library. 10886238106Sdeslibrary_names='$library_names' 10887238106Sdes 10888238106Sdes# The name of the static archive. 10889238106Sdesold_library='$old_library' 10890238106Sdes 10891296415Sdes# Linker flags that cannot go in dependency_libs. 10892238106Sdesinherited_linker_flags='$new_inherited_linker_flags' 10893238106Sdes 10894238106Sdes# Libraries that this one depends upon. 10895238106Sdesdependency_libs='$dependency_libs' 10896238106Sdes 10897238106Sdes# Names of additional weak libraries provided by this library 10898238106Sdesweak_library_names='$weak_libs' 10899238106Sdes 10900238106Sdes# Version information for $libname. 10901238106Sdescurrent=$current 10902238106Sdesage=$age 10903238106Sdesrevision=$revision 10904238106Sdes 10905238106Sdes# Is this an already installed library? 10906238106Sdesinstalled=$installed 10907238106Sdes 10908238106Sdes# Should we warn about portability when linking against -modules? 10909238106Sdesshouldnotlink=$module 10910238106Sdes 10911238106Sdes# Files to dlopen/dlpreopen 10912238106Sdesdlopen='$dlfiles' 10913238106Sdesdlpreopen='$dlprefiles' 10914238106Sdes 10915238106Sdes# Directory that this library needs to be installed in: 10916238106Sdeslibdir='$install_libdir'" 10917296415Sdes if test no,yes = "$installed,$need_relink"; then 10918238106Sdes $ECHO >> $output "\ 10919238106Sdesrelink_command=\"$relink_command\"" 10920238106Sdes fi 10921238106Sdes done 10922238106Sdes } 10923238106Sdes 10924238106Sdes # Do a symbolic link so that the libtool archive can be found in 10925238106Sdes # LD_LIBRARY_PATH before the program is installed. 10926238106Sdes func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10927238106Sdes ;; 10928238106Sdes esac 10929238106Sdes exit $EXIT_SUCCESS 10930238106Sdes} 10931238106Sdes 10932296415Sdesif test link = "$opt_mode" || test relink = "$opt_mode"; then 10933296415Sdes func_mode_link ${1+"$@"} 10934296415Sdesfi 10935238106Sdes 10936238106Sdes 10937238106Sdes# func_mode_uninstall arg... 10938238106Sdesfunc_mode_uninstall () 10939238106Sdes{ 10940296415Sdes $debug_cmd 10941296415Sdes 10942296415Sdes RM=$nonopt 10943238106Sdes files= 10944296415Sdes rmforce=false 10945238106Sdes exit_status=0 10946238106Sdes 10947238106Sdes # This variable tells wrapper scripts just to set variables rather 10948238106Sdes # than running their programs. 10949296415Sdes libtool_install_magic=$magic 10950238106Sdes 10951238106Sdes for arg 10952238106Sdes do 10953238106Sdes case $arg in 10954296415Sdes -f) func_append RM " $arg"; rmforce=: ;; 10955238106Sdes -*) func_append RM " $arg" ;; 10956238106Sdes *) func_append files " $arg" ;; 10957238106Sdes esac 10958238106Sdes done 10959238106Sdes 10960238106Sdes test -z "$RM" && \ 10961238106Sdes func_fatal_help "you must specify an RM program" 10962238106Sdes 10963238106Sdes rmdirs= 10964238106Sdes 10965238106Sdes for file in $files; do 10966238106Sdes func_dirname "$file" "" "." 10967296415Sdes dir=$func_dirname_result 10968296415Sdes if test . = "$dir"; then 10969296415Sdes odir=$objdir 10970238106Sdes else 10971296415Sdes odir=$dir/$objdir 10972238106Sdes fi 10973238106Sdes func_basename "$file" 10974296415Sdes name=$func_basename_result 10975296415Sdes test uninstall = "$opt_mode" && odir=$dir 10976238106Sdes 10977238106Sdes # Remember odir for removal later, being careful to avoid duplicates 10978296415Sdes if test clean = "$opt_mode"; then 10979238106Sdes case " $rmdirs " in 10980238106Sdes *" $odir "*) ;; 10981238106Sdes *) func_append rmdirs " $odir" ;; 10982238106Sdes esac 10983238106Sdes fi 10984238106Sdes 10985238106Sdes # Don't error if the file doesn't exist and rm -f was used. 10986238106Sdes if { test -L "$file"; } >/dev/null 2>&1 || 10987238106Sdes { test -h "$file"; } >/dev/null 2>&1 || 10988238106Sdes test -f "$file"; then 10989238106Sdes : 10990238106Sdes elif test -d "$file"; then 10991238106Sdes exit_status=1 10992238106Sdes continue 10993296415Sdes elif $rmforce; then 10994238106Sdes continue 10995238106Sdes fi 10996238106Sdes 10997296415Sdes rmfiles=$file 10998238106Sdes 10999238106Sdes case $name in 11000238106Sdes *.la) 11001238106Sdes # Possibly a libtool archive, so verify it. 11002238106Sdes if func_lalib_p "$file"; then 11003238106Sdes func_source $dir/$name 11004238106Sdes 11005238106Sdes # Delete the libtool libraries and symlinks. 11006238106Sdes for n in $library_names; do 11007238106Sdes func_append rmfiles " $odir/$n" 11008238106Sdes done 11009238106Sdes test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11010238106Sdes 11011296415Sdes case $opt_mode in 11012238106Sdes clean) 11013238106Sdes case " $library_names " in 11014238106Sdes *" $dlname "*) ;; 11015238106Sdes *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11016238106Sdes esac 11017238106Sdes test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11018238106Sdes ;; 11019238106Sdes uninstall) 11020238106Sdes if test -n "$library_names"; then 11021238106Sdes # Do each command in the postuninstall commands. 11022296415Sdes func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11023238106Sdes fi 11024238106Sdes 11025238106Sdes if test -n "$old_library"; then 11026238106Sdes # Do each command in the old_postuninstall commands. 11027296415Sdes func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11028238106Sdes fi 11029238106Sdes # FIXME: should reinstall the best remaining shared library. 11030238106Sdes ;; 11031238106Sdes esac 11032238106Sdes fi 11033238106Sdes ;; 11034238106Sdes 11035238106Sdes *.lo) 11036238106Sdes # Possibly a libtool object, so verify it. 11037238106Sdes if func_lalib_p "$file"; then 11038238106Sdes 11039238106Sdes # Read the .lo file 11040238106Sdes func_source $dir/$name 11041238106Sdes 11042238106Sdes # Add PIC object to the list of files to remove. 11043296415Sdes if test -n "$pic_object" && test none != "$pic_object"; then 11044238106Sdes func_append rmfiles " $dir/$pic_object" 11045238106Sdes fi 11046238106Sdes 11047238106Sdes # Add non-PIC object to the list of files to remove. 11048296415Sdes if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11049238106Sdes func_append rmfiles " $dir/$non_pic_object" 11050238106Sdes fi 11051238106Sdes fi 11052238106Sdes ;; 11053238106Sdes 11054238106Sdes *) 11055296415Sdes if test clean = "$opt_mode"; then 11056238106Sdes noexename=$name 11057238106Sdes case $file in 11058238106Sdes *.exe) 11059238106Sdes func_stripname '' '.exe' "$file" 11060238106Sdes file=$func_stripname_result 11061238106Sdes func_stripname '' '.exe' "$name" 11062238106Sdes noexename=$func_stripname_result 11063238106Sdes # $file with .exe has already been added to rmfiles, 11064238106Sdes # add $file without .exe 11065238106Sdes func_append rmfiles " $file" 11066238106Sdes ;; 11067238106Sdes esac 11068238106Sdes # Do a test to see if this is a libtool program. 11069238106Sdes if func_ltwrapper_p "$file"; then 11070238106Sdes if func_ltwrapper_executable_p "$file"; then 11071238106Sdes func_ltwrapper_scriptname "$file" 11072238106Sdes relink_command= 11073238106Sdes func_source $func_ltwrapper_scriptname_result 11074238106Sdes func_append rmfiles " $func_ltwrapper_scriptname_result" 11075238106Sdes else 11076238106Sdes relink_command= 11077238106Sdes func_source $dir/$noexename 11078238106Sdes fi 11079238106Sdes 11080238106Sdes # note $name still contains .exe if it was in $file originally 11081238106Sdes # as does the version of $file that was added into $rmfiles 11082296415Sdes func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11083296415Sdes if test yes = "$fast_install" && test -n "$relink_command"; then 11084238106Sdes func_append rmfiles " $odir/lt-$name" 11085238106Sdes fi 11086296415Sdes if test "X$noexename" != "X$name"; then 11087296415Sdes func_append rmfiles " $odir/lt-$noexename.c" 11088238106Sdes fi 11089238106Sdes fi 11090238106Sdes fi 11091238106Sdes ;; 11092238106Sdes esac 11093238106Sdes func_show_eval "$RM $rmfiles" 'exit_status=1' 11094238106Sdes done 11095238106Sdes 11096296415Sdes # Try to remove the $objdir's in the directories where we deleted files 11097238106Sdes for dir in $rmdirs; do 11098238106Sdes if test -d "$dir"; then 11099238106Sdes func_show_eval "rmdir $dir >/dev/null 2>&1" 11100238106Sdes fi 11101238106Sdes done 11102238106Sdes 11103238106Sdes exit $exit_status 11104238106Sdes} 11105238106Sdes 11106296415Sdesif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11107296415Sdes func_mode_uninstall ${1+"$@"} 11108296415Sdesfi 11109238106Sdes 11110238106Sdestest -z "$opt_mode" && { 11111296415Sdes help=$generic_help 11112238106Sdes func_fatal_help "you must specify a MODE" 11113238106Sdes} 11114238106Sdes 11115238106Sdestest -z "$exec_cmd" && \ 11116296415Sdes func_fatal_help "invalid operation mode '$opt_mode'" 11117238106Sdes 11118238106Sdesif test -n "$exec_cmd"; then 11119238106Sdes eval exec "$exec_cmd" 11120238106Sdes exit $EXIT_FAILURE 11121238106Sdesfi 11122238106Sdes 11123238106Sdesexit $exit_status 11124238106Sdes 11125238106Sdes 11126238106Sdes# The TAGs below are defined such that we never get into a situation 11127296415Sdes# where we disable both kinds of libraries. Given conflicting 11128238106Sdes# choices, we go for a static library, that is the most portable, 11129238106Sdes# since we can't tell whether shared libraries were disabled because 11130238106Sdes# the user asked for that or because the platform doesn't support 11131238106Sdes# them. This is particularly important on AIX, because we don't 11132238106Sdes# support having both static and shared libraries enabled at the same 11133238106Sdes# time on that platform, so we default to a shared-only configuration. 11134238106Sdes# If a disable-shared tag is given, we'll fallback to a static-only 11135238106Sdes# configuration. But we'll never go from static-only to shared-only. 11136238106Sdes 11137238106Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11138238106Sdesbuild_libtool_libs=no 11139238106Sdesbuild_old_libs=yes 11140238106Sdes# ### END LIBTOOL TAG CONFIG: disable-shared 11141238106Sdes 11142238106Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11143238106Sdesbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11144238106Sdes# ### END LIBTOOL TAG CONFIG: disable-static 11145238106Sdes 11146238106Sdes# Local Variables: 11147238106Sdes# mode:shell-script 11148238106Sdes# sh-indentation:2 11149238106Sdes# End: 11150