1285206Sdes#! /bin/sh 2285206Sdes## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3285206Sdes## by inline-source v2014-01-03.01 4238104Sdes 5285206Sdes# libtool (GNU libtool) 2.4.6 6285206Sdes# Provide generalized library-building support services. 7238104Sdes# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8238104Sdes 9285206Sdes# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10238104Sdes# This is free software; see the source for copying conditions. There is NO 11238104Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12238104Sdes 13238104Sdes# GNU Libtool is free software; you can redistribute it and/or modify 14238104Sdes# it under the terms of the GNU General Public License as published by 15238104Sdes# the Free Software Foundation; either version 2 of the License, or 16238104Sdes# (at your option) any later version. 17238104Sdes# 18238104Sdes# As a special exception to the GNU General Public License, 19238104Sdes# if you distribute this file as part of a program or library that 20238104Sdes# is built using GNU Libtool, you may include this file under the 21238104Sdes# same distribution terms that you use for the rest of that program. 22238104Sdes# 23238104Sdes# GNU Libtool is distributed in the hope that it will be useful, but 24238104Sdes# WITHOUT ANY WARRANTY; without even the implied warranty of 25238104Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26238104Sdes# General Public License for more details. 27238104Sdes# 28238104Sdes# You should have received a copy of the GNU General Public License 29285206Sdes# along with this program. If not, see <http://www.gnu.org/licenses/>. 30238104Sdes 31238104Sdes 32238104SdesPROGRAM=libtool 33238104SdesPACKAGE=libtool 34285206SdesVERSION=2.4.6 35285206Sdespackage_revision=2.4.6 36238104Sdes 37285206Sdes 38285206Sdes## ------ ## 39285206Sdes## Usage. ## 40285206Sdes## ------ ## 41285206Sdes 42285206Sdes# Run './libtool --help' for help with using this script from the 43285206Sdes# command line. 44285206Sdes 45285206Sdes 46285206Sdes## ------------------------------- ## 47285206Sdes## User overridable command paths. ## 48285206Sdes## ------------------------------- ## 49285206Sdes 50285206Sdes# After configure completes, it has a better idea of some of the 51285206Sdes# shell tools we need than the defaults used by the functions shared 52285206Sdes# with bootstrap, so set those here where they can still be over- 53285206Sdes# ridden by the user, but otherwise take precedence. 54285206Sdes 55285206Sdes: ${AUTOCONF="autoconf"} 56285206Sdes: ${AUTOMAKE="automake"} 57285206Sdes 58285206Sdes 59285206Sdes## -------------------------- ## 60285206Sdes## Source external libraries. ## 61285206Sdes## -------------------------- ## 62285206Sdes 63285206Sdes# Much of our low-level functionality needs to be sourced from external 64285206Sdes# libraries, which are installed to $pkgauxdir. 65285206Sdes 66285206Sdes# Set a version string for this script. 67285206Sdesscriptversion=2015-01-20.17; # UTC 68285206Sdes 69285206Sdes# General shell script boiler plate, and helper functions. 70285206Sdes# Written by Gary V. Vaughan, 2004 71285206Sdes 72285206Sdes# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73285206Sdes# This is free software; see the source for copying conditions. There is NO 74285206Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75285206Sdes 76285206Sdes# This program is free software; you can redistribute it and/or modify 77285206Sdes# it under the terms of the GNU General Public License as published by 78285206Sdes# the Free Software Foundation; either version 3 of the License, or 79285206Sdes# (at your option) any later version. 80285206Sdes 81285206Sdes# As a special exception to the GNU General Public License, if you distribute 82285206Sdes# this file as part of a program or library that is built using GNU Libtool, 83285206Sdes# you may include this file under the same distribution terms that you use 84285206Sdes# for the rest of that program. 85285206Sdes 86285206Sdes# This program is distributed in the hope that it will be useful, 87285206Sdes# but WITHOUT ANY WARRANTY; without even the implied warranty of 88285206Sdes# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89285206Sdes# General Public License for more details. 90285206Sdes 91285206Sdes# You should have received a copy of the GNU General Public License 92285206Sdes# along with this program. If not, see <http://www.gnu.org/licenses/>. 93285206Sdes 94285206Sdes# Please report bugs or propose patches to gary@gnu.org. 95285206Sdes 96285206Sdes 97285206Sdes## ------ ## 98285206Sdes## Usage. ## 99285206Sdes## ------ ## 100285206Sdes 101285206Sdes# Evaluate this file near the top of your script to gain access to 102285206Sdes# the functions and variables defined here: 103285206Sdes# 104285206Sdes# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105285206Sdes# 106285206Sdes# If you need to override any of the default environment variable 107285206Sdes# settings, do that before evaluating this file. 108285206Sdes 109285206Sdes 110285206Sdes## -------------------- ## 111285206Sdes## Shell normalisation. ## 112285206Sdes## -------------------- ## 113285206Sdes 114285206Sdes# Some shells need a little help to be as Bourne compatible as possible. 115285206Sdes# Before doing anything else, make sure all that help has been provided! 116285206Sdes 117285206SdesDUALCASE=1; export DUALCASE # for MKS sh 118285206Sdesif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119238104Sdes emulate sh 120238104Sdes NULLCMD=: 121285206Sdes # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122238104Sdes # is contrary to our usage. Disable this feature. 123238104Sdes alias -g '${1+"$@"}'='"$@"' 124238104Sdes setopt NO_GLOB_SUBST 125238104Sdeselse 126285206Sdes case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127238104Sdesfi 128238104Sdes 129285206Sdes# NLS nuisances: We save the old values in case they are required later. 130285206Sdes_G_user_locale= 131285206Sdes_G_safe_locale= 132285206Sdesfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133238104Sdesdo 134285206Sdes eval "if test set = \"\${$_G_var+set}\"; then 135285206Sdes save_$_G_var=\$$_G_var 136285206Sdes $_G_var=C 137285206Sdes export $_G_var 138285206Sdes _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139285206Sdes _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140238104Sdes fi" 141238104Sdesdone 142238104Sdes 143285206Sdes# CDPATH. 144285206Sdes(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145238104Sdes 146285206Sdes# Make sure IFS has a sensible default 147285206Sdessp=' ' 148285206Sdesnl=' 149285206Sdes' 150285206SdesIFS="$sp $nl" 151238104Sdes 152285206Sdes# There are apparently some retarded systems that use ';' as a PATH separator! 153285206Sdesif test "${PATH_SEPARATOR+set}" != set; then 154285206Sdes PATH_SEPARATOR=: 155285206Sdes (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156285206Sdes (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157285206Sdes PATH_SEPARATOR=';' 158285206Sdes } 159285206Sdesfi 160238104Sdes 161238104Sdes 162238104Sdes 163285206Sdes## ------------------------- ## 164285206Sdes## Locate command utilities. ## 165285206Sdes## ------------------------- ## 166285206Sdes 167285206Sdes 168285206Sdes# func_executable_p FILE 169285206Sdes# ---------------------- 170285206Sdes# Check that FILE is an executable regular file. 171285206Sdesfunc_executable_p () 172285206Sdes{ 173285206Sdes test -f "$1" && test -x "$1" 174285206Sdes} 175285206Sdes 176285206Sdes 177285206Sdes# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178285206Sdes# -------------------------------------------- 179285206Sdes# Search for either a program that responds to --version with output 180285206Sdes# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181285206Sdes# trying all the directories in PATH with each of the elements of 182285206Sdes# PROGS_LIST. 183285206Sdes# 184285206Sdes# CHECK_FUNC should accept the path to a candidate program, and 185285206Sdes# set $func_check_prog_result if it truncates its output less than 186285206Sdes# $_G_path_prog_max characters. 187285206Sdesfunc_path_progs () 188285206Sdes{ 189285206Sdes _G_progs_list=$1 190285206Sdes _G_check_func=$2 191285206Sdes _G_PATH=${3-"$PATH"} 192285206Sdes 193285206Sdes _G_path_prog_max=0 194285206Sdes _G_path_prog_found=false 195285206Sdes _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196285206Sdes for _G_dir in $_G_PATH; do 197285206Sdes IFS=$_G_save_IFS 198285206Sdes test -z "$_G_dir" && _G_dir=. 199285206Sdes for _G_prog_name in $_G_progs_list; do 200285206Sdes for _exeext in '' .EXE; do 201285206Sdes _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202285206Sdes func_executable_p "$_G_path_prog" || continue 203285206Sdes case `"$_G_path_prog" --version 2>&1` in 204285206Sdes *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205285206Sdes *) $_G_check_func $_G_path_prog 206285206Sdes func_path_progs_result=$func_check_prog_result 207285206Sdes ;; 208285206Sdes esac 209285206Sdes $_G_path_prog_found && break 3 210285206Sdes done 211285206Sdes done 212285206Sdes done 213285206Sdes IFS=$_G_save_IFS 214285206Sdes test -z "$func_path_progs_result" && { 215285206Sdes echo "no acceptable sed could be found in \$PATH" >&2 216285206Sdes exit 1 217285206Sdes } 218285206Sdes} 219285206Sdes 220285206Sdes 221285206Sdes# We want to be able to use the functions in this file before configure 222285206Sdes# has figured out where the best binaries are kept, which means we have 223285206Sdes# to search for them ourselves - except when the results are already set 224285206Sdes# where we skip the searches. 225285206Sdes 226285206Sdes# Unless the user overrides by setting SED, search the path for either GNU 227285206Sdes# sed, or the sed that truncates its output the least. 228285206Sdestest -z "$SED" && { 229285206Sdes _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230285206Sdes for _G_i in 1 2 3 4 5 6 7; do 231285206Sdes _G_sed_script=$_G_sed_script$nl$_G_sed_script 232285206Sdes done 233285206Sdes echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234285206Sdes _G_sed_script= 235285206Sdes 236285206Sdes func_check_prog_sed () 237285206Sdes { 238285206Sdes _G_path_prog=$1 239285206Sdes 240285206Sdes _G_count=0 241285206Sdes printf 0123456789 >conftest.in 242285206Sdes while : 243285206Sdes do 244285206Sdes cat conftest.in conftest.in >conftest.tmp 245285206Sdes mv conftest.tmp conftest.in 246285206Sdes cp conftest.in conftest.nl 247285206Sdes echo '' >> conftest.nl 248285206Sdes "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249285206Sdes diff conftest.out conftest.nl >/dev/null 2>&1 || break 250285206Sdes _G_count=`expr $_G_count + 1` 251285206Sdes if test "$_G_count" -gt "$_G_path_prog_max"; then 252285206Sdes # Best one so far, save it but keep looking for a better one 253285206Sdes func_check_prog_result=$_G_path_prog 254285206Sdes _G_path_prog_max=$_G_count 255285206Sdes fi 256285206Sdes # 10*(2^10) chars as input seems more than enough 257285206Sdes test 10 -lt "$_G_count" && break 258285206Sdes done 259285206Sdes rm -f conftest.in conftest.tmp conftest.nl conftest.out 260285206Sdes } 261285206Sdes 262285206Sdes func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263285206Sdes rm -f conftest.sed 264285206Sdes SED=$func_path_progs_result 265285206Sdes} 266285206Sdes 267285206Sdes 268285206Sdes# Unless the user overrides by setting GREP, search the path for either GNU 269285206Sdes# grep, or the grep that truncates its output the least. 270285206Sdestest -z "$GREP" && { 271285206Sdes func_check_prog_grep () 272285206Sdes { 273285206Sdes _G_path_prog=$1 274285206Sdes 275285206Sdes _G_count=0 276285206Sdes _G_path_prog_max=0 277285206Sdes printf 0123456789 >conftest.in 278285206Sdes while : 279285206Sdes do 280285206Sdes cat conftest.in conftest.in >conftest.tmp 281285206Sdes mv conftest.tmp conftest.in 282285206Sdes cp conftest.in conftest.nl 283285206Sdes echo 'GREP' >> conftest.nl 284285206Sdes "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285285206Sdes diff conftest.out conftest.nl >/dev/null 2>&1 || break 286285206Sdes _G_count=`expr $_G_count + 1` 287285206Sdes if test "$_G_count" -gt "$_G_path_prog_max"; then 288285206Sdes # Best one so far, save it but keep looking for a better one 289285206Sdes func_check_prog_result=$_G_path_prog 290285206Sdes _G_path_prog_max=$_G_count 291285206Sdes fi 292285206Sdes # 10*(2^10) chars as input seems more than enough 293285206Sdes test 10 -lt "$_G_count" && break 294285206Sdes done 295285206Sdes rm -f conftest.in conftest.tmp conftest.nl conftest.out 296285206Sdes } 297285206Sdes 298285206Sdes func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299285206Sdes GREP=$func_path_progs_result 300285206Sdes} 301285206Sdes 302285206Sdes 303285206Sdes## ------------------------------- ## 304285206Sdes## User overridable command paths. ## 305285206Sdes## ------------------------------- ## 306285206Sdes 307285206Sdes# All uppercase variable names are used for environment variables. These 308285206Sdes# variables can be overridden by the user before calling a script that 309285206Sdes# uses them if a suitable command of that name is not already available 310285206Sdes# in the command search PATH. 311285206Sdes 312238104Sdes: ${CP="cp -f"} 313285206Sdes: ${ECHO="printf %s\n"} 314285206Sdes: ${EGREP="$GREP -E"} 315285206Sdes: ${FGREP="$GREP -F"} 316285206Sdes: ${LN_S="ln -s"} 317238104Sdes: ${MAKE="make"} 318238104Sdes: ${MKDIR="mkdir"} 319238104Sdes: ${MV="mv -f"} 320238104Sdes: ${RM="rm -f"} 321238104Sdes: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322238104Sdes 323238104Sdes 324285206Sdes## -------------------- ## 325285206Sdes## Useful sed snippets. ## 326285206Sdes## -------------------- ## 327238104Sdes 328285206Sdessed_dirname='s|/[^/]*$||' 329285206Sdessed_basename='s|^.*/||' 330238104Sdes 331285206Sdes# Sed substitution that helps us do robust quoting. It backslashifies 332285206Sdes# metacharacters that are still active within double-quoted strings. 333285206Sdessed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334238104Sdes 335285206Sdes# Same as above, but do not quote variable references. 336285206Sdessed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337238104Sdes 338285206Sdes# Sed substitution that turns a string into a regex matching for the 339285206Sdes# string literally. 340285206Sdessed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341238104Sdes 342285206Sdes# Sed substitution that converts a w32 file name or path 343285206Sdes# that contains forward slashes, into one that contains 344285206Sdes# (escaped) backslashes. A very naive implementation. 345285206Sdessed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346238104Sdes 347285206Sdes# Re-'\' parameter expansions in output of sed_double_quote_subst that 348285206Sdes# were '\'-ed in input to the same. If an odd number of '\' preceded a 349285206Sdes# '$' in input to sed_double_quote_subst, that '$' was protected from 350285206Sdes# expansion. Since each input '\' is now two '\'s, look for any number 351285206Sdes# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352285206Sdes_G_bs='\\' 353285206Sdes_G_bs2='\\\\' 354285206Sdes_G_bs4='\\\\\\\\' 355285206Sdes_G_dollar='\$' 356285206Sdessed_double_backslash="\ 357285206Sdes s/$_G_bs4/&\\ 358285206Sdes/g 359285206Sdes s/^$_G_bs2$_G_dollar/$_G_bs&/ 360285206Sdes s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361285206Sdes s/\n//g" 362238104Sdes 363238104Sdes 364285206Sdes## ----------------- ## 365285206Sdes## Global variables. ## 366285206Sdes## ----------------- ## 367238104Sdes 368285206Sdes# Except for the global variables explicitly listed below, the following 369285206Sdes# functions in the '^func_' namespace, and the '^require_' namespace 370285206Sdes# variables initialised in the 'Resource management' section, sourcing 371285206Sdes# this file will not pollute your global namespace with anything 372285206Sdes# else. There's no portable way to scope variables in Bourne shell 373285206Sdes# though, so actually running these functions will sometimes place 374285206Sdes# results into a variable named after the function, and often use 375285206Sdes# temporary variables in the '^_G_' namespace. If you are careful to 376285206Sdes# avoid using those namespaces casually in your sourcing script, things 377285206Sdes# should continue to work as you expect. And, of course, you can freely 378285206Sdes# overwrite any of the functions or variables defined here before 379285206Sdes# calling anything to customize them. 380238104Sdes 381285206SdesEXIT_SUCCESS=0 382285206SdesEXIT_FAILURE=1 383285206SdesEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384285206SdesEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385238104Sdes 386285206Sdes# Allow overriding, eg assuming that you follow the convention of 387285206Sdes# putting '$debug_cmd' at the start of all your functions, you can get 388285206Sdes# bash to show function call trace with: 389285206Sdes# 390285206Sdes# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391285206Sdesdebug_cmd=${debug_cmd-":"} 392285206Sdesexit_cmd=: 393238104Sdes 394285206Sdes# By convention, finish your script with: 395285206Sdes# 396285206Sdes# exit $exit_status 397285206Sdes# 398285206Sdes# so that you can set exit_status to non-zero if you want to indicate 399285206Sdes# something went wrong during execution without actually bailing out at 400285206Sdes# the point of failure. 401285206Sdesexit_status=$EXIT_SUCCESS 402238104Sdes 403285206Sdes# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404285206Sdes# is ksh but when the shell is invoked as "sh" and the current value of 405285206Sdes# the _XPG environment variable is not equal to 1 (one), the special 406285206Sdes# positional parameter $0, within a function call, is the name of the 407285206Sdes# function. 408285206Sdesprogpath=$0 409238104Sdes 410285206Sdes# The name of this program. 411285206Sdesprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412238104Sdes 413285206Sdes# Make sure we have an absolute progpath for reexecution: 414238104Sdescase $progpath in 415238104Sdes [\\/]*|[A-Za-z]:\\*) ;; 416238104Sdes *[\\/]*) 417285206Sdes progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418238104Sdes progdir=`cd "$progdir" && pwd` 419285206Sdes progpath=$progdir/$progname 420238104Sdes ;; 421238104Sdes *) 422285206Sdes _G_IFS=$IFS 423238104Sdes IFS=${PATH_SEPARATOR-:} 424238104Sdes for progdir in $PATH; do 425285206Sdes IFS=$_G_IFS 426238104Sdes test -x "$progdir/$progname" && break 427238104Sdes done 428285206Sdes IFS=$_G_IFS 429238104Sdes test -n "$progdir" || progdir=`pwd` 430285206Sdes progpath=$progdir/$progname 431238104Sdes ;; 432238104Sdesesac 433238104Sdes 434238104Sdes 435285206Sdes## ----------------- ## 436285206Sdes## Standard options. ## 437285206Sdes## ----------------- ## 438238104Sdes 439285206Sdes# The following options affect the operation of the functions defined 440285206Sdes# below, and should be set appropriately depending on run-time para- 441285206Sdes# meters passed on the command line. 442238104Sdes 443238104Sdesopt_dry_run=false 444238104Sdesopt_quiet=false 445238104Sdesopt_verbose=false 446238104Sdes 447285206Sdes# Categories 'all' and 'none' are always available. Append any others 448285206Sdes# you will pass as the first argument to func_warning from your own 449285206Sdes# code. 450285206Sdeswarning_categories= 451285206Sdes 452285206Sdes# By default, display warnings according to 'opt_warning_types'. Set 453285206Sdes# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454285206Sdes# treat the next displayed warning as a fatal error. 455285206Sdeswarning_func=func_warn_and_continue 456285206Sdes 457285206Sdes# Set to 'all' to display all warnings, 'none' to suppress all 458285206Sdes# warnings, or a space delimited list of some subset of 459285206Sdes# 'warning_categories' to display only the listed warnings. 460285206Sdesopt_warning_types=all 461285206Sdes 462285206Sdes 463285206Sdes## -------------------- ## 464285206Sdes## Resource management. ## 465285206Sdes## -------------------- ## 466285206Sdes 467285206Sdes# This section contains definitions for functions that each ensure a 468285206Sdes# particular resource (a file, or a non-empty configuration variable for 469285206Sdes# example) is available, and if appropriate to extract default values 470285206Sdes# from pertinent package files. Call them using their associated 471285206Sdes# 'require_*' variable to ensure that they are executed, at most, once. 472285206Sdes# 473285206Sdes# It's entirely deliberate that calling these functions can set 474285206Sdes# variables that don't obey the namespace limitations obeyed by the rest 475285206Sdes# of this file, in order that that they be as useful as possible to 476285206Sdes# callers. 477285206Sdes 478285206Sdes 479285206Sdes# require_term_colors 480285206Sdes# ------------------- 481285206Sdes# Allow display of bold text on terminals that support it. 482285206Sdesrequire_term_colors=func_require_term_colors 483285206Sdesfunc_require_term_colors () 484238104Sdes{ 485285206Sdes $debug_cmd 486285206Sdes 487285206Sdes test -t 1 && { 488285206Sdes # COLORTERM and USE_ANSI_COLORS environment variables take 489285206Sdes # precedence, because most terminfo databases neglect to describe 490285206Sdes # whether color sequences are supported. 491285206Sdes test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492285206Sdes 493285206Sdes if test 1 = "$USE_ANSI_COLORS"; then 494285206Sdes # Standard ANSI escape sequences 495285206Sdes tc_reset='[0m' 496285206Sdes tc_bold='[1m'; tc_standout='[7m' 497285206Sdes tc_red='[31m'; tc_green='[32m' 498285206Sdes tc_blue='[34m'; tc_cyan='[36m' 499285206Sdes else 500285206Sdes # Otherwise trust the terminfo database after all. 501285206Sdes test -n "`tput sgr0 2>/dev/null`" && { 502285206Sdes tc_reset=`tput sgr0` 503285206Sdes test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504285206Sdes tc_standout=$tc_bold 505285206Sdes test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506285206Sdes test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507285206Sdes test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508285206Sdes test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509285206Sdes test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510285206Sdes } 511285206Sdes fi 512285206Sdes } 513285206Sdes 514285206Sdes require_term_colors=: 515238104Sdes} 516238104Sdes 517285206Sdes 518285206Sdes## ----------------- ## 519285206Sdes## Function library. ## 520285206Sdes## ----------------- ## 521285206Sdes 522285206Sdes# This section contains a variety of useful functions to call in your 523285206Sdes# scripts. Take note of the portable wrappers for features provided by 524285206Sdes# some modern shells, which will fall back to slower equivalents on 525285206Sdes# less featureful shells. 526285206Sdes 527285206Sdes 528285206Sdes# func_append VAR VALUE 529285206Sdes# --------------------- 530285206Sdes# Append VALUE onto the existing contents of VAR. 531285206Sdes 532285206Sdes # We should try to minimise forks, especially on Windows where they are 533285206Sdes # unreasonably slow, so skip the feature probes when bash or zsh are 534285206Sdes # being used: 535285206Sdes if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536285206Sdes : ${_G_HAVE_ARITH_OP="yes"} 537285206Sdes : ${_G_HAVE_XSI_OPS="yes"} 538285206Sdes # The += operator was introduced in bash 3.1 539285206Sdes case $BASH_VERSION in 540285206Sdes [12].* | 3.0 | 3.0*) ;; 541285206Sdes *) 542285206Sdes : ${_G_HAVE_PLUSEQ_OP="yes"} 543285206Sdes ;; 544285206Sdes esac 545285206Sdes fi 546285206Sdes 547285206Sdes # _G_HAVE_PLUSEQ_OP 548285206Sdes # Can be empty, in which case the shell is probed, "yes" if += is 549285206Sdes # useable or anything else if it does not work. 550285206Sdes test -z "$_G_HAVE_PLUSEQ_OP" \ 551285206Sdes && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552285206Sdes && _G_HAVE_PLUSEQ_OP=yes 553285206Sdes 554285206Sdesif test yes = "$_G_HAVE_PLUSEQ_OP" 555285206Sdesthen 556285206Sdes # This is an XSI compatible shell, allowing a faster implementation... 557285206Sdes eval 'func_append () 558285206Sdes { 559285206Sdes $debug_cmd 560285206Sdes 561285206Sdes eval "$1+=\$2" 562285206Sdes }' 563285206Sdeselse 564285206Sdes # ...otherwise fall back to using expr, which is often a shell builtin. 565285206Sdes func_append () 566285206Sdes { 567285206Sdes $debug_cmd 568285206Sdes 569285206Sdes eval "$1=\$$1\$2" 570285206Sdes } 571285206Sdesfi 572285206Sdes 573285206Sdes 574285206Sdes# func_append_quoted VAR VALUE 575285206Sdes# ---------------------------- 576285206Sdes# Quote VALUE and append to the end of shell variable VAR, separated 577285206Sdes# by a space. 578285206Sdesif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579285206Sdes eval 'func_append_quoted () 580285206Sdes { 581285206Sdes $debug_cmd 582285206Sdes 583285206Sdes func_quote_for_eval "$2" 584285206Sdes eval "$1+=\\ \$func_quote_for_eval_result" 585285206Sdes }' 586285206Sdeselse 587285206Sdes func_append_quoted () 588285206Sdes { 589285206Sdes $debug_cmd 590285206Sdes 591285206Sdes func_quote_for_eval "$2" 592285206Sdes eval "$1=\$$1\\ \$func_quote_for_eval_result" 593285206Sdes } 594285206Sdesfi 595285206Sdes 596285206Sdes 597285206Sdes# func_append_uniq VAR VALUE 598285206Sdes# -------------------------- 599285206Sdes# Append unique VALUE onto the existing contents of VAR, assuming 600285206Sdes# entries are delimited by the first character of VALUE. For example: 601285206Sdes# 602285206Sdes# func_append_uniq options " --another-option option-argument" 603285206Sdes# 604285206Sdes# will only append to $options if " --another-option option-argument " 605285206Sdes# is not already present somewhere in $options already (note spaces at 606285206Sdes# each end implied by leading space in second argument). 607285206Sdesfunc_append_uniq () 608238104Sdes{ 609285206Sdes $debug_cmd 610238104Sdes 611285206Sdes eval _G_current_value='`$ECHO $'$1'`' 612285206Sdes _G_delim=`expr "$2" : '\(.\)'` 613285206Sdes 614285206Sdes case $_G_delim$_G_current_value$_G_delim in 615285206Sdes *"$2$_G_delim"*) ;; 616285206Sdes *) func_append "$@" ;; 617285206Sdes esac 618238104Sdes} 619238104Sdes 620285206Sdes 621285206Sdes# func_arith TERM... 622285206Sdes# ------------------ 623285206Sdes# Set func_arith_result to the result of evaluating TERMs. 624285206Sdes test -z "$_G_HAVE_ARITH_OP" \ 625285206Sdes && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626285206Sdes && _G_HAVE_ARITH_OP=yes 627285206Sdes 628285206Sdesif test yes = "$_G_HAVE_ARITH_OP"; then 629285206Sdes eval 'func_arith () 630285206Sdes { 631285206Sdes $debug_cmd 632285206Sdes 633285206Sdes func_arith_result=$(( $* )) 634285206Sdes }' 635285206Sdeselse 636285206Sdes func_arith () 637285206Sdes { 638285206Sdes $debug_cmd 639285206Sdes 640285206Sdes func_arith_result=`expr "$@"` 641285206Sdes } 642285206Sdesfi 643285206Sdes 644285206Sdes 645285206Sdes# func_basename FILE 646285206Sdes# ------------------ 647285206Sdes# Set func_basename_result to FILE with everything up to and including 648285206Sdes# the last / stripped. 649285206Sdesif test yes = "$_G_HAVE_XSI_OPS"; then 650285206Sdes # If this shell supports suffix pattern removal, then use it to avoid 651285206Sdes # forking. Hide the definitions single quotes in case the shell chokes 652285206Sdes # on unsupported syntax... 653285206Sdes _b='func_basename_result=${1##*/}' 654285206Sdes _d='case $1 in 655285206Sdes */*) func_dirname_result=${1%/*}$2 ;; 656285206Sdes * ) func_dirname_result=$3 ;; 657285206Sdes esac' 658285206Sdes 659285206Sdeselse 660285206Sdes # ...otherwise fall back to using sed. 661285206Sdes _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662285206Sdes _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663285206Sdes if test "X$func_dirname_result" = "X$1"; then 664285206Sdes func_dirname_result=$3 665285206Sdes else 666285206Sdes func_append func_dirname_result "$2" 667285206Sdes fi' 668285206Sdesfi 669285206Sdes 670285206Sdeseval 'func_basename () 671285206Sdes{ 672285206Sdes $debug_cmd 673285206Sdes 674285206Sdes '"$_b"' 675285206Sdes}' 676285206Sdes 677285206Sdes 678285206Sdes# func_dirname FILE APPEND NONDIR_REPLACEMENT 679285206Sdes# ------------------------------------------- 680285206Sdes# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681285206Sdes# otherwise set result to NONDIR_REPLACEMENT. 682285206Sdeseval 'func_dirname () 683285206Sdes{ 684285206Sdes $debug_cmd 685285206Sdes 686285206Sdes '"$_d"' 687285206Sdes}' 688285206Sdes 689285206Sdes 690285206Sdes# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691285206Sdes# -------------------------------------------------------- 692285206Sdes# Perform func_basename and func_dirname in a single function 693285206Sdes# call: 694285206Sdes# dirname: Compute the dirname of FILE. If nonempty, 695285206Sdes# add APPEND to the result, otherwise set result 696285206Sdes# to NONDIR_REPLACEMENT. 697285206Sdes# value returned in "$func_dirname_result" 698285206Sdes# basename: Compute filename of FILE. 699285206Sdes# value retuned in "$func_basename_result" 700285206Sdes# For efficiency, we do not delegate to the functions above but instead 701285206Sdes# duplicate the functionality here. 702285206Sdeseval 'func_dirname_and_basename () 703285206Sdes{ 704285206Sdes $debug_cmd 705285206Sdes 706285206Sdes '"$_b"' 707285206Sdes '"$_d"' 708285206Sdes}' 709285206Sdes 710285206Sdes 711285206Sdes# func_echo ARG... 712285206Sdes# ---------------- 713285206Sdes# Echo program name prefixed message. 714285206Sdesfunc_echo () 715285206Sdes{ 716285206Sdes $debug_cmd 717285206Sdes 718285206Sdes _G_message=$* 719285206Sdes 720285206Sdes func_echo_IFS=$IFS 721285206Sdes IFS=$nl 722285206Sdes for _G_line in $_G_message; do 723285206Sdes IFS=$func_echo_IFS 724285206Sdes $ECHO "$progname: $_G_line" 725285206Sdes done 726285206Sdes IFS=$func_echo_IFS 727285206Sdes} 728285206Sdes 729285206Sdes 730285206Sdes# func_echo_all ARG... 731285206Sdes# -------------------- 732238104Sdes# Invoke $ECHO with all args, space-separated. 733238104Sdesfunc_echo_all () 734238104Sdes{ 735238104Sdes $ECHO "$*" 736238104Sdes} 737238104Sdes 738285206Sdes 739285206Sdes# func_echo_infix_1 INFIX ARG... 740285206Sdes# ------------------------------ 741285206Sdes# Echo program name, followed by INFIX on the first line, with any 742285206Sdes# additional lines not showing INFIX. 743285206Sdesfunc_echo_infix_1 () 744238104Sdes{ 745285206Sdes $debug_cmd 746285206Sdes 747285206Sdes $require_term_colors 748285206Sdes 749285206Sdes _G_infix=$1; shift 750285206Sdes _G_indent=$_G_infix 751285206Sdes _G_prefix="$progname: $_G_infix: " 752285206Sdes _G_message=$* 753285206Sdes 754285206Sdes # Strip color escape sequences before counting printable length 755285206Sdes for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756285206Sdes do 757285206Sdes test -n "$_G_tc" && { 758285206Sdes _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759285206Sdes _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760285206Sdes } 761285206Sdes done 762285206Sdes _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763285206Sdes 764285206Sdes func_echo_infix_1_IFS=$IFS 765285206Sdes IFS=$nl 766285206Sdes for _G_line in $_G_message; do 767285206Sdes IFS=$func_echo_infix_1_IFS 768285206Sdes $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769285206Sdes _G_prefix=$_G_indent 770285206Sdes done 771285206Sdes IFS=$func_echo_infix_1_IFS 772238104Sdes} 773238104Sdes 774285206Sdes 775285206Sdes# func_error ARG... 776285206Sdes# ----------------- 777285206Sdes# Echo program name prefixed message to standard error. 778285206Sdesfunc_error () 779238104Sdes{ 780285206Sdes $debug_cmd 781238104Sdes 782285206Sdes $require_term_colors 783285206Sdes 784285206Sdes func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785238104Sdes} 786238104Sdes 787285206Sdes 788285206Sdes# func_fatal_error ARG... 789285206Sdes# ----------------------- 790238104Sdes# Echo program name prefixed message to standard error, and exit. 791238104Sdesfunc_fatal_error () 792238104Sdes{ 793285206Sdes $debug_cmd 794285206Sdes 795285206Sdes func_error "$*" 796238104Sdes exit $EXIT_FAILURE 797238104Sdes} 798238104Sdes 799238104Sdes 800285206Sdes# func_grep EXPRESSION FILENAME 801285206Sdes# ----------------------------- 802238104Sdes# Check whether EXPRESSION matches any line of FILENAME, without output. 803238104Sdesfunc_grep () 804238104Sdes{ 805285206Sdes $debug_cmd 806285206Sdes 807238104Sdes $GREP "$1" "$2" >/dev/null 2>&1 808238104Sdes} 809238104Sdes 810238104Sdes 811285206Sdes# func_len STRING 812285206Sdes# --------------- 813285206Sdes# Set func_len_result to the length of STRING. STRING may not 814285206Sdes# start with a hyphen. 815285206Sdes test -z "$_G_HAVE_XSI_OPS" \ 816285206Sdes && (eval 'x=a/b/c; 817285206Sdes test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818285206Sdes && _G_HAVE_XSI_OPS=yes 819285206Sdes 820285206Sdesif test yes = "$_G_HAVE_XSI_OPS"; then 821285206Sdes eval 'func_len () 822285206Sdes { 823285206Sdes $debug_cmd 824285206Sdes 825285206Sdes func_len_result=${#1} 826285206Sdes }' 827285206Sdeselse 828285206Sdes func_len () 829285206Sdes { 830285206Sdes $debug_cmd 831285206Sdes 832285206Sdes func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833285206Sdes } 834285206Sdesfi 835285206Sdes 836285206Sdes 837285206Sdes# func_mkdir_p DIRECTORY-PATH 838285206Sdes# --------------------------- 839238104Sdes# Make sure the entire path to DIRECTORY-PATH is available. 840238104Sdesfunc_mkdir_p () 841238104Sdes{ 842285206Sdes $debug_cmd 843238104Sdes 844285206Sdes _G_directory_path=$1 845285206Sdes _G_dir_list= 846238104Sdes 847285206Sdes if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848285206Sdes 849285206Sdes # Protect directory names starting with '-' 850285206Sdes case $_G_directory_path in 851285206Sdes -*) _G_directory_path=./$_G_directory_path ;; 852238104Sdes esac 853238104Sdes 854238104Sdes # While some portion of DIR does not yet exist... 855285206Sdes while test ! -d "$_G_directory_path"; do 856238104Sdes # ...make a list in topmost first order. Use a colon delimited 857238104Sdes # list incase some portion of path contains whitespace. 858285206Sdes _G_dir_list=$_G_directory_path:$_G_dir_list 859238104Sdes 860238104Sdes # If the last portion added has no slash in it, the list is done 861285206Sdes case $_G_directory_path in */*) ;; *) break ;; esac 862238104Sdes 863238104Sdes # ...otherwise throw away the child directory and loop 864285206Sdes _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865238104Sdes done 866285206Sdes _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867238104Sdes 868285206Sdes func_mkdir_p_IFS=$IFS; IFS=: 869285206Sdes for _G_dir in $_G_dir_list; do 870285206Sdes IFS=$func_mkdir_p_IFS 871285206Sdes # mkdir can fail with a 'File exist' error if two processes 872238104Sdes # try to create one of the directories concurrently. Don't 873238104Sdes # stop in that case! 874285206Sdes $MKDIR "$_G_dir" 2>/dev/null || : 875238104Sdes done 876285206Sdes IFS=$func_mkdir_p_IFS 877238104Sdes 878238104Sdes # Bail out if we (or some other process) failed to create a directory. 879285206Sdes test -d "$_G_directory_path" || \ 880285206Sdes func_fatal_error "Failed to create '$1'" 881238104Sdes fi 882238104Sdes} 883238104Sdes 884238104Sdes 885285206Sdes# func_mktempdir [BASENAME] 886285206Sdes# ------------------------- 887238104Sdes# Make a temporary directory that won't clash with other running 888238104Sdes# libtool processes, and avoids race conditions if possible. If 889285206Sdes# given, BASENAME is the basename for that directory. 890238104Sdesfunc_mktempdir () 891238104Sdes{ 892285206Sdes $debug_cmd 893238104Sdes 894285206Sdes _G_template=${TMPDIR-/tmp}/${1-$progname} 895285206Sdes 896285206Sdes if test : = "$opt_dry_run"; then 897238104Sdes # Return a directory name, but don't create it in dry-run mode 898285206Sdes _G_tmpdir=$_G_template-$$ 899238104Sdes else 900238104Sdes 901238104Sdes # If mktemp works, use that first and foremost 902285206Sdes _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903238104Sdes 904285206Sdes if test ! -d "$_G_tmpdir"; then 905238104Sdes # Failing that, at least try and use $RANDOM to avoid a race 906285206Sdes _G_tmpdir=$_G_template-${RANDOM-0}$$ 907238104Sdes 908285206Sdes func_mktempdir_umask=`umask` 909238104Sdes umask 0077 910285206Sdes $MKDIR "$_G_tmpdir" 911285206Sdes umask $func_mktempdir_umask 912238104Sdes fi 913238104Sdes 914238104Sdes # If we're not in dry-run mode, bomb out on failure 915285206Sdes test -d "$_G_tmpdir" || \ 916285206Sdes func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917238104Sdes fi 918238104Sdes 919285206Sdes $ECHO "$_G_tmpdir" 920238104Sdes} 921238104Sdes 922238104Sdes 923285206Sdes# func_normal_abspath PATH 924285206Sdes# ------------------------ 925285206Sdes# Remove doubled-up and trailing slashes, "." path components, 926285206Sdes# and cancel out any ".." path components in PATH after making 927285206Sdes# it an absolute path. 928285206Sdesfunc_normal_abspath () 929238104Sdes{ 930285206Sdes $debug_cmd 931238104Sdes 932285206Sdes # These SED scripts presuppose an absolute path with a trailing slash. 933285206Sdes _G_pathcar='s|^/\([^/]*\).*$|\1|' 934285206Sdes _G_pathcdr='s|^/[^/]*||' 935285206Sdes _G_removedotparts=':dotsl 936285206Sdes s|/\./|/|g 937285206Sdes t dotsl 938285206Sdes s|/\.$|/|' 939285206Sdes _G_collapseslashes='s|/\{1,\}|/|g' 940285206Sdes _G_finalslash='s|/*$|/|' 941285206Sdes 942285206Sdes # Start from root dir and reassemble the path. 943285206Sdes func_normal_abspath_result= 944285206Sdes func_normal_abspath_tpath=$1 945285206Sdes func_normal_abspath_altnamespace= 946285206Sdes case $func_normal_abspath_tpath in 947285206Sdes "") 948285206Sdes # Empty path, that just means $cwd. 949285206Sdes func_stripname '' '/' "`pwd`" 950285206Sdes func_normal_abspath_result=$func_stripname_result 951285206Sdes return 952238104Sdes ;; 953285206Sdes # The next three entries are used to spot a run of precisely 954285206Sdes # two leading slashes without using negated character classes; 955285206Sdes # we take advantage of case's first-match behaviour. 956285206Sdes ///*) 957285206Sdes # Unusual form of absolute path, do nothing. 958285206Sdes ;; 959285206Sdes //*) 960285206Sdes # Not necessarily an ordinary path; POSIX reserves leading '//' 961285206Sdes # and for example Cygwin uses it to access remote file shares 962285206Sdes # over CIFS/SMB, so we conserve a leading double slash if found. 963285206Sdes func_normal_abspath_altnamespace=/ 964285206Sdes ;; 965285206Sdes /*) 966285206Sdes # Absolute path, do nothing. 967285206Sdes ;; 968238104Sdes *) 969285206Sdes # Relative path, prepend $cwd. 970285206Sdes func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971285206Sdes ;; 972238104Sdes esac 973285206Sdes 974285206Sdes # Cancel out all the simple stuff to save iterations. We also want 975285206Sdes # the path to end with a slash for ease of parsing, so make sure 976285206Sdes # there is one (and only one) here. 977285206Sdes func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978285206Sdes -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979285206Sdes while :; do 980285206Sdes # Processed it all yet? 981285206Sdes if test / = "$func_normal_abspath_tpath"; then 982285206Sdes # If we ascended to the root using ".." the result may be empty now. 983285206Sdes if test -z "$func_normal_abspath_result"; then 984285206Sdes func_normal_abspath_result=/ 985285206Sdes fi 986285206Sdes break 987285206Sdes fi 988285206Sdes func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989285206Sdes -e "$_G_pathcar"` 990285206Sdes func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991285206Sdes -e "$_G_pathcdr"` 992285206Sdes # Figure out what to do with it 993285206Sdes case $func_normal_abspath_tcomponent in 994285206Sdes "") 995285206Sdes # Trailing empty path component, ignore it. 996285206Sdes ;; 997285206Sdes ..) 998285206Sdes # Parent dir; strip last assembled component from result. 999285206Sdes func_dirname "$func_normal_abspath_result" 1000285206Sdes func_normal_abspath_result=$func_dirname_result 1001285206Sdes ;; 1002285206Sdes *) 1003285206Sdes # Actual path component, append it. 1004285206Sdes func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005285206Sdes ;; 1006285206Sdes esac 1007285206Sdes done 1008285206Sdes # Restore leading double-slash if one was found on entry. 1009285206Sdes func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010238104Sdes} 1011238104Sdes 1012238104Sdes 1013285206Sdes# func_notquiet ARG... 1014285206Sdes# -------------------- 1015285206Sdes# Echo program name prefixed message only when not in quiet mode. 1016285206Sdesfunc_notquiet () 1017285206Sdes{ 1018285206Sdes $debug_cmd 1019285206Sdes 1020285206Sdes $opt_quiet || func_echo ${1+"$@"} 1021285206Sdes 1022285206Sdes # A bug in bash halts the script if the last line of a function 1023285206Sdes # fails when set -e is in force, so we need another command to 1024285206Sdes # work around that: 1025285206Sdes : 1026285206Sdes} 1027285206Sdes 1028285206Sdes 1029285206Sdes# func_relative_path SRCDIR DSTDIR 1030285206Sdes# -------------------------------- 1031285206Sdes# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032285206Sdesfunc_relative_path () 1033285206Sdes{ 1034285206Sdes $debug_cmd 1035285206Sdes 1036285206Sdes func_relative_path_result= 1037285206Sdes func_normal_abspath "$1" 1038285206Sdes func_relative_path_tlibdir=$func_normal_abspath_result 1039285206Sdes func_normal_abspath "$2" 1040285206Sdes func_relative_path_tbindir=$func_normal_abspath_result 1041285206Sdes 1042285206Sdes # Ascend the tree starting from libdir 1043285206Sdes while :; do 1044285206Sdes # check if we have found a prefix of bindir 1045285206Sdes case $func_relative_path_tbindir in 1046285206Sdes $func_relative_path_tlibdir) 1047285206Sdes # found an exact match 1048285206Sdes func_relative_path_tcancelled= 1049285206Sdes break 1050285206Sdes ;; 1051285206Sdes $func_relative_path_tlibdir*) 1052285206Sdes # found a matching prefix 1053285206Sdes func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054285206Sdes func_relative_path_tcancelled=$func_stripname_result 1055285206Sdes if test -z "$func_relative_path_result"; then 1056285206Sdes func_relative_path_result=. 1057285206Sdes fi 1058285206Sdes break 1059285206Sdes ;; 1060285206Sdes *) 1061285206Sdes func_dirname $func_relative_path_tlibdir 1062285206Sdes func_relative_path_tlibdir=$func_dirname_result 1063285206Sdes if test -z "$func_relative_path_tlibdir"; then 1064285206Sdes # Have to descend all the way to the root! 1065285206Sdes func_relative_path_result=../$func_relative_path_result 1066285206Sdes func_relative_path_tcancelled=$func_relative_path_tbindir 1067285206Sdes break 1068285206Sdes fi 1069285206Sdes func_relative_path_result=../$func_relative_path_result 1070285206Sdes ;; 1071285206Sdes esac 1072285206Sdes done 1073285206Sdes 1074285206Sdes # Now calculate path; take care to avoid doubling-up slashes. 1075285206Sdes func_stripname '' '/' "$func_relative_path_result" 1076285206Sdes func_relative_path_result=$func_stripname_result 1077285206Sdes func_stripname '/' '/' "$func_relative_path_tcancelled" 1078285206Sdes if test -n "$func_stripname_result"; then 1079285206Sdes func_append func_relative_path_result "/$func_stripname_result" 1080285206Sdes fi 1081285206Sdes 1082285206Sdes # Normalisation. If bindir is libdir, return '.' else relative path. 1083285206Sdes if test -n "$func_relative_path_result"; then 1084285206Sdes func_stripname './' '' "$func_relative_path_result" 1085285206Sdes func_relative_path_result=$func_stripname_result 1086285206Sdes fi 1087285206Sdes 1088285206Sdes test -n "$func_relative_path_result" || func_relative_path_result=. 1089285206Sdes 1090285206Sdes : 1091285206Sdes} 1092285206Sdes 1093285206Sdes 1094285206Sdes# func_quote_for_eval ARG... 1095285206Sdes# -------------------------- 1096285206Sdes# Aesthetically quote ARGs to be evaled later. 1097285206Sdes# This function returns two values: 1098285206Sdes# i) func_quote_for_eval_result 1099285206Sdes# double-quoted, suitable for a subsequent eval 1100285206Sdes# ii) func_quote_for_eval_unquoted_result 1101285206Sdes# has all characters that are still active within double 1102285206Sdes# quotes backslashified. 1103285206Sdesfunc_quote_for_eval () 1104285206Sdes{ 1105285206Sdes $debug_cmd 1106285206Sdes 1107285206Sdes func_quote_for_eval_unquoted_result= 1108285206Sdes func_quote_for_eval_result= 1109285206Sdes while test 0 -lt $#; do 1110285206Sdes case $1 in 1111285206Sdes *[\\\`\"\$]*) 1112285206Sdes _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113285206Sdes *) 1114285206Sdes _G_unquoted_arg=$1 ;; 1115285206Sdes esac 1116285206Sdes if test -n "$func_quote_for_eval_unquoted_result"; then 1117285206Sdes func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118285206Sdes else 1119285206Sdes func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120285206Sdes fi 1121285206Sdes 1122285206Sdes case $_G_unquoted_arg in 1123285206Sdes # Double-quote args containing shell metacharacters to delay 1124285206Sdes # word splitting, command substitution and variable expansion 1125285206Sdes # for a subsequent eval. 1126285206Sdes # Many Bourne shells cannot handle close brackets correctly 1127285206Sdes # in scan sets, so we specify it separately. 1128285206Sdes *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129285206Sdes _G_quoted_arg=\"$_G_unquoted_arg\" 1130285206Sdes ;; 1131285206Sdes *) 1132285206Sdes _G_quoted_arg=$_G_unquoted_arg 1133285206Sdes ;; 1134285206Sdes esac 1135285206Sdes 1136285206Sdes if test -n "$func_quote_for_eval_result"; then 1137285206Sdes func_append func_quote_for_eval_result " $_G_quoted_arg" 1138285206Sdes else 1139285206Sdes func_append func_quote_for_eval_result "$_G_quoted_arg" 1140285206Sdes fi 1141285206Sdes shift 1142285206Sdes done 1143285206Sdes} 1144285206Sdes 1145285206Sdes 1146285206Sdes# func_quote_for_expand ARG 1147285206Sdes# ------------------------- 1148238104Sdes# Aesthetically quote ARG to be evaled later; same as above, 1149238104Sdes# but do not quote variable references. 1150238104Sdesfunc_quote_for_expand () 1151238104Sdes{ 1152285206Sdes $debug_cmd 1153285206Sdes 1154238104Sdes case $1 in 1155238104Sdes *[\\\`\"]*) 1156285206Sdes _G_arg=`$ECHO "$1" | $SED \ 1157285206Sdes -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1158238104Sdes *) 1159285206Sdes _G_arg=$1 ;; 1160238104Sdes esac 1161238104Sdes 1162285206Sdes case $_G_arg in 1163238104Sdes # Double-quote args containing shell metacharacters to delay 1164238104Sdes # word splitting and command substitution for a subsequent eval. 1165238104Sdes # Many Bourne shells cannot handle close brackets correctly 1166238104Sdes # in scan sets, so we specify it separately. 1167238104Sdes *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168285206Sdes _G_arg=\"$_G_arg\" 1169238104Sdes ;; 1170238104Sdes esac 1171238104Sdes 1172285206Sdes func_quote_for_expand_result=$_G_arg 1173238104Sdes} 1174238104Sdes 1175238104Sdes 1176285206Sdes# func_stripname PREFIX SUFFIX NAME 1177285206Sdes# --------------------------------- 1178285206Sdes# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179285206Sdes# PREFIX and SUFFIX must not contain globbing or regex special 1180285206Sdes# characters, hashes, percent signs, but SUFFIX may contain a leading 1181285206Sdes# dot (in which case that matches only a dot). 1182285206Sdesif test yes = "$_G_HAVE_XSI_OPS"; then 1183285206Sdes eval 'func_stripname () 1184285206Sdes { 1185285206Sdes $debug_cmd 1186285206Sdes 1187285206Sdes # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188285206Sdes # positional parameters, so assign one to ordinary variable first. 1189285206Sdes func_stripname_result=$3 1190285206Sdes func_stripname_result=${func_stripname_result#"$1"} 1191285206Sdes func_stripname_result=${func_stripname_result%"$2"} 1192285206Sdes }' 1193285206Sdeselse 1194285206Sdes func_stripname () 1195285206Sdes { 1196285206Sdes $debug_cmd 1197285206Sdes 1198285206Sdes case $2 in 1199285206Sdes .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200285206Sdes *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201285206Sdes esac 1202285206Sdes } 1203285206Sdesfi 1204285206Sdes 1205285206Sdes 1206285206Sdes# func_show_eval CMD [FAIL_EXP] 1207285206Sdes# ----------------------------- 1208285206Sdes# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209238104Sdes# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210238104Sdes# is given, then evaluate it. 1211238104Sdesfunc_show_eval () 1212238104Sdes{ 1213285206Sdes $debug_cmd 1214238104Sdes 1215285206Sdes _G_cmd=$1 1216285206Sdes _G_fail_exp=${2-':'} 1217238104Sdes 1218285206Sdes func_quote_for_expand "$_G_cmd" 1219285206Sdes eval "func_notquiet $func_quote_for_expand_result" 1220285206Sdes 1221285206Sdes $opt_dry_run || { 1222285206Sdes eval "$_G_cmd" 1223285206Sdes _G_status=$? 1224285206Sdes if test 0 -ne "$_G_status"; then 1225285206Sdes eval "(exit $_G_status); $_G_fail_exp" 1226238104Sdes fi 1227285206Sdes } 1228238104Sdes} 1229238104Sdes 1230238104Sdes 1231285206Sdes# func_show_eval_locale CMD [FAIL_EXP] 1232285206Sdes# ------------------------------------ 1233285206Sdes# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234238104Sdes# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235238104Sdes# is given, then evaluate it. Use the saved locale for evaluation. 1236238104Sdesfunc_show_eval_locale () 1237238104Sdes{ 1238285206Sdes $debug_cmd 1239238104Sdes 1240285206Sdes _G_cmd=$1 1241285206Sdes _G_fail_exp=${2-':'} 1242285206Sdes 1243285206Sdes $opt_quiet || { 1244285206Sdes func_quote_for_expand "$_G_cmd" 1245238104Sdes eval "func_echo $func_quote_for_expand_result" 1246238104Sdes } 1247238104Sdes 1248285206Sdes $opt_dry_run || { 1249285206Sdes eval "$_G_user_locale 1250285206Sdes $_G_cmd" 1251285206Sdes _G_status=$? 1252285206Sdes eval "$_G_safe_locale" 1253285206Sdes if test 0 -ne "$_G_status"; then 1254285206Sdes eval "(exit $_G_status); $_G_fail_exp" 1255238104Sdes fi 1256285206Sdes } 1257238104Sdes} 1258238104Sdes 1259285206Sdes 1260238104Sdes# func_tr_sh 1261285206Sdes# ---------- 1262238104Sdes# Turn $1 into a string suitable for a shell variable name. 1263238104Sdes# Result is stored in $func_tr_sh_result. All characters 1264238104Sdes# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265238104Sdes# if $1 begins with a digit, a '_' is prepended as well. 1266238104Sdesfunc_tr_sh () 1267238104Sdes{ 1268285206Sdes $debug_cmd 1269285206Sdes 1270285206Sdes case $1 in 1271285206Sdes [0-9]* | *[!a-zA-Z0-9_]*) 1272285206Sdes func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273285206Sdes ;; 1274285206Sdes * ) 1275285206Sdes func_tr_sh_result=$1 1276285206Sdes ;; 1277285206Sdes esac 1278238104Sdes} 1279238104Sdes 1280238104Sdes 1281285206Sdes# func_verbose ARG... 1282285206Sdes# ------------------- 1283285206Sdes# Echo program name prefixed message in verbose mode only. 1284285206Sdesfunc_verbose () 1285238104Sdes{ 1286285206Sdes $debug_cmd 1287238104Sdes 1288285206Sdes $opt_verbose && func_echo "$*" 1289285206Sdes 1290285206Sdes : 1291238104Sdes} 1292238104Sdes 1293285206Sdes 1294285206Sdes# func_warn_and_continue ARG... 1295285206Sdes# ----------------------------- 1296285206Sdes# Echo program name prefixed warning message to standard error. 1297285206Sdesfunc_warn_and_continue () 1298238104Sdes{ 1299285206Sdes $debug_cmd 1300238104Sdes 1301285206Sdes $require_term_colors 1302285206Sdes 1303285206Sdes func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304238104Sdes} 1305238104Sdes 1306285206Sdes 1307285206Sdes# func_warning CATEGORY ARG... 1308285206Sdes# ---------------------------- 1309285206Sdes# Echo program name prefixed warning message to standard error. Warning 1310285206Sdes# messages can be filtered according to CATEGORY, where this function 1311285206Sdes# elides messages where CATEGORY is not listed in the global variable 1312285206Sdes# 'opt_warning_types'. 1313285206Sdesfunc_warning () 1314285206Sdes{ 1315285206Sdes $debug_cmd 1316285206Sdes 1317285206Sdes # CATEGORY must be in the warning_categories list! 1318285206Sdes case " $warning_categories " in 1319285206Sdes *" $1 "*) ;; 1320285206Sdes *) func_internal_error "invalid warning category '$1'" ;; 1321285206Sdes esac 1322285206Sdes 1323285206Sdes _G_category=$1 1324285206Sdes shift 1325285206Sdes 1326285206Sdes case " $opt_warning_types " in 1327285206Sdes *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328285206Sdes esac 1329285206Sdes} 1330285206Sdes 1331285206Sdes 1332285206Sdes# func_sort_ver VER1 VER2 1333285206Sdes# ----------------------- 1334285206Sdes# 'sort -V' is not generally available. 1335285206Sdes# Note this deviates from the version comparison in automake 1336285206Sdes# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337285206Sdes# but this should suffice as we won't be specifying old 1338285206Sdes# version formats or redundant trailing .0 in bootstrap.conf. 1339285206Sdes# If we did want full compatibility then we should probably 1340285206Sdes# use m4_version_compare from autoconf. 1341285206Sdesfunc_sort_ver () 1342285206Sdes{ 1343285206Sdes $debug_cmd 1344285206Sdes 1345285206Sdes printf '%s\n%s\n' "$1" "$2" \ 1346285206Sdes | 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 1347285206Sdes} 1348285206Sdes 1349285206Sdes# func_lt_ver PREV CURR 1350285206Sdes# --------------------- 1351285206Sdes# Return true if PREV and CURR are in the correct order according to 1352285206Sdes# func_sort_ver, otherwise false. Use it like this: 1353285206Sdes# 1354285206Sdes# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355285206Sdesfunc_lt_ver () 1356285206Sdes{ 1357285206Sdes $debug_cmd 1358285206Sdes 1359285206Sdes test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360285206Sdes} 1361285206Sdes 1362285206Sdes 1363285206Sdes# Local variables: 1364285206Sdes# mode: shell-script 1365285206Sdes# sh-indentation: 2 1366285206Sdes# eval: (add-hook 'before-save-hook 'time-stamp) 1367285206Sdes# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368285206Sdes# time-stamp-time-zone: "UTC" 1369285206Sdes# End: 1370285206Sdes#! /bin/sh 1371285206Sdes 1372285206Sdes# Set a version string for this script. 1373285206Sdesscriptversion=2014-01-07.03; # UTC 1374285206Sdes 1375285206Sdes# A portable, pluggable option parser for Bourne shell. 1376285206Sdes# Written by Gary V. Vaughan, 2010 1377285206Sdes 1378285206Sdes# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379285206Sdes# This is free software; see the source for copying conditions. There is NO 1380285206Sdes# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381285206Sdes 1382285206Sdes# This program is free software: you can redistribute it and/or modify 1383285206Sdes# it under the terms of the GNU General Public License as published by 1384285206Sdes# the Free Software Foundation, either version 3 of the License, or 1385285206Sdes# (at your option) any later version. 1386285206Sdes 1387285206Sdes# This program is distributed in the hope that it will be useful, 1388285206Sdes# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389285206Sdes# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390285206Sdes# GNU General Public License for more details. 1391285206Sdes 1392285206Sdes# You should have received a copy of the GNU General Public License 1393285206Sdes# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394285206Sdes 1395285206Sdes# Please report bugs or propose patches to gary@gnu.org. 1396285206Sdes 1397285206Sdes 1398285206Sdes## ------ ## 1399285206Sdes## Usage. ## 1400285206Sdes## ------ ## 1401285206Sdes 1402285206Sdes# This file is a library for parsing options in your shell scripts along 1403285206Sdes# with assorted other useful supporting features that you can make use 1404285206Sdes# of too. 1405285206Sdes# 1406285206Sdes# For the simplest scripts you might need only: 1407285206Sdes# 1408285206Sdes# #!/bin/sh 1409285206Sdes# . relative/path/to/funclib.sh 1410285206Sdes# . relative/path/to/options-parser 1411285206Sdes# scriptversion=1.0 1412285206Sdes# func_options ${1+"$@"} 1413285206Sdes# eval set dummy "$func_options_result"; shift 1414285206Sdes# ...rest of your script... 1415285206Sdes# 1416285206Sdes# In order for the '--version' option to work, you will need to have a 1417285206Sdes# suitably formatted comment like the one at the top of this file 1418285206Sdes# starting with '# Written by ' and ending with '# warranty; '. 1419285206Sdes# 1420285206Sdes# For '-h' and '--help' to work, you will also need a one line 1421285206Sdes# description of your script's purpose in a comment directly above the 1422285206Sdes# '# Written by ' line, like the one at the top of this file. 1423285206Sdes# 1424285206Sdes# The default options also support '--debug', which will turn on shell 1425285206Sdes# execution tracing (see the comment above debug_cmd below for another 1426285206Sdes# use), and '--verbose' and the func_verbose function to allow your script 1427285206Sdes# to display verbose messages only when your user has specified 1428285206Sdes# '--verbose'. 1429285206Sdes# 1430285206Sdes# After sourcing this file, you can plug processing for additional 1431285206Sdes# options by amending the variables from the 'Configuration' section 1432285206Sdes# below, and following the instructions in the 'Option parsing' 1433285206Sdes# section further down. 1434285206Sdes 1435285206Sdes## -------------- ## 1436285206Sdes## Configuration. ## 1437285206Sdes## -------------- ## 1438285206Sdes 1439285206Sdes# You should override these variables in your script after sourcing this 1440285206Sdes# file so that they reflect the customisations you have added to the 1441285206Sdes# option parser. 1442285206Sdes 1443285206Sdes# The usage line for option parsing errors and the start of '-h' and 1444285206Sdes# '--help' output messages. You can embed shell variables for delayed 1445285206Sdes# expansion at the time the message is displayed, but you will need to 1446285206Sdes# quote other shell meta-characters carefully to prevent them being 1447285206Sdes# expanded when the contents are evaled. 1448285206Sdesusage='$progpath [OPTION]...' 1449285206Sdes 1450285206Sdes# Short help message in response to '-h' and '--help'. Add to this or 1451285206Sdes# override it after sourcing this library to reflect the full set of 1452285206Sdes# options your script accepts. 1453285206Sdesusage_message="\ 1454285206Sdes --debug enable verbose shell tracing 1455285206Sdes -W, --warnings=CATEGORY 1456285206Sdes report the warnings falling in CATEGORY [all] 1457285206Sdes -v, --verbose verbosely report processing 1458285206Sdes --version print version information and exit 1459285206Sdes -h, --help print short or long help message and exit 1460285206Sdes" 1461285206Sdes 1462285206Sdes# Additional text appended to 'usage_message' in response to '--help'. 1463285206Sdeslong_help_message=" 1464285206SdesWarning categories include: 1465285206Sdes 'all' show all warnings 1466285206Sdes 'none' turn off all the warnings 1467285206Sdes 'error' warnings are treated as fatal errors" 1468285206Sdes 1469285206Sdes# Help message printed before fatal option parsing errors. 1470285206Sdesfatal_help="Try '\$progname --help' for more information." 1471285206Sdes 1472285206Sdes 1473285206Sdes 1474285206Sdes## ------------------------- ## 1475285206Sdes## Hook function management. ## 1476285206Sdes## ------------------------- ## 1477285206Sdes 1478285206Sdes# This section contains functions for adding, removing, and running hooks 1479285206Sdes# to the main code. A hook is just a named list of of function, that can 1480285206Sdes# be run in order later on. 1481285206Sdes 1482285206Sdes# func_hookable FUNC_NAME 1483285206Sdes# ----------------------- 1484285206Sdes# Declare that FUNC_NAME will run hooks added with 1485285206Sdes# 'func_add_hook FUNC_NAME ...'. 1486285206Sdesfunc_hookable () 1487285206Sdes{ 1488285206Sdes $debug_cmd 1489285206Sdes 1490285206Sdes func_append hookable_fns " $1" 1491285206Sdes} 1492285206Sdes 1493285206Sdes 1494285206Sdes# func_add_hook FUNC_NAME HOOK_FUNC 1495285206Sdes# --------------------------------- 1496285206Sdes# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497285206Sdes# first have been declared "hookable" by a call to 'func_hookable'. 1498285206Sdesfunc_add_hook () 1499285206Sdes{ 1500285206Sdes $debug_cmd 1501285206Sdes 1502285206Sdes case " $hookable_fns " in 1503285206Sdes *" $1 "*) ;; 1504285206Sdes *) func_fatal_error "'$1' does not accept hook functions." ;; 1505285206Sdes esac 1506285206Sdes 1507285206Sdes eval func_append ${1}_hooks '" $2"' 1508285206Sdes} 1509285206Sdes 1510285206Sdes 1511285206Sdes# func_remove_hook FUNC_NAME HOOK_FUNC 1512285206Sdes# ------------------------------------ 1513285206Sdes# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514285206Sdesfunc_remove_hook () 1515285206Sdes{ 1516285206Sdes $debug_cmd 1517285206Sdes 1518285206Sdes eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519285206Sdes} 1520285206Sdes 1521285206Sdes 1522285206Sdes# func_run_hooks FUNC_NAME [ARG]... 1523285206Sdes# --------------------------------- 1524285206Sdes# Run all hook functions registered to FUNC_NAME. 1525285206Sdes# It is assumed that the list of hook functions contains nothing more 1526285206Sdes# than a whitespace-delimited list of legal shell function names, and 1527285206Sdes# no effort is wasted trying to catch shell meta-characters or preserve 1528285206Sdes# whitespace. 1529285206Sdesfunc_run_hooks () 1530285206Sdes{ 1531285206Sdes $debug_cmd 1532285206Sdes 1533285206Sdes case " $hookable_fns " in 1534285206Sdes *" $1 "*) ;; 1535285206Sdes *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536285206Sdes esac 1537285206Sdes 1538285206Sdes eval _G_hook_fns=\$$1_hooks; shift 1539285206Sdes 1540285206Sdes for _G_hook in $_G_hook_fns; do 1541285206Sdes eval $_G_hook '"$@"' 1542285206Sdes 1543285206Sdes # store returned options list back into positional 1544285206Sdes # parameters for next 'cmd' execution. 1545285206Sdes eval _G_hook_result=\$${_G_hook}_result 1546285206Sdes eval set dummy "$_G_hook_result"; shift 1547285206Sdes done 1548285206Sdes 1549285206Sdes func_quote_for_eval ${1+"$@"} 1550285206Sdes func_run_hooks_result=$func_quote_for_eval_result 1551285206Sdes} 1552285206Sdes 1553285206Sdes 1554285206Sdes 1555285206Sdes## --------------- ## 1556285206Sdes## Option parsing. ## 1557285206Sdes## --------------- ## 1558285206Sdes 1559285206Sdes# In order to add your own option parsing hooks, you must accept the 1560285206Sdes# full positional parameter list in your hook function, remove any 1561285206Sdes# options that you action, and then pass back the remaining unprocessed 1562285206Sdes# options in '<hooked_function_name>_result', escaped suitably for 1563285206Sdes# 'eval'. Like this: 1564285206Sdes# 1565285206Sdes# my_options_prep () 1566285206Sdes# { 1567285206Sdes# $debug_cmd 1568285206Sdes# 1569285206Sdes# # Extend the existing usage message. 1570285206Sdes# usage_message=$usage_message' 1571285206Sdes# -s, --silent don'\''t print informational messages 1572285206Sdes# ' 1573285206Sdes# 1574285206Sdes# func_quote_for_eval ${1+"$@"} 1575285206Sdes# my_options_prep_result=$func_quote_for_eval_result 1576285206Sdes# } 1577285206Sdes# func_add_hook func_options_prep my_options_prep 1578285206Sdes# 1579285206Sdes# 1580285206Sdes# my_silent_option () 1581285206Sdes# { 1582285206Sdes# $debug_cmd 1583285206Sdes# 1584285206Sdes# # Note that for efficiency, we parse as many options as we can 1585285206Sdes# # recognise in a loop before passing the remainder back to the 1586285206Sdes# # caller on the first unrecognised argument we encounter. 1587285206Sdes# while test $# -gt 0; do 1588285206Sdes# opt=$1; shift 1589285206Sdes# case $opt in 1590285206Sdes# --silent|-s) opt_silent=: ;; 1591285206Sdes# # Separate non-argument short options: 1592285206Sdes# -s*) func_split_short_opt "$_G_opt" 1593285206Sdes# set dummy "$func_split_short_opt_name" \ 1594285206Sdes# "-$func_split_short_opt_arg" ${1+"$@"} 1595285206Sdes# shift 1596285206Sdes# ;; 1597285206Sdes# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598285206Sdes# esac 1599285206Sdes# done 1600285206Sdes# 1601285206Sdes# func_quote_for_eval ${1+"$@"} 1602285206Sdes# my_silent_option_result=$func_quote_for_eval_result 1603285206Sdes# } 1604285206Sdes# func_add_hook func_parse_options my_silent_option 1605285206Sdes# 1606285206Sdes# 1607285206Sdes# my_option_validation () 1608285206Sdes# { 1609285206Sdes# $debug_cmd 1610285206Sdes# 1611285206Sdes# $opt_silent && $opt_verbose && func_fatal_help "\ 1612285206Sdes# '--silent' and '--verbose' options are mutually exclusive." 1613285206Sdes# 1614285206Sdes# func_quote_for_eval ${1+"$@"} 1615285206Sdes# my_option_validation_result=$func_quote_for_eval_result 1616285206Sdes# } 1617285206Sdes# func_add_hook func_validate_options my_option_validation 1618285206Sdes# 1619285206Sdes# You'll alse need to manually amend $usage_message to reflect the extra 1620285206Sdes# options you parse. It's preferable to append if you can, so that 1621285206Sdes# multiple option parsing hooks can be added safely. 1622285206Sdes 1623285206Sdes 1624285206Sdes# func_options [ARG]... 1625285206Sdes# --------------------- 1626285206Sdes# All the functions called inside func_options are hookable. See the 1627285206Sdes# individual implementations for details. 1628285206Sdesfunc_hookable func_options 1629285206Sdesfunc_options () 1630285206Sdes{ 1631285206Sdes $debug_cmd 1632285206Sdes 1633285206Sdes func_options_prep ${1+"$@"} 1634285206Sdes eval func_parse_options \ 1635285206Sdes ${func_options_prep_result+"$func_options_prep_result"} 1636285206Sdes eval func_validate_options \ 1637285206Sdes ${func_parse_options_result+"$func_parse_options_result"} 1638285206Sdes 1639285206Sdes eval func_run_hooks func_options \ 1640285206Sdes ${func_validate_options_result+"$func_validate_options_result"} 1641285206Sdes 1642285206Sdes # save modified positional parameters for caller 1643285206Sdes func_options_result=$func_run_hooks_result 1644285206Sdes} 1645285206Sdes 1646285206Sdes 1647285206Sdes# func_options_prep [ARG]... 1648285206Sdes# -------------------------- 1649285206Sdes# All initialisations required before starting the option parse loop. 1650285206Sdes# Note that when calling hook functions, we pass through the list of 1651285206Sdes# positional parameters. If a hook function modifies that list, and 1652285206Sdes# needs to propogate that back to rest of this script, then the complete 1653285206Sdes# modified list must be put in 'func_run_hooks_result' before 1654285206Sdes# returning. 1655285206Sdesfunc_hookable func_options_prep 1656285206Sdesfunc_options_prep () 1657285206Sdes{ 1658285206Sdes $debug_cmd 1659285206Sdes 1660285206Sdes # Option defaults: 1661285206Sdes opt_verbose=false 1662285206Sdes opt_warning_types= 1663285206Sdes 1664285206Sdes func_run_hooks func_options_prep ${1+"$@"} 1665285206Sdes 1666285206Sdes # save modified positional parameters for caller 1667285206Sdes func_options_prep_result=$func_run_hooks_result 1668285206Sdes} 1669285206Sdes 1670285206Sdes 1671285206Sdes# func_parse_options [ARG]... 1672285206Sdes# --------------------------- 1673285206Sdes# The main option parsing loop. 1674285206Sdesfunc_hookable func_parse_options 1675285206Sdesfunc_parse_options () 1676285206Sdes{ 1677285206Sdes $debug_cmd 1678285206Sdes 1679285206Sdes func_parse_options_result= 1680285206Sdes 1681285206Sdes # this just eases exit handling 1682285206Sdes while test $# -gt 0; do 1683285206Sdes # Defer to hook functions for initial option parsing, so they 1684285206Sdes # get priority in the event of reusing an option name. 1685285206Sdes func_run_hooks func_parse_options ${1+"$@"} 1686285206Sdes 1687285206Sdes # Adjust func_parse_options positional parameters to match 1688285206Sdes eval set dummy "$func_run_hooks_result"; shift 1689285206Sdes 1690285206Sdes # Break out of the loop if we already parsed every option. 1691285206Sdes test $# -gt 0 || break 1692285206Sdes 1693285206Sdes _G_opt=$1 1694285206Sdes shift 1695285206Sdes case $_G_opt in 1696285206Sdes --debug|-x) debug_cmd='set -x' 1697285206Sdes func_echo "enabling shell trace mode" 1698285206Sdes $debug_cmd 1699285206Sdes ;; 1700285206Sdes 1701285206Sdes --no-warnings|--no-warning|--no-warn) 1702285206Sdes set dummy --warnings none ${1+"$@"} 1703285206Sdes shift 1704285206Sdes ;; 1705285206Sdes 1706285206Sdes --warnings|--warning|-W) 1707285206Sdes test $# = 0 && func_missing_arg $_G_opt && break 1708285206Sdes case " $warning_categories $1" in 1709285206Sdes *" $1 "*) 1710285206Sdes # trailing space prevents matching last $1 above 1711285206Sdes func_append_uniq opt_warning_types " $1" 1712285206Sdes ;; 1713285206Sdes *all) 1714285206Sdes opt_warning_types=$warning_categories 1715285206Sdes ;; 1716285206Sdes *none) 1717285206Sdes opt_warning_types=none 1718285206Sdes warning_func=: 1719285206Sdes ;; 1720285206Sdes *error) 1721285206Sdes opt_warning_types=$warning_categories 1722285206Sdes warning_func=func_fatal_error 1723285206Sdes ;; 1724285206Sdes *) 1725285206Sdes func_fatal_error \ 1726285206Sdes "unsupported warning category: '$1'" 1727285206Sdes ;; 1728285206Sdes esac 1729285206Sdes shift 1730285206Sdes ;; 1731285206Sdes 1732285206Sdes --verbose|-v) opt_verbose=: ;; 1733285206Sdes --version) func_version ;; 1734285206Sdes -\?|-h) func_usage ;; 1735285206Sdes --help) func_help ;; 1736285206Sdes 1737285206Sdes # Separate optargs to long options (plugins may need this): 1738285206Sdes --*=*) func_split_equals "$_G_opt" 1739285206Sdes set dummy "$func_split_equals_lhs" \ 1740285206Sdes "$func_split_equals_rhs" ${1+"$@"} 1741285206Sdes shift 1742285206Sdes ;; 1743285206Sdes 1744285206Sdes # Separate optargs to short options: 1745285206Sdes -W*) 1746285206Sdes func_split_short_opt "$_G_opt" 1747285206Sdes set dummy "$func_split_short_opt_name" \ 1748285206Sdes "$func_split_short_opt_arg" ${1+"$@"} 1749285206Sdes shift 1750285206Sdes ;; 1751285206Sdes 1752285206Sdes # Separate non-argument short options: 1753285206Sdes -\?*|-h*|-v*|-x*) 1754285206Sdes func_split_short_opt "$_G_opt" 1755285206Sdes set dummy "$func_split_short_opt_name" \ 1756285206Sdes "-$func_split_short_opt_arg" ${1+"$@"} 1757285206Sdes shift 1758285206Sdes ;; 1759285206Sdes 1760285206Sdes --) break ;; 1761285206Sdes -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762285206Sdes *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763285206Sdes esac 1764285206Sdes done 1765285206Sdes 1766285206Sdes # save modified positional parameters for caller 1767285206Sdes func_quote_for_eval ${1+"$@"} 1768285206Sdes func_parse_options_result=$func_quote_for_eval_result 1769285206Sdes} 1770285206Sdes 1771285206Sdes 1772285206Sdes# func_validate_options [ARG]... 1773285206Sdes# ------------------------------ 1774285206Sdes# Perform any sanity checks on option settings and/or unconsumed 1775285206Sdes# arguments. 1776285206Sdesfunc_hookable func_validate_options 1777285206Sdesfunc_validate_options () 1778285206Sdes{ 1779285206Sdes $debug_cmd 1780285206Sdes 1781285206Sdes # Display all warnings if -W was not given. 1782285206Sdes test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783285206Sdes 1784285206Sdes func_run_hooks func_validate_options ${1+"$@"} 1785285206Sdes 1786285206Sdes # Bail if the options were screwed! 1787285206Sdes $exit_cmd $EXIT_FAILURE 1788285206Sdes 1789285206Sdes # save modified positional parameters for caller 1790285206Sdes func_validate_options_result=$func_run_hooks_result 1791285206Sdes} 1792285206Sdes 1793285206Sdes 1794285206Sdes 1795285206Sdes## ----------------- ## 1796285206Sdes## Helper functions. ## 1797285206Sdes## ----------------- ## 1798285206Sdes 1799285206Sdes# This section contains the helper functions used by the rest of the 1800285206Sdes# hookable option parser framework in ascii-betical order. 1801285206Sdes 1802285206Sdes 1803285206Sdes# func_fatal_help ARG... 1804285206Sdes# ---------------------- 1805285206Sdes# Echo program name prefixed message to standard error, followed by 1806285206Sdes# a help hint, and exit. 1807285206Sdesfunc_fatal_help () 1808285206Sdes{ 1809285206Sdes $debug_cmd 1810285206Sdes 1811285206Sdes eval \$ECHO \""Usage: $usage"\" 1812285206Sdes eval \$ECHO \""$fatal_help"\" 1813285206Sdes func_error ${1+"$@"} 1814285206Sdes exit $EXIT_FAILURE 1815285206Sdes} 1816285206Sdes 1817285206Sdes 1818285206Sdes# func_help 1819285206Sdes# --------- 1820285206Sdes# Echo long help message to standard output and exit. 1821238104Sdesfunc_help () 1822238104Sdes{ 1823285206Sdes $debug_cmd 1824238104Sdes 1825285206Sdes func_usage_message 1826285206Sdes $ECHO "$long_help_message" 1827285206Sdes exit 0 1828238104Sdes} 1829238104Sdes 1830285206Sdes 1831285206Sdes# func_missing_arg ARGNAME 1832285206Sdes# ------------------------ 1833238104Sdes# Echo program name prefixed message to standard error and set global 1834238104Sdes# exit_cmd. 1835238104Sdesfunc_missing_arg () 1836238104Sdes{ 1837285206Sdes $debug_cmd 1838238104Sdes 1839285206Sdes func_error "Missing argument for '$1'." 1840238104Sdes exit_cmd=exit 1841238104Sdes} 1842238104Sdes 1843238104Sdes 1844285206Sdes# func_split_equals STRING 1845285206Sdes# ------------------------ 1846285206Sdes# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847285206Sdes# splitting STRING at the '=' sign. 1848285206Sdestest -z "$_G_HAVE_XSI_OPS" \ 1849285206Sdes && (eval 'x=a/b/c; 1850285206Sdes test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851285206Sdes && _G_HAVE_XSI_OPS=yes 1852285206Sdes 1853285206Sdesif test yes = "$_G_HAVE_XSI_OPS" 1854285206Sdesthen 1855285206Sdes # This is an XSI compatible shell, allowing a faster implementation... 1856285206Sdes eval 'func_split_equals () 1857285206Sdes { 1858285206Sdes $debug_cmd 1859285206Sdes 1860285206Sdes func_split_equals_lhs=${1%%=*} 1861285206Sdes func_split_equals_rhs=${1#*=} 1862285206Sdes test "x$func_split_equals_lhs" = "x$1" \ 1863285206Sdes && func_split_equals_rhs= 1864285206Sdes }' 1865285206Sdeselse 1866285206Sdes # ...otherwise fall back to using expr, which is often a shell builtin. 1867285206Sdes func_split_equals () 1868285206Sdes { 1869285206Sdes $debug_cmd 1870285206Sdes 1871285206Sdes func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872285206Sdes func_split_equals_rhs= 1873285206Sdes test "x$func_split_equals_lhs" = "x$1" \ 1874285206Sdes || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875285206Sdes } 1876285206Sdesfi #func_split_equals 1877285206Sdes 1878285206Sdes 1879285206Sdes# func_split_short_opt SHORTOPT 1880285206Sdes# ----------------------------- 1881238104Sdes# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882238104Sdes# variables after splitting SHORTOPT after the 2nd character. 1883285206Sdesif test yes = "$_G_HAVE_XSI_OPS" 1884285206Sdesthen 1885285206Sdes # This is an XSI compatible shell, allowing a faster implementation... 1886285206Sdes eval 'func_split_short_opt () 1887285206Sdes { 1888285206Sdes $debug_cmd 1889285206Sdes 1890285206Sdes func_split_short_opt_arg=${1#??} 1891285206Sdes func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892285206Sdes }' 1893285206Sdeselse 1894285206Sdes # ...otherwise fall back to using expr, which is often a shell builtin. 1895285206Sdes func_split_short_opt () 1896285206Sdes { 1897285206Sdes $debug_cmd 1898285206Sdes 1899285206Sdes func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900285206Sdes func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901285206Sdes } 1902285206Sdesfi #func_split_short_opt 1903285206Sdes 1904285206Sdes 1905285206Sdes# func_usage 1906285206Sdes# ---------- 1907285206Sdes# Echo short help message to standard output and exit. 1908285206Sdesfunc_usage () 1909238104Sdes{ 1910285206Sdes $debug_cmd 1911238104Sdes 1912285206Sdes func_usage_message 1913285206Sdes $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914285206Sdes exit 0 1915285206Sdes} 1916238104Sdes 1917238104Sdes 1918285206Sdes# func_usage_message 1919285206Sdes# ------------------ 1920285206Sdes# Echo short help message to standard output. 1921285206Sdesfunc_usage_message () 1922238104Sdes{ 1923285206Sdes $debug_cmd 1924238104Sdes 1925285206Sdes eval \$ECHO \""Usage: $usage"\" 1926285206Sdes echo 1927285206Sdes $SED -n 's|^# || 1928285206Sdes /^Written by/{ 1929285206Sdes x;p;x 1930285206Sdes } 1931285206Sdes h 1932285206Sdes /^Written by/q' < "$progpath" 1933285206Sdes echo 1934285206Sdes eval \$ECHO \""$usage_message"\" 1935285206Sdes} 1936238104Sdes 1937238104Sdes 1938285206Sdes# func_version 1939285206Sdes# ------------ 1940285206Sdes# Echo version message to standard output and exit. 1941285206Sdesfunc_version () 1942285206Sdes{ 1943285206Sdes $debug_cmd 1944238104Sdes 1945285206Sdes printf '%s\n' "$progname $scriptversion" 1946285206Sdes $SED -n ' 1947285206Sdes /(C)/!b go 1948285206Sdes :more 1949285206Sdes /\./!{ 1950285206Sdes N 1951285206Sdes s|\n# | | 1952285206Sdes b more 1953285206Sdes } 1954285206Sdes :go 1955285206Sdes /^# Written by /,/# warranty; / { 1956285206Sdes s|^# || 1957285206Sdes s|^# *$|| 1958285206Sdes s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959285206Sdes p 1960285206Sdes } 1961285206Sdes /^# Written by / { 1962285206Sdes s|^# || 1963285206Sdes p 1964285206Sdes } 1965285206Sdes /^warranty; /q' < "$progpath" 1966238104Sdes 1967285206Sdes exit $? 1968285206Sdes} 1969238104Sdes 1970238104Sdes 1971285206Sdes# Local variables: 1972285206Sdes# mode: shell-script 1973285206Sdes# sh-indentation: 2 1974285206Sdes# eval: (add-hook 'before-save-hook 'time-stamp) 1975285206Sdes# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976285206Sdes# time-stamp-time-zone: "UTC" 1977285206Sdes# End: 1978238104Sdes 1979285206Sdes# Set a version string. 1980285206Sdesscriptversion='(GNU libtool) 2.4.6' 1981238104Sdes 1982238104Sdes 1983285206Sdes# func_echo ARG... 1984285206Sdes# ---------------- 1985285206Sdes# Libtool also displays the current mode in messages, so override 1986285206Sdes# funclib.sh func_echo with this custom definition. 1987285206Sdesfunc_echo () 1988238104Sdes{ 1989285206Sdes $debug_cmd 1990238104Sdes 1991285206Sdes _G_message=$* 1992238104Sdes 1993285206Sdes func_echo_IFS=$IFS 1994285206Sdes IFS=$nl 1995285206Sdes for _G_line in $_G_message; do 1996285206Sdes IFS=$func_echo_IFS 1997285206Sdes $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998285206Sdes done 1999285206Sdes IFS=$func_echo_IFS 2000285206Sdes} 2001238104Sdes 2002285206Sdes 2003285206Sdes# func_warning ARG... 2004285206Sdes# ------------------- 2005285206Sdes# Libtool warnings are not categorized, so override funclib.sh 2006285206Sdes# func_warning with this simpler definition. 2007285206Sdesfunc_warning () 2008238104Sdes{ 2009285206Sdes $debug_cmd 2010238104Sdes 2011285206Sdes $warning_func ${1+"$@"} 2012285206Sdes} 2013238104Sdes 2014238104Sdes 2015285206Sdes## ---------------- ## 2016285206Sdes## Options parsing. ## 2017285206Sdes## ---------------- ## 2018238104Sdes 2019285206Sdes# Hook in the functions to make sure our own options are parsed during 2020285206Sdes# the option parsing loop. 2021238104Sdes 2022285206Sdesusage='$progpath [OPTION]... [MODE-ARG]...' 2023238104Sdes 2024285206Sdes# Short help message in response to '-h'. 2025285206Sdesusage_message="Options: 2026285206Sdes --config show all configuration variables 2027285206Sdes --debug enable verbose shell tracing 2028285206Sdes -n, --dry-run display commands without modifying any files 2029285206Sdes --features display basic configuration information and exit 2030285206Sdes --mode=MODE use operation mode MODE 2031285206Sdes --no-warnings equivalent to '-Wnone' 2032285206Sdes --preserve-dup-deps don't remove duplicate dependency libraries 2033285206Sdes --quiet, --silent don't print informational messages 2034285206Sdes --tag=TAG use configuration variables from tag TAG 2035285206Sdes -v, --verbose print more informational messages than default 2036285206Sdes --version print version information 2037285206Sdes -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038285206Sdes -h, --help, --help-all print short, long, or detailed help message 2039285206Sdes" 2040285206Sdes 2041285206Sdes# Additional text appended to 'usage_message' in response to '--help'. 2042285206Sdesfunc_help () 2043238104Sdes{ 2044285206Sdes $debug_cmd 2045238104Sdes 2046285206Sdes func_usage_message 2047285206Sdes $ECHO "$long_help_message 2048238104Sdes 2049285206SdesMODE must be one of the following: 2050285206Sdes 2051285206Sdes clean remove files from the build directory 2052285206Sdes compile compile a source file into a libtool object 2053285206Sdes execute automatically set library path, then run a program 2054285206Sdes finish complete the installation of libtool libraries 2055285206Sdes install install libraries or executables 2056285206Sdes link create a library or an executable 2057285206Sdes uninstall remove libraries from an installed directory 2058285206Sdes 2059285206SdesMODE-ARGS vary depending on the MODE. When passed as first option, 2060285206Sdes'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061285206SdesTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062285206Sdes 2063285206SdesWhen reporting a bug, please describe a test case to reproduce it and 2064285206Sdesinclude the following information: 2065285206Sdes 2066285206Sdes host-triplet: $host 2067285206Sdes shell: $SHELL 2068285206Sdes compiler: $LTCC 2069285206Sdes compiler flags: $LTCFLAGS 2070285206Sdes linker: $LD (gnu? $with_gnu_ld) 2071285206Sdes version: $progname (GNU libtool) 2.4.6 2072285206Sdes automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073285206Sdes autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074285206Sdes 2075285206SdesReport bugs to <bug-libtool@gnu.org>. 2076285206SdesGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2077285206SdesGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078285206Sdes exit 0 2079285206Sdes} 2080285206Sdes 2081285206Sdes 2082285206Sdes# func_lo2o OBJECT-NAME 2083285206Sdes# --------------------- 2084285206Sdes# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085285206Sdes# object suffix. 2086285206Sdes 2087285206Sdeslo2o=s/\\.lo\$/.$objext/ 2088285206Sdeso2lo=s/\\.$objext\$/.lo/ 2089285206Sdes 2090285206Sdesif test yes = "$_G_HAVE_XSI_OPS"; then 2091285206Sdes eval 'func_lo2o () 2092285206Sdes { 2093285206Sdes case $1 in 2094285206Sdes *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095285206Sdes * ) func_lo2o_result=$1 ;; 2096285206Sdes esac 2097285206Sdes }' 2098285206Sdes 2099285206Sdes # func_xform LIBOBJ-OR-SOURCE 2100285206Sdes # --------------------------- 2101285206Sdes # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102285206Sdes # suffix to a '.lo' libtool-object suffix. 2103285206Sdes eval 'func_xform () 2104285206Sdes { 2105285206Sdes func_xform_result=${1%.*}.lo 2106285206Sdes }' 2107285206Sdeselse 2108285206Sdes # ...otherwise fall back to using sed. 2109285206Sdes func_lo2o () 2110285206Sdes { 2111285206Sdes func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112285206Sdes } 2113285206Sdes 2114285206Sdes func_xform () 2115285206Sdes { 2116285206Sdes func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117285206Sdes } 2118285206Sdesfi 2119285206Sdes 2120285206Sdes 2121285206Sdes# func_fatal_configuration ARG... 2122285206Sdes# ------------------------------- 2123238104Sdes# Echo program name prefixed message to standard error, followed by 2124238104Sdes# a configuration failure hint, and exit. 2125238104Sdesfunc_fatal_configuration () 2126238104Sdes{ 2127285206Sdes func__fatal_error ${1+"$@"} \ 2128285206Sdes "See the $PACKAGE documentation for more information." \ 2129285206Sdes "Fatal configuration error." 2130238104Sdes} 2131238104Sdes 2132238104Sdes 2133238104Sdes# func_config 2134285206Sdes# ----------- 2135238104Sdes# Display the configuration for all the tags in this script. 2136238104Sdesfunc_config () 2137238104Sdes{ 2138238104Sdes re_begincf='^# ### BEGIN LIBTOOL' 2139238104Sdes re_endcf='^# ### END LIBTOOL' 2140238104Sdes 2141238104Sdes # Default configuration. 2142238104Sdes $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143238104Sdes 2144238104Sdes # Now print the configurations for the tags. 2145238104Sdes for tagname in $taglist; do 2146238104Sdes $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147238104Sdes done 2148238104Sdes 2149238104Sdes exit $? 2150238104Sdes} 2151238104Sdes 2152285206Sdes 2153238104Sdes# func_features 2154285206Sdes# ------------- 2155238104Sdes# Display the features supported by this script. 2156238104Sdesfunc_features () 2157238104Sdes{ 2158238104Sdes echo "host: $host" 2159285206Sdes if test yes = "$build_libtool_libs"; then 2160238104Sdes echo "enable shared libraries" 2161238104Sdes else 2162238104Sdes echo "disable shared libraries" 2163238104Sdes fi 2164285206Sdes if test yes = "$build_old_libs"; then 2165238104Sdes echo "enable static libraries" 2166238104Sdes else 2167238104Sdes echo "disable static libraries" 2168238104Sdes fi 2169238104Sdes 2170238104Sdes exit $? 2171238104Sdes} 2172238104Sdes 2173285206Sdes 2174285206Sdes# func_enable_tag TAGNAME 2175285206Sdes# ----------------------- 2176238104Sdes# Verify that TAGNAME is valid, and either flag an error and exit, or 2177238104Sdes# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178238104Sdes# variable here. 2179238104Sdesfunc_enable_tag () 2180238104Sdes{ 2181285206Sdes # Global variable: 2182285206Sdes tagname=$1 2183238104Sdes 2184285206Sdes re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185285206Sdes re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186285206Sdes sed_extractcf=/$re_begincf/,/$re_endcf/p 2187238104Sdes 2188285206Sdes # Validate tagname. 2189285206Sdes case $tagname in 2190285206Sdes *[!-_A-Za-z0-9,/]*) 2191285206Sdes func_fatal_error "invalid tag name: $tagname" 2192285206Sdes ;; 2193285206Sdes esac 2194238104Sdes 2195285206Sdes # Don't test for the "default" C tag, as we know it's 2196285206Sdes # there but not specially marked. 2197285206Sdes case $tagname in 2198285206Sdes CC) ;; 2199238104Sdes *) 2200285206Sdes if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201285206Sdes taglist="$taglist $tagname" 2202238104Sdes 2203285206Sdes # Evaluate the configuration. Be careful to quote the path 2204285206Sdes # and the sed script, to avoid splitting on whitespace, but 2205285206Sdes # also don't use non-portable quotes within backquotes within 2206285206Sdes # quotes we have to do it in 2 steps: 2207285206Sdes extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208285206Sdes eval "$extractedcf" 2209285206Sdes else 2210285206Sdes func_error "ignoring unknown tag $tagname" 2211285206Sdes fi 2212285206Sdes ;; 2213285206Sdes esac 2214238104Sdes} 2215238104Sdes 2216285206Sdes 2217238104Sdes# func_check_version_match 2218285206Sdes# ------------------------ 2219238104Sdes# Ensure that we are using m4 macros, and libtool script from the same 2220238104Sdes# release of libtool. 2221238104Sdesfunc_check_version_match () 2222238104Sdes{ 2223285206Sdes if test "$package_revision" != "$macro_revision"; then 2224285206Sdes if test "$VERSION" != "$macro_version"; then 2225285206Sdes if test -z "$macro_version"; then 2226285206Sdes cat >&2 <<_LT_EOF 2227238104Sdes$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228238104Sdes$progname: definition of this LT_INIT comes from an older release. 2229238104Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230238104Sdes$progname: and run autoconf again. 2231238104Sdes_LT_EOF 2232285206Sdes else 2233285206Sdes cat >&2 <<_LT_EOF 2234238104Sdes$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235238104Sdes$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236238104Sdes$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237238104Sdes$progname: and run autoconf again. 2238238104Sdes_LT_EOF 2239285206Sdes fi 2240285206Sdes else 2241285206Sdes cat >&2 <<_LT_EOF 2242238104Sdes$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243238104Sdes$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244238104Sdes$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245238104Sdes$progname: of $PACKAGE $VERSION and run autoconf again. 2246238104Sdes_LT_EOF 2247285206Sdes fi 2248285206Sdes 2249285206Sdes exit $EXIT_MISMATCH 2250238104Sdes fi 2251238104Sdes} 2252238104Sdes 2253238104Sdes 2254285206Sdes# libtool_options_prep [ARG]... 2255285206Sdes# ----------------------------- 2256285206Sdes# Preparation for options parsed by libtool. 2257285206Sdeslibtool_options_prep () 2258285206Sdes{ 2259285206Sdes $debug_mode 2260238104Sdes 2261285206Sdes # Option defaults: 2262285206Sdes opt_config=false 2263285206Sdes opt_dlopen= 2264285206Sdes opt_dry_run=false 2265285206Sdes opt_help=false 2266285206Sdes opt_mode= 2267285206Sdes opt_preserve_dup_deps=false 2268285206Sdes opt_quiet=false 2269238104Sdes 2270285206Sdes nonopt= 2271285206Sdes preserve_args= 2272238104Sdes 2273285206Sdes # Shorthand for --mode=foo, only valid as the first argument 2274285206Sdes case $1 in 2275285206Sdes clean|clea|cle|cl) 2276285206Sdes shift; set dummy --mode clean ${1+"$@"}; shift 2277285206Sdes ;; 2278285206Sdes compile|compil|compi|comp|com|co|c) 2279285206Sdes shift; set dummy --mode compile ${1+"$@"}; shift 2280285206Sdes ;; 2281285206Sdes execute|execut|execu|exec|exe|ex|e) 2282285206Sdes shift; set dummy --mode execute ${1+"$@"}; shift 2283285206Sdes ;; 2284285206Sdes finish|finis|fini|fin|fi|f) 2285285206Sdes shift; set dummy --mode finish ${1+"$@"}; shift 2286285206Sdes ;; 2287285206Sdes install|instal|insta|inst|ins|in|i) 2288285206Sdes shift; set dummy --mode install ${1+"$@"}; shift 2289285206Sdes ;; 2290285206Sdes link|lin|li|l) 2291285206Sdes shift; set dummy --mode link ${1+"$@"}; shift 2292285206Sdes ;; 2293285206Sdes uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294285206Sdes shift; set dummy --mode uninstall ${1+"$@"}; shift 2295285206Sdes ;; 2296285206Sdes esac 2297238104Sdes 2298285206Sdes # Pass back the list of options. 2299285206Sdes func_quote_for_eval ${1+"$@"} 2300285206Sdes libtool_options_prep_result=$func_quote_for_eval_result 2301285206Sdes} 2302285206Sdesfunc_add_hook func_options_prep libtool_options_prep 2303238104Sdes 2304285206Sdes 2305285206Sdes# libtool_parse_options [ARG]... 2306285206Sdes# --------------------------------- 2307285206Sdes# Provide handling for libtool specific options. 2308285206Sdeslibtool_parse_options () 2309238104Sdes{ 2310285206Sdes $debug_cmd 2311238104Sdes 2312285206Sdes # Perform our own loop to consume as many options as possible in 2313285206Sdes # each iteration. 2314285206Sdes while test $# -gt 0; do 2315285206Sdes _G_opt=$1 2316285206Sdes shift 2317285206Sdes case $_G_opt in 2318285206Sdes --dry-run|--dryrun|-n) 2319285206Sdes opt_dry_run=: 2320285206Sdes ;; 2321238104Sdes 2322285206Sdes --config) func_config ;; 2323238104Sdes 2324285206Sdes --dlopen|-dlopen) 2325285206Sdes opt_dlopen="${opt_dlopen+$opt_dlopen 2326285206Sdes}$1" 2327285206Sdes shift 2328285206Sdes ;; 2329238104Sdes 2330285206Sdes --preserve-dup-deps) 2331285206Sdes opt_preserve_dup_deps=: ;; 2332238104Sdes 2333285206Sdes --features) func_features ;; 2334238104Sdes 2335285206Sdes --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336238104Sdes 2337285206Sdes --help) opt_help=: ;; 2338238104Sdes 2339285206Sdes --help-all) opt_help=': help-all' ;; 2340238104Sdes 2341285206Sdes --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342285206Sdes opt_mode=$1 2343285206Sdes case $1 in 2344285206Sdes # Valid mode arguments: 2345285206Sdes clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346238104Sdes 2347285206Sdes # Catch anything else as an error 2348285206Sdes *) func_error "invalid argument for $_G_opt" 2349285206Sdes exit_cmd=exit 2350285206Sdes break 2351285206Sdes ;; 2352285206Sdes esac 2353285206Sdes shift 2354285206Sdes ;; 2355238104Sdes 2356285206Sdes --no-silent|--no-quiet) 2357285206Sdes opt_quiet=false 2358285206Sdes func_append preserve_args " $_G_opt" 2359285206Sdes ;; 2360238104Sdes 2361285206Sdes --no-warnings|--no-warning|--no-warn) 2362285206Sdes opt_warning=false 2363285206Sdes func_append preserve_args " $_G_opt" 2364285206Sdes ;; 2365238104Sdes 2366285206Sdes --no-verbose) 2367285206Sdes opt_verbose=false 2368285206Sdes func_append preserve_args " $_G_opt" 2369285206Sdes ;; 2370285206Sdes 2371285206Sdes --silent|--quiet) 2372285206Sdes opt_quiet=: 2373285206Sdes opt_verbose=false 2374285206Sdes func_append preserve_args " $_G_opt" 2375285206Sdes ;; 2376285206Sdes 2377285206Sdes --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378285206Sdes opt_tag=$1 2379285206Sdes func_append preserve_args " $_G_opt $1" 2380285206Sdes func_enable_tag "$1" 2381285206Sdes shift 2382285206Sdes ;; 2383285206Sdes 2384285206Sdes --verbose|-v) opt_quiet=false 2385285206Sdes opt_verbose=: 2386285206Sdes func_append preserve_args " $_G_opt" 2387285206Sdes ;; 2388285206Sdes 2389285206Sdes # An option not handled by this hook function: 2390285206Sdes *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391285206Sdes esac 2392285206Sdes done 2393285206Sdes 2394285206Sdes 2395285206Sdes # save modified positional parameters for caller 2396285206Sdes func_quote_for_eval ${1+"$@"} 2397285206Sdes libtool_parse_options_result=$func_quote_for_eval_result 2398285206Sdes} 2399285206Sdesfunc_add_hook func_parse_options libtool_parse_options 2400285206Sdes 2401285206Sdes 2402285206Sdes 2403285206Sdes# libtool_validate_options [ARG]... 2404285206Sdes# --------------------------------- 2405285206Sdes# Perform any sanity checks on option settings and/or unconsumed 2406285206Sdes# arguments. 2407285206Sdeslibtool_validate_options () 2408285206Sdes{ 2409285206Sdes # save first non-option argument 2410285206Sdes if test 0 -lt $#; then 2411285206Sdes nonopt=$1 2412285206Sdes shift 2413238104Sdes fi 2414238104Sdes 2415285206Sdes # preserve --debug 2416285206Sdes test : = "$debug_cmd" || func_append preserve_args " --debug" 2417238104Sdes 2418285206Sdes case $host in 2419285206Sdes # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420285206Sdes # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421285206Sdes *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422285206Sdes # don't eliminate duplications in $postdeps and $predeps 2423285206Sdes opt_duplicate_compiler_generated_deps=: 2424285206Sdes ;; 2425285206Sdes *) 2426285206Sdes opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427285206Sdes ;; 2428285206Sdes esac 2429238104Sdes 2430285206Sdes $opt_help || { 2431285206Sdes # Sanity checks first: 2432285206Sdes func_check_version_match 2433285206Sdes 2434285206Sdes test yes != "$build_libtool_libs" \ 2435285206Sdes && test yes != "$build_old_libs" \ 2436285206Sdes && func_fatal_configuration "not configured to build any kind of library" 2437285206Sdes 2438285206Sdes # Darwin sucks 2439285206Sdes eval std_shrext=\"$shrext_cmds\" 2440285206Sdes 2441285206Sdes # Only execute mode is allowed to have -dlopen flags. 2442285206Sdes if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443285206Sdes func_error "unrecognized option '-dlopen'" 2444285206Sdes $ECHO "$help" 1>&2 2445285206Sdes exit $EXIT_FAILURE 2446285206Sdes fi 2447285206Sdes 2448285206Sdes # Change the help message to a mode-specific one. 2449285206Sdes generic_help=$help 2450285206Sdes help="Try '$progname --help --mode=$opt_mode' for more information." 2451285206Sdes } 2452285206Sdes 2453285206Sdes # Pass back the unparsed argument list 2454285206Sdes func_quote_for_eval ${1+"$@"} 2455285206Sdes libtool_validate_options_result=$func_quote_for_eval_result 2456238104Sdes} 2457285206Sdesfunc_add_hook func_validate_options libtool_validate_options 2458238104Sdes 2459238104Sdes 2460285206Sdes# Process options as early as possible so that --help and --version 2461285206Sdes# can return quickly. 2462285206Sdesfunc_options ${1+"$@"} 2463285206Sdeseval set dummy "$func_options_result"; shift 2464238104Sdes 2465238104Sdes 2466285206Sdes 2467238104Sdes## ----------- ## 2468238104Sdes## Main. ## 2469238104Sdes## ----------- ## 2470238104Sdes 2471285206Sdesmagic='%%%MAGIC variable%%%' 2472285206Sdesmagic_exe='%%%MAGIC EXE variable%%%' 2473285206Sdes 2474285206Sdes# Global variables. 2475285206Sdesextracted_archives= 2476285206Sdesextracted_serial=0 2477285206Sdes 2478285206Sdes# If this variable is set in any of the actions, the command in it 2479285206Sdes# will be execed at the end. This prevents here-documents from being 2480285206Sdes# left over by shells. 2481285206Sdesexec_cmd= 2482285206Sdes 2483285206Sdes 2484285206Sdes# A function that is used when there is no print builtin or printf. 2485285206Sdesfunc_fallback_echo () 2486285206Sdes{ 2487285206Sdes eval 'cat <<_LTECHO_EOF 2488285206Sdes$1 2489285206Sdes_LTECHO_EOF' 2490285206Sdes} 2491285206Sdes 2492285206Sdes# func_generated_by_libtool 2493285206Sdes# True iff stdin has been generated by Libtool. This function is only 2494285206Sdes# a basic sanity check; it will hardly flush out determined imposters. 2495285206Sdesfunc_generated_by_libtool_p () 2496285206Sdes{ 2497285206Sdes $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498285206Sdes} 2499285206Sdes 2500238104Sdes# func_lalib_p file 2501285206Sdes# True iff FILE is a libtool '.la' library or '.lo' object file. 2502238104Sdes# This function is only a basic sanity check; it will hardly flush out 2503238104Sdes# determined imposters. 2504238104Sdesfunc_lalib_p () 2505238104Sdes{ 2506238104Sdes test -f "$1" && 2507285206Sdes $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508238104Sdes} 2509238104Sdes 2510238104Sdes# func_lalib_unsafe_p file 2511285206Sdes# True iff FILE is a libtool '.la' library or '.lo' object file. 2512238104Sdes# This function implements the same check as func_lalib_p without 2513238104Sdes# resorting to external programs. To this end, it redirects stdin and 2514238104Sdes# closes it afterwards, without saving the original file descriptor. 2515238104Sdes# As a safety measure, use it only where a negative result would be 2516285206Sdes# fatal anyway. Works if 'file' does not exist. 2517238104Sdesfunc_lalib_unsafe_p () 2518238104Sdes{ 2519238104Sdes lalib_p=no 2520238104Sdes if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521238104Sdes for lalib_p_l in 1 2 3 4 2522238104Sdes do 2523238104Sdes read lalib_p_line 2524285206Sdes case $lalib_p_line in 2525238104Sdes \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526238104Sdes esac 2527238104Sdes done 2528238104Sdes exec 0<&5 5<&- 2529238104Sdes fi 2530285206Sdes test yes = "$lalib_p" 2531238104Sdes} 2532238104Sdes 2533238104Sdes# func_ltwrapper_script_p file 2534238104Sdes# True iff FILE is a libtool wrapper script 2535238104Sdes# This function is only a basic sanity check; it will hardly flush out 2536238104Sdes# determined imposters. 2537238104Sdesfunc_ltwrapper_script_p () 2538238104Sdes{ 2539285206Sdes test -f "$1" && 2540285206Sdes $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541238104Sdes} 2542238104Sdes 2543238104Sdes# func_ltwrapper_executable_p file 2544238104Sdes# True iff FILE is a libtool wrapper executable 2545238104Sdes# This function is only a basic sanity check; it will hardly flush out 2546238104Sdes# determined imposters. 2547238104Sdesfunc_ltwrapper_executable_p () 2548238104Sdes{ 2549238104Sdes func_ltwrapper_exec_suffix= 2550238104Sdes case $1 in 2551238104Sdes *.exe) ;; 2552238104Sdes *) func_ltwrapper_exec_suffix=.exe ;; 2553238104Sdes esac 2554238104Sdes $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555238104Sdes} 2556238104Sdes 2557238104Sdes# func_ltwrapper_scriptname file 2558238104Sdes# Assumes file is an ltwrapper_executable 2559238104Sdes# uses $file to determine the appropriate filename for a 2560238104Sdes# temporary ltwrapper_script. 2561238104Sdesfunc_ltwrapper_scriptname () 2562238104Sdes{ 2563238104Sdes func_dirname_and_basename "$1" "" "." 2564238104Sdes func_stripname '' '.exe' "$func_basename_result" 2565285206Sdes func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566238104Sdes} 2567238104Sdes 2568238104Sdes# func_ltwrapper_p file 2569238104Sdes# True iff FILE is a libtool wrapper script or wrapper executable 2570238104Sdes# This function is only a basic sanity check; it will hardly flush out 2571238104Sdes# determined imposters. 2572238104Sdesfunc_ltwrapper_p () 2573238104Sdes{ 2574238104Sdes func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575238104Sdes} 2576238104Sdes 2577238104Sdes 2578238104Sdes# func_execute_cmds commands fail_cmd 2579238104Sdes# Execute tilde-delimited COMMANDS. 2580238104Sdes# If FAIL_CMD is given, eval that upon failure. 2581238104Sdes# FAIL_CMD may read-access the current command in variable CMD! 2582238104Sdesfunc_execute_cmds () 2583238104Sdes{ 2584285206Sdes $debug_cmd 2585285206Sdes 2586238104Sdes save_ifs=$IFS; IFS='~' 2587238104Sdes for cmd in $1; do 2588285206Sdes IFS=$sp$nl 2589285206Sdes eval cmd=\"$cmd\" 2590238104Sdes IFS=$save_ifs 2591238104Sdes func_show_eval "$cmd" "${2-:}" 2592238104Sdes done 2593238104Sdes IFS=$save_ifs 2594238104Sdes} 2595238104Sdes 2596238104Sdes 2597238104Sdes# func_source file 2598238104Sdes# Source FILE, adding directory component if necessary. 2599238104Sdes# Note that it is not necessary on cygwin/mingw to append a dot to 2600238104Sdes# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601238104Sdes# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602285206Sdes# 'FILE.' does not work on cygwin managed mounts. 2603238104Sdesfunc_source () 2604238104Sdes{ 2605285206Sdes $debug_cmd 2606285206Sdes 2607238104Sdes case $1 in 2608238104Sdes */* | *\\*) . "$1" ;; 2609238104Sdes *) . "./$1" ;; 2610238104Sdes esac 2611238104Sdes} 2612238104Sdes 2613238104Sdes 2614238104Sdes# func_resolve_sysroot PATH 2615238104Sdes# Replace a leading = in PATH with a sysroot. Store the result into 2616238104Sdes# func_resolve_sysroot_result 2617238104Sdesfunc_resolve_sysroot () 2618238104Sdes{ 2619238104Sdes func_resolve_sysroot_result=$1 2620238104Sdes case $func_resolve_sysroot_result in 2621238104Sdes =*) 2622238104Sdes func_stripname '=' '' "$func_resolve_sysroot_result" 2623238104Sdes func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624238104Sdes ;; 2625238104Sdes esac 2626238104Sdes} 2627238104Sdes 2628238104Sdes# func_replace_sysroot PATH 2629238104Sdes# If PATH begins with the sysroot, replace it with = and 2630238104Sdes# store the result into func_replace_sysroot_result. 2631238104Sdesfunc_replace_sysroot () 2632238104Sdes{ 2633285206Sdes case $lt_sysroot:$1 in 2634238104Sdes ?*:"$lt_sysroot"*) 2635238104Sdes func_stripname "$lt_sysroot" '' "$1" 2636285206Sdes func_replace_sysroot_result='='$func_stripname_result 2637238104Sdes ;; 2638238104Sdes *) 2639238104Sdes # Including no sysroot. 2640238104Sdes func_replace_sysroot_result=$1 2641238104Sdes ;; 2642238104Sdes esac 2643238104Sdes} 2644238104Sdes 2645238104Sdes# func_infer_tag arg 2646238104Sdes# Infer tagged configuration to use if any are available and 2647238104Sdes# if one wasn't chosen via the "--tag" command line option. 2648238104Sdes# Only attempt this if the compiler in the base compile 2649238104Sdes# command doesn't match the default compiler. 2650238104Sdes# arg is usually of the form 'gcc ...' 2651238104Sdesfunc_infer_tag () 2652238104Sdes{ 2653285206Sdes $debug_cmd 2654285206Sdes 2655238104Sdes if test -n "$available_tags" && test -z "$tagname"; then 2656238104Sdes CC_quoted= 2657238104Sdes for arg in $CC; do 2658238104Sdes func_append_quoted CC_quoted "$arg" 2659238104Sdes done 2660238104Sdes CC_expanded=`func_echo_all $CC` 2661238104Sdes CC_quoted_expanded=`func_echo_all $CC_quoted` 2662238104Sdes case $@ in 2663238104Sdes # Blanks in the command may have been stripped by the calling shell, 2664238104Sdes # but not from the CC environment variable when configure was run. 2665238104Sdes " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666238104Sdes " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667238104Sdes # Blanks at the start of $base_compile will cause this to fail 2668238104Sdes # if we don't check for them as well. 2669238104Sdes *) 2670238104Sdes for z in $available_tags; do 2671238104Sdes if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672238104Sdes # Evaluate the configuration. 2673285206Sdes eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674238104Sdes CC_quoted= 2675238104Sdes for arg in $CC; do 2676238104Sdes # Double-quote args containing other shell metacharacters. 2677238104Sdes func_append_quoted CC_quoted "$arg" 2678238104Sdes done 2679238104Sdes CC_expanded=`func_echo_all $CC` 2680238104Sdes CC_quoted_expanded=`func_echo_all $CC_quoted` 2681238104Sdes case "$@ " in 2682238104Sdes " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683238104Sdes " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684238104Sdes # The compiler in the base compile command matches 2685238104Sdes # the one in the tagged configuration. 2686238104Sdes # Assume this is the tagged configuration we want. 2687238104Sdes tagname=$z 2688238104Sdes break 2689238104Sdes ;; 2690238104Sdes esac 2691238104Sdes fi 2692238104Sdes done 2693238104Sdes # If $tagname still isn't set, then no tagged configuration 2694238104Sdes # was found and let the user know that the "--tag" command 2695238104Sdes # line option must be used. 2696238104Sdes if test -z "$tagname"; then 2697238104Sdes func_echo "unable to infer tagged configuration" 2698285206Sdes func_fatal_error "specify a tag with '--tag'" 2699238104Sdes# else 2700238104Sdes# func_verbose "using $tagname tagged configuration" 2701238104Sdes fi 2702238104Sdes ;; 2703238104Sdes esac 2704238104Sdes fi 2705238104Sdes} 2706238104Sdes 2707238104Sdes 2708238104Sdes 2709238104Sdes# func_write_libtool_object output_name pic_name nonpic_name 2710238104Sdes# Create a libtool object file (analogous to a ".la" file), 2711238104Sdes# but don't create it if we're doing a dry run. 2712238104Sdesfunc_write_libtool_object () 2713238104Sdes{ 2714285206Sdes write_libobj=$1 2715285206Sdes if test yes = "$build_libtool_libs"; then 2716285206Sdes write_lobj=\'$2\' 2717238104Sdes else 2718238104Sdes write_lobj=none 2719238104Sdes fi 2720238104Sdes 2721285206Sdes if test yes = "$build_old_libs"; then 2722285206Sdes write_oldobj=\'$3\' 2723238104Sdes else 2724238104Sdes write_oldobj=none 2725238104Sdes fi 2726238104Sdes 2727238104Sdes $opt_dry_run || { 2728238104Sdes cat >${write_libobj}T <<EOF 2729238104Sdes# $write_libobj - a libtool object file 2730285206Sdes# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731238104Sdes# 2732238104Sdes# Please DO NOT delete this file! 2733238104Sdes# It is necessary for linking the library. 2734238104Sdes 2735238104Sdes# Name of the PIC object. 2736238104Sdespic_object=$write_lobj 2737238104Sdes 2738238104Sdes# Name of the non-PIC object 2739238104Sdesnon_pic_object=$write_oldobj 2740238104Sdes 2741238104SdesEOF 2742285206Sdes $MV "${write_libobj}T" "$write_libobj" 2743238104Sdes } 2744238104Sdes} 2745238104Sdes 2746238104Sdes 2747238104Sdes################################################## 2748238104Sdes# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749238104Sdes################################################## 2750238104Sdes 2751238104Sdes# func_convert_core_file_wine_to_w32 ARG 2752238104Sdes# Helper function used by file name conversion functions when $build is *nix, 2753238104Sdes# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754238104Sdes# correctly configured wine environment available, with the winepath program 2755238104Sdes# in $build's $PATH. 2756238104Sdes# 2757238104Sdes# ARG is the $build file name to be converted to w32 format. 2758238104Sdes# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759238104Sdes# be empty on error (or when ARG is empty) 2760238104Sdesfunc_convert_core_file_wine_to_w32 () 2761238104Sdes{ 2762285206Sdes $debug_cmd 2763285206Sdes 2764285206Sdes func_convert_core_file_wine_to_w32_result=$1 2765238104Sdes if test -n "$1"; then 2766238104Sdes # Unfortunately, winepath does not exit with a non-zero error code, so we 2767238104Sdes # are forced to check the contents of stdout. On the other hand, if the 2768238104Sdes # command is not found, the shell will set an exit code of 127 and print 2769238104Sdes # *an error message* to stdout. So we must check for both error code of 2770238104Sdes # zero AND non-empty stdout, which explains the odd construction: 2771238104Sdes func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772285206Sdes if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773238104Sdes func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774285206Sdes $SED -e "$sed_naive_backslashify"` 2775238104Sdes else 2776238104Sdes func_convert_core_file_wine_to_w32_result= 2777238104Sdes fi 2778238104Sdes fi 2779238104Sdes} 2780238104Sdes# end: func_convert_core_file_wine_to_w32 2781238104Sdes 2782238104Sdes 2783238104Sdes# func_convert_core_path_wine_to_w32 ARG 2784238104Sdes# Helper function used by path conversion functions when $build is *nix, and 2785238104Sdes# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786238104Sdes# configured wine environment available, with the winepath program in $build's 2787238104Sdes# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788238104Sdes# 2789238104Sdes# ARG is path to be converted from $build format to win32. 2790238104Sdes# Result is available in $func_convert_core_path_wine_to_w32_result. 2791238104Sdes# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792238104Sdes# are convertible, then the result may be empty. 2793238104Sdesfunc_convert_core_path_wine_to_w32 () 2794238104Sdes{ 2795285206Sdes $debug_cmd 2796285206Sdes 2797238104Sdes # unfortunately, winepath doesn't convert paths, only file names 2798285206Sdes func_convert_core_path_wine_to_w32_result= 2799238104Sdes if test -n "$1"; then 2800238104Sdes oldIFS=$IFS 2801238104Sdes IFS=: 2802238104Sdes for func_convert_core_path_wine_to_w32_f in $1; do 2803238104Sdes IFS=$oldIFS 2804238104Sdes func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805285206Sdes if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806238104Sdes if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807285206Sdes func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808238104Sdes else 2809238104Sdes func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810238104Sdes fi 2811238104Sdes fi 2812238104Sdes done 2813238104Sdes IFS=$oldIFS 2814238104Sdes fi 2815238104Sdes} 2816238104Sdes# end: func_convert_core_path_wine_to_w32 2817238104Sdes 2818238104Sdes 2819238104Sdes# func_cygpath ARGS... 2820238104Sdes# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821238104Sdes# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822238104Sdes# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823238104Sdes# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824238104Sdes# file name or path is assumed to be in w32 format, as previously converted 2825238104Sdes# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826238104Sdes# or path in func_cygpath_result (input file name or path is assumed to be in 2827238104Sdes# Cygwin format). Returns an empty string on error. 2828238104Sdes# 2829238104Sdes# ARGS are passed to cygpath, with the last one being the file name or path to 2830238104Sdes# be converted. 2831238104Sdes# 2832238104Sdes# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833238104Sdes# environment variable; do not put it in $PATH. 2834238104Sdesfunc_cygpath () 2835238104Sdes{ 2836285206Sdes $debug_cmd 2837285206Sdes 2838238104Sdes if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839238104Sdes func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840238104Sdes if test "$?" -ne 0; then 2841238104Sdes # on failure, ensure result is empty 2842238104Sdes func_cygpath_result= 2843238104Sdes fi 2844238104Sdes else 2845238104Sdes func_cygpath_result= 2846285206Sdes func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847238104Sdes fi 2848238104Sdes} 2849238104Sdes#end: func_cygpath 2850238104Sdes 2851238104Sdes 2852238104Sdes# func_convert_core_msys_to_w32 ARG 2853238104Sdes# Convert file name or path ARG from MSYS format to w32 format. Return 2854238104Sdes# result in func_convert_core_msys_to_w32_result. 2855238104Sdesfunc_convert_core_msys_to_w32 () 2856238104Sdes{ 2857285206Sdes $debug_cmd 2858285206Sdes 2859238104Sdes # awkward: cmd appends spaces to result 2860238104Sdes func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861285206Sdes $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862238104Sdes} 2863238104Sdes#end: func_convert_core_msys_to_w32 2864238104Sdes 2865238104Sdes 2866238104Sdes# func_convert_file_check ARG1 ARG2 2867238104Sdes# Verify that ARG1 (a file name in $build format) was converted to $host 2868238104Sdes# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869238104Sdes# func_to_host_file_result to ARG1). 2870238104Sdesfunc_convert_file_check () 2871238104Sdes{ 2872285206Sdes $debug_cmd 2873285206Sdes 2874285206Sdes if test -z "$2" && test -n "$1"; then 2875238104Sdes func_error "Could not determine host file name corresponding to" 2876285206Sdes func_error " '$1'" 2877238104Sdes func_error "Continuing, but uninstalled executables may not work." 2878238104Sdes # Fallback: 2879285206Sdes func_to_host_file_result=$1 2880238104Sdes fi 2881238104Sdes} 2882238104Sdes# end func_convert_file_check 2883238104Sdes 2884238104Sdes 2885238104Sdes# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886238104Sdes# Verify that FROM_PATH (a path in $build format) was converted to $host 2887238104Sdes# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888238104Sdes# func_to_host_file_result to a simplistic fallback value (see below). 2889238104Sdesfunc_convert_path_check () 2890238104Sdes{ 2891285206Sdes $debug_cmd 2892285206Sdes 2893238104Sdes if test -z "$4" && test -n "$3"; then 2894238104Sdes func_error "Could not determine the host path corresponding to" 2895285206Sdes func_error " '$3'" 2896238104Sdes func_error "Continuing, but uninstalled executables may not work." 2897238104Sdes # Fallback. This is a deliberately simplistic "conversion" and 2898238104Sdes # should not be "improved". See libtool.info. 2899238104Sdes if test "x$1" != "x$2"; then 2900238104Sdes lt_replace_pathsep_chars="s|$1|$2|g" 2901238104Sdes func_to_host_path_result=`echo "$3" | 2902238104Sdes $SED -e "$lt_replace_pathsep_chars"` 2903238104Sdes else 2904285206Sdes func_to_host_path_result=$3 2905238104Sdes fi 2906238104Sdes fi 2907238104Sdes} 2908238104Sdes# end func_convert_path_check 2909238104Sdes 2910238104Sdes 2911238104Sdes# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912238104Sdes# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913238104Sdes# and appending REPL if ORIG matches BACKPAT. 2914238104Sdesfunc_convert_path_front_back_pathsep () 2915238104Sdes{ 2916285206Sdes $debug_cmd 2917285206Sdes 2918238104Sdes case $4 in 2919285206Sdes $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920238104Sdes ;; 2921238104Sdes esac 2922238104Sdes case $4 in 2923238104Sdes $2 ) func_append func_to_host_path_result "$3" 2924238104Sdes ;; 2925238104Sdes esac 2926238104Sdes} 2927238104Sdes# end func_convert_path_front_back_pathsep 2928238104Sdes 2929238104Sdes 2930238104Sdes################################################## 2931238104Sdes# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932238104Sdes################################################## 2933285206Sdes# invoked via '$to_host_file_cmd ARG' 2934238104Sdes# 2935238104Sdes# In each case, ARG is the path to be converted from $build to $host format. 2936238104Sdes# Result will be available in $func_to_host_file_result. 2937238104Sdes 2938238104Sdes 2939238104Sdes# func_to_host_file ARG 2940238104Sdes# Converts the file name ARG from $build format to $host format. Return result 2941238104Sdes# in func_to_host_file_result. 2942238104Sdesfunc_to_host_file () 2943238104Sdes{ 2944285206Sdes $debug_cmd 2945285206Sdes 2946238104Sdes $to_host_file_cmd "$1" 2947238104Sdes} 2948238104Sdes# end func_to_host_file 2949238104Sdes 2950238104Sdes 2951238104Sdes# func_to_tool_file ARG LAZY 2952238104Sdes# converts the file name ARG from $build format to toolchain format. Return 2953238104Sdes# result in func_to_tool_file_result. If the conversion in use is listed 2954238104Sdes# in (the comma separated) LAZY, no conversion takes place. 2955238104Sdesfunc_to_tool_file () 2956238104Sdes{ 2957285206Sdes $debug_cmd 2958285206Sdes 2959238104Sdes case ,$2, in 2960238104Sdes *,"$to_tool_file_cmd",*) 2961238104Sdes func_to_tool_file_result=$1 2962238104Sdes ;; 2963238104Sdes *) 2964238104Sdes $to_tool_file_cmd "$1" 2965238104Sdes func_to_tool_file_result=$func_to_host_file_result 2966238104Sdes ;; 2967238104Sdes esac 2968238104Sdes} 2969238104Sdes# end func_to_tool_file 2970238104Sdes 2971238104Sdes 2972238104Sdes# func_convert_file_noop ARG 2973238104Sdes# Copy ARG to func_to_host_file_result. 2974238104Sdesfunc_convert_file_noop () 2975238104Sdes{ 2976285206Sdes func_to_host_file_result=$1 2977238104Sdes} 2978238104Sdes# end func_convert_file_noop 2979238104Sdes 2980238104Sdes 2981238104Sdes# func_convert_file_msys_to_w32 ARG 2982238104Sdes# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983238104Sdes# conversion to w32 is not available inside the cwrapper. Returns result in 2984238104Sdes# func_to_host_file_result. 2985238104Sdesfunc_convert_file_msys_to_w32 () 2986238104Sdes{ 2987285206Sdes $debug_cmd 2988285206Sdes 2989285206Sdes func_to_host_file_result=$1 2990238104Sdes if test -n "$1"; then 2991238104Sdes func_convert_core_msys_to_w32 "$1" 2992285206Sdes func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993238104Sdes fi 2994238104Sdes func_convert_file_check "$1" "$func_to_host_file_result" 2995238104Sdes} 2996238104Sdes# end func_convert_file_msys_to_w32 2997238104Sdes 2998238104Sdes 2999238104Sdes# func_convert_file_cygwin_to_w32 ARG 3000238104Sdes# Convert file name ARG from Cygwin to w32 format. Returns result in 3001238104Sdes# func_to_host_file_result. 3002238104Sdesfunc_convert_file_cygwin_to_w32 () 3003238104Sdes{ 3004285206Sdes $debug_cmd 3005285206Sdes 3006285206Sdes func_to_host_file_result=$1 3007238104Sdes if test -n "$1"; then 3008238104Sdes # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009238104Sdes # LT_CYGPATH in this case. 3010238104Sdes func_to_host_file_result=`cygpath -m "$1"` 3011238104Sdes fi 3012238104Sdes func_convert_file_check "$1" "$func_to_host_file_result" 3013238104Sdes} 3014238104Sdes# end func_convert_file_cygwin_to_w32 3015238104Sdes 3016238104Sdes 3017238104Sdes# func_convert_file_nix_to_w32 ARG 3018238104Sdes# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019238104Sdes# and a working winepath. Returns result in func_to_host_file_result. 3020238104Sdesfunc_convert_file_nix_to_w32 () 3021238104Sdes{ 3022285206Sdes $debug_cmd 3023285206Sdes 3024285206Sdes func_to_host_file_result=$1 3025238104Sdes if test -n "$1"; then 3026238104Sdes func_convert_core_file_wine_to_w32 "$1" 3027285206Sdes func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028238104Sdes fi 3029238104Sdes func_convert_file_check "$1" "$func_to_host_file_result" 3030238104Sdes} 3031238104Sdes# end func_convert_file_nix_to_w32 3032238104Sdes 3033238104Sdes 3034238104Sdes# func_convert_file_msys_to_cygwin ARG 3035238104Sdes# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036238104Sdes# Returns result in func_to_host_file_result. 3037238104Sdesfunc_convert_file_msys_to_cygwin () 3038238104Sdes{ 3039285206Sdes $debug_cmd 3040285206Sdes 3041285206Sdes func_to_host_file_result=$1 3042238104Sdes if test -n "$1"; then 3043238104Sdes func_convert_core_msys_to_w32 "$1" 3044238104Sdes func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045285206Sdes func_to_host_file_result=$func_cygpath_result 3046238104Sdes fi 3047238104Sdes func_convert_file_check "$1" "$func_to_host_file_result" 3048238104Sdes} 3049238104Sdes# end func_convert_file_msys_to_cygwin 3050238104Sdes 3051238104Sdes 3052238104Sdes# func_convert_file_nix_to_cygwin ARG 3053238104Sdes# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054238104Sdes# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055238104Sdes# in func_to_host_file_result. 3056238104Sdesfunc_convert_file_nix_to_cygwin () 3057238104Sdes{ 3058285206Sdes $debug_cmd 3059285206Sdes 3060285206Sdes func_to_host_file_result=$1 3061238104Sdes if test -n "$1"; then 3062238104Sdes # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063238104Sdes func_convert_core_file_wine_to_w32 "$1" 3064238104Sdes func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065285206Sdes func_to_host_file_result=$func_cygpath_result 3066238104Sdes fi 3067238104Sdes func_convert_file_check "$1" "$func_to_host_file_result" 3068238104Sdes} 3069238104Sdes# end func_convert_file_nix_to_cygwin 3070238104Sdes 3071238104Sdes 3072238104Sdes############################################# 3073238104Sdes# $build to $host PATH CONVERSION FUNCTIONS # 3074238104Sdes############################################# 3075285206Sdes# invoked via '$to_host_path_cmd ARG' 3076238104Sdes# 3077238104Sdes# In each case, ARG is the path to be converted from $build to $host format. 3078238104Sdes# The result will be available in $func_to_host_path_result. 3079238104Sdes# 3080238104Sdes# Path separators are also converted from $build format to $host format. If 3081238104Sdes# ARG begins or ends with a path separator character, it is preserved (but 3082238104Sdes# converted to $host format) on output. 3083238104Sdes# 3084238104Sdes# All path conversion functions are named using the following convention: 3085238104Sdes# file name conversion function : func_convert_file_X_to_Y () 3086238104Sdes# path conversion function : func_convert_path_X_to_Y () 3087238104Sdes# where, for any given $build/$host combination the 'X_to_Y' value is the 3088238104Sdes# same. If conversion functions are added for new $build/$host combinations, 3089238104Sdes# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090238104Sdes# will break. 3091238104Sdes 3092238104Sdes 3093238104Sdes# func_init_to_host_path_cmd 3094238104Sdes# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095238104Sdes# appropriate value, based on the value of $to_host_file_cmd. 3096238104Sdesto_host_path_cmd= 3097238104Sdesfunc_init_to_host_path_cmd () 3098238104Sdes{ 3099285206Sdes $debug_cmd 3100285206Sdes 3101238104Sdes if test -z "$to_host_path_cmd"; then 3102238104Sdes func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103285206Sdes to_host_path_cmd=func_convert_path_$func_stripname_result 3104238104Sdes fi 3105238104Sdes} 3106238104Sdes 3107238104Sdes 3108238104Sdes# func_to_host_path ARG 3109238104Sdes# Converts the path ARG from $build format to $host format. Return result 3110238104Sdes# in func_to_host_path_result. 3111238104Sdesfunc_to_host_path () 3112238104Sdes{ 3113285206Sdes $debug_cmd 3114285206Sdes 3115238104Sdes func_init_to_host_path_cmd 3116238104Sdes $to_host_path_cmd "$1" 3117238104Sdes} 3118238104Sdes# end func_to_host_path 3119238104Sdes 3120238104Sdes 3121238104Sdes# func_convert_path_noop ARG 3122238104Sdes# Copy ARG to func_to_host_path_result. 3123238104Sdesfunc_convert_path_noop () 3124238104Sdes{ 3125285206Sdes func_to_host_path_result=$1 3126238104Sdes} 3127238104Sdes# end func_convert_path_noop 3128238104Sdes 3129238104Sdes 3130238104Sdes# func_convert_path_msys_to_w32 ARG 3131238104Sdes# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132238104Sdes# conversion to w32 is not available inside the cwrapper. Returns result in 3133238104Sdes# func_to_host_path_result. 3134238104Sdesfunc_convert_path_msys_to_w32 () 3135238104Sdes{ 3136285206Sdes $debug_cmd 3137285206Sdes 3138285206Sdes func_to_host_path_result=$1 3139238104Sdes if test -n "$1"; then 3140238104Sdes # Remove leading and trailing path separator characters from ARG. MSYS 3141238104Sdes # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142238104Sdes # and winepath ignores them completely. 3143238104Sdes func_stripname : : "$1" 3144238104Sdes func_to_host_path_tmp1=$func_stripname_result 3145238104Sdes func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146285206Sdes func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147238104Sdes func_convert_path_check : ";" \ 3148238104Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149238104Sdes func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150238104Sdes fi 3151238104Sdes} 3152238104Sdes# end func_convert_path_msys_to_w32 3153238104Sdes 3154238104Sdes 3155238104Sdes# func_convert_path_cygwin_to_w32 ARG 3156238104Sdes# Convert path ARG from Cygwin to w32 format. Returns result in 3157238104Sdes# func_to_host_file_result. 3158238104Sdesfunc_convert_path_cygwin_to_w32 () 3159238104Sdes{ 3160285206Sdes $debug_cmd 3161285206Sdes 3162285206Sdes func_to_host_path_result=$1 3163238104Sdes if test -n "$1"; then 3164238104Sdes # See func_convert_path_msys_to_w32: 3165238104Sdes func_stripname : : "$1" 3166238104Sdes func_to_host_path_tmp1=$func_stripname_result 3167238104Sdes func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168238104Sdes func_convert_path_check : ";" \ 3169238104Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170238104Sdes func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171238104Sdes fi 3172238104Sdes} 3173238104Sdes# end func_convert_path_cygwin_to_w32 3174238104Sdes 3175238104Sdes 3176238104Sdes# func_convert_path_nix_to_w32 ARG 3177238104Sdes# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178238104Sdes# a working winepath. Returns result in func_to_host_file_result. 3179238104Sdesfunc_convert_path_nix_to_w32 () 3180238104Sdes{ 3181285206Sdes $debug_cmd 3182285206Sdes 3183285206Sdes func_to_host_path_result=$1 3184238104Sdes if test -n "$1"; then 3185238104Sdes # See func_convert_path_msys_to_w32: 3186238104Sdes func_stripname : : "$1" 3187238104Sdes func_to_host_path_tmp1=$func_stripname_result 3188238104Sdes func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189285206Sdes func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190238104Sdes func_convert_path_check : ";" \ 3191238104Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192238104Sdes func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193238104Sdes fi 3194238104Sdes} 3195238104Sdes# end func_convert_path_nix_to_w32 3196238104Sdes 3197238104Sdes 3198238104Sdes# func_convert_path_msys_to_cygwin ARG 3199238104Sdes# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200238104Sdes# Returns result in func_to_host_file_result. 3201238104Sdesfunc_convert_path_msys_to_cygwin () 3202238104Sdes{ 3203285206Sdes $debug_cmd 3204285206Sdes 3205285206Sdes func_to_host_path_result=$1 3206238104Sdes if test -n "$1"; then 3207238104Sdes # See func_convert_path_msys_to_w32: 3208238104Sdes func_stripname : : "$1" 3209238104Sdes func_to_host_path_tmp1=$func_stripname_result 3210238104Sdes func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211238104Sdes func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212285206Sdes func_to_host_path_result=$func_cygpath_result 3213238104Sdes func_convert_path_check : : \ 3214238104Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215238104Sdes func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216238104Sdes fi 3217238104Sdes} 3218238104Sdes# end func_convert_path_msys_to_cygwin 3219238104Sdes 3220238104Sdes 3221238104Sdes# func_convert_path_nix_to_cygwin ARG 3222238104Sdes# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223238104Sdes# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224238104Sdes# func_to_host_file_result. 3225238104Sdesfunc_convert_path_nix_to_cygwin () 3226238104Sdes{ 3227285206Sdes $debug_cmd 3228285206Sdes 3229285206Sdes func_to_host_path_result=$1 3230238104Sdes if test -n "$1"; then 3231238104Sdes # Remove leading and trailing path separator characters from 3232238104Sdes # ARG. msys behavior is inconsistent here, cygpath turns them 3233238104Sdes # into '.;' and ';.', and winepath ignores them completely. 3234238104Sdes func_stripname : : "$1" 3235238104Sdes func_to_host_path_tmp1=$func_stripname_result 3236238104Sdes func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237238104Sdes func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238285206Sdes func_to_host_path_result=$func_cygpath_result 3239238104Sdes func_convert_path_check : : \ 3240238104Sdes "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241238104Sdes func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242238104Sdes fi 3243238104Sdes} 3244238104Sdes# end func_convert_path_nix_to_cygwin 3245238104Sdes 3246238104Sdes 3247285206Sdes# func_dll_def_p FILE 3248285206Sdes# True iff FILE is a Windows DLL '.def' file. 3249285206Sdes# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250285206Sdesfunc_dll_def_p () 3251285206Sdes{ 3252285206Sdes $debug_cmd 3253285206Sdes 3254285206Sdes func_dll_def_p_tmp=`$SED -n \ 3255285206Sdes -e 's/^[ ]*//' \ 3256285206Sdes -e '/^\(;.*\)*$/d' \ 3257285206Sdes -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258285206Sdes -e q \ 3259285206Sdes "$1"` 3260285206Sdes test DEF = "$func_dll_def_p_tmp" 3261285206Sdes} 3262285206Sdes 3263285206Sdes 3264238104Sdes# func_mode_compile arg... 3265238104Sdesfunc_mode_compile () 3266238104Sdes{ 3267285206Sdes $debug_cmd 3268285206Sdes 3269238104Sdes # Get the compilation command and the source file. 3270238104Sdes base_compile= 3271285206Sdes srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272238104Sdes suppress_opt=yes 3273238104Sdes suppress_output= 3274238104Sdes arg_mode=normal 3275238104Sdes libobj= 3276238104Sdes later= 3277238104Sdes pie_flag= 3278238104Sdes 3279238104Sdes for arg 3280238104Sdes do 3281238104Sdes case $arg_mode in 3282238104Sdes arg ) 3283238104Sdes # do not "continue". Instead, add this to base_compile 3284285206Sdes lastarg=$arg 3285238104Sdes arg_mode=normal 3286238104Sdes ;; 3287238104Sdes 3288238104Sdes target ) 3289285206Sdes libobj=$arg 3290238104Sdes arg_mode=normal 3291238104Sdes continue 3292238104Sdes ;; 3293238104Sdes 3294238104Sdes normal ) 3295238104Sdes # Accept any command-line options. 3296238104Sdes case $arg in 3297238104Sdes -o) 3298238104Sdes test -n "$libobj" && \ 3299285206Sdes func_fatal_error "you cannot specify '-o' more than once" 3300238104Sdes arg_mode=target 3301238104Sdes continue 3302238104Sdes ;; 3303238104Sdes 3304238104Sdes -pie | -fpie | -fPIE) 3305238104Sdes func_append pie_flag " $arg" 3306238104Sdes continue 3307238104Sdes ;; 3308238104Sdes 3309238104Sdes -shared | -static | -prefer-pic | -prefer-non-pic) 3310238104Sdes func_append later " $arg" 3311238104Sdes continue 3312238104Sdes ;; 3313238104Sdes 3314238104Sdes -no-suppress) 3315238104Sdes suppress_opt=no 3316238104Sdes continue 3317238104Sdes ;; 3318238104Sdes 3319238104Sdes -Xcompiler) 3320238104Sdes arg_mode=arg # the next one goes into the "base_compile" arg list 3321238104Sdes continue # The current "srcfile" will either be retained or 3322238104Sdes ;; # replaced later. I would guess that would be a bug. 3323238104Sdes 3324238104Sdes -Wc,*) 3325238104Sdes func_stripname '-Wc,' '' "$arg" 3326238104Sdes args=$func_stripname_result 3327238104Sdes lastarg= 3328285206Sdes save_ifs=$IFS; IFS=, 3329238104Sdes for arg in $args; do 3330285206Sdes IFS=$save_ifs 3331238104Sdes func_append_quoted lastarg "$arg" 3332238104Sdes done 3333285206Sdes IFS=$save_ifs 3334238104Sdes func_stripname ' ' '' "$lastarg" 3335238104Sdes lastarg=$func_stripname_result 3336238104Sdes 3337238104Sdes # Add the arguments to base_compile. 3338238104Sdes func_append base_compile " $lastarg" 3339238104Sdes continue 3340238104Sdes ;; 3341238104Sdes 3342238104Sdes *) 3343238104Sdes # Accept the current argument as the source file. 3344238104Sdes # The previous "srcfile" becomes the current argument. 3345238104Sdes # 3346285206Sdes lastarg=$srcfile 3347285206Sdes srcfile=$arg 3348238104Sdes ;; 3349238104Sdes esac # case $arg 3350238104Sdes ;; 3351238104Sdes esac # case $arg_mode 3352238104Sdes 3353238104Sdes # Aesthetically quote the previous argument. 3354238104Sdes func_append_quoted base_compile "$lastarg" 3355238104Sdes done # for arg 3356238104Sdes 3357238104Sdes case $arg_mode in 3358238104Sdes arg) 3359238104Sdes func_fatal_error "you must specify an argument for -Xcompile" 3360238104Sdes ;; 3361238104Sdes target) 3362285206Sdes func_fatal_error "you must specify a target with '-o'" 3363238104Sdes ;; 3364238104Sdes *) 3365238104Sdes # Get the name of the library object. 3366238104Sdes test -z "$libobj" && { 3367238104Sdes func_basename "$srcfile" 3368285206Sdes libobj=$func_basename_result 3369238104Sdes } 3370238104Sdes ;; 3371238104Sdes esac 3372238104Sdes 3373238104Sdes # Recognize several different file suffixes. 3374238104Sdes # If the user specifies -o file.o, it is replaced with file.lo 3375238104Sdes case $libobj in 3376238104Sdes *.[cCFSifmso] | \ 3377238104Sdes *.ada | *.adb | *.ads | *.asm | \ 3378238104Sdes *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379238104Sdes *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380238104Sdes func_xform "$libobj" 3381238104Sdes libobj=$func_xform_result 3382238104Sdes ;; 3383238104Sdes esac 3384238104Sdes 3385238104Sdes case $libobj in 3386238104Sdes *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387238104Sdes *) 3388285206Sdes func_fatal_error "cannot determine name of library object from '$libobj'" 3389238104Sdes ;; 3390238104Sdes esac 3391238104Sdes 3392238104Sdes func_infer_tag $base_compile 3393238104Sdes 3394238104Sdes for arg in $later; do 3395238104Sdes case $arg in 3396238104Sdes -shared) 3397285206Sdes test yes = "$build_libtool_libs" \ 3398285206Sdes || func_fatal_configuration "cannot build a shared library" 3399238104Sdes build_old_libs=no 3400238104Sdes continue 3401238104Sdes ;; 3402238104Sdes 3403238104Sdes -static) 3404238104Sdes build_libtool_libs=no 3405238104Sdes build_old_libs=yes 3406238104Sdes continue 3407238104Sdes ;; 3408238104Sdes 3409238104Sdes -prefer-pic) 3410238104Sdes pic_mode=yes 3411238104Sdes continue 3412238104Sdes ;; 3413238104Sdes 3414238104Sdes -prefer-non-pic) 3415238104Sdes pic_mode=no 3416238104Sdes continue 3417238104Sdes ;; 3418238104Sdes esac 3419238104Sdes done 3420238104Sdes 3421238104Sdes func_quote_for_eval "$libobj" 3422238104Sdes test "X$libobj" != "X$func_quote_for_eval_result" \ 3423238104Sdes && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424285206Sdes && func_warning "libobj name '$libobj' may not contain shell special characters." 3425238104Sdes func_dirname_and_basename "$obj" "/" "" 3426285206Sdes objname=$func_basename_result 3427285206Sdes xdir=$func_dirname_result 3428285206Sdes lobj=$xdir$objdir/$objname 3429238104Sdes 3430238104Sdes test -z "$base_compile" && \ 3431238104Sdes func_fatal_help "you must specify a compilation command" 3432238104Sdes 3433238104Sdes # Delete any leftover library objects. 3434285206Sdes if test yes = "$build_old_libs"; then 3435238104Sdes removelist="$obj $lobj $libobj ${libobj}T" 3436238104Sdes else 3437238104Sdes removelist="$lobj $libobj ${libobj}T" 3438238104Sdes fi 3439238104Sdes 3440238104Sdes # On Cygwin there's no "real" PIC flag so we must build both object types 3441238104Sdes case $host_os in 3442238104Sdes cygwin* | mingw* | pw32* | os2* | cegcc*) 3443238104Sdes pic_mode=default 3444238104Sdes ;; 3445238104Sdes esac 3446285206Sdes if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447238104Sdes # non-PIC code in shared libraries is not supported 3448238104Sdes pic_mode=default 3449238104Sdes fi 3450238104Sdes 3451238104Sdes # Calculate the filename of the output object if compiler does 3452238104Sdes # not support -o with -c 3453285206Sdes if test no = "$compiler_c_o"; then 3454285206Sdes output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455285206Sdes lockfile=$output_obj.lock 3456238104Sdes else 3457238104Sdes output_obj= 3458238104Sdes need_locks=no 3459238104Sdes lockfile= 3460238104Sdes fi 3461238104Sdes 3462238104Sdes # Lock this critical section if it is needed 3463238104Sdes # We use this script file to make the link, it avoids creating a new file 3464285206Sdes if test yes = "$need_locks"; then 3465238104Sdes until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466238104Sdes func_echo "Waiting for $lockfile to be removed" 3467238104Sdes sleep 2 3468238104Sdes done 3469285206Sdes elif test warn = "$need_locks"; then 3470238104Sdes if test -f "$lockfile"; then 3471238104Sdes $ECHO "\ 3472238104Sdes*** ERROR, $lockfile exists and contains: 3473238104Sdes`cat $lockfile 2>/dev/null` 3474238104Sdes 3475238104SdesThis indicates that another process is trying to use the same 3476238104Sdestemporary object file, and libtool could not work around it because 3477285206Sdesyour compiler does not support '-c' and '-o' together. If you 3478238104Sdesrepeat this compilation, it may succeed, by chance, but you had better 3479238104Sdesavoid parallel builds (make -j) in this platform, or get a better 3480238104Sdescompiler." 3481238104Sdes 3482238104Sdes $opt_dry_run || $RM $removelist 3483238104Sdes exit $EXIT_FAILURE 3484238104Sdes fi 3485238104Sdes func_append removelist " $output_obj" 3486238104Sdes $ECHO "$srcfile" > "$lockfile" 3487238104Sdes fi 3488238104Sdes 3489238104Sdes $opt_dry_run || $RM $removelist 3490238104Sdes func_append removelist " $lockfile" 3491238104Sdes trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492238104Sdes 3493238104Sdes func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494238104Sdes srcfile=$func_to_tool_file_result 3495238104Sdes func_quote_for_eval "$srcfile" 3496238104Sdes qsrcfile=$func_quote_for_eval_result 3497238104Sdes 3498238104Sdes # Only build a PIC object if we are building libtool libraries. 3499285206Sdes if test yes = "$build_libtool_libs"; then 3500238104Sdes # Without this assignment, base_compile gets emptied. 3501238104Sdes fbsd_hideous_sh_bug=$base_compile 3502238104Sdes 3503285206Sdes if test no != "$pic_mode"; then 3504238104Sdes command="$base_compile $qsrcfile $pic_flag" 3505238104Sdes else 3506238104Sdes # Don't build PIC code 3507238104Sdes command="$base_compile $qsrcfile" 3508238104Sdes fi 3509238104Sdes 3510238104Sdes func_mkdir_p "$xdir$objdir" 3511238104Sdes 3512238104Sdes if test -z "$output_obj"; then 3513238104Sdes # Place PIC objects in $objdir 3514238104Sdes func_append command " -o $lobj" 3515238104Sdes fi 3516238104Sdes 3517238104Sdes func_show_eval_locale "$command" \ 3518238104Sdes 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519238104Sdes 3520285206Sdes if test warn = "$need_locks" && 3521238104Sdes test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522238104Sdes $ECHO "\ 3523238104Sdes*** ERROR, $lockfile contains: 3524238104Sdes`cat $lockfile 2>/dev/null` 3525238104Sdes 3526238104Sdesbut it should contain: 3527238104Sdes$srcfile 3528238104Sdes 3529238104SdesThis indicates that another process is trying to use the same 3530238104Sdestemporary object file, and libtool could not work around it because 3531285206Sdesyour compiler does not support '-c' and '-o' together. If you 3532238104Sdesrepeat this compilation, it may succeed, by chance, but you had better 3533238104Sdesavoid parallel builds (make -j) in this platform, or get a better 3534238104Sdescompiler." 3535238104Sdes 3536238104Sdes $opt_dry_run || $RM $removelist 3537238104Sdes exit $EXIT_FAILURE 3538238104Sdes fi 3539238104Sdes 3540238104Sdes # Just move the object if needed, then go on to compile the next one 3541238104Sdes if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542238104Sdes func_show_eval '$MV "$output_obj" "$lobj"' \ 3543238104Sdes 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544238104Sdes fi 3545238104Sdes 3546238104Sdes # Allow error messages only from the first compilation. 3547285206Sdes if test yes = "$suppress_opt"; then 3548238104Sdes suppress_output=' >/dev/null 2>&1' 3549238104Sdes fi 3550238104Sdes fi 3551238104Sdes 3552238104Sdes # Only build a position-dependent object if we build old libraries. 3553285206Sdes if test yes = "$build_old_libs"; then 3554285206Sdes if test yes != "$pic_mode"; then 3555238104Sdes # Don't build PIC code 3556238104Sdes command="$base_compile $qsrcfile$pie_flag" 3557238104Sdes else 3558238104Sdes command="$base_compile $qsrcfile $pic_flag" 3559238104Sdes fi 3560285206Sdes if test yes = "$compiler_c_o"; then 3561238104Sdes func_append command " -o $obj" 3562238104Sdes fi 3563238104Sdes 3564238104Sdes # Suppress compiler output if we already did a PIC compilation. 3565238104Sdes func_append command "$suppress_output" 3566238104Sdes func_show_eval_locale "$command" \ 3567238104Sdes '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568238104Sdes 3569285206Sdes if test warn = "$need_locks" && 3570238104Sdes test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571238104Sdes $ECHO "\ 3572238104Sdes*** ERROR, $lockfile contains: 3573238104Sdes`cat $lockfile 2>/dev/null` 3574238104Sdes 3575238104Sdesbut it should contain: 3576238104Sdes$srcfile 3577238104Sdes 3578238104SdesThis indicates that another process is trying to use the same 3579238104Sdestemporary object file, and libtool could not work around it because 3580285206Sdesyour compiler does not support '-c' and '-o' together. If you 3581238104Sdesrepeat this compilation, it may succeed, by chance, but you had better 3582238104Sdesavoid parallel builds (make -j) in this platform, or get a better 3583238104Sdescompiler." 3584238104Sdes 3585238104Sdes $opt_dry_run || $RM $removelist 3586238104Sdes exit $EXIT_FAILURE 3587238104Sdes fi 3588238104Sdes 3589238104Sdes # Just move the object if needed 3590238104Sdes if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591238104Sdes func_show_eval '$MV "$output_obj" "$obj"' \ 3592238104Sdes 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593238104Sdes fi 3594238104Sdes fi 3595238104Sdes 3596238104Sdes $opt_dry_run || { 3597238104Sdes func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598238104Sdes 3599238104Sdes # Unlock the critical section if it was locked 3600285206Sdes if test no != "$need_locks"; then 3601238104Sdes removelist=$lockfile 3602238104Sdes $RM "$lockfile" 3603238104Sdes fi 3604238104Sdes } 3605238104Sdes 3606238104Sdes exit $EXIT_SUCCESS 3607238104Sdes} 3608238104Sdes 3609238104Sdes$opt_help || { 3610285206Sdes test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611238104Sdes} 3612238104Sdes 3613238104Sdesfunc_mode_help () 3614238104Sdes{ 3615238104Sdes # We need to display help for each of the modes. 3616238104Sdes case $opt_mode in 3617238104Sdes "") 3618238104Sdes # Generic help is extracted from the usage comments 3619238104Sdes # at the start of this file. 3620238104Sdes func_help 3621238104Sdes ;; 3622238104Sdes 3623238104Sdes clean) 3624238104Sdes $ECHO \ 3625238104Sdes"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626238104Sdes 3627238104SdesRemove files from the build directory. 3628238104Sdes 3629238104SdesRM is the name of the program to use to delete files associated with each FILE 3630285206Sdes(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631238104Sdesto RM. 3632238104Sdes 3633238104SdesIf FILE is a libtool library, object or program, all the files associated 3634238104Sdeswith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635238104Sdes ;; 3636238104Sdes 3637238104Sdes compile) 3638238104Sdes $ECHO \ 3639238104Sdes"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640238104Sdes 3641238104SdesCompile a source file into a libtool library object. 3642238104Sdes 3643238104SdesThis mode accepts the following additional options: 3644238104Sdes 3645238104Sdes -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646238104Sdes -no-suppress do not suppress compiler output for multiple passes 3647238104Sdes -prefer-pic try to build PIC objects only 3648238104Sdes -prefer-non-pic try to build non-PIC objects only 3649285206Sdes -shared do not build a '.o' file suitable for static linking 3650285206Sdes -static only build a '.o' file suitable for static linking 3651238104Sdes -Wc,FLAG pass FLAG directly to the compiler 3652238104Sdes 3653285206SdesCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654238104Sdesfrom the given SOURCEFILE. 3655238104Sdes 3656238104SdesThe output file name is determined by removing the directory component from 3657285206SdesSOURCEFILE, then substituting the C source code suffix '.c' with the 3658285206Sdeslibrary object suffix, '.lo'." 3659238104Sdes ;; 3660238104Sdes 3661238104Sdes execute) 3662238104Sdes $ECHO \ 3663238104Sdes"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664238104Sdes 3665238104SdesAutomatically set library path, then run a program. 3666238104Sdes 3667238104SdesThis mode accepts the following additional options: 3668238104Sdes 3669238104Sdes -dlopen FILE add the directory containing FILE to the library path 3670238104Sdes 3671285206SdesThis mode sets the library path environment variable according to '-dlopen' 3672238104Sdesflags. 3673238104Sdes 3674238104SdesIf any of the ARGS are libtool executable wrappers, then they are translated 3675238104Sdesinto their corresponding uninstalled binary, and any of their required library 3676238104Sdesdirectories are added to the library path. 3677238104Sdes 3678238104SdesThen, COMMAND is executed, with ARGS as arguments." 3679238104Sdes ;; 3680238104Sdes 3681238104Sdes finish) 3682238104Sdes $ECHO \ 3683238104Sdes"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684238104Sdes 3685238104SdesComplete the installation of libtool libraries. 3686238104Sdes 3687238104SdesEach LIBDIR is a directory that contains libtool libraries. 3688238104Sdes 3689238104SdesThe commands that this mode executes may require superuser privileges. Use 3690285206Sdesthe '--dry-run' option if you just want to see what would be executed." 3691238104Sdes ;; 3692238104Sdes 3693238104Sdes install) 3694238104Sdes $ECHO \ 3695238104Sdes"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696238104Sdes 3697238104SdesInstall executables or libraries. 3698238104Sdes 3699238104SdesINSTALL-COMMAND is the installation command. The first component should be 3700285206Sdeseither the 'install' or 'cp' program. 3701238104Sdes 3702238104SdesThe following components of INSTALL-COMMAND are treated specially: 3703238104Sdes 3704238104Sdes -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705238104Sdes 3706238104SdesThe rest of the components are interpreted as arguments to that command (only 3707238104SdesBSD-compatible install options are recognized)." 3708238104Sdes ;; 3709238104Sdes 3710238104Sdes link) 3711238104Sdes $ECHO \ 3712238104Sdes"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713238104Sdes 3714238104SdesLink object files or libraries together to form another library, or to 3715238104Sdescreate an executable program. 3716238104Sdes 3717238104SdesLINK-COMMAND is a command using the C compiler that you would use to create 3718238104Sdesa program from several object files. 3719238104Sdes 3720238104SdesThe following components of LINK-COMMAND are treated specially: 3721238104Sdes 3722238104Sdes -all-static do not do any dynamic linking at all 3723238104Sdes -avoid-version do not add a version suffix if possible 3724238104Sdes -bindir BINDIR specify path to binaries directory (for systems where 3725238104Sdes libraries must be found in the PATH setting at runtime) 3726285206Sdes -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727238104Sdes -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728238104Sdes -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729238104Sdes -export-symbols SYMFILE 3730238104Sdes try to export only the symbols listed in SYMFILE 3731238104Sdes -export-symbols-regex REGEX 3732238104Sdes try to export only the symbols matching REGEX 3733238104Sdes -LLIBDIR search LIBDIR for required installed libraries 3734238104Sdes -lNAME OUTPUT-FILE requires the installed library libNAME 3735238104Sdes -module build a library that can dlopened 3736238104Sdes -no-fast-install disable the fast-install mode 3737238104Sdes -no-install link a not-installable executable 3738238104Sdes -no-undefined declare that a library does not refer to external symbols 3739238104Sdes -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740285206Sdes -objectlist FILE use a list of object files found in FILE to specify objects 3741285206Sdes -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742238104Sdes -precious-files-regex REGEX 3743238104Sdes don't remove output files matching REGEX 3744238104Sdes -release RELEASE specify package release information 3745238104Sdes -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746238104Sdes -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747238104Sdes -shared only do dynamic linking of libtool libraries 3748238104Sdes -shrext SUFFIX override the standard shared library file extension 3749238104Sdes -static do not do any dynamic linking of uninstalled libtool libraries 3750238104Sdes -static-libtool-libs 3751238104Sdes do not do any dynamic linking of libtool libraries 3752238104Sdes -version-info CURRENT[:REVISION[:AGE]] 3753238104Sdes specify library version info [each variable defaults to 0] 3754238104Sdes -weak LIBNAME declare that the target provides the LIBNAME interface 3755238104Sdes -Wc,FLAG 3756238104Sdes -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757238104Sdes -Wl,FLAG 3758238104Sdes -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759238104Sdes -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760238104Sdes 3761285206SdesAll other options (arguments beginning with '-') are ignored. 3762238104Sdes 3763285206SdesEvery other argument is treated as a filename. Files ending in '.la' are 3764238104Sdestreated as uninstalled libtool libraries, other files are standard or library 3765238104Sdesobject files. 3766238104Sdes 3767285206SdesIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768285206Sdesonly library objects ('.lo' files) may be specified, and '-rpath' is 3769238104Sdesrequired, except when creating a convenience library. 3770238104Sdes 3771285206SdesIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772285206Sdesusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773238104Sdes 3774285206SdesIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775238104Sdesis created, otherwise an executable program is created." 3776238104Sdes ;; 3777238104Sdes 3778238104Sdes uninstall) 3779238104Sdes $ECHO \ 3780238104Sdes"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781238104Sdes 3782238104SdesRemove libraries from an installation directory. 3783238104Sdes 3784238104SdesRM is the name of the program to use to delete files associated with each FILE 3785285206Sdes(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786238104Sdesto RM. 3787238104Sdes 3788238104SdesIf FILE is a libtool library, all the files associated with it are deleted. 3789238104SdesOtherwise, only FILE itself is deleted using RM." 3790238104Sdes ;; 3791238104Sdes 3792238104Sdes *) 3793285206Sdes func_fatal_help "invalid operation mode '$opt_mode'" 3794238104Sdes ;; 3795238104Sdes esac 3796238104Sdes 3797238104Sdes echo 3798285206Sdes $ECHO "Try '$progname --help' for more information about other modes." 3799238104Sdes} 3800238104Sdes 3801238104Sdes# Now that we've collected a possible --mode arg, show help if necessary 3802238104Sdesif $opt_help; then 3803285206Sdes if test : = "$opt_help"; then 3804238104Sdes func_mode_help 3805238104Sdes else 3806238104Sdes { 3807238104Sdes func_help noexit 3808238104Sdes for opt_mode in compile link execute install finish uninstall clean; do 3809238104Sdes func_mode_help 3810238104Sdes done 3811285206Sdes } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812238104Sdes { 3813238104Sdes func_help noexit 3814238104Sdes for opt_mode in compile link execute install finish uninstall clean; do 3815238104Sdes echo 3816238104Sdes func_mode_help 3817238104Sdes done 3818238104Sdes } | 3819285206Sdes $SED '1d 3820238104Sdes /^When reporting/,/^Report/{ 3821238104Sdes H 3822238104Sdes d 3823238104Sdes } 3824238104Sdes $x 3825238104Sdes /information about other modes/d 3826238104Sdes /more detailed .*MODE/d 3827238104Sdes s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828238104Sdes fi 3829238104Sdes exit $? 3830238104Sdesfi 3831238104Sdes 3832238104Sdes 3833238104Sdes# func_mode_execute arg... 3834238104Sdesfunc_mode_execute () 3835238104Sdes{ 3836285206Sdes $debug_cmd 3837285206Sdes 3838238104Sdes # The first argument is the command name. 3839285206Sdes cmd=$nonopt 3840238104Sdes test -z "$cmd" && \ 3841238104Sdes func_fatal_help "you must specify a COMMAND" 3842238104Sdes 3843238104Sdes # Handle -dlopen flags immediately. 3844238104Sdes for file in $opt_dlopen; do 3845238104Sdes test -f "$file" \ 3846285206Sdes || func_fatal_help "'$file' is not a file" 3847238104Sdes 3848238104Sdes dir= 3849238104Sdes case $file in 3850238104Sdes *.la) 3851238104Sdes func_resolve_sysroot "$file" 3852238104Sdes file=$func_resolve_sysroot_result 3853238104Sdes 3854238104Sdes # Check to see that this really is a libtool archive. 3855238104Sdes func_lalib_unsafe_p "$file" \ 3856285206Sdes || func_fatal_help "'$lib' is not a valid libtool archive" 3857238104Sdes 3858238104Sdes # Read the libtool library. 3859238104Sdes dlname= 3860238104Sdes library_names= 3861238104Sdes func_source "$file" 3862238104Sdes 3863238104Sdes # Skip this library if it cannot be dlopened. 3864238104Sdes if test -z "$dlname"; then 3865238104Sdes # Warn if it was a shared library. 3866238104Sdes test -n "$library_names" && \ 3867285206Sdes func_warning "'$file' was not linked with '-export-dynamic'" 3868238104Sdes continue 3869238104Sdes fi 3870238104Sdes 3871238104Sdes func_dirname "$file" "" "." 3872285206Sdes dir=$func_dirname_result 3873238104Sdes 3874238104Sdes if test -f "$dir/$objdir/$dlname"; then 3875238104Sdes func_append dir "/$objdir" 3876238104Sdes else 3877238104Sdes if test ! -f "$dir/$dlname"; then 3878285206Sdes func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879238104Sdes fi 3880238104Sdes fi 3881238104Sdes ;; 3882238104Sdes 3883238104Sdes *.lo) 3884238104Sdes # Just add the directory containing the .lo file. 3885238104Sdes func_dirname "$file" "" "." 3886285206Sdes dir=$func_dirname_result 3887238104Sdes ;; 3888238104Sdes 3889238104Sdes *) 3890285206Sdes func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891238104Sdes continue 3892238104Sdes ;; 3893238104Sdes esac 3894238104Sdes 3895238104Sdes # Get the absolute pathname. 3896238104Sdes absdir=`cd "$dir" && pwd` 3897285206Sdes test -n "$absdir" && dir=$absdir 3898238104Sdes 3899238104Sdes # Now add the directory to shlibpath_var. 3900238104Sdes if eval "test -z \"\$$shlibpath_var\""; then 3901238104Sdes eval "$shlibpath_var=\"\$dir\"" 3902238104Sdes else 3903238104Sdes eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904238104Sdes fi 3905238104Sdes done 3906238104Sdes 3907238104Sdes # This variable tells wrapper scripts just to set shlibpath_var 3908238104Sdes # rather than running their programs. 3909285206Sdes libtool_execute_magic=$magic 3910238104Sdes 3911238104Sdes # Check if any of the arguments is a wrapper script. 3912238104Sdes args= 3913238104Sdes for file 3914238104Sdes do 3915238104Sdes case $file in 3916238104Sdes -* | *.la | *.lo ) ;; 3917238104Sdes *) 3918238104Sdes # Do a test to see if this is really a libtool program. 3919238104Sdes if func_ltwrapper_script_p "$file"; then 3920238104Sdes func_source "$file" 3921238104Sdes # Transform arg to wrapped name. 3922285206Sdes file=$progdir/$program 3923238104Sdes elif func_ltwrapper_executable_p "$file"; then 3924238104Sdes func_ltwrapper_scriptname "$file" 3925238104Sdes func_source "$func_ltwrapper_scriptname_result" 3926238104Sdes # Transform arg to wrapped name. 3927285206Sdes file=$progdir/$program 3928238104Sdes fi 3929238104Sdes ;; 3930238104Sdes esac 3931238104Sdes # Quote arguments (to preserve shell metacharacters). 3932238104Sdes func_append_quoted args "$file" 3933238104Sdes done 3934238104Sdes 3935285206Sdes if $opt_dry_run; then 3936285206Sdes # Display what would be done. 3937238104Sdes if test -n "$shlibpath_var"; then 3938285206Sdes eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939285206Sdes echo "export $shlibpath_var" 3940285206Sdes fi 3941285206Sdes $ECHO "$cmd$args" 3942285206Sdes exit $EXIT_SUCCESS 3943285206Sdes else 3944285206Sdes if test -n "$shlibpath_var"; then 3945238104Sdes # Export the shlibpath_var. 3946238104Sdes eval "export $shlibpath_var" 3947238104Sdes fi 3948238104Sdes 3949238104Sdes # Restore saved environment variables 3950238104Sdes for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951238104Sdes do 3952238104Sdes eval "if test \"\${save_$lt_var+set}\" = set; then 3953238104Sdes $lt_var=\$save_$lt_var; export $lt_var 3954238104Sdes else 3955238104Sdes $lt_unset $lt_var 3956238104Sdes fi" 3957238104Sdes done 3958238104Sdes 3959238104Sdes # Now prepare to actually exec the command. 3960285206Sdes exec_cmd=\$cmd$args 3961238104Sdes fi 3962238104Sdes} 3963238104Sdes 3964285206Sdestest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965238104Sdes 3966238104Sdes 3967238104Sdes# func_mode_finish arg... 3968238104Sdesfunc_mode_finish () 3969238104Sdes{ 3970285206Sdes $debug_cmd 3971285206Sdes 3972238104Sdes libs= 3973238104Sdes libdirs= 3974238104Sdes admincmds= 3975238104Sdes 3976238104Sdes for opt in "$nonopt" ${1+"$@"} 3977238104Sdes do 3978238104Sdes if test -d "$opt"; then 3979238104Sdes func_append libdirs " $opt" 3980238104Sdes 3981238104Sdes elif test -f "$opt"; then 3982238104Sdes if func_lalib_unsafe_p "$opt"; then 3983238104Sdes func_append libs " $opt" 3984238104Sdes else 3985285206Sdes func_warning "'$opt' is not a valid libtool archive" 3986238104Sdes fi 3987238104Sdes 3988238104Sdes else 3989285206Sdes func_fatal_error "invalid argument '$opt'" 3990238104Sdes fi 3991238104Sdes done 3992238104Sdes 3993238104Sdes if test -n "$libs"; then 3994238104Sdes if test -n "$lt_sysroot"; then 3995238104Sdes sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996238104Sdes sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997238104Sdes else 3998238104Sdes sysroot_cmd= 3999238104Sdes fi 4000238104Sdes 4001238104Sdes # Remove sysroot references 4002238104Sdes if $opt_dry_run; then 4003238104Sdes for lib in $libs; do 4004285206Sdes echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005238104Sdes done 4006238104Sdes else 4007238104Sdes tmpdir=`func_mktempdir` 4008238104Sdes for lib in $libs; do 4009285206Sdes $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010238104Sdes > $tmpdir/tmp-la 4011238104Sdes mv -f $tmpdir/tmp-la $lib 4012238104Sdes done 4013238104Sdes ${RM}r "$tmpdir" 4014238104Sdes fi 4015238104Sdes fi 4016238104Sdes 4017238104Sdes if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018238104Sdes for libdir in $libdirs; do 4019238104Sdes if test -n "$finish_cmds"; then 4020238104Sdes # Do each command in the finish commands. 4021238104Sdes func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022238104Sdes'"$cmd"'"' 4023238104Sdes fi 4024238104Sdes if test -n "$finish_eval"; then 4025238104Sdes # Do the single finish_eval. 4026238104Sdes eval cmds=\"$finish_eval\" 4027238104Sdes $opt_dry_run || eval "$cmds" || func_append admincmds " 4028238104Sdes $cmds" 4029238104Sdes fi 4030238104Sdes done 4031238104Sdes fi 4032238104Sdes 4033238104Sdes # Exit here if they wanted silent mode. 4034285206Sdes $opt_quiet && exit $EXIT_SUCCESS 4035238104Sdes 4036238104Sdes if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037238104Sdes echo "----------------------------------------------------------------------" 4038238104Sdes echo "Libraries have been installed in:" 4039238104Sdes for libdir in $libdirs; do 4040238104Sdes $ECHO " $libdir" 4041238104Sdes done 4042238104Sdes echo 4043238104Sdes echo "If you ever happen to want to link against installed libraries" 4044238104Sdes echo "in a given directory, LIBDIR, you must either use libtool, and" 4045285206Sdes echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046238104Sdes echo "flag during linking and do at least one of the following:" 4047238104Sdes if test -n "$shlibpath_var"; then 4048285206Sdes echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049238104Sdes echo " during execution" 4050238104Sdes fi 4051238104Sdes if test -n "$runpath_var"; then 4052285206Sdes echo " - add LIBDIR to the '$runpath_var' environment variable" 4053238104Sdes echo " during linking" 4054238104Sdes fi 4055238104Sdes if test -n "$hardcode_libdir_flag_spec"; then 4056238104Sdes libdir=LIBDIR 4057238104Sdes eval flag=\"$hardcode_libdir_flag_spec\" 4058238104Sdes 4059285206Sdes $ECHO " - use the '$flag' linker flag" 4060238104Sdes fi 4061238104Sdes if test -n "$admincmds"; then 4062238104Sdes $ECHO " - have your system administrator run these commands:$admincmds" 4063238104Sdes fi 4064238104Sdes if test -f /etc/ld.so.conf; then 4065285206Sdes echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066238104Sdes fi 4067238104Sdes echo 4068238104Sdes 4069238104Sdes echo "See any operating system documentation about shared libraries for" 4070238104Sdes case $host in 4071238104Sdes solaris2.[6789]|solaris2.1[0-9]) 4072238104Sdes echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073238104Sdes echo "pages." 4074238104Sdes ;; 4075238104Sdes *) 4076238104Sdes echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077238104Sdes ;; 4078238104Sdes esac 4079238104Sdes echo "----------------------------------------------------------------------" 4080238104Sdes fi 4081238104Sdes exit $EXIT_SUCCESS 4082238104Sdes} 4083238104Sdes 4084285206Sdestest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085238104Sdes 4086238104Sdes 4087238104Sdes# func_mode_install arg... 4088238104Sdesfunc_mode_install () 4089238104Sdes{ 4090285206Sdes $debug_cmd 4091285206Sdes 4092238104Sdes # There may be an optional sh(1) argument at the beginning of 4093238104Sdes # install_prog (especially on Windows NT). 4094285206Sdes if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095238104Sdes # Allow the use of GNU shtool's install command. 4096285206Sdes case $nonopt in *shtool*) :;; *) false;; esac 4097285206Sdes then 4098238104Sdes # Aesthetically quote it. 4099238104Sdes func_quote_for_eval "$nonopt" 4100238104Sdes install_prog="$func_quote_for_eval_result " 4101238104Sdes arg=$1 4102238104Sdes shift 4103238104Sdes else 4104238104Sdes install_prog= 4105238104Sdes arg=$nonopt 4106238104Sdes fi 4107238104Sdes 4108238104Sdes # The real first argument should be the name of the installation program. 4109238104Sdes # Aesthetically quote it. 4110238104Sdes func_quote_for_eval "$arg" 4111238104Sdes func_append install_prog "$func_quote_for_eval_result" 4112238104Sdes install_shared_prog=$install_prog 4113238104Sdes case " $install_prog " in 4114238104Sdes *[\\\ /]cp\ *) install_cp=: ;; 4115238104Sdes *) install_cp=false ;; 4116238104Sdes esac 4117238104Sdes 4118238104Sdes # We need to accept at least all the BSD install flags. 4119238104Sdes dest= 4120238104Sdes files= 4121238104Sdes opts= 4122238104Sdes prev= 4123238104Sdes install_type= 4124285206Sdes isdir=false 4125238104Sdes stripme= 4126238104Sdes no_mode=: 4127238104Sdes for arg 4128238104Sdes do 4129238104Sdes arg2= 4130238104Sdes if test -n "$dest"; then 4131238104Sdes func_append files " $dest" 4132238104Sdes dest=$arg 4133238104Sdes continue 4134238104Sdes fi 4135238104Sdes 4136238104Sdes case $arg in 4137285206Sdes -d) isdir=: ;; 4138238104Sdes -f) 4139238104Sdes if $install_cp; then :; else 4140238104Sdes prev=$arg 4141238104Sdes fi 4142238104Sdes ;; 4143238104Sdes -g | -m | -o) 4144238104Sdes prev=$arg 4145238104Sdes ;; 4146238104Sdes -s) 4147238104Sdes stripme=" -s" 4148238104Sdes continue 4149238104Sdes ;; 4150238104Sdes -*) 4151238104Sdes ;; 4152238104Sdes *) 4153238104Sdes # If the previous option needed an argument, then skip it. 4154238104Sdes if test -n "$prev"; then 4155285206Sdes if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156238104Sdes arg2=$install_override_mode 4157238104Sdes no_mode=false 4158238104Sdes fi 4159238104Sdes prev= 4160238104Sdes else 4161238104Sdes dest=$arg 4162238104Sdes continue 4163238104Sdes fi 4164238104Sdes ;; 4165238104Sdes esac 4166238104Sdes 4167238104Sdes # Aesthetically quote the argument. 4168238104Sdes func_quote_for_eval "$arg" 4169238104Sdes func_append install_prog " $func_quote_for_eval_result" 4170238104Sdes if test -n "$arg2"; then 4171238104Sdes func_quote_for_eval "$arg2" 4172238104Sdes fi 4173238104Sdes func_append install_shared_prog " $func_quote_for_eval_result" 4174238104Sdes done 4175238104Sdes 4176238104Sdes test -z "$install_prog" && \ 4177238104Sdes func_fatal_help "you must specify an install program" 4178238104Sdes 4179238104Sdes test -n "$prev" && \ 4180285206Sdes func_fatal_help "the '$prev' option requires an argument" 4181238104Sdes 4182238104Sdes if test -n "$install_override_mode" && $no_mode; then 4183238104Sdes if $install_cp; then :; else 4184238104Sdes func_quote_for_eval "$install_override_mode" 4185238104Sdes func_append install_shared_prog " -m $func_quote_for_eval_result" 4186238104Sdes fi 4187238104Sdes fi 4188238104Sdes 4189238104Sdes if test -z "$files"; then 4190238104Sdes if test -z "$dest"; then 4191238104Sdes func_fatal_help "no file or destination specified" 4192238104Sdes else 4193238104Sdes func_fatal_help "you must specify a destination" 4194238104Sdes fi 4195238104Sdes fi 4196238104Sdes 4197238104Sdes # Strip any trailing slash from the destination. 4198238104Sdes func_stripname '' '/' "$dest" 4199238104Sdes dest=$func_stripname_result 4200238104Sdes 4201238104Sdes # Check to see that the destination is a directory. 4202285206Sdes test -d "$dest" && isdir=: 4203285206Sdes if $isdir; then 4204285206Sdes destdir=$dest 4205238104Sdes destname= 4206238104Sdes else 4207238104Sdes func_dirname_and_basename "$dest" "" "." 4208285206Sdes destdir=$func_dirname_result 4209285206Sdes destname=$func_basename_result 4210238104Sdes 4211238104Sdes # Not a directory, so check to see that there is only one file specified. 4212238104Sdes set dummy $files; shift 4213238104Sdes test "$#" -gt 1 && \ 4214285206Sdes func_fatal_help "'$dest' is not a directory" 4215238104Sdes fi 4216238104Sdes case $destdir in 4217238104Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 4218238104Sdes *) 4219238104Sdes for file in $files; do 4220238104Sdes case $file in 4221238104Sdes *.lo) ;; 4222238104Sdes *) 4223285206Sdes func_fatal_help "'$destdir' must be an absolute directory name" 4224238104Sdes ;; 4225238104Sdes esac 4226238104Sdes done 4227238104Sdes ;; 4228238104Sdes esac 4229238104Sdes 4230238104Sdes # This variable tells wrapper scripts just to set variables rather 4231238104Sdes # than running their programs. 4232285206Sdes libtool_install_magic=$magic 4233238104Sdes 4234238104Sdes staticlibs= 4235238104Sdes future_libdirs= 4236238104Sdes current_libdirs= 4237238104Sdes for file in $files; do 4238238104Sdes 4239238104Sdes # Do each installation. 4240238104Sdes case $file in 4241238104Sdes *.$libext) 4242238104Sdes # Do the static libraries later. 4243238104Sdes func_append staticlibs " $file" 4244238104Sdes ;; 4245238104Sdes 4246238104Sdes *.la) 4247238104Sdes func_resolve_sysroot "$file" 4248238104Sdes file=$func_resolve_sysroot_result 4249238104Sdes 4250238104Sdes # Check to see that this really is a libtool archive. 4251238104Sdes func_lalib_unsafe_p "$file" \ 4252285206Sdes || func_fatal_help "'$file' is not a valid libtool archive" 4253238104Sdes 4254238104Sdes library_names= 4255238104Sdes old_library= 4256238104Sdes relink_command= 4257238104Sdes func_source "$file" 4258238104Sdes 4259238104Sdes # Add the libdir to current_libdirs if it is the destination. 4260238104Sdes if test "X$destdir" = "X$libdir"; then 4261238104Sdes case "$current_libdirs " in 4262238104Sdes *" $libdir "*) ;; 4263238104Sdes *) func_append current_libdirs " $libdir" ;; 4264238104Sdes esac 4265238104Sdes else 4266238104Sdes # Note the libdir as a future libdir. 4267238104Sdes case "$future_libdirs " in 4268238104Sdes *" $libdir "*) ;; 4269238104Sdes *) func_append future_libdirs " $libdir" ;; 4270238104Sdes esac 4271238104Sdes fi 4272238104Sdes 4273238104Sdes func_dirname "$file" "/" "" 4274285206Sdes dir=$func_dirname_result 4275238104Sdes func_append dir "$objdir" 4276238104Sdes 4277238104Sdes if test -n "$relink_command"; then 4278238104Sdes # Determine the prefix the user has applied to our future dir. 4279238104Sdes inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280238104Sdes 4281238104Sdes # Don't allow the user to place us outside of our expected 4282238104Sdes # location b/c this prevents finding dependent libraries that 4283238104Sdes # are installed to the same prefix. 4284238104Sdes # At present, this check doesn't affect windows .dll's that 4285238104Sdes # are installed into $libdir/../bin (currently, that works fine) 4286238104Sdes # but it's something to keep an eye on. 4287238104Sdes test "$inst_prefix_dir" = "$destdir" && \ 4288285206Sdes func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289238104Sdes 4290238104Sdes if test -n "$inst_prefix_dir"; then 4291238104Sdes # Stick the inst_prefix_dir data into the link command. 4292238104Sdes relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293238104Sdes else 4294238104Sdes relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295238104Sdes fi 4296238104Sdes 4297285206Sdes func_warning "relinking '$file'" 4298238104Sdes func_show_eval "$relink_command" \ 4299285206Sdes 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300238104Sdes fi 4301238104Sdes 4302238104Sdes # See the names of the shared library. 4303238104Sdes set dummy $library_names; shift 4304238104Sdes if test -n "$1"; then 4305285206Sdes realname=$1 4306238104Sdes shift 4307238104Sdes 4308285206Sdes srcname=$realname 4309285206Sdes test -n "$relink_command" && srcname=${realname}T 4310238104Sdes 4311238104Sdes # Install the shared library and build the symlinks. 4312238104Sdes func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313238104Sdes 'exit $?' 4314285206Sdes tstripme=$stripme 4315238104Sdes case $host_os in 4316238104Sdes cygwin* | mingw* | pw32* | cegcc*) 4317238104Sdes case $realname in 4318238104Sdes *.dll.a) 4319285206Sdes tstripme= 4320238104Sdes ;; 4321238104Sdes esac 4322238104Sdes ;; 4323285206Sdes os2*) 4324285206Sdes case $realname in 4325285206Sdes *_dll.a) 4326285206Sdes tstripme= 4327285206Sdes ;; 4328285206Sdes esac 4329285206Sdes ;; 4330238104Sdes esac 4331238104Sdes if test -n "$tstripme" && test -n "$striplib"; then 4332238104Sdes func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333238104Sdes fi 4334238104Sdes 4335238104Sdes if test "$#" -gt 0; then 4336238104Sdes # Delete the old symlinks, and create new ones. 4337285206Sdes # Try 'ln -sf' first, because the 'ln' binary might depend on 4338238104Sdes # the symlink we replace! Solaris /bin/ln does not understand -f, 4339238104Sdes # so we also need to try rm && ln -s. 4340238104Sdes for linkname 4341238104Sdes do 4342238104Sdes test "$linkname" != "$realname" \ 4343238104Sdes && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344238104Sdes done 4345238104Sdes fi 4346238104Sdes 4347238104Sdes # Do each command in the postinstall commands. 4348285206Sdes lib=$destdir/$realname 4349238104Sdes func_execute_cmds "$postinstall_cmds" 'exit $?' 4350238104Sdes fi 4351238104Sdes 4352238104Sdes # Install the pseudo-library for information purposes. 4353238104Sdes func_basename "$file" 4354285206Sdes name=$func_basename_result 4355285206Sdes instname=$dir/${name}i 4356238104Sdes func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357238104Sdes 4358238104Sdes # Maybe install the static library, too. 4359238104Sdes test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360238104Sdes ;; 4361238104Sdes 4362238104Sdes *.lo) 4363238104Sdes # Install (i.e. copy) a libtool object. 4364238104Sdes 4365238104Sdes # Figure out destination file name, if it wasn't already specified. 4366238104Sdes if test -n "$destname"; then 4367285206Sdes destfile=$destdir/$destname 4368238104Sdes else 4369238104Sdes func_basename "$file" 4370285206Sdes destfile=$func_basename_result 4371285206Sdes destfile=$destdir/$destfile 4372238104Sdes fi 4373238104Sdes 4374238104Sdes # Deduce the name of the destination old-style object file. 4375238104Sdes case $destfile in 4376238104Sdes *.lo) 4377238104Sdes func_lo2o "$destfile" 4378238104Sdes staticdest=$func_lo2o_result 4379238104Sdes ;; 4380238104Sdes *.$objext) 4381285206Sdes staticdest=$destfile 4382238104Sdes destfile= 4383238104Sdes ;; 4384238104Sdes *) 4385285206Sdes func_fatal_help "cannot copy a libtool object to '$destfile'" 4386238104Sdes ;; 4387238104Sdes esac 4388238104Sdes 4389238104Sdes # Install the libtool object if requested. 4390238104Sdes test -n "$destfile" && \ 4391238104Sdes func_show_eval "$install_prog $file $destfile" 'exit $?' 4392238104Sdes 4393238104Sdes # Install the old object if enabled. 4394285206Sdes if test yes = "$build_old_libs"; then 4395238104Sdes # Deduce the name of the old-style object file. 4396238104Sdes func_lo2o "$file" 4397238104Sdes staticobj=$func_lo2o_result 4398238104Sdes func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399238104Sdes fi 4400238104Sdes exit $EXIT_SUCCESS 4401238104Sdes ;; 4402238104Sdes 4403238104Sdes *) 4404238104Sdes # Figure out destination file name, if it wasn't already specified. 4405238104Sdes if test -n "$destname"; then 4406285206Sdes destfile=$destdir/$destname 4407238104Sdes else 4408238104Sdes func_basename "$file" 4409285206Sdes destfile=$func_basename_result 4410285206Sdes destfile=$destdir/$destfile 4411238104Sdes fi 4412238104Sdes 4413238104Sdes # If the file is missing, and there is a .exe on the end, strip it 4414238104Sdes # because it is most likely a libtool script we actually want to 4415238104Sdes # install 4416285206Sdes stripped_ext= 4417238104Sdes case $file in 4418238104Sdes *.exe) 4419238104Sdes if test ! -f "$file"; then 4420238104Sdes func_stripname '' '.exe' "$file" 4421238104Sdes file=$func_stripname_result 4422285206Sdes stripped_ext=.exe 4423238104Sdes fi 4424238104Sdes ;; 4425238104Sdes esac 4426238104Sdes 4427238104Sdes # Do a test to see if this is really a libtool program. 4428238104Sdes case $host in 4429238104Sdes *cygwin* | *mingw*) 4430238104Sdes if func_ltwrapper_executable_p "$file"; then 4431238104Sdes func_ltwrapper_scriptname "$file" 4432238104Sdes wrapper=$func_ltwrapper_scriptname_result 4433238104Sdes else 4434238104Sdes func_stripname '' '.exe' "$file" 4435238104Sdes wrapper=$func_stripname_result 4436238104Sdes fi 4437238104Sdes ;; 4438238104Sdes *) 4439238104Sdes wrapper=$file 4440238104Sdes ;; 4441238104Sdes esac 4442238104Sdes if func_ltwrapper_script_p "$wrapper"; then 4443238104Sdes notinst_deplibs= 4444238104Sdes relink_command= 4445238104Sdes 4446238104Sdes func_source "$wrapper" 4447238104Sdes 4448238104Sdes # Check the variables that should have been set. 4449238104Sdes test -z "$generated_by_libtool_version" && \ 4450285206Sdes func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451238104Sdes 4452285206Sdes finalize=: 4453238104Sdes for lib in $notinst_deplibs; do 4454238104Sdes # Check to see that each library is installed. 4455238104Sdes libdir= 4456238104Sdes if test -f "$lib"; then 4457238104Sdes func_source "$lib" 4458238104Sdes fi 4459285206Sdes libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460238104Sdes if test -n "$libdir" && test ! -f "$libfile"; then 4461285206Sdes func_warning "'$lib' has not been installed in '$libdir'" 4462285206Sdes finalize=false 4463238104Sdes fi 4464238104Sdes done 4465238104Sdes 4466238104Sdes relink_command= 4467238104Sdes func_source "$wrapper" 4468238104Sdes 4469238104Sdes outputname= 4470285206Sdes if test no = "$fast_install" && test -n "$relink_command"; then 4471238104Sdes $opt_dry_run || { 4472285206Sdes if $finalize; then 4473238104Sdes tmpdir=`func_mktempdir` 4474238104Sdes func_basename "$file$stripped_ext" 4475285206Sdes file=$func_basename_result 4476285206Sdes outputname=$tmpdir/$file 4477238104Sdes # Replace the output file specification. 4478238104Sdes relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479238104Sdes 4480285206Sdes $opt_quiet || { 4481238104Sdes func_quote_for_expand "$relink_command" 4482238104Sdes eval "func_echo $func_quote_for_expand_result" 4483238104Sdes } 4484238104Sdes if eval "$relink_command"; then : 4485238104Sdes else 4486285206Sdes func_error "error: relink '$file' with the above command before installing it" 4487238104Sdes $opt_dry_run || ${RM}r "$tmpdir" 4488238104Sdes continue 4489238104Sdes fi 4490285206Sdes file=$outputname 4491238104Sdes else 4492285206Sdes func_warning "cannot relink '$file'" 4493238104Sdes fi 4494238104Sdes } 4495238104Sdes else 4496238104Sdes # Install the binary that we compiled earlier. 4497238104Sdes file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498238104Sdes fi 4499238104Sdes fi 4500238104Sdes 4501238104Sdes # remove .exe since cygwin /usr/bin/install will append another 4502238104Sdes # one anyway 4503238104Sdes case $install_prog,$host in 4504238104Sdes */usr/bin/install*,*cygwin*) 4505238104Sdes case $file:$destfile in 4506238104Sdes *.exe:*.exe) 4507238104Sdes # this is ok 4508238104Sdes ;; 4509238104Sdes *.exe:*) 4510238104Sdes destfile=$destfile.exe 4511238104Sdes ;; 4512238104Sdes *:*.exe) 4513238104Sdes func_stripname '' '.exe' "$destfile" 4514238104Sdes destfile=$func_stripname_result 4515238104Sdes ;; 4516238104Sdes esac 4517238104Sdes ;; 4518238104Sdes esac 4519238104Sdes func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520238104Sdes $opt_dry_run || if test -n "$outputname"; then 4521238104Sdes ${RM}r "$tmpdir" 4522238104Sdes fi 4523238104Sdes ;; 4524238104Sdes esac 4525238104Sdes done 4526238104Sdes 4527238104Sdes for file in $staticlibs; do 4528238104Sdes func_basename "$file" 4529285206Sdes name=$func_basename_result 4530238104Sdes 4531238104Sdes # Set up the ranlib parameters. 4532285206Sdes oldlib=$destdir/$name 4533238104Sdes func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534238104Sdes tool_oldlib=$func_to_tool_file_result 4535238104Sdes 4536238104Sdes func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537238104Sdes 4538238104Sdes if test -n "$stripme" && test -n "$old_striplib"; then 4539238104Sdes func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540238104Sdes fi 4541238104Sdes 4542238104Sdes # Do each command in the postinstall commands. 4543238104Sdes func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544238104Sdes done 4545238104Sdes 4546238104Sdes test -n "$future_libdirs" && \ 4547285206Sdes func_warning "remember to run '$progname --finish$future_libdirs'" 4548238104Sdes 4549238104Sdes if test -n "$current_libdirs"; then 4550238104Sdes # Maybe just do a dry run. 4551238104Sdes $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552285206Sdes exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553238104Sdes else 4554238104Sdes exit $EXIT_SUCCESS 4555238104Sdes fi 4556238104Sdes} 4557238104Sdes 4558285206Sdestest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559238104Sdes 4560238104Sdes 4561238104Sdes# func_generate_dlsyms outputname originator pic_p 4562238104Sdes# Extract symbols from dlprefiles and create ${outputname}S.o with 4563238104Sdes# a dlpreopen symbol table. 4564238104Sdesfunc_generate_dlsyms () 4565238104Sdes{ 4566285206Sdes $debug_cmd 4567285206Sdes 4568285206Sdes my_outputname=$1 4569285206Sdes my_originator=$2 4570285206Sdes my_pic_p=${3-false} 4571285206Sdes my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572238104Sdes my_dlsyms= 4573238104Sdes 4574285206Sdes if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575238104Sdes if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576285206Sdes my_dlsyms=${my_outputname}S.c 4577238104Sdes else 4578238104Sdes func_error "not configured to extract global symbols from dlpreopened files" 4579238104Sdes fi 4580238104Sdes fi 4581238104Sdes 4582238104Sdes if test -n "$my_dlsyms"; then 4583238104Sdes case $my_dlsyms in 4584238104Sdes "") ;; 4585238104Sdes *.c) 4586238104Sdes # Discover the nlist of each of the dlfiles. 4587285206Sdes nlist=$output_objdir/$my_outputname.nm 4588238104Sdes 4589238104Sdes func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590238104Sdes 4591238104Sdes # Parse the name list into a source file. 4592238104Sdes func_verbose "creating $output_objdir/$my_dlsyms" 4593238104Sdes 4594238104Sdes $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595285206Sdes/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596285206Sdes/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597238104Sdes 4598238104Sdes#ifdef __cplusplus 4599238104Sdesextern \"C\" { 4600238104Sdes#endif 4601238104Sdes 4602285206Sdes#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603238104Sdes#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604238104Sdes#endif 4605238104Sdes 4606238104Sdes/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607285206Sdes#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608285206Sdes/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609238104Sdes relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610238104Sdes# define LT_DLSYM_CONST 4611285206Sdes#elif defined __osf__ 4612238104Sdes/* This system does not cope well with relocations in const data. */ 4613238104Sdes# define LT_DLSYM_CONST 4614238104Sdes#else 4615238104Sdes# define LT_DLSYM_CONST const 4616238104Sdes#endif 4617238104Sdes 4618285206Sdes#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619285206Sdes 4620238104Sdes/* External symbol declarations for the compiler. */\ 4621238104Sdes" 4622238104Sdes 4623285206Sdes if test yes = "$dlself"; then 4624285206Sdes func_verbose "generating symbol list for '$output'" 4625238104Sdes 4626238104Sdes $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627238104Sdes 4628238104Sdes # Add our own program objects to the symbol list. 4629238104Sdes progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630238104Sdes for progfile in $progfiles; do 4631238104Sdes func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632285206Sdes func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633238104Sdes $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634238104Sdes done 4635238104Sdes 4636238104Sdes if test -n "$exclude_expsyms"; then 4637238104Sdes $opt_dry_run || { 4638238104Sdes eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639238104Sdes eval '$MV "$nlist"T "$nlist"' 4640238104Sdes } 4641238104Sdes fi 4642238104Sdes 4643238104Sdes if test -n "$export_symbols_regex"; then 4644238104Sdes $opt_dry_run || { 4645238104Sdes eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646238104Sdes eval '$MV "$nlist"T "$nlist"' 4647238104Sdes } 4648238104Sdes fi 4649238104Sdes 4650238104Sdes # Prepare the list of exported symbols 4651238104Sdes if test -z "$export_symbols"; then 4652285206Sdes export_symbols=$output_objdir/$outputname.exp 4653238104Sdes $opt_dry_run || { 4654238104Sdes $RM $export_symbols 4655285206Sdes eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656238104Sdes case $host in 4657238104Sdes *cygwin* | *mingw* | *cegcc* ) 4658238104Sdes eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659238104Sdes eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660238104Sdes ;; 4661238104Sdes esac 4662238104Sdes } 4663238104Sdes else 4664238104Sdes $opt_dry_run || { 4665285206Sdes eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666238104Sdes eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667238104Sdes eval '$MV "$nlist"T "$nlist"' 4668238104Sdes case $host in 4669238104Sdes *cygwin* | *mingw* | *cegcc* ) 4670238104Sdes eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671238104Sdes eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672238104Sdes ;; 4673238104Sdes esac 4674238104Sdes } 4675238104Sdes fi 4676238104Sdes fi 4677238104Sdes 4678238104Sdes for dlprefile in $dlprefiles; do 4679285206Sdes func_verbose "extracting global C symbols from '$dlprefile'" 4680238104Sdes func_basename "$dlprefile" 4681285206Sdes name=$func_basename_result 4682238104Sdes case $host in 4683238104Sdes *cygwin* | *mingw* | *cegcc* ) 4684238104Sdes # if an import library, we need to obtain dlname 4685238104Sdes if func_win32_import_lib_p "$dlprefile"; then 4686238104Sdes func_tr_sh "$dlprefile" 4687238104Sdes eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688285206Sdes dlprefile_dlbasename= 4689238104Sdes if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690238104Sdes # Use subshell, to avoid clobbering current variable values 4691238104Sdes dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692285206Sdes if test -n "$dlprefile_dlname"; then 4693238104Sdes func_basename "$dlprefile_dlname" 4694285206Sdes dlprefile_dlbasename=$func_basename_result 4695238104Sdes else 4696238104Sdes # no lafile. user explicitly requested -dlpreopen <import library>. 4697238104Sdes $sharedlib_from_linklib_cmd "$dlprefile" 4698238104Sdes dlprefile_dlbasename=$sharedlib_from_linklib_result 4699238104Sdes fi 4700238104Sdes fi 4701238104Sdes $opt_dry_run || { 4702285206Sdes if test -n "$dlprefile_dlbasename"; then 4703238104Sdes eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704238104Sdes else 4705238104Sdes func_warning "Could not compute DLL name from $name" 4706238104Sdes eval '$ECHO ": $name " >> "$nlist"' 4707238104Sdes fi 4708238104Sdes func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709238104Sdes eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710238104Sdes $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711238104Sdes } 4712238104Sdes else # not an import lib 4713238104Sdes $opt_dry_run || { 4714238104Sdes eval '$ECHO ": $name " >> "$nlist"' 4715238104Sdes func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716238104Sdes eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717238104Sdes } 4718238104Sdes fi 4719238104Sdes ;; 4720238104Sdes *) 4721238104Sdes $opt_dry_run || { 4722238104Sdes eval '$ECHO ": $name " >> "$nlist"' 4723238104Sdes func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724238104Sdes eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725238104Sdes } 4726238104Sdes ;; 4727238104Sdes esac 4728238104Sdes done 4729238104Sdes 4730238104Sdes $opt_dry_run || { 4731238104Sdes # Make sure we have at least an empty file. 4732238104Sdes test -f "$nlist" || : > "$nlist" 4733238104Sdes 4734238104Sdes if test -n "$exclude_expsyms"; then 4735238104Sdes $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736238104Sdes $MV "$nlist"T "$nlist" 4737238104Sdes fi 4738238104Sdes 4739238104Sdes # Try sorting and uniquifying the output. 4740238104Sdes if $GREP -v "^: " < "$nlist" | 4741238104Sdes if sort -k 3 </dev/null >/dev/null 2>&1; then 4742238104Sdes sort -k 3 4743238104Sdes else 4744238104Sdes sort +2 4745238104Sdes fi | 4746238104Sdes uniq > "$nlist"S; then 4747238104Sdes : 4748238104Sdes else 4749238104Sdes $GREP -v "^: " < "$nlist" > "$nlist"S 4750238104Sdes fi 4751238104Sdes 4752238104Sdes if test -f "$nlist"S; then 4753238104Sdes eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754238104Sdes else 4755238104Sdes echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756238104Sdes fi 4757238104Sdes 4758285206Sdes func_show_eval '$RM "${nlist}I"' 4759285206Sdes if test -n "$global_symbol_to_import"; then 4760285206Sdes eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761285206Sdes fi 4762285206Sdes 4763238104Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4764238104Sdes 4765238104Sdes/* The mapping between symbol names and symbols. */ 4766238104Sdestypedef struct { 4767238104Sdes const char *name; 4768238104Sdes void *address; 4769238104Sdes} lt_dlsymlist; 4770238104Sdesextern LT_DLSYM_CONST lt_dlsymlist 4771285206Sdeslt_${my_prefix}_LTX_preloaded_symbols[];\ 4772285206Sdes" 4773285206Sdes 4774285206Sdes if test -s "$nlist"I; then 4775285206Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4776285206Sdesstatic void lt_syminit(void) 4777285206Sdes{ 4778285206Sdes LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779285206Sdes for (; symbol->name; ++symbol) 4780285206Sdes {" 4781285206Sdes $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782285206Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4783285206Sdes } 4784285206Sdes}" 4785285206Sdes fi 4786285206Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4787238104SdesLT_DLSYM_CONST lt_dlsymlist 4788238104Sdeslt_${my_prefix}_LTX_preloaded_symbols[] = 4789285206Sdes{ {\"$my_originator\", (void *) 0}," 4790238104Sdes 4791285206Sdes if test -s "$nlist"I; then 4792285206Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4793285206Sdes {\"@INIT@\", (void *) <_syminit}," 4794285206Sdes fi 4795285206Sdes 4796238104Sdes case $need_lib_prefix in 4797238104Sdes no) 4798238104Sdes eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799238104Sdes ;; 4800238104Sdes *) 4801238104Sdes eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802238104Sdes ;; 4803238104Sdes esac 4804238104Sdes echo >> "$output_objdir/$my_dlsyms" "\ 4805238104Sdes {0, (void *) 0} 4806238104Sdes}; 4807238104Sdes 4808238104Sdes/* This works around a problem in FreeBSD linker */ 4809238104Sdes#ifdef FREEBSD_WORKAROUND 4810238104Sdesstatic const void *lt_preloaded_setup() { 4811238104Sdes return lt_${my_prefix}_LTX_preloaded_symbols; 4812238104Sdes} 4813238104Sdes#endif 4814238104Sdes 4815238104Sdes#ifdef __cplusplus 4816238104Sdes} 4817238104Sdes#endif\ 4818238104Sdes" 4819238104Sdes } # !$opt_dry_run 4820238104Sdes 4821238104Sdes pic_flag_for_symtable= 4822238104Sdes case "$compile_command " in 4823238104Sdes *" -static "*) ;; 4824238104Sdes *) 4825238104Sdes case $host in 4826238104Sdes # compiling the symbol table file with pic_flag works around 4827238104Sdes # a FreeBSD bug that causes programs to crash when -lm is 4828238104Sdes # linked before any other PIC object. But we must not use 4829238104Sdes # pic_flag when linking with -static. The problem exists in 4830238104Sdes # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831238104Sdes *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832238104Sdes pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833238104Sdes *-*-hpux*) 4834238104Sdes pic_flag_for_symtable=" $pic_flag" ;; 4835238104Sdes *) 4836285206Sdes $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837238104Sdes ;; 4838238104Sdes esac 4839238104Sdes ;; 4840238104Sdes esac 4841238104Sdes symtab_cflags= 4842238104Sdes for arg in $LTCFLAGS; do 4843238104Sdes case $arg in 4844238104Sdes -pie | -fpie | -fPIE) ;; 4845238104Sdes *) func_append symtab_cflags " $arg" ;; 4846238104Sdes esac 4847238104Sdes done 4848238104Sdes 4849238104Sdes # Now compile the dynamic symbol file. 4850238104Sdes func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851238104Sdes 4852238104Sdes # Clean up the generated files. 4853285206Sdes func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854238104Sdes 4855238104Sdes # Transform the symbol file into the correct name. 4856285206Sdes symfileobj=$output_objdir/${my_outputname}S.$objext 4857238104Sdes case $host in 4858238104Sdes *cygwin* | *mingw* | *cegcc* ) 4859238104Sdes if test -f "$output_objdir/$my_outputname.def"; then 4860238104Sdes compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861238104Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862238104Sdes else 4863238104Sdes compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864238104Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865238104Sdes fi 4866238104Sdes ;; 4867238104Sdes *) 4868238104Sdes compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869238104Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870238104Sdes ;; 4871238104Sdes esac 4872238104Sdes ;; 4873238104Sdes *) 4874285206Sdes func_fatal_error "unknown suffix for '$my_dlsyms'" 4875238104Sdes ;; 4876238104Sdes esac 4877238104Sdes else 4878238104Sdes # We keep going just in case the user didn't refer to 4879238104Sdes # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880238104Sdes # really was required. 4881238104Sdes 4882238104Sdes # Nullify the symbol file. 4883238104Sdes compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884238104Sdes finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885238104Sdes fi 4886238104Sdes} 4887238104Sdes 4888285206Sdes# func_cygming_gnu_implib_p ARG 4889285206Sdes# This predicate returns with zero status (TRUE) if 4890285206Sdes# ARG is a GNU/binutils-style import library. Returns 4891285206Sdes# with nonzero status (FALSE) otherwise. 4892285206Sdesfunc_cygming_gnu_implib_p () 4893285206Sdes{ 4894285206Sdes $debug_cmd 4895285206Sdes 4896285206Sdes func_to_tool_file "$1" func_convert_file_msys_to_w32 4897285206Sdes 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)$'` 4898285206Sdes test -n "$func_cygming_gnu_implib_tmp" 4899285206Sdes} 4900285206Sdes 4901285206Sdes# func_cygming_ms_implib_p ARG 4902285206Sdes# This predicate returns with zero status (TRUE) if 4903285206Sdes# ARG is an MS-style import library. Returns 4904285206Sdes# with nonzero status (FALSE) otherwise. 4905285206Sdesfunc_cygming_ms_implib_p () 4906285206Sdes{ 4907285206Sdes $debug_cmd 4908285206Sdes 4909285206Sdes func_to_tool_file "$1" func_convert_file_msys_to_w32 4910285206Sdes func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911285206Sdes test -n "$func_cygming_ms_implib_tmp" 4912285206Sdes} 4913285206Sdes 4914238104Sdes# func_win32_libid arg 4915238104Sdes# return the library type of file 'arg' 4916238104Sdes# 4917238104Sdes# Need a lot of goo to handle *both* DLLs and import libs 4918238104Sdes# Has to be a shell function in order to 'eat' the argument 4919238104Sdes# that is supplied when $file_magic_command is called. 4920238104Sdes# Despite the name, also deal with 64 bit binaries. 4921238104Sdesfunc_win32_libid () 4922238104Sdes{ 4923285206Sdes $debug_cmd 4924285206Sdes 4925285206Sdes win32_libid_type=unknown 4926238104Sdes win32_fileres=`file -L $1 2>/dev/null` 4927238104Sdes case $win32_fileres in 4928238104Sdes *ar\ archive\ import\ library*) # definitely import 4929238104Sdes win32_libid_type="x86 archive import" 4930238104Sdes ;; 4931238104Sdes *ar\ archive*) # could be an import, or static 4932238104Sdes # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933238104Sdes if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934238104Sdes $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935285206Sdes case $nm_interface in 4936285206Sdes "MS dumpbin") 4937285206Sdes if func_cygming_ms_implib_p "$1" || 4938285206Sdes func_cygming_gnu_implib_p "$1" 4939285206Sdes then 4940285206Sdes win32_nmres=import 4941285206Sdes else 4942285206Sdes win32_nmres= 4943285206Sdes fi 4944285206Sdes ;; 4945285206Sdes *) 4946285206Sdes func_to_tool_file "$1" func_convert_file_msys_to_w32 4947285206Sdes win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948285206Sdes $SED -n -e ' 4949238104Sdes 1,100{ 4950238104Sdes / I /{ 4951285206Sdes s|.*|import| 4952238104Sdes p 4953238104Sdes q 4954238104Sdes } 4955238104Sdes }'` 4956285206Sdes ;; 4957285206Sdes esac 4958238104Sdes case $win32_nmres in 4959238104Sdes import*) win32_libid_type="x86 archive import";; 4960238104Sdes *) win32_libid_type="x86 archive static";; 4961238104Sdes esac 4962238104Sdes fi 4963238104Sdes ;; 4964238104Sdes *DLL*) 4965238104Sdes win32_libid_type="x86 DLL" 4966238104Sdes ;; 4967238104Sdes *executable*) # but shell scripts are "executable" too... 4968238104Sdes case $win32_fileres in 4969238104Sdes *MS\ Windows\ PE\ Intel*) 4970238104Sdes win32_libid_type="x86 DLL" 4971238104Sdes ;; 4972238104Sdes esac 4973238104Sdes ;; 4974238104Sdes esac 4975238104Sdes $ECHO "$win32_libid_type" 4976238104Sdes} 4977238104Sdes 4978238104Sdes# func_cygming_dll_for_implib ARG 4979238104Sdes# 4980238104Sdes# Platform-specific function to extract the 4981238104Sdes# name of the DLL associated with the specified 4982238104Sdes# import library ARG. 4983238104Sdes# Invoked by eval'ing the libtool variable 4984238104Sdes# $sharedlib_from_linklib_cmd 4985238104Sdes# Result is available in the variable 4986238104Sdes# $sharedlib_from_linklib_result 4987238104Sdesfunc_cygming_dll_for_implib () 4988238104Sdes{ 4989285206Sdes $debug_cmd 4990285206Sdes 4991238104Sdes sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992238104Sdes} 4993238104Sdes 4994238104Sdes# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995238104Sdes# 4996238104Sdes# The is the core of a fallback implementation of a 4997238104Sdes# platform-specific function to extract the name of the 4998238104Sdes# DLL associated with the specified import library LIBNAME. 4999238104Sdes# 5000238104Sdes# SECTION_NAME is either .idata$6 or .idata$7, depending 5001238104Sdes# on the platform and compiler that created the implib. 5002238104Sdes# 5003238104Sdes# Echos the name of the DLL associated with the 5004238104Sdes# specified import library. 5005238104Sdesfunc_cygming_dll_for_implib_fallback_core () 5006238104Sdes{ 5007285206Sdes $debug_cmd 5008285206Sdes 5009238104Sdes match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010238104Sdes $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011238104Sdes $SED '/^Contents of section '"$match_literal"':/{ 5012238104Sdes # Place marker at beginning of archive member dllname section 5013238104Sdes s/.*/====MARK====/ 5014238104Sdes p 5015238104Sdes d 5016238104Sdes } 5017238104Sdes # These lines can sometimes be longer than 43 characters, but 5018238104Sdes # are always uninteresting 5019238104Sdes /:[ ]*file format pe[i]\{,1\}-/d 5020238104Sdes /^In archive [^:]*:/d 5021238104Sdes # Ensure marker is printed 5022238104Sdes /^====MARK====/p 5023238104Sdes # Remove all lines with less than 43 characters 5024238104Sdes /^.\{43\}/!d 5025238104Sdes # From remaining lines, remove first 43 characters 5026238104Sdes s/^.\{43\}//' | 5027238104Sdes $SED -n ' 5028238104Sdes # Join marker and all lines until next marker into a single line 5029238104Sdes /^====MARK====/ b para 5030238104Sdes H 5031238104Sdes $ b para 5032238104Sdes b 5033238104Sdes :para 5034238104Sdes x 5035238104Sdes s/\n//g 5036238104Sdes # Remove the marker 5037238104Sdes s/^====MARK====// 5038238104Sdes # Remove trailing dots and whitespace 5039238104Sdes s/[\. \t]*$// 5040238104Sdes # Print 5041238104Sdes /./p' | 5042238104Sdes # we now have a list, one entry per line, of the stringified 5043238104Sdes # contents of the appropriate section of all members of the 5044285206Sdes # archive that possess that section. Heuristic: eliminate 5045285206Sdes # all those that have a first or second character that is 5046238104Sdes # a '.' (that is, objdump's representation of an unprintable 5047238104Sdes # character.) This should work for all archives with less than 5048238104Sdes # 0x302f exports -- but will fail for DLLs whose name actually 5049238104Sdes # begins with a literal '.' or a single character followed by 5050238104Sdes # a '.'. 5051238104Sdes # 5052238104Sdes # Of those that remain, print the first one. 5053238104Sdes $SED -e '/^\./d;/^.\./d;q' 5054238104Sdes} 5055238104Sdes 5056238104Sdes# func_cygming_dll_for_implib_fallback ARG 5057238104Sdes# Platform-specific function to extract the 5058238104Sdes# name of the DLL associated with the specified 5059238104Sdes# import library ARG. 5060238104Sdes# 5061238104Sdes# This fallback implementation is for use when $DLLTOOL 5062238104Sdes# does not support the --identify-strict option. 5063238104Sdes# Invoked by eval'ing the libtool variable 5064238104Sdes# $sharedlib_from_linklib_cmd 5065238104Sdes# Result is available in the variable 5066238104Sdes# $sharedlib_from_linklib_result 5067238104Sdesfunc_cygming_dll_for_implib_fallback () 5068238104Sdes{ 5069285206Sdes $debug_cmd 5070285206Sdes 5071285206Sdes if func_cygming_gnu_implib_p "$1"; then 5072238104Sdes # binutils import library 5073238104Sdes sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074285206Sdes elif func_cygming_ms_implib_p "$1"; then 5075238104Sdes # ms-generated import library 5076238104Sdes sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077238104Sdes else 5078238104Sdes # unknown 5079285206Sdes sharedlib_from_linklib_result= 5080238104Sdes fi 5081238104Sdes} 5082238104Sdes 5083238104Sdes 5084238104Sdes# func_extract_an_archive dir oldlib 5085238104Sdesfunc_extract_an_archive () 5086238104Sdes{ 5087285206Sdes $debug_cmd 5088285206Sdes 5089285206Sdes f_ex_an_ar_dir=$1; shift 5090285206Sdes f_ex_an_ar_oldlib=$1 5091285206Sdes if test yes = "$lock_old_archive_extraction"; then 5092238104Sdes lockfile=$f_ex_an_ar_oldlib.lock 5093238104Sdes until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094238104Sdes func_echo "Waiting for $lockfile to be removed" 5095238104Sdes sleep 2 5096238104Sdes done 5097238104Sdes fi 5098238104Sdes func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099238104Sdes 'stat=$?; rm -f "$lockfile"; exit $stat' 5100285206Sdes if test yes = "$lock_old_archive_extraction"; then 5101238104Sdes $opt_dry_run || rm -f "$lockfile" 5102238104Sdes fi 5103238104Sdes if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104238104Sdes : 5105238104Sdes else 5106238104Sdes func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107238104Sdes fi 5108238104Sdes} 5109238104Sdes 5110238104Sdes 5111238104Sdes# func_extract_archives gentop oldlib ... 5112238104Sdesfunc_extract_archives () 5113238104Sdes{ 5114285206Sdes $debug_cmd 5115285206Sdes 5116285206Sdes my_gentop=$1; shift 5117238104Sdes my_oldlibs=${1+"$@"} 5118285206Sdes my_oldobjs= 5119285206Sdes my_xlib= 5120285206Sdes my_xabs= 5121285206Sdes my_xdir= 5122238104Sdes 5123238104Sdes for my_xlib in $my_oldlibs; do 5124238104Sdes # Extract the objects. 5125238104Sdes case $my_xlib in 5126285206Sdes [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127238104Sdes *) my_xabs=`pwd`"/$my_xlib" ;; 5128238104Sdes esac 5129238104Sdes func_basename "$my_xlib" 5130285206Sdes my_xlib=$func_basename_result 5131238104Sdes my_xlib_u=$my_xlib 5132238104Sdes while :; do 5133238104Sdes case " $extracted_archives " in 5134238104Sdes *" $my_xlib_u "*) 5135238104Sdes func_arith $extracted_serial + 1 5136238104Sdes extracted_serial=$func_arith_result 5137238104Sdes my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138238104Sdes *) break ;; 5139238104Sdes esac 5140238104Sdes done 5141238104Sdes extracted_archives="$extracted_archives $my_xlib_u" 5142285206Sdes my_xdir=$my_gentop/$my_xlib_u 5143238104Sdes 5144238104Sdes func_mkdir_p "$my_xdir" 5145238104Sdes 5146238104Sdes case $host in 5147238104Sdes *-darwin*) 5148238104Sdes func_verbose "Extracting $my_xabs" 5149238104Sdes # Do not bother doing anything if just a dry run 5150238104Sdes $opt_dry_run || { 5151238104Sdes darwin_orig_dir=`pwd` 5152238104Sdes cd $my_xdir || exit $? 5153238104Sdes darwin_archive=$my_xabs 5154238104Sdes darwin_curdir=`pwd` 5155285206Sdes func_basename "$darwin_archive" 5156285206Sdes darwin_base_archive=$func_basename_result 5157238104Sdes darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158238104Sdes if test -n "$darwin_arches"; then 5159238104Sdes darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160238104Sdes darwin_arch= 5161238104Sdes func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162285206Sdes for darwin_arch in $darwin_arches; do 5163285206Sdes func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164285206Sdes $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165285206Sdes cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166285206Sdes func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167238104Sdes cd "$darwin_curdir" 5168285206Sdes $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169238104Sdes done # $darwin_arches 5170238104Sdes ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171285206Sdes darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172238104Sdes darwin_file= 5173238104Sdes darwin_files= 5174238104Sdes for darwin_file in $darwin_filelist; do 5175238104Sdes darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176238104Sdes $LIPO -create -output "$darwin_file" $darwin_files 5177238104Sdes done # $darwin_filelist 5178238104Sdes $RM -rf unfat-$$ 5179238104Sdes cd "$darwin_orig_dir" 5180238104Sdes else 5181238104Sdes cd $darwin_orig_dir 5182238104Sdes func_extract_an_archive "$my_xdir" "$my_xabs" 5183238104Sdes fi # $darwin_arches 5184238104Sdes } # !$opt_dry_run 5185238104Sdes ;; 5186238104Sdes *) 5187238104Sdes func_extract_an_archive "$my_xdir" "$my_xabs" 5188238104Sdes ;; 5189238104Sdes esac 5190238104Sdes my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191238104Sdes done 5192238104Sdes 5193285206Sdes func_extract_archives_result=$my_oldobjs 5194238104Sdes} 5195238104Sdes 5196238104Sdes 5197238104Sdes# func_emit_wrapper [arg=no] 5198238104Sdes# 5199238104Sdes# Emit a libtool wrapper script on stdout. 5200238104Sdes# Don't directly open a file because we may want to 5201238104Sdes# incorporate the script contents within a cygwin/mingw 5202238104Sdes# wrapper executable. Must ONLY be called from within 5203238104Sdes# func_mode_link because it depends on a number of variables 5204238104Sdes# set therein. 5205238104Sdes# 5206238104Sdes# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207238104Sdes# variable will take. If 'yes', then the emitted script 5208285206Sdes# will assume that the directory where it is stored is 5209238104Sdes# the $objdir directory. This is a cygwin/mingw-specific 5210238104Sdes# behavior. 5211238104Sdesfunc_emit_wrapper () 5212238104Sdes{ 5213238104Sdes func_emit_wrapper_arg1=${1-no} 5214238104Sdes 5215238104Sdes $ECHO "\ 5216238104Sdes#! $SHELL 5217238104Sdes 5218238104Sdes# $output - temporary wrapper script for $objdir/$outputname 5219285206Sdes# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220238104Sdes# 5221238104Sdes# The $output program cannot be directly executed until all the libtool 5222238104Sdes# libraries that it depends on are installed. 5223238104Sdes# 5224238104Sdes# This wrapper script should never be moved out of the build directory. 5225238104Sdes# If it is, it will not operate correctly. 5226238104Sdes 5227238104Sdes# Sed substitution that helps us do robust quoting. It backslashifies 5228238104Sdes# metacharacters that are still active within double-quoted strings. 5229238104Sdessed_quote_subst='$sed_quote_subst' 5230238104Sdes 5231238104Sdes# Be Bourne compatible 5232238104Sdesif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233238104Sdes emulate sh 5234238104Sdes NULLCMD=: 5235238104Sdes # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236238104Sdes # is contrary to our usage. Disable this feature. 5237238104Sdes alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238238104Sdes setopt NO_GLOB_SUBST 5239238104Sdeselse 5240238104Sdes case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241238104Sdesfi 5242238104SdesBIN_SH=xpg4; export BIN_SH # for Tru64 5243238104SdesDUALCASE=1; export DUALCASE # for MKS sh 5244238104Sdes 5245238104Sdes# The HP-UX ksh and POSIX shell print the target directory to stdout 5246238104Sdes# if CDPATH is set. 5247238104Sdes(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248238104Sdes 5249238104Sdesrelink_command=\"$relink_command\" 5250238104Sdes 5251238104Sdes# This environment variable determines our operation mode. 5252238104Sdesif test \"\$libtool_install_magic\" = \"$magic\"; then 5253238104Sdes # install mode needs the following variables: 5254238104Sdes generated_by_libtool_version='$macro_version' 5255238104Sdes notinst_deplibs='$notinst_deplibs' 5256238104Sdeselse 5257238104Sdes # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258238104Sdes if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259238104Sdes file=\"\$0\"" 5260238104Sdes 5261238104Sdes qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262238104Sdes $ECHO "\ 5263238104Sdes 5264238104Sdes# A function that is used when there is no print builtin or printf. 5265238104Sdesfunc_fallback_echo () 5266238104Sdes{ 5267238104Sdes eval 'cat <<_LTECHO_EOF 5268238104Sdes\$1 5269238104Sdes_LTECHO_EOF' 5270238104Sdes} 5271238104Sdes ECHO=\"$qECHO\" 5272238104Sdes fi 5273238104Sdes 5274238104Sdes# Very basic option parsing. These options are (a) specific to 5275238104Sdes# the libtool wrapper, (b) are identical between the wrapper 5276285206Sdes# /script/ and the wrapper /executable/ that is used only on 5277238104Sdes# windows platforms, and (c) all begin with the string "--lt-" 5278285206Sdes# (application programs are unlikely to have options that match 5279238104Sdes# this pattern). 5280238104Sdes# 5281238104Sdes# There are only two supported options: --lt-debug and 5282238104Sdes# --lt-dump-script. There is, deliberately, no --lt-help. 5283238104Sdes# 5284238104Sdes# The first argument to this parsing function should be the 5285238104Sdes# script's $0 value, followed by "$@". 5286238104Sdeslt_option_debug= 5287238104Sdesfunc_parse_lt_options () 5288238104Sdes{ 5289238104Sdes lt_script_arg0=\$0 5290238104Sdes shift 5291238104Sdes for lt_opt 5292238104Sdes do 5293238104Sdes case \"\$lt_opt\" in 5294238104Sdes --lt-debug) lt_option_debug=1 ;; 5295238104Sdes --lt-dump-script) 5296238104Sdes lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297238104Sdes test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298238104Sdes lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299238104Sdes cat \"\$lt_dump_D/\$lt_dump_F\" 5300238104Sdes exit 0 5301238104Sdes ;; 5302238104Sdes --lt-*) 5303238104Sdes \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304238104Sdes exit 1 5305238104Sdes ;; 5306238104Sdes esac 5307238104Sdes done 5308238104Sdes 5309238104Sdes # Print the debug banner immediately: 5310238104Sdes if test -n \"\$lt_option_debug\"; then 5311285206Sdes echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312238104Sdes fi 5313238104Sdes} 5314238104Sdes 5315238104Sdes# Used when --lt-debug. Prints its arguments to stdout 5316238104Sdes# (redirection is the responsibility of the caller) 5317238104Sdesfunc_lt_dump_args () 5318238104Sdes{ 5319238104Sdes lt_dump_args_N=1; 5320238104Sdes for lt_arg 5321238104Sdes do 5322285206Sdes \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323238104Sdes lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324238104Sdes done 5325238104Sdes} 5326238104Sdes 5327238104Sdes# Core function for launching the target application 5328238104Sdesfunc_exec_program_core () 5329238104Sdes{ 5330238104Sdes" 5331238104Sdes case $host in 5332238104Sdes # Backslashes separate directories on plain windows 5333238104Sdes *-*-mingw | *-*-os2* | *-cegcc*) 5334238104Sdes $ECHO "\ 5335238104Sdes if test -n \"\$lt_option_debug\"; then 5336285206Sdes \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337238104Sdes func_lt_dump_args \${1+\"\$@\"} 1>&2 5338238104Sdes fi 5339238104Sdes exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340238104Sdes" 5341238104Sdes ;; 5342238104Sdes 5343238104Sdes *) 5344238104Sdes $ECHO "\ 5345238104Sdes if test -n \"\$lt_option_debug\"; then 5346285206Sdes \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347238104Sdes func_lt_dump_args \${1+\"\$@\"} 1>&2 5348238104Sdes fi 5349238104Sdes exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350238104Sdes" 5351238104Sdes ;; 5352238104Sdes esac 5353238104Sdes $ECHO "\ 5354238104Sdes \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355238104Sdes exit 1 5356238104Sdes} 5357238104Sdes 5358238104Sdes# A function to encapsulate launching the target application 5359238104Sdes# Strips options in the --lt-* namespace from \$@ and 5360238104Sdes# launches target application with the remaining arguments. 5361238104Sdesfunc_exec_program () 5362238104Sdes{ 5363238104Sdes case \" \$* \" in 5364238104Sdes *\\ --lt-*) 5365238104Sdes for lt_wr_arg 5366238104Sdes do 5367238104Sdes case \$lt_wr_arg in 5368238104Sdes --lt-*) ;; 5369238104Sdes *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370238104Sdes esac 5371238104Sdes shift 5372238104Sdes done ;; 5373238104Sdes esac 5374238104Sdes func_exec_program_core \${1+\"\$@\"} 5375238104Sdes} 5376238104Sdes 5377238104Sdes # Parse options 5378238104Sdes func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379238104Sdes 5380238104Sdes # Find the directory that this script lives in. 5381238104Sdes thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382238104Sdes test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383238104Sdes 5384238104Sdes # Follow symbolic links until we get to the real thisdir. 5385238104Sdes file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386238104Sdes while test -n \"\$file\"; do 5387238104Sdes destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388238104Sdes 5389238104Sdes # If there was a directory component, then change thisdir. 5390238104Sdes if test \"x\$destdir\" != \"x\$file\"; then 5391238104Sdes case \"\$destdir\" in 5392238104Sdes [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393238104Sdes *) thisdir=\"\$thisdir/\$destdir\" ;; 5394238104Sdes esac 5395238104Sdes fi 5396238104Sdes 5397238104Sdes file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398238104Sdes file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399238104Sdes done 5400238104Sdes 5401238104Sdes # Usually 'no', except on cygwin/mingw when embedded into 5402238104Sdes # the cwrapper. 5403238104Sdes WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404238104Sdes if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405238104Sdes # special case for '.' 5406238104Sdes if test \"\$thisdir\" = \".\"; then 5407238104Sdes thisdir=\`pwd\` 5408238104Sdes fi 5409238104Sdes # remove .libs from thisdir 5410238104Sdes case \"\$thisdir\" in 5411238104Sdes *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412238104Sdes $objdir ) thisdir=. ;; 5413238104Sdes esac 5414238104Sdes fi 5415238104Sdes 5416238104Sdes # Try to get the absolute directory name. 5417238104Sdes absdir=\`cd \"\$thisdir\" && pwd\` 5418238104Sdes test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419238104Sdes" 5420238104Sdes 5421285206Sdes if test yes = "$fast_install"; then 5422238104Sdes $ECHO "\ 5423238104Sdes program=lt-'$outputname'$exeext 5424238104Sdes progdir=\"\$thisdir/$objdir\" 5425238104Sdes 5426238104Sdes if test ! -f \"\$progdir/\$program\" || 5427285206Sdes { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428238104Sdes test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429238104Sdes 5430238104Sdes file=\"\$\$-\$program\" 5431238104Sdes 5432238104Sdes if test ! -d \"\$progdir\"; then 5433238104Sdes $MKDIR \"\$progdir\" 5434238104Sdes else 5435238104Sdes $RM \"\$progdir/\$file\" 5436238104Sdes fi" 5437238104Sdes 5438238104Sdes $ECHO "\ 5439238104Sdes 5440238104Sdes # relink executable if necessary 5441238104Sdes if test -n \"\$relink_command\"; then 5442238104Sdes if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443238104Sdes else 5444285206Sdes \$ECHO \"\$relink_command_output\" >&2 5445238104Sdes $RM \"\$progdir/\$file\" 5446238104Sdes exit 1 5447238104Sdes fi 5448238104Sdes fi 5449238104Sdes 5450238104Sdes $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451238104Sdes { $RM \"\$progdir/\$program\"; 5452238104Sdes $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453238104Sdes $RM \"\$progdir/\$file\" 5454238104Sdes fi" 5455238104Sdes else 5456238104Sdes $ECHO "\ 5457238104Sdes program='$outputname' 5458238104Sdes progdir=\"\$thisdir/$objdir\" 5459238104Sdes" 5460238104Sdes fi 5461238104Sdes 5462238104Sdes $ECHO "\ 5463238104Sdes 5464238104Sdes if test -f \"\$progdir/\$program\"; then" 5465238104Sdes 5466238104Sdes # fixup the dll searchpath if we need to. 5467238104Sdes # 5468238104Sdes # Fix the DLL searchpath if we need to. Do this before prepending 5469238104Sdes # to shlibpath, because on Windows, both are PATH and uninstalled 5470238104Sdes # libraries must come first. 5471238104Sdes if test -n "$dllsearchpath"; then 5472238104Sdes $ECHO "\ 5473238104Sdes # Add the dll search path components to the executable PATH 5474238104Sdes PATH=$dllsearchpath:\$PATH 5475238104Sdes" 5476238104Sdes fi 5477238104Sdes 5478238104Sdes # Export our shlibpath_var if we have one. 5479285206Sdes if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480238104Sdes $ECHO "\ 5481238104Sdes # Add our own library path to $shlibpath_var 5482238104Sdes $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483238104Sdes 5484238104Sdes # Some systems cannot cope with colon-terminated $shlibpath_var 5485238104Sdes # The second colon is a workaround for a bug in BeOS R4 sed 5486238104Sdes $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487238104Sdes 5488238104Sdes export $shlibpath_var 5489238104Sdes" 5490238104Sdes fi 5491238104Sdes 5492238104Sdes $ECHO "\ 5493238104Sdes if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494238104Sdes # Run the actual program with our arguments. 5495238104Sdes func_exec_program \${1+\"\$@\"} 5496238104Sdes fi 5497238104Sdes else 5498238104Sdes # The program doesn't exist. 5499285206Sdes \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500238104Sdes \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501238104Sdes \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502238104Sdes exit 1 5503238104Sdes fi 5504238104Sdesfi\ 5505238104Sdes" 5506238104Sdes} 5507238104Sdes 5508238104Sdes 5509238104Sdes# func_emit_cwrapperexe_src 5510238104Sdes# emit the source code for a wrapper executable on stdout 5511238104Sdes# Must ONLY be called from within func_mode_link because 5512238104Sdes# it depends on a number of variable set therein. 5513238104Sdesfunc_emit_cwrapperexe_src () 5514238104Sdes{ 5515238104Sdes cat <<EOF 5516238104Sdes 5517238104Sdes/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518285206Sdes Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519238104Sdes 5520238104Sdes The $output program cannot be directly executed until all the libtool 5521238104Sdes libraries that it depends on are installed. 5522238104Sdes 5523238104Sdes This wrapper executable should never be moved out of the build directory. 5524238104Sdes If it is, it will not operate correctly. 5525238104Sdes*/ 5526238104SdesEOF 5527238104Sdes cat <<"EOF" 5528238104Sdes#ifdef _MSC_VER 5529238104Sdes# define _CRT_SECURE_NO_DEPRECATE 1 5530238104Sdes#endif 5531238104Sdes#include <stdio.h> 5532238104Sdes#include <stdlib.h> 5533238104Sdes#ifdef _MSC_VER 5534238104Sdes# include <direct.h> 5535238104Sdes# include <process.h> 5536238104Sdes# include <io.h> 5537238104Sdes#else 5538238104Sdes# include <unistd.h> 5539238104Sdes# include <stdint.h> 5540238104Sdes# ifdef __CYGWIN__ 5541238104Sdes# include <io.h> 5542238104Sdes# endif 5543238104Sdes#endif 5544238104Sdes#include <malloc.h> 5545238104Sdes#include <stdarg.h> 5546238104Sdes#include <assert.h> 5547238104Sdes#include <string.h> 5548238104Sdes#include <ctype.h> 5549238104Sdes#include <errno.h> 5550238104Sdes#include <fcntl.h> 5551238104Sdes#include <sys/stat.h> 5552238104Sdes 5553285206Sdes#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554285206Sdes 5555238104Sdes/* declarations of non-ANSI functions */ 5556285206Sdes#if defined __MINGW32__ 5557238104Sdes# ifdef __STRICT_ANSI__ 5558238104Sdesint _putenv (const char *); 5559238104Sdes# endif 5560285206Sdes#elif defined __CYGWIN__ 5561238104Sdes# ifdef __STRICT_ANSI__ 5562238104Sdeschar *realpath (const char *, char *); 5563238104Sdesint putenv (char *); 5564238104Sdesint setenv (const char *, const char *, int); 5565238104Sdes# endif 5566285206Sdes/* #elif defined other_platform || defined ... */ 5567238104Sdes#endif 5568238104Sdes 5569238104Sdes/* portability defines, excluding path handling macros */ 5570285206Sdes#if defined _MSC_VER 5571238104Sdes# define setmode _setmode 5572238104Sdes# define stat _stat 5573238104Sdes# define chmod _chmod 5574238104Sdes# define getcwd _getcwd 5575238104Sdes# define putenv _putenv 5576238104Sdes# define S_IXUSR _S_IEXEC 5577285206Sdes#elif defined __MINGW32__ 5578238104Sdes# define setmode _setmode 5579238104Sdes# define stat _stat 5580238104Sdes# define chmod _chmod 5581238104Sdes# define getcwd _getcwd 5582238104Sdes# define putenv _putenv 5583285206Sdes#elif defined __CYGWIN__ 5584238104Sdes# define HAVE_SETENV 5585238104Sdes# define FOPEN_WB "wb" 5586285206Sdes/* #elif defined other platforms ... */ 5587238104Sdes#endif 5588238104Sdes 5589285206Sdes#if defined PATH_MAX 5590238104Sdes# define LT_PATHMAX PATH_MAX 5591285206Sdes#elif defined MAXPATHLEN 5592238104Sdes# define LT_PATHMAX MAXPATHLEN 5593238104Sdes#else 5594238104Sdes# define LT_PATHMAX 1024 5595238104Sdes#endif 5596238104Sdes 5597238104Sdes#ifndef S_IXOTH 5598238104Sdes# define S_IXOTH 0 5599238104Sdes#endif 5600238104Sdes#ifndef S_IXGRP 5601238104Sdes# define S_IXGRP 0 5602238104Sdes#endif 5603238104Sdes 5604238104Sdes/* path handling portability macros */ 5605238104Sdes#ifndef DIR_SEPARATOR 5606238104Sdes# define DIR_SEPARATOR '/' 5607238104Sdes# define PATH_SEPARATOR ':' 5608238104Sdes#endif 5609238104Sdes 5610285206Sdes#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611285206Sdes defined __OS2__ 5612238104Sdes# define HAVE_DOS_BASED_FILE_SYSTEM 5613238104Sdes# define FOPEN_WB "wb" 5614238104Sdes# ifndef DIR_SEPARATOR_2 5615238104Sdes# define DIR_SEPARATOR_2 '\\' 5616238104Sdes# endif 5617238104Sdes# ifndef PATH_SEPARATOR_2 5618238104Sdes# define PATH_SEPARATOR_2 ';' 5619238104Sdes# endif 5620238104Sdes#endif 5621238104Sdes 5622238104Sdes#ifndef DIR_SEPARATOR_2 5623238104Sdes# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624238104Sdes#else /* DIR_SEPARATOR_2 */ 5625238104Sdes# define IS_DIR_SEPARATOR(ch) \ 5626238104Sdes (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627238104Sdes#endif /* DIR_SEPARATOR_2 */ 5628238104Sdes 5629238104Sdes#ifndef PATH_SEPARATOR_2 5630238104Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631238104Sdes#else /* PATH_SEPARATOR_2 */ 5632238104Sdes# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633238104Sdes#endif /* PATH_SEPARATOR_2 */ 5634238104Sdes 5635238104Sdes#ifndef FOPEN_WB 5636238104Sdes# define FOPEN_WB "w" 5637238104Sdes#endif 5638238104Sdes#ifndef _O_BINARY 5639238104Sdes# define _O_BINARY 0 5640238104Sdes#endif 5641238104Sdes 5642238104Sdes#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643238104Sdes#define XFREE(stale) do { \ 5644285206Sdes if (stale) { free (stale); stale = 0; } \ 5645238104Sdes} while (0) 5646238104Sdes 5647285206Sdes#if defined LT_DEBUGWRAPPER 5648238104Sdesstatic int lt_debug = 1; 5649238104Sdes#else 5650238104Sdesstatic int lt_debug = 0; 5651238104Sdes#endif 5652238104Sdes 5653238104Sdesconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654238104Sdes 5655238104Sdesvoid *xmalloc (size_t num); 5656238104Sdeschar *xstrdup (const char *string); 5657238104Sdesconst char *base_name (const char *name); 5658238104Sdeschar *find_executable (const char *wrapper); 5659238104Sdeschar *chase_symlinks (const char *pathspec); 5660238104Sdesint make_executable (const char *path); 5661238104Sdesint check_executable (const char *path); 5662238104Sdeschar *strendzap (char *str, const char *pat); 5663238104Sdesvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664238104Sdesvoid lt_fatal (const char *file, int line, const char *message, ...); 5665238104Sdesstatic const char *nonnull (const char *s); 5666238104Sdesstatic const char *nonempty (const char *s); 5667238104Sdesvoid lt_setenv (const char *name, const char *value); 5668238104Sdeschar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669238104Sdesvoid lt_update_exe_path (const char *name, const char *value); 5670238104Sdesvoid lt_update_lib_path (const char *name, const char *value); 5671238104Sdeschar **prepare_spawn (char **argv); 5672238104Sdesvoid lt_dump_script (FILE *f); 5673238104SdesEOF 5674238104Sdes 5675238104Sdes cat <<EOF 5676285206Sdes#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677285206Sdes# define externally_visible volatile 5678285206Sdes#else 5679285206Sdes# define externally_visible __attribute__((externally_visible)) volatile 5680285206Sdes#endif 5681285206Sdesexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682238104Sdesconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683238104SdesEOF 5684238104Sdes 5685285206Sdes if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686238104Sdes func_to_host_path "$temp_rpath" 5687238104Sdes cat <<EOF 5688238104Sdesconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689238104SdesEOF 5690238104Sdes else 5691238104Sdes cat <<"EOF" 5692238104Sdesconst char * LIB_PATH_VALUE = ""; 5693238104SdesEOF 5694238104Sdes fi 5695238104Sdes 5696238104Sdes if test -n "$dllsearchpath"; then 5697238104Sdes func_to_host_path "$dllsearchpath:" 5698238104Sdes cat <<EOF 5699238104Sdesconst char * EXE_PATH_VARNAME = "PATH"; 5700238104Sdesconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701238104SdesEOF 5702238104Sdes else 5703238104Sdes cat <<"EOF" 5704238104Sdesconst char * EXE_PATH_VARNAME = ""; 5705238104Sdesconst char * EXE_PATH_VALUE = ""; 5706238104SdesEOF 5707238104Sdes fi 5708238104Sdes 5709285206Sdes if test yes = "$fast_install"; then 5710238104Sdes cat <<EOF 5711238104Sdesconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712238104SdesEOF 5713238104Sdes else 5714238104Sdes cat <<EOF 5715238104Sdesconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716238104SdesEOF 5717238104Sdes fi 5718238104Sdes 5719238104Sdes 5720238104Sdes cat <<"EOF" 5721238104Sdes 5722238104Sdes#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723238104Sdes 5724238104Sdesstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725238104Sdesstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726238104Sdesstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727238104Sdes 5728238104Sdesint 5729238104Sdesmain (int argc, char *argv[]) 5730238104Sdes{ 5731238104Sdes char **newargz; 5732238104Sdes int newargc; 5733238104Sdes char *tmp_pathspec; 5734238104Sdes char *actual_cwrapper_path; 5735238104Sdes char *actual_cwrapper_name; 5736238104Sdes char *target_name; 5737238104Sdes char *lt_argv_zero; 5738285206Sdes int rval = 127; 5739238104Sdes 5740238104Sdes int i; 5741238104Sdes 5742238104Sdes program_name = (char *) xstrdup (base_name (argv[0])); 5743285206Sdes newargz = XMALLOC (char *, (size_t) argc + 1); 5744238104Sdes 5745238104Sdes /* very simple arg parsing; don't want to rely on getopt 5746238104Sdes * also, copy all non cwrapper options to newargz, except 5747238104Sdes * argz[0], which is handled differently 5748238104Sdes */ 5749238104Sdes newargc=0; 5750238104Sdes for (i = 1; i < argc; i++) 5751238104Sdes { 5752285206Sdes if (STREQ (argv[i], dumpscript_opt)) 5753238104Sdes { 5754238104SdesEOF 5755285206Sdes case $host in 5756238104Sdes *mingw* | *cygwin* ) 5757238104Sdes # make stdout use "unix" line endings 5758238104Sdes echo " setmode(1,_O_BINARY);" 5759238104Sdes ;; 5760238104Sdes esac 5761238104Sdes 5762238104Sdes cat <<"EOF" 5763238104Sdes lt_dump_script (stdout); 5764238104Sdes return 0; 5765238104Sdes } 5766285206Sdes if (STREQ (argv[i], debug_opt)) 5767238104Sdes { 5768238104Sdes lt_debug = 1; 5769238104Sdes continue; 5770238104Sdes } 5771285206Sdes if (STREQ (argv[i], ltwrapper_option_prefix)) 5772238104Sdes { 5773238104Sdes /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774238104Sdes namespace, but it is not one of the ones we know about and 5775238104Sdes have already dealt with, above (inluding dump-script), then 5776238104Sdes report an error. Otherwise, targets might begin to believe 5777238104Sdes they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778238104Sdes namespace. The first time any user complains about this, we'll 5779238104Sdes need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780238104Sdes or a configure.ac-settable value. 5781238104Sdes */ 5782238104Sdes lt_fatal (__FILE__, __LINE__, 5783238104Sdes "unrecognized %s option: '%s'", 5784238104Sdes ltwrapper_option_prefix, argv[i]); 5785238104Sdes } 5786238104Sdes /* otherwise ... */ 5787238104Sdes newargz[++newargc] = xstrdup (argv[i]); 5788238104Sdes } 5789238104Sdes newargz[++newargc] = NULL; 5790238104Sdes 5791238104SdesEOF 5792238104Sdes cat <<EOF 5793238104Sdes /* The GNU banner must be the first non-error debug message */ 5794285206Sdes lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795238104SdesEOF 5796238104Sdes cat <<"EOF" 5797238104Sdes lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798238104Sdes lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799238104Sdes 5800238104Sdes tmp_pathspec = find_executable (argv[0]); 5801238104Sdes if (tmp_pathspec == NULL) 5802238104Sdes lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803238104Sdes lt_debugprintf (__FILE__, __LINE__, 5804238104Sdes "(main) found exe (before symlink chase) at: %s\n", 5805238104Sdes tmp_pathspec); 5806238104Sdes 5807238104Sdes actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808238104Sdes lt_debugprintf (__FILE__, __LINE__, 5809238104Sdes "(main) found exe (after symlink chase) at: %s\n", 5810238104Sdes actual_cwrapper_path); 5811238104Sdes XFREE (tmp_pathspec); 5812238104Sdes 5813238104Sdes actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814238104Sdes strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815238104Sdes 5816238104Sdes /* wrapper name transforms */ 5817238104Sdes strendzap (actual_cwrapper_name, ".exe"); 5818238104Sdes tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819238104Sdes XFREE (actual_cwrapper_name); 5820238104Sdes actual_cwrapper_name = tmp_pathspec; 5821238104Sdes tmp_pathspec = 0; 5822238104Sdes 5823238104Sdes /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824238104Sdes target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825238104Sdes strendzap (target_name, ".exe"); 5826238104Sdes tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827238104Sdes XFREE (target_name); 5828238104Sdes target_name = tmp_pathspec; 5829238104Sdes tmp_pathspec = 0; 5830238104Sdes 5831238104Sdes lt_debugprintf (__FILE__, __LINE__, 5832238104Sdes "(main) libtool target name: %s\n", 5833238104Sdes target_name); 5834238104SdesEOF 5835238104Sdes 5836238104Sdes cat <<EOF 5837238104Sdes newargz[0] = 5838238104Sdes XMALLOC (char, (strlen (actual_cwrapper_path) + 5839238104Sdes strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840238104Sdes strcpy (newargz[0], actual_cwrapper_path); 5841238104Sdes strcat (newargz[0], "$objdir"); 5842238104Sdes strcat (newargz[0], "/"); 5843238104SdesEOF 5844238104Sdes 5845238104Sdes cat <<"EOF" 5846238104Sdes /* stop here, and copy so we don't have to do this twice */ 5847238104Sdes tmp_pathspec = xstrdup (newargz[0]); 5848238104Sdes 5849238104Sdes /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850238104Sdes strcat (newargz[0], actual_cwrapper_name); 5851238104Sdes 5852238104Sdes /* DO want the lt- prefix here if it exists, so use target_name */ 5853238104Sdes lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854238104Sdes XFREE (tmp_pathspec); 5855238104Sdes tmp_pathspec = NULL; 5856238104SdesEOF 5857238104Sdes 5858238104Sdes case $host_os in 5859238104Sdes mingw*) 5860238104Sdes cat <<"EOF" 5861238104Sdes { 5862238104Sdes char* p; 5863238104Sdes while ((p = strchr (newargz[0], '\\')) != NULL) 5864238104Sdes { 5865238104Sdes *p = '/'; 5866238104Sdes } 5867238104Sdes while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868238104Sdes { 5869238104Sdes *p = '/'; 5870238104Sdes } 5871238104Sdes } 5872238104SdesEOF 5873238104Sdes ;; 5874238104Sdes esac 5875238104Sdes 5876238104Sdes cat <<"EOF" 5877238104Sdes XFREE (target_name); 5878238104Sdes XFREE (actual_cwrapper_path); 5879238104Sdes XFREE (actual_cwrapper_name); 5880238104Sdes 5881238104Sdes lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882238104Sdes lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883238104Sdes /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884238104Sdes be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885238104Sdes because on Windows, both *_VARNAMEs are PATH but uninstalled 5886238104Sdes libraries must come first. */ 5887238104Sdes lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888238104Sdes lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889238104Sdes 5890238104Sdes lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891238104Sdes nonnull (lt_argv_zero)); 5892238104Sdes for (i = 0; i < newargc; i++) 5893238104Sdes { 5894238104Sdes lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895238104Sdes i, nonnull (newargz[i])); 5896238104Sdes } 5897238104Sdes 5898238104SdesEOF 5899238104Sdes 5900238104Sdes case $host_os in 5901238104Sdes mingw*) 5902238104Sdes cat <<"EOF" 5903238104Sdes /* execv doesn't actually work on mingw as expected on unix */ 5904238104Sdes newargz = prepare_spawn (newargz); 5905285206Sdes rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906238104Sdes if (rval == -1) 5907238104Sdes { 5908238104Sdes /* failed to start process */ 5909238104Sdes lt_debugprintf (__FILE__, __LINE__, 5910238104Sdes "(main) failed to launch target \"%s\": %s\n", 5911238104Sdes lt_argv_zero, nonnull (strerror (errno))); 5912238104Sdes return 127; 5913238104Sdes } 5914238104Sdes return rval; 5915238104SdesEOF 5916238104Sdes ;; 5917238104Sdes *) 5918238104Sdes cat <<"EOF" 5919238104Sdes execv (lt_argv_zero, newargz); 5920238104Sdes return rval; /* =127, but avoids unused variable warning */ 5921238104SdesEOF 5922238104Sdes ;; 5923238104Sdes esac 5924238104Sdes 5925238104Sdes cat <<"EOF" 5926238104Sdes} 5927238104Sdes 5928238104Sdesvoid * 5929238104Sdesxmalloc (size_t num) 5930238104Sdes{ 5931238104Sdes void *p = (void *) malloc (num); 5932238104Sdes if (!p) 5933238104Sdes lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934238104Sdes 5935238104Sdes return p; 5936238104Sdes} 5937238104Sdes 5938238104Sdeschar * 5939238104Sdesxstrdup (const char *string) 5940238104Sdes{ 5941238104Sdes return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942238104Sdes string) : NULL; 5943238104Sdes} 5944238104Sdes 5945238104Sdesconst char * 5946238104Sdesbase_name (const char *name) 5947238104Sdes{ 5948238104Sdes const char *base; 5949238104Sdes 5950285206Sdes#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951238104Sdes /* Skip over the disk name in MSDOS pathnames. */ 5952238104Sdes if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953238104Sdes name += 2; 5954238104Sdes#endif 5955238104Sdes 5956238104Sdes for (base = name; *name; name++) 5957238104Sdes if (IS_DIR_SEPARATOR (*name)) 5958238104Sdes base = name + 1; 5959238104Sdes return base; 5960238104Sdes} 5961238104Sdes 5962238104Sdesint 5963238104Sdescheck_executable (const char *path) 5964238104Sdes{ 5965238104Sdes struct stat st; 5966238104Sdes 5967238104Sdes lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968238104Sdes nonempty (path)); 5969238104Sdes if ((!path) || (!*path)) 5970238104Sdes return 0; 5971238104Sdes 5972238104Sdes if ((stat (path, &st) >= 0) 5973238104Sdes && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974238104Sdes return 1; 5975238104Sdes else 5976238104Sdes return 0; 5977238104Sdes} 5978238104Sdes 5979238104Sdesint 5980238104Sdesmake_executable (const char *path) 5981238104Sdes{ 5982238104Sdes int rval = 0; 5983238104Sdes struct stat st; 5984238104Sdes 5985238104Sdes lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986238104Sdes nonempty (path)); 5987238104Sdes if ((!path) || (!*path)) 5988238104Sdes return 0; 5989238104Sdes 5990238104Sdes if (stat (path, &st) >= 0) 5991238104Sdes { 5992238104Sdes rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993238104Sdes } 5994238104Sdes return rval; 5995238104Sdes} 5996238104Sdes 5997238104Sdes/* Searches for the full path of the wrapper. Returns 5998238104Sdes newly allocated full path name if found, NULL otherwise 5999238104Sdes Does not chase symlinks, even on platforms that support them. 6000238104Sdes*/ 6001238104Sdeschar * 6002238104Sdesfind_executable (const char *wrapper) 6003238104Sdes{ 6004238104Sdes int has_slash = 0; 6005238104Sdes const char *p; 6006238104Sdes const char *p_next; 6007238104Sdes /* static buffer for getcwd */ 6008238104Sdes char tmp[LT_PATHMAX + 1]; 6009285206Sdes size_t tmp_len; 6010238104Sdes char *concat_name; 6011238104Sdes 6012238104Sdes lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013238104Sdes nonempty (wrapper)); 6014238104Sdes 6015238104Sdes if ((wrapper == NULL) || (*wrapper == '\0')) 6016238104Sdes return NULL; 6017238104Sdes 6018238104Sdes /* Absolute path? */ 6019285206Sdes#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020238104Sdes if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021238104Sdes { 6022238104Sdes concat_name = xstrdup (wrapper); 6023238104Sdes if (check_executable (concat_name)) 6024238104Sdes return concat_name; 6025238104Sdes XFREE (concat_name); 6026238104Sdes } 6027238104Sdes else 6028238104Sdes { 6029238104Sdes#endif 6030238104Sdes if (IS_DIR_SEPARATOR (wrapper[0])) 6031238104Sdes { 6032238104Sdes concat_name = xstrdup (wrapper); 6033238104Sdes if (check_executable (concat_name)) 6034238104Sdes return concat_name; 6035238104Sdes XFREE (concat_name); 6036238104Sdes } 6037285206Sdes#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038238104Sdes } 6039238104Sdes#endif 6040238104Sdes 6041238104Sdes for (p = wrapper; *p; p++) 6042238104Sdes if (*p == '/') 6043238104Sdes { 6044238104Sdes has_slash = 1; 6045238104Sdes break; 6046238104Sdes } 6047238104Sdes if (!has_slash) 6048238104Sdes { 6049238104Sdes /* no slashes; search PATH */ 6050238104Sdes const char *path = getenv ("PATH"); 6051238104Sdes if (path != NULL) 6052238104Sdes { 6053238104Sdes for (p = path; *p; p = p_next) 6054238104Sdes { 6055238104Sdes const char *q; 6056238104Sdes size_t p_len; 6057238104Sdes for (q = p; *q; q++) 6058238104Sdes if (IS_PATH_SEPARATOR (*q)) 6059238104Sdes break; 6060285206Sdes p_len = (size_t) (q - p); 6061238104Sdes p_next = (*q == '\0' ? q : q + 1); 6062238104Sdes if (p_len == 0) 6063238104Sdes { 6064238104Sdes /* empty path: current directory */ 6065238104Sdes if (getcwd (tmp, LT_PATHMAX) == NULL) 6066238104Sdes lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067238104Sdes nonnull (strerror (errno))); 6068238104Sdes tmp_len = strlen (tmp); 6069238104Sdes concat_name = 6070238104Sdes XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071238104Sdes memcpy (concat_name, tmp, tmp_len); 6072238104Sdes concat_name[tmp_len] = '/'; 6073238104Sdes strcpy (concat_name + tmp_len + 1, wrapper); 6074238104Sdes } 6075238104Sdes else 6076238104Sdes { 6077238104Sdes concat_name = 6078238104Sdes XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079238104Sdes memcpy (concat_name, p, p_len); 6080238104Sdes concat_name[p_len] = '/'; 6081238104Sdes strcpy (concat_name + p_len + 1, wrapper); 6082238104Sdes } 6083238104Sdes if (check_executable (concat_name)) 6084238104Sdes return concat_name; 6085238104Sdes XFREE (concat_name); 6086238104Sdes } 6087238104Sdes } 6088238104Sdes /* not found in PATH; assume curdir */ 6089238104Sdes } 6090238104Sdes /* Relative path | not found in path: prepend cwd */ 6091238104Sdes if (getcwd (tmp, LT_PATHMAX) == NULL) 6092238104Sdes lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093238104Sdes nonnull (strerror (errno))); 6094238104Sdes tmp_len = strlen (tmp); 6095238104Sdes concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096238104Sdes memcpy (concat_name, tmp, tmp_len); 6097238104Sdes concat_name[tmp_len] = '/'; 6098238104Sdes strcpy (concat_name + tmp_len + 1, wrapper); 6099238104Sdes 6100238104Sdes if (check_executable (concat_name)) 6101238104Sdes return concat_name; 6102238104Sdes XFREE (concat_name); 6103238104Sdes return NULL; 6104238104Sdes} 6105238104Sdes 6106238104Sdeschar * 6107238104Sdeschase_symlinks (const char *pathspec) 6108238104Sdes{ 6109238104Sdes#ifndef S_ISLNK 6110238104Sdes return xstrdup (pathspec); 6111238104Sdes#else 6112238104Sdes char buf[LT_PATHMAX]; 6113238104Sdes struct stat s; 6114238104Sdes char *tmp_pathspec = xstrdup (pathspec); 6115238104Sdes char *p; 6116238104Sdes int has_symlinks = 0; 6117238104Sdes while (strlen (tmp_pathspec) && !has_symlinks) 6118238104Sdes { 6119238104Sdes lt_debugprintf (__FILE__, __LINE__, 6120238104Sdes "checking path component for symlinks: %s\n", 6121238104Sdes tmp_pathspec); 6122238104Sdes if (lstat (tmp_pathspec, &s) == 0) 6123238104Sdes { 6124238104Sdes if (S_ISLNK (s.st_mode) != 0) 6125238104Sdes { 6126238104Sdes has_symlinks = 1; 6127238104Sdes break; 6128238104Sdes } 6129238104Sdes 6130238104Sdes /* search backwards for last DIR_SEPARATOR */ 6131238104Sdes p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132238104Sdes while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133238104Sdes p--; 6134238104Sdes if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135238104Sdes { 6136238104Sdes /* no more DIR_SEPARATORS left */ 6137238104Sdes break; 6138238104Sdes } 6139238104Sdes *p = '\0'; 6140238104Sdes } 6141238104Sdes else 6142238104Sdes { 6143238104Sdes lt_fatal (__FILE__, __LINE__, 6144238104Sdes "error accessing file \"%s\": %s", 6145238104Sdes tmp_pathspec, nonnull (strerror (errno))); 6146238104Sdes } 6147238104Sdes } 6148238104Sdes XFREE (tmp_pathspec); 6149238104Sdes 6150238104Sdes if (!has_symlinks) 6151238104Sdes { 6152238104Sdes return xstrdup (pathspec); 6153238104Sdes } 6154238104Sdes 6155238104Sdes tmp_pathspec = realpath (pathspec, buf); 6156238104Sdes if (tmp_pathspec == 0) 6157238104Sdes { 6158238104Sdes lt_fatal (__FILE__, __LINE__, 6159238104Sdes "could not follow symlinks for %s", pathspec); 6160238104Sdes } 6161238104Sdes return xstrdup (tmp_pathspec); 6162238104Sdes#endif 6163238104Sdes} 6164238104Sdes 6165238104Sdeschar * 6166238104Sdesstrendzap (char *str, const char *pat) 6167238104Sdes{ 6168238104Sdes size_t len, patlen; 6169238104Sdes 6170238104Sdes assert (str != NULL); 6171238104Sdes assert (pat != NULL); 6172238104Sdes 6173238104Sdes len = strlen (str); 6174238104Sdes patlen = strlen (pat); 6175238104Sdes 6176238104Sdes if (patlen <= len) 6177238104Sdes { 6178238104Sdes str += len - patlen; 6179285206Sdes if (STREQ (str, pat)) 6180238104Sdes *str = '\0'; 6181238104Sdes } 6182238104Sdes return str; 6183238104Sdes} 6184238104Sdes 6185238104Sdesvoid 6186238104Sdeslt_debugprintf (const char *file, int line, const char *fmt, ...) 6187238104Sdes{ 6188238104Sdes va_list args; 6189238104Sdes if (lt_debug) 6190238104Sdes { 6191238104Sdes (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192238104Sdes va_start (args, fmt); 6193238104Sdes (void) vfprintf (stderr, fmt, args); 6194238104Sdes va_end (args); 6195238104Sdes } 6196238104Sdes} 6197238104Sdes 6198238104Sdesstatic void 6199238104Sdeslt_error_core (int exit_status, const char *file, 6200238104Sdes int line, const char *mode, 6201238104Sdes const char *message, va_list ap) 6202238104Sdes{ 6203238104Sdes fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204238104Sdes vfprintf (stderr, message, ap); 6205238104Sdes fprintf (stderr, ".\n"); 6206238104Sdes 6207238104Sdes if (exit_status >= 0) 6208238104Sdes exit (exit_status); 6209238104Sdes} 6210238104Sdes 6211238104Sdesvoid 6212238104Sdeslt_fatal (const char *file, int line, const char *message, ...) 6213238104Sdes{ 6214238104Sdes va_list ap; 6215238104Sdes va_start (ap, message); 6216238104Sdes lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217238104Sdes va_end (ap); 6218238104Sdes} 6219238104Sdes 6220238104Sdesstatic const char * 6221238104Sdesnonnull (const char *s) 6222238104Sdes{ 6223238104Sdes return s ? s : "(null)"; 6224238104Sdes} 6225238104Sdes 6226238104Sdesstatic const char * 6227238104Sdesnonempty (const char *s) 6228238104Sdes{ 6229238104Sdes return (s && !*s) ? "(empty)" : nonnull (s); 6230238104Sdes} 6231238104Sdes 6232238104Sdesvoid 6233238104Sdeslt_setenv (const char *name, const char *value) 6234238104Sdes{ 6235238104Sdes lt_debugprintf (__FILE__, __LINE__, 6236238104Sdes "(lt_setenv) setting '%s' to '%s'\n", 6237238104Sdes nonnull (name), nonnull (value)); 6238238104Sdes { 6239238104Sdes#ifdef HAVE_SETENV 6240238104Sdes /* always make a copy, for consistency with !HAVE_SETENV */ 6241238104Sdes char *str = xstrdup (value); 6242238104Sdes setenv (name, str, 1); 6243238104Sdes#else 6244285206Sdes size_t len = strlen (name) + 1 + strlen (value) + 1; 6245238104Sdes char *str = XMALLOC (char, len); 6246238104Sdes sprintf (str, "%s=%s", name, value); 6247238104Sdes if (putenv (str) != EXIT_SUCCESS) 6248238104Sdes { 6249238104Sdes XFREE (str); 6250238104Sdes } 6251238104Sdes#endif 6252238104Sdes } 6253238104Sdes} 6254238104Sdes 6255238104Sdeschar * 6256238104Sdeslt_extend_str (const char *orig_value, const char *add, int to_end) 6257238104Sdes{ 6258238104Sdes char *new_value; 6259238104Sdes if (orig_value && *orig_value) 6260238104Sdes { 6261285206Sdes size_t orig_value_len = strlen (orig_value); 6262285206Sdes size_t add_len = strlen (add); 6263238104Sdes new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264238104Sdes if (to_end) 6265238104Sdes { 6266238104Sdes strcpy (new_value, orig_value); 6267238104Sdes strcpy (new_value + orig_value_len, add); 6268238104Sdes } 6269238104Sdes else 6270238104Sdes { 6271238104Sdes strcpy (new_value, add); 6272238104Sdes strcpy (new_value + add_len, orig_value); 6273238104Sdes } 6274238104Sdes } 6275238104Sdes else 6276238104Sdes { 6277238104Sdes new_value = xstrdup (add); 6278238104Sdes } 6279238104Sdes return new_value; 6280238104Sdes} 6281238104Sdes 6282238104Sdesvoid 6283238104Sdeslt_update_exe_path (const char *name, const char *value) 6284238104Sdes{ 6285238104Sdes lt_debugprintf (__FILE__, __LINE__, 6286238104Sdes "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287238104Sdes nonnull (name), nonnull (value)); 6288238104Sdes 6289238104Sdes if (name && *name && value && *value) 6290238104Sdes { 6291238104Sdes char *new_value = lt_extend_str (getenv (name), value, 0); 6292238104Sdes /* some systems can't cope with a ':'-terminated path #' */ 6293285206Sdes size_t len = strlen (new_value); 6294285206Sdes while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295238104Sdes { 6296285206Sdes new_value[--len] = '\0'; 6297238104Sdes } 6298238104Sdes lt_setenv (name, new_value); 6299238104Sdes XFREE (new_value); 6300238104Sdes } 6301238104Sdes} 6302238104Sdes 6303238104Sdesvoid 6304238104Sdeslt_update_lib_path (const char *name, const char *value) 6305238104Sdes{ 6306238104Sdes lt_debugprintf (__FILE__, __LINE__, 6307238104Sdes "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308238104Sdes nonnull (name), nonnull (value)); 6309238104Sdes 6310238104Sdes if (name && *name && value && *value) 6311238104Sdes { 6312238104Sdes char *new_value = lt_extend_str (getenv (name), value, 0); 6313238104Sdes lt_setenv (name, new_value); 6314238104Sdes XFREE (new_value); 6315238104Sdes } 6316238104Sdes} 6317238104Sdes 6318238104SdesEOF 6319238104Sdes case $host_os in 6320238104Sdes mingw*) 6321238104Sdes cat <<"EOF" 6322238104Sdes 6323238104Sdes/* Prepares an argument vector before calling spawn(). 6324238104Sdes Note that spawn() does not by itself call the command interpreter 6325238104Sdes (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326238104Sdes ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327238104Sdes GetVersionEx(&v); 6328238104Sdes v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329238104Sdes }) ? "cmd.exe" : "command.com"). 6330238104Sdes Instead it simply concatenates the arguments, separated by ' ', and calls 6331238104Sdes CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332238104Sdes interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333238104Sdes special way: 6334238104Sdes - Space and tab are interpreted as delimiters. They are not treated as 6335238104Sdes delimiters if they are surrounded by double quotes: "...". 6336238104Sdes - Unescaped double quotes are removed from the input. Their only effect is 6337238104Sdes that within double quotes, space and tab are treated like normal 6338238104Sdes characters. 6339238104Sdes - Backslashes not followed by double quotes are not special. 6340238104Sdes - But 2*n+1 backslashes followed by a double quote become 6341238104Sdes n backslashes followed by a double quote (n >= 0): 6342238104Sdes \" -> " 6343238104Sdes \\\" -> \" 6344238104Sdes \\\\\" -> \\" 6345238104Sdes */ 6346238104Sdes#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" 6347238104Sdes#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" 6348238104Sdeschar ** 6349238104Sdesprepare_spawn (char **argv) 6350238104Sdes{ 6351238104Sdes size_t argc; 6352238104Sdes char **new_argv; 6353238104Sdes size_t i; 6354238104Sdes 6355238104Sdes /* Count number of arguments. */ 6356238104Sdes for (argc = 0; argv[argc] != NULL; argc++) 6357238104Sdes ; 6358238104Sdes 6359238104Sdes /* Allocate new argument vector. */ 6360238104Sdes new_argv = XMALLOC (char *, argc + 1); 6361238104Sdes 6362238104Sdes /* Put quoted arguments into the new argument vector. */ 6363238104Sdes for (i = 0; i < argc; i++) 6364238104Sdes { 6365238104Sdes const char *string = argv[i]; 6366238104Sdes 6367238104Sdes if (string[0] == '\0') 6368238104Sdes new_argv[i] = xstrdup ("\"\""); 6369238104Sdes else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370238104Sdes { 6371238104Sdes int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372238104Sdes size_t length; 6373238104Sdes unsigned int backslashes; 6374238104Sdes const char *s; 6375238104Sdes char *quoted_string; 6376238104Sdes char *p; 6377238104Sdes 6378238104Sdes length = 0; 6379238104Sdes backslashes = 0; 6380238104Sdes if (quote_around) 6381238104Sdes length++; 6382238104Sdes for (s = string; *s != '\0'; s++) 6383238104Sdes { 6384238104Sdes char c = *s; 6385238104Sdes if (c == '"') 6386238104Sdes length += backslashes + 1; 6387238104Sdes length++; 6388238104Sdes if (c == '\\') 6389238104Sdes backslashes++; 6390238104Sdes else 6391238104Sdes backslashes = 0; 6392238104Sdes } 6393238104Sdes if (quote_around) 6394238104Sdes length += backslashes + 1; 6395238104Sdes 6396238104Sdes quoted_string = XMALLOC (char, length + 1); 6397238104Sdes 6398238104Sdes p = quoted_string; 6399238104Sdes backslashes = 0; 6400238104Sdes if (quote_around) 6401238104Sdes *p++ = '"'; 6402238104Sdes for (s = string; *s != '\0'; s++) 6403238104Sdes { 6404238104Sdes char c = *s; 6405238104Sdes if (c == '"') 6406238104Sdes { 6407238104Sdes unsigned int j; 6408238104Sdes for (j = backslashes + 1; j > 0; j--) 6409238104Sdes *p++ = '\\'; 6410238104Sdes } 6411238104Sdes *p++ = c; 6412238104Sdes if (c == '\\') 6413238104Sdes backslashes++; 6414238104Sdes else 6415238104Sdes backslashes = 0; 6416238104Sdes } 6417238104Sdes if (quote_around) 6418238104Sdes { 6419238104Sdes unsigned int j; 6420238104Sdes for (j = backslashes; j > 0; j--) 6421238104Sdes *p++ = '\\'; 6422238104Sdes *p++ = '"'; 6423238104Sdes } 6424238104Sdes *p = '\0'; 6425238104Sdes 6426238104Sdes new_argv[i] = quoted_string; 6427238104Sdes } 6428238104Sdes else 6429238104Sdes new_argv[i] = (char *) string; 6430238104Sdes } 6431238104Sdes new_argv[argc] = NULL; 6432238104Sdes 6433238104Sdes return new_argv; 6434238104Sdes} 6435238104SdesEOF 6436238104Sdes ;; 6437238104Sdes esac 6438238104Sdes 6439238104Sdes cat <<"EOF" 6440238104Sdesvoid lt_dump_script (FILE* f) 6441238104Sdes{ 6442238104SdesEOF 6443238104Sdes func_emit_wrapper yes | 6444238104Sdes $SED -n -e ' 6445238104Sdess/^\(.\{79\}\)\(..*\)/\1\ 6446238104Sdes\2/ 6447238104Sdesh 6448238104Sdess/\([\\"]\)/\\\1/g 6449238104Sdess/$/\\n/ 6450238104Sdess/\([^\n]*\).*/ fputs ("\1", f);/p 6451238104Sdesg 6452238104SdesD' 6453238104Sdes cat <<"EOF" 6454238104Sdes} 6455238104SdesEOF 6456238104Sdes} 6457238104Sdes# end: func_emit_cwrapperexe_src 6458238104Sdes 6459238104Sdes# func_win32_import_lib_p ARG 6460238104Sdes# True if ARG is an import lib, as indicated by $file_magic_cmd 6461238104Sdesfunc_win32_import_lib_p () 6462238104Sdes{ 6463285206Sdes $debug_cmd 6464285206Sdes 6465238104Sdes case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466238104Sdes *import*) : ;; 6467238104Sdes *) false ;; 6468238104Sdes esac 6469238104Sdes} 6470238104Sdes 6471285206Sdes# func_suncc_cstd_abi 6472285206Sdes# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473285206Sdes# Several compiler flags select an ABI that is incompatible with the 6474285206Sdes# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475285206Sdesfunc_suncc_cstd_abi () 6476285206Sdes{ 6477285206Sdes $debug_cmd 6478285206Sdes 6479285206Sdes case " $compile_command " in 6480285206Sdes *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481285206Sdes suncc_use_cstd_abi=no 6482285206Sdes ;; 6483285206Sdes *) 6484285206Sdes suncc_use_cstd_abi=yes 6485285206Sdes ;; 6486285206Sdes esac 6487285206Sdes} 6488285206Sdes 6489238104Sdes# func_mode_link arg... 6490238104Sdesfunc_mode_link () 6491238104Sdes{ 6492285206Sdes $debug_cmd 6493285206Sdes 6494238104Sdes case $host in 6495238104Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496238104Sdes # It is impossible to link a dll without this setting, and 6497238104Sdes # we shouldn't force the makefile maintainer to figure out 6498285206Sdes # what system we are compiling for in order to pass an extra 6499238104Sdes # flag for every libtool invocation. 6500238104Sdes # allow_undefined=no 6501238104Sdes 6502238104Sdes # FIXME: Unfortunately, there are problems with the above when trying 6503285206Sdes # to make a dll that has undefined symbols, in which case not 6504238104Sdes # even a static library is built. For now, we need to specify 6505238104Sdes # -no-undefined on the libtool link line when we can be certain 6506238104Sdes # that all symbols are satisfied, otherwise we get a static library. 6507238104Sdes allow_undefined=yes 6508238104Sdes ;; 6509238104Sdes *) 6510238104Sdes allow_undefined=yes 6511238104Sdes ;; 6512238104Sdes esac 6513238104Sdes libtool_args=$nonopt 6514238104Sdes base_compile="$nonopt $@" 6515238104Sdes compile_command=$nonopt 6516238104Sdes finalize_command=$nonopt 6517238104Sdes 6518238104Sdes compile_rpath= 6519238104Sdes finalize_rpath= 6520238104Sdes compile_shlibpath= 6521238104Sdes finalize_shlibpath= 6522238104Sdes convenience= 6523238104Sdes old_convenience= 6524238104Sdes deplibs= 6525238104Sdes old_deplibs= 6526238104Sdes compiler_flags= 6527238104Sdes linker_flags= 6528238104Sdes dllsearchpath= 6529238104Sdes lib_search_path=`pwd` 6530238104Sdes inst_prefix_dir= 6531238104Sdes new_inherited_linker_flags= 6532238104Sdes 6533238104Sdes avoid_version=no 6534238104Sdes bindir= 6535238104Sdes dlfiles= 6536238104Sdes dlprefiles= 6537238104Sdes dlself=no 6538238104Sdes export_dynamic=no 6539238104Sdes export_symbols= 6540238104Sdes export_symbols_regex= 6541238104Sdes generated= 6542238104Sdes libobjs= 6543238104Sdes ltlibs= 6544238104Sdes module=no 6545238104Sdes no_install=no 6546238104Sdes objs= 6547285206Sdes os2dllname= 6548238104Sdes non_pic_objects= 6549238104Sdes precious_files_regex= 6550238104Sdes prefer_static_libs=no 6551285206Sdes preload=false 6552238104Sdes prev= 6553238104Sdes prevarg= 6554238104Sdes release= 6555238104Sdes rpath= 6556238104Sdes xrpath= 6557238104Sdes perm_rpath= 6558238104Sdes temp_rpath= 6559238104Sdes thread_safe=no 6560238104Sdes vinfo= 6561238104Sdes vinfo_number=no 6562238104Sdes weak_libs= 6563285206Sdes single_module=$wl-single_module 6564238104Sdes func_infer_tag $base_compile 6565238104Sdes 6566238104Sdes # We need to know -static, to get the right output filenames. 6567238104Sdes for arg 6568238104Sdes do 6569238104Sdes case $arg in 6570238104Sdes -shared) 6571285206Sdes test yes != "$build_libtool_libs" \ 6572285206Sdes && func_fatal_configuration "cannot build a shared library" 6573238104Sdes build_old_libs=no 6574238104Sdes break 6575238104Sdes ;; 6576238104Sdes -all-static | -static | -static-libtool-libs) 6577238104Sdes case $arg in 6578238104Sdes -all-static) 6579285206Sdes if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580238104Sdes func_warning "complete static linking is impossible in this configuration" 6581238104Sdes fi 6582238104Sdes if test -n "$link_static_flag"; then 6583238104Sdes dlopen_self=$dlopen_self_static 6584238104Sdes fi 6585238104Sdes prefer_static_libs=yes 6586238104Sdes ;; 6587238104Sdes -static) 6588238104Sdes if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589238104Sdes dlopen_self=$dlopen_self_static 6590238104Sdes fi 6591238104Sdes prefer_static_libs=built 6592238104Sdes ;; 6593238104Sdes -static-libtool-libs) 6594238104Sdes if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595238104Sdes dlopen_self=$dlopen_self_static 6596238104Sdes fi 6597238104Sdes prefer_static_libs=yes 6598238104Sdes ;; 6599238104Sdes esac 6600238104Sdes build_libtool_libs=no 6601238104Sdes build_old_libs=yes 6602238104Sdes break 6603238104Sdes ;; 6604238104Sdes esac 6605238104Sdes done 6606238104Sdes 6607238104Sdes # See if our shared archives depend on static archives. 6608238104Sdes test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609238104Sdes 6610238104Sdes # Go through the arguments, transforming them on the way. 6611238104Sdes while test "$#" -gt 0; do 6612285206Sdes arg=$1 6613238104Sdes shift 6614238104Sdes func_quote_for_eval "$arg" 6615238104Sdes qarg=$func_quote_for_eval_unquoted_result 6616238104Sdes func_append libtool_args " $func_quote_for_eval_result" 6617238104Sdes 6618238104Sdes # If the previous option needs an argument, assign it. 6619238104Sdes if test -n "$prev"; then 6620238104Sdes case $prev in 6621238104Sdes output) 6622238104Sdes func_append compile_command " @OUTPUT@" 6623238104Sdes func_append finalize_command " @OUTPUT@" 6624238104Sdes ;; 6625238104Sdes esac 6626238104Sdes 6627238104Sdes case $prev in 6628238104Sdes bindir) 6629285206Sdes bindir=$arg 6630238104Sdes prev= 6631238104Sdes continue 6632238104Sdes ;; 6633238104Sdes dlfiles|dlprefiles) 6634285206Sdes $preload || { 6635238104Sdes # Add the symbol object into the linking commands. 6636238104Sdes func_append compile_command " @SYMFILE@" 6637238104Sdes func_append finalize_command " @SYMFILE@" 6638285206Sdes preload=: 6639285206Sdes } 6640238104Sdes case $arg in 6641238104Sdes *.la | *.lo) ;; # We handle these cases below. 6642238104Sdes force) 6643285206Sdes if test no = "$dlself"; then 6644238104Sdes dlself=needless 6645238104Sdes export_dynamic=yes 6646238104Sdes fi 6647238104Sdes prev= 6648238104Sdes continue 6649238104Sdes ;; 6650238104Sdes self) 6651285206Sdes if test dlprefiles = "$prev"; then 6652238104Sdes dlself=yes 6653285206Sdes elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654238104Sdes dlself=yes 6655238104Sdes else 6656238104Sdes dlself=needless 6657238104Sdes export_dynamic=yes 6658238104Sdes fi 6659238104Sdes prev= 6660238104Sdes continue 6661238104Sdes ;; 6662238104Sdes *) 6663285206Sdes if test dlfiles = "$prev"; then 6664238104Sdes func_append dlfiles " $arg" 6665238104Sdes else 6666238104Sdes func_append dlprefiles " $arg" 6667238104Sdes fi 6668238104Sdes prev= 6669238104Sdes continue 6670238104Sdes ;; 6671238104Sdes esac 6672238104Sdes ;; 6673238104Sdes expsyms) 6674285206Sdes export_symbols=$arg 6675238104Sdes test -f "$arg" \ 6676285206Sdes || func_fatal_error "symbol file '$arg' does not exist" 6677238104Sdes prev= 6678238104Sdes continue 6679238104Sdes ;; 6680238104Sdes expsyms_regex) 6681285206Sdes export_symbols_regex=$arg 6682238104Sdes prev= 6683238104Sdes continue 6684238104Sdes ;; 6685238104Sdes framework) 6686238104Sdes case $host in 6687238104Sdes *-*-darwin*) 6688238104Sdes case "$deplibs " in 6689238104Sdes *" $qarg.ltframework "*) ;; 6690238104Sdes *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691238104Sdes ;; 6692238104Sdes esac 6693238104Sdes ;; 6694238104Sdes esac 6695238104Sdes prev= 6696238104Sdes continue 6697238104Sdes ;; 6698238104Sdes inst_prefix) 6699285206Sdes inst_prefix_dir=$arg 6700238104Sdes prev= 6701238104Sdes continue 6702238104Sdes ;; 6703285206Sdes mllvm) 6704285206Sdes # Clang does not use LLVM to link, so we can simply discard any 6705285206Sdes # '-mllvm $arg' options when doing the link step. 6706285206Sdes prev= 6707285206Sdes continue 6708285206Sdes ;; 6709238104Sdes objectlist) 6710238104Sdes if test -f "$arg"; then 6711238104Sdes save_arg=$arg 6712238104Sdes moreargs= 6713238104Sdes for fil in `cat "$save_arg"` 6714238104Sdes do 6715238104Sdes# func_append moreargs " $fil" 6716238104Sdes arg=$fil 6717238104Sdes # A libtool-controlled object. 6718238104Sdes 6719238104Sdes # Check to see that this really is a libtool object. 6720238104Sdes if func_lalib_unsafe_p "$arg"; then 6721238104Sdes pic_object= 6722238104Sdes non_pic_object= 6723238104Sdes 6724238104Sdes # Read the .lo file 6725238104Sdes func_source "$arg" 6726238104Sdes 6727238104Sdes if test -z "$pic_object" || 6728238104Sdes test -z "$non_pic_object" || 6729285206Sdes test none = "$pic_object" && 6730285206Sdes test none = "$non_pic_object"; then 6731285206Sdes func_fatal_error "cannot find name of object for '$arg'" 6732238104Sdes fi 6733238104Sdes 6734238104Sdes # Extract subdirectory from the argument. 6735238104Sdes func_dirname "$arg" "/" "" 6736285206Sdes xdir=$func_dirname_result 6737238104Sdes 6738285206Sdes if test none != "$pic_object"; then 6739238104Sdes # Prepend the subdirectory the object is found in. 6740285206Sdes pic_object=$xdir$pic_object 6741238104Sdes 6742285206Sdes if test dlfiles = "$prev"; then 6743285206Sdes if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744238104Sdes func_append dlfiles " $pic_object" 6745238104Sdes prev= 6746238104Sdes continue 6747238104Sdes else 6748238104Sdes # If libtool objects are unsupported, then we need to preload. 6749238104Sdes prev=dlprefiles 6750238104Sdes fi 6751238104Sdes fi 6752238104Sdes 6753238104Sdes # CHECK ME: I think I busted this. -Ossama 6754285206Sdes if test dlprefiles = "$prev"; then 6755238104Sdes # Preload the old-style object. 6756238104Sdes func_append dlprefiles " $pic_object" 6757238104Sdes prev= 6758238104Sdes fi 6759238104Sdes 6760238104Sdes # A PIC object. 6761238104Sdes func_append libobjs " $pic_object" 6762285206Sdes arg=$pic_object 6763238104Sdes fi 6764238104Sdes 6765238104Sdes # Non-PIC object. 6766285206Sdes if test none != "$non_pic_object"; then 6767238104Sdes # Prepend the subdirectory the object is found in. 6768285206Sdes non_pic_object=$xdir$non_pic_object 6769238104Sdes 6770238104Sdes # A standard non-PIC object 6771238104Sdes func_append non_pic_objects " $non_pic_object" 6772285206Sdes if test -z "$pic_object" || test none = "$pic_object"; then 6773285206Sdes arg=$non_pic_object 6774238104Sdes fi 6775238104Sdes else 6776238104Sdes # If the PIC object exists, use it instead. 6777238104Sdes # $xdir was prepended to $pic_object above. 6778285206Sdes non_pic_object=$pic_object 6779238104Sdes func_append non_pic_objects " $non_pic_object" 6780238104Sdes fi 6781238104Sdes else 6782238104Sdes # Only an error if not doing a dry-run. 6783238104Sdes if $opt_dry_run; then 6784238104Sdes # Extract subdirectory from the argument. 6785238104Sdes func_dirname "$arg" "/" "" 6786285206Sdes xdir=$func_dirname_result 6787238104Sdes 6788238104Sdes func_lo2o "$arg" 6789238104Sdes pic_object=$xdir$objdir/$func_lo2o_result 6790238104Sdes non_pic_object=$xdir$func_lo2o_result 6791238104Sdes func_append libobjs " $pic_object" 6792238104Sdes func_append non_pic_objects " $non_pic_object" 6793238104Sdes else 6794285206Sdes func_fatal_error "'$arg' is not a valid libtool object" 6795238104Sdes fi 6796238104Sdes fi 6797238104Sdes done 6798238104Sdes else 6799285206Sdes func_fatal_error "link input file '$arg' does not exist" 6800238104Sdes fi 6801238104Sdes arg=$save_arg 6802238104Sdes prev= 6803238104Sdes continue 6804238104Sdes ;; 6805285206Sdes os2dllname) 6806285206Sdes os2dllname=$arg 6807285206Sdes prev= 6808285206Sdes continue 6809285206Sdes ;; 6810238104Sdes precious_regex) 6811285206Sdes precious_files_regex=$arg 6812238104Sdes prev= 6813238104Sdes continue 6814238104Sdes ;; 6815238104Sdes release) 6816285206Sdes release=-$arg 6817238104Sdes prev= 6818238104Sdes continue 6819238104Sdes ;; 6820238104Sdes rpath | xrpath) 6821238104Sdes # We need an absolute path. 6822238104Sdes case $arg in 6823238104Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 6824238104Sdes *) 6825238104Sdes func_fatal_error "only absolute run-paths are allowed" 6826238104Sdes ;; 6827238104Sdes esac 6828285206Sdes if test rpath = "$prev"; then 6829238104Sdes case "$rpath " in 6830238104Sdes *" $arg "*) ;; 6831238104Sdes *) func_append rpath " $arg" ;; 6832238104Sdes esac 6833238104Sdes else 6834238104Sdes case "$xrpath " in 6835238104Sdes *" $arg "*) ;; 6836238104Sdes *) func_append xrpath " $arg" ;; 6837238104Sdes esac 6838238104Sdes fi 6839238104Sdes prev= 6840238104Sdes continue 6841238104Sdes ;; 6842238104Sdes shrext) 6843285206Sdes shrext_cmds=$arg 6844238104Sdes prev= 6845238104Sdes continue 6846238104Sdes ;; 6847238104Sdes weak) 6848238104Sdes func_append weak_libs " $arg" 6849238104Sdes prev= 6850238104Sdes continue 6851238104Sdes ;; 6852238104Sdes xcclinker) 6853238104Sdes func_append linker_flags " $qarg" 6854238104Sdes func_append compiler_flags " $qarg" 6855238104Sdes prev= 6856238104Sdes func_append compile_command " $qarg" 6857238104Sdes func_append finalize_command " $qarg" 6858238104Sdes continue 6859238104Sdes ;; 6860238104Sdes xcompiler) 6861238104Sdes func_append compiler_flags " $qarg" 6862238104Sdes prev= 6863238104Sdes func_append compile_command " $qarg" 6864238104Sdes func_append finalize_command " $qarg" 6865238104Sdes continue 6866238104Sdes ;; 6867238104Sdes xlinker) 6868238104Sdes func_append linker_flags " $qarg" 6869238104Sdes func_append compiler_flags " $wl$qarg" 6870238104Sdes prev= 6871238104Sdes func_append compile_command " $wl$qarg" 6872238104Sdes func_append finalize_command " $wl$qarg" 6873238104Sdes continue 6874238104Sdes ;; 6875238104Sdes *) 6876238104Sdes eval "$prev=\"\$arg\"" 6877238104Sdes prev= 6878238104Sdes continue 6879238104Sdes ;; 6880238104Sdes esac 6881238104Sdes fi # test -n "$prev" 6882238104Sdes 6883285206Sdes prevarg=$arg 6884238104Sdes 6885238104Sdes case $arg in 6886238104Sdes -all-static) 6887238104Sdes if test -n "$link_static_flag"; then 6888238104Sdes # See comment for -static flag below, for more details. 6889238104Sdes func_append compile_command " $link_static_flag" 6890238104Sdes func_append finalize_command " $link_static_flag" 6891238104Sdes fi 6892238104Sdes continue 6893238104Sdes ;; 6894238104Sdes 6895238104Sdes -allow-undefined) 6896238104Sdes # FIXME: remove this flag sometime in the future. 6897285206Sdes func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898238104Sdes ;; 6899238104Sdes 6900238104Sdes -avoid-version) 6901238104Sdes avoid_version=yes 6902238104Sdes continue 6903238104Sdes ;; 6904238104Sdes 6905238104Sdes -bindir) 6906238104Sdes prev=bindir 6907238104Sdes continue 6908238104Sdes ;; 6909238104Sdes 6910238104Sdes -dlopen) 6911238104Sdes prev=dlfiles 6912238104Sdes continue 6913238104Sdes ;; 6914238104Sdes 6915238104Sdes -dlpreopen) 6916238104Sdes prev=dlprefiles 6917238104Sdes continue 6918238104Sdes ;; 6919238104Sdes 6920238104Sdes -export-dynamic) 6921238104Sdes export_dynamic=yes 6922238104Sdes continue 6923238104Sdes ;; 6924238104Sdes 6925238104Sdes -export-symbols | -export-symbols-regex) 6926238104Sdes if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927238104Sdes func_fatal_error "more than one -exported-symbols argument is not allowed" 6928238104Sdes fi 6929285206Sdes if test X-export-symbols = "X$arg"; then 6930238104Sdes prev=expsyms 6931238104Sdes else 6932238104Sdes prev=expsyms_regex 6933238104Sdes fi 6934238104Sdes continue 6935238104Sdes ;; 6936238104Sdes 6937238104Sdes -framework) 6938238104Sdes prev=framework 6939238104Sdes continue 6940238104Sdes ;; 6941238104Sdes 6942238104Sdes -inst-prefix-dir) 6943238104Sdes prev=inst_prefix 6944238104Sdes continue 6945238104Sdes ;; 6946238104Sdes 6947238104Sdes # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948238104Sdes # so, if we see these flags be careful not to treat them like -L 6949238104Sdes -L[A-Z][A-Z]*:*) 6950238104Sdes case $with_gcc/$host in 6951238104Sdes no/*-*-irix* | /*-*-irix*) 6952238104Sdes func_append compile_command " $arg" 6953238104Sdes func_append finalize_command " $arg" 6954238104Sdes ;; 6955238104Sdes esac 6956238104Sdes continue 6957238104Sdes ;; 6958238104Sdes 6959238104Sdes -L*) 6960238104Sdes func_stripname "-L" '' "$arg" 6961238104Sdes if test -z "$func_stripname_result"; then 6962238104Sdes if test "$#" -gt 0; then 6963285206Sdes func_fatal_error "require no space between '-L' and '$1'" 6964238104Sdes else 6965285206Sdes func_fatal_error "need path for '-L' option" 6966238104Sdes fi 6967238104Sdes fi 6968238104Sdes func_resolve_sysroot "$func_stripname_result" 6969238104Sdes dir=$func_resolve_sysroot_result 6970238104Sdes # We need an absolute path. 6971238104Sdes case $dir in 6972238104Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 6973238104Sdes *) 6974238104Sdes absdir=`cd "$dir" && pwd` 6975238104Sdes test -z "$absdir" && \ 6976285206Sdes func_fatal_error "cannot determine absolute directory name of '$dir'" 6977285206Sdes dir=$absdir 6978238104Sdes ;; 6979238104Sdes esac 6980238104Sdes case "$deplibs " in 6981238104Sdes *" -L$dir "* | *" $arg "*) 6982238104Sdes # Will only happen for absolute or sysroot arguments 6983238104Sdes ;; 6984238104Sdes *) 6985238104Sdes # Preserve sysroot, but never include relative directories 6986238104Sdes case $dir in 6987238104Sdes [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988238104Sdes *) func_append deplibs " -L$dir" ;; 6989238104Sdes esac 6990238104Sdes func_append lib_search_path " $dir" 6991238104Sdes ;; 6992238104Sdes esac 6993238104Sdes case $host in 6994238104Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995238104Sdes testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996238104Sdes case :$dllsearchpath: in 6997238104Sdes *":$dir:"*) ;; 6998238104Sdes ::) dllsearchpath=$dir;; 6999238104Sdes *) func_append dllsearchpath ":$dir";; 7000238104Sdes esac 7001238104Sdes case :$dllsearchpath: in 7002238104Sdes *":$testbindir:"*) ;; 7003238104Sdes ::) dllsearchpath=$testbindir;; 7004238104Sdes *) func_append dllsearchpath ":$testbindir";; 7005238104Sdes esac 7006238104Sdes ;; 7007238104Sdes esac 7008238104Sdes continue 7009238104Sdes ;; 7010238104Sdes 7011238104Sdes -l*) 7012285206Sdes if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013238104Sdes case $host in 7014238104Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015238104Sdes # These systems don't actually have a C or math library (as such) 7016238104Sdes continue 7017238104Sdes ;; 7018238104Sdes *-*-os2*) 7019238104Sdes # These systems don't actually have a C library (as such) 7020285206Sdes test X-lc = "X$arg" && continue 7021238104Sdes ;; 7022285206Sdes *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023238104Sdes # Do not include libc due to us having libc/libc_r. 7024285206Sdes test X-lc = "X$arg" && continue 7025238104Sdes ;; 7026238104Sdes *-*-rhapsody* | *-*-darwin1.[012]) 7027238104Sdes # Rhapsody C and math libraries are in the System framework 7028238104Sdes func_append deplibs " System.ltframework" 7029238104Sdes continue 7030238104Sdes ;; 7031238104Sdes *-*-sco3.2v5* | *-*-sco5v6*) 7032238104Sdes # Causes problems with __ctype 7033285206Sdes test X-lc = "X$arg" && continue 7034238104Sdes ;; 7035238104Sdes *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036238104Sdes # Compiler inserts libc in the correct place for threads to work 7037285206Sdes test X-lc = "X$arg" && continue 7038238104Sdes ;; 7039238104Sdes esac 7040285206Sdes elif test X-lc_r = "X$arg"; then 7041238104Sdes case $host in 7042285206Sdes *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043238104Sdes # Do not include libc_r directly, use -pthread flag. 7044238104Sdes continue 7045238104Sdes ;; 7046238104Sdes esac 7047238104Sdes fi 7048238104Sdes func_append deplibs " $arg" 7049238104Sdes continue 7050238104Sdes ;; 7051238104Sdes 7052285206Sdes -mllvm) 7053285206Sdes prev=mllvm 7054285206Sdes continue 7055285206Sdes ;; 7056285206Sdes 7057238104Sdes -module) 7058238104Sdes module=yes 7059238104Sdes continue 7060238104Sdes ;; 7061238104Sdes 7062238104Sdes # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063238104Sdes # classes, name mangling, and exception handling. 7064238104Sdes # Darwin uses the -arch flag to determine output architecture. 7065238104Sdes -model|-arch|-isysroot|--sysroot) 7066238104Sdes func_append compiler_flags " $arg" 7067238104Sdes func_append compile_command " $arg" 7068238104Sdes func_append finalize_command " $arg" 7069238104Sdes prev=xcompiler 7070238104Sdes continue 7071238104Sdes ;; 7072238104Sdes 7073238104Sdes -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074238104Sdes |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075238104Sdes func_append compiler_flags " $arg" 7076238104Sdes func_append compile_command " $arg" 7077238104Sdes func_append finalize_command " $arg" 7078238104Sdes case "$new_inherited_linker_flags " in 7079238104Sdes *" $arg "*) ;; 7080238104Sdes * ) func_append new_inherited_linker_flags " $arg" ;; 7081238104Sdes esac 7082238104Sdes continue 7083238104Sdes ;; 7084238104Sdes 7085238104Sdes -multi_module) 7086285206Sdes single_module=$wl-multi_module 7087238104Sdes continue 7088238104Sdes ;; 7089238104Sdes 7090238104Sdes -no-fast-install) 7091238104Sdes fast_install=no 7092238104Sdes continue 7093238104Sdes ;; 7094238104Sdes 7095238104Sdes -no-install) 7096238104Sdes case $host in 7097238104Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098238104Sdes # The PATH hackery in wrapper scripts is required on Windows 7099238104Sdes # and Darwin in order for the loader to find any dlls it needs. 7100285206Sdes func_warning "'-no-install' is ignored for $host" 7101285206Sdes func_warning "assuming '-no-fast-install' instead" 7102238104Sdes fast_install=no 7103238104Sdes ;; 7104238104Sdes *) no_install=yes ;; 7105238104Sdes esac 7106238104Sdes continue 7107238104Sdes ;; 7108238104Sdes 7109238104Sdes -no-undefined) 7110238104Sdes allow_undefined=no 7111238104Sdes continue 7112238104Sdes ;; 7113238104Sdes 7114238104Sdes -objectlist) 7115238104Sdes prev=objectlist 7116238104Sdes continue 7117238104Sdes ;; 7118238104Sdes 7119285206Sdes -os2dllname) 7120285206Sdes prev=os2dllname 7121285206Sdes continue 7122285206Sdes ;; 7123285206Sdes 7124238104Sdes -o) prev=output ;; 7125238104Sdes 7126238104Sdes -precious-files-regex) 7127238104Sdes prev=precious_regex 7128238104Sdes continue 7129238104Sdes ;; 7130238104Sdes 7131238104Sdes -release) 7132238104Sdes prev=release 7133238104Sdes continue 7134238104Sdes ;; 7135238104Sdes 7136238104Sdes -rpath) 7137238104Sdes prev=rpath 7138238104Sdes continue 7139238104Sdes ;; 7140238104Sdes 7141238104Sdes -R) 7142238104Sdes prev=xrpath 7143238104Sdes continue 7144238104Sdes ;; 7145238104Sdes 7146238104Sdes -R*) 7147238104Sdes func_stripname '-R' '' "$arg" 7148238104Sdes dir=$func_stripname_result 7149238104Sdes # We need an absolute path. 7150238104Sdes case $dir in 7151238104Sdes [\\/]* | [A-Za-z]:[\\/]*) ;; 7152238104Sdes =*) 7153238104Sdes func_stripname '=' '' "$dir" 7154238104Sdes dir=$lt_sysroot$func_stripname_result 7155238104Sdes ;; 7156238104Sdes *) 7157238104Sdes func_fatal_error "only absolute run-paths are allowed" 7158238104Sdes ;; 7159238104Sdes esac 7160238104Sdes case "$xrpath " in 7161238104Sdes *" $dir "*) ;; 7162238104Sdes *) func_append xrpath " $dir" ;; 7163238104Sdes esac 7164238104Sdes continue 7165238104Sdes ;; 7166238104Sdes 7167238104Sdes -shared) 7168238104Sdes # The effects of -shared are defined in a previous loop. 7169238104Sdes continue 7170238104Sdes ;; 7171238104Sdes 7172238104Sdes -shrext) 7173238104Sdes prev=shrext 7174238104Sdes continue 7175238104Sdes ;; 7176238104Sdes 7177238104Sdes -static | -static-libtool-libs) 7178238104Sdes # The effects of -static are defined in a previous loop. 7179238104Sdes # We used to do the same as -all-static on platforms that 7180238104Sdes # didn't have a PIC flag, but the assumption that the effects 7181238104Sdes # would be equivalent was wrong. It would break on at least 7182238104Sdes # Digital Unix and AIX. 7183238104Sdes continue 7184238104Sdes ;; 7185238104Sdes 7186238104Sdes -thread-safe) 7187238104Sdes thread_safe=yes 7188238104Sdes continue 7189238104Sdes ;; 7190238104Sdes 7191238104Sdes -version-info) 7192238104Sdes prev=vinfo 7193238104Sdes continue 7194238104Sdes ;; 7195238104Sdes 7196238104Sdes -version-number) 7197238104Sdes prev=vinfo 7198238104Sdes vinfo_number=yes 7199238104Sdes continue 7200238104Sdes ;; 7201238104Sdes 7202238104Sdes -weak) 7203238104Sdes prev=weak 7204238104Sdes continue 7205238104Sdes ;; 7206238104Sdes 7207238104Sdes -Wc,*) 7208238104Sdes func_stripname '-Wc,' '' "$arg" 7209238104Sdes args=$func_stripname_result 7210238104Sdes arg= 7211285206Sdes save_ifs=$IFS; IFS=, 7212238104Sdes for flag in $args; do 7213285206Sdes IFS=$save_ifs 7214238104Sdes func_quote_for_eval "$flag" 7215238104Sdes func_append arg " $func_quote_for_eval_result" 7216238104Sdes func_append compiler_flags " $func_quote_for_eval_result" 7217238104Sdes done 7218285206Sdes IFS=$save_ifs 7219238104Sdes func_stripname ' ' '' "$arg" 7220238104Sdes arg=$func_stripname_result 7221238104Sdes ;; 7222238104Sdes 7223238104Sdes -Wl,*) 7224238104Sdes func_stripname '-Wl,' '' "$arg" 7225238104Sdes args=$func_stripname_result 7226238104Sdes arg= 7227285206Sdes save_ifs=$IFS; IFS=, 7228238104Sdes for flag in $args; do 7229285206Sdes IFS=$save_ifs 7230238104Sdes func_quote_for_eval "$flag" 7231238104Sdes func_append arg " $wl$func_quote_for_eval_result" 7232238104Sdes func_append compiler_flags " $wl$func_quote_for_eval_result" 7233238104Sdes func_append linker_flags " $func_quote_for_eval_result" 7234238104Sdes done 7235285206Sdes IFS=$save_ifs 7236238104Sdes func_stripname ' ' '' "$arg" 7237238104Sdes arg=$func_stripname_result 7238238104Sdes ;; 7239238104Sdes 7240238104Sdes -Xcompiler) 7241238104Sdes prev=xcompiler 7242238104Sdes continue 7243238104Sdes ;; 7244238104Sdes 7245238104Sdes -Xlinker) 7246238104Sdes prev=xlinker 7247238104Sdes continue 7248238104Sdes ;; 7249238104Sdes 7250238104Sdes -XCClinker) 7251238104Sdes prev=xcclinker 7252238104Sdes continue 7253238104Sdes ;; 7254238104Sdes 7255238104Sdes # -msg_* for osf cc 7256238104Sdes -msg_*) 7257238104Sdes func_quote_for_eval "$arg" 7258285206Sdes arg=$func_quote_for_eval_result 7259238104Sdes ;; 7260238104Sdes 7261238104Sdes # Flags to be passed through unchanged, with rationale: 7262238104Sdes # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263238104Sdes # -r[0-9][0-9]* specify processor for the SGI compiler 7264238104Sdes # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265238104Sdes # +DA*, +DD* enable 64-bit mode for the HP compiler 7266238104Sdes # -q* compiler args for the IBM compiler 7267238104Sdes # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268238104Sdes # -F/path path to uninstalled frameworks, gcc on darwin 7269238104Sdes # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270285206Sdes # -fstack-protector* stack protector flags for GCC 7271238104Sdes # @file GCC response files 7272238104Sdes # -tp=* Portland pgcc target processor selection 7273238104Sdes # --sysroot=* for sysroot support 7274285206Sdes # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275285206Sdes # -stdlib=* select c++ std lib with clang 7276238104Sdes -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7277238104Sdes -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7278285206Sdes -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7279238104Sdes func_quote_for_eval "$arg" 7280285206Sdes arg=$func_quote_for_eval_result 7281238104Sdes func_append compile_command " $arg" 7282238104Sdes func_append finalize_command " $arg" 7283238104Sdes func_append compiler_flags " $arg" 7284238104Sdes continue 7285238104Sdes ;; 7286238104Sdes 7287285206Sdes -Z*) 7288285206Sdes if test os2 = "`expr $host : '.*\(os2\)'`"; then 7289285206Sdes # OS/2 uses -Zxxx to specify OS/2-specific options 7290285206Sdes compiler_flags="$compiler_flags $arg" 7291285206Sdes func_append compile_command " $arg" 7292285206Sdes func_append finalize_command " $arg" 7293285206Sdes case $arg in 7294285206Sdes -Zlinker | -Zstack) 7295285206Sdes prev=xcompiler 7296285206Sdes ;; 7297285206Sdes esac 7298285206Sdes continue 7299285206Sdes else 7300285206Sdes # Otherwise treat like 'Some other compiler flag' below 7301285206Sdes func_quote_for_eval "$arg" 7302285206Sdes arg=$func_quote_for_eval_result 7303285206Sdes fi 7304285206Sdes ;; 7305285206Sdes 7306238104Sdes # Some other compiler flag. 7307238104Sdes -* | +*) 7308238104Sdes func_quote_for_eval "$arg" 7309285206Sdes arg=$func_quote_for_eval_result 7310238104Sdes ;; 7311238104Sdes 7312238104Sdes *.$objext) 7313238104Sdes # A standard object. 7314238104Sdes func_append objs " $arg" 7315238104Sdes ;; 7316238104Sdes 7317238104Sdes *.lo) 7318238104Sdes # A libtool-controlled object. 7319238104Sdes 7320238104Sdes # Check to see that this really is a libtool object. 7321238104Sdes if func_lalib_unsafe_p "$arg"; then 7322238104Sdes pic_object= 7323238104Sdes non_pic_object= 7324238104Sdes 7325238104Sdes # Read the .lo file 7326238104Sdes func_source "$arg" 7327238104Sdes 7328238104Sdes if test -z "$pic_object" || 7329238104Sdes test -z "$non_pic_object" || 7330285206Sdes test none = "$pic_object" && 7331285206Sdes test none = "$non_pic_object"; then 7332285206Sdes func_fatal_error "cannot find name of object for '$arg'" 7333238104Sdes fi 7334238104Sdes 7335238104Sdes # Extract subdirectory from the argument. 7336238104Sdes func_dirname "$arg" "/" "" 7337285206Sdes xdir=$func_dirname_result 7338238104Sdes 7339285206Sdes test none = "$pic_object" || { 7340238104Sdes # Prepend the subdirectory the object is found in. 7341285206Sdes pic_object=$xdir$pic_object 7342238104Sdes 7343285206Sdes if test dlfiles = "$prev"; then 7344285206Sdes if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7345238104Sdes func_append dlfiles " $pic_object" 7346238104Sdes prev= 7347238104Sdes continue 7348238104Sdes else 7349238104Sdes # If libtool objects are unsupported, then we need to preload. 7350238104Sdes prev=dlprefiles 7351238104Sdes fi 7352238104Sdes fi 7353238104Sdes 7354238104Sdes # CHECK ME: I think I busted this. -Ossama 7355285206Sdes if test dlprefiles = "$prev"; then 7356238104Sdes # Preload the old-style object. 7357238104Sdes func_append dlprefiles " $pic_object" 7358238104Sdes prev= 7359238104Sdes fi 7360238104Sdes 7361238104Sdes # A PIC object. 7362238104Sdes func_append libobjs " $pic_object" 7363285206Sdes arg=$pic_object 7364285206Sdes } 7365238104Sdes 7366238104Sdes # Non-PIC object. 7367285206Sdes if test none != "$non_pic_object"; then 7368238104Sdes # Prepend the subdirectory the object is found in. 7369285206Sdes non_pic_object=$xdir$non_pic_object 7370238104Sdes 7371238104Sdes # A standard non-PIC object 7372238104Sdes func_append non_pic_objects " $non_pic_object" 7373285206Sdes if test -z "$pic_object" || test none = "$pic_object"; then 7374285206Sdes arg=$non_pic_object 7375238104Sdes fi 7376238104Sdes else 7377238104Sdes # If the PIC object exists, use it instead. 7378238104Sdes # $xdir was prepended to $pic_object above. 7379285206Sdes non_pic_object=$pic_object 7380238104Sdes func_append non_pic_objects " $non_pic_object" 7381238104Sdes fi 7382238104Sdes else 7383238104Sdes # Only an error if not doing a dry-run. 7384238104Sdes if $opt_dry_run; then 7385238104Sdes # Extract subdirectory from the argument. 7386238104Sdes func_dirname "$arg" "/" "" 7387285206Sdes xdir=$func_dirname_result 7388238104Sdes 7389238104Sdes func_lo2o "$arg" 7390238104Sdes pic_object=$xdir$objdir/$func_lo2o_result 7391238104Sdes non_pic_object=$xdir$func_lo2o_result 7392238104Sdes func_append libobjs " $pic_object" 7393238104Sdes func_append non_pic_objects " $non_pic_object" 7394238104Sdes else 7395285206Sdes func_fatal_error "'$arg' is not a valid libtool object" 7396238104Sdes fi 7397238104Sdes fi 7398238104Sdes ;; 7399238104Sdes 7400238104Sdes *.$libext) 7401238104Sdes # An archive. 7402238104Sdes func_append deplibs " $arg" 7403238104Sdes func_append old_deplibs " $arg" 7404238104Sdes continue 7405238104Sdes ;; 7406238104Sdes 7407238104Sdes *.la) 7408238104Sdes # A libtool-controlled library. 7409238104Sdes 7410238104Sdes func_resolve_sysroot "$arg" 7411285206Sdes if test dlfiles = "$prev"; then 7412238104Sdes # This library was specified with -dlopen. 7413238104Sdes func_append dlfiles " $func_resolve_sysroot_result" 7414238104Sdes prev= 7415285206Sdes elif test dlprefiles = "$prev"; then 7416238104Sdes # The library was specified with -dlpreopen. 7417238104Sdes func_append dlprefiles " $func_resolve_sysroot_result" 7418238104Sdes prev= 7419238104Sdes else 7420238104Sdes func_append deplibs " $func_resolve_sysroot_result" 7421238104Sdes fi 7422238104Sdes continue 7423238104Sdes ;; 7424238104Sdes 7425238104Sdes # Some other compiler argument. 7426238104Sdes *) 7427238104Sdes # Unknown arguments in both finalize_command and compile_command need 7428238104Sdes # to be aesthetically quoted because they are evaled later. 7429238104Sdes func_quote_for_eval "$arg" 7430285206Sdes arg=$func_quote_for_eval_result 7431238104Sdes ;; 7432238104Sdes esac # arg 7433238104Sdes 7434238104Sdes # Now actually substitute the argument into the commands. 7435238104Sdes if test -n "$arg"; then 7436238104Sdes func_append compile_command " $arg" 7437238104Sdes func_append finalize_command " $arg" 7438238104Sdes fi 7439238104Sdes done # argument parsing loop 7440238104Sdes 7441238104Sdes test -n "$prev" && \ 7442285206Sdes func_fatal_help "the '$prevarg' option requires an argument" 7443238104Sdes 7444285206Sdes if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7445238104Sdes eval arg=\"$export_dynamic_flag_spec\" 7446238104Sdes func_append compile_command " $arg" 7447238104Sdes func_append finalize_command " $arg" 7448238104Sdes fi 7449238104Sdes 7450238104Sdes oldlibs= 7451238104Sdes # calculate the name of the file, without its directory 7452238104Sdes func_basename "$output" 7453285206Sdes outputname=$func_basename_result 7454285206Sdes libobjs_save=$libobjs 7455238104Sdes 7456238104Sdes if test -n "$shlibpath_var"; then 7457238104Sdes # get the directories listed in $shlibpath_var 7458285206Sdes eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7459238104Sdes else 7460238104Sdes shlib_search_path= 7461238104Sdes fi 7462238104Sdes eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7463238104Sdes eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7464238104Sdes 7465285206Sdes # Definition is injected by LT_CONFIG during libtool generation. 7466285206Sdes func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7467285206Sdes 7468238104Sdes func_dirname "$output" "/" "" 7469285206Sdes output_objdir=$func_dirname_result$objdir 7470238104Sdes func_to_tool_file "$output_objdir/" 7471238104Sdes tool_output_objdir=$func_to_tool_file_result 7472238104Sdes # Create the object directory. 7473238104Sdes func_mkdir_p "$output_objdir" 7474238104Sdes 7475238104Sdes # Determine the type of output 7476238104Sdes case $output in 7477238104Sdes "") 7478238104Sdes func_fatal_help "you must specify an output file" 7479238104Sdes ;; 7480238104Sdes *.$libext) linkmode=oldlib ;; 7481238104Sdes *.lo | *.$objext) linkmode=obj ;; 7482238104Sdes *.la) linkmode=lib ;; 7483238104Sdes *) linkmode=prog ;; # Anything else should be a program. 7484238104Sdes esac 7485238104Sdes 7486238104Sdes specialdeplibs= 7487238104Sdes 7488238104Sdes libs= 7489238104Sdes # Find all interdependent deplibs by searching for libraries 7490238104Sdes # that are linked more than once (e.g. -la -lb -la) 7491238104Sdes for deplib in $deplibs; do 7492285206Sdes if $opt_preserve_dup_deps; then 7493238104Sdes case "$libs " in 7494238104Sdes *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7495238104Sdes esac 7496238104Sdes fi 7497238104Sdes func_append libs " $deplib" 7498238104Sdes done 7499238104Sdes 7500285206Sdes if test lib = "$linkmode"; then 7501238104Sdes libs="$predeps $libs $compiler_lib_search_path $postdeps" 7502238104Sdes 7503238104Sdes # Compute libraries that are listed more than once in $predeps 7504238104Sdes # $postdeps and mark them as special (i.e., whose duplicates are 7505238104Sdes # not to be eliminated). 7506238104Sdes pre_post_deps= 7507238104Sdes if $opt_duplicate_compiler_generated_deps; then 7508238104Sdes for pre_post_dep in $predeps $postdeps; do 7509238104Sdes case "$pre_post_deps " in 7510238104Sdes *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7511238104Sdes esac 7512238104Sdes func_append pre_post_deps " $pre_post_dep" 7513238104Sdes done 7514238104Sdes fi 7515238104Sdes pre_post_deps= 7516238104Sdes fi 7517238104Sdes 7518238104Sdes deplibs= 7519238104Sdes newdependency_libs= 7520238104Sdes newlib_search_path= 7521238104Sdes need_relink=no # whether we're linking any uninstalled libtool libraries 7522238104Sdes notinst_deplibs= # not-installed libtool libraries 7523238104Sdes notinst_path= # paths that contain not-installed libtool libraries 7524238104Sdes 7525238104Sdes case $linkmode in 7526238104Sdes lib) 7527238104Sdes passes="conv dlpreopen link" 7528238104Sdes for file in $dlfiles $dlprefiles; do 7529238104Sdes case $file in 7530238104Sdes *.la) ;; 7531238104Sdes *) 7532285206Sdes func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7533238104Sdes ;; 7534238104Sdes esac 7535238104Sdes done 7536238104Sdes ;; 7537238104Sdes prog) 7538238104Sdes compile_deplibs= 7539238104Sdes finalize_deplibs= 7540285206Sdes alldeplibs=false 7541238104Sdes newdlfiles= 7542238104Sdes newdlprefiles= 7543238104Sdes passes="conv scan dlopen dlpreopen link" 7544238104Sdes ;; 7545238104Sdes *) passes="conv" 7546238104Sdes ;; 7547238104Sdes esac 7548238104Sdes 7549238104Sdes for pass in $passes; do 7550238104Sdes # The preopen pass in lib mode reverses $deplibs; put it back here 7551238104Sdes # so that -L comes before libs that need it for instance... 7552285206Sdes if test lib,link = "$linkmode,$pass"; then 7553238104Sdes ## FIXME: Find the place where the list is rebuilt in the wrong 7554238104Sdes ## order, and fix it there properly 7555238104Sdes tmp_deplibs= 7556238104Sdes for deplib in $deplibs; do 7557238104Sdes tmp_deplibs="$deplib $tmp_deplibs" 7558238104Sdes done 7559285206Sdes deplibs=$tmp_deplibs 7560238104Sdes fi 7561238104Sdes 7562285206Sdes if test lib,link = "$linkmode,$pass" || 7563285206Sdes test prog,scan = "$linkmode,$pass"; then 7564285206Sdes libs=$deplibs 7565238104Sdes deplibs= 7566238104Sdes fi 7567285206Sdes if test prog = "$linkmode"; then 7568238104Sdes case $pass in 7569285206Sdes dlopen) libs=$dlfiles ;; 7570285206Sdes dlpreopen) libs=$dlprefiles ;; 7571285206Sdes link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7572238104Sdes esac 7573238104Sdes fi 7574285206Sdes if test lib,dlpreopen = "$linkmode,$pass"; then 7575238104Sdes # Collect and forward deplibs of preopened libtool libs 7576238104Sdes for lib in $dlprefiles; do 7577238104Sdes # Ignore non-libtool-libs 7578238104Sdes dependency_libs= 7579238104Sdes func_resolve_sysroot "$lib" 7580238104Sdes case $lib in 7581238104Sdes *.la) func_source "$func_resolve_sysroot_result" ;; 7582238104Sdes esac 7583238104Sdes 7584238104Sdes # Collect preopened libtool deplibs, except any this library 7585238104Sdes # has declared as weak libs 7586238104Sdes for deplib in $dependency_libs; do 7587238104Sdes func_basename "$deplib" 7588238104Sdes deplib_base=$func_basename_result 7589238104Sdes case " $weak_libs " in 7590238104Sdes *" $deplib_base "*) ;; 7591238104Sdes *) func_append deplibs " $deplib" ;; 7592238104Sdes esac 7593238104Sdes done 7594238104Sdes done 7595285206Sdes libs=$dlprefiles 7596238104Sdes fi 7597285206Sdes if test dlopen = "$pass"; then 7598238104Sdes # Collect dlpreopened libraries 7599285206Sdes save_deplibs=$deplibs 7600238104Sdes deplibs= 7601238104Sdes fi 7602238104Sdes 7603238104Sdes for deplib in $libs; do 7604238104Sdes lib= 7605285206Sdes found=false 7606238104Sdes case $deplib in 7607238104Sdes -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608238104Sdes |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7609285206Sdes if test prog,link = "$linkmode,$pass"; then 7610238104Sdes compile_deplibs="$deplib $compile_deplibs" 7611238104Sdes finalize_deplibs="$deplib $finalize_deplibs" 7612238104Sdes else 7613238104Sdes func_append compiler_flags " $deplib" 7614285206Sdes if test lib = "$linkmode"; then 7615238104Sdes case "$new_inherited_linker_flags " in 7616238104Sdes *" $deplib "*) ;; 7617238104Sdes * ) func_append new_inherited_linker_flags " $deplib" ;; 7618238104Sdes esac 7619238104Sdes fi 7620238104Sdes fi 7621238104Sdes continue 7622238104Sdes ;; 7623238104Sdes -l*) 7624285206Sdes if test lib != "$linkmode" && test prog != "$linkmode"; then 7625285206Sdes func_warning "'-l' is ignored for archives/objects" 7626238104Sdes continue 7627238104Sdes fi 7628238104Sdes func_stripname '-l' '' "$deplib" 7629238104Sdes name=$func_stripname_result 7630285206Sdes if test lib = "$linkmode"; then 7631238104Sdes searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7632238104Sdes else 7633238104Sdes searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7634238104Sdes fi 7635238104Sdes for searchdir in $searchdirs; do 7636238104Sdes for search_ext in .la $std_shrext .so .a; do 7637238104Sdes # Search the libtool library 7638285206Sdes lib=$searchdir/lib$name$search_ext 7639238104Sdes if test -f "$lib"; then 7640285206Sdes if test .la = "$search_ext"; then 7641285206Sdes found=: 7642238104Sdes else 7643285206Sdes found=false 7644238104Sdes fi 7645238104Sdes break 2 7646238104Sdes fi 7647238104Sdes done 7648238104Sdes done 7649285206Sdes if $found; then 7650285206Sdes # deplib is a libtool library 7651238104Sdes # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7652238104Sdes # We need to do some special things here, and not later. 7653285206Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7654238104Sdes case " $predeps $postdeps " in 7655238104Sdes *" $deplib "*) 7656238104Sdes if func_lalib_p "$lib"; then 7657238104Sdes library_names= 7658238104Sdes old_library= 7659238104Sdes func_source "$lib" 7660238104Sdes for l in $old_library $library_names; do 7661285206Sdes ll=$l 7662238104Sdes done 7663285206Sdes if test "X$ll" = "X$old_library"; then # only static version available 7664285206Sdes found=false 7665238104Sdes func_dirname "$lib" "" "." 7666285206Sdes ladir=$func_dirname_result 7667238104Sdes lib=$ladir/$old_library 7668285206Sdes if test prog,link = "$linkmode,$pass"; then 7669238104Sdes compile_deplibs="$deplib $compile_deplibs" 7670238104Sdes finalize_deplibs="$deplib $finalize_deplibs" 7671238104Sdes else 7672238104Sdes deplibs="$deplib $deplibs" 7673285206Sdes test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7674238104Sdes fi 7675238104Sdes continue 7676238104Sdes fi 7677238104Sdes fi 7678238104Sdes ;; 7679238104Sdes *) ;; 7680238104Sdes esac 7681238104Sdes fi 7682285206Sdes else 7683285206Sdes # deplib doesn't seem to be a libtool library 7684285206Sdes if test prog,link = "$linkmode,$pass"; then 7685285206Sdes compile_deplibs="$deplib $compile_deplibs" 7686285206Sdes finalize_deplibs="$deplib $finalize_deplibs" 7687285206Sdes else 7688285206Sdes deplibs="$deplib $deplibs" 7689285206Sdes test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7690285206Sdes fi 7691285206Sdes continue 7692238104Sdes fi 7693238104Sdes ;; # -l 7694238104Sdes *.ltframework) 7695285206Sdes if test prog,link = "$linkmode,$pass"; then 7696238104Sdes compile_deplibs="$deplib $compile_deplibs" 7697238104Sdes finalize_deplibs="$deplib $finalize_deplibs" 7698238104Sdes else 7699238104Sdes deplibs="$deplib $deplibs" 7700285206Sdes if test lib = "$linkmode"; then 7701238104Sdes case "$new_inherited_linker_flags " in 7702238104Sdes *" $deplib "*) ;; 7703238104Sdes * ) func_append new_inherited_linker_flags " $deplib" ;; 7704238104Sdes esac 7705238104Sdes fi 7706238104Sdes fi 7707238104Sdes continue 7708238104Sdes ;; 7709238104Sdes -L*) 7710238104Sdes case $linkmode in 7711238104Sdes lib) 7712238104Sdes deplibs="$deplib $deplibs" 7713285206Sdes test conv = "$pass" && continue 7714238104Sdes newdependency_libs="$deplib $newdependency_libs" 7715238104Sdes func_stripname '-L' '' "$deplib" 7716238104Sdes func_resolve_sysroot "$func_stripname_result" 7717238104Sdes func_append newlib_search_path " $func_resolve_sysroot_result" 7718238104Sdes ;; 7719238104Sdes prog) 7720285206Sdes if test conv = "$pass"; then 7721238104Sdes deplibs="$deplib $deplibs" 7722238104Sdes continue 7723238104Sdes fi 7724285206Sdes if test scan = "$pass"; then 7725238104Sdes deplibs="$deplib $deplibs" 7726238104Sdes else 7727238104Sdes compile_deplibs="$deplib $compile_deplibs" 7728238104Sdes finalize_deplibs="$deplib $finalize_deplibs" 7729238104Sdes fi 7730238104Sdes func_stripname '-L' '' "$deplib" 7731238104Sdes func_resolve_sysroot "$func_stripname_result" 7732238104Sdes func_append newlib_search_path " $func_resolve_sysroot_result" 7733238104Sdes ;; 7734238104Sdes *) 7735285206Sdes func_warning "'-L' is ignored for archives/objects" 7736238104Sdes ;; 7737238104Sdes esac # linkmode 7738238104Sdes continue 7739238104Sdes ;; # -L 7740238104Sdes -R*) 7741285206Sdes if test link = "$pass"; then 7742238104Sdes func_stripname '-R' '' "$deplib" 7743238104Sdes func_resolve_sysroot "$func_stripname_result" 7744238104Sdes dir=$func_resolve_sysroot_result 7745238104Sdes # Make sure the xrpath contains only unique directories. 7746238104Sdes case "$xrpath " in 7747238104Sdes *" $dir "*) ;; 7748238104Sdes *) func_append xrpath " $dir" ;; 7749238104Sdes esac 7750238104Sdes fi 7751238104Sdes deplibs="$deplib $deplibs" 7752238104Sdes continue 7753238104Sdes ;; 7754238104Sdes *.la) 7755238104Sdes func_resolve_sysroot "$deplib" 7756238104Sdes lib=$func_resolve_sysroot_result 7757238104Sdes ;; 7758238104Sdes *.$libext) 7759285206Sdes if test conv = "$pass"; then 7760238104Sdes deplibs="$deplib $deplibs" 7761238104Sdes continue 7762238104Sdes fi 7763238104Sdes case $linkmode in 7764238104Sdes lib) 7765238104Sdes # Linking convenience modules into shared libraries is allowed, 7766238104Sdes # but linking other static libraries is non-portable. 7767238104Sdes case " $dlpreconveniencelibs " in 7768238104Sdes *" $deplib "*) ;; 7769238104Sdes *) 7770285206Sdes valid_a_lib=false 7771238104Sdes case $deplibs_check_method in 7772238104Sdes match_pattern*) 7773238104Sdes set dummy $deplibs_check_method; shift 7774238104Sdes match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7775238104Sdes if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7776238104Sdes | $EGREP "$match_pattern_regex" > /dev/null; then 7777285206Sdes valid_a_lib=: 7778238104Sdes fi 7779238104Sdes ;; 7780238104Sdes pass_all) 7781285206Sdes valid_a_lib=: 7782238104Sdes ;; 7783238104Sdes esac 7784285206Sdes if $valid_a_lib; then 7785238104Sdes echo 7786285206Sdes $ECHO "*** Warning: Linking the shared library $output against the" 7787285206Sdes $ECHO "*** static library $deplib is not portable!" 7788285206Sdes deplibs="$deplib $deplibs" 7789285206Sdes else 7790285206Sdes echo 7791238104Sdes $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7792238104Sdes echo "*** I have the capability to make that library automatically link in when" 7793238104Sdes echo "*** you link to this library. But I can only do this if you have a" 7794238104Sdes echo "*** shared version of the library, which you do not appear to have" 7795238104Sdes echo "*** because the file extensions .$libext of this argument makes me believe" 7796238104Sdes echo "*** that it is just a static archive that I should not use here." 7797238104Sdes fi 7798238104Sdes ;; 7799238104Sdes esac 7800238104Sdes continue 7801238104Sdes ;; 7802238104Sdes prog) 7803285206Sdes if test link != "$pass"; then 7804238104Sdes deplibs="$deplib $deplibs" 7805238104Sdes else 7806238104Sdes compile_deplibs="$deplib $compile_deplibs" 7807238104Sdes finalize_deplibs="$deplib $finalize_deplibs" 7808238104Sdes fi 7809238104Sdes continue 7810238104Sdes ;; 7811238104Sdes esac # linkmode 7812238104Sdes ;; # *.$libext 7813238104Sdes *.lo | *.$objext) 7814285206Sdes if test conv = "$pass"; then 7815238104Sdes deplibs="$deplib $deplibs" 7816285206Sdes elif test prog = "$linkmode"; then 7817285206Sdes if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7818238104Sdes # If there is no dlopen support or we're linking statically, 7819238104Sdes # we need to preload. 7820238104Sdes func_append newdlprefiles " $deplib" 7821238104Sdes compile_deplibs="$deplib $compile_deplibs" 7822238104Sdes finalize_deplibs="$deplib $finalize_deplibs" 7823238104Sdes else 7824238104Sdes func_append newdlfiles " $deplib" 7825238104Sdes fi 7826238104Sdes fi 7827238104Sdes continue 7828238104Sdes ;; 7829238104Sdes %DEPLIBS%) 7830285206Sdes alldeplibs=: 7831238104Sdes continue 7832238104Sdes ;; 7833238104Sdes esac # case $deplib 7834238104Sdes 7835285206Sdes $found || test -f "$lib" \ 7836285206Sdes || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7837238104Sdes 7838238104Sdes # Check to see that this really is a libtool archive. 7839238104Sdes func_lalib_unsafe_p "$lib" \ 7840285206Sdes || func_fatal_error "'$lib' is not a valid libtool archive" 7841238104Sdes 7842238104Sdes func_dirname "$lib" "" "." 7843285206Sdes ladir=$func_dirname_result 7844238104Sdes 7845238104Sdes dlname= 7846238104Sdes dlopen= 7847238104Sdes dlpreopen= 7848238104Sdes libdir= 7849238104Sdes library_names= 7850238104Sdes old_library= 7851238104Sdes inherited_linker_flags= 7852238104Sdes # If the library was installed with an old release of libtool, 7853238104Sdes # it will not redefine variables installed, or shouldnotlink 7854238104Sdes installed=yes 7855238104Sdes shouldnotlink=no 7856238104Sdes avoidtemprpath= 7857238104Sdes 7858238104Sdes 7859238104Sdes # Read the .la file 7860238104Sdes func_source "$lib" 7861238104Sdes 7862238104Sdes # Convert "-framework foo" to "foo.ltframework" 7863238104Sdes if test -n "$inherited_linker_flags"; then 7864238104Sdes tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7865238104Sdes for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7866238104Sdes case " $new_inherited_linker_flags " in 7867238104Sdes *" $tmp_inherited_linker_flag "*) ;; 7868238104Sdes *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7869238104Sdes esac 7870238104Sdes done 7871238104Sdes fi 7872238104Sdes dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7873285206Sdes if test lib,link = "$linkmode,$pass" || 7874285206Sdes test prog,scan = "$linkmode,$pass" || 7875285206Sdes { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7876238104Sdes test -n "$dlopen" && func_append dlfiles " $dlopen" 7877238104Sdes test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7878238104Sdes fi 7879238104Sdes 7880285206Sdes if test conv = "$pass"; then 7881238104Sdes # Only check for convenience libraries 7882238104Sdes deplibs="$lib $deplibs" 7883238104Sdes if test -z "$libdir"; then 7884238104Sdes if test -z "$old_library"; then 7885285206Sdes func_fatal_error "cannot find name of link library for '$lib'" 7886238104Sdes fi 7887238104Sdes # It is a libtool convenience library, so add in its objects. 7888238104Sdes func_append convenience " $ladir/$objdir/$old_library" 7889238104Sdes func_append old_convenience " $ladir/$objdir/$old_library" 7890285206Sdes elif test prog != "$linkmode" && test lib != "$linkmode"; then 7891285206Sdes func_fatal_error "'$lib' is not a convenience library" 7892238104Sdes fi 7893285206Sdes tmp_libs= 7894285206Sdes for deplib in $dependency_libs; do 7895285206Sdes deplibs="$deplib $deplibs" 7896285206Sdes if $opt_preserve_dup_deps; then 7897285206Sdes case "$tmp_libs " in 7898285206Sdes *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899285206Sdes esac 7900285206Sdes fi 7901285206Sdes func_append tmp_libs " $deplib" 7902285206Sdes done 7903238104Sdes continue 7904238104Sdes fi # $pass = conv 7905238104Sdes 7906238104Sdes 7907238104Sdes # Get the name of the library we link against. 7908238104Sdes linklib= 7909238104Sdes if test -n "$old_library" && 7910285206Sdes { test yes = "$prefer_static_libs" || 7911285206Sdes test built,no = "$prefer_static_libs,$installed"; }; then 7912238104Sdes linklib=$old_library 7913238104Sdes else 7914238104Sdes for l in $old_library $library_names; do 7915285206Sdes linklib=$l 7916238104Sdes done 7917238104Sdes fi 7918238104Sdes if test -z "$linklib"; then 7919285206Sdes func_fatal_error "cannot find name of link library for '$lib'" 7920238104Sdes fi 7921238104Sdes 7922238104Sdes # This library was specified with -dlopen. 7923285206Sdes if test dlopen = "$pass"; then 7924285206Sdes test -z "$libdir" \ 7925285206Sdes && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7926238104Sdes if test -z "$dlname" || 7927285206Sdes test yes != "$dlopen_support" || 7928285206Sdes test no = "$build_libtool_libs" 7929285206Sdes then 7930238104Sdes # If there is no dlname, no dlopen support or we're linking 7931238104Sdes # statically, we need to preload. We also need to preload any 7932238104Sdes # dependent libraries so libltdl's deplib preloader doesn't 7933238104Sdes # bomb out in the load deplibs phase. 7934238104Sdes func_append dlprefiles " $lib $dependency_libs" 7935238104Sdes else 7936238104Sdes func_append newdlfiles " $lib" 7937238104Sdes fi 7938238104Sdes continue 7939238104Sdes fi # $pass = dlopen 7940238104Sdes 7941238104Sdes # We need an absolute path. 7942238104Sdes case $ladir in 7943285206Sdes [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7944238104Sdes *) 7945238104Sdes abs_ladir=`cd "$ladir" && pwd` 7946238104Sdes if test -z "$abs_ladir"; then 7947285206Sdes func_warning "cannot determine absolute directory name of '$ladir'" 7948238104Sdes func_warning "passing it literally to the linker, although it might fail" 7949285206Sdes abs_ladir=$ladir 7950238104Sdes fi 7951238104Sdes ;; 7952238104Sdes esac 7953238104Sdes func_basename "$lib" 7954285206Sdes laname=$func_basename_result 7955238104Sdes 7956238104Sdes # Find the relevant object directory and library name. 7957285206Sdes if test yes = "$installed"; then 7958238104Sdes if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7959285206Sdes func_warning "library '$lib' was moved." 7960285206Sdes dir=$ladir 7961285206Sdes absdir=$abs_ladir 7962285206Sdes libdir=$abs_ladir 7963238104Sdes else 7964285206Sdes dir=$lt_sysroot$libdir 7965285206Sdes absdir=$lt_sysroot$libdir 7966238104Sdes fi 7967285206Sdes test yes = "$hardcode_automatic" && avoidtemprpath=yes 7968238104Sdes else 7969238104Sdes if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7970285206Sdes dir=$ladir 7971285206Sdes absdir=$abs_ladir 7972238104Sdes # Remove this search path later 7973238104Sdes func_append notinst_path " $abs_ladir" 7974238104Sdes else 7975285206Sdes dir=$ladir/$objdir 7976285206Sdes absdir=$abs_ladir/$objdir 7977238104Sdes # Remove this search path later 7978238104Sdes func_append notinst_path " $abs_ladir" 7979238104Sdes fi 7980238104Sdes fi # $installed = yes 7981238104Sdes func_stripname 'lib' '.la' "$laname" 7982238104Sdes name=$func_stripname_result 7983238104Sdes 7984238104Sdes # This library was specified with -dlpreopen. 7985285206Sdes if test dlpreopen = "$pass"; then 7986285206Sdes if test -z "$libdir" && test prog = "$linkmode"; then 7987285206Sdes func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7988238104Sdes fi 7989285206Sdes case $host in 7990238104Sdes # special handling for platforms with PE-DLLs. 7991238104Sdes *cygwin* | *mingw* | *cegcc* ) 7992238104Sdes # Linker will automatically link against shared library if both 7993238104Sdes # static and shared are present. Therefore, ensure we extract 7994238104Sdes # symbols from the import library if a shared library is present 7995238104Sdes # (otherwise, the dlopen module name will be incorrect). We do 7996238104Sdes # this by putting the import library name into $newdlprefiles. 7997238104Sdes # We recover the dlopen module name by 'saving' the la file 7998238104Sdes # name in a special purpose variable, and (later) extracting the 7999238104Sdes # dlname from the la file. 8000238104Sdes if test -n "$dlname"; then 8001238104Sdes func_tr_sh "$dir/$linklib" 8002238104Sdes eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8003238104Sdes func_append newdlprefiles " $dir/$linklib" 8004238104Sdes else 8005238104Sdes func_append newdlprefiles " $dir/$old_library" 8006238104Sdes # Keep a list of preopened convenience libraries to check 8007238104Sdes # that they are being used correctly in the link pass. 8008238104Sdes test -z "$libdir" && \ 8009238104Sdes func_append dlpreconveniencelibs " $dir/$old_library" 8010238104Sdes fi 8011238104Sdes ;; 8012238104Sdes * ) 8013238104Sdes # Prefer using a static library (so that no silly _DYNAMIC symbols 8014238104Sdes # are required to link). 8015238104Sdes if test -n "$old_library"; then 8016238104Sdes func_append newdlprefiles " $dir/$old_library" 8017238104Sdes # Keep a list of preopened convenience libraries to check 8018238104Sdes # that they are being used correctly in the link pass. 8019238104Sdes test -z "$libdir" && \ 8020238104Sdes func_append dlpreconveniencelibs " $dir/$old_library" 8021238104Sdes # Otherwise, use the dlname, so that lt_dlopen finds it. 8022238104Sdes elif test -n "$dlname"; then 8023238104Sdes func_append newdlprefiles " $dir/$dlname" 8024238104Sdes else 8025238104Sdes func_append newdlprefiles " $dir/$linklib" 8026238104Sdes fi 8027238104Sdes ;; 8028238104Sdes esac 8029238104Sdes fi # $pass = dlpreopen 8030238104Sdes 8031238104Sdes if test -z "$libdir"; then 8032238104Sdes # Link the convenience library 8033285206Sdes if test lib = "$linkmode"; then 8034238104Sdes deplibs="$dir/$old_library $deplibs" 8035285206Sdes elif test prog,link = "$linkmode,$pass"; then 8036238104Sdes compile_deplibs="$dir/$old_library $compile_deplibs" 8037238104Sdes finalize_deplibs="$dir/$old_library $finalize_deplibs" 8038238104Sdes else 8039238104Sdes deplibs="$lib $deplibs" # used for prog,scan pass 8040238104Sdes fi 8041238104Sdes continue 8042238104Sdes fi 8043238104Sdes 8044238104Sdes 8045285206Sdes if test prog = "$linkmode" && test link != "$pass"; then 8046238104Sdes func_append newlib_search_path " $ladir" 8047238104Sdes deplibs="$lib $deplibs" 8048238104Sdes 8049285206Sdes linkalldeplibs=false 8050285206Sdes if test no != "$link_all_deplibs" || test -z "$library_names" || 8051285206Sdes test no = "$build_libtool_libs"; then 8052285206Sdes linkalldeplibs=: 8053238104Sdes fi 8054238104Sdes 8055238104Sdes tmp_libs= 8056238104Sdes for deplib in $dependency_libs; do 8057238104Sdes case $deplib in 8058238104Sdes -L*) func_stripname '-L' '' "$deplib" 8059238104Sdes func_resolve_sysroot "$func_stripname_result" 8060238104Sdes func_append newlib_search_path " $func_resolve_sysroot_result" 8061238104Sdes ;; 8062238104Sdes esac 8063238104Sdes # Need to link against all dependency_libs? 8064285206Sdes if $linkalldeplibs; then 8065238104Sdes deplibs="$deplib $deplibs" 8066238104Sdes else 8067238104Sdes # Need to hardcode shared library paths 8068238104Sdes # or/and link against static libraries 8069238104Sdes newdependency_libs="$deplib $newdependency_libs" 8070238104Sdes fi 8071285206Sdes if $opt_preserve_dup_deps; then 8072238104Sdes case "$tmp_libs " in 8073238104Sdes *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8074238104Sdes esac 8075238104Sdes fi 8076238104Sdes func_append tmp_libs " $deplib" 8077238104Sdes done # for deplib 8078238104Sdes continue 8079238104Sdes fi # $linkmode = prog... 8080238104Sdes 8081285206Sdes if test prog,link = "$linkmode,$pass"; then 8082238104Sdes if test -n "$library_names" && 8083285206Sdes { { test no = "$prefer_static_libs" || 8084285206Sdes test built,yes = "$prefer_static_libs,$installed"; } || 8085238104Sdes test -z "$old_library"; }; then 8086238104Sdes # We need to hardcode the library path 8087285206Sdes if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8088238104Sdes # Make sure the rpath contains only unique directories. 8089285206Sdes case $temp_rpath: in 8090238104Sdes *"$absdir:"*) ;; 8091238104Sdes *) func_append temp_rpath "$absdir:" ;; 8092238104Sdes esac 8093238104Sdes fi 8094238104Sdes 8095238104Sdes # Hardcode the library path. 8096238104Sdes # Skip directories that are in the system default run-time 8097238104Sdes # search path. 8098238104Sdes case " $sys_lib_dlsearch_path " in 8099238104Sdes *" $absdir "*) ;; 8100238104Sdes *) 8101238104Sdes case "$compile_rpath " in 8102238104Sdes *" $absdir "*) ;; 8103238104Sdes *) func_append compile_rpath " $absdir" ;; 8104238104Sdes esac 8105238104Sdes ;; 8106238104Sdes esac 8107238104Sdes case " $sys_lib_dlsearch_path " in 8108238104Sdes *" $libdir "*) ;; 8109238104Sdes *) 8110238104Sdes case "$finalize_rpath " in 8111238104Sdes *" $libdir "*) ;; 8112238104Sdes *) func_append finalize_rpath " $libdir" ;; 8113238104Sdes esac 8114238104Sdes ;; 8115238104Sdes esac 8116238104Sdes fi # $linkmode,$pass = prog,link... 8117238104Sdes 8118285206Sdes if $alldeplibs && 8119285206Sdes { test pass_all = "$deplibs_check_method" || 8120285206Sdes { test yes = "$build_libtool_libs" && 8121238104Sdes test -n "$library_names"; }; }; then 8122238104Sdes # We only need to search for static libraries 8123238104Sdes continue 8124238104Sdes fi 8125238104Sdes fi 8126238104Sdes 8127238104Sdes link_static=no # Whether the deplib will be linked statically 8128238104Sdes use_static_libs=$prefer_static_libs 8129285206Sdes if test built = "$use_static_libs" && test yes = "$installed"; then 8130238104Sdes use_static_libs=no 8131238104Sdes fi 8132238104Sdes if test -n "$library_names" && 8133285206Sdes { test no = "$use_static_libs" || test -z "$old_library"; }; then 8134238104Sdes case $host in 8135285206Sdes *cygwin* | *mingw* | *cegcc* | *os2*) 8136238104Sdes # No point in relinking DLLs because paths are not encoded 8137238104Sdes func_append notinst_deplibs " $lib" 8138238104Sdes need_relink=no 8139238104Sdes ;; 8140238104Sdes *) 8141285206Sdes if test no = "$installed"; then 8142238104Sdes func_append notinst_deplibs " $lib" 8143238104Sdes need_relink=yes 8144238104Sdes fi 8145238104Sdes ;; 8146238104Sdes esac 8147238104Sdes # This is a shared library 8148238104Sdes 8149238104Sdes # Warn about portability, can't link against -module's on some 8150238104Sdes # systems (darwin). Don't bleat about dlopened modules though! 8151285206Sdes dlopenmodule= 8152238104Sdes for dlpremoduletest in $dlprefiles; do 8153238104Sdes if test "X$dlpremoduletest" = "X$lib"; then 8154285206Sdes dlopenmodule=$dlpremoduletest 8155238104Sdes break 8156238104Sdes fi 8157238104Sdes done 8158285206Sdes if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8159238104Sdes echo 8160285206Sdes if test prog = "$linkmode"; then 8161238104Sdes $ECHO "*** Warning: Linking the executable $output against the loadable module" 8162238104Sdes else 8163238104Sdes $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8164238104Sdes fi 8165238104Sdes $ECHO "*** $linklib is not portable!" 8166238104Sdes fi 8167285206Sdes if test lib = "$linkmode" && 8168285206Sdes test yes = "$hardcode_into_libs"; then 8169238104Sdes # Hardcode the library path. 8170238104Sdes # Skip directories that are in the system default run-time 8171238104Sdes # search path. 8172238104Sdes case " $sys_lib_dlsearch_path " in 8173238104Sdes *" $absdir "*) ;; 8174238104Sdes *) 8175238104Sdes case "$compile_rpath " in 8176238104Sdes *" $absdir "*) ;; 8177238104Sdes *) func_append compile_rpath " $absdir" ;; 8178238104Sdes esac 8179238104Sdes ;; 8180238104Sdes esac 8181238104Sdes case " $sys_lib_dlsearch_path " in 8182238104Sdes *" $libdir "*) ;; 8183238104Sdes *) 8184238104Sdes case "$finalize_rpath " in 8185238104Sdes *" $libdir "*) ;; 8186238104Sdes *) func_append finalize_rpath " $libdir" ;; 8187238104Sdes esac 8188238104Sdes ;; 8189238104Sdes esac 8190238104Sdes fi 8191238104Sdes 8192238104Sdes if test -n "$old_archive_from_expsyms_cmds"; then 8193238104Sdes # figure out the soname 8194238104Sdes set dummy $library_names 8195238104Sdes shift 8196285206Sdes realname=$1 8197238104Sdes shift 8198238104Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 8199238104Sdes # use dlname if we got it. it's perfectly good, no? 8200238104Sdes if test -n "$dlname"; then 8201285206Sdes soname=$dlname 8202238104Sdes elif test -n "$soname_spec"; then 8203238104Sdes # bleh windows 8204238104Sdes case $host in 8205285206Sdes *cygwin* | mingw* | *cegcc* | *os2*) 8206238104Sdes func_arith $current - $age 8207238104Sdes major=$func_arith_result 8208285206Sdes versuffix=-$major 8209238104Sdes ;; 8210238104Sdes esac 8211238104Sdes eval soname=\"$soname_spec\" 8212238104Sdes else 8213285206Sdes soname=$realname 8214238104Sdes fi 8215238104Sdes 8216238104Sdes # Make a new name for the extract_expsyms_cmds to use 8217285206Sdes soroot=$soname 8218238104Sdes func_basename "$soroot" 8219285206Sdes soname=$func_basename_result 8220238104Sdes func_stripname 'lib' '.dll' "$soname" 8221238104Sdes newlib=libimp-$func_stripname_result.a 8222238104Sdes 8223238104Sdes # If the library has no export list, then create one now 8224238104Sdes if test -f "$output_objdir/$soname-def"; then : 8225238104Sdes else 8226285206Sdes func_verbose "extracting exported symbol list from '$soname'" 8227238104Sdes func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8228238104Sdes fi 8229238104Sdes 8230238104Sdes # Create $newlib 8231238104Sdes if test -f "$output_objdir/$newlib"; then :; else 8232285206Sdes func_verbose "generating import library for '$soname'" 8233238104Sdes func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8234238104Sdes fi 8235238104Sdes # make sure the library variables are pointing to the new library 8236238104Sdes dir=$output_objdir 8237238104Sdes linklib=$newlib 8238238104Sdes fi # test -n "$old_archive_from_expsyms_cmds" 8239238104Sdes 8240285206Sdes if test prog = "$linkmode" || test relink != "$opt_mode"; then 8241238104Sdes add_shlibpath= 8242238104Sdes add_dir= 8243238104Sdes add= 8244238104Sdes lib_linked=yes 8245238104Sdes case $hardcode_action in 8246238104Sdes immediate | unsupported) 8247285206Sdes if test no = "$hardcode_direct"; then 8248285206Sdes add=$dir/$linklib 8249238104Sdes case $host in 8250285206Sdes *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8251285206Sdes *-*-sysv4*uw2*) add_dir=-L$dir ;; 8252238104Sdes *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8253285206Sdes *-*-unixware7*) add_dir=-L$dir ;; 8254238104Sdes *-*-darwin* ) 8255285206Sdes # if the lib is a (non-dlopened) module then we cannot 8256238104Sdes # link against it, someone is ignoring the earlier warnings 8257238104Sdes if /usr/bin/file -L $add 2> /dev/null | 8258285206Sdes $GREP ": [^:]* bundle" >/dev/null; then 8259238104Sdes if test "X$dlopenmodule" != "X$lib"; then 8260238104Sdes $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8261285206Sdes if test -z "$old_library"; then 8262238104Sdes echo 8263238104Sdes echo "*** And there doesn't seem to be a static archive available" 8264238104Sdes echo "*** The link will probably fail, sorry" 8265238104Sdes else 8266285206Sdes add=$dir/$old_library 8267238104Sdes fi 8268238104Sdes elif test -n "$old_library"; then 8269285206Sdes add=$dir/$old_library 8270238104Sdes fi 8271238104Sdes fi 8272238104Sdes esac 8273285206Sdes elif test no = "$hardcode_minus_L"; then 8274238104Sdes case $host in 8275285206Sdes *-*-sunos*) add_shlibpath=$dir ;; 8276238104Sdes esac 8277285206Sdes add_dir=-L$dir 8278285206Sdes add=-l$name 8279285206Sdes elif test no = "$hardcode_shlibpath_var"; then 8280285206Sdes add_shlibpath=$dir 8281285206Sdes add=-l$name 8282238104Sdes else 8283238104Sdes lib_linked=no 8284238104Sdes fi 8285238104Sdes ;; 8286238104Sdes relink) 8287285206Sdes if test yes = "$hardcode_direct" && 8288285206Sdes test no = "$hardcode_direct_absolute"; then 8289285206Sdes add=$dir/$linklib 8290285206Sdes elif test yes = "$hardcode_minus_L"; then 8291285206Sdes add_dir=-L$absdir 8292238104Sdes # Try looking first in the location we're being installed to. 8293238104Sdes if test -n "$inst_prefix_dir"; then 8294238104Sdes case $libdir in 8295238104Sdes [\\/]*) 8296238104Sdes func_append add_dir " -L$inst_prefix_dir$libdir" 8297238104Sdes ;; 8298238104Sdes esac 8299238104Sdes fi 8300285206Sdes add=-l$name 8301285206Sdes elif test yes = "$hardcode_shlibpath_var"; then 8302285206Sdes add_shlibpath=$dir 8303285206Sdes add=-l$name 8304238104Sdes else 8305238104Sdes lib_linked=no 8306238104Sdes fi 8307238104Sdes ;; 8308238104Sdes *) lib_linked=no ;; 8309238104Sdes esac 8310238104Sdes 8311285206Sdes if test yes != "$lib_linked"; then 8312238104Sdes func_fatal_configuration "unsupported hardcode properties" 8313238104Sdes fi 8314238104Sdes 8315238104Sdes if test -n "$add_shlibpath"; then 8316238104Sdes case :$compile_shlibpath: in 8317238104Sdes *":$add_shlibpath:"*) ;; 8318238104Sdes *) func_append compile_shlibpath "$add_shlibpath:" ;; 8319238104Sdes esac 8320238104Sdes fi 8321285206Sdes if test prog = "$linkmode"; then 8322238104Sdes test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8323238104Sdes test -n "$add" && compile_deplibs="$add $compile_deplibs" 8324238104Sdes else 8325238104Sdes test -n "$add_dir" && deplibs="$add_dir $deplibs" 8326238104Sdes test -n "$add" && deplibs="$add $deplibs" 8327285206Sdes if test yes != "$hardcode_direct" && 8328285206Sdes test yes != "$hardcode_minus_L" && 8329285206Sdes test yes = "$hardcode_shlibpath_var"; then 8330238104Sdes case :$finalize_shlibpath: in 8331238104Sdes *":$libdir:"*) ;; 8332238104Sdes *) func_append finalize_shlibpath "$libdir:" ;; 8333238104Sdes esac 8334238104Sdes fi 8335238104Sdes fi 8336238104Sdes fi 8337238104Sdes 8338285206Sdes if test prog = "$linkmode" || test relink = "$opt_mode"; then 8339238104Sdes add_shlibpath= 8340238104Sdes add_dir= 8341238104Sdes add= 8342238104Sdes # Finalize command for both is simple: just hardcode it. 8343285206Sdes if test yes = "$hardcode_direct" && 8344285206Sdes test no = "$hardcode_direct_absolute"; then 8345285206Sdes add=$libdir/$linklib 8346285206Sdes elif test yes = "$hardcode_minus_L"; then 8347285206Sdes add_dir=-L$libdir 8348285206Sdes add=-l$name 8349285206Sdes elif test yes = "$hardcode_shlibpath_var"; then 8350238104Sdes case :$finalize_shlibpath: in 8351238104Sdes *":$libdir:"*) ;; 8352238104Sdes *) func_append finalize_shlibpath "$libdir:" ;; 8353238104Sdes esac 8354285206Sdes add=-l$name 8355285206Sdes elif test yes = "$hardcode_automatic"; then 8356238104Sdes if test -n "$inst_prefix_dir" && 8357285206Sdes test -f "$inst_prefix_dir$libdir/$linklib"; then 8358285206Sdes add=$inst_prefix_dir$libdir/$linklib 8359238104Sdes else 8360285206Sdes add=$libdir/$linklib 8361238104Sdes fi 8362238104Sdes else 8363238104Sdes # We cannot seem to hardcode it, guess we'll fake it. 8364285206Sdes add_dir=-L$libdir 8365238104Sdes # Try looking first in the location we're being installed to. 8366238104Sdes if test -n "$inst_prefix_dir"; then 8367238104Sdes case $libdir in 8368238104Sdes [\\/]*) 8369238104Sdes func_append add_dir " -L$inst_prefix_dir$libdir" 8370238104Sdes ;; 8371238104Sdes esac 8372238104Sdes fi 8373285206Sdes add=-l$name 8374238104Sdes fi 8375238104Sdes 8376285206Sdes if test prog = "$linkmode"; then 8377238104Sdes test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8378238104Sdes test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8379238104Sdes else 8380238104Sdes test -n "$add_dir" && deplibs="$add_dir $deplibs" 8381238104Sdes test -n "$add" && deplibs="$add $deplibs" 8382238104Sdes fi 8383238104Sdes fi 8384285206Sdes elif test prog = "$linkmode"; then 8385238104Sdes # Here we assume that one of hardcode_direct or hardcode_minus_L 8386238104Sdes # is not unsupported. This is valid on all known static and 8387238104Sdes # shared platforms. 8388285206Sdes if test unsupported != "$hardcode_direct"; then 8389285206Sdes test -n "$old_library" && linklib=$old_library 8390238104Sdes compile_deplibs="$dir/$linklib $compile_deplibs" 8391238104Sdes finalize_deplibs="$dir/$linklib $finalize_deplibs" 8392238104Sdes else 8393238104Sdes compile_deplibs="-l$name -L$dir $compile_deplibs" 8394238104Sdes finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8395238104Sdes fi 8396285206Sdes elif test yes = "$build_libtool_libs"; then 8397238104Sdes # Not a shared library 8398285206Sdes if test pass_all != "$deplibs_check_method"; then 8399238104Sdes # We're trying link a shared library against a static one 8400238104Sdes # but the system doesn't support it. 8401238104Sdes 8402238104Sdes # Just print a warning and add the library to dependency_libs so 8403238104Sdes # that the program can be linked against the static library. 8404238104Sdes echo 8405285206Sdes $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8406238104Sdes echo "*** I have the capability to make that library automatically link in when" 8407238104Sdes echo "*** you link to this library. But I can only do this if you have a" 8408238104Sdes echo "*** shared version of the library, which you do not appear to have." 8409285206Sdes if test yes = "$module"; then 8410238104Sdes echo "*** But as you try to build a module library, libtool will still create " 8411238104Sdes echo "*** a static module, that should work as long as the dlopening application" 8412238104Sdes echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8413238104Sdes if test -z "$global_symbol_pipe"; then 8414238104Sdes echo 8415238104Sdes echo "*** However, this would only work if libtool was able to extract symbol" 8416285206Sdes echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8417238104Sdes echo "*** not find such a program. So, this module is probably useless." 8418285206Sdes echo "*** 'nm' from GNU binutils and a full rebuild may help." 8419238104Sdes fi 8420285206Sdes if test no = "$build_old_libs"; then 8421238104Sdes build_libtool_libs=module 8422238104Sdes build_old_libs=yes 8423238104Sdes else 8424238104Sdes build_libtool_libs=no 8425238104Sdes fi 8426238104Sdes fi 8427238104Sdes else 8428238104Sdes deplibs="$dir/$old_library $deplibs" 8429238104Sdes link_static=yes 8430238104Sdes fi 8431238104Sdes fi # link shared/static library? 8432238104Sdes 8433285206Sdes if test lib = "$linkmode"; then 8434238104Sdes if test -n "$dependency_libs" && 8435285206Sdes { test yes != "$hardcode_into_libs" || 8436285206Sdes test yes = "$build_old_libs" || 8437285206Sdes test yes = "$link_static"; }; then 8438238104Sdes # Extract -R from dependency_libs 8439238104Sdes temp_deplibs= 8440238104Sdes for libdir in $dependency_libs; do 8441238104Sdes case $libdir in 8442238104Sdes -R*) func_stripname '-R' '' "$libdir" 8443238104Sdes temp_xrpath=$func_stripname_result 8444238104Sdes case " $xrpath " in 8445238104Sdes *" $temp_xrpath "*) ;; 8446238104Sdes *) func_append xrpath " $temp_xrpath";; 8447238104Sdes esac;; 8448238104Sdes *) func_append temp_deplibs " $libdir";; 8449238104Sdes esac 8450238104Sdes done 8451285206Sdes dependency_libs=$temp_deplibs 8452238104Sdes fi 8453238104Sdes 8454238104Sdes func_append newlib_search_path " $absdir" 8455238104Sdes # Link against this library 8456285206Sdes test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8457238104Sdes # ... and its dependency_libs 8458238104Sdes tmp_libs= 8459238104Sdes for deplib in $dependency_libs; do 8460238104Sdes newdependency_libs="$deplib $newdependency_libs" 8461238104Sdes case $deplib in 8462238104Sdes -L*) func_stripname '-L' '' "$deplib" 8463238104Sdes func_resolve_sysroot "$func_stripname_result";; 8464238104Sdes *) func_resolve_sysroot "$deplib" ;; 8465238104Sdes esac 8466285206Sdes if $opt_preserve_dup_deps; then 8467238104Sdes case "$tmp_libs " in 8468238104Sdes *" $func_resolve_sysroot_result "*) 8469238104Sdes func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8470238104Sdes esac 8471238104Sdes fi 8472238104Sdes func_append tmp_libs " $func_resolve_sysroot_result" 8473238104Sdes done 8474238104Sdes 8475285206Sdes if test no != "$link_all_deplibs"; then 8476238104Sdes # Add the search paths of all dependency libraries 8477238104Sdes for deplib in $dependency_libs; do 8478238104Sdes path= 8479238104Sdes case $deplib in 8480285206Sdes -L*) path=$deplib ;; 8481238104Sdes *.la) 8482238104Sdes func_resolve_sysroot "$deplib" 8483238104Sdes deplib=$func_resolve_sysroot_result 8484238104Sdes func_dirname "$deplib" "" "." 8485238104Sdes dir=$func_dirname_result 8486238104Sdes # We need an absolute path. 8487238104Sdes case $dir in 8488285206Sdes [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8489238104Sdes *) 8490238104Sdes absdir=`cd "$dir" && pwd` 8491238104Sdes if test -z "$absdir"; then 8492285206Sdes func_warning "cannot determine absolute directory name of '$dir'" 8493285206Sdes absdir=$dir 8494238104Sdes fi 8495238104Sdes ;; 8496238104Sdes esac 8497238104Sdes if $GREP "^installed=no" $deplib > /dev/null; then 8498238104Sdes case $host in 8499238104Sdes *-*-darwin*) 8500238104Sdes depdepl= 8501285206Sdes eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8502285206Sdes if test -n "$deplibrary_names"; then 8503285206Sdes for tmp in $deplibrary_names; do 8504238104Sdes depdepl=$tmp 8505238104Sdes done 8506285206Sdes if test -f "$absdir/$objdir/$depdepl"; then 8507285206Sdes depdepl=$absdir/$objdir/$depdepl 8508285206Sdes darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8509238104Sdes if test -z "$darwin_install_name"; then 8510285206Sdes darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511238104Sdes fi 8512285206Sdes func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8513285206Sdes func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8514238104Sdes path= 8515238104Sdes fi 8516238104Sdes fi 8517238104Sdes ;; 8518238104Sdes *) 8519285206Sdes path=-L$absdir/$objdir 8520238104Sdes ;; 8521238104Sdes esac 8522238104Sdes else 8523285206Sdes eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8524238104Sdes test -z "$libdir" && \ 8525285206Sdes func_fatal_error "'$deplib' is not a valid libtool archive" 8526238104Sdes test "$absdir" != "$libdir" && \ 8527285206Sdes func_warning "'$deplib' seems to be moved" 8528238104Sdes 8529285206Sdes path=-L$absdir 8530238104Sdes fi 8531238104Sdes ;; 8532238104Sdes esac 8533238104Sdes case " $deplibs " in 8534238104Sdes *" $path "*) ;; 8535238104Sdes *) deplibs="$path $deplibs" ;; 8536238104Sdes esac 8537238104Sdes done 8538238104Sdes fi # link_all_deplibs != no 8539238104Sdes fi # linkmode = lib 8540238104Sdes done # for deplib in $libs 8541285206Sdes if test link = "$pass"; then 8542285206Sdes if test prog = "$linkmode"; then 8543238104Sdes compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8544238104Sdes finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8545238104Sdes else 8546238104Sdes compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8547238104Sdes fi 8548238104Sdes fi 8549285206Sdes dependency_libs=$newdependency_libs 8550285206Sdes if test dlpreopen = "$pass"; then 8551238104Sdes # Link the dlpreopened libraries before other libraries 8552238104Sdes for deplib in $save_deplibs; do 8553238104Sdes deplibs="$deplib $deplibs" 8554238104Sdes done 8555238104Sdes fi 8556285206Sdes if test dlopen != "$pass"; then 8557285206Sdes test conv = "$pass" || { 8558238104Sdes # Make sure lib_search_path contains only unique directories. 8559238104Sdes lib_search_path= 8560238104Sdes for dir in $newlib_search_path; do 8561238104Sdes case "$lib_search_path " in 8562238104Sdes *" $dir "*) ;; 8563238104Sdes *) func_append lib_search_path " $dir" ;; 8564238104Sdes esac 8565238104Sdes done 8566238104Sdes newlib_search_path= 8567285206Sdes } 8568238104Sdes 8569285206Sdes if test prog,link = "$linkmode,$pass"; then 8570285206Sdes vars="compile_deplibs finalize_deplibs" 8571238104Sdes else 8572285206Sdes vars=deplibs 8573238104Sdes fi 8574238104Sdes for var in $vars dependency_libs; do 8575238104Sdes # Add libraries to $var in reverse order 8576238104Sdes eval tmp_libs=\"\$$var\" 8577238104Sdes new_libs= 8578238104Sdes for deplib in $tmp_libs; do 8579238104Sdes # FIXME: Pedantically, this is the right thing to do, so 8580238104Sdes # that some nasty dependency loop isn't accidentally 8581238104Sdes # broken: 8582238104Sdes #new_libs="$deplib $new_libs" 8583238104Sdes # Pragmatically, this seems to cause very few problems in 8584238104Sdes # practice: 8585238104Sdes case $deplib in 8586238104Sdes -L*) new_libs="$deplib $new_libs" ;; 8587238104Sdes -R*) ;; 8588238104Sdes *) 8589238104Sdes # And here is the reason: when a library appears more 8590238104Sdes # than once as an explicit dependence of a library, or 8591238104Sdes # is implicitly linked in more than once by the 8592238104Sdes # compiler, it is considered special, and multiple 8593238104Sdes # occurrences thereof are not removed. Compare this 8594238104Sdes # with having the same library being listed as a 8595238104Sdes # dependency of multiple other libraries: in this case, 8596238104Sdes # we know (pedantically, we assume) the library does not 8597238104Sdes # need to be listed more than once, so we keep only the 8598238104Sdes # last copy. This is not always right, but it is rare 8599238104Sdes # enough that we require users that really mean to play 8600238104Sdes # such unportable linking tricks to link the library 8601238104Sdes # using -Wl,-lname, so that libtool does not consider it 8602238104Sdes # for duplicate removal. 8603238104Sdes case " $specialdeplibs " in 8604238104Sdes *" $deplib "*) new_libs="$deplib $new_libs" ;; 8605238104Sdes *) 8606238104Sdes case " $new_libs " in 8607238104Sdes *" $deplib "*) ;; 8608238104Sdes *) new_libs="$deplib $new_libs" ;; 8609238104Sdes esac 8610238104Sdes ;; 8611238104Sdes esac 8612238104Sdes ;; 8613238104Sdes esac 8614238104Sdes done 8615238104Sdes tmp_libs= 8616238104Sdes for deplib in $new_libs; do 8617238104Sdes case $deplib in 8618238104Sdes -L*) 8619238104Sdes case " $tmp_libs " in 8620238104Sdes *" $deplib "*) ;; 8621238104Sdes *) func_append tmp_libs " $deplib" ;; 8622238104Sdes esac 8623238104Sdes ;; 8624238104Sdes *) func_append tmp_libs " $deplib" ;; 8625238104Sdes esac 8626238104Sdes done 8627238104Sdes eval $var=\"$tmp_libs\" 8628238104Sdes done # for var 8629238104Sdes fi 8630285206Sdes 8631285206Sdes # Add Sun CC postdeps if required: 8632285206Sdes test CXX = "$tagname" && { 8633285206Sdes case $host_os in 8634285206Sdes linux*) 8635285206Sdes case `$CC -V 2>&1 | sed 5q` in 8636285206Sdes *Sun\ C*) # Sun C++ 5.9 8637285206Sdes func_suncc_cstd_abi 8638285206Sdes 8639285206Sdes if test no != "$suncc_use_cstd_abi"; then 8640285206Sdes func_append postdeps ' -library=Cstd -library=Crun' 8641285206Sdes fi 8642285206Sdes ;; 8643285206Sdes esac 8644285206Sdes ;; 8645285206Sdes 8646285206Sdes solaris*) 8647285206Sdes func_cc_basename "$CC" 8648285206Sdes case $func_cc_basename_result in 8649285206Sdes CC* | sunCC*) 8650285206Sdes func_suncc_cstd_abi 8651285206Sdes 8652285206Sdes if test no != "$suncc_use_cstd_abi"; then 8653285206Sdes func_append postdeps ' -library=Cstd -library=Crun' 8654285206Sdes fi 8655285206Sdes ;; 8656285206Sdes esac 8657285206Sdes ;; 8658285206Sdes esac 8659285206Sdes } 8660285206Sdes 8661238104Sdes # Last step: remove runtime libs from dependency_libs 8662238104Sdes # (they stay in deplibs) 8663238104Sdes tmp_libs= 8664285206Sdes for i in $dependency_libs; do 8665238104Sdes case " $predeps $postdeps $compiler_lib_search_path " in 8666238104Sdes *" $i "*) 8667285206Sdes i= 8668238104Sdes ;; 8669238104Sdes esac 8670285206Sdes if test -n "$i"; then 8671238104Sdes func_append tmp_libs " $i" 8672238104Sdes fi 8673238104Sdes done 8674238104Sdes dependency_libs=$tmp_libs 8675238104Sdes done # for pass 8676285206Sdes if test prog = "$linkmode"; then 8677285206Sdes dlfiles=$newdlfiles 8678238104Sdes fi 8679285206Sdes if test prog = "$linkmode" || test lib = "$linkmode"; then 8680285206Sdes dlprefiles=$newdlprefiles 8681238104Sdes fi 8682238104Sdes 8683238104Sdes case $linkmode in 8684238104Sdes oldlib) 8685285206Sdes if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8686285206Sdes func_warning "'-dlopen' is ignored for archives" 8687238104Sdes fi 8688238104Sdes 8689238104Sdes case " $deplibs" in 8690238104Sdes *\ -l* | *\ -L*) 8691285206Sdes func_warning "'-l' and '-L' are ignored for archives" ;; 8692238104Sdes esac 8693238104Sdes 8694238104Sdes test -n "$rpath" && \ 8695285206Sdes func_warning "'-rpath' is ignored for archives" 8696238104Sdes 8697238104Sdes test -n "$xrpath" && \ 8698285206Sdes func_warning "'-R' is ignored for archives" 8699238104Sdes 8700238104Sdes test -n "$vinfo" && \ 8701285206Sdes func_warning "'-version-info/-version-number' is ignored for archives" 8702238104Sdes 8703238104Sdes test -n "$release" && \ 8704285206Sdes func_warning "'-release' is ignored for archives" 8705238104Sdes 8706238104Sdes test -n "$export_symbols$export_symbols_regex" && \ 8707285206Sdes func_warning "'-export-symbols' is ignored for archives" 8708238104Sdes 8709238104Sdes # Now set the variables for building old libraries. 8710238104Sdes build_libtool_libs=no 8711285206Sdes oldlibs=$output 8712238104Sdes func_append objs "$old_deplibs" 8713238104Sdes ;; 8714238104Sdes 8715238104Sdes lib) 8716285206Sdes # Make sure we only generate libraries of the form 'libNAME.la'. 8717238104Sdes case $outputname in 8718238104Sdes lib*) 8719238104Sdes func_stripname 'lib' '.la' "$outputname" 8720238104Sdes name=$func_stripname_result 8721238104Sdes eval shared_ext=\"$shrext_cmds\" 8722238104Sdes eval libname=\"$libname_spec\" 8723238104Sdes ;; 8724238104Sdes *) 8725285206Sdes test no = "$module" \ 8726285206Sdes && func_fatal_help "libtool library '$output' must begin with 'lib'" 8727238104Sdes 8728285206Sdes if test no != "$need_lib_prefix"; then 8729238104Sdes # Add the "lib" prefix for modules if required 8730238104Sdes func_stripname '' '.la' "$outputname" 8731238104Sdes name=$func_stripname_result 8732238104Sdes eval shared_ext=\"$shrext_cmds\" 8733238104Sdes eval libname=\"$libname_spec\" 8734238104Sdes else 8735238104Sdes func_stripname '' '.la' "$outputname" 8736238104Sdes libname=$func_stripname_result 8737238104Sdes fi 8738238104Sdes ;; 8739238104Sdes esac 8740238104Sdes 8741238104Sdes if test -n "$objs"; then 8742285206Sdes if test pass_all != "$deplibs_check_method"; then 8743285206Sdes func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8744238104Sdes else 8745238104Sdes echo 8746238104Sdes $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8747238104Sdes $ECHO "*** objects $objs is not portable!" 8748238104Sdes func_append libobjs " $objs" 8749238104Sdes fi 8750238104Sdes fi 8751238104Sdes 8752285206Sdes test no = "$dlself" \ 8753285206Sdes || func_warning "'-dlopen self' is ignored for libtool libraries" 8754238104Sdes 8755238104Sdes set dummy $rpath 8756238104Sdes shift 8757285206Sdes test 1 -lt "$#" \ 8758285206Sdes && func_warning "ignoring multiple '-rpath's for a libtool library" 8759238104Sdes 8760285206Sdes install_libdir=$1 8761238104Sdes 8762238104Sdes oldlibs= 8763238104Sdes if test -z "$rpath"; then 8764285206Sdes if test yes = "$build_libtool_libs"; then 8765238104Sdes # Building a libtool convenience library. 8766285206Sdes # Some compilers have problems with a '.al' extension so 8767238104Sdes # convenience libraries should have the same extension an 8768238104Sdes # archive normally would. 8769238104Sdes oldlibs="$output_objdir/$libname.$libext $oldlibs" 8770238104Sdes build_libtool_libs=convenience 8771238104Sdes build_old_libs=yes 8772238104Sdes fi 8773238104Sdes 8774238104Sdes test -n "$vinfo" && \ 8775285206Sdes func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8776238104Sdes 8777238104Sdes test -n "$release" && \ 8778285206Sdes func_warning "'-release' is ignored for convenience libraries" 8779238104Sdes else 8780238104Sdes 8781238104Sdes # Parse the version information argument. 8782285206Sdes save_ifs=$IFS; IFS=: 8783238104Sdes set dummy $vinfo 0 0 0 8784238104Sdes shift 8785285206Sdes IFS=$save_ifs 8786238104Sdes 8787238104Sdes test -n "$7" && \ 8788285206Sdes func_fatal_help "too many parameters to '-version-info'" 8789238104Sdes 8790238104Sdes # convert absolute version numbers to libtool ages 8791238104Sdes # this retains compatibility with .la files and attempts 8792238104Sdes # to make the code below a bit more comprehensible 8793238104Sdes 8794238104Sdes case $vinfo_number in 8795238104Sdes yes) 8796285206Sdes number_major=$1 8797285206Sdes number_minor=$2 8798285206Sdes number_revision=$3 8799238104Sdes # 8800238104Sdes # There are really only two kinds -- those that 8801238104Sdes # use the current revision as the major version 8802238104Sdes # and those that subtract age and use age as 8803238104Sdes # a minor version. But, then there is irix 8804285206Sdes # that has an extra 1 added just for fun 8805238104Sdes # 8806238104Sdes case $version_type in 8807238104Sdes # correct linux to gnu/linux during the next big refactor 8808285206Sdes darwin|freebsd-elf|linux|osf|windows|none) 8809238104Sdes func_arith $number_major + $number_minor 8810238104Sdes current=$func_arith_result 8811285206Sdes age=$number_minor 8812285206Sdes revision=$number_revision 8813238104Sdes ;; 8814285206Sdes freebsd-aout|qnx|sunos) 8815285206Sdes current=$number_major 8816285206Sdes revision=$number_minor 8817285206Sdes age=0 8818238104Sdes ;; 8819238104Sdes irix|nonstopux) 8820238104Sdes func_arith $number_major + $number_minor 8821238104Sdes current=$func_arith_result 8822285206Sdes age=$number_minor 8823285206Sdes revision=$number_minor 8824238104Sdes lt_irix_increment=no 8825238104Sdes ;; 8826238104Sdes esac 8827238104Sdes ;; 8828238104Sdes no) 8829285206Sdes current=$1 8830285206Sdes revision=$2 8831285206Sdes age=$3 8832238104Sdes ;; 8833238104Sdes esac 8834238104Sdes 8835238104Sdes # Check that each of the things are valid numbers. 8836238104Sdes case $current in 8837238104Sdes 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]) ;; 8838238104Sdes *) 8839285206Sdes func_error "CURRENT '$current' must be a nonnegative integer" 8840285206Sdes func_fatal_error "'$vinfo' is not valid version information" 8841238104Sdes ;; 8842238104Sdes esac 8843238104Sdes 8844238104Sdes case $revision in 8845238104Sdes 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]) ;; 8846238104Sdes *) 8847285206Sdes func_error "REVISION '$revision' must be a nonnegative integer" 8848285206Sdes func_fatal_error "'$vinfo' is not valid version information" 8849238104Sdes ;; 8850238104Sdes esac 8851238104Sdes 8852238104Sdes case $age in 8853238104Sdes 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]) ;; 8854238104Sdes *) 8855285206Sdes func_error "AGE '$age' must be a nonnegative integer" 8856285206Sdes func_fatal_error "'$vinfo' is not valid version information" 8857238104Sdes ;; 8858238104Sdes esac 8859238104Sdes 8860238104Sdes if test "$age" -gt "$current"; then 8861285206Sdes func_error "AGE '$age' is greater than the current interface number '$current'" 8862285206Sdes func_fatal_error "'$vinfo' is not valid version information" 8863238104Sdes fi 8864238104Sdes 8865238104Sdes # Calculate the version variables. 8866238104Sdes major= 8867238104Sdes versuffix= 8868238104Sdes verstring= 8869238104Sdes case $version_type in 8870238104Sdes none) ;; 8871238104Sdes 8872238104Sdes darwin) 8873238104Sdes # Like Linux, but with the current version available in 8874238104Sdes # verstring for coding it into the library header 8875238104Sdes func_arith $current - $age 8876238104Sdes major=.$func_arith_result 8877285206Sdes versuffix=$major.$age.$revision 8878238104Sdes # Darwin ld doesn't like 0 for these options... 8879238104Sdes func_arith $current + 1 8880238104Sdes minor_current=$func_arith_result 8881285206Sdes xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8882238104Sdes verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8883285206Sdes # On Darwin other compilers 8884285206Sdes case $CC in 8885285206Sdes nagfor*) 8886285206Sdes verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8887285206Sdes ;; 8888285206Sdes *) 8889285206Sdes verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8890285206Sdes ;; 8891285206Sdes esac 8892238104Sdes ;; 8893238104Sdes 8894238104Sdes freebsd-aout) 8895285206Sdes major=.$current 8896285206Sdes versuffix=.$current.$revision 8897238104Sdes ;; 8898238104Sdes 8899238104Sdes freebsd-elf) 8900285206Sdes func_arith $current - $age 8901285206Sdes major=.$func_arith_result 8902285206Sdes versuffix=$major.$age.$revision 8903238104Sdes ;; 8904238104Sdes 8905238104Sdes irix | nonstopux) 8906285206Sdes if test no = "$lt_irix_increment"; then 8907238104Sdes func_arith $current - $age 8908238104Sdes else 8909238104Sdes func_arith $current - $age + 1 8910238104Sdes fi 8911238104Sdes major=$func_arith_result 8912238104Sdes 8913238104Sdes case $version_type in 8914238104Sdes nonstopux) verstring_prefix=nonstopux ;; 8915238104Sdes *) verstring_prefix=sgi ;; 8916238104Sdes esac 8917285206Sdes verstring=$verstring_prefix$major.$revision 8918238104Sdes 8919238104Sdes # Add in all the interfaces that we are compatible with. 8920238104Sdes loop=$revision 8921285206Sdes while test 0 -ne "$loop"; do 8922238104Sdes func_arith $revision - $loop 8923238104Sdes iface=$func_arith_result 8924238104Sdes func_arith $loop - 1 8925238104Sdes loop=$func_arith_result 8926285206Sdes verstring=$verstring_prefix$major.$iface:$verstring 8927238104Sdes done 8928238104Sdes 8929285206Sdes # Before this point, $major must not contain '.'. 8930238104Sdes major=.$major 8931285206Sdes versuffix=$major.$revision 8932238104Sdes ;; 8933238104Sdes 8934238104Sdes linux) # correct to gnu/linux during the next big refactor 8935238104Sdes func_arith $current - $age 8936238104Sdes major=.$func_arith_result 8937285206Sdes versuffix=$major.$age.$revision 8938238104Sdes ;; 8939238104Sdes 8940238104Sdes osf) 8941238104Sdes func_arith $current - $age 8942238104Sdes major=.$func_arith_result 8943285206Sdes versuffix=.$current.$age.$revision 8944285206Sdes verstring=$current.$age.$revision 8945238104Sdes 8946238104Sdes # Add in all the interfaces that we are compatible with. 8947238104Sdes loop=$age 8948285206Sdes while test 0 -ne "$loop"; do 8949238104Sdes func_arith $current - $loop 8950238104Sdes iface=$func_arith_result 8951238104Sdes func_arith $loop - 1 8952238104Sdes loop=$func_arith_result 8953285206Sdes verstring=$verstring:$iface.0 8954238104Sdes done 8955238104Sdes 8956238104Sdes # Make executables depend on our current version. 8957285206Sdes func_append verstring ":$current.0" 8958238104Sdes ;; 8959238104Sdes 8960238104Sdes qnx) 8961285206Sdes major=.$current 8962285206Sdes versuffix=.$current 8963238104Sdes ;; 8964238104Sdes 8965285206Sdes sco) 8966285206Sdes major=.$current 8967285206Sdes versuffix=.$current 8968285206Sdes ;; 8969285206Sdes 8970238104Sdes sunos) 8971285206Sdes major=.$current 8972285206Sdes versuffix=.$current.$revision 8973238104Sdes ;; 8974238104Sdes 8975238104Sdes windows) 8976238104Sdes # Use '-' rather than '.', since we only want one 8977285206Sdes # extension on DOS 8.3 file systems. 8978238104Sdes func_arith $current - $age 8979238104Sdes major=$func_arith_result 8980285206Sdes versuffix=-$major 8981238104Sdes ;; 8982238104Sdes 8983238104Sdes *) 8984285206Sdes func_fatal_configuration "unknown library version type '$version_type'" 8985238104Sdes ;; 8986238104Sdes esac 8987238104Sdes 8988238104Sdes # Clear the version info if we defaulted, and they specified a release. 8989238104Sdes if test -z "$vinfo" && test -n "$release"; then 8990238104Sdes major= 8991238104Sdes case $version_type in 8992238104Sdes darwin) 8993238104Sdes # we can't check for "0.0" in archive_cmds due to quoting 8994238104Sdes # problems, so we reset it completely 8995238104Sdes verstring= 8996238104Sdes ;; 8997238104Sdes *) 8998285206Sdes verstring=0.0 8999238104Sdes ;; 9000238104Sdes esac 9001285206Sdes if test no = "$need_version"; then 9002238104Sdes versuffix= 9003238104Sdes else 9004285206Sdes versuffix=.0.0 9005238104Sdes fi 9006238104Sdes fi 9007238104Sdes 9008238104Sdes # Remove version info from name if versioning should be avoided 9009285206Sdes if test yes,no = "$avoid_version,$need_version"; then 9010238104Sdes major= 9011238104Sdes versuffix= 9012285206Sdes verstring= 9013238104Sdes fi 9014238104Sdes 9015238104Sdes # Check to see if the archive will have undefined symbols. 9016285206Sdes if test yes = "$allow_undefined"; then 9017285206Sdes if test unsupported = "$allow_undefined_flag"; then 9018285206Sdes if test yes = "$build_old_libs"; then 9019285206Sdes func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9020285206Sdes build_libtool_libs=no 9021285206Sdes else 9022285206Sdes func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9023285206Sdes fi 9024238104Sdes fi 9025238104Sdes else 9026238104Sdes # Don't allow undefined symbols. 9027285206Sdes allow_undefined_flag=$no_undefined_flag 9028238104Sdes fi 9029238104Sdes 9030238104Sdes fi 9031238104Sdes 9032285206Sdes func_generate_dlsyms "$libname" "$libname" : 9033238104Sdes func_append libobjs " $symfileobj" 9034285206Sdes test " " = "$libobjs" && libobjs= 9035238104Sdes 9036285206Sdes if test relink != "$opt_mode"; then 9037238104Sdes # Remove our outputs, but don't remove object files since they 9038238104Sdes # may have been created when compiling PIC objects. 9039238104Sdes removelist= 9040238104Sdes tempremovelist=`$ECHO "$output_objdir/*"` 9041238104Sdes for p in $tempremovelist; do 9042238104Sdes case $p in 9043238104Sdes *.$objext | *.gcno) 9044238104Sdes ;; 9045285206Sdes $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9046285206Sdes if test -n "$precious_files_regex"; then 9047238104Sdes if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9048238104Sdes then 9049238104Sdes continue 9050238104Sdes fi 9051238104Sdes fi 9052238104Sdes func_append removelist " $p" 9053238104Sdes ;; 9054238104Sdes *) ;; 9055238104Sdes esac 9056238104Sdes done 9057238104Sdes test -n "$removelist" && \ 9058238104Sdes func_show_eval "${RM}r \$removelist" 9059238104Sdes fi 9060238104Sdes 9061238104Sdes # Now set the variables for building old libraries. 9062285206Sdes if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9063238104Sdes func_append oldlibs " $output_objdir/$libname.$libext" 9064238104Sdes 9065238104Sdes # Transform .lo files to .o files. 9066285206Sdes oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9067238104Sdes fi 9068238104Sdes 9069238104Sdes # Eliminate all temporary directories. 9070238104Sdes #for path in $notinst_path; do 9071238104Sdes # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9072238104Sdes # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9073238104Sdes # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9074238104Sdes #done 9075238104Sdes 9076238104Sdes if test -n "$xrpath"; then 9077238104Sdes # If the user specified any rpath flags, then add them. 9078238104Sdes temp_xrpath= 9079238104Sdes for libdir in $xrpath; do 9080238104Sdes func_replace_sysroot "$libdir" 9081238104Sdes func_append temp_xrpath " -R$func_replace_sysroot_result" 9082238104Sdes case "$finalize_rpath " in 9083238104Sdes *" $libdir "*) ;; 9084238104Sdes *) func_append finalize_rpath " $libdir" ;; 9085238104Sdes esac 9086238104Sdes done 9087285206Sdes if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9088238104Sdes dependency_libs="$temp_xrpath $dependency_libs" 9089238104Sdes fi 9090238104Sdes fi 9091238104Sdes 9092238104Sdes # Make sure dlfiles contains only unique files that won't be dlpreopened 9093285206Sdes old_dlfiles=$dlfiles 9094238104Sdes dlfiles= 9095238104Sdes for lib in $old_dlfiles; do 9096238104Sdes case " $dlprefiles $dlfiles " in 9097238104Sdes *" $lib "*) ;; 9098238104Sdes *) func_append dlfiles " $lib" ;; 9099238104Sdes esac 9100238104Sdes done 9101238104Sdes 9102238104Sdes # Make sure dlprefiles contains only unique files 9103285206Sdes old_dlprefiles=$dlprefiles 9104238104Sdes dlprefiles= 9105238104Sdes for lib in $old_dlprefiles; do 9106238104Sdes case "$dlprefiles " in 9107238104Sdes *" $lib "*) ;; 9108238104Sdes *) func_append dlprefiles " $lib" ;; 9109238104Sdes esac 9110238104Sdes done 9111238104Sdes 9112285206Sdes if test yes = "$build_libtool_libs"; then 9113238104Sdes if test -n "$rpath"; then 9114238104Sdes case $host in 9115238104Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9116238104Sdes # these systems don't actually have a c library (as such)! 9117238104Sdes ;; 9118238104Sdes *-*-rhapsody* | *-*-darwin1.[012]) 9119238104Sdes # Rhapsody C library is in the System framework 9120238104Sdes func_append deplibs " System.ltframework" 9121238104Sdes ;; 9122238104Sdes *-*-netbsd*) 9123238104Sdes # Don't link with libc until the a.out ld.so is fixed. 9124238104Sdes ;; 9125238104Sdes *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9126238104Sdes # Do not include libc due to us having libc/libc_r. 9127238104Sdes ;; 9128238104Sdes *-*-sco3.2v5* | *-*-sco5v6*) 9129238104Sdes # Causes problems with __ctype 9130238104Sdes ;; 9131238104Sdes *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9132238104Sdes # Compiler inserts libc in the correct place for threads to work 9133238104Sdes ;; 9134238104Sdes *) 9135238104Sdes # Add libc to deplibs on all other systems if necessary. 9136285206Sdes if test yes = "$build_libtool_need_lc"; then 9137238104Sdes func_append deplibs " -lc" 9138238104Sdes fi 9139238104Sdes ;; 9140238104Sdes esac 9141238104Sdes fi 9142238104Sdes 9143238104Sdes # Transform deplibs into only deplibs that can be linked in shared. 9144238104Sdes name_save=$name 9145238104Sdes libname_save=$libname 9146238104Sdes release_save=$release 9147238104Sdes versuffix_save=$versuffix 9148238104Sdes major_save=$major 9149238104Sdes # I'm not sure if I'm treating the release correctly. I think 9150238104Sdes # release should show up in the -l (ie -lgmp5) so we don't want to 9151238104Sdes # add it in twice. Is that correct? 9152285206Sdes release= 9153285206Sdes versuffix= 9154285206Sdes major= 9155238104Sdes newdeplibs= 9156238104Sdes droppeddeps=no 9157238104Sdes case $deplibs_check_method in 9158238104Sdes pass_all) 9159238104Sdes # Don't check for shared/static. Everything works. 9160238104Sdes # This might be a little naive. We might want to check 9161238104Sdes # whether the library exists or not. But this is on 9162238104Sdes # osf3 & osf4 and I'm not really sure... Just 9163238104Sdes # implementing what was already the behavior. 9164238104Sdes newdeplibs=$deplibs 9165238104Sdes ;; 9166238104Sdes test_compile) 9167238104Sdes # This code stresses the "libraries are programs" paradigm to its 9168238104Sdes # limits. Maybe even breaks it. We compile a program, linking it 9169238104Sdes # against the deplibs as a proxy for the library. Then we can check 9170238104Sdes # whether they linked in statically or dynamically with ldd. 9171238104Sdes $opt_dry_run || $RM conftest.c 9172238104Sdes cat > conftest.c <<EOF 9173238104Sdes int main() { return 0; } 9174238104SdesEOF 9175238104Sdes $opt_dry_run || $RM conftest 9176238104Sdes if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9177238104Sdes ldd_output=`ldd conftest` 9178238104Sdes for i in $deplibs; do 9179238104Sdes case $i in 9180238104Sdes -l*) 9181238104Sdes func_stripname -l '' "$i" 9182238104Sdes name=$func_stripname_result 9183285206Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9184238104Sdes case " $predeps $postdeps " in 9185238104Sdes *" $i "*) 9186238104Sdes func_append newdeplibs " $i" 9187285206Sdes i= 9188238104Sdes ;; 9189238104Sdes esac 9190238104Sdes fi 9191285206Sdes if test -n "$i"; then 9192238104Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 9193238104Sdes deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9194238104Sdes set dummy $deplib_matches; shift 9195238104Sdes deplib_match=$1 9196285206Sdes if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9197238104Sdes func_append newdeplibs " $i" 9198238104Sdes else 9199238104Sdes droppeddeps=yes 9200238104Sdes echo 9201238104Sdes $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9202238104Sdes echo "*** I have the capability to make that library automatically link in when" 9203238104Sdes echo "*** you link to this library. But I can only do this if you have a" 9204238104Sdes echo "*** shared version of the library, which I believe you do not have" 9205238104Sdes echo "*** because a test_compile did reveal that the linker did not use it for" 9206238104Sdes echo "*** its dynamic dependency list that programs get resolved with at runtime." 9207238104Sdes fi 9208238104Sdes fi 9209238104Sdes ;; 9210238104Sdes *) 9211238104Sdes func_append newdeplibs " $i" 9212238104Sdes ;; 9213238104Sdes esac 9214238104Sdes done 9215238104Sdes else 9216238104Sdes # Error occurred in the first compile. Let's try to salvage 9217238104Sdes # the situation: Compile a separate program for each library. 9218238104Sdes for i in $deplibs; do 9219238104Sdes case $i in 9220238104Sdes -l*) 9221238104Sdes func_stripname -l '' "$i" 9222238104Sdes name=$func_stripname_result 9223238104Sdes $opt_dry_run || $RM conftest 9224238104Sdes if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9225238104Sdes ldd_output=`ldd conftest` 9226285206Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9227238104Sdes case " $predeps $postdeps " in 9228238104Sdes *" $i "*) 9229238104Sdes func_append newdeplibs " $i" 9230285206Sdes i= 9231238104Sdes ;; 9232238104Sdes esac 9233238104Sdes fi 9234285206Sdes if test -n "$i"; then 9235238104Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 9236238104Sdes deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9237238104Sdes set dummy $deplib_matches; shift 9238238104Sdes deplib_match=$1 9239285206Sdes if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9240238104Sdes func_append newdeplibs " $i" 9241238104Sdes else 9242238104Sdes droppeddeps=yes 9243238104Sdes echo 9244238104Sdes $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9245238104Sdes echo "*** I have the capability to make that library automatically link in when" 9246238104Sdes echo "*** you link to this library. But I can only do this if you have a" 9247238104Sdes echo "*** shared version of the library, which you do not appear to have" 9248238104Sdes echo "*** because a test_compile did reveal that the linker did not use this one" 9249238104Sdes echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9250238104Sdes fi 9251238104Sdes fi 9252238104Sdes else 9253238104Sdes droppeddeps=yes 9254238104Sdes echo 9255238104Sdes $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9256238104Sdes echo "*** make it link in! You will probably need to install it or some" 9257238104Sdes echo "*** library that it depends on before this library will be fully" 9258238104Sdes echo "*** functional. Installing it before continuing would be even better." 9259238104Sdes fi 9260238104Sdes ;; 9261238104Sdes *) 9262238104Sdes func_append newdeplibs " $i" 9263238104Sdes ;; 9264238104Sdes esac 9265238104Sdes done 9266238104Sdes fi 9267238104Sdes ;; 9268238104Sdes file_magic*) 9269238104Sdes set dummy $deplibs_check_method; shift 9270238104Sdes file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9271238104Sdes for a_deplib in $deplibs; do 9272238104Sdes case $a_deplib in 9273238104Sdes -l*) 9274238104Sdes func_stripname -l '' "$a_deplib" 9275238104Sdes name=$func_stripname_result 9276285206Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9277238104Sdes case " $predeps $postdeps " in 9278238104Sdes *" $a_deplib "*) 9279238104Sdes func_append newdeplibs " $a_deplib" 9280285206Sdes a_deplib= 9281238104Sdes ;; 9282238104Sdes esac 9283238104Sdes fi 9284285206Sdes if test -n "$a_deplib"; then 9285238104Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 9286238104Sdes if test -n "$file_magic_glob"; then 9287238104Sdes libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9288238104Sdes else 9289238104Sdes libnameglob=$libname 9290238104Sdes fi 9291285206Sdes test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9292238104Sdes for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9293285206Sdes if test yes = "$want_nocaseglob"; then 9294238104Sdes shopt -s nocaseglob 9295238104Sdes potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9296238104Sdes $nocaseglob 9297238104Sdes else 9298238104Sdes potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9299238104Sdes fi 9300238104Sdes for potent_lib in $potential_libs; do 9301238104Sdes # Follow soft links. 9302238104Sdes if ls -lLd "$potent_lib" 2>/dev/null | 9303238104Sdes $GREP " -> " >/dev/null; then 9304238104Sdes continue 9305238104Sdes fi 9306238104Sdes # The statement above tries to avoid entering an 9307238104Sdes # endless loop below, in case of cyclic links. 9308238104Sdes # We might still enter an endless loop, since a link 9309238104Sdes # loop can be closed while we follow links, 9310238104Sdes # but so what? 9311285206Sdes potlib=$potent_lib 9312238104Sdes while test -h "$potlib" 2>/dev/null; do 9313285206Sdes potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9314238104Sdes case $potliblink in 9315285206Sdes [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9316285206Sdes *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9317238104Sdes esac 9318238104Sdes done 9319238104Sdes if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9320238104Sdes $SED -e 10q | 9321238104Sdes $EGREP "$file_magic_regex" > /dev/null; then 9322238104Sdes func_append newdeplibs " $a_deplib" 9323285206Sdes a_deplib= 9324238104Sdes break 2 9325238104Sdes fi 9326238104Sdes done 9327238104Sdes done 9328238104Sdes fi 9329285206Sdes if test -n "$a_deplib"; then 9330238104Sdes droppeddeps=yes 9331238104Sdes echo 9332238104Sdes $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9333238104Sdes echo "*** I have the capability to make that library automatically link in when" 9334238104Sdes echo "*** you link to this library. But I can only do this if you have a" 9335238104Sdes echo "*** shared version of the library, which you do not appear to have" 9336238104Sdes echo "*** because I did check the linker path looking for a file starting" 9337285206Sdes if test -z "$potlib"; then 9338238104Sdes $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9339238104Sdes else 9340238104Sdes $ECHO "*** with $libname and none of the candidates passed a file format test" 9341238104Sdes $ECHO "*** using a file magic. Last file checked: $potlib" 9342238104Sdes fi 9343238104Sdes fi 9344238104Sdes ;; 9345238104Sdes *) 9346238104Sdes # Add a -L argument. 9347238104Sdes func_append newdeplibs " $a_deplib" 9348238104Sdes ;; 9349238104Sdes esac 9350238104Sdes done # Gone through all deplibs. 9351238104Sdes ;; 9352238104Sdes match_pattern*) 9353238104Sdes set dummy $deplibs_check_method; shift 9354238104Sdes match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9355238104Sdes for a_deplib in $deplibs; do 9356238104Sdes case $a_deplib in 9357238104Sdes -l*) 9358238104Sdes func_stripname -l '' "$a_deplib" 9359238104Sdes name=$func_stripname_result 9360285206Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9361238104Sdes case " $predeps $postdeps " in 9362238104Sdes *" $a_deplib "*) 9363238104Sdes func_append newdeplibs " $a_deplib" 9364285206Sdes a_deplib= 9365238104Sdes ;; 9366238104Sdes esac 9367238104Sdes fi 9368285206Sdes if test -n "$a_deplib"; then 9369238104Sdes libname=`eval "\\$ECHO \"$libname_spec\""` 9370238104Sdes for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9371238104Sdes potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9372238104Sdes for potent_lib in $potential_libs; do 9373285206Sdes potlib=$potent_lib # see symlink-check above in file_magic test 9374238104Sdes if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9375238104Sdes $EGREP "$match_pattern_regex" > /dev/null; then 9376238104Sdes func_append newdeplibs " $a_deplib" 9377285206Sdes a_deplib= 9378238104Sdes break 2 9379238104Sdes fi 9380238104Sdes done 9381238104Sdes done 9382238104Sdes fi 9383285206Sdes if test -n "$a_deplib"; then 9384238104Sdes droppeddeps=yes 9385238104Sdes echo 9386238104Sdes $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9387238104Sdes echo "*** I have the capability to make that library automatically link in when" 9388238104Sdes echo "*** you link to this library. But I can only do this if you have a" 9389238104Sdes echo "*** shared version of the library, which you do not appear to have" 9390238104Sdes echo "*** because I did check the linker path looking for a file starting" 9391285206Sdes if test -z "$potlib"; then 9392238104Sdes $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9393238104Sdes else 9394238104Sdes $ECHO "*** with $libname and none of the candidates passed a file format test" 9395238104Sdes $ECHO "*** using a regex pattern. Last file checked: $potlib" 9396238104Sdes fi 9397238104Sdes fi 9398238104Sdes ;; 9399238104Sdes *) 9400238104Sdes # Add a -L argument. 9401238104Sdes func_append newdeplibs " $a_deplib" 9402238104Sdes ;; 9403238104Sdes esac 9404238104Sdes done # Gone through all deplibs. 9405238104Sdes ;; 9406238104Sdes none | unknown | *) 9407285206Sdes newdeplibs= 9408238104Sdes tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9409285206Sdes if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9410285206Sdes for i in $predeps $postdeps; do 9411238104Sdes # can't use Xsed below, because $i might contain '/' 9412285206Sdes tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9413238104Sdes done 9414238104Sdes fi 9415238104Sdes case $tmp_deplibs in 9416238104Sdes *[!\ \ ]*) 9417238104Sdes echo 9418285206Sdes if test none = "$deplibs_check_method"; then 9419238104Sdes echo "*** Warning: inter-library dependencies are not supported in this platform." 9420238104Sdes else 9421238104Sdes echo "*** Warning: inter-library dependencies are not known to be supported." 9422238104Sdes fi 9423238104Sdes echo "*** All declared inter-library dependencies are being dropped." 9424238104Sdes droppeddeps=yes 9425238104Sdes ;; 9426238104Sdes esac 9427238104Sdes ;; 9428238104Sdes esac 9429238104Sdes versuffix=$versuffix_save 9430238104Sdes major=$major_save 9431238104Sdes release=$release_save 9432238104Sdes libname=$libname_save 9433238104Sdes name=$name_save 9434238104Sdes 9435238104Sdes case $host in 9436238104Sdes *-*-rhapsody* | *-*-darwin1.[012]) 9437238104Sdes # On Rhapsody replace the C library with the System framework 9438238104Sdes newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9439238104Sdes ;; 9440238104Sdes esac 9441238104Sdes 9442285206Sdes if test yes = "$droppeddeps"; then 9443285206Sdes if test yes = "$module"; then 9444238104Sdes echo 9445238104Sdes echo "*** Warning: libtool could not satisfy all declared inter-library" 9446238104Sdes $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9447238104Sdes echo "*** a static module, that should work as long as the dlopening" 9448238104Sdes echo "*** application is linked with the -dlopen flag." 9449238104Sdes if test -z "$global_symbol_pipe"; then 9450238104Sdes echo 9451238104Sdes echo "*** However, this would only work if libtool was able to extract symbol" 9452285206Sdes echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9453238104Sdes echo "*** not find such a program. So, this module is probably useless." 9454285206Sdes echo "*** 'nm' from GNU binutils and a full rebuild may help." 9455238104Sdes fi 9456285206Sdes if test no = "$build_old_libs"; then 9457285206Sdes oldlibs=$output_objdir/$libname.$libext 9458238104Sdes build_libtool_libs=module 9459238104Sdes build_old_libs=yes 9460238104Sdes else 9461238104Sdes build_libtool_libs=no 9462238104Sdes fi 9463238104Sdes else 9464238104Sdes echo "*** The inter-library dependencies that have been dropped here will be" 9465238104Sdes echo "*** automatically added whenever a program is linked with this library" 9466238104Sdes echo "*** or is declared to -dlopen it." 9467238104Sdes 9468285206Sdes if test no = "$allow_undefined"; then 9469238104Sdes echo 9470238104Sdes echo "*** Since this library must not contain undefined symbols," 9471238104Sdes echo "*** because either the platform does not support them or" 9472238104Sdes echo "*** it was explicitly requested with -no-undefined," 9473238104Sdes echo "*** libtool will only create a static version of it." 9474285206Sdes if test no = "$build_old_libs"; then 9475285206Sdes oldlibs=$output_objdir/$libname.$libext 9476238104Sdes build_libtool_libs=module 9477238104Sdes build_old_libs=yes 9478238104Sdes else 9479238104Sdes build_libtool_libs=no 9480238104Sdes fi 9481238104Sdes fi 9482238104Sdes fi 9483238104Sdes fi 9484238104Sdes # Done checking deplibs! 9485238104Sdes deplibs=$newdeplibs 9486238104Sdes fi 9487238104Sdes # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9488238104Sdes case $host in 9489238104Sdes *-*-darwin*) 9490238104Sdes newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9491238104Sdes new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9492238104Sdes deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493238104Sdes ;; 9494238104Sdes esac 9495238104Sdes 9496238104Sdes # move library search paths that coincide with paths to not yet 9497238104Sdes # installed libraries to the beginning of the library search list 9498238104Sdes new_libs= 9499238104Sdes for path in $notinst_path; do 9500238104Sdes case " $new_libs " in 9501238104Sdes *" -L$path/$objdir "*) ;; 9502238104Sdes *) 9503238104Sdes case " $deplibs " in 9504238104Sdes *" -L$path/$objdir "*) 9505238104Sdes func_append new_libs " -L$path/$objdir" ;; 9506238104Sdes esac 9507238104Sdes ;; 9508238104Sdes esac 9509238104Sdes done 9510238104Sdes for deplib in $deplibs; do 9511238104Sdes case $deplib in 9512238104Sdes -L*) 9513238104Sdes case " $new_libs " in 9514238104Sdes *" $deplib "*) ;; 9515238104Sdes *) func_append new_libs " $deplib" ;; 9516238104Sdes esac 9517238104Sdes ;; 9518238104Sdes *) func_append new_libs " $deplib" ;; 9519238104Sdes esac 9520238104Sdes done 9521285206Sdes deplibs=$new_libs 9522238104Sdes 9523238104Sdes # All the library-specific variables (install_libdir is set above). 9524238104Sdes library_names= 9525238104Sdes old_library= 9526238104Sdes dlname= 9527238104Sdes 9528238104Sdes # Test again, we may have decided not to build it any more 9529285206Sdes if test yes = "$build_libtool_libs"; then 9530285206Sdes # Remove $wl instances when linking with ld. 9531238104Sdes # FIXME: should test the right _cmds variable. 9532238104Sdes case $archive_cmds in 9533238104Sdes *\$LD\ *) wl= ;; 9534238104Sdes esac 9535285206Sdes if test yes = "$hardcode_into_libs"; then 9536238104Sdes # Hardcode the library paths 9537238104Sdes hardcode_libdirs= 9538238104Sdes dep_rpath= 9539285206Sdes rpath=$finalize_rpath 9540285206Sdes test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9541238104Sdes for libdir in $rpath; do 9542238104Sdes if test -n "$hardcode_libdir_flag_spec"; then 9543238104Sdes if test -n "$hardcode_libdir_separator"; then 9544238104Sdes func_replace_sysroot "$libdir" 9545238104Sdes libdir=$func_replace_sysroot_result 9546238104Sdes if test -z "$hardcode_libdirs"; then 9547285206Sdes hardcode_libdirs=$libdir 9548238104Sdes else 9549238104Sdes # Just accumulate the unique libdirs. 9550238104Sdes case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9551238104Sdes *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9552238104Sdes ;; 9553238104Sdes *) 9554238104Sdes func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9555238104Sdes ;; 9556238104Sdes esac 9557238104Sdes fi 9558238104Sdes else 9559238104Sdes eval flag=\"$hardcode_libdir_flag_spec\" 9560238104Sdes func_append dep_rpath " $flag" 9561238104Sdes fi 9562238104Sdes elif test -n "$runpath_var"; then 9563238104Sdes case "$perm_rpath " in 9564238104Sdes *" $libdir "*) ;; 9565238104Sdes *) func_append perm_rpath " $libdir" ;; 9566238104Sdes esac 9567238104Sdes fi 9568238104Sdes done 9569238104Sdes # Substitute the hardcoded libdirs into the rpath. 9570238104Sdes if test -n "$hardcode_libdir_separator" && 9571238104Sdes test -n "$hardcode_libdirs"; then 9572285206Sdes libdir=$hardcode_libdirs 9573238104Sdes eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9574238104Sdes fi 9575238104Sdes if test -n "$runpath_var" && test -n "$perm_rpath"; then 9576238104Sdes # We should set the runpath_var. 9577238104Sdes rpath= 9578238104Sdes for dir in $perm_rpath; do 9579238104Sdes func_append rpath "$dir:" 9580238104Sdes done 9581238104Sdes eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9582238104Sdes fi 9583238104Sdes test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584238104Sdes fi 9585238104Sdes 9586285206Sdes shlibpath=$finalize_shlibpath 9587285206Sdes test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9588238104Sdes if test -n "$shlibpath"; then 9589238104Sdes eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590238104Sdes fi 9591238104Sdes 9592238104Sdes # Get the real and link names of the library. 9593238104Sdes eval shared_ext=\"$shrext_cmds\" 9594238104Sdes eval library_names=\"$library_names_spec\" 9595238104Sdes set dummy $library_names 9596238104Sdes shift 9597285206Sdes realname=$1 9598238104Sdes shift 9599238104Sdes 9600238104Sdes if test -n "$soname_spec"; then 9601238104Sdes eval soname=\"$soname_spec\" 9602238104Sdes else 9603285206Sdes soname=$realname 9604238104Sdes fi 9605238104Sdes if test -z "$dlname"; then 9606238104Sdes dlname=$soname 9607238104Sdes fi 9608238104Sdes 9609285206Sdes lib=$output_objdir/$realname 9610238104Sdes linknames= 9611238104Sdes for link 9612238104Sdes do 9613238104Sdes func_append linknames " $link" 9614238104Sdes done 9615238104Sdes 9616238104Sdes # Use standard objects if they are pic 9617238104Sdes test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9618238104Sdes test "X$libobjs" = "X " && libobjs= 9619238104Sdes 9620238104Sdes delfiles= 9621238104Sdes if test -n "$export_symbols" && test -n "$include_expsyms"; then 9622238104Sdes $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9623285206Sdes export_symbols=$output_objdir/$libname.uexp 9624238104Sdes func_append delfiles " $export_symbols" 9625238104Sdes fi 9626238104Sdes 9627238104Sdes orig_export_symbols= 9628238104Sdes case $host_os in 9629238104Sdes cygwin* | mingw* | cegcc*) 9630238104Sdes if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9631238104Sdes # exporting using user supplied symfile 9632285206Sdes func_dll_def_p "$export_symbols" || { 9633238104Sdes # and it's NOT already a .def file. Must figure out 9634238104Sdes # which of the given symbols are data symbols and tag 9635238104Sdes # them as such. So, trigger use of export_symbols_cmds. 9636238104Sdes # export_symbols gets reassigned inside the "prepare 9637238104Sdes # the list of exported symbols" if statement, so the 9638238104Sdes # include_expsyms logic still works. 9639285206Sdes orig_export_symbols=$export_symbols 9640238104Sdes export_symbols= 9641238104Sdes always_export_symbols=yes 9642285206Sdes } 9643238104Sdes fi 9644238104Sdes ;; 9645238104Sdes esac 9646238104Sdes 9647238104Sdes # Prepare the list of exported symbols 9648238104Sdes if test -z "$export_symbols"; then 9649285206Sdes if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9650285206Sdes func_verbose "generating symbol list for '$libname.la'" 9651285206Sdes export_symbols=$output_objdir/$libname.exp 9652238104Sdes $opt_dry_run || $RM $export_symbols 9653238104Sdes cmds=$export_symbols_cmds 9654285206Sdes save_ifs=$IFS; IFS='~' 9655238104Sdes for cmd1 in $cmds; do 9656285206Sdes IFS=$save_ifs 9657238104Sdes # Take the normal branch if the nm_file_list_spec branch 9658238104Sdes # doesn't work or if tool conversion is not needed. 9659238104Sdes case $nm_file_list_spec~$to_tool_file_cmd in 9660238104Sdes *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9661238104Sdes try_normal_branch=yes 9662238104Sdes eval cmd=\"$cmd1\" 9663238104Sdes func_len " $cmd" 9664238104Sdes len=$func_len_result 9665238104Sdes ;; 9666238104Sdes *) 9667238104Sdes try_normal_branch=no 9668238104Sdes ;; 9669238104Sdes esac 9670285206Sdes if test yes = "$try_normal_branch" \ 9671238104Sdes && { test "$len" -lt "$max_cmd_len" \ 9672238104Sdes || test "$max_cmd_len" -le -1; } 9673238104Sdes then 9674238104Sdes func_show_eval "$cmd" 'exit $?' 9675238104Sdes skipped_export=false 9676238104Sdes elif test -n "$nm_file_list_spec"; then 9677238104Sdes func_basename "$output" 9678238104Sdes output_la=$func_basename_result 9679238104Sdes save_libobjs=$libobjs 9680238104Sdes save_output=$output 9681285206Sdes output=$output_objdir/$output_la.nm 9682238104Sdes func_to_tool_file "$output" 9683238104Sdes libobjs=$nm_file_list_spec$func_to_tool_file_result 9684238104Sdes func_append delfiles " $output" 9685238104Sdes func_verbose "creating $NM input file list: $output" 9686238104Sdes for obj in $save_libobjs; do 9687238104Sdes func_to_tool_file "$obj" 9688238104Sdes $ECHO "$func_to_tool_file_result" 9689238104Sdes done > "$output" 9690238104Sdes eval cmd=\"$cmd1\" 9691238104Sdes func_show_eval "$cmd" 'exit $?' 9692238104Sdes output=$save_output 9693238104Sdes libobjs=$save_libobjs 9694238104Sdes skipped_export=false 9695238104Sdes else 9696238104Sdes # The command line is too long to execute in one step. 9697238104Sdes func_verbose "using reloadable object file for export list..." 9698238104Sdes skipped_export=: 9699238104Sdes # Break out early, otherwise skipped_export may be 9700238104Sdes # set to false by a later but shorter cmd. 9701238104Sdes break 9702238104Sdes fi 9703238104Sdes done 9704285206Sdes IFS=$save_ifs 9705285206Sdes if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9706238104Sdes func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9707238104Sdes func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9708238104Sdes fi 9709238104Sdes fi 9710238104Sdes fi 9711238104Sdes 9712238104Sdes if test -n "$export_symbols" && test -n "$include_expsyms"; then 9713285206Sdes tmp_export_symbols=$export_symbols 9714285206Sdes test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9715238104Sdes $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716238104Sdes fi 9717238104Sdes 9718285206Sdes if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9719238104Sdes # The given exports_symbols file has to be filtered, so filter it. 9720285206Sdes func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9721238104Sdes # FIXME: $output_objdir/$libname.filter potentially contains lots of 9722285206Sdes # 's' commands, which not all seds can handle. GNU sed should be fine 9723238104Sdes # though. Also, the filter scales superlinearly with the number of 9724238104Sdes # global variables. join(1) would be nice here, but unfortunately 9725238104Sdes # isn't a blessed tool. 9726238104Sdes $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9727238104Sdes func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9728238104Sdes export_symbols=$output_objdir/$libname.def 9729238104Sdes $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9730238104Sdes fi 9731238104Sdes 9732238104Sdes tmp_deplibs= 9733238104Sdes for test_deplib in $deplibs; do 9734238104Sdes case " $convenience " in 9735238104Sdes *" $test_deplib "*) ;; 9736238104Sdes *) 9737238104Sdes func_append tmp_deplibs " $test_deplib" 9738238104Sdes ;; 9739238104Sdes esac 9740238104Sdes done 9741285206Sdes deplibs=$tmp_deplibs 9742238104Sdes 9743238104Sdes if test -n "$convenience"; then 9744238104Sdes if test -n "$whole_archive_flag_spec" && 9745285206Sdes test yes = "$compiler_needs_object" && 9746238104Sdes test -z "$libobjs"; then 9747238104Sdes # extract the archives, so we have objects to list. 9748238104Sdes # TODO: could optimize this to just extract one archive. 9749238104Sdes whole_archive_flag_spec= 9750238104Sdes fi 9751238104Sdes if test -n "$whole_archive_flag_spec"; then 9752238104Sdes save_libobjs=$libobjs 9753238104Sdes eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9754238104Sdes test "X$libobjs" = "X " && libobjs= 9755238104Sdes else 9756285206Sdes gentop=$output_objdir/${outputname}x 9757238104Sdes func_append generated " $gentop" 9758238104Sdes 9759238104Sdes func_extract_archives $gentop $convenience 9760238104Sdes func_append libobjs " $func_extract_archives_result" 9761238104Sdes test "X$libobjs" = "X " && libobjs= 9762238104Sdes fi 9763238104Sdes fi 9764238104Sdes 9765285206Sdes if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9766238104Sdes eval flag=\"$thread_safe_flag_spec\" 9767238104Sdes func_append linker_flags " $flag" 9768238104Sdes fi 9769238104Sdes 9770238104Sdes # Make a backup of the uninstalled library when relinking 9771285206Sdes if test relink = "$opt_mode"; then 9772238104Sdes $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9773238104Sdes fi 9774238104Sdes 9775238104Sdes # Do each of the archive commands. 9776285206Sdes if test yes = "$module" && test -n "$module_cmds"; then 9777238104Sdes if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9778238104Sdes eval test_cmds=\"$module_expsym_cmds\" 9779238104Sdes cmds=$module_expsym_cmds 9780238104Sdes else 9781238104Sdes eval test_cmds=\"$module_cmds\" 9782238104Sdes cmds=$module_cmds 9783238104Sdes fi 9784238104Sdes else 9785238104Sdes if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9786238104Sdes eval test_cmds=\"$archive_expsym_cmds\" 9787238104Sdes cmds=$archive_expsym_cmds 9788238104Sdes else 9789238104Sdes eval test_cmds=\"$archive_cmds\" 9790238104Sdes cmds=$archive_cmds 9791238104Sdes fi 9792238104Sdes fi 9793238104Sdes 9794285206Sdes if test : != "$skipped_export" && 9795238104Sdes func_len " $test_cmds" && 9796238104Sdes len=$func_len_result && 9797238104Sdes test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9798238104Sdes : 9799238104Sdes else 9800238104Sdes # The command line is too long to link in one step, link piecewise 9801238104Sdes # or, if using GNU ld and skipped_export is not :, use a linker 9802238104Sdes # script. 9803238104Sdes 9804238104Sdes # Save the value of $output and $libobjs because we want to 9805238104Sdes # use them later. If we have whole_archive_flag_spec, we 9806238104Sdes # want to use save_libobjs as it was before 9807238104Sdes # whole_archive_flag_spec was expanded, because we can't 9808238104Sdes # assume the linker understands whole_archive_flag_spec. 9809238104Sdes # This may have to be revisited, in case too many 9810238104Sdes # convenience libraries get linked in and end up exceeding 9811238104Sdes # the spec. 9812238104Sdes if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9813238104Sdes save_libobjs=$libobjs 9814238104Sdes fi 9815238104Sdes save_output=$output 9816238104Sdes func_basename "$output" 9817238104Sdes output_la=$func_basename_result 9818238104Sdes 9819238104Sdes # Clear the reloadable object creation command queue and 9820238104Sdes # initialize k to one. 9821238104Sdes test_cmds= 9822238104Sdes concat_cmds= 9823238104Sdes objlist= 9824238104Sdes last_robj= 9825238104Sdes k=1 9826238104Sdes 9827285206Sdes if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9828285206Sdes output=$output_objdir/$output_la.lnkscript 9829238104Sdes func_verbose "creating GNU ld script: $output" 9830238104Sdes echo 'INPUT (' > $output 9831238104Sdes for obj in $save_libobjs 9832238104Sdes do 9833238104Sdes func_to_tool_file "$obj" 9834238104Sdes $ECHO "$func_to_tool_file_result" >> $output 9835238104Sdes done 9836238104Sdes echo ')' >> $output 9837238104Sdes func_append delfiles " $output" 9838238104Sdes func_to_tool_file "$output" 9839238104Sdes output=$func_to_tool_file_result 9840285206Sdes elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9841285206Sdes output=$output_objdir/$output_la.lnk 9842238104Sdes func_verbose "creating linker input file list: $output" 9843238104Sdes : > $output 9844238104Sdes set x $save_libobjs 9845238104Sdes shift 9846238104Sdes firstobj= 9847285206Sdes if test yes = "$compiler_needs_object"; then 9848238104Sdes firstobj="$1 " 9849238104Sdes shift 9850238104Sdes fi 9851238104Sdes for obj 9852238104Sdes do 9853238104Sdes func_to_tool_file "$obj" 9854238104Sdes $ECHO "$func_to_tool_file_result" >> $output 9855238104Sdes done 9856238104Sdes func_append delfiles " $output" 9857238104Sdes func_to_tool_file "$output" 9858238104Sdes output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9859238104Sdes else 9860238104Sdes if test -n "$save_libobjs"; then 9861238104Sdes func_verbose "creating reloadable object files..." 9862285206Sdes output=$output_objdir/$output_la-$k.$objext 9863238104Sdes eval test_cmds=\"$reload_cmds\" 9864238104Sdes func_len " $test_cmds" 9865238104Sdes len0=$func_len_result 9866238104Sdes len=$len0 9867238104Sdes 9868238104Sdes # Loop over the list of objects to be linked. 9869238104Sdes for obj in $save_libobjs 9870238104Sdes do 9871238104Sdes func_len " $obj" 9872238104Sdes func_arith $len + $func_len_result 9873238104Sdes len=$func_arith_result 9874285206Sdes if test -z "$objlist" || 9875238104Sdes test "$len" -lt "$max_cmd_len"; then 9876238104Sdes func_append objlist " $obj" 9877238104Sdes else 9878238104Sdes # The command $test_cmds is almost too long, add a 9879238104Sdes # command to the queue. 9880285206Sdes if test 1 -eq "$k"; then 9881238104Sdes # The first file doesn't have a previous command to add. 9882238104Sdes reload_objs=$objlist 9883238104Sdes eval concat_cmds=\"$reload_cmds\" 9884238104Sdes else 9885238104Sdes # All subsequent reloadable object files will link in 9886238104Sdes # the last one created. 9887238104Sdes reload_objs="$objlist $last_robj" 9888238104Sdes eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9889238104Sdes fi 9890285206Sdes last_robj=$output_objdir/$output_la-$k.$objext 9891238104Sdes func_arith $k + 1 9892238104Sdes k=$func_arith_result 9893285206Sdes output=$output_objdir/$output_la-$k.$objext 9894238104Sdes objlist=" $obj" 9895238104Sdes func_len " $last_robj" 9896238104Sdes func_arith $len0 + $func_len_result 9897238104Sdes len=$func_arith_result 9898238104Sdes fi 9899238104Sdes done 9900238104Sdes # Handle the remaining objects by creating one last 9901238104Sdes # reloadable object file. All subsequent reloadable object 9902238104Sdes # files will link in the last one created. 9903238104Sdes test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9904238104Sdes reload_objs="$objlist $last_robj" 9905285206Sdes eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9906238104Sdes if test -n "$last_robj"; then 9907285206Sdes eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908238104Sdes fi 9909238104Sdes func_append delfiles " $output" 9910238104Sdes 9911238104Sdes else 9912238104Sdes output= 9913238104Sdes fi 9914238104Sdes 9915285206Sdes ${skipped_export-false} && { 9916285206Sdes func_verbose "generating symbol list for '$libname.la'" 9917285206Sdes export_symbols=$output_objdir/$libname.exp 9918238104Sdes $opt_dry_run || $RM $export_symbols 9919238104Sdes libobjs=$output 9920238104Sdes # Append the command to create the export file. 9921238104Sdes test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9922238104Sdes eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9923238104Sdes if test -n "$last_robj"; then 9924238104Sdes eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925238104Sdes fi 9926285206Sdes } 9927238104Sdes 9928238104Sdes test -n "$save_libobjs" && 9929238104Sdes func_verbose "creating a temporary reloadable object file: $output" 9930238104Sdes 9931238104Sdes # Loop through the commands generated above and execute them. 9932285206Sdes save_ifs=$IFS; IFS='~' 9933238104Sdes for cmd in $concat_cmds; do 9934285206Sdes IFS=$save_ifs 9935285206Sdes $opt_quiet || { 9936238104Sdes func_quote_for_expand "$cmd" 9937238104Sdes eval "func_echo $func_quote_for_expand_result" 9938238104Sdes } 9939238104Sdes $opt_dry_run || eval "$cmd" || { 9940238104Sdes lt_exit=$? 9941238104Sdes 9942238104Sdes # Restore the uninstalled library and exit 9943285206Sdes if test relink = "$opt_mode"; then 9944238104Sdes ( cd "$output_objdir" && \ 9945238104Sdes $RM "${realname}T" && \ 9946238104Sdes $MV "${realname}U" "$realname" ) 9947238104Sdes fi 9948238104Sdes 9949238104Sdes exit $lt_exit 9950238104Sdes } 9951238104Sdes done 9952285206Sdes IFS=$save_ifs 9953238104Sdes 9954238104Sdes if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9955238104Sdes func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9956238104Sdes func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9957238104Sdes fi 9958238104Sdes fi 9959238104Sdes 9960285206Sdes ${skipped_export-false} && { 9961238104Sdes if test -n "$export_symbols" && test -n "$include_expsyms"; then 9962285206Sdes tmp_export_symbols=$export_symbols 9963285206Sdes test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9964238104Sdes $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9965238104Sdes fi 9966238104Sdes 9967238104Sdes if test -n "$orig_export_symbols"; then 9968238104Sdes # The given exports_symbols file has to be filtered, so filter it. 9969285206Sdes func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9970238104Sdes # FIXME: $output_objdir/$libname.filter potentially contains lots of 9971285206Sdes # 's' commands, which not all seds can handle. GNU sed should be fine 9972238104Sdes # though. Also, the filter scales superlinearly with the number of 9973238104Sdes # global variables. join(1) would be nice here, but unfortunately 9974238104Sdes # isn't a blessed tool. 9975238104Sdes $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9976238104Sdes func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9977238104Sdes export_symbols=$output_objdir/$libname.def 9978238104Sdes $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9979238104Sdes fi 9980285206Sdes } 9981238104Sdes 9982238104Sdes libobjs=$output 9983238104Sdes # Restore the value of output. 9984238104Sdes output=$save_output 9985238104Sdes 9986238104Sdes if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9987238104Sdes eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9988238104Sdes test "X$libobjs" = "X " && libobjs= 9989238104Sdes fi 9990238104Sdes # Expand the library linking commands again to reset the 9991238104Sdes # value of $libobjs for piecewise linking. 9992238104Sdes 9993238104Sdes # Do each of the archive commands. 9994285206Sdes if test yes = "$module" && test -n "$module_cmds"; then 9995238104Sdes if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9996238104Sdes cmds=$module_expsym_cmds 9997238104Sdes else 9998238104Sdes cmds=$module_cmds 9999238104Sdes fi 10000238104Sdes else 10001238104Sdes if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10002238104Sdes cmds=$archive_expsym_cmds 10003238104Sdes else 10004238104Sdes cmds=$archive_cmds 10005238104Sdes fi 10006238104Sdes fi 10007238104Sdes fi 10008238104Sdes 10009238104Sdes if test -n "$delfiles"; then 10010238104Sdes # Append the command to remove temporary files to $cmds. 10011238104Sdes eval cmds=\"\$cmds~\$RM $delfiles\" 10012238104Sdes fi 10013238104Sdes 10014238104Sdes # Add any objects from preloaded convenience libraries 10015238104Sdes if test -n "$dlprefiles"; then 10016285206Sdes gentop=$output_objdir/${outputname}x 10017238104Sdes func_append generated " $gentop" 10018238104Sdes 10019238104Sdes func_extract_archives $gentop $dlprefiles 10020238104Sdes func_append libobjs " $func_extract_archives_result" 10021238104Sdes test "X$libobjs" = "X " && libobjs= 10022238104Sdes fi 10023238104Sdes 10024285206Sdes save_ifs=$IFS; IFS='~' 10025238104Sdes for cmd in $cmds; do 10026285206Sdes IFS=$sp$nl 10027238104Sdes eval cmd=\"$cmd\" 10028285206Sdes IFS=$save_ifs 10029285206Sdes $opt_quiet || { 10030238104Sdes func_quote_for_expand "$cmd" 10031238104Sdes eval "func_echo $func_quote_for_expand_result" 10032238104Sdes } 10033238104Sdes $opt_dry_run || eval "$cmd" || { 10034238104Sdes lt_exit=$? 10035238104Sdes 10036238104Sdes # Restore the uninstalled library and exit 10037285206Sdes if test relink = "$opt_mode"; then 10038238104Sdes ( cd "$output_objdir" && \ 10039238104Sdes $RM "${realname}T" && \ 10040238104Sdes $MV "${realname}U" "$realname" ) 10041238104Sdes fi 10042238104Sdes 10043238104Sdes exit $lt_exit 10044238104Sdes } 10045238104Sdes done 10046285206Sdes IFS=$save_ifs 10047238104Sdes 10048238104Sdes # Restore the uninstalled library and exit 10049285206Sdes if test relink = "$opt_mode"; then 10050238104Sdes $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051238104Sdes 10052238104Sdes if test -n "$convenience"; then 10053238104Sdes if test -z "$whole_archive_flag_spec"; then 10054238104Sdes func_show_eval '${RM}r "$gentop"' 10055238104Sdes fi 10056238104Sdes fi 10057238104Sdes 10058238104Sdes exit $EXIT_SUCCESS 10059238104Sdes fi 10060238104Sdes 10061238104Sdes # Create links to the real library. 10062238104Sdes for linkname in $linknames; do 10063238104Sdes if test "$realname" != "$linkname"; then 10064238104Sdes func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065238104Sdes fi 10066238104Sdes done 10067238104Sdes 10068238104Sdes # If -module or -export-dynamic was specified, set the dlname. 10069285206Sdes if test yes = "$module" || test yes = "$export_dynamic"; then 10070238104Sdes # On all known operating systems, these are identical. 10071285206Sdes dlname=$soname 10072238104Sdes fi 10073238104Sdes fi 10074238104Sdes ;; 10075238104Sdes 10076238104Sdes obj) 10077285206Sdes if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10078285206Sdes func_warning "'-dlopen' is ignored for objects" 10079238104Sdes fi 10080238104Sdes 10081238104Sdes case " $deplibs" in 10082238104Sdes *\ -l* | *\ -L*) 10083285206Sdes func_warning "'-l' and '-L' are ignored for objects" ;; 10084238104Sdes esac 10085238104Sdes 10086238104Sdes test -n "$rpath" && \ 10087285206Sdes func_warning "'-rpath' is ignored for objects" 10088238104Sdes 10089238104Sdes test -n "$xrpath" && \ 10090285206Sdes func_warning "'-R' is ignored for objects" 10091238104Sdes 10092238104Sdes test -n "$vinfo" && \ 10093285206Sdes func_warning "'-version-info' is ignored for objects" 10094238104Sdes 10095238104Sdes test -n "$release" && \ 10096285206Sdes func_warning "'-release' is ignored for objects" 10097238104Sdes 10098238104Sdes case $output in 10099238104Sdes *.lo) 10100238104Sdes test -n "$objs$old_deplibs" && \ 10101285206Sdes func_fatal_error "cannot build library object '$output' from non-libtool objects" 10102238104Sdes 10103238104Sdes libobj=$output 10104238104Sdes func_lo2o "$libobj" 10105238104Sdes obj=$func_lo2o_result 10106238104Sdes ;; 10107238104Sdes *) 10108238104Sdes libobj= 10109285206Sdes obj=$output 10110238104Sdes ;; 10111238104Sdes esac 10112238104Sdes 10113238104Sdes # Delete the old objects. 10114238104Sdes $opt_dry_run || $RM $obj $libobj 10115238104Sdes 10116238104Sdes # Objects from convenience libraries. This assumes 10117238104Sdes # single-version convenience libraries. Whenever we create 10118238104Sdes # different ones for PIC/non-PIC, this we'll have to duplicate 10119238104Sdes # the extraction. 10120238104Sdes reload_conv_objs= 10121238104Sdes gentop= 10122285206Sdes # if reload_cmds runs $LD directly, get rid of -Wl from 10123285206Sdes # whole_archive_flag_spec and hope we can get by with turning comma 10124285206Sdes # into space. 10125285206Sdes case $reload_cmds in 10126285206Sdes *\$LD[\ \$]*) wl= ;; 10127285206Sdes esac 10128238104Sdes if test -n "$convenience"; then 10129238104Sdes if test -n "$whole_archive_flag_spec"; then 10130238104Sdes eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10131285206Sdes test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10132285206Sdes reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133238104Sdes else 10134285206Sdes gentop=$output_objdir/${obj}x 10135238104Sdes func_append generated " $gentop" 10136238104Sdes 10137238104Sdes func_extract_archives $gentop $convenience 10138238104Sdes reload_conv_objs="$reload_objs $func_extract_archives_result" 10139238104Sdes fi 10140238104Sdes fi 10141238104Sdes 10142238104Sdes # If we're not building shared, we need to use non_pic_objs 10143285206Sdes test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144238104Sdes 10145238104Sdes # Create the old-style object. 10146285206Sdes reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147238104Sdes 10148285206Sdes output=$obj 10149238104Sdes func_execute_cmds "$reload_cmds" 'exit $?' 10150238104Sdes 10151238104Sdes # Exit if we aren't doing a library object file. 10152238104Sdes if test -z "$libobj"; then 10153238104Sdes if test -n "$gentop"; then 10154238104Sdes func_show_eval '${RM}r "$gentop"' 10155238104Sdes fi 10156238104Sdes 10157238104Sdes exit $EXIT_SUCCESS 10158238104Sdes fi 10159238104Sdes 10160285206Sdes test yes = "$build_libtool_libs" || { 10161238104Sdes if test -n "$gentop"; then 10162238104Sdes func_show_eval '${RM}r "$gentop"' 10163238104Sdes fi 10164238104Sdes 10165238104Sdes # Create an invalid libtool object if no PIC, so that we don't 10166238104Sdes # accidentally link it into a program. 10167238104Sdes # $show "echo timestamp > $libobj" 10168238104Sdes # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10169238104Sdes exit $EXIT_SUCCESS 10170285206Sdes } 10171238104Sdes 10172285206Sdes if test -n "$pic_flag" || test default != "$pic_mode"; then 10173238104Sdes # Only do commands if we really have different PIC objects. 10174238104Sdes reload_objs="$libobjs $reload_conv_objs" 10175285206Sdes output=$libobj 10176238104Sdes func_execute_cmds "$reload_cmds" 'exit $?' 10177238104Sdes fi 10178238104Sdes 10179238104Sdes if test -n "$gentop"; then 10180238104Sdes func_show_eval '${RM}r "$gentop"' 10181238104Sdes fi 10182238104Sdes 10183238104Sdes exit $EXIT_SUCCESS 10184238104Sdes ;; 10185238104Sdes 10186238104Sdes prog) 10187238104Sdes case $host in 10188238104Sdes *cygwin*) func_stripname '' '.exe' "$output" 10189238104Sdes output=$func_stripname_result.exe;; 10190238104Sdes esac 10191238104Sdes test -n "$vinfo" && \ 10192285206Sdes func_warning "'-version-info' is ignored for programs" 10193238104Sdes 10194238104Sdes test -n "$release" && \ 10195285206Sdes func_warning "'-release' is ignored for programs" 10196238104Sdes 10197285206Sdes $preload \ 10198285206Sdes && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10199285206Sdes && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10200238104Sdes 10201238104Sdes case $host in 10202238104Sdes *-*-rhapsody* | *-*-darwin1.[012]) 10203238104Sdes # On Rhapsody replace the C library is the System framework 10204238104Sdes compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10205238104Sdes finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206238104Sdes ;; 10207238104Sdes esac 10208238104Sdes 10209238104Sdes case $host in 10210238104Sdes *-*-darwin*) 10211238104Sdes # Don't allow lazy linking, it breaks C++ global constructors 10212238104Sdes # But is supposedly fixed on 10.4 or later (yay!). 10213285206Sdes if test CXX = "$tagname"; then 10214238104Sdes case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10215238104Sdes 10.[0123]) 10216285206Sdes func_append compile_command " $wl-bind_at_load" 10217285206Sdes func_append finalize_command " $wl-bind_at_load" 10218238104Sdes ;; 10219238104Sdes esac 10220238104Sdes fi 10221238104Sdes # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10222238104Sdes compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10223238104Sdes finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10224238104Sdes ;; 10225238104Sdes esac 10226238104Sdes 10227238104Sdes 10228238104Sdes # move library search paths that coincide with paths to not yet 10229238104Sdes # installed libraries to the beginning of the library search list 10230238104Sdes new_libs= 10231238104Sdes for path in $notinst_path; do 10232238104Sdes case " $new_libs " in 10233238104Sdes *" -L$path/$objdir "*) ;; 10234238104Sdes *) 10235238104Sdes case " $compile_deplibs " in 10236238104Sdes *" -L$path/$objdir "*) 10237238104Sdes func_append new_libs " -L$path/$objdir" ;; 10238238104Sdes esac 10239238104Sdes ;; 10240238104Sdes esac 10241238104Sdes done 10242238104Sdes for deplib in $compile_deplibs; do 10243238104Sdes case $deplib in 10244238104Sdes -L*) 10245238104Sdes case " $new_libs " in 10246238104Sdes *" $deplib "*) ;; 10247238104Sdes *) func_append new_libs " $deplib" ;; 10248238104Sdes esac 10249238104Sdes ;; 10250238104Sdes *) func_append new_libs " $deplib" ;; 10251238104Sdes esac 10252238104Sdes done 10253285206Sdes compile_deplibs=$new_libs 10254238104Sdes 10255238104Sdes 10256238104Sdes func_append compile_command " $compile_deplibs" 10257238104Sdes func_append finalize_command " $finalize_deplibs" 10258238104Sdes 10259238104Sdes if test -n "$rpath$xrpath"; then 10260238104Sdes # If the user specified any rpath flags, then add them. 10261238104Sdes for libdir in $rpath $xrpath; do 10262238104Sdes # This is the magic to use -rpath. 10263238104Sdes case "$finalize_rpath " in 10264238104Sdes *" $libdir "*) ;; 10265238104Sdes *) func_append finalize_rpath " $libdir" ;; 10266238104Sdes esac 10267238104Sdes done 10268238104Sdes fi 10269238104Sdes 10270238104Sdes # Now hardcode the library paths 10271238104Sdes rpath= 10272238104Sdes hardcode_libdirs= 10273238104Sdes for libdir in $compile_rpath $finalize_rpath; do 10274238104Sdes if test -n "$hardcode_libdir_flag_spec"; then 10275238104Sdes if test -n "$hardcode_libdir_separator"; then 10276238104Sdes if test -z "$hardcode_libdirs"; then 10277285206Sdes hardcode_libdirs=$libdir 10278238104Sdes else 10279238104Sdes # Just accumulate the unique libdirs. 10280238104Sdes case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10281238104Sdes *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10282238104Sdes ;; 10283238104Sdes *) 10284238104Sdes func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10285238104Sdes ;; 10286238104Sdes esac 10287238104Sdes fi 10288238104Sdes else 10289238104Sdes eval flag=\"$hardcode_libdir_flag_spec\" 10290238104Sdes func_append rpath " $flag" 10291238104Sdes fi 10292238104Sdes elif test -n "$runpath_var"; then 10293238104Sdes case "$perm_rpath " in 10294238104Sdes *" $libdir "*) ;; 10295238104Sdes *) func_append perm_rpath " $libdir" ;; 10296238104Sdes esac 10297238104Sdes fi 10298238104Sdes case $host in 10299238104Sdes *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10300285206Sdes testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10301238104Sdes case :$dllsearchpath: in 10302238104Sdes *":$libdir:"*) ;; 10303238104Sdes ::) dllsearchpath=$libdir;; 10304238104Sdes *) func_append dllsearchpath ":$libdir";; 10305238104Sdes esac 10306238104Sdes case :$dllsearchpath: in 10307238104Sdes *":$testbindir:"*) ;; 10308238104Sdes ::) dllsearchpath=$testbindir;; 10309238104Sdes *) func_append dllsearchpath ":$testbindir";; 10310238104Sdes esac 10311238104Sdes ;; 10312238104Sdes esac 10313238104Sdes done 10314238104Sdes # Substitute the hardcoded libdirs into the rpath. 10315238104Sdes if test -n "$hardcode_libdir_separator" && 10316238104Sdes test -n "$hardcode_libdirs"; then 10317285206Sdes libdir=$hardcode_libdirs 10318238104Sdes eval rpath=\" $hardcode_libdir_flag_spec\" 10319238104Sdes fi 10320285206Sdes compile_rpath=$rpath 10321238104Sdes 10322238104Sdes rpath= 10323238104Sdes hardcode_libdirs= 10324238104Sdes for libdir in $finalize_rpath; do 10325238104Sdes if test -n "$hardcode_libdir_flag_spec"; then 10326238104Sdes if test -n "$hardcode_libdir_separator"; then 10327238104Sdes if test -z "$hardcode_libdirs"; then 10328285206Sdes hardcode_libdirs=$libdir 10329238104Sdes else 10330238104Sdes # Just accumulate the unique libdirs. 10331238104Sdes case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10332238104Sdes *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10333238104Sdes ;; 10334238104Sdes *) 10335238104Sdes func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10336238104Sdes ;; 10337238104Sdes esac 10338238104Sdes fi 10339238104Sdes else 10340238104Sdes eval flag=\"$hardcode_libdir_flag_spec\" 10341238104Sdes func_append rpath " $flag" 10342238104Sdes fi 10343238104Sdes elif test -n "$runpath_var"; then 10344238104Sdes case "$finalize_perm_rpath " in 10345238104Sdes *" $libdir "*) ;; 10346238104Sdes *) func_append finalize_perm_rpath " $libdir" ;; 10347238104Sdes esac 10348238104Sdes fi 10349238104Sdes done 10350238104Sdes # Substitute the hardcoded libdirs into the rpath. 10351238104Sdes if test -n "$hardcode_libdir_separator" && 10352238104Sdes test -n "$hardcode_libdirs"; then 10353285206Sdes libdir=$hardcode_libdirs 10354238104Sdes eval rpath=\" $hardcode_libdir_flag_spec\" 10355238104Sdes fi 10356285206Sdes finalize_rpath=$rpath 10357238104Sdes 10358285206Sdes if test -n "$libobjs" && test yes = "$build_old_libs"; then 10359238104Sdes # Transform all the library objects into standard objects. 10360238104Sdes compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10361238104Sdes finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10362238104Sdes fi 10363238104Sdes 10364285206Sdes func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365238104Sdes 10366238104Sdes # template prelinking step 10367238104Sdes if test -n "$prelink_cmds"; then 10368238104Sdes func_execute_cmds "$prelink_cmds" 'exit $?' 10369238104Sdes fi 10370238104Sdes 10371285206Sdes wrappers_required=: 10372238104Sdes case $host in 10373238104Sdes *cegcc* | *mingw32ce*) 10374238104Sdes # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10375285206Sdes wrappers_required=false 10376238104Sdes ;; 10377238104Sdes *cygwin* | *mingw* ) 10378285206Sdes test yes = "$build_libtool_libs" || wrappers_required=false 10379238104Sdes ;; 10380238104Sdes *) 10381285206Sdes if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10382285206Sdes wrappers_required=false 10383238104Sdes fi 10384238104Sdes ;; 10385238104Sdes esac 10386285206Sdes $wrappers_required || { 10387238104Sdes # Replace the output file specification. 10388238104Sdes compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10389285206Sdes link_command=$compile_command$compile_rpath 10390238104Sdes 10391238104Sdes # We have no uninstalled library dependencies, so finalize right now. 10392238104Sdes exit_status=0 10393238104Sdes func_show_eval "$link_command" 'exit_status=$?' 10394238104Sdes 10395238104Sdes if test -n "$postlink_cmds"; then 10396238104Sdes func_to_tool_file "$output" 10397238104Sdes postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10398238104Sdes func_execute_cmds "$postlink_cmds" 'exit $?' 10399238104Sdes fi 10400238104Sdes 10401238104Sdes # Delete the generated files. 10402285206Sdes if test -f "$output_objdir/${outputname}S.$objext"; then 10403285206Sdes func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404238104Sdes fi 10405238104Sdes 10406238104Sdes exit $exit_status 10407285206Sdes } 10408238104Sdes 10409238104Sdes if test -n "$compile_shlibpath$finalize_shlibpath"; then 10410238104Sdes compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10411238104Sdes fi 10412238104Sdes if test -n "$finalize_shlibpath"; then 10413238104Sdes finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10414238104Sdes fi 10415238104Sdes 10416238104Sdes compile_var= 10417238104Sdes finalize_var= 10418238104Sdes if test -n "$runpath_var"; then 10419238104Sdes if test -n "$perm_rpath"; then 10420238104Sdes # We should set the runpath_var. 10421238104Sdes rpath= 10422238104Sdes for dir in $perm_rpath; do 10423238104Sdes func_append rpath "$dir:" 10424238104Sdes done 10425238104Sdes compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426238104Sdes fi 10427238104Sdes if test -n "$finalize_perm_rpath"; then 10428238104Sdes # We should set the runpath_var. 10429238104Sdes rpath= 10430238104Sdes for dir in $finalize_perm_rpath; do 10431238104Sdes func_append rpath "$dir:" 10432238104Sdes done 10433238104Sdes finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434238104Sdes fi 10435238104Sdes fi 10436238104Sdes 10437285206Sdes if test yes = "$no_install"; then 10438238104Sdes # We don't need to create a wrapper script. 10439285206Sdes link_command=$compile_var$compile_command$compile_rpath 10440238104Sdes # Replace the output file specification. 10441238104Sdes link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10442238104Sdes # Delete the old output file. 10443238104Sdes $opt_dry_run || $RM $output 10444238104Sdes # Link the executable and exit 10445238104Sdes func_show_eval "$link_command" 'exit $?' 10446238104Sdes 10447238104Sdes if test -n "$postlink_cmds"; then 10448238104Sdes func_to_tool_file "$output" 10449238104Sdes postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10450238104Sdes func_execute_cmds "$postlink_cmds" 'exit $?' 10451238104Sdes fi 10452238104Sdes 10453238104Sdes exit $EXIT_SUCCESS 10454238104Sdes fi 10455238104Sdes 10456285206Sdes case $hardcode_action,$fast_install in 10457285206Sdes relink,*) 10458285206Sdes # Fast installation is not supported 10459285206Sdes link_command=$compile_var$compile_command$compile_rpath 10460285206Sdes relink_command=$finalize_var$finalize_command$finalize_rpath 10461238104Sdes 10462285206Sdes func_warning "this platform does not like uninstalled shared libraries" 10463285206Sdes func_warning "'$output' will be relinked during installation" 10464285206Sdes ;; 10465285206Sdes *,yes) 10466285206Sdes link_command=$finalize_var$compile_command$finalize_rpath 10467285206Sdes relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10468285206Sdes ;; 10469285206Sdes *,no) 10470285206Sdes link_command=$compile_var$compile_command$compile_rpath 10471285206Sdes relink_command=$finalize_var$finalize_command$finalize_rpath 10472285206Sdes ;; 10473285206Sdes *,needless) 10474285206Sdes link_command=$finalize_var$compile_command$finalize_rpath 10475285206Sdes relink_command= 10476285206Sdes ;; 10477285206Sdes esac 10478238104Sdes 10479238104Sdes # Replace the output file specification. 10480238104Sdes link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481238104Sdes 10482238104Sdes # Delete the old output files. 10483238104Sdes $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484238104Sdes 10485238104Sdes func_show_eval "$link_command" 'exit $?' 10486238104Sdes 10487238104Sdes if test -n "$postlink_cmds"; then 10488238104Sdes func_to_tool_file "$output_objdir/$outputname" 10489238104Sdes 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'` 10490238104Sdes func_execute_cmds "$postlink_cmds" 'exit $?' 10491238104Sdes fi 10492238104Sdes 10493238104Sdes # Now create the wrapper script. 10494238104Sdes func_verbose "creating $output" 10495238104Sdes 10496238104Sdes # Quote the relink command for shipping. 10497238104Sdes if test -n "$relink_command"; then 10498238104Sdes # Preserve any variables that may affect compiler behavior 10499238104Sdes for var in $variables_saved_for_relink; do 10500238104Sdes if eval test -z \"\${$var+set}\"; then 10501238104Sdes relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10502238104Sdes elif eval var_value=\$$var; test -z "$var_value"; then 10503238104Sdes relink_command="$var=; export $var; $relink_command" 10504238104Sdes else 10505238104Sdes func_quote_for_eval "$var_value" 10506238104Sdes relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507238104Sdes fi 10508238104Sdes done 10509238104Sdes relink_command="(cd `pwd`; $relink_command)" 10510238104Sdes relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10511238104Sdes fi 10512238104Sdes 10513238104Sdes # Only actually do things if not in dry run mode. 10514238104Sdes $opt_dry_run || { 10515238104Sdes # win32 will think the script is a binary if it has 10516238104Sdes # a .exe suffix, so we strip it off here. 10517238104Sdes case $output in 10518238104Sdes *.exe) func_stripname '' '.exe' "$output" 10519238104Sdes output=$func_stripname_result ;; 10520238104Sdes esac 10521238104Sdes # test for cygwin because mv fails w/o .exe extensions 10522238104Sdes case $host in 10523238104Sdes *cygwin*) 10524238104Sdes exeext=.exe 10525238104Sdes func_stripname '' '.exe' "$outputname" 10526238104Sdes outputname=$func_stripname_result ;; 10527238104Sdes *) exeext= ;; 10528238104Sdes esac 10529238104Sdes case $host in 10530238104Sdes *cygwin* | *mingw* ) 10531238104Sdes func_dirname_and_basename "$output" "" "." 10532238104Sdes output_name=$func_basename_result 10533238104Sdes output_path=$func_dirname_result 10534285206Sdes cwrappersource=$output_path/$objdir/lt-$output_name.c 10535285206Sdes cwrapper=$output_path/$output_name.exe 10536238104Sdes $RM $cwrappersource $cwrapper 10537238104Sdes trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10538238104Sdes 10539238104Sdes func_emit_cwrapperexe_src > $cwrappersource 10540238104Sdes 10541238104Sdes # The wrapper executable is built using the $host compiler, 10542238104Sdes # because it contains $host paths and files. If cross- 10543238104Sdes # compiling, it, like the target executable, must be 10544238104Sdes # executed on the $host or under an emulation environment. 10545238104Sdes $opt_dry_run || { 10546238104Sdes $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10547238104Sdes $STRIP $cwrapper 10548238104Sdes } 10549238104Sdes 10550238104Sdes # Now, create the wrapper script for func_source use: 10551238104Sdes func_ltwrapper_scriptname $cwrapper 10552238104Sdes $RM $func_ltwrapper_scriptname_result 10553238104Sdes trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10554238104Sdes $opt_dry_run || { 10555238104Sdes # note: this script will not be executed, so do not chmod. 10556285206Sdes if test "x$build" = "x$host"; then 10557238104Sdes $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10558238104Sdes else 10559238104Sdes func_emit_wrapper no > $func_ltwrapper_scriptname_result 10560238104Sdes fi 10561238104Sdes } 10562238104Sdes ;; 10563238104Sdes * ) 10564238104Sdes $RM $output 10565238104Sdes trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566238104Sdes 10567238104Sdes func_emit_wrapper no > $output 10568238104Sdes chmod +x $output 10569238104Sdes ;; 10570238104Sdes esac 10571238104Sdes } 10572238104Sdes exit $EXIT_SUCCESS 10573238104Sdes ;; 10574238104Sdes esac 10575238104Sdes 10576238104Sdes # See if we need to build an old-fashioned archive. 10577238104Sdes for oldlib in $oldlibs; do 10578238104Sdes 10579285206Sdes case $build_libtool_libs in 10580285206Sdes convenience) 10581285206Sdes oldobjs="$libobjs_save $symfileobj" 10582285206Sdes addlibs=$convenience 10583238104Sdes build_libtool_libs=no 10584285206Sdes ;; 10585285206Sdes module) 10586285206Sdes oldobjs=$libobjs_save 10587285206Sdes addlibs=$old_convenience 10588285206Sdes build_libtool_libs=no 10589285206Sdes ;; 10590285206Sdes *) 10591238104Sdes oldobjs="$old_deplibs $non_pic_objects" 10592285206Sdes $preload && test -f "$symfileobj" \ 10593285206Sdes && func_append oldobjs " $symfileobj" 10594285206Sdes addlibs=$old_convenience 10595285206Sdes ;; 10596285206Sdes esac 10597238104Sdes 10598238104Sdes if test -n "$addlibs"; then 10599285206Sdes gentop=$output_objdir/${outputname}x 10600238104Sdes func_append generated " $gentop" 10601238104Sdes 10602238104Sdes func_extract_archives $gentop $addlibs 10603238104Sdes func_append oldobjs " $func_extract_archives_result" 10604238104Sdes fi 10605238104Sdes 10606238104Sdes # Do each command in the archive commands. 10607285206Sdes if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10608238104Sdes cmds=$old_archive_from_new_cmds 10609238104Sdes else 10610238104Sdes 10611238104Sdes # Add any objects from preloaded convenience libraries 10612238104Sdes if test -n "$dlprefiles"; then 10613285206Sdes gentop=$output_objdir/${outputname}x 10614238104Sdes func_append generated " $gentop" 10615238104Sdes 10616238104Sdes func_extract_archives $gentop $dlprefiles 10617238104Sdes func_append oldobjs " $func_extract_archives_result" 10618238104Sdes fi 10619238104Sdes 10620238104Sdes # POSIX demands no paths to be encoded in archives. We have 10621238104Sdes # to avoid creating archives with duplicate basenames if we 10622238104Sdes # might have to extract them afterwards, e.g., when creating a 10623238104Sdes # static archive out of a convenience library, or when linking 10624238104Sdes # the entirety of a libtool archive into another (currently 10625238104Sdes # not supported by libtool). 10626238104Sdes if (for obj in $oldobjs 10627238104Sdes do 10628238104Sdes func_basename "$obj" 10629238104Sdes $ECHO "$func_basename_result" 10630238104Sdes done | sort | sort -uc >/dev/null 2>&1); then 10631238104Sdes : 10632238104Sdes else 10633238104Sdes echo "copying selected object files to avoid basename conflicts..." 10634285206Sdes gentop=$output_objdir/${outputname}x 10635238104Sdes func_append generated " $gentop" 10636238104Sdes func_mkdir_p "$gentop" 10637238104Sdes save_oldobjs=$oldobjs 10638238104Sdes oldobjs= 10639238104Sdes counter=1 10640238104Sdes for obj in $save_oldobjs 10641238104Sdes do 10642238104Sdes func_basename "$obj" 10643285206Sdes objbase=$func_basename_result 10644238104Sdes case " $oldobjs " in 10645238104Sdes " ") oldobjs=$obj ;; 10646238104Sdes *[\ /]"$objbase "*) 10647238104Sdes while :; do 10648238104Sdes # Make sure we don't pick an alternate name that also 10649238104Sdes # overlaps. 10650238104Sdes newobj=lt$counter-$objbase 10651238104Sdes func_arith $counter + 1 10652238104Sdes counter=$func_arith_result 10653238104Sdes case " $oldobjs " in 10654238104Sdes *[\ /]"$newobj "*) ;; 10655238104Sdes *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10656238104Sdes esac 10657238104Sdes done 10658238104Sdes func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10659238104Sdes func_append oldobjs " $gentop/$newobj" 10660238104Sdes ;; 10661238104Sdes *) func_append oldobjs " $obj" ;; 10662238104Sdes esac 10663238104Sdes done 10664238104Sdes fi 10665238104Sdes func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666238104Sdes tool_oldlib=$func_to_tool_file_result 10667238104Sdes eval cmds=\"$old_archive_cmds\" 10668238104Sdes 10669238104Sdes func_len " $cmds" 10670238104Sdes len=$func_len_result 10671238104Sdes if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10672238104Sdes cmds=$old_archive_cmds 10673238104Sdes elif test -n "$archiver_list_spec"; then 10674238104Sdes func_verbose "using command file archive linking..." 10675238104Sdes for obj in $oldobjs 10676238104Sdes do 10677238104Sdes func_to_tool_file "$obj" 10678238104Sdes $ECHO "$func_to_tool_file_result" 10679238104Sdes done > $output_objdir/$libname.libcmd 10680238104Sdes func_to_tool_file "$output_objdir/$libname.libcmd" 10681238104Sdes oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10682238104Sdes cmds=$old_archive_cmds 10683238104Sdes else 10684238104Sdes # the command line is too long to link in one step, link in parts 10685238104Sdes func_verbose "using piecewise archive linking..." 10686238104Sdes save_RANLIB=$RANLIB 10687238104Sdes RANLIB=: 10688238104Sdes objlist= 10689238104Sdes concat_cmds= 10690238104Sdes save_oldobjs=$oldobjs 10691238104Sdes oldobjs= 10692238104Sdes # Is there a better way of finding the last object in the list? 10693238104Sdes for obj in $save_oldobjs 10694238104Sdes do 10695238104Sdes last_oldobj=$obj 10696238104Sdes done 10697238104Sdes eval test_cmds=\"$old_archive_cmds\" 10698238104Sdes func_len " $test_cmds" 10699238104Sdes len0=$func_len_result 10700238104Sdes len=$len0 10701238104Sdes for obj in $save_oldobjs 10702238104Sdes do 10703238104Sdes func_len " $obj" 10704238104Sdes func_arith $len + $func_len_result 10705238104Sdes len=$func_arith_result 10706238104Sdes func_append objlist " $obj" 10707238104Sdes if test "$len" -lt "$max_cmd_len"; then 10708238104Sdes : 10709238104Sdes else 10710238104Sdes # the above command should be used before it gets too long 10711238104Sdes oldobjs=$objlist 10712285206Sdes if test "$obj" = "$last_oldobj"; then 10713238104Sdes RANLIB=$save_RANLIB 10714238104Sdes fi 10715238104Sdes test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10716285206Sdes eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10717238104Sdes objlist= 10718238104Sdes len=$len0 10719238104Sdes fi 10720238104Sdes done 10721238104Sdes RANLIB=$save_RANLIB 10722238104Sdes oldobjs=$objlist 10723285206Sdes if test -z "$oldobjs"; then 10724238104Sdes eval cmds=\"\$concat_cmds\" 10725238104Sdes else 10726238104Sdes eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10727238104Sdes fi 10728238104Sdes fi 10729238104Sdes fi 10730238104Sdes func_execute_cmds "$cmds" 'exit $?' 10731238104Sdes done 10732238104Sdes 10733238104Sdes test -n "$generated" && \ 10734238104Sdes func_show_eval "${RM}r$generated" 10735238104Sdes 10736238104Sdes # Now create the libtool archive. 10737238104Sdes case $output in 10738238104Sdes *.la) 10739238104Sdes old_library= 10740285206Sdes test yes = "$build_old_libs" && old_library=$libname.$libext 10741238104Sdes func_verbose "creating $output" 10742238104Sdes 10743238104Sdes # Preserve any variables that may affect compiler behavior 10744238104Sdes for var in $variables_saved_for_relink; do 10745238104Sdes if eval test -z \"\${$var+set}\"; then 10746238104Sdes relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10747238104Sdes elif eval var_value=\$$var; test -z "$var_value"; then 10748238104Sdes relink_command="$var=; export $var; $relink_command" 10749238104Sdes else 10750238104Sdes func_quote_for_eval "$var_value" 10751238104Sdes relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752238104Sdes fi 10753238104Sdes done 10754238104Sdes # Quote the link command for shipping. 10755285206Sdes relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10756238104Sdes relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10757285206Sdes if test yes = "$hardcode_automatic"; then 10758238104Sdes relink_command= 10759238104Sdes fi 10760238104Sdes 10761238104Sdes # Only create the output if not a dry run. 10762238104Sdes $opt_dry_run || { 10763238104Sdes for installed in no yes; do 10764285206Sdes if test yes = "$installed"; then 10765238104Sdes if test -z "$install_libdir"; then 10766238104Sdes break 10767238104Sdes fi 10768285206Sdes output=$output_objdir/${outputname}i 10769238104Sdes # Replace all uninstalled libtool libraries with the installed ones 10770238104Sdes newdependency_libs= 10771238104Sdes for deplib in $dependency_libs; do 10772238104Sdes case $deplib in 10773238104Sdes *.la) 10774238104Sdes func_basename "$deplib" 10775285206Sdes name=$func_basename_result 10776238104Sdes func_resolve_sysroot "$deplib" 10777285206Sdes eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10778238104Sdes test -z "$libdir" && \ 10779285206Sdes func_fatal_error "'$deplib' is not a valid libtool archive" 10780238104Sdes func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10781238104Sdes ;; 10782238104Sdes -L*) 10783238104Sdes func_stripname -L '' "$deplib" 10784238104Sdes func_replace_sysroot "$func_stripname_result" 10785238104Sdes func_append newdependency_libs " -L$func_replace_sysroot_result" 10786238104Sdes ;; 10787238104Sdes -R*) 10788238104Sdes func_stripname -R '' "$deplib" 10789238104Sdes func_replace_sysroot "$func_stripname_result" 10790238104Sdes func_append newdependency_libs " -R$func_replace_sysroot_result" 10791238104Sdes ;; 10792238104Sdes *) func_append newdependency_libs " $deplib" ;; 10793238104Sdes esac 10794238104Sdes done 10795285206Sdes dependency_libs=$newdependency_libs 10796238104Sdes newdlfiles= 10797238104Sdes 10798238104Sdes for lib in $dlfiles; do 10799238104Sdes case $lib in 10800238104Sdes *.la) 10801238104Sdes func_basename "$lib" 10802285206Sdes name=$func_basename_result 10803285206Sdes eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10804238104Sdes test -z "$libdir" && \ 10805285206Sdes func_fatal_error "'$lib' is not a valid libtool archive" 10806238104Sdes func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10807238104Sdes ;; 10808238104Sdes *) func_append newdlfiles " $lib" ;; 10809238104Sdes esac 10810238104Sdes done 10811285206Sdes dlfiles=$newdlfiles 10812238104Sdes newdlprefiles= 10813238104Sdes for lib in $dlprefiles; do 10814238104Sdes case $lib in 10815238104Sdes *.la) 10816238104Sdes # Only pass preopened files to the pseudo-archive (for 10817238104Sdes # eventual linking with the app. that links it) if we 10818238104Sdes # didn't already link the preopened objects directly into 10819238104Sdes # the library: 10820238104Sdes func_basename "$lib" 10821285206Sdes name=$func_basename_result 10822285206Sdes eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10823238104Sdes test -z "$libdir" && \ 10824285206Sdes func_fatal_error "'$lib' is not a valid libtool archive" 10825238104Sdes func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10826238104Sdes ;; 10827238104Sdes esac 10828238104Sdes done 10829285206Sdes dlprefiles=$newdlprefiles 10830238104Sdes else 10831238104Sdes newdlfiles= 10832238104Sdes for lib in $dlfiles; do 10833238104Sdes case $lib in 10834285206Sdes [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10835238104Sdes *) abs=`pwd`"/$lib" ;; 10836238104Sdes esac 10837238104Sdes func_append newdlfiles " $abs" 10838238104Sdes done 10839285206Sdes dlfiles=$newdlfiles 10840238104Sdes newdlprefiles= 10841238104Sdes for lib in $dlprefiles; do 10842238104Sdes case $lib in 10843285206Sdes [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844238104Sdes *) abs=`pwd`"/$lib" ;; 10845238104Sdes esac 10846238104Sdes func_append newdlprefiles " $abs" 10847238104Sdes done 10848285206Sdes dlprefiles=$newdlprefiles 10849238104Sdes fi 10850238104Sdes $RM $output 10851238104Sdes # place dlname in correct position for cygwin 10852238104Sdes # In fact, it would be nice if we could use this code for all target 10853238104Sdes # systems that can't hard-code library paths into their executables 10854238104Sdes # and that have no shared library path variable independent of PATH, 10855238104Sdes # but it turns out we can't easily determine that from inspecting 10856238104Sdes # libtool variables, so we have to hard-code the OSs to which it 10857238104Sdes # applies here; at the moment, that means platforms that use the PE 10858238104Sdes # object format with DLL files. See the long comment at the top of 10859238104Sdes # tests/bindir.at for full details. 10860238104Sdes tdlname=$dlname 10861238104Sdes case $host,$output,$installed,$module,$dlname in 10862238104Sdes *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10863238104Sdes # If a -bindir argument was supplied, place the dll there. 10864285206Sdes if test -n "$bindir"; then 10865238104Sdes func_relative_path "$install_libdir" "$bindir" 10866285206Sdes tdlname=$func_relative_path_result/$dlname 10867238104Sdes else 10868238104Sdes # Otherwise fall back on heuristic. 10869238104Sdes tdlname=../bin/$dlname 10870238104Sdes fi 10871238104Sdes ;; 10872238104Sdes esac 10873238104Sdes $ECHO > $output "\ 10874238104Sdes# $outputname - a libtool library file 10875285206Sdes# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10876238104Sdes# 10877238104Sdes# Please DO NOT delete this file! 10878238104Sdes# It is necessary for linking the library. 10879238104Sdes 10880238104Sdes# The name that we can dlopen(3). 10881238104Sdesdlname='$tdlname' 10882238104Sdes 10883238104Sdes# Names of this library. 10884238104Sdeslibrary_names='$library_names' 10885238104Sdes 10886238104Sdes# The name of the static archive. 10887238104Sdesold_library='$old_library' 10888238104Sdes 10889285206Sdes# Linker flags that cannot go in dependency_libs. 10890238104Sdesinherited_linker_flags='$new_inherited_linker_flags' 10891238104Sdes 10892238104Sdes# Libraries that this one depends upon. 10893238104Sdesdependency_libs='$dependency_libs' 10894238104Sdes 10895238104Sdes# Names of additional weak libraries provided by this library 10896238104Sdesweak_library_names='$weak_libs' 10897238104Sdes 10898238104Sdes# Version information for $libname. 10899238104Sdescurrent=$current 10900238104Sdesage=$age 10901238104Sdesrevision=$revision 10902238104Sdes 10903238104Sdes# Is this an already installed library? 10904238104Sdesinstalled=$installed 10905238104Sdes 10906238104Sdes# Should we warn about portability when linking against -modules? 10907238104Sdesshouldnotlink=$module 10908238104Sdes 10909238104Sdes# Files to dlopen/dlpreopen 10910238104Sdesdlopen='$dlfiles' 10911238104Sdesdlpreopen='$dlprefiles' 10912238104Sdes 10913238104Sdes# Directory that this library needs to be installed in: 10914238104Sdeslibdir='$install_libdir'" 10915285206Sdes if test no,yes = "$installed,$need_relink"; then 10916238104Sdes $ECHO >> $output "\ 10917238104Sdesrelink_command=\"$relink_command\"" 10918238104Sdes fi 10919238104Sdes done 10920238104Sdes } 10921238104Sdes 10922238104Sdes # Do a symbolic link so that the libtool archive can be found in 10923238104Sdes # LD_LIBRARY_PATH before the program is installed. 10924238104Sdes func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10925238104Sdes ;; 10926238104Sdes esac 10927238104Sdes exit $EXIT_SUCCESS 10928238104Sdes} 10929238104Sdes 10930285206Sdesif test link = "$opt_mode" || test relink = "$opt_mode"; then 10931285206Sdes func_mode_link ${1+"$@"} 10932285206Sdesfi 10933238104Sdes 10934238104Sdes 10935238104Sdes# func_mode_uninstall arg... 10936238104Sdesfunc_mode_uninstall () 10937238104Sdes{ 10938285206Sdes $debug_cmd 10939285206Sdes 10940285206Sdes RM=$nonopt 10941238104Sdes files= 10942285206Sdes rmforce=false 10943238104Sdes exit_status=0 10944238104Sdes 10945238104Sdes # This variable tells wrapper scripts just to set variables rather 10946238104Sdes # than running their programs. 10947285206Sdes libtool_install_magic=$magic 10948238104Sdes 10949238104Sdes for arg 10950238104Sdes do 10951238104Sdes case $arg in 10952285206Sdes -f) func_append RM " $arg"; rmforce=: ;; 10953238104Sdes -*) func_append RM " $arg" ;; 10954238104Sdes *) func_append files " $arg" ;; 10955238104Sdes esac 10956238104Sdes done 10957238104Sdes 10958238104Sdes test -z "$RM" && \ 10959238104Sdes func_fatal_help "you must specify an RM program" 10960238104Sdes 10961238104Sdes rmdirs= 10962238104Sdes 10963238104Sdes for file in $files; do 10964238104Sdes func_dirname "$file" "" "." 10965285206Sdes dir=$func_dirname_result 10966285206Sdes if test . = "$dir"; then 10967285206Sdes odir=$objdir 10968238104Sdes else 10969285206Sdes odir=$dir/$objdir 10970238104Sdes fi 10971238104Sdes func_basename "$file" 10972285206Sdes name=$func_basename_result 10973285206Sdes test uninstall = "$opt_mode" && odir=$dir 10974238104Sdes 10975238104Sdes # Remember odir for removal later, being careful to avoid duplicates 10976285206Sdes if test clean = "$opt_mode"; then 10977238104Sdes case " $rmdirs " in 10978238104Sdes *" $odir "*) ;; 10979238104Sdes *) func_append rmdirs " $odir" ;; 10980238104Sdes esac 10981238104Sdes fi 10982238104Sdes 10983238104Sdes # Don't error if the file doesn't exist and rm -f was used. 10984238104Sdes if { test -L "$file"; } >/dev/null 2>&1 || 10985238104Sdes { test -h "$file"; } >/dev/null 2>&1 || 10986238104Sdes test -f "$file"; then 10987238104Sdes : 10988238104Sdes elif test -d "$file"; then 10989238104Sdes exit_status=1 10990238104Sdes continue 10991285206Sdes elif $rmforce; then 10992238104Sdes continue 10993238104Sdes fi 10994238104Sdes 10995285206Sdes rmfiles=$file 10996238104Sdes 10997238104Sdes case $name in 10998238104Sdes *.la) 10999238104Sdes # Possibly a libtool archive, so verify it. 11000238104Sdes if func_lalib_p "$file"; then 11001238104Sdes func_source $dir/$name 11002238104Sdes 11003238104Sdes # Delete the libtool libraries and symlinks. 11004238104Sdes for n in $library_names; do 11005238104Sdes func_append rmfiles " $odir/$n" 11006238104Sdes done 11007238104Sdes test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008238104Sdes 11009285206Sdes case $opt_mode in 11010238104Sdes clean) 11011238104Sdes case " $library_names " in 11012238104Sdes *" $dlname "*) ;; 11013238104Sdes *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014238104Sdes esac 11015238104Sdes test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016238104Sdes ;; 11017238104Sdes uninstall) 11018238104Sdes if test -n "$library_names"; then 11019238104Sdes # Do each command in the postuninstall commands. 11020285206Sdes func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021238104Sdes fi 11022238104Sdes 11023238104Sdes if test -n "$old_library"; then 11024238104Sdes # Do each command in the old_postuninstall commands. 11025285206Sdes func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026238104Sdes fi 11027238104Sdes # FIXME: should reinstall the best remaining shared library. 11028238104Sdes ;; 11029238104Sdes esac 11030238104Sdes fi 11031238104Sdes ;; 11032238104Sdes 11033238104Sdes *.lo) 11034238104Sdes # Possibly a libtool object, so verify it. 11035238104Sdes if func_lalib_p "$file"; then 11036238104Sdes 11037238104Sdes # Read the .lo file 11038238104Sdes func_source $dir/$name 11039238104Sdes 11040238104Sdes # Add PIC object to the list of files to remove. 11041285206Sdes if test -n "$pic_object" && test none != "$pic_object"; then 11042238104Sdes func_append rmfiles " $dir/$pic_object" 11043238104Sdes fi 11044238104Sdes 11045238104Sdes # Add non-PIC object to the list of files to remove. 11046285206Sdes if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11047238104Sdes func_append rmfiles " $dir/$non_pic_object" 11048238104Sdes fi 11049238104Sdes fi 11050238104Sdes ;; 11051238104Sdes 11052238104Sdes *) 11053285206Sdes if test clean = "$opt_mode"; then 11054238104Sdes noexename=$name 11055238104Sdes case $file in 11056238104Sdes *.exe) 11057238104Sdes func_stripname '' '.exe' "$file" 11058238104Sdes file=$func_stripname_result 11059238104Sdes func_stripname '' '.exe' "$name" 11060238104Sdes noexename=$func_stripname_result 11061238104Sdes # $file with .exe has already been added to rmfiles, 11062238104Sdes # add $file without .exe 11063238104Sdes func_append rmfiles " $file" 11064238104Sdes ;; 11065238104Sdes esac 11066238104Sdes # Do a test to see if this is a libtool program. 11067238104Sdes if func_ltwrapper_p "$file"; then 11068238104Sdes if func_ltwrapper_executable_p "$file"; then 11069238104Sdes func_ltwrapper_scriptname "$file" 11070238104Sdes relink_command= 11071238104Sdes func_source $func_ltwrapper_scriptname_result 11072238104Sdes func_append rmfiles " $func_ltwrapper_scriptname_result" 11073238104Sdes else 11074238104Sdes relink_command= 11075238104Sdes func_source $dir/$noexename 11076238104Sdes fi 11077238104Sdes 11078238104Sdes # note $name still contains .exe if it was in $file originally 11079238104Sdes # as does the version of $file that was added into $rmfiles 11080285206Sdes func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11081285206Sdes if test yes = "$fast_install" && test -n "$relink_command"; then 11082238104Sdes func_append rmfiles " $odir/lt-$name" 11083238104Sdes fi 11084285206Sdes if test "X$noexename" != "X$name"; then 11085285206Sdes func_append rmfiles " $odir/lt-$noexename.c" 11086238104Sdes fi 11087238104Sdes fi 11088238104Sdes fi 11089238104Sdes ;; 11090238104Sdes esac 11091238104Sdes func_show_eval "$RM $rmfiles" 'exit_status=1' 11092238104Sdes done 11093238104Sdes 11094285206Sdes # Try to remove the $objdir's in the directories where we deleted files 11095238104Sdes for dir in $rmdirs; do 11096238104Sdes if test -d "$dir"; then 11097238104Sdes func_show_eval "rmdir $dir >/dev/null 2>&1" 11098238104Sdes fi 11099238104Sdes done 11100238104Sdes 11101238104Sdes exit $exit_status 11102238104Sdes} 11103238104Sdes 11104285206Sdesif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11105285206Sdes func_mode_uninstall ${1+"$@"} 11106285206Sdesfi 11107238104Sdes 11108238104Sdestest -z "$opt_mode" && { 11109285206Sdes help=$generic_help 11110238104Sdes func_fatal_help "you must specify a MODE" 11111238104Sdes} 11112238104Sdes 11113238104Sdestest -z "$exec_cmd" && \ 11114285206Sdes func_fatal_help "invalid operation mode '$opt_mode'" 11115238104Sdes 11116238104Sdesif test -n "$exec_cmd"; then 11117238104Sdes eval exec "$exec_cmd" 11118238104Sdes exit $EXIT_FAILURE 11119238104Sdesfi 11120238104Sdes 11121238104Sdesexit $exit_status 11122238104Sdes 11123238104Sdes 11124238104Sdes# The TAGs below are defined such that we never get into a situation 11125285206Sdes# where we disable both kinds of libraries. Given conflicting 11126238104Sdes# choices, we go for a static library, that is the most portable, 11127238104Sdes# since we can't tell whether shared libraries were disabled because 11128238104Sdes# the user asked for that or because the platform doesn't support 11129238104Sdes# them. This is particularly important on AIX, because we don't 11130238104Sdes# support having both static and shared libraries enabled at the same 11131238104Sdes# time on that platform, so we default to a shared-only configuration. 11132238104Sdes# If a disable-shared tag is given, we'll fallback to a static-only 11133238104Sdes# configuration. But we'll never go from static-only to shared-only. 11134238104Sdes 11135238104Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11136238104Sdesbuild_libtool_libs=no 11137238104Sdesbuild_old_libs=yes 11138238104Sdes# ### END LIBTOOL TAG CONFIG: disable-shared 11139238104Sdes 11140238104Sdes# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11141238104Sdesbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142238104Sdes# ### END LIBTOOL TAG CONFIG: disable-static 11143238104Sdes 11144238104Sdes# Local Variables: 11145238104Sdes# mode:shell-script 11146238104Sdes# sh-indentation:2 11147238104Sdes# End: 11148