1316068Sdelphij#! /bin/sh 2316068Sdelphij## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3316068Sdelphij## by inline-source v2014-01-03.01 4275970Scy 5316068Sdelphij# libtool (GNU libtool) 2.4.6 6316068Sdelphij# Provide generalized library-building support services. 7275970Scy# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8275970Scy 9316068Sdelphij# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10275970Scy# This is free software; see the source for copying conditions. There is NO 11275970Scy# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12275970Scy 13275970Scy# GNU Libtool is free software; you can redistribute it and/or modify 14275970Scy# it under the terms of the GNU General Public License as published by 15275970Scy# the Free Software Foundation; either version 2 of the License, or 16275970Scy# (at your option) any later version. 17275970Scy# 18275970Scy# As a special exception to the GNU General Public License, 19275970Scy# if you distribute this file as part of a program or library that 20275970Scy# is built using GNU Libtool, you may include this file under the 21275970Scy# same distribution terms that you use for the rest of that program. 22275970Scy# 23275970Scy# GNU Libtool is distributed in the hope that it will be useful, but 24275970Scy# WITHOUT ANY WARRANTY; without even the implied warranty of 25275970Scy# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26275970Scy# General Public License for more details. 27275970Scy# 28275970Scy# You should have received a copy of the GNU General Public License 29316068Sdelphij# along with this program. If not, see <http://www.gnu.org/licenses/>. 30275970Scy 31275970Scy 32275970ScyPROGRAM=libtool 33275970ScyPACKAGE=libtool 34316068SdelphijVERSION=2.4.6 35316068Sdelphijpackage_revision=2.4.6 36275970Scy 37316068Sdelphij 38316068Sdelphij## ------ ## 39316068Sdelphij## Usage. ## 40316068Sdelphij## ------ ## 41316068Sdelphij 42316068Sdelphij# Run './libtool --help' for help with using this script from the 43316068Sdelphij# command line. 44316068Sdelphij 45316068Sdelphij 46316068Sdelphij## ------------------------------- ## 47316068Sdelphij## User overridable command paths. ## 48316068Sdelphij## ------------------------------- ## 49316068Sdelphij 50316068Sdelphij# After configure completes, it has a better idea of some of the 51316068Sdelphij# shell tools we need than the defaults used by the functions shared 52316068Sdelphij# with bootstrap, so set those here where they can still be over- 53316068Sdelphij# ridden by the user, but otherwise take precedence. 54316068Sdelphij 55316068Sdelphij: ${AUTOCONF="autoconf"} 56316068Sdelphij: ${AUTOMAKE="automake"} 57316068Sdelphij 58316068Sdelphij 59316068Sdelphij## -------------------------- ## 60316068Sdelphij## Source external libraries. ## 61316068Sdelphij## -------------------------- ## 62316068Sdelphij 63316068Sdelphij# Much of our low-level functionality needs to be sourced from external 64316068Sdelphij# libraries, which are installed to $pkgauxdir. 65316068Sdelphij 66316068Sdelphij# Set a version string for this script. 67316068Sdelphijscriptversion=2015-01-20.17; # UTC 68316068Sdelphij 69316068Sdelphij# General shell script boiler plate, and helper functions. 70316068Sdelphij# Written by Gary V. Vaughan, 2004 71316068Sdelphij 72316068Sdelphij# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73316068Sdelphij# This is free software; see the source for copying conditions. There is NO 74316068Sdelphij# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75316068Sdelphij 76316068Sdelphij# This program is free software; you can redistribute it and/or modify 77316068Sdelphij# it under the terms of the GNU General Public License as published by 78316068Sdelphij# the Free Software Foundation; either version 3 of the License, or 79316068Sdelphij# (at your option) any later version. 80316068Sdelphij 81316068Sdelphij# As a special exception to the GNU General Public License, if you distribute 82316068Sdelphij# this file as part of a program or library that is built using GNU Libtool, 83316068Sdelphij# you may include this file under the same distribution terms that you use 84316068Sdelphij# for the rest of that program. 85316068Sdelphij 86316068Sdelphij# This program is distributed in the hope that it will be useful, 87316068Sdelphij# but WITHOUT ANY WARRANTY; without even the implied warranty of 88316068Sdelphij# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89316068Sdelphij# General Public License for more details. 90316068Sdelphij 91316068Sdelphij# You should have received a copy of the GNU General Public License 92316068Sdelphij# along with this program. If not, see <http://www.gnu.org/licenses/>. 93316068Sdelphij 94316068Sdelphij# Please report bugs or propose patches to gary@gnu.org. 95316068Sdelphij 96316068Sdelphij 97316068Sdelphij## ------ ## 98316068Sdelphij## Usage. ## 99316068Sdelphij## ------ ## 100316068Sdelphij 101316068Sdelphij# Evaluate this file near the top of your script to gain access to 102316068Sdelphij# the functions and variables defined here: 103316068Sdelphij# 104316068Sdelphij# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105316068Sdelphij# 106316068Sdelphij# If you need to override any of the default environment variable 107316068Sdelphij# settings, do that before evaluating this file. 108316068Sdelphij 109316068Sdelphij 110316068Sdelphij## -------------------- ## 111316068Sdelphij## Shell normalisation. ## 112316068Sdelphij## -------------------- ## 113316068Sdelphij 114316068Sdelphij# Some shells need a little help to be as Bourne compatible as possible. 115316068Sdelphij# Before doing anything else, make sure all that help has been provided! 116316068Sdelphij 117316068SdelphijDUALCASE=1; export DUALCASE # for MKS sh 118316068Sdelphijif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119275970Scy emulate sh 120275970Scy NULLCMD=: 121316068Sdelphij # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122275970Scy # is contrary to our usage. Disable this feature. 123275970Scy alias -g '${1+"$@"}'='"$@"' 124275970Scy setopt NO_GLOB_SUBST 125275970Scyelse 126316068Sdelphij case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127275970Scyfi 128275970Scy 129316068Sdelphij# NLS nuisances: We save the old values in case they are required later. 130316068Sdelphij_G_user_locale= 131316068Sdelphij_G_safe_locale= 132316068Sdelphijfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133275970Scydo 134316068Sdelphij eval "if test set = \"\${$_G_var+set}\"; then 135316068Sdelphij save_$_G_var=\$$_G_var 136316068Sdelphij $_G_var=C 137316068Sdelphij export $_G_var 138316068Sdelphij _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139316068Sdelphij _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140275970Scy fi" 141275970Scydone 142275970Scy 143316068Sdelphij# CDPATH. 144316068Sdelphij(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145275970Scy 146316068Sdelphij# Make sure IFS has a sensible default 147316068Sdelphijsp=' ' 148316068Sdelphijnl=' 149316068Sdelphij' 150316068SdelphijIFS="$sp $nl" 151275970Scy 152316068Sdelphij# There are apparently some retarded systems that use ';' as a PATH separator! 153316068Sdelphijif test "${PATH_SEPARATOR+set}" != set; then 154316068Sdelphij PATH_SEPARATOR=: 155316068Sdelphij (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156316068Sdelphij (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157316068Sdelphij PATH_SEPARATOR=';' 158316068Sdelphij } 159316068Sdelphijfi 160275970Scy 161275970Scy 162275970Scy 163316068Sdelphij## ------------------------- ## 164316068Sdelphij## Locate command utilities. ## 165316068Sdelphij## ------------------------- ## 166316068Sdelphij 167316068Sdelphij 168316068Sdelphij# func_executable_p FILE 169316068Sdelphij# ---------------------- 170316068Sdelphij# Check that FILE is an executable regular file. 171316068Sdelphijfunc_executable_p () 172316068Sdelphij{ 173316068Sdelphij test -f "$1" && test -x "$1" 174316068Sdelphij} 175316068Sdelphij 176316068Sdelphij 177316068Sdelphij# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178316068Sdelphij# -------------------------------------------- 179316068Sdelphij# Search for either a program that responds to --version with output 180316068Sdelphij# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181316068Sdelphij# trying all the directories in PATH with each of the elements of 182316068Sdelphij# PROGS_LIST. 183316068Sdelphij# 184316068Sdelphij# CHECK_FUNC should accept the path to a candidate program, and 185316068Sdelphij# set $func_check_prog_result if it truncates its output less than 186316068Sdelphij# $_G_path_prog_max characters. 187316068Sdelphijfunc_path_progs () 188316068Sdelphij{ 189316068Sdelphij _G_progs_list=$1 190316068Sdelphij _G_check_func=$2 191316068Sdelphij _G_PATH=${3-"$PATH"} 192316068Sdelphij 193316068Sdelphij _G_path_prog_max=0 194316068Sdelphij _G_path_prog_found=false 195316068Sdelphij _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196316068Sdelphij for _G_dir in $_G_PATH; do 197316068Sdelphij IFS=$_G_save_IFS 198316068Sdelphij test -z "$_G_dir" && _G_dir=. 199316068Sdelphij for _G_prog_name in $_G_progs_list; do 200316068Sdelphij for _exeext in '' .EXE; do 201316068Sdelphij _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202316068Sdelphij func_executable_p "$_G_path_prog" || continue 203316068Sdelphij case `"$_G_path_prog" --version 2>&1` in 204316068Sdelphij *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205316068Sdelphij *) $_G_check_func $_G_path_prog 206316068Sdelphij func_path_progs_result=$func_check_prog_result 207316068Sdelphij ;; 208316068Sdelphij esac 209316068Sdelphij $_G_path_prog_found && break 3 210316068Sdelphij done 211316068Sdelphij done 212316068Sdelphij done 213316068Sdelphij IFS=$_G_save_IFS 214316068Sdelphij test -z "$func_path_progs_result" && { 215316068Sdelphij echo "no acceptable sed could be found in \$PATH" >&2 216316068Sdelphij exit 1 217316068Sdelphij } 218316068Sdelphij} 219316068Sdelphij 220316068Sdelphij 221316068Sdelphij# We want to be able to use the functions in this file before configure 222316068Sdelphij# has figured out where the best binaries are kept, which means we have 223316068Sdelphij# to search for them ourselves - except when the results are already set 224316068Sdelphij# where we skip the searches. 225316068Sdelphij 226316068Sdelphij# Unless the user overrides by setting SED, search the path for either GNU 227316068Sdelphij# sed, or the sed that truncates its output the least. 228316068Sdelphijtest -z "$SED" && { 229316068Sdelphij _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230316068Sdelphij for _G_i in 1 2 3 4 5 6 7; do 231316068Sdelphij _G_sed_script=$_G_sed_script$nl$_G_sed_script 232316068Sdelphij done 233316068Sdelphij echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234316068Sdelphij _G_sed_script= 235316068Sdelphij 236316068Sdelphij func_check_prog_sed () 237316068Sdelphij { 238316068Sdelphij _G_path_prog=$1 239316068Sdelphij 240316068Sdelphij _G_count=0 241316068Sdelphij printf 0123456789 >conftest.in 242316068Sdelphij while : 243316068Sdelphij do 244316068Sdelphij cat conftest.in conftest.in >conftest.tmp 245316068Sdelphij mv conftest.tmp conftest.in 246316068Sdelphij cp conftest.in conftest.nl 247316068Sdelphij echo '' >> conftest.nl 248316068Sdelphij "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249316068Sdelphij diff conftest.out conftest.nl >/dev/null 2>&1 || break 250316068Sdelphij _G_count=`expr $_G_count + 1` 251316068Sdelphij if test "$_G_count" -gt "$_G_path_prog_max"; then 252316068Sdelphij # Best one so far, save it but keep looking for a better one 253316068Sdelphij func_check_prog_result=$_G_path_prog 254316068Sdelphij _G_path_prog_max=$_G_count 255316068Sdelphij fi 256316068Sdelphij # 10*(2^10) chars as input seems more than enough 257316068Sdelphij test 10 -lt "$_G_count" && break 258316068Sdelphij done 259316068Sdelphij rm -f conftest.in conftest.tmp conftest.nl conftest.out 260316068Sdelphij } 261316068Sdelphij 262316068Sdelphij func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263316068Sdelphij rm -f conftest.sed 264316068Sdelphij SED=$func_path_progs_result 265316068Sdelphij} 266316068Sdelphij 267316068Sdelphij 268316068Sdelphij# Unless the user overrides by setting GREP, search the path for either GNU 269316068Sdelphij# grep, or the grep that truncates its output the least. 270316068Sdelphijtest -z "$GREP" && { 271316068Sdelphij func_check_prog_grep () 272316068Sdelphij { 273316068Sdelphij _G_path_prog=$1 274316068Sdelphij 275316068Sdelphij _G_count=0 276316068Sdelphij _G_path_prog_max=0 277316068Sdelphij printf 0123456789 >conftest.in 278316068Sdelphij while : 279316068Sdelphij do 280316068Sdelphij cat conftest.in conftest.in >conftest.tmp 281316068Sdelphij mv conftest.tmp conftest.in 282316068Sdelphij cp conftest.in conftest.nl 283316068Sdelphij echo 'GREP' >> conftest.nl 284316068Sdelphij "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285316068Sdelphij diff conftest.out conftest.nl >/dev/null 2>&1 || break 286316068Sdelphij _G_count=`expr $_G_count + 1` 287316068Sdelphij if test "$_G_count" -gt "$_G_path_prog_max"; then 288316068Sdelphij # Best one so far, save it but keep looking for a better one 289316068Sdelphij func_check_prog_result=$_G_path_prog 290316068Sdelphij _G_path_prog_max=$_G_count 291316068Sdelphij fi 292316068Sdelphij # 10*(2^10) chars as input seems more than enough 293316068Sdelphij test 10 -lt "$_G_count" && break 294316068Sdelphij done 295316068Sdelphij rm -f conftest.in conftest.tmp conftest.nl conftest.out 296316068Sdelphij } 297316068Sdelphij 298316068Sdelphij func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299316068Sdelphij GREP=$func_path_progs_result 300316068Sdelphij} 301316068Sdelphij 302316068Sdelphij 303316068Sdelphij## ------------------------------- ## 304316068Sdelphij## User overridable command paths. ## 305316068Sdelphij## ------------------------------- ## 306316068Sdelphij 307316068Sdelphij# All uppercase variable names are used for environment variables. These 308316068Sdelphij# variables can be overridden by the user before calling a script that 309316068Sdelphij# uses them if a suitable command of that name is not already available 310316068Sdelphij# in the command search PATH. 311316068Sdelphij 312275970Scy: ${CP="cp -f"} 313316068Sdelphij: ${ECHO="printf %s\n"} 314316068Sdelphij: ${EGREP="$GREP -E"} 315316068Sdelphij: ${FGREP="$GREP -F"} 316316068Sdelphij: ${LN_S="ln -s"} 317275970Scy: ${MAKE="make"} 318275970Scy: ${MKDIR="mkdir"} 319275970Scy: ${MV="mv -f"} 320275970Scy: ${RM="rm -f"} 321275970Scy: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322275970Scy 323275970Scy 324316068Sdelphij## -------------------- ## 325316068Sdelphij## Useful sed snippets. ## 326316068Sdelphij## -------------------- ## 327275970Scy 328316068Sdelphijsed_dirname='s|/[^/]*$||' 329316068Sdelphijsed_basename='s|^.*/||' 330275970Scy 331316068Sdelphij# Sed substitution that helps us do robust quoting. It backslashifies 332316068Sdelphij# metacharacters that are still active within double-quoted strings. 333316068Sdelphijsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334275970Scy 335316068Sdelphij# Same as above, but do not quote variable references. 336316068Sdelphijsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337275970Scy 338316068Sdelphij# Sed substitution that turns a string into a regex matching for the 339316068Sdelphij# string literally. 340316068Sdelphijsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341275970Scy 342316068Sdelphij# Sed substitution that converts a w32 file name or path 343316068Sdelphij# that contains forward slashes, into one that contains 344316068Sdelphij# (escaped) backslashes. A very naive implementation. 345316068Sdelphijsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346275970Scy 347316068Sdelphij# Re-'\' parameter expansions in output of sed_double_quote_subst that 348316068Sdelphij# were '\'-ed in input to the same. If an odd number of '\' preceded a 349316068Sdelphij# '$' in input to sed_double_quote_subst, that '$' was protected from 350316068Sdelphij# expansion. Since each input '\' is now two '\'s, look for any number 351316068Sdelphij# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352316068Sdelphij_G_bs='\\' 353316068Sdelphij_G_bs2='\\\\' 354316068Sdelphij_G_bs4='\\\\\\\\' 355316068Sdelphij_G_dollar='\$' 356316068Sdelphijsed_double_backslash="\ 357316068Sdelphij s/$_G_bs4/&\\ 358316068Sdelphij/g 359316068Sdelphij s/^$_G_bs2$_G_dollar/$_G_bs&/ 360316068Sdelphij s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361316068Sdelphij s/\n//g" 362275970Scy 363275970Scy 364316068Sdelphij## ----------------- ## 365316068Sdelphij## Global variables. ## 366316068Sdelphij## ----------------- ## 367275970Scy 368316068Sdelphij# Except for the global variables explicitly listed below, the following 369316068Sdelphij# functions in the '^func_' namespace, and the '^require_' namespace 370316068Sdelphij# variables initialised in the 'Resource management' section, sourcing 371316068Sdelphij# this file will not pollute your global namespace with anything 372316068Sdelphij# else. There's no portable way to scope variables in Bourne shell 373316068Sdelphij# though, so actually running these functions will sometimes place 374316068Sdelphij# results into a variable named after the function, and often use 375316068Sdelphij# temporary variables in the '^_G_' namespace. If you are careful to 376316068Sdelphij# avoid using those namespaces casually in your sourcing script, things 377316068Sdelphij# should continue to work as you expect. And, of course, you can freely 378316068Sdelphij# overwrite any of the functions or variables defined here before 379316068Sdelphij# calling anything to customize them. 380275970Scy 381316068SdelphijEXIT_SUCCESS=0 382316068SdelphijEXIT_FAILURE=1 383316068SdelphijEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384316068SdelphijEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385275970Scy 386316068Sdelphij# Allow overriding, eg assuming that you follow the convention of 387316068Sdelphij# putting '$debug_cmd' at the start of all your functions, you can get 388316068Sdelphij# bash to show function call trace with: 389316068Sdelphij# 390316068Sdelphij# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391316068Sdelphijdebug_cmd=${debug_cmd-":"} 392316068Sdelphijexit_cmd=: 393275970Scy 394316068Sdelphij# By convention, finish your script with: 395316068Sdelphij# 396316068Sdelphij# exit $exit_status 397316068Sdelphij# 398316068Sdelphij# so that you can set exit_status to non-zero if you want to indicate 399316068Sdelphij# something went wrong during execution without actually bailing out at 400316068Sdelphij# the point of failure. 401316068Sdelphijexit_status=$EXIT_SUCCESS 402275970Scy 403316068Sdelphij# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404316068Sdelphij# is ksh but when the shell is invoked as "sh" and the current value of 405316068Sdelphij# the _XPG environment variable is not equal to 1 (one), the special 406316068Sdelphij# positional parameter $0, within a function call, is the name of the 407316068Sdelphij# function. 408316068Sdelphijprogpath=$0 409275970Scy 410316068Sdelphij# The name of this program. 411316068Sdelphijprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412275970Scy 413316068Sdelphij# Make sure we have an absolute progpath for reexecution: 414275970Scycase $progpath in 415275970Scy [\\/]*|[A-Za-z]:\\*) ;; 416275970Scy *[\\/]*) 417316068Sdelphij progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418275970Scy progdir=`cd "$progdir" && pwd` 419316068Sdelphij progpath=$progdir/$progname 420275970Scy ;; 421275970Scy *) 422316068Sdelphij _G_IFS=$IFS 423285169Scy IFS=${PATH_SEPARATOR-:} 424275970Scy for progdir in $PATH; do 425316068Sdelphij IFS=$_G_IFS 426275970Scy test -x "$progdir/$progname" && break 427275970Scy done 428316068Sdelphij IFS=$_G_IFS 429275970Scy test -n "$progdir" || progdir=`pwd` 430316068Sdelphij progpath=$progdir/$progname 431275970Scy ;; 432275970Scyesac 433275970Scy 434275970Scy 435316068Sdelphij## ----------------- ## 436316068Sdelphij## Standard options. ## 437316068Sdelphij## ----------------- ## 438275970Scy 439316068Sdelphij# The following options affect the operation of the functions defined 440316068Sdelphij# below, and should be set appropriately depending on run-time para- 441316068Sdelphij# meters passed on the command line. 442275970Scy 443275970Scyopt_dry_run=false 444275970Scyopt_quiet=false 445275970Scyopt_verbose=false 446275970Scy 447316068Sdelphij# Categories 'all' and 'none' are always available. Append any others 448316068Sdelphij# you will pass as the first argument to func_warning from your own 449316068Sdelphij# code. 450316068Sdelphijwarning_categories= 451316068Sdelphij 452316068Sdelphij# By default, display warnings according to 'opt_warning_types'. Set 453316068Sdelphij# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454316068Sdelphij# treat the next displayed warning as a fatal error. 455316068Sdelphijwarning_func=func_warn_and_continue 456316068Sdelphij 457316068Sdelphij# Set to 'all' to display all warnings, 'none' to suppress all 458316068Sdelphij# warnings, or a space delimited list of some subset of 459316068Sdelphij# 'warning_categories' to display only the listed warnings. 460316068Sdelphijopt_warning_types=all 461316068Sdelphij 462316068Sdelphij 463316068Sdelphij## -------------------- ## 464316068Sdelphij## Resource management. ## 465316068Sdelphij## -------------------- ## 466316068Sdelphij 467316068Sdelphij# This section contains definitions for functions that each ensure a 468316068Sdelphij# particular resource (a file, or a non-empty configuration variable for 469316068Sdelphij# example) is available, and if appropriate to extract default values 470316068Sdelphij# from pertinent package files. Call them using their associated 471316068Sdelphij# 'require_*' variable to ensure that they are executed, at most, once. 472316068Sdelphij# 473316068Sdelphij# It's entirely deliberate that calling these functions can set 474316068Sdelphij# variables that don't obey the namespace limitations obeyed by the rest 475316068Sdelphij# of this file, in order that that they be as useful as possible to 476316068Sdelphij# callers. 477316068Sdelphij 478316068Sdelphij 479316068Sdelphij# require_term_colors 480316068Sdelphij# ------------------- 481316068Sdelphij# Allow display of bold text on terminals that support it. 482316068Sdelphijrequire_term_colors=func_require_term_colors 483316068Sdelphijfunc_require_term_colors () 484275970Scy{ 485316068Sdelphij $debug_cmd 486316068Sdelphij 487316068Sdelphij test -t 1 && { 488316068Sdelphij # COLORTERM and USE_ANSI_COLORS environment variables take 489316068Sdelphij # precedence, because most terminfo databases neglect to describe 490316068Sdelphij # whether color sequences are supported. 491316068Sdelphij test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492316068Sdelphij 493316068Sdelphij if test 1 = "$USE_ANSI_COLORS"; then 494316068Sdelphij # Standard ANSI escape sequences 495316068Sdelphij tc_reset='[0m' 496316068Sdelphij tc_bold='[1m'; tc_standout='[7m' 497316068Sdelphij tc_red='[31m'; tc_green='[32m' 498316068Sdelphij tc_blue='[34m'; tc_cyan='[36m' 499316068Sdelphij else 500316068Sdelphij # Otherwise trust the terminfo database after all. 501316068Sdelphij test -n "`tput sgr0 2>/dev/null`" && { 502316068Sdelphij tc_reset=`tput sgr0` 503316068Sdelphij test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504316068Sdelphij tc_standout=$tc_bold 505316068Sdelphij test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506316068Sdelphij test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507316068Sdelphij test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508316068Sdelphij test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509316068Sdelphij test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510316068Sdelphij } 511316068Sdelphij fi 512316068Sdelphij } 513316068Sdelphij 514316068Sdelphij require_term_colors=: 515275970Scy} 516275970Scy 517316068Sdelphij 518316068Sdelphij## ----------------- ## 519316068Sdelphij## Function library. ## 520316068Sdelphij## ----------------- ## 521316068Sdelphij 522316068Sdelphij# This section contains a variety of useful functions to call in your 523316068Sdelphij# scripts. Take note of the portable wrappers for features provided by 524316068Sdelphij# some modern shells, which will fall back to slower equivalents on 525316068Sdelphij# less featureful shells. 526316068Sdelphij 527316068Sdelphij 528316068Sdelphij# func_append VAR VALUE 529316068Sdelphij# --------------------- 530316068Sdelphij# Append VALUE onto the existing contents of VAR. 531316068Sdelphij 532316068Sdelphij # We should try to minimise forks, especially on Windows where they are 533316068Sdelphij # unreasonably slow, so skip the feature probes when bash or zsh are 534316068Sdelphij # being used: 535316068Sdelphij if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536316068Sdelphij : ${_G_HAVE_ARITH_OP="yes"} 537316068Sdelphij : ${_G_HAVE_XSI_OPS="yes"} 538316068Sdelphij # The += operator was introduced in bash 3.1 539316068Sdelphij case $BASH_VERSION in 540316068Sdelphij [12].* | 3.0 | 3.0*) ;; 541316068Sdelphij *) 542316068Sdelphij : ${_G_HAVE_PLUSEQ_OP="yes"} 543316068Sdelphij ;; 544316068Sdelphij esac 545316068Sdelphij fi 546316068Sdelphij 547316068Sdelphij # _G_HAVE_PLUSEQ_OP 548316068Sdelphij # Can be empty, in which case the shell is probed, "yes" if += is 549316068Sdelphij # useable or anything else if it does not work. 550316068Sdelphij test -z "$_G_HAVE_PLUSEQ_OP" \ 551316068Sdelphij && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552316068Sdelphij && _G_HAVE_PLUSEQ_OP=yes 553316068Sdelphij 554316068Sdelphijif test yes = "$_G_HAVE_PLUSEQ_OP" 555316068Sdelphijthen 556316068Sdelphij # This is an XSI compatible shell, allowing a faster implementation... 557316068Sdelphij eval 'func_append () 558316068Sdelphij { 559316068Sdelphij $debug_cmd 560316068Sdelphij 561316068Sdelphij eval "$1+=\$2" 562316068Sdelphij }' 563316068Sdelphijelse 564316068Sdelphij # ...otherwise fall back to using expr, which is often a shell builtin. 565316068Sdelphij func_append () 566316068Sdelphij { 567316068Sdelphij $debug_cmd 568316068Sdelphij 569316068Sdelphij eval "$1=\$$1\$2" 570316068Sdelphij } 571316068Sdelphijfi 572316068Sdelphij 573316068Sdelphij 574316068Sdelphij# func_append_quoted VAR VALUE 575316068Sdelphij# ---------------------------- 576316068Sdelphij# Quote VALUE and append to the end of shell variable VAR, separated 577316068Sdelphij# by a space. 578316068Sdelphijif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579316068Sdelphij eval 'func_append_quoted () 580316068Sdelphij { 581316068Sdelphij $debug_cmd 582316068Sdelphij 583316068Sdelphij func_quote_for_eval "$2" 584316068Sdelphij eval "$1+=\\ \$func_quote_for_eval_result" 585316068Sdelphij }' 586316068Sdelphijelse 587316068Sdelphij func_append_quoted () 588316068Sdelphij { 589316068Sdelphij $debug_cmd 590316068Sdelphij 591316068Sdelphij func_quote_for_eval "$2" 592316068Sdelphij eval "$1=\$$1\\ \$func_quote_for_eval_result" 593316068Sdelphij } 594316068Sdelphijfi 595316068Sdelphij 596316068Sdelphij 597316068Sdelphij# func_append_uniq VAR VALUE 598316068Sdelphij# -------------------------- 599316068Sdelphij# Append unique VALUE onto the existing contents of VAR, assuming 600316068Sdelphij# entries are delimited by the first character of VALUE. For example: 601316068Sdelphij# 602316068Sdelphij# func_append_uniq options " --another-option option-argument" 603316068Sdelphij# 604316068Sdelphij# will only append to $options if " --another-option option-argument " 605316068Sdelphij# is not already present somewhere in $options already (note spaces at 606316068Sdelphij# each end implied by leading space in second argument). 607316068Sdelphijfunc_append_uniq () 608275970Scy{ 609316068Sdelphij $debug_cmd 610275970Scy 611316068Sdelphij eval _G_current_value='`$ECHO $'$1'`' 612316068Sdelphij _G_delim=`expr "$2" : '\(.\)'` 613316068Sdelphij 614316068Sdelphij case $_G_delim$_G_current_value$_G_delim in 615316068Sdelphij *"$2$_G_delim"*) ;; 616316068Sdelphij *) func_append "$@" ;; 617316068Sdelphij esac 618275970Scy} 619275970Scy 620316068Sdelphij 621316068Sdelphij# func_arith TERM... 622316068Sdelphij# ------------------ 623316068Sdelphij# Set func_arith_result to the result of evaluating TERMs. 624316068Sdelphij test -z "$_G_HAVE_ARITH_OP" \ 625316068Sdelphij && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626316068Sdelphij && _G_HAVE_ARITH_OP=yes 627316068Sdelphij 628316068Sdelphijif test yes = "$_G_HAVE_ARITH_OP"; then 629316068Sdelphij eval 'func_arith () 630316068Sdelphij { 631316068Sdelphij $debug_cmd 632316068Sdelphij 633316068Sdelphij func_arith_result=$(( $* )) 634316068Sdelphij }' 635316068Sdelphijelse 636316068Sdelphij func_arith () 637316068Sdelphij { 638316068Sdelphij $debug_cmd 639316068Sdelphij 640316068Sdelphij func_arith_result=`expr "$@"` 641316068Sdelphij } 642316068Sdelphijfi 643316068Sdelphij 644316068Sdelphij 645316068Sdelphij# func_basename FILE 646316068Sdelphij# ------------------ 647316068Sdelphij# Set func_basename_result to FILE with everything up to and including 648316068Sdelphij# the last / stripped. 649316068Sdelphijif test yes = "$_G_HAVE_XSI_OPS"; then 650316068Sdelphij # If this shell supports suffix pattern removal, then use it to avoid 651316068Sdelphij # forking. Hide the definitions single quotes in case the shell chokes 652316068Sdelphij # on unsupported syntax... 653316068Sdelphij _b='func_basename_result=${1##*/}' 654316068Sdelphij _d='case $1 in 655316068Sdelphij */*) func_dirname_result=${1%/*}$2 ;; 656316068Sdelphij * ) func_dirname_result=$3 ;; 657316068Sdelphij esac' 658316068Sdelphij 659316068Sdelphijelse 660316068Sdelphij # ...otherwise fall back to using sed. 661316068Sdelphij _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662316068Sdelphij _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663316068Sdelphij if test "X$func_dirname_result" = "X$1"; then 664316068Sdelphij func_dirname_result=$3 665316068Sdelphij else 666316068Sdelphij func_append func_dirname_result "$2" 667316068Sdelphij fi' 668316068Sdelphijfi 669316068Sdelphij 670316068Sdelphijeval 'func_basename () 671316068Sdelphij{ 672316068Sdelphij $debug_cmd 673316068Sdelphij 674316068Sdelphij '"$_b"' 675316068Sdelphij}' 676316068Sdelphij 677316068Sdelphij 678316068Sdelphij# func_dirname FILE APPEND NONDIR_REPLACEMENT 679316068Sdelphij# ------------------------------------------- 680316068Sdelphij# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681316068Sdelphij# otherwise set result to NONDIR_REPLACEMENT. 682316068Sdelphijeval 'func_dirname () 683316068Sdelphij{ 684316068Sdelphij $debug_cmd 685316068Sdelphij 686316068Sdelphij '"$_d"' 687316068Sdelphij}' 688316068Sdelphij 689316068Sdelphij 690316068Sdelphij# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691316068Sdelphij# -------------------------------------------------------- 692316068Sdelphij# Perform func_basename and func_dirname in a single function 693316068Sdelphij# call: 694316068Sdelphij# dirname: Compute the dirname of FILE. If nonempty, 695316068Sdelphij# add APPEND to the result, otherwise set result 696316068Sdelphij# to NONDIR_REPLACEMENT. 697316068Sdelphij# value returned in "$func_dirname_result" 698316068Sdelphij# basename: Compute filename of FILE. 699316068Sdelphij# value retuned in "$func_basename_result" 700316068Sdelphij# For efficiency, we do not delegate to the functions above but instead 701316068Sdelphij# duplicate the functionality here. 702316068Sdelphijeval 'func_dirname_and_basename () 703316068Sdelphij{ 704316068Sdelphij $debug_cmd 705316068Sdelphij 706316068Sdelphij '"$_b"' 707316068Sdelphij '"$_d"' 708316068Sdelphij}' 709316068Sdelphij 710316068Sdelphij 711316068Sdelphij# func_echo ARG... 712316068Sdelphij# ---------------- 713316068Sdelphij# Echo program name prefixed message. 714316068Sdelphijfunc_echo () 715316068Sdelphij{ 716316068Sdelphij $debug_cmd 717316068Sdelphij 718316068Sdelphij _G_message=$* 719316068Sdelphij 720316068Sdelphij func_echo_IFS=$IFS 721316068Sdelphij IFS=$nl 722316068Sdelphij for _G_line in $_G_message; do 723316068Sdelphij IFS=$func_echo_IFS 724316068Sdelphij $ECHO "$progname: $_G_line" 725316068Sdelphij done 726316068Sdelphij IFS=$func_echo_IFS 727316068Sdelphij} 728316068Sdelphij 729316068Sdelphij 730316068Sdelphij# func_echo_all ARG... 731316068Sdelphij# -------------------- 732275970Scy# Invoke $ECHO with all args, space-separated. 733275970Scyfunc_echo_all () 734275970Scy{ 735275970Scy $ECHO "$*" 736275970Scy} 737275970Scy 738316068Sdelphij 739316068Sdelphij# func_echo_infix_1 INFIX ARG... 740316068Sdelphij# ------------------------------ 741316068Sdelphij# Echo program name, followed by INFIX on the first line, with any 742316068Sdelphij# additional lines not showing INFIX. 743316068Sdelphijfunc_echo_infix_1 () 744275970Scy{ 745316068Sdelphij $debug_cmd 746316068Sdelphij 747316068Sdelphij $require_term_colors 748316068Sdelphij 749316068Sdelphij _G_infix=$1; shift 750316068Sdelphij _G_indent=$_G_infix 751316068Sdelphij _G_prefix="$progname: $_G_infix: " 752316068Sdelphij _G_message=$* 753316068Sdelphij 754316068Sdelphij # Strip color escape sequences before counting printable length 755316068Sdelphij for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756316068Sdelphij do 757316068Sdelphij test -n "$_G_tc" && { 758316068Sdelphij _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759316068Sdelphij _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760316068Sdelphij } 761316068Sdelphij done 762316068Sdelphij _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763316068Sdelphij 764316068Sdelphij func_echo_infix_1_IFS=$IFS 765316068Sdelphij IFS=$nl 766316068Sdelphij for _G_line in $_G_message; do 767316068Sdelphij IFS=$func_echo_infix_1_IFS 768316068Sdelphij $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769316068Sdelphij _G_prefix=$_G_indent 770316068Sdelphij done 771316068Sdelphij IFS=$func_echo_infix_1_IFS 772275970Scy} 773275970Scy 774316068Sdelphij 775316068Sdelphij# func_error ARG... 776316068Sdelphij# ----------------- 777316068Sdelphij# Echo program name prefixed message to standard error. 778316068Sdelphijfunc_error () 779275970Scy{ 780316068Sdelphij $debug_cmd 781275970Scy 782316068Sdelphij $require_term_colors 783316068Sdelphij 784316068Sdelphij func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785275970Scy} 786275970Scy 787316068Sdelphij 788316068Sdelphij# func_fatal_error ARG... 789316068Sdelphij# ----------------------- 790275970Scy# Echo program name prefixed message to standard error, and exit. 791275970Scyfunc_fatal_error () 792275970Scy{ 793316068Sdelphij $debug_cmd 794316068Sdelphij 795316068Sdelphij func_error "$*" 796275970Scy exit $EXIT_FAILURE 797275970Scy} 798275970Scy 799275970Scy 800316068Sdelphij# func_grep EXPRESSION FILENAME 801316068Sdelphij# ----------------------------- 802275970Scy# Check whether EXPRESSION matches any line of FILENAME, without output. 803275970Scyfunc_grep () 804275970Scy{ 805316068Sdelphij $debug_cmd 806316068Sdelphij 807275970Scy $GREP "$1" "$2" >/dev/null 2>&1 808275970Scy} 809275970Scy 810275970Scy 811316068Sdelphij# func_len STRING 812316068Sdelphij# --------------- 813316068Sdelphij# Set func_len_result to the length of STRING. STRING may not 814316068Sdelphij# start with a hyphen. 815316068Sdelphij test -z "$_G_HAVE_XSI_OPS" \ 816316068Sdelphij && (eval 'x=a/b/c; 817316068Sdelphij test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818316068Sdelphij && _G_HAVE_XSI_OPS=yes 819316068Sdelphij 820316068Sdelphijif test yes = "$_G_HAVE_XSI_OPS"; then 821316068Sdelphij eval 'func_len () 822316068Sdelphij { 823316068Sdelphij $debug_cmd 824316068Sdelphij 825316068Sdelphij func_len_result=${#1} 826316068Sdelphij }' 827316068Sdelphijelse 828316068Sdelphij func_len () 829316068Sdelphij { 830316068Sdelphij $debug_cmd 831316068Sdelphij 832316068Sdelphij func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833316068Sdelphij } 834316068Sdelphijfi 835316068Sdelphij 836316068Sdelphij 837316068Sdelphij# func_mkdir_p DIRECTORY-PATH 838316068Sdelphij# --------------------------- 839275970Scy# Make sure the entire path to DIRECTORY-PATH is available. 840275970Scyfunc_mkdir_p () 841275970Scy{ 842316068Sdelphij $debug_cmd 843275970Scy 844316068Sdelphij _G_directory_path=$1 845316068Sdelphij _G_dir_list= 846275970Scy 847316068Sdelphij if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848316068Sdelphij 849316068Sdelphij # Protect directory names starting with '-' 850316068Sdelphij case $_G_directory_path in 851316068Sdelphij -*) _G_directory_path=./$_G_directory_path ;; 852275970Scy esac 853275970Scy 854275970Scy # While some portion of DIR does not yet exist... 855316068Sdelphij while test ! -d "$_G_directory_path"; do 856275970Scy # ...make a list in topmost first order. Use a colon delimited 857275970Scy # list incase some portion of path contains whitespace. 858316068Sdelphij _G_dir_list=$_G_directory_path:$_G_dir_list 859275970Scy 860275970Scy # If the last portion added has no slash in it, the list is done 861316068Sdelphij case $_G_directory_path in */*) ;; *) break ;; esac 862275970Scy 863275970Scy # ...otherwise throw away the child directory and loop 864316068Sdelphij _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865275970Scy done 866316068Sdelphij _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867275970Scy 868316068Sdelphij func_mkdir_p_IFS=$IFS; IFS=: 869316068Sdelphij for _G_dir in $_G_dir_list; do 870316068Sdelphij IFS=$func_mkdir_p_IFS 871316068Sdelphij # mkdir can fail with a 'File exist' error if two processes 872275970Scy # try to create one of the directories concurrently. Don't 873275970Scy # stop in that case! 874316068Sdelphij $MKDIR "$_G_dir" 2>/dev/null || : 875275970Scy done 876316068Sdelphij IFS=$func_mkdir_p_IFS 877275970Scy 878275970Scy # Bail out if we (or some other process) failed to create a directory. 879316068Sdelphij test -d "$_G_directory_path" || \ 880316068Sdelphij func_fatal_error "Failed to create '$1'" 881275970Scy fi 882275970Scy} 883275970Scy 884275970Scy 885316068Sdelphij# func_mktempdir [BASENAME] 886316068Sdelphij# ------------------------- 887275970Scy# Make a temporary directory that won't clash with other running 888275970Scy# libtool processes, and avoids race conditions if possible. If 889316068Sdelphij# given, BASENAME is the basename for that directory. 890275970Scyfunc_mktempdir () 891275970Scy{ 892316068Sdelphij $debug_cmd 893275970Scy 894316068Sdelphij _G_template=${TMPDIR-/tmp}/${1-$progname} 895316068Sdelphij 896316068Sdelphij if test : = "$opt_dry_run"; then 897275970Scy # Return a directory name, but don't create it in dry-run mode 898316068Sdelphij _G_tmpdir=$_G_template-$$ 899275970Scy else 900275970Scy 901275970Scy # If mktemp works, use that first and foremost 902316068Sdelphij _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903275970Scy 904316068Sdelphij if test ! -d "$_G_tmpdir"; then 905275970Scy # Failing that, at least try and use $RANDOM to avoid a race 906316068Sdelphij _G_tmpdir=$_G_template-${RANDOM-0}$$ 907275970Scy 908316068Sdelphij func_mktempdir_umask=`umask` 909275970Scy umask 0077 910316068Sdelphij $MKDIR "$_G_tmpdir" 911316068Sdelphij umask $func_mktempdir_umask 912275970Scy fi 913275970Scy 914275970Scy # If we're not in dry-run mode, bomb out on failure 915316068Sdelphij test -d "$_G_tmpdir" || \ 916316068Sdelphij func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917275970Scy fi 918275970Scy 919316068Sdelphij $ECHO "$_G_tmpdir" 920275970Scy} 921275970Scy 922275970Scy 923316068Sdelphij# func_normal_abspath PATH 924316068Sdelphij# ------------------------ 925316068Sdelphij# Remove doubled-up and trailing slashes, "." path components, 926316068Sdelphij# and cancel out any ".." path components in PATH after making 927316068Sdelphij# it an absolute path. 928316068Sdelphijfunc_normal_abspath () 929275970Scy{ 930316068Sdelphij $debug_cmd 931275970Scy 932316068Sdelphij # These SED scripts presuppose an absolute path with a trailing slash. 933316068Sdelphij _G_pathcar='s|^/\([^/]*\).*$|\1|' 934316068Sdelphij _G_pathcdr='s|^/[^/]*||' 935316068Sdelphij _G_removedotparts=':dotsl 936316068Sdelphij s|/\./|/|g 937316068Sdelphij t dotsl 938316068Sdelphij s|/\.$|/|' 939316068Sdelphij _G_collapseslashes='s|/\{1,\}|/|g' 940316068Sdelphij _G_finalslash='s|/*$|/|' 941316068Sdelphij 942316068Sdelphij # Start from root dir and reassemble the path. 943316068Sdelphij func_normal_abspath_result= 944316068Sdelphij func_normal_abspath_tpath=$1 945316068Sdelphij func_normal_abspath_altnamespace= 946316068Sdelphij case $func_normal_abspath_tpath in 947316068Sdelphij "") 948316068Sdelphij # Empty path, that just means $cwd. 949316068Sdelphij func_stripname '' '/' "`pwd`" 950316068Sdelphij func_normal_abspath_result=$func_stripname_result 951316068Sdelphij return 952275970Scy ;; 953316068Sdelphij # The next three entries are used to spot a run of precisely 954316068Sdelphij # two leading slashes without using negated character classes; 955316068Sdelphij # we take advantage of case's first-match behaviour. 956316068Sdelphij ///*) 957316068Sdelphij # Unusual form of absolute path, do nothing. 958316068Sdelphij ;; 959316068Sdelphij //*) 960316068Sdelphij # Not necessarily an ordinary path; POSIX reserves leading '//' 961316068Sdelphij # and for example Cygwin uses it to access remote file shares 962316068Sdelphij # over CIFS/SMB, so we conserve a leading double slash if found. 963316068Sdelphij func_normal_abspath_altnamespace=/ 964316068Sdelphij ;; 965316068Sdelphij /*) 966316068Sdelphij # Absolute path, do nothing. 967316068Sdelphij ;; 968275970Scy *) 969316068Sdelphij # Relative path, prepend $cwd. 970316068Sdelphij func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971316068Sdelphij ;; 972275970Scy esac 973316068Sdelphij 974316068Sdelphij # Cancel out all the simple stuff to save iterations. We also want 975316068Sdelphij # the path to end with a slash for ease of parsing, so make sure 976316068Sdelphij # there is one (and only one) here. 977316068Sdelphij func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978316068Sdelphij -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979316068Sdelphij while :; do 980316068Sdelphij # Processed it all yet? 981316068Sdelphij if test / = "$func_normal_abspath_tpath"; then 982316068Sdelphij # If we ascended to the root using ".." the result may be empty now. 983316068Sdelphij if test -z "$func_normal_abspath_result"; then 984316068Sdelphij func_normal_abspath_result=/ 985316068Sdelphij fi 986316068Sdelphij break 987316068Sdelphij fi 988316068Sdelphij func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989316068Sdelphij -e "$_G_pathcar"` 990316068Sdelphij func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991316068Sdelphij -e "$_G_pathcdr"` 992316068Sdelphij # Figure out what to do with it 993316068Sdelphij case $func_normal_abspath_tcomponent in 994316068Sdelphij "") 995316068Sdelphij # Trailing empty path component, ignore it. 996316068Sdelphij ;; 997316068Sdelphij ..) 998316068Sdelphij # Parent dir; strip last assembled component from result. 999316068Sdelphij func_dirname "$func_normal_abspath_result" 1000316068Sdelphij func_normal_abspath_result=$func_dirname_result 1001316068Sdelphij ;; 1002316068Sdelphij *) 1003316068Sdelphij # Actual path component, append it. 1004316068Sdelphij func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005316068Sdelphij ;; 1006316068Sdelphij esac 1007316068Sdelphij done 1008316068Sdelphij # Restore leading double-slash if one was found on entry. 1009316068Sdelphij func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010275970Scy} 1011275970Scy 1012275970Scy 1013316068Sdelphij# func_notquiet ARG... 1014316068Sdelphij# -------------------- 1015316068Sdelphij# Echo program name prefixed message only when not in quiet mode. 1016316068Sdelphijfunc_notquiet () 1017316068Sdelphij{ 1018316068Sdelphij $debug_cmd 1019316068Sdelphij 1020316068Sdelphij $opt_quiet || func_echo ${1+"$@"} 1021316068Sdelphij 1022316068Sdelphij # A bug in bash halts the script if the last line of a function 1023316068Sdelphij # fails when set -e is in force, so we need another command to 1024316068Sdelphij # work around that: 1025316068Sdelphij : 1026316068Sdelphij} 1027316068Sdelphij 1028316068Sdelphij 1029316068Sdelphij# func_relative_path SRCDIR DSTDIR 1030316068Sdelphij# -------------------------------- 1031316068Sdelphij# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032316068Sdelphijfunc_relative_path () 1033316068Sdelphij{ 1034316068Sdelphij $debug_cmd 1035316068Sdelphij 1036316068Sdelphij func_relative_path_result= 1037316068Sdelphij func_normal_abspath "$1" 1038316068Sdelphij func_relative_path_tlibdir=$func_normal_abspath_result 1039316068Sdelphij func_normal_abspath "$2" 1040316068Sdelphij func_relative_path_tbindir=$func_normal_abspath_result 1041316068Sdelphij 1042316068Sdelphij # Ascend the tree starting from libdir 1043316068Sdelphij while :; do 1044316068Sdelphij # check if we have found a prefix of bindir 1045316068Sdelphij case $func_relative_path_tbindir in 1046316068Sdelphij $func_relative_path_tlibdir) 1047316068Sdelphij # found an exact match 1048316068Sdelphij func_relative_path_tcancelled= 1049316068Sdelphij break 1050316068Sdelphij ;; 1051316068Sdelphij $func_relative_path_tlibdir*) 1052316068Sdelphij # found a matching prefix 1053316068Sdelphij func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054316068Sdelphij func_relative_path_tcancelled=$func_stripname_result 1055316068Sdelphij if test -z "$func_relative_path_result"; then 1056316068Sdelphij func_relative_path_result=. 1057316068Sdelphij fi 1058316068Sdelphij break 1059316068Sdelphij ;; 1060316068Sdelphij *) 1061316068Sdelphij func_dirname $func_relative_path_tlibdir 1062316068Sdelphij func_relative_path_tlibdir=$func_dirname_result 1063316068Sdelphij if test -z "$func_relative_path_tlibdir"; then 1064316068Sdelphij # Have to descend all the way to the root! 1065316068Sdelphij func_relative_path_result=../$func_relative_path_result 1066316068Sdelphij func_relative_path_tcancelled=$func_relative_path_tbindir 1067316068Sdelphij break 1068316068Sdelphij fi 1069316068Sdelphij func_relative_path_result=../$func_relative_path_result 1070316068Sdelphij ;; 1071316068Sdelphij esac 1072316068Sdelphij done 1073316068Sdelphij 1074316068Sdelphij # Now calculate path; take care to avoid doubling-up slashes. 1075316068Sdelphij func_stripname '' '/' "$func_relative_path_result" 1076316068Sdelphij func_relative_path_result=$func_stripname_result 1077316068Sdelphij func_stripname '/' '/' "$func_relative_path_tcancelled" 1078316068Sdelphij if test -n "$func_stripname_result"; then 1079316068Sdelphij func_append func_relative_path_result "/$func_stripname_result" 1080316068Sdelphij fi 1081316068Sdelphij 1082316068Sdelphij # Normalisation. If bindir is libdir, return '.' else relative path. 1083316068Sdelphij if test -n "$func_relative_path_result"; then 1084316068Sdelphij func_stripname './' '' "$func_relative_path_result" 1085316068Sdelphij func_relative_path_result=$func_stripname_result 1086316068Sdelphij fi 1087316068Sdelphij 1088316068Sdelphij test -n "$func_relative_path_result" || func_relative_path_result=. 1089316068Sdelphij 1090316068Sdelphij : 1091316068Sdelphij} 1092316068Sdelphij 1093316068Sdelphij 1094316068Sdelphij# func_quote_for_eval ARG... 1095316068Sdelphij# -------------------------- 1096316068Sdelphij# Aesthetically quote ARGs to be evaled later. 1097316068Sdelphij# This function returns two values: 1098316068Sdelphij# i) func_quote_for_eval_result 1099316068Sdelphij# double-quoted, suitable for a subsequent eval 1100316068Sdelphij# ii) func_quote_for_eval_unquoted_result 1101316068Sdelphij# has all characters that are still active within double 1102316068Sdelphij# quotes backslashified. 1103316068Sdelphijfunc_quote_for_eval () 1104316068Sdelphij{ 1105316068Sdelphij $debug_cmd 1106316068Sdelphij 1107316068Sdelphij func_quote_for_eval_unquoted_result= 1108316068Sdelphij func_quote_for_eval_result= 1109316068Sdelphij while test 0 -lt $#; do 1110316068Sdelphij case $1 in 1111316068Sdelphij *[\\\`\"\$]*) 1112316068Sdelphij _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113316068Sdelphij *) 1114316068Sdelphij _G_unquoted_arg=$1 ;; 1115316068Sdelphij esac 1116316068Sdelphij if test -n "$func_quote_for_eval_unquoted_result"; then 1117316068Sdelphij func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118316068Sdelphij else 1119316068Sdelphij func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120316068Sdelphij fi 1121316068Sdelphij 1122316068Sdelphij case $_G_unquoted_arg in 1123316068Sdelphij # Double-quote args containing shell metacharacters to delay 1124316068Sdelphij # word splitting, command substitution and variable expansion 1125316068Sdelphij # for a subsequent eval. 1126316068Sdelphij # Many Bourne shells cannot handle close brackets correctly 1127316068Sdelphij # in scan sets, so we specify it separately. 1128316068Sdelphij *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129316068Sdelphij _G_quoted_arg=\"$_G_unquoted_arg\" 1130316068Sdelphij ;; 1131316068Sdelphij *) 1132316068Sdelphij _G_quoted_arg=$_G_unquoted_arg 1133316068Sdelphij ;; 1134316068Sdelphij esac 1135316068Sdelphij 1136316068Sdelphij if test -n "$func_quote_for_eval_result"; then 1137316068Sdelphij func_append func_quote_for_eval_result " $_G_quoted_arg" 1138316068Sdelphij else 1139316068Sdelphij func_append func_quote_for_eval_result "$_G_quoted_arg" 1140316068Sdelphij fi 1141316068Sdelphij shift 1142316068Sdelphij done 1143316068Sdelphij} 1144316068Sdelphij 1145316068Sdelphij 1146316068Sdelphij# func_quote_for_expand ARG 1147316068Sdelphij# ------------------------- 1148275970Scy# Aesthetically quote ARG to be evaled later; same as above, 1149275970Scy# but do not quote variable references. 1150275970Scyfunc_quote_for_expand () 1151275970Scy{ 1152316068Sdelphij $debug_cmd 1153316068Sdelphij 1154275970Scy case $1 in 1155275970Scy *[\\\`\"]*) 1156316068Sdelphij _G_arg=`$ECHO "$1" | $SED \ 1157316068Sdelphij -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1158275970Scy *) 1159316068Sdelphij _G_arg=$1 ;; 1160275970Scy esac 1161275970Scy 1162316068Sdelphij case $_G_arg in 1163275970Scy # Double-quote args containing shell metacharacters to delay 1164275970Scy # word splitting and command substitution for a subsequent eval. 1165275970Scy # Many Bourne shells cannot handle close brackets correctly 1166275970Scy # in scan sets, so we specify it separately. 1167275970Scy *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168316068Sdelphij _G_arg=\"$_G_arg\" 1169275970Scy ;; 1170275970Scy esac 1171275970Scy 1172316068Sdelphij func_quote_for_expand_result=$_G_arg 1173275970Scy} 1174275970Scy 1175275970Scy 1176316068Sdelphij# func_stripname PREFIX SUFFIX NAME 1177316068Sdelphij# --------------------------------- 1178316068Sdelphij# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179316068Sdelphij# PREFIX and SUFFIX must not contain globbing or regex special 1180316068Sdelphij# characters, hashes, percent signs, but SUFFIX may contain a leading 1181316068Sdelphij# dot (in which case that matches only a dot). 1182316068Sdelphijif test yes = "$_G_HAVE_XSI_OPS"; then 1183316068Sdelphij eval 'func_stripname () 1184316068Sdelphij { 1185316068Sdelphij $debug_cmd 1186316068Sdelphij 1187316068Sdelphij # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188316068Sdelphij # positional parameters, so assign one to ordinary variable first. 1189316068Sdelphij func_stripname_result=$3 1190316068Sdelphij func_stripname_result=${func_stripname_result#"$1"} 1191316068Sdelphij func_stripname_result=${func_stripname_result%"$2"} 1192316068Sdelphij }' 1193316068Sdelphijelse 1194316068Sdelphij func_stripname () 1195316068Sdelphij { 1196316068Sdelphij $debug_cmd 1197316068Sdelphij 1198316068Sdelphij case $2 in 1199316068Sdelphij .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200316068Sdelphij *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201316068Sdelphij esac 1202316068Sdelphij } 1203316068Sdelphijfi 1204316068Sdelphij 1205316068Sdelphij 1206316068Sdelphij# func_show_eval CMD [FAIL_EXP] 1207316068Sdelphij# ----------------------------- 1208316068Sdelphij# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209275970Scy# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210275970Scy# is given, then evaluate it. 1211275970Scyfunc_show_eval () 1212275970Scy{ 1213316068Sdelphij $debug_cmd 1214275970Scy 1215316068Sdelphij _G_cmd=$1 1216316068Sdelphij _G_fail_exp=${2-':'} 1217275970Scy 1218316068Sdelphij func_quote_for_expand "$_G_cmd" 1219316068Sdelphij eval "func_notquiet $func_quote_for_expand_result" 1220316068Sdelphij 1221316068Sdelphij $opt_dry_run || { 1222316068Sdelphij eval "$_G_cmd" 1223316068Sdelphij _G_status=$? 1224316068Sdelphij if test 0 -ne "$_G_status"; then 1225316068Sdelphij eval "(exit $_G_status); $_G_fail_exp" 1226275970Scy fi 1227316068Sdelphij } 1228275970Scy} 1229275970Scy 1230275970Scy 1231316068Sdelphij# func_show_eval_locale CMD [FAIL_EXP] 1232316068Sdelphij# ------------------------------------ 1233316068Sdelphij# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234275970Scy# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235275970Scy# is given, then evaluate it. Use the saved locale for evaluation. 1236275970Scyfunc_show_eval_locale () 1237275970Scy{ 1238316068Sdelphij $debug_cmd 1239275970Scy 1240316068Sdelphij _G_cmd=$1 1241316068Sdelphij _G_fail_exp=${2-':'} 1242316068Sdelphij 1243316068Sdelphij $opt_quiet || { 1244316068Sdelphij func_quote_for_expand "$_G_cmd" 1245275970Scy eval "func_echo $func_quote_for_expand_result" 1246275970Scy } 1247275970Scy 1248316068Sdelphij $opt_dry_run || { 1249316068Sdelphij eval "$_G_user_locale 1250316068Sdelphij $_G_cmd" 1251316068Sdelphij _G_status=$? 1252316068Sdelphij eval "$_G_safe_locale" 1253316068Sdelphij if test 0 -ne "$_G_status"; then 1254316068Sdelphij eval "(exit $_G_status); $_G_fail_exp" 1255275970Scy fi 1256316068Sdelphij } 1257275970Scy} 1258275970Scy 1259316068Sdelphij 1260275970Scy# func_tr_sh 1261316068Sdelphij# ---------- 1262275970Scy# Turn $1 into a string suitable for a shell variable name. 1263275970Scy# Result is stored in $func_tr_sh_result. All characters 1264275970Scy# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265275970Scy# if $1 begins with a digit, a '_' is prepended as well. 1266275970Scyfunc_tr_sh () 1267275970Scy{ 1268316068Sdelphij $debug_cmd 1269316068Sdelphij 1270316068Sdelphij case $1 in 1271316068Sdelphij [0-9]* | *[!a-zA-Z0-9_]*) 1272316068Sdelphij func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273316068Sdelphij ;; 1274316068Sdelphij * ) 1275316068Sdelphij func_tr_sh_result=$1 1276316068Sdelphij ;; 1277316068Sdelphij esac 1278275970Scy} 1279275970Scy 1280275970Scy 1281316068Sdelphij# func_verbose ARG... 1282316068Sdelphij# ------------------- 1283316068Sdelphij# Echo program name prefixed message in verbose mode only. 1284316068Sdelphijfunc_verbose () 1285275970Scy{ 1286316068Sdelphij $debug_cmd 1287275970Scy 1288316068Sdelphij $opt_verbose && func_echo "$*" 1289316068Sdelphij 1290316068Sdelphij : 1291275970Scy} 1292275970Scy 1293316068Sdelphij 1294316068Sdelphij# func_warn_and_continue ARG... 1295316068Sdelphij# ----------------------------- 1296316068Sdelphij# Echo program name prefixed warning message to standard error. 1297316068Sdelphijfunc_warn_and_continue () 1298275970Scy{ 1299316068Sdelphij $debug_cmd 1300275970Scy 1301316068Sdelphij $require_term_colors 1302316068Sdelphij 1303316068Sdelphij func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304275970Scy} 1305275970Scy 1306316068Sdelphij 1307316068Sdelphij# func_warning CATEGORY ARG... 1308316068Sdelphij# ---------------------------- 1309316068Sdelphij# Echo program name prefixed warning message to standard error. Warning 1310316068Sdelphij# messages can be filtered according to CATEGORY, where this function 1311316068Sdelphij# elides messages where CATEGORY is not listed in the global variable 1312316068Sdelphij# 'opt_warning_types'. 1313316068Sdelphijfunc_warning () 1314316068Sdelphij{ 1315316068Sdelphij $debug_cmd 1316316068Sdelphij 1317316068Sdelphij # CATEGORY must be in the warning_categories list! 1318316068Sdelphij case " $warning_categories " in 1319316068Sdelphij *" $1 "*) ;; 1320316068Sdelphij *) func_internal_error "invalid warning category '$1'" ;; 1321316068Sdelphij esac 1322316068Sdelphij 1323316068Sdelphij _G_category=$1 1324316068Sdelphij shift 1325316068Sdelphij 1326316068Sdelphij case " $opt_warning_types " in 1327316068Sdelphij *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328316068Sdelphij esac 1329316068Sdelphij} 1330316068Sdelphij 1331316068Sdelphij 1332316068Sdelphij# func_sort_ver VER1 VER2 1333316068Sdelphij# ----------------------- 1334316068Sdelphij# 'sort -V' is not generally available. 1335316068Sdelphij# Note this deviates from the version comparison in automake 1336316068Sdelphij# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337316068Sdelphij# but this should suffice as we won't be specifying old 1338316068Sdelphij# version formats or redundant trailing .0 in bootstrap.conf. 1339316068Sdelphij# If we did want full compatibility then we should probably 1340316068Sdelphij# use m4_version_compare from autoconf. 1341316068Sdelphijfunc_sort_ver () 1342316068Sdelphij{ 1343316068Sdelphij $debug_cmd 1344316068Sdelphij 1345316068Sdelphij printf '%s\n%s\n' "$1" "$2" \ 1346316068Sdelphij | 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 1347316068Sdelphij} 1348316068Sdelphij 1349316068Sdelphij# func_lt_ver PREV CURR 1350316068Sdelphij# --------------------- 1351316068Sdelphij# Return true if PREV and CURR are in the correct order according to 1352316068Sdelphij# func_sort_ver, otherwise false. Use it like this: 1353316068Sdelphij# 1354316068Sdelphij# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355316068Sdelphijfunc_lt_ver () 1356316068Sdelphij{ 1357316068Sdelphij $debug_cmd 1358316068Sdelphij 1359316068Sdelphij test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360316068Sdelphij} 1361316068Sdelphij 1362316068Sdelphij 1363316068Sdelphij# Local variables: 1364316068Sdelphij# mode: shell-script 1365316068Sdelphij# sh-indentation: 2 1366316068Sdelphij# eval: (add-hook 'before-save-hook 'time-stamp) 1367316068Sdelphij# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368316068Sdelphij# time-stamp-time-zone: "UTC" 1369316068Sdelphij# End: 1370316068Sdelphij#! /bin/sh 1371316068Sdelphij 1372316068Sdelphij# Set a version string for this script. 1373316068Sdelphijscriptversion=2014-01-07.03; # UTC 1374316068Sdelphij 1375316068Sdelphij# A portable, pluggable option parser for Bourne shell. 1376316068Sdelphij# Written by Gary V. Vaughan, 2010 1377316068Sdelphij 1378316068Sdelphij# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379316068Sdelphij# This is free software; see the source for copying conditions. There is NO 1380316068Sdelphij# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381316068Sdelphij 1382316068Sdelphij# This program is free software: you can redistribute it and/or modify 1383316068Sdelphij# it under the terms of the GNU General Public License as published by 1384316068Sdelphij# the Free Software Foundation, either version 3 of the License, or 1385316068Sdelphij# (at your option) any later version. 1386316068Sdelphij 1387316068Sdelphij# This program is distributed in the hope that it will be useful, 1388316068Sdelphij# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389316068Sdelphij# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390316068Sdelphij# GNU General Public License for more details. 1391316068Sdelphij 1392316068Sdelphij# You should have received a copy of the GNU General Public License 1393316068Sdelphij# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394316068Sdelphij 1395316068Sdelphij# Please report bugs or propose patches to gary@gnu.org. 1396316068Sdelphij 1397316068Sdelphij 1398316068Sdelphij## ------ ## 1399316068Sdelphij## Usage. ## 1400316068Sdelphij## ------ ## 1401316068Sdelphij 1402316068Sdelphij# This file is a library for parsing options in your shell scripts along 1403316068Sdelphij# with assorted other useful supporting features that you can make use 1404316068Sdelphij# of too. 1405316068Sdelphij# 1406316068Sdelphij# For the simplest scripts you might need only: 1407316068Sdelphij# 1408316068Sdelphij# #!/bin/sh 1409316068Sdelphij# . relative/path/to/funclib.sh 1410316068Sdelphij# . relative/path/to/options-parser 1411316068Sdelphij# scriptversion=1.0 1412316068Sdelphij# func_options ${1+"$@"} 1413316068Sdelphij# eval set dummy "$func_options_result"; shift 1414316068Sdelphij# ...rest of your script... 1415316068Sdelphij# 1416316068Sdelphij# In order for the '--version' option to work, you will need to have a 1417316068Sdelphij# suitably formatted comment like the one at the top of this file 1418316068Sdelphij# starting with '# Written by ' and ending with '# warranty; '. 1419316068Sdelphij# 1420316068Sdelphij# For '-h' and '--help' to work, you will also need a one line 1421316068Sdelphij# description of your script's purpose in a comment directly above the 1422316068Sdelphij# '# Written by ' line, like the one at the top of this file. 1423316068Sdelphij# 1424316068Sdelphij# The default options also support '--debug', which will turn on shell 1425316068Sdelphij# execution tracing (see the comment above debug_cmd below for another 1426316068Sdelphij# use), and '--verbose' and the func_verbose function to allow your script 1427316068Sdelphij# to display verbose messages only when your user has specified 1428316068Sdelphij# '--verbose'. 1429316068Sdelphij# 1430316068Sdelphij# After sourcing this file, you can plug processing for additional 1431316068Sdelphij# options by amending the variables from the 'Configuration' section 1432316068Sdelphij# below, and following the instructions in the 'Option parsing' 1433316068Sdelphij# section further down. 1434316068Sdelphij 1435316068Sdelphij## -------------- ## 1436316068Sdelphij## Configuration. ## 1437316068Sdelphij## -------------- ## 1438316068Sdelphij 1439316068Sdelphij# You should override these variables in your script after sourcing this 1440316068Sdelphij# file so that they reflect the customisations you have added to the 1441316068Sdelphij# option parser. 1442316068Sdelphij 1443316068Sdelphij# The usage line for option parsing errors and the start of '-h' and 1444316068Sdelphij# '--help' output messages. You can embed shell variables for delayed 1445316068Sdelphij# expansion at the time the message is displayed, but you will need to 1446316068Sdelphij# quote other shell meta-characters carefully to prevent them being 1447316068Sdelphij# expanded when the contents are evaled. 1448316068Sdelphijusage='$progpath [OPTION]...' 1449316068Sdelphij 1450316068Sdelphij# Short help message in response to '-h' and '--help'. Add to this or 1451316068Sdelphij# override it after sourcing this library to reflect the full set of 1452316068Sdelphij# options your script accepts. 1453316068Sdelphijusage_message="\ 1454316068Sdelphij --debug enable verbose shell tracing 1455316068Sdelphij -W, --warnings=CATEGORY 1456316068Sdelphij report the warnings falling in CATEGORY [all] 1457316068Sdelphij -v, --verbose verbosely report processing 1458316068Sdelphij --version print version information and exit 1459316068Sdelphij -h, --help print short or long help message and exit 1460316068Sdelphij" 1461316068Sdelphij 1462316068Sdelphij# Additional text appended to 'usage_message' in response to '--help'. 1463316068Sdelphijlong_help_message=" 1464316068SdelphijWarning categories include: 1465316068Sdelphij 'all' show all warnings 1466316068Sdelphij 'none' turn off all the warnings 1467316068Sdelphij 'error' warnings are treated as fatal errors" 1468316068Sdelphij 1469316068Sdelphij# Help message printed before fatal option parsing errors. 1470316068Sdelphijfatal_help="Try '\$progname --help' for more information." 1471316068Sdelphij 1472316068Sdelphij 1473316068Sdelphij 1474316068Sdelphij## ------------------------- ## 1475316068Sdelphij## Hook function management. ## 1476316068Sdelphij## ------------------------- ## 1477316068Sdelphij 1478316068Sdelphij# This section contains functions for adding, removing, and running hooks 1479316068Sdelphij# to the main code. A hook is just a named list of of function, that can 1480316068Sdelphij# be run in order later on. 1481316068Sdelphij 1482316068Sdelphij# func_hookable FUNC_NAME 1483316068Sdelphij# ----------------------- 1484316068Sdelphij# Declare that FUNC_NAME will run hooks added with 1485316068Sdelphij# 'func_add_hook FUNC_NAME ...'. 1486316068Sdelphijfunc_hookable () 1487316068Sdelphij{ 1488316068Sdelphij $debug_cmd 1489316068Sdelphij 1490316068Sdelphij func_append hookable_fns " $1" 1491316068Sdelphij} 1492316068Sdelphij 1493316068Sdelphij 1494316068Sdelphij# func_add_hook FUNC_NAME HOOK_FUNC 1495316068Sdelphij# --------------------------------- 1496316068Sdelphij# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497316068Sdelphij# first have been declared "hookable" by a call to 'func_hookable'. 1498316068Sdelphijfunc_add_hook () 1499316068Sdelphij{ 1500316068Sdelphij $debug_cmd 1501316068Sdelphij 1502316068Sdelphij case " $hookable_fns " in 1503316068Sdelphij *" $1 "*) ;; 1504316068Sdelphij *) func_fatal_error "'$1' does not accept hook functions." ;; 1505316068Sdelphij esac 1506316068Sdelphij 1507316068Sdelphij eval func_append ${1}_hooks '" $2"' 1508316068Sdelphij} 1509316068Sdelphij 1510316068Sdelphij 1511316068Sdelphij# func_remove_hook FUNC_NAME HOOK_FUNC 1512316068Sdelphij# ------------------------------------ 1513316068Sdelphij# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514316068Sdelphijfunc_remove_hook () 1515316068Sdelphij{ 1516316068Sdelphij $debug_cmd 1517316068Sdelphij 1518316068Sdelphij eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519316068Sdelphij} 1520316068Sdelphij 1521316068Sdelphij 1522316068Sdelphij# func_run_hooks FUNC_NAME [ARG]... 1523316068Sdelphij# --------------------------------- 1524316068Sdelphij# Run all hook functions registered to FUNC_NAME. 1525316068Sdelphij# It is assumed that the list of hook functions contains nothing more 1526316068Sdelphij# than a whitespace-delimited list of legal shell function names, and 1527316068Sdelphij# no effort is wasted trying to catch shell meta-characters or preserve 1528316068Sdelphij# whitespace. 1529316068Sdelphijfunc_run_hooks () 1530316068Sdelphij{ 1531316068Sdelphij $debug_cmd 1532316068Sdelphij 1533316068Sdelphij case " $hookable_fns " in 1534316068Sdelphij *" $1 "*) ;; 1535316068Sdelphij *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536316068Sdelphij esac 1537316068Sdelphij 1538316068Sdelphij eval _G_hook_fns=\$$1_hooks; shift 1539316068Sdelphij 1540316068Sdelphij for _G_hook in $_G_hook_fns; do 1541316068Sdelphij eval $_G_hook '"$@"' 1542316068Sdelphij 1543316068Sdelphij # store returned options list back into positional 1544316068Sdelphij # parameters for next 'cmd' execution. 1545316068Sdelphij eval _G_hook_result=\$${_G_hook}_result 1546316068Sdelphij eval set dummy "$_G_hook_result"; shift 1547316068Sdelphij done 1548316068Sdelphij 1549316068Sdelphij func_quote_for_eval ${1+"$@"} 1550316068Sdelphij func_run_hooks_result=$func_quote_for_eval_result 1551316068Sdelphij} 1552316068Sdelphij 1553316068Sdelphij 1554316068Sdelphij 1555316068Sdelphij## --------------- ## 1556316068Sdelphij## Option parsing. ## 1557316068Sdelphij## --------------- ## 1558316068Sdelphij 1559316068Sdelphij# In order to add your own option parsing hooks, you must accept the 1560316068Sdelphij# full positional parameter list in your hook function, remove any 1561316068Sdelphij# options that you action, and then pass back the remaining unprocessed 1562316068Sdelphij# options in '<hooked_function_name>_result', escaped suitably for 1563316068Sdelphij# 'eval'. Like this: 1564316068Sdelphij# 1565316068Sdelphij# my_options_prep () 1566316068Sdelphij# { 1567316068Sdelphij# $debug_cmd 1568316068Sdelphij# 1569316068Sdelphij# # Extend the existing usage message. 1570316068Sdelphij# usage_message=$usage_message' 1571316068Sdelphij# -s, --silent don'\''t print informational messages 1572316068Sdelphij# ' 1573316068Sdelphij# 1574316068Sdelphij# func_quote_for_eval ${1+"$@"} 1575316068Sdelphij# my_options_prep_result=$func_quote_for_eval_result 1576316068Sdelphij# } 1577316068Sdelphij# func_add_hook func_options_prep my_options_prep 1578316068Sdelphij# 1579316068Sdelphij# 1580316068Sdelphij# my_silent_option () 1581316068Sdelphij# { 1582316068Sdelphij# $debug_cmd 1583316068Sdelphij# 1584316068Sdelphij# # Note that for efficiency, we parse as many options as we can 1585316068Sdelphij# # recognise in a loop before passing the remainder back to the 1586316068Sdelphij# # caller on the first unrecognised argument we encounter. 1587316068Sdelphij# while test $# -gt 0; do 1588316068Sdelphij# opt=$1; shift 1589316068Sdelphij# case $opt in 1590316068Sdelphij# --silent|-s) opt_silent=: ;; 1591316068Sdelphij# # Separate non-argument short options: 1592316068Sdelphij# -s*) func_split_short_opt "$_G_opt" 1593316068Sdelphij# set dummy "$func_split_short_opt_name" \ 1594316068Sdelphij# "-$func_split_short_opt_arg" ${1+"$@"} 1595316068Sdelphij# shift 1596316068Sdelphij# ;; 1597316068Sdelphij# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598316068Sdelphij# esac 1599316068Sdelphij# done 1600316068Sdelphij# 1601316068Sdelphij# func_quote_for_eval ${1+"$@"} 1602316068Sdelphij# my_silent_option_result=$func_quote_for_eval_result 1603316068Sdelphij# } 1604316068Sdelphij# func_add_hook func_parse_options my_silent_option 1605316068Sdelphij# 1606316068Sdelphij# 1607316068Sdelphij# my_option_validation () 1608316068Sdelphij# { 1609316068Sdelphij# $debug_cmd 1610316068Sdelphij# 1611316068Sdelphij# $opt_silent && $opt_verbose && func_fatal_help "\ 1612316068Sdelphij# '--silent' and '--verbose' options are mutually exclusive." 1613316068Sdelphij# 1614316068Sdelphij# func_quote_for_eval ${1+"$@"} 1615316068Sdelphij# my_option_validation_result=$func_quote_for_eval_result 1616316068Sdelphij# } 1617316068Sdelphij# func_add_hook func_validate_options my_option_validation 1618316068Sdelphij# 1619316068Sdelphij# You'll alse need to manually amend $usage_message to reflect the extra 1620316068Sdelphij# options you parse. It's preferable to append if you can, so that 1621316068Sdelphij# multiple option parsing hooks can be added safely. 1622316068Sdelphij 1623316068Sdelphij 1624316068Sdelphij# func_options [ARG]... 1625316068Sdelphij# --------------------- 1626316068Sdelphij# All the functions called inside func_options are hookable. See the 1627316068Sdelphij# individual implementations for details. 1628316068Sdelphijfunc_hookable func_options 1629316068Sdelphijfunc_options () 1630316068Sdelphij{ 1631316068Sdelphij $debug_cmd 1632316068Sdelphij 1633316068Sdelphij func_options_prep ${1+"$@"} 1634316068Sdelphij eval func_parse_options \ 1635316068Sdelphij ${func_options_prep_result+"$func_options_prep_result"} 1636316068Sdelphij eval func_validate_options \ 1637316068Sdelphij ${func_parse_options_result+"$func_parse_options_result"} 1638316068Sdelphij 1639316068Sdelphij eval func_run_hooks func_options \ 1640316068Sdelphij ${func_validate_options_result+"$func_validate_options_result"} 1641316068Sdelphij 1642316068Sdelphij # save modified positional parameters for caller 1643316068Sdelphij func_options_result=$func_run_hooks_result 1644316068Sdelphij} 1645316068Sdelphij 1646316068Sdelphij 1647316068Sdelphij# func_options_prep [ARG]... 1648316068Sdelphij# -------------------------- 1649316068Sdelphij# All initialisations required before starting the option parse loop. 1650316068Sdelphij# Note that when calling hook functions, we pass through the list of 1651316068Sdelphij# positional parameters. If a hook function modifies that list, and 1652316068Sdelphij# needs to propogate that back to rest of this script, then the complete 1653316068Sdelphij# modified list must be put in 'func_run_hooks_result' before 1654316068Sdelphij# returning. 1655316068Sdelphijfunc_hookable func_options_prep 1656316068Sdelphijfunc_options_prep () 1657316068Sdelphij{ 1658316068Sdelphij $debug_cmd 1659316068Sdelphij 1660316068Sdelphij # Option defaults: 1661316068Sdelphij opt_verbose=false 1662316068Sdelphij opt_warning_types= 1663316068Sdelphij 1664316068Sdelphij func_run_hooks func_options_prep ${1+"$@"} 1665316068Sdelphij 1666316068Sdelphij # save modified positional parameters for caller 1667316068Sdelphij func_options_prep_result=$func_run_hooks_result 1668316068Sdelphij} 1669316068Sdelphij 1670316068Sdelphij 1671316068Sdelphij# func_parse_options [ARG]... 1672316068Sdelphij# --------------------------- 1673316068Sdelphij# The main option parsing loop. 1674316068Sdelphijfunc_hookable func_parse_options 1675316068Sdelphijfunc_parse_options () 1676316068Sdelphij{ 1677316068Sdelphij $debug_cmd 1678316068Sdelphij 1679316068Sdelphij func_parse_options_result= 1680316068Sdelphij 1681316068Sdelphij # this just eases exit handling 1682316068Sdelphij while test $# -gt 0; do 1683316068Sdelphij # Defer to hook functions for initial option parsing, so they 1684316068Sdelphij # get priority in the event of reusing an option name. 1685316068Sdelphij func_run_hooks func_parse_options ${1+"$@"} 1686316068Sdelphij 1687316068Sdelphij # Adjust func_parse_options positional parameters to match 1688316068Sdelphij eval set dummy "$func_run_hooks_result"; shift 1689316068Sdelphij 1690316068Sdelphij # Break out of the loop if we already parsed every option. 1691316068Sdelphij test $# -gt 0 || break 1692316068Sdelphij 1693316068Sdelphij _G_opt=$1 1694316068Sdelphij shift 1695316068Sdelphij case $_G_opt in 1696316068Sdelphij --debug|-x) debug_cmd='set -x' 1697316068Sdelphij func_echo "enabling shell trace mode" 1698316068Sdelphij $debug_cmd 1699316068Sdelphij ;; 1700316068Sdelphij 1701316068Sdelphij --no-warnings|--no-warning|--no-warn) 1702316068Sdelphij set dummy --warnings none ${1+"$@"} 1703316068Sdelphij shift 1704316068Sdelphij ;; 1705316068Sdelphij 1706316068Sdelphij --warnings|--warning|-W) 1707316068Sdelphij test $# = 0 && func_missing_arg $_G_opt && break 1708316068Sdelphij case " $warning_categories $1" in 1709316068Sdelphij *" $1 "*) 1710316068Sdelphij # trailing space prevents matching last $1 above 1711316068Sdelphij func_append_uniq opt_warning_types " $1" 1712316068Sdelphij ;; 1713316068Sdelphij *all) 1714316068Sdelphij opt_warning_types=$warning_categories 1715316068Sdelphij ;; 1716316068Sdelphij *none) 1717316068Sdelphij opt_warning_types=none 1718316068Sdelphij warning_func=: 1719316068Sdelphij ;; 1720316068Sdelphij *error) 1721316068Sdelphij opt_warning_types=$warning_categories 1722316068Sdelphij warning_func=func_fatal_error 1723316068Sdelphij ;; 1724316068Sdelphij *) 1725316068Sdelphij func_fatal_error \ 1726316068Sdelphij "unsupported warning category: '$1'" 1727316068Sdelphij ;; 1728316068Sdelphij esac 1729316068Sdelphij shift 1730316068Sdelphij ;; 1731316068Sdelphij 1732316068Sdelphij --verbose|-v) opt_verbose=: ;; 1733316068Sdelphij --version) func_version ;; 1734316068Sdelphij -\?|-h) func_usage ;; 1735316068Sdelphij --help) func_help ;; 1736316068Sdelphij 1737316068Sdelphij # Separate optargs to long options (plugins may need this): 1738316068Sdelphij --*=*) func_split_equals "$_G_opt" 1739316068Sdelphij set dummy "$func_split_equals_lhs" \ 1740316068Sdelphij "$func_split_equals_rhs" ${1+"$@"} 1741316068Sdelphij shift 1742316068Sdelphij ;; 1743316068Sdelphij 1744316068Sdelphij # Separate optargs to short options: 1745316068Sdelphij -W*) 1746316068Sdelphij func_split_short_opt "$_G_opt" 1747316068Sdelphij set dummy "$func_split_short_opt_name" \ 1748316068Sdelphij "$func_split_short_opt_arg" ${1+"$@"} 1749316068Sdelphij shift 1750316068Sdelphij ;; 1751316068Sdelphij 1752316068Sdelphij # Separate non-argument short options: 1753316068Sdelphij -\?*|-h*|-v*|-x*) 1754316068Sdelphij func_split_short_opt "$_G_opt" 1755316068Sdelphij set dummy "$func_split_short_opt_name" \ 1756316068Sdelphij "-$func_split_short_opt_arg" ${1+"$@"} 1757316068Sdelphij shift 1758316068Sdelphij ;; 1759316068Sdelphij 1760316068Sdelphij --) break ;; 1761316068Sdelphij -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762316068Sdelphij *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763316068Sdelphij esac 1764316068Sdelphij done 1765316068Sdelphij 1766316068Sdelphij # save modified positional parameters for caller 1767316068Sdelphij func_quote_for_eval ${1+"$@"} 1768316068Sdelphij func_parse_options_result=$func_quote_for_eval_result 1769316068Sdelphij} 1770316068Sdelphij 1771316068Sdelphij 1772316068Sdelphij# func_validate_options [ARG]... 1773316068Sdelphij# ------------------------------ 1774316068Sdelphij# Perform any sanity checks on option settings and/or unconsumed 1775316068Sdelphij# arguments. 1776316068Sdelphijfunc_hookable func_validate_options 1777316068Sdelphijfunc_validate_options () 1778316068Sdelphij{ 1779316068Sdelphij $debug_cmd 1780316068Sdelphij 1781316068Sdelphij # Display all warnings if -W was not given. 1782316068Sdelphij test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783316068Sdelphij 1784316068Sdelphij func_run_hooks func_validate_options ${1+"$@"} 1785316068Sdelphij 1786316068Sdelphij # Bail if the options were screwed! 1787316068Sdelphij $exit_cmd $EXIT_FAILURE 1788316068Sdelphij 1789316068Sdelphij # save modified positional parameters for caller 1790316068Sdelphij func_validate_options_result=$func_run_hooks_result 1791316068Sdelphij} 1792316068Sdelphij 1793316068Sdelphij 1794316068Sdelphij 1795316068Sdelphij## ----------------- ## 1796316068Sdelphij## Helper functions. ## 1797316068Sdelphij## ----------------- ## 1798316068Sdelphij 1799316068Sdelphij# This section contains the helper functions used by the rest of the 1800316068Sdelphij# hookable option parser framework in ascii-betical order. 1801316068Sdelphij 1802316068Sdelphij 1803316068Sdelphij# func_fatal_help ARG... 1804316068Sdelphij# ---------------------- 1805316068Sdelphij# Echo program name prefixed message to standard error, followed by 1806316068Sdelphij# a help hint, and exit. 1807316068Sdelphijfunc_fatal_help () 1808316068Sdelphij{ 1809316068Sdelphij $debug_cmd 1810316068Sdelphij 1811316068Sdelphij eval \$ECHO \""Usage: $usage"\" 1812316068Sdelphij eval \$ECHO \""$fatal_help"\" 1813316068Sdelphij func_error ${1+"$@"} 1814316068Sdelphij exit $EXIT_FAILURE 1815316068Sdelphij} 1816316068Sdelphij 1817316068Sdelphij 1818316068Sdelphij# func_help 1819316068Sdelphij# --------- 1820316068Sdelphij# Echo long help message to standard output and exit. 1821275970Scyfunc_help () 1822275970Scy{ 1823316068Sdelphij $debug_cmd 1824275970Scy 1825316068Sdelphij func_usage_message 1826316068Sdelphij $ECHO "$long_help_message" 1827316068Sdelphij exit 0 1828275970Scy} 1829275970Scy 1830316068Sdelphij 1831316068Sdelphij# func_missing_arg ARGNAME 1832316068Sdelphij# ------------------------ 1833275970Scy# Echo program name prefixed message to standard error and set global 1834275970Scy# exit_cmd. 1835275970Scyfunc_missing_arg () 1836275970Scy{ 1837316068Sdelphij $debug_cmd 1838275970Scy 1839316068Sdelphij func_error "Missing argument for '$1'." 1840275970Scy exit_cmd=exit 1841275970Scy} 1842275970Scy 1843275970Scy 1844316068Sdelphij# func_split_equals STRING 1845316068Sdelphij# ------------------------ 1846316068Sdelphij# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847316068Sdelphij# splitting STRING at the '=' sign. 1848316068Sdelphijtest -z "$_G_HAVE_XSI_OPS" \ 1849316068Sdelphij && (eval 'x=a/b/c; 1850316068Sdelphij test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851316068Sdelphij && _G_HAVE_XSI_OPS=yes 1852316068Sdelphij 1853316068Sdelphijif test yes = "$_G_HAVE_XSI_OPS" 1854316068Sdelphijthen 1855316068Sdelphij # This is an XSI compatible shell, allowing a faster implementation... 1856316068Sdelphij eval 'func_split_equals () 1857316068Sdelphij { 1858316068Sdelphij $debug_cmd 1859316068Sdelphij 1860316068Sdelphij func_split_equals_lhs=${1%%=*} 1861316068Sdelphij func_split_equals_rhs=${1#*=} 1862316068Sdelphij test "x$func_split_equals_lhs" = "x$1" \ 1863316068Sdelphij && func_split_equals_rhs= 1864316068Sdelphij }' 1865316068Sdelphijelse 1866316068Sdelphij # ...otherwise fall back to using expr, which is often a shell builtin. 1867316068Sdelphij func_split_equals () 1868316068Sdelphij { 1869316068Sdelphij $debug_cmd 1870316068Sdelphij 1871316068Sdelphij func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872316068Sdelphij func_split_equals_rhs= 1873316068Sdelphij test "x$func_split_equals_lhs" = "x$1" \ 1874316068Sdelphij || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875316068Sdelphij } 1876316068Sdelphijfi #func_split_equals 1877316068Sdelphij 1878316068Sdelphij 1879316068Sdelphij# func_split_short_opt SHORTOPT 1880316068Sdelphij# ----------------------------- 1881275970Scy# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882275970Scy# variables after splitting SHORTOPT after the 2nd character. 1883316068Sdelphijif test yes = "$_G_HAVE_XSI_OPS" 1884316068Sdelphijthen 1885316068Sdelphij # This is an XSI compatible shell, allowing a faster implementation... 1886316068Sdelphij eval 'func_split_short_opt () 1887316068Sdelphij { 1888316068Sdelphij $debug_cmd 1889316068Sdelphij 1890316068Sdelphij func_split_short_opt_arg=${1#??} 1891316068Sdelphij func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892316068Sdelphij }' 1893316068Sdelphijelse 1894316068Sdelphij # ...otherwise fall back to using expr, which is often a shell builtin. 1895316068Sdelphij func_split_short_opt () 1896316068Sdelphij { 1897316068Sdelphij $debug_cmd 1898316068Sdelphij 1899316068Sdelphij func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900316068Sdelphij func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901316068Sdelphij } 1902316068Sdelphijfi #func_split_short_opt 1903316068Sdelphij 1904316068Sdelphij 1905316068Sdelphij# func_usage 1906316068Sdelphij# ---------- 1907316068Sdelphij# Echo short help message to standard output and exit. 1908316068Sdelphijfunc_usage () 1909275970Scy{ 1910316068Sdelphij $debug_cmd 1911275970Scy 1912316068Sdelphij func_usage_message 1913316068Sdelphij $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914316068Sdelphij exit 0 1915316068Sdelphij} 1916275970Scy 1917275970Scy 1918316068Sdelphij# func_usage_message 1919316068Sdelphij# ------------------ 1920316068Sdelphij# Echo short help message to standard output. 1921316068Sdelphijfunc_usage_message () 1922275970Scy{ 1923316068Sdelphij $debug_cmd 1924275970Scy 1925316068Sdelphij eval \$ECHO \""Usage: $usage"\" 1926316068Sdelphij echo 1927316068Sdelphij $SED -n 's|^# || 1928316068Sdelphij /^Written by/{ 1929316068Sdelphij x;p;x 1930316068Sdelphij } 1931316068Sdelphij h 1932316068Sdelphij /^Written by/q' < "$progpath" 1933316068Sdelphij echo 1934316068Sdelphij eval \$ECHO \""$usage_message"\" 1935316068Sdelphij} 1936275970Scy 1937275970Scy 1938316068Sdelphij# func_version 1939316068Sdelphij# ------------ 1940316068Sdelphij# Echo version message to standard output and exit. 1941316068Sdelphijfunc_version () 1942316068Sdelphij{ 1943316068Sdelphij $debug_cmd 1944275970Scy 1945316068Sdelphij printf '%s\n' "$progname $scriptversion" 1946316068Sdelphij $SED -n ' 1947316068Sdelphij /(C)/!b go 1948316068Sdelphij :more 1949316068Sdelphij /\./!{ 1950316068Sdelphij N 1951316068Sdelphij s|\n# | | 1952316068Sdelphij b more 1953316068Sdelphij } 1954316068Sdelphij :go 1955316068Sdelphij /^# Written by /,/# warranty; / { 1956316068Sdelphij s|^# || 1957316068Sdelphij s|^# *$|| 1958316068Sdelphij s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959316068Sdelphij p 1960316068Sdelphij } 1961316068Sdelphij /^# Written by / { 1962316068Sdelphij s|^# || 1963316068Sdelphij p 1964316068Sdelphij } 1965316068Sdelphij /^warranty; /q' < "$progpath" 1966275970Scy 1967316068Sdelphij exit $? 1968316068Sdelphij} 1969275970Scy 1970275970Scy 1971316068Sdelphij# Local variables: 1972316068Sdelphij# mode: shell-script 1973316068Sdelphij# sh-indentation: 2 1974316068Sdelphij# eval: (add-hook 'before-save-hook 'time-stamp) 1975316068Sdelphij# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976316068Sdelphij# time-stamp-time-zone: "UTC" 1977316068Sdelphij# End: 1978275970Scy 1979316068Sdelphij# Set a version string. 1980316068Sdelphijscriptversion='(GNU libtool) 2.4.6' 1981275970Scy 1982275970Scy 1983316068Sdelphij# func_echo ARG... 1984316068Sdelphij# ---------------- 1985316068Sdelphij# Libtool also displays the current mode in messages, so override 1986316068Sdelphij# funclib.sh func_echo with this custom definition. 1987316068Sdelphijfunc_echo () 1988275970Scy{ 1989316068Sdelphij $debug_cmd 1990275970Scy 1991316068Sdelphij _G_message=$* 1992275970Scy 1993316068Sdelphij func_echo_IFS=$IFS 1994316068Sdelphij IFS=$nl 1995316068Sdelphij for _G_line in $_G_message; do 1996316068Sdelphij IFS=$func_echo_IFS 1997316068Sdelphij $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998316068Sdelphij done 1999316068Sdelphij IFS=$func_echo_IFS 2000316068Sdelphij} 2001275970Scy 2002316068Sdelphij 2003316068Sdelphij# func_warning ARG... 2004316068Sdelphij# ------------------- 2005316068Sdelphij# Libtool warnings are not categorized, so override funclib.sh 2006316068Sdelphij# func_warning with this simpler definition. 2007316068Sdelphijfunc_warning () 2008275970Scy{ 2009316068Sdelphij $debug_cmd 2010275970Scy 2011316068Sdelphij $warning_func ${1+"$@"} 2012316068Sdelphij} 2013275970Scy 2014275970Scy 2015316068Sdelphij## ---------------- ## 2016316068Sdelphij## Options parsing. ## 2017316068Sdelphij## ---------------- ## 2018275970Scy 2019316068Sdelphij# Hook in the functions to make sure our own options are parsed during 2020316068Sdelphij# the option parsing loop. 2021275970Scy 2022316068Sdelphijusage='$progpath [OPTION]... [MODE-ARG]...' 2023275970Scy 2024316068Sdelphij# Short help message in response to '-h'. 2025316068Sdelphijusage_message="Options: 2026316068Sdelphij --config show all configuration variables 2027316068Sdelphij --debug enable verbose shell tracing 2028316068Sdelphij -n, --dry-run display commands without modifying any files 2029316068Sdelphij --features display basic configuration information and exit 2030316068Sdelphij --mode=MODE use operation mode MODE 2031316068Sdelphij --no-warnings equivalent to '-Wnone' 2032316068Sdelphij --preserve-dup-deps don't remove duplicate dependency libraries 2033316068Sdelphij --quiet, --silent don't print informational messages 2034316068Sdelphij --tag=TAG use configuration variables from tag TAG 2035316068Sdelphij -v, --verbose print more informational messages than default 2036316068Sdelphij --version print version information 2037316068Sdelphij -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038316068Sdelphij -h, --help, --help-all print short, long, or detailed help message 2039316068Sdelphij" 2040316068Sdelphij 2041316068Sdelphij# Additional text appended to 'usage_message' in response to '--help'. 2042316068Sdelphijfunc_help () 2043275970Scy{ 2044316068Sdelphij $debug_cmd 2045275970Scy 2046316068Sdelphij func_usage_message 2047316068Sdelphij $ECHO "$long_help_message 2048275970Scy 2049316068SdelphijMODE must be one of the following: 2050316068Sdelphij 2051316068Sdelphij clean remove files from the build directory 2052316068Sdelphij compile compile a source file into a libtool object 2053316068Sdelphij execute automatically set library path, then run a program 2054316068Sdelphij finish complete the installation of libtool libraries 2055316068Sdelphij install install libraries or executables 2056316068Sdelphij link create a library or an executable 2057316068Sdelphij uninstall remove libraries from an installed directory 2058316068Sdelphij 2059316068SdelphijMODE-ARGS vary depending on the MODE. When passed as first option, 2060316068Sdelphij'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061316068SdelphijTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062316068Sdelphij 2063316068SdelphijWhen reporting a bug, please describe a test case to reproduce it and 2064316068Sdelphijinclude the following information: 2065316068Sdelphij 2066316068Sdelphij host-triplet: $host 2067316068Sdelphij shell: $SHELL 2068316068Sdelphij compiler: $LTCC 2069316068Sdelphij compiler flags: $LTCFLAGS 2070316068Sdelphij linker: $LD (gnu? $with_gnu_ld) 2071316068Sdelphij version: $progname (GNU libtool) 2.4.6 2072316068Sdelphij automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073316068Sdelphij autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074316068Sdelphij 2075316068SdelphijReport bugs to <bug-libtool@gnu.org>. 2076316068SdelphijGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2077316068SdelphijGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078316068Sdelphij exit 0 2079316068Sdelphij} 2080316068Sdelphij 2081316068Sdelphij 2082316068Sdelphij# func_lo2o OBJECT-NAME 2083316068Sdelphij# --------------------- 2084316068Sdelphij# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085316068Sdelphij# object suffix. 2086316068Sdelphij 2087316068Sdelphijlo2o=s/\\.lo\$/.$objext/ 2088316068Sdelphijo2lo=s/\\.$objext\$/.lo/ 2089316068Sdelphij 2090316068Sdelphijif test yes = "$_G_HAVE_XSI_OPS"; then 2091316068Sdelphij eval 'func_lo2o () 2092316068Sdelphij { 2093316068Sdelphij case $1 in 2094316068Sdelphij *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095316068Sdelphij * ) func_lo2o_result=$1 ;; 2096316068Sdelphij esac 2097316068Sdelphij }' 2098316068Sdelphij 2099316068Sdelphij # func_xform LIBOBJ-OR-SOURCE 2100316068Sdelphij # --------------------------- 2101316068Sdelphij # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102316068Sdelphij # suffix to a '.lo' libtool-object suffix. 2103316068Sdelphij eval 'func_xform () 2104316068Sdelphij { 2105316068Sdelphij func_xform_result=${1%.*}.lo 2106316068Sdelphij }' 2107316068Sdelphijelse 2108316068Sdelphij # ...otherwise fall back to using sed. 2109316068Sdelphij func_lo2o () 2110316068Sdelphij { 2111316068Sdelphij func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112316068Sdelphij } 2113316068Sdelphij 2114316068Sdelphij func_xform () 2115316068Sdelphij { 2116316068Sdelphij func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117316068Sdelphij } 2118316068Sdelphijfi 2119316068Sdelphij 2120316068Sdelphij 2121316068Sdelphij# func_fatal_configuration ARG... 2122316068Sdelphij# ------------------------------- 2123275970Scy# Echo program name prefixed message to standard error, followed by 2124275970Scy# a configuration failure hint, and exit. 2125275970Scyfunc_fatal_configuration () 2126275970Scy{ 2127316068Sdelphij func__fatal_error ${1+"$@"} \ 2128316068Sdelphij "See the $PACKAGE documentation for more information." \ 2129316068Sdelphij "Fatal configuration error." 2130275970Scy} 2131275970Scy 2132275970Scy 2133275970Scy# func_config 2134316068Sdelphij# ----------- 2135275970Scy# Display the configuration for all the tags in this script. 2136275970Scyfunc_config () 2137275970Scy{ 2138275970Scy re_begincf='^# ### BEGIN LIBTOOL' 2139275970Scy re_endcf='^# ### END LIBTOOL' 2140275970Scy 2141275970Scy # Default configuration. 2142275970Scy $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143275970Scy 2144275970Scy # Now print the configurations for the tags. 2145275970Scy for tagname in $taglist; do 2146275970Scy $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147275970Scy done 2148275970Scy 2149275970Scy exit $? 2150275970Scy} 2151275970Scy 2152316068Sdelphij 2153275970Scy# func_features 2154316068Sdelphij# ------------- 2155275970Scy# Display the features supported by this script. 2156275970Scyfunc_features () 2157275970Scy{ 2158275970Scy echo "host: $host" 2159316068Sdelphij if test yes = "$build_libtool_libs"; then 2160275970Scy echo "enable shared libraries" 2161275970Scy else 2162275970Scy echo "disable shared libraries" 2163275970Scy fi 2164316068Sdelphij if test yes = "$build_old_libs"; then 2165275970Scy echo "enable static libraries" 2166275970Scy else 2167275970Scy echo "disable static libraries" 2168275970Scy fi 2169275970Scy 2170275970Scy exit $? 2171275970Scy} 2172275970Scy 2173316068Sdelphij 2174316068Sdelphij# func_enable_tag TAGNAME 2175316068Sdelphij# ----------------------- 2176275970Scy# Verify that TAGNAME is valid, and either flag an error and exit, or 2177275970Scy# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178275970Scy# variable here. 2179275970Scyfunc_enable_tag () 2180275970Scy{ 2181316068Sdelphij # Global variable: 2182316068Sdelphij tagname=$1 2183275970Scy 2184316068Sdelphij re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185316068Sdelphij re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186316068Sdelphij sed_extractcf=/$re_begincf/,/$re_endcf/p 2187275970Scy 2188316068Sdelphij # Validate tagname. 2189316068Sdelphij case $tagname in 2190316068Sdelphij *[!-_A-Za-z0-9,/]*) 2191316068Sdelphij func_fatal_error "invalid tag name: $tagname" 2192316068Sdelphij ;; 2193316068Sdelphij esac 2194275970Scy 2195316068Sdelphij # Don't test for the "default" C tag, as we know it's 2196316068Sdelphij # there but not specially marked. 2197316068Sdelphij case $tagname in 2198316068Sdelphij CC) ;; 2199275970Scy *) 2200316068Sdelphij if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201316068Sdelphij taglist="$taglist $tagname" 2202275970Scy 2203316068Sdelphij # Evaluate the configuration. Be careful to quote the path 2204316068Sdelphij # and the sed script, to avoid splitting on whitespace, but 2205316068Sdelphij # also don't use non-portable quotes within backquotes within 2206316068Sdelphij # quotes we have to do it in 2 steps: 2207316068Sdelphij extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208316068Sdelphij eval "$extractedcf" 2209316068Sdelphij else 2210316068Sdelphij func_error "ignoring unknown tag $tagname" 2211316068Sdelphij fi 2212316068Sdelphij ;; 2213316068Sdelphij esac 2214275970Scy} 2215275970Scy 2216316068Sdelphij 2217275970Scy# func_check_version_match 2218316068Sdelphij# ------------------------ 2219275970Scy# Ensure that we are using m4 macros, and libtool script from the same 2220275970Scy# release of libtool. 2221275970Scyfunc_check_version_match () 2222275970Scy{ 2223316068Sdelphij if test "$package_revision" != "$macro_revision"; then 2224316068Sdelphij if test "$VERSION" != "$macro_version"; then 2225316068Sdelphij if test -z "$macro_version"; then 2226316068Sdelphij cat >&2 <<_LT_EOF 2227275970Scy$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228275970Scy$progname: definition of this LT_INIT comes from an older release. 2229275970Scy$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230275970Scy$progname: and run autoconf again. 2231275970Scy_LT_EOF 2232316068Sdelphij else 2233316068Sdelphij cat >&2 <<_LT_EOF 2234275970Scy$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235275970Scy$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236275970Scy$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237275970Scy$progname: and run autoconf again. 2238275970Scy_LT_EOF 2239316068Sdelphij fi 2240316068Sdelphij else 2241316068Sdelphij cat >&2 <<_LT_EOF 2242275970Scy$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243275970Scy$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244275970Scy$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245275970Scy$progname: of $PACKAGE $VERSION and run autoconf again. 2246275970Scy_LT_EOF 2247316068Sdelphij fi 2248316068Sdelphij 2249316068Sdelphij exit $EXIT_MISMATCH 2250275970Scy fi 2251275970Scy} 2252275970Scy 2253275970Scy 2254316068Sdelphij# libtool_options_prep [ARG]... 2255316068Sdelphij# ----------------------------- 2256316068Sdelphij# Preparation for options parsed by libtool. 2257316068Sdelphijlibtool_options_prep () 2258316068Sdelphij{ 2259316068Sdelphij $debug_mode 2260275970Scy 2261316068Sdelphij # Option defaults: 2262316068Sdelphij opt_config=false 2263316068Sdelphij opt_dlopen= 2264316068Sdelphij opt_dry_run=false 2265316068Sdelphij opt_help=false 2266316068Sdelphij opt_mode= 2267316068Sdelphij opt_preserve_dup_deps=false 2268316068Sdelphij opt_quiet=false 2269275970Scy 2270316068Sdelphij nonopt= 2271316068Sdelphij preserve_args= 2272275970Scy 2273316068Sdelphij # Shorthand for --mode=foo, only valid as the first argument 2274316068Sdelphij case $1 in 2275316068Sdelphij clean|clea|cle|cl) 2276316068Sdelphij shift; set dummy --mode clean ${1+"$@"}; shift 2277316068Sdelphij ;; 2278316068Sdelphij compile|compil|compi|comp|com|co|c) 2279316068Sdelphij shift; set dummy --mode compile ${1+"$@"}; shift 2280316068Sdelphij ;; 2281316068Sdelphij execute|execut|execu|exec|exe|ex|e) 2282316068Sdelphij shift; set dummy --mode execute ${1+"$@"}; shift 2283316068Sdelphij ;; 2284316068Sdelphij finish|finis|fini|fin|fi|f) 2285316068Sdelphij shift; set dummy --mode finish ${1+"$@"}; shift 2286316068Sdelphij ;; 2287316068Sdelphij install|instal|insta|inst|ins|in|i) 2288316068Sdelphij shift; set dummy --mode install ${1+"$@"}; shift 2289316068Sdelphij ;; 2290316068Sdelphij link|lin|li|l) 2291316068Sdelphij shift; set dummy --mode link ${1+"$@"}; shift 2292316068Sdelphij ;; 2293316068Sdelphij uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294316068Sdelphij shift; set dummy --mode uninstall ${1+"$@"}; shift 2295316068Sdelphij ;; 2296316068Sdelphij esac 2297275970Scy 2298316068Sdelphij # Pass back the list of options. 2299316068Sdelphij func_quote_for_eval ${1+"$@"} 2300316068Sdelphij libtool_options_prep_result=$func_quote_for_eval_result 2301316068Sdelphij} 2302316068Sdelphijfunc_add_hook func_options_prep libtool_options_prep 2303275970Scy 2304316068Sdelphij 2305316068Sdelphij# libtool_parse_options [ARG]... 2306316068Sdelphij# --------------------------------- 2307316068Sdelphij# Provide handling for libtool specific options. 2308316068Sdelphijlibtool_parse_options () 2309275970Scy{ 2310316068Sdelphij $debug_cmd 2311275970Scy 2312316068Sdelphij # Perform our own loop to consume as many options as possible in 2313316068Sdelphij # each iteration. 2314316068Sdelphij while test $# -gt 0; do 2315316068Sdelphij _G_opt=$1 2316316068Sdelphij shift 2317316068Sdelphij case $_G_opt in 2318316068Sdelphij --dry-run|--dryrun|-n) 2319316068Sdelphij opt_dry_run=: 2320316068Sdelphij ;; 2321275970Scy 2322316068Sdelphij --config) func_config ;; 2323275970Scy 2324316068Sdelphij --dlopen|-dlopen) 2325316068Sdelphij opt_dlopen="${opt_dlopen+$opt_dlopen 2326316068Sdelphij}$1" 2327316068Sdelphij shift 2328316068Sdelphij ;; 2329275970Scy 2330316068Sdelphij --preserve-dup-deps) 2331316068Sdelphij opt_preserve_dup_deps=: ;; 2332275970Scy 2333316068Sdelphij --features) func_features ;; 2334275970Scy 2335316068Sdelphij --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336275970Scy 2337316068Sdelphij --help) opt_help=: ;; 2338275970Scy 2339316068Sdelphij --help-all) opt_help=': help-all' ;; 2340275970Scy 2341316068Sdelphij --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342316068Sdelphij opt_mode=$1 2343316068Sdelphij case $1 in 2344316068Sdelphij # Valid mode arguments: 2345316068Sdelphij clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346275970Scy 2347316068Sdelphij # Catch anything else as an error 2348316068Sdelphij *) func_error "invalid argument for $_G_opt" 2349316068Sdelphij exit_cmd=exit 2350316068Sdelphij break 2351316068Sdelphij ;; 2352316068Sdelphij esac 2353316068Sdelphij shift 2354316068Sdelphij ;; 2355275970Scy 2356316068Sdelphij --no-silent|--no-quiet) 2357316068Sdelphij opt_quiet=false 2358316068Sdelphij func_append preserve_args " $_G_opt" 2359316068Sdelphij ;; 2360275970Scy 2361316068Sdelphij --no-warnings|--no-warning|--no-warn) 2362316068Sdelphij opt_warning=false 2363316068Sdelphij func_append preserve_args " $_G_opt" 2364316068Sdelphij ;; 2365275970Scy 2366316068Sdelphij --no-verbose) 2367316068Sdelphij opt_verbose=false 2368316068Sdelphij func_append preserve_args " $_G_opt" 2369316068Sdelphij ;; 2370316068Sdelphij 2371316068Sdelphij --silent|--quiet) 2372316068Sdelphij opt_quiet=: 2373316068Sdelphij opt_verbose=false 2374316068Sdelphij func_append preserve_args " $_G_opt" 2375316068Sdelphij ;; 2376316068Sdelphij 2377316068Sdelphij --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378316068Sdelphij opt_tag=$1 2379316068Sdelphij func_append preserve_args " $_G_opt $1" 2380316068Sdelphij func_enable_tag "$1" 2381316068Sdelphij shift 2382316068Sdelphij ;; 2383316068Sdelphij 2384316068Sdelphij --verbose|-v) opt_quiet=false 2385316068Sdelphij opt_verbose=: 2386316068Sdelphij func_append preserve_args " $_G_opt" 2387316068Sdelphij ;; 2388316068Sdelphij 2389316068Sdelphij # An option not handled by this hook function: 2390316068Sdelphij *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391316068Sdelphij esac 2392316068Sdelphij done 2393316068Sdelphij 2394316068Sdelphij 2395316068Sdelphij # save modified positional parameters for caller 2396316068Sdelphij func_quote_for_eval ${1+"$@"} 2397316068Sdelphij libtool_parse_options_result=$func_quote_for_eval_result 2398316068Sdelphij} 2399316068Sdelphijfunc_add_hook func_parse_options libtool_parse_options 2400316068Sdelphij 2401316068Sdelphij 2402316068Sdelphij 2403316068Sdelphij# libtool_validate_options [ARG]... 2404316068Sdelphij# --------------------------------- 2405316068Sdelphij# Perform any sanity checks on option settings and/or unconsumed 2406316068Sdelphij# arguments. 2407316068Sdelphijlibtool_validate_options () 2408316068Sdelphij{ 2409316068Sdelphij # save first non-option argument 2410316068Sdelphij if test 0 -lt $#; then 2411316068Sdelphij nonopt=$1 2412316068Sdelphij shift 2413275970Scy fi 2414275970Scy 2415316068Sdelphij # preserve --debug 2416316068Sdelphij test : = "$debug_cmd" || func_append preserve_args " --debug" 2417275970Scy 2418316068Sdelphij case $host in 2419316068Sdelphij # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420316068Sdelphij # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421316068Sdelphij *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422316068Sdelphij # don't eliminate duplications in $postdeps and $predeps 2423316068Sdelphij opt_duplicate_compiler_generated_deps=: 2424316068Sdelphij ;; 2425316068Sdelphij *) 2426316068Sdelphij opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427316068Sdelphij ;; 2428316068Sdelphij esac 2429275970Scy 2430316068Sdelphij $opt_help || { 2431316068Sdelphij # Sanity checks first: 2432316068Sdelphij func_check_version_match 2433316068Sdelphij 2434316068Sdelphij test yes != "$build_libtool_libs" \ 2435316068Sdelphij && test yes != "$build_old_libs" \ 2436316068Sdelphij && func_fatal_configuration "not configured to build any kind of library" 2437316068Sdelphij 2438316068Sdelphij # Darwin sucks 2439316068Sdelphij eval std_shrext=\"$shrext_cmds\" 2440316068Sdelphij 2441316068Sdelphij # Only execute mode is allowed to have -dlopen flags. 2442316068Sdelphij if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443316068Sdelphij func_error "unrecognized option '-dlopen'" 2444316068Sdelphij $ECHO "$help" 1>&2 2445316068Sdelphij exit $EXIT_FAILURE 2446316068Sdelphij fi 2447316068Sdelphij 2448316068Sdelphij # Change the help message to a mode-specific one. 2449316068Sdelphij generic_help=$help 2450316068Sdelphij help="Try '$progname --help --mode=$opt_mode' for more information." 2451316068Sdelphij } 2452316068Sdelphij 2453316068Sdelphij # Pass back the unparsed argument list 2454316068Sdelphij func_quote_for_eval ${1+"$@"} 2455316068Sdelphij libtool_validate_options_result=$func_quote_for_eval_result 2456275970Scy} 2457316068Sdelphijfunc_add_hook func_validate_options libtool_validate_options 2458275970Scy 2459275970Scy 2460316068Sdelphij# Process options as early as possible so that --help and --version 2461316068Sdelphij# can return quickly. 2462316068Sdelphijfunc_options ${1+"$@"} 2463316068Sdelphijeval set dummy "$func_options_result"; shift 2464275970Scy 2465275970Scy 2466316068Sdelphij 2467275970Scy## ----------- ## 2468275970Scy## Main. ## 2469275970Scy## ----------- ## 2470275970Scy 2471316068Sdelphijmagic='%%%MAGIC variable%%%' 2472316068Sdelphijmagic_exe='%%%MAGIC EXE variable%%%' 2473316068Sdelphij 2474316068Sdelphij# Global variables. 2475316068Sdelphijextracted_archives= 2476316068Sdelphijextracted_serial=0 2477316068Sdelphij 2478316068Sdelphij# If this variable is set in any of the actions, the command in it 2479316068Sdelphij# will be execed at the end. This prevents here-documents from being 2480316068Sdelphij# left over by shells. 2481316068Sdelphijexec_cmd= 2482316068Sdelphij 2483316068Sdelphij 2484316068Sdelphij# A function that is used when there is no print builtin or printf. 2485316068Sdelphijfunc_fallback_echo () 2486316068Sdelphij{ 2487316068Sdelphij eval 'cat <<_LTECHO_EOF 2488316068Sdelphij$1 2489316068Sdelphij_LTECHO_EOF' 2490316068Sdelphij} 2491316068Sdelphij 2492316068Sdelphij# func_generated_by_libtool 2493316068Sdelphij# True iff stdin has been generated by Libtool. This function is only 2494316068Sdelphij# a basic sanity check; it will hardly flush out determined imposters. 2495316068Sdelphijfunc_generated_by_libtool_p () 2496316068Sdelphij{ 2497316068Sdelphij $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498316068Sdelphij} 2499316068Sdelphij 2500275970Scy# func_lalib_p file 2501316068Sdelphij# True iff FILE is a libtool '.la' library or '.lo' object file. 2502275970Scy# This function is only a basic sanity check; it will hardly flush out 2503275970Scy# determined imposters. 2504275970Scyfunc_lalib_p () 2505275970Scy{ 2506275970Scy test -f "$1" && 2507316068Sdelphij $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508275970Scy} 2509275970Scy 2510275970Scy# func_lalib_unsafe_p file 2511316068Sdelphij# True iff FILE is a libtool '.la' library or '.lo' object file. 2512275970Scy# This function implements the same check as func_lalib_p without 2513275970Scy# resorting to external programs. To this end, it redirects stdin and 2514275970Scy# closes it afterwards, without saving the original file descriptor. 2515275970Scy# As a safety measure, use it only where a negative result would be 2516316068Sdelphij# fatal anyway. Works if 'file' does not exist. 2517275970Scyfunc_lalib_unsafe_p () 2518275970Scy{ 2519275970Scy lalib_p=no 2520275970Scy if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521275970Scy for lalib_p_l in 1 2 3 4 2522275970Scy do 2523275970Scy read lalib_p_line 2524316068Sdelphij case $lalib_p_line in 2525275970Scy \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526275970Scy esac 2527275970Scy done 2528275970Scy exec 0<&5 5<&- 2529275970Scy fi 2530316068Sdelphij test yes = "$lalib_p" 2531275970Scy} 2532275970Scy 2533275970Scy# func_ltwrapper_script_p file 2534275970Scy# True iff FILE is a libtool wrapper script 2535275970Scy# This function is only a basic sanity check; it will hardly flush out 2536275970Scy# determined imposters. 2537275970Scyfunc_ltwrapper_script_p () 2538275970Scy{ 2539316068Sdelphij test -f "$1" && 2540316068Sdelphij $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541275970Scy} 2542275970Scy 2543275970Scy# func_ltwrapper_executable_p file 2544275970Scy# True iff FILE is a libtool wrapper executable 2545275970Scy# This function is only a basic sanity check; it will hardly flush out 2546275970Scy# determined imposters. 2547275970Scyfunc_ltwrapper_executable_p () 2548275970Scy{ 2549275970Scy func_ltwrapper_exec_suffix= 2550275970Scy case $1 in 2551275970Scy *.exe) ;; 2552275970Scy *) func_ltwrapper_exec_suffix=.exe ;; 2553275970Scy esac 2554275970Scy $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555275970Scy} 2556275970Scy 2557275970Scy# func_ltwrapper_scriptname file 2558275970Scy# Assumes file is an ltwrapper_executable 2559275970Scy# uses $file to determine the appropriate filename for a 2560275970Scy# temporary ltwrapper_script. 2561275970Scyfunc_ltwrapper_scriptname () 2562275970Scy{ 2563275970Scy func_dirname_and_basename "$1" "" "." 2564275970Scy func_stripname '' '.exe' "$func_basename_result" 2565316068Sdelphij func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566275970Scy} 2567275970Scy 2568275970Scy# func_ltwrapper_p file 2569275970Scy# True iff FILE is a libtool wrapper script or wrapper executable 2570275970Scy# This function is only a basic sanity check; it will hardly flush out 2571275970Scy# determined imposters. 2572275970Scyfunc_ltwrapper_p () 2573275970Scy{ 2574275970Scy func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575275970Scy} 2576275970Scy 2577275970Scy 2578275970Scy# func_execute_cmds commands fail_cmd 2579275970Scy# Execute tilde-delimited COMMANDS. 2580275970Scy# If FAIL_CMD is given, eval that upon failure. 2581275970Scy# FAIL_CMD may read-access the current command in variable CMD! 2582275970Scyfunc_execute_cmds () 2583275970Scy{ 2584316068Sdelphij $debug_cmd 2585316068Sdelphij 2586275970Scy save_ifs=$IFS; IFS='~' 2587275970Scy for cmd in $1; do 2588316068Sdelphij IFS=$sp$nl 2589316068Sdelphij eval cmd=\"$cmd\" 2590275970Scy IFS=$save_ifs 2591275970Scy func_show_eval "$cmd" "${2-:}" 2592275970Scy done 2593275970Scy IFS=$save_ifs 2594275970Scy} 2595275970Scy 2596275970Scy 2597275970Scy# func_source file 2598275970Scy# Source FILE, adding directory component if necessary. 2599275970Scy# Note that it is not necessary on cygwin/mingw to append a dot to 2600275970Scy# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601275970Scy# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602316068Sdelphij# 'FILE.' does not work on cygwin managed mounts. 2603275970Scyfunc_source () 2604275970Scy{ 2605316068Sdelphij $debug_cmd 2606316068Sdelphij 2607275970Scy case $1 in 2608275970Scy */* | *\\*) . "$1" ;; 2609275970Scy *) . "./$1" ;; 2610275970Scy esac 2611275970Scy} 2612275970Scy 2613275970Scy 2614275970Scy# func_resolve_sysroot PATH 2615275970Scy# Replace a leading = in PATH with a sysroot. Store the result into 2616275970Scy# func_resolve_sysroot_result 2617275970Scyfunc_resolve_sysroot () 2618275970Scy{ 2619275970Scy func_resolve_sysroot_result=$1 2620275970Scy case $func_resolve_sysroot_result in 2621275970Scy =*) 2622275970Scy func_stripname '=' '' "$func_resolve_sysroot_result" 2623275970Scy func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624275970Scy ;; 2625275970Scy esac 2626275970Scy} 2627275970Scy 2628275970Scy# func_replace_sysroot PATH 2629275970Scy# If PATH begins with the sysroot, replace it with = and 2630275970Scy# store the result into func_replace_sysroot_result. 2631275970Scyfunc_replace_sysroot () 2632275970Scy{ 2633316068Sdelphij case $lt_sysroot:$1 in 2634275970Scy ?*:"$lt_sysroot"*) 2635275970Scy func_stripname "$lt_sysroot" '' "$1" 2636316068Sdelphij func_replace_sysroot_result='='$func_stripname_result 2637275970Scy ;; 2638275970Scy *) 2639275970Scy # Including no sysroot. 2640275970Scy func_replace_sysroot_result=$1 2641275970Scy ;; 2642275970Scy esac 2643275970Scy} 2644275970Scy 2645275970Scy# func_infer_tag arg 2646275970Scy# Infer tagged configuration to use if any are available and 2647275970Scy# if one wasn't chosen via the "--tag" command line option. 2648275970Scy# Only attempt this if the compiler in the base compile 2649275970Scy# command doesn't match the default compiler. 2650275970Scy# arg is usually of the form 'gcc ...' 2651275970Scyfunc_infer_tag () 2652275970Scy{ 2653316068Sdelphij $debug_cmd 2654316068Sdelphij 2655275970Scy if test -n "$available_tags" && test -z "$tagname"; then 2656275970Scy CC_quoted= 2657275970Scy for arg in $CC; do 2658275970Scy func_append_quoted CC_quoted "$arg" 2659275970Scy done 2660275970Scy CC_expanded=`func_echo_all $CC` 2661275970Scy CC_quoted_expanded=`func_echo_all $CC_quoted` 2662275970Scy case $@ in 2663275970Scy # Blanks in the command may have been stripped by the calling shell, 2664275970Scy # but not from the CC environment variable when configure was run. 2665275970Scy " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666275970Scy " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667275970Scy # Blanks at the start of $base_compile will cause this to fail 2668275970Scy # if we don't check for them as well. 2669275970Scy *) 2670275970Scy for z in $available_tags; do 2671275970Scy if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672275970Scy # Evaluate the configuration. 2673316068Sdelphij eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674275970Scy CC_quoted= 2675275970Scy for arg in $CC; do 2676275970Scy # Double-quote args containing other shell metacharacters. 2677275970Scy func_append_quoted CC_quoted "$arg" 2678275970Scy done 2679275970Scy CC_expanded=`func_echo_all $CC` 2680275970Scy CC_quoted_expanded=`func_echo_all $CC_quoted` 2681275970Scy case "$@ " in 2682275970Scy " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683275970Scy " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684275970Scy # The compiler in the base compile command matches 2685275970Scy # the one in the tagged configuration. 2686275970Scy # Assume this is the tagged configuration we want. 2687275970Scy tagname=$z 2688275970Scy break 2689275970Scy ;; 2690275970Scy esac 2691275970Scy fi 2692275970Scy done 2693275970Scy # If $tagname still isn't set, then no tagged configuration 2694275970Scy # was found and let the user know that the "--tag" command 2695275970Scy # line option must be used. 2696275970Scy if test -z "$tagname"; then 2697275970Scy func_echo "unable to infer tagged configuration" 2698316068Sdelphij func_fatal_error "specify a tag with '--tag'" 2699275970Scy# else 2700275970Scy# func_verbose "using $tagname tagged configuration" 2701275970Scy fi 2702275970Scy ;; 2703275970Scy esac 2704275970Scy fi 2705275970Scy} 2706275970Scy 2707275970Scy 2708275970Scy 2709275970Scy# func_write_libtool_object output_name pic_name nonpic_name 2710275970Scy# Create a libtool object file (analogous to a ".la" file), 2711275970Scy# but don't create it if we're doing a dry run. 2712275970Scyfunc_write_libtool_object () 2713275970Scy{ 2714316068Sdelphij write_libobj=$1 2715316068Sdelphij if test yes = "$build_libtool_libs"; then 2716316068Sdelphij write_lobj=\'$2\' 2717275970Scy else 2718275970Scy write_lobj=none 2719275970Scy fi 2720275970Scy 2721316068Sdelphij if test yes = "$build_old_libs"; then 2722316068Sdelphij write_oldobj=\'$3\' 2723275970Scy else 2724275970Scy write_oldobj=none 2725275970Scy fi 2726275970Scy 2727275970Scy $opt_dry_run || { 2728275970Scy cat >${write_libobj}T <<EOF 2729275970Scy# $write_libobj - a libtool object file 2730316068Sdelphij# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731275970Scy# 2732275970Scy# Please DO NOT delete this file! 2733275970Scy# It is necessary for linking the library. 2734275970Scy 2735275970Scy# Name of the PIC object. 2736275970Scypic_object=$write_lobj 2737275970Scy 2738275970Scy# Name of the non-PIC object 2739275970Scynon_pic_object=$write_oldobj 2740275970Scy 2741275970ScyEOF 2742316068Sdelphij $MV "${write_libobj}T" "$write_libobj" 2743275970Scy } 2744275970Scy} 2745275970Scy 2746275970Scy 2747275970Scy################################################## 2748275970Scy# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749275970Scy################################################## 2750275970Scy 2751275970Scy# func_convert_core_file_wine_to_w32 ARG 2752275970Scy# Helper function used by file name conversion functions when $build is *nix, 2753275970Scy# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754275970Scy# correctly configured wine environment available, with the winepath program 2755275970Scy# in $build's $PATH. 2756275970Scy# 2757275970Scy# ARG is the $build file name to be converted to w32 format. 2758275970Scy# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759275970Scy# be empty on error (or when ARG is empty) 2760275970Scyfunc_convert_core_file_wine_to_w32 () 2761275970Scy{ 2762316068Sdelphij $debug_cmd 2763316068Sdelphij 2764316068Sdelphij func_convert_core_file_wine_to_w32_result=$1 2765275970Scy if test -n "$1"; then 2766275970Scy # Unfortunately, winepath does not exit with a non-zero error code, so we 2767275970Scy # are forced to check the contents of stdout. On the other hand, if the 2768275970Scy # command is not found, the shell will set an exit code of 127 and print 2769275970Scy # *an error message* to stdout. So we must check for both error code of 2770275970Scy # zero AND non-empty stdout, which explains the odd construction: 2771275970Scy func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772316068Sdelphij if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773275970Scy func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774316068Sdelphij $SED -e "$sed_naive_backslashify"` 2775275970Scy else 2776275970Scy func_convert_core_file_wine_to_w32_result= 2777275970Scy fi 2778275970Scy fi 2779275970Scy} 2780275970Scy# end: func_convert_core_file_wine_to_w32 2781275970Scy 2782275970Scy 2783275970Scy# func_convert_core_path_wine_to_w32 ARG 2784275970Scy# Helper function used by path conversion functions when $build is *nix, and 2785275970Scy# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786275970Scy# configured wine environment available, with the winepath program in $build's 2787275970Scy# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788275970Scy# 2789275970Scy# ARG is path to be converted from $build format to win32. 2790275970Scy# Result is available in $func_convert_core_path_wine_to_w32_result. 2791275970Scy# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792275970Scy# are convertible, then the result may be empty. 2793275970Scyfunc_convert_core_path_wine_to_w32 () 2794275970Scy{ 2795316068Sdelphij $debug_cmd 2796316068Sdelphij 2797275970Scy # unfortunately, winepath doesn't convert paths, only file names 2798316068Sdelphij func_convert_core_path_wine_to_w32_result= 2799275970Scy if test -n "$1"; then 2800275970Scy oldIFS=$IFS 2801275970Scy IFS=: 2802275970Scy for func_convert_core_path_wine_to_w32_f in $1; do 2803275970Scy IFS=$oldIFS 2804275970Scy func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805316068Sdelphij if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806275970Scy if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807316068Sdelphij func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808275970Scy else 2809275970Scy func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810275970Scy fi 2811275970Scy fi 2812275970Scy done 2813275970Scy IFS=$oldIFS 2814275970Scy fi 2815275970Scy} 2816275970Scy# end: func_convert_core_path_wine_to_w32 2817275970Scy 2818275970Scy 2819275970Scy# func_cygpath ARGS... 2820275970Scy# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821275970Scy# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822275970Scy# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823275970Scy# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824275970Scy# file name or path is assumed to be in w32 format, as previously converted 2825275970Scy# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826275970Scy# or path in func_cygpath_result (input file name or path is assumed to be in 2827275970Scy# Cygwin format). Returns an empty string on error. 2828275970Scy# 2829275970Scy# ARGS are passed to cygpath, with the last one being the file name or path to 2830275970Scy# be converted. 2831275970Scy# 2832275970Scy# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833275970Scy# environment variable; do not put it in $PATH. 2834275970Scyfunc_cygpath () 2835275970Scy{ 2836316068Sdelphij $debug_cmd 2837316068Sdelphij 2838275970Scy if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839275970Scy func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840275970Scy if test "$?" -ne 0; then 2841275970Scy # on failure, ensure result is empty 2842275970Scy func_cygpath_result= 2843275970Scy fi 2844275970Scy else 2845275970Scy func_cygpath_result= 2846316068Sdelphij func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847275970Scy fi 2848275970Scy} 2849275970Scy#end: func_cygpath 2850275970Scy 2851275970Scy 2852275970Scy# func_convert_core_msys_to_w32 ARG 2853275970Scy# Convert file name or path ARG from MSYS format to w32 format. Return 2854275970Scy# result in func_convert_core_msys_to_w32_result. 2855275970Scyfunc_convert_core_msys_to_w32 () 2856275970Scy{ 2857316068Sdelphij $debug_cmd 2858316068Sdelphij 2859275970Scy # awkward: cmd appends spaces to result 2860275970Scy func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861316068Sdelphij $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862275970Scy} 2863275970Scy#end: func_convert_core_msys_to_w32 2864275970Scy 2865275970Scy 2866275970Scy# func_convert_file_check ARG1 ARG2 2867275970Scy# Verify that ARG1 (a file name in $build format) was converted to $host 2868275970Scy# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869275970Scy# func_to_host_file_result to ARG1). 2870275970Scyfunc_convert_file_check () 2871275970Scy{ 2872316068Sdelphij $debug_cmd 2873316068Sdelphij 2874316068Sdelphij if test -z "$2" && test -n "$1"; then 2875275970Scy func_error "Could not determine host file name corresponding to" 2876316068Sdelphij func_error " '$1'" 2877275970Scy func_error "Continuing, but uninstalled executables may not work." 2878275970Scy # Fallback: 2879316068Sdelphij func_to_host_file_result=$1 2880275970Scy fi 2881275970Scy} 2882275970Scy# end func_convert_file_check 2883275970Scy 2884275970Scy 2885275970Scy# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886275970Scy# Verify that FROM_PATH (a path in $build format) was converted to $host 2887275970Scy# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888275970Scy# func_to_host_file_result to a simplistic fallback value (see below). 2889275970Scyfunc_convert_path_check () 2890275970Scy{ 2891316068Sdelphij $debug_cmd 2892316068Sdelphij 2893275970Scy if test -z "$4" && test -n "$3"; then 2894275970Scy func_error "Could not determine the host path corresponding to" 2895316068Sdelphij func_error " '$3'" 2896275970Scy func_error "Continuing, but uninstalled executables may not work." 2897275970Scy # Fallback. This is a deliberately simplistic "conversion" and 2898275970Scy # should not be "improved". See libtool.info. 2899275970Scy if test "x$1" != "x$2"; then 2900275970Scy lt_replace_pathsep_chars="s|$1|$2|g" 2901275970Scy func_to_host_path_result=`echo "$3" | 2902275970Scy $SED -e "$lt_replace_pathsep_chars"` 2903275970Scy else 2904316068Sdelphij func_to_host_path_result=$3 2905275970Scy fi 2906275970Scy fi 2907275970Scy} 2908275970Scy# end func_convert_path_check 2909275970Scy 2910275970Scy 2911275970Scy# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912275970Scy# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913275970Scy# and appending REPL if ORIG matches BACKPAT. 2914275970Scyfunc_convert_path_front_back_pathsep () 2915275970Scy{ 2916316068Sdelphij $debug_cmd 2917316068Sdelphij 2918275970Scy case $4 in 2919316068Sdelphij $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920275970Scy ;; 2921275970Scy esac 2922275970Scy case $4 in 2923275970Scy $2 ) func_append func_to_host_path_result "$3" 2924275970Scy ;; 2925275970Scy esac 2926275970Scy} 2927275970Scy# end func_convert_path_front_back_pathsep 2928275970Scy 2929275970Scy 2930275970Scy################################################## 2931275970Scy# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932275970Scy################################################## 2933316068Sdelphij# invoked via '$to_host_file_cmd ARG' 2934275970Scy# 2935275970Scy# In each case, ARG is the path to be converted from $build to $host format. 2936275970Scy# Result will be available in $func_to_host_file_result. 2937275970Scy 2938275970Scy 2939275970Scy# func_to_host_file ARG 2940275970Scy# Converts the file name ARG from $build format to $host format. Return result 2941275970Scy# in func_to_host_file_result. 2942275970Scyfunc_to_host_file () 2943275970Scy{ 2944316068Sdelphij $debug_cmd 2945316068Sdelphij 2946275970Scy $to_host_file_cmd "$1" 2947275970Scy} 2948275970Scy# end func_to_host_file 2949275970Scy 2950275970Scy 2951275970Scy# func_to_tool_file ARG LAZY 2952275970Scy# converts the file name ARG from $build format to toolchain format. Return 2953275970Scy# result in func_to_tool_file_result. If the conversion in use is listed 2954275970Scy# in (the comma separated) LAZY, no conversion takes place. 2955275970Scyfunc_to_tool_file () 2956275970Scy{ 2957316068Sdelphij $debug_cmd 2958316068Sdelphij 2959275970Scy case ,$2, in 2960275970Scy *,"$to_tool_file_cmd",*) 2961275970Scy func_to_tool_file_result=$1 2962275970Scy ;; 2963275970Scy *) 2964275970Scy $to_tool_file_cmd "$1" 2965275970Scy func_to_tool_file_result=$func_to_host_file_result 2966275970Scy ;; 2967275970Scy esac 2968275970Scy} 2969275970Scy# end func_to_tool_file 2970275970Scy 2971275970Scy 2972275970Scy# func_convert_file_noop ARG 2973275970Scy# Copy ARG to func_to_host_file_result. 2974275970Scyfunc_convert_file_noop () 2975275970Scy{ 2976316068Sdelphij func_to_host_file_result=$1 2977275970Scy} 2978275970Scy# end func_convert_file_noop 2979275970Scy 2980275970Scy 2981275970Scy# func_convert_file_msys_to_w32 ARG 2982275970Scy# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983275970Scy# conversion to w32 is not available inside the cwrapper. Returns result in 2984275970Scy# func_to_host_file_result. 2985275970Scyfunc_convert_file_msys_to_w32 () 2986275970Scy{ 2987316068Sdelphij $debug_cmd 2988316068Sdelphij 2989316068Sdelphij func_to_host_file_result=$1 2990275970Scy if test -n "$1"; then 2991275970Scy func_convert_core_msys_to_w32 "$1" 2992316068Sdelphij func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993275970Scy fi 2994275970Scy func_convert_file_check "$1" "$func_to_host_file_result" 2995275970Scy} 2996275970Scy# end func_convert_file_msys_to_w32 2997275970Scy 2998275970Scy 2999275970Scy# func_convert_file_cygwin_to_w32 ARG 3000275970Scy# Convert file name ARG from Cygwin to w32 format. Returns result in 3001275970Scy# func_to_host_file_result. 3002275970Scyfunc_convert_file_cygwin_to_w32 () 3003275970Scy{ 3004316068Sdelphij $debug_cmd 3005316068Sdelphij 3006316068Sdelphij func_to_host_file_result=$1 3007275970Scy if test -n "$1"; then 3008275970Scy # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009275970Scy # LT_CYGPATH in this case. 3010275970Scy func_to_host_file_result=`cygpath -m "$1"` 3011275970Scy fi 3012275970Scy func_convert_file_check "$1" "$func_to_host_file_result" 3013275970Scy} 3014275970Scy# end func_convert_file_cygwin_to_w32 3015275970Scy 3016275970Scy 3017275970Scy# func_convert_file_nix_to_w32 ARG 3018275970Scy# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019275970Scy# and a working winepath. Returns result in func_to_host_file_result. 3020275970Scyfunc_convert_file_nix_to_w32 () 3021275970Scy{ 3022316068Sdelphij $debug_cmd 3023316068Sdelphij 3024316068Sdelphij func_to_host_file_result=$1 3025275970Scy if test -n "$1"; then 3026275970Scy func_convert_core_file_wine_to_w32 "$1" 3027316068Sdelphij func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028275970Scy fi 3029275970Scy func_convert_file_check "$1" "$func_to_host_file_result" 3030275970Scy} 3031275970Scy# end func_convert_file_nix_to_w32 3032275970Scy 3033275970Scy 3034275970Scy# func_convert_file_msys_to_cygwin ARG 3035275970Scy# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036275970Scy# Returns result in func_to_host_file_result. 3037275970Scyfunc_convert_file_msys_to_cygwin () 3038275970Scy{ 3039316068Sdelphij $debug_cmd 3040316068Sdelphij 3041316068Sdelphij func_to_host_file_result=$1 3042275970Scy if test -n "$1"; then 3043275970Scy func_convert_core_msys_to_w32 "$1" 3044275970Scy func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045316068Sdelphij func_to_host_file_result=$func_cygpath_result 3046275970Scy fi 3047275970Scy func_convert_file_check "$1" "$func_to_host_file_result" 3048275970Scy} 3049275970Scy# end func_convert_file_msys_to_cygwin 3050275970Scy 3051275970Scy 3052275970Scy# func_convert_file_nix_to_cygwin ARG 3053275970Scy# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054275970Scy# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055275970Scy# in func_to_host_file_result. 3056275970Scyfunc_convert_file_nix_to_cygwin () 3057275970Scy{ 3058316068Sdelphij $debug_cmd 3059316068Sdelphij 3060316068Sdelphij func_to_host_file_result=$1 3061275970Scy if test -n "$1"; then 3062275970Scy # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063275970Scy func_convert_core_file_wine_to_w32 "$1" 3064275970Scy func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065316068Sdelphij func_to_host_file_result=$func_cygpath_result 3066275970Scy fi 3067275970Scy func_convert_file_check "$1" "$func_to_host_file_result" 3068275970Scy} 3069275970Scy# end func_convert_file_nix_to_cygwin 3070275970Scy 3071275970Scy 3072275970Scy############################################# 3073275970Scy# $build to $host PATH CONVERSION FUNCTIONS # 3074275970Scy############################################# 3075316068Sdelphij# invoked via '$to_host_path_cmd ARG' 3076275970Scy# 3077275970Scy# In each case, ARG is the path to be converted from $build to $host format. 3078275970Scy# The result will be available in $func_to_host_path_result. 3079275970Scy# 3080275970Scy# Path separators are also converted from $build format to $host format. If 3081275970Scy# ARG begins or ends with a path separator character, it is preserved (but 3082275970Scy# converted to $host format) on output. 3083275970Scy# 3084275970Scy# All path conversion functions are named using the following convention: 3085275970Scy# file name conversion function : func_convert_file_X_to_Y () 3086275970Scy# path conversion function : func_convert_path_X_to_Y () 3087275970Scy# where, for any given $build/$host combination the 'X_to_Y' value is the 3088275970Scy# same. If conversion functions are added for new $build/$host combinations, 3089275970Scy# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090275970Scy# will break. 3091275970Scy 3092275970Scy 3093275970Scy# func_init_to_host_path_cmd 3094275970Scy# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095275970Scy# appropriate value, based on the value of $to_host_file_cmd. 3096275970Scyto_host_path_cmd= 3097275970Scyfunc_init_to_host_path_cmd () 3098275970Scy{ 3099316068Sdelphij $debug_cmd 3100316068Sdelphij 3101275970Scy if test -z "$to_host_path_cmd"; then 3102275970Scy func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103316068Sdelphij to_host_path_cmd=func_convert_path_$func_stripname_result 3104275970Scy fi 3105275970Scy} 3106275970Scy 3107275970Scy 3108275970Scy# func_to_host_path ARG 3109275970Scy# Converts the path ARG from $build format to $host format. Return result 3110275970Scy# in func_to_host_path_result. 3111275970Scyfunc_to_host_path () 3112275970Scy{ 3113316068Sdelphij $debug_cmd 3114316068Sdelphij 3115275970Scy func_init_to_host_path_cmd 3116275970Scy $to_host_path_cmd "$1" 3117275970Scy} 3118275970Scy# end func_to_host_path 3119275970Scy 3120275970Scy 3121275970Scy# func_convert_path_noop ARG 3122275970Scy# Copy ARG to func_to_host_path_result. 3123275970Scyfunc_convert_path_noop () 3124275970Scy{ 3125316068Sdelphij func_to_host_path_result=$1 3126275970Scy} 3127275970Scy# end func_convert_path_noop 3128275970Scy 3129275970Scy 3130275970Scy# func_convert_path_msys_to_w32 ARG 3131275970Scy# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132275970Scy# conversion to w32 is not available inside the cwrapper. Returns result in 3133275970Scy# func_to_host_path_result. 3134275970Scyfunc_convert_path_msys_to_w32 () 3135275970Scy{ 3136316068Sdelphij $debug_cmd 3137316068Sdelphij 3138316068Sdelphij func_to_host_path_result=$1 3139275970Scy if test -n "$1"; then 3140275970Scy # Remove leading and trailing path separator characters from ARG. MSYS 3141275970Scy # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142275970Scy # and winepath ignores them completely. 3143275970Scy func_stripname : : "$1" 3144275970Scy func_to_host_path_tmp1=$func_stripname_result 3145275970Scy func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146316068Sdelphij func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147275970Scy func_convert_path_check : ";" \ 3148275970Scy "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149275970Scy func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150275970Scy fi 3151275970Scy} 3152275970Scy# end func_convert_path_msys_to_w32 3153275970Scy 3154275970Scy 3155275970Scy# func_convert_path_cygwin_to_w32 ARG 3156275970Scy# Convert path ARG from Cygwin to w32 format. Returns result in 3157275970Scy# func_to_host_file_result. 3158275970Scyfunc_convert_path_cygwin_to_w32 () 3159275970Scy{ 3160316068Sdelphij $debug_cmd 3161316068Sdelphij 3162316068Sdelphij func_to_host_path_result=$1 3163275970Scy if test -n "$1"; then 3164275970Scy # See func_convert_path_msys_to_w32: 3165275970Scy func_stripname : : "$1" 3166275970Scy func_to_host_path_tmp1=$func_stripname_result 3167275970Scy func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168275970Scy func_convert_path_check : ";" \ 3169275970Scy "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170275970Scy func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171275970Scy fi 3172275970Scy} 3173275970Scy# end func_convert_path_cygwin_to_w32 3174275970Scy 3175275970Scy 3176275970Scy# func_convert_path_nix_to_w32 ARG 3177275970Scy# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178275970Scy# a working winepath. Returns result in func_to_host_file_result. 3179275970Scyfunc_convert_path_nix_to_w32 () 3180275970Scy{ 3181316068Sdelphij $debug_cmd 3182316068Sdelphij 3183316068Sdelphij func_to_host_path_result=$1 3184275970Scy if test -n "$1"; then 3185275970Scy # See func_convert_path_msys_to_w32: 3186275970Scy func_stripname : : "$1" 3187275970Scy func_to_host_path_tmp1=$func_stripname_result 3188275970Scy func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189316068Sdelphij func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190275970Scy func_convert_path_check : ";" \ 3191275970Scy "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192275970Scy func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193275970Scy fi 3194275970Scy} 3195275970Scy# end func_convert_path_nix_to_w32 3196275970Scy 3197275970Scy 3198275970Scy# func_convert_path_msys_to_cygwin ARG 3199275970Scy# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200275970Scy# Returns result in func_to_host_file_result. 3201275970Scyfunc_convert_path_msys_to_cygwin () 3202275970Scy{ 3203316068Sdelphij $debug_cmd 3204316068Sdelphij 3205316068Sdelphij func_to_host_path_result=$1 3206275970Scy if test -n "$1"; then 3207275970Scy # See func_convert_path_msys_to_w32: 3208275970Scy func_stripname : : "$1" 3209275970Scy func_to_host_path_tmp1=$func_stripname_result 3210275970Scy func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211275970Scy func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212316068Sdelphij func_to_host_path_result=$func_cygpath_result 3213275970Scy func_convert_path_check : : \ 3214275970Scy "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215275970Scy func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216275970Scy fi 3217275970Scy} 3218275970Scy# end func_convert_path_msys_to_cygwin 3219275970Scy 3220275970Scy 3221275970Scy# func_convert_path_nix_to_cygwin ARG 3222275970Scy# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223275970Scy# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224275970Scy# func_to_host_file_result. 3225275970Scyfunc_convert_path_nix_to_cygwin () 3226275970Scy{ 3227316068Sdelphij $debug_cmd 3228316068Sdelphij 3229316068Sdelphij func_to_host_path_result=$1 3230275970Scy if test -n "$1"; then 3231275970Scy # Remove leading and trailing path separator characters from 3232275970Scy # ARG. msys behavior is inconsistent here, cygpath turns them 3233275970Scy # into '.;' and ';.', and winepath ignores them completely. 3234275970Scy func_stripname : : "$1" 3235275970Scy func_to_host_path_tmp1=$func_stripname_result 3236275970Scy func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237275970Scy func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238316068Sdelphij func_to_host_path_result=$func_cygpath_result 3239275970Scy func_convert_path_check : : \ 3240275970Scy "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241275970Scy func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242275970Scy fi 3243275970Scy} 3244275970Scy# end func_convert_path_nix_to_cygwin 3245275970Scy 3246275970Scy 3247316068Sdelphij# func_dll_def_p FILE 3248316068Sdelphij# True iff FILE is a Windows DLL '.def' file. 3249316068Sdelphij# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250316068Sdelphijfunc_dll_def_p () 3251316068Sdelphij{ 3252316068Sdelphij $debug_cmd 3253316068Sdelphij 3254316068Sdelphij func_dll_def_p_tmp=`$SED -n \ 3255316068Sdelphij -e 's/^[ ]*//' \ 3256316068Sdelphij -e '/^\(;.*\)*$/d' \ 3257316068Sdelphij -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258316068Sdelphij -e q \ 3259316068Sdelphij "$1"` 3260316068Sdelphij test DEF = "$func_dll_def_p_tmp" 3261316068Sdelphij} 3262316068Sdelphij 3263316068Sdelphij 3264275970Scy# func_mode_compile arg... 3265275970Scyfunc_mode_compile () 3266275970Scy{ 3267316068Sdelphij $debug_cmd 3268316068Sdelphij 3269275970Scy # Get the compilation command and the source file. 3270275970Scy base_compile= 3271316068Sdelphij srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272275970Scy suppress_opt=yes 3273275970Scy suppress_output= 3274275970Scy arg_mode=normal 3275275970Scy libobj= 3276275970Scy later= 3277275970Scy pie_flag= 3278275970Scy 3279275970Scy for arg 3280275970Scy do 3281275970Scy case $arg_mode in 3282275970Scy arg ) 3283275970Scy # do not "continue". Instead, add this to base_compile 3284316068Sdelphij lastarg=$arg 3285275970Scy arg_mode=normal 3286275970Scy ;; 3287275970Scy 3288275970Scy target ) 3289316068Sdelphij libobj=$arg 3290275970Scy arg_mode=normal 3291275970Scy continue 3292275970Scy ;; 3293275970Scy 3294275970Scy normal ) 3295275970Scy # Accept any command-line options. 3296275970Scy case $arg in 3297275970Scy -o) 3298275970Scy test -n "$libobj" && \ 3299316068Sdelphij func_fatal_error "you cannot specify '-o' more than once" 3300275970Scy arg_mode=target 3301275970Scy continue 3302275970Scy ;; 3303275970Scy 3304275970Scy -pie | -fpie | -fPIE) 3305275970Scy func_append pie_flag " $arg" 3306275970Scy continue 3307275970Scy ;; 3308275970Scy 3309275970Scy -shared | -static | -prefer-pic | -prefer-non-pic) 3310275970Scy func_append later " $arg" 3311275970Scy continue 3312275970Scy ;; 3313275970Scy 3314275970Scy -no-suppress) 3315275970Scy suppress_opt=no 3316275970Scy continue 3317275970Scy ;; 3318275970Scy 3319275970Scy -Xcompiler) 3320275970Scy arg_mode=arg # the next one goes into the "base_compile" arg list 3321275970Scy continue # The current "srcfile" will either be retained or 3322275970Scy ;; # replaced later. I would guess that would be a bug. 3323275970Scy 3324275970Scy -Wc,*) 3325275970Scy func_stripname '-Wc,' '' "$arg" 3326275970Scy args=$func_stripname_result 3327275970Scy lastarg= 3328316068Sdelphij save_ifs=$IFS; IFS=, 3329275970Scy for arg in $args; do 3330316068Sdelphij IFS=$save_ifs 3331275970Scy func_append_quoted lastarg "$arg" 3332275970Scy done 3333316068Sdelphij IFS=$save_ifs 3334275970Scy func_stripname ' ' '' "$lastarg" 3335275970Scy lastarg=$func_stripname_result 3336275970Scy 3337275970Scy # Add the arguments to base_compile. 3338275970Scy func_append base_compile " $lastarg" 3339275970Scy continue 3340275970Scy ;; 3341275970Scy 3342275970Scy *) 3343275970Scy # Accept the current argument as the source file. 3344275970Scy # The previous "srcfile" becomes the current argument. 3345275970Scy # 3346316068Sdelphij lastarg=$srcfile 3347316068Sdelphij srcfile=$arg 3348275970Scy ;; 3349275970Scy esac # case $arg 3350275970Scy ;; 3351275970Scy esac # case $arg_mode 3352275970Scy 3353275970Scy # Aesthetically quote the previous argument. 3354275970Scy func_append_quoted base_compile "$lastarg" 3355275970Scy done # for arg 3356275970Scy 3357275970Scy case $arg_mode in 3358275970Scy arg) 3359275970Scy func_fatal_error "you must specify an argument for -Xcompile" 3360275970Scy ;; 3361275970Scy target) 3362316068Sdelphij func_fatal_error "you must specify a target with '-o'" 3363275970Scy ;; 3364275970Scy *) 3365275970Scy # Get the name of the library object. 3366275970Scy test -z "$libobj" && { 3367275970Scy func_basename "$srcfile" 3368316068Sdelphij libobj=$func_basename_result 3369275970Scy } 3370275970Scy ;; 3371275970Scy esac 3372275970Scy 3373275970Scy # Recognize several different file suffixes. 3374275970Scy # If the user specifies -o file.o, it is replaced with file.lo 3375275970Scy case $libobj in 3376275970Scy *.[cCFSifmso] | \ 3377275970Scy *.ada | *.adb | *.ads | *.asm | \ 3378275970Scy *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379285169Scy *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380275970Scy func_xform "$libobj" 3381275970Scy libobj=$func_xform_result 3382275970Scy ;; 3383275970Scy esac 3384275970Scy 3385275970Scy case $libobj in 3386275970Scy *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387275970Scy *) 3388316068Sdelphij func_fatal_error "cannot determine name of library object from '$libobj'" 3389275970Scy ;; 3390275970Scy esac 3391275970Scy 3392275970Scy func_infer_tag $base_compile 3393275970Scy 3394275970Scy for arg in $later; do 3395275970Scy case $arg in 3396275970Scy -shared) 3397316068Sdelphij test yes = "$build_libtool_libs" \ 3398316068Sdelphij || func_fatal_configuration "cannot build a shared library" 3399275970Scy build_old_libs=no 3400275970Scy continue 3401275970Scy ;; 3402275970Scy 3403275970Scy -static) 3404275970Scy build_libtool_libs=no 3405275970Scy build_old_libs=yes 3406275970Scy continue 3407275970Scy ;; 3408275970Scy 3409275970Scy -prefer-pic) 3410275970Scy pic_mode=yes 3411275970Scy continue 3412275970Scy ;; 3413275970Scy 3414275970Scy -prefer-non-pic) 3415275970Scy pic_mode=no 3416275970Scy continue 3417275970Scy ;; 3418275970Scy esac 3419275970Scy done 3420275970Scy 3421275970Scy func_quote_for_eval "$libobj" 3422275970Scy test "X$libobj" != "X$func_quote_for_eval_result" \ 3423275970Scy && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424316068Sdelphij && func_warning "libobj name '$libobj' may not contain shell special characters." 3425275970Scy func_dirname_and_basename "$obj" "/" "" 3426316068Sdelphij objname=$func_basename_result 3427316068Sdelphij xdir=$func_dirname_result 3428316068Sdelphij lobj=$xdir$objdir/$objname 3429275970Scy 3430275970Scy test -z "$base_compile" && \ 3431275970Scy func_fatal_help "you must specify a compilation command" 3432275970Scy 3433275970Scy # Delete any leftover library objects. 3434316068Sdelphij if test yes = "$build_old_libs"; then 3435275970Scy removelist="$obj $lobj $libobj ${libobj}T" 3436275970Scy else 3437275970Scy removelist="$lobj $libobj ${libobj}T" 3438275970Scy fi 3439275970Scy 3440275970Scy # On Cygwin there's no "real" PIC flag so we must build both object types 3441275970Scy case $host_os in 3442275970Scy cygwin* | mingw* | pw32* | os2* | cegcc*) 3443275970Scy pic_mode=default 3444275970Scy ;; 3445275970Scy esac 3446316068Sdelphij if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447275970Scy # non-PIC code in shared libraries is not supported 3448275970Scy pic_mode=default 3449275970Scy fi 3450275970Scy 3451275970Scy # Calculate the filename of the output object if compiler does 3452275970Scy # not support -o with -c 3453316068Sdelphij if test no = "$compiler_c_o"; then 3454316068Sdelphij output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455316068Sdelphij lockfile=$output_obj.lock 3456275970Scy else 3457275970Scy output_obj= 3458275970Scy need_locks=no 3459275970Scy lockfile= 3460275970Scy fi 3461275970Scy 3462275970Scy # Lock this critical section if it is needed 3463275970Scy # We use this script file to make the link, it avoids creating a new file 3464316068Sdelphij if test yes = "$need_locks"; then 3465275970Scy until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466275970Scy func_echo "Waiting for $lockfile to be removed" 3467275970Scy sleep 2 3468275970Scy done 3469316068Sdelphij elif test warn = "$need_locks"; then 3470275970Scy if test -f "$lockfile"; then 3471275970Scy $ECHO "\ 3472275970Scy*** ERROR, $lockfile exists and contains: 3473275970Scy`cat $lockfile 2>/dev/null` 3474275970Scy 3475275970ScyThis indicates that another process is trying to use the same 3476275970Scytemporary object file, and libtool could not work around it because 3477316068Sdelphijyour compiler does not support '-c' and '-o' together. If you 3478275970Scyrepeat this compilation, it may succeed, by chance, but you had better 3479275970Scyavoid parallel builds (make -j) in this platform, or get a better 3480275970Scycompiler." 3481275970Scy 3482275970Scy $opt_dry_run || $RM $removelist 3483275970Scy exit $EXIT_FAILURE 3484275970Scy fi 3485275970Scy func_append removelist " $output_obj" 3486275970Scy $ECHO "$srcfile" > "$lockfile" 3487275970Scy fi 3488275970Scy 3489275970Scy $opt_dry_run || $RM $removelist 3490275970Scy func_append removelist " $lockfile" 3491275970Scy trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492275970Scy 3493275970Scy func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494275970Scy srcfile=$func_to_tool_file_result 3495275970Scy func_quote_for_eval "$srcfile" 3496275970Scy qsrcfile=$func_quote_for_eval_result 3497275970Scy 3498275970Scy # Only build a PIC object if we are building libtool libraries. 3499316068Sdelphij if test yes = "$build_libtool_libs"; then 3500275970Scy # Without this assignment, base_compile gets emptied. 3501275970Scy fbsd_hideous_sh_bug=$base_compile 3502275970Scy 3503316068Sdelphij if test no != "$pic_mode"; then 3504275970Scy command="$base_compile $qsrcfile $pic_flag" 3505275970Scy else 3506275970Scy # Don't build PIC code 3507275970Scy command="$base_compile $qsrcfile" 3508275970Scy fi 3509275970Scy 3510275970Scy func_mkdir_p "$xdir$objdir" 3511275970Scy 3512275970Scy if test -z "$output_obj"; then 3513275970Scy # Place PIC objects in $objdir 3514275970Scy func_append command " -o $lobj" 3515275970Scy fi 3516275970Scy 3517275970Scy func_show_eval_locale "$command" \ 3518275970Scy 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519275970Scy 3520316068Sdelphij if test warn = "$need_locks" && 3521275970Scy test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522275970Scy $ECHO "\ 3523275970Scy*** ERROR, $lockfile contains: 3524275970Scy`cat $lockfile 2>/dev/null` 3525275970Scy 3526275970Scybut it should contain: 3527275970Scy$srcfile 3528275970Scy 3529275970ScyThis indicates that another process is trying to use the same 3530275970Scytemporary object file, and libtool could not work around it because 3531316068Sdelphijyour compiler does not support '-c' and '-o' together. If you 3532275970Scyrepeat this compilation, it may succeed, by chance, but you had better 3533275970Scyavoid parallel builds (make -j) in this platform, or get a better 3534275970Scycompiler." 3535275970Scy 3536275970Scy $opt_dry_run || $RM $removelist 3537275970Scy exit $EXIT_FAILURE 3538275970Scy fi 3539275970Scy 3540275970Scy # Just move the object if needed, then go on to compile the next one 3541275970Scy if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542275970Scy func_show_eval '$MV "$output_obj" "$lobj"' \ 3543275970Scy 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544275970Scy fi 3545275970Scy 3546275970Scy # Allow error messages only from the first compilation. 3547316068Sdelphij if test yes = "$suppress_opt"; then 3548275970Scy suppress_output=' >/dev/null 2>&1' 3549275970Scy fi 3550275970Scy fi 3551275970Scy 3552275970Scy # Only build a position-dependent object if we build old libraries. 3553316068Sdelphij if test yes = "$build_old_libs"; then 3554316068Sdelphij if test yes != "$pic_mode"; then 3555275970Scy # Don't build PIC code 3556275970Scy command="$base_compile $qsrcfile$pie_flag" 3557275970Scy else 3558275970Scy command="$base_compile $qsrcfile $pic_flag" 3559275970Scy fi 3560316068Sdelphij if test yes = "$compiler_c_o"; then 3561275970Scy func_append command " -o $obj" 3562275970Scy fi 3563275970Scy 3564275970Scy # Suppress compiler output if we already did a PIC compilation. 3565275970Scy func_append command "$suppress_output" 3566275970Scy func_show_eval_locale "$command" \ 3567275970Scy '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568275970Scy 3569316068Sdelphij if test warn = "$need_locks" && 3570275970Scy test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571275970Scy $ECHO "\ 3572275970Scy*** ERROR, $lockfile contains: 3573275970Scy`cat $lockfile 2>/dev/null` 3574275970Scy 3575275970Scybut it should contain: 3576275970Scy$srcfile 3577275970Scy 3578275970ScyThis indicates that another process is trying to use the same 3579275970Scytemporary object file, and libtool could not work around it because 3580316068Sdelphijyour compiler does not support '-c' and '-o' together. If you 3581275970Scyrepeat this compilation, it may succeed, by chance, but you had better 3582275970Scyavoid parallel builds (make -j) in this platform, or get a better 3583275970Scycompiler." 3584275970Scy 3585275970Scy $opt_dry_run || $RM $removelist 3586275970Scy exit $EXIT_FAILURE 3587275970Scy fi 3588275970Scy 3589275970Scy # Just move the object if needed 3590275970Scy if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591275970Scy func_show_eval '$MV "$output_obj" "$obj"' \ 3592275970Scy 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593275970Scy fi 3594275970Scy fi 3595275970Scy 3596275970Scy $opt_dry_run || { 3597275970Scy func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598275970Scy 3599275970Scy # Unlock the critical section if it was locked 3600316068Sdelphij if test no != "$need_locks"; then 3601275970Scy removelist=$lockfile 3602275970Scy $RM "$lockfile" 3603275970Scy fi 3604275970Scy } 3605275970Scy 3606275970Scy exit $EXIT_SUCCESS 3607275970Scy} 3608275970Scy 3609275970Scy$opt_help || { 3610316068Sdelphij test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611275970Scy} 3612275970Scy 3613275970Scyfunc_mode_help () 3614275970Scy{ 3615275970Scy # We need to display help for each of the modes. 3616275970Scy case $opt_mode in 3617275970Scy "") 3618275970Scy # Generic help is extracted from the usage comments 3619275970Scy # at the start of this file. 3620275970Scy func_help 3621275970Scy ;; 3622275970Scy 3623275970Scy clean) 3624275970Scy $ECHO \ 3625275970Scy"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626275970Scy 3627275970ScyRemove files from the build directory. 3628275970Scy 3629275970ScyRM is the name of the program to use to delete files associated with each FILE 3630316068Sdelphij(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631275970Scyto RM. 3632275970Scy 3633275970ScyIf FILE is a libtool library, object or program, all the files associated 3634275970Scywith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635275970Scy ;; 3636275970Scy 3637275970Scy compile) 3638275970Scy $ECHO \ 3639275970Scy"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640275970Scy 3641275970ScyCompile a source file into a libtool library object. 3642275970Scy 3643275970ScyThis mode accepts the following additional options: 3644275970Scy 3645275970Scy -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646275970Scy -no-suppress do not suppress compiler output for multiple passes 3647275970Scy -prefer-pic try to build PIC objects only 3648275970Scy -prefer-non-pic try to build non-PIC objects only 3649316068Sdelphij -shared do not build a '.o' file suitable for static linking 3650316068Sdelphij -static only build a '.o' file suitable for static linking 3651275970Scy -Wc,FLAG pass FLAG directly to the compiler 3652275970Scy 3653316068SdelphijCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654275970Scyfrom the given SOURCEFILE. 3655275970Scy 3656275970ScyThe output file name is determined by removing the directory component from 3657316068SdelphijSOURCEFILE, then substituting the C source code suffix '.c' with the 3658316068Sdelphijlibrary object suffix, '.lo'." 3659275970Scy ;; 3660275970Scy 3661275970Scy execute) 3662275970Scy $ECHO \ 3663275970Scy"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664275970Scy 3665275970ScyAutomatically set library path, then run a program. 3666275970Scy 3667275970ScyThis mode accepts the following additional options: 3668275970Scy 3669275970Scy -dlopen FILE add the directory containing FILE to the library path 3670275970Scy 3671316068SdelphijThis mode sets the library path environment variable according to '-dlopen' 3672275970Scyflags. 3673275970Scy 3674275970ScyIf any of the ARGS are libtool executable wrappers, then they are translated 3675275970Scyinto their corresponding uninstalled binary, and any of their required library 3676275970Scydirectories are added to the library path. 3677275970Scy 3678275970ScyThen, COMMAND is executed, with ARGS as arguments." 3679275970Scy ;; 3680275970Scy 3681275970Scy finish) 3682275970Scy $ECHO \ 3683275970Scy"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684275970Scy 3685275970ScyComplete the installation of libtool libraries. 3686275970Scy 3687275970ScyEach LIBDIR is a directory that contains libtool libraries. 3688275970Scy 3689275970ScyThe commands that this mode executes may require superuser privileges. Use 3690316068Sdelphijthe '--dry-run' option if you just want to see what would be executed." 3691275970Scy ;; 3692275970Scy 3693275970Scy install) 3694275970Scy $ECHO \ 3695275970Scy"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696275970Scy 3697275970ScyInstall executables or libraries. 3698275970Scy 3699275970ScyINSTALL-COMMAND is the installation command. The first component should be 3700316068Sdelphijeither the 'install' or 'cp' program. 3701275970Scy 3702275970ScyThe following components of INSTALL-COMMAND are treated specially: 3703275970Scy 3704275970Scy -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705275970Scy 3706275970ScyThe rest of the components are interpreted as arguments to that command (only 3707275970ScyBSD-compatible install options are recognized)." 3708275970Scy ;; 3709275970Scy 3710275970Scy link) 3711275970Scy $ECHO \ 3712275970Scy"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713275970Scy 3714275970ScyLink object files or libraries together to form another library, or to 3715275970Scycreate an executable program. 3716275970Scy 3717275970ScyLINK-COMMAND is a command using the C compiler that you would use to create 3718275970Scya program from several object files. 3719275970Scy 3720275970ScyThe following components of LINK-COMMAND are treated specially: 3721275970Scy 3722275970Scy -all-static do not do any dynamic linking at all 3723275970Scy -avoid-version do not add a version suffix if possible 3724275970Scy -bindir BINDIR specify path to binaries directory (for systems where 3725275970Scy libraries must be found in the PATH setting at runtime) 3726316068Sdelphij -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727275970Scy -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728275970Scy -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729275970Scy -export-symbols SYMFILE 3730275970Scy try to export only the symbols listed in SYMFILE 3731275970Scy -export-symbols-regex REGEX 3732275970Scy try to export only the symbols matching REGEX 3733275970Scy -LLIBDIR search LIBDIR for required installed libraries 3734275970Scy -lNAME OUTPUT-FILE requires the installed library libNAME 3735275970Scy -module build a library that can dlopened 3736275970Scy -no-fast-install disable the fast-install mode 3737275970Scy -no-install link a not-installable executable 3738275970Scy -no-undefined declare that a library does not refer to external symbols 3739275970Scy -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740316068Sdelphij -objectlist FILE use a list of object files found in FILE to specify objects 3741316068Sdelphij -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742275970Scy -precious-files-regex REGEX 3743275970Scy don't remove output files matching REGEX 3744275970Scy -release RELEASE specify package release information 3745275970Scy -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746275970Scy -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747275970Scy -shared only do dynamic linking of libtool libraries 3748275970Scy -shrext SUFFIX override the standard shared library file extension 3749275970Scy -static do not do any dynamic linking of uninstalled libtool libraries 3750275970Scy -static-libtool-libs 3751275970Scy do not do any dynamic linking of libtool libraries 3752275970Scy -version-info CURRENT[:REVISION[:AGE]] 3753275970Scy specify library version info [each variable defaults to 0] 3754275970Scy -weak LIBNAME declare that the target provides the LIBNAME interface 3755275970Scy -Wc,FLAG 3756275970Scy -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757275970Scy -Wl,FLAG 3758275970Scy -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759275970Scy -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760275970Scy 3761316068SdelphijAll other options (arguments beginning with '-') are ignored. 3762275970Scy 3763316068SdelphijEvery other argument is treated as a filename. Files ending in '.la' are 3764275970Scytreated as uninstalled libtool libraries, other files are standard or library 3765275970Scyobject files. 3766275970Scy 3767316068SdelphijIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768316068Sdelphijonly library objects ('.lo' files) may be specified, and '-rpath' is 3769275970Scyrequired, except when creating a convenience library. 3770275970Scy 3771316068SdelphijIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772316068Sdelphijusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773275970Scy 3774316068SdelphijIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775275970Scyis created, otherwise an executable program is created." 3776275970Scy ;; 3777275970Scy 3778275970Scy uninstall) 3779275970Scy $ECHO \ 3780275970Scy"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781275970Scy 3782275970ScyRemove libraries from an installation directory. 3783275970Scy 3784275970ScyRM is the name of the program to use to delete files associated with each FILE 3785316068Sdelphij(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786275970Scyto RM. 3787275970Scy 3788275970ScyIf FILE is a libtool library, all the files associated with it are deleted. 3789275970ScyOtherwise, only FILE itself is deleted using RM." 3790275970Scy ;; 3791275970Scy 3792275970Scy *) 3793316068Sdelphij func_fatal_help "invalid operation mode '$opt_mode'" 3794275970Scy ;; 3795275970Scy esac 3796275970Scy 3797275970Scy echo 3798316068Sdelphij $ECHO "Try '$progname --help' for more information about other modes." 3799275970Scy} 3800275970Scy 3801275970Scy# Now that we've collected a possible --mode arg, show help if necessary 3802275970Scyif $opt_help; then 3803316068Sdelphij if test : = "$opt_help"; then 3804275970Scy func_mode_help 3805275970Scy else 3806275970Scy { 3807275970Scy func_help noexit 3808275970Scy for opt_mode in compile link execute install finish uninstall clean; do 3809275970Scy func_mode_help 3810275970Scy done 3811316068Sdelphij } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812275970Scy { 3813275970Scy func_help noexit 3814275970Scy for opt_mode in compile link execute install finish uninstall clean; do 3815275970Scy echo 3816275970Scy func_mode_help 3817275970Scy done 3818275970Scy } | 3819316068Sdelphij $SED '1d 3820275970Scy /^When reporting/,/^Report/{ 3821275970Scy H 3822275970Scy d 3823275970Scy } 3824275970Scy $x 3825275970Scy /information about other modes/d 3826275970Scy /more detailed .*MODE/d 3827275970Scy s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828275970Scy fi 3829275970Scy exit $? 3830275970Scyfi 3831275970Scy 3832275970Scy 3833275970Scy# func_mode_execute arg... 3834275970Scyfunc_mode_execute () 3835275970Scy{ 3836316068Sdelphij $debug_cmd 3837316068Sdelphij 3838275970Scy # The first argument is the command name. 3839316068Sdelphij cmd=$nonopt 3840275970Scy test -z "$cmd" && \ 3841275970Scy func_fatal_help "you must specify a COMMAND" 3842275970Scy 3843275970Scy # Handle -dlopen flags immediately. 3844275970Scy for file in $opt_dlopen; do 3845275970Scy test -f "$file" \ 3846316068Sdelphij || func_fatal_help "'$file' is not a file" 3847275970Scy 3848275970Scy dir= 3849275970Scy case $file in 3850275970Scy *.la) 3851275970Scy func_resolve_sysroot "$file" 3852275970Scy file=$func_resolve_sysroot_result 3853275970Scy 3854275970Scy # Check to see that this really is a libtool archive. 3855275970Scy func_lalib_unsafe_p "$file" \ 3856316068Sdelphij || func_fatal_help "'$lib' is not a valid libtool archive" 3857275970Scy 3858275970Scy # Read the libtool library. 3859275970Scy dlname= 3860275970Scy library_names= 3861275970Scy func_source "$file" 3862275970Scy 3863275970Scy # Skip this library if it cannot be dlopened. 3864275970Scy if test -z "$dlname"; then 3865275970Scy # Warn if it was a shared library. 3866275970Scy test -n "$library_names" && \ 3867316068Sdelphij func_warning "'$file' was not linked with '-export-dynamic'" 3868275970Scy continue 3869275970Scy fi 3870275970Scy 3871275970Scy func_dirname "$file" "" "." 3872316068Sdelphij dir=$func_dirname_result 3873275970Scy 3874275970Scy if test -f "$dir/$objdir/$dlname"; then 3875275970Scy func_append dir "/$objdir" 3876275970Scy else 3877275970Scy if test ! -f "$dir/$dlname"; then 3878316068Sdelphij func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879275970Scy fi 3880275970Scy fi 3881275970Scy ;; 3882275970Scy 3883275970Scy *.lo) 3884275970Scy # Just add the directory containing the .lo file. 3885275970Scy func_dirname "$file" "" "." 3886316068Sdelphij dir=$func_dirname_result 3887275970Scy ;; 3888275970Scy 3889275970Scy *) 3890316068Sdelphij func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891275970Scy continue 3892275970Scy ;; 3893275970Scy esac 3894275970Scy 3895275970Scy # Get the absolute pathname. 3896275970Scy absdir=`cd "$dir" && pwd` 3897316068Sdelphij test -n "$absdir" && dir=$absdir 3898275970Scy 3899275970Scy # Now add the directory to shlibpath_var. 3900275970Scy if eval "test -z \"\$$shlibpath_var\""; then 3901275970Scy eval "$shlibpath_var=\"\$dir\"" 3902275970Scy else 3903275970Scy eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904275970Scy fi 3905275970Scy done 3906275970Scy 3907275970Scy # This variable tells wrapper scripts just to set shlibpath_var 3908275970Scy # rather than running their programs. 3909316068Sdelphij libtool_execute_magic=$magic 3910275970Scy 3911275970Scy # Check if any of the arguments is a wrapper script. 3912275970Scy args= 3913275970Scy for file 3914275970Scy do 3915275970Scy case $file in 3916275970Scy -* | *.la | *.lo ) ;; 3917275970Scy *) 3918275970Scy # Do a test to see if this is really a libtool program. 3919275970Scy if func_ltwrapper_script_p "$file"; then 3920275970Scy func_source "$file" 3921275970Scy # Transform arg to wrapped name. 3922316068Sdelphij file=$progdir/$program 3923275970Scy elif func_ltwrapper_executable_p "$file"; then 3924275970Scy func_ltwrapper_scriptname "$file" 3925275970Scy func_source "$func_ltwrapper_scriptname_result" 3926275970Scy # Transform arg to wrapped name. 3927316068Sdelphij file=$progdir/$program 3928275970Scy fi 3929275970Scy ;; 3930275970Scy esac 3931275970Scy # Quote arguments (to preserve shell metacharacters). 3932275970Scy func_append_quoted args "$file" 3933275970Scy done 3934275970Scy 3935316068Sdelphij if $opt_dry_run; then 3936316068Sdelphij # Display what would be done. 3937275970Scy if test -n "$shlibpath_var"; then 3938316068Sdelphij eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939316068Sdelphij echo "export $shlibpath_var" 3940316068Sdelphij fi 3941316068Sdelphij $ECHO "$cmd$args" 3942316068Sdelphij exit $EXIT_SUCCESS 3943316068Sdelphij else 3944316068Sdelphij if test -n "$shlibpath_var"; then 3945275970Scy # Export the shlibpath_var. 3946275970Scy eval "export $shlibpath_var" 3947275970Scy fi 3948275970Scy 3949275970Scy # Restore saved environment variables 3950275970Scy for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951275970Scy do 3952275970Scy eval "if test \"\${save_$lt_var+set}\" = set; then 3953275970Scy $lt_var=\$save_$lt_var; export $lt_var 3954275970Scy else 3955275970Scy $lt_unset $lt_var 3956275970Scy fi" 3957275970Scy done 3958275970Scy 3959275970Scy # Now prepare to actually exec the command. 3960316068Sdelphij exec_cmd=\$cmd$args 3961275970Scy fi 3962275970Scy} 3963275970Scy 3964316068Sdelphijtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965275970Scy 3966275970Scy 3967275970Scy# func_mode_finish arg... 3968275970Scyfunc_mode_finish () 3969275970Scy{ 3970316068Sdelphij $debug_cmd 3971316068Sdelphij 3972275970Scy libs= 3973275970Scy libdirs= 3974275970Scy admincmds= 3975275970Scy 3976275970Scy for opt in "$nonopt" ${1+"$@"} 3977275970Scy do 3978275970Scy if test -d "$opt"; then 3979275970Scy func_append libdirs " $opt" 3980275970Scy 3981275970Scy elif test -f "$opt"; then 3982275970Scy if func_lalib_unsafe_p "$opt"; then 3983275970Scy func_append libs " $opt" 3984275970Scy else 3985316068Sdelphij func_warning "'$opt' is not a valid libtool archive" 3986275970Scy fi 3987275970Scy 3988275970Scy else 3989316068Sdelphij func_fatal_error "invalid argument '$opt'" 3990275970Scy fi 3991275970Scy done 3992275970Scy 3993275970Scy if test -n "$libs"; then 3994275970Scy if test -n "$lt_sysroot"; then 3995275970Scy sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996275970Scy sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997275970Scy else 3998275970Scy sysroot_cmd= 3999275970Scy fi 4000275970Scy 4001275970Scy # Remove sysroot references 4002275970Scy if $opt_dry_run; then 4003275970Scy for lib in $libs; do 4004316068Sdelphij echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005275970Scy done 4006275970Scy else 4007275970Scy tmpdir=`func_mktempdir` 4008275970Scy for lib in $libs; do 4009316068Sdelphij $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010275970Scy > $tmpdir/tmp-la 4011275970Scy mv -f $tmpdir/tmp-la $lib 4012275970Scy done 4013275970Scy ${RM}r "$tmpdir" 4014275970Scy fi 4015275970Scy fi 4016275970Scy 4017275970Scy if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018275970Scy for libdir in $libdirs; do 4019275970Scy if test -n "$finish_cmds"; then 4020275970Scy # Do each command in the finish commands. 4021275970Scy func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022275970Scy'"$cmd"'"' 4023275970Scy fi 4024275970Scy if test -n "$finish_eval"; then 4025275970Scy # Do the single finish_eval. 4026275970Scy eval cmds=\"$finish_eval\" 4027275970Scy $opt_dry_run || eval "$cmds" || func_append admincmds " 4028275970Scy $cmds" 4029275970Scy fi 4030275970Scy done 4031275970Scy fi 4032275970Scy 4033275970Scy # Exit here if they wanted silent mode. 4034316068Sdelphij $opt_quiet && exit $EXIT_SUCCESS 4035275970Scy 4036275970Scy if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037275970Scy echo "----------------------------------------------------------------------" 4038275970Scy echo "Libraries have been installed in:" 4039275970Scy for libdir in $libdirs; do 4040275970Scy $ECHO " $libdir" 4041275970Scy done 4042275970Scy echo 4043275970Scy echo "If you ever happen to want to link against installed libraries" 4044275970Scy echo "in a given directory, LIBDIR, you must either use libtool, and" 4045316068Sdelphij echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046275970Scy echo "flag during linking and do at least one of the following:" 4047275970Scy if test -n "$shlibpath_var"; then 4048316068Sdelphij echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049275970Scy echo " during execution" 4050275970Scy fi 4051275970Scy if test -n "$runpath_var"; then 4052316068Sdelphij echo " - add LIBDIR to the '$runpath_var' environment variable" 4053275970Scy echo " during linking" 4054275970Scy fi 4055275970Scy if test -n "$hardcode_libdir_flag_spec"; then 4056275970Scy libdir=LIBDIR 4057275970Scy eval flag=\"$hardcode_libdir_flag_spec\" 4058275970Scy 4059316068Sdelphij $ECHO " - use the '$flag' linker flag" 4060275970Scy fi 4061275970Scy if test -n "$admincmds"; then 4062275970Scy $ECHO " - have your system administrator run these commands:$admincmds" 4063275970Scy fi 4064275970Scy if test -f /etc/ld.so.conf; then 4065316068Sdelphij echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066275970Scy fi 4067275970Scy echo 4068275970Scy 4069275970Scy echo "See any operating system documentation about shared libraries for" 4070275970Scy case $host in 4071275970Scy solaris2.[6789]|solaris2.1[0-9]) 4072275970Scy echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073275970Scy echo "pages." 4074275970Scy ;; 4075275970Scy *) 4076275970Scy echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077275970Scy ;; 4078275970Scy esac 4079275970Scy echo "----------------------------------------------------------------------" 4080275970Scy fi 4081275970Scy exit $EXIT_SUCCESS 4082275970Scy} 4083275970Scy 4084316068Sdelphijtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085275970Scy 4086275970Scy 4087275970Scy# func_mode_install arg... 4088275970Scyfunc_mode_install () 4089275970Scy{ 4090316068Sdelphij $debug_cmd 4091316068Sdelphij 4092275970Scy # There may be an optional sh(1) argument at the beginning of 4093275970Scy # install_prog (especially on Windows NT). 4094316068Sdelphij if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095275970Scy # Allow the use of GNU shtool's install command. 4096316068Sdelphij case $nonopt in *shtool*) :;; *) false;; esac 4097316068Sdelphij then 4098275970Scy # Aesthetically quote it. 4099275970Scy func_quote_for_eval "$nonopt" 4100275970Scy install_prog="$func_quote_for_eval_result " 4101275970Scy arg=$1 4102275970Scy shift 4103275970Scy else 4104275970Scy install_prog= 4105275970Scy arg=$nonopt 4106275970Scy fi 4107275970Scy 4108275970Scy # The real first argument should be the name of the installation program. 4109275970Scy # Aesthetically quote it. 4110275970Scy func_quote_for_eval "$arg" 4111275970Scy func_append install_prog "$func_quote_for_eval_result" 4112275970Scy install_shared_prog=$install_prog 4113275970Scy case " $install_prog " in 4114275970Scy *[\\\ /]cp\ *) install_cp=: ;; 4115275970Scy *) install_cp=false ;; 4116275970Scy esac 4117275970Scy 4118275970Scy # We need to accept at least all the BSD install flags. 4119275970Scy dest= 4120275970Scy files= 4121275970Scy opts= 4122275970Scy prev= 4123275970Scy install_type= 4124316068Sdelphij isdir=false 4125275970Scy stripme= 4126275970Scy no_mode=: 4127275970Scy for arg 4128275970Scy do 4129275970Scy arg2= 4130275970Scy if test -n "$dest"; then 4131275970Scy func_append files " $dest" 4132275970Scy dest=$arg 4133275970Scy continue 4134275970Scy fi 4135275970Scy 4136275970Scy case $arg in 4137316068Sdelphij -d) isdir=: ;; 4138275970Scy -f) 4139275970Scy if $install_cp; then :; else 4140275970Scy prev=$arg 4141275970Scy fi 4142275970Scy ;; 4143275970Scy -g | -m | -o) 4144275970Scy prev=$arg 4145275970Scy ;; 4146275970Scy -s) 4147275970Scy stripme=" -s" 4148275970Scy continue 4149275970Scy ;; 4150275970Scy -*) 4151275970Scy ;; 4152275970Scy *) 4153275970Scy # If the previous option needed an argument, then skip it. 4154275970Scy if test -n "$prev"; then 4155316068Sdelphij if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156275970Scy arg2=$install_override_mode 4157275970Scy no_mode=false 4158275970Scy fi 4159275970Scy prev= 4160275970Scy else 4161275970Scy dest=$arg 4162275970Scy continue 4163275970Scy fi 4164275970Scy ;; 4165275970Scy esac 4166275970Scy 4167275970Scy # Aesthetically quote the argument. 4168275970Scy func_quote_for_eval "$arg" 4169275970Scy func_append install_prog " $func_quote_for_eval_result" 4170275970Scy if test -n "$arg2"; then 4171275970Scy func_quote_for_eval "$arg2" 4172275970Scy fi 4173275970Scy func_append install_shared_prog " $func_quote_for_eval_result" 4174275970Scy done 4175275970Scy 4176275970Scy test -z "$install_prog" && \ 4177275970Scy func_fatal_help "you must specify an install program" 4178275970Scy 4179275970Scy test -n "$prev" && \ 4180316068Sdelphij func_fatal_help "the '$prev' option requires an argument" 4181275970Scy 4182275970Scy if test -n "$install_override_mode" && $no_mode; then 4183275970Scy if $install_cp; then :; else 4184275970Scy func_quote_for_eval "$install_override_mode" 4185275970Scy func_append install_shared_prog " -m $func_quote_for_eval_result" 4186275970Scy fi 4187275970Scy fi 4188275970Scy 4189275970Scy if test -z "$files"; then 4190275970Scy if test -z "$dest"; then 4191275970Scy func_fatal_help "no file or destination specified" 4192275970Scy else 4193275970Scy func_fatal_help "you must specify a destination" 4194275970Scy fi 4195275970Scy fi 4196275970Scy 4197275970Scy # Strip any trailing slash from the destination. 4198275970Scy func_stripname '' '/' "$dest" 4199275970Scy dest=$func_stripname_result 4200275970Scy 4201275970Scy # Check to see that the destination is a directory. 4202316068Sdelphij test -d "$dest" && isdir=: 4203316068Sdelphij if $isdir; then 4204316068Sdelphij destdir=$dest 4205275970Scy destname= 4206275970Scy else 4207275970Scy func_dirname_and_basename "$dest" "" "." 4208316068Sdelphij destdir=$func_dirname_result 4209316068Sdelphij destname=$func_basename_result 4210275970Scy 4211275970Scy # Not a directory, so check to see that there is only one file specified. 4212275970Scy set dummy $files; shift 4213275970Scy test "$#" -gt 1 && \ 4214316068Sdelphij func_fatal_help "'$dest' is not a directory" 4215275970Scy fi 4216275970Scy case $destdir in 4217275970Scy [\\/]* | [A-Za-z]:[\\/]*) ;; 4218275970Scy *) 4219275970Scy for file in $files; do 4220275970Scy case $file in 4221275970Scy *.lo) ;; 4222275970Scy *) 4223316068Sdelphij func_fatal_help "'$destdir' must be an absolute directory name" 4224275970Scy ;; 4225275970Scy esac 4226275970Scy done 4227275970Scy ;; 4228275970Scy esac 4229275970Scy 4230275970Scy # This variable tells wrapper scripts just to set variables rather 4231275970Scy # than running their programs. 4232316068Sdelphij libtool_install_magic=$magic 4233275970Scy 4234275970Scy staticlibs= 4235275970Scy future_libdirs= 4236275970Scy current_libdirs= 4237275970Scy for file in $files; do 4238275970Scy 4239275970Scy # Do each installation. 4240275970Scy case $file in 4241275970Scy *.$libext) 4242275970Scy # Do the static libraries later. 4243275970Scy func_append staticlibs " $file" 4244275970Scy ;; 4245275970Scy 4246275970Scy *.la) 4247275970Scy func_resolve_sysroot "$file" 4248275970Scy file=$func_resolve_sysroot_result 4249275970Scy 4250275970Scy # Check to see that this really is a libtool archive. 4251275970Scy func_lalib_unsafe_p "$file" \ 4252316068Sdelphij || func_fatal_help "'$file' is not a valid libtool archive" 4253275970Scy 4254275970Scy library_names= 4255275970Scy old_library= 4256275970Scy relink_command= 4257275970Scy func_source "$file" 4258275970Scy 4259275970Scy # Add the libdir to current_libdirs if it is the destination. 4260275970Scy if test "X$destdir" = "X$libdir"; then 4261275970Scy case "$current_libdirs " in 4262275970Scy *" $libdir "*) ;; 4263275970Scy *) func_append current_libdirs " $libdir" ;; 4264275970Scy esac 4265275970Scy else 4266275970Scy # Note the libdir as a future libdir. 4267275970Scy case "$future_libdirs " in 4268275970Scy *" $libdir "*) ;; 4269275970Scy *) func_append future_libdirs " $libdir" ;; 4270275970Scy esac 4271275970Scy fi 4272275970Scy 4273275970Scy func_dirname "$file" "/" "" 4274316068Sdelphij dir=$func_dirname_result 4275275970Scy func_append dir "$objdir" 4276275970Scy 4277275970Scy if test -n "$relink_command"; then 4278275970Scy # Determine the prefix the user has applied to our future dir. 4279275970Scy inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280275970Scy 4281275970Scy # Don't allow the user to place us outside of our expected 4282275970Scy # location b/c this prevents finding dependent libraries that 4283275970Scy # are installed to the same prefix. 4284275970Scy # At present, this check doesn't affect windows .dll's that 4285275970Scy # are installed into $libdir/../bin (currently, that works fine) 4286275970Scy # but it's something to keep an eye on. 4287275970Scy test "$inst_prefix_dir" = "$destdir" && \ 4288316068Sdelphij func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289275970Scy 4290275970Scy if test -n "$inst_prefix_dir"; then 4291275970Scy # Stick the inst_prefix_dir data into the link command. 4292275970Scy relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293275970Scy else 4294275970Scy relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295275970Scy fi 4296275970Scy 4297316068Sdelphij func_warning "relinking '$file'" 4298275970Scy func_show_eval "$relink_command" \ 4299316068Sdelphij 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300275970Scy fi 4301275970Scy 4302275970Scy # See the names of the shared library. 4303275970Scy set dummy $library_names; shift 4304275970Scy if test -n "$1"; then 4305316068Sdelphij realname=$1 4306275970Scy shift 4307275970Scy 4308316068Sdelphij srcname=$realname 4309316068Sdelphij test -n "$relink_command" && srcname=${realname}T 4310275970Scy 4311275970Scy # Install the shared library and build the symlinks. 4312275970Scy func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313275970Scy 'exit $?' 4314316068Sdelphij tstripme=$stripme 4315275970Scy case $host_os in 4316275970Scy cygwin* | mingw* | pw32* | cegcc*) 4317275970Scy case $realname in 4318275970Scy *.dll.a) 4319316068Sdelphij tstripme= 4320275970Scy ;; 4321275970Scy esac 4322275970Scy ;; 4323316068Sdelphij os2*) 4324316068Sdelphij case $realname in 4325316068Sdelphij *_dll.a) 4326316068Sdelphij tstripme= 4327316068Sdelphij ;; 4328316068Sdelphij esac 4329316068Sdelphij ;; 4330275970Scy esac 4331275970Scy if test -n "$tstripme" && test -n "$striplib"; then 4332275970Scy func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333275970Scy fi 4334275970Scy 4335275970Scy if test "$#" -gt 0; then 4336275970Scy # Delete the old symlinks, and create new ones. 4337316068Sdelphij # Try 'ln -sf' first, because the 'ln' binary might depend on 4338275970Scy # the symlink we replace! Solaris /bin/ln does not understand -f, 4339275970Scy # so we also need to try rm && ln -s. 4340275970Scy for linkname 4341275970Scy do 4342275970Scy test "$linkname" != "$realname" \ 4343275970Scy && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344275970Scy done 4345275970Scy fi 4346275970Scy 4347275970Scy # Do each command in the postinstall commands. 4348316068Sdelphij lib=$destdir/$realname 4349275970Scy func_execute_cmds "$postinstall_cmds" 'exit $?' 4350275970Scy fi 4351275970Scy 4352275970Scy # Install the pseudo-library for information purposes. 4353275970Scy func_basename "$file" 4354316068Sdelphij name=$func_basename_result 4355316068Sdelphij instname=$dir/${name}i 4356275970Scy func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357275970Scy 4358275970Scy # Maybe install the static library, too. 4359275970Scy test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360275970Scy ;; 4361275970Scy 4362275970Scy *.lo) 4363275970Scy # Install (i.e. copy) a libtool object. 4364275970Scy 4365275970Scy # Figure out destination file name, if it wasn't already specified. 4366275970Scy if test -n "$destname"; then 4367316068Sdelphij destfile=$destdir/$destname 4368275970Scy else 4369275970Scy func_basename "$file" 4370316068Sdelphij destfile=$func_basename_result 4371316068Sdelphij destfile=$destdir/$destfile 4372275970Scy fi 4373275970Scy 4374275970Scy # Deduce the name of the destination old-style object file. 4375275970Scy case $destfile in 4376275970Scy *.lo) 4377275970Scy func_lo2o "$destfile" 4378275970Scy staticdest=$func_lo2o_result 4379275970Scy ;; 4380275970Scy *.$objext) 4381316068Sdelphij staticdest=$destfile 4382275970Scy destfile= 4383275970Scy ;; 4384275970Scy *) 4385316068Sdelphij func_fatal_help "cannot copy a libtool object to '$destfile'" 4386275970Scy ;; 4387275970Scy esac 4388275970Scy 4389275970Scy # Install the libtool object if requested. 4390275970Scy test -n "$destfile" && \ 4391275970Scy func_show_eval "$install_prog $file $destfile" 'exit $?' 4392275970Scy 4393275970Scy # Install the old object if enabled. 4394316068Sdelphij if test yes = "$build_old_libs"; then 4395275970Scy # Deduce the name of the old-style object file. 4396275970Scy func_lo2o "$file" 4397275970Scy staticobj=$func_lo2o_result 4398275970Scy func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399275970Scy fi 4400275970Scy exit $EXIT_SUCCESS 4401275970Scy ;; 4402275970Scy 4403275970Scy *) 4404275970Scy # Figure out destination file name, if it wasn't already specified. 4405275970Scy if test -n "$destname"; then 4406316068Sdelphij destfile=$destdir/$destname 4407275970Scy else 4408275970Scy func_basename "$file" 4409316068Sdelphij destfile=$func_basename_result 4410316068Sdelphij destfile=$destdir/$destfile 4411275970Scy fi 4412275970Scy 4413275970Scy # If the file is missing, and there is a .exe on the end, strip it 4414275970Scy # because it is most likely a libtool script we actually want to 4415275970Scy # install 4416316068Sdelphij stripped_ext= 4417275970Scy case $file in 4418275970Scy *.exe) 4419275970Scy if test ! -f "$file"; then 4420275970Scy func_stripname '' '.exe' "$file" 4421275970Scy file=$func_stripname_result 4422316068Sdelphij stripped_ext=.exe 4423275970Scy fi 4424275970Scy ;; 4425275970Scy esac 4426275970Scy 4427275970Scy # Do a test to see if this is really a libtool program. 4428275970Scy case $host in 4429275970Scy *cygwin* | *mingw*) 4430275970Scy if func_ltwrapper_executable_p "$file"; then 4431275970Scy func_ltwrapper_scriptname "$file" 4432275970Scy wrapper=$func_ltwrapper_scriptname_result 4433275970Scy else 4434275970Scy func_stripname '' '.exe' "$file" 4435275970Scy wrapper=$func_stripname_result 4436275970Scy fi 4437275970Scy ;; 4438275970Scy *) 4439275970Scy wrapper=$file 4440275970Scy ;; 4441275970Scy esac 4442275970Scy if func_ltwrapper_script_p "$wrapper"; then 4443275970Scy notinst_deplibs= 4444275970Scy relink_command= 4445275970Scy 4446275970Scy func_source "$wrapper" 4447275970Scy 4448275970Scy # Check the variables that should have been set. 4449275970Scy test -z "$generated_by_libtool_version" && \ 4450316068Sdelphij func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451275970Scy 4452316068Sdelphij finalize=: 4453275970Scy for lib in $notinst_deplibs; do 4454275970Scy # Check to see that each library is installed. 4455275970Scy libdir= 4456275970Scy if test -f "$lib"; then 4457275970Scy func_source "$lib" 4458275970Scy fi 4459316068Sdelphij libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460275970Scy if test -n "$libdir" && test ! -f "$libfile"; then 4461316068Sdelphij func_warning "'$lib' has not been installed in '$libdir'" 4462316068Sdelphij finalize=false 4463275970Scy fi 4464275970Scy done 4465275970Scy 4466275970Scy relink_command= 4467275970Scy func_source "$wrapper" 4468275970Scy 4469275970Scy outputname= 4470316068Sdelphij if test no = "$fast_install" && test -n "$relink_command"; then 4471275970Scy $opt_dry_run || { 4472316068Sdelphij if $finalize; then 4473275970Scy tmpdir=`func_mktempdir` 4474275970Scy func_basename "$file$stripped_ext" 4475316068Sdelphij file=$func_basename_result 4476316068Sdelphij outputname=$tmpdir/$file 4477275970Scy # Replace the output file specification. 4478275970Scy relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479275970Scy 4480316068Sdelphij $opt_quiet || { 4481275970Scy func_quote_for_expand "$relink_command" 4482275970Scy eval "func_echo $func_quote_for_expand_result" 4483275970Scy } 4484275970Scy if eval "$relink_command"; then : 4485275970Scy else 4486316068Sdelphij func_error "error: relink '$file' with the above command before installing it" 4487275970Scy $opt_dry_run || ${RM}r "$tmpdir" 4488275970Scy continue 4489275970Scy fi 4490316068Sdelphij file=$outputname 4491275970Scy else 4492316068Sdelphij func_warning "cannot relink '$file'" 4493275970Scy fi 4494275970Scy } 4495275970Scy else 4496275970Scy # Install the binary that we compiled earlier. 4497275970Scy file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498275970Scy fi 4499275970Scy fi 4500275970Scy 4501275970Scy # remove .exe since cygwin /usr/bin/install will append another 4502275970Scy # one anyway 4503275970Scy case $install_prog,$host in 4504275970Scy */usr/bin/install*,*cygwin*) 4505275970Scy case $file:$destfile in 4506275970Scy *.exe:*.exe) 4507275970Scy # this is ok 4508275970Scy ;; 4509275970Scy *.exe:*) 4510275970Scy destfile=$destfile.exe 4511275970Scy ;; 4512275970Scy *:*.exe) 4513275970Scy func_stripname '' '.exe' "$destfile" 4514275970Scy destfile=$func_stripname_result 4515275970Scy ;; 4516275970Scy esac 4517275970Scy ;; 4518275970Scy esac 4519275970Scy func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520275970Scy $opt_dry_run || if test -n "$outputname"; then 4521275970Scy ${RM}r "$tmpdir" 4522275970Scy fi 4523275970Scy ;; 4524275970Scy esac 4525275970Scy done 4526275970Scy 4527275970Scy for file in $staticlibs; do 4528275970Scy func_basename "$file" 4529316068Sdelphij name=$func_basename_result 4530275970Scy 4531275970Scy # Set up the ranlib parameters. 4532316068Sdelphij oldlib=$destdir/$name 4533285169Scy func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534285169Scy tool_oldlib=$func_to_tool_file_result 4535275970Scy 4536275970Scy func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537275970Scy 4538275970Scy if test -n "$stripme" && test -n "$old_striplib"; then 4539285169Scy func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540275970Scy fi 4541275970Scy 4542275970Scy # Do each command in the postinstall commands. 4543275970Scy func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544275970Scy done 4545275970Scy 4546275970Scy test -n "$future_libdirs" && \ 4547316068Sdelphij func_warning "remember to run '$progname --finish$future_libdirs'" 4548275970Scy 4549275970Scy if test -n "$current_libdirs"; then 4550275970Scy # Maybe just do a dry run. 4551275970Scy $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552316068Sdelphij exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553275970Scy else 4554275970Scy exit $EXIT_SUCCESS 4555275970Scy fi 4556275970Scy} 4557275970Scy 4558316068Sdelphijtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559275970Scy 4560275970Scy 4561275970Scy# func_generate_dlsyms outputname originator pic_p 4562275970Scy# Extract symbols from dlprefiles and create ${outputname}S.o with 4563275970Scy# a dlpreopen symbol table. 4564275970Scyfunc_generate_dlsyms () 4565275970Scy{ 4566316068Sdelphij $debug_cmd 4567316068Sdelphij 4568316068Sdelphij my_outputname=$1 4569316068Sdelphij my_originator=$2 4570316068Sdelphij my_pic_p=${3-false} 4571316068Sdelphij my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572275970Scy my_dlsyms= 4573275970Scy 4574316068Sdelphij if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575275970Scy if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576316068Sdelphij my_dlsyms=${my_outputname}S.c 4577275970Scy else 4578275970Scy func_error "not configured to extract global symbols from dlpreopened files" 4579275970Scy fi 4580275970Scy fi 4581275970Scy 4582275970Scy if test -n "$my_dlsyms"; then 4583275970Scy case $my_dlsyms in 4584275970Scy "") ;; 4585275970Scy *.c) 4586275970Scy # Discover the nlist of each of the dlfiles. 4587316068Sdelphij nlist=$output_objdir/$my_outputname.nm 4588275970Scy 4589275970Scy func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590275970Scy 4591275970Scy # Parse the name list into a source file. 4592275970Scy func_verbose "creating $output_objdir/$my_dlsyms" 4593275970Scy 4594275970Scy $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595316068Sdelphij/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596316068Sdelphij/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597275970Scy 4598275970Scy#ifdef __cplusplus 4599275970Scyextern \"C\" { 4600275970Scy#endif 4601275970Scy 4602316068Sdelphij#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603275970Scy#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604275970Scy#endif 4605275970Scy 4606275970Scy/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607316068Sdelphij#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608316068Sdelphij/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609275970Scy relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610275970Scy# define LT_DLSYM_CONST 4611316068Sdelphij#elif defined __osf__ 4612275970Scy/* This system does not cope well with relocations in const data. */ 4613275970Scy# define LT_DLSYM_CONST 4614275970Scy#else 4615275970Scy# define LT_DLSYM_CONST const 4616275970Scy#endif 4617275970Scy 4618316068Sdelphij#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619316068Sdelphij 4620275970Scy/* External symbol declarations for the compiler. */\ 4621275970Scy" 4622275970Scy 4623316068Sdelphij if test yes = "$dlself"; then 4624316068Sdelphij func_verbose "generating symbol list for '$output'" 4625275970Scy 4626275970Scy $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627275970Scy 4628275970Scy # Add our own program objects to the symbol list. 4629275970Scy progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630275970Scy for progfile in $progfiles; do 4631275970Scy func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632316068Sdelphij func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633275970Scy $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634275970Scy done 4635275970Scy 4636275970Scy if test -n "$exclude_expsyms"; then 4637275970Scy $opt_dry_run || { 4638275970Scy eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639275970Scy eval '$MV "$nlist"T "$nlist"' 4640275970Scy } 4641275970Scy fi 4642275970Scy 4643275970Scy if test -n "$export_symbols_regex"; then 4644275970Scy $opt_dry_run || { 4645275970Scy eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646275970Scy eval '$MV "$nlist"T "$nlist"' 4647275970Scy } 4648275970Scy fi 4649275970Scy 4650275970Scy # Prepare the list of exported symbols 4651275970Scy if test -z "$export_symbols"; then 4652316068Sdelphij export_symbols=$output_objdir/$outputname.exp 4653275970Scy $opt_dry_run || { 4654275970Scy $RM $export_symbols 4655316068Sdelphij eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656275970Scy case $host in 4657275970Scy *cygwin* | *mingw* | *cegcc* ) 4658275970Scy eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659275970Scy eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660275970Scy ;; 4661275970Scy esac 4662275970Scy } 4663275970Scy else 4664275970Scy $opt_dry_run || { 4665316068Sdelphij eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666275970Scy eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667275970Scy eval '$MV "$nlist"T "$nlist"' 4668275970Scy case $host in 4669275970Scy *cygwin* | *mingw* | *cegcc* ) 4670275970Scy eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671275970Scy eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672275970Scy ;; 4673275970Scy esac 4674275970Scy } 4675275970Scy fi 4676275970Scy fi 4677275970Scy 4678275970Scy for dlprefile in $dlprefiles; do 4679316068Sdelphij func_verbose "extracting global C symbols from '$dlprefile'" 4680275970Scy func_basename "$dlprefile" 4681316068Sdelphij name=$func_basename_result 4682275970Scy case $host in 4683275970Scy *cygwin* | *mingw* | *cegcc* ) 4684275970Scy # if an import library, we need to obtain dlname 4685275970Scy if func_win32_import_lib_p "$dlprefile"; then 4686275970Scy func_tr_sh "$dlprefile" 4687275970Scy eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688316068Sdelphij dlprefile_dlbasename= 4689275970Scy if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690275970Scy # Use subshell, to avoid clobbering current variable values 4691275970Scy dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692316068Sdelphij if test -n "$dlprefile_dlname"; then 4693275970Scy func_basename "$dlprefile_dlname" 4694316068Sdelphij dlprefile_dlbasename=$func_basename_result 4695275970Scy else 4696275970Scy # no lafile. user explicitly requested -dlpreopen <import library>. 4697275970Scy $sharedlib_from_linklib_cmd "$dlprefile" 4698275970Scy dlprefile_dlbasename=$sharedlib_from_linklib_result 4699275970Scy fi 4700275970Scy fi 4701275970Scy $opt_dry_run || { 4702316068Sdelphij if test -n "$dlprefile_dlbasename"; then 4703275970Scy eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704275970Scy else 4705275970Scy func_warning "Could not compute DLL name from $name" 4706275970Scy eval '$ECHO ": $name " >> "$nlist"' 4707275970Scy fi 4708275970Scy func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709275970Scy eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710275970Scy $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711275970Scy } 4712275970Scy else # not an import lib 4713275970Scy $opt_dry_run || { 4714275970Scy eval '$ECHO ": $name " >> "$nlist"' 4715275970Scy func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716275970Scy eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717275970Scy } 4718275970Scy fi 4719275970Scy ;; 4720275970Scy *) 4721275970Scy $opt_dry_run || { 4722275970Scy eval '$ECHO ": $name " >> "$nlist"' 4723275970Scy func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724275970Scy eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725275970Scy } 4726275970Scy ;; 4727275970Scy esac 4728275970Scy done 4729275970Scy 4730275970Scy $opt_dry_run || { 4731275970Scy # Make sure we have at least an empty file. 4732275970Scy test -f "$nlist" || : > "$nlist" 4733275970Scy 4734275970Scy if test -n "$exclude_expsyms"; then 4735275970Scy $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736275970Scy $MV "$nlist"T "$nlist" 4737275970Scy fi 4738275970Scy 4739275970Scy # Try sorting and uniquifying the output. 4740275970Scy if $GREP -v "^: " < "$nlist" | 4741275970Scy if sort -k 3 </dev/null >/dev/null 2>&1; then 4742275970Scy sort -k 3 4743275970Scy else 4744275970Scy sort +2 4745275970Scy fi | 4746275970Scy uniq > "$nlist"S; then 4747275970Scy : 4748275970Scy else 4749275970Scy $GREP -v "^: " < "$nlist" > "$nlist"S 4750275970Scy fi 4751275970Scy 4752275970Scy if test -f "$nlist"S; then 4753275970Scy eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754275970Scy else 4755275970Scy echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756275970Scy fi 4757275970Scy 4758316068Sdelphij func_show_eval '$RM "${nlist}I"' 4759316068Sdelphij if test -n "$global_symbol_to_import"; then 4760316068Sdelphij eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761316068Sdelphij fi 4762316068Sdelphij 4763275970Scy echo >> "$output_objdir/$my_dlsyms" "\ 4764275970Scy 4765275970Scy/* The mapping between symbol names and symbols. */ 4766275970Scytypedef struct { 4767275970Scy const char *name; 4768275970Scy void *address; 4769275970Scy} lt_dlsymlist; 4770275970Scyextern LT_DLSYM_CONST lt_dlsymlist 4771316068Sdelphijlt_${my_prefix}_LTX_preloaded_symbols[];\ 4772316068Sdelphij" 4773316068Sdelphij 4774316068Sdelphij if test -s "$nlist"I; then 4775316068Sdelphij echo >> "$output_objdir/$my_dlsyms" "\ 4776316068Sdelphijstatic void lt_syminit(void) 4777316068Sdelphij{ 4778316068Sdelphij LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779316068Sdelphij for (; symbol->name; ++symbol) 4780316068Sdelphij {" 4781316068Sdelphij $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782316068Sdelphij echo >> "$output_objdir/$my_dlsyms" "\ 4783316068Sdelphij } 4784316068Sdelphij}" 4785316068Sdelphij fi 4786316068Sdelphij echo >> "$output_objdir/$my_dlsyms" "\ 4787275970ScyLT_DLSYM_CONST lt_dlsymlist 4788275970Scylt_${my_prefix}_LTX_preloaded_symbols[] = 4789316068Sdelphij{ {\"$my_originator\", (void *) 0}," 4790275970Scy 4791316068Sdelphij if test -s "$nlist"I; then 4792316068Sdelphij echo >> "$output_objdir/$my_dlsyms" "\ 4793316068Sdelphij {\"@INIT@\", (void *) <_syminit}," 4794316068Sdelphij fi 4795316068Sdelphij 4796275970Scy case $need_lib_prefix in 4797275970Scy no) 4798275970Scy eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799275970Scy ;; 4800275970Scy *) 4801275970Scy eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802275970Scy ;; 4803275970Scy esac 4804275970Scy echo >> "$output_objdir/$my_dlsyms" "\ 4805275970Scy {0, (void *) 0} 4806275970Scy}; 4807275970Scy 4808275970Scy/* This works around a problem in FreeBSD linker */ 4809275970Scy#ifdef FREEBSD_WORKAROUND 4810275970Scystatic const void *lt_preloaded_setup() { 4811275970Scy return lt_${my_prefix}_LTX_preloaded_symbols; 4812275970Scy} 4813275970Scy#endif 4814275970Scy 4815275970Scy#ifdef __cplusplus 4816275970Scy} 4817275970Scy#endif\ 4818275970Scy" 4819275970Scy } # !$opt_dry_run 4820275970Scy 4821275970Scy pic_flag_for_symtable= 4822275970Scy case "$compile_command " in 4823275970Scy *" -static "*) ;; 4824275970Scy *) 4825275970Scy case $host in 4826275970Scy # compiling the symbol table file with pic_flag works around 4827275970Scy # a FreeBSD bug that causes programs to crash when -lm is 4828275970Scy # linked before any other PIC object. But we must not use 4829275970Scy # pic_flag when linking with -static. The problem exists in 4830275970Scy # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831285169Scy *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832275970Scy pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833275970Scy *-*-hpux*) 4834275970Scy pic_flag_for_symtable=" $pic_flag" ;; 4835275970Scy *) 4836316068Sdelphij $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837275970Scy ;; 4838275970Scy esac 4839275970Scy ;; 4840275970Scy esac 4841275970Scy symtab_cflags= 4842275970Scy for arg in $LTCFLAGS; do 4843275970Scy case $arg in 4844275970Scy -pie | -fpie | -fPIE) ;; 4845275970Scy *) func_append symtab_cflags " $arg" ;; 4846275970Scy esac 4847275970Scy done 4848275970Scy 4849275970Scy # Now compile the dynamic symbol file. 4850275970Scy func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851275970Scy 4852275970Scy # Clean up the generated files. 4853316068Sdelphij func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854275970Scy 4855275970Scy # Transform the symbol file into the correct name. 4856316068Sdelphij symfileobj=$output_objdir/${my_outputname}S.$objext 4857275970Scy case $host in 4858275970Scy *cygwin* | *mingw* | *cegcc* ) 4859275970Scy if test -f "$output_objdir/$my_outputname.def"; then 4860275970Scy compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861275970Scy finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862275970Scy else 4863275970Scy compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864275970Scy finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865275970Scy fi 4866275970Scy ;; 4867275970Scy *) 4868275970Scy compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869275970Scy finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870275970Scy ;; 4871275970Scy esac 4872275970Scy ;; 4873275970Scy *) 4874316068Sdelphij func_fatal_error "unknown suffix for '$my_dlsyms'" 4875275970Scy ;; 4876275970Scy esac 4877275970Scy else 4878275970Scy # We keep going just in case the user didn't refer to 4879275970Scy # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880275970Scy # really was required. 4881275970Scy 4882275970Scy # Nullify the symbol file. 4883275970Scy compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884275970Scy finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885275970Scy fi 4886275970Scy} 4887275970Scy 4888316068Sdelphij# func_cygming_gnu_implib_p ARG 4889316068Sdelphij# This predicate returns with zero status (TRUE) if 4890316068Sdelphij# ARG is a GNU/binutils-style import library. Returns 4891316068Sdelphij# with nonzero status (FALSE) otherwise. 4892316068Sdelphijfunc_cygming_gnu_implib_p () 4893316068Sdelphij{ 4894316068Sdelphij $debug_cmd 4895316068Sdelphij 4896316068Sdelphij func_to_tool_file "$1" func_convert_file_msys_to_w32 4897316068Sdelphij 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)$'` 4898316068Sdelphij test -n "$func_cygming_gnu_implib_tmp" 4899316068Sdelphij} 4900316068Sdelphij 4901316068Sdelphij# func_cygming_ms_implib_p ARG 4902316068Sdelphij# This predicate returns with zero status (TRUE) if 4903316068Sdelphij# ARG is an MS-style import library. Returns 4904316068Sdelphij# with nonzero status (FALSE) otherwise. 4905316068Sdelphijfunc_cygming_ms_implib_p () 4906316068Sdelphij{ 4907316068Sdelphij $debug_cmd 4908316068Sdelphij 4909316068Sdelphij func_to_tool_file "$1" func_convert_file_msys_to_w32 4910316068Sdelphij func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911316068Sdelphij test -n "$func_cygming_ms_implib_tmp" 4912316068Sdelphij} 4913316068Sdelphij 4914275970Scy# func_win32_libid arg 4915275970Scy# return the library type of file 'arg' 4916275970Scy# 4917275970Scy# Need a lot of goo to handle *both* DLLs and import libs 4918275970Scy# Has to be a shell function in order to 'eat' the argument 4919275970Scy# that is supplied when $file_magic_command is called. 4920275970Scy# Despite the name, also deal with 64 bit binaries. 4921275970Scyfunc_win32_libid () 4922275970Scy{ 4923316068Sdelphij $debug_cmd 4924316068Sdelphij 4925316068Sdelphij win32_libid_type=unknown 4926275970Scy win32_fileres=`file -L $1 2>/dev/null` 4927275970Scy case $win32_fileres in 4928275970Scy *ar\ archive\ import\ library*) # definitely import 4929275970Scy win32_libid_type="x86 archive import" 4930275970Scy ;; 4931275970Scy *ar\ archive*) # could be an import, or static 4932275970Scy # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933275970Scy if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934275970Scy $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935316068Sdelphij case $nm_interface in 4936316068Sdelphij "MS dumpbin") 4937316068Sdelphij if func_cygming_ms_implib_p "$1" || 4938316068Sdelphij func_cygming_gnu_implib_p "$1" 4939316068Sdelphij then 4940316068Sdelphij win32_nmres=import 4941316068Sdelphij else 4942316068Sdelphij win32_nmres= 4943316068Sdelphij fi 4944316068Sdelphij ;; 4945316068Sdelphij *) 4946316068Sdelphij func_to_tool_file "$1" func_convert_file_msys_to_w32 4947316068Sdelphij win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948316068Sdelphij $SED -n -e ' 4949275970Scy 1,100{ 4950275970Scy / I /{ 4951316068Sdelphij s|.*|import| 4952275970Scy p 4953275970Scy q 4954275970Scy } 4955275970Scy }'` 4956316068Sdelphij ;; 4957316068Sdelphij esac 4958275970Scy case $win32_nmres in 4959275970Scy import*) win32_libid_type="x86 archive import";; 4960275970Scy *) win32_libid_type="x86 archive static";; 4961275970Scy esac 4962275970Scy fi 4963275970Scy ;; 4964275970Scy *DLL*) 4965275970Scy win32_libid_type="x86 DLL" 4966275970Scy ;; 4967275970Scy *executable*) # but shell scripts are "executable" too... 4968275970Scy case $win32_fileres in 4969275970Scy *MS\ Windows\ PE\ Intel*) 4970275970Scy win32_libid_type="x86 DLL" 4971275970Scy ;; 4972275970Scy esac 4973275970Scy ;; 4974275970Scy esac 4975275970Scy $ECHO "$win32_libid_type" 4976275970Scy} 4977275970Scy 4978275970Scy# func_cygming_dll_for_implib ARG 4979275970Scy# 4980275970Scy# Platform-specific function to extract the 4981275970Scy# name of the DLL associated with the specified 4982275970Scy# import library ARG. 4983275970Scy# Invoked by eval'ing the libtool variable 4984275970Scy# $sharedlib_from_linklib_cmd 4985275970Scy# Result is available in the variable 4986275970Scy# $sharedlib_from_linklib_result 4987275970Scyfunc_cygming_dll_for_implib () 4988275970Scy{ 4989316068Sdelphij $debug_cmd 4990316068Sdelphij 4991275970Scy sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992275970Scy} 4993275970Scy 4994275970Scy# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995275970Scy# 4996275970Scy# The is the core of a fallback implementation of a 4997275970Scy# platform-specific function to extract the name of the 4998275970Scy# DLL associated with the specified import library LIBNAME. 4999275970Scy# 5000275970Scy# SECTION_NAME is either .idata$6 or .idata$7, depending 5001275970Scy# on the platform and compiler that created the implib. 5002275970Scy# 5003275970Scy# Echos the name of the DLL associated with the 5004275970Scy# specified import library. 5005275970Scyfunc_cygming_dll_for_implib_fallback_core () 5006275970Scy{ 5007316068Sdelphij $debug_cmd 5008316068Sdelphij 5009275970Scy match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010275970Scy $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011275970Scy $SED '/^Contents of section '"$match_literal"':/{ 5012275970Scy # Place marker at beginning of archive member dllname section 5013275970Scy s/.*/====MARK====/ 5014275970Scy p 5015275970Scy d 5016275970Scy } 5017275970Scy # These lines can sometimes be longer than 43 characters, but 5018275970Scy # are always uninteresting 5019275970Scy /:[ ]*file format pe[i]\{,1\}-/d 5020275970Scy /^In archive [^:]*:/d 5021275970Scy # Ensure marker is printed 5022275970Scy /^====MARK====/p 5023275970Scy # Remove all lines with less than 43 characters 5024275970Scy /^.\{43\}/!d 5025275970Scy # From remaining lines, remove first 43 characters 5026275970Scy s/^.\{43\}//' | 5027275970Scy $SED -n ' 5028275970Scy # Join marker and all lines until next marker into a single line 5029275970Scy /^====MARK====/ b para 5030275970Scy H 5031275970Scy $ b para 5032275970Scy b 5033275970Scy :para 5034275970Scy x 5035275970Scy s/\n//g 5036275970Scy # Remove the marker 5037275970Scy s/^====MARK====// 5038275970Scy # Remove trailing dots and whitespace 5039275970Scy s/[\. \t]*$// 5040275970Scy # Print 5041275970Scy /./p' | 5042275970Scy # we now have a list, one entry per line, of the stringified 5043275970Scy # contents of the appropriate section of all members of the 5044316068Sdelphij # archive that possess that section. Heuristic: eliminate 5045316068Sdelphij # all those that have a first or second character that is 5046275970Scy # a '.' (that is, objdump's representation of an unprintable 5047275970Scy # character.) This should work for all archives with less than 5048275970Scy # 0x302f exports -- but will fail for DLLs whose name actually 5049275970Scy # begins with a literal '.' or a single character followed by 5050275970Scy # a '.'. 5051275970Scy # 5052275970Scy # Of those that remain, print the first one. 5053275970Scy $SED -e '/^\./d;/^.\./d;q' 5054275970Scy} 5055275970Scy 5056275970Scy# func_cygming_dll_for_implib_fallback ARG 5057275970Scy# Platform-specific function to extract the 5058275970Scy# name of the DLL associated with the specified 5059275970Scy# import library ARG. 5060275970Scy# 5061275970Scy# This fallback implementation is for use when $DLLTOOL 5062275970Scy# does not support the --identify-strict option. 5063275970Scy# Invoked by eval'ing the libtool variable 5064275970Scy# $sharedlib_from_linklib_cmd 5065275970Scy# Result is available in the variable 5066275970Scy# $sharedlib_from_linklib_result 5067275970Scyfunc_cygming_dll_for_implib_fallback () 5068275970Scy{ 5069316068Sdelphij $debug_cmd 5070316068Sdelphij 5071316068Sdelphij if func_cygming_gnu_implib_p "$1"; then 5072275970Scy # binutils import library 5073275970Scy sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074316068Sdelphij elif func_cygming_ms_implib_p "$1"; then 5075275970Scy # ms-generated import library 5076275970Scy sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077275970Scy else 5078275970Scy # unknown 5079316068Sdelphij sharedlib_from_linklib_result= 5080275970Scy fi 5081275970Scy} 5082275970Scy 5083275970Scy 5084275970Scy# func_extract_an_archive dir oldlib 5085275970Scyfunc_extract_an_archive () 5086275970Scy{ 5087316068Sdelphij $debug_cmd 5088316068Sdelphij 5089316068Sdelphij f_ex_an_ar_dir=$1; shift 5090316068Sdelphij f_ex_an_ar_oldlib=$1 5091316068Sdelphij if test yes = "$lock_old_archive_extraction"; then 5092275970Scy lockfile=$f_ex_an_ar_oldlib.lock 5093275970Scy until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094275970Scy func_echo "Waiting for $lockfile to be removed" 5095275970Scy sleep 2 5096275970Scy done 5097275970Scy fi 5098275970Scy func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099275970Scy 'stat=$?; rm -f "$lockfile"; exit $stat' 5100316068Sdelphij if test yes = "$lock_old_archive_extraction"; then 5101275970Scy $opt_dry_run || rm -f "$lockfile" 5102275970Scy fi 5103275970Scy if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104275970Scy : 5105275970Scy else 5106275970Scy func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107275970Scy fi 5108275970Scy} 5109275970Scy 5110275970Scy 5111275970Scy# func_extract_archives gentop oldlib ... 5112275970Scyfunc_extract_archives () 5113275970Scy{ 5114316068Sdelphij $debug_cmd 5115316068Sdelphij 5116316068Sdelphij my_gentop=$1; shift 5117275970Scy my_oldlibs=${1+"$@"} 5118316068Sdelphij my_oldobjs= 5119316068Sdelphij my_xlib= 5120316068Sdelphij my_xabs= 5121316068Sdelphij my_xdir= 5122275970Scy 5123275970Scy for my_xlib in $my_oldlibs; do 5124275970Scy # Extract the objects. 5125275970Scy case $my_xlib in 5126316068Sdelphij [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127275970Scy *) my_xabs=`pwd`"/$my_xlib" ;; 5128275970Scy esac 5129275970Scy func_basename "$my_xlib" 5130316068Sdelphij my_xlib=$func_basename_result 5131275970Scy my_xlib_u=$my_xlib 5132275970Scy while :; do 5133275970Scy case " $extracted_archives " in 5134275970Scy *" $my_xlib_u "*) 5135275970Scy func_arith $extracted_serial + 1 5136275970Scy extracted_serial=$func_arith_result 5137275970Scy my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138275970Scy *) break ;; 5139275970Scy esac 5140275970Scy done 5141275970Scy extracted_archives="$extracted_archives $my_xlib_u" 5142316068Sdelphij my_xdir=$my_gentop/$my_xlib_u 5143275970Scy 5144275970Scy func_mkdir_p "$my_xdir" 5145275970Scy 5146275970Scy case $host in 5147275970Scy *-darwin*) 5148275970Scy func_verbose "Extracting $my_xabs" 5149275970Scy # Do not bother doing anything if just a dry run 5150275970Scy $opt_dry_run || { 5151275970Scy darwin_orig_dir=`pwd` 5152275970Scy cd $my_xdir || exit $? 5153275970Scy darwin_archive=$my_xabs 5154275970Scy darwin_curdir=`pwd` 5155316068Sdelphij func_basename "$darwin_archive" 5156316068Sdelphij darwin_base_archive=$func_basename_result 5157275970Scy darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158275970Scy if test -n "$darwin_arches"; then 5159275970Scy darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160275970Scy darwin_arch= 5161275970Scy func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162316068Sdelphij for darwin_arch in $darwin_arches; do 5163316068Sdelphij func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164316068Sdelphij $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165316068Sdelphij cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166316068Sdelphij func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167275970Scy cd "$darwin_curdir" 5168316068Sdelphij $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169275970Scy done # $darwin_arches 5170275970Scy ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171316068Sdelphij darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172275970Scy darwin_file= 5173275970Scy darwin_files= 5174275970Scy for darwin_file in $darwin_filelist; do 5175275970Scy darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176275970Scy $LIPO -create -output "$darwin_file" $darwin_files 5177275970Scy done # $darwin_filelist 5178275970Scy $RM -rf unfat-$$ 5179275970Scy cd "$darwin_orig_dir" 5180275970Scy else 5181275970Scy cd $darwin_orig_dir 5182275970Scy func_extract_an_archive "$my_xdir" "$my_xabs" 5183275970Scy fi # $darwin_arches 5184275970Scy } # !$opt_dry_run 5185275970Scy ;; 5186275970Scy *) 5187275970Scy func_extract_an_archive "$my_xdir" "$my_xabs" 5188275970Scy ;; 5189275970Scy esac 5190275970Scy my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191275970Scy done 5192275970Scy 5193316068Sdelphij func_extract_archives_result=$my_oldobjs 5194275970Scy} 5195275970Scy 5196275970Scy 5197275970Scy# func_emit_wrapper [arg=no] 5198275970Scy# 5199275970Scy# Emit a libtool wrapper script on stdout. 5200275970Scy# Don't directly open a file because we may want to 5201275970Scy# incorporate the script contents within a cygwin/mingw 5202275970Scy# wrapper executable. Must ONLY be called from within 5203275970Scy# func_mode_link because it depends on a number of variables 5204275970Scy# set therein. 5205275970Scy# 5206275970Scy# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207275970Scy# variable will take. If 'yes', then the emitted script 5208316068Sdelphij# will assume that the directory where it is stored is 5209275970Scy# the $objdir directory. This is a cygwin/mingw-specific 5210275970Scy# behavior. 5211275970Scyfunc_emit_wrapper () 5212275970Scy{ 5213275970Scy func_emit_wrapper_arg1=${1-no} 5214275970Scy 5215275970Scy $ECHO "\ 5216275970Scy#! $SHELL 5217275970Scy 5218275970Scy# $output - temporary wrapper script for $objdir/$outputname 5219316068Sdelphij# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220275970Scy# 5221275970Scy# The $output program cannot be directly executed until all the libtool 5222275970Scy# libraries that it depends on are installed. 5223275970Scy# 5224275970Scy# This wrapper script should never be moved out of the build directory. 5225275970Scy# If it is, it will not operate correctly. 5226275970Scy 5227275970Scy# Sed substitution that helps us do robust quoting. It backslashifies 5228275970Scy# metacharacters that are still active within double-quoted strings. 5229275970Scysed_quote_subst='$sed_quote_subst' 5230275970Scy 5231275970Scy# Be Bourne compatible 5232275970Scyif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233275970Scy emulate sh 5234275970Scy NULLCMD=: 5235275970Scy # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236275970Scy # is contrary to our usage. Disable this feature. 5237275970Scy alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238275970Scy setopt NO_GLOB_SUBST 5239275970Scyelse 5240275970Scy case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241275970Scyfi 5242275970ScyBIN_SH=xpg4; export BIN_SH # for Tru64 5243275970ScyDUALCASE=1; export DUALCASE # for MKS sh 5244275970Scy 5245275970Scy# The HP-UX ksh and POSIX shell print the target directory to stdout 5246275970Scy# if CDPATH is set. 5247275970Scy(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248275970Scy 5249275970Scyrelink_command=\"$relink_command\" 5250275970Scy 5251275970Scy# This environment variable determines our operation mode. 5252275970Scyif test \"\$libtool_install_magic\" = \"$magic\"; then 5253275970Scy # install mode needs the following variables: 5254275970Scy generated_by_libtool_version='$macro_version' 5255275970Scy notinst_deplibs='$notinst_deplibs' 5256275970Scyelse 5257275970Scy # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258275970Scy if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259275970Scy file=\"\$0\"" 5260275970Scy 5261275970Scy qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262275970Scy $ECHO "\ 5263275970Scy 5264275970Scy# A function that is used when there is no print builtin or printf. 5265275970Scyfunc_fallback_echo () 5266275970Scy{ 5267275970Scy eval 'cat <<_LTECHO_EOF 5268275970Scy\$1 5269275970Scy_LTECHO_EOF' 5270275970Scy} 5271275970Scy ECHO=\"$qECHO\" 5272275970Scy fi 5273275970Scy 5274275970Scy# Very basic option parsing. These options are (a) specific to 5275275970Scy# the libtool wrapper, (b) are identical between the wrapper 5276316068Sdelphij# /script/ and the wrapper /executable/ that is used only on 5277275970Scy# windows platforms, and (c) all begin with the string "--lt-" 5278316068Sdelphij# (application programs are unlikely to have options that match 5279275970Scy# this pattern). 5280275970Scy# 5281275970Scy# There are only two supported options: --lt-debug and 5282275970Scy# --lt-dump-script. There is, deliberately, no --lt-help. 5283275970Scy# 5284275970Scy# The first argument to this parsing function should be the 5285275970Scy# script's $0 value, followed by "$@". 5286275970Scylt_option_debug= 5287275970Scyfunc_parse_lt_options () 5288275970Scy{ 5289275970Scy lt_script_arg0=\$0 5290275970Scy shift 5291275970Scy for lt_opt 5292275970Scy do 5293275970Scy case \"\$lt_opt\" in 5294275970Scy --lt-debug) lt_option_debug=1 ;; 5295275970Scy --lt-dump-script) 5296275970Scy lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297275970Scy test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298275970Scy lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299275970Scy cat \"\$lt_dump_D/\$lt_dump_F\" 5300275970Scy exit 0 5301275970Scy ;; 5302275970Scy --lt-*) 5303275970Scy \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304275970Scy exit 1 5305275970Scy ;; 5306275970Scy esac 5307275970Scy done 5308275970Scy 5309275970Scy # Print the debug banner immediately: 5310275970Scy if test -n \"\$lt_option_debug\"; then 5311316068Sdelphij echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312275970Scy fi 5313275970Scy} 5314275970Scy 5315275970Scy# Used when --lt-debug. Prints its arguments to stdout 5316275970Scy# (redirection is the responsibility of the caller) 5317275970Scyfunc_lt_dump_args () 5318275970Scy{ 5319275970Scy lt_dump_args_N=1; 5320275970Scy for lt_arg 5321275970Scy do 5322316068Sdelphij \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323275970Scy lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324275970Scy done 5325275970Scy} 5326275970Scy 5327275970Scy# Core function for launching the target application 5328275970Scyfunc_exec_program_core () 5329275970Scy{ 5330275970Scy" 5331275970Scy case $host in 5332275970Scy # Backslashes separate directories on plain windows 5333275970Scy *-*-mingw | *-*-os2* | *-cegcc*) 5334275970Scy $ECHO "\ 5335275970Scy if test -n \"\$lt_option_debug\"; then 5336316068Sdelphij \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337275970Scy func_lt_dump_args \${1+\"\$@\"} 1>&2 5338275970Scy fi 5339275970Scy exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340275970Scy" 5341275970Scy ;; 5342275970Scy 5343275970Scy *) 5344275970Scy $ECHO "\ 5345275970Scy if test -n \"\$lt_option_debug\"; then 5346316068Sdelphij \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347275970Scy func_lt_dump_args \${1+\"\$@\"} 1>&2 5348275970Scy fi 5349275970Scy exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350275970Scy" 5351275970Scy ;; 5352275970Scy esac 5353275970Scy $ECHO "\ 5354275970Scy \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355275970Scy exit 1 5356275970Scy} 5357275970Scy 5358275970Scy# A function to encapsulate launching the target application 5359275970Scy# Strips options in the --lt-* namespace from \$@ and 5360275970Scy# launches target application with the remaining arguments. 5361275970Scyfunc_exec_program () 5362275970Scy{ 5363285169Scy case \" \$* \" in 5364285169Scy *\\ --lt-*) 5365285169Scy for lt_wr_arg 5366285169Scy do 5367285169Scy case \$lt_wr_arg in 5368285169Scy --lt-*) ;; 5369285169Scy *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370285169Scy esac 5371285169Scy shift 5372285169Scy done ;; 5373285169Scy esac 5374275970Scy func_exec_program_core \${1+\"\$@\"} 5375275970Scy} 5376275970Scy 5377275970Scy # Parse options 5378275970Scy func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379275970Scy 5380275970Scy # Find the directory that this script lives in. 5381275970Scy thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382275970Scy test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383275970Scy 5384275970Scy # Follow symbolic links until we get to the real thisdir. 5385275970Scy file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386275970Scy while test -n \"\$file\"; do 5387275970Scy destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388275970Scy 5389275970Scy # If there was a directory component, then change thisdir. 5390275970Scy if test \"x\$destdir\" != \"x\$file\"; then 5391275970Scy case \"\$destdir\" in 5392275970Scy [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393275970Scy *) thisdir=\"\$thisdir/\$destdir\" ;; 5394275970Scy esac 5395275970Scy fi 5396275970Scy 5397275970Scy file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398275970Scy file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399275970Scy done 5400275970Scy 5401275970Scy # Usually 'no', except on cygwin/mingw when embedded into 5402275970Scy # the cwrapper. 5403275970Scy WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404275970Scy if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405275970Scy # special case for '.' 5406275970Scy if test \"\$thisdir\" = \".\"; then 5407275970Scy thisdir=\`pwd\` 5408275970Scy fi 5409275970Scy # remove .libs from thisdir 5410275970Scy case \"\$thisdir\" in 5411275970Scy *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412275970Scy $objdir ) thisdir=. ;; 5413275970Scy esac 5414275970Scy fi 5415275970Scy 5416275970Scy # Try to get the absolute directory name. 5417275970Scy absdir=\`cd \"\$thisdir\" && pwd\` 5418275970Scy test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419275970Scy" 5420275970Scy 5421316068Sdelphij if test yes = "$fast_install"; then 5422275970Scy $ECHO "\ 5423275970Scy program=lt-'$outputname'$exeext 5424275970Scy progdir=\"\$thisdir/$objdir\" 5425275970Scy 5426275970Scy if test ! -f \"\$progdir/\$program\" || 5427316068Sdelphij { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428275970Scy test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429275970Scy 5430275970Scy file=\"\$\$-\$program\" 5431275970Scy 5432275970Scy if test ! -d \"\$progdir\"; then 5433275970Scy $MKDIR \"\$progdir\" 5434275970Scy else 5435275970Scy $RM \"\$progdir/\$file\" 5436275970Scy fi" 5437275970Scy 5438275970Scy $ECHO "\ 5439275970Scy 5440275970Scy # relink executable if necessary 5441275970Scy if test -n \"\$relink_command\"; then 5442275970Scy if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443275970Scy else 5444316068Sdelphij \$ECHO \"\$relink_command_output\" >&2 5445275970Scy $RM \"\$progdir/\$file\" 5446275970Scy exit 1 5447275970Scy fi 5448275970Scy fi 5449275970Scy 5450275970Scy $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451275970Scy { $RM \"\$progdir/\$program\"; 5452275970Scy $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453275970Scy $RM \"\$progdir/\$file\" 5454275970Scy fi" 5455275970Scy else 5456275970Scy $ECHO "\ 5457275970Scy program='$outputname' 5458275970Scy progdir=\"\$thisdir/$objdir\" 5459275970Scy" 5460275970Scy fi 5461275970Scy 5462275970Scy $ECHO "\ 5463275970Scy 5464275970Scy if test -f \"\$progdir/\$program\"; then" 5465275970Scy 5466275970Scy # fixup the dll searchpath if we need to. 5467275970Scy # 5468275970Scy # Fix the DLL searchpath if we need to. Do this before prepending 5469275970Scy # to shlibpath, because on Windows, both are PATH and uninstalled 5470275970Scy # libraries must come first. 5471275970Scy if test -n "$dllsearchpath"; then 5472275970Scy $ECHO "\ 5473275970Scy # Add the dll search path components to the executable PATH 5474275970Scy PATH=$dllsearchpath:\$PATH 5475275970Scy" 5476275970Scy fi 5477275970Scy 5478275970Scy # Export our shlibpath_var if we have one. 5479316068Sdelphij if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480275970Scy $ECHO "\ 5481275970Scy # Add our own library path to $shlibpath_var 5482275970Scy $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483275970Scy 5484275970Scy # Some systems cannot cope with colon-terminated $shlibpath_var 5485275970Scy # The second colon is a workaround for a bug in BeOS R4 sed 5486275970Scy $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487275970Scy 5488275970Scy export $shlibpath_var 5489275970Scy" 5490275970Scy fi 5491275970Scy 5492275970Scy $ECHO "\ 5493275970Scy if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494275970Scy # Run the actual program with our arguments. 5495275970Scy func_exec_program \${1+\"\$@\"} 5496275970Scy fi 5497275970Scy else 5498275970Scy # The program doesn't exist. 5499316068Sdelphij \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500275970Scy \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501275970Scy \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502275970Scy exit 1 5503275970Scy fi 5504275970Scyfi\ 5505275970Scy" 5506275970Scy} 5507275970Scy 5508275970Scy 5509275970Scy# func_emit_cwrapperexe_src 5510275970Scy# emit the source code for a wrapper executable on stdout 5511275970Scy# Must ONLY be called from within func_mode_link because 5512275970Scy# it depends on a number of variable set therein. 5513275970Scyfunc_emit_cwrapperexe_src () 5514275970Scy{ 5515275970Scy cat <<EOF 5516275970Scy 5517275970Scy/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518316068Sdelphij Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519275970Scy 5520275970Scy The $output program cannot be directly executed until all the libtool 5521275970Scy libraries that it depends on are installed. 5522275970Scy 5523275970Scy This wrapper executable should never be moved out of the build directory. 5524275970Scy If it is, it will not operate correctly. 5525275970Scy*/ 5526275970ScyEOF 5527275970Scy cat <<"EOF" 5528275970Scy#ifdef _MSC_VER 5529275970Scy# define _CRT_SECURE_NO_DEPRECATE 1 5530275970Scy#endif 5531275970Scy#include <stdio.h> 5532275970Scy#include <stdlib.h> 5533275970Scy#ifdef _MSC_VER 5534275970Scy# include <direct.h> 5535275970Scy# include <process.h> 5536275970Scy# include <io.h> 5537275970Scy#else 5538275970Scy# include <unistd.h> 5539275970Scy# include <stdint.h> 5540275970Scy# ifdef __CYGWIN__ 5541275970Scy# include <io.h> 5542275970Scy# endif 5543275970Scy#endif 5544275970Scy#include <malloc.h> 5545275970Scy#include <stdarg.h> 5546275970Scy#include <assert.h> 5547275970Scy#include <string.h> 5548275970Scy#include <ctype.h> 5549275970Scy#include <errno.h> 5550275970Scy#include <fcntl.h> 5551275970Scy#include <sys/stat.h> 5552275970Scy 5553316068Sdelphij#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554316068Sdelphij 5555275970Scy/* declarations of non-ANSI functions */ 5556316068Sdelphij#if defined __MINGW32__ 5557275970Scy# ifdef __STRICT_ANSI__ 5558275970Scyint _putenv (const char *); 5559275970Scy# endif 5560316068Sdelphij#elif defined __CYGWIN__ 5561275970Scy# ifdef __STRICT_ANSI__ 5562275970Scychar *realpath (const char *, char *); 5563275970Scyint putenv (char *); 5564275970Scyint setenv (const char *, const char *, int); 5565275970Scy# endif 5566316068Sdelphij/* #elif defined other_platform || defined ... */ 5567275970Scy#endif 5568275970Scy 5569275970Scy/* portability defines, excluding path handling macros */ 5570316068Sdelphij#if defined _MSC_VER 5571275970Scy# define setmode _setmode 5572275970Scy# define stat _stat 5573275970Scy# define chmod _chmod 5574275970Scy# define getcwd _getcwd 5575275970Scy# define putenv _putenv 5576275970Scy# define S_IXUSR _S_IEXEC 5577316068Sdelphij#elif defined __MINGW32__ 5578275970Scy# define setmode _setmode 5579275970Scy# define stat _stat 5580275970Scy# define chmod _chmod 5581275970Scy# define getcwd _getcwd 5582275970Scy# define putenv _putenv 5583316068Sdelphij#elif defined __CYGWIN__ 5584275970Scy# define HAVE_SETENV 5585275970Scy# define FOPEN_WB "wb" 5586316068Sdelphij/* #elif defined other platforms ... */ 5587275970Scy#endif 5588275970Scy 5589316068Sdelphij#if defined PATH_MAX 5590275970Scy# define LT_PATHMAX PATH_MAX 5591316068Sdelphij#elif defined MAXPATHLEN 5592275970Scy# define LT_PATHMAX MAXPATHLEN 5593275970Scy#else 5594275970Scy# define LT_PATHMAX 1024 5595275970Scy#endif 5596275970Scy 5597275970Scy#ifndef S_IXOTH 5598275970Scy# define S_IXOTH 0 5599275970Scy#endif 5600275970Scy#ifndef S_IXGRP 5601275970Scy# define S_IXGRP 0 5602275970Scy#endif 5603275970Scy 5604275970Scy/* path handling portability macros */ 5605275970Scy#ifndef DIR_SEPARATOR 5606275970Scy# define DIR_SEPARATOR '/' 5607275970Scy# define PATH_SEPARATOR ':' 5608275970Scy#endif 5609275970Scy 5610316068Sdelphij#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611316068Sdelphij defined __OS2__ 5612275970Scy# define HAVE_DOS_BASED_FILE_SYSTEM 5613275970Scy# define FOPEN_WB "wb" 5614275970Scy# ifndef DIR_SEPARATOR_2 5615275970Scy# define DIR_SEPARATOR_2 '\\' 5616275970Scy# endif 5617275970Scy# ifndef PATH_SEPARATOR_2 5618275970Scy# define PATH_SEPARATOR_2 ';' 5619275970Scy# endif 5620275970Scy#endif 5621275970Scy 5622275970Scy#ifndef DIR_SEPARATOR_2 5623275970Scy# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624275970Scy#else /* DIR_SEPARATOR_2 */ 5625275970Scy# define IS_DIR_SEPARATOR(ch) \ 5626275970Scy (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627275970Scy#endif /* DIR_SEPARATOR_2 */ 5628275970Scy 5629275970Scy#ifndef PATH_SEPARATOR_2 5630275970Scy# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631275970Scy#else /* PATH_SEPARATOR_2 */ 5632275970Scy# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633275970Scy#endif /* PATH_SEPARATOR_2 */ 5634275970Scy 5635275970Scy#ifndef FOPEN_WB 5636275970Scy# define FOPEN_WB "w" 5637275970Scy#endif 5638275970Scy#ifndef _O_BINARY 5639275970Scy# define _O_BINARY 0 5640275970Scy#endif 5641275970Scy 5642275970Scy#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643275970Scy#define XFREE(stale) do { \ 5644316068Sdelphij if (stale) { free (stale); stale = 0; } \ 5645275970Scy} while (0) 5646275970Scy 5647316068Sdelphij#if defined LT_DEBUGWRAPPER 5648275970Scystatic int lt_debug = 1; 5649275970Scy#else 5650275970Scystatic int lt_debug = 0; 5651275970Scy#endif 5652275970Scy 5653275970Scyconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654275970Scy 5655275970Scyvoid *xmalloc (size_t num); 5656275970Scychar *xstrdup (const char *string); 5657275970Scyconst char *base_name (const char *name); 5658275970Scychar *find_executable (const char *wrapper); 5659275970Scychar *chase_symlinks (const char *pathspec); 5660275970Scyint make_executable (const char *path); 5661275970Scyint check_executable (const char *path); 5662275970Scychar *strendzap (char *str, const char *pat); 5663275970Scyvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664275970Scyvoid lt_fatal (const char *file, int line, const char *message, ...); 5665275970Scystatic const char *nonnull (const char *s); 5666275970Scystatic const char *nonempty (const char *s); 5667275970Scyvoid lt_setenv (const char *name, const char *value); 5668275970Scychar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669275970Scyvoid lt_update_exe_path (const char *name, const char *value); 5670275970Scyvoid lt_update_lib_path (const char *name, const char *value); 5671275970Scychar **prepare_spawn (char **argv); 5672275970Scyvoid lt_dump_script (FILE *f); 5673275970ScyEOF 5674275970Scy 5675275970Scy cat <<EOF 5676316068Sdelphij#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677316068Sdelphij# define externally_visible volatile 5678316068Sdelphij#else 5679316068Sdelphij# define externally_visible __attribute__((externally_visible)) volatile 5680316068Sdelphij#endif 5681316068Sdelphijexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682275970Scyconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683275970ScyEOF 5684275970Scy 5685316068Sdelphij if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686275970Scy func_to_host_path "$temp_rpath" 5687275970Scy cat <<EOF 5688275970Scyconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689275970ScyEOF 5690275970Scy else 5691275970Scy cat <<"EOF" 5692275970Scyconst char * LIB_PATH_VALUE = ""; 5693275970ScyEOF 5694275970Scy fi 5695275970Scy 5696275970Scy if test -n "$dllsearchpath"; then 5697275970Scy func_to_host_path "$dllsearchpath:" 5698275970Scy cat <<EOF 5699275970Scyconst char * EXE_PATH_VARNAME = "PATH"; 5700275970Scyconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701275970ScyEOF 5702275970Scy else 5703275970Scy cat <<"EOF" 5704275970Scyconst char * EXE_PATH_VARNAME = ""; 5705275970Scyconst char * EXE_PATH_VALUE = ""; 5706275970ScyEOF 5707275970Scy fi 5708275970Scy 5709316068Sdelphij if test yes = "$fast_install"; then 5710275970Scy cat <<EOF 5711275970Scyconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712275970ScyEOF 5713275970Scy else 5714275970Scy cat <<EOF 5715275970Scyconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716275970ScyEOF 5717275970Scy fi 5718275970Scy 5719275970Scy 5720275970Scy cat <<"EOF" 5721275970Scy 5722275970Scy#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723275970Scy 5724275970Scystatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725275970Scystatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726275970Scystatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727275970Scy 5728275970Scyint 5729275970Scymain (int argc, char *argv[]) 5730275970Scy{ 5731275970Scy char **newargz; 5732275970Scy int newargc; 5733275970Scy char *tmp_pathspec; 5734275970Scy char *actual_cwrapper_path; 5735275970Scy char *actual_cwrapper_name; 5736275970Scy char *target_name; 5737275970Scy char *lt_argv_zero; 5738316068Sdelphij int rval = 127; 5739275970Scy 5740275970Scy int i; 5741275970Scy 5742275970Scy program_name = (char *) xstrdup (base_name (argv[0])); 5743316068Sdelphij newargz = XMALLOC (char *, (size_t) argc + 1); 5744275970Scy 5745275970Scy /* very simple arg parsing; don't want to rely on getopt 5746275970Scy * also, copy all non cwrapper options to newargz, except 5747275970Scy * argz[0], which is handled differently 5748275970Scy */ 5749275970Scy newargc=0; 5750275970Scy for (i = 1; i < argc; i++) 5751275970Scy { 5752316068Sdelphij if (STREQ (argv[i], dumpscript_opt)) 5753275970Scy { 5754275970ScyEOF 5755316068Sdelphij case $host in 5756275970Scy *mingw* | *cygwin* ) 5757275970Scy # make stdout use "unix" line endings 5758275970Scy echo " setmode(1,_O_BINARY);" 5759275970Scy ;; 5760275970Scy esac 5761275970Scy 5762275970Scy cat <<"EOF" 5763275970Scy lt_dump_script (stdout); 5764275970Scy return 0; 5765275970Scy } 5766316068Sdelphij if (STREQ (argv[i], debug_opt)) 5767275970Scy { 5768275970Scy lt_debug = 1; 5769275970Scy continue; 5770275970Scy } 5771316068Sdelphij if (STREQ (argv[i], ltwrapper_option_prefix)) 5772275970Scy { 5773275970Scy /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774275970Scy namespace, but it is not one of the ones we know about and 5775275970Scy have already dealt with, above (inluding dump-script), then 5776275970Scy report an error. Otherwise, targets might begin to believe 5777275970Scy they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778275970Scy namespace. The first time any user complains about this, we'll 5779275970Scy need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780275970Scy or a configure.ac-settable value. 5781275970Scy */ 5782275970Scy lt_fatal (__FILE__, __LINE__, 5783275970Scy "unrecognized %s option: '%s'", 5784275970Scy ltwrapper_option_prefix, argv[i]); 5785275970Scy } 5786275970Scy /* otherwise ... */ 5787275970Scy newargz[++newargc] = xstrdup (argv[i]); 5788275970Scy } 5789275970Scy newargz[++newargc] = NULL; 5790275970Scy 5791275970ScyEOF 5792275970Scy cat <<EOF 5793275970Scy /* The GNU banner must be the first non-error debug message */ 5794316068Sdelphij lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795275970ScyEOF 5796275970Scy cat <<"EOF" 5797275970Scy lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798275970Scy lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799275970Scy 5800275970Scy tmp_pathspec = find_executable (argv[0]); 5801275970Scy if (tmp_pathspec == NULL) 5802275970Scy lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803275970Scy lt_debugprintf (__FILE__, __LINE__, 5804275970Scy "(main) found exe (before symlink chase) at: %s\n", 5805275970Scy tmp_pathspec); 5806275970Scy 5807275970Scy actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808275970Scy lt_debugprintf (__FILE__, __LINE__, 5809275970Scy "(main) found exe (after symlink chase) at: %s\n", 5810275970Scy actual_cwrapper_path); 5811275970Scy XFREE (tmp_pathspec); 5812275970Scy 5813275970Scy actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814275970Scy strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815275970Scy 5816275970Scy /* wrapper name transforms */ 5817275970Scy strendzap (actual_cwrapper_name, ".exe"); 5818275970Scy tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819275970Scy XFREE (actual_cwrapper_name); 5820275970Scy actual_cwrapper_name = tmp_pathspec; 5821275970Scy tmp_pathspec = 0; 5822275970Scy 5823275970Scy /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824275970Scy target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825275970Scy strendzap (target_name, ".exe"); 5826275970Scy tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827275970Scy XFREE (target_name); 5828275970Scy target_name = tmp_pathspec; 5829275970Scy tmp_pathspec = 0; 5830275970Scy 5831275970Scy lt_debugprintf (__FILE__, __LINE__, 5832275970Scy "(main) libtool target name: %s\n", 5833275970Scy target_name); 5834275970ScyEOF 5835275970Scy 5836275970Scy cat <<EOF 5837275970Scy newargz[0] = 5838275970Scy XMALLOC (char, (strlen (actual_cwrapper_path) + 5839275970Scy strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840275970Scy strcpy (newargz[0], actual_cwrapper_path); 5841275970Scy strcat (newargz[0], "$objdir"); 5842275970Scy strcat (newargz[0], "/"); 5843275970ScyEOF 5844275970Scy 5845275970Scy cat <<"EOF" 5846275970Scy /* stop here, and copy so we don't have to do this twice */ 5847275970Scy tmp_pathspec = xstrdup (newargz[0]); 5848275970Scy 5849275970Scy /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850275970Scy strcat (newargz[0], actual_cwrapper_name); 5851275970Scy 5852275970Scy /* DO want the lt- prefix here if it exists, so use target_name */ 5853275970Scy lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854275970Scy XFREE (tmp_pathspec); 5855275970Scy tmp_pathspec = NULL; 5856275970ScyEOF 5857275970Scy 5858275970Scy case $host_os in 5859275970Scy mingw*) 5860275970Scy cat <<"EOF" 5861275970Scy { 5862275970Scy char* p; 5863275970Scy while ((p = strchr (newargz[0], '\\')) != NULL) 5864275970Scy { 5865275970Scy *p = '/'; 5866275970Scy } 5867275970Scy while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868275970Scy { 5869275970Scy *p = '/'; 5870275970Scy } 5871275970Scy } 5872275970ScyEOF 5873275970Scy ;; 5874275970Scy esac 5875275970Scy 5876275970Scy cat <<"EOF" 5877275970Scy XFREE (target_name); 5878275970Scy XFREE (actual_cwrapper_path); 5879275970Scy XFREE (actual_cwrapper_name); 5880275970Scy 5881275970Scy lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882275970Scy lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883275970Scy /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884275970Scy be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885275970Scy because on Windows, both *_VARNAMEs are PATH but uninstalled 5886275970Scy libraries must come first. */ 5887275970Scy lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888275970Scy lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889275970Scy 5890275970Scy lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891275970Scy nonnull (lt_argv_zero)); 5892275970Scy for (i = 0; i < newargc; i++) 5893275970Scy { 5894275970Scy lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895275970Scy i, nonnull (newargz[i])); 5896275970Scy } 5897275970Scy 5898275970ScyEOF 5899275970Scy 5900275970Scy case $host_os in 5901275970Scy mingw*) 5902275970Scy cat <<"EOF" 5903275970Scy /* execv doesn't actually work on mingw as expected on unix */ 5904275970Scy newargz = prepare_spawn (newargz); 5905316068Sdelphij rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906275970Scy if (rval == -1) 5907275970Scy { 5908275970Scy /* failed to start process */ 5909275970Scy lt_debugprintf (__FILE__, __LINE__, 5910275970Scy "(main) failed to launch target \"%s\": %s\n", 5911275970Scy lt_argv_zero, nonnull (strerror (errno))); 5912275970Scy return 127; 5913275970Scy } 5914275970Scy return rval; 5915275970ScyEOF 5916275970Scy ;; 5917275970Scy *) 5918275970Scy cat <<"EOF" 5919275970Scy execv (lt_argv_zero, newargz); 5920275970Scy return rval; /* =127, but avoids unused variable warning */ 5921275970ScyEOF 5922275970Scy ;; 5923275970Scy esac 5924275970Scy 5925275970Scy cat <<"EOF" 5926275970Scy} 5927275970Scy 5928275970Scyvoid * 5929275970Scyxmalloc (size_t num) 5930275970Scy{ 5931275970Scy void *p = (void *) malloc (num); 5932275970Scy if (!p) 5933275970Scy lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934275970Scy 5935275970Scy return p; 5936275970Scy} 5937275970Scy 5938275970Scychar * 5939275970Scyxstrdup (const char *string) 5940275970Scy{ 5941275970Scy return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942275970Scy string) : NULL; 5943275970Scy} 5944275970Scy 5945275970Scyconst char * 5946275970Scybase_name (const char *name) 5947275970Scy{ 5948275970Scy const char *base; 5949275970Scy 5950316068Sdelphij#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951275970Scy /* Skip over the disk name in MSDOS pathnames. */ 5952275970Scy if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953275970Scy name += 2; 5954275970Scy#endif 5955275970Scy 5956275970Scy for (base = name; *name; name++) 5957275970Scy if (IS_DIR_SEPARATOR (*name)) 5958275970Scy base = name + 1; 5959275970Scy return base; 5960275970Scy} 5961275970Scy 5962275970Scyint 5963275970Scycheck_executable (const char *path) 5964275970Scy{ 5965275970Scy struct stat st; 5966275970Scy 5967275970Scy lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968275970Scy nonempty (path)); 5969275970Scy if ((!path) || (!*path)) 5970275970Scy return 0; 5971275970Scy 5972275970Scy if ((stat (path, &st) >= 0) 5973275970Scy && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974275970Scy return 1; 5975275970Scy else 5976275970Scy return 0; 5977275970Scy} 5978275970Scy 5979275970Scyint 5980275970Scymake_executable (const char *path) 5981275970Scy{ 5982275970Scy int rval = 0; 5983275970Scy struct stat st; 5984275970Scy 5985275970Scy lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986275970Scy nonempty (path)); 5987275970Scy if ((!path) || (!*path)) 5988275970Scy return 0; 5989275970Scy 5990275970Scy if (stat (path, &st) >= 0) 5991275970Scy { 5992275970Scy rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993275970Scy } 5994275970Scy return rval; 5995275970Scy} 5996275970Scy 5997275970Scy/* Searches for the full path of the wrapper. Returns 5998275970Scy newly allocated full path name if found, NULL otherwise 5999275970Scy Does not chase symlinks, even on platforms that support them. 6000275970Scy*/ 6001275970Scychar * 6002275970Scyfind_executable (const char *wrapper) 6003275970Scy{ 6004275970Scy int has_slash = 0; 6005275970Scy const char *p; 6006275970Scy const char *p_next; 6007275970Scy /* static buffer for getcwd */ 6008275970Scy char tmp[LT_PATHMAX + 1]; 6009316068Sdelphij size_t tmp_len; 6010275970Scy char *concat_name; 6011275970Scy 6012275970Scy lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013275970Scy nonempty (wrapper)); 6014275970Scy 6015275970Scy if ((wrapper == NULL) || (*wrapper == '\0')) 6016275970Scy return NULL; 6017275970Scy 6018275970Scy /* Absolute path? */ 6019316068Sdelphij#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020275970Scy if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021275970Scy { 6022275970Scy concat_name = xstrdup (wrapper); 6023275970Scy if (check_executable (concat_name)) 6024275970Scy return concat_name; 6025275970Scy XFREE (concat_name); 6026275970Scy } 6027275970Scy else 6028275970Scy { 6029275970Scy#endif 6030275970Scy if (IS_DIR_SEPARATOR (wrapper[0])) 6031275970Scy { 6032275970Scy concat_name = xstrdup (wrapper); 6033275970Scy if (check_executable (concat_name)) 6034275970Scy return concat_name; 6035275970Scy XFREE (concat_name); 6036275970Scy } 6037316068Sdelphij#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038275970Scy } 6039275970Scy#endif 6040275970Scy 6041275970Scy for (p = wrapper; *p; p++) 6042275970Scy if (*p == '/') 6043275970Scy { 6044275970Scy has_slash = 1; 6045275970Scy break; 6046275970Scy } 6047275970Scy if (!has_slash) 6048275970Scy { 6049275970Scy /* no slashes; search PATH */ 6050275970Scy const char *path = getenv ("PATH"); 6051275970Scy if (path != NULL) 6052275970Scy { 6053275970Scy for (p = path; *p; p = p_next) 6054275970Scy { 6055275970Scy const char *q; 6056275970Scy size_t p_len; 6057275970Scy for (q = p; *q; q++) 6058275970Scy if (IS_PATH_SEPARATOR (*q)) 6059275970Scy break; 6060316068Sdelphij p_len = (size_t) (q - p); 6061275970Scy p_next = (*q == '\0' ? q : q + 1); 6062275970Scy if (p_len == 0) 6063275970Scy { 6064275970Scy /* empty path: current directory */ 6065275970Scy if (getcwd (tmp, LT_PATHMAX) == NULL) 6066275970Scy lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067275970Scy nonnull (strerror (errno))); 6068275970Scy tmp_len = strlen (tmp); 6069275970Scy concat_name = 6070275970Scy XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071275970Scy memcpy (concat_name, tmp, tmp_len); 6072275970Scy concat_name[tmp_len] = '/'; 6073275970Scy strcpy (concat_name + tmp_len + 1, wrapper); 6074275970Scy } 6075275970Scy else 6076275970Scy { 6077275970Scy concat_name = 6078275970Scy XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079275970Scy memcpy (concat_name, p, p_len); 6080275970Scy concat_name[p_len] = '/'; 6081275970Scy strcpy (concat_name + p_len + 1, wrapper); 6082275970Scy } 6083275970Scy if (check_executable (concat_name)) 6084275970Scy return concat_name; 6085275970Scy XFREE (concat_name); 6086275970Scy } 6087275970Scy } 6088275970Scy /* not found in PATH; assume curdir */ 6089275970Scy } 6090275970Scy /* Relative path | not found in path: prepend cwd */ 6091275970Scy if (getcwd (tmp, LT_PATHMAX) == NULL) 6092275970Scy lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093275970Scy nonnull (strerror (errno))); 6094275970Scy tmp_len = strlen (tmp); 6095275970Scy concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096275970Scy memcpy (concat_name, tmp, tmp_len); 6097275970Scy concat_name[tmp_len] = '/'; 6098275970Scy strcpy (concat_name + tmp_len + 1, wrapper); 6099275970Scy 6100275970Scy if (check_executable (concat_name)) 6101275970Scy return concat_name; 6102275970Scy XFREE (concat_name); 6103275970Scy return NULL; 6104275970Scy} 6105275970Scy 6106275970Scychar * 6107275970Scychase_symlinks (const char *pathspec) 6108275970Scy{ 6109275970Scy#ifndef S_ISLNK 6110275970Scy return xstrdup (pathspec); 6111275970Scy#else 6112275970Scy char buf[LT_PATHMAX]; 6113275970Scy struct stat s; 6114275970Scy char *tmp_pathspec = xstrdup (pathspec); 6115275970Scy char *p; 6116275970Scy int has_symlinks = 0; 6117275970Scy while (strlen (tmp_pathspec) && !has_symlinks) 6118275970Scy { 6119275970Scy lt_debugprintf (__FILE__, __LINE__, 6120275970Scy "checking path component for symlinks: %s\n", 6121275970Scy tmp_pathspec); 6122275970Scy if (lstat (tmp_pathspec, &s) == 0) 6123275970Scy { 6124275970Scy if (S_ISLNK (s.st_mode) != 0) 6125275970Scy { 6126275970Scy has_symlinks = 1; 6127275970Scy break; 6128275970Scy } 6129275970Scy 6130275970Scy /* search backwards for last DIR_SEPARATOR */ 6131275970Scy p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132275970Scy while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133275970Scy p--; 6134275970Scy if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135275970Scy { 6136275970Scy /* no more DIR_SEPARATORS left */ 6137275970Scy break; 6138275970Scy } 6139275970Scy *p = '\0'; 6140275970Scy } 6141275970Scy else 6142275970Scy { 6143275970Scy lt_fatal (__FILE__, __LINE__, 6144275970Scy "error accessing file \"%s\": %s", 6145275970Scy tmp_pathspec, nonnull (strerror (errno))); 6146275970Scy } 6147275970Scy } 6148275970Scy XFREE (tmp_pathspec); 6149275970Scy 6150275970Scy if (!has_symlinks) 6151275970Scy { 6152275970Scy return xstrdup (pathspec); 6153275970Scy } 6154275970Scy 6155275970Scy tmp_pathspec = realpath (pathspec, buf); 6156275970Scy if (tmp_pathspec == 0) 6157275970Scy { 6158275970Scy lt_fatal (__FILE__, __LINE__, 6159275970Scy "could not follow symlinks for %s", pathspec); 6160275970Scy } 6161275970Scy return xstrdup (tmp_pathspec); 6162275970Scy#endif 6163275970Scy} 6164275970Scy 6165275970Scychar * 6166275970Scystrendzap (char *str, const char *pat) 6167275970Scy{ 6168275970Scy size_t len, patlen; 6169275970Scy 6170275970Scy assert (str != NULL); 6171275970Scy assert (pat != NULL); 6172275970Scy 6173275970Scy len = strlen (str); 6174275970Scy patlen = strlen (pat); 6175275970Scy 6176275970Scy if (patlen <= len) 6177275970Scy { 6178275970Scy str += len - patlen; 6179316068Sdelphij if (STREQ (str, pat)) 6180275970Scy *str = '\0'; 6181275970Scy } 6182275970Scy return str; 6183275970Scy} 6184275970Scy 6185275970Scyvoid 6186275970Scylt_debugprintf (const char *file, int line, const char *fmt, ...) 6187275970Scy{ 6188275970Scy va_list args; 6189275970Scy if (lt_debug) 6190275970Scy { 6191275970Scy (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192275970Scy va_start (args, fmt); 6193275970Scy (void) vfprintf (stderr, fmt, args); 6194275970Scy va_end (args); 6195275970Scy } 6196275970Scy} 6197275970Scy 6198275970Scystatic void 6199275970Scylt_error_core (int exit_status, const char *file, 6200275970Scy int line, const char *mode, 6201275970Scy const char *message, va_list ap) 6202275970Scy{ 6203275970Scy fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204275970Scy vfprintf (stderr, message, ap); 6205275970Scy fprintf (stderr, ".\n"); 6206275970Scy 6207275970Scy if (exit_status >= 0) 6208275970Scy exit (exit_status); 6209275970Scy} 6210275970Scy 6211275970Scyvoid 6212275970Scylt_fatal (const char *file, int line, const char *message, ...) 6213275970Scy{ 6214275970Scy va_list ap; 6215275970Scy va_start (ap, message); 6216275970Scy lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217275970Scy va_end (ap); 6218275970Scy} 6219275970Scy 6220275970Scystatic const char * 6221275970Scynonnull (const char *s) 6222275970Scy{ 6223275970Scy return s ? s : "(null)"; 6224275970Scy} 6225275970Scy 6226275970Scystatic const char * 6227275970Scynonempty (const char *s) 6228275970Scy{ 6229275970Scy return (s && !*s) ? "(empty)" : nonnull (s); 6230275970Scy} 6231275970Scy 6232275970Scyvoid 6233275970Scylt_setenv (const char *name, const char *value) 6234275970Scy{ 6235275970Scy lt_debugprintf (__FILE__, __LINE__, 6236275970Scy "(lt_setenv) setting '%s' to '%s'\n", 6237275970Scy nonnull (name), nonnull (value)); 6238275970Scy { 6239275970Scy#ifdef HAVE_SETENV 6240275970Scy /* always make a copy, for consistency with !HAVE_SETENV */ 6241275970Scy char *str = xstrdup (value); 6242275970Scy setenv (name, str, 1); 6243275970Scy#else 6244316068Sdelphij size_t len = strlen (name) + 1 + strlen (value) + 1; 6245275970Scy char *str = XMALLOC (char, len); 6246275970Scy sprintf (str, "%s=%s", name, value); 6247275970Scy if (putenv (str) != EXIT_SUCCESS) 6248275970Scy { 6249275970Scy XFREE (str); 6250275970Scy } 6251275970Scy#endif 6252275970Scy } 6253275970Scy} 6254275970Scy 6255275970Scychar * 6256275970Scylt_extend_str (const char *orig_value, const char *add, int to_end) 6257275970Scy{ 6258275970Scy char *new_value; 6259275970Scy if (orig_value && *orig_value) 6260275970Scy { 6261316068Sdelphij size_t orig_value_len = strlen (orig_value); 6262316068Sdelphij size_t add_len = strlen (add); 6263275970Scy new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264275970Scy if (to_end) 6265275970Scy { 6266275970Scy strcpy (new_value, orig_value); 6267275970Scy strcpy (new_value + orig_value_len, add); 6268275970Scy } 6269275970Scy else 6270275970Scy { 6271275970Scy strcpy (new_value, add); 6272275970Scy strcpy (new_value + add_len, orig_value); 6273275970Scy } 6274275970Scy } 6275275970Scy else 6276275970Scy { 6277275970Scy new_value = xstrdup (add); 6278275970Scy } 6279275970Scy return new_value; 6280275970Scy} 6281275970Scy 6282275970Scyvoid 6283275970Scylt_update_exe_path (const char *name, const char *value) 6284275970Scy{ 6285275970Scy lt_debugprintf (__FILE__, __LINE__, 6286275970Scy "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287275970Scy nonnull (name), nonnull (value)); 6288275970Scy 6289275970Scy if (name && *name && value && *value) 6290275970Scy { 6291275970Scy char *new_value = lt_extend_str (getenv (name), value, 0); 6292275970Scy /* some systems can't cope with a ':'-terminated path #' */ 6293316068Sdelphij size_t len = strlen (new_value); 6294316068Sdelphij while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295275970Scy { 6296316068Sdelphij new_value[--len] = '\0'; 6297275970Scy } 6298275970Scy lt_setenv (name, new_value); 6299275970Scy XFREE (new_value); 6300275970Scy } 6301275970Scy} 6302275970Scy 6303275970Scyvoid 6304275970Scylt_update_lib_path (const char *name, const char *value) 6305275970Scy{ 6306275970Scy lt_debugprintf (__FILE__, __LINE__, 6307275970Scy "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308275970Scy nonnull (name), nonnull (value)); 6309275970Scy 6310275970Scy if (name && *name && value && *value) 6311275970Scy { 6312275970Scy char *new_value = lt_extend_str (getenv (name), value, 0); 6313275970Scy lt_setenv (name, new_value); 6314275970Scy XFREE (new_value); 6315275970Scy } 6316275970Scy} 6317275970Scy 6318275970ScyEOF 6319275970Scy case $host_os in 6320275970Scy mingw*) 6321275970Scy cat <<"EOF" 6322275970Scy 6323275970Scy/* Prepares an argument vector before calling spawn(). 6324275970Scy Note that spawn() does not by itself call the command interpreter 6325275970Scy (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326275970Scy ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327275970Scy GetVersionEx(&v); 6328275970Scy v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329275970Scy }) ? "cmd.exe" : "command.com"). 6330275970Scy Instead it simply concatenates the arguments, separated by ' ', and calls 6331275970Scy CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332275970Scy interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333275970Scy special way: 6334275970Scy - Space and tab are interpreted as delimiters. They are not treated as 6335275970Scy delimiters if they are surrounded by double quotes: "...". 6336275970Scy - Unescaped double quotes are removed from the input. Their only effect is 6337275970Scy that within double quotes, space and tab are treated like normal 6338275970Scy characters. 6339275970Scy - Backslashes not followed by double quotes are not special. 6340275970Scy - But 2*n+1 backslashes followed by a double quote become 6341275970Scy n backslashes followed by a double quote (n >= 0): 6342275970Scy \" -> " 6343275970Scy \\\" -> \" 6344275970Scy \\\\\" -> \\" 6345275970Scy */ 6346275970Scy#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" 6347275970Scy#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" 6348275970Scychar ** 6349275970Scyprepare_spawn (char **argv) 6350275970Scy{ 6351275970Scy size_t argc; 6352275970Scy char **new_argv; 6353275970Scy size_t i; 6354275970Scy 6355275970Scy /* Count number of arguments. */ 6356275970Scy for (argc = 0; argv[argc] != NULL; argc++) 6357275970Scy ; 6358275970Scy 6359275970Scy /* Allocate new argument vector. */ 6360275970Scy new_argv = XMALLOC (char *, argc + 1); 6361275970Scy 6362275970Scy /* Put quoted arguments into the new argument vector. */ 6363275970Scy for (i = 0; i < argc; i++) 6364275970Scy { 6365275970Scy const char *string = argv[i]; 6366275970Scy 6367275970Scy if (string[0] == '\0') 6368275970Scy new_argv[i] = xstrdup ("\"\""); 6369275970Scy else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370275970Scy { 6371275970Scy int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372275970Scy size_t length; 6373275970Scy unsigned int backslashes; 6374275970Scy const char *s; 6375275970Scy char *quoted_string; 6376275970Scy char *p; 6377275970Scy 6378275970Scy length = 0; 6379275970Scy backslashes = 0; 6380275970Scy if (quote_around) 6381275970Scy length++; 6382275970Scy for (s = string; *s != '\0'; s++) 6383275970Scy { 6384275970Scy char c = *s; 6385275970Scy if (c == '"') 6386275970Scy length += backslashes + 1; 6387275970Scy length++; 6388275970Scy if (c == '\\') 6389275970Scy backslashes++; 6390275970Scy else 6391275970Scy backslashes = 0; 6392275970Scy } 6393275970Scy if (quote_around) 6394275970Scy length += backslashes + 1; 6395275970Scy 6396275970Scy quoted_string = XMALLOC (char, length + 1); 6397275970Scy 6398275970Scy p = quoted_string; 6399275970Scy backslashes = 0; 6400275970Scy if (quote_around) 6401275970Scy *p++ = '"'; 6402275970Scy for (s = string; *s != '\0'; s++) 6403275970Scy { 6404275970Scy char c = *s; 6405275970Scy if (c == '"') 6406275970Scy { 6407275970Scy unsigned int j; 6408275970Scy for (j = backslashes + 1; j > 0; j--) 6409275970Scy *p++ = '\\'; 6410275970Scy } 6411275970Scy *p++ = c; 6412275970Scy if (c == '\\') 6413275970Scy backslashes++; 6414275970Scy else 6415275970Scy backslashes = 0; 6416275970Scy } 6417275970Scy if (quote_around) 6418275970Scy { 6419275970Scy unsigned int j; 6420275970Scy for (j = backslashes; j > 0; j--) 6421275970Scy *p++ = '\\'; 6422275970Scy *p++ = '"'; 6423275970Scy } 6424275970Scy *p = '\0'; 6425275970Scy 6426275970Scy new_argv[i] = quoted_string; 6427275970Scy } 6428275970Scy else 6429275970Scy new_argv[i] = (char *) string; 6430275970Scy } 6431275970Scy new_argv[argc] = NULL; 6432275970Scy 6433275970Scy return new_argv; 6434275970Scy} 6435275970ScyEOF 6436275970Scy ;; 6437275970Scy esac 6438275970Scy 6439275970Scy cat <<"EOF" 6440275970Scyvoid lt_dump_script (FILE* f) 6441275970Scy{ 6442275970ScyEOF 6443275970Scy func_emit_wrapper yes | 6444285169Scy $SED -n -e ' 6445285169Scys/^\(.\{79\}\)\(..*\)/\1\ 6446285169Scy\2/ 6447285169Scyh 6448285169Scys/\([\\"]\)/\\\1/g 6449285169Scys/$/\\n/ 6450285169Scys/\([^\n]*\).*/ fputs ("\1", f);/p 6451285169Scyg 6452285169ScyD' 6453275970Scy cat <<"EOF" 6454275970Scy} 6455275970ScyEOF 6456275970Scy} 6457275970Scy# end: func_emit_cwrapperexe_src 6458275970Scy 6459275970Scy# func_win32_import_lib_p ARG 6460275970Scy# True if ARG is an import lib, as indicated by $file_magic_cmd 6461275970Scyfunc_win32_import_lib_p () 6462275970Scy{ 6463316068Sdelphij $debug_cmd 6464316068Sdelphij 6465275970Scy case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466275970Scy *import*) : ;; 6467275970Scy *) false ;; 6468275970Scy esac 6469275970Scy} 6470275970Scy 6471316068Sdelphij# func_suncc_cstd_abi 6472316068Sdelphij# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473316068Sdelphij# Several compiler flags select an ABI that is incompatible with the 6474316068Sdelphij# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475316068Sdelphijfunc_suncc_cstd_abi () 6476316068Sdelphij{ 6477316068Sdelphij $debug_cmd 6478316068Sdelphij 6479316068Sdelphij case " $compile_command " in 6480316068Sdelphij *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481316068Sdelphij suncc_use_cstd_abi=no 6482316068Sdelphij ;; 6483316068Sdelphij *) 6484316068Sdelphij suncc_use_cstd_abi=yes 6485316068Sdelphij ;; 6486316068Sdelphij esac 6487316068Sdelphij} 6488316068Sdelphij 6489275970Scy# func_mode_link arg... 6490275970Scyfunc_mode_link () 6491275970Scy{ 6492316068Sdelphij $debug_cmd 6493316068Sdelphij 6494275970Scy case $host in 6495275970Scy *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496275970Scy # It is impossible to link a dll without this setting, and 6497275970Scy # we shouldn't force the makefile maintainer to figure out 6498316068Sdelphij # what system we are compiling for in order to pass an extra 6499275970Scy # flag for every libtool invocation. 6500275970Scy # allow_undefined=no 6501275970Scy 6502275970Scy # FIXME: Unfortunately, there are problems with the above when trying 6503316068Sdelphij # to make a dll that has undefined symbols, in which case not 6504275970Scy # even a static library is built. For now, we need to specify 6505275970Scy # -no-undefined on the libtool link line when we can be certain 6506275970Scy # that all symbols are satisfied, otherwise we get a static library. 6507275970Scy allow_undefined=yes 6508275970Scy ;; 6509275970Scy *) 6510275970Scy allow_undefined=yes 6511275970Scy ;; 6512275970Scy esac 6513275970Scy libtool_args=$nonopt 6514275970Scy base_compile="$nonopt $@" 6515275970Scy compile_command=$nonopt 6516275970Scy finalize_command=$nonopt 6517275970Scy 6518275970Scy compile_rpath= 6519275970Scy finalize_rpath= 6520275970Scy compile_shlibpath= 6521275970Scy finalize_shlibpath= 6522275970Scy convenience= 6523275970Scy old_convenience= 6524275970Scy deplibs= 6525275970Scy old_deplibs= 6526275970Scy compiler_flags= 6527275970Scy linker_flags= 6528275970Scy dllsearchpath= 6529275970Scy lib_search_path=`pwd` 6530275970Scy inst_prefix_dir= 6531275970Scy new_inherited_linker_flags= 6532275970Scy 6533275970Scy avoid_version=no 6534275970Scy bindir= 6535275970Scy dlfiles= 6536275970Scy dlprefiles= 6537275970Scy dlself=no 6538275970Scy export_dynamic=no 6539275970Scy export_symbols= 6540275970Scy export_symbols_regex= 6541275970Scy generated= 6542275970Scy libobjs= 6543275970Scy ltlibs= 6544275970Scy module=no 6545275970Scy no_install=no 6546275970Scy objs= 6547316068Sdelphij os2dllname= 6548275970Scy non_pic_objects= 6549275970Scy precious_files_regex= 6550275970Scy prefer_static_libs=no 6551316068Sdelphij preload=false 6552275970Scy prev= 6553275970Scy prevarg= 6554275970Scy release= 6555275970Scy rpath= 6556275970Scy xrpath= 6557275970Scy perm_rpath= 6558275970Scy temp_rpath= 6559275970Scy thread_safe=no 6560275970Scy vinfo= 6561275970Scy vinfo_number=no 6562275970Scy weak_libs= 6563316068Sdelphij single_module=$wl-single_module 6564275970Scy func_infer_tag $base_compile 6565275970Scy 6566275970Scy # We need to know -static, to get the right output filenames. 6567275970Scy for arg 6568275970Scy do 6569275970Scy case $arg in 6570275970Scy -shared) 6571316068Sdelphij test yes != "$build_libtool_libs" \ 6572316068Sdelphij && func_fatal_configuration "cannot build a shared library" 6573275970Scy build_old_libs=no 6574275970Scy break 6575275970Scy ;; 6576275970Scy -all-static | -static | -static-libtool-libs) 6577275970Scy case $arg in 6578275970Scy -all-static) 6579316068Sdelphij if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580275970Scy func_warning "complete static linking is impossible in this configuration" 6581275970Scy fi 6582275970Scy if test -n "$link_static_flag"; then 6583275970Scy dlopen_self=$dlopen_self_static 6584275970Scy fi 6585275970Scy prefer_static_libs=yes 6586275970Scy ;; 6587275970Scy -static) 6588275970Scy if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589275970Scy dlopen_self=$dlopen_self_static 6590275970Scy fi 6591275970Scy prefer_static_libs=built 6592275970Scy ;; 6593275970Scy -static-libtool-libs) 6594275970Scy if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595275970Scy dlopen_self=$dlopen_self_static 6596275970Scy fi 6597275970Scy prefer_static_libs=yes 6598275970Scy ;; 6599275970Scy esac 6600275970Scy build_libtool_libs=no 6601275970Scy build_old_libs=yes 6602275970Scy break 6603275970Scy ;; 6604275970Scy esac 6605275970Scy done 6606275970Scy 6607275970Scy # See if our shared archives depend on static archives. 6608275970Scy test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609275970Scy 6610275970Scy # Go through the arguments, transforming them on the way. 6611275970Scy while test "$#" -gt 0; do 6612316068Sdelphij arg=$1 6613275970Scy shift 6614275970Scy func_quote_for_eval "$arg" 6615275970Scy qarg=$func_quote_for_eval_unquoted_result 6616275970Scy func_append libtool_args " $func_quote_for_eval_result" 6617275970Scy 6618275970Scy # If the previous option needs an argument, assign it. 6619275970Scy if test -n "$prev"; then 6620275970Scy case $prev in 6621275970Scy output) 6622275970Scy func_append compile_command " @OUTPUT@" 6623275970Scy func_append finalize_command " @OUTPUT@" 6624275970Scy ;; 6625275970Scy esac 6626275970Scy 6627275970Scy case $prev in 6628275970Scy bindir) 6629316068Sdelphij bindir=$arg 6630275970Scy prev= 6631275970Scy continue 6632275970Scy ;; 6633275970Scy dlfiles|dlprefiles) 6634316068Sdelphij $preload || { 6635275970Scy # Add the symbol object into the linking commands. 6636275970Scy func_append compile_command " @SYMFILE@" 6637275970Scy func_append finalize_command " @SYMFILE@" 6638316068Sdelphij preload=: 6639316068Sdelphij } 6640275970Scy case $arg in 6641275970Scy *.la | *.lo) ;; # We handle these cases below. 6642275970Scy force) 6643316068Sdelphij if test no = "$dlself"; then 6644275970Scy dlself=needless 6645275970Scy export_dynamic=yes 6646275970Scy fi 6647275970Scy prev= 6648275970Scy continue 6649275970Scy ;; 6650275970Scy self) 6651316068Sdelphij if test dlprefiles = "$prev"; then 6652275970Scy dlself=yes 6653316068Sdelphij elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654275970Scy dlself=yes 6655275970Scy else 6656275970Scy dlself=needless 6657275970Scy export_dynamic=yes 6658275970Scy fi 6659275970Scy prev= 6660275970Scy continue 6661275970Scy ;; 6662275970Scy *) 6663316068Sdelphij if test dlfiles = "$prev"; then 6664275970Scy func_append dlfiles " $arg" 6665275970Scy else 6666275970Scy func_append dlprefiles " $arg" 6667275970Scy fi 6668275970Scy prev= 6669275970Scy continue 6670275970Scy ;; 6671275970Scy esac 6672275970Scy ;; 6673275970Scy expsyms) 6674316068Sdelphij export_symbols=$arg 6675275970Scy test -f "$arg" \ 6676316068Sdelphij || func_fatal_error "symbol file '$arg' does not exist" 6677275970Scy prev= 6678275970Scy continue 6679275970Scy ;; 6680275970Scy expsyms_regex) 6681316068Sdelphij export_symbols_regex=$arg 6682275970Scy prev= 6683275970Scy continue 6684275970Scy ;; 6685275970Scy framework) 6686275970Scy case $host in 6687275970Scy *-*-darwin*) 6688275970Scy case "$deplibs " in 6689275970Scy *" $qarg.ltframework "*) ;; 6690275970Scy *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691275970Scy ;; 6692275970Scy esac 6693275970Scy ;; 6694275970Scy esac 6695275970Scy prev= 6696275970Scy continue 6697275970Scy ;; 6698275970Scy inst_prefix) 6699316068Sdelphij inst_prefix_dir=$arg 6700275970Scy prev= 6701275970Scy continue 6702275970Scy ;; 6703316068Sdelphij mllvm) 6704316068Sdelphij # Clang does not use LLVM to link, so we can simply discard any 6705316068Sdelphij # '-mllvm $arg' options when doing the link step. 6706316068Sdelphij prev= 6707316068Sdelphij continue 6708316068Sdelphij ;; 6709275970Scy objectlist) 6710275970Scy if test -f "$arg"; then 6711275970Scy save_arg=$arg 6712275970Scy moreargs= 6713275970Scy for fil in `cat "$save_arg"` 6714275970Scy do 6715275970Scy# func_append moreargs " $fil" 6716275970Scy arg=$fil 6717275970Scy # A libtool-controlled object. 6718275970Scy 6719275970Scy # Check to see that this really is a libtool object. 6720275970Scy if func_lalib_unsafe_p "$arg"; then 6721275970Scy pic_object= 6722275970Scy non_pic_object= 6723275970Scy 6724275970Scy # Read the .lo file 6725275970Scy func_source "$arg" 6726275970Scy 6727275970Scy if test -z "$pic_object" || 6728275970Scy test -z "$non_pic_object" || 6729316068Sdelphij test none = "$pic_object" && 6730316068Sdelphij test none = "$non_pic_object"; then 6731316068Sdelphij func_fatal_error "cannot find name of object for '$arg'" 6732275970Scy fi 6733275970Scy 6734275970Scy # Extract subdirectory from the argument. 6735275970Scy func_dirname "$arg" "/" "" 6736316068Sdelphij xdir=$func_dirname_result 6737275970Scy 6738316068Sdelphij if test none != "$pic_object"; then 6739275970Scy # Prepend the subdirectory the object is found in. 6740316068Sdelphij pic_object=$xdir$pic_object 6741275970Scy 6742316068Sdelphij if test dlfiles = "$prev"; then 6743316068Sdelphij if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744275970Scy func_append dlfiles " $pic_object" 6745275970Scy prev= 6746275970Scy continue 6747275970Scy else 6748275970Scy # If libtool objects are unsupported, then we need to preload. 6749275970Scy prev=dlprefiles 6750275970Scy fi 6751275970Scy fi 6752275970Scy 6753275970Scy # CHECK ME: I think I busted this. -Ossama 6754316068Sdelphij if test dlprefiles = "$prev"; then 6755275970Scy # Preload the old-style object. 6756275970Scy func_append dlprefiles " $pic_object" 6757275970Scy prev= 6758275970Scy fi 6759275970Scy 6760275970Scy # A PIC object. 6761275970Scy func_append libobjs " $pic_object" 6762316068Sdelphij arg=$pic_object 6763275970Scy fi 6764275970Scy 6765275970Scy # Non-PIC object. 6766316068Sdelphij if test none != "$non_pic_object"; then 6767275970Scy # Prepend the subdirectory the object is found in. 6768316068Sdelphij non_pic_object=$xdir$non_pic_object 6769275970Scy 6770275970Scy # A standard non-PIC object 6771275970Scy func_append non_pic_objects " $non_pic_object" 6772316068Sdelphij if test -z "$pic_object" || test none = "$pic_object"; then 6773316068Sdelphij arg=$non_pic_object 6774275970Scy fi 6775275970Scy else 6776275970Scy # If the PIC object exists, use it instead. 6777275970Scy # $xdir was prepended to $pic_object above. 6778316068Sdelphij non_pic_object=$pic_object 6779275970Scy func_append non_pic_objects " $non_pic_object" 6780275970Scy fi 6781275970Scy else 6782275970Scy # Only an error if not doing a dry-run. 6783275970Scy if $opt_dry_run; then 6784275970Scy # Extract subdirectory from the argument. 6785275970Scy func_dirname "$arg" "/" "" 6786316068Sdelphij xdir=$func_dirname_result 6787275970Scy 6788275970Scy func_lo2o "$arg" 6789275970Scy pic_object=$xdir$objdir/$func_lo2o_result 6790275970Scy non_pic_object=$xdir$func_lo2o_result 6791275970Scy func_append libobjs " $pic_object" 6792275970Scy func_append non_pic_objects " $non_pic_object" 6793275970Scy else 6794316068Sdelphij func_fatal_error "'$arg' is not a valid libtool object" 6795275970Scy fi 6796275970Scy fi 6797275970Scy done 6798275970Scy else 6799316068Sdelphij func_fatal_error "link input file '$arg' does not exist" 6800275970Scy fi 6801275970Scy arg=$save_arg 6802275970Scy prev= 6803275970Scy continue 6804275970Scy ;; 6805316068Sdelphij os2dllname) 6806316068Sdelphij os2dllname=$arg 6807316068Sdelphij prev= 6808316068Sdelphij continue 6809316068Sdelphij ;; 6810275970Scy precious_regex) 6811316068Sdelphij precious_files_regex=$arg 6812275970Scy prev= 6813275970Scy continue 6814275970Scy ;; 6815275970Scy release) 6816316068Sdelphij release=-$arg 6817275970Scy prev= 6818275970Scy continue 6819275970Scy ;; 6820275970Scy rpath | xrpath) 6821275970Scy # We need an absolute path. 6822275970Scy case $arg in 6823275970Scy [\\/]* | [A-Za-z]:[\\/]*) ;; 6824275970Scy *) 6825275970Scy func_fatal_error "only absolute run-paths are allowed" 6826275970Scy ;; 6827275970Scy esac 6828316068Sdelphij if test rpath = "$prev"; then 6829275970Scy case "$rpath " in 6830275970Scy *" $arg "*) ;; 6831275970Scy *) func_append rpath " $arg" ;; 6832275970Scy esac 6833275970Scy else 6834275970Scy case "$xrpath " in 6835275970Scy *" $arg "*) ;; 6836275970Scy *) func_append xrpath " $arg" ;; 6837275970Scy esac 6838275970Scy fi 6839275970Scy prev= 6840275970Scy continue 6841275970Scy ;; 6842275970Scy shrext) 6843316068Sdelphij shrext_cmds=$arg 6844275970Scy prev= 6845275970Scy continue 6846275970Scy ;; 6847275970Scy weak) 6848275970Scy func_append weak_libs " $arg" 6849275970Scy prev= 6850275970Scy continue 6851275970Scy ;; 6852275970Scy xcclinker) 6853275970Scy func_append linker_flags " $qarg" 6854275970Scy func_append compiler_flags " $qarg" 6855275970Scy prev= 6856275970Scy func_append compile_command " $qarg" 6857275970Scy func_append finalize_command " $qarg" 6858275970Scy continue 6859275970Scy ;; 6860275970Scy xcompiler) 6861275970Scy func_append compiler_flags " $qarg" 6862275970Scy prev= 6863275970Scy func_append compile_command " $qarg" 6864275970Scy func_append finalize_command " $qarg" 6865275970Scy continue 6866275970Scy ;; 6867275970Scy xlinker) 6868275970Scy func_append linker_flags " $qarg" 6869275970Scy func_append compiler_flags " $wl$qarg" 6870275970Scy prev= 6871275970Scy func_append compile_command " $wl$qarg" 6872275970Scy func_append finalize_command " $wl$qarg" 6873275970Scy continue 6874275970Scy ;; 6875275970Scy *) 6876275970Scy eval "$prev=\"\$arg\"" 6877275970Scy prev= 6878275970Scy continue 6879275970Scy ;; 6880275970Scy esac 6881275970Scy fi # test -n "$prev" 6882275970Scy 6883316068Sdelphij prevarg=$arg 6884275970Scy 6885275970Scy case $arg in 6886275970Scy -all-static) 6887275970Scy if test -n "$link_static_flag"; then 6888275970Scy # See comment for -static flag below, for more details. 6889275970Scy func_append compile_command " $link_static_flag" 6890275970Scy func_append finalize_command " $link_static_flag" 6891275970Scy fi 6892275970Scy continue 6893275970Scy ;; 6894275970Scy 6895275970Scy -allow-undefined) 6896275970Scy # FIXME: remove this flag sometime in the future. 6897316068Sdelphij func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898275970Scy ;; 6899275970Scy 6900275970Scy -avoid-version) 6901275970Scy avoid_version=yes 6902275970Scy continue 6903275970Scy ;; 6904275970Scy 6905275970Scy -bindir) 6906275970Scy prev=bindir 6907275970Scy continue 6908275970Scy ;; 6909275970Scy 6910275970Scy -dlopen) 6911275970Scy prev=dlfiles 6912275970Scy continue 6913275970Scy ;; 6914275970Scy 6915275970Scy -dlpreopen) 6916275970Scy prev=dlprefiles 6917275970Scy continue 6918275970Scy ;; 6919275970Scy 6920275970Scy -export-dynamic) 6921275970Scy export_dynamic=yes 6922275970Scy continue 6923275970Scy ;; 6924275970Scy 6925275970Scy -export-symbols | -export-symbols-regex) 6926275970Scy if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927275970Scy func_fatal_error "more than one -exported-symbols argument is not allowed" 6928275970Scy fi 6929316068Sdelphij if test X-export-symbols = "X$arg"; then 6930275970Scy prev=expsyms 6931275970Scy else 6932275970Scy prev=expsyms_regex 6933275970Scy fi 6934275970Scy continue 6935275970Scy ;; 6936275970Scy 6937275970Scy -framework) 6938275970Scy prev=framework 6939275970Scy continue 6940275970Scy ;; 6941275970Scy 6942275970Scy -inst-prefix-dir) 6943275970Scy prev=inst_prefix 6944275970Scy continue 6945275970Scy ;; 6946275970Scy 6947275970Scy # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948275970Scy # so, if we see these flags be careful not to treat them like -L 6949275970Scy -L[A-Z][A-Z]*:*) 6950275970Scy case $with_gcc/$host in 6951275970Scy no/*-*-irix* | /*-*-irix*) 6952275970Scy func_append compile_command " $arg" 6953275970Scy func_append finalize_command " $arg" 6954275970Scy ;; 6955275970Scy esac 6956275970Scy continue 6957275970Scy ;; 6958275970Scy 6959275970Scy -L*) 6960275970Scy func_stripname "-L" '' "$arg" 6961275970Scy if test -z "$func_stripname_result"; then 6962275970Scy if test "$#" -gt 0; then 6963316068Sdelphij func_fatal_error "require no space between '-L' and '$1'" 6964275970Scy else 6965316068Sdelphij func_fatal_error "need path for '-L' option" 6966275970Scy fi 6967275970Scy fi 6968275970Scy func_resolve_sysroot "$func_stripname_result" 6969275970Scy dir=$func_resolve_sysroot_result 6970275970Scy # We need an absolute path. 6971275970Scy case $dir in 6972275970Scy [\\/]* | [A-Za-z]:[\\/]*) ;; 6973275970Scy *) 6974275970Scy absdir=`cd "$dir" && pwd` 6975275970Scy test -z "$absdir" && \ 6976316068Sdelphij func_fatal_error "cannot determine absolute directory name of '$dir'" 6977316068Sdelphij dir=$absdir 6978275970Scy ;; 6979275970Scy esac 6980275970Scy case "$deplibs " in 6981275970Scy *" -L$dir "* | *" $arg "*) 6982275970Scy # Will only happen for absolute or sysroot arguments 6983275970Scy ;; 6984275970Scy *) 6985275970Scy # Preserve sysroot, but never include relative directories 6986275970Scy case $dir in 6987275970Scy [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988275970Scy *) func_append deplibs " -L$dir" ;; 6989275970Scy esac 6990275970Scy func_append lib_search_path " $dir" 6991275970Scy ;; 6992275970Scy esac 6993275970Scy case $host in 6994275970Scy *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995275970Scy testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996275970Scy case :$dllsearchpath: in 6997275970Scy *":$dir:"*) ;; 6998275970Scy ::) dllsearchpath=$dir;; 6999275970Scy *) func_append dllsearchpath ":$dir";; 7000275970Scy esac 7001275970Scy case :$dllsearchpath: in 7002275970Scy *":$testbindir:"*) ;; 7003275970Scy ::) dllsearchpath=$testbindir;; 7004275970Scy *) func_append dllsearchpath ":$testbindir";; 7005275970Scy esac 7006275970Scy ;; 7007275970Scy esac 7008275970Scy continue 7009275970Scy ;; 7010275970Scy 7011275970Scy -l*) 7012316068Sdelphij if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013275970Scy case $host in 7014275970Scy *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015275970Scy # These systems don't actually have a C or math library (as such) 7016275970Scy continue 7017275970Scy ;; 7018275970Scy *-*-os2*) 7019275970Scy # These systems don't actually have a C library (as such) 7020316068Sdelphij test X-lc = "X$arg" && continue 7021275970Scy ;; 7022316068Sdelphij *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023275970Scy # Do not include libc due to us having libc/libc_r. 7024316068Sdelphij test X-lc = "X$arg" && continue 7025275970Scy ;; 7026275970Scy *-*-rhapsody* | *-*-darwin1.[012]) 7027275970Scy # Rhapsody C and math libraries are in the System framework 7028275970Scy func_append deplibs " System.ltframework" 7029275970Scy continue 7030275970Scy ;; 7031275970Scy *-*-sco3.2v5* | *-*-sco5v6*) 7032275970Scy # Causes problems with __ctype 7033316068Sdelphij test X-lc = "X$arg" && continue 7034275970Scy ;; 7035275970Scy *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036275970Scy # Compiler inserts libc in the correct place for threads to work 7037316068Sdelphij test X-lc = "X$arg" && continue 7038275970Scy ;; 7039275970Scy esac 7040316068Sdelphij elif test X-lc_r = "X$arg"; then 7041275970Scy case $host in 7042316068Sdelphij *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043275970Scy # Do not include libc_r directly, use -pthread flag. 7044275970Scy continue 7045275970Scy ;; 7046275970Scy esac 7047275970Scy fi 7048275970Scy func_append deplibs " $arg" 7049275970Scy continue 7050275970Scy ;; 7051275970Scy 7052316068Sdelphij -mllvm) 7053316068Sdelphij prev=mllvm 7054316068Sdelphij continue 7055316068Sdelphij ;; 7056316068Sdelphij 7057275970Scy -module) 7058275970Scy module=yes 7059275970Scy continue 7060275970Scy ;; 7061275970Scy 7062275970Scy # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063275970Scy # classes, name mangling, and exception handling. 7064275970Scy # Darwin uses the -arch flag to determine output architecture. 7065275970Scy -model|-arch|-isysroot|--sysroot) 7066275970Scy func_append compiler_flags " $arg" 7067275970Scy func_append compile_command " $arg" 7068275970Scy func_append finalize_command " $arg" 7069275970Scy prev=xcompiler 7070275970Scy continue 7071275970Scy ;; 7072275970Scy 7073285169Scy -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074285169Scy |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075275970Scy func_append compiler_flags " $arg" 7076275970Scy func_append compile_command " $arg" 7077275970Scy func_append finalize_command " $arg" 7078275970Scy case "$new_inherited_linker_flags " in 7079275970Scy *" $arg "*) ;; 7080275970Scy * ) func_append new_inherited_linker_flags " $arg" ;; 7081275970Scy esac 7082275970Scy continue 7083275970Scy ;; 7084275970Scy 7085275970Scy -multi_module) 7086316068Sdelphij single_module=$wl-multi_module 7087275970Scy continue 7088275970Scy ;; 7089275970Scy 7090275970Scy -no-fast-install) 7091275970Scy fast_install=no 7092275970Scy continue 7093275970Scy ;; 7094275970Scy 7095275970Scy -no-install) 7096275970Scy case $host in 7097275970Scy *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098275970Scy # The PATH hackery in wrapper scripts is required on Windows 7099275970Scy # and Darwin in order for the loader to find any dlls it needs. 7100316068Sdelphij func_warning "'-no-install' is ignored for $host" 7101316068Sdelphij func_warning "assuming '-no-fast-install' instead" 7102275970Scy fast_install=no 7103275970Scy ;; 7104275970Scy *) no_install=yes ;; 7105275970Scy esac 7106275970Scy continue 7107275970Scy ;; 7108275970Scy 7109275970Scy -no-undefined) 7110275970Scy allow_undefined=no 7111275970Scy continue 7112275970Scy ;; 7113275970Scy 7114275970Scy -objectlist) 7115275970Scy prev=objectlist 7116275970Scy continue 7117275970Scy ;; 7118275970Scy 7119316068Sdelphij -os2dllname) 7120316068Sdelphij prev=os2dllname 7121316068Sdelphij continue 7122316068Sdelphij ;; 7123316068Sdelphij 7124275970Scy -o) prev=output ;; 7125275970Scy 7126275970Scy -precious-files-regex) 7127275970Scy prev=precious_regex 7128275970Scy continue 7129275970Scy ;; 7130275970Scy 7131275970Scy -release) 7132275970Scy prev=release 7133275970Scy continue 7134275970Scy ;; 7135275970Scy 7136275970Scy -rpath) 7137275970Scy prev=rpath 7138275970Scy continue 7139275970Scy ;; 7140275970Scy 7141275970Scy -R) 7142275970Scy prev=xrpath 7143275970Scy continue 7144275970Scy ;; 7145275970Scy 7146275970Scy -R*) 7147275970Scy func_stripname '-R' '' "$arg" 7148275970Scy dir=$func_stripname_result 7149275970Scy # We need an absolute path. 7150275970Scy case $dir in 7151275970Scy [\\/]* | [A-Za-z]:[\\/]*) ;; 7152275970Scy =*) 7153275970Scy func_stripname '=' '' "$dir" 7154275970Scy dir=$lt_sysroot$func_stripname_result 7155275970Scy ;; 7156275970Scy *) 7157275970Scy func_fatal_error "only absolute run-paths are allowed" 7158275970Scy ;; 7159275970Scy esac 7160275970Scy case "$xrpath " in 7161275970Scy *" $dir "*) ;; 7162275970Scy *) func_append xrpath " $dir" ;; 7163275970Scy esac 7164275970Scy continue 7165275970Scy ;; 7166275970Scy 7167275970Scy -shared) 7168275970Scy # The effects of -shared are defined in a previous loop. 7169275970Scy continue 7170275970Scy ;; 7171275970Scy 7172275970Scy -shrext) 7173275970Scy prev=shrext 7174275970Scy continue 7175275970Scy ;; 7176275970Scy 7177275970Scy -static | -static-libtool-libs) 7178275970Scy # The effects of -static are defined in a previous loop. 7179275970Scy # We used to do the same as -all-static on platforms that 7180275970Scy # didn't have a PIC flag, but the assumption that the effects 7181275970Scy # would be equivalent was wrong. It would break on at least 7182275970Scy # Digital Unix and AIX. 7183275970Scy continue 7184275970Scy ;; 7185275970Scy 7186275970Scy -thread-safe) 7187275970Scy thread_safe=yes 7188275970Scy continue 7189275970Scy ;; 7190275970Scy 7191275970Scy -version-info) 7192275970Scy prev=vinfo 7193275970Scy continue 7194275970Scy ;; 7195275970Scy 7196275970Scy -version-number) 7197275970Scy prev=vinfo 7198275970Scy vinfo_number=yes 7199275970Scy continue 7200275970Scy ;; 7201275970Scy 7202275970Scy -weak) 7203275970Scy prev=weak 7204275970Scy continue 7205275970Scy ;; 7206275970Scy 7207275970Scy -Wc,*) 7208275970Scy func_stripname '-Wc,' '' "$arg" 7209275970Scy args=$func_stripname_result 7210275970Scy arg= 7211316068Sdelphij save_ifs=$IFS; IFS=, 7212275970Scy for flag in $args; do 7213316068Sdelphij IFS=$save_ifs 7214275970Scy func_quote_for_eval "$flag" 7215275970Scy func_append arg " $func_quote_for_eval_result" 7216275970Scy func_append compiler_flags " $func_quote_for_eval_result" 7217275970Scy done 7218316068Sdelphij IFS=$save_ifs 7219275970Scy func_stripname ' ' '' "$arg" 7220275970Scy arg=$func_stripname_result 7221275970Scy ;; 7222275970Scy 7223275970Scy -Wl,*) 7224275970Scy func_stripname '-Wl,' '' "$arg" 7225275970Scy args=$func_stripname_result 7226275970Scy arg= 7227316068Sdelphij save_ifs=$IFS; IFS=, 7228275970Scy for flag in $args; do 7229316068Sdelphij IFS=$save_ifs 7230275970Scy func_quote_for_eval "$flag" 7231275970Scy func_append arg " $wl$func_quote_for_eval_result" 7232275970Scy func_append compiler_flags " $wl$func_quote_for_eval_result" 7233275970Scy func_append linker_flags " $func_quote_for_eval_result" 7234275970Scy done 7235316068Sdelphij IFS=$save_ifs 7236275970Scy func_stripname ' ' '' "$arg" 7237275970Scy arg=$func_stripname_result 7238275970Scy ;; 7239275970Scy 7240275970Scy -Xcompiler) 7241275970Scy prev=xcompiler 7242275970Scy continue 7243275970Scy ;; 7244275970Scy 7245275970Scy -Xlinker) 7246275970Scy prev=xlinker 7247275970Scy continue 7248275970Scy ;; 7249275970Scy 7250275970Scy -XCClinker) 7251275970Scy prev=xcclinker 7252275970Scy continue 7253275970Scy ;; 7254275970Scy 7255275970Scy # -msg_* for osf cc 7256275970Scy -msg_*) 7257275970Scy func_quote_for_eval "$arg" 7258316068Sdelphij arg=$func_quote_for_eval_result 7259275970Scy ;; 7260275970Scy 7261275970Scy # Flags to be passed through unchanged, with rationale: 7262275970Scy # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263275970Scy # -r[0-9][0-9]* specify processor for the SGI compiler 7264275970Scy # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265275970Scy # +DA*, +DD* enable 64-bit mode for the HP compiler 7266275970Scy # -q* compiler args for the IBM compiler 7267275970Scy # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268275970Scy # -F/path path to uninstalled frameworks, gcc on darwin 7269275970Scy # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270316068Sdelphij # -fstack-protector* stack protector flags for GCC 7271275970Scy # @file GCC response files 7272275970Scy # -tp=* Portland pgcc target processor selection 7273275970Scy # --sysroot=* for sysroot support 7274316068Sdelphij # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275316068Sdelphij # -stdlib=* select c++ std lib with clang 7276275970Scy -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7277275970Scy -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7278316068Sdelphij -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7279275970Scy func_quote_for_eval "$arg" 7280316068Sdelphij arg=$func_quote_for_eval_result 7281275970Scy func_append compile_command " $arg" 7282275970Scy func_append finalize_command " $arg" 7283275970Scy func_append compiler_flags " $arg" 7284275970Scy continue 7285275970Scy ;; 7286275970Scy 7287316068Sdelphij -Z*) 7288316068Sdelphij if test os2 = "`expr $host : '.*\(os2\)'`"; then 7289316068Sdelphij # OS/2 uses -Zxxx to specify OS/2-specific options 7290316068Sdelphij compiler_flags="$compiler_flags $arg" 7291316068Sdelphij func_append compile_command " $arg" 7292316068Sdelphij func_append finalize_command " $arg" 7293316068Sdelphij case $arg in 7294316068Sdelphij -Zlinker | -Zstack) 7295316068Sdelphij prev=xcompiler 7296316068Sdelphij ;; 7297316068Sdelphij esac 7298316068Sdelphij continue 7299316068Sdelphij else 7300316068Sdelphij # Otherwise treat like 'Some other compiler flag' below 7301316068Sdelphij func_quote_for_eval "$arg" 7302316068Sdelphij arg=$func_quote_for_eval_result 7303316068Sdelphij fi 7304316068Sdelphij ;; 7305316068Sdelphij 7306275970Scy # Some other compiler flag. 7307275970Scy -* | +*) 7308275970Scy func_quote_for_eval "$arg" 7309316068Sdelphij arg=$func_quote_for_eval_result 7310275970Scy ;; 7311275970Scy 7312275970Scy *.$objext) 7313275970Scy # A standard object. 7314275970Scy func_append objs " $arg" 7315275970Scy ;; 7316275970Scy 7317275970Scy *.lo) 7318275970Scy # A libtool-controlled object. 7319275970Scy 7320275970Scy # Check to see that this really is a libtool object. 7321275970Scy if func_lalib_unsafe_p "$arg"; then 7322275970Scy pic_object= 7323275970Scy non_pic_object= 7324275970Scy 7325275970Scy # Read the .lo file 7326275970Scy func_source "$arg" 7327275970Scy 7328275970Scy if test -z "$pic_object" || 7329275970Scy test -z "$non_pic_object" || 7330316068Sdelphij test none = "$pic_object" && 7331316068Sdelphij test none = "$non_pic_object"; then 7332316068Sdelphij func_fatal_error "cannot find name of object for '$arg'" 7333275970Scy fi 7334275970Scy 7335275970Scy # Extract subdirectory from the argument. 7336275970Scy func_dirname "$arg" "/" "" 7337316068Sdelphij xdir=$func_dirname_result 7338275970Scy 7339316068Sdelphij test none = "$pic_object" || { 7340275970Scy # Prepend the subdirectory the object is found in. 7341316068Sdelphij pic_object=$xdir$pic_object 7342275970Scy 7343316068Sdelphij if test dlfiles = "$prev"; then 7344316068Sdelphij if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7345275970Scy func_append dlfiles " $pic_object" 7346275970Scy prev= 7347275970Scy continue 7348275970Scy else 7349275970Scy # If libtool objects are unsupported, then we need to preload. 7350275970Scy prev=dlprefiles 7351275970Scy fi 7352275970Scy fi 7353275970Scy 7354275970Scy # CHECK ME: I think I busted this. -Ossama 7355316068Sdelphij if test dlprefiles = "$prev"; then 7356275970Scy # Preload the old-style object. 7357275970Scy func_append dlprefiles " $pic_object" 7358275970Scy prev= 7359275970Scy fi 7360275970Scy 7361275970Scy # A PIC object. 7362275970Scy func_append libobjs " $pic_object" 7363316068Sdelphij arg=$pic_object 7364316068Sdelphij } 7365275970Scy 7366275970Scy # Non-PIC object. 7367316068Sdelphij if test none != "$non_pic_object"; then 7368275970Scy # Prepend the subdirectory the object is found in. 7369316068Sdelphij non_pic_object=$xdir$non_pic_object 7370275970Scy 7371275970Scy # A standard non-PIC object 7372275970Scy func_append non_pic_objects " $non_pic_object" 7373316068Sdelphij if test -z "$pic_object" || test none = "$pic_object"; then 7374316068Sdelphij arg=$non_pic_object 7375275970Scy fi 7376275970Scy else 7377275970Scy # If the PIC object exists, use it instead. 7378275970Scy # $xdir was prepended to $pic_object above. 7379316068Sdelphij non_pic_object=$pic_object 7380275970Scy func_append non_pic_objects " $non_pic_object" 7381275970Scy fi 7382275970Scy else 7383275970Scy # Only an error if not doing a dry-run. 7384275970Scy if $opt_dry_run; then 7385275970Scy # Extract subdirectory from the argument. 7386275970Scy func_dirname "$arg" "/" "" 7387316068Sdelphij xdir=$func_dirname_result 7388275970Scy 7389275970Scy func_lo2o "$arg" 7390275970Scy pic_object=$xdir$objdir/$func_lo2o_result 7391275970Scy non_pic_object=$xdir$func_lo2o_result 7392275970Scy func_append libobjs " $pic_object" 7393275970Scy func_append non_pic_objects " $non_pic_object" 7394275970Scy else 7395316068Sdelphij func_fatal_error "'$arg' is not a valid libtool object" 7396275970Scy fi 7397275970Scy fi 7398275970Scy ;; 7399275970Scy 7400275970Scy *.$libext) 7401275970Scy # An archive. 7402275970Scy func_append deplibs " $arg" 7403275970Scy func_append old_deplibs " $arg" 7404275970Scy continue 7405275970Scy ;; 7406275970Scy 7407275970Scy *.la) 7408275970Scy # A libtool-controlled library. 7409275970Scy 7410275970Scy func_resolve_sysroot "$arg" 7411316068Sdelphij if test dlfiles = "$prev"; then 7412275970Scy # This library was specified with -dlopen. 7413275970Scy func_append dlfiles " $func_resolve_sysroot_result" 7414275970Scy prev= 7415316068Sdelphij elif test dlprefiles = "$prev"; then 7416275970Scy # The library was specified with -dlpreopen. 7417275970Scy func_append dlprefiles " $func_resolve_sysroot_result" 7418275970Scy prev= 7419275970Scy else 7420275970Scy func_append deplibs " $func_resolve_sysroot_result" 7421275970Scy fi 7422275970Scy continue 7423275970Scy ;; 7424275970Scy 7425275970Scy # Some other compiler argument. 7426275970Scy *) 7427275970Scy # Unknown arguments in both finalize_command and compile_command need 7428275970Scy # to be aesthetically quoted because they are evaled later. 7429275970Scy func_quote_for_eval "$arg" 7430316068Sdelphij arg=$func_quote_for_eval_result 7431275970Scy ;; 7432275970Scy esac # arg 7433275970Scy 7434275970Scy # Now actually substitute the argument into the commands. 7435275970Scy if test -n "$arg"; then 7436275970Scy func_append compile_command " $arg" 7437275970Scy func_append finalize_command " $arg" 7438275970Scy fi 7439275970Scy done # argument parsing loop 7440275970Scy 7441275970Scy test -n "$prev" && \ 7442316068Sdelphij func_fatal_help "the '$prevarg' option requires an argument" 7443275970Scy 7444316068Sdelphij if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7445275970Scy eval arg=\"$export_dynamic_flag_spec\" 7446275970Scy func_append compile_command " $arg" 7447275970Scy func_append finalize_command " $arg" 7448275970Scy fi 7449275970Scy 7450275970Scy oldlibs= 7451275970Scy # calculate the name of the file, without its directory 7452275970Scy func_basename "$output" 7453316068Sdelphij outputname=$func_basename_result 7454316068Sdelphij libobjs_save=$libobjs 7455275970Scy 7456275970Scy if test -n "$shlibpath_var"; then 7457275970Scy # get the directories listed in $shlibpath_var 7458316068Sdelphij eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7459275970Scy else 7460275970Scy shlib_search_path= 7461275970Scy fi 7462275970Scy eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7463275970Scy eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7464275970Scy 7465316068Sdelphij # Definition is injected by LT_CONFIG during libtool generation. 7466316068Sdelphij func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7467316068Sdelphij 7468275970Scy func_dirname "$output" "/" "" 7469316068Sdelphij output_objdir=$func_dirname_result$objdir 7470275970Scy func_to_tool_file "$output_objdir/" 7471275970Scy tool_output_objdir=$func_to_tool_file_result 7472275970Scy # Create the object directory. 7473275970Scy func_mkdir_p "$output_objdir" 7474275970Scy 7475275970Scy # Determine the type of output 7476275970Scy case $output in 7477275970Scy "") 7478275970Scy func_fatal_help "you must specify an output file" 7479275970Scy ;; 7480275970Scy *.$libext) linkmode=oldlib ;; 7481275970Scy *.lo | *.$objext) linkmode=obj ;; 7482275970Scy *.la) linkmode=lib ;; 7483275970Scy *) linkmode=prog ;; # Anything else should be a program. 7484275970Scy esac 7485275970Scy 7486275970Scy specialdeplibs= 7487275970Scy 7488275970Scy libs= 7489275970Scy # Find all interdependent deplibs by searching for libraries 7490275970Scy # that are linked more than once (e.g. -la -lb -la) 7491275970Scy for deplib in $deplibs; do 7492316068Sdelphij if $opt_preserve_dup_deps; then 7493275970Scy case "$libs " in 7494275970Scy *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7495275970Scy esac 7496275970Scy fi 7497275970Scy func_append libs " $deplib" 7498275970Scy done 7499275970Scy 7500316068Sdelphij if test lib = "$linkmode"; then 7501275970Scy libs="$predeps $libs $compiler_lib_search_path $postdeps" 7502275970Scy 7503275970Scy # Compute libraries that are listed more than once in $predeps 7504275970Scy # $postdeps and mark them as special (i.e., whose duplicates are 7505275970Scy # not to be eliminated). 7506275970Scy pre_post_deps= 7507275970Scy if $opt_duplicate_compiler_generated_deps; then 7508275970Scy for pre_post_dep in $predeps $postdeps; do 7509275970Scy case "$pre_post_deps " in 7510275970Scy *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7511275970Scy esac 7512275970Scy func_append pre_post_deps " $pre_post_dep" 7513275970Scy done 7514275970Scy fi 7515275970Scy pre_post_deps= 7516275970Scy fi 7517275970Scy 7518275970Scy deplibs= 7519275970Scy newdependency_libs= 7520275970Scy newlib_search_path= 7521275970Scy need_relink=no # whether we're linking any uninstalled libtool libraries 7522275970Scy notinst_deplibs= # not-installed libtool libraries 7523275970Scy notinst_path= # paths that contain not-installed libtool libraries 7524275970Scy 7525275970Scy case $linkmode in 7526275970Scy lib) 7527275970Scy passes="conv dlpreopen link" 7528275970Scy for file in $dlfiles $dlprefiles; do 7529275970Scy case $file in 7530275970Scy *.la) ;; 7531275970Scy *) 7532316068Sdelphij func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7533275970Scy ;; 7534275970Scy esac 7535275970Scy done 7536275970Scy ;; 7537275970Scy prog) 7538275970Scy compile_deplibs= 7539275970Scy finalize_deplibs= 7540316068Sdelphij alldeplibs=false 7541275970Scy newdlfiles= 7542275970Scy newdlprefiles= 7543275970Scy passes="conv scan dlopen dlpreopen link" 7544275970Scy ;; 7545275970Scy *) passes="conv" 7546275970Scy ;; 7547275970Scy esac 7548275970Scy 7549275970Scy for pass in $passes; do 7550275970Scy # The preopen pass in lib mode reverses $deplibs; put it back here 7551275970Scy # so that -L comes before libs that need it for instance... 7552316068Sdelphij if test lib,link = "$linkmode,$pass"; then 7553275970Scy ## FIXME: Find the place where the list is rebuilt in the wrong 7554275970Scy ## order, and fix it there properly 7555275970Scy tmp_deplibs= 7556275970Scy for deplib in $deplibs; do 7557275970Scy tmp_deplibs="$deplib $tmp_deplibs" 7558275970Scy done 7559316068Sdelphij deplibs=$tmp_deplibs 7560275970Scy fi 7561275970Scy 7562316068Sdelphij if test lib,link = "$linkmode,$pass" || 7563316068Sdelphij test prog,scan = "$linkmode,$pass"; then 7564316068Sdelphij libs=$deplibs 7565275970Scy deplibs= 7566275970Scy fi 7567316068Sdelphij if test prog = "$linkmode"; then 7568275970Scy case $pass in 7569316068Sdelphij dlopen) libs=$dlfiles ;; 7570316068Sdelphij dlpreopen) libs=$dlprefiles ;; 7571275970Scy link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7572275970Scy esac 7573275970Scy fi 7574316068Sdelphij if test lib,dlpreopen = "$linkmode,$pass"; then 7575275970Scy # Collect and forward deplibs of preopened libtool libs 7576275970Scy for lib in $dlprefiles; do 7577275970Scy # Ignore non-libtool-libs 7578275970Scy dependency_libs= 7579275970Scy func_resolve_sysroot "$lib" 7580275970Scy case $lib in 7581275970Scy *.la) func_source "$func_resolve_sysroot_result" ;; 7582275970Scy esac 7583275970Scy 7584275970Scy # Collect preopened libtool deplibs, except any this library 7585275970Scy # has declared as weak libs 7586275970Scy for deplib in $dependency_libs; do 7587275970Scy func_basename "$deplib" 7588275970Scy deplib_base=$func_basename_result 7589275970Scy case " $weak_libs " in 7590275970Scy *" $deplib_base "*) ;; 7591275970Scy *) func_append deplibs " $deplib" ;; 7592275970Scy esac 7593275970Scy done 7594275970Scy done 7595316068Sdelphij libs=$dlprefiles 7596275970Scy fi 7597316068Sdelphij if test dlopen = "$pass"; then 7598275970Scy # Collect dlpreopened libraries 7599316068Sdelphij save_deplibs=$deplibs 7600275970Scy deplibs= 7601275970Scy fi 7602275970Scy 7603275970Scy for deplib in $libs; do 7604275970Scy lib= 7605316068Sdelphij found=false 7606275970Scy case $deplib in 7607285169Scy -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608285169Scy |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7609316068Sdelphij if test prog,link = "$linkmode,$pass"; then 7610275970Scy compile_deplibs="$deplib $compile_deplibs" 7611275970Scy finalize_deplibs="$deplib $finalize_deplibs" 7612275970Scy else 7613275970Scy func_append compiler_flags " $deplib" 7614316068Sdelphij if test lib = "$linkmode"; then 7615275970Scy case "$new_inherited_linker_flags " in 7616275970Scy *" $deplib "*) ;; 7617275970Scy * ) func_append new_inherited_linker_flags " $deplib" ;; 7618275970Scy esac 7619275970Scy fi 7620275970Scy fi 7621275970Scy continue 7622275970Scy ;; 7623275970Scy -l*) 7624316068Sdelphij if test lib != "$linkmode" && test prog != "$linkmode"; then 7625316068Sdelphij func_warning "'-l' is ignored for archives/objects" 7626275970Scy continue 7627275970Scy fi 7628275970Scy func_stripname '-l' '' "$deplib" 7629275970Scy name=$func_stripname_result 7630316068Sdelphij if test lib = "$linkmode"; then 7631275970Scy searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7632275970Scy else 7633275970Scy searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7634275970Scy fi 7635275970Scy for searchdir in $searchdirs; do 7636275970Scy for search_ext in .la $std_shrext .so .a; do 7637275970Scy # Search the libtool library 7638316068Sdelphij lib=$searchdir/lib$name$search_ext 7639275970Scy if test -f "$lib"; then 7640316068Sdelphij if test .la = "$search_ext"; then 7641316068Sdelphij found=: 7642275970Scy else 7643316068Sdelphij found=false 7644275970Scy fi 7645275970Scy break 2 7646275970Scy fi 7647275970Scy done 7648275970Scy done 7649316068Sdelphij if $found; then 7650316068Sdelphij # deplib is a libtool library 7651275970Scy # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7652275970Scy # We need to do some special things here, and not later. 7653316068Sdelphij if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7654275970Scy case " $predeps $postdeps " in 7655275970Scy *" $deplib "*) 7656275970Scy if func_lalib_p "$lib"; then 7657275970Scy library_names= 7658275970Scy old_library= 7659275970Scy func_source "$lib" 7660275970Scy for l in $old_library $library_names; do 7661316068Sdelphij ll=$l 7662275970Scy done 7663316068Sdelphij if test "X$ll" = "X$old_library"; then # only static version available 7664316068Sdelphij found=false 7665275970Scy func_dirname "$lib" "" "." 7666316068Sdelphij ladir=$func_dirname_result 7667275970Scy lib=$ladir/$old_library 7668316068Sdelphij if test prog,link = "$linkmode,$pass"; then 7669275970Scy compile_deplibs="$deplib $compile_deplibs" 7670275970Scy finalize_deplibs="$deplib $finalize_deplibs" 7671275970Scy else 7672275970Scy deplibs="$deplib $deplibs" 7673316068Sdelphij test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7674275970Scy fi 7675275970Scy continue 7676275970Scy fi 7677275970Scy fi 7678275970Scy ;; 7679275970Scy *) ;; 7680275970Scy esac 7681275970Scy fi 7682316068Sdelphij else 7683316068Sdelphij # deplib doesn't seem to be a libtool library 7684316068Sdelphij if test prog,link = "$linkmode,$pass"; then 7685316068Sdelphij compile_deplibs="$deplib $compile_deplibs" 7686316068Sdelphij finalize_deplibs="$deplib $finalize_deplibs" 7687316068Sdelphij else 7688316068Sdelphij deplibs="$deplib $deplibs" 7689316068Sdelphij test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7690316068Sdelphij fi 7691316068Sdelphij continue 7692275970Scy fi 7693275970Scy ;; # -l 7694275970Scy *.ltframework) 7695316068Sdelphij if test prog,link = "$linkmode,$pass"; then 7696275970Scy compile_deplibs="$deplib $compile_deplibs" 7697275970Scy finalize_deplibs="$deplib $finalize_deplibs" 7698275970Scy else 7699275970Scy deplibs="$deplib $deplibs" 7700316068Sdelphij if test lib = "$linkmode"; then 7701275970Scy case "$new_inherited_linker_flags " in 7702275970Scy *" $deplib "*) ;; 7703275970Scy * ) func_append new_inherited_linker_flags " $deplib" ;; 7704275970Scy esac 7705275970Scy fi 7706275970Scy fi 7707275970Scy continue 7708275970Scy ;; 7709275970Scy -L*) 7710275970Scy case $linkmode in 7711275970Scy lib) 7712275970Scy deplibs="$deplib $deplibs" 7713316068Sdelphij test conv = "$pass" && continue 7714275970Scy newdependency_libs="$deplib $newdependency_libs" 7715275970Scy func_stripname '-L' '' "$deplib" 7716275970Scy func_resolve_sysroot "$func_stripname_result" 7717275970Scy func_append newlib_search_path " $func_resolve_sysroot_result" 7718275970Scy ;; 7719275970Scy prog) 7720316068Sdelphij if test conv = "$pass"; then 7721275970Scy deplibs="$deplib $deplibs" 7722275970Scy continue 7723275970Scy fi 7724316068Sdelphij if test scan = "$pass"; then 7725275970Scy deplibs="$deplib $deplibs" 7726275970Scy else 7727275970Scy compile_deplibs="$deplib $compile_deplibs" 7728275970Scy finalize_deplibs="$deplib $finalize_deplibs" 7729275970Scy fi 7730275970Scy func_stripname '-L' '' "$deplib" 7731275970Scy func_resolve_sysroot "$func_stripname_result" 7732275970Scy func_append newlib_search_path " $func_resolve_sysroot_result" 7733275970Scy ;; 7734275970Scy *) 7735316068Sdelphij func_warning "'-L' is ignored for archives/objects" 7736275970Scy ;; 7737275970Scy esac # linkmode 7738275970Scy continue 7739275970Scy ;; # -L 7740275970Scy -R*) 7741316068Sdelphij if test link = "$pass"; then 7742275970Scy func_stripname '-R' '' "$deplib" 7743275970Scy func_resolve_sysroot "$func_stripname_result" 7744275970Scy dir=$func_resolve_sysroot_result 7745275970Scy # Make sure the xrpath contains only unique directories. 7746275970Scy case "$xrpath " in 7747275970Scy *" $dir "*) ;; 7748275970Scy *) func_append xrpath " $dir" ;; 7749275970Scy esac 7750275970Scy fi 7751275970Scy deplibs="$deplib $deplibs" 7752275970Scy continue 7753275970Scy ;; 7754275970Scy *.la) 7755275970Scy func_resolve_sysroot "$deplib" 7756275970Scy lib=$func_resolve_sysroot_result 7757275970Scy ;; 7758275970Scy *.$libext) 7759316068Sdelphij if test conv = "$pass"; then 7760275970Scy deplibs="$deplib $deplibs" 7761275970Scy continue 7762275970Scy fi 7763275970Scy case $linkmode in 7764275970Scy lib) 7765275970Scy # Linking convenience modules into shared libraries is allowed, 7766275970Scy # but linking other static libraries is non-portable. 7767275970Scy case " $dlpreconveniencelibs " in 7768275970Scy *" $deplib "*) ;; 7769275970Scy *) 7770316068Sdelphij valid_a_lib=false 7771275970Scy case $deplibs_check_method in 7772275970Scy match_pattern*) 7773275970Scy set dummy $deplibs_check_method; shift 7774275970Scy match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7775275970Scy if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7776275970Scy | $EGREP "$match_pattern_regex" > /dev/null; then 7777316068Sdelphij valid_a_lib=: 7778275970Scy fi 7779275970Scy ;; 7780275970Scy pass_all) 7781316068Sdelphij valid_a_lib=: 7782275970Scy ;; 7783275970Scy esac 7784316068Sdelphij if $valid_a_lib; then 7785275970Scy echo 7786316068Sdelphij $ECHO "*** Warning: Linking the shared library $output against the" 7787316068Sdelphij $ECHO "*** static library $deplib is not portable!" 7788316068Sdelphij deplibs="$deplib $deplibs" 7789316068Sdelphij else 7790316068Sdelphij echo 7791275970Scy $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7792275970Scy echo "*** I have the capability to make that library automatically link in when" 7793275970Scy echo "*** you link to this library. But I can only do this if you have a" 7794275970Scy echo "*** shared version of the library, which you do not appear to have" 7795275970Scy echo "*** because the file extensions .$libext of this argument makes me believe" 7796275970Scy echo "*** that it is just a static archive that I should not use here." 7797275970Scy fi 7798275970Scy ;; 7799275970Scy esac 7800275970Scy continue 7801275970Scy ;; 7802275970Scy prog) 7803316068Sdelphij if test link != "$pass"; then 7804275970Scy deplibs="$deplib $deplibs" 7805275970Scy else 7806275970Scy compile_deplibs="$deplib $compile_deplibs" 7807275970Scy finalize_deplibs="$deplib $finalize_deplibs" 7808275970Scy fi 7809275970Scy continue 7810275970Scy ;; 7811275970Scy esac # linkmode 7812275970Scy ;; # *.$libext 7813275970Scy *.lo | *.$objext) 7814316068Sdelphij if test conv = "$pass"; then 7815275970Scy deplibs="$deplib $deplibs" 7816316068Sdelphij elif test prog = "$linkmode"; then 7817316068Sdelphij if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7818275970Scy # If there is no dlopen support or we're linking statically, 7819275970Scy # we need to preload. 7820275970Scy func_append newdlprefiles " $deplib" 7821275970Scy compile_deplibs="$deplib $compile_deplibs" 7822275970Scy finalize_deplibs="$deplib $finalize_deplibs" 7823275970Scy else 7824275970Scy func_append newdlfiles " $deplib" 7825275970Scy fi 7826275970Scy fi 7827275970Scy continue 7828275970Scy ;; 7829275970Scy %DEPLIBS%) 7830316068Sdelphij alldeplibs=: 7831275970Scy continue 7832275970Scy ;; 7833275970Scy esac # case $deplib 7834275970Scy 7835316068Sdelphij $found || test -f "$lib" \ 7836316068Sdelphij || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7837275970Scy 7838275970Scy # Check to see that this really is a libtool archive. 7839275970Scy func_lalib_unsafe_p "$lib" \ 7840316068Sdelphij || func_fatal_error "'$lib' is not a valid libtool archive" 7841275970Scy 7842275970Scy func_dirname "$lib" "" "." 7843316068Sdelphij ladir=$func_dirname_result 7844275970Scy 7845275970Scy dlname= 7846275970Scy dlopen= 7847275970Scy dlpreopen= 7848275970Scy libdir= 7849275970Scy library_names= 7850275970Scy old_library= 7851275970Scy inherited_linker_flags= 7852275970Scy # If the library was installed with an old release of libtool, 7853275970Scy # it will not redefine variables installed, or shouldnotlink 7854275970Scy installed=yes 7855275970Scy shouldnotlink=no 7856275970Scy avoidtemprpath= 7857275970Scy 7858275970Scy 7859275970Scy # Read the .la file 7860275970Scy func_source "$lib" 7861275970Scy 7862275970Scy # Convert "-framework foo" to "foo.ltframework" 7863275970Scy if test -n "$inherited_linker_flags"; then 7864275970Scy tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7865275970Scy for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7866275970Scy case " $new_inherited_linker_flags " in 7867275970Scy *" $tmp_inherited_linker_flag "*) ;; 7868275970Scy *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7869275970Scy esac 7870275970Scy done 7871275970Scy fi 7872275970Scy dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7873316068Sdelphij if test lib,link = "$linkmode,$pass" || 7874316068Sdelphij test prog,scan = "$linkmode,$pass" || 7875316068Sdelphij { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7876275970Scy test -n "$dlopen" && func_append dlfiles " $dlopen" 7877275970Scy test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7878275970Scy fi 7879275970Scy 7880316068Sdelphij if test conv = "$pass"; then 7881275970Scy # Only check for convenience libraries 7882275970Scy deplibs="$lib $deplibs" 7883275970Scy if test -z "$libdir"; then 7884275970Scy if test -z "$old_library"; then 7885316068Sdelphij func_fatal_error "cannot find name of link library for '$lib'" 7886275970Scy fi 7887275970Scy # It is a libtool convenience library, so add in its objects. 7888275970Scy func_append convenience " $ladir/$objdir/$old_library" 7889275970Scy func_append old_convenience " $ladir/$objdir/$old_library" 7890316068Sdelphij elif test prog != "$linkmode" && test lib != "$linkmode"; then 7891316068Sdelphij func_fatal_error "'$lib' is not a convenience library" 7892275970Scy fi 7893275970Scy tmp_libs= 7894275970Scy for deplib in $dependency_libs; do 7895275970Scy deplibs="$deplib $deplibs" 7896316068Sdelphij if $opt_preserve_dup_deps; then 7897275970Scy case "$tmp_libs " in 7898275970Scy *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899275970Scy esac 7900275970Scy fi 7901275970Scy func_append tmp_libs " $deplib" 7902275970Scy done 7903275970Scy continue 7904275970Scy fi # $pass = conv 7905275970Scy 7906275970Scy 7907275970Scy # Get the name of the library we link against. 7908275970Scy linklib= 7909275970Scy if test -n "$old_library" && 7910316068Sdelphij { test yes = "$prefer_static_libs" || 7911316068Sdelphij test built,no = "$prefer_static_libs,$installed"; }; then 7912275970Scy linklib=$old_library 7913275970Scy else 7914275970Scy for l in $old_library $library_names; do 7915316068Sdelphij linklib=$l 7916275970Scy done 7917275970Scy fi 7918275970Scy if test -z "$linklib"; then 7919316068Sdelphij func_fatal_error "cannot find name of link library for '$lib'" 7920275970Scy fi 7921275970Scy 7922275970Scy # This library was specified with -dlopen. 7923316068Sdelphij if test dlopen = "$pass"; then 7924316068Sdelphij test -z "$libdir" \ 7925316068Sdelphij && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7926275970Scy if test -z "$dlname" || 7927316068Sdelphij test yes != "$dlopen_support" || 7928316068Sdelphij test no = "$build_libtool_libs" 7929316068Sdelphij then 7930275970Scy # If there is no dlname, no dlopen support or we're linking 7931275970Scy # statically, we need to preload. We also need to preload any 7932275970Scy # dependent libraries so libltdl's deplib preloader doesn't 7933275970Scy # bomb out in the load deplibs phase. 7934275970Scy func_append dlprefiles " $lib $dependency_libs" 7935275970Scy else 7936275970Scy func_append newdlfiles " $lib" 7937275970Scy fi 7938275970Scy continue 7939275970Scy fi # $pass = dlopen 7940275970Scy 7941275970Scy # We need an absolute path. 7942275970Scy case $ladir in 7943316068Sdelphij [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7944275970Scy *) 7945275970Scy abs_ladir=`cd "$ladir" && pwd` 7946275970Scy if test -z "$abs_ladir"; then 7947316068Sdelphij func_warning "cannot determine absolute directory name of '$ladir'" 7948275970Scy func_warning "passing it literally to the linker, although it might fail" 7949316068Sdelphij abs_ladir=$ladir 7950275970Scy fi 7951275970Scy ;; 7952275970Scy esac 7953275970Scy func_basename "$lib" 7954316068Sdelphij laname=$func_basename_result 7955275970Scy 7956275970Scy # Find the relevant object directory and library name. 7957316068Sdelphij if test yes = "$installed"; then 7958275970Scy if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7959316068Sdelphij func_warning "library '$lib' was moved." 7960316068Sdelphij dir=$ladir 7961316068Sdelphij absdir=$abs_ladir 7962316068Sdelphij libdir=$abs_ladir 7963275970Scy else 7964316068Sdelphij dir=$lt_sysroot$libdir 7965316068Sdelphij absdir=$lt_sysroot$libdir 7966275970Scy fi 7967316068Sdelphij test yes = "$hardcode_automatic" && avoidtemprpath=yes 7968275970Scy else 7969275970Scy if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7970316068Sdelphij dir=$ladir 7971316068Sdelphij absdir=$abs_ladir 7972275970Scy # Remove this search path later 7973275970Scy func_append notinst_path " $abs_ladir" 7974275970Scy else 7975316068Sdelphij dir=$ladir/$objdir 7976316068Sdelphij absdir=$abs_ladir/$objdir 7977275970Scy # Remove this search path later 7978275970Scy func_append notinst_path " $abs_ladir" 7979275970Scy fi 7980275970Scy fi # $installed = yes 7981275970Scy func_stripname 'lib' '.la' "$laname" 7982275970Scy name=$func_stripname_result 7983275970Scy 7984275970Scy # This library was specified with -dlpreopen. 7985316068Sdelphij if test dlpreopen = "$pass"; then 7986316068Sdelphij if test -z "$libdir" && test prog = "$linkmode"; then 7987316068Sdelphij func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7988275970Scy fi 7989316068Sdelphij case $host in 7990275970Scy # special handling for platforms with PE-DLLs. 7991275970Scy *cygwin* | *mingw* | *cegcc* ) 7992275970Scy # Linker will automatically link against shared library if both 7993275970Scy # static and shared are present. Therefore, ensure we extract 7994275970Scy # symbols from the import library if a shared library is present 7995275970Scy # (otherwise, the dlopen module name will be incorrect). We do 7996275970Scy # this by putting the import library name into $newdlprefiles. 7997275970Scy # We recover the dlopen module name by 'saving' the la file 7998275970Scy # name in a special purpose variable, and (later) extracting the 7999275970Scy # dlname from the la file. 8000275970Scy if test -n "$dlname"; then 8001275970Scy func_tr_sh "$dir/$linklib" 8002275970Scy eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8003275970Scy func_append newdlprefiles " $dir/$linklib" 8004275970Scy else 8005275970Scy func_append newdlprefiles " $dir/$old_library" 8006275970Scy # Keep a list of preopened convenience libraries to check 8007275970Scy # that they are being used correctly in the link pass. 8008275970Scy test -z "$libdir" && \ 8009275970Scy func_append dlpreconveniencelibs " $dir/$old_library" 8010275970Scy fi 8011275970Scy ;; 8012275970Scy * ) 8013275970Scy # Prefer using a static library (so that no silly _DYNAMIC symbols 8014275970Scy # are required to link). 8015275970Scy if test -n "$old_library"; then 8016275970Scy func_append newdlprefiles " $dir/$old_library" 8017275970Scy # Keep a list of preopened convenience libraries to check 8018275970Scy # that they are being used correctly in the link pass. 8019275970Scy test -z "$libdir" && \ 8020275970Scy func_append dlpreconveniencelibs " $dir/$old_library" 8021275970Scy # Otherwise, use the dlname, so that lt_dlopen finds it. 8022275970Scy elif test -n "$dlname"; then 8023275970Scy func_append newdlprefiles " $dir/$dlname" 8024275970Scy else 8025275970Scy func_append newdlprefiles " $dir/$linklib" 8026275970Scy fi 8027275970Scy ;; 8028275970Scy esac 8029275970Scy fi # $pass = dlpreopen 8030275970Scy 8031275970Scy if test -z "$libdir"; then 8032275970Scy # Link the convenience library 8033316068Sdelphij if test lib = "$linkmode"; then 8034275970Scy deplibs="$dir/$old_library $deplibs" 8035316068Sdelphij elif test prog,link = "$linkmode,$pass"; then 8036275970Scy compile_deplibs="$dir/$old_library $compile_deplibs" 8037275970Scy finalize_deplibs="$dir/$old_library $finalize_deplibs" 8038275970Scy else 8039275970Scy deplibs="$lib $deplibs" # used for prog,scan pass 8040275970Scy fi 8041275970Scy continue 8042275970Scy fi 8043275970Scy 8044275970Scy 8045316068Sdelphij if test prog = "$linkmode" && test link != "$pass"; then 8046275970Scy func_append newlib_search_path " $ladir" 8047275970Scy deplibs="$lib $deplibs" 8048275970Scy 8049316068Sdelphij linkalldeplibs=false 8050316068Sdelphij if test no != "$link_all_deplibs" || test -z "$library_names" || 8051316068Sdelphij test no = "$build_libtool_libs"; then 8052316068Sdelphij linkalldeplibs=: 8053275970Scy fi 8054275970Scy 8055275970Scy tmp_libs= 8056275970Scy for deplib in $dependency_libs; do 8057275970Scy case $deplib in 8058275970Scy -L*) func_stripname '-L' '' "$deplib" 8059275970Scy func_resolve_sysroot "$func_stripname_result" 8060275970Scy func_append newlib_search_path " $func_resolve_sysroot_result" 8061275970Scy ;; 8062275970Scy esac 8063275970Scy # Need to link against all dependency_libs? 8064316068Sdelphij if $linkalldeplibs; then 8065275970Scy deplibs="$deplib $deplibs" 8066275970Scy else 8067275970Scy # Need to hardcode shared library paths 8068275970Scy # or/and link against static libraries 8069275970Scy newdependency_libs="$deplib $newdependency_libs" 8070275970Scy fi 8071316068Sdelphij if $opt_preserve_dup_deps; then 8072275970Scy case "$tmp_libs " in 8073275970Scy *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8074275970Scy esac 8075275970Scy fi 8076275970Scy func_append tmp_libs " $deplib" 8077275970Scy done # for deplib 8078275970Scy continue 8079275970Scy fi # $linkmode = prog... 8080275970Scy 8081316068Sdelphij if test prog,link = "$linkmode,$pass"; then 8082275970Scy if test -n "$library_names" && 8083316068Sdelphij { { test no = "$prefer_static_libs" || 8084316068Sdelphij test built,yes = "$prefer_static_libs,$installed"; } || 8085275970Scy test -z "$old_library"; }; then 8086275970Scy # We need to hardcode the library path 8087316068Sdelphij if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8088275970Scy # Make sure the rpath contains only unique directories. 8089316068Sdelphij case $temp_rpath: in 8090275970Scy *"$absdir:"*) ;; 8091275970Scy *) func_append temp_rpath "$absdir:" ;; 8092275970Scy esac 8093275970Scy fi 8094275970Scy 8095275970Scy # Hardcode the library path. 8096275970Scy # Skip directories that are in the system default run-time 8097275970Scy # search path. 8098275970Scy case " $sys_lib_dlsearch_path " in 8099275970Scy *" $absdir "*) ;; 8100275970Scy *) 8101275970Scy case "$compile_rpath " in 8102275970Scy *" $absdir "*) ;; 8103275970Scy *) func_append compile_rpath " $absdir" ;; 8104275970Scy esac 8105275970Scy ;; 8106275970Scy esac 8107275970Scy case " $sys_lib_dlsearch_path " in 8108275970Scy *" $libdir "*) ;; 8109275970Scy *) 8110275970Scy case "$finalize_rpath " in 8111275970Scy *" $libdir "*) ;; 8112275970Scy *) func_append finalize_rpath " $libdir" ;; 8113275970Scy esac 8114275970Scy ;; 8115275970Scy esac 8116275970Scy fi # $linkmode,$pass = prog,link... 8117275970Scy 8118316068Sdelphij if $alldeplibs && 8119316068Sdelphij { test pass_all = "$deplibs_check_method" || 8120316068Sdelphij { test yes = "$build_libtool_libs" && 8121275970Scy test -n "$library_names"; }; }; then 8122275970Scy # We only need to search for static libraries 8123275970Scy continue 8124275970Scy fi 8125275970Scy fi 8126275970Scy 8127275970Scy link_static=no # Whether the deplib will be linked statically 8128275970Scy use_static_libs=$prefer_static_libs 8129316068Sdelphij if test built = "$use_static_libs" && test yes = "$installed"; then 8130275970Scy use_static_libs=no 8131275970Scy fi 8132275970Scy if test -n "$library_names" && 8133316068Sdelphij { test no = "$use_static_libs" || test -z "$old_library"; }; then 8134275970Scy case $host in 8135316068Sdelphij *cygwin* | *mingw* | *cegcc* | *os2*) 8136275970Scy # No point in relinking DLLs because paths are not encoded 8137275970Scy func_append notinst_deplibs " $lib" 8138275970Scy need_relink=no 8139275970Scy ;; 8140275970Scy *) 8141316068Sdelphij if test no = "$installed"; then 8142275970Scy func_append notinst_deplibs " $lib" 8143275970Scy need_relink=yes 8144275970Scy fi 8145275970Scy ;; 8146275970Scy esac 8147275970Scy # This is a shared library 8148275970Scy 8149275970Scy # Warn about portability, can't link against -module's on some 8150275970Scy # systems (darwin). Don't bleat about dlopened modules though! 8151316068Sdelphij dlopenmodule= 8152275970Scy for dlpremoduletest in $dlprefiles; do 8153275970Scy if test "X$dlpremoduletest" = "X$lib"; then 8154316068Sdelphij dlopenmodule=$dlpremoduletest 8155275970Scy break 8156275970Scy fi 8157275970Scy done 8158316068Sdelphij if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8159275970Scy echo 8160316068Sdelphij if test prog = "$linkmode"; then 8161275970Scy $ECHO "*** Warning: Linking the executable $output against the loadable module" 8162275970Scy else 8163275970Scy $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8164275970Scy fi 8165275970Scy $ECHO "*** $linklib is not portable!" 8166275970Scy fi 8167316068Sdelphij if test lib = "$linkmode" && 8168316068Sdelphij test yes = "$hardcode_into_libs"; then 8169275970Scy # Hardcode the library path. 8170275970Scy # Skip directories that are in the system default run-time 8171275970Scy # search path. 8172275970Scy case " $sys_lib_dlsearch_path " in 8173275970Scy *" $absdir "*) ;; 8174275970Scy *) 8175275970Scy case "$compile_rpath " in 8176275970Scy *" $absdir "*) ;; 8177275970Scy *) func_append compile_rpath " $absdir" ;; 8178275970Scy esac 8179275970Scy ;; 8180275970Scy esac 8181275970Scy case " $sys_lib_dlsearch_path " in 8182275970Scy *" $libdir "*) ;; 8183275970Scy *) 8184275970Scy case "$finalize_rpath " in 8185275970Scy *" $libdir "*) ;; 8186275970Scy *) func_append finalize_rpath " $libdir" ;; 8187275970Scy esac 8188275970Scy ;; 8189275970Scy esac 8190275970Scy fi 8191275970Scy 8192275970Scy if test -n "$old_archive_from_expsyms_cmds"; then 8193275970Scy # figure out the soname 8194275970Scy set dummy $library_names 8195275970Scy shift 8196316068Sdelphij realname=$1 8197275970Scy shift 8198275970Scy libname=`eval "\\$ECHO \"$libname_spec\""` 8199275970Scy # use dlname if we got it. it's perfectly good, no? 8200275970Scy if test -n "$dlname"; then 8201316068Sdelphij soname=$dlname 8202275970Scy elif test -n "$soname_spec"; then 8203275970Scy # bleh windows 8204275970Scy case $host in 8205316068Sdelphij *cygwin* | mingw* | *cegcc* | *os2*) 8206275970Scy func_arith $current - $age 8207275970Scy major=$func_arith_result 8208316068Sdelphij versuffix=-$major 8209275970Scy ;; 8210275970Scy esac 8211275970Scy eval soname=\"$soname_spec\" 8212275970Scy else 8213316068Sdelphij soname=$realname 8214275970Scy fi 8215275970Scy 8216275970Scy # Make a new name for the extract_expsyms_cmds to use 8217316068Sdelphij soroot=$soname 8218275970Scy func_basename "$soroot" 8219316068Sdelphij soname=$func_basename_result 8220275970Scy func_stripname 'lib' '.dll' "$soname" 8221275970Scy newlib=libimp-$func_stripname_result.a 8222275970Scy 8223275970Scy # If the library has no export list, then create one now 8224275970Scy if test -f "$output_objdir/$soname-def"; then : 8225275970Scy else 8226316068Sdelphij func_verbose "extracting exported symbol list from '$soname'" 8227275970Scy func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8228275970Scy fi 8229275970Scy 8230275970Scy # Create $newlib 8231275970Scy if test -f "$output_objdir/$newlib"; then :; else 8232316068Sdelphij func_verbose "generating import library for '$soname'" 8233275970Scy func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8234275970Scy fi 8235275970Scy # make sure the library variables are pointing to the new library 8236275970Scy dir=$output_objdir 8237275970Scy linklib=$newlib 8238275970Scy fi # test -n "$old_archive_from_expsyms_cmds" 8239275970Scy 8240316068Sdelphij if test prog = "$linkmode" || test relink != "$opt_mode"; then 8241275970Scy add_shlibpath= 8242275970Scy add_dir= 8243275970Scy add= 8244275970Scy lib_linked=yes 8245275970Scy case $hardcode_action in 8246275970Scy immediate | unsupported) 8247316068Sdelphij if test no = "$hardcode_direct"; then 8248316068Sdelphij add=$dir/$linklib 8249275970Scy case $host in 8250316068Sdelphij *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8251316068Sdelphij *-*-sysv4*uw2*) add_dir=-L$dir ;; 8252275970Scy *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8253316068Sdelphij *-*-unixware7*) add_dir=-L$dir ;; 8254275970Scy *-*-darwin* ) 8255316068Sdelphij # if the lib is a (non-dlopened) module then we cannot 8256275970Scy # link against it, someone is ignoring the earlier warnings 8257275970Scy if /usr/bin/file -L $add 2> /dev/null | 8258316068Sdelphij $GREP ": [^:]* bundle" >/dev/null; then 8259275970Scy if test "X$dlopenmodule" != "X$lib"; then 8260275970Scy $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8261316068Sdelphij if test -z "$old_library"; then 8262275970Scy echo 8263275970Scy echo "*** And there doesn't seem to be a static archive available" 8264275970Scy echo "*** The link will probably fail, sorry" 8265275970Scy else 8266316068Sdelphij add=$dir/$old_library 8267275970Scy fi 8268275970Scy elif test -n "$old_library"; then 8269316068Sdelphij add=$dir/$old_library 8270275970Scy fi 8271275970Scy fi 8272275970Scy esac 8273316068Sdelphij elif test no = "$hardcode_minus_L"; then 8274275970Scy case $host in 8275316068Sdelphij *-*-sunos*) add_shlibpath=$dir ;; 8276275970Scy esac 8277316068Sdelphij add_dir=-L$dir 8278316068Sdelphij add=-l$name 8279316068Sdelphij elif test no = "$hardcode_shlibpath_var"; then 8280316068Sdelphij add_shlibpath=$dir 8281316068Sdelphij add=-l$name 8282275970Scy else 8283275970Scy lib_linked=no 8284275970Scy fi 8285275970Scy ;; 8286275970Scy relink) 8287316068Sdelphij if test yes = "$hardcode_direct" && 8288316068Sdelphij test no = "$hardcode_direct_absolute"; then 8289316068Sdelphij add=$dir/$linklib 8290316068Sdelphij elif test yes = "$hardcode_minus_L"; then 8291316068Sdelphij add_dir=-L$absdir 8292275970Scy # Try looking first in the location we're being installed to. 8293275970Scy if test -n "$inst_prefix_dir"; then 8294275970Scy case $libdir in 8295275970Scy [\\/]*) 8296275970Scy func_append add_dir " -L$inst_prefix_dir$libdir" 8297275970Scy ;; 8298275970Scy esac 8299275970Scy fi 8300316068Sdelphij add=-l$name 8301316068Sdelphij elif test yes = "$hardcode_shlibpath_var"; then 8302316068Sdelphij add_shlibpath=$dir 8303316068Sdelphij add=-l$name 8304275970Scy else 8305275970Scy lib_linked=no 8306275970Scy fi 8307275970Scy ;; 8308275970Scy *) lib_linked=no ;; 8309275970Scy esac 8310275970Scy 8311316068Sdelphij if test yes != "$lib_linked"; then 8312275970Scy func_fatal_configuration "unsupported hardcode properties" 8313275970Scy fi 8314275970Scy 8315275970Scy if test -n "$add_shlibpath"; then 8316275970Scy case :$compile_shlibpath: in 8317275970Scy *":$add_shlibpath:"*) ;; 8318275970Scy *) func_append compile_shlibpath "$add_shlibpath:" ;; 8319275970Scy esac 8320275970Scy fi 8321316068Sdelphij if test prog = "$linkmode"; then 8322275970Scy test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8323275970Scy test -n "$add" && compile_deplibs="$add $compile_deplibs" 8324275970Scy else 8325275970Scy test -n "$add_dir" && deplibs="$add_dir $deplibs" 8326275970Scy test -n "$add" && deplibs="$add $deplibs" 8327316068Sdelphij if test yes != "$hardcode_direct" && 8328316068Sdelphij test yes != "$hardcode_minus_L" && 8329316068Sdelphij test yes = "$hardcode_shlibpath_var"; then 8330275970Scy case :$finalize_shlibpath: in 8331275970Scy *":$libdir:"*) ;; 8332275970Scy *) func_append finalize_shlibpath "$libdir:" ;; 8333275970Scy esac 8334275970Scy fi 8335275970Scy fi 8336275970Scy fi 8337275970Scy 8338316068Sdelphij if test prog = "$linkmode" || test relink = "$opt_mode"; then 8339275970Scy add_shlibpath= 8340275970Scy add_dir= 8341275970Scy add= 8342275970Scy # Finalize command for both is simple: just hardcode it. 8343316068Sdelphij if test yes = "$hardcode_direct" && 8344316068Sdelphij test no = "$hardcode_direct_absolute"; then 8345316068Sdelphij add=$libdir/$linklib 8346316068Sdelphij elif test yes = "$hardcode_minus_L"; then 8347316068Sdelphij add_dir=-L$libdir 8348316068Sdelphij add=-l$name 8349316068Sdelphij elif test yes = "$hardcode_shlibpath_var"; then 8350275970Scy case :$finalize_shlibpath: in 8351275970Scy *":$libdir:"*) ;; 8352275970Scy *) func_append finalize_shlibpath "$libdir:" ;; 8353275970Scy esac 8354316068Sdelphij add=-l$name 8355316068Sdelphij elif test yes = "$hardcode_automatic"; then 8356275970Scy if test -n "$inst_prefix_dir" && 8357316068Sdelphij test -f "$inst_prefix_dir$libdir/$linklib"; then 8358316068Sdelphij add=$inst_prefix_dir$libdir/$linklib 8359275970Scy else 8360316068Sdelphij add=$libdir/$linklib 8361275970Scy fi 8362275970Scy else 8363275970Scy # We cannot seem to hardcode it, guess we'll fake it. 8364316068Sdelphij add_dir=-L$libdir 8365275970Scy # Try looking first in the location we're being installed to. 8366275970Scy if test -n "$inst_prefix_dir"; then 8367275970Scy case $libdir in 8368275970Scy [\\/]*) 8369275970Scy func_append add_dir " -L$inst_prefix_dir$libdir" 8370275970Scy ;; 8371275970Scy esac 8372275970Scy fi 8373316068Sdelphij add=-l$name 8374275970Scy fi 8375275970Scy 8376316068Sdelphij if test prog = "$linkmode"; then 8377275970Scy test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8378275970Scy test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8379275970Scy else 8380275970Scy test -n "$add_dir" && deplibs="$add_dir $deplibs" 8381275970Scy test -n "$add" && deplibs="$add $deplibs" 8382275970Scy fi 8383275970Scy fi 8384316068Sdelphij elif test prog = "$linkmode"; then 8385275970Scy # Here we assume that one of hardcode_direct or hardcode_minus_L 8386275970Scy # is not unsupported. This is valid on all known static and 8387275970Scy # shared platforms. 8388316068Sdelphij if test unsupported != "$hardcode_direct"; then 8389316068Sdelphij test -n "$old_library" && linklib=$old_library 8390275970Scy compile_deplibs="$dir/$linklib $compile_deplibs" 8391275970Scy finalize_deplibs="$dir/$linklib $finalize_deplibs" 8392275970Scy else 8393275970Scy compile_deplibs="-l$name -L$dir $compile_deplibs" 8394275970Scy finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8395275970Scy fi 8396316068Sdelphij elif test yes = "$build_libtool_libs"; then 8397275970Scy # Not a shared library 8398316068Sdelphij if test pass_all != "$deplibs_check_method"; then 8399275970Scy # We're trying link a shared library against a static one 8400275970Scy # but the system doesn't support it. 8401275970Scy 8402275970Scy # Just print a warning and add the library to dependency_libs so 8403275970Scy # that the program can be linked against the static library. 8404275970Scy echo 8405316068Sdelphij $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8406275970Scy echo "*** I have the capability to make that library automatically link in when" 8407275970Scy echo "*** you link to this library. But I can only do this if you have a" 8408275970Scy echo "*** shared version of the library, which you do not appear to have." 8409316068Sdelphij if test yes = "$module"; then 8410275970Scy echo "*** But as you try to build a module library, libtool will still create " 8411275970Scy echo "*** a static module, that should work as long as the dlopening application" 8412275970Scy echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8413275970Scy if test -z "$global_symbol_pipe"; then 8414275970Scy echo 8415275970Scy echo "*** However, this would only work if libtool was able to extract symbol" 8416316068Sdelphij echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8417275970Scy echo "*** not find such a program. So, this module is probably useless." 8418316068Sdelphij echo "*** 'nm' from GNU binutils and a full rebuild may help." 8419275970Scy fi 8420316068Sdelphij if test no = "$build_old_libs"; then 8421275970Scy build_libtool_libs=module 8422275970Scy build_old_libs=yes 8423275970Scy else 8424275970Scy build_libtool_libs=no 8425275970Scy fi 8426275970Scy fi 8427275970Scy else 8428275970Scy deplibs="$dir/$old_library $deplibs" 8429275970Scy link_static=yes 8430275970Scy fi 8431275970Scy fi # link shared/static library? 8432275970Scy 8433316068Sdelphij if test lib = "$linkmode"; then 8434275970Scy if test -n "$dependency_libs" && 8435316068Sdelphij { test yes != "$hardcode_into_libs" || 8436316068Sdelphij test yes = "$build_old_libs" || 8437316068Sdelphij test yes = "$link_static"; }; then 8438275970Scy # Extract -R from dependency_libs 8439275970Scy temp_deplibs= 8440275970Scy for libdir in $dependency_libs; do 8441275970Scy case $libdir in 8442275970Scy -R*) func_stripname '-R' '' "$libdir" 8443275970Scy temp_xrpath=$func_stripname_result 8444275970Scy case " $xrpath " in 8445275970Scy *" $temp_xrpath "*) ;; 8446275970Scy *) func_append xrpath " $temp_xrpath";; 8447275970Scy esac;; 8448275970Scy *) func_append temp_deplibs " $libdir";; 8449275970Scy esac 8450275970Scy done 8451316068Sdelphij dependency_libs=$temp_deplibs 8452275970Scy fi 8453275970Scy 8454275970Scy func_append newlib_search_path " $absdir" 8455275970Scy # Link against this library 8456316068Sdelphij test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8457275970Scy # ... and its dependency_libs 8458275970Scy tmp_libs= 8459275970Scy for deplib in $dependency_libs; do 8460275970Scy newdependency_libs="$deplib $newdependency_libs" 8461275970Scy case $deplib in 8462275970Scy -L*) func_stripname '-L' '' "$deplib" 8463275970Scy func_resolve_sysroot "$func_stripname_result";; 8464275970Scy *) func_resolve_sysroot "$deplib" ;; 8465275970Scy esac 8466316068Sdelphij if $opt_preserve_dup_deps; then 8467275970Scy case "$tmp_libs " in 8468275970Scy *" $func_resolve_sysroot_result "*) 8469275970Scy func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8470275970Scy esac 8471275970Scy fi 8472275970Scy func_append tmp_libs " $func_resolve_sysroot_result" 8473275970Scy done 8474275970Scy 8475316068Sdelphij if test no != "$link_all_deplibs"; then 8476275970Scy # Add the search paths of all dependency libraries 8477275970Scy for deplib in $dependency_libs; do 8478275970Scy path= 8479275970Scy case $deplib in 8480316068Sdelphij -L*) path=$deplib ;; 8481275970Scy *.la) 8482275970Scy func_resolve_sysroot "$deplib" 8483275970Scy deplib=$func_resolve_sysroot_result 8484275970Scy func_dirname "$deplib" "" "." 8485275970Scy dir=$func_dirname_result 8486275970Scy # We need an absolute path. 8487275970Scy case $dir in 8488316068Sdelphij [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8489275970Scy *) 8490275970Scy absdir=`cd "$dir" && pwd` 8491275970Scy if test -z "$absdir"; then 8492316068Sdelphij func_warning "cannot determine absolute directory name of '$dir'" 8493316068Sdelphij absdir=$dir 8494275970Scy fi 8495275970Scy ;; 8496275970Scy esac 8497275970Scy if $GREP "^installed=no" $deplib > /dev/null; then 8498275970Scy case $host in 8499275970Scy *-*-darwin*) 8500275970Scy depdepl= 8501316068Sdelphij eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8502316068Sdelphij if test -n "$deplibrary_names"; then 8503316068Sdelphij for tmp in $deplibrary_names; do 8504275970Scy depdepl=$tmp 8505275970Scy done 8506316068Sdelphij if test -f "$absdir/$objdir/$depdepl"; then 8507316068Sdelphij depdepl=$absdir/$objdir/$depdepl 8508316068Sdelphij darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8509275970Scy if test -z "$darwin_install_name"; then 8510316068Sdelphij darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511275970Scy fi 8512316068Sdelphij func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8513316068Sdelphij func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8514275970Scy path= 8515275970Scy fi 8516275970Scy fi 8517275970Scy ;; 8518275970Scy *) 8519316068Sdelphij path=-L$absdir/$objdir 8520275970Scy ;; 8521275970Scy esac 8522275970Scy else 8523316068Sdelphij eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8524275970Scy test -z "$libdir" && \ 8525316068Sdelphij func_fatal_error "'$deplib' is not a valid libtool archive" 8526275970Scy test "$absdir" != "$libdir" && \ 8527316068Sdelphij func_warning "'$deplib' seems to be moved" 8528275970Scy 8529316068Sdelphij path=-L$absdir 8530275970Scy fi 8531275970Scy ;; 8532275970Scy esac 8533275970Scy case " $deplibs " in 8534275970Scy *" $path "*) ;; 8535275970Scy *) deplibs="$path $deplibs" ;; 8536275970Scy esac 8537275970Scy done 8538275970Scy fi # link_all_deplibs != no 8539275970Scy fi # linkmode = lib 8540275970Scy done # for deplib in $libs 8541316068Sdelphij if test link = "$pass"; then 8542316068Sdelphij if test prog = "$linkmode"; then 8543275970Scy compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8544275970Scy finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8545275970Scy else 8546275970Scy compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8547275970Scy fi 8548275970Scy fi 8549316068Sdelphij dependency_libs=$newdependency_libs 8550316068Sdelphij if test dlpreopen = "$pass"; then 8551275970Scy # Link the dlpreopened libraries before other libraries 8552275970Scy for deplib in $save_deplibs; do 8553275970Scy deplibs="$deplib $deplibs" 8554275970Scy done 8555275970Scy fi 8556316068Sdelphij if test dlopen != "$pass"; then 8557316068Sdelphij test conv = "$pass" || { 8558275970Scy # Make sure lib_search_path contains only unique directories. 8559275970Scy lib_search_path= 8560275970Scy for dir in $newlib_search_path; do 8561275970Scy case "$lib_search_path " in 8562275970Scy *" $dir "*) ;; 8563275970Scy *) func_append lib_search_path " $dir" ;; 8564275970Scy esac 8565275970Scy done 8566275970Scy newlib_search_path= 8567316068Sdelphij } 8568275970Scy 8569316068Sdelphij if test prog,link = "$linkmode,$pass"; then 8570316068Sdelphij vars="compile_deplibs finalize_deplibs" 8571275970Scy else 8572316068Sdelphij vars=deplibs 8573275970Scy fi 8574275970Scy for var in $vars dependency_libs; do 8575275970Scy # Add libraries to $var in reverse order 8576275970Scy eval tmp_libs=\"\$$var\" 8577275970Scy new_libs= 8578275970Scy for deplib in $tmp_libs; do 8579275970Scy # FIXME: Pedantically, this is the right thing to do, so 8580275970Scy # that some nasty dependency loop isn't accidentally 8581275970Scy # broken: 8582275970Scy #new_libs="$deplib $new_libs" 8583275970Scy # Pragmatically, this seems to cause very few problems in 8584275970Scy # practice: 8585275970Scy case $deplib in 8586275970Scy -L*) new_libs="$deplib $new_libs" ;; 8587275970Scy -R*) ;; 8588275970Scy *) 8589275970Scy # And here is the reason: when a library appears more 8590275970Scy # than once as an explicit dependence of a library, or 8591275970Scy # is implicitly linked in more than once by the 8592275970Scy # compiler, it is considered special, and multiple 8593275970Scy # occurrences thereof are not removed. Compare this 8594275970Scy # with having the same library being listed as a 8595275970Scy # dependency of multiple other libraries: in this case, 8596275970Scy # we know (pedantically, we assume) the library does not 8597275970Scy # need to be listed more than once, so we keep only the 8598275970Scy # last copy. This is not always right, but it is rare 8599275970Scy # enough that we require users that really mean to play 8600275970Scy # such unportable linking tricks to link the library 8601275970Scy # using -Wl,-lname, so that libtool does not consider it 8602275970Scy # for duplicate removal. 8603275970Scy case " $specialdeplibs " in 8604275970Scy *" $deplib "*) new_libs="$deplib $new_libs" ;; 8605275970Scy *) 8606275970Scy case " $new_libs " in 8607275970Scy *" $deplib "*) ;; 8608275970Scy *) new_libs="$deplib $new_libs" ;; 8609275970Scy esac 8610275970Scy ;; 8611275970Scy esac 8612275970Scy ;; 8613275970Scy esac 8614275970Scy done 8615275970Scy tmp_libs= 8616275970Scy for deplib in $new_libs; do 8617275970Scy case $deplib in 8618275970Scy -L*) 8619275970Scy case " $tmp_libs " in 8620275970Scy *" $deplib "*) ;; 8621275970Scy *) func_append tmp_libs " $deplib" ;; 8622275970Scy esac 8623275970Scy ;; 8624275970Scy *) func_append tmp_libs " $deplib" ;; 8625275970Scy esac 8626275970Scy done 8627275970Scy eval $var=\"$tmp_libs\" 8628275970Scy done # for var 8629275970Scy fi 8630316068Sdelphij 8631316068Sdelphij # Add Sun CC postdeps if required: 8632316068Sdelphij test CXX = "$tagname" && { 8633316068Sdelphij case $host_os in 8634316068Sdelphij linux*) 8635316068Sdelphij case `$CC -V 2>&1 | sed 5q` in 8636316068Sdelphij *Sun\ C*) # Sun C++ 5.9 8637316068Sdelphij func_suncc_cstd_abi 8638316068Sdelphij 8639316068Sdelphij if test no != "$suncc_use_cstd_abi"; then 8640316068Sdelphij func_append postdeps ' -library=Cstd -library=Crun' 8641316068Sdelphij fi 8642316068Sdelphij ;; 8643316068Sdelphij esac 8644316068Sdelphij ;; 8645316068Sdelphij 8646316068Sdelphij solaris*) 8647316068Sdelphij func_cc_basename "$CC" 8648316068Sdelphij case $func_cc_basename_result in 8649316068Sdelphij CC* | sunCC*) 8650316068Sdelphij func_suncc_cstd_abi 8651316068Sdelphij 8652316068Sdelphij if test no != "$suncc_use_cstd_abi"; then 8653316068Sdelphij func_append postdeps ' -library=Cstd -library=Crun' 8654316068Sdelphij fi 8655316068Sdelphij ;; 8656316068Sdelphij esac 8657316068Sdelphij ;; 8658316068Sdelphij esac 8659316068Sdelphij } 8660316068Sdelphij 8661275970Scy # Last step: remove runtime libs from dependency_libs 8662275970Scy # (they stay in deplibs) 8663275970Scy tmp_libs= 8664316068Sdelphij for i in $dependency_libs; do 8665275970Scy case " $predeps $postdeps $compiler_lib_search_path " in 8666275970Scy *" $i "*) 8667316068Sdelphij i= 8668275970Scy ;; 8669275970Scy esac 8670316068Sdelphij if test -n "$i"; then 8671275970Scy func_append tmp_libs " $i" 8672275970Scy fi 8673275970Scy done 8674275970Scy dependency_libs=$tmp_libs 8675275970Scy done # for pass 8676316068Sdelphij if test prog = "$linkmode"; then 8677316068Sdelphij dlfiles=$newdlfiles 8678275970Scy fi 8679316068Sdelphij if test prog = "$linkmode" || test lib = "$linkmode"; then 8680316068Sdelphij dlprefiles=$newdlprefiles 8681275970Scy fi 8682275970Scy 8683275970Scy case $linkmode in 8684275970Scy oldlib) 8685316068Sdelphij if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8686316068Sdelphij func_warning "'-dlopen' is ignored for archives" 8687275970Scy fi 8688275970Scy 8689275970Scy case " $deplibs" in 8690275970Scy *\ -l* | *\ -L*) 8691316068Sdelphij func_warning "'-l' and '-L' are ignored for archives" ;; 8692275970Scy esac 8693275970Scy 8694275970Scy test -n "$rpath" && \ 8695316068Sdelphij func_warning "'-rpath' is ignored for archives" 8696275970Scy 8697275970Scy test -n "$xrpath" && \ 8698316068Sdelphij func_warning "'-R' is ignored for archives" 8699275970Scy 8700275970Scy test -n "$vinfo" && \ 8701316068Sdelphij func_warning "'-version-info/-version-number' is ignored for archives" 8702275970Scy 8703275970Scy test -n "$release" && \ 8704316068Sdelphij func_warning "'-release' is ignored for archives" 8705275970Scy 8706275970Scy test -n "$export_symbols$export_symbols_regex" && \ 8707316068Sdelphij func_warning "'-export-symbols' is ignored for archives" 8708275970Scy 8709275970Scy # Now set the variables for building old libraries. 8710275970Scy build_libtool_libs=no 8711316068Sdelphij oldlibs=$output 8712275970Scy func_append objs "$old_deplibs" 8713275970Scy ;; 8714275970Scy 8715275970Scy lib) 8716316068Sdelphij # Make sure we only generate libraries of the form 'libNAME.la'. 8717275970Scy case $outputname in 8718275970Scy lib*) 8719275970Scy func_stripname 'lib' '.la' "$outputname" 8720275970Scy name=$func_stripname_result 8721275970Scy eval shared_ext=\"$shrext_cmds\" 8722275970Scy eval libname=\"$libname_spec\" 8723275970Scy ;; 8724275970Scy *) 8725316068Sdelphij test no = "$module" \ 8726316068Sdelphij && func_fatal_help "libtool library '$output' must begin with 'lib'" 8727275970Scy 8728316068Sdelphij if test no != "$need_lib_prefix"; then 8729275970Scy # Add the "lib" prefix for modules if required 8730275970Scy func_stripname '' '.la' "$outputname" 8731275970Scy name=$func_stripname_result 8732275970Scy eval shared_ext=\"$shrext_cmds\" 8733275970Scy eval libname=\"$libname_spec\" 8734275970Scy else 8735275970Scy func_stripname '' '.la' "$outputname" 8736275970Scy libname=$func_stripname_result 8737275970Scy fi 8738275970Scy ;; 8739275970Scy esac 8740275970Scy 8741275970Scy if test -n "$objs"; then 8742316068Sdelphij if test pass_all != "$deplibs_check_method"; then 8743316068Sdelphij func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8744275970Scy else 8745275970Scy echo 8746275970Scy $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8747275970Scy $ECHO "*** objects $objs is not portable!" 8748275970Scy func_append libobjs " $objs" 8749275970Scy fi 8750275970Scy fi 8751275970Scy 8752316068Sdelphij test no = "$dlself" \ 8753316068Sdelphij || func_warning "'-dlopen self' is ignored for libtool libraries" 8754275970Scy 8755275970Scy set dummy $rpath 8756275970Scy shift 8757316068Sdelphij test 1 -lt "$#" \ 8758316068Sdelphij && func_warning "ignoring multiple '-rpath's for a libtool library" 8759275970Scy 8760316068Sdelphij install_libdir=$1 8761275970Scy 8762275970Scy oldlibs= 8763275970Scy if test -z "$rpath"; then 8764316068Sdelphij if test yes = "$build_libtool_libs"; then 8765275970Scy # Building a libtool convenience library. 8766316068Sdelphij # Some compilers have problems with a '.al' extension so 8767275970Scy # convenience libraries should have the same extension an 8768275970Scy # archive normally would. 8769275970Scy oldlibs="$output_objdir/$libname.$libext $oldlibs" 8770275970Scy build_libtool_libs=convenience 8771275970Scy build_old_libs=yes 8772275970Scy fi 8773275970Scy 8774275970Scy test -n "$vinfo" && \ 8775316068Sdelphij func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8776275970Scy 8777275970Scy test -n "$release" && \ 8778316068Sdelphij func_warning "'-release' is ignored for convenience libraries" 8779275970Scy else 8780275970Scy 8781275970Scy # Parse the version information argument. 8782316068Sdelphij save_ifs=$IFS; IFS=: 8783275970Scy set dummy $vinfo 0 0 0 8784275970Scy shift 8785316068Sdelphij IFS=$save_ifs 8786275970Scy 8787275970Scy test -n "$7" && \ 8788316068Sdelphij func_fatal_help "too many parameters to '-version-info'" 8789275970Scy 8790275970Scy # convert absolute version numbers to libtool ages 8791275970Scy # this retains compatibility with .la files and attempts 8792275970Scy # to make the code below a bit more comprehensible 8793275970Scy 8794275970Scy case $vinfo_number in 8795275970Scy yes) 8796316068Sdelphij number_major=$1 8797316068Sdelphij number_minor=$2 8798316068Sdelphij number_revision=$3 8799275970Scy # 8800275970Scy # There are really only two kinds -- those that 8801275970Scy # use the current revision as the major version 8802275970Scy # and those that subtract age and use age as 8803275970Scy # a minor version. But, then there is irix 8804316068Sdelphij # that has an extra 1 added just for fun 8805275970Scy # 8806275970Scy case $version_type in 8807285169Scy # correct linux to gnu/linux during the next big refactor 8808316068Sdelphij darwin|freebsd-elf|linux|osf|windows|none) 8809275970Scy func_arith $number_major + $number_minor 8810275970Scy current=$func_arith_result 8811316068Sdelphij age=$number_minor 8812316068Sdelphij revision=$number_revision 8813275970Scy ;; 8814316068Sdelphij freebsd-aout|qnx|sunos) 8815316068Sdelphij current=$number_major 8816316068Sdelphij revision=$number_minor 8817316068Sdelphij age=0 8818275970Scy ;; 8819275970Scy irix|nonstopux) 8820275970Scy func_arith $number_major + $number_minor 8821275970Scy current=$func_arith_result 8822316068Sdelphij age=$number_minor 8823316068Sdelphij revision=$number_minor 8824275970Scy lt_irix_increment=no 8825275970Scy ;; 8826275970Scy esac 8827275970Scy ;; 8828275970Scy no) 8829316068Sdelphij current=$1 8830316068Sdelphij revision=$2 8831316068Sdelphij age=$3 8832275970Scy ;; 8833275970Scy esac 8834275970Scy 8835275970Scy # Check that each of the things are valid numbers. 8836275970Scy case $current in 8837275970Scy 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]) ;; 8838275970Scy *) 8839316068Sdelphij func_error "CURRENT '$current' must be a nonnegative integer" 8840316068Sdelphij func_fatal_error "'$vinfo' is not valid version information" 8841275970Scy ;; 8842275970Scy esac 8843275970Scy 8844275970Scy case $revision in 8845275970Scy 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]) ;; 8846275970Scy *) 8847316068Sdelphij func_error "REVISION '$revision' must be a nonnegative integer" 8848316068Sdelphij func_fatal_error "'$vinfo' is not valid version information" 8849275970Scy ;; 8850275970Scy esac 8851275970Scy 8852275970Scy case $age in 8853275970Scy 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]) ;; 8854275970Scy *) 8855316068Sdelphij func_error "AGE '$age' must be a nonnegative integer" 8856316068Sdelphij func_fatal_error "'$vinfo' is not valid version information" 8857275970Scy ;; 8858275970Scy esac 8859275970Scy 8860275970Scy if test "$age" -gt "$current"; then 8861316068Sdelphij func_error "AGE '$age' is greater than the current interface number '$current'" 8862316068Sdelphij func_fatal_error "'$vinfo' is not valid version information" 8863275970Scy fi 8864275970Scy 8865275970Scy # Calculate the version variables. 8866275970Scy major= 8867275970Scy versuffix= 8868275970Scy verstring= 8869275970Scy case $version_type in 8870275970Scy none) ;; 8871275970Scy 8872275970Scy darwin) 8873275970Scy # Like Linux, but with the current version available in 8874275970Scy # verstring for coding it into the library header 8875275970Scy func_arith $current - $age 8876275970Scy major=.$func_arith_result 8877316068Sdelphij versuffix=$major.$age.$revision 8878275970Scy # Darwin ld doesn't like 0 for these options... 8879275970Scy func_arith $current + 1 8880275970Scy minor_current=$func_arith_result 8881316068Sdelphij xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8882275970Scy verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8883316068Sdelphij # On Darwin other compilers 8884316068Sdelphij case $CC in 8885316068Sdelphij nagfor*) 8886316068Sdelphij verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8887316068Sdelphij ;; 8888316068Sdelphij *) 8889316068Sdelphij verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8890316068Sdelphij ;; 8891316068Sdelphij esac 8892275970Scy ;; 8893275970Scy 8894275970Scy freebsd-aout) 8895316068Sdelphij major=.$current 8896316068Sdelphij versuffix=.$current.$revision 8897275970Scy ;; 8898275970Scy 8899275970Scy freebsd-elf) 8900316068Sdelphij func_arith $current - $age 8901316068Sdelphij major=.$func_arith_result 8902316068Sdelphij versuffix=$major.$age.$revision 8903275970Scy ;; 8904275970Scy 8905275970Scy irix | nonstopux) 8906316068Sdelphij if test no = "$lt_irix_increment"; then 8907275970Scy func_arith $current - $age 8908275970Scy else 8909275970Scy func_arith $current - $age + 1 8910275970Scy fi 8911275970Scy major=$func_arith_result 8912275970Scy 8913275970Scy case $version_type in 8914275970Scy nonstopux) verstring_prefix=nonstopux ;; 8915275970Scy *) verstring_prefix=sgi ;; 8916275970Scy esac 8917316068Sdelphij verstring=$verstring_prefix$major.$revision 8918275970Scy 8919275970Scy # Add in all the interfaces that we are compatible with. 8920275970Scy loop=$revision 8921316068Sdelphij while test 0 -ne "$loop"; do 8922275970Scy func_arith $revision - $loop 8923275970Scy iface=$func_arith_result 8924275970Scy func_arith $loop - 1 8925275970Scy loop=$func_arith_result 8926316068Sdelphij verstring=$verstring_prefix$major.$iface:$verstring 8927275970Scy done 8928275970Scy 8929316068Sdelphij # Before this point, $major must not contain '.'. 8930275970Scy major=.$major 8931316068Sdelphij versuffix=$major.$revision 8932275970Scy ;; 8933275970Scy 8934285169Scy linux) # correct to gnu/linux during the next big refactor 8935275970Scy func_arith $current - $age 8936275970Scy major=.$func_arith_result 8937316068Sdelphij versuffix=$major.$age.$revision 8938275970Scy ;; 8939275970Scy 8940275970Scy osf) 8941275970Scy func_arith $current - $age 8942275970Scy major=.$func_arith_result 8943316068Sdelphij versuffix=.$current.$age.$revision 8944316068Sdelphij verstring=$current.$age.$revision 8945275970Scy 8946275970Scy # Add in all the interfaces that we are compatible with. 8947275970Scy loop=$age 8948316068Sdelphij while test 0 -ne "$loop"; do 8949275970Scy func_arith $current - $loop 8950275970Scy iface=$func_arith_result 8951275970Scy func_arith $loop - 1 8952275970Scy loop=$func_arith_result 8953316068Sdelphij verstring=$verstring:$iface.0 8954275970Scy done 8955275970Scy 8956275970Scy # Make executables depend on our current version. 8957316068Sdelphij func_append verstring ":$current.0" 8958275970Scy ;; 8959275970Scy 8960275970Scy qnx) 8961316068Sdelphij major=.$current 8962316068Sdelphij versuffix=.$current 8963275970Scy ;; 8964275970Scy 8965316068Sdelphij sco) 8966316068Sdelphij major=.$current 8967316068Sdelphij versuffix=.$current 8968316068Sdelphij ;; 8969316068Sdelphij 8970275970Scy sunos) 8971316068Sdelphij major=.$current 8972316068Sdelphij versuffix=.$current.$revision 8973275970Scy ;; 8974275970Scy 8975275970Scy windows) 8976275970Scy # Use '-' rather than '.', since we only want one 8977316068Sdelphij # extension on DOS 8.3 file systems. 8978275970Scy func_arith $current - $age 8979275970Scy major=$func_arith_result 8980316068Sdelphij versuffix=-$major 8981275970Scy ;; 8982275970Scy 8983275970Scy *) 8984316068Sdelphij func_fatal_configuration "unknown library version type '$version_type'" 8985275970Scy ;; 8986275970Scy esac 8987275970Scy 8988275970Scy # Clear the version info if we defaulted, and they specified a release. 8989275970Scy if test -z "$vinfo" && test -n "$release"; then 8990275970Scy major= 8991275970Scy case $version_type in 8992275970Scy darwin) 8993275970Scy # we can't check for "0.0" in archive_cmds due to quoting 8994275970Scy # problems, so we reset it completely 8995275970Scy verstring= 8996275970Scy ;; 8997275970Scy *) 8998316068Sdelphij verstring=0.0 8999275970Scy ;; 9000275970Scy esac 9001316068Sdelphij if test no = "$need_version"; then 9002275970Scy versuffix= 9003275970Scy else 9004316068Sdelphij versuffix=.0.0 9005275970Scy fi 9006275970Scy fi 9007275970Scy 9008275970Scy # Remove version info from name if versioning should be avoided 9009316068Sdelphij if test yes,no = "$avoid_version,$need_version"; then 9010275970Scy major= 9011275970Scy versuffix= 9012316068Sdelphij verstring= 9013275970Scy fi 9014275970Scy 9015275970Scy # Check to see if the archive will have undefined symbols. 9016316068Sdelphij if test yes = "$allow_undefined"; then 9017316068Sdelphij if test unsupported = "$allow_undefined_flag"; then 9018316068Sdelphij if test yes = "$build_old_libs"; then 9019316068Sdelphij func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9020316068Sdelphij build_libtool_libs=no 9021316068Sdelphij else 9022316068Sdelphij func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9023316068Sdelphij fi 9024275970Scy fi 9025275970Scy else 9026275970Scy # Don't allow undefined symbols. 9027316068Sdelphij allow_undefined_flag=$no_undefined_flag 9028275970Scy fi 9029275970Scy 9030275970Scy fi 9031275970Scy 9032316068Sdelphij func_generate_dlsyms "$libname" "$libname" : 9033275970Scy func_append libobjs " $symfileobj" 9034316068Sdelphij test " " = "$libobjs" && libobjs= 9035275970Scy 9036316068Sdelphij if test relink != "$opt_mode"; then 9037275970Scy # Remove our outputs, but don't remove object files since they 9038275970Scy # may have been created when compiling PIC objects. 9039275970Scy removelist= 9040275970Scy tempremovelist=`$ECHO "$output_objdir/*"` 9041275970Scy for p in $tempremovelist; do 9042275970Scy case $p in 9043275970Scy *.$objext | *.gcno) 9044275970Scy ;; 9045316068Sdelphij $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9046316068Sdelphij if test -n "$precious_files_regex"; then 9047275970Scy if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9048275970Scy then 9049275970Scy continue 9050275970Scy fi 9051275970Scy fi 9052275970Scy func_append removelist " $p" 9053275970Scy ;; 9054275970Scy *) ;; 9055275970Scy esac 9056275970Scy done 9057275970Scy test -n "$removelist" && \ 9058275970Scy func_show_eval "${RM}r \$removelist" 9059275970Scy fi 9060275970Scy 9061275970Scy # Now set the variables for building old libraries. 9062316068Sdelphij if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9063275970Scy func_append oldlibs " $output_objdir/$libname.$libext" 9064275970Scy 9065275970Scy # Transform .lo files to .o files. 9066316068Sdelphij oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9067275970Scy fi 9068275970Scy 9069275970Scy # Eliminate all temporary directories. 9070275970Scy #for path in $notinst_path; do 9071275970Scy # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9072275970Scy # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9073275970Scy # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9074275970Scy #done 9075275970Scy 9076275970Scy if test -n "$xrpath"; then 9077275970Scy # If the user specified any rpath flags, then add them. 9078275970Scy temp_xrpath= 9079275970Scy for libdir in $xrpath; do 9080275970Scy func_replace_sysroot "$libdir" 9081275970Scy func_append temp_xrpath " -R$func_replace_sysroot_result" 9082275970Scy case "$finalize_rpath " in 9083275970Scy *" $libdir "*) ;; 9084275970Scy *) func_append finalize_rpath " $libdir" ;; 9085275970Scy esac 9086275970Scy done 9087316068Sdelphij if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9088275970Scy dependency_libs="$temp_xrpath $dependency_libs" 9089275970Scy fi 9090275970Scy fi 9091275970Scy 9092275970Scy # Make sure dlfiles contains only unique files that won't be dlpreopened 9093316068Sdelphij old_dlfiles=$dlfiles 9094275970Scy dlfiles= 9095275970Scy for lib in $old_dlfiles; do 9096275970Scy case " $dlprefiles $dlfiles " in 9097275970Scy *" $lib "*) ;; 9098275970Scy *) func_append dlfiles " $lib" ;; 9099275970Scy esac 9100275970Scy done 9101275970Scy 9102275970Scy # Make sure dlprefiles contains only unique files 9103316068Sdelphij old_dlprefiles=$dlprefiles 9104275970Scy dlprefiles= 9105275970Scy for lib in $old_dlprefiles; do 9106275970Scy case "$dlprefiles " in 9107275970Scy *" $lib "*) ;; 9108275970Scy *) func_append dlprefiles " $lib" ;; 9109275970Scy esac 9110275970Scy done 9111275970Scy 9112316068Sdelphij if test yes = "$build_libtool_libs"; then 9113275970Scy if test -n "$rpath"; then 9114275970Scy case $host in 9115275970Scy *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9116275970Scy # these systems don't actually have a c library (as such)! 9117275970Scy ;; 9118275970Scy *-*-rhapsody* | *-*-darwin1.[012]) 9119275970Scy # Rhapsody C library is in the System framework 9120275970Scy func_append deplibs " System.ltframework" 9121275970Scy ;; 9122275970Scy *-*-netbsd*) 9123275970Scy # Don't link with libc until the a.out ld.so is fixed. 9124275970Scy ;; 9125275970Scy *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9126275970Scy # Do not include libc due to us having libc/libc_r. 9127275970Scy ;; 9128275970Scy *-*-sco3.2v5* | *-*-sco5v6*) 9129275970Scy # Causes problems with __ctype 9130275970Scy ;; 9131275970Scy *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9132275970Scy # Compiler inserts libc in the correct place for threads to work 9133275970Scy ;; 9134275970Scy *) 9135275970Scy # Add libc to deplibs on all other systems if necessary. 9136316068Sdelphij if test yes = "$build_libtool_need_lc"; then 9137275970Scy func_append deplibs " -lc" 9138275970Scy fi 9139275970Scy ;; 9140275970Scy esac 9141275970Scy fi 9142275970Scy 9143275970Scy # Transform deplibs into only deplibs that can be linked in shared. 9144275970Scy name_save=$name 9145275970Scy libname_save=$libname 9146275970Scy release_save=$release 9147275970Scy versuffix_save=$versuffix 9148275970Scy major_save=$major 9149275970Scy # I'm not sure if I'm treating the release correctly. I think 9150275970Scy # release should show up in the -l (ie -lgmp5) so we don't want to 9151275970Scy # add it in twice. Is that correct? 9152316068Sdelphij release= 9153316068Sdelphij versuffix= 9154316068Sdelphij major= 9155275970Scy newdeplibs= 9156275970Scy droppeddeps=no 9157275970Scy case $deplibs_check_method in 9158275970Scy pass_all) 9159275970Scy # Don't check for shared/static. Everything works. 9160275970Scy # This might be a little naive. We might want to check 9161275970Scy # whether the library exists or not. But this is on 9162275970Scy # osf3 & osf4 and I'm not really sure... Just 9163275970Scy # implementing what was already the behavior. 9164275970Scy newdeplibs=$deplibs 9165275970Scy ;; 9166275970Scy test_compile) 9167275970Scy # This code stresses the "libraries are programs" paradigm to its 9168275970Scy # limits. Maybe even breaks it. We compile a program, linking it 9169275970Scy # against the deplibs as a proxy for the library. Then we can check 9170275970Scy # whether they linked in statically or dynamically with ldd. 9171275970Scy $opt_dry_run || $RM conftest.c 9172275970Scy cat > conftest.c <<EOF 9173275970Scy int main() { return 0; } 9174275970ScyEOF 9175275970Scy $opt_dry_run || $RM conftest 9176275970Scy if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9177275970Scy ldd_output=`ldd conftest` 9178275970Scy for i in $deplibs; do 9179275970Scy case $i in 9180275970Scy -l*) 9181275970Scy func_stripname -l '' "$i" 9182275970Scy name=$func_stripname_result 9183316068Sdelphij if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9184275970Scy case " $predeps $postdeps " in 9185275970Scy *" $i "*) 9186275970Scy func_append newdeplibs " $i" 9187316068Sdelphij i= 9188275970Scy ;; 9189275970Scy esac 9190275970Scy fi 9191316068Sdelphij if test -n "$i"; then 9192275970Scy libname=`eval "\\$ECHO \"$libname_spec\""` 9193275970Scy deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9194275970Scy set dummy $deplib_matches; shift 9195275970Scy deplib_match=$1 9196316068Sdelphij if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9197275970Scy func_append newdeplibs " $i" 9198275970Scy else 9199275970Scy droppeddeps=yes 9200275970Scy echo 9201275970Scy $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9202275970Scy echo "*** I have the capability to make that library automatically link in when" 9203275970Scy echo "*** you link to this library. But I can only do this if you have a" 9204275970Scy echo "*** shared version of the library, which I believe you do not have" 9205275970Scy echo "*** because a test_compile did reveal that the linker did not use it for" 9206275970Scy echo "*** its dynamic dependency list that programs get resolved with at runtime." 9207275970Scy fi 9208275970Scy fi 9209275970Scy ;; 9210275970Scy *) 9211275970Scy func_append newdeplibs " $i" 9212275970Scy ;; 9213275970Scy esac 9214275970Scy done 9215275970Scy else 9216275970Scy # Error occurred in the first compile. Let's try to salvage 9217275970Scy # the situation: Compile a separate program for each library. 9218275970Scy for i in $deplibs; do 9219275970Scy case $i in 9220275970Scy -l*) 9221275970Scy func_stripname -l '' "$i" 9222275970Scy name=$func_stripname_result 9223275970Scy $opt_dry_run || $RM conftest 9224275970Scy if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9225275970Scy ldd_output=`ldd conftest` 9226316068Sdelphij if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9227275970Scy case " $predeps $postdeps " in 9228275970Scy *" $i "*) 9229275970Scy func_append newdeplibs " $i" 9230316068Sdelphij i= 9231275970Scy ;; 9232275970Scy esac 9233275970Scy fi 9234316068Sdelphij if test -n "$i"; then 9235275970Scy libname=`eval "\\$ECHO \"$libname_spec\""` 9236275970Scy deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9237275970Scy set dummy $deplib_matches; shift 9238275970Scy deplib_match=$1 9239316068Sdelphij if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9240275970Scy func_append newdeplibs " $i" 9241275970Scy else 9242275970Scy droppeddeps=yes 9243275970Scy echo 9244275970Scy $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9245275970Scy echo "*** I have the capability to make that library automatically link in when" 9246275970Scy echo "*** you link to this library. But I can only do this if you have a" 9247275970Scy echo "*** shared version of the library, which you do not appear to have" 9248275970Scy echo "*** because a test_compile did reveal that the linker did not use this one" 9249275970Scy echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9250275970Scy fi 9251275970Scy fi 9252275970Scy else 9253275970Scy droppeddeps=yes 9254275970Scy echo 9255275970Scy $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9256275970Scy echo "*** make it link in! You will probably need to install it or some" 9257275970Scy echo "*** library that it depends on before this library will be fully" 9258275970Scy echo "*** functional. Installing it before continuing would be even better." 9259275970Scy fi 9260275970Scy ;; 9261275970Scy *) 9262275970Scy func_append newdeplibs " $i" 9263275970Scy ;; 9264275970Scy esac 9265275970Scy done 9266275970Scy fi 9267275970Scy ;; 9268275970Scy file_magic*) 9269275970Scy set dummy $deplibs_check_method; shift 9270275970Scy file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9271275970Scy for a_deplib in $deplibs; do 9272275970Scy case $a_deplib in 9273275970Scy -l*) 9274275970Scy func_stripname -l '' "$a_deplib" 9275275970Scy name=$func_stripname_result 9276316068Sdelphij if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9277275970Scy case " $predeps $postdeps " in 9278275970Scy *" $a_deplib "*) 9279275970Scy func_append newdeplibs " $a_deplib" 9280316068Sdelphij a_deplib= 9281275970Scy ;; 9282275970Scy esac 9283275970Scy fi 9284316068Sdelphij if test -n "$a_deplib"; then 9285275970Scy libname=`eval "\\$ECHO \"$libname_spec\""` 9286275970Scy if test -n "$file_magic_glob"; then 9287275970Scy libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9288275970Scy else 9289275970Scy libnameglob=$libname 9290275970Scy fi 9291316068Sdelphij test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9292275970Scy for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9293316068Sdelphij if test yes = "$want_nocaseglob"; then 9294275970Scy shopt -s nocaseglob 9295275970Scy potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9296275970Scy $nocaseglob 9297275970Scy else 9298275970Scy potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9299275970Scy fi 9300275970Scy for potent_lib in $potential_libs; do 9301275970Scy # Follow soft links. 9302275970Scy if ls -lLd "$potent_lib" 2>/dev/null | 9303275970Scy $GREP " -> " >/dev/null; then 9304275970Scy continue 9305275970Scy fi 9306275970Scy # The statement above tries to avoid entering an 9307275970Scy # endless loop below, in case of cyclic links. 9308275970Scy # We might still enter an endless loop, since a link 9309275970Scy # loop can be closed while we follow links, 9310275970Scy # but so what? 9311316068Sdelphij potlib=$potent_lib 9312275970Scy while test -h "$potlib" 2>/dev/null; do 9313316068Sdelphij potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9314275970Scy case $potliblink in 9315316068Sdelphij [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9316316068Sdelphij *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9317275970Scy esac 9318275970Scy done 9319275970Scy if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9320275970Scy $SED -e 10q | 9321275970Scy $EGREP "$file_magic_regex" > /dev/null; then 9322275970Scy func_append newdeplibs " $a_deplib" 9323316068Sdelphij a_deplib= 9324275970Scy break 2 9325275970Scy fi 9326275970Scy done 9327275970Scy done 9328275970Scy fi 9329316068Sdelphij if test -n "$a_deplib"; then 9330275970Scy droppeddeps=yes 9331275970Scy echo 9332275970Scy $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9333275970Scy echo "*** I have the capability to make that library automatically link in when" 9334275970Scy echo "*** you link to this library. But I can only do this if you have a" 9335275970Scy echo "*** shared version of the library, which you do not appear to have" 9336275970Scy echo "*** because I did check the linker path looking for a file starting" 9337316068Sdelphij if test -z "$potlib"; then 9338275970Scy $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9339275970Scy else 9340275970Scy $ECHO "*** with $libname and none of the candidates passed a file format test" 9341275970Scy $ECHO "*** using a file magic. Last file checked: $potlib" 9342275970Scy fi 9343275970Scy fi 9344275970Scy ;; 9345275970Scy *) 9346275970Scy # Add a -L argument. 9347275970Scy func_append newdeplibs " $a_deplib" 9348275970Scy ;; 9349275970Scy esac 9350275970Scy done # Gone through all deplibs. 9351275970Scy ;; 9352275970Scy match_pattern*) 9353275970Scy set dummy $deplibs_check_method; shift 9354275970Scy match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9355275970Scy for a_deplib in $deplibs; do 9356275970Scy case $a_deplib in 9357275970Scy -l*) 9358275970Scy func_stripname -l '' "$a_deplib" 9359275970Scy name=$func_stripname_result 9360316068Sdelphij if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9361275970Scy case " $predeps $postdeps " in 9362275970Scy *" $a_deplib "*) 9363275970Scy func_append newdeplibs " $a_deplib" 9364316068Sdelphij a_deplib= 9365275970Scy ;; 9366275970Scy esac 9367275970Scy fi 9368316068Sdelphij if test -n "$a_deplib"; then 9369275970Scy libname=`eval "\\$ECHO \"$libname_spec\""` 9370275970Scy for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9371275970Scy potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9372275970Scy for potent_lib in $potential_libs; do 9373316068Sdelphij potlib=$potent_lib # see symlink-check above in file_magic test 9374275970Scy if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9375275970Scy $EGREP "$match_pattern_regex" > /dev/null; then 9376275970Scy func_append newdeplibs " $a_deplib" 9377316068Sdelphij a_deplib= 9378275970Scy break 2 9379275970Scy fi 9380275970Scy done 9381275970Scy done 9382275970Scy fi 9383316068Sdelphij if test -n "$a_deplib"; then 9384275970Scy droppeddeps=yes 9385275970Scy echo 9386275970Scy $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9387275970Scy echo "*** I have the capability to make that library automatically link in when" 9388275970Scy echo "*** you link to this library. But I can only do this if you have a" 9389275970Scy echo "*** shared version of the library, which you do not appear to have" 9390275970Scy echo "*** because I did check the linker path looking for a file starting" 9391316068Sdelphij if test -z "$potlib"; then 9392275970Scy $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9393275970Scy else 9394275970Scy $ECHO "*** with $libname and none of the candidates passed a file format test" 9395275970Scy $ECHO "*** using a regex pattern. Last file checked: $potlib" 9396275970Scy fi 9397275970Scy fi 9398275970Scy ;; 9399275970Scy *) 9400275970Scy # Add a -L argument. 9401275970Scy func_append newdeplibs " $a_deplib" 9402275970Scy ;; 9403275970Scy esac 9404275970Scy done # Gone through all deplibs. 9405275970Scy ;; 9406275970Scy none | unknown | *) 9407316068Sdelphij newdeplibs= 9408275970Scy tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9409316068Sdelphij if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9410316068Sdelphij for i in $predeps $postdeps; do 9411275970Scy # can't use Xsed below, because $i might contain '/' 9412316068Sdelphij tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9413275970Scy done 9414275970Scy fi 9415275970Scy case $tmp_deplibs in 9416275970Scy *[!\ \ ]*) 9417275970Scy echo 9418316068Sdelphij if test none = "$deplibs_check_method"; then 9419275970Scy echo "*** Warning: inter-library dependencies are not supported in this platform." 9420275970Scy else 9421275970Scy echo "*** Warning: inter-library dependencies are not known to be supported." 9422275970Scy fi 9423275970Scy echo "*** All declared inter-library dependencies are being dropped." 9424275970Scy droppeddeps=yes 9425275970Scy ;; 9426275970Scy esac 9427275970Scy ;; 9428275970Scy esac 9429275970Scy versuffix=$versuffix_save 9430275970Scy major=$major_save 9431275970Scy release=$release_save 9432275970Scy libname=$libname_save 9433275970Scy name=$name_save 9434275970Scy 9435275970Scy case $host in 9436275970Scy *-*-rhapsody* | *-*-darwin1.[012]) 9437275970Scy # On Rhapsody replace the C library with the System framework 9438275970Scy newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9439275970Scy ;; 9440275970Scy esac 9441275970Scy 9442316068Sdelphij if test yes = "$droppeddeps"; then 9443316068Sdelphij if test yes = "$module"; then 9444275970Scy echo 9445275970Scy echo "*** Warning: libtool could not satisfy all declared inter-library" 9446275970Scy $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9447275970Scy echo "*** a static module, that should work as long as the dlopening" 9448275970Scy echo "*** application is linked with the -dlopen flag." 9449275970Scy if test -z "$global_symbol_pipe"; then 9450275970Scy echo 9451275970Scy echo "*** However, this would only work if libtool was able to extract symbol" 9452316068Sdelphij echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9453275970Scy echo "*** not find such a program. So, this module is probably useless." 9454316068Sdelphij echo "*** 'nm' from GNU binutils and a full rebuild may help." 9455275970Scy fi 9456316068Sdelphij if test no = "$build_old_libs"; then 9457316068Sdelphij oldlibs=$output_objdir/$libname.$libext 9458275970Scy build_libtool_libs=module 9459275970Scy build_old_libs=yes 9460275970Scy else 9461275970Scy build_libtool_libs=no 9462275970Scy fi 9463275970Scy else 9464275970Scy echo "*** The inter-library dependencies that have been dropped here will be" 9465275970Scy echo "*** automatically added whenever a program is linked with this library" 9466275970Scy echo "*** or is declared to -dlopen it." 9467275970Scy 9468316068Sdelphij if test no = "$allow_undefined"; then 9469275970Scy echo 9470275970Scy echo "*** Since this library must not contain undefined symbols," 9471275970Scy echo "*** because either the platform does not support them or" 9472275970Scy echo "*** it was explicitly requested with -no-undefined," 9473275970Scy echo "*** libtool will only create a static version of it." 9474316068Sdelphij if test no = "$build_old_libs"; then 9475316068Sdelphij oldlibs=$output_objdir/$libname.$libext 9476275970Scy build_libtool_libs=module 9477275970Scy build_old_libs=yes 9478275970Scy else 9479275970Scy build_libtool_libs=no 9480275970Scy fi 9481275970Scy fi 9482275970Scy fi 9483275970Scy fi 9484275970Scy # Done checking deplibs! 9485275970Scy deplibs=$newdeplibs 9486275970Scy fi 9487275970Scy # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9488275970Scy case $host in 9489275970Scy *-*-darwin*) 9490275970Scy newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9491275970Scy new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9492275970Scy deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493275970Scy ;; 9494275970Scy esac 9495275970Scy 9496275970Scy # move library search paths that coincide with paths to not yet 9497275970Scy # installed libraries to the beginning of the library search list 9498275970Scy new_libs= 9499275970Scy for path in $notinst_path; do 9500275970Scy case " $new_libs " in 9501275970Scy *" -L$path/$objdir "*) ;; 9502275970Scy *) 9503275970Scy case " $deplibs " in 9504275970Scy *" -L$path/$objdir "*) 9505275970Scy func_append new_libs " -L$path/$objdir" ;; 9506275970Scy esac 9507275970Scy ;; 9508275970Scy esac 9509275970Scy done 9510275970Scy for deplib in $deplibs; do 9511275970Scy case $deplib in 9512275970Scy -L*) 9513275970Scy case " $new_libs " in 9514275970Scy *" $deplib "*) ;; 9515275970Scy *) func_append new_libs " $deplib" ;; 9516275970Scy esac 9517275970Scy ;; 9518275970Scy *) func_append new_libs " $deplib" ;; 9519275970Scy esac 9520275970Scy done 9521316068Sdelphij deplibs=$new_libs 9522275970Scy 9523275970Scy # All the library-specific variables (install_libdir is set above). 9524275970Scy library_names= 9525275970Scy old_library= 9526275970Scy dlname= 9527275970Scy 9528275970Scy # Test again, we may have decided not to build it any more 9529316068Sdelphij if test yes = "$build_libtool_libs"; then 9530316068Sdelphij # Remove $wl instances when linking with ld. 9531285169Scy # FIXME: should test the right _cmds variable. 9532285169Scy case $archive_cmds in 9533285169Scy *\$LD\ *) wl= ;; 9534285169Scy esac 9535316068Sdelphij if test yes = "$hardcode_into_libs"; then 9536275970Scy # Hardcode the library paths 9537275970Scy hardcode_libdirs= 9538275970Scy dep_rpath= 9539316068Sdelphij rpath=$finalize_rpath 9540316068Sdelphij test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9541275970Scy for libdir in $rpath; do 9542275970Scy if test -n "$hardcode_libdir_flag_spec"; then 9543275970Scy if test -n "$hardcode_libdir_separator"; then 9544275970Scy func_replace_sysroot "$libdir" 9545275970Scy libdir=$func_replace_sysroot_result 9546275970Scy if test -z "$hardcode_libdirs"; then 9547316068Sdelphij hardcode_libdirs=$libdir 9548275970Scy else 9549275970Scy # Just accumulate the unique libdirs. 9550275970Scy case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9551275970Scy *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9552275970Scy ;; 9553275970Scy *) 9554275970Scy func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9555275970Scy ;; 9556275970Scy esac 9557275970Scy fi 9558275970Scy else 9559275970Scy eval flag=\"$hardcode_libdir_flag_spec\" 9560275970Scy func_append dep_rpath " $flag" 9561275970Scy fi 9562275970Scy elif test -n "$runpath_var"; then 9563275970Scy case "$perm_rpath " in 9564275970Scy *" $libdir "*) ;; 9565285169Scy *) func_append perm_rpath " $libdir" ;; 9566275970Scy esac 9567275970Scy fi 9568275970Scy done 9569275970Scy # Substitute the hardcoded libdirs into the rpath. 9570275970Scy if test -n "$hardcode_libdir_separator" && 9571275970Scy test -n "$hardcode_libdirs"; then 9572316068Sdelphij libdir=$hardcode_libdirs 9573285169Scy eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9574275970Scy fi 9575275970Scy if test -n "$runpath_var" && test -n "$perm_rpath"; then 9576275970Scy # We should set the runpath_var. 9577275970Scy rpath= 9578275970Scy for dir in $perm_rpath; do 9579275970Scy func_append rpath "$dir:" 9580275970Scy done 9581275970Scy eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9582275970Scy fi 9583275970Scy test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584275970Scy fi 9585275970Scy 9586316068Sdelphij shlibpath=$finalize_shlibpath 9587316068Sdelphij test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9588275970Scy if test -n "$shlibpath"; then 9589275970Scy eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590275970Scy fi 9591275970Scy 9592275970Scy # Get the real and link names of the library. 9593275970Scy eval shared_ext=\"$shrext_cmds\" 9594275970Scy eval library_names=\"$library_names_spec\" 9595275970Scy set dummy $library_names 9596275970Scy shift 9597316068Sdelphij realname=$1 9598275970Scy shift 9599275970Scy 9600275970Scy if test -n "$soname_spec"; then 9601275970Scy eval soname=\"$soname_spec\" 9602275970Scy else 9603316068Sdelphij soname=$realname 9604275970Scy fi 9605275970Scy if test -z "$dlname"; then 9606275970Scy dlname=$soname 9607275970Scy fi 9608275970Scy 9609316068Sdelphij lib=$output_objdir/$realname 9610275970Scy linknames= 9611275970Scy for link 9612275970Scy do 9613275970Scy func_append linknames " $link" 9614275970Scy done 9615275970Scy 9616275970Scy # Use standard objects if they are pic 9617275970Scy test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9618275970Scy test "X$libobjs" = "X " && libobjs= 9619275970Scy 9620275970Scy delfiles= 9621275970Scy if test -n "$export_symbols" && test -n "$include_expsyms"; then 9622275970Scy $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9623316068Sdelphij export_symbols=$output_objdir/$libname.uexp 9624275970Scy func_append delfiles " $export_symbols" 9625275970Scy fi 9626275970Scy 9627275970Scy orig_export_symbols= 9628275970Scy case $host_os in 9629275970Scy cygwin* | mingw* | cegcc*) 9630275970Scy if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9631275970Scy # exporting using user supplied symfile 9632316068Sdelphij func_dll_def_p "$export_symbols" || { 9633275970Scy # and it's NOT already a .def file. Must figure out 9634275970Scy # which of the given symbols are data symbols and tag 9635275970Scy # them as such. So, trigger use of export_symbols_cmds. 9636275970Scy # export_symbols gets reassigned inside the "prepare 9637275970Scy # the list of exported symbols" if statement, so the 9638275970Scy # include_expsyms logic still works. 9639316068Sdelphij orig_export_symbols=$export_symbols 9640275970Scy export_symbols= 9641275970Scy always_export_symbols=yes 9642316068Sdelphij } 9643275970Scy fi 9644275970Scy ;; 9645275970Scy esac 9646275970Scy 9647275970Scy # Prepare the list of exported symbols 9648275970Scy if test -z "$export_symbols"; then 9649316068Sdelphij if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9650316068Sdelphij func_verbose "generating symbol list for '$libname.la'" 9651316068Sdelphij export_symbols=$output_objdir/$libname.exp 9652275970Scy $opt_dry_run || $RM $export_symbols 9653275970Scy cmds=$export_symbols_cmds 9654316068Sdelphij save_ifs=$IFS; IFS='~' 9655275970Scy for cmd1 in $cmds; do 9656316068Sdelphij IFS=$save_ifs 9657275970Scy # Take the normal branch if the nm_file_list_spec branch 9658275970Scy # doesn't work or if tool conversion is not needed. 9659275970Scy case $nm_file_list_spec~$to_tool_file_cmd in 9660275970Scy *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9661275970Scy try_normal_branch=yes 9662275970Scy eval cmd=\"$cmd1\" 9663275970Scy func_len " $cmd" 9664275970Scy len=$func_len_result 9665275970Scy ;; 9666275970Scy *) 9667275970Scy try_normal_branch=no 9668275970Scy ;; 9669275970Scy esac 9670316068Sdelphij if test yes = "$try_normal_branch" \ 9671275970Scy && { test "$len" -lt "$max_cmd_len" \ 9672275970Scy || test "$max_cmd_len" -le -1; } 9673275970Scy then 9674275970Scy func_show_eval "$cmd" 'exit $?' 9675275970Scy skipped_export=false 9676275970Scy elif test -n "$nm_file_list_spec"; then 9677275970Scy func_basename "$output" 9678275970Scy output_la=$func_basename_result 9679275970Scy save_libobjs=$libobjs 9680275970Scy save_output=$output 9681316068Sdelphij output=$output_objdir/$output_la.nm 9682275970Scy func_to_tool_file "$output" 9683275970Scy libobjs=$nm_file_list_spec$func_to_tool_file_result 9684275970Scy func_append delfiles " $output" 9685275970Scy func_verbose "creating $NM input file list: $output" 9686275970Scy for obj in $save_libobjs; do 9687275970Scy func_to_tool_file "$obj" 9688275970Scy $ECHO "$func_to_tool_file_result" 9689275970Scy done > "$output" 9690275970Scy eval cmd=\"$cmd1\" 9691275970Scy func_show_eval "$cmd" 'exit $?' 9692275970Scy output=$save_output 9693275970Scy libobjs=$save_libobjs 9694275970Scy skipped_export=false 9695275970Scy else 9696275970Scy # The command line is too long to execute in one step. 9697275970Scy func_verbose "using reloadable object file for export list..." 9698275970Scy skipped_export=: 9699275970Scy # Break out early, otherwise skipped_export may be 9700275970Scy # set to false by a later but shorter cmd. 9701275970Scy break 9702275970Scy fi 9703275970Scy done 9704316068Sdelphij IFS=$save_ifs 9705316068Sdelphij if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9706275970Scy func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9707275970Scy func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9708275970Scy fi 9709275970Scy fi 9710275970Scy fi 9711275970Scy 9712275970Scy if test -n "$export_symbols" && test -n "$include_expsyms"; then 9713316068Sdelphij tmp_export_symbols=$export_symbols 9714316068Sdelphij test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9715275970Scy $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716275970Scy fi 9717275970Scy 9718316068Sdelphij if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9719275970Scy # The given exports_symbols file has to be filtered, so filter it. 9720316068Sdelphij func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9721275970Scy # FIXME: $output_objdir/$libname.filter potentially contains lots of 9722316068Sdelphij # 's' commands, which not all seds can handle. GNU sed should be fine 9723275970Scy # though. Also, the filter scales superlinearly with the number of 9724275970Scy # global variables. join(1) would be nice here, but unfortunately 9725275970Scy # isn't a blessed tool. 9726275970Scy $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9727275970Scy func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9728275970Scy export_symbols=$output_objdir/$libname.def 9729275970Scy $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9730275970Scy fi 9731275970Scy 9732275970Scy tmp_deplibs= 9733275970Scy for test_deplib in $deplibs; do 9734275970Scy case " $convenience " in 9735275970Scy *" $test_deplib "*) ;; 9736275970Scy *) 9737275970Scy func_append tmp_deplibs " $test_deplib" 9738275970Scy ;; 9739275970Scy esac 9740275970Scy done 9741316068Sdelphij deplibs=$tmp_deplibs 9742275970Scy 9743275970Scy if test -n "$convenience"; then 9744275970Scy if test -n "$whole_archive_flag_spec" && 9745316068Sdelphij test yes = "$compiler_needs_object" && 9746275970Scy test -z "$libobjs"; then 9747275970Scy # extract the archives, so we have objects to list. 9748275970Scy # TODO: could optimize this to just extract one archive. 9749275970Scy whole_archive_flag_spec= 9750275970Scy fi 9751275970Scy if test -n "$whole_archive_flag_spec"; then 9752275970Scy save_libobjs=$libobjs 9753275970Scy eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9754275970Scy test "X$libobjs" = "X " && libobjs= 9755275970Scy else 9756316068Sdelphij gentop=$output_objdir/${outputname}x 9757275970Scy func_append generated " $gentop" 9758275970Scy 9759275970Scy func_extract_archives $gentop $convenience 9760275970Scy func_append libobjs " $func_extract_archives_result" 9761275970Scy test "X$libobjs" = "X " && libobjs= 9762275970Scy fi 9763275970Scy fi 9764275970Scy 9765316068Sdelphij if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9766275970Scy eval flag=\"$thread_safe_flag_spec\" 9767275970Scy func_append linker_flags " $flag" 9768275970Scy fi 9769275970Scy 9770275970Scy # Make a backup of the uninstalled library when relinking 9771316068Sdelphij if test relink = "$opt_mode"; then 9772275970Scy $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9773275970Scy fi 9774275970Scy 9775275970Scy # Do each of the archive commands. 9776316068Sdelphij if test yes = "$module" && test -n "$module_cmds"; then 9777275970Scy if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9778275970Scy eval test_cmds=\"$module_expsym_cmds\" 9779275970Scy cmds=$module_expsym_cmds 9780275970Scy else 9781275970Scy eval test_cmds=\"$module_cmds\" 9782275970Scy cmds=$module_cmds 9783275970Scy fi 9784275970Scy else 9785275970Scy if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9786275970Scy eval test_cmds=\"$archive_expsym_cmds\" 9787275970Scy cmds=$archive_expsym_cmds 9788275970Scy else 9789275970Scy eval test_cmds=\"$archive_cmds\" 9790275970Scy cmds=$archive_cmds 9791275970Scy fi 9792275970Scy fi 9793275970Scy 9794316068Sdelphij if test : != "$skipped_export" && 9795275970Scy func_len " $test_cmds" && 9796275970Scy len=$func_len_result && 9797275970Scy test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9798275970Scy : 9799275970Scy else 9800275970Scy # The command line is too long to link in one step, link piecewise 9801275970Scy # or, if using GNU ld and skipped_export is not :, use a linker 9802275970Scy # script. 9803275970Scy 9804275970Scy # Save the value of $output and $libobjs because we want to 9805275970Scy # use them later. If we have whole_archive_flag_spec, we 9806275970Scy # want to use save_libobjs as it was before 9807275970Scy # whole_archive_flag_spec was expanded, because we can't 9808275970Scy # assume the linker understands whole_archive_flag_spec. 9809275970Scy # This may have to be revisited, in case too many 9810275970Scy # convenience libraries get linked in and end up exceeding 9811275970Scy # the spec. 9812275970Scy if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9813275970Scy save_libobjs=$libobjs 9814275970Scy fi 9815275970Scy save_output=$output 9816275970Scy func_basename "$output" 9817275970Scy output_la=$func_basename_result 9818275970Scy 9819275970Scy # Clear the reloadable object creation command queue and 9820275970Scy # initialize k to one. 9821275970Scy test_cmds= 9822275970Scy concat_cmds= 9823275970Scy objlist= 9824275970Scy last_robj= 9825275970Scy k=1 9826275970Scy 9827316068Sdelphij if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9828316068Sdelphij output=$output_objdir/$output_la.lnkscript 9829275970Scy func_verbose "creating GNU ld script: $output" 9830275970Scy echo 'INPUT (' > $output 9831275970Scy for obj in $save_libobjs 9832275970Scy do 9833275970Scy func_to_tool_file "$obj" 9834275970Scy $ECHO "$func_to_tool_file_result" >> $output 9835275970Scy done 9836275970Scy echo ')' >> $output 9837275970Scy func_append delfiles " $output" 9838275970Scy func_to_tool_file "$output" 9839275970Scy output=$func_to_tool_file_result 9840316068Sdelphij elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9841316068Sdelphij output=$output_objdir/$output_la.lnk 9842275970Scy func_verbose "creating linker input file list: $output" 9843275970Scy : > $output 9844275970Scy set x $save_libobjs 9845275970Scy shift 9846275970Scy firstobj= 9847316068Sdelphij if test yes = "$compiler_needs_object"; then 9848275970Scy firstobj="$1 " 9849275970Scy shift 9850275970Scy fi 9851275970Scy for obj 9852275970Scy do 9853275970Scy func_to_tool_file "$obj" 9854275970Scy $ECHO "$func_to_tool_file_result" >> $output 9855275970Scy done 9856275970Scy func_append delfiles " $output" 9857275970Scy func_to_tool_file "$output" 9858275970Scy output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9859275970Scy else 9860275970Scy if test -n "$save_libobjs"; then 9861275970Scy func_verbose "creating reloadable object files..." 9862316068Sdelphij output=$output_objdir/$output_la-$k.$objext 9863275970Scy eval test_cmds=\"$reload_cmds\" 9864275970Scy func_len " $test_cmds" 9865275970Scy len0=$func_len_result 9866275970Scy len=$len0 9867275970Scy 9868275970Scy # Loop over the list of objects to be linked. 9869275970Scy for obj in $save_libobjs 9870275970Scy do 9871275970Scy func_len " $obj" 9872275970Scy func_arith $len + $func_len_result 9873275970Scy len=$func_arith_result 9874316068Sdelphij if test -z "$objlist" || 9875275970Scy test "$len" -lt "$max_cmd_len"; then 9876275970Scy func_append objlist " $obj" 9877275970Scy else 9878275970Scy # The command $test_cmds is almost too long, add a 9879275970Scy # command to the queue. 9880316068Sdelphij if test 1 -eq "$k"; then 9881275970Scy # The first file doesn't have a previous command to add. 9882275970Scy reload_objs=$objlist 9883275970Scy eval concat_cmds=\"$reload_cmds\" 9884275970Scy else 9885275970Scy # All subsequent reloadable object files will link in 9886275970Scy # the last one created. 9887275970Scy reload_objs="$objlist $last_robj" 9888275970Scy eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9889275970Scy fi 9890316068Sdelphij last_robj=$output_objdir/$output_la-$k.$objext 9891275970Scy func_arith $k + 1 9892275970Scy k=$func_arith_result 9893316068Sdelphij output=$output_objdir/$output_la-$k.$objext 9894275970Scy objlist=" $obj" 9895275970Scy func_len " $last_robj" 9896275970Scy func_arith $len0 + $func_len_result 9897275970Scy len=$func_arith_result 9898275970Scy fi 9899275970Scy done 9900275970Scy # Handle the remaining objects by creating one last 9901275970Scy # reloadable object file. All subsequent reloadable object 9902275970Scy # files will link in the last one created. 9903275970Scy test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9904275970Scy reload_objs="$objlist $last_robj" 9905316068Sdelphij eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9906275970Scy if test -n "$last_robj"; then 9907316068Sdelphij eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908275970Scy fi 9909275970Scy func_append delfiles " $output" 9910275970Scy 9911275970Scy else 9912275970Scy output= 9913275970Scy fi 9914275970Scy 9915316068Sdelphij ${skipped_export-false} && { 9916316068Sdelphij func_verbose "generating symbol list for '$libname.la'" 9917316068Sdelphij export_symbols=$output_objdir/$libname.exp 9918275970Scy $opt_dry_run || $RM $export_symbols 9919275970Scy libobjs=$output 9920275970Scy # Append the command to create the export file. 9921275970Scy test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9922275970Scy eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9923275970Scy if test -n "$last_robj"; then 9924275970Scy eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925275970Scy fi 9926316068Sdelphij } 9927275970Scy 9928275970Scy test -n "$save_libobjs" && 9929275970Scy func_verbose "creating a temporary reloadable object file: $output" 9930275970Scy 9931275970Scy # Loop through the commands generated above and execute them. 9932316068Sdelphij save_ifs=$IFS; IFS='~' 9933275970Scy for cmd in $concat_cmds; do 9934316068Sdelphij IFS=$save_ifs 9935316068Sdelphij $opt_quiet || { 9936275970Scy func_quote_for_expand "$cmd" 9937275970Scy eval "func_echo $func_quote_for_expand_result" 9938275970Scy } 9939275970Scy $opt_dry_run || eval "$cmd" || { 9940275970Scy lt_exit=$? 9941275970Scy 9942275970Scy # Restore the uninstalled library and exit 9943316068Sdelphij if test relink = "$opt_mode"; then 9944275970Scy ( cd "$output_objdir" && \ 9945275970Scy $RM "${realname}T" && \ 9946275970Scy $MV "${realname}U" "$realname" ) 9947275970Scy fi 9948275970Scy 9949275970Scy exit $lt_exit 9950275970Scy } 9951275970Scy done 9952316068Sdelphij IFS=$save_ifs 9953275970Scy 9954275970Scy if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9955275970Scy func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9956275970Scy func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9957275970Scy fi 9958275970Scy fi 9959275970Scy 9960316068Sdelphij ${skipped_export-false} && { 9961275970Scy if test -n "$export_symbols" && test -n "$include_expsyms"; then 9962316068Sdelphij tmp_export_symbols=$export_symbols 9963316068Sdelphij test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9964275970Scy $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9965275970Scy fi 9966275970Scy 9967275970Scy if test -n "$orig_export_symbols"; then 9968275970Scy # The given exports_symbols file has to be filtered, so filter it. 9969316068Sdelphij func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9970275970Scy # FIXME: $output_objdir/$libname.filter potentially contains lots of 9971316068Sdelphij # 's' commands, which not all seds can handle. GNU sed should be fine 9972275970Scy # though. Also, the filter scales superlinearly with the number of 9973275970Scy # global variables. join(1) would be nice here, but unfortunately 9974275970Scy # isn't a blessed tool. 9975275970Scy $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9976275970Scy func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9977275970Scy export_symbols=$output_objdir/$libname.def 9978275970Scy $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9979275970Scy fi 9980316068Sdelphij } 9981275970Scy 9982275970Scy libobjs=$output 9983275970Scy # Restore the value of output. 9984275970Scy output=$save_output 9985275970Scy 9986275970Scy if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9987275970Scy eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9988275970Scy test "X$libobjs" = "X " && libobjs= 9989275970Scy fi 9990275970Scy # Expand the library linking commands again to reset the 9991275970Scy # value of $libobjs for piecewise linking. 9992275970Scy 9993275970Scy # Do each of the archive commands. 9994316068Sdelphij if test yes = "$module" && test -n "$module_cmds"; then 9995275970Scy if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9996275970Scy cmds=$module_expsym_cmds 9997275970Scy else 9998275970Scy cmds=$module_cmds 9999275970Scy fi 10000275970Scy else 10001275970Scy if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10002275970Scy cmds=$archive_expsym_cmds 10003275970Scy else 10004275970Scy cmds=$archive_cmds 10005275970Scy fi 10006275970Scy fi 10007275970Scy fi 10008275970Scy 10009275970Scy if test -n "$delfiles"; then 10010275970Scy # Append the command to remove temporary files to $cmds. 10011275970Scy eval cmds=\"\$cmds~\$RM $delfiles\" 10012275970Scy fi 10013275970Scy 10014275970Scy # Add any objects from preloaded convenience libraries 10015275970Scy if test -n "$dlprefiles"; then 10016316068Sdelphij gentop=$output_objdir/${outputname}x 10017275970Scy func_append generated " $gentop" 10018275970Scy 10019275970Scy func_extract_archives $gentop $dlprefiles 10020275970Scy func_append libobjs " $func_extract_archives_result" 10021275970Scy test "X$libobjs" = "X " && libobjs= 10022275970Scy fi 10023275970Scy 10024316068Sdelphij save_ifs=$IFS; IFS='~' 10025275970Scy for cmd in $cmds; do 10026316068Sdelphij IFS=$sp$nl 10027275970Scy eval cmd=\"$cmd\" 10028316068Sdelphij IFS=$save_ifs 10029316068Sdelphij $opt_quiet || { 10030275970Scy func_quote_for_expand "$cmd" 10031275970Scy eval "func_echo $func_quote_for_expand_result" 10032275970Scy } 10033275970Scy $opt_dry_run || eval "$cmd" || { 10034275970Scy lt_exit=$? 10035275970Scy 10036275970Scy # Restore the uninstalled library and exit 10037316068Sdelphij if test relink = "$opt_mode"; then 10038275970Scy ( cd "$output_objdir" && \ 10039275970Scy $RM "${realname}T" && \ 10040275970Scy $MV "${realname}U" "$realname" ) 10041275970Scy fi 10042275970Scy 10043275970Scy exit $lt_exit 10044275970Scy } 10045275970Scy done 10046316068Sdelphij IFS=$save_ifs 10047275970Scy 10048275970Scy # Restore the uninstalled library and exit 10049316068Sdelphij if test relink = "$opt_mode"; then 10050275970Scy $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051275970Scy 10052275970Scy if test -n "$convenience"; then 10053275970Scy if test -z "$whole_archive_flag_spec"; then 10054275970Scy func_show_eval '${RM}r "$gentop"' 10055275970Scy fi 10056275970Scy fi 10057275970Scy 10058275970Scy exit $EXIT_SUCCESS 10059275970Scy fi 10060275970Scy 10061275970Scy # Create links to the real library. 10062275970Scy for linkname in $linknames; do 10063275970Scy if test "$realname" != "$linkname"; then 10064275970Scy func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065275970Scy fi 10066275970Scy done 10067275970Scy 10068275970Scy # If -module or -export-dynamic was specified, set the dlname. 10069316068Sdelphij if test yes = "$module" || test yes = "$export_dynamic"; then 10070275970Scy # On all known operating systems, these are identical. 10071316068Sdelphij dlname=$soname 10072275970Scy fi 10073275970Scy fi 10074275970Scy ;; 10075275970Scy 10076275970Scy obj) 10077316068Sdelphij if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10078316068Sdelphij func_warning "'-dlopen' is ignored for objects" 10079275970Scy fi 10080275970Scy 10081275970Scy case " $deplibs" in 10082275970Scy *\ -l* | *\ -L*) 10083316068Sdelphij func_warning "'-l' and '-L' are ignored for objects" ;; 10084275970Scy esac 10085275970Scy 10086275970Scy test -n "$rpath" && \ 10087316068Sdelphij func_warning "'-rpath' is ignored for objects" 10088275970Scy 10089275970Scy test -n "$xrpath" && \ 10090316068Sdelphij func_warning "'-R' is ignored for objects" 10091275970Scy 10092275970Scy test -n "$vinfo" && \ 10093316068Sdelphij func_warning "'-version-info' is ignored for objects" 10094275970Scy 10095275970Scy test -n "$release" && \ 10096316068Sdelphij func_warning "'-release' is ignored for objects" 10097275970Scy 10098275970Scy case $output in 10099275970Scy *.lo) 10100275970Scy test -n "$objs$old_deplibs" && \ 10101316068Sdelphij func_fatal_error "cannot build library object '$output' from non-libtool objects" 10102275970Scy 10103275970Scy libobj=$output 10104275970Scy func_lo2o "$libobj" 10105275970Scy obj=$func_lo2o_result 10106275970Scy ;; 10107275970Scy *) 10108275970Scy libobj= 10109316068Sdelphij obj=$output 10110275970Scy ;; 10111275970Scy esac 10112275970Scy 10113275970Scy # Delete the old objects. 10114275970Scy $opt_dry_run || $RM $obj $libobj 10115275970Scy 10116275970Scy # Objects from convenience libraries. This assumes 10117275970Scy # single-version convenience libraries. Whenever we create 10118275970Scy # different ones for PIC/non-PIC, this we'll have to duplicate 10119275970Scy # the extraction. 10120275970Scy reload_conv_objs= 10121275970Scy gentop= 10122316068Sdelphij # if reload_cmds runs $LD directly, get rid of -Wl from 10123316068Sdelphij # whole_archive_flag_spec and hope we can get by with turning comma 10124316068Sdelphij # into space. 10125316068Sdelphij case $reload_cmds in 10126316068Sdelphij *\$LD[\ \$]*) wl= ;; 10127316068Sdelphij esac 10128275970Scy if test -n "$convenience"; then 10129275970Scy if test -n "$whole_archive_flag_spec"; then 10130275970Scy eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10131316068Sdelphij test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10132316068Sdelphij reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133275970Scy else 10134316068Sdelphij gentop=$output_objdir/${obj}x 10135275970Scy func_append generated " $gentop" 10136275970Scy 10137275970Scy func_extract_archives $gentop $convenience 10138275970Scy reload_conv_objs="$reload_objs $func_extract_archives_result" 10139275970Scy fi 10140275970Scy fi 10141275970Scy 10142275970Scy # If we're not building shared, we need to use non_pic_objs 10143316068Sdelphij test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144275970Scy 10145275970Scy # Create the old-style object. 10146316068Sdelphij reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147275970Scy 10148316068Sdelphij output=$obj 10149275970Scy func_execute_cmds "$reload_cmds" 'exit $?' 10150275970Scy 10151275970Scy # Exit if we aren't doing a library object file. 10152275970Scy if test -z "$libobj"; then 10153275970Scy if test -n "$gentop"; then 10154275970Scy func_show_eval '${RM}r "$gentop"' 10155275970Scy fi 10156275970Scy 10157275970Scy exit $EXIT_SUCCESS 10158275970Scy fi 10159275970Scy 10160316068Sdelphij test yes = "$build_libtool_libs" || { 10161275970Scy if test -n "$gentop"; then 10162275970Scy func_show_eval '${RM}r "$gentop"' 10163275970Scy fi 10164275970Scy 10165275970Scy # Create an invalid libtool object if no PIC, so that we don't 10166275970Scy # accidentally link it into a program. 10167275970Scy # $show "echo timestamp > $libobj" 10168275970Scy # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10169275970Scy exit $EXIT_SUCCESS 10170316068Sdelphij } 10171275970Scy 10172316068Sdelphij if test -n "$pic_flag" || test default != "$pic_mode"; then 10173275970Scy # Only do commands if we really have different PIC objects. 10174275970Scy reload_objs="$libobjs $reload_conv_objs" 10175316068Sdelphij output=$libobj 10176275970Scy func_execute_cmds "$reload_cmds" 'exit $?' 10177275970Scy fi 10178275970Scy 10179275970Scy if test -n "$gentop"; then 10180275970Scy func_show_eval '${RM}r "$gentop"' 10181275970Scy fi 10182275970Scy 10183275970Scy exit $EXIT_SUCCESS 10184275970Scy ;; 10185275970Scy 10186275970Scy prog) 10187275970Scy case $host in 10188275970Scy *cygwin*) func_stripname '' '.exe' "$output" 10189275970Scy output=$func_stripname_result.exe;; 10190275970Scy esac 10191275970Scy test -n "$vinfo" && \ 10192316068Sdelphij func_warning "'-version-info' is ignored for programs" 10193275970Scy 10194275970Scy test -n "$release" && \ 10195316068Sdelphij func_warning "'-release' is ignored for programs" 10196275970Scy 10197316068Sdelphij $preload \ 10198316068Sdelphij && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10199316068Sdelphij && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10200275970Scy 10201275970Scy case $host in 10202275970Scy *-*-rhapsody* | *-*-darwin1.[012]) 10203275970Scy # On Rhapsody replace the C library is the System framework 10204275970Scy compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10205275970Scy finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206275970Scy ;; 10207275970Scy esac 10208275970Scy 10209275970Scy case $host in 10210275970Scy *-*-darwin*) 10211275970Scy # Don't allow lazy linking, it breaks C++ global constructors 10212275970Scy # But is supposedly fixed on 10.4 or later (yay!). 10213316068Sdelphij if test CXX = "$tagname"; then 10214275970Scy case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10215275970Scy 10.[0123]) 10216316068Sdelphij func_append compile_command " $wl-bind_at_load" 10217316068Sdelphij func_append finalize_command " $wl-bind_at_load" 10218275970Scy ;; 10219275970Scy esac 10220275970Scy fi 10221275970Scy # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10222275970Scy compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10223275970Scy finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10224275970Scy ;; 10225275970Scy esac 10226275970Scy 10227275970Scy 10228275970Scy # move library search paths that coincide with paths to not yet 10229275970Scy # installed libraries to the beginning of the library search list 10230275970Scy new_libs= 10231275970Scy for path in $notinst_path; do 10232275970Scy case " $new_libs " in 10233275970Scy *" -L$path/$objdir "*) ;; 10234275970Scy *) 10235275970Scy case " $compile_deplibs " in 10236275970Scy *" -L$path/$objdir "*) 10237275970Scy func_append new_libs " -L$path/$objdir" ;; 10238275970Scy esac 10239275970Scy ;; 10240275970Scy esac 10241275970Scy done 10242275970Scy for deplib in $compile_deplibs; do 10243275970Scy case $deplib in 10244275970Scy -L*) 10245275970Scy case " $new_libs " in 10246275970Scy *" $deplib "*) ;; 10247275970Scy *) func_append new_libs " $deplib" ;; 10248275970Scy esac 10249275970Scy ;; 10250275970Scy *) func_append new_libs " $deplib" ;; 10251275970Scy esac 10252275970Scy done 10253316068Sdelphij compile_deplibs=$new_libs 10254275970Scy 10255275970Scy 10256275970Scy func_append compile_command " $compile_deplibs" 10257275970Scy func_append finalize_command " $finalize_deplibs" 10258275970Scy 10259275970Scy if test -n "$rpath$xrpath"; then 10260275970Scy # If the user specified any rpath flags, then add them. 10261275970Scy for libdir in $rpath $xrpath; do 10262275970Scy # This is the magic to use -rpath. 10263275970Scy case "$finalize_rpath " in 10264275970Scy *" $libdir "*) ;; 10265275970Scy *) func_append finalize_rpath " $libdir" ;; 10266275970Scy esac 10267275970Scy done 10268275970Scy fi 10269275970Scy 10270275970Scy # Now hardcode the library paths 10271275970Scy rpath= 10272275970Scy hardcode_libdirs= 10273275970Scy for libdir in $compile_rpath $finalize_rpath; do 10274275970Scy if test -n "$hardcode_libdir_flag_spec"; then 10275275970Scy if test -n "$hardcode_libdir_separator"; then 10276275970Scy if test -z "$hardcode_libdirs"; then 10277316068Sdelphij hardcode_libdirs=$libdir 10278275970Scy else 10279275970Scy # Just accumulate the unique libdirs. 10280275970Scy case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10281275970Scy *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10282275970Scy ;; 10283275970Scy *) 10284275970Scy func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10285275970Scy ;; 10286275970Scy esac 10287275970Scy fi 10288275970Scy else 10289275970Scy eval flag=\"$hardcode_libdir_flag_spec\" 10290275970Scy func_append rpath " $flag" 10291275970Scy fi 10292275970Scy elif test -n "$runpath_var"; then 10293275970Scy case "$perm_rpath " in 10294275970Scy *" $libdir "*) ;; 10295275970Scy *) func_append perm_rpath " $libdir" ;; 10296275970Scy esac 10297275970Scy fi 10298275970Scy case $host in 10299275970Scy *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10300316068Sdelphij testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10301275970Scy case :$dllsearchpath: in 10302275970Scy *":$libdir:"*) ;; 10303275970Scy ::) dllsearchpath=$libdir;; 10304275970Scy *) func_append dllsearchpath ":$libdir";; 10305275970Scy esac 10306275970Scy case :$dllsearchpath: in 10307275970Scy *":$testbindir:"*) ;; 10308275970Scy ::) dllsearchpath=$testbindir;; 10309275970Scy *) func_append dllsearchpath ":$testbindir";; 10310275970Scy esac 10311275970Scy ;; 10312275970Scy esac 10313275970Scy done 10314275970Scy # Substitute the hardcoded libdirs into the rpath. 10315275970Scy if test -n "$hardcode_libdir_separator" && 10316275970Scy test -n "$hardcode_libdirs"; then 10317316068Sdelphij libdir=$hardcode_libdirs 10318275970Scy eval rpath=\" $hardcode_libdir_flag_spec\" 10319275970Scy fi 10320316068Sdelphij compile_rpath=$rpath 10321275970Scy 10322275970Scy rpath= 10323275970Scy hardcode_libdirs= 10324275970Scy for libdir in $finalize_rpath; do 10325275970Scy if test -n "$hardcode_libdir_flag_spec"; then 10326275970Scy if test -n "$hardcode_libdir_separator"; then 10327275970Scy if test -z "$hardcode_libdirs"; then 10328316068Sdelphij hardcode_libdirs=$libdir 10329275970Scy else 10330275970Scy # Just accumulate the unique libdirs. 10331275970Scy case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10332275970Scy *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10333275970Scy ;; 10334275970Scy *) 10335275970Scy func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10336275970Scy ;; 10337275970Scy esac 10338275970Scy fi 10339275970Scy else 10340275970Scy eval flag=\"$hardcode_libdir_flag_spec\" 10341275970Scy func_append rpath " $flag" 10342275970Scy fi 10343275970Scy elif test -n "$runpath_var"; then 10344275970Scy case "$finalize_perm_rpath " in 10345275970Scy *" $libdir "*) ;; 10346275970Scy *) func_append finalize_perm_rpath " $libdir" ;; 10347275970Scy esac 10348275970Scy fi 10349275970Scy done 10350275970Scy # Substitute the hardcoded libdirs into the rpath. 10351275970Scy if test -n "$hardcode_libdir_separator" && 10352275970Scy test -n "$hardcode_libdirs"; then 10353316068Sdelphij libdir=$hardcode_libdirs 10354275970Scy eval rpath=\" $hardcode_libdir_flag_spec\" 10355275970Scy fi 10356316068Sdelphij finalize_rpath=$rpath 10357275970Scy 10358316068Sdelphij if test -n "$libobjs" && test yes = "$build_old_libs"; then 10359275970Scy # Transform all the library objects into standard objects. 10360275970Scy compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10361275970Scy finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10362275970Scy fi 10363275970Scy 10364316068Sdelphij func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365275970Scy 10366275970Scy # template prelinking step 10367275970Scy if test -n "$prelink_cmds"; then 10368275970Scy func_execute_cmds "$prelink_cmds" 'exit $?' 10369275970Scy fi 10370275970Scy 10371316068Sdelphij wrappers_required=: 10372275970Scy case $host in 10373275970Scy *cegcc* | *mingw32ce*) 10374275970Scy # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10375316068Sdelphij wrappers_required=false 10376275970Scy ;; 10377275970Scy *cygwin* | *mingw* ) 10378316068Sdelphij test yes = "$build_libtool_libs" || wrappers_required=false 10379275970Scy ;; 10380275970Scy *) 10381316068Sdelphij if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10382316068Sdelphij wrappers_required=false 10383275970Scy fi 10384275970Scy ;; 10385275970Scy esac 10386316068Sdelphij $wrappers_required || { 10387275970Scy # Replace the output file specification. 10388275970Scy compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10389316068Sdelphij link_command=$compile_command$compile_rpath 10390275970Scy 10391275970Scy # We have no uninstalled library dependencies, so finalize right now. 10392275970Scy exit_status=0 10393275970Scy func_show_eval "$link_command" 'exit_status=$?' 10394275970Scy 10395275970Scy if test -n "$postlink_cmds"; then 10396275970Scy func_to_tool_file "$output" 10397275970Scy postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10398275970Scy func_execute_cmds "$postlink_cmds" 'exit $?' 10399275970Scy fi 10400275970Scy 10401275970Scy # Delete the generated files. 10402316068Sdelphij if test -f "$output_objdir/${outputname}S.$objext"; then 10403316068Sdelphij func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404275970Scy fi 10405275970Scy 10406275970Scy exit $exit_status 10407316068Sdelphij } 10408275970Scy 10409275970Scy if test -n "$compile_shlibpath$finalize_shlibpath"; then 10410275970Scy compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10411275970Scy fi 10412275970Scy if test -n "$finalize_shlibpath"; then 10413275970Scy finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10414275970Scy fi 10415275970Scy 10416275970Scy compile_var= 10417275970Scy finalize_var= 10418275970Scy if test -n "$runpath_var"; then 10419275970Scy if test -n "$perm_rpath"; then 10420275970Scy # We should set the runpath_var. 10421275970Scy rpath= 10422275970Scy for dir in $perm_rpath; do 10423275970Scy func_append rpath "$dir:" 10424275970Scy done 10425275970Scy compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426275970Scy fi 10427275970Scy if test -n "$finalize_perm_rpath"; then 10428275970Scy # We should set the runpath_var. 10429275970Scy rpath= 10430275970Scy for dir in $finalize_perm_rpath; do 10431275970Scy func_append rpath "$dir:" 10432275970Scy done 10433275970Scy finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434275970Scy fi 10435275970Scy fi 10436275970Scy 10437316068Sdelphij if test yes = "$no_install"; then 10438275970Scy # We don't need to create a wrapper script. 10439316068Sdelphij link_command=$compile_var$compile_command$compile_rpath 10440275970Scy # Replace the output file specification. 10441275970Scy link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10442275970Scy # Delete the old output file. 10443275970Scy $opt_dry_run || $RM $output 10444275970Scy # Link the executable and exit 10445275970Scy func_show_eval "$link_command" 'exit $?' 10446275970Scy 10447275970Scy if test -n "$postlink_cmds"; then 10448275970Scy func_to_tool_file "$output" 10449275970Scy postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10450275970Scy func_execute_cmds "$postlink_cmds" 'exit $?' 10451275970Scy fi 10452275970Scy 10453275970Scy exit $EXIT_SUCCESS 10454275970Scy fi 10455275970Scy 10456316068Sdelphij case $hardcode_action,$fast_install in 10457316068Sdelphij relink,*) 10458316068Sdelphij # Fast installation is not supported 10459316068Sdelphij link_command=$compile_var$compile_command$compile_rpath 10460316068Sdelphij relink_command=$finalize_var$finalize_command$finalize_rpath 10461275970Scy 10462316068Sdelphij func_warning "this platform does not like uninstalled shared libraries" 10463316068Sdelphij func_warning "'$output' will be relinked during installation" 10464316068Sdelphij ;; 10465316068Sdelphij *,yes) 10466316068Sdelphij link_command=$finalize_var$compile_command$finalize_rpath 10467316068Sdelphij relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10468316068Sdelphij ;; 10469316068Sdelphij *,no) 10470316068Sdelphij link_command=$compile_var$compile_command$compile_rpath 10471316068Sdelphij relink_command=$finalize_var$finalize_command$finalize_rpath 10472316068Sdelphij ;; 10473316068Sdelphij *,needless) 10474316068Sdelphij link_command=$finalize_var$compile_command$finalize_rpath 10475316068Sdelphij relink_command= 10476316068Sdelphij ;; 10477316068Sdelphij esac 10478275970Scy 10479275970Scy # Replace the output file specification. 10480275970Scy link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481275970Scy 10482275970Scy # Delete the old output files. 10483275970Scy $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484275970Scy 10485275970Scy func_show_eval "$link_command" 'exit $?' 10486275970Scy 10487275970Scy if test -n "$postlink_cmds"; then 10488275970Scy func_to_tool_file "$output_objdir/$outputname" 10489275970Scy 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'` 10490275970Scy func_execute_cmds "$postlink_cmds" 'exit $?' 10491275970Scy fi 10492275970Scy 10493275970Scy # Now create the wrapper script. 10494275970Scy func_verbose "creating $output" 10495275970Scy 10496275970Scy # Quote the relink command for shipping. 10497275970Scy if test -n "$relink_command"; then 10498275970Scy # Preserve any variables that may affect compiler behavior 10499275970Scy for var in $variables_saved_for_relink; do 10500275970Scy if eval test -z \"\${$var+set}\"; then 10501275970Scy relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10502275970Scy elif eval var_value=\$$var; test -z "$var_value"; then 10503275970Scy relink_command="$var=; export $var; $relink_command" 10504275970Scy else 10505275970Scy func_quote_for_eval "$var_value" 10506275970Scy relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507275970Scy fi 10508275970Scy done 10509275970Scy relink_command="(cd `pwd`; $relink_command)" 10510275970Scy relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10511275970Scy fi 10512275970Scy 10513275970Scy # Only actually do things if not in dry run mode. 10514275970Scy $opt_dry_run || { 10515275970Scy # win32 will think the script is a binary if it has 10516275970Scy # a .exe suffix, so we strip it off here. 10517275970Scy case $output in 10518275970Scy *.exe) func_stripname '' '.exe' "$output" 10519275970Scy output=$func_stripname_result ;; 10520275970Scy esac 10521275970Scy # test for cygwin because mv fails w/o .exe extensions 10522275970Scy case $host in 10523275970Scy *cygwin*) 10524275970Scy exeext=.exe 10525275970Scy func_stripname '' '.exe' "$outputname" 10526275970Scy outputname=$func_stripname_result ;; 10527275970Scy *) exeext= ;; 10528275970Scy esac 10529275970Scy case $host in 10530275970Scy *cygwin* | *mingw* ) 10531275970Scy func_dirname_and_basename "$output" "" "." 10532275970Scy output_name=$func_basename_result 10533275970Scy output_path=$func_dirname_result 10534316068Sdelphij cwrappersource=$output_path/$objdir/lt-$output_name.c 10535316068Sdelphij cwrapper=$output_path/$output_name.exe 10536275970Scy $RM $cwrappersource $cwrapper 10537275970Scy trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10538275970Scy 10539275970Scy func_emit_cwrapperexe_src > $cwrappersource 10540275970Scy 10541275970Scy # The wrapper executable is built using the $host compiler, 10542275970Scy # because it contains $host paths and files. If cross- 10543275970Scy # compiling, it, like the target executable, must be 10544275970Scy # executed on the $host or under an emulation environment. 10545275970Scy $opt_dry_run || { 10546275970Scy $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10547275970Scy $STRIP $cwrapper 10548275970Scy } 10549275970Scy 10550275970Scy # Now, create the wrapper script for func_source use: 10551275970Scy func_ltwrapper_scriptname $cwrapper 10552275970Scy $RM $func_ltwrapper_scriptname_result 10553275970Scy trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10554275970Scy $opt_dry_run || { 10555275970Scy # note: this script will not be executed, so do not chmod. 10556316068Sdelphij if test "x$build" = "x$host"; then 10557275970Scy $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10558275970Scy else 10559275970Scy func_emit_wrapper no > $func_ltwrapper_scriptname_result 10560275970Scy fi 10561275970Scy } 10562275970Scy ;; 10563275970Scy * ) 10564275970Scy $RM $output 10565275970Scy trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566275970Scy 10567275970Scy func_emit_wrapper no > $output 10568275970Scy chmod +x $output 10569275970Scy ;; 10570275970Scy esac 10571275970Scy } 10572275970Scy exit $EXIT_SUCCESS 10573275970Scy ;; 10574275970Scy esac 10575275970Scy 10576275970Scy # See if we need to build an old-fashioned archive. 10577275970Scy for oldlib in $oldlibs; do 10578275970Scy 10579316068Sdelphij case $build_libtool_libs in 10580316068Sdelphij convenience) 10581316068Sdelphij oldobjs="$libobjs_save $symfileobj" 10582316068Sdelphij addlibs=$convenience 10583275970Scy build_libtool_libs=no 10584316068Sdelphij ;; 10585316068Sdelphij module) 10586316068Sdelphij oldobjs=$libobjs_save 10587316068Sdelphij addlibs=$old_convenience 10588316068Sdelphij build_libtool_libs=no 10589316068Sdelphij ;; 10590316068Sdelphij *) 10591275970Scy oldobjs="$old_deplibs $non_pic_objects" 10592316068Sdelphij $preload && test -f "$symfileobj" \ 10593316068Sdelphij && func_append oldobjs " $symfileobj" 10594316068Sdelphij addlibs=$old_convenience 10595316068Sdelphij ;; 10596316068Sdelphij esac 10597275970Scy 10598275970Scy if test -n "$addlibs"; then 10599316068Sdelphij gentop=$output_objdir/${outputname}x 10600275970Scy func_append generated " $gentop" 10601275970Scy 10602275970Scy func_extract_archives $gentop $addlibs 10603275970Scy func_append oldobjs " $func_extract_archives_result" 10604275970Scy fi 10605275970Scy 10606275970Scy # Do each command in the archive commands. 10607316068Sdelphij if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10608275970Scy cmds=$old_archive_from_new_cmds 10609275970Scy else 10610275970Scy 10611275970Scy # Add any objects from preloaded convenience libraries 10612275970Scy if test -n "$dlprefiles"; then 10613316068Sdelphij gentop=$output_objdir/${outputname}x 10614275970Scy func_append generated " $gentop" 10615275970Scy 10616275970Scy func_extract_archives $gentop $dlprefiles 10617275970Scy func_append oldobjs " $func_extract_archives_result" 10618275970Scy fi 10619275970Scy 10620275970Scy # POSIX demands no paths to be encoded in archives. We have 10621275970Scy # to avoid creating archives with duplicate basenames if we 10622275970Scy # might have to extract them afterwards, e.g., when creating a 10623275970Scy # static archive out of a convenience library, or when linking 10624275970Scy # the entirety of a libtool archive into another (currently 10625275970Scy # not supported by libtool). 10626275970Scy if (for obj in $oldobjs 10627275970Scy do 10628275970Scy func_basename "$obj" 10629275970Scy $ECHO "$func_basename_result" 10630275970Scy done | sort | sort -uc >/dev/null 2>&1); then 10631275970Scy : 10632275970Scy else 10633275970Scy echo "copying selected object files to avoid basename conflicts..." 10634316068Sdelphij gentop=$output_objdir/${outputname}x 10635275970Scy func_append generated " $gentop" 10636275970Scy func_mkdir_p "$gentop" 10637275970Scy save_oldobjs=$oldobjs 10638275970Scy oldobjs= 10639275970Scy counter=1 10640275970Scy for obj in $save_oldobjs 10641275970Scy do 10642275970Scy func_basename "$obj" 10643316068Sdelphij objbase=$func_basename_result 10644275970Scy case " $oldobjs " in 10645275970Scy " ") oldobjs=$obj ;; 10646275970Scy *[\ /]"$objbase "*) 10647275970Scy while :; do 10648275970Scy # Make sure we don't pick an alternate name that also 10649275970Scy # overlaps. 10650275970Scy newobj=lt$counter-$objbase 10651275970Scy func_arith $counter + 1 10652275970Scy counter=$func_arith_result 10653275970Scy case " $oldobjs " in 10654275970Scy *[\ /]"$newobj "*) ;; 10655275970Scy *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10656275970Scy esac 10657275970Scy done 10658275970Scy func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10659275970Scy func_append oldobjs " $gentop/$newobj" 10660275970Scy ;; 10661275970Scy *) func_append oldobjs " $obj" ;; 10662275970Scy esac 10663275970Scy done 10664275970Scy fi 10665285169Scy func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666285169Scy tool_oldlib=$func_to_tool_file_result 10667275970Scy eval cmds=\"$old_archive_cmds\" 10668275970Scy 10669275970Scy func_len " $cmds" 10670275970Scy len=$func_len_result 10671275970Scy if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10672275970Scy cmds=$old_archive_cmds 10673275970Scy elif test -n "$archiver_list_spec"; then 10674275970Scy func_verbose "using command file archive linking..." 10675275970Scy for obj in $oldobjs 10676275970Scy do 10677275970Scy func_to_tool_file "$obj" 10678275970Scy $ECHO "$func_to_tool_file_result" 10679275970Scy done > $output_objdir/$libname.libcmd 10680275970Scy func_to_tool_file "$output_objdir/$libname.libcmd" 10681275970Scy oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10682275970Scy cmds=$old_archive_cmds 10683275970Scy else 10684275970Scy # the command line is too long to link in one step, link in parts 10685275970Scy func_verbose "using piecewise archive linking..." 10686275970Scy save_RANLIB=$RANLIB 10687275970Scy RANLIB=: 10688275970Scy objlist= 10689275970Scy concat_cmds= 10690275970Scy save_oldobjs=$oldobjs 10691275970Scy oldobjs= 10692275970Scy # Is there a better way of finding the last object in the list? 10693275970Scy for obj in $save_oldobjs 10694275970Scy do 10695275970Scy last_oldobj=$obj 10696275970Scy done 10697275970Scy eval test_cmds=\"$old_archive_cmds\" 10698275970Scy func_len " $test_cmds" 10699275970Scy len0=$func_len_result 10700275970Scy len=$len0 10701275970Scy for obj in $save_oldobjs 10702275970Scy do 10703275970Scy func_len " $obj" 10704275970Scy func_arith $len + $func_len_result 10705275970Scy len=$func_arith_result 10706275970Scy func_append objlist " $obj" 10707275970Scy if test "$len" -lt "$max_cmd_len"; then 10708275970Scy : 10709275970Scy else 10710275970Scy # the above command should be used before it gets too long 10711275970Scy oldobjs=$objlist 10712316068Sdelphij if test "$obj" = "$last_oldobj"; then 10713275970Scy RANLIB=$save_RANLIB 10714275970Scy fi 10715275970Scy test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10716316068Sdelphij eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10717275970Scy objlist= 10718275970Scy len=$len0 10719275970Scy fi 10720275970Scy done 10721275970Scy RANLIB=$save_RANLIB 10722275970Scy oldobjs=$objlist 10723316068Sdelphij if test -z "$oldobjs"; then 10724275970Scy eval cmds=\"\$concat_cmds\" 10725275970Scy else 10726275970Scy eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10727275970Scy fi 10728275970Scy fi 10729275970Scy fi 10730275970Scy func_execute_cmds "$cmds" 'exit $?' 10731275970Scy done 10732275970Scy 10733275970Scy test -n "$generated" && \ 10734275970Scy func_show_eval "${RM}r$generated" 10735275970Scy 10736275970Scy # Now create the libtool archive. 10737275970Scy case $output in 10738275970Scy *.la) 10739275970Scy old_library= 10740316068Sdelphij test yes = "$build_old_libs" && old_library=$libname.$libext 10741275970Scy func_verbose "creating $output" 10742275970Scy 10743275970Scy # Preserve any variables that may affect compiler behavior 10744275970Scy for var in $variables_saved_for_relink; do 10745275970Scy if eval test -z \"\${$var+set}\"; then 10746275970Scy relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10747275970Scy elif eval var_value=\$$var; test -z "$var_value"; then 10748275970Scy relink_command="$var=; export $var; $relink_command" 10749275970Scy else 10750275970Scy func_quote_for_eval "$var_value" 10751275970Scy relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752275970Scy fi 10753275970Scy done 10754275970Scy # Quote the link command for shipping. 10755316068Sdelphij relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10756275970Scy relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10757316068Sdelphij if test yes = "$hardcode_automatic"; then 10758275970Scy relink_command= 10759275970Scy fi 10760275970Scy 10761275970Scy # Only create the output if not a dry run. 10762275970Scy $opt_dry_run || { 10763275970Scy for installed in no yes; do 10764316068Sdelphij if test yes = "$installed"; then 10765275970Scy if test -z "$install_libdir"; then 10766275970Scy break 10767275970Scy fi 10768316068Sdelphij output=$output_objdir/${outputname}i 10769275970Scy # Replace all uninstalled libtool libraries with the installed ones 10770275970Scy newdependency_libs= 10771275970Scy for deplib in $dependency_libs; do 10772275970Scy case $deplib in 10773275970Scy *.la) 10774275970Scy func_basename "$deplib" 10775316068Sdelphij name=$func_basename_result 10776285169Scy func_resolve_sysroot "$deplib" 10777316068Sdelphij eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10778275970Scy test -z "$libdir" && \ 10779316068Sdelphij func_fatal_error "'$deplib' is not a valid libtool archive" 10780275970Scy func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10781275970Scy ;; 10782275970Scy -L*) 10783275970Scy func_stripname -L '' "$deplib" 10784275970Scy func_replace_sysroot "$func_stripname_result" 10785275970Scy func_append newdependency_libs " -L$func_replace_sysroot_result" 10786275970Scy ;; 10787275970Scy -R*) 10788275970Scy func_stripname -R '' "$deplib" 10789275970Scy func_replace_sysroot "$func_stripname_result" 10790275970Scy func_append newdependency_libs " -R$func_replace_sysroot_result" 10791275970Scy ;; 10792275970Scy *) func_append newdependency_libs " $deplib" ;; 10793275970Scy esac 10794275970Scy done 10795316068Sdelphij dependency_libs=$newdependency_libs 10796275970Scy newdlfiles= 10797275970Scy 10798275970Scy for lib in $dlfiles; do 10799275970Scy case $lib in 10800275970Scy *.la) 10801275970Scy func_basename "$lib" 10802316068Sdelphij name=$func_basename_result 10803316068Sdelphij eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10804275970Scy test -z "$libdir" && \ 10805316068Sdelphij func_fatal_error "'$lib' is not a valid libtool archive" 10806275970Scy func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10807275970Scy ;; 10808275970Scy *) func_append newdlfiles " $lib" ;; 10809275970Scy esac 10810275970Scy done 10811316068Sdelphij dlfiles=$newdlfiles 10812275970Scy newdlprefiles= 10813275970Scy for lib in $dlprefiles; do 10814275970Scy case $lib in 10815275970Scy *.la) 10816275970Scy # Only pass preopened files to the pseudo-archive (for 10817275970Scy # eventual linking with the app. that links it) if we 10818275970Scy # didn't already link the preopened objects directly into 10819275970Scy # the library: 10820275970Scy func_basename "$lib" 10821316068Sdelphij name=$func_basename_result 10822316068Sdelphij eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10823275970Scy test -z "$libdir" && \ 10824316068Sdelphij func_fatal_error "'$lib' is not a valid libtool archive" 10825275970Scy func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10826275970Scy ;; 10827275970Scy esac 10828275970Scy done 10829316068Sdelphij dlprefiles=$newdlprefiles 10830275970Scy else 10831275970Scy newdlfiles= 10832275970Scy for lib in $dlfiles; do 10833275970Scy case $lib in 10834316068Sdelphij [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10835275970Scy *) abs=`pwd`"/$lib" ;; 10836275970Scy esac 10837275970Scy func_append newdlfiles " $abs" 10838275970Scy done 10839316068Sdelphij dlfiles=$newdlfiles 10840275970Scy newdlprefiles= 10841275970Scy for lib in $dlprefiles; do 10842275970Scy case $lib in 10843316068Sdelphij [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844275970Scy *) abs=`pwd`"/$lib" ;; 10845275970Scy esac 10846275970Scy func_append newdlprefiles " $abs" 10847275970Scy done 10848316068Sdelphij dlprefiles=$newdlprefiles 10849275970Scy fi 10850275970Scy $RM $output 10851275970Scy # place dlname in correct position for cygwin 10852275970Scy # In fact, it would be nice if we could use this code for all target 10853275970Scy # systems that can't hard-code library paths into their executables 10854275970Scy # and that have no shared library path variable independent of PATH, 10855275970Scy # but it turns out we can't easily determine that from inspecting 10856275970Scy # libtool variables, so we have to hard-code the OSs to which it 10857275970Scy # applies here; at the moment, that means platforms that use the PE 10858275970Scy # object format with DLL files. See the long comment at the top of 10859275970Scy # tests/bindir.at for full details. 10860275970Scy tdlname=$dlname 10861275970Scy case $host,$output,$installed,$module,$dlname in 10862275970Scy *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10863275970Scy # If a -bindir argument was supplied, place the dll there. 10864316068Sdelphij if test -n "$bindir"; then 10865275970Scy func_relative_path "$install_libdir" "$bindir" 10866316068Sdelphij tdlname=$func_relative_path_result/$dlname 10867275970Scy else 10868275970Scy # Otherwise fall back on heuristic. 10869275970Scy tdlname=../bin/$dlname 10870275970Scy fi 10871275970Scy ;; 10872275970Scy esac 10873275970Scy $ECHO > $output "\ 10874275970Scy# $outputname - a libtool library file 10875316068Sdelphij# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10876275970Scy# 10877275970Scy# Please DO NOT delete this file! 10878275970Scy# It is necessary for linking the library. 10879275970Scy 10880275970Scy# The name that we can dlopen(3). 10881275970Scydlname='$tdlname' 10882275970Scy 10883275970Scy# Names of this library. 10884275970Scylibrary_names='$library_names' 10885275970Scy 10886275970Scy# The name of the static archive. 10887275970Scyold_library='$old_library' 10888275970Scy 10889316068Sdelphij# Linker flags that cannot go in dependency_libs. 10890275970Scyinherited_linker_flags='$new_inherited_linker_flags' 10891275970Scy 10892275970Scy# Libraries that this one depends upon. 10893275970Scydependency_libs='$dependency_libs' 10894275970Scy 10895275970Scy# Names of additional weak libraries provided by this library 10896275970Scyweak_library_names='$weak_libs' 10897275970Scy 10898275970Scy# Version information for $libname. 10899275970Scycurrent=$current 10900275970Scyage=$age 10901275970Scyrevision=$revision 10902275970Scy 10903275970Scy# Is this an already installed library? 10904275970Scyinstalled=$installed 10905275970Scy 10906275970Scy# Should we warn about portability when linking against -modules? 10907275970Scyshouldnotlink=$module 10908275970Scy 10909275970Scy# Files to dlopen/dlpreopen 10910275970Scydlopen='$dlfiles' 10911275970Scydlpreopen='$dlprefiles' 10912275970Scy 10913275970Scy# Directory that this library needs to be installed in: 10914275970Scylibdir='$install_libdir'" 10915316068Sdelphij if test no,yes = "$installed,$need_relink"; then 10916275970Scy $ECHO >> $output "\ 10917275970Scyrelink_command=\"$relink_command\"" 10918275970Scy fi 10919275970Scy done 10920275970Scy } 10921275970Scy 10922275970Scy # Do a symbolic link so that the libtool archive can be found in 10923275970Scy # LD_LIBRARY_PATH before the program is installed. 10924275970Scy func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10925275970Scy ;; 10926275970Scy esac 10927275970Scy exit $EXIT_SUCCESS 10928275970Scy} 10929275970Scy 10930316068Sdelphijif test link = "$opt_mode" || test relink = "$opt_mode"; then 10931316068Sdelphij func_mode_link ${1+"$@"} 10932316068Sdelphijfi 10933275970Scy 10934275970Scy 10935275970Scy# func_mode_uninstall arg... 10936275970Scyfunc_mode_uninstall () 10937275970Scy{ 10938316068Sdelphij $debug_cmd 10939316068Sdelphij 10940316068Sdelphij RM=$nonopt 10941275970Scy files= 10942316068Sdelphij rmforce=false 10943275970Scy exit_status=0 10944275970Scy 10945275970Scy # This variable tells wrapper scripts just to set variables rather 10946275970Scy # than running their programs. 10947316068Sdelphij libtool_install_magic=$magic 10948275970Scy 10949275970Scy for arg 10950275970Scy do 10951275970Scy case $arg in 10952316068Sdelphij -f) func_append RM " $arg"; rmforce=: ;; 10953275970Scy -*) func_append RM " $arg" ;; 10954275970Scy *) func_append files " $arg" ;; 10955275970Scy esac 10956275970Scy done 10957275970Scy 10958275970Scy test -z "$RM" && \ 10959275970Scy func_fatal_help "you must specify an RM program" 10960275970Scy 10961275970Scy rmdirs= 10962275970Scy 10963275970Scy for file in $files; do 10964275970Scy func_dirname "$file" "" "." 10965316068Sdelphij dir=$func_dirname_result 10966316068Sdelphij if test . = "$dir"; then 10967316068Sdelphij odir=$objdir 10968275970Scy else 10969316068Sdelphij odir=$dir/$objdir 10970275970Scy fi 10971275970Scy func_basename "$file" 10972316068Sdelphij name=$func_basename_result 10973316068Sdelphij test uninstall = "$opt_mode" && odir=$dir 10974275970Scy 10975275970Scy # Remember odir for removal later, being careful to avoid duplicates 10976316068Sdelphij if test clean = "$opt_mode"; then 10977275970Scy case " $rmdirs " in 10978275970Scy *" $odir "*) ;; 10979275970Scy *) func_append rmdirs " $odir" ;; 10980275970Scy esac 10981275970Scy fi 10982275970Scy 10983275970Scy # Don't error if the file doesn't exist and rm -f was used. 10984275970Scy if { test -L "$file"; } >/dev/null 2>&1 || 10985275970Scy { test -h "$file"; } >/dev/null 2>&1 || 10986275970Scy test -f "$file"; then 10987275970Scy : 10988275970Scy elif test -d "$file"; then 10989275970Scy exit_status=1 10990275970Scy continue 10991316068Sdelphij elif $rmforce; then 10992275970Scy continue 10993275970Scy fi 10994275970Scy 10995316068Sdelphij rmfiles=$file 10996275970Scy 10997275970Scy case $name in 10998275970Scy *.la) 10999275970Scy # Possibly a libtool archive, so verify it. 11000275970Scy if func_lalib_p "$file"; then 11001275970Scy func_source $dir/$name 11002275970Scy 11003275970Scy # Delete the libtool libraries and symlinks. 11004275970Scy for n in $library_names; do 11005275970Scy func_append rmfiles " $odir/$n" 11006275970Scy done 11007275970Scy test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008275970Scy 11009316068Sdelphij case $opt_mode in 11010275970Scy clean) 11011275970Scy case " $library_names " in 11012275970Scy *" $dlname "*) ;; 11013275970Scy *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014275970Scy esac 11015275970Scy test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016275970Scy ;; 11017275970Scy uninstall) 11018275970Scy if test -n "$library_names"; then 11019275970Scy # Do each command in the postuninstall commands. 11020316068Sdelphij func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021275970Scy fi 11022275970Scy 11023275970Scy if test -n "$old_library"; then 11024275970Scy # Do each command in the old_postuninstall commands. 11025316068Sdelphij func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026275970Scy fi 11027275970Scy # FIXME: should reinstall the best remaining shared library. 11028275970Scy ;; 11029275970Scy esac 11030275970Scy fi 11031275970Scy ;; 11032275970Scy 11033275970Scy *.lo) 11034275970Scy # Possibly a libtool object, so verify it. 11035275970Scy if func_lalib_p "$file"; then 11036275970Scy 11037275970Scy # Read the .lo file 11038275970Scy func_source $dir/$name 11039275970Scy 11040275970Scy # Add PIC object to the list of files to remove. 11041316068Sdelphij if test -n "$pic_object" && test none != "$pic_object"; then 11042275970Scy func_append rmfiles " $dir/$pic_object" 11043275970Scy fi 11044275970Scy 11045275970Scy # Add non-PIC object to the list of files to remove. 11046316068Sdelphij if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11047275970Scy func_append rmfiles " $dir/$non_pic_object" 11048275970Scy fi 11049275970Scy fi 11050275970Scy ;; 11051275970Scy 11052275970Scy *) 11053316068Sdelphij if test clean = "$opt_mode"; then 11054275970Scy noexename=$name 11055275970Scy case $file in 11056275970Scy *.exe) 11057275970Scy func_stripname '' '.exe' "$file" 11058275970Scy file=$func_stripname_result 11059275970Scy func_stripname '' '.exe' "$name" 11060275970Scy noexename=$func_stripname_result 11061275970Scy # $file with .exe has already been added to rmfiles, 11062275970Scy # add $file without .exe 11063275970Scy func_append rmfiles " $file" 11064275970Scy ;; 11065275970Scy esac 11066275970Scy # Do a test to see if this is a libtool program. 11067275970Scy if func_ltwrapper_p "$file"; then 11068275970Scy if func_ltwrapper_executable_p "$file"; then 11069275970Scy func_ltwrapper_scriptname "$file" 11070275970Scy relink_command= 11071275970Scy func_source $func_ltwrapper_scriptname_result 11072275970Scy func_append rmfiles " $func_ltwrapper_scriptname_result" 11073275970Scy else 11074275970Scy relink_command= 11075275970Scy func_source $dir/$noexename 11076275970Scy fi 11077275970Scy 11078275970Scy # note $name still contains .exe if it was in $file originally 11079275970Scy # as does the version of $file that was added into $rmfiles 11080316068Sdelphij func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11081316068Sdelphij if test yes = "$fast_install" && test -n "$relink_command"; then 11082275970Scy func_append rmfiles " $odir/lt-$name" 11083275970Scy fi 11084316068Sdelphij if test "X$noexename" != "X$name"; then 11085316068Sdelphij func_append rmfiles " $odir/lt-$noexename.c" 11086275970Scy fi 11087275970Scy fi 11088275970Scy fi 11089275970Scy ;; 11090275970Scy esac 11091275970Scy func_show_eval "$RM $rmfiles" 'exit_status=1' 11092275970Scy done 11093275970Scy 11094316068Sdelphij # Try to remove the $objdir's in the directories where we deleted files 11095275970Scy for dir in $rmdirs; do 11096275970Scy if test -d "$dir"; then 11097275970Scy func_show_eval "rmdir $dir >/dev/null 2>&1" 11098275970Scy fi 11099275970Scy done 11100275970Scy 11101275970Scy exit $exit_status 11102275970Scy} 11103275970Scy 11104316068Sdelphijif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11105316068Sdelphij func_mode_uninstall ${1+"$@"} 11106316068Sdelphijfi 11107275970Scy 11108275970Scytest -z "$opt_mode" && { 11109316068Sdelphij help=$generic_help 11110275970Scy func_fatal_help "you must specify a MODE" 11111275970Scy} 11112275970Scy 11113275970Scytest -z "$exec_cmd" && \ 11114316068Sdelphij func_fatal_help "invalid operation mode '$opt_mode'" 11115275970Scy 11116275970Scyif test -n "$exec_cmd"; then 11117275970Scy eval exec "$exec_cmd" 11118275970Scy exit $EXIT_FAILURE 11119275970Scyfi 11120275970Scy 11121275970Scyexit $exit_status 11122275970Scy 11123275970Scy 11124275970Scy# The TAGs below are defined such that we never get into a situation 11125316068Sdelphij# where we disable both kinds of libraries. Given conflicting 11126275970Scy# choices, we go for a static library, that is the most portable, 11127275970Scy# since we can't tell whether shared libraries were disabled because 11128275970Scy# the user asked for that or because the platform doesn't support 11129275970Scy# them. This is particularly important on AIX, because we don't 11130275970Scy# support having both static and shared libraries enabled at the same 11131275970Scy# time on that platform, so we default to a shared-only configuration. 11132275970Scy# If a disable-shared tag is given, we'll fallback to a static-only 11133275970Scy# configuration. But we'll never go from static-only to shared-only. 11134275970Scy 11135275970Scy# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11136275970Scybuild_libtool_libs=no 11137275970Scybuild_old_libs=yes 11138275970Scy# ### END LIBTOOL TAG CONFIG: disable-shared 11139275970Scy 11140275970Scy# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11141275970Scybuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142275970Scy# ### END LIBTOOL TAG CONFIG: disable-static 11143275970Scy 11144275970Scy# Local Variables: 11145275970Scy# mode:shell-script 11146275970Scy# sh-indentation:2 11147275970Scy# End: 11148