ltmain.sh revision 03ea5dc6
1862bcd1aSmrg#! /bin/sh 2862bcd1aSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3862bcd1aSmrg## by inline-source v2014-01-03.01 488de56ccSmrg 5862bcd1aSmrg# libtool (GNU libtool) 2.4.6 6862bcd1aSmrg# Provide generalized library-building support services. 788de56ccSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 888de56ccSmrg 9862bcd1aSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 1088de56ccSmrg# This is free software; see the source for copying conditions. There is NO 1188de56ccSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1288de56ccSmrg 1388de56ccSmrg# GNU Libtool is free software; you can redistribute it and/or modify 141ab64890Smrg# it under the terms of the GNU General Public License as published by 151ab64890Smrg# the Free Software Foundation; either version 2 of the License, or 161ab64890Smrg# (at your option) any later version. 171ab64890Smrg# 1888de56ccSmrg# As a special exception to the GNU General Public License, 1988de56ccSmrg# if you distribute this file as part of a program or library that 2088de56ccSmrg# is built using GNU Libtool, you may include this file under the 2188de56ccSmrg# same distribution terms that you use for the rest of that program. 2288de56ccSmrg# 2388de56ccSmrg# GNU Libtool is distributed in the hope that it will be useful, but 241ab64890Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 251ab64890Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 261ab64890Smrg# General Public License for more details. 271ab64890Smrg# 281ab64890Smrg# You should have received a copy of the GNU General Public License 29862bcd1aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30b4ee4795Smrg 311ab64890Smrg 32e9fcaa8aSmrgPROGRAM=libtool 331ab64890SmrgPACKAGE=libtool 3403ea5dc6SmrgVERSION=2.4.6 35862bcd1aSmrgpackage_revision=2.4.6 361ab64890Smrg 37862bcd1aSmrg 38862bcd1aSmrg## ------ ## 39862bcd1aSmrg## Usage. ## 40862bcd1aSmrg## ------ ## 41862bcd1aSmrg 42862bcd1aSmrg# Run './libtool --help' for help with using this script from the 43862bcd1aSmrg# command line. 44862bcd1aSmrg 45862bcd1aSmrg 46862bcd1aSmrg## ------------------------------- ## 47862bcd1aSmrg## User overridable command paths. ## 48862bcd1aSmrg## ------------------------------- ## 49862bcd1aSmrg 50862bcd1aSmrg# After configure completes, it has a better idea of some of the 51862bcd1aSmrg# shell tools we need than the defaults used by the functions shared 52862bcd1aSmrg# with bootstrap, so set those here where they can still be over- 53862bcd1aSmrg# ridden by the user, but otherwise take precedence. 54862bcd1aSmrg 55862bcd1aSmrg: ${AUTOCONF="autoconf"} 56862bcd1aSmrg: ${AUTOMAKE="automake"} 57862bcd1aSmrg 58862bcd1aSmrg 59862bcd1aSmrg## -------------------------- ## 60862bcd1aSmrg## Source external libraries. ## 61862bcd1aSmrg## -------------------------- ## 62862bcd1aSmrg 63862bcd1aSmrg# Much of our low-level functionality needs to be sourced from external 64862bcd1aSmrg# libraries, which are installed to $pkgauxdir. 65862bcd1aSmrg 66862bcd1aSmrg# Set a version string for this script. 675afda2e6Smrgscriptversion=2015-01-20.17; # UTC 68862bcd1aSmrg 69862bcd1aSmrg# General shell script boiler plate, and helper functions. 70862bcd1aSmrg# Written by Gary V. Vaughan, 2004 71862bcd1aSmrg 72862bcd1aSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73862bcd1aSmrg# This is free software; see the source for copying conditions. There is NO 74862bcd1aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75862bcd1aSmrg 76862bcd1aSmrg# This program is free software; you can redistribute it and/or modify 77862bcd1aSmrg# it under the terms of the GNU General Public License as published by 78862bcd1aSmrg# the Free Software Foundation; either version 3 of the License, or 79862bcd1aSmrg# (at your option) any later version. 80862bcd1aSmrg 81862bcd1aSmrg# As a special exception to the GNU General Public License, if you distribute 82862bcd1aSmrg# this file as part of a program or library that is built using GNU Libtool, 83862bcd1aSmrg# you may include this file under the same distribution terms that you use 84862bcd1aSmrg# for the rest of that program. 85862bcd1aSmrg 86862bcd1aSmrg# This program is distributed in the hope that it will be useful, 87862bcd1aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 88862bcd1aSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89862bcd1aSmrg# General Public License for more details. 90862bcd1aSmrg 91862bcd1aSmrg# You should have received a copy of the GNU General Public License 92862bcd1aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 93862bcd1aSmrg 94862bcd1aSmrg# Please report bugs or propose patches to gary@gnu.org. 95862bcd1aSmrg 96862bcd1aSmrg 97862bcd1aSmrg## ------ ## 98862bcd1aSmrg## Usage. ## 99862bcd1aSmrg## ------ ## 100862bcd1aSmrg 101862bcd1aSmrg# Evaluate this file near the top of your script to gain access to 102862bcd1aSmrg# the functions and variables defined here: 103862bcd1aSmrg# 104862bcd1aSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105862bcd1aSmrg# 106862bcd1aSmrg# If you need to override any of the default environment variable 107862bcd1aSmrg# settings, do that before evaluating this file. 108862bcd1aSmrg 109862bcd1aSmrg 110862bcd1aSmrg## -------------------- ## 111862bcd1aSmrg## Shell normalisation. ## 112862bcd1aSmrg## -------------------- ## 113862bcd1aSmrg 114862bcd1aSmrg# Some shells need a little help to be as Bourne compatible as possible. 115862bcd1aSmrg# Before doing anything else, make sure all that help has been provided! 116862bcd1aSmrg 117862bcd1aSmrgDUALCASE=1; export DUALCASE # for MKS sh 118862bcd1aSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1191ab64890Smrg emulate sh 1201ab64890Smrg NULLCMD=: 121862bcd1aSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1221ab64890Smrg # is contrary to our usage. Disable this feature. 1231ab64890Smrg alias -g '${1+"$@"}'='"$@"' 1241ab64890Smrg setopt NO_GLOB_SUBST 1251ab64890Smrgelse 126862bcd1aSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 1271ab64890Smrgfi 128e9fcaa8aSmrg 129862bcd1aSmrg# NLS nuisances: We save the old values in case they are required later. 130862bcd1aSmrg_G_user_locale= 131862bcd1aSmrg_G_safe_locale= 132862bcd1aSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1331ab64890Smrgdo 134862bcd1aSmrg eval "if test set = \"\${$_G_var+set}\"; then 135862bcd1aSmrg save_$_G_var=\$$_G_var 136862bcd1aSmrg $_G_var=C 137862bcd1aSmrg export $_G_var 138862bcd1aSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139862bcd1aSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1401ab64890Smrg fi" 1411ab64890Smrgdone 1421ab64890Smrg 143862bcd1aSmrg# CDPATH. 144862bcd1aSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 14588de56ccSmrg 146862bcd1aSmrg# Make sure IFS has a sensible default 147862bcd1aSmrgsp=' ' 148862bcd1aSmrgnl=' 149862bcd1aSmrg' 150862bcd1aSmrgIFS="$sp $nl" 151862bcd1aSmrg 152862bcd1aSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 153862bcd1aSmrgif test "${PATH_SEPARATOR+set}" != set; then 154862bcd1aSmrg PATH_SEPARATOR=: 155862bcd1aSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156862bcd1aSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157862bcd1aSmrg PATH_SEPARATOR=';' 158862bcd1aSmrg } 159862bcd1aSmrgfi 16088de56ccSmrg 16188de56ccSmrg 16288de56ccSmrg 163862bcd1aSmrg## ------------------------- ## 164862bcd1aSmrg## Locate command utilities. ## 165862bcd1aSmrg## ------------------------- ## 166862bcd1aSmrg 167862bcd1aSmrg 168862bcd1aSmrg# func_executable_p FILE 169862bcd1aSmrg# ---------------------- 170862bcd1aSmrg# Check that FILE is an executable regular file. 171862bcd1aSmrgfunc_executable_p () 172862bcd1aSmrg{ 173862bcd1aSmrg test -f "$1" && test -x "$1" 174862bcd1aSmrg} 175862bcd1aSmrg 176862bcd1aSmrg 177862bcd1aSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178862bcd1aSmrg# -------------------------------------------- 179862bcd1aSmrg# Search for either a program that responds to --version with output 180862bcd1aSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181862bcd1aSmrg# trying all the directories in PATH with each of the elements of 182862bcd1aSmrg# PROGS_LIST. 183862bcd1aSmrg# 184862bcd1aSmrg# CHECK_FUNC should accept the path to a candidate program, and 185862bcd1aSmrg# set $func_check_prog_result if it truncates its output less than 186862bcd1aSmrg# $_G_path_prog_max characters. 187862bcd1aSmrgfunc_path_progs () 188862bcd1aSmrg{ 189862bcd1aSmrg _G_progs_list=$1 190862bcd1aSmrg _G_check_func=$2 191862bcd1aSmrg _G_PATH=${3-"$PATH"} 192862bcd1aSmrg 193862bcd1aSmrg _G_path_prog_max=0 194862bcd1aSmrg _G_path_prog_found=false 195862bcd1aSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196862bcd1aSmrg for _G_dir in $_G_PATH; do 197862bcd1aSmrg IFS=$_G_save_IFS 198862bcd1aSmrg test -z "$_G_dir" && _G_dir=. 199862bcd1aSmrg for _G_prog_name in $_G_progs_list; do 200862bcd1aSmrg for _exeext in '' .EXE; do 201862bcd1aSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202862bcd1aSmrg func_executable_p "$_G_path_prog" || continue 203862bcd1aSmrg case `"$_G_path_prog" --version 2>&1` in 204862bcd1aSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205862bcd1aSmrg *) $_G_check_func $_G_path_prog 206862bcd1aSmrg func_path_progs_result=$func_check_prog_result 207862bcd1aSmrg ;; 208862bcd1aSmrg esac 209862bcd1aSmrg $_G_path_prog_found && break 3 210862bcd1aSmrg done 211862bcd1aSmrg done 212862bcd1aSmrg done 213862bcd1aSmrg IFS=$_G_save_IFS 214862bcd1aSmrg test -z "$func_path_progs_result" && { 215862bcd1aSmrg echo "no acceptable sed could be found in \$PATH" >&2 216862bcd1aSmrg exit 1 217862bcd1aSmrg } 218862bcd1aSmrg} 219862bcd1aSmrg 220862bcd1aSmrg 221862bcd1aSmrg# We want to be able to use the functions in this file before configure 222862bcd1aSmrg# has figured out where the best binaries are kept, which means we have 223862bcd1aSmrg# to search for them ourselves - except when the results are already set 224862bcd1aSmrg# where we skip the searches. 225862bcd1aSmrg 226862bcd1aSmrg# Unless the user overrides by setting SED, search the path for either GNU 227862bcd1aSmrg# sed, or the sed that truncates its output the least. 228862bcd1aSmrgtest -z "$SED" && { 229862bcd1aSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230862bcd1aSmrg for _G_i in 1 2 3 4 5 6 7; do 231862bcd1aSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 232862bcd1aSmrg done 233862bcd1aSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234862bcd1aSmrg _G_sed_script= 235862bcd1aSmrg 236862bcd1aSmrg func_check_prog_sed () 237862bcd1aSmrg { 238862bcd1aSmrg _G_path_prog=$1 239862bcd1aSmrg 240862bcd1aSmrg _G_count=0 241862bcd1aSmrg printf 0123456789 >conftest.in 242862bcd1aSmrg while : 243862bcd1aSmrg do 244862bcd1aSmrg cat conftest.in conftest.in >conftest.tmp 245862bcd1aSmrg mv conftest.tmp conftest.in 246862bcd1aSmrg cp conftest.in conftest.nl 247862bcd1aSmrg echo '' >> conftest.nl 248862bcd1aSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249862bcd1aSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 250862bcd1aSmrg _G_count=`expr $_G_count + 1` 251862bcd1aSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 252862bcd1aSmrg # Best one so far, save it but keep looking for a better one 253862bcd1aSmrg func_check_prog_result=$_G_path_prog 254862bcd1aSmrg _G_path_prog_max=$_G_count 255862bcd1aSmrg fi 256862bcd1aSmrg # 10*(2^10) chars as input seems more than enough 257862bcd1aSmrg test 10 -lt "$_G_count" && break 258862bcd1aSmrg done 259862bcd1aSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 260862bcd1aSmrg } 261862bcd1aSmrg 262862bcd1aSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263862bcd1aSmrg rm -f conftest.sed 264862bcd1aSmrg SED=$func_path_progs_result 265862bcd1aSmrg} 266862bcd1aSmrg 267862bcd1aSmrg 268862bcd1aSmrg# Unless the user overrides by setting GREP, search the path for either GNU 269862bcd1aSmrg# grep, or the grep that truncates its output the least. 270862bcd1aSmrgtest -z "$GREP" && { 271862bcd1aSmrg func_check_prog_grep () 272862bcd1aSmrg { 273862bcd1aSmrg _G_path_prog=$1 274862bcd1aSmrg 275862bcd1aSmrg _G_count=0 276862bcd1aSmrg _G_path_prog_max=0 277862bcd1aSmrg printf 0123456789 >conftest.in 278862bcd1aSmrg while : 279862bcd1aSmrg do 280862bcd1aSmrg cat conftest.in conftest.in >conftest.tmp 281862bcd1aSmrg mv conftest.tmp conftest.in 282862bcd1aSmrg cp conftest.in conftest.nl 283862bcd1aSmrg echo 'GREP' >> conftest.nl 284862bcd1aSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285862bcd1aSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 286862bcd1aSmrg _G_count=`expr $_G_count + 1` 287862bcd1aSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 288862bcd1aSmrg # Best one so far, save it but keep looking for a better one 289862bcd1aSmrg func_check_prog_result=$_G_path_prog 290862bcd1aSmrg _G_path_prog_max=$_G_count 291862bcd1aSmrg fi 292862bcd1aSmrg # 10*(2^10) chars as input seems more than enough 293862bcd1aSmrg test 10 -lt "$_G_count" && break 294862bcd1aSmrg done 295862bcd1aSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 296862bcd1aSmrg } 297862bcd1aSmrg 298862bcd1aSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299862bcd1aSmrg GREP=$func_path_progs_result 300862bcd1aSmrg} 301862bcd1aSmrg 302862bcd1aSmrg 303862bcd1aSmrg## ------------------------------- ## 304862bcd1aSmrg## User overridable command paths. ## 305862bcd1aSmrg## ------------------------------- ## 306862bcd1aSmrg 307862bcd1aSmrg# All uppercase variable names are used for environment variables. These 308862bcd1aSmrg# variables can be overridden by the user before calling a script that 309862bcd1aSmrg# uses them if a suitable command of that name is not already available 310862bcd1aSmrg# in the command search PATH. 31188de56ccSmrg 31288de56ccSmrg: ${CP="cp -f"} 313862bcd1aSmrg: ${ECHO="printf %s\n"} 314862bcd1aSmrg: ${EGREP="$GREP -E"} 315862bcd1aSmrg: ${FGREP="$GREP -F"} 316862bcd1aSmrg: ${LN_S="ln -s"} 31788de56ccSmrg: ${MAKE="make"} 31888de56ccSmrg: ${MKDIR="mkdir"} 31988de56ccSmrg: ${MV="mv -f"} 32088de56ccSmrg: ${RM="rm -f"} 32188de56ccSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 3221ab64890Smrg 32388de56ccSmrg 324862bcd1aSmrg## -------------------- ## 325862bcd1aSmrg## Useful sed snippets. ## 326862bcd1aSmrg## -------------------- ## 327e9fcaa8aSmrg 328862bcd1aSmrgsed_dirname='s|/[^/]*$||' 329862bcd1aSmrgsed_basename='s|^.*/||' 330e9fcaa8aSmrg 331862bcd1aSmrg# Sed substitution that helps us do robust quoting. It backslashifies 332862bcd1aSmrg# metacharacters that are still active within double-quoted strings. 333862bcd1aSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334e9fcaa8aSmrg 335862bcd1aSmrg# Same as above, but do not quote variable references. 336862bcd1aSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337e9fcaa8aSmrg 338862bcd1aSmrg# Sed substitution that turns a string into a regex matching for the 339862bcd1aSmrg# string literally. 340862bcd1aSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341e9fcaa8aSmrg 342862bcd1aSmrg# Sed substitution that converts a w32 file name or path 343862bcd1aSmrg# that contains forward slashes, into one that contains 344862bcd1aSmrg# (escaped) backslashes. A very naive implementation. 345862bcd1aSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346862bcd1aSmrg 347862bcd1aSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 348862bcd1aSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 349862bcd1aSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 350862bcd1aSmrg# expansion. Since each input '\' is now two '\'s, look for any number 351862bcd1aSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352862bcd1aSmrg_G_bs='\\' 353862bcd1aSmrg_G_bs2='\\\\' 354862bcd1aSmrg_G_bs4='\\\\\\\\' 355862bcd1aSmrg_G_dollar='\$' 356862bcd1aSmrgsed_double_backslash="\ 357862bcd1aSmrg s/$_G_bs4/&\\ 358862bcd1aSmrg/g 359862bcd1aSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 360862bcd1aSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361862bcd1aSmrg s/\n//g" 362e9fcaa8aSmrg 363e9fcaa8aSmrg 364862bcd1aSmrg## ----------------- ## 365862bcd1aSmrg## Global variables. ## 366862bcd1aSmrg## ----------------- ## 367e9fcaa8aSmrg 368862bcd1aSmrg# Except for the global variables explicitly listed below, the following 369862bcd1aSmrg# functions in the '^func_' namespace, and the '^require_' namespace 370862bcd1aSmrg# variables initialised in the 'Resource management' section, sourcing 371862bcd1aSmrg# this file will not pollute your global namespace with anything 372862bcd1aSmrg# else. There's no portable way to scope variables in Bourne shell 373862bcd1aSmrg# though, so actually running these functions will sometimes place 374862bcd1aSmrg# results into a variable named after the function, and often use 375862bcd1aSmrg# temporary variables in the '^_G_' namespace. If you are careful to 376862bcd1aSmrg# avoid using those namespaces casually in your sourcing script, things 377862bcd1aSmrg# should continue to work as you expect. And, of course, you can freely 378862bcd1aSmrg# overwrite any of the functions or variables defined here before 379862bcd1aSmrg# calling anything to customize them. 380e9fcaa8aSmrg 381862bcd1aSmrgEXIT_SUCCESS=0 382862bcd1aSmrgEXIT_FAILURE=1 383862bcd1aSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384862bcd1aSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 3852e9c7c8cSmrg 386862bcd1aSmrg# Allow overriding, eg assuming that you follow the convention of 387862bcd1aSmrg# putting '$debug_cmd' at the start of all your functions, you can get 388862bcd1aSmrg# bash to show function call trace with: 389862bcd1aSmrg# 39003ea5dc6Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391862bcd1aSmrgdebug_cmd=${debug_cmd-":"} 392862bcd1aSmrgexit_cmd=: 39388de56ccSmrg 394862bcd1aSmrg# By convention, finish your script with: 395862bcd1aSmrg# 396862bcd1aSmrg# exit $exit_status 397862bcd1aSmrg# 398862bcd1aSmrg# so that you can set exit_status to non-zero if you want to indicate 399862bcd1aSmrg# something went wrong during execution without actually bailing out at 400862bcd1aSmrg# the point of failure. 401862bcd1aSmrgexit_status=$EXIT_SUCCESS 402e9fcaa8aSmrg 403862bcd1aSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404862bcd1aSmrg# is ksh but when the shell is invoked as "sh" and the current value of 405862bcd1aSmrg# the _XPG environment variable is not equal to 1 (one), the special 406862bcd1aSmrg# positional parameter $0, within a function call, is the name of the 407862bcd1aSmrg# function. 408862bcd1aSmrgprogpath=$0 40988de56ccSmrg 410862bcd1aSmrg# The name of this program. 411862bcd1aSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 41288de56ccSmrg 413862bcd1aSmrg# Make sure we have an absolute progpath for reexecution: 41488de56ccSmrgcase $progpath in 41588de56ccSmrg [\\/]*|[A-Za-z]:\\*) ;; 41688de56ccSmrg *[\\/]*) 417862bcd1aSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 41888de56ccSmrg progdir=`cd "$progdir" && pwd` 419862bcd1aSmrg progpath=$progdir/$progname 42088de56ccSmrg ;; 42188de56ccSmrg *) 422862bcd1aSmrg _G_IFS=$IFS 423eb411b4bSmrg IFS=${PATH_SEPARATOR-:} 42488de56ccSmrg for progdir in $PATH; do 425862bcd1aSmrg IFS=$_G_IFS 42688de56ccSmrg test -x "$progdir/$progname" && break 42788de56ccSmrg done 428862bcd1aSmrg IFS=$_G_IFS 42988de56ccSmrg test -n "$progdir" || progdir=`pwd` 430862bcd1aSmrg progpath=$progdir/$progname 43188de56ccSmrg ;; 43288de56ccSmrgesac 43388de56ccSmrg 43488de56ccSmrg 435862bcd1aSmrg## ----------------- ## 436862bcd1aSmrg## Standard options. ## 437862bcd1aSmrg## ----------------- ## 438e9fcaa8aSmrg 439862bcd1aSmrg# The following options affect the operation of the functions defined 440862bcd1aSmrg# below, and should be set appropriately depending on run-time para- 441862bcd1aSmrg# meters passed on the command line. 44288de56ccSmrg 44388de56ccSmrgopt_dry_run=false 44488de56ccSmrgopt_quiet=false 44588de56ccSmrgopt_verbose=false 44688de56ccSmrg 447862bcd1aSmrg# Categories 'all' and 'none' are always available. Append any others 448862bcd1aSmrg# you will pass as the first argument to func_warning from your own 449862bcd1aSmrg# code. 450862bcd1aSmrgwarning_categories= 45188de56ccSmrg 452862bcd1aSmrg# By default, display warnings according to 'opt_warning_types'. Set 453862bcd1aSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454862bcd1aSmrg# treat the next displayed warning as a fatal error. 455862bcd1aSmrgwarning_func=func_warn_and_continue 45688de56ccSmrg 457862bcd1aSmrg# Set to 'all' to display all warnings, 'none' to suppress all 458862bcd1aSmrg# warnings, or a space delimited list of some subset of 459862bcd1aSmrg# 'warning_categories' to display only the listed warnings. 460862bcd1aSmrgopt_warning_types=all 46188de56ccSmrg 462e9fcaa8aSmrg 463862bcd1aSmrg## -------------------- ## 464862bcd1aSmrg## Resource management. ## 465862bcd1aSmrg## -------------------- ## 46688de56ccSmrg 467862bcd1aSmrg# This section contains definitions for functions that each ensure a 468862bcd1aSmrg# particular resource (a file, or a non-empty configuration variable for 469862bcd1aSmrg# example) is available, and if appropriate to extract default values 470862bcd1aSmrg# from pertinent package files. Call them using their associated 471862bcd1aSmrg# 'require_*' variable to ensure that they are executed, at most, once. 472862bcd1aSmrg# 473862bcd1aSmrg# It's entirely deliberate that calling these functions can set 474862bcd1aSmrg# variables that don't obey the namespace limitations obeyed by the rest 475862bcd1aSmrg# of this file, in order that that they be as useful as possible to 476862bcd1aSmrg# callers. 47788de56ccSmrg 47888de56ccSmrg 479862bcd1aSmrg# require_term_colors 480862bcd1aSmrg# ------------------- 481862bcd1aSmrg# Allow display of bold text on terminals that support it. 482862bcd1aSmrgrequire_term_colors=func_require_term_colors 483862bcd1aSmrgfunc_require_term_colors () 48488de56ccSmrg{ 485862bcd1aSmrg $debug_cmd 486862bcd1aSmrg 487862bcd1aSmrg test -t 1 && { 488862bcd1aSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 489862bcd1aSmrg # precedence, because most terminfo databases neglect to describe 490862bcd1aSmrg # whether color sequences are supported. 491862bcd1aSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492862bcd1aSmrg 493862bcd1aSmrg if test 1 = "$USE_ANSI_COLORS"; then 494862bcd1aSmrg # Standard ANSI escape sequences 495862bcd1aSmrg tc_reset='[0m' 496862bcd1aSmrg tc_bold='[1m'; tc_standout='[7m' 497862bcd1aSmrg tc_red='[31m'; tc_green='[32m' 498862bcd1aSmrg tc_blue='[34m'; tc_cyan='[36m' 499862bcd1aSmrg else 500862bcd1aSmrg # Otherwise trust the terminfo database after all. 501862bcd1aSmrg test -n "`tput sgr0 2>/dev/null`" && { 502862bcd1aSmrg tc_reset=`tput sgr0` 503862bcd1aSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504862bcd1aSmrg tc_standout=$tc_bold 505862bcd1aSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506862bcd1aSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507862bcd1aSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508862bcd1aSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509862bcd1aSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510862bcd1aSmrg } 511862bcd1aSmrg fi 512862bcd1aSmrg } 51388de56ccSmrg 514862bcd1aSmrg require_term_colors=: 51588de56ccSmrg} 51688de56ccSmrg 51788de56ccSmrg 518862bcd1aSmrg## ----------------- ## 519862bcd1aSmrg## Function library. ## 520862bcd1aSmrg## ----------------- ## 521862bcd1aSmrg 522862bcd1aSmrg# This section contains a variety of useful functions to call in your 523862bcd1aSmrg# scripts. Take note of the portable wrappers for features provided by 524862bcd1aSmrg# some modern shells, which will fall back to slower equivalents on 525862bcd1aSmrg# less featureful shells. 526862bcd1aSmrg 527862bcd1aSmrg 528862bcd1aSmrg# func_append VAR VALUE 529862bcd1aSmrg# --------------------- 530862bcd1aSmrg# Append VALUE onto the existing contents of VAR. 531862bcd1aSmrg 532862bcd1aSmrg # We should try to minimise forks, especially on Windows where they are 533862bcd1aSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 534862bcd1aSmrg # being used: 535862bcd1aSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536862bcd1aSmrg : ${_G_HAVE_ARITH_OP="yes"} 537862bcd1aSmrg : ${_G_HAVE_XSI_OPS="yes"} 538862bcd1aSmrg # The += operator was introduced in bash 3.1 539862bcd1aSmrg case $BASH_VERSION in 540862bcd1aSmrg [12].* | 3.0 | 3.0*) ;; 541862bcd1aSmrg *) 542862bcd1aSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 543862bcd1aSmrg ;; 544862bcd1aSmrg esac 545862bcd1aSmrg fi 546862bcd1aSmrg 547862bcd1aSmrg # _G_HAVE_PLUSEQ_OP 548862bcd1aSmrg # Can be empty, in which case the shell is probed, "yes" if += is 549862bcd1aSmrg # useable or anything else if it does not work. 550862bcd1aSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 551862bcd1aSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552862bcd1aSmrg && _G_HAVE_PLUSEQ_OP=yes 553862bcd1aSmrg 554862bcd1aSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 555862bcd1aSmrgthen 556862bcd1aSmrg # This is an XSI compatible shell, allowing a faster implementation... 557862bcd1aSmrg eval 'func_append () 558862bcd1aSmrg { 559862bcd1aSmrg $debug_cmd 560862bcd1aSmrg 561862bcd1aSmrg eval "$1+=\$2" 562862bcd1aSmrg }' 563862bcd1aSmrgelse 564862bcd1aSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 565862bcd1aSmrg func_append () 566862bcd1aSmrg { 567862bcd1aSmrg $debug_cmd 568862bcd1aSmrg 569862bcd1aSmrg eval "$1=\$$1\$2" 570862bcd1aSmrg } 571862bcd1aSmrgfi 572862bcd1aSmrg 573862bcd1aSmrg 574862bcd1aSmrg# func_append_quoted VAR VALUE 575862bcd1aSmrg# ---------------------------- 576862bcd1aSmrg# Quote VALUE and append to the end of shell variable VAR, separated 577862bcd1aSmrg# by a space. 578862bcd1aSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579862bcd1aSmrg eval 'func_append_quoted () 580862bcd1aSmrg { 581862bcd1aSmrg $debug_cmd 582862bcd1aSmrg 583862bcd1aSmrg func_quote_for_eval "$2" 584862bcd1aSmrg eval "$1+=\\ \$func_quote_for_eval_result" 585862bcd1aSmrg }' 586862bcd1aSmrgelse 587862bcd1aSmrg func_append_quoted () 588862bcd1aSmrg { 589862bcd1aSmrg $debug_cmd 590862bcd1aSmrg 591862bcd1aSmrg func_quote_for_eval "$2" 592862bcd1aSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 593862bcd1aSmrg } 594862bcd1aSmrgfi 595862bcd1aSmrg 596862bcd1aSmrg 597862bcd1aSmrg# func_append_uniq VAR VALUE 598862bcd1aSmrg# -------------------------- 599862bcd1aSmrg# Append unique VALUE onto the existing contents of VAR, assuming 600862bcd1aSmrg# entries are delimited by the first character of VALUE. For example: 601862bcd1aSmrg# 602862bcd1aSmrg# func_append_uniq options " --another-option option-argument" 603862bcd1aSmrg# 604862bcd1aSmrg# will only append to $options if " --another-option option-argument " 605862bcd1aSmrg# is not already present somewhere in $options already (note spaces at 606862bcd1aSmrg# each end implied by leading space in second argument). 607862bcd1aSmrgfunc_append_uniq () 608862bcd1aSmrg{ 609862bcd1aSmrg $debug_cmd 610862bcd1aSmrg 611862bcd1aSmrg eval _G_current_value='`$ECHO $'$1'`' 612862bcd1aSmrg _G_delim=`expr "$2" : '\(.\)'` 613862bcd1aSmrg 614862bcd1aSmrg case $_G_delim$_G_current_value$_G_delim in 615862bcd1aSmrg *"$2$_G_delim"*) ;; 616862bcd1aSmrg *) func_append "$@" ;; 617862bcd1aSmrg esac 618862bcd1aSmrg} 619862bcd1aSmrg 620862bcd1aSmrg 621862bcd1aSmrg# func_arith TERM... 622862bcd1aSmrg# ------------------ 623862bcd1aSmrg# Set func_arith_result to the result of evaluating TERMs. 624862bcd1aSmrg test -z "$_G_HAVE_ARITH_OP" \ 625862bcd1aSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626862bcd1aSmrg && _G_HAVE_ARITH_OP=yes 627862bcd1aSmrg 628862bcd1aSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 629862bcd1aSmrg eval 'func_arith () 630862bcd1aSmrg { 631862bcd1aSmrg $debug_cmd 632862bcd1aSmrg 633862bcd1aSmrg func_arith_result=$(( $* )) 634862bcd1aSmrg }' 635862bcd1aSmrgelse 636862bcd1aSmrg func_arith () 637862bcd1aSmrg { 638862bcd1aSmrg $debug_cmd 639862bcd1aSmrg 640862bcd1aSmrg func_arith_result=`expr "$@"` 641862bcd1aSmrg } 642862bcd1aSmrgfi 643862bcd1aSmrg 644862bcd1aSmrg 645862bcd1aSmrg# func_basename FILE 646862bcd1aSmrg# ------------------ 647862bcd1aSmrg# Set func_basename_result to FILE with everything up to and including 648862bcd1aSmrg# the last / stripped. 649862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 650862bcd1aSmrg # If this shell supports suffix pattern removal, then use it to avoid 651862bcd1aSmrg # forking. Hide the definitions single quotes in case the shell chokes 652862bcd1aSmrg # on unsupported syntax... 653862bcd1aSmrg _b='func_basename_result=${1##*/}' 654862bcd1aSmrg _d='case $1 in 655862bcd1aSmrg */*) func_dirname_result=${1%/*}$2 ;; 656862bcd1aSmrg * ) func_dirname_result=$3 ;; 657862bcd1aSmrg esac' 658862bcd1aSmrg 659862bcd1aSmrgelse 660862bcd1aSmrg # ...otherwise fall back to using sed. 661862bcd1aSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662862bcd1aSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663862bcd1aSmrg if test "X$func_dirname_result" = "X$1"; then 664862bcd1aSmrg func_dirname_result=$3 665862bcd1aSmrg else 666862bcd1aSmrg func_append func_dirname_result "$2" 667862bcd1aSmrg fi' 668862bcd1aSmrgfi 669862bcd1aSmrg 670862bcd1aSmrgeval 'func_basename () 671862bcd1aSmrg{ 672862bcd1aSmrg $debug_cmd 673862bcd1aSmrg 674862bcd1aSmrg '"$_b"' 675862bcd1aSmrg}' 676862bcd1aSmrg 677862bcd1aSmrg 678862bcd1aSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 679862bcd1aSmrg# ------------------------------------------- 680862bcd1aSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681862bcd1aSmrg# otherwise set result to NONDIR_REPLACEMENT. 682862bcd1aSmrgeval 'func_dirname () 683862bcd1aSmrg{ 684862bcd1aSmrg $debug_cmd 685862bcd1aSmrg 686862bcd1aSmrg '"$_d"' 687862bcd1aSmrg}' 688862bcd1aSmrg 689862bcd1aSmrg 690862bcd1aSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691862bcd1aSmrg# -------------------------------------------------------- 692862bcd1aSmrg# Perform func_basename and func_dirname in a single function 693862bcd1aSmrg# call: 694862bcd1aSmrg# dirname: Compute the dirname of FILE. If nonempty, 695862bcd1aSmrg# add APPEND to the result, otherwise set result 696862bcd1aSmrg# to NONDIR_REPLACEMENT. 697862bcd1aSmrg# value returned in "$func_dirname_result" 698862bcd1aSmrg# basename: Compute filename of FILE. 699862bcd1aSmrg# value retuned in "$func_basename_result" 700862bcd1aSmrg# For efficiency, we do not delegate to the functions above but instead 701862bcd1aSmrg# duplicate the functionality here. 702862bcd1aSmrgeval 'func_dirname_and_basename () 703862bcd1aSmrg{ 704862bcd1aSmrg $debug_cmd 705862bcd1aSmrg 706862bcd1aSmrg '"$_b"' 707862bcd1aSmrg '"$_d"' 708862bcd1aSmrg}' 709862bcd1aSmrg 710862bcd1aSmrg 711862bcd1aSmrg# func_echo ARG... 712862bcd1aSmrg# ---------------- 713862bcd1aSmrg# Echo program name prefixed message. 714862bcd1aSmrgfunc_echo () 715862bcd1aSmrg{ 716862bcd1aSmrg $debug_cmd 717862bcd1aSmrg 718862bcd1aSmrg _G_message=$* 719862bcd1aSmrg 720862bcd1aSmrg func_echo_IFS=$IFS 721862bcd1aSmrg IFS=$nl 722862bcd1aSmrg for _G_line in $_G_message; do 723862bcd1aSmrg IFS=$func_echo_IFS 724862bcd1aSmrg $ECHO "$progname: $_G_line" 725862bcd1aSmrg done 726862bcd1aSmrg IFS=$func_echo_IFS 727862bcd1aSmrg} 728862bcd1aSmrg 729862bcd1aSmrg 730862bcd1aSmrg# func_echo_all ARG... 731862bcd1aSmrg# -------------------- 732862bcd1aSmrg# Invoke $ECHO with all args, space-separated. 733862bcd1aSmrgfunc_echo_all () 734862bcd1aSmrg{ 735862bcd1aSmrg $ECHO "$*" 736862bcd1aSmrg} 737862bcd1aSmrg 738862bcd1aSmrg 739862bcd1aSmrg# func_echo_infix_1 INFIX ARG... 740862bcd1aSmrg# ------------------------------ 741862bcd1aSmrg# Echo program name, followed by INFIX on the first line, with any 742862bcd1aSmrg# additional lines not showing INFIX. 743862bcd1aSmrgfunc_echo_infix_1 () 744862bcd1aSmrg{ 745862bcd1aSmrg $debug_cmd 746862bcd1aSmrg 747862bcd1aSmrg $require_term_colors 748862bcd1aSmrg 749862bcd1aSmrg _G_infix=$1; shift 750862bcd1aSmrg _G_indent=$_G_infix 751862bcd1aSmrg _G_prefix="$progname: $_G_infix: " 752862bcd1aSmrg _G_message=$* 753862bcd1aSmrg 754862bcd1aSmrg # Strip color escape sequences before counting printable length 755862bcd1aSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756862bcd1aSmrg do 757862bcd1aSmrg test -n "$_G_tc" && { 758862bcd1aSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759862bcd1aSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760862bcd1aSmrg } 761862bcd1aSmrg done 762862bcd1aSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763862bcd1aSmrg 764862bcd1aSmrg func_echo_infix_1_IFS=$IFS 765862bcd1aSmrg IFS=$nl 766862bcd1aSmrg for _G_line in $_G_message; do 767862bcd1aSmrg IFS=$func_echo_infix_1_IFS 768862bcd1aSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769862bcd1aSmrg _G_prefix=$_G_indent 770862bcd1aSmrg done 771862bcd1aSmrg IFS=$func_echo_infix_1_IFS 772862bcd1aSmrg} 773862bcd1aSmrg 774862bcd1aSmrg 775862bcd1aSmrg# func_error ARG... 776862bcd1aSmrg# ----------------- 777862bcd1aSmrg# Echo program name prefixed message to standard error. 778862bcd1aSmrgfunc_error () 779862bcd1aSmrg{ 780862bcd1aSmrg $debug_cmd 781862bcd1aSmrg 782862bcd1aSmrg $require_term_colors 783862bcd1aSmrg 784862bcd1aSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785862bcd1aSmrg} 786862bcd1aSmrg 787862bcd1aSmrg 788862bcd1aSmrg# func_fatal_error ARG... 789862bcd1aSmrg# ----------------------- 790862bcd1aSmrg# Echo program name prefixed message to standard error, and exit. 791862bcd1aSmrgfunc_fatal_error () 792862bcd1aSmrg{ 793862bcd1aSmrg $debug_cmd 794862bcd1aSmrg 795862bcd1aSmrg func_error "$*" 796862bcd1aSmrg exit $EXIT_FAILURE 797862bcd1aSmrg} 798862bcd1aSmrg 799862bcd1aSmrg 800862bcd1aSmrg# func_grep EXPRESSION FILENAME 801862bcd1aSmrg# ----------------------------- 80288de56ccSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 80388de56ccSmrgfunc_grep () 80488de56ccSmrg{ 805862bcd1aSmrg $debug_cmd 806862bcd1aSmrg 80788de56ccSmrg $GREP "$1" "$2" >/dev/null 2>&1 80888de56ccSmrg} 80988de56ccSmrg 81088de56ccSmrg 811862bcd1aSmrg# func_len STRING 812862bcd1aSmrg# --------------- 813862bcd1aSmrg# Set func_len_result to the length of STRING. STRING may not 814862bcd1aSmrg# start with a hyphen. 815862bcd1aSmrg test -z "$_G_HAVE_XSI_OPS" \ 816862bcd1aSmrg && (eval 'x=a/b/c; 817862bcd1aSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818862bcd1aSmrg && _G_HAVE_XSI_OPS=yes 819862bcd1aSmrg 820862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 821862bcd1aSmrg eval 'func_len () 822862bcd1aSmrg { 823862bcd1aSmrg $debug_cmd 824862bcd1aSmrg 825862bcd1aSmrg func_len_result=${#1} 826862bcd1aSmrg }' 827862bcd1aSmrgelse 828862bcd1aSmrg func_len () 829862bcd1aSmrg { 830862bcd1aSmrg $debug_cmd 831862bcd1aSmrg 832862bcd1aSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833862bcd1aSmrg } 834862bcd1aSmrgfi 835862bcd1aSmrg 836862bcd1aSmrg 837862bcd1aSmrg# func_mkdir_p DIRECTORY-PATH 838862bcd1aSmrg# --------------------------- 83988de56ccSmrg# Make sure the entire path to DIRECTORY-PATH is available. 84088de56ccSmrgfunc_mkdir_p () 84188de56ccSmrg{ 842862bcd1aSmrg $debug_cmd 843862bcd1aSmrg 844862bcd1aSmrg _G_directory_path=$1 845862bcd1aSmrg _G_dir_list= 84688de56ccSmrg 847862bcd1aSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 84888de56ccSmrg 849862bcd1aSmrg # Protect directory names starting with '-' 850862bcd1aSmrg case $_G_directory_path in 851862bcd1aSmrg -*) _G_directory_path=./$_G_directory_path ;; 85288de56ccSmrg esac 85388de56ccSmrg 85488de56ccSmrg # While some portion of DIR does not yet exist... 855862bcd1aSmrg while test ! -d "$_G_directory_path"; do 85688de56ccSmrg # ...make a list in topmost first order. Use a colon delimited 85788de56ccSmrg # list incase some portion of path contains whitespace. 858862bcd1aSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 85988de56ccSmrg 86088de56ccSmrg # If the last portion added has no slash in it, the list is done 861862bcd1aSmrg case $_G_directory_path in */*) ;; *) break ;; esac 86288de56ccSmrg 86388de56ccSmrg # ...otherwise throw away the child directory and loop 864862bcd1aSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 86588de56ccSmrg done 866862bcd1aSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 86788de56ccSmrg 868862bcd1aSmrg func_mkdir_p_IFS=$IFS; IFS=: 869862bcd1aSmrg for _G_dir in $_G_dir_list; do 870862bcd1aSmrg IFS=$func_mkdir_p_IFS 871862bcd1aSmrg # mkdir can fail with a 'File exist' error if two processes 87288de56ccSmrg # try to create one of the directories concurrently. Don't 87388de56ccSmrg # stop in that case! 874862bcd1aSmrg $MKDIR "$_G_dir" 2>/dev/null || : 87588de56ccSmrg done 876862bcd1aSmrg IFS=$func_mkdir_p_IFS 87788de56ccSmrg 87888de56ccSmrg # Bail out if we (or some other process) failed to create a directory. 879862bcd1aSmrg test -d "$_G_directory_path" || \ 880862bcd1aSmrg func_fatal_error "Failed to create '$1'" 88188de56ccSmrg fi 88288de56ccSmrg} 8831ab64890Smrg 8841ab64890Smrg 885862bcd1aSmrg# func_mktempdir [BASENAME] 886862bcd1aSmrg# ------------------------- 8871ab64890Smrg# Make a temporary directory that won't clash with other running 8881ab64890Smrg# libtool processes, and avoids race conditions if possible. If 889862bcd1aSmrg# given, BASENAME is the basename for that directory. 8901ab64890Smrgfunc_mktempdir () 8911ab64890Smrg{ 892862bcd1aSmrg $debug_cmd 893862bcd1aSmrg 894862bcd1aSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 8951ab64890Smrg 896862bcd1aSmrg if test : = "$opt_dry_run"; then 8971ab64890Smrg # Return a directory name, but don't create it in dry-run mode 898862bcd1aSmrg _G_tmpdir=$_G_template-$$ 8991ab64890Smrg else 9001ab64890Smrg 9011ab64890Smrg # If mktemp works, use that first and foremost 902862bcd1aSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 9031ab64890Smrg 904862bcd1aSmrg if test ! -d "$_G_tmpdir"; then 90588de56ccSmrg # Failing that, at least try and use $RANDOM to avoid a race 906862bcd1aSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 9071ab64890Smrg 908862bcd1aSmrg func_mktempdir_umask=`umask` 90988de56ccSmrg umask 0077 910862bcd1aSmrg $MKDIR "$_G_tmpdir" 911862bcd1aSmrg umask $func_mktempdir_umask 9121ab64890Smrg fi 9131ab64890Smrg 9141ab64890Smrg # If we're not in dry-run mode, bomb out on failure 915862bcd1aSmrg test -d "$_G_tmpdir" || \ 916862bcd1aSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 9171ab64890Smrg fi 9181ab64890Smrg 919862bcd1aSmrg $ECHO "$_G_tmpdir" 9201ab64890Smrg} 9211ab64890Smrg 9221ab64890Smrg 923862bcd1aSmrg# func_normal_abspath PATH 924862bcd1aSmrg# ------------------------ 925862bcd1aSmrg# Remove doubled-up and trailing slashes, "." path components, 926862bcd1aSmrg# and cancel out any ".." path components in PATH after making 927862bcd1aSmrg# it an absolute path. 928862bcd1aSmrgfunc_normal_abspath () 9291ab64890Smrg{ 930862bcd1aSmrg $debug_cmd 93188de56ccSmrg 932862bcd1aSmrg # These SED scripts presuppose an absolute path with a trailing slash. 933862bcd1aSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 934862bcd1aSmrg _G_pathcdr='s|^/[^/]*||' 935862bcd1aSmrg _G_removedotparts=':dotsl 936862bcd1aSmrg s|/\./|/|g 937862bcd1aSmrg t dotsl 938862bcd1aSmrg s|/\.$|/|' 939862bcd1aSmrg _G_collapseslashes='s|/\{1,\}|/|g' 940862bcd1aSmrg _G_finalslash='s|/*$|/|' 941862bcd1aSmrg 942862bcd1aSmrg # Start from root dir and reassemble the path. 943862bcd1aSmrg func_normal_abspath_result= 944862bcd1aSmrg func_normal_abspath_tpath=$1 945862bcd1aSmrg func_normal_abspath_altnamespace= 946862bcd1aSmrg case $func_normal_abspath_tpath in 947862bcd1aSmrg "") 948862bcd1aSmrg # Empty path, that just means $cwd. 949862bcd1aSmrg func_stripname '' '/' "`pwd`" 950862bcd1aSmrg func_normal_abspath_result=$func_stripname_result 951862bcd1aSmrg return 952862bcd1aSmrg ;; 953862bcd1aSmrg # The next three entries are used to spot a run of precisely 954862bcd1aSmrg # two leading slashes without using negated character classes; 955862bcd1aSmrg # we take advantage of case's first-match behaviour. 956862bcd1aSmrg ///*) 957862bcd1aSmrg # Unusual form of absolute path, do nothing. 958862bcd1aSmrg ;; 959862bcd1aSmrg //*) 960862bcd1aSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 961862bcd1aSmrg # and for example Cygwin uses it to access remote file shares 962862bcd1aSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 963862bcd1aSmrg func_normal_abspath_altnamespace=/ 964862bcd1aSmrg ;; 965862bcd1aSmrg /*) 966862bcd1aSmrg # Absolute path, do nothing. 96788de56ccSmrg ;; 96888de56ccSmrg *) 969862bcd1aSmrg # Relative path, prepend $cwd. 970862bcd1aSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971862bcd1aSmrg ;; 9721ab64890Smrg esac 973862bcd1aSmrg 974862bcd1aSmrg # Cancel out all the simple stuff to save iterations. We also want 975862bcd1aSmrg # the path to end with a slash for ease of parsing, so make sure 976862bcd1aSmrg # there is one (and only one) here. 977862bcd1aSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978862bcd1aSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979862bcd1aSmrg while :; do 980862bcd1aSmrg # Processed it all yet? 981862bcd1aSmrg if test / = "$func_normal_abspath_tpath"; then 982862bcd1aSmrg # If we ascended to the root using ".." the result may be empty now. 983862bcd1aSmrg if test -z "$func_normal_abspath_result"; then 984862bcd1aSmrg func_normal_abspath_result=/ 985862bcd1aSmrg fi 986862bcd1aSmrg break 987862bcd1aSmrg fi 988862bcd1aSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989862bcd1aSmrg -e "$_G_pathcar"` 990862bcd1aSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991862bcd1aSmrg -e "$_G_pathcdr"` 992862bcd1aSmrg # Figure out what to do with it 993862bcd1aSmrg case $func_normal_abspath_tcomponent in 994862bcd1aSmrg "") 995862bcd1aSmrg # Trailing empty path component, ignore it. 996862bcd1aSmrg ;; 997862bcd1aSmrg ..) 998862bcd1aSmrg # Parent dir; strip last assembled component from result. 999862bcd1aSmrg func_dirname "$func_normal_abspath_result" 1000862bcd1aSmrg func_normal_abspath_result=$func_dirname_result 1001862bcd1aSmrg ;; 1002862bcd1aSmrg *) 1003862bcd1aSmrg # Actual path component, append it. 1004862bcd1aSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005862bcd1aSmrg ;; 1006862bcd1aSmrg esac 1007862bcd1aSmrg done 1008862bcd1aSmrg # Restore leading double-slash if one was found on entry. 1009862bcd1aSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010862bcd1aSmrg} 1011862bcd1aSmrg 1012862bcd1aSmrg 1013862bcd1aSmrg# func_notquiet ARG... 1014862bcd1aSmrg# -------------------- 1015862bcd1aSmrg# Echo program name prefixed message only when not in quiet mode. 1016862bcd1aSmrgfunc_notquiet () 1017862bcd1aSmrg{ 1018862bcd1aSmrg $debug_cmd 1019862bcd1aSmrg 1020862bcd1aSmrg $opt_quiet || func_echo ${1+"$@"} 1021862bcd1aSmrg 1022862bcd1aSmrg # A bug in bash halts the script if the last line of a function 1023862bcd1aSmrg # fails when set -e is in force, so we need another command to 1024862bcd1aSmrg # work around that: 1025862bcd1aSmrg : 1026862bcd1aSmrg} 1027862bcd1aSmrg 1028862bcd1aSmrg 1029862bcd1aSmrg# func_relative_path SRCDIR DSTDIR 1030862bcd1aSmrg# -------------------------------- 1031862bcd1aSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032862bcd1aSmrgfunc_relative_path () 1033862bcd1aSmrg{ 1034862bcd1aSmrg $debug_cmd 1035862bcd1aSmrg 1036862bcd1aSmrg func_relative_path_result= 1037862bcd1aSmrg func_normal_abspath "$1" 1038862bcd1aSmrg func_relative_path_tlibdir=$func_normal_abspath_result 1039862bcd1aSmrg func_normal_abspath "$2" 1040862bcd1aSmrg func_relative_path_tbindir=$func_normal_abspath_result 1041862bcd1aSmrg 1042862bcd1aSmrg # Ascend the tree starting from libdir 1043862bcd1aSmrg while :; do 1044862bcd1aSmrg # check if we have found a prefix of bindir 1045862bcd1aSmrg case $func_relative_path_tbindir in 1046862bcd1aSmrg $func_relative_path_tlibdir) 1047862bcd1aSmrg # found an exact match 1048862bcd1aSmrg func_relative_path_tcancelled= 1049862bcd1aSmrg break 1050862bcd1aSmrg ;; 1051862bcd1aSmrg $func_relative_path_tlibdir*) 1052862bcd1aSmrg # found a matching prefix 1053862bcd1aSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054862bcd1aSmrg func_relative_path_tcancelled=$func_stripname_result 1055862bcd1aSmrg if test -z "$func_relative_path_result"; then 1056862bcd1aSmrg func_relative_path_result=. 1057862bcd1aSmrg fi 1058862bcd1aSmrg break 1059862bcd1aSmrg ;; 1060862bcd1aSmrg *) 1061862bcd1aSmrg func_dirname $func_relative_path_tlibdir 1062862bcd1aSmrg func_relative_path_tlibdir=$func_dirname_result 1063862bcd1aSmrg if test -z "$func_relative_path_tlibdir"; then 1064862bcd1aSmrg # Have to descend all the way to the root! 1065862bcd1aSmrg func_relative_path_result=../$func_relative_path_result 1066862bcd1aSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 1067862bcd1aSmrg break 1068862bcd1aSmrg fi 1069862bcd1aSmrg func_relative_path_result=../$func_relative_path_result 1070862bcd1aSmrg ;; 1071862bcd1aSmrg esac 1072862bcd1aSmrg done 1073862bcd1aSmrg 1074862bcd1aSmrg # Now calculate path; take care to avoid doubling-up slashes. 1075862bcd1aSmrg func_stripname '' '/' "$func_relative_path_result" 1076862bcd1aSmrg func_relative_path_result=$func_stripname_result 1077862bcd1aSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1078862bcd1aSmrg if test -n "$func_stripname_result"; then 1079862bcd1aSmrg func_append func_relative_path_result "/$func_stripname_result" 1080862bcd1aSmrg fi 1081862bcd1aSmrg 1082862bcd1aSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 1083862bcd1aSmrg if test -n "$func_relative_path_result"; then 1084862bcd1aSmrg func_stripname './' '' "$func_relative_path_result" 1085862bcd1aSmrg func_relative_path_result=$func_stripname_result 1086862bcd1aSmrg fi 1087862bcd1aSmrg 1088862bcd1aSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 1089862bcd1aSmrg 1090862bcd1aSmrg : 10911ab64890Smrg} 10921ab64890Smrg 10931ab64890Smrg 1094862bcd1aSmrg# func_quote_for_eval ARG... 1095862bcd1aSmrg# -------------------------- 1096862bcd1aSmrg# Aesthetically quote ARGs to be evaled later. 1097862bcd1aSmrg# This function returns two values: 1098862bcd1aSmrg# i) func_quote_for_eval_result 1099862bcd1aSmrg# double-quoted, suitable for a subsequent eval 1100862bcd1aSmrg# ii) func_quote_for_eval_unquoted_result 1101862bcd1aSmrg# has all characters that are still active within double 1102862bcd1aSmrg# quotes backslashified. 1103862bcd1aSmrgfunc_quote_for_eval () 1104862bcd1aSmrg{ 1105862bcd1aSmrg $debug_cmd 1106862bcd1aSmrg 1107862bcd1aSmrg func_quote_for_eval_unquoted_result= 1108862bcd1aSmrg func_quote_for_eval_result= 1109862bcd1aSmrg while test 0 -lt $#; do 11105afda2e6Smrg case $1 in 11115afda2e6Smrg *[\\\`\"\$]*) 11125afda2e6Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 11135afda2e6Smrg *) 11145afda2e6Smrg _G_unquoted_arg=$1 ;; 11155afda2e6Smrg esac 1116862bcd1aSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 1117862bcd1aSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118862bcd1aSmrg else 1119862bcd1aSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120862bcd1aSmrg fi 1121862bcd1aSmrg 1122862bcd1aSmrg case $_G_unquoted_arg in 1123862bcd1aSmrg # Double-quote args containing shell metacharacters to delay 1124862bcd1aSmrg # word splitting, command substitution and variable expansion 1125862bcd1aSmrg # for a subsequent eval. 1126862bcd1aSmrg # Many Bourne shells cannot handle close brackets correctly 1127862bcd1aSmrg # in scan sets, so we specify it separately. 1128862bcd1aSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129862bcd1aSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 1130862bcd1aSmrg ;; 1131862bcd1aSmrg *) 1132862bcd1aSmrg _G_quoted_arg=$_G_unquoted_arg 1133862bcd1aSmrg ;; 1134862bcd1aSmrg esac 1135862bcd1aSmrg 1136862bcd1aSmrg if test -n "$func_quote_for_eval_result"; then 1137862bcd1aSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 1138862bcd1aSmrg else 1139862bcd1aSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 1140862bcd1aSmrg fi 1141862bcd1aSmrg shift 1142862bcd1aSmrg done 1143862bcd1aSmrg} 1144862bcd1aSmrg 1145862bcd1aSmrg 1146862bcd1aSmrg# func_quote_for_expand ARG 1147862bcd1aSmrg# ------------------------- 114888de56ccSmrg# Aesthetically quote ARG to be evaled later; same as above, 114988de56ccSmrg# but do not quote variable references. 115088de56ccSmrgfunc_quote_for_expand () 11511ab64890Smrg{ 1152862bcd1aSmrg $debug_cmd 1153862bcd1aSmrg 115488de56ccSmrg case $1 in 115588de56ccSmrg *[\\\`\"]*) 1156862bcd1aSmrg _G_arg=`$ECHO "$1" | $SED \ 1157862bcd1aSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 11581ab64890Smrg *) 1159862bcd1aSmrg _G_arg=$1 ;; 116088de56ccSmrg esac 116188de56ccSmrg 1162862bcd1aSmrg case $_G_arg in 116388de56ccSmrg # Double-quote args containing shell metacharacters to delay 116488de56ccSmrg # word splitting and command substitution for a subsequent eval. 116588de56ccSmrg # Many Bourne shells cannot handle close brackets correctly 116688de56ccSmrg # in scan sets, so we specify it separately. 116788de56ccSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168862bcd1aSmrg _G_arg=\"$_G_arg\" 116988de56ccSmrg ;; 117088de56ccSmrg esac 117188de56ccSmrg 1172862bcd1aSmrg func_quote_for_expand_result=$_G_arg 1173862bcd1aSmrg} 1174862bcd1aSmrg 1175862bcd1aSmrg 1176862bcd1aSmrg# func_stripname PREFIX SUFFIX NAME 1177862bcd1aSmrg# --------------------------------- 1178862bcd1aSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179862bcd1aSmrg# PREFIX and SUFFIX must not contain globbing or regex special 1180862bcd1aSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1181862bcd1aSmrg# dot (in which case that matches only a dot). 1182862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 1183862bcd1aSmrg eval 'func_stripname () 1184862bcd1aSmrg { 1185862bcd1aSmrg $debug_cmd 1186862bcd1aSmrg 1187862bcd1aSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188862bcd1aSmrg # positional parameters, so assign one to ordinary variable first. 1189862bcd1aSmrg func_stripname_result=$3 1190862bcd1aSmrg func_stripname_result=${func_stripname_result#"$1"} 1191862bcd1aSmrg func_stripname_result=${func_stripname_result%"$2"} 1192862bcd1aSmrg }' 1193862bcd1aSmrgelse 1194862bcd1aSmrg func_stripname () 1195862bcd1aSmrg { 1196862bcd1aSmrg $debug_cmd 1197862bcd1aSmrg 1198862bcd1aSmrg case $2 in 1199862bcd1aSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200862bcd1aSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201862bcd1aSmrg esac 1202862bcd1aSmrg } 1203862bcd1aSmrgfi 1204862bcd1aSmrg 1205862bcd1aSmrg 1206862bcd1aSmrg# func_show_eval CMD [FAIL_EXP] 1207862bcd1aSmrg# ----------------------------- 1208862bcd1aSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209862bcd1aSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210862bcd1aSmrg# is given, then evaluate it. 1211862bcd1aSmrgfunc_show_eval () 1212862bcd1aSmrg{ 1213862bcd1aSmrg $debug_cmd 1214862bcd1aSmrg 1215862bcd1aSmrg _G_cmd=$1 1216862bcd1aSmrg _G_fail_exp=${2-':'} 1217862bcd1aSmrg 1218862bcd1aSmrg func_quote_for_expand "$_G_cmd" 1219862bcd1aSmrg eval "func_notquiet $func_quote_for_expand_result" 1220862bcd1aSmrg 1221862bcd1aSmrg $opt_dry_run || { 1222862bcd1aSmrg eval "$_G_cmd" 1223862bcd1aSmrg _G_status=$? 1224862bcd1aSmrg if test 0 -ne "$_G_status"; then 1225862bcd1aSmrg eval "(exit $_G_status); $_G_fail_exp" 1226862bcd1aSmrg fi 1227862bcd1aSmrg } 1228862bcd1aSmrg} 1229862bcd1aSmrg 1230862bcd1aSmrg 1231862bcd1aSmrg# func_show_eval_locale CMD [FAIL_EXP] 1232862bcd1aSmrg# ------------------------------------ 1233862bcd1aSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234862bcd1aSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235862bcd1aSmrg# is given, then evaluate it. Use the saved locale for evaluation. 1236862bcd1aSmrgfunc_show_eval_locale () 1237862bcd1aSmrg{ 1238862bcd1aSmrg $debug_cmd 1239862bcd1aSmrg 1240862bcd1aSmrg _G_cmd=$1 1241862bcd1aSmrg _G_fail_exp=${2-':'} 1242862bcd1aSmrg 1243862bcd1aSmrg $opt_quiet || { 1244862bcd1aSmrg func_quote_for_expand "$_G_cmd" 1245862bcd1aSmrg eval "func_echo $func_quote_for_expand_result" 1246862bcd1aSmrg } 1247862bcd1aSmrg 1248862bcd1aSmrg $opt_dry_run || { 1249862bcd1aSmrg eval "$_G_user_locale 1250862bcd1aSmrg $_G_cmd" 1251862bcd1aSmrg _G_status=$? 1252862bcd1aSmrg eval "$_G_safe_locale" 1253862bcd1aSmrg if test 0 -ne "$_G_status"; then 1254862bcd1aSmrg eval "(exit $_G_status); $_G_fail_exp" 1255862bcd1aSmrg fi 1256862bcd1aSmrg } 1257862bcd1aSmrg} 1258862bcd1aSmrg 1259862bcd1aSmrg 1260862bcd1aSmrg# func_tr_sh 1261862bcd1aSmrg# ---------- 1262862bcd1aSmrg# Turn $1 into a string suitable for a shell variable name. 1263862bcd1aSmrg# Result is stored in $func_tr_sh_result. All characters 1264862bcd1aSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265862bcd1aSmrg# if $1 begins with a digit, a '_' is prepended as well. 1266862bcd1aSmrgfunc_tr_sh () 1267862bcd1aSmrg{ 1268862bcd1aSmrg $debug_cmd 1269862bcd1aSmrg 1270862bcd1aSmrg case $1 in 1271862bcd1aSmrg [0-9]* | *[!a-zA-Z0-9_]*) 1272862bcd1aSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273862bcd1aSmrg ;; 1274862bcd1aSmrg * ) 1275862bcd1aSmrg func_tr_sh_result=$1 1276862bcd1aSmrg ;; 1277862bcd1aSmrg esac 1278862bcd1aSmrg} 1279862bcd1aSmrg 1280862bcd1aSmrg 1281862bcd1aSmrg# func_verbose ARG... 1282862bcd1aSmrg# ------------------- 1283862bcd1aSmrg# Echo program name prefixed message in verbose mode only. 1284862bcd1aSmrgfunc_verbose () 1285862bcd1aSmrg{ 1286862bcd1aSmrg $debug_cmd 1287862bcd1aSmrg 1288862bcd1aSmrg $opt_verbose && func_echo "$*" 1289862bcd1aSmrg 1290862bcd1aSmrg : 1291862bcd1aSmrg} 1292862bcd1aSmrg 1293862bcd1aSmrg 1294862bcd1aSmrg# func_warn_and_continue ARG... 1295862bcd1aSmrg# ----------------------------- 1296862bcd1aSmrg# Echo program name prefixed warning message to standard error. 1297862bcd1aSmrgfunc_warn_and_continue () 1298862bcd1aSmrg{ 1299862bcd1aSmrg $debug_cmd 1300862bcd1aSmrg 1301862bcd1aSmrg $require_term_colors 1302862bcd1aSmrg 1303862bcd1aSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304862bcd1aSmrg} 1305862bcd1aSmrg 1306862bcd1aSmrg 1307862bcd1aSmrg# func_warning CATEGORY ARG... 1308862bcd1aSmrg# ---------------------------- 1309862bcd1aSmrg# Echo program name prefixed warning message to standard error. Warning 1310862bcd1aSmrg# messages can be filtered according to CATEGORY, where this function 1311862bcd1aSmrg# elides messages where CATEGORY is not listed in the global variable 1312862bcd1aSmrg# 'opt_warning_types'. 1313862bcd1aSmrgfunc_warning () 1314862bcd1aSmrg{ 1315862bcd1aSmrg $debug_cmd 1316862bcd1aSmrg 1317862bcd1aSmrg # CATEGORY must be in the warning_categories list! 1318862bcd1aSmrg case " $warning_categories " in 1319862bcd1aSmrg *" $1 "*) ;; 1320862bcd1aSmrg *) func_internal_error "invalid warning category '$1'" ;; 1321862bcd1aSmrg esac 1322862bcd1aSmrg 1323862bcd1aSmrg _G_category=$1 1324862bcd1aSmrg shift 1325862bcd1aSmrg 1326862bcd1aSmrg case " $opt_warning_types " in 1327862bcd1aSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328862bcd1aSmrg esac 13291ab64890Smrg} 13301ab64890Smrg 13311ab64890Smrg 1332862bcd1aSmrg# func_sort_ver VER1 VER2 1333862bcd1aSmrg# ----------------------- 1334862bcd1aSmrg# 'sort -V' is not generally available. 1335862bcd1aSmrg# Note this deviates from the version comparison in automake 1336862bcd1aSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337862bcd1aSmrg# but this should suffice as we won't be specifying old 1338862bcd1aSmrg# version formats or redundant trailing .0 in bootstrap.conf. 1339862bcd1aSmrg# If we did want full compatibility then we should probably 1340862bcd1aSmrg# use m4_version_compare from autoconf. 1341862bcd1aSmrgfunc_sort_ver () 1342862bcd1aSmrg{ 1343862bcd1aSmrg $debug_cmd 1344862bcd1aSmrg 1345862bcd1aSmrg printf '%s\n%s\n' "$1" "$2" \ 1346862bcd1aSmrg | 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 1347862bcd1aSmrg} 1348862bcd1aSmrg 1349862bcd1aSmrg# func_lt_ver PREV CURR 1350862bcd1aSmrg# --------------------- 1351862bcd1aSmrg# Return true if PREV and CURR are in the correct order according to 1352862bcd1aSmrg# func_sort_ver, otherwise false. Use it like this: 1353862bcd1aSmrg# 1354862bcd1aSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355862bcd1aSmrgfunc_lt_ver () 1356862bcd1aSmrg{ 1357862bcd1aSmrg $debug_cmd 1358862bcd1aSmrg 1359862bcd1aSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360862bcd1aSmrg} 1361862bcd1aSmrg 1362862bcd1aSmrg 1363862bcd1aSmrg# Local variables: 1364862bcd1aSmrg# mode: shell-script 1365862bcd1aSmrg# sh-indentation: 2 1366862bcd1aSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1367862bcd1aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368862bcd1aSmrg# time-stamp-time-zone: "UTC" 1369862bcd1aSmrg# End: 1370862bcd1aSmrg#! /bin/sh 1371862bcd1aSmrg 1372862bcd1aSmrg# Set a version string for this script. 137303ea5dc6Smrgscriptversion=2014-01-07.03; # UTC 1374862bcd1aSmrg 1375862bcd1aSmrg# A portable, pluggable option parser for Bourne shell. 1376862bcd1aSmrg# Written by Gary V. Vaughan, 2010 1377862bcd1aSmrg 1378862bcd1aSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379862bcd1aSmrg# This is free software; see the source for copying conditions. There is NO 1380862bcd1aSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381862bcd1aSmrg 1382862bcd1aSmrg# This program is free software: you can redistribute it and/or modify 1383862bcd1aSmrg# it under the terms of the GNU General Public License as published by 1384862bcd1aSmrg# the Free Software Foundation, either version 3 of the License, or 1385862bcd1aSmrg# (at your option) any later version. 1386862bcd1aSmrg 1387862bcd1aSmrg# This program is distributed in the hope that it will be useful, 1388862bcd1aSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389862bcd1aSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390862bcd1aSmrg# GNU General Public License for more details. 1391862bcd1aSmrg 1392862bcd1aSmrg# You should have received a copy of the GNU General Public License 1393862bcd1aSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394862bcd1aSmrg 1395862bcd1aSmrg# Please report bugs or propose patches to gary@gnu.org. 1396862bcd1aSmrg 1397862bcd1aSmrg 1398862bcd1aSmrg## ------ ## 1399862bcd1aSmrg## Usage. ## 1400862bcd1aSmrg## ------ ## 1401862bcd1aSmrg 1402862bcd1aSmrg# This file is a library for parsing options in your shell scripts along 1403862bcd1aSmrg# with assorted other useful supporting features that you can make use 1404862bcd1aSmrg# of too. 1405862bcd1aSmrg# 1406862bcd1aSmrg# For the simplest scripts you might need only: 1407862bcd1aSmrg# 1408862bcd1aSmrg# #!/bin/sh 1409862bcd1aSmrg# . relative/path/to/funclib.sh 1410862bcd1aSmrg# . relative/path/to/options-parser 1411862bcd1aSmrg# scriptversion=1.0 1412862bcd1aSmrg# func_options ${1+"$@"} 1413862bcd1aSmrg# eval set dummy "$func_options_result"; shift 1414862bcd1aSmrg# ...rest of your script... 1415862bcd1aSmrg# 1416862bcd1aSmrg# In order for the '--version' option to work, you will need to have a 1417862bcd1aSmrg# suitably formatted comment like the one at the top of this file 1418862bcd1aSmrg# starting with '# Written by ' and ending with '# warranty; '. 1419862bcd1aSmrg# 1420862bcd1aSmrg# For '-h' and '--help' to work, you will also need a one line 1421862bcd1aSmrg# description of your script's purpose in a comment directly above the 1422862bcd1aSmrg# '# Written by ' line, like the one at the top of this file. 1423862bcd1aSmrg# 1424862bcd1aSmrg# The default options also support '--debug', which will turn on shell 1425862bcd1aSmrg# execution tracing (see the comment above debug_cmd below for another 1426862bcd1aSmrg# use), and '--verbose' and the func_verbose function to allow your script 1427862bcd1aSmrg# to display verbose messages only when your user has specified 1428862bcd1aSmrg# '--verbose'. 1429862bcd1aSmrg# 1430862bcd1aSmrg# After sourcing this file, you can plug processing for additional 1431862bcd1aSmrg# options by amending the variables from the 'Configuration' section 1432862bcd1aSmrg# below, and following the instructions in the 'Option parsing' 1433862bcd1aSmrg# section further down. 1434862bcd1aSmrg 1435862bcd1aSmrg## -------------- ## 1436862bcd1aSmrg## Configuration. ## 1437862bcd1aSmrg## -------------- ## 1438862bcd1aSmrg 1439862bcd1aSmrg# You should override these variables in your script after sourcing this 1440862bcd1aSmrg# file so that they reflect the customisations you have added to the 1441862bcd1aSmrg# option parser. 1442862bcd1aSmrg 1443862bcd1aSmrg# The usage line for option parsing errors and the start of '-h' and 1444862bcd1aSmrg# '--help' output messages. You can embed shell variables for delayed 1445862bcd1aSmrg# expansion at the time the message is displayed, but you will need to 1446862bcd1aSmrg# quote other shell meta-characters carefully to prevent them being 1447862bcd1aSmrg# expanded when the contents are evaled. 1448862bcd1aSmrgusage='$progpath [OPTION]...' 1449862bcd1aSmrg 1450862bcd1aSmrg# Short help message in response to '-h' and '--help'. Add to this or 1451862bcd1aSmrg# override it after sourcing this library to reflect the full set of 1452862bcd1aSmrg# options your script accepts. 1453862bcd1aSmrgusage_message="\ 1454862bcd1aSmrg --debug enable verbose shell tracing 1455862bcd1aSmrg -W, --warnings=CATEGORY 1456862bcd1aSmrg report the warnings falling in CATEGORY [all] 1457862bcd1aSmrg -v, --verbose verbosely report processing 1458862bcd1aSmrg --version print version information and exit 1459862bcd1aSmrg -h, --help print short or long help message and exit 1460862bcd1aSmrg" 1461862bcd1aSmrg 1462862bcd1aSmrg# Additional text appended to 'usage_message' in response to '--help'. 1463862bcd1aSmrglong_help_message=" 1464862bcd1aSmrgWarning categories include: 1465862bcd1aSmrg 'all' show all warnings 1466862bcd1aSmrg 'none' turn off all the warnings 1467862bcd1aSmrg 'error' warnings are treated as fatal errors" 1468862bcd1aSmrg 1469862bcd1aSmrg# Help message printed before fatal option parsing errors. 1470862bcd1aSmrgfatal_help="Try '\$progname --help' for more information." 1471862bcd1aSmrg 1472862bcd1aSmrg 1473862bcd1aSmrg 1474862bcd1aSmrg## ------------------------- ## 1475862bcd1aSmrg## Hook function management. ## 1476862bcd1aSmrg## ------------------------- ## 1477862bcd1aSmrg 1478862bcd1aSmrg# This section contains functions for adding, removing, and running hooks 1479862bcd1aSmrg# to the main code. A hook is just a named list of of function, that can 1480862bcd1aSmrg# be run in order later on. 1481862bcd1aSmrg 1482862bcd1aSmrg# func_hookable FUNC_NAME 1483862bcd1aSmrg# ----------------------- 1484862bcd1aSmrg# Declare that FUNC_NAME will run hooks added with 1485862bcd1aSmrg# 'func_add_hook FUNC_NAME ...'. 1486862bcd1aSmrgfunc_hookable () 1487862bcd1aSmrg{ 1488862bcd1aSmrg $debug_cmd 1489862bcd1aSmrg 1490862bcd1aSmrg func_append hookable_fns " $1" 1491862bcd1aSmrg} 1492862bcd1aSmrg 1493862bcd1aSmrg 1494862bcd1aSmrg# func_add_hook FUNC_NAME HOOK_FUNC 1495862bcd1aSmrg# --------------------------------- 1496862bcd1aSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497862bcd1aSmrg# first have been declared "hookable" by a call to 'func_hookable'. 1498862bcd1aSmrgfunc_add_hook () 1499862bcd1aSmrg{ 1500862bcd1aSmrg $debug_cmd 1501862bcd1aSmrg 1502862bcd1aSmrg case " $hookable_fns " in 1503862bcd1aSmrg *" $1 "*) ;; 1504862bcd1aSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1505862bcd1aSmrg esac 1506862bcd1aSmrg 1507862bcd1aSmrg eval func_append ${1}_hooks '" $2"' 1508862bcd1aSmrg} 1509862bcd1aSmrg 1510862bcd1aSmrg 1511862bcd1aSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 1512862bcd1aSmrg# ------------------------------------ 1513862bcd1aSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514862bcd1aSmrgfunc_remove_hook () 1515862bcd1aSmrg{ 1516862bcd1aSmrg $debug_cmd 1517862bcd1aSmrg 1518862bcd1aSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519862bcd1aSmrg} 1520862bcd1aSmrg 1521862bcd1aSmrg 1522862bcd1aSmrg# func_run_hooks FUNC_NAME [ARG]... 1523862bcd1aSmrg# --------------------------------- 1524862bcd1aSmrg# Run all hook functions registered to FUNC_NAME. 1525862bcd1aSmrg# It is assumed that the list of hook functions contains nothing more 1526862bcd1aSmrg# than a whitespace-delimited list of legal shell function names, and 1527862bcd1aSmrg# no effort is wasted trying to catch shell meta-characters or preserve 1528862bcd1aSmrg# whitespace. 1529862bcd1aSmrgfunc_run_hooks () 1530862bcd1aSmrg{ 1531862bcd1aSmrg $debug_cmd 1532862bcd1aSmrg 1533862bcd1aSmrg case " $hookable_fns " in 1534862bcd1aSmrg *" $1 "*) ;; 1535862bcd1aSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536862bcd1aSmrg esac 1537862bcd1aSmrg 1538862bcd1aSmrg eval _G_hook_fns=\$$1_hooks; shift 1539862bcd1aSmrg 1540862bcd1aSmrg for _G_hook in $_G_hook_fns; do 154103ea5dc6Smrg eval $_G_hook '"$@"' 154203ea5dc6Smrg 154303ea5dc6Smrg # store returned options list back into positional 154403ea5dc6Smrg # parameters for next 'cmd' execution. 154503ea5dc6Smrg eval _G_hook_result=\$${_G_hook}_result 154603ea5dc6Smrg eval set dummy "$_G_hook_result"; shift 1547862bcd1aSmrg done 1548862bcd1aSmrg 154903ea5dc6Smrg func_quote_for_eval ${1+"$@"} 155003ea5dc6Smrg func_run_hooks_result=$func_quote_for_eval_result 1551862bcd1aSmrg} 1552862bcd1aSmrg 1553862bcd1aSmrg 1554862bcd1aSmrg 1555862bcd1aSmrg## --------------- ## 1556862bcd1aSmrg## Option parsing. ## 1557862bcd1aSmrg## --------------- ## 1558862bcd1aSmrg 1559862bcd1aSmrg# In order to add your own option parsing hooks, you must accept the 156003ea5dc6Smrg# full positional parameter list in your hook function, remove any 156103ea5dc6Smrg# options that you action, and then pass back the remaining unprocessed 1562862bcd1aSmrg# options in '<hooked_function_name>_result', escaped suitably for 156303ea5dc6Smrg# 'eval'. Like this: 1564862bcd1aSmrg# 1565862bcd1aSmrg# my_options_prep () 1566862bcd1aSmrg# { 1567862bcd1aSmrg# $debug_cmd 1568862bcd1aSmrg# 1569862bcd1aSmrg# # Extend the existing usage message. 1570862bcd1aSmrg# usage_message=$usage_message' 1571862bcd1aSmrg# -s, --silent don'\''t print informational messages 1572862bcd1aSmrg# ' 157303ea5dc6Smrg# 157403ea5dc6Smrg# func_quote_for_eval ${1+"$@"} 157503ea5dc6Smrg# my_options_prep_result=$func_quote_for_eval_result 1576862bcd1aSmrg# } 1577862bcd1aSmrg# func_add_hook func_options_prep my_options_prep 1578862bcd1aSmrg# 1579862bcd1aSmrg# 1580862bcd1aSmrg# my_silent_option () 1581862bcd1aSmrg# { 1582862bcd1aSmrg# $debug_cmd 1583862bcd1aSmrg# 1584862bcd1aSmrg# # Note that for efficiency, we parse as many options as we can 1585862bcd1aSmrg# # recognise in a loop before passing the remainder back to the 1586862bcd1aSmrg# # caller on the first unrecognised argument we encounter. 1587862bcd1aSmrg# while test $# -gt 0; do 1588862bcd1aSmrg# opt=$1; shift 1589862bcd1aSmrg# case $opt in 159003ea5dc6Smrg# --silent|-s) opt_silent=: ;; 1591862bcd1aSmrg# # Separate non-argument short options: 1592862bcd1aSmrg# -s*) func_split_short_opt "$_G_opt" 1593862bcd1aSmrg# set dummy "$func_split_short_opt_name" \ 1594862bcd1aSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 1595862bcd1aSmrg# shift 1596862bcd1aSmrg# ;; 159703ea5dc6Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598862bcd1aSmrg# esac 1599862bcd1aSmrg# done 1600862bcd1aSmrg# 160103ea5dc6Smrg# func_quote_for_eval ${1+"$@"} 160203ea5dc6Smrg# my_silent_option_result=$func_quote_for_eval_result 1603862bcd1aSmrg# } 1604862bcd1aSmrg# func_add_hook func_parse_options my_silent_option 1605862bcd1aSmrg# 1606862bcd1aSmrg# 1607862bcd1aSmrg# my_option_validation () 1608862bcd1aSmrg# { 1609862bcd1aSmrg# $debug_cmd 1610862bcd1aSmrg# 1611862bcd1aSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1612862bcd1aSmrg# '--silent' and '--verbose' options are mutually exclusive." 1613862bcd1aSmrg# 161403ea5dc6Smrg# func_quote_for_eval ${1+"$@"} 161503ea5dc6Smrg# my_option_validation_result=$func_quote_for_eval_result 1616862bcd1aSmrg# } 1617862bcd1aSmrg# func_add_hook func_validate_options my_option_validation 1618862bcd1aSmrg# 161903ea5dc6Smrg# You'll alse need to manually amend $usage_message to reflect the extra 1620862bcd1aSmrg# options you parse. It's preferable to append if you can, so that 1621862bcd1aSmrg# multiple option parsing hooks can be added safely. 1622862bcd1aSmrg 1623862bcd1aSmrg 1624862bcd1aSmrg# func_options [ARG]... 1625862bcd1aSmrg# --------------------- 1626862bcd1aSmrg# All the functions called inside func_options are hookable. See the 1627862bcd1aSmrg# individual implementations for details. 1628862bcd1aSmrgfunc_hookable func_options 1629862bcd1aSmrgfunc_options () 16301ab64890Smrg{ 1631862bcd1aSmrg $debug_cmd 16322e9c7c8cSmrg 163303ea5dc6Smrg func_options_prep ${1+"$@"} 163403ea5dc6Smrg eval func_parse_options \ 163503ea5dc6Smrg ${func_options_prep_result+"$func_options_prep_result"} 163603ea5dc6Smrg eval func_validate_options \ 163703ea5dc6Smrg ${func_parse_options_result+"$func_parse_options_result"} 1638862bcd1aSmrg 163903ea5dc6Smrg eval func_run_hooks func_options \ 164003ea5dc6Smrg ${func_validate_options_result+"$func_validate_options_result"} 1641d4a3aaf4Smrg 164203ea5dc6Smrg # save modified positional parameters for caller 164303ea5dc6Smrg func_options_result=$func_run_hooks_result 16441ab64890Smrg} 16451ab64890Smrg 164688de56ccSmrg 1647862bcd1aSmrg# func_options_prep [ARG]... 1648862bcd1aSmrg# -------------------------- 1649862bcd1aSmrg# All initialisations required before starting the option parse loop. 1650862bcd1aSmrg# Note that when calling hook functions, we pass through the list of 1651862bcd1aSmrg# positional parameters. If a hook function modifies that list, and 165203ea5dc6Smrg# needs to propogate that back to rest of this script, then the complete 1653862bcd1aSmrg# modified list must be put in 'func_run_hooks_result' before 165403ea5dc6Smrg# returning. 1655862bcd1aSmrgfunc_hookable func_options_prep 1656862bcd1aSmrgfunc_options_prep () 16571ab64890Smrg{ 1658862bcd1aSmrg $debug_cmd 165988de56ccSmrg 1660862bcd1aSmrg # Option defaults: 1661862bcd1aSmrg opt_verbose=false 1662862bcd1aSmrg opt_warning_types= 166388de56ccSmrg 166403ea5dc6Smrg func_run_hooks func_options_prep ${1+"$@"} 1665862bcd1aSmrg 166603ea5dc6Smrg # save modified positional parameters for caller 166703ea5dc6Smrg func_options_prep_result=$func_run_hooks_result 166888de56ccSmrg} 16691ab64890Smrg 1670862bcd1aSmrg 1671862bcd1aSmrg# func_parse_options [ARG]... 1672862bcd1aSmrg# --------------------------- 1673862bcd1aSmrg# The main option parsing loop. 1674862bcd1aSmrgfunc_hookable func_parse_options 1675862bcd1aSmrgfunc_parse_options () 1676e9fcaa8aSmrg{ 1677862bcd1aSmrg $debug_cmd 1678862bcd1aSmrg 1679862bcd1aSmrg func_parse_options_result= 1680862bcd1aSmrg 1681862bcd1aSmrg # this just eases exit handling 1682862bcd1aSmrg while test $# -gt 0; do 1683862bcd1aSmrg # Defer to hook functions for initial option parsing, so they 1684862bcd1aSmrg # get priority in the event of reusing an option name. 168503ea5dc6Smrg func_run_hooks func_parse_options ${1+"$@"} 168603ea5dc6Smrg 168703ea5dc6Smrg # Adjust func_parse_options positional parameters to match 168803ea5dc6Smrg eval set dummy "$func_run_hooks_result"; shift 1689862bcd1aSmrg 1690862bcd1aSmrg # Break out of the loop if we already parsed every option. 1691862bcd1aSmrg test $# -gt 0 || break 1692862bcd1aSmrg 1693862bcd1aSmrg _G_opt=$1 1694862bcd1aSmrg shift 1695862bcd1aSmrg case $_G_opt in 1696862bcd1aSmrg --debug|-x) debug_cmd='set -x' 1697862bcd1aSmrg func_echo "enabling shell trace mode" 1698862bcd1aSmrg $debug_cmd 1699862bcd1aSmrg ;; 1700862bcd1aSmrg 1701862bcd1aSmrg --no-warnings|--no-warning|--no-warn) 1702862bcd1aSmrg set dummy --warnings none ${1+"$@"} 1703862bcd1aSmrg shift 1704862bcd1aSmrg ;; 1705862bcd1aSmrg 1706862bcd1aSmrg --warnings|--warning|-W) 170703ea5dc6Smrg test $# = 0 && func_missing_arg $_G_opt && break 1708862bcd1aSmrg case " $warning_categories $1" in 1709862bcd1aSmrg *" $1 "*) 1710862bcd1aSmrg # trailing space prevents matching last $1 above 1711862bcd1aSmrg func_append_uniq opt_warning_types " $1" 1712862bcd1aSmrg ;; 1713862bcd1aSmrg *all) 1714862bcd1aSmrg opt_warning_types=$warning_categories 1715862bcd1aSmrg ;; 1716862bcd1aSmrg *none) 1717862bcd1aSmrg opt_warning_types=none 1718862bcd1aSmrg warning_func=: 1719862bcd1aSmrg ;; 1720862bcd1aSmrg *error) 1721862bcd1aSmrg opt_warning_types=$warning_categories 1722862bcd1aSmrg warning_func=func_fatal_error 1723862bcd1aSmrg ;; 1724862bcd1aSmrg *) 1725862bcd1aSmrg func_fatal_error \ 1726862bcd1aSmrg "unsupported warning category: '$1'" 1727862bcd1aSmrg ;; 1728862bcd1aSmrg esac 1729862bcd1aSmrg shift 1730862bcd1aSmrg ;; 1731862bcd1aSmrg 1732862bcd1aSmrg --verbose|-v) opt_verbose=: ;; 1733862bcd1aSmrg --version) func_version ;; 1734862bcd1aSmrg -\?|-h) func_usage ;; 1735862bcd1aSmrg --help) func_help ;; 1736862bcd1aSmrg 1737862bcd1aSmrg # Separate optargs to long options (plugins may need this): 1738862bcd1aSmrg --*=*) func_split_equals "$_G_opt" 1739862bcd1aSmrg set dummy "$func_split_equals_lhs" \ 1740862bcd1aSmrg "$func_split_equals_rhs" ${1+"$@"} 1741862bcd1aSmrg shift 1742862bcd1aSmrg ;; 1743862bcd1aSmrg 1744862bcd1aSmrg # Separate optargs to short options: 1745862bcd1aSmrg -W*) 1746862bcd1aSmrg func_split_short_opt "$_G_opt" 1747862bcd1aSmrg set dummy "$func_split_short_opt_name" \ 1748862bcd1aSmrg "$func_split_short_opt_arg" ${1+"$@"} 1749862bcd1aSmrg shift 1750862bcd1aSmrg ;; 1751862bcd1aSmrg 1752862bcd1aSmrg # Separate non-argument short options: 1753862bcd1aSmrg -\?*|-h*|-v*|-x*) 1754862bcd1aSmrg func_split_short_opt "$_G_opt" 1755862bcd1aSmrg set dummy "$func_split_short_opt_name" \ 1756862bcd1aSmrg "-$func_split_short_opt_arg" ${1+"$@"} 1757862bcd1aSmrg shift 1758862bcd1aSmrg ;; 1759862bcd1aSmrg 176003ea5dc6Smrg --) break ;; 1761862bcd1aSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 176203ea5dc6Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763862bcd1aSmrg esac 1764862bcd1aSmrg done 1765862bcd1aSmrg 176603ea5dc6Smrg # save modified positional parameters for caller 176703ea5dc6Smrg func_quote_for_eval ${1+"$@"} 176803ea5dc6Smrg func_parse_options_result=$func_quote_for_eval_result 1769e9fcaa8aSmrg} 177088de56ccSmrg 177188de56ccSmrg 1772862bcd1aSmrg# func_validate_options [ARG]... 1773862bcd1aSmrg# ------------------------------ 1774862bcd1aSmrg# Perform any sanity checks on option settings and/or unconsumed 1775862bcd1aSmrg# arguments. 1776862bcd1aSmrgfunc_hookable func_validate_options 1777862bcd1aSmrgfunc_validate_options () 177888de56ccSmrg{ 1779862bcd1aSmrg $debug_cmd 1780e9fcaa8aSmrg 1781862bcd1aSmrg # Display all warnings if -W was not given. 1782862bcd1aSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783862bcd1aSmrg 178403ea5dc6Smrg func_run_hooks func_validate_options ${1+"$@"} 1785862bcd1aSmrg 1786862bcd1aSmrg # Bail if the options were screwed! 1787862bcd1aSmrg $exit_cmd $EXIT_FAILURE 1788862bcd1aSmrg 178903ea5dc6Smrg # save modified positional parameters for caller 179003ea5dc6Smrg func_validate_options_result=$func_run_hooks_result 179188de56ccSmrg} 179288de56ccSmrg 1793862bcd1aSmrg 1794862bcd1aSmrg 1795862bcd1aSmrg## ----------------- ## 1796862bcd1aSmrg## Helper functions. ## 1797862bcd1aSmrg## ----------------- ## 1798862bcd1aSmrg 1799862bcd1aSmrg# This section contains the helper functions used by the rest of the 1800862bcd1aSmrg# hookable option parser framework in ascii-betical order. 1801862bcd1aSmrg 1802862bcd1aSmrg 1803862bcd1aSmrg# func_fatal_help ARG... 1804862bcd1aSmrg# ---------------------- 1805862bcd1aSmrg# Echo program name prefixed message to standard error, followed by 1806862bcd1aSmrg# a help hint, and exit. 1807862bcd1aSmrgfunc_fatal_help () 180888de56ccSmrg{ 1809862bcd1aSmrg $debug_cmd 1810e9fcaa8aSmrg 1811862bcd1aSmrg eval \$ECHO \""Usage: $usage"\" 1812862bcd1aSmrg eval \$ECHO \""$fatal_help"\" 1813862bcd1aSmrg func_error ${1+"$@"} 1814862bcd1aSmrg exit $EXIT_FAILURE 181588de56ccSmrg} 181688de56ccSmrg 1817862bcd1aSmrg 1818862bcd1aSmrg# func_help 1819862bcd1aSmrg# --------- 1820862bcd1aSmrg# Echo long help message to standard output and exit. 182188de56ccSmrgfunc_help () 182288de56ccSmrg{ 1823862bcd1aSmrg $debug_cmd 1824862bcd1aSmrg 1825862bcd1aSmrg func_usage_message 1826862bcd1aSmrg $ECHO "$long_help_message" 1827862bcd1aSmrg exit 0 182888de56ccSmrg} 182988de56ccSmrg 1830862bcd1aSmrg 1831862bcd1aSmrg# func_missing_arg ARGNAME 1832862bcd1aSmrg# ------------------------ 183388de56ccSmrg# Echo program name prefixed message to standard error and set global 183488de56ccSmrg# exit_cmd. 183588de56ccSmrgfunc_missing_arg () 183688de56ccSmrg{ 1837862bcd1aSmrg $debug_cmd 1838e9fcaa8aSmrg 1839862bcd1aSmrg func_error "Missing argument for '$1'." 184088de56ccSmrg exit_cmd=exit 18411ab64890Smrg} 18421ab64890Smrg 18432e9c7c8cSmrg 1844862bcd1aSmrg# func_split_equals STRING 1845862bcd1aSmrg# ------------------------ 1846862bcd1aSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847862bcd1aSmrg# splitting STRING at the '=' sign. 1848862bcd1aSmrgtest -z "$_G_HAVE_XSI_OPS" \ 1849862bcd1aSmrg && (eval 'x=a/b/c; 1850862bcd1aSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851862bcd1aSmrg && _G_HAVE_XSI_OPS=yes 1852862bcd1aSmrg 1853862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS" 1854862bcd1aSmrgthen 1855862bcd1aSmrg # This is an XSI compatible shell, allowing a faster implementation... 1856862bcd1aSmrg eval 'func_split_equals () 1857862bcd1aSmrg { 1858862bcd1aSmrg $debug_cmd 1859862bcd1aSmrg 1860862bcd1aSmrg func_split_equals_lhs=${1%%=*} 1861862bcd1aSmrg func_split_equals_rhs=${1#*=} 1862862bcd1aSmrg test "x$func_split_equals_lhs" = "x$1" \ 1863862bcd1aSmrg && func_split_equals_rhs= 1864862bcd1aSmrg }' 1865862bcd1aSmrgelse 1866862bcd1aSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 1867862bcd1aSmrg func_split_equals () 1868862bcd1aSmrg { 1869862bcd1aSmrg $debug_cmd 1870862bcd1aSmrg 1871862bcd1aSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872862bcd1aSmrg func_split_equals_rhs= 1873862bcd1aSmrg test "x$func_split_equals_lhs" = "x$1" \ 1874862bcd1aSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875862bcd1aSmrg } 1876862bcd1aSmrgfi #func_split_equals 1877862bcd1aSmrg 1878862bcd1aSmrg 1879862bcd1aSmrg# func_split_short_opt SHORTOPT 1880862bcd1aSmrg# ----------------------------- 1881e9fcaa8aSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882e9fcaa8aSmrg# variables after splitting SHORTOPT after the 2nd character. 1883862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS" 1884862bcd1aSmrgthen 1885862bcd1aSmrg # This is an XSI compatible shell, allowing a faster implementation... 1886862bcd1aSmrg eval 'func_split_short_opt () 1887862bcd1aSmrg { 1888862bcd1aSmrg $debug_cmd 1889862bcd1aSmrg 1890862bcd1aSmrg func_split_short_opt_arg=${1#??} 1891862bcd1aSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892862bcd1aSmrg }' 1893862bcd1aSmrgelse 1894862bcd1aSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 1895862bcd1aSmrg func_split_short_opt () 1896862bcd1aSmrg { 1897862bcd1aSmrg $debug_cmd 1898862bcd1aSmrg 1899862bcd1aSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900862bcd1aSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901862bcd1aSmrg } 1902862bcd1aSmrgfi #func_split_short_opt 1903862bcd1aSmrg 1904862bcd1aSmrg 1905862bcd1aSmrg# func_usage 1906862bcd1aSmrg# ---------- 1907862bcd1aSmrg# Echo short help message to standard output and exit. 1908862bcd1aSmrgfunc_usage () 1909e9fcaa8aSmrg{ 1910862bcd1aSmrg $debug_cmd 1911e9fcaa8aSmrg 1912862bcd1aSmrg func_usage_message 1913862bcd1aSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914862bcd1aSmrg exit 0 1915862bcd1aSmrg} 19162e9c7c8cSmrg 191788de56ccSmrg 1918862bcd1aSmrg# func_usage_message 1919862bcd1aSmrg# ------------------ 1920862bcd1aSmrg# Echo short help message to standard output. 1921862bcd1aSmrgfunc_usage_message () 1922e9fcaa8aSmrg{ 1923862bcd1aSmrg $debug_cmd 1924e9fcaa8aSmrg 1925862bcd1aSmrg eval \$ECHO \""Usage: $usage"\" 1926862bcd1aSmrg echo 1927862bcd1aSmrg $SED -n 's|^# || 1928862bcd1aSmrg /^Written by/{ 1929862bcd1aSmrg x;p;x 1930862bcd1aSmrg } 1931862bcd1aSmrg h 1932862bcd1aSmrg /^Written by/q' < "$progpath" 1933862bcd1aSmrg echo 1934862bcd1aSmrg eval \$ECHO \""$usage_message"\" 1935862bcd1aSmrg} 1936e9fcaa8aSmrg 1937e9fcaa8aSmrg 1938862bcd1aSmrg# func_version 1939862bcd1aSmrg# ------------ 1940862bcd1aSmrg# Echo version message to standard output and exit. 1941862bcd1aSmrgfunc_version () 1942862bcd1aSmrg{ 1943862bcd1aSmrg $debug_cmd 194488de56ccSmrg 1945862bcd1aSmrg printf '%s\n' "$progname $scriptversion" 1946862bcd1aSmrg $SED -n ' 1947862bcd1aSmrg /(C)/!b go 1948862bcd1aSmrg :more 1949862bcd1aSmrg /\./!{ 1950862bcd1aSmrg N 1951862bcd1aSmrg s|\n# | | 1952862bcd1aSmrg b more 1953862bcd1aSmrg } 1954862bcd1aSmrg :go 1955862bcd1aSmrg /^# Written by /,/# warranty; / { 1956862bcd1aSmrg s|^# || 1957862bcd1aSmrg s|^# *$|| 1958862bcd1aSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959862bcd1aSmrg p 1960862bcd1aSmrg } 1961862bcd1aSmrg /^# Written by / { 1962862bcd1aSmrg s|^# || 1963862bcd1aSmrg p 1964862bcd1aSmrg } 1965862bcd1aSmrg /^warranty; /q' < "$progpath" 196688de56ccSmrg 1967862bcd1aSmrg exit $? 1968862bcd1aSmrg} 19691ab64890Smrg 19701ab64890Smrg 1971862bcd1aSmrg# Local variables: 1972862bcd1aSmrg# mode: shell-script 1973862bcd1aSmrg# sh-indentation: 2 1974862bcd1aSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1975862bcd1aSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976862bcd1aSmrg# time-stamp-time-zone: "UTC" 1977862bcd1aSmrg# End: 19781ab64890Smrg 1979862bcd1aSmrg# Set a version string. 1980862bcd1aSmrgscriptversion='(GNU libtool) 2.4.6' 19812e9c7c8cSmrg 198288de56ccSmrg 1983862bcd1aSmrg# func_echo ARG... 1984862bcd1aSmrg# ---------------- 1985862bcd1aSmrg# Libtool also displays the current mode in messages, so override 1986862bcd1aSmrg# funclib.sh func_echo with this custom definition. 1987862bcd1aSmrgfunc_echo () 1988e9fcaa8aSmrg{ 1989862bcd1aSmrg $debug_cmd 1990e9fcaa8aSmrg 1991862bcd1aSmrg _G_message=$* 1992862bcd1aSmrg 1993862bcd1aSmrg func_echo_IFS=$IFS 1994862bcd1aSmrg IFS=$nl 1995862bcd1aSmrg for _G_line in $_G_message; do 1996862bcd1aSmrg IFS=$func_echo_IFS 1997862bcd1aSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998862bcd1aSmrg done 1999862bcd1aSmrg IFS=$func_echo_IFS 2000862bcd1aSmrg} 2001e9fcaa8aSmrg 2002e9fcaa8aSmrg 2003862bcd1aSmrg# func_warning ARG... 2004862bcd1aSmrg# ------------------- 2005862bcd1aSmrg# Libtool warnings are not categorized, so override funclib.sh 2006862bcd1aSmrg# func_warning with this simpler definition. 2007862bcd1aSmrgfunc_warning () 2008e9fcaa8aSmrg{ 2009862bcd1aSmrg $debug_cmd 2010862bcd1aSmrg 2011862bcd1aSmrg $warning_func ${1+"$@"} 2012862bcd1aSmrg} 2013862bcd1aSmrg 2014e9fcaa8aSmrg 2015862bcd1aSmrg## ---------------- ## 2016862bcd1aSmrg## Options parsing. ## 2017862bcd1aSmrg## ---------------- ## 2018862bcd1aSmrg 2019862bcd1aSmrg# Hook in the functions to make sure our own options are parsed during 2020862bcd1aSmrg# the option parsing loop. 2021862bcd1aSmrg 2022862bcd1aSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 2023862bcd1aSmrg 2024862bcd1aSmrg# Short help message in response to '-h'. 2025862bcd1aSmrgusage_message="Options: 2026862bcd1aSmrg --config show all configuration variables 2027862bcd1aSmrg --debug enable verbose shell tracing 2028862bcd1aSmrg -n, --dry-run display commands without modifying any files 2029862bcd1aSmrg --features display basic configuration information and exit 2030862bcd1aSmrg --mode=MODE use operation mode MODE 2031862bcd1aSmrg --no-warnings equivalent to '-Wnone' 2032862bcd1aSmrg --preserve-dup-deps don't remove duplicate dependency libraries 2033862bcd1aSmrg --quiet, --silent don't print informational messages 2034862bcd1aSmrg --tag=TAG use configuration variables from tag TAG 2035862bcd1aSmrg -v, --verbose print more informational messages than default 2036862bcd1aSmrg --version print version information 2037862bcd1aSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038862bcd1aSmrg -h, --help, --help-all print short, long, or detailed help message 2039862bcd1aSmrg" 2040e9fcaa8aSmrg 2041862bcd1aSmrg# Additional text appended to 'usage_message' in response to '--help'. 2042862bcd1aSmrgfunc_help () 2043e9fcaa8aSmrg{ 2044862bcd1aSmrg $debug_cmd 2045862bcd1aSmrg 2046862bcd1aSmrg func_usage_message 2047862bcd1aSmrg $ECHO "$long_help_message 2048862bcd1aSmrg 2049862bcd1aSmrgMODE must be one of the following: 2050862bcd1aSmrg 2051862bcd1aSmrg clean remove files from the build directory 2052862bcd1aSmrg compile compile a source file into a libtool object 2053862bcd1aSmrg execute automatically set library path, then run a program 2054862bcd1aSmrg finish complete the installation of libtool libraries 2055862bcd1aSmrg install install libraries or executables 2056862bcd1aSmrg link create a library or an executable 2057862bcd1aSmrg uninstall remove libraries from an installed directory 2058862bcd1aSmrg 2059862bcd1aSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2060862bcd1aSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061862bcd1aSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062862bcd1aSmrg 2063862bcd1aSmrgWhen reporting a bug, please describe a test case to reproduce it and 2064862bcd1aSmrginclude the following information: 2065862bcd1aSmrg 2066862bcd1aSmrg host-triplet: $host 2067862bcd1aSmrg shell: $SHELL 2068862bcd1aSmrg compiler: $LTCC 2069862bcd1aSmrg compiler flags: $LTCFLAGS 2070862bcd1aSmrg linker: $LD (gnu? $with_gnu_ld) 207103ea5dc6Smrg version: $progname (GNU libtool) 2.4.6 2072862bcd1aSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073862bcd1aSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074862bcd1aSmrg 2075862bcd1aSmrgReport bugs to <bug-libtool@gnu.org>. 207603ea5dc6SmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2077862bcd1aSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078862bcd1aSmrg exit 0 2079862bcd1aSmrg} 2080e9fcaa8aSmrg 2081e9fcaa8aSmrg 2082862bcd1aSmrg# func_lo2o OBJECT-NAME 2083862bcd1aSmrg# --------------------- 2084862bcd1aSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085862bcd1aSmrg# object suffix. 2086e9fcaa8aSmrg 2087862bcd1aSmrglo2o=s/\\.lo\$/.$objext/ 2088862bcd1aSmrgo2lo=s/\\.$objext\$/.lo/ 2089e9fcaa8aSmrg 2090862bcd1aSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 2091862bcd1aSmrg eval 'func_lo2o () 2092862bcd1aSmrg { 2093862bcd1aSmrg case $1 in 2094862bcd1aSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095862bcd1aSmrg * ) func_lo2o_result=$1 ;; 2096862bcd1aSmrg esac 2097862bcd1aSmrg }' 2098862bcd1aSmrg 2099862bcd1aSmrg # func_xform LIBOBJ-OR-SOURCE 2100862bcd1aSmrg # --------------------------- 2101862bcd1aSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102862bcd1aSmrg # suffix to a '.lo' libtool-object suffix. 2103862bcd1aSmrg eval 'func_xform () 2104862bcd1aSmrg { 2105862bcd1aSmrg func_xform_result=${1%.*}.lo 2106862bcd1aSmrg }' 2107862bcd1aSmrgelse 2108862bcd1aSmrg # ...otherwise fall back to using sed. 2109862bcd1aSmrg func_lo2o () 2110862bcd1aSmrg { 2111862bcd1aSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112862bcd1aSmrg } 2113862bcd1aSmrg 2114862bcd1aSmrg func_xform () 2115862bcd1aSmrg { 2116862bcd1aSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117862bcd1aSmrg } 2118862bcd1aSmrgfi 2119e9fcaa8aSmrg 2120e9fcaa8aSmrg 2121862bcd1aSmrg# func_fatal_configuration ARG... 2122862bcd1aSmrg# ------------------------------- 212388de56ccSmrg# Echo program name prefixed message to standard error, followed by 212488de56ccSmrg# a configuration failure hint, and exit. 212588de56ccSmrgfunc_fatal_configuration () 212688de56ccSmrg{ 21279c019ec5Smaya func__fatal_error ${1+"$@"} \ 2128862bcd1aSmrg "See the $PACKAGE documentation for more information." \ 2129862bcd1aSmrg "Fatal configuration error." 213088de56ccSmrg} 21311ab64890Smrg 21322e9c7c8cSmrg 213388de56ccSmrg# func_config 2134862bcd1aSmrg# ----------- 213588de56ccSmrg# Display the configuration for all the tags in this script. 213688de56ccSmrgfunc_config () 213788de56ccSmrg{ 213888de56ccSmrg re_begincf='^# ### BEGIN LIBTOOL' 213988de56ccSmrg re_endcf='^# ### END LIBTOOL' 214088de56ccSmrg 214188de56ccSmrg # Default configuration. 214288de56ccSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 21431ab64890Smrg 21441ab64890Smrg # Now print the configurations for the tags. 21451ab64890Smrg for tagname in $taglist; do 214688de56ccSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 21471ab64890Smrg done 2148b4ee4795Smrg 214988de56ccSmrg exit $? 215088de56ccSmrg} 2151b4ee4795Smrg 2152862bcd1aSmrg 215388de56ccSmrg# func_features 2154862bcd1aSmrg# ------------- 215588de56ccSmrg# Display the features supported by this script. 215688de56ccSmrgfunc_features () 215788de56ccSmrg{ 2158e9fcaa8aSmrg echo "host: $host" 2159862bcd1aSmrg if test yes = "$build_libtool_libs"; then 2160e9fcaa8aSmrg echo "enable shared libraries" 21611ab64890Smrg else 2162e9fcaa8aSmrg echo "disable shared libraries" 21631ab64890Smrg fi 2164862bcd1aSmrg if test yes = "$build_old_libs"; then 2165e9fcaa8aSmrg echo "enable static libraries" 21661ab64890Smrg else 2167e9fcaa8aSmrg echo "disable static libraries" 21681ab64890Smrg fi 216988de56ccSmrg 21701ab64890Smrg exit $? 217188de56ccSmrg} 21721ab64890Smrg 2173862bcd1aSmrg 2174862bcd1aSmrg# func_enable_tag TAGNAME 2175862bcd1aSmrg# ----------------------- 217688de56ccSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 217788de56ccSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 217888de56ccSmrg# variable here. 217988de56ccSmrgfunc_enable_tag () 218088de56ccSmrg{ 2181862bcd1aSmrg # Global variable: 2182862bcd1aSmrg tagname=$1 21831ab64890Smrg 2184862bcd1aSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185862bcd1aSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186862bcd1aSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 21872e9c7c8cSmrg 2188862bcd1aSmrg # Validate tagname. 2189862bcd1aSmrg case $tagname in 2190862bcd1aSmrg *[!-_A-Za-z0-9,/]*) 2191862bcd1aSmrg func_fatal_error "invalid tag name: $tagname" 2192862bcd1aSmrg ;; 2193862bcd1aSmrg esac 21941ab64890Smrg 2195862bcd1aSmrg # Don't test for the "default" C tag, as we know it's 2196862bcd1aSmrg # there but not specially marked. 2197862bcd1aSmrg case $tagname in 2198862bcd1aSmrg CC) ;; 219988de56ccSmrg *) 2200862bcd1aSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201862bcd1aSmrg taglist="$taglist $tagname" 2202862bcd1aSmrg 2203862bcd1aSmrg # Evaluate the configuration. Be careful to quote the path 2204862bcd1aSmrg # and the sed script, to avoid splitting on whitespace, but 2205862bcd1aSmrg # also don't use non-portable quotes within backquotes within 2206862bcd1aSmrg # quotes we have to do it in 2 steps: 2207862bcd1aSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208862bcd1aSmrg eval "$extractedcf" 2209862bcd1aSmrg else 2210862bcd1aSmrg func_error "ignoring unknown tag $tagname" 2211862bcd1aSmrg fi 2212862bcd1aSmrg ;; 2213862bcd1aSmrg esac 221488de56ccSmrg} 221588de56ccSmrg 2216862bcd1aSmrg 2217e9fcaa8aSmrg# func_check_version_match 2218862bcd1aSmrg# ------------------------ 2219e9fcaa8aSmrg# Ensure that we are using m4 macros, and libtool script from the same 2220e9fcaa8aSmrg# release of libtool. 2221e9fcaa8aSmrgfunc_check_version_match () 222288de56ccSmrg{ 2223862bcd1aSmrg if test "$package_revision" != "$macro_revision"; then 2224862bcd1aSmrg if test "$VERSION" != "$macro_version"; then 2225862bcd1aSmrg if test -z "$macro_version"; then 2226862bcd1aSmrg cat >&2 <<_LT_EOF 2227e9fcaa8aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228e9fcaa8aSmrg$progname: definition of this LT_INIT comes from an older release. 2229e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230e9fcaa8aSmrg$progname: and run autoconf again. 2231e9fcaa8aSmrg_LT_EOF 2232862bcd1aSmrg else 2233862bcd1aSmrg cat >&2 <<_LT_EOF 2234e9fcaa8aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235e9fcaa8aSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237e9fcaa8aSmrg$progname: and run autoconf again. 2238e9fcaa8aSmrg_LT_EOF 2239862bcd1aSmrg fi 2240862bcd1aSmrg else 2241862bcd1aSmrg cat >&2 <<_LT_EOF 2242e9fcaa8aSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243e9fcaa8aSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244e9fcaa8aSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245e9fcaa8aSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2246e9fcaa8aSmrg_LT_EOF 2247862bcd1aSmrg fi 2248e9fcaa8aSmrg 2249862bcd1aSmrg exit $EXIT_MISMATCH 2250862bcd1aSmrg fi 2251e9fcaa8aSmrg} 2252e9fcaa8aSmrg 2253e9fcaa8aSmrg 2254862bcd1aSmrg# libtool_options_prep [ARG]... 2255862bcd1aSmrg# ----------------------------- 2256862bcd1aSmrg# Preparation for options parsed by libtool. 2257862bcd1aSmrglibtool_options_prep () 2258862bcd1aSmrg{ 2259862bcd1aSmrg $debug_mode 2260b4ee4795Smrg 2261862bcd1aSmrg # Option defaults: 2262862bcd1aSmrg opt_config=false 2263862bcd1aSmrg opt_dlopen= 2264862bcd1aSmrg opt_dry_run=false 2265862bcd1aSmrg opt_help=false 2266862bcd1aSmrg opt_mode= 2267862bcd1aSmrg opt_preserve_dup_deps=false 2268862bcd1aSmrg opt_quiet=false 22691ab64890Smrg 2270862bcd1aSmrg nonopt= 2271862bcd1aSmrg preserve_args= 2272e9fcaa8aSmrg 2273862bcd1aSmrg # Shorthand for --mode=foo, only valid as the first argument 2274862bcd1aSmrg case $1 in 2275862bcd1aSmrg clean|clea|cle|cl) 2276862bcd1aSmrg shift; set dummy --mode clean ${1+"$@"}; shift 2277862bcd1aSmrg ;; 2278862bcd1aSmrg compile|compil|compi|comp|com|co|c) 2279862bcd1aSmrg shift; set dummy --mode compile ${1+"$@"}; shift 2280862bcd1aSmrg ;; 2281862bcd1aSmrg execute|execut|execu|exec|exe|ex|e) 2282862bcd1aSmrg shift; set dummy --mode execute ${1+"$@"}; shift 2283862bcd1aSmrg ;; 2284862bcd1aSmrg finish|finis|fini|fin|fi|f) 2285862bcd1aSmrg shift; set dummy --mode finish ${1+"$@"}; shift 2286862bcd1aSmrg ;; 2287862bcd1aSmrg install|instal|insta|inst|ins|in|i) 2288862bcd1aSmrg shift; set dummy --mode install ${1+"$@"}; shift 2289862bcd1aSmrg ;; 2290862bcd1aSmrg link|lin|li|l) 2291862bcd1aSmrg shift; set dummy --mode link ${1+"$@"}; shift 2292862bcd1aSmrg ;; 2293862bcd1aSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294862bcd1aSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2295862bcd1aSmrg ;; 2296862bcd1aSmrg esac 2297862bcd1aSmrg 229803ea5dc6Smrg # Pass back the list of options. 229903ea5dc6Smrg func_quote_for_eval ${1+"$@"} 230003ea5dc6Smrg libtool_options_prep_result=$func_quote_for_eval_result 2301862bcd1aSmrg} 2302862bcd1aSmrgfunc_add_hook func_options_prep libtool_options_prep 2303e9fcaa8aSmrg 2304e9fcaa8aSmrg 2305862bcd1aSmrg# libtool_parse_options [ARG]... 2306862bcd1aSmrg# --------------------------------- 2307862bcd1aSmrg# Provide handling for libtool specific options. 2308862bcd1aSmrglibtool_parse_options () 2309e9fcaa8aSmrg{ 2310862bcd1aSmrg $debug_cmd 231188de56ccSmrg 2312862bcd1aSmrg # Perform our own loop to consume as many options as possible in 2313862bcd1aSmrg # each iteration. 2314862bcd1aSmrg while test $# -gt 0; do 2315862bcd1aSmrg _G_opt=$1 2316862bcd1aSmrg shift 2317862bcd1aSmrg case $_G_opt in 2318862bcd1aSmrg --dry-run|--dryrun|-n) 2319862bcd1aSmrg opt_dry_run=: 2320862bcd1aSmrg ;; 2321862bcd1aSmrg 2322862bcd1aSmrg --config) func_config ;; 2323862bcd1aSmrg 2324862bcd1aSmrg --dlopen|-dlopen) 2325862bcd1aSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 2326862bcd1aSmrg}$1" 2327862bcd1aSmrg shift 2328862bcd1aSmrg ;; 2329862bcd1aSmrg 2330862bcd1aSmrg --preserve-dup-deps) 2331862bcd1aSmrg opt_preserve_dup_deps=: ;; 2332862bcd1aSmrg 2333862bcd1aSmrg --features) func_features ;; 2334862bcd1aSmrg 2335862bcd1aSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336862bcd1aSmrg 2337862bcd1aSmrg --help) opt_help=: ;; 2338862bcd1aSmrg 2339862bcd1aSmrg --help-all) opt_help=': help-all' ;; 2340862bcd1aSmrg 2341862bcd1aSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342862bcd1aSmrg opt_mode=$1 2343862bcd1aSmrg case $1 in 2344862bcd1aSmrg # Valid mode arguments: 2345862bcd1aSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346862bcd1aSmrg 2347862bcd1aSmrg # Catch anything else as an error 2348862bcd1aSmrg *) func_error "invalid argument for $_G_opt" 2349862bcd1aSmrg exit_cmd=exit 2350862bcd1aSmrg break 2351862bcd1aSmrg ;; 2352862bcd1aSmrg esac 2353862bcd1aSmrg shift 2354862bcd1aSmrg ;; 2355862bcd1aSmrg 2356862bcd1aSmrg --no-silent|--no-quiet) 2357862bcd1aSmrg opt_quiet=false 2358862bcd1aSmrg func_append preserve_args " $_G_opt" 2359862bcd1aSmrg ;; 2360862bcd1aSmrg 2361862bcd1aSmrg --no-warnings|--no-warning|--no-warn) 2362862bcd1aSmrg opt_warning=false 2363862bcd1aSmrg func_append preserve_args " $_G_opt" 2364862bcd1aSmrg ;; 2365862bcd1aSmrg 2366862bcd1aSmrg --no-verbose) 2367862bcd1aSmrg opt_verbose=false 2368862bcd1aSmrg func_append preserve_args " $_G_opt" 2369862bcd1aSmrg ;; 2370862bcd1aSmrg 2371862bcd1aSmrg --silent|--quiet) 2372862bcd1aSmrg opt_quiet=: 2373862bcd1aSmrg opt_verbose=false 2374862bcd1aSmrg func_append preserve_args " $_G_opt" 2375862bcd1aSmrg ;; 2376862bcd1aSmrg 2377862bcd1aSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378862bcd1aSmrg opt_tag=$1 2379862bcd1aSmrg func_append preserve_args " $_G_opt $1" 2380862bcd1aSmrg func_enable_tag "$1" 2381862bcd1aSmrg shift 2382862bcd1aSmrg ;; 2383862bcd1aSmrg 2384862bcd1aSmrg --verbose|-v) opt_quiet=false 2385862bcd1aSmrg opt_verbose=: 2386862bcd1aSmrg func_append preserve_args " $_G_opt" 2387862bcd1aSmrg ;; 2388862bcd1aSmrg 238903ea5dc6Smrg # An option not handled by this hook function: 239003ea5dc6Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391862bcd1aSmrg esac 2392862bcd1aSmrg done 2393e9fcaa8aSmrg 2394e9fcaa8aSmrg 239503ea5dc6Smrg # save modified positional parameters for caller 239603ea5dc6Smrg func_quote_for_eval ${1+"$@"} 239703ea5dc6Smrg libtool_parse_options_result=$func_quote_for_eval_result 2398862bcd1aSmrg} 2399862bcd1aSmrgfunc_add_hook func_parse_options libtool_parse_options 240088de56ccSmrg 24012e9c7c8cSmrg 240288de56ccSmrg 2403862bcd1aSmrg# libtool_validate_options [ARG]... 2404862bcd1aSmrg# --------------------------------- 2405862bcd1aSmrg# Perform any sanity checks on option settings and/or unconsumed 2406862bcd1aSmrg# arguments. 2407862bcd1aSmrglibtool_validate_options () 2408862bcd1aSmrg{ 2409862bcd1aSmrg # save first non-option argument 2410862bcd1aSmrg if test 0 -lt $#; then 2411862bcd1aSmrg nonopt=$1 2412862bcd1aSmrg shift 241388de56ccSmrg fi 241488de56ccSmrg 2415862bcd1aSmrg # preserve --debug 2416862bcd1aSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 241788de56ccSmrg 2418862bcd1aSmrg case $host in 2419862bcd1aSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420862bcd1aSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421862bcd1aSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422862bcd1aSmrg # don't eliminate duplications in $postdeps and $predeps 2423862bcd1aSmrg opt_duplicate_compiler_generated_deps=: 2424862bcd1aSmrg ;; 2425862bcd1aSmrg *) 2426862bcd1aSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427862bcd1aSmrg ;; 2428862bcd1aSmrg esac 24291ab64890Smrg 2430862bcd1aSmrg $opt_help || { 2431862bcd1aSmrg # Sanity checks first: 2432862bcd1aSmrg func_check_version_match 243388de56ccSmrg 2434862bcd1aSmrg test yes != "$build_libtool_libs" \ 2435862bcd1aSmrg && test yes != "$build_old_libs" \ 2436862bcd1aSmrg && func_fatal_configuration "not configured to build any kind of library" 243788de56ccSmrg 2438862bcd1aSmrg # Darwin sucks 2439862bcd1aSmrg eval std_shrext=\"$shrext_cmds\" 2440862bcd1aSmrg 2441862bcd1aSmrg # Only execute mode is allowed to have -dlopen flags. 2442862bcd1aSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443862bcd1aSmrg func_error "unrecognized option '-dlopen'" 2444862bcd1aSmrg $ECHO "$help" 1>&2 2445862bcd1aSmrg exit $EXIT_FAILURE 2446862bcd1aSmrg fi 2447862bcd1aSmrg 2448862bcd1aSmrg # Change the help message to a mode-specific one. 2449862bcd1aSmrg generic_help=$help 2450862bcd1aSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 2451862bcd1aSmrg } 2452862bcd1aSmrg 2453862bcd1aSmrg # Pass back the unparsed argument list 2454862bcd1aSmrg func_quote_for_eval ${1+"$@"} 2455862bcd1aSmrg libtool_validate_options_result=$func_quote_for_eval_result 2456e9fcaa8aSmrg} 2457862bcd1aSmrgfunc_add_hook func_validate_options libtool_validate_options 2458862bcd1aSmrg 245988de56ccSmrg 2460862bcd1aSmrg# Process options as early as possible so that --help and --version 2461862bcd1aSmrg# can return quickly. 2462862bcd1aSmrgfunc_options ${1+"$@"} 2463862bcd1aSmrgeval set dummy "$func_options_result"; shift 246488de56ccSmrg 24651ab64890Smrg 24661ab64890Smrg 2467e9fcaa8aSmrg## ----------- ## 2468e9fcaa8aSmrg## Main. ## 2469e9fcaa8aSmrg## ----------- ## 24701ab64890Smrg 2471862bcd1aSmrgmagic='%%%MAGIC variable%%%' 2472862bcd1aSmrgmagic_exe='%%%MAGIC EXE variable%%%' 2473862bcd1aSmrg 2474862bcd1aSmrg# Global variables. 2475862bcd1aSmrgextracted_archives= 2476862bcd1aSmrgextracted_serial=0 2477862bcd1aSmrg 2478862bcd1aSmrg# If this variable is set in any of the actions, the command in it 2479862bcd1aSmrg# will be execed at the end. This prevents here-documents from being 2480862bcd1aSmrg# left over by shells. 2481862bcd1aSmrgexec_cmd= 2482862bcd1aSmrg 2483862bcd1aSmrg 2484862bcd1aSmrg# A function that is used when there is no print builtin or printf. 2485862bcd1aSmrgfunc_fallback_echo () 2486862bcd1aSmrg{ 2487862bcd1aSmrg eval 'cat <<_LTECHO_EOF 2488862bcd1aSmrg$1 2489862bcd1aSmrg_LTECHO_EOF' 2490862bcd1aSmrg} 2491862bcd1aSmrg 2492862bcd1aSmrg# func_generated_by_libtool 2493862bcd1aSmrg# True iff stdin has been generated by Libtool. This function is only 2494862bcd1aSmrg# a basic sanity check; it will hardly flush out determined imposters. 2495862bcd1aSmrgfunc_generated_by_libtool_p () 2496862bcd1aSmrg{ 2497862bcd1aSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498862bcd1aSmrg} 2499862bcd1aSmrg 250088de56ccSmrg# func_lalib_p file 2501862bcd1aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 250288de56ccSmrg# This function is only a basic sanity check; it will hardly flush out 250388de56ccSmrg# determined imposters. 250488de56ccSmrgfunc_lalib_p () 250588de56ccSmrg{ 250688de56ccSmrg test -f "$1" && 2507862bcd1aSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 250888de56ccSmrg} 25091ab64890Smrg 251088de56ccSmrg# func_lalib_unsafe_p file 2511862bcd1aSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 251288de56ccSmrg# This function implements the same check as func_lalib_p without 251388de56ccSmrg# resorting to external programs. To this end, it redirects stdin and 251488de56ccSmrg# closes it afterwards, without saving the original file descriptor. 251588de56ccSmrg# As a safety measure, use it only where a negative result would be 2516862bcd1aSmrg# fatal anyway. Works if 'file' does not exist. 251788de56ccSmrgfunc_lalib_unsafe_p () 251888de56ccSmrg{ 251988de56ccSmrg lalib_p=no 252088de56ccSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 252188de56ccSmrg for lalib_p_l in 1 2 3 4 252288de56ccSmrg do 252388de56ccSmrg read lalib_p_line 2524862bcd1aSmrg case $lalib_p_line in 252588de56ccSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 252688de56ccSmrg esac 252788de56ccSmrg done 252888de56ccSmrg exec 0<&5 5<&- 252988de56ccSmrg fi 2530862bcd1aSmrg test yes = "$lalib_p" 253188de56ccSmrg} 25321ab64890Smrg 253388de56ccSmrg# func_ltwrapper_script_p file 253488de56ccSmrg# True iff FILE is a libtool wrapper script 253588de56ccSmrg# This function is only a basic sanity check; it will hardly flush out 253688de56ccSmrg# determined imposters. 253788de56ccSmrgfunc_ltwrapper_script_p () 253888de56ccSmrg{ 2539862bcd1aSmrg test -f "$1" && 2540862bcd1aSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 254188de56ccSmrg} 25421ab64890Smrg 254388de56ccSmrg# func_ltwrapper_executable_p file 254488de56ccSmrg# True iff FILE is a libtool wrapper executable 254588de56ccSmrg# This function is only a basic sanity check; it will hardly flush out 254688de56ccSmrg# determined imposters. 254788de56ccSmrgfunc_ltwrapper_executable_p () 254888de56ccSmrg{ 254988de56ccSmrg func_ltwrapper_exec_suffix= 255088de56ccSmrg case $1 in 255188de56ccSmrg *.exe) ;; 255288de56ccSmrg *) func_ltwrapper_exec_suffix=.exe ;; 255388de56ccSmrg esac 255488de56ccSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 255588de56ccSmrg} 25562e9c7c8cSmrg 255788de56ccSmrg# func_ltwrapper_scriptname file 255888de56ccSmrg# Assumes file is an ltwrapper_executable 255988de56ccSmrg# uses $file to determine the appropriate filename for a 256088de56ccSmrg# temporary ltwrapper_script. 256188de56ccSmrgfunc_ltwrapper_scriptname () 256288de56ccSmrg{ 2563e9fcaa8aSmrg func_dirname_and_basename "$1" "" "." 2564e9fcaa8aSmrg func_stripname '' '.exe' "$func_basename_result" 2565862bcd1aSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 256688de56ccSmrg} 256788de56ccSmrg 256888de56ccSmrg# func_ltwrapper_p file 256988de56ccSmrg# True iff FILE is a libtool wrapper script or wrapper executable 257088de56ccSmrg# This function is only a basic sanity check; it will hardly flush out 257188de56ccSmrg# determined imposters. 257288de56ccSmrgfunc_ltwrapper_p () 257388de56ccSmrg{ 257488de56ccSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 257588de56ccSmrg} 257688de56ccSmrg 257788de56ccSmrg 257888de56ccSmrg# func_execute_cmds commands fail_cmd 257988de56ccSmrg# Execute tilde-delimited COMMANDS. 258088de56ccSmrg# If FAIL_CMD is given, eval that upon failure. 258188de56ccSmrg# FAIL_CMD may read-access the current command in variable CMD! 258288de56ccSmrgfunc_execute_cmds () 258388de56ccSmrg{ 2584862bcd1aSmrg $debug_cmd 2585862bcd1aSmrg 258688de56ccSmrg save_ifs=$IFS; IFS='~' 258788de56ccSmrg for cmd in $1; do 2588862bcd1aSmrg IFS=$sp$nl 258988de56ccSmrg eval cmd=\"$cmd\" 2590862bcd1aSmrg IFS=$save_ifs 259188de56ccSmrg func_show_eval "$cmd" "${2-:}" 259288de56ccSmrg done 259388de56ccSmrg IFS=$save_ifs 259488de56ccSmrg} 259588de56ccSmrg 259688de56ccSmrg 259788de56ccSmrg# func_source file 259888de56ccSmrg# Source FILE, adding directory component if necessary. 259988de56ccSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 260088de56ccSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 260188de56ccSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602862bcd1aSmrg# 'FILE.' does not work on cygwin managed mounts. 260388de56ccSmrgfunc_source () 260488de56ccSmrg{ 2605862bcd1aSmrg $debug_cmd 2606862bcd1aSmrg 260788de56ccSmrg case $1 in 260888de56ccSmrg */* | *\\*) . "$1" ;; 260988de56ccSmrg *) . "./$1" ;; 261088de56ccSmrg esac 261188de56ccSmrg} 261288de56ccSmrg 261388de56ccSmrg 2614e9fcaa8aSmrg# func_resolve_sysroot PATH 2615e9fcaa8aSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2616e9fcaa8aSmrg# func_resolve_sysroot_result 2617e9fcaa8aSmrgfunc_resolve_sysroot () 2618e9fcaa8aSmrg{ 2619e9fcaa8aSmrg func_resolve_sysroot_result=$1 2620e9fcaa8aSmrg case $func_resolve_sysroot_result in 2621e9fcaa8aSmrg =*) 2622e9fcaa8aSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2623e9fcaa8aSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624e9fcaa8aSmrg ;; 2625e9fcaa8aSmrg esac 2626e9fcaa8aSmrg} 2627e9fcaa8aSmrg 2628e9fcaa8aSmrg# func_replace_sysroot PATH 2629e9fcaa8aSmrg# If PATH begins with the sysroot, replace it with = and 2630e9fcaa8aSmrg# store the result into func_replace_sysroot_result. 2631e9fcaa8aSmrgfunc_replace_sysroot () 2632e9fcaa8aSmrg{ 2633862bcd1aSmrg case $lt_sysroot:$1 in 2634e9fcaa8aSmrg ?*:"$lt_sysroot"*) 2635e9fcaa8aSmrg func_stripname "$lt_sysroot" '' "$1" 2636862bcd1aSmrg func_replace_sysroot_result='='$func_stripname_result 2637e9fcaa8aSmrg ;; 2638e9fcaa8aSmrg *) 2639e9fcaa8aSmrg # Including no sysroot. 2640e9fcaa8aSmrg func_replace_sysroot_result=$1 2641e9fcaa8aSmrg ;; 2642e9fcaa8aSmrg esac 2643e9fcaa8aSmrg} 2644e9fcaa8aSmrg 264588de56ccSmrg# func_infer_tag arg 264688de56ccSmrg# Infer tagged configuration to use if any are available and 264788de56ccSmrg# if one wasn't chosen via the "--tag" command line option. 264888de56ccSmrg# Only attempt this if the compiler in the base compile 264988de56ccSmrg# command doesn't match the default compiler. 265088de56ccSmrg# arg is usually of the form 'gcc ...' 265188de56ccSmrgfunc_infer_tag () 265288de56ccSmrg{ 2653862bcd1aSmrg $debug_cmd 2654862bcd1aSmrg 265588de56ccSmrg if test -n "$available_tags" && test -z "$tagname"; then 265688de56ccSmrg CC_quoted= 265788de56ccSmrg for arg in $CC; do 2658e9fcaa8aSmrg func_append_quoted CC_quoted "$arg" 265988de56ccSmrg done 2660e9fcaa8aSmrg CC_expanded=`func_echo_all $CC` 2661e9fcaa8aSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 266288de56ccSmrg case $@ in 266388de56ccSmrg # Blanks in the command may have been stripped by the calling shell, 266488de56ccSmrg # but not from the CC environment variable when configure was run. 2665e9fcaa8aSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666e9fcaa8aSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 266788de56ccSmrg # Blanks at the start of $base_compile will cause this to fail 266888de56ccSmrg # if we don't check for them as well. 266988de56ccSmrg *) 267088de56ccSmrg for z in $available_tags; do 267188de56ccSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 267288de56ccSmrg # Evaluate the configuration. 2673862bcd1aSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 267488de56ccSmrg CC_quoted= 267588de56ccSmrg for arg in $CC; do 267688de56ccSmrg # Double-quote args containing other shell metacharacters. 2677e9fcaa8aSmrg func_append_quoted CC_quoted "$arg" 267888de56ccSmrg done 2679e9fcaa8aSmrg CC_expanded=`func_echo_all $CC` 2680e9fcaa8aSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 268188de56ccSmrg case "$@ " in 2682e9fcaa8aSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683e9fcaa8aSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 268488de56ccSmrg # The compiler in the base compile command matches 268588de56ccSmrg # the one in the tagged configuration. 268688de56ccSmrg # Assume this is the tagged configuration we want. 268788de56ccSmrg tagname=$z 268888de56ccSmrg break 268988de56ccSmrg ;; 269088de56ccSmrg esac 269188de56ccSmrg fi 269288de56ccSmrg done 269388de56ccSmrg # If $tagname still isn't set, then no tagged configuration 269488de56ccSmrg # was found and let the user know that the "--tag" command 269588de56ccSmrg # line option must be used. 269688de56ccSmrg if test -z "$tagname"; then 269788de56ccSmrg func_echo "unable to infer tagged configuration" 2698862bcd1aSmrg func_fatal_error "specify a tag with '--tag'" 269988de56ccSmrg# else 270088de56ccSmrg# func_verbose "using $tagname tagged configuration" 270188de56ccSmrg fi 270288de56ccSmrg ;; 270388de56ccSmrg esac 270488de56ccSmrg fi 270588de56ccSmrg} 270688de56ccSmrg 270788de56ccSmrg 270888de56ccSmrg 270988de56ccSmrg# func_write_libtool_object output_name pic_name nonpic_name 271088de56ccSmrg# Create a libtool object file (analogous to a ".la" file), 271188de56ccSmrg# but don't create it if we're doing a dry run. 271288de56ccSmrgfunc_write_libtool_object () 271388de56ccSmrg{ 2714862bcd1aSmrg write_libobj=$1 2715862bcd1aSmrg if test yes = "$build_libtool_libs"; then 2716862bcd1aSmrg write_lobj=\'$2\' 271788de56ccSmrg else 271888de56ccSmrg write_lobj=none 271988de56ccSmrg fi 272088de56ccSmrg 2721862bcd1aSmrg if test yes = "$build_old_libs"; then 2722862bcd1aSmrg write_oldobj=\'$3\' 272388de56ccSmrg else 272488de56ccSmrg write_oldobj=none 272588de56ccSmrg fi 272688de56ccSmrg 272788de56ccSmrg $opt_dry_run || { 272888de56ccSmrg cat >${write_libobj}T <<EOF 272988de56ccSmrg# $write_libobj - a libtool object file 2730862bcd1aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 273188de56ccSmrg# 273288de56ccSmrg# Please DO NOT delete this file! 273388de56ccSmrg# It is necessary for linking the library. 273488de56ccSmrg 273588de56ccSmrg# Name of the PIC object. 273688de56ccSmrgpic_object=$write_lobj 273788de56ccSmrg 273888de56ccSmrg# Name of the non-PIC object 273988de56ccSmrgnon_pic_object=$write_oldobj 274088de56ccSmrg 274188de56ccSmrgEOF 2742862bcd1aSmrg $MV "${write_libobj}T" "$write_libobj" 274388de56ccSmrg } 274488de56ccSmrg} 274588de56ccSmrg 2746e9fcaa8aSmrg 2747e9fcaa8aSmrg################################################## 2748e9fcaa8aSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749e9fcaa8aSmrg################################################## 2750e9fcaa8aSmrg 2751e9fcaa8aSmrg# func_convert_core_file_wine_to_w32 ARG 2752e9fcaa8aSmrg# Helper function used by file name conversion functions when $build is *nix, 2753e9fcaa8aSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754e9fcaa8aSmrg# correctly configured wine environment available, with the winepath program 2755e9fcaa8aSmrg# in $build's $PATH. 2756e9fcaa8aSmrg# 2757e9fcaa8aSmrg# ARG is the $build file name to be converted to w32 format. 2758e9fcaa8aSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759e9fcaa8aSmrg# be empty on error (or when ARG is empty) 2760e9fcaa8aSmrgfunc_convert_core_file_wine_to_w32 () 2761e9fcaa8aSmrg{ 2762862bcd1aSmrg $debug_cmd 2763862bcd1aSmrg 2764862bcd1aSmrg func_convert_core_file_wine_to_w32_result=$1 2765e9fcaa8aSmrg if test -n "$1"; then 2766e9fcaa8aSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2767e9fcaa8aSmrg # are forced to check the contents of stdout. On the other hand, if the 2768e9fcaa8aSmrg # command is not found, the shell will set an exit code of 127 and print 2769e9fcaa8aSmrg # *an error message* to stdout. So we must check for both error code of 2770e9fcaa8aSmrg # zero AND non-empty stdout, which explains the odd construction: 2771e9fcaa8aSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772862bcd1aSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773e9fcaa8aSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774862bcd1aSmrg $SED -e "$sed_naive_backslashify"` 2775e9fcaa8aSmrg else 2776e9fcaa8aSmrg func_convert_core_file_wine_to_w32_result= 2777e9fcaa8aSmrg fi 2778e9fcaa8aSmrg fi 2779e9fcaa8aSmrg} 2780e9fcaa8aSmrg# end: func_convert_core_file_wine_to_w32 2781e9fcaa8aSmrg 2782e9fcaa8aSmrg 2783e9fcaa8aSmrg# func_convert_core_path_wine_to_w32 ARG 2784e9fcaa8aSmrg# Helper function used by path conversion functions when $build is *nix, and 2785e9fcaa8aSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786e9fcaa8aSmrg# configured wine environment available, with the winepath program in $build's 2787e9fcaa8aSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788e9fcaa8aSmrg# 2789e9fcaa8aSmrg# ARG is path to be converted from $build format to win32. 2790e9fcaa8aSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2791e9fcaa8aSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792e9fcaa8aSmrg# are convertible, then the result may be empty. 2793e9fcaa8aSmrgfunc_convert_core_path_wine_to_w32 () 2794e9fcaa8aSmrg{ 2795862bcd1aSmrg $debug_cmd 2796862bcd1aSmrg 2797e9fcaa8aSmrg # unfortunately, winepath doesn't convert paths, only file names 2798862bcd1aSmrg func_convert_core_path_wine_to_w32_result= 2799e9fcaa8aSmrg if test -n "$1"; then 2800e9fcaa8aSmrg oldIFS=$IFS 2801e9fcaa8aSmrg IFS=: 2802e9fcaa8aSmrg for func_convert_core_path_wine_to_w32_f in $1; do 2803e9fcaa8aSmrg IFS=$oldIFS 2804e9fcaa8aSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805862bcd1aSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806e9fcaa8aSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807862bcd1aSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808e9fcaa8aSmrg else 2809e9fcaa8aSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810e9fcaa8aSmrg fi 2811e9fcaa8aSmrg fi 2812e9fcaa8aSmrg done 2813e9fcaa8aSmrg IFS=$oldIFS 2814e9fcaa8aSmrg fi 2815e9fcaa8aSmrg} 2816e9fcaa8aSmrg# end: func_convert_core_path_wine_to_w32 2817e9fcaa8aSmrg 2818e9fcaa8aSmrg 2819e9fcaa8aSmrg# func_cygpath ARGS... 2820e9fcaa8aSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821e9fcaa8aSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822e9fcaa8aSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823e9fcaa8aSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824e9fcaa8aSmrg# file name or path is assumed to be in w32 format, as previously converted 2825e9fcaa8aSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826e9fcaa8aSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 2827e9fcaa8aSmrg# Cygwin format). Returns an empty string on error. 2828e9fcaa8aSmrg# 2829e9fcaa8aSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 2830e9fcaa8aSmrg# be converted. 2831e9fcaa8aSmrg# 2832e9fcaa8aSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833e9fcaa8aSmrg# environment variable; do not put it in $PATH. 2834e9fcaa8aSmrgfunc_cygpath () 2835e9fcaa8aSmrg{ 2836862bcd1aSmrg $debug_cmd 2837862bcd1aSmrg 2838e9fcaa8aSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839e9fcaa8aSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840e9fcaa8aSmrg if test "$?" -ne 0; then 2841e9fcaa8aSmrg # on failure, ensure result is empty 2842e9fcaa8aSmrg func_cygpath_result= 2843e9fcaa8aSmrg fi 2844e9fcaa8aSmrg else 2845e9fcaa8aSmrg func_cygpath_result= 2846862bcd1aSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847e9fcaa8aSmrg fi 2848e9fcaa8aSmrg} 2849e9fcaa8aSmrg#end: func_cygpath 2850e9fcaa8aSmrg 2851e9fcaa8aSmrg 2852e9fcaa8aSmrg# func_convert_core_msys_to_w32 ARG 2853e9fcaa8aSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 2854e9fcaa8aSmrg# result in func_convert_core_msys_to_w32_result. 2855e9fcaa8aSmrgfunc_convert_core_msys_to_w32 () 2856e9fcaa8aSmrg{ 2857862bcd1aSmrg $debug_cmd 2858862bcd1aSmrg 2859e9fcaa8aSmrg # awkward: cmd appends spaces to result 2860e9fcaa8aSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861862bcd1aSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862e9fcaa8aSmrg} 2863e9fcaa8aSmrg#end: func_convert_core_msys_to_w32 2864e9fcaa8aSmrg 2865e9fcaa8aSmrg 2866e9fcaa8aSmrg# func_convert_file_check ARG1 ARG2 2867e9fcaa8aSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 2868e9fcaa8aSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869e9fcaa8aSmrg# func_to_host_file_result to ARG1). 2870e9fcaa8aSmrgfunc_convert_file_check () 2871e9fcaa8aSmrg{ 2872862bcd1aSmrg $debug_cmd 2873862bcd1aSmrg 2874862bcd1aSmrg if test -z "$2" && test -n "$1"; then 2875e9fcaa8aSmrg func_error "Could not determine host file name corresponding to" 2876862bcd1aSmrg func_error " '$1'" 2877e9fcaa8aSmrg func_error "Continuing, but uninstalled executables may not work." 2878e9fcaa8aSmrg # Fallback: 2879862bcd1aSmrg func_to_host_file_result=$1 2880e9fcaa8aSmrg fi 2881e9fcaa8aSmrg} 2882e9fcaa8aSmrg# end func_convert_file_check 2883e9fcaa8aSmrg 2884e9fcaa8aSmrg 2885e9fcaa8aSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886e9fcaa8aSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2887e9fcaa8aSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888e9fcaa8aSmrg# func_to_host_file_result to a simplistic fallback value (see below). 2889e9fcaa8aSmrgfunc_convert_path_check () 2890e9fcaa8aSmrg{ 2891862bcd1aSmrg $debug_cmd 2892862bcd1aSmrg 2893e9fcaa8aSmrg if test -z "$4" && test -n "$3"; then 2894e9fcaa8aSmrg func_error "Could not determine the host path corresponding to" 2895862bcd1aSmrg func_error " '$3'" 2896e9fcaa8aSmrg func_error "Continuing, but uninstalled executables may not work." 2897e9fcaa8aSmrg # Fallback. This is a deliberately simplistic "conversion" and 2898e9fcaa8aSmrg # should not be "improved". See libtool.info. 2899e9fcaa8aSmrg if test "x$1" != "x$2"; then 2900e9fcaa8aSmrg lt_replace_pathsep_chars="s|$1|$2|g" 2901e9fcaa8aSmrg func_to_host_path_result=`echo "$3" | 2902e9fcaa8aSmrg $SED -e "$lt_replace_pathsep_chars"` 2903e9fcaa8aSmrg else 2904862bcd1aSmrg func_to_host_path_result=$3 2905e9fcaa8aSmrg fi 2906e9fcaa8aSmrg fi 2907e9fcaa8aSmrg} 2908e9fcaa8aSmrg# end func_convert_path_check 2909e9fcaa8aSmrg 2910e9fcaa8aSmrg 2911e9fcaa8aSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912e9fcaa8aSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913e9fcaa8aSmrg# and appending REPL if ORIG matches BACKPAT. 2914e9fcaa8aSmrgfunc_convert_path_front_back_pathsep () 2915e9fcaa8aSmrg{ 2916862bcd1aSmrg $debug_cmd 2917862bcd1aSmrg 2918e9fcaa8aSmrg case $4 in 2919862bcd1aSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920e9fcaa8aSmrg ;; 2921e9fcaa8aSmrg esac 2922e9fcaa8aSmrg case $4 in 2923e9fcaa8aSmrg $2 ) func_append func_to_host_path_result "$3" 2924e9fcaa8aSmrg ;; 2925e9fcaa8aSmrg esac 2926e9fcaa8aSmrg} 2927e9fcaa8aSmrg# end func_convert_path_front_back_pathsep 2928e9fcaa8aSmrg 2929e9fcaa8aSmrg 2930e9fcaa8aSmrg################################################## 2931e9fcaa8aSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932e9fcaa8aSmrg################################################## 2933862bcd1aSmrg# invoked via '$to_host_file_cmd ARG' 2934e9fcaa8aSmrg# 2935e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format. 2936e9fcaa8aSmrg# Result will be available in $func_to_host_file_result. 2937e9fcaa8aSmrg 2938e9fcaa8aSmrg 2939e9fcaa8aSmrg# func_to_host_file ARG 2940e9fcaa8aSmrg# Converts the file name ARG from $build format to $host format. Return result 2941e9fcaa8aSmrg# in func_to_host_file_result. 2942e9fcaa8aSmrgfunc_to_host_file () 2943e9fcaa8aSmrg{ 2944862bcd1aSmrg $debug_cmd 2945862bcd1aSmrg 2946e9fcaa8aSmrg $to_host_file_cmd "$1" 2947e9fcaa8aSmrg} 2948e9fcaa8aSmrg# end func_to_host_file 2949e9fcaa8aSmrg 2950e9fcaa8aSmrg 2951e9fcaa8aSmrg# func_to_tool_file ARG LAZY 2952e9fcaa8aSmrg# converts the file name ARG from $build format to toolchain format. Return 2953e9fcaa8aSmrg# result in func_to_tool_file_result. If the conversion in use is listed 2954e9fcaa8aSmrg# in (the comma separated) LAZY, no conversion takes place. 2955e9fcaa8aSmrgfunc_to_tool_file () 2956e9fcaa8aSmrg{ 2957862bcd1aSmrg $debug_cmd 2958862bcd1aSmrg 2959e9fcaa8aSmrg case ,$2, in 2960e9fcaa8aSmrg *,"$to_tool_file_cmd",*) 2961e9fcaa8aSmrg func_to_tool_file_result=$1 2962e9fcaa8aSmrg ;; 2963e9fcaa8aSmrg *) 2964e9fcaa8aSmrg $to_tool_file_cmd "$1" 2965e9fcaa8aSmrg func_to_tool_file_result=$func_to_host_file_result 2966e9fcaa8aSmrg ;; 2967e9fcaa8aSmrg esac 2968e9fcaa8aSmrg} 2969e9fcaa8aSmrg# end func_to_tool_file 2970e9fcaa8aSmrg 2971e9fcaa8aSmrg 2972e9fcaa8aSmrg# func_convert_file_noop ARG 2973e9fcaa8aSmrg# Copy ARG to func_to_host_file_result. 2974e9fcaa8aSmrgfunc_convert_file_noop () 2975e9fcaa8aSmrg{ 2976862bcd1aSmrg func_to_host_file_result=$1 2977e9fcaa8aSmrg} 2978e9fcaa8aSmrg# end func_convert_file_noop 2979e9fcaa8aSmrg 2980e9fcaa8aSmrg 2981e9fcaa8aSmrg# func_convert_file_msys_to_w32 ARG 2982e9fcaa8aSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 2984e9fcaa8aSmrg# func_to_host_file_result. 2985e9fcaa8aSmrgfunc_convert_file_msys_to_w32 () 2986e9fcaa8aSmrg{ 2987862bcd1aSmrg $debug_cmd 2988862bcd1aSmrg 2989862bcd1aSmrg func_to_host_file_result=$1 2990e9fcaa8aSmrg if test -n "$1"; then 2991e9fcaa8aSmrg func_convert_core_msys_to_w32 "$1" 2992862bcd1aSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993e9fcaa8aSmrg fi 2994e9fcaa8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 2995e9fcaa8aSmrg} 2996e9fcaa8aSmrg# end func_convert_file_msys_to_w32 2997e9fcaa8aSmrg 2998e9fcaa8aSmrg 2999e9fcaa8aSmrg# func_convert_file_cygwin_to_w32 ARG 3000e9fcaa8aSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3001e9fcaa8aSmrg# func_to_host_file_result. 3002e9fcaa8aSmrgfunc_convert_file_cygwin_to_w32 () 3003e9fcaa8aSmrg{ 3004862bcd1aSmrg $debug_cmd 3005862bcd1aSmrg 3006862bcd1aSmrg func_to_host_file_result=$1 3007e9fcaa8aSmrg if test -n "$1"; then 3008e9fcaa8aSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009e9fcaa8aSmrg # LT_CYGPATH in this case. 3010e9fcaa8aSmrg func_to_host_file_result=`cygpath -m "$1"` 3011e9fcaa8aSmrg fi 3012e9fcaa8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3013e9fcaa8aSmrg} 3014e9fcaa8aSmrg# end func_convert_file_cygwin_to_w32 3015e9fcaa8aSmrg 3016e9fcaa8aSmrg 3017e9fcaa8aSmrg# func_convert_file_nix_to_w32 ARG 3018e9fcaa8aSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019e9fcaa8aSmrg# and a working winepath. Returns result in func_to_host_file_result. 3020e9fcaa8aSmrgfunc_convert_file_nix_to_w32 () 3021e9fcaa8aSmrg{ 3022862bcd1aSmrg $debug_cmd 3023862bcd1aSmrg 3024862bcd1aSmrg func_to_host_file_result=$1 3025e9fcaa8aSmrg if test -n "$1"; then 3026e9fcaa8aSmrg func_convert_core_file_wine_to_w32 "$1" 3027862bcd1aSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028e9fcaa8aSmrg fi 3029e9fcaa8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3030e9fcaa8aSmrg} 3031e9fcaa8aSmrg# end func_convert_file_nix_to_w32 3032e9fcaa8aSmrg 3033e9fcaa8aSmrg 3034e9fcaa8aSmrg# func_convert_file_msys_to_cygwin ARG 3035e9fcaa8aSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036e9fcaa8aSmrg# Returns result in func_to_host_file_result. 3037e9fcaa8aSmrgfunc_convert_file_msys_to_cygwin () 3038e9fcaa8aSmrg{ 3039862bcd1aSmrg $debug_cmd 3040862bcd1aSmrg 3041862bcd1aSmrg func_to_host_file_result=$1 3042e9fcaa8aSmrg if test -n "$1"; then 3043e9fcaa8aSmrg func_convert_core_msys_to_w32 "$1" 3044e9fcaa8aSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045862bcd1aSmrg func_to_host_file_result=$func_cygpath_result 3046e9fcaa8aSmrg fi 3047e9fcaa8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3048e9fcaa8aSmrg} 3049e9fcaa8aSmrg# end func_convert_file_msys_to_cygwin 3050e9fcaa8aSmrg 3051e9fcaa8aSmrg 3052e9fcaa8aSmrg# func_convert_file_nix_to_cygwin ARG 3053e9fcaa8aSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054e9fcaa8aSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055e9fcaa8aSmrg# in func_to_host_file_result. 3056e9fcaa8aSmrgfunc_convert_file_nix_to_cygwin () 3057e9fcaa8aSmrg{ 3058862bcd1aSmrg $debug_cmd 3059862bcd1aSmrg 3060862bcd1aSmrg func_to_host_file_result=$1 3061e9fcaa8aSmrg if test -n "$1"; then 3062e9fcaa8aSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063e9fcaa8aSmrg func_convert_core_file_wine_to_w32 "$1" 3064e9fcaa8aSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065862bcd1aSmrg func_to_host_file_result=$func_cygpath_result 3066e9fcaa8aSmrg fi 3067e9fcaa8aSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3068e9fcaa8aSmrg} 3069e9fcaa8aSmrg# end func_convert_file_nix_to_cygwin 3070e9fcaa8aSmrg 3071e9fcaa8aSmrg 3072e9fcaa8aSmrg############################################# 3073e9fcaa8aSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3074e9fcaa8aSmrg############################################# 3075862bcd1aSmrg# invoked via '$to_host_path_cmd ARG' 3076e9fcaa8aSmrg# 3077e9fcaa8aSmrg# In each case, ARG is the path to be converted from $build to $host format. 3078e9fcaa8aSmrg# The result will be available in $func_to_host_path_result. 3079e9fcaa8aSmrg# 3080e9fcaa8aSmrg# Path separators are also converted from $build format to $host format. If 3081e9fcaa8aSmrg# ARG begins or ends with a path separator character, it is preserved (but 3082e9fcaa8aSmrg# converted to $host format) on output. 3083e9fcaa8aSmrg# 3084e9fcaa8aSmrg# All path conversion functions are named using the following convention: 3085e9fcaa8aSmrg# file name conversion function : func_convert_file_X_to_Y () 3086e9fcaa8aSmrg# path conversion function : func_convert_path_X_to_Y () 3087e9fcaa8aSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3088e9fcaa8aSmrg# same. If conversion functions are added for new $build/$host combinations, 3089e9fcaa8aSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090e9fcaa8aSmrg# will break. 3091e9fcaa8aSmrg 3092e9fcaa8aSmrg 3093e9fcaa8aSmrg# func_init_to_host_path_cmd 3094e9fcaa8aSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095e9fcaa8aSmrg# appropriate value, based on the value of $to_host_file_cmd. 3096e9fcaa8aSmrgto_host_path_cmd= 3097e9fcaa8aSmrgfunc_init_to_host_path_cmd () 3098e9fcaa8aSmrg{ 3099862bcd1aSmrg $debug_cmd 3100862bcd1aSmrg 3101e9fcaa8aSmrg if test -z "$to_host_path_cmd"; then 3102e9fcaa8aSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103862bcd1aSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3104e9fcaa8aSmrg fi 3105e9fcaa8aSmrg} 3106e9fcaa8aSmrg 3107e9fcaa8aSmrg 3108e9fcaa8aSmrg# func_to_host_path ARG 3109e9fcaa8aSmrg# Converts the path ARG from $build format to $host format. Return result 3110e9fcaa8aSmrg# in func_to_host_path_result. 3111e9fcaa8aSmrgfunc_to_host_path () 3112e9fcaa8aSmrg{ 3113862bcd1aSmrg $debug_cmd 3114862bcd1aSmrg 3115e9fcaa8aSmrg func_init_to_host_path_cmd 3116e9fcaa8aSmrg $to_host_path_cmd "$1" 3117e9fcaa8aSmrg} 3118e9fcaa8aSmrg# end func_to_host_path 3119e9fcaa8aSmrg 3120e9fcaa8aSmrg 3121e9fcaa8aSmrg# func_convert_path_noop ARG 3122e9fcaa8aSmrg# Copy ARG to func_to_host_path_result. 3123e9fcaa8aSmrgfunc_convert_path_noop () 3124e9fcaa8aSmrg{ 3125862bcd1aSmrg func_to_host_path_result=$1 3126e9fcaa8aSmrg} 3127e9fcaa8aSmrg# end func_convert_path_noop 3128e9fcaa8aSmrg 3129e9fcaa8aSmrg 3130e9fcaa8aSmrg# func_convert_path_msys_to_w32 ARG 3131e9fcaa8aSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132e9fcaa8aSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3133e9fcaa8aSmrg# func_to_host_path_result. 3134e9fcaa8aSmrgfunc_convert_path_msys_to_w32 () 3135e9fcaa8aSmrg{ 3136862bcd1aSmrg $debug_cmd 3137862bcd1aSmrg 3138862bcd1aSmrg func_to_host_path_result=$1 3139e9fcaa8aSmrg if test -n "$1"; then 3140e9fcaa8aSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3141e9fcaa8aSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142e9fcaa8aSmrg # and winepath ignores them completely. 3143e9fcaa8aSmrg func_stripname : : "$1" 3144e9fcaa8aSmrg func_to_host_path_tmp1=$func_stripname_result 3145e9fcaa8aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146862bcd1aSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147e9fcaa8aSmrg func_convert_path_check : ";" \ 3148e9fcaa8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149e9fcaa8aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150e9fcaa8aSmrg fi 3151e9fcaa8aSmrg} 3152e9fcaa8aSmrg# end func_convert_path_msys_to_w32 3153e9fcaa8aSmrg 3154e9fcaa8aSmrg 3155e9fcaa8aSmrg# func_convert_path_cygwin_to_w32 ARG 3156e9fcaa8aSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3157e9fcaa8aSmrg# func_to_host_file_result. 3158e9fcaa8aSmrgfunc_convert_path_cygwin_to_w32 () 3159e9fcaa8aSmrg{ 3160862bcd1aSmrg $debug_cmd 3161862bcd1aSmrg 3162862bcd1aSmrg func_to_host_path_result=$1 3163e9fcaa8aSmrg if test -n "$1"; then 3164e9fcaa8aSmrg # See func_convert_path_msys_to_w32: 3165e9fcaa8aSmrg func_stripname : : "$1" 3166e9fcaa8aSmrg func_to_host_path_tmp1=$func_stripname_result 3167e9fcaa8aSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168e9fcaa8aSmrg func_convert_path_check : ";" \ 3169e9fcaa8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170e9fcaa8aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171e9fcaa8aSmrg fi 3172e9fcaa8aSmrg} 3173e9fcaa8aSmrg# end func_convert_path_cygwin_to_w32 3174e9fcaa8aSmrg 3175e9fcaa8aSmrg 3176e9fcaa8aSmrg# func_convert_path_nix_to_w32 ARG 3177e9fcaa8aSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178e9fcaa8aSmrg# a working winepath. Returns result in func_to_host_file_result. 3179e9fcaa8aSmrgfunc_convert_path_nix_to_w32 () 3180e9fcaa8aSmrg{ 3181862bcd1aSmrg $debug_cmd 3182862bcd1aSmrg 3183862bcd1aSmrg func_to_host_path_result=$1 3184e9fcaa8aSmrg if test -n "$1"; then 3185e9fcaa8aSmrg # See func_convert_path_msys_to_w32: 3186e9fcaa8aSmrg func_stripname : : "$1" 3187e9fcaa8aSmrg func_to_host_path_tmp1=$func_stripname_result 3188e9fcaa8aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189862bcd1aSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190e9fcaa8aSmrg func_convert_path_check : ";" \ 3191e9fcaa8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192e9fcaa8aSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193e9fcaa8aSmrg fi 3194e9fcaa8aSmrg} 3195e9fcaa8aSmrg# end func_convert_path_nix_to_w32 3196e9fcaa8aSmrg 3197e9fcaa8aSmrg 3198e9fcaa8aSmrg# func_convert_path_msys_to_cygwin ARG 3199e9fcaa8aSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200e9fcaa8aSmrg# Returns result in func_to_host_file_result. 3201e9fcaa8aSmrgfunc_convert_path_msys_to_cygwin () 3202e9fcaa8aSmrg{ 3203862bcd1aSmrg $debug_cmd 3204862bcd1aSmrg 3205862bcd1aSmrg func_to_host_path_result=$1 3206e9fcaa8aSmrg if test -n "$1"; then 3207e9fcaa8aSmrg # See func_convert_path_msys_to_w32: 3208e9fcaa8aSmrg func_stripname : : "$1" 3209e9fcaa8aSmrg func_to_host_path_tmp1=$func_stripname_result 3210e9fcaa8aSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211e9fcaa8aSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212862bcd1aSmrg func_to_host_path_result=$func_cygpath_result 3213e9fcaa8aSmrg func_convert_path_check : : \ 3214e9fcaa8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215e9fcaa8aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216e9fcaa8aSmrg fi 3217e9fcaa8aSmrg} 3218e9fcaa8aSmrg# end func_convert_path_msys_to_cygwin 3219e9fcaa8aSmrg 3220e9fcaa8aSmrg 3221e9fcaa8aSmrg# func_convert_path_nix_to_cygwin ARG 3222e9fcaa8aSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223e9fcaa8aSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224e9fcaa8aSmrg# func_to_host_file_result. 3225e9fcaa8aSmrgfunc_convert_path_nix_to_cygwin () 3226e9fcaa8aSmrg{ 3227862bcd1aSmrg $debug_cmd 3228862bcd1aSmrg 3229862bcd1aSmrg func_to_host_path_result=$1 3230e9fcaa8aSmrg if test -n "$1"; then 3231e9fcaa8aSmrg # Remove leading and trailing path separator characters from 3232e9fcaa8aSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3233e9fcaa8aSmrg # into '.;' and ';.', and winepath ignores them completely. 3234e9fcaa8aSmrg func_stripname : : "$1" 3235e9fcaa8aSmrg func_to_host_path_tmp1=$func_stripname_result 3236e9fcaa8aSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237e9fcaa8aSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238862bcd1aSmrg func_to_host_path_result=$func_cygpath_result 3239e9fcaa8aSmrg func_convert_path_check : : \ 3240e9fcaa8aSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241e9fcaa8aSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242e9fcaa8aSmrg fi 3243e9fcaa8aSmrg} 3244e9fcaa8aSmrg# end func_convert_path_nix_to_cygwin 3245e9fcaa8aSmrg 3246e9fcaa8aSmrg 3247862bcd1aSmrg# func_dll_def_p FILE 3248862bcd1aSmrg# True iff FILE is a Windows DLL '.def' file. 3249862bcd1aSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250862bcd1aSmrgfunc_dll_def_p () 3251862bcd1aSmrg{ 3252862bcd1aSmrg $debug_cmd 3253862bcd1aSmrg 3254862bcd1aSmrg func_dll_def_p_tmp=`$SED -n \ 3255862bcd1aSmrg -e 's/^[ ]*//' \ 3256862bcd1aSmrg -e '/^\(;.*\)*$/d' \ 3257862bcd1aSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258862bcd1aSmrg -e q \ 3259862bcd1aSmrg "$1"` 3260862bcd1aSmrg test DEF = "$func_dll_def_p_tmp" 3261862bcd1aSmrg} 3262862bcd1aSmrg 3263862bcd1aSmrg 326488de56ccSmrg# func_mode_compile arg... 326588de56ccSmrgfunc_mode_compile () 326688de56ccSmrg{ 3267862bcd1aSmrg $debug_cmd 3268862bcd1aSmrg 326988de56ccSmrg # Get the compilation command and the source file. 327088de56ccSmrg base_compile= 3271862bcd1aSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 327288de56ccSmrg suppress_opt=yes 327388de56ccSmrg suppress_output= 327488de56ccSmrg arg_mode=normal 327588de56ccSmrg libobj= 327688de56ccSmrg later= 327788de56ccSmrg pie_flag= 327888de56ccSmrg 327988de56ccSmrg for arg 328088de56ccSmrg do 328188de56ccSmrg case $arg_mode in 328288de56ccSmrg arg ) 328388de56ccSmrg # do not "continue". Instead, add this to base_compile 3284862bcd1aSmrg lastarg=$arg 328588de56ccSmrg arg_mode=normal 328688de56ccSmrg ;; 328788de56ccSmrg 328888de56ccSmrg target ) 3289862bcd1aSmrg libobj=$arg 329088de56ccSmrg arg_mode=normal 329188de56ccSmrg continue 329288de56ccSmrg ;; 329388de56ccSmrg 329488de56ccSmrg normal ) 329588de56ccSmrg # Accept any command-line options. 329688de56ccSmrg case $arg in 329788de56ccSmrg -o) 329888de56ccSmrg test -n "$libobj" && \ 3299862bcd1aSmrg func_fatal_error "you cannot specify '-o' more than once" 330088de56ccSmrg arg_mode=target 330188de56ccSmrg continue 330288de56ccSmrg ;; 330388de56ccSmrg 330488de56ccSmrg -pie | -fpie | -fPIE) 3305e9fcaa8aSmrg func_append pie_flag " $arg" 330688de56ccSmrg continue 330788de56ccSmrg ;; 330888de56ccSmrg 330988de56ccSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 3310e9fcaa8aSmrg func_append later " $arg" 331188de56ccSmrg continue 331288de56ccSmrg ;; 331388de56ccSmrg 331488de56ccSmrg -no-suppress) 33151ab64890Smrg suppress_opt=no 33161ab64890Smrg continue 33171ab64890Smrg ;; 33181ab64890Smrg 33191ab64890Smrg -Xcompiler) 33201ab64890Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 33211ab64890Smrg continue # The current "srcfile" will either be retained or 33221ab64890Smrg ;; # replaced later. I would guess that would be a bug. 33231ab64890Smrg 33241ab64890Smrg -Wc,*) 332588de56ccSmrg func_stripname '-Wc,' '' "$arg" 332688de56ccSmrg args=$func_stripname_result 33271ab64890Smrg lastarg= 3328862bcd1aSmrg save_ifs=$IFS; IFS=, 332988de56ccSmrg for arg in $args; do 3330862bcd1aSmrg IFS=$save_ifs 3331e9fcaa8aSmrg func_append_quoted lastarg "$arg" 33321ab64890Smrg done 3333862bcd1aSmrg IFS=$save_ifs 333488de56ccSmrg func_stripname ' ' '' "$lastarg" 333588de56ccSmrg lastarg=$func_stripname_result 33361ab64890Smrg 33371ab64890Smrg # Add the arguments to base_compile. 3338e9fcaa8aSmrg func_append base_compile " $lastarg" 33391ab64890Smrg continue 33401ab64890Smrg ;; 33411ab64890Smrg 334288de56ccSmrg *) 33431ab64890Smrg # Accept the current argument as the source file. 33441ab64890Smrg # The previous "srcfile" becomes the current argument. 33451ab64890Smrg # 3346862bcd1aSmrg lastarg=$srcfile 3347862bcd1aSmrg srcfile=$arg 33481ab64890Smrg ;; 33491ab64890Smrg esac # case $arg 33501ab64890Smrg ;; 33511ab64890Smrg esac # case $arg_mode 33521ab64890Smrg 33531ab64890Smrg # Aesthetically quote the previous argument. 3354e9fcaa8aSmrg func_append_quoted base_compile "$lastarg" 33551ab64890Smrg done # for arg 33561ab64890Smrg 33571ab64890Smrg case $arg_mode in 33581ab64890Smrg arg) 335988de56ccSmrg func_fatal_error "you must specify an argument for -Xcompile" 33601ab64890Smrg ;; 33611ab64890Smrg target) 3362862bcd1aSmrg func_fatal_error "you must specify a target with '-o'" 33631ab64890Smrg ;; 33641ab64890Smrg *) 33651ab64890Smrg # Get the name of the library object. 336688de56ccSmrg test -z "$libobj" && { 336788de56ccSmrg func_basename "$srcfile" 3368862bcd1aSmrg libobj=$func_basename_result 336988de56ccSmrg } 33701ab64890Smrg ;; 33711ab64890Smrg esac 33721ab64890Smrg 33731ab64890Smrg # Recognize several different file suffixes. 33741ab64890Smrg # If the user specifies -o file.o, it is replaced with file.lo 33751ab64890Smrg case $libobj in 337688de56ccSmrg *.[cCFSifmso] | \ 337788de56ccSmrg *.ada | *.adb | *.ads | *.asm | \ 337888de56ccSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379eb411b4bSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 338088de56ccSmrg func_xform "$libobj" 338188de56ccSmrg libobj=$func_xform_result 338288de56ccSmrg ;; 33831ab64890Smrg esac 33841ab64890Smrg 33851ab64890Smrg case $libobj in 338688de56ccSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 33871ab64890Smrg *) 3388862bcd1aSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 33891ab64890Smrg ;; 33901ab64890Smrg esac 33911ab64890Smrg 33921ab64890Smrg func_infer_tag $base_compile 33931ab64890Smrg 33941ab64890Smrg for arg in $later; do 33951ab64890Smrg case $arg in 339688de56ccSmrg -shared) 3397862bcd1aSmrg test yes = "$build_libtool_libs" \ 3398862bcd1aSmrg || func_fatal_configuration "cannot build a shared library" 339988de56ccSmrg build_old_libs=no 340088de56ccSmrg continue 340188de56ccSmrg ;; 340288de56ccSmrg 34031ab64890Smrg -static) 340488de56ccSmrg build_libtool_libs=no 34051ab64890Smrg build_old_libs=yes 34061ab64890Smrg continue 34071ab64890Smrg ;; 34081ab64890Smrg 34091ab64890Smrg -prefer-pic) 34101ab64890Smrg pic_mode=yes 34111ab64890Smrg continue 34121ab64890Smrg ;; 34131ab64890Smrg 34141ab64890Smrg -prefer-non-pic) 34151ab64890Smrg pic_mode=no 34161ab64890Smrg continue 34171ab64890Smrg ;; 34181ab64890Smrg esac 34191ab64890Smrg done 34201ab64890Smrg 342188de56ccSmrg func_quote_for_eval "$libobj" 342288de56ccSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 342388de56ccSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424862bcd1aSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 342588de56ccSmrg func_dirname_and_basename "$obj" "/" "" 3426862bcd1aSmrg objname=$func_basename_result 3427862bcd1aSmrg xdir=$func_dirname_result 3428862bcd1aSmrg lobj=$xdir$objdir/$objname 34291ab64890Smrg 343088de56ccSmrg test -z "$base_compile" && \ 343188de56ccSmrg func_fatal_help "you must specify a compilation command" 34321ab64890Smrg 34331ab64890Smrg # Delete any leftover library objects. 3434862bcd1aSmrg if test yes = "$build_old_libs"; then 34351ab64890Smrg removelist="$obj $lobj $libobj ${libobj}T" 34361ab64890Smrg else 34371ab64890Smrg removelist="$lobj $libobj ${libobj}T" 34381ab64890Smrg fi 34391ab64890Smrg 34401ab64890Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 34411ab64890Smrg case $host_os in 344288de56ccSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 34431ab64890Smrg pic_mode=default 34441ab64890Smrg ;; 34451ab64890Smrg esac 3446862bcd1aSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 34471ab64890Smrg # non-PIC code in shared libraries is not supported 34481ab64890Smrg pic_mode=default 34491ab64890Smrg fi 34501ab64890Smrg 34511ab64890Smrg # Calculate the filename of the output object if compiler does 34521ab64890Smrg # not support -o with -c 3453862bcd1aSmrg if test no = "$compiler_c_o"; then 3454862bcd1aSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455862bcd1aSmrg lockfile=$output_obj.lock 34561ab64890Smrg else 34571ab64890Smrg output_obj= 34581ab64890Smrg need_locks=no 34591ab64890Smrg lockfile= 34601ab64890Smrg fi 34611ab64890Smrg 34621ab64890Smrg # Lock this critical section if it is needed 34631ab64890Smrg # We use this script file to make the link, it avoids creating a new file 3464862bcd1aSmrg if test yes = "$need_locks"; then 346588de56ccSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 346688de56ccSmrg func_echo "Waiting for $lockfile to be removed" 34671ab64890Smrg sleep 2 34681ab64890Smrg done 3469862bcd1aSmrg elif test warn = "$need_locks"; then 34701ab64890Smrg if test -f "$lockfile"; then 347188de56ccSmrg $ECHO "\ 34721ab64890Smrg*** ERROR, $lockfile exists and contains: 34731ab64890Smrg`cat $lockfile 2>/dev/null` 34741ab64890Smrg 34751ab64890SmrgThis indicates that another process is trying to use the same 34761ab64890Smrgtemporary object file, and libtool could not work around it because 3477862bcd1aSmrgyour compiler does not support '-c' and '-o' together. If you 34781ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better 34791ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better 34801ab64890Smrgcompiler." 34811ab64890Smrg 348288de56ccSmrg $opt_dry_run || $RM $removelist 34831ab64890Smrg exit $EXIT_FAILURE 34841ab64890Smrg fi 3485e9fcaa8aSmrg func_append removelist " $output_obj" 348688de56ccSmrg $ECHO "$srcfile" > "$lockfile" 34871ab64890Smrg fi 34881ab64890Smrg 348988de56ccSmrg $opt_dry_run || $RM $removelist 3490e9fcaa8aSmrg func_append removelist " $lockfile" 349188de56ccSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 349288de56ccSmrg 3493e9fcaa8aSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494e9fcaa8aSmrg srcfile=$func_to_tool_file_result 349588de56ccSmrg func_quote_for_eval "$srcfile" 349688de56ccSmrg qsrcfile=$func_quote_for_eval_result 34971ab64890Smrg 34981ab64890Smrg # Only build a PIC object if we are building libtool libraries. 3499862bcd1aSmrg if test yes = "$build_libtool_libs"; then 35001ab64890Smrg # Without this assignment, base_compile gets emptied. 35011ab64890Smrg fbsd_hideous_sh_bug=$base_compile 35021ab64890Smrg 3503862bcd1aSmrg if test no != "$pic_mode"; then 35041ab64890Smrg command="$base_compile $qsrcfile $pic_flag" 35051ab64890Smrg else 35061ab64890Smrg # Don't build PIC code 35071ab64890Smrg command="$base_compile $qsrcfile" 35081ab64890Smrg fi 35091ab64890Smrg 351088de56ccSmrg func_mkdir_p "$xdir$objdir" 35111ab64890Smrg 35121ab64890Smrg if test -z "$output_obj"; then 35131ab64890Smrg # Place PIC objects in $objdir 3514e9fcaa8aSmrg func_append command " -o $lobj" 35151ab64890Smrg fi 35161ab64890Smrg 351788de56ccSmrg func_show_eval_locale "$command" \ 351888de56ccSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 35191ab64890Smrg 3520862bcd1aSmrg if test warn = "$need_locks" && 35211ab64890Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 352288de56ccSmrg $ECHO "\ 35231ab64890Smrg*** ERROR, $lockfile contains: 35241ab64890Smrg`cat $lockfile 2>/dev/null` 35251ab64890Smrg 35261ab64890Smrgbut it should contain: 35271ab64890Smrg$srcfile 35281ab64890Smrg 35291ab64890SmrgThis indicates that another process is trying to use the same 35301ab64890Smrgtemporary object file, and libtool could not work around it because 3531862bcd1aSmrgyour compiler does not support '-c' and '-o' together. If you 35321ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better 35331ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better 35341ab64890Smrgcompiler." 35351ab64890Smrg 353688de56ccSmrg $opt_dry_run || $RM $removelist 35371ab64890Smrg exit $EXIT_FAILURE 35381ab64890Smrg fi 35391ab64890Smrg 35401ab64890Smrg # Just move the object if needed, then go on to compile the next one 35411ab64890Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 354288de56ccSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 354388de56ccSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 35441ab64890Smrg fi 35451ab64890Smrg 35461ab64890Smrg # Allow error messages only from the first compilation. 3547862bcd1aSmrg if test yes = "$suppress_opt"; then 354888de56ccSmrg suppress_output=' >/dev/null 2>&1' 35491ab64890Smrg fi 35501ab64890Smrg fi 35511ab64890Smrg 35521ab64890Smrg # Only build a position-dependent object if we build old libraries. 3553862bcd1aSmrg if test yes = "$build_old_libs"; then 3554862bcd1aSmrg if test yes != "$pic_mode"; then 35551ab64890Smrg # Don't build PIC code 355688de56ccSmrg command="$base_compile $qsrcfile$pie_flag" 35571ab64890Smrg else 35581ab64890Smrg command="$base_compile $qsrcfile $pic_flag" 35591ab64890Smrg fi 3560862bcd1aSmrg if test yes = "$compiler_c_o"; then 3561e9fcaa8aSmrg func_append command " -o $obj" 35621ab64890Smrg fi 35631ab64890Smrg 35641ab64890Smrg # Suppress compiler output if we already did a PIC compilation. 3565e9fcaa8aSmrg func_append command "$suppress_output" 356688de56ccSmrg func_show_eval_locale "$command" \ 356788de56ccSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 35681ab64890Smrg 3569862bcd1aSmrg if test warn = "$need_locks" && 35701ab64890Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 357188de56ccSmrg $ECHO "\ 35721ab64890Smrg*** ERROR, $lockfile contains: 35731ab64890Smrg`cat $lockfile 2>/dev/null` 35741ab64890Smrg 35751ab64890Smrgbut it should contain: 35761ab64890Smrg$srcfile 35771ab64890Smrg 35781ab64890SmrgThis indicates that another process is trying to use the same 35791ab64890Smrgtemporary object file, and libtool could not work around it because 3580862bcd1aSmrgyour compiler does not support '-c' and '-o' together. If you 35811ab64890Smrgrepeat this compilation, it may succeed, by chance, but you had better 35821ab64890Smrgavoid parallel builds (make -j) in this platform, or get a better 35831ab64890Smrgcompiler." 35841ab64890Smrg 358588de56ccSmrg $opt_dry_run || $RM $removelist 35861ab64890Smrg exit $EXIT_FAILURE 35871ab64890Smrg fi 35881ab64890Smrg 35891ab64890Smrg # Just move the object if needed 35901ab64890Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 359188de56ccSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 359288de56ccSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 35931ab64890Smrg fi 35941ab64890Smrg fi 35951ab64890Smrg 359688de56ccSmrg $opt_dry_run || { 359788de56ccSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 35981ab64890Smrg 359988de56ccSmrg # Unlock the critical section if it was locked 3600862bcd1aSmrg if test no != "$need_locks"; then 360188de56ccSmrg removelist=$lockfile 360288de56ccSmrg $RM "$lockfile" 360388de56ccSmrg fi 360488de56ccSmrg } 36051ab64890Smrg 36061ab64890Smrg exit $EXIT_SUCCESS 360788de56ccSmrg} 36081ab64890Smrg 360988de56ccSmrg$opt_help || { 3610862bcd1aSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 361188de56ccSmrg} 36121ab64890Smrg 361388de56ccSmrgfunc_mode_help () 361488de56ccSmrg{ 361588de56ccSmrg # We need to display help for each of the modes. 3616e9fcaa8aSmrg case $opt_mode in 361788de56ccSmrg "") 361888de56ccSmrg # Generic help is extracted from the usage comments 361988de56ccSmrg # at the start of this file. 362088de56ccSmrg func_help 362188de56ccSmrg ;; 36221ab64890Smrg 362388de56ccSmrg clean) 362488de56ccSmrg $ECHO \ 362588de56ccSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 36261ab64890Smrg 362788de56ccSmrgRemove files from the build directory. 36281ab64890Smrg 362988de56ccSmrgRM is the name of the program to use to delete files associated with each FILE 3630862bcd1aSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 363188de56ccSmrgto RM. 36321ab64890Smrg 363388de56ccSmrgIf FILE is a libtool library, object or program, all the files associated 363488de56ccSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 363588de56ccSmrg ;; 36361ab64890Smrg 363788de56ccSmrg compile) 363888de56ccSmrg $ECHO \ 363988de56ccSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 36401ab64890Smrg 364188de56ccSmrgCompile a source file into a libtool library object. 36421ab64890Smrg 364388de56ccSmrgThis mode accepts the following additional options: 36441ab64890Smrg 364588de56ccSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 364688de56ccSmrg -no-suppress do not suppress compiler output for multiple passes 3647e9fcaa8aSmrg -prefer-pic try to build PIC objects only 3648e9fcaa8aSmrg -prefer-non-pic try to build non-PIC objects only 3649862bcd1aSmrg -shared do not build a '.o' file suitable for static linking 3650862bcd1aSmrg -static only build a '.o' file suitable for static linking 3651e9fcaa8aSmrg -Wc,FLAG pass FLAG directly to the compiler 36521ab64890Smrg 3653862bcd1aSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 365488de56ccSmrgfrom the given SOURCEFILE. 36551ab64890Smrg 365688de56ccSmrgThe output file name is determined by removing the directory component from 3657862bcd1aSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3658862bcd1aSmrglibrary object suffix, '.lo'." 365988de56ccSmrg ;; 36601ab64890Smrg 366188de56ccSmrg execute) 366288de56ccSmrg $ECHO \ 366388de56ccSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 36641ab64890Smrg 366588de56ccSmrgAutomatically set library path, then run a program. 36661ab64890Smrg 366788de56ccSmrgThis mode accepts the following additional options: 36681ab64890Smrg 366988de56ccSmrg -dlopen FILE add the directory containing FILE to the library path 36701ab64890Smrg 3671862bcd1aSmrgThis mode sets the library path environment variable according to '-dlopen' 367288de56ccSmrgflags. 36731ab64890Smrg 367488de56ccSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 367588de56ccSmrginto their corresponding uninstalled binary, and any of their required library 367688de56ccSmrgdirectories are added to the library path. 36771ab64890Smrg 367888de56ccSmrgThen, COMMAND is executed, with ARGS as arguments." 367988de56ccSmrg ;; 36801ab64890Smrg 368188de56ccSmrg finish) 368288de56ccSmrg $ECHO \ 368388de56ccSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 36841ab64890Smrg 368588de56ccSmrgComplete the installation of libtool libraries. 36861ab64890Smrg 368788de56ccSmrgEach LIBDIR is a directory that contains libtool libraries. 36881ab64890Smrg 368988de56ccSmrgThe commands that this mode executes may require superuser privileges. Use 3690862bcd1aSmrgthe '--dry-run' option if you just want to see what would be executed." 369188de56ccSmrg ;; 36921ab64890Smrg 369388de56ccSmrg install) 369488de56ccSmrg $ECHO \ 369588de56ccSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 36961ab64890Smrg 369788de56ccSmrgInstall executables or libraries. 36981ab64890Smrg 369988de56ccSmrgINSTALL-COMMAND is the installation command. The first component should be 3700862bcd1aSmrgeither the 'install' or 'cp' program. 37011ab64890Smrg 370288de56ccSmrgThe following components of INSTALL-COMMAND are treated specially: 37031ab64890Smrg 3704e9fcaa8aSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 37051ab64890Smrg 370688de56ccSmrgThe rest of the components are interpreted as arguments to that command (only 370788de56ccSmrgBSD-compatible install options are recognized)." 370888de56ccSmrg ;; 37091ab64890Smrg 371088de56ccSmrg link) 371188de56ccSmrg $ECHO \ 371288de56ccSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 37131ab64890Smrg 371488de56ccSmrgLink object files or libraries together to form another library, or to 371588de56ccSmrgcreate an executable program. 37161ab64890Smrg 371788de56ccSmrgLINK-COMMAND is a command using the C compiler that you would use to create 371888de56ccSmrga program from several object files. 37191ab64890Smrg 372088de56ccSmrgThe following components of LINK-COMMAND are treated specially: 37211ab64890Smrg 372288de56ccSmrg -all-static do not do any dynamic linking at all 372388de56ccSmrg -avoid-version do not add a version suffix if possible 3724e9fcaa8aSmrg -bindir BINDIR specify path to binaries directory (for systems where 3725e9fcaa8aSmrg libraries must be found in the PATH setting at runtime) 3726862bcd1aSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 372788de56ccSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 372888de56ccSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 372988de56ccSmrg -export-symbols SYMFILE 373088de56ccSmrg try to export only the symbols listed in SYMFILE 373188de56ccSmrg -export-symbols-regex REGEX 373288de56ccSmrg try to export only the symbols matching REGEX 373388de56ccSmrg -LLIBDIR search LIBDIR for required installed libraries 373488de56ccSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 373588de56ccSmrg -module build a library that can dlopened 373688de56ccSmrg -no-fast-install disable the fast-install mode 373788de56ccSmrg -no-install link a not-installable executable 373888de56ccSmrg -no-undefined declare that a library does not refer to external symbols 373988de56ccSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740862bcd1aSmrg -objectlist FILE use a list of object files found in FILE to specify objects 3741862bcd1aSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 374288de56ccSmrg -precious-files-regex REGEX 374388de56ccSmrg don't remove output files matching REGEX 374488de56ccSmrg -release RELEASE specify package release information 374588de56ccSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 374688de56ccSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 374788de56ccSmrg -shared only do dynamic linking of libtool libraries 374888de56ccSmrg -shrext SUFFIX override the standard shared library file extension 374988de56ccSmrg -static do not do any dynamic linking of uninstalled libtool libraries 375088de56ccSmrg -static-libtool-libs 375188de56ccSmrg do not do any dynamic linking of libtool libraries 375288de56ccSmrg -version-info CURRENT[:REVISION[:AGE]] 375388de56ccSmrg specify library version info [each variable defaults to 0] 375488de56ccSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 3755e9fcaa8aSmrg -Wc,FLAG 3756e9fcaa8aSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757e9fcaa8aSmrg -Wl,FLAG 3758e9fcaa8aSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759e9fcaa8aSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 37601ab64890Smrg 3761862bcd1aSmrgAll other options (arguments beginning with '-') are ignored. 37621ab64890Smrg 3763862bcd1aSmrgEvery other argument is treated as a filename. Files ending in '.la' are 376488de56ccSmrgtreated as uninstalled libtool libraries, other files are standard or library 376588de56ccSmrgobject files. 37661ab64890Smrg 3767862bcd1aSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768862bcd1aSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 376988de56ccSmrgrequired, except when creating a convenience library. 37701ab64890Smrg 3771862bcd1aSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772862bcd1aSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 37731ab64890Smrg 3774862bcd1aSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 377588de56ccSmrgis created, otherwise an executable program is created." 3776b4ee4795Smrg ;; 37771ab64890Smrg 377888de56ccSmrg uninstall) 377988de56ccSmrg $ECHO \ 378088de56ccSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 37811ab64890Smrg 378288de56ccSmrgRemove libraries from an installation directory. 37831ab64890Smrg 378488de56ccSmrgRM is the name of the program to use to delete files associated with each FILE 3785862bcd1aSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 378688de56ccSmrgto RM. 37872e9c7c8cSmrg 378888de56ccSmrgIf FILE is a libtool library, all the files associated with it are deleted. 378988de56ccSmrgOtherwise, only FILE itself is deleted using RM." 379088de56ccSmrg ;; 37912e9c7c8cSmrg 379288de56ccSmrg *) 3793862bcd1aSmrg func_fatal_help "invalid operation mode '$opt_mode'" 379488de56ccSmrg ;; 379588de56ccSmrg esac 37962e9c7c8cSmrg 3797e9fcaa8aSmrg echo 3798862bcd1aSmrg $ECHO "Try '$progname --help' for more information about other modes." 379988de56ccSmrg} 38002e9c7c8cSmrg 3801e9fcaa8aSmrg# Now that we've collected a possible --mode arg, show help if necessary 3802e9fcaa8aSmrgif $opt_help; then 3803862bcd1aSmrg if test : = "$opt_help"; then 3804e9fcaa8aSmrg func_mode_help 3805e9fcaa8aSmrg else 3806e9fcaa8aSmrg { 3807e9fcaa8aSmrg func_help noexit 3808e9fcaa8aSmrg for opt_mode in compile link execute install finish uninstall clean; do 3809e9fcaa8aSmrg func_mode_help 3810e9fcaa8aSmrg done 3811862bcd1aSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812e9fcaa8aSmrg { 3813e9fcaa8aSmrg func_help noexit 3814e9fcaa8aSmrg for opt_mode in compile link execute install finish uninstall clean; do 3815e9fcaa8aSmrg echo 3816e9fcaa8aSmrg func_mode_help 3817e9fcaa8aSmrg done 3818e9fcaa8aSmrg } | 3819862bcd1aSmrg $SED '1d 3820e9fcaa8aSmrg /^When reporting/,/^Report/{ 3821e9fcaa8aSmrg H 3822e9fcaa8aSmrg d 3823e9fcaa8aSmrg } 3824e9fcaa8aSmrg $x 3825e9fcaa8aSmrg /information about other modes/d 3826e9fcaa8aSmrg /more detailed .*MODE/d 3827e9fcaa8aSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828e9fcaa8aSmrg fi 3829e9fcaa8aSmrg exit $? 3830e9fcaa8aSmrgfi 38312e9c7c8cSmrg 38322e9c7c8cSmrg 383388de56ccSmrg# func_mode_execute arg... 383488de56ccSmrgfunc_mode_execute () 383588de56ccSmrg{ 3836862bcd1aSmrg $debug_cmd 3837862bcd1aSmrg 383888de56ccSmrg # The first argument is the command name. 3839862bcd1aSmrg cmd=$nonopt 384088de56ccSmrg test -z "$cmd" && \ 384188de56ccSmrg func_fatal_help "you must specify a COMMAND" 3842b4ee4795Smrg 384388de56ccSmrg # Handle -dlopen flags immediately. 3844e9fcaa8aSmrg for file in $opt_dlopen; do 384588de56ccSmrg test -f "$file" \ 3846862bcd1aSmrg || func_fatal_help "'$file' is not a file" 3847b4ee4795Smrg 384888de56ccSmrg dir= 384988de56ccSmrg case $file in 385088de56ccSmrg *.la) 3851e9fcaa8aSmrg func_resolve_sysroot "$file" 3852e9fcaa8aSmrg file=$func_resolve_sysroot_result 3853e9fcaa8aSmrg 385488de56ccSmrg # Check to see that this really is a libtool archive. 385588de56ccSmrg func_lalib_unsafe_p "$file" \ 3856862bcd1aSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857b4ee4795Smrg 385888de56ccSmrg # Read the libtool library. 385988de56ccSmrg dlname= 386088de56ccSmrg library_names= 386188de56ccSmrg func_source "$file" 38621ab64890Smrg 386388de56ccSmrg # Skip this library if it cannot be dlopened. 386488de56ccSmrg if test -z "$dlname"; then 386588de56ccSmrg # Warn if it was a shared library. 386688de56ccSmrg test -n "$library_names" && \ 3867862bcd1aSmrg func_warning "'$file' was not linked with '-export-dynamic'" 386888de56ccSmrg continue 386988de56ccSmrg fi 38701ab64890Smrg 387188de56ccSmrg func_dirname "$file" "" "." 3872862bcd1aSmrg dir=$func_dirname_result 38731ab64890Smrg 387488de56ccSmrg if test -f "$dir/$objdir/$dlname"; then 3875e9fcaa8aSmrg func_append dir "/$objdir" 387688de56ccSmrg else 387788de56ccSmrg if test ! -f "$dir/$dlname"; then 3878862bcd1aSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 387988de56ccSmrg fi 388088de56ccSmrg fi 3881b4ee4795Smrg ;; 38821ab64890Smrg 388388de56ccSmrg *.lo) 388488de56ccSmrg # Just add the directory containing the .lo file. 388588de56ccSmrg func_dirname "$file" "" "." 3886862bcd1aSmrg dir=$func_dirname_result 3887b4ee4795Smrg ;; 38881ab64890Smrg 388988de56ccSmrg *) 3890862bcd1aSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891b4ee4795Smrg continue 3892b4ee4795Smrg ;; 389388de56ccSmrg esac 38941ab64890Smrg 389588de56ccSmrg # Get the absolute pathname. 389688de56ccSmrg absdir=`cd "$dir" && pwd` 3897862bcd1aSmrg test -n "$absdir" && dir=$absdir 38982e9c7c8cSmrg 389988de56ccSmrg # Now add the directory to shlibpath_var. 390088de56ccSmrg if eval "test -z \"\$$shlibpath_var\""; then 390188de56ccSmrg eval "$shlibpath_var=\"\$dir\"" 390288de56ccSmrg else 390388de56ccSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 390488de56ccSmrg fi 390588de56ccSmrg done 39062e9c7c8cSmrg 390788de56ccSmrg # This variable tells wrapper scripts just to set shlibpath_var 390888de56ccSmrg # rather than running their programs. 3909862bcd1aSmrg libtool_execute_magic=$magic 39102e9c7c8cSmrg 391188de56ccSmrg # Check if any of the arguments is a wrapper script. 391288de56ccSmrg args= 391388de56ccSmrg for file 391488de56ccSmrg do 391588de56ccSmrg case $file in 3916e9fcaa8aSmrg -* | *.la | *.lo ) ;; 391788de56ccSmrg *) 391888de56ccSmrg # Do a test to see if this is really a libtool program. 391988de56ccSmrg if func_ltwrapper_script_p "$file"; then 392088de56ccSmrg func_source "$file" 392188de56ccSmrg # Transform arg to wrapped name. 3922862bcd1aSmrg file=$progdir/$program 392388de56ccSmrg elif func_ltwrapper_executable_p "$file"; then 392488de56ccSmrg func_ltwrapper_scriptname "$file" 392588de56ccSmrg func_source "$func_ltwrapper_scriptname_result" 392688de56ccSmrg # Transform arg to wrapped name. 3927862bcd1aSmrg file=$progdir/$program 392888de56ccSmrg fi 392988de56ccSmrg ;; 393088de56ccSmrg esac 393188de56ccSmrg # Quote arguments (to preserve shell metacharacters). 3932e9fcaa8aSmrg func_append_quoted args "$file" 393388de56ccSmrg done 39342e9c7c8cSmrg 3935862bcd1aSmrg if $opt_dry_run; then 3936862bcd1aSmrg # Display what would be done. 3937862bcd1aSmrg if test -n "$shlibpath_var"; then 3938862bcd1aSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939862bcd1aSmrg echo "export $shlibpath_var" 3940862bcd1aSmrg fi 3941862bcd1aSmrg $ECHO "$cmd$args" 3942862bcd1aSmrg exit $EXIT_SUCCESS 3943862bcd1aSmrg else 394488de56ccSmrg if test -n "$shlibpath_var"; then 394588de56ccSmrg # Export the shlibpath_var. 394688de56ccSmrg eval "export $shlibpath_var" 394788de56ccSmrg fi 39482e9c7c8cSmrg 394988de56ccSmrg # Restore saved environment variables 395088de56ccSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 395188de56ccSmrg do 395288de56ccSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 395388de56ccSmrg $lt_var=\$save_$lt_var; export $lt_var 3954b4ee4795Smrg else 395588de56ccSmrg $lt_unset $lt_var 395688de56ccSmrg fi" 395788de56ccSmrg done 39582e9c7c8cSmrg 395988de56ccSmrg # Now prepare to actually exec the command. 3960862bcd1aSmrg exec_cmd=\$cmd$args 396188de56ccSmrg fi 396288de56ccSmrg} 39632e9c7c8cSmrg 3964862bcd1aSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 39652e9c7c8cSmrg 3966b4ee4795Smrg 396788de56ccSmrg# func_mode_finish arg... 396888de56ccSmrgfunc_mode_finish () 396988de56ccSmrg{ 3970862bcd1aSmrg $debug_cmd 3971862bcd1aSmrg 3972e9fcaa8aSmrg libs= 3973e9fcaa8aSmrg libdirs= 397488de56ccSmrg admincmds= 39751ab64890Smrg 3976e9fcaa8aSmrg for opt in "$nonopt" ${1+"$@"} 3977e9fcaa8aSmrg do 3978e9fcaa8aSmrg if test -d "$opt"; then 3979e9fcaa8aSmrg func_append libdirs " $opt" 3980e9fcaa8aSmrg 3981e9fcaa8aSmrg elif test -f "$opt"; then 3982e9fcaa8aSmrg if func_lalib_unsafe_p "$opt"; then 3983e9fcaa8aSmrg func_append libs " $opt" 3984e9fcaa8aSmrg else 3985862bcd1aSmrg func_warning "'$opt' is not a valid libtool archive" 3986e9fcaa8aSmrg fi 3987e9fcaa8aSmrg 3988e9fcaa8aSmrg else 3989862bcd1aSmrg func_fatal_error "invalid argument '$opt'" 3990e9fcaa8aSmrg fi 3991e9fcaa8aSmrg done 3992e9fcaa8aSmrg 3993e9fcaa8aSmrg if test -n "$libs"; then 3994e9fcaa8aSmrg if test -n "$lt_sysroot"; then 3995e9fcaa8aSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996e9fcaa8aSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997e9fcaa8aSmrg else 3998e9fcaa8aSmrg sysroot_cmd= 3999e9fcaa8aSmrg fi 40001ab64890Smrg 4001e9fcaa8aSmrg # Remove sysroot references 4002e9fcaa8aSmrg if $opt_dry_run; then 4003e9fcaa8aSmrg for lib in $libs; do 4004862bcd1aSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005e9fcaa8aSmrg done 4006e9fcaa8aSmrg else 4007e9fcaa8aSmrg tmpdir=`func_mktempdir` 4008e9fcaa8aSmrg for lib in $libs; do 4009862bcd1aSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010e9fcaa8aSmrg > $tmpdir/tmp-la 4011e9fcaa8aSmrg mv -f $tmpdir/tmp-la $lib 4012e9fcaa8aSmrg done 4013e9fcaa8aSmrg ${RM}r "$tmpdir" 4014e9fcaa8aSmrg fi 4015e9fcaa8aSmrg fi 4016e9fcaa8aSmrg 4017e9fcaa8aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 401888de56ccSmrg for libdir in $libdirs; do 401988de56ccSmrg if test -n "$finish_cmds"; then 402088de56ccSmrg # Do each command in the finish commands. 402188de56ccSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 402288de56ccSmrg'"$cmd"'"' 4023b4ee4795Smrg fi 402488de56ccSmrg if test -n "$finish_eval"; then 402588de56ccSmrg # Do the single finish_eval. 402688de56ccSmrg eval cmds=\"$finish_eval\" 4027e9fcaa8aSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 402888de56ccSmrg $cmds" 402988de56ccSmrg fi 403088de56ccSmrg done 403188de56ccSmrg fi 40321ab64890Smrg 403388de56ccSmrg # Exit here if they wanted silent mode. 4034862bcd1aSmrg $opt_quiet && exit $EXIT_SUCCESS 40351ab64890Smrg 4036e9fcaa8aSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037e9fcaa8aSmrg echo "----------------------------------------------------------------------" 4038e9fcaa8aSmrg echo "Libraries have been installed in:" 4039e9fcaa8aSmrg for libdir in $libdirs; do 4040e9fcaa8aSmrg $ECHO " $libdir" 4041e9fcaa8aSmrg done 4042e9fcaa8aSmrg echo 4043e9fcaa8aSmrg echo "If you ever happen to want to link against installed libraries" 4044e9fcaa8aSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4045862bcd1aSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046e9fcaa8aSmrg echo "flag during linking and do at least one of the following:" 4047e9fcaa8aSmrg if test -n "$shlibpath_var"; then 4048862bcd1aSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049e9fcaa8aSmrg echo " during execution" 4050e9fcaa8aSmrg fi 4051e9fcaa8aSmrg if test -n "$runpath_var"; then 4052862bcd1aSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4053e9fcaa8aSmrg echo " during linking" 4054e9fcaa8aSmrg fi 4055e9fcaa8aSmrg if test -n "$hardcode_libdir_flag_spec"; then 4056e9fcaa8aSmrg libdir=LIBDIR 4057e9fcaa8aSmrg eval flag=\"$hardcode_libdir_flag_spec\" 405888de56ccSmrg 4059862bcd1aSmrg $ECHO " - use the '$flag' linker flag" 4060e9fcaa8aSmrg fi 4061e9fcaa8aSmrg if test -n "$admincmds"; then 4062e9fcaa8aSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4063e9fcaa8aSmrg fi 4064e9fcaa8aSmrg if test -f /etc/ld.so.conf; then 4065862bcd1aSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066e9fcaa8aSmrg fi 4067e9fcaa8aSmrg echo 406888de56ccSmrg 4069e9fcaa8aSmrg echo "See any operating system documentation about shared libraries for" 4070e9fcaa8aSmrg case $host in 4071e9fcaa8aSmrg solaris2.[6789]|solaris2.1[0-9]) 4072e9fcaa8aSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073e9fcaa8aSmrg echo "pages." 4074e9fcaa8aSmrg ;; 4075e9fcaa8aSmrg *) 4076e9fcaa8aSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077e9fcaa8aSmrg ;; 4078e9fcaa8aSmrg esac 4079e9fcaa8aSmrg echo "----------------------------------------------------------------------" 4080e9fcaa8aSmrg fi 408188de56ccSmrg exit $EXIT_SUCCESS 408288de56ccSmrg} 408388de56ccSmrg 4084862bcd1aSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 408588de56ccSmrg 408688de56ccSmrg 408788de56ccSmrg# func_mode_install arg... 408888de56ccSmrgfunc_mode_install () 408988de56ccSmrg{ 4090862bcd1aSmrg $debug_cmd 4091862bcd1aSmrg 409288de56ccSmrg # There may be an optional sh(1) argument at the beginning of 409388de56ccSmrg # install_prog (especially on Windows NT). 4094862bcd1aSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 409588de56ccSmrg # Allow the use of GNU shtool's install command. 4096862bcd1aSmrg case $nonopt in *shtool*) :;; *) false;; esac 4097862bcd1aSmrg then 409888de56ccSmrg # Aesthetically quote it. 409988de56ccSmrg func_quote_for_eval "$nonopt" 410088de56ccSmrg install_prog="$func_quote_for_eval_result " 410188de56ccSmrg arg=$1 410288de56ccSmrg shift 410388de56ccSmrg else 410488de56ccSmrg install_prog= 410588de56ccSmrg arg=$nonopt 410688de56ccSmrg fi 410788de56ccSmrg 410888de56ccSmrg # The real first argument should be the name of the installation program. 410988de56ccSmrg # Aesthetically quote it. 411088de56ccSmrg func_quote_for_eval "$arg" 4111e9fcaa8aSmrg func_append install_prog "$func_quote_for_eval_result" 4112e9fcaa8aSmrg install_shared_prog=$install_prog 4113e9fcaa8aSmrg case " $install_prog " in 4114e9fcaa8aSmrg *[\\\ /]cp\ *) install_cp=: ;; 4115e9fcaa8aSmrg *) install_cp=false ;; 4116e9fcaa8aSmrg esac 411788de56ccSmrg 411888de56ccSmrg # We need to accept at least all the BSD install flags. 411988de56ccSmrg dest= 412088de56ccSmrg files= 412188de56ccSmrg opts= 412288de56ccSmrg prev= 412388de56ccSmrg install_type= 4124862bcd1aSmrg isdir=false 412588de56ccSmrg stripme= 4126e9fcaa8aSmrg no_mode=: 412788de56ccSmrg for arg 412888de56ccSmrg do 4129e9fcaa8aSmrg arg2= 413088de56ccSmrg if test -n "$dest"; then 4131e9fcaa8aSmrg func_append files " $dest" 413288de56ccSmrg dest=$arg 413388de56ccSmrg continue 413488de56ccSmrg fi 413588de56ccSmrg 413688de56ccSmrg case $arg in 4137862bcd1aSmrg -d) isdir=: ;; 413888de56ccSmrg -f) 4139e9fcaa8aSmrg if $install_cp; then :; else 4140e9fcaa8aSmrg prev=$arg 4141e9fcaa8aSmrg fi 414288de56ccSmrg ;; 414388de56ccSmrg -g | -m | -o) 414488de56ccSmrg prev=$arg 414588de56ccSmrg ;; 414688de56ccSmrg -s) 414788de56ccSmrg stripme=" -s" 414888de56ccSmrg continue 414988de56ccSmrg ;; 415088de56ccSmrg -*) 415188de56ccSmrg ;; 415288de56ccSmrg *) 415388de56ccSmrg # If the previous option needed an argument, then skip it. 415488de56ccSmrg if test -n "$prev"; then 4155862bcd1aSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156e9fcaa8aSmrg arg2=$install_override_mode 4157e9fcaa8aSmrg no_mode=false 4158e9fcaa8aSmrg fi 4159b4ee4795Smrg prev= 41602e9c7c8cSmrg else 416188de56ccSmrg dest=$arg 416288de56ccSmrg continue 41631ab64890Smrg fi 4164b4ee4795Smrg ;; 416588de56ccSmrg esac 41661ab64890Smrg 416788de56ccSmrg # Aesthetically quote the argument. 416888de56ccSmrg func_quote_for_eval "$arg" 4169e9fcaa8aSmrg func_append install_prog " $func_quote_for_eval_result" 4170e9fcaa8aSmrg if test -n "$arg2"; then 4171e9fcaa8aSmrg func_quote_for_eval "$arg2" 4172e9fcaa8aSmrg fi 4173e9fcaa8aSmrg func_append install_shared_prog " $func_quote_for_eval_result" 417488de56ccSmrg done 41751ab64890Smrg 417688de56ccSmrg test -z "$install_prog" && \ 417788de56ccSmrg func_fatal_help "you must specify an install program" 41781ab64890Smrg 417988de56ccSmrg test -n "$prev" && \ 4180862bcd1aSmrg func_fatal_help "the '$prev' option requires an argument" 41812e9c7c8cSmrg 4182e9fcaa8aSmrg if test -n "$install_override_mode" && $no_mode; then 4183e9fcaa8aSmrg if $install_cp; then :; else 4184e9fcaa8aSmrg func_quote_for_eval "$install_override_mode" 4185e9fcaa8aSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4186e9fcaa8aSmrg fi 4187e9fcaa8aSmrg fi 4188e9fcaa8aSmrg 418988de56ccSmrg if test -z "$files"; then 419088de56ccSmrg if test -z "$dest"; then 419188de56ccSmrg func_fatal_help "no file or destination specified" 419288de56ccSmrg else 419388de56ccSmrg func_fatal_help "you must specify a destination" 419488de56ccSmrg fi 4195b4ee4795Smrg fi 41962e9c7c8cSmrg 419788de56ccSmrg # Strip any trailing slash from the destination. 419888de56ccSmrg func_stripname '' '/' "$dest" 419988de56ccSmrg dest=$func_stripname_result 42002e9c7c8cSmrg 420188de56ccSmrg # Check to see that the destination is a directory. 4202862bcd1aSmrg test -d "$dest" && isdir=: 4203862bcd1aSmrg if $isdir; then 4204862bcd1aSmrg destdir=$dest 420588de56ccSmrg destname= 4206b4ee4795Smrg else 420788de56ccSmrg func_dirname_and_basename "$dest" "" "." 4208862bcd1aSmrg destdir=$func_dirname_result 4209862bcd1aSmrg destname=$func_basename_result 42102e9c7c8cSmrg 421188de56ccSmrg # Not a directory, so check to see that there is only one file specified. 421288de56ccSmrg set dummy $files; shift 421388de56ccSmrg test "$#" -gt 1 && \ 4214862bcd1aSmrg func_fatal_help "'$dest' is not a directory" 42152e9c7c8cSmrg fi 421688de56ccSmrg case $destdir in 421788de56ccSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218b4ee4795Smrg *) 421988de56ccSmrg for file in $files; do 422088de56ccSmrg case $file in 422188de56ccSmrg *.lo) ;; 422288de56ccSmrg *) 4223862bcd1aSmrg func_fatal_help "'$destdir' must be an absolute directory name" 422488de56ccSmrg ;; 422588de56ccSmrg esac 422688de56ccSmrg done 4227b4ee4795Smrg ;; 4228b4ee4795Smrg esac 42291ab64890Smrg 423088de56ccSmrg # This variable tells wrapper scripts just to set variables rather 423188de56ccSmrg # than running their programs. 4232862bcd1aSmrg libtool_install_magic=$magic 42331ab64890Smrg 423488de56ccSmrg staticlibs= 423588de56ccSmrg future_libdirs= 423688de56ccSmrg current_libdirs= 423788de56ccSmrg for file in $files; do 42381ab64890Smrg 423988de56ccSmrg # Do each installation. 424088de56ccSmrg case $file in 424188de56ccSmrg *.$libext) 424288de56ccSmrg # Do the static libraries later. 4243e9fcaa8aSmrg func_append staticlibs " $file" 424488de56ccSmrg ;; 424588de56ccSmrg 424688de56ccSmrg *.la) 4247e9fcaa8aSmrg func_resolve_sysroot "$file" 4248e9fcaa8aSmrg file=$func_resolve_sysroot_result 4249e9fcaa8aSmrg 425088de56ccSmrg # Check to see that this really is a libtool archive. 425188de56ccSmrg func_lalib_unsafe_p "$file" \ 4252862bcd1aSmrg || func_fatal_help "'$file' is not a valid libtool archive" 425388de56ccSmrg 425488de56ccSmrg library_names= 425588de56ccSmrg old_library= 425688de56ccSmrg relink_command= 425788de56ccSmrg func_source "$file" 425888de56ccSmrg 425988de56ccSmrg # Add the libdir to current_libdirs if it is the destination. 426088de56ccSmrg if test "X$destdir" = "X$libdir"; then 426188de56ccSmrg case "$current_libdirs " in 426288de56ccSmrg *" $libdir "*) ;; 4263e9fcaa8aSmrg *) func_append current_libdirs " $libdir" ;; 42642e9c7c8cSmrg esac 426588de56ccSmrg else 426688de56ccSmrg # Note the libdir as a future libdir. 426788de56ccSmrg case "$future_libdirs " in 426888de56ccSmrg *" $libdir "*) ;; 4269e9fcaa8aSmrg *) func_append future_libdirs " $libdir" ;; 427088de56ccSmrg esac 427188de56ccSmrg fi 42722e9c7c8cSmrg 427388de56ccSmrg func_dirname "$file" "/" "" 4274862bcd1aSmrg dir=$func_dirname_result 4275e9fcaa8aSmrg func_append dir "$objdir" 427688de56ccSmrg 427788de56ccSmrg if test -n "$relink_command"; then 427888de56ccSmrg # Determine the prefix the user has applied to our future dir. 4279e9fcaa8aSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 428088de56ccSmrg 428188de56ccSmrg # Don't allow the user to place us outside of our expected 428288de56ccSmrg # location b/c this prevents finding dependent libraries that 428388de56ccSmrg # are installed to the same prefix. 428488de56ccSmrg # At present, this check doesn't affect windows .dll's that 428588de56ccSmrg # are installed into $libdir/../bin (currently, that works fine) 428688de56ccSmrg # but it's something to keep an eye on. 428788de56ccSmrg test "$inst_prefix_dir" = "$destdir" && \ 4288862bcd1aSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 428988de56ccSmrg 429088de56ccSmrg if test -n "$inst_prefix_dir"; then 429188de56ccSmrg # Stick the inst_prefix_dir data into the link command. 4292e9fcaa8aSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 429388de56ccSmrg else 4294e9fcaa8aSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 429588de56ccSmrg fi 429688de56ccSmrg 4297862bcd1aSmrg func_warning "relinking '$file'" 429888de56ccSmrg func_show_eval "$relink_command" \ 4299862bcd1aSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 430088de56ccSmrg fi 430188de56ccSmrg 430288de56ccSmrg # See the names of the shared library. 430388de56ccSmrg set dummy $library_names; shift 430488de56ccSmrg if test -n "$1"; then 4305862bcd1aSmrg realname=$1 430688de56ccSmrg shift 430788de56ccSmrg 4308862bcd1aSmrg srcname=$realname 4309862bcd1aSmrg test -n "$relink_command" && srcname=${realname}T 431088de56ccSmrg 431188de56ccSmrg # Install the shared library and build the symlinks. 4312e9fcaa8aSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 431388de56ccSmrg 'exit $?' 4314862bcd1aSmrg tstripme=$stripme 431588de56ccSmrg case $host_os in 431688de56ccSmrg cygwin* | mingw* | pw32* | cegcc*) 431788de56ccSmrg case $realname in 431888de56ccSmrg *.dll.a) 4319862bcd1aSmrg tstripme= 4320862bcd1aSmrg ;; 4321862bcd1aSmrg esac 4322862bcd1aSmrg ;; 4323862bcd1aSmrg os2*) 4324862bcd1aSmrg case $realname in 4325862bcd1aSmrg *_dll.a) 4326862bcd1aSmrg tstripme= 432788de56ccSmrg ;; 432888de56ccSmrg esac 43292e9c7c8cSmrg ;; 43302e9c7c8cSmrg esac 433188de56ccSmrg if test -n "$tstripme" && test -n "$striplib"; then 433288de56ccSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333b4ee4795Smrg fi 433488de56ccSmrg 433588de56ccSmrg if test "$#" -gt 0; then 433688de56ccSmrg # Delete the old symlinks, and create new ones. 4337862bcd1aSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 433888de56ccSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 433988de56ccSmrg # so we also need to try rm && ln -s. 434088de56ccSmrg for linkname 434188de56ccSmrg do 434288de56ccSmrg test "$linkname" != "$realname" \ 434388de56ccSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344b4ee4795Smrg done 4345b4ee4795Smrg fi 43461ab64890Smrg 434788de56ccSmrg # Do each command in the postinstall commands. 4348862bcd1aSmrg lib=$destdir/$realname 434988de56ccSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350b4ee4795Smrg fi 43511ab64890Smrg 435288de56ccSmrg # Install the pseudo-library for information purposes. 435388de56ccSmrg func_basename "$file" 4354862bcd1aSmrg name=$func_basename_result 4355862bcd1aSmrg instname=$dir/${name}i 435688de56ccSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 43571ab64890Smrg 435888de56ccSmrg # Maybe install the static library, too. 4359e9fcaa8aSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 436088de56ccSmrg ;; 43611ab64890Smrg 436288de56ccSmrg *.lo) 436388de56ccSmrg # Install (i.e. copy) a libtool object. 43641ab64890Smrg 436588de56ccSmrg # Figure out destination file name, if it wasn't already specified. 436688de56ccSmrg if test -n "$destname"; then 4367862bcd1aSmrg destfile=$destdir/$destname 436888de56ccSmrg else 436988de56ccSmrg func_basename "$file" 4370862bcd1aSmrg destfile=$func_basename_result 4371862bcd1aSmrg destfile=$destdir/$destfile 4372b4ee4795Smrg fi 43731ab64890Smrg 437488de56ccSmrg # Deduce the name of the destination old-style object file. 437588de56ccSmrg case $destfile in 437688de56ccSmrg *.lo) 437788de56ccSmrg func_lo2o "$destfile" 437888de56ccSmrg staticdest=$func_lo2o_result 437988de56ccSmrg ;; 438088de56ccSmrg *.$objext) 4381862bcd1aSmrg staticdest=$destfile 438288de56ccSmrg destfile= 438388de56ccSmrg ;; 438488de56ccSmrg *) 4385862bcd1aSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 438688de56ccSmrg ;; 438788de56ccSmrg esac 43881ab64890Smrg 438988de56ccSmrg # Install the libtool object if requested. 439088de56ccSmrg test -n "$destfile" && \ 439188de56ccSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 43921ab64890Smrg 439388de56ccSmrg # Install the old object if enabled. 4394862bcd1aSmrg if test yes = "$build_old_libs"; then 439588de56ccSmrg # Deduce the name of the old-style object file. 439688de56ccSmrg func_lo2o "$file" 439788de56ccSmrg staticobj=$func_lo2o_result 439888de56ccSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 43991ab64890Smrg fi 440088de56ccSmrg exit $EXIT_SUCCESS 440188de56ccSmrg ;; 44021ab64890Smrg 440388de56ccSmrg *) 440488de56ccSmrg # Figure out destination file name, if it wasn't already specified. 440588de56ccSmrg if test -n "$destname"; then 4406862bcd1aSmrg destfile=$destdir/$destname 440788de56ccSmrg else 440888de56ccSmrg func_basename "$file" 4409862bcd1aSmrg destfile=$func_basename_result 4410862bcd1aSmrg destfile=$destdir/$destfile 441188de56ccSmrg fi 44121ab64890Smrg 441388de56ccSmrg # If the file is missing, and there is a .exe on the end, strip it 441488de56ccSmrg # because it is most likely a libtool script we actually want to 441588de56ccSmrg # install 4416862bcd1aSmrg stripped_ext= 441788de56ccSmrg case $file in 441888de56ccSmrg *.exe) 441988de56ccSmrg if test ! -f "$file"; then 442088de56ccSmrg func_stripname '' '.exe' "$file" 442188de56ccSmrg file=$func_stripname_result 4422862bcd1aSmrg stripped_ext=.exe 442388de56ccSmrg fi 442488de56ccSmrg ;; 442588de56ccSmrg esac 442688de56ccSmrg 442788de56ccSmrg # Do a test to see if this is really a libtool program. 442888de56ccSmrg case $host in 442988de56ccSmrg *cygwin* | *mingw*) 443088de56ccSmrg if func_ltwrapper_executable_p "$file"; then 443188de56ccSmrg func_ltwrapper_scriptname "$file" 443288de56ccSmrg wrapper=$func_ltwrapper_scriptname_result 443388de56ccSmrg else 443488de56ccSmrg func_stripname '' '.exe' "$file" 443588de56ccSmrg wrapper=$func_stripname_result 443688de56ccSmrg fi 443788de56ccSmrg ;; 4438b4ee4795Smrg *) 443988de56ccSmrg wrapper=$file 444088de56ccSmrg ;; 444188de56ccSmrg esac 444288de56ccSmrg if func_ltwrapper_script_p "$wrapper"; then 444388de56ccSmrg notinst_deplibs= 444488de56ccSmrg relink_command= 444588de56ccSmrg 444688de56ccSmrg func_source "$wrapper" 444788de56ccSmrg 444888de56ccSmrg # Check the variables that should have been set. 444988de56ccSmrg test -z "$generated_by_libtool_version" && \ 4450862bcd1aSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 445188de56ccSmrg 4452862bcd1aSmrg finalize=: 445388de56ccSmrg for lib in $notinst_deplibs; do 445488de56ccSmrg # Check to see that each library is installed. 445588de56ccSmrg libdir= 445688de56ccSmrg if test -f "$lib"; then 445788de56ccSmrg func_source "$lib" 445888de56ccSmrg fi 4459862bcd1aSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 446088de56ccSmrg if test -n "$libdir" && test ! -f "$libfile"; then 4461862bcd1aSmrg func_warning "'$lib' has not been installed in '$libdir'" 4462862bcd1aSmrg finalize=false 446388de56ccSmrg fi 446488de56ccSmrg done 446588de56ccSmrg 446688de56ccSmrg relink_command= 446788de56ccSmrg func_source "$wrapper" 446888de56ccSmrg 446988de56ccSmrg outputname= 4470862bcd1aSmrg if test no = "$fast_install" && test -n "$relink_command"; then 447188de56ccSmrg $opt_dry_run || { 4472862bcd1aSmrg if $finalize; then 447388de56ccSmrg tmpdir=`func_mktempdir` 447488de56ccSmrg func_basename "$file$stripped_ext" 4475862bcd1aSmrg file=$func_basename_result 4476862bcd1aSmrg outputname=$tmpdir/$file 447788de56ccSmrg # Replace the output file specification. 4478e9fcaa8aSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 447988de56ccSmrg 4480862bcd1aSmrg $opt_quiet || { 448188de56ccSmrg func_quote_for_expand "$relink_command" 448288de56ccSmrg eval "func_echo $func_quote_for_expand_result" 448388de56ccSmrg } 448488de56ccSmrg if eval "$relink_command"; then : 448588de56ccSmrg else 4486862bcd1aSmrg func_error "error: relink '$file' with the above command before installing it" 448788de56ccSmrg $opt_dry_run || ${RM}r "$tmpdir" 448888de56ccSmrg continue 448988de56ccSmrg fi 4490862bcd1aSmrg file=$outputname 449188de56ccSmrg else 4492862bcd1aSmrg func_warning "cannot relink '$file'" 449388de56ccSmrg fi 449488de56ccSmrg } 449588de56ccSmrg else 449688de56ccSmrg # Install the binary that we compiled earlier. 4497e9fcaa8aSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498b4ee4795Smrg fi 449988de56ccSmrg fi 450088de56ccSmrg 450188de56ccSmrg # remove .exe since cygwin /usr/bin/install will append another 450288de56ccSmrg # one anyway 450388de56ccSmrg case $install_prog,$host in 450488de56ccSmrg */usr/bin/install*,*cygwin*) 450588de56ccSmrg case $file:$destfile in 450688de56ccSmrg *.exe:*.exe) 450788de56ccSmrg # this is ok 450888de56ccSmrg ;; 450988de56ccSmrg *.exe:*) 451088de56ccSmrg destfile=$destfile.exe 451188de56ccSmrg ;; 451288de56ccSmrg *:*.exe) 451388de56ccSmrg func_stripname '' '.exe' "$destfile" 451488de56ccSmrg destfile=$func_stripname_result 451588de56ccSmrg ;; 451688de56ccSmrg esac 4517b4ee4795Smrg ;; 4518b4ee4795Smrg esac 451988de56ccSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 452088de56ccSmrg $opt_dry_run || if test -n "$outputname"; then 452188de56ccSmrg ${RM}r "$tmpdir" 452288de56ccSmrg fi 452388de56ccSmrg ;; 452488de56ccSmrg esac 452588de56ccSmrg done 45261ab64890Smrg 452788de56ccSmrg for file in $staticlibs; do 452888de56ccSmrg func_basename "$file" 4529862bcd1aSmrg name=$func_basename_result 453088de56ccSmrg 453188de56ccSmrg # Set up the ranlib parameters. 4532862bcd1aSmrg oldlib=$destdir/$name 4533eb411b4bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534eb411b4bSmrg tool_oldlib=$func_to_tool_file_result 453588de56ccSmrg 453688de56ccSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 453788de56ccSmrg 453888de56ccSmrg if test -n "$stripme" && test -n "$old_striplib"; then 4539eb411b4bSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 454088de56ccSmrg fi 454188de56ccSmrg 454288de56ccSmrg # Do each command in the postinstall commands. 454388de56ccSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 454488de56ccSmrg done 454588de56ccSmrg 454688de56ccSmrg test -n "$future_libdirs" && \ 4547862bcd1aSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 454888de56ccSmrg 454988de56ccSmrg if test -n "$current_libdirs"; then 455088de56ccSmrg # Maybe just do a dry run. 455188de56ccSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552862bcd1aSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 455388de56ccSmrg else 455488de56ccSmrg exit $EXIT_SUCCESS 455588de56ccSmrg fi 455688de56ccSmrg} 455788de56ccSmrg 4558862bcd1aSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 455988de56ccSmrg 456088de56ccSmrg 456188de56ccSmrg# func_generate_dlsyms outputname originator pic_p 456288de56ccSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 456388de56ccSmrg# a dlpreopen symbol table. 456488de56ccSmrgfunc_generate_dlsyms () 456588de56ccSmrg{ 4566862bcd1aSmrg $debug_cmd 4567862bcd1aSmrg 4568862bcd1aSmrg my_outputname=$1 4569862bcd1aSmrg my_originator=$2 4570862bcd1aSmrg my_pic_p=${3-false} 4571862bcd1aSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 457288de56ccSmrg my_dlsyms= 457388de56ccSmrg 4574862bcd1aSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 457588de56ccSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576862bcd1aSmrg my_dlsyms=${my_outputname}S.c 457788de56ccSmrg else 457888de56ccSmrg func_error "not configured to extract global symbols from dlpreopened files" 457988de56ccSmrg fi 458088de56ccSmrg fi 458188de56ccSmrg 458288de56ccSmrg if test -n "$my_dlsyms"; then 458388de56ccSmrg case $my_dlsyms in 458488de56ccSmrg "") ;; 458588de56ccSmrg *.c) 458688de56ccSmrg # Discover the nlist of each of the dlfiles. 4587862bcd1aSmrg nlist=$output_objdir/$my_outputname.nm 458888de56ccSmrg 458988de56ccSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 459088de56ccSmrg 459188de56ccSmrg # Parse the name list into a source file. 459288de56ccSmrg func_verbose "creating $output_objdir/$my_dlsyms" 459388de56ccSmrg 459488de56ccSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595862bcd1aSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596862bcd1aSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 459788de56ccSmrg 459888de56ccSmrg#ifdef __cplusplus 459988de56ccSmrgextern \"C\" { 460088de56ccSmrg#endif 460188de56ccSmrg 4602862bcd1aSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603e9fcaa8aSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604e9fcaa8aSmrg#endif 4605e9fcaa8aSmrg 4606e9fcaa8aSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607862bcd1aSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608862bcd1aSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609e9fcaa8aSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610e9fcaa8aSmrg# define LT_DLSYM_CONST 4611862bcd1aSmrg#elif defined __osf__ 4612e9fcaa8aSmrg/* This system does not cope well with relocations in const data. */ 4613e9fcaa8aSmrg# define LT_DLSYM_CONST 4614e9fcaa8aSmrg#else 4615e9fcaa8aSmrg# define LT_DLSYM_CONST const 4616e9fcaa8aSmrg#endif 4617e9fcaa8aSmrg 4618862bcd1aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619862bcd1aSmrg 462088de56ccSmrg/* External symbol declarations for the compiler. */\ 462188de56ccSmrg" 462288de56ccSmrg 4623862bcd1aSmrg if test yes = "$dlself"; then 4624862bcd1aSmrg func_verbose "generating symbol list for '$output'" 462588de56ccSmrg 462688de56ccSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 462788de56ccSmrg 462888de56ccSmrg # Add our own program objects to the symbol list. 4629e9fcaa8aSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 463088de56ccSmrg for progfile in $progfiles; do 4631e9fcaa8aSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632862bcd1aSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633e9fcaa8aSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 463488de56ccSmrg done 463588de56ccSmrg 463688de56ccSmrg if test -n "$exclude_expsyms"; then 463788de56ccSmrg $opt_dry_run || { 463888de56ccSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 463988de56ccSmrg eval '$MV "$nlist"T "$nlist"' 464088de56ccSmrg } 4641b4ee4795Smrg fi 464288de56ccSmrg 464388de56ccSmrg if test -n "$export_symbols_regex"; then 464488de56ccSmrg $opt_dry_run || { 464588de56ccSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 464688de56ccSmrg eval '$MV "$nlist"T "$nlist"' 464788de56ccSmrg } 464888de56ccSmrg fi 464988de56ccSmrg 465088de56ccSmrg # Prepare the list of exported symbols 465188de56ccSmrg if test -z "$export_symbols"; then 4652862bcd1aSmrg export_symbols=$output_objdir/$outputname.exp 465388de56ccSmrg $opt_dry_run || { 465488de56ccSmrg $RM $export_symbols 4655862bcd1aSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 465688de56ccSmrg case $host in 465788de56ccSmrg *cygwin* | *mingw* | *cegcc* ) 465888de56ccSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 465988de56ccSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 466088de56ccSmrg ;; 466188de56ccSmrg esac 466288de56ccSmrg } 4663b4ee4795Smrg else 466488de56ccSmrg $opt_dry_run || { 4665862bcd1aSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 466688de56ccSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 466788de56ccSmrg eval '$MV "$nlist"T "$nlist"' 466888de56ccSmrg case $host in 4669e9fcaa8aSmrg *cygwin* | *mingw* | *cegcc* ) 467088de56ccSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 467188de56ccSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 467288de56ccSmrg ;; 467388de56ccSmrg esac 467488de56ccSmrg } 4675b4ee4795Smrg fi 467688de56ccSmrg fi 46771ab64890Smrg 467888de56ccSmrg for dlprefile in $dlprefiles; do 4679862bcd1aSmrg func_verbose "extracting global C symbols from '$dlprefile'" 468088de56ccSmrg func_basename "$dlprefile" 4681862bcd1aSmrg name=$func_basename_result 4682e9fcaa8aSmrg case $host in 4683e9fcaa8aSmrg *cygwin* | *mingw* | *cegcc* ) 4684e9fcaa8aSmrg # if an import library, we need to obtain dlname 4685e9fcaa8aSmrg if func_win32_import_lib_p "$dlprefile"; then 4686e9fcaa8aSmrg func_tr_sh "$dlprefile" 4687e9fcaa8aSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688862bcd1aSmrg dlprefile_dlbasename= 4689e9fcaa8aSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690e9fcaa8aSmrg # Use subshell, to avoid clobbering current variable values 4691e9fcaa8aSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692862bcd1aSmrg if test -n "$dlprefile_dlname"; then 4693e9fcaa8aSmrg func_basename "$dlprefile_dlname" 4694862bcd1aSmrg dlprefile_dlbasename=$func_basename_result 4695e9fcaa8aSmrg else 4696e9fcaa8aSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4697e9fcaa8aSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4698e9fcaa8aSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4699e9fcaa8aSmrg fi 4700e9fcaa8aSmrg fi 4701e9fcaa8aSmrg $opt_dry_run || { 4702862bcd1aSmrg if test -n "$dlprefile_dlbasename"; then 4703e9fcaa8aSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704e9fcaa8aSmrg else 4705e9fcaa8aSmrg func_warning "Could not compute DLL name from $name" 4706e9fcaa8aSmrg eval '$ECHO ": $name " >> "$nlist"' 4707e9fcaa8aSmrg fi 4708e9fcaa8aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709e9fcaa8aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710e9fcaa8aSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711e9fcaa8aSmrg } 4712e9fcaa8aSmrg else # not an import lib 4713e9fcaa8aSmrg $opt_dry_run || { 4714e9fcaa8aSmrg eval '$ECHO ": $name " >> "$nlist"' 4715e9fcaa8aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716e9fcaa8aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717e9fcaa8aSmrg } 4718e9fcaa8aSmrg fi 4719e9fcaa8aSmrg ;; 4720e9fcaa8aSmrg *) 4721e9fcaa8aSmrg $opt_dry_run || { 4722e9fcaa8aSmrg eval '$ECHO ": $name " >> "$nlist"' 4723e9fcaa8aSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724e9fcaa8aSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725e9fcaa8aSmrg } 4726e9fcaa8aSmrg ;; 4727e9fcaa8aSmrg esac 472888de56ccSmrg done 472988de56ccSmrg 473088de56ccSmrg $opt_dry_run || { 473188de56ccSmrg # Make sure we have at least an empty file. 473288de56ccSmrg test -f "$nlist" || : > "$nlist" 473388de56ccSmrg 473488de56ccSmrg if test -n "$exclude_expsyms"; then 473588de56ccSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 473688de56ccSmrg $MV "$nlist"T "$nlist" 4737b4ee4795Smrg fi 473888de56ccSmrg 473988de56ccSmrg # Try sorting and uniquifying the output. 474088de56ccSmrg if $GREP -v "^: " < "$nlist" | 474188de56ccSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 474288de56ccSmrg sort -k 3 474388de56ccSmrg else 474488de56ccSmrg sort +2 474588de56ccSmrg fi | 474688de56ccSmrg uniq > "$nlist"S; then 474788de56ccSmrg : 4748b4ee4795Smrg else 474988de56ccSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750b4ee4795Smrg fi 47511ab64890Smrg 475288de56ccSmrg if test -f "$nlist"S; then 475388de56ccSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754b4ee4795Smrg else 4755e9fcaa8aSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756b4ee4795Smrg fi 47571ab64890Smrg 4758862bcd1aSmrg func_show_eval '$RM "${nlist}I"' 4759862bcd1aSmrg if test -n "$global_symbol_to_import"; then 4760862bcd1aSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761862bcd1aSmrg fi 4762862bcd1aSmrg 4763e9fcaa8aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 47641ab64890Smrg 476588de56ccSmrg/* The mapping between symbol names and symbols. */ 476688de56ccSmrgtypedef struct { 476788de56ccSmrg const char *name; 476888de56ccSmrg void *address; 476988de56ccSmrg} lt_dlsymlist; 4770e9fcaa8aSmrgextern LT_DLSYM_CONST lt_dlsymlist 4771862bcd1aSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4772862bcd1aSmrg" 4773862bcd1aSmrg 4774862bcd1aSmrg if test -s "$nlist"I; then 4775862bcd1aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4776862bcd1aSmrgstatic void lt_syminit(void) 4777862bcd1aSmrg{ 4778862bcd1aSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779862bcd1aSmrg for (; symbol->name; ++symbol) 4780862bcd1aSmrg {" 4781862bcd1aSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782862bcd1aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4783862bcd1aSmrg } 4784862bcd1aSmrg}" 4785862bcd1aSmrg fi 4786862bcd1aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4787e9fcaa8aSmrgLT_DLSYM_CONST lt_dlsymlist 478888de56ccSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 4789862bcd1aSmrg{ {\"$my_originator\", (void *) 0}," 4790862bcd1aSmrg 4791862bcd1aSmrg if test -s "$nlist"I; then 4792862bcd1aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4793862bcd1aSmrg {\"@INIT@\", (void *) <_syminit}," 4794862bcd1aSmrg fi 47951ab64890Smrg 479688de56ccSmrg case $need_lib_prefix in 479788de56ccSmrg no) 479888de56ccSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 479988de56ccSmrg ;; 480088de56ccSmrg *) 480188de56ccSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 480288de56ccSmrg ;; 480388de56ccSmrg esac 4804e9fcaa8aSmrg echo >> "$output_objdir/$my_dlsyms" "\ 480588de56ccSmrg {0, (void *) 0} 480688de56ccSmrg}; 48071ab64890Smrg 480888de56ccSmrg/* This works around a problem in FreeBSD linker */ 480988de56ccSmrg#ifdef FREEBSD_WORKAROUND 481088de56ccSmrgstatic const void *lt_preloaded_setup() { 481188de56ccSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 481288de56ccSmrg} 481388de56ccSmrg#endif 481488de56ccSmrg 481588de56ccSmrg#ifdef __cplusplus 481688de56ccSmrg} 481788de56ccSmrg#endif\ 481888de56ccSmrg" 481988de56ccSmrg } # !$opt_dry_run 482088de56ccSmrg 482188de56ccSmrg pic_flag_for_symtable= 482288de56ccSmrg case "$compile_command " in 482388de56ccSmrg *" -static "*) ;; 482488de56ccSmrg *) 482588de56ccSmrg case $host in 482688de56ccSmrg # compiling the symbol table file with pic_flag works around 482788de56ccSmrg # a FreeBSD bug that causes programs to crash when -lm is 482888de56ccSmrg # linked before any other PIC object. But we must not use 482988de56ccSmrg # pic_flag when linking with -static. The problem exists in 483088de56ccSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831eb411b4bSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 483288de56ccSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 483388de56ccSmrg *-*-hpux*) 483488de56ccSmrg pic_flag_for_symtable=" $pic_flag" ;; 483588de56ccSmrg *) 4836862bcd1aSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 483788de56ccSmrg ;; 483888de56ccSmrg esac 483988de56ccSmrg ;; 484088de56ccSmrg esac 484188de56ccSmrg symtab_cflags= 484288de56ccSmrg for arg in $LTCFLAGS; do 484388de56ccSmrg case $arg in 484488de56ccSmrg -pie | -fpie | -fPIE) ;; 4845e9fcaa8aSmrg *) func_append symtab_cflags " $arg" ;; 484688de56ccSmrg esac 484788de56ccSmrg done 48481ab64890Smrg 484988de56ccSmrg # Now compile the dynamic symbol file. 485088de56ccSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 48512e9c7c8cSmrg 485288de56ccSmrg # Clean up the generated files. 4853862bcd1aSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 48541ab64890Smrg 485588de56ccSmrg # Transform the symbol file into the correct name. 4856862bcd1aSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 485788de56ccSmrg case $host in 485888de56ccSmrg *cygwin* | *mingw* | *cegcc* ) 485988de56ccSmrg if test -f "$output_objdir/$my_outputname.def"; then 4860e9fcaa8aSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861e9fcaa8aSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486288de56ccSmrg else 4863e9fcaa8aSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864e9fcaa8aSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865b4ee4795Smrg fi 486688de56ccSmrg ;; 486788de56ccSmrg *) 4868e9fcaa8aSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869e9fcaa8aSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 487088de56ccSmrg ;; 487188de56ccSmrg esac 487288de56ccSmrg ;; 487388de56ccSmrg *) 4874862bcd1aSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 487588de56ccSmrg ;; 487688de56ccSmrg esac 487788de56ccSmrg else 487888de56ccSmrg # We keep going just in case the user didn't refer to 487988de56ccSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 488088de56ccSmrg # really was required. 48811ab64890Smrg 488288de56ccSmrg # Nullify the symbol file. 4883e9fcaa8aSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884e9fcaa8aSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 488588de56ccSmrg fi 488688de56ccSmrg} 48872e9c7c8cSmrg 4888862bcd1aSmrg# func_cygming_gnu_implib_p ARG 4889862bcd1aSmrg# This predicate returns with zero status (TRUE) if 4890862bcd1aSmrg# ARG is a GNU/binutils-style import library. Returns 4891862bcd1aSmrg# with nonzero status (FALSE) otherwise. 4892862bcd1aSmrgfunc_cygming_gnu_implib_p () 4893862bcd1aSmrg{ 4894862bcd1aSmrg $debug_cmd 4895862bcd1aSmrg 4896862bcd1aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4897862bcd1aSmrg 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)$'` 4898862bcd1aSmrg test -n "$func_cygming_gnu_implib_tmp" 4899862bcd1aSmrg} 4900862bcd1aSmrg 4901862bcd1aSmrg# func_cygming_ms_implib_p ARG 4902862bcd1aSmrg# This predicate returns with zero status (TRUE) if 4903862bcd1aSmrg# ARG is an MS-style import library. Returns 4904862bcd1aSmrg# with nonzero status (FALSE) otherwise. 4905862bcd1aSmrgfunc_cygming_ms_implib_p () 4906862bcd1aSmrg{ 4907862bcd1aSmrg $debug_cmd 4908862bcd1aSmrg 4909862bcd1aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4910862bcd1aSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911862bcd1aSmrg test -n "$func_cygming_ms_implib_tmp" 4912862bcd1aSmrg} 4913862bcd1aSmrg 491488de56ccSmrg# func_win32_libid arg 491588de56ccSmrg# return the library type of file 'arg' 491688de56ccSmrg# 491788de56ccSmrg# Need a lot of goo to handle *both* DLLs and import libs 491888de56ccSmrg# Has to be a shell function in order to 'eat' the argument 491988de56ccSmrg# that is supplied when $file_magic_command is called. 4920e9fcaa8aSmrg# Despite the name, also deal with 64 bit binaries. 492188de56ccSmrgfunc_win32_libid () 492288de56ccSmrg{ 4923862bcd1aSmrg $debug_cmd 4924862bcd1aSmrg 4925862bcd1aSmrg win32_libid_type=unknown 492688de56ccSmrg win32_fileres=`file -L $1 2>/dev/null` 492788de56ccSmrg case $win32_fileres in 492888de56ccSmrg *ar\ archive\ import\ library*) # definitely import 492988de56ccSmrg win32_libid_type="x86 archive import" 493088de56ccSmrg ;; 493188de56ccSmrg *ar\ archive*) # could be an import, or static 4932e9fcaa8aSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 493388de56ccSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934e9fcaa8aSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935862bcd1aSmrg case $nm_interface in 4936862bcd1aSmrg "MS dumpbin") 4937862bcd1aSmrg if func_cygming_ms_implib_p "$1" || 4938862bcd1aSmrg func_cygming_gnu_implib_p "$1" 4939862bcd1aSmrg then 4940862bcd1aSmrg win32_nmres=import 4941862bcd1aSmrg else 4942862bcd1aSmrg win32_nmres= 4943862bcd1aSmrg fi 4944862bcd1aSmrg ;; 4945862bcd1aSmrg *) 4946862bcd1aSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4947862bcd1aSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948862bcd1aSmrg $SED -n -e ' 494988de56ccSmrg 1,100{ 495088de56ccSmrg / I /{ 4951862bcd1aSmrg s|.*|import| 495288de56ccSmrg p 495388de56ccSmrg q 495488de56ccSmrg } 495588de56ccSmrg }'` 4956862bcd1aSmrg ;; 4957862bcd1aSmrg esac 495888de56ccSmrg case $win32_nmres in 495988de56ccSmrg import*) win32_libid_type="x86 archive import";; 496088de56ccSmrg *) win32_libid_type="x86 archive static";; 496188de56ccSmrg esac 496288de56ccSmrg fi 496388de56ccSmrg ;; 496488de56ccSmrg *DLL*) 496588de56ccSmrg win32_libid_type="x86 DLL" 496688de56ccSmrg ;; 496788de56ccSmrg *executable*) # but shell scripts are "executable" too... 496888de56ccSmrg case $win32_fileres in 496988de56ccSmrg *MS\ Windows\ PE\ Intel*) 497088de56ccSmrg win32_libid_type="x86 DLL" 497188de56ccSmrg ;; 497288de56ccSmrg esac 497388de56ccSmrg ;; 497488de56ccSmrg esac 497588de56ccSmrg $ECHO "$win32_libid_type" 497688de56ccSmrg} 49772e9c7c8cSmrg 4978e9fcaa8aSmrg# func_cygming_dll_for_implib ARG 4979e9fcaa8aSmrg# 4980e9fcaa8aSmrg# Platform-specific function to extract the 4981e9fcaa8aSmrg# name of the DLL associated with the specified 4982e9fcaa8aSmrg# import library ARG. 4983e9fcaa8aSmrg# Invoked by eval'ing the libtool variable 4984e9fcaa8aSmrg# $sharedlib_from_linklib_cmd 4985e9fcaa8aSmrg# Result is available in the variable 4986e9fcaa8aSmrg# $sharedlib_from_linklib_result 4987e9fcaa8aSmrgfunc_cygming_dll_for_implib () 4988e9fcaa8aSmrg{ 4989862bcd1aSmrg $debug_cmd 4990862bcd1aSmrg 4991e9fcaa8aSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992e9fcaa8aSmrg} 4993e9fcaa8aSmrg 4994e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995e9fcaa8aSmrg# 4996e9fcaa8aSmrg# The is the core of a fallback implementation of a 4997e9fcaa8aSmrg# platform-specific function to extract the name of the 4998e9fcaa8aSmrg# DLL associated with the specified import library LIBNAME. 4999e9fcaa8aSmrg# 5000e9fcaa8aSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5001e9fcaa8aSmrg# on the platform and compiler that created the implib. 5002e9fcaa8aSmrg# 5003e9fcaa8aSmrg# Echos the name of the DLL associated with the 5004e9fcaa8aSmrg# specified import library. 5005e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback_core () 5006e9fcaa8aSmrg{ 5007862bcd1aSmrg $debug_cmd 5008862bcd1aSmrg 5009e9fcaa8aSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010e9fcaa8aSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011e9fcaa8aSmrg $SED '/^Contents of section '"$match_literal"':/{ 5012e9fcaa8aSmrg # Place marker at beginning of archive member dllname section 5013e9fcaa8aSmrg s/.*/====MARK====/ 5014e9fcaa8aSmrg p 5015e9fcaa8aSmrg d 5016e9fcaa8aSmrg } 5017e9fcaa8aSmrg # These lines can sometimes be longer than 43 characters, but 5018e9fcaa8aSmrg # are always uninteresting 5019e9fcaa8aSmrg /:[ ]*file format pe[i]\{,1\}-/d 5020e9fcaa8aSmrg /^In archive [^:]*:/d 5021e9fcaa8aSmrg # Ensure marker is printed 5022e9fcaa8aSmrg /^====MARK====/p 5023e9fcaa8aSmrg # Remove all lines with less than 43 characters 5024e9fcaa8aSmrg /^.\{43\}/!d 5025e9fcaa8aSmrg # From remaining lines, remove first 43 characters 5026e9fcaa8aSmrg s/^.\{43\}//' | 5027e9fcaa8aSmrg $SED -n ' 5028e9fcaa8aSmrg # Join marker and all lines until next marker into a single line 5029e9fcaa8aSmrg /^====MARK====/ b para 5030e9fcaa8aSmrg H 5031e9fcaa8aSmrg $ b para 5032e9fcaa8aSmrg b 5033e9fcaa8aSmrg :para 5034e9fcaa8aSmrg x 5035e9fcaa8aSmrg s/\n//g 5036e9fcaa8aSmrg # Remove the marker 5037e9fcaa8aSmrg s/^====MARK====// 5038e9fcaa8aSmrg # Remove trailing dots and whitespace 5039e9fcaa8aSmrg s/[\. \t]*$// 5040e9fcaa8aSmrg # Print 5041e9fcaa8aSmrg /./p' | 5042e9fcaa8aSmrg # we now have a list, one entry per line, of the stringified 5043e9fcaa8aSmrg # contents of the appropriate section of all members of the 5044862bcd1aSmrg # archive that possess that section. Heuristic: eliminate 5045862bcd1aSmrg # all those that have a first or second character that is 5046e9fcaa8aSmrg # a '.' (that is, objdump's representation of an unprintable 5047e9fcaa8aSmrg # character.) This should work for all archives with less than 5048e9fcaa8aSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5049e9fcaa8aSmrg # begins with a literal '.' or a single character followed by 5050e9fcaa8aSmrg # a '.'. 5051e9fcaa8aSmrg # 5052e9fcaa8aSmrg # Of those that remain, print the first one. 5053e9fcaa8aSmrg $SED -e '/^\./d;/^.\./d;q' 5054e9fcaa8aSmrg} 5055e9fcaa8aSmrg 5056e9fcaa8aSmrg# func_cygming_dll_for_implib_fallback ARG 5057e9fcaa8aSmrg# Platform-specific function to extract the 5058e9fcaa8aSmrg# name of the DLL associated with the specified 5059e9fcaa8aSmrg# import library ARG. 5060e9fcaa8aSmrg# 5061e9fcaa8aSmrg# This fallback implementation is for use when $DLLTOOL 5062e9fcaa8aSmrg# does not support the --identify-strict option. 5063e9fcaa8aSmrg# Invoked by eval'ing the libtool variable 5064e9fcaa8aSmrg# $sharedlib_from_linklib_cmd 5065e9fcaa8aSmrg# Result is available in the variable 5066e9fcaa8aSmrg# $sharedlib_from_linklib_result 5067e9fcaa8aSmrgfunc_cygming_dll_for_implib_fallback () 5068e9fcaa8aSmrg{ 5069862bcd1aSmrg $debug_cmd 5070862bcd1aSmrg 5071862bcd1aSmrg if func_cygming_gnu_implib_p "$1"; then 5072e9fcaa8aSmrg # binutils import library 5073e9fcaa8aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074862bcd1aSmrg elif func_cygming_ms_implib_p "$1"; then 5075e9fcaa8aSmrg # ms-generated import library 5076e9fcaa8aSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077e9fcaa8aSmrg else 5078e9fcaa8aSmrg # unknown 5079862bcd1aSmrg sharedlib_from_linklib_result= 5080e9fcaa8aSmrg fi 5081e9fcaa8aSmrg} 50822e9c7c8cSmrg 50832e9c7c8cSmrg 508488de56ccSmrg# func_extract_an_archive dir oldlib 508588de56ccSmrgfunc_extract_an_archive () 508688de56ccSmrg{ 5087862bcd1aSmrg $debug_cmd 5088862bcd1aSmrg 5089862bcd1aSmrg f_ex_an_ar_dir=$1; shift 5090862bcd1aSmrg f_ex_an_ar_oldlib=$1 5091862bcd1aSmrg if test yes = "$lock_old_archive_extraction"; then 5092e9fcaa8aSmrg lockfile=$f_ex_an_ar_oldlib.lock 5093e9fcaa8aSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094e9fcaa8aSmrg func_echo "Waiting for $lockfile to be removed" 5095e9fcaa8aSmrg sleep 2 5096e9fcaa8aSmrg done 5097e9fcaa8aSmrg fi 5098e9fcaa8aSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099e9fcaa8aSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5100862bcd1aSmrg if test yes = "$lock_old_archive_extraction"; then 5101e9fcaa8aSmrg $opt_dry_run || rm -f "$lockfile" 5102e9fcaa8aSmrg fi 510388de56ccSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 510488de56ccSmrg : 510588de56ccSmrg else 510688de56ccSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 510788de56ccSmrg fi 510888de56ccSmrg} 51091ab64890Smrg 51101ab64890Smrg 511188de56ccSmrg# func_extract_archives gentop oldlib ... 511288de56ccSmrgfunc_extract_archives () 511388de56ccSmrg{ 5114862bcd1aSmrg $debug_cmd 5115862bcd1aSmrg 5116862bcd1aSmrg my_gentop=$1; shift 511788de56ccSmrg my_oldlibs=${1+"$@"} 5118862bcd1aSmrg my_oldobjs= 5119862bcd1aSmrg my_xlib= 5120862bcd1aSmrg my_xabs= 5121862bcd1aSmrg my_xdir= 51221ab64890Smrg 512388de56ccSmrg for my_xlib in $my_oldlibs; do 512488de56ccSmrg # Extract the objects. 512588de56ccSmrg case $my_xlib in 5126862bcd1aSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 512788de56ccSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 512888de56ccSmrg esac 512988de56ccSmrg func_basename "$my_xlib" 5130862bcd1aSmrg my_xlib=$func_basename_result 513188de56ccSmrg my_xlib_u=$my_xlib 513288de56ccSmrg while :; do 513388de56ccSmrg case " $extracted_archives " in 513488de56ccSmrg *" $my_xlib_u "*) 513588de56ccSmrg func_arith $extracted_serial + 1 513688de56ccSmrg extracted_serial=$func_arith_result 513788de56ccSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 513888de56ccSmrg *) break ;; 513988de56ccSmrg esac 514088de56ccSmrg done 514188de56ccSmrg extracted_archives="$extracted_archives $my_xlib_u" 5142862bcd1aSmrg my_xdir=$my_gentop/$my_xlib_u 51431ab64890Smrg 514488de56ccSmrg func_mkdir_p "$my_xdir" 51452e9c7c8cSmrg 514688de56ccSmrg case $host in 514788de56ccSmrg *-darwin*) 514888de56ccSmrg func_verbose "Extracting $my_xabs" 514988de56ccSmrg # Do not bother doing anything if just a dry run 515088de56ccSmrg $opt_dry_run || { 515188de56ccSmrg darwin_orig_dir=`pwd` 515288de56ccSmrg cd $my_xdir || exit $? 515388de56ccSmrg darwin_archive=$my_xabs 515488de56ccSmrg darwin_curdir=`pwd` 5155862bcd1aSmrg func_basename "$darwin_archive" 5156862bcd1aSmrg darwin_base_archive=$func_basename_result 515788de56ccSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 515888de56ccSmrg if test -n "$darwin_arches"; then 515988de56ccSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 516088de56ccSmrg darwin_arch= 516188de56ccSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162862bcd1aSmrg for darwin_arch in $darwin_arches; do 5163862bcd1aSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164862bcd1aSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165862bcd1aSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166862bcd1aSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 516788de56ccSmrg cd "$darwin_curdir" 5168862bcd1aSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 516988de56ccSmrg done # $darwin_arches 517088de56ccSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171862bcd1aSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 517288de56ccSmrg darwin_file= 517388de56ccSmrg darwin_files= 517488de56ccSmrg for darwin_file in $darwin_filelist; do 5175e9fcaa8aSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 517688de56ccSmrg $LIPO -create -output "$darwin_file" $darwin_files 517788de56ccSmrg done # $darwin_filelist 517888de56ccSmrg $RM -rf unfat-$$ 517988de56ccSmrg cd "$darwin_orig_dir" 5180b4ee4795Smrg else 518188de56ccSmrg cd $darwin_orig_dir 518288de56ccSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 518388de56ccSmrg fi # $darwin_arches 518488de56ccSmrg } # !$opt_dry_run 518588de56ccSmrg ;; 518688de56ccSmrg *) 518788de56ccSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 518888de56ccSmrg ;; 518988de56ccSmrg esac 5190e9fcaa8aSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 519188de56ccSmrg done 51921ab64890Smrg 5193862bcd1aSmrg func_extract_archives_result=$my_oldobjs 519488de56ccSmrg} 51951ab64890Smrg 51961ab64890Smrg 5197e9fcaa8aSmrg# func_emit_wrapper [arg=no] 5198e9fcaa8aSmrg# 5199e9fcaa8aSmrg# Emit a libtool wrapper script on stdout. 5200e9fcaa8aSmrg# Don't directly open a file because we may want to 5201e9fcaa8aSmrg# incorporate the script contents within a cygwin/mingw 5202e9fcaa8aSmrg# wrapper executable. Must ONLY be called from within 5203e9fcaa8aSmrg# func_mode_link because it depends on a number of variables 5204e9fcaa8aSmrg# set therein. 520588de56ccSmrg# 5206e9fcaa8aSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207e9fcaa8aSmrg# variable will take. If 'yes', then the emitted script 5208862bcd1aSmrg# will assume that the directory where it is stored is 5209e9fcaa8aSmrg# the $objdir directory. This is a cygwin/mingw-specific 5210e9fcaa8aSmrg# behavior. 5211e9fcaa8aSmrgfunc_emit_wrapper () 521288de56ccSmrg{ 5213e9fcaa8aSmrg func_emit_wrapper_arg1=${1-no} 5214b4ee4795Smrg 521588de56ccSmrg $ECHO "\ 521688de56ccSmrg#! $SHELL 52171ab64890Smrg 521888de56ccSmrg# $output - temporary wrapper script for $objdir/$outputname 5219862bcd1aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 522088de56ccSmrg# 522188de56ccSmrg# The $output program cannot be directly executed until all the libtool 522288de56ccSmrg# libraries that it depends on are installed. 522388de56ccSmrg# 522488de56ccSmrg# This wrapper script should never be moved out of the build directory. 522588de56ccSmrg# If it is, it will not operate correctly. 52261ab64890Smrg 522788de56ccSmrg# Sed substitution that helps us do robust quoting. It backslashifies 522888de56ccSmrg# metacharacters that are still active within double-quoted strings. 522988de56ccSmrgsed_quote_subst='$sed_quote_subst' 52301ab64890Smrg 523188de56ccSmrg# Be Bourne compatible 523288de56ccSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 523388de56ccSmrg emulate sh 523488de56ccSmrg NULLCMD=: 523588de56ccSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 523688de56ccSmrg # is contrary to our usage. Disable this feature. 523788de56ccSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 523888de56ccSmrg setopt NO_GLOB_SUBST 523988de56ccSmrgelse 524088de56ccSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 524188de56ccSmrgfi 524288de56ccSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 524388de56ccSmrgDUALCASE=1; export DUALCASE # for MKS sh 52441ab64890Smrg 524588de56ccSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 524688de56ccSmrg# if CDPATH is set. 524788de56ccSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 52481ab64890Smrg 524988de56ccSmrgrelink_command=\"$relink_command\" 52501ab64890Smrg 525188de56ccSmrg# This environment variable determines our operation mode. 525288de56ccSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 525388de56ccSmrg # install mode needs the following variables: 525488de56ccSmrg generated_by_libtool_version='$macro_version' 525588de56ccSmrg notinst_deplibs='$notinst_deplibs' 525688de56ccSmrgelse 525788de56ccSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 525888de56ccSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259e9fcaa8aSmrg file=\"\$0\"" 5260e9fcaa8aSmrg 52615afda2e6Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262e9fcaa8aSmrg $ECHO "\ 5263e9fcaa8aSmrg 5264e9fcaa8aSmrg# A function that is used when there is no print builtin or printf. 5265e9fcaa8aSmrgfunc_fallback_echo () 5266e9fcaa8aSmrg{ 5267e9fcaa8aSmrg eval 'cat <<_LTECHO_EOF 5268e9fcaa8aSmrg\$1 5269e9fcaa8aSmrg_LTECHO_EOF' 5270e9fcaa8aSmrg} 5271e9fcaa8aSmrg ECHO=\"$qECHO\" 5272e9fcaa8aSmrg fi 5273e9fcaa8aSmrg 5274e9fcaa8aSmrg# Very basic option parsing. These options are (a) specific to 5275e9fcaa8aSmrg# the libtool wrapper, (b) are identical between the wrapper 5276862bcd1aSmrg# /script/ and the wrapper /executable/ that is used only on 5277e9fcaa8aSmrg# windows platforms, and (c) all begin with the string "--lt-" 5278862bcd1aSmrg# (application programs are unlikely to have options that match 5279e9fcaa8aSmrg# this pattern). 5280e9fcaa8aSmrg# 5281e9fcaa8aSmrg# There are only two supported options: --lt-debug and 5282e9fcaa8aSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 5283e9fcaa8aSmrg# 5284e9fcaa8aSmrg# The first argument to this parsing function should be the 5285e9fcaa8aSmrg# script's $0 value, followed by "$@". 5286e9fcaa8aSmrglt_option_debug= 5287e9fcaa8aSmrgfunc_parse_lt_options () 5288e9fcaa8aSmrg{ 5289e9fcaa8aSmrg lt_script_arg0=\$0 5290e9fcaa8aSmrg shift 5291e9fcaa8aSmrg for lt_opt 5292e9fcaa8aSmrg do 5293e9fcaa8aSmrg case \"\$lt_opt\" in 5294e9fcaa8aSmrg --lt-debug) lt_option_debug=1 ;; 5295e9fcaa8aSmrg --lt-dump-script) 5296e9fcaa8aSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297e9fcaa8aSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298e9fcaa8aSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299e9fcaa8aSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 5300e9fcaa8aSmrg exit 0 5301e9fcaa8aSmrg ;; 5302e9fcaa8aSmrg --lt-*) 5303e9fcaa8aSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304e9fcaa8aSmrg exit 1 5305e9fcaa8aSmrg ;; 5306e9fcaa8aSmrg esac 5307e9fcaa8aSmrg done 5308e9fcaa8aSmrg 5309e9fcaa8aSmrg # Print the debug banner immediately: 5310e9fcaa8aSmrg if test -n \"\$lt_option_debug\"; then 5311862bcd1aSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312e9fcaa8aSmrg fi 5313e9fcaa8aSmrg} 5314e9fcaa8aSmrg 5315e9fcaa8aSmrg# Used when --lt-debug. Prints its arguments to stdout 5316e9fcaa8aSmrg# (redirection is the responsibility of the caller) 5317e9fcaa8aSmrgfunc_lt_dump_args () 5318e9fcaa8aSmrg{ 5319e9fcaa8aSmrg lt_dump_args_N=1; 5320e9fcaa8aSmrg for lt_arg 5321e9fcaa8aSmrg do 5322862bcd1aSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323e9fcaa8aSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324e9fcaa8aSmrg done 5325e9fcaa8aSmrg} 5326e9fcaa8aSmrg 5327e9fcaa8aSmrg# Core function for launching the target application 5328e9fcaa8aSmrgfunc_exec_program_core () 5329e9fcaa8aSmrg{ 533088de56ccSmrg" 5331e9fcaa8aSmrg case $host in 5332e9fcaa8aSmrg # Backslashes separate directories on plain windows 5333e9fcaa8aSmrg *-*-mingw | *-*-os2* | *-cegcc*) 5334e9fcaa8aSmrg $ECHO "\ 5335e9fcaa8aSmrg if test -n \"\$lt_option_debug\"; then 5336862bcd1aSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337e9fcaa8aSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5338e9fcaa8aSmrg fi 5339e9fcaa8aSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340e9fcaa8aSmrg" 5341e9fcaa8aSmrg ;; 5342e9fcaa8aSmrg 5343e9fcaa8aSmrg *) 5344e9fcaa8aSmrg $ECHO "\ 5345e9fcaa8aSmrg if test -n \"\$lt_option_debug\"; then 5346862bcd1aSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347e9fcaa8aSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5348e9fcaa8aSmrg fi 5349e9fcaa8aSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350e9fcaa8aSmrg" 5351e9fcaa8aSmrg ;; 5352e9fcaa8aSmrg esac 5353e9fcaa8aSmrg $ECHO "\ 5354e9fcaa8aSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355e9fcaa8aSmrg exit 1 5356e9fcaa8aSmrg} 5357e9fcaa8aSmrg 5358e9fcaa8aSmrg# A function to encapsulate launching the target application 5359e9fcaa8aSmrg# Strips options in the --lt-* namespace from \$@ and 5360e9fcaa8aSmrg# launches target application with the remaining arguments. 5361e9fcaa8aSmrgfunc_exec_program () 5362e9fcaa8aSmrg{ 5363eb411b4bSmrg case \" \$* \" in 5364eb411b4bSmrg *\\ --lt-*) 5365eb411b4bSmrg for lt_wr_arg 5366eb411b4bSmrg do 5367eb411b4bSmrg case \$lt_wr_arg in 5368eb411b4bSmrg --lt-*) ;; 5369eb411b4bSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370eb411b4bSmrg esac 5371eb411b4bSmrg shift 5372eb411b4bSmrg done ;; 5373eb411b4bSmrg esac 5374e9fcaa8aSmrg func_exec_program_core \${1+\"\$@\"} 5375e9fcaa8aSmrg} 5376e9fcaa8aSmrg 5377e9fcaa8aSmrg # Parse options 5378e9fcaa8aSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 53791ab64890Smrg 538088de56ccSmrg # Find the directory that this script lives in. 5381e9fcaa8aSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 538288de56ccSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 53831ab64890Smrg 538488de56ccSmrg # Follow symbolic links until we get to the real thisdir. 5385e9fcaa8aSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 538688de56ccSmrg while test -n \"\$file\"; do 5387e9fcaa8aSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 53881ab64890Smrg 538988de56ccSmrg # If there was a directory component, then change thisdir. 539088de56ccSmrg if test \"x\$destdir\" != \"x\$file\"; then 539188de56ccSmrg case \"\$destdir\" in 539288de56ccSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 539388de56ccSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394b4ee4795Smrg esac 539588de56ccSmrg fi 53961ab64890Smrg 5397e9fcaa8aSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398e9fcaa8aSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 539988de56ccSmrg done 54001ab64890Smrg 540188de56ccSmrg # Usually 'no', except on cygwin/mingw when embedded into 540288de56ccSmrg # the cwrapper. 5403e9fcaa8aSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 540488de56ccSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 540588de56ccSmrg # special case for '.' 540688de56ccSmrg if test \"\$thisdir\" = \".\"; then 540788de56ccSmrg thisdir=\`pwd\` 540888de56ccSmrg fi 540988de56ccSmrg # remove .libs from thisdir 541088de56ccSmrg case \"\$thisdir\" in 5411e9fcaa8aSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 541288de56ccSmrg $objdir ) thisdir=. ;; 541388de56ccSmrg esac 541488de56ccSmrg fi 541588de56ccSmrg 541688de56ccSmrg # Try to get the absolute directory name. 541788de56ccSmrg absdir=\`cd \"\$thisdir\" && pwd\` 541888de56ccSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 541988de56ccSmrg" 542088de56ccSmrg 5421862bcd1aSmrg if test yes = "$fast_install"; then 542288de56ccSmrg $ECHO "\ 542388de56ccSmrg program=lt-'$outputname'$exeext 542488de56ccSmrg progdir=\"\$thisdir/$objdir\" 542588de56ccSmrg 542688de56ccSmrg if test ! -f \"\$progdir/\$program\" || 5427862bcd1aSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 542888de56ccSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 542988de56ccSmrg 543088de56ccSmrg file=\"\$\$-\$program\" 543188de56ccSmrg 543288de56ccSmrg if test ! -d \"\$progdir\"; then 543388de56ccSmrg $MKDIR \"\$progdir\" 543488de56ccSmrg else 543588de56ccSmrg $RM \"\$progdir/\$file\" 543688de56ccSmrg fi" 543788de56ccSmrg 543888de56ccSmrg $ECHO "\ 543988de56ccSmrg 544088de56ccSmrg # relink executable if necessary 544188de56ccSmrg if test -n \"\$relink_command\"; then 544288de56ccSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 544388de56ccSmrg else 5444862bcd1aSmrg \$ECHO \"\$relink_command_output\" >&2 544588de56ccSmrg $RM \"\$progdir/\$file\" 544688de56ccSmrg exit 1 5447b4ee4795Smrg fi 544888de56ccSmrg fi 54491ab64890Smrg 545088de56ccSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 545188de56ccSmrg { $RM \"\$progdir/\$program\"; 545288de56ccSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 545388de56ccSmrg $RM \"\$progdir/\$file\" 545488de56ccSmrg fi" 545588de56ccSmrg else 545688de56ccSmrg $ECHO "\ 545788de56ccSmrg program='$outputname' 545888de56ccSmrg progdir=\"\$thisdir/$objdir\" 545988de56ccSmrg" 5460b4ee4795Smrg fi 54611ab64890Smrg 546288de56ccSmrg $ECHO "\ 54631ab64890Smrg 546488de56ccSmrg if test -f \"\$progdir/\$program\"; then" 54651ab64890Smrg 5466e9fcaa8aSmrg # fixup the dll searchpath if we need to. 5467e9fcaa8aSmrg # 5468e9fcaa8aSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5469e9fcaa8aSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5470e9fcaa8aSmrg # libraries must come first. 5471e9fcaa8aSmrg if test -n "$dllsearchpath"; then 5472e9fcaa8aSmrg $ECHO "\ 5473e9fcaa8aSmrg # Add the dll search path components to the executable PATH 5474e9fcaa8aSmrg PATH=$dllsearchpath:\$PATH 5475e9fcaa8aSmrg" 5476e9fcaa8aSmrg fi 5477e9fcaa8aSmrg 547888de56ccSmrg # Export our shlibpath_var if we have one. 5479862bcd1aSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 548088de56ccSmrg $ECHO "\ 548188de56ccSmrg # Add our own library path to $shlibpath_var 548288de56ccSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 548388de56ccSmrg 548488de56ccSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 548588de56ccSmrg # The second colon is a workaround for a bug in BeOS R4 sed 5486e9fcaa8aSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 54871ab64890Smrg 548888de56ccSmrg export $shlibpath_var 548988de56ccSmrg" 5490b4ee4795Smrg fi 54911ab64890Smrg 549288de56ccSmrg $ECHO "\ 549388de56ccSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 549488de56ccSmrg # Run the actual program with our arguments. 5495e9fcaa8aSmrg func_exec_program \${1+\"\$@\"} 549688de56ccSmrg fi 549788de56ccSmrg else 549888de56ccSmrg # The program doesn't exist. 5499862bcd1aSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 550088de56ccSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501e9fcaa8aSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 550288de56ccSmrg exit 1 550388de56ccSmrg fi 550488de56ccSmrgfi\ 550588de56ccSmrg" 550688de56ccSmrg} 55071ab64890Smrg 55081ab64890Smrg 550988de56ccSmrg# func_emit_cwrapperexe_src 551088de56ccSmrg# emit the source code for a wrapper executable on stdout 551188de56ccSmrg# Must ONLY be called from within func_mode_link because 551288de56ccSmrg# it depends on a number of variable set therein. 551388de56ccSmrgfunc_emit_cwrapperexe_src () 551488de56ccSmrg{ 551588de56ccSmrg cat <<EOF 55161ab64890Smrg 551788de56ccSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518862bcd1aSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 55191ab64890Smrg 552088de56ccSmrg The $output program cannot be directly executed until all the libtool 552188de56ccSmrg libraries that it depends on are installed. 55221ab64890Smrg 552388de56ccSmrg This wrapper executable should never be moved out of the build directory. 552488de56ccSmrg If it is, it will not operate correctly. 552588de56ccSmrg*/ 552688de56ccSmrgEOF 552788de56ccSmrg cat <<"EOF" 5528e9fcaa8aSmrg#ifdef _MSC_VER 5529e9fcaa8aSmrg# define _CRT_SECURE_NO_DEPRECATE 1 5530e9fcaa8aSmrg#endif 553188de56ccSmrg#include <stdio.h> 553288de56ccSmrg#include <stdlib.h> 553388de56ccSmrg#ifdef _MSC_VER 553488de56ccSmrg# include <direct.h> 553588de56ccSmrg# include <process.h> 553688de56ccSmrg# include <io.h> 553788de56ccSmrg#else 553888de56ccSmrg# include <unistd.h> 553988de56ccSmrg# include <stdint.h> 554088de56ccSmrg# ifdef __CYGWIN__ 554188de56ccSmrg# include <io.h> 5542e9fcaa8aSmrg# endif 5543e9fcaa8aSmrg#endif 5544e9fcaa8aSmrg#include <malloc.h> 5545e9fcaa8aSmrg#include <stdarg.h> 5546e9fcaa8aSmrg#include <assert.h> 5547e9fcaa8aSmrg#include <string.h> 5548e9fcaa8aSmrg#include <ctype.h> 5549e9fcaa8aSmrg#include <errno.h> 5550e9fcaa8aSmrg#include <fcntl.h> 5551e9fcaa8aSmrg#include <sys/stat.h> 5552e9fcaa8aSmrg 5553862bcd1aSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554862bcd1aSmrg 5555e9fcaa8aSmrg/* declarations of non-ANSI functions */ 5556862bcd1aSmrg#if defined __MINGW32__ 5557e9fcaa8aSmrg# ifdef __STRICT_ANSI__ 5558e9fcaa8aSmrgint _putenv (const char *); 5559e9fcaa8aSmrg# endif 5560862bcd1aSmrg#elif defined __CYGWIN__ 5561e9fcaa8aSmrg# ifdef __STRICT_ANSI__ 556288de56ccSmrgchar *realpath (const char *, char *); 556388de56ccSmrgint putenv (char *); 556488de56ccSmrgint setenv (const char *, const char *, int); 556588de56ccSmrg# endif 5566862bcd1aSmrg/* #elif defined other_platform || defined ... */ 5567e9fcaa8aSmrg#endif 5568e9fcaa8aSmrg 5569e9fcaa8aSmrg/* portability defines, excluding path handling macros */ 5570862bcd1aSmrg#if defined _MSC_VER 5571e9fcaa8aSmrg# define setmode _setmode 5572e9fcaa8aSmrg# define stat _stat 5573e9fcaa8aSmrg# define chmod _chmod 5574e9fcaa8aSmrg# define getcwd _getcwd 5575e9fcaa8aSmrg# define putenv _putenv 5576e9fcaa8aSmrg# define S_IXUSR _S_IEXEC 5577862bcd1aSmrg#elif defined __MINGW32__ 5578e9fcaa8aSmrg# define setmode _setmode 5579e9fcaa8aSmrg# define stat _stat 5580e9fcaa8aSmrg# define chmod _chmod 5581e9fcaa8aSmrg# define getcwd _getcwd 5582e9fcaa8aSmrg# define putenv _putenv 5583862bcd1aSmrg#elif defined __CYGWIN__ 5584e9fcaa8aSmrg# define HAVE_SETENV 5585e9fcaa8aSmrg# define FOPEN_WB "wb" 5586862bcd1aSmrg/* #elif defined other platforms ... */ 558788de56ccSmrg#endif 55881ab64890Smrg 5589862bcd1aSmrg#if defined PATH_MAX 559088de56ccSmrg# define LT_PATHMAX PATH_MAX 5591862bcd1aSmrg#elif defined MAXPATHLEN 559288de56ccSmrg# define LT_PATHMAX MAXPATHLEN 559388de56ccSmrg#else 559488de56ccSmrg# define LT_PATHMAX 1024 559588de56ccSmrg#endif 55961ab64890Smrg 559788de56ccSmrg#ifndef S_IXOTH 559888de56ccSmrg# define S_IXOTH 0 559988de56ccSmrg#endif 560088de56ccSmrg#ifndef S_IXGRP 560188de56ccSmrg# define S_IXGRP 0 560288de56ccSmrg#endif 56031ab64890Smrg 5604e9fcaa8aSmrg/* path handling portability macros */ 560588de56ccSmrg#ifndef DIR_SEPARATOR 560688de56ccSmrg# define DIR_SEPARATOR '/' 560788de56ccSmrg# define PATH_SEPARATOR ':' 560888de56ccSmrg#endif 56091ab64890Smrg 5610862bcd1aSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611862bcd1aSmrg defined __OS2__ 561288de56ccSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 561388de56ccSmrg# define FOPEN_WB "wb" 561488de56ccSmrg# ifndef DIR_SEPARATOR_2 561588de56ccSmrg# define DIR_SEPARATOR_2 '\\' 561688de56ccSmrg# endif 561788de56ccSmrg# ifndef PATH_SEPARATOR_2 561888de56ccSmrg# define PATH_SEPARATOR_2 ';' 561988de56ccSmrg# endif 562088de56ccSmrg#endif 56211ab64890Smrg 562288de56ccSmrg#ifndef DIR_SEPARATOR_2 562388de56ccSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 562488de56ccSmrg#else /* DIR_SEPARATOR_2 */ 562588de56ccSmrg# define IS_DIR_SEPARATOR(ch) \ 562688de56ccSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 562788de56ccSmrg#endif /* DIR_SEPARATOR_2 */ 56281ab64890Smrg 562988de56ccSmrg#ifndef PATH_SEPARATOR_2 563088de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 563188de56ccSmrg#else /* PATH_SEPARATOR_2 */ 563288de56ccSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 563388de56ccSmrg#endif /* PATH_SEPARATOR_2 */ 56341ab64890Smrg 563588de56ccSmrg#ifndef FOPEN_WB 563688de56ccSmrg# define FOPEN_WB "w" 563788de56ccSmrg#endif 563888de56ccSmrg#ifndef _O_BINARY 563988de56ccSmrg# define _O_BINARY 0 564088de56ccSmrg#endif 56411ab64890Smrg 564288de56ccSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 564388de56ccSmrg#define XFREE(stale) do { \ 5644862bcd1aSmrg if (stale) { free (stale); stale = 0; } \ 564588de56ccSmrg} while (0) 56461ab64890Smrg 5647862bcd1aSmrg#if defined LT_DEBUGWRAPPER 5648e9fcaa8aSmrgstatic int lt_debug = 1; 564988de56ccSmrg#else 5650e9fcaa8aSmrgstatic int lt_debug = 0; 565188de56ccSmrg#endif 56521ab64890Smrg 5653e9fcaa8aSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 56541ab64890Smrg 565588de56ccSmrgvoid *xmalloc (size_t num); 565688de56ccSmrgchar *xstrdup (const char *string); 565788de56ccSmrgconst char *base_name (const char *name); 565888de56ccSmrgchar *find_executable (const char *wrapper); 565988de56ccSmrgchar *chase_symlinks (const char *pathspec); 566088de56ccSmrgint make_executable (const char *path); 566188de56ccSmrgint check_executable (const char *path); 566288de56ccSmrgchar *strendzap (char *str, const char *pat); 5663e9fcaa8aSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664e9fcaa8aSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5665e9fcaa8aSmrgstatic const char *nonnull (const char *s); 5666e9fcaa8aSmrgstatic const char *nonempty (const char *s); 566788de56ccSmrgvoid lt_setenv (const char *name, const char *value); 566888de56ccSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 566988de56ccSmrgvoid lt_update_exe_path (const char *name, const char *value); 567088de56ccSmrgvoid lt_update_lib_path (const char *name, const char *value); 5671e9fcaa8aSmrgchar **prepare_spawn (char **argv); 5672e9fcaa8aSmrgvoid lt_dump_script (FILE *f); 567388de56ccSmrgEOF 567488de56ccSmrg 567588de56ccSmrg cat <<EOF 5676862bcd1aSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677862bcd1aSmrg# define externally_visible volatile 5678862bcd1aSmrg#else 5679862bcd1aSmrg# define externally_visible __attribute__((externally_visible)) volatile 5680862bcd1aSmrg#endif 5681862bcd1aSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 568288de56ccSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 568388de56ccSmrgEOF 56841ab64890Smrg 5685862bcd1aSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686e9fcaa8aSmrg func_to_host_path "$temp_rpath" 568788de56ccSmrg cat <<EOF 5688e9fcaa8aSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 568988de56ccSmrgEOF 569088de56ccSmrg else 569188de56ccSmrg cat <<"EOF" 569288de56ccSmrgconst char * LIB_PATH_VALUE = ""; 569388de56ccSmrgEOF 5694b4ee4795Smrg fi 56951ab64890Smrg 569688de56ccSmrg if test -n "$dllsearchpath"; then 5697e9fcaa8aSmrg func_to_host_path "$dllsearchpath:" 569888de56ccSmrg cat <<EOF 569988de56ccSmrgconst char * EXE_PATH_VARNAME = "PATH"; 5700e9fcaa8aSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701b4ee4795SmrgEOF 5702b4ee4795Smrg else 570388de56ccSmrg cat <<"EOF" 570488de56ccSmrgconst char * EXE_PATH_VARNAME = ""; 570588de56ccSmrgconst char * EXE_PATH_VALUE = ""; 570688de56ccSmrgEOF 5707b4ee4795Smrg fi 570888de56ccSmrg 5709862bcd1aSmrg if test yes = "$fast_install"; then 571088de56ccSmrg cat <<EOF 571188de56ccSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 571288de56ccSmrgEOF 5713b4ee4795Smrg else 571488de56ccSmrg cat <<EOF 571588de56ccSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 571688de56ccSmrgEOF 5717b4ee4795Smrg fi 57181ab64890Smrg 57191ab64890Smrg 572088de56ccSmrg cat <<"EOF" 57211ab64890Smrg 572288de56ccSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 57231ab64890Smrg 572488de56ccSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 572588de56ccSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726e9fcaa8aSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 57271ab64890Smrg 572888de56ccSmrgint 572988de56ccSmrgmain (int argc, char *argv[]) 573088de56ccSmrg{ 573188de56ccSmrg char **newargz; 573288de56ccSmrg int newargc; 573388de56ccSmrg char *tmp_pathspec; 573488de56ccSmrg char *actual_cwrapper_path; 573588de56ccSmrg char *actual_cwrapper_name; 573688de56ccSmrg char *target_name; 573788de56ccSmrg char *lt_argv_zero; 5738862bcd1aSmrg int rval = 127; 57391ab64890Smrg 574088de56ccSmrg int i; 57411ab64890Smrg 574288de56ccSmrg program_name = (char *) xstrdup (base_name (argv[0])); 5743862bcd1aSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 57441ab64890Smrg 5745e9fcaa8aSmrg /* very simple arg parsing; don't want to rely on getopt 5746e9fcaa8aSmrg * also, copy all non cwrapper options to newargz, except 5747e9fcaa8aSmrg * argz[0], which is handled differently 5748e9fcaa8aSmrg */ 5749e9fcaa8aSmrg newargc=0; 575088de56ccSmrg for (i = 1; i < argc; i++) 575188de56ccSmrg { 5752862bcd1aSmrg if (STREQ (argv[i], dumpscript_opt)) 575388de56ccSmrg { 575488de56ccSmrgEOF 5755862bcd1aSmrg case $host in 575688de56ccSmrg *mingw* | *cygwin* ) 575788de56ccSmrg # make stdout use "unix" line endings 575888de56ccSmrg echo " setmode(1,_O_BINARY);" 575988de56ccSmrg ;; 576088de56ccSmrg esac 57611ab64890Smrg 576288de56ccSmrg cat <<"EOF" 5763e9fcaa8aSmrg lt_dump_script (stdout); 576488de56ccSmrg return 0; 576588de56ccSmrg } 5766862bcd1aSmrg if (STREQ (argv[i], debug_opt)) 5767e9fcaa8aSmrg { 5768e9fcaa8aSmrg lt_debug = 1; 5769e9fcaa8aSmrg continue; 5770e9fcaa8aSmrg } 5771862bcd1aSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5772e9fcaa8aSmrg { 5773e9fcaa8aSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774e9fcaa8aSmrg namespace, but it is not one of the ones we know about and 5775e9fcaa8aSmrg have already dealt with, above (inluding dump-script), then 5776e9fcaa8aSmrg report an error. Otherwise, targets might begin to believe 5777e9fcaa8aSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778e9fcaa8aSmrg namespace. The first time any user complains about this, we'll 5779e9fcaa8aSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780e9fcaa8aSmrg or a configure.ac-settable value. 5781e9fcaa8aSmrg */ 5782e9fcaa8aSmrg lt_fatal (__FILE__, __LINE__, 5783e9fcaa8aSmrg "unrecognized %s option: '%s'", 5784e9fcaa8aSmrg ltwrapper_option_prefix, argv[i]); 5785e9fcaa8aSmrg } 5786e9fcaa8aSmrg /* otherwise ... */ 5787e9fcaa8aSmrg newargz[++newargc] = xstrdup (argv[i]); 578888de56ccSmrg } 5789e9fcaa8aSmrg newargz[++newargc] = NULL; 5790e9fcaa8aSmrg 5791e9fcaa8aSmrgEOF 5792e9fcaa8aSmrg cat <<EOF 5793e9fcaa8aSmrg /* The GNU banner must be the first non-error debug message */ 5794862bcd1aSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795e9fcaa8aSmrgEOF 5796e9fcaa8aSmrg cat <<"EOF" 5797e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 57991ab64890Smrg 580088de56ccSmrg tmp_pathspec = find_executable (argv[0]); 580188de56ccSmrg if (tmp_pathspec == NULL) 5802e9fcaa8aSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, 5804e9fcaa8aSmrg "(main) found exe (before symlink chase) at: %s\n", 5805e9fcaa8aSmrg tmp_pathspec); 580688de56ccSmrg 580788de56ccSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, 5809e9fcaa8aSmrg "(main) found exe (after symlink chase) at: %s\n", 5810e9fcaa8aSmrg actual_cwrapper_path); 581188de56ccSmrg XFREE (tmp_pathspec); 581288de56ccSmrg 5813e9fcaa8aSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 581488de56ccSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 581588de56ccSmrg 581688de56ccSmrg /* wrapper name transforms */ 581788de56ccSmrg strendzap (actual_cwrapper_name, ".exe"); 581888de56ccSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 581988de56ccSmrg XFREE (actual_cwrapper_name); 582088de56ccSmrg actual_cwrapper_name = tmp_pathspec; 582188de56ccSmrg tmp_pathspec = 0; 582288de56ccSmrg 582388de56ccSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 582488de56ccSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 582588de56ccSmrg strendzap (target_name, ".exe"); 582688de56ccSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 582788de56ccSmrg XFREE (target_name); 582888de56ccSmrg target_name = tmp_pathspec; 582988de56ccSmrg tmp_pathspec = 0; 583088de56ccSmrg 5831e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, 5832e9fcaa8aSmrg "(main) libtool target name: %s\n", 5833e9fcaa8aSmrg target_name); 583488de56ccSmrgEOF 58351ab64890Smrg 583688de56ccSmrg cat <<EOF 583788de56ccSmrg newargz[0] = 583888de56ccSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 583988de56ccSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 584088de56ccSmrg strcpy (newargz[0], actual_cwrapper_path); 584188de56ccSmrg strcat (newargz[0], "$objdir"); 584288de56ccSmrg strcat (newargz[0], "/"); 584388de56ccSmrgEOF 58441ab64890Smrg 584588de56ccSmrg cat <<"EOF" 584688de56ccSmrg /* stop here, and copy so we don't have to do this twice */ 584788de56ccSmrg tmp_pathspec = xstrdup (newargz[0]); 58481ab64890Smrg 584988de56ccSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 585088de56ccSmrg strcat (newargz[0], actual_cwrapper_name); 58511ab64890Smrg 585288de56ccSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 585388de56ccSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 585488de56ccSmrg XFREE (tmp_pathspec); 585588de56ccSmrg tmp_pathspec = NULL; 585688de56ccSmrgEOF 58571ab64890Smrg 585888de56ccSmrg case $host_os in 585988de56ccSmrg mingw*) 586088de56ccSmrg cat <<"EOF" 586188de56ccSmrg { 586288de56ccSmrg char* p; 586388de56ccSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 586488de56ccSmrg { 586588de56ccSmrg *p = '/'; 586688de56ccSmrg } 586788de56ccSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 586888de56ccSmrg { 586988de56ccSmrg *p = '/'; 587088de56ccSmrg } 587188de56ccSmrg } 587288de56ccSmrgEOF 587388de56ccSmrg ;; 587488de56ccSmrg esac 58751ab64890Smrg 587688de56ccSmrg cat <<"EOF" 587788de56ccSmrg XFREE (target_name); 587888de56ccSmrg XFREE (actual_cwrapper_path); 587988de56ccSmrg XFREE (actual_cwrapper_name); 58801ab64890Smrg 588188de56ccSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 588288de56ccSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883e9fcaa8aSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884e9fcaa8aSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885e9fcaa8aSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5886e9fcaa8aSmrg libraries must come first. */ 588788de56ccSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888e9fcaa8aSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 58891ab64890Smrg 5890e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891e9fcaa8aSmrg nonnull (lt_argv_zero)); 589288de56ccSmrg for (i = 0; i < newargc; i++) 589388de56ccSmrg { 5894e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895e9fcaa8aSmrg i, nonnull (newargz[i])); 589688de56ccSmrg } 58971ab64890Smrg 589888de56ccSmrgEOF 58991ab64890Smrg 590088de56ccSmrg case $host_os in 590188de56ccSmrg mingw*) 590288de56ccSmrg cat <<"EOF" 590388de56ccSmrg /* execv doesn't actually work on mingw as expected on unix */ 5904e9fcaa8aSmrg newargz = prepare_spawn (newargz); 5905862bcd1aSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 590688de56ccSmrg if (rval == -1) 590788de56ccSmrg { 590888de56ccSmrg /* failed to start process */ 5909e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, 5910e9fcaa8aSmrg "(main) failed to launch target \"%s\": %s\n", 5911e9fcaa8aSmrg lt_argv_zero, nonnull (strerror (errno))); 591288de56ccSmrg return 127; 591388de56ccSmrg } 591488de56ccSmrg return rval; 591588de56ccSmrgEOF 591688de56ccSmrg ;; 591788de56ccSmrg *) 591888de56ccSmrg cat <<"EOF" 591988de56ccSmrg execv (lt_argv_zero, newargz); 592088de56ccSmrg return rval; /* =127, but avoids unused variable warning */ 592188de56ccSmrgEOF 592288de56ccSmrg ;; 592388de56ccSmrg esac 59241ab64890Smrg 592588de56ccSmrg cat <<"EOF" 592688de56ccSmrg} 59271ab64890Smrg 592888de56ccSmrgvoid * 592988de56ccSmrgxmalloc (size_t num) 593088de56ccSmrg{ 593188de56ccSmrg void *p = (void *) malloc (num); 593288de56ccSmrg if (!p) 5933e9fcaa8aSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 59341ab64890Smrg 593588de56ccSmrg return p; 593688de56ccSmrg} 59371ab64890Smrg 593888de56ccSmrgchar * 593988de56ccSmrgxstrdup (const char *string) 594088de56ccSmrg{ 594188de56ccSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 594288de56ccSmrg string) : NULL; 594388de56ccSmrg} 59441ab64890Smrg 594588de56ccSmrgconst char * 594688de56ccSmrgbase_name (const char *name) 594788de56ccSmrg{ 594888de56ccSmrg const char *base; 5949b4ee4795Smrg 5950862bcd1aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 595188de56ccSmrg /* Skip over the disk name in MSDOS pathnames. */ 595288de56ccSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 595388de56ccSmrg name += 2; 595488de56ccSmrg#endif 5955b4ee4795Smrg 595688de56ccSmrg for (base = name; *name; name++) 595788de56ccSmrg if (IS_DIR_SEPARATOR (*name)) 595888de56ccSmrg base = name + 1; 595988de56ccSmrg return base; 596088de56ccSmrg} 5961b4ee4795Smrg 596288de56ccSmrgint 596388de56ccSmrgcheck_executable (const char *path) 596488de56ccSmrg{ 596588de56ccSmrg struct stat st; 5966b4ee4795Smrg 5967e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968e9fcaa8aSmrg nonempty (path)); 596988de56ccSmrg if ((!path) || (!*path)) 597088de56ccSmrg return 0; 5971b4ee4795Smrg 597288de56ccSmrg if ((stat (path, &st) >= 0) 597388de56ccSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 597488de56ccSmrg return 1; 597588de56ccSmrg else 597688de56ccSmrg return 0; 597788de56ccSmrg} 59781ab64890Smrg 597988de56ccSmrgint 598088de56ccSmrgmake_executable (const char *path) 598188de56ccSmrg{ 598288de56ccSmrg int rval = 0; 598388de56ccSmrg struct stat st; 59841ab64890Smrg 5985e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986e9fcaa8aSmrg nonempty (path)); 598788de56ccSmrg if ((!path) || (!*path)) 598888de56ccSmrg return 0; 59891ab64890Smrg 599088de56ccSmrg if (stat (path, &st) >= 0) 599188de56ccSmrg { 599288de56ccSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 599388de56ccSmrg } 599488de56ccSmrg return rval; 599588de56ccSmrg} 5996b4ee4795Smrg 599788de56ccSmrg/* Searches for the full path of the wrapper. Returns 599888de56ccSmrg newly allocated full path name if found, NULL otherwise 599988de56ccSmrg Does not chase symlinks, even on platforms that support them. 600088de56ccSmrg*/ 600188de56ccSmrgchar * 600288de56ccSmrgfind_executable (const char *wrapper) 600388de56ccSmrg{ 600488de56ccSmrg int has_slash = 0; 600588de56ccSmrg const char *p; 600688de56ccSmrg const char *p_next; 600788de56ccSmrg /* static buffer for getcwd */ 600888de56ccSmrg char tmp[LT_PATHMAX + 1]; 6009862bcd1aSmrg size_t tmp_len; 601088de56ccSmrg char *concat_name; 6011b4ee4795Smrg 6012e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013e9fcaa8aSmrg nonempty (wrapper)); 6014b4ee4795Smrg 601588de56ccSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 601688de56ccSmrg return NULL; 6017b4ee4795Smrg 601888de56ccSmrg /* Absolute path? */ 6019862bcd1aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 602088de56ccSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 602188de56ccSmrg { 602288de56ccSmrg concat_name = xstrdup (wrapper); 602388de56ccSmrg if (check_executable (concat_name)) 602488de56ccSmrg return concat_name; 602588de56ccSmrg XFREE (concat_name); 602688de56ccSmrg } 602788de56ccSmrg else 602888de56ccSmrg { 602988de56ccSmrg#endif 603088de56ccSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 603188de56ccSmrg { 603288de56ccSmrg concat_name = xstrdup (wrapper); 603388de56ccSmrg if (check_executable (concat_name)) 603488de56ccSmrg return concat_name; 603588de56ccSmrg XFREE (concat_name); 603688de56ccSmrg } 6037862bcd1aSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 603888de56ccSmrg } 603988de56ccSmrg#endif 60401ab64890Smrg 604188de56ccSmrg for (p = wrapper; *p; p++) 604288de56ccSmrg if (*p == '/') 604388de56ccSmrg { 604488de56ccSmrg has_slash = 1; 604588de56ccSmrg break; 604688de56ccSmrg } 604788de56ccSmrg if (!has_slash) 604888de56ccSmrg { 604988de56ccSmrg /* no slashes; search PATH */ 605088de56ccSmrg const char *path = getenv ("PATH"); 605188de56ccSmrg if (path != NULL) 605288de56ccSmrg { 605388de56ccSmrg for (p = path; *p; p = p_next) 605488de56ccSmrg { 605588de56ccSmrg const char *q; 605688de56ccSmrg size_t p_len; 605788de56ccSmrg for (q = p; *q; q++) 605888de56ccSmrg if (IS_PATH_SEPARATOR (*q)) 605988de56ccSmrg break; 6060862bcd1aSmrg p_len = (size_t) (q - p); 606188de56ccSmrg p_next = (*q == '\0' ? q : q + 1); 606288de56ccSmrg if (p_len == 0) 606388de56ccSmrg { 606488de56ccSmrg /* empty path: current directory */ 606588de56ccSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6066e9fcaa8aSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067e9fcaa8aSmrg nonnull (strerror (errno))); 606888de56ccSmrg tmp_len = strlen (tmp); 606988de56ccSmrg concat_name = 607088de56ccSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 607188de56ccSmrg memcpy (concat_name, tmp, tmp_len); 607288de56ccSmrg concat_name[tmp_len] = '/'; 607388de56ccSmrg strcpy (concat_name + tmp_len + 1, wrapper); 607488de56ccSmrg } 607588de56ccSmrg else 607688de56ccSmrg { 607788de56ccSmrg concat_name = 607888de56ccSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 607988de56ccSmrg memcpy (concat_name, p, p_len); 608088de56ccSmrg concat_name[p_len] = '/'; 608188de56ccSmrg strcpy (concat_name + p_len + 1, wrapper); 608288de56ccSmrg } 608388de56ccSmrg if (check_executable (concat_name)) 608488de56ccSmrg return concat_name; 608588de56ccSmrg XFREE (concat_name); 608688de56ccSmrg } 608788de56ccSmrg } 608888de56ccSmrg /* not found in PATH; assume curdir */ 608988de56ccSmrg } 609088de56ccSmrg /* Relative path | not found in path: prepend cwd */ 609188de56ccSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6092e9fcaa8aSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093e9fcaa8aSmrg nonnull (strerror (errno))); 609488de56ccSmrg tmp_len = strlen (tmp); 609588de56ccSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 609688de56ccSmrg memcpy (concat_name, tmp, tmp_len); 609788de56ccSmrg concat_name[tmp_len] = '/'; 609888de56ccSmrg strcpy (concat_name + tmp_len + 1, wrapper); 60991ab64890Smrg 610088de56ccSmrg if (check_executable (concat_name)) 610188de56ccSmrg return concat_name; 610288de56ccSmrg XFREE (concat_name); 610388de56ccSmrg return NULL; 610488de56ccSmrg} 61051ab64890Smrg 610688de56ccSmrgchar * 610788de56ccSmrgchase_symlinks (const char *pathspec) 610888de56ccSmrg{ 610988de56ccSmrg#ifndef S_ISLNK 611088de56ccSmrg return xstrdup (pathspec); 611188de56ccSmrg#else 611288de56ccSmrg char buf[LT_PATHMAX]; 611388de56ccSmrg struct stat s; 611488de56ccSmrg char *tmp_pathspec = xstrdup (pathspec); 611588de56ccSmrg char *p; 611688de56ccSmrg int has_symlinks = 0; 611788de56ccSmrg while (strlen (tmp_pathspec) && !has_symlinks) 611888de56ccSmrg { 6119e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, 6120e9fcaa8aSmrg "checking path component for symlinks: %s\n", 6121e9fcaa8aSmrg tmp_pathspec); 612288de56ccSmrg if (lstat (tmp_pathspec, &s) == 0) 612388de56ccSmrg { 612488de56ccSmrg if (S_ISLNK (s.st_mode) != 0) 612588de56ccSmrg { 612688de56ccSmrg has_symlinks = 1; 612788de56ccSmrg break; 612888de56ccSmrg } 61291ab64890Smrg 613088de56ccSmrg /* search backwards for last DIR_SEPARATOR */ 613188de56ccSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 613288de56ccSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 613388de56ccSmrg p--; 613488de56ccSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 613588de56ccSmrg { 613688de56ccSmrg /* no more DIR_SEPARATORS left */ 613788de56ccSmrg break; 613888de56ccSmrg } 613988de56ccSmrg *p = '\0'; 614088de56ccSmrg } 614188de56ccSmrg else 614288de56ccSmrg { 6143e9fcaa8aSmrg lt_fatal (__FILE__, __LINE__, 6144e9fcaa8aSmrg "error accessing file \"%s\": %s", 6145e9fcaa8aSmrg tmp_pathspec, nonnull (strerror (errno))); 614688de56ccSmrg } 614788de56ccSmrg } 614888de56ccSmrg XFREE (tmp_pathspec); 61491ab64890Smrg 615088de56ccSmrg if (!has_symlinks) 615188de56ccSmrg { 615288de56ccSmrg return xstrdup (pathspec); 615388de56ccSmrg } 61541ab64890Smrg 615588de56ccSmrg tmp_pathspec = realpath (pathspec, buf); 615688de56ccSmrg if (tmp_pathspec == 0) 615788de56ccSmrg { 6158e9fcaa8aSmrg lt_fatal (__FILE__, __LINE__, 6159e9fcaa8aSmrg "could not follow symlinks for %s", pathspec); 616088de56ccSmrg } 616188de56ccSmrg return xstrdup (tmp_pathspec); 616288de56ccSmrg#endif 616388de56ccSmrg} 61641ab64890Smrg 616588de56ccSmrgchar * 616688de56ccSmrgstrendzap (char *str, const char *pat) 616788de56ccSmrg{ 616888de56ccSmrg size_t len, patlen; 61691ab64890Smrg 617088de56ccSmrg assert (str != NULL); 617188de56ccSmrg assert (pat != NULL); 61721ab64890Smrg 617388de56ccSmrg len = strlen (str); 617488de56ccSmrg patlen = strlen (pat); 61751ab64890Smrg 617688de56ccSmrg if (patlen <= len) 617788de56ccSmrg { 617888de56ccSmrg str += len - patlen; 6179862bcd1aSmrg if (STREQ (str, pat)) 618088de56ccSmrg *str = '\0'; 618188de56ccSmrg } 618288de56ccSmrg return str; 618388de56ccSmrg} 61841ab64890Smrg 6185e9fcaa8aSmrgvoid 6186e9fcaa8aSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6187e9fcaa8aSmrg{ 6188e9fcaa8aSmrg va_list args; 6189e9fcaa8aSmrg if (lt_debug) 6190e9fcaa8aSmrg { 6191e9fcaa8aSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192e9fcaa8aSmrg va_start (args, fmt); 6193e9fcaa8aSmrg (void) vfprintf (stderr, fmt, args); 6194e9fcaa8aSmrg va_end (args); 6195e9fcaa8aSmrg } 6196e9fcaa8aSmrg} 6197e9fcaa8aSmrg 619888de56ccSmrgstatic void 6199e9fcaa8aSmrglt_error_core (int exit_status, const char *file, 6200e9fcaa8aSmrg int line, const char *mode, 620188de56ccSmrg const char *message, va_list ap) 620288de56ccSmrg{ 6203e9fcaa8aSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 620488de56ccSmrg vfprintf (stderr, message, ap); 620588de56ccSmrg fprintf (stderr, ".\n"); 62061ab64890Smrg 620788de56ccSmrg if (exit_status >= 0) 620888de56ccSmrg exit (exit_status); 620988de56ccSmrg} 62101ab64890Smrg 621188de56ccSmrgvoid 6212e9fcaa8aSmrglt_fatal (const char *file, int line, const char *message, ...) 621388de56ccSmrg{ 621488de56ccSmrg va_list ap; 621588de56ccSmrg va_start (ap, message); 6216e9fcaa8aSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 621788de56ccSmrg va_end (ap); 621888de56ccSmrg} 62192e9c7c8cSmrg 6220e9fcaa8aSmrgstatic const char * 6221e9fcaa8aSmrgnonnull (const char *s) 6222e9fcaa8aSmrg{ 6223e9fcaa8aSmrg return s ? s : "(null)"; 6224e9fcaa8aSmrg} 6225e9fcaa8aSmrg 6226e9fcaa8aSmrgstatic const char * 6227e9fcaa8aSmrgnonempty (const char *s) 6228e9fcaa8aSmrg{ 6229e9fcaa8aSmrg return (s && !*s) ? "(empty)" : nonnull (s); 6230e9fcaa8aSmrg} 6231e9fcaa8aSmrg 623288de56ccSmrgvoid 623388de56ccSmrglt_setenv (const char *name, const char *value) 623488de56ccSmrg{ 6235e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, 6236e9fcaa8aSmrg "(lt_setenv) setting '%s' to '%s'\n", 6237e9fcaa8aSmrg nonnull (name), nonnull (value)); 623888de56ccSmrg { 623988de56ccSmrg#ifdef HAVE_SETENV 624088de56ccSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 624188de56ccSmrg char *str = xstrdup (value); 624288de56ccSmrg setenv (name, str, 1); 624388de56ccSmrg#else 6244862bcd1aSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 624588de56ccSmrg char *str = XMALLOC (char, len); 624688de56ccSmrg sprintf (str, "%s=%s", name, value); 624788de56ccSmrg if (putenv (str) != EXIT_SUCCESS) 624888de56ccSmrg { 624988de56ccSmrg XFREE (str); 625088de56ccSmrg } 625188de56ccSmrg#endif 625288de56ccSmrg } 625388de56ccSmrg} 62541ab64890Smrg 625588de56ccSmrgchar * 625688de56ccSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 625788de56ccSmrg{ 625888de56ccSmrg char *new_value; 625988de56ccSmrg if (orig_value && *orig_value) 626088de56ccSmrg { 6261862bcd1aSmrg size_t orig_value_len = strlen (orig_value); 6262862bcd1aSmrg size_t add_len = strlen (add); 626388de56ccSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 626488de56ccSmrg if (to_end) 626588de56ccSmrg { 626688de56ccSmrg strcpy (new_value, orig_value); 626788de56ccSmrg strcpy (new_value + orig_value_len, add); 626888de56ccSmrg } 626988de56ccSmrg else 627088de56ccSmrg { 627188de56ccSmrg strcpy (new_value, add); 627288de56ccSmrg strcpy (new_value + add_len, orig_value); 627388de56ccSmrg } 627488de56ccSmrg } 627588de56ccSmrg else 627688de56ccSmrg { 627788de56ccSmrg new_value = xstrdup (add); 627888de56ccSmrg } 627988de56ccSmrg return new_value; 628088de56ccSmrg} 62811ab64890Smrg 628288de56ccSmrgvoid 628388de56ccSmrglt_update_exe_path (const char *name, const char *value) 628488de56ccSmrg{ 6285e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, 6286e9fcaa8aSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287e9fcaa8aSmrg nonnull (name), nonnull (value)); 62881ab64890Smrg 628988de56ccSmrg if (name && *name && value && *value) 629088de56ccSmrg { 629188de56ccSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 629288de56ccSmrg /* some systems can't cope with a ':'-terminated path #' */ 6293862bcd1aSmrg size_t len = strlen (new_value); 6294862bcd1aSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 629588de56ccSmrg { 6296862bcd1aSmrg new_value[--len] = '\0'; 629788de56ccSmrg } 629888de56ccSmrg lt_setenv (name, new_value); 629988de56ccSmrg XFREE (new_value); 630088de56ccSmrg } 630188de56ccSmrg} 63021ab64890Smrg 630388de56ccSmrgvoid 630488de56ccSmrglt_update_lib_path (const char *name, const char *value) 630588de56ccSmrg{ 6306e9fcaa8aSmrg lt_debugprintf (__FILE__, __LINE__, 6307e9fcaa8aSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308e9fcaa8aSmrg nonnull (name), nonnull (value)); 63091ab64890Smrg 631088de56ccSmrg if (name && *name && value && *value) 631188de56ccSmrg { 631288de56ccSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 631388de56ccSmrg lt_setenv (name, new_value); 631488de56ccSmrg XFREE (new_value); 631588de56ccSmrg } 631688de56ccSmrg} 63171ab64890Smrg 6318e9fcaa8aSmrgEOF 6319e9fcaa8aSmrg case $host_os in 6320e9fcaa8aSmrg mingw*) 6321e9fcaa8aSmrg cat <<"EOF" 6322e9fcaa8aSmrg 6323e9fcaa8aSmrg/* Prepares an argument vector before calling spawn(). 6324e9fcaa8aSmrg Note that spawn() does not by itself call the command interpreter 6325e9fcaa8aSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326e9fcaa8aSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327e9fcaa8aSmrg GetVersionEx(&v); 6328e9fcaa8aSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329e9fcaa8aSmrg }) ? "cmd.exe" : "command.com"). 6330e9fcaa8aSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 6331e9fcaa8aSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332e9fcaa8aSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333e9fcaa8aSmrg special way: 6334e9fcaa8aSmrg - Space and tab are interpreted as delimiters. They are not treated as 6335e9fcaa8aSmrg delimiters if they are surrounded by double quotes: "...". 6336e9fcaa8aSmrg - Unescaped double quotes are removed from the input. Their only effect is 6337e9fcaa8aSmrg that within double quotes, space and tab are treated like normal 6338e9fcaa8aSmrg characters. 6339e9fcaa8aSmrg - Backslashes not followed by double quotes are not special. 6340e9fcaa8aSmrg - But 2*n+1 backslashes followed by a double quote become 6341e9fcaa8aSmrg n backslashes followed by a double quote (n >= 0): 6342e9fcaa8aSmrg \" -> " 6343e9fcaa8aSmrg \\\" -> \" 6344e9fcaa8aSmrg \\\\\" -> \\" 6345e9fcaa8aSmrg */ 6346e9fcaa8aSmrg#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" 6347e9fcaa8aSmrg#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" 6348e9fcaa8aSmrgchar ** 6349e9fcaa8aSmrgprepare_spawn (char **argv) 6350e9fcaa8aSmrg{ 6351e9fcaa8aSmrg size_t argc; 6352e9fcaa8aSmrg char **new_argv; 6353e9fcaa8aSmrg size_t i; 6354e9fcaa8aSmrg 6355e9fcaa8aSmrg /* Count number of arguments. */ 6356e9fcaa8aSmrg for (argc = 0; argv[argc] != NULL; argc++) 6357e9fcaa8aSmrg ; 6358e9fcaa8aSmrg 6359e9fcaa8aSmrg /* Allocate new argument vector. */ 6360e9fcaa8aSmrg new_argv = XMALLOC (char *, argc + 1); 6361e9fcaa8aSmrg 6362e9fcaa8aSmrg /* Put quoted arguments into the new argument vector. */ 6363e9fcaa8aSmrg for (i = 0; i < argc; i++) 6364e9fcaa8aSmrg { 6365e9fcaa8aSmrg const char *string = argv[i]; 6366e9fcaa8aSmrg 6367e9fcaa8aSmrg if (string[0] == '\0') 6368e9fcaa8aSmrg new_argv[i] = xstrdup ("\"\""); 6369e9fcaa8aSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370e9fcaa8aSmrg { 6371e9fcaa8aSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372e9fcaa8aSmrg size_t length; 6373e9fcaa8aSmrg unsigned int backslashes; 6374e9fcaa8aSmrg const char *s; 6375e9fcaa8aSmrg char *quoted_string; 6376e9fcaa8aSmrg char *p; 6377e9fcaa8aSmrg 6378e9fcaa8aSmrg length = 0; 6379e9fcaa8aSmrg backslashes = 0; 6380e9fcaa8aSmrg if (quote_around) 6381e9fcaa8aSmrg length++; 6382e9fcaa8aSmrg for (s = string; *s != '\0'; s++) 6383e9fcaa8aSmrg { 6384e9fcaa8aSmrg char c = *s; 6385e9fcaa8aSmrg if (c == '"') 6386e9fcaa8aSmrg length += backslashes + 1; 6387e9fcaa8aSmrg length++; 6388e9fcaa8aSmrg if (c == '\\') 6389e9fcaa8aSmrg backslashes++; 6390e9fcaa8aSmrg else 6391e9fcaa8aSmrg backslashes = 0; 6392e9fcaa8aSmrg } 6393e9fcaa8aSmrg if (quote_around) 6394e9fcaa8aSmrg length += backslashes + 1; 6395e9fcaa8aSmrg 6396e9fcaa8aSmrg quoted_string = XMALLOC (char, length + 1); 6397e9fcaa8aSmrg 6398e9fcaa8aSmrg p = quoted_string; 6399e9fcaa8aSmrg backslashes = 0; 6400e9fcaa8aSmrg if (quote_around) 6401e9fcaa8aSmrg *p++ = '"'; 6402e9fcaa8aSmrg for (s = string; *s != '\0'; s++) 6403e9fcaa8aSmrg { 6404e9fcaa8aSmrg char c = *s; 6405e9fcaa8aSmrg if (c == '"') 6406e9fcaa8aSmrg { 6407e9fcaa8aSmrg unsigned int j; 6408e9fcaa8aSmrg for (j = backslashes + 1; j > 0; j--) 6409e9fcaa8aSmrg *p++ = '\\'; 6410e9fcaa8aSmrg } 6411e9fcaa8aSmrg *p++ = c; 6412e9fcaa8aSmrg if (c == '\\') 6413e9fcaa8aSmrg backslashes++; 6414e9fcaa8aSmrg else 6415e9fcaa8aSmrg backslashes = 0; 6416e9fcaa8aSmrg } 6417e9fcaa8aSmrg if (quote_around) 6418e9fcaa8aSmrg { 6419e9fcaa8aSmrg unsigned int j; 6420e9fcaa8aSmrg for (j = backslashes; j > 0; j--) 6421e9fcaa8aSmrg *p++ = '\\'; 6422e9fcaa8aSmrg *p++ = '"'; 6423e9fcaa8aSmrg } 6424e9fcaa8aSmrg *p = '\0'; 6425e9fcaa8aSmrg 6426e9fcaa8aSmrg new_argv[i] = quoted_string; 6427e9fcaa8aSmrg } 6428e9fcaa8aSmrg else 6429e9fcaa8aSmrg new_argv[i] = (char *) string; 6430e9fcaa8aSmrg } 6431e9fcaa8aSmrg new_argv[argc] = NULL; 6432e9fcaa8aSmrg 6433e9fcaa8aSmrg return new_argv; 6434e9fcaa8aSmrg} 6435e9fcaa8aSmrgEOF 6436e9fcaa8aSmrg ;; 6437e9fcaa8aSmrg esac 6438e9fcaa8aSmrg 6439e9fcaa8aSmrg cat <<"EOF" 6440e9fcaa8aSmrgvoid lt_dump_script (FILE* f) 6441e9fcaa8aSmrg{ 6442e9fcaa8aSmrgEOF 6443e9fcaa8aSmrg func_emit_wrapper yes | 6444eb411b4bSmrg $SED -n -e ' 6445eb411b4bSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6446eb411b4bSmrg\2/ 6447eb411b4bSmrgh 6448eb411b4bSmrgs/\([\\"]\)/\\\1/g 6449eb411b4bSmrgs/$/\\n/ 6450eb411b4bSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451eb411b4bSmrgg 6452eb411b4bSmrgD' 6453e9fcaa8aSmrg cat <<"EOF" 6454e9fcaa8aSmrg} 645588de56ccSmrgEOF 645688de56ccSmrg} 645788de56ccSmrg# end: func_emit_cwrapperexe_src 64581ab64890Smrg 6459e9fcaa8aSmrg# func_win32_import_lib_p ARG 6460e9fcaa8aSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6461e9fcaa8aSmrgfunc_win32_import_lib_p () 6462e9fcaa8aSmrg{ 6463862bcd1aSmrg $debug_cmd 6464862bcd1aSmrg 6465e9fcaa8aSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466e9fcaa8aSmrg *import*) : ;; 6467e9fcaa8aSmrg *) false ;; 6468e9fcaa8aSmrg esac 6469e9fcaa8aSmrg} 6470e9fcaa8aSmrg 6471862bcd1aSmrg# func_suncc_cstd_abi 6472862bcd1aSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473862bcd1aSmrg# Several compiler flags select an ABI that is incompatible with the 6474862bcd1aSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475862bcd1aSmrgfunc_suncc_cstd_abi () 6476862bcd1aSmrg{ 6477862bcd1aSmrg $debug_cmd 6478862bcd1aSmrg 6479862bcd1aSmrg case " $compile_command " in 6480862bcd1aSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481862bcd1aSmrg suncc_use_cstd_abi=no 6482862bcd1aSmrg ;; 6483862bcd1aSmrg *) 6484862bcd1aSmrg suncc_use_cstd_abi=yes 6485862bcd1aSmrg ;; 6486862bcd1aSmrg esac 6487862bcd1aSmrg} 6488862bcd1aSmrg 648988de56ccSmrg# func_mode_link arg... 649088de56ccSmrgfunc_mode_link () 649188de56ccSmrg{ 6492862bcd1aSmrg $debug_cmd 6493862bcd1aSmrg 649488de56ccSmrg case $host in 649588de56ccSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 649688de56ccSmrg # It is impossible to link a dll without this setting, and 649788de56ccSmrg # we shouldn't force the makefile maintainer to figure out 6498862bcd1aSmrg # what system we are compiling for in order to pass an extra 649988de56ccSmrg # flag for every libtool invocation. 650088de56ccSmrg # allow_undefined=no 65011ab64890Smrg 650288de56ccSmrg # FIXME: Unfortunately, there are problems with the above when trying 6503862bcd1aSmrg # to make a dll that has undefined symbols, in which case not 650488de56ccSmrg # even a static library is built. For now, we need to specify 650588de56ccSmrg # -no-undefined on the libtool link line when we can be certain 650688de56ccSmrg # that all symbols are satisfied, otherwise we get a static library. 650788de56ccSmrg allow_undefined=yes 650888de56ccSmrg ;; 650988de56ccSmrg *) 651088de56ccSmrg allow_undefined=yes 651188de56ccSmrg ;; 651288de56ccSmrg esac 651388de56ccSmrg libtool_args=$nonopt 651488de56ccSmrg base_compile="$nonopt $@" 651588de56ccSmrg compile_command=$nonopt 651688de56ccSmrg finalize_command=$nonopt 65171ab64890Smrg 651888de56ccSmrg compile_rpath= 651988de56ccSmrg finalize_rpath= 652088de56ccSmrg compile_shlibpath= 652188de56ccSmrg finalize_shlibpath= 652288de56ccSmrg convenience= 652388de56ccSmrg old_convenience= 652488de56ccSmrg deplibs= 652588de56ccSmrg old_deplibs= 652688de56ccSmrg compiler_flags= 652788de56ccSmrg linker_flags= 652888de56ccSmrg dllsearchpath= 652988de56ccSmrg lib_search_path=`pwd` 653088de56ccSmrg inst_prefix_dir= 653188de56ccSmrg new_inherited_linker_flags= 65321ab64890Smrg 653388de56ccSmrg avoid_version=no 6534e9fcaa8aSmrg bindir= 653588de56ccSmrg dlfiles= 653688de56ccSmrg dlprefiles= 653788de56ccSmrg dlself=no 653888de56ccSmrg export_dynamic=no 653988de56ccSmrg export_symbols= 654088de56ccSmrg export_symbols_regex= 654188de56ccSmrg generated= 654288de56ccSmrg libobjs= 654388de56ccSmrg ltlibs= 654488de56ccSmrg module=no 654588de56ccSmrg no_install=no 654688de56ccSmrg objs= 6547862bcd1aSmrg os2dllname= 654888de56ccSmrg non_pic_objects= 654988de56ccSmrg precious_files_regex= 655088de56ccSmrg prefer_static_libs=no 6551862bcd1aSmrg preload=false 655288de56ccSmrg prev= 655388de56ccSmrg prevarg= 655488de56ccSmrg release= 655588de56ccSmrg rpath= 655688de56ccSmrg xrpath= 655788de56ccSmrg perm_rpath= 655888de56ccSmrg temp_rpath= 655988de56ccSmrg thread_safe=no 656088de56ccSmrg vinfo= 656188de56ccSmrg vinfo_number=no 656288de56ccSmrg weak_libs= 6563862bcd1aSmrg single_module=$wl-single_module 656488de56ccSmrg func_infer_tag $base_compile 656588de56ccSmrg 656688de56ccSmrg # We need to know -static, to get the right output filenames. 656788de56ccSmrg for arg 656888de56ccSmrg do 656988de56ccSmrg case $arg in 657088de56ccSmrg -shared) 6571862bcd1aSmrg test yes != "$build_libtool_libs" \ 6572862bcd1aSmrg && func_fatal_configuration "cannot build a shared library" 657388de56ccSmrg build_old_libs=no 657488de56ccSmrg break 657588de56ccSmrg ;; 657688de56ccSmrg -all-static | -static | -static-libtool-libs) 657788de56ccSmrg case $arg in 657888de56ccSmrg -all-static) 6579862bcd1aSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 658088de56ccSmrg func_warning "complete static linking is impossible in this configuration" 658188de56ccSmrg fi 658288de56ccSmrg if test -n "$link_static_flag"; then 658388de56ccSmrg dlopen_self=$dlopen_self_static 658488de56ccSmrg fi 658588de56ccSmrg prefer_static_libs=yes 658688de56ccSmrg ;; 658788de56ccSmrg -static) 658888de56ccSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 658988de56ccSmrg dlopen_self=$dlopen_self_static 659088de56ccSmrg fi 659188de56ccSmrg prefer_static_libs=built 659288de56ccSmrg ;; 659388de56ccSmrg -static-libtool-libs) 659488de56ccSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 659588de56ccSmrg dlopen_self=$dlopen_self_static 6596b4ee4795Smrg fi 659788de56ccSmrg prefer_static_libs=yes 659888de56ccSmrg ;; 659988de56ccSmrg esac 660088de56ccSmrg build_libtool_libs=no 660188de56ccSmrg build_old_libs=yes 660288de56ccSmrg break 660388de56ccSmrg ;; 660488de56ccSmrg esac 660588de56ccSmrg done 66061ab64890Smrg 660788de56ccSmrg # See if our shared archives depend on static archives. 660888de56ccSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 66091ab64890Smrg 661088de56ccSmrg # Go through the arguments, transforming them on the way. 661188de56ccSmrg while test "$#" -gt 0; do 6612862bcd1aSmrg arg=$1 661388de56ccSmrg shift 661488de56ccSmrg func_quote_for_eval "$arg" 661588de56ccSmrg qarg=$func_quote_for_eval_unquoted_result 661688de56ccSmrg func_append libtool_args " $func_quote_for_eval_result" 66171ab64890Smrg 661888de56ccSmrg # If the previous option needs an argument, assign it. 661988de56ccSmrg if test -n "$prev"; then 662088de56ccSmrg case $prev in 662188de56ccSmrg output) 662288de56ccSmrg func_append compile_command " @OUTPUT@" 662388de56ccSmrg func_append finalize_command " @OUTPUT@" 662488de56ccSmrg ;; 662588de56ccSmrg esac 66261ab64890Smrg 662788de56ccSmrg case $prev in 6628e9fcaa8aSmrg bindir) 6629862bcd1aSmrg bindir=$arg 6630e9fcaa8aSmrg prev= 6631e9fcaa8aSmrg continue 6632e9fcaa8aSmrg ;; 663388de56ccSmrg dlfiles|dlprefiles) 6634862bcd1aSmrg $preload || { 663588de56ccSmrg # Add the symbol object into the linking commands. 663688de56ccSmrg func_append compile_command " @SYMFILE@" 663788de56ccSmrg func_append finalize_command " @SYMFILE@" 6638862bcd1aSmrg preload=: 6639862bcd1aSmrg } 664088de56ccSmrg case $arg in 664188de56ccSmrg *.la | *.lo) ;; # We handle these cases below. 664288de56ccSmrg force) 6643862bcd1aSmrg if test no = "$dlself"; then 664488de56ccSmrg dlself=needless 664588de56ccSmrg export_dynamic=yes 664688de56ccSmrg fi 664788de56ccSmrg prev= 664888de56ccSmrg continue 664988de56ccSmrg ;; 665088de56ccSmrg self) 6651862bcd1aSmrg if test dlprefiles = "$prev"; then 665288de56ccSmrg dlself=yes 6653862bcd1aSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 665488de56ccSmrg dlself=yes 6655b4ee4795Smrg else 665688de56ccSmrg dlself=needless 665788de56ccSmrg export_dynamic=yes 6658b4ee4795Smrg fi 665988de56ccSmrg prev= 666088de56ccSmrg continue 666188de56ccSmrg ;; 666288de56ccSmrg *) 6663862bcd1aSmrg if test dlfiles = "$prev"; then 6664e9fcaa8aSmrg func_append dlfiles " $arg" 6665b4ee4795Smrg else 6666e9fcaa8aSmrg func_append dlprefiles " $arg" 6667b4ee4795Smrg fi 666888de56ccSmrg prev= 666988de56ccSmrg continue 667088de56ccSmrg ;; 667188de56ccSmrg esac 667288de56ccSmrg ;; 667388de56ccSmrg expsyms) 6674862bcd1aSmrg export_symbols=$arg 667588de56ccSmrg test -f "$arg" \ 6676862bcd1aSmrg || func_fatal_error "symbol file '$arg' does not exist" 667788de56ccSmrg prev= 667888de56ccSmrg continue 667988de56ccSmrg ;; 668088de56ccSmrg expsyms_regex) 6681862bcd1aSmrg export_symbols_regex=$arg 668288de56ccSmrg prev= 668388de56ccSmrg continue 668488de56ccSmrg ;; 668588de56ccSmrg framework) 6686b4ee4795Smrg case $host in 668788de56ccSmrg *-*-darwin*) 668888de56ccSmrg case "$deplibs " in 668988de56ccSmrg *" $qarg.ltframework "*) ;; 6690e9fcaa8aSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 669188de56ccSmrg ;; 669288de56ccSmrg esac 669388de56ccSmrg ;; 6694b4ee4795Smrg esac 669588de56ccSmrg prev= 669688de56ccSmrg continue 6697b4ee4795Smrg ;; 669888de56ccSmrg inst_prefix) 6699862bcd1aSmrg inst_prefix_dir=$arg 6700862bcd1aSmrg prev= 6701862bcd1aSmrg continue 6702862bcd1aSmrg ;; 6703862bcd1aSmrg mllvm) 6704862bcd1aSmrg # Clang does not use LLVM to link, so we can simply discard any 6705862bcd1aSmrg # '-mllvm $arg' options when doing the link step. 670688de56ccSmrg prev= 670788de56ccSmrg continue 6708b4ee4795Smrg ;; 670988de56ccSmrg objectlist) 671088de56ccSmrg if test -f "$arg"; then 671188de56ccSmrg save_arg=$arg 671288de56ccSmrg moreargs= 671388de56ccSmrg for fil in `cat "$save_arg"` 671488de56ccSmrg do 6715e9fcaa8aSmrg# func_append moreargs " $fil" 671688de56ccSmrg arg=$fil 671788de56ccSmrg # A libtool-controlled object. 67182e9c7c8cSmrg 671988de56ccSmrg # Check to see that this really is a libtool object. 672088de56ccSmrg if func_lalib_unsafe_p "$arg"; then 672188de56ccSmrg pic_object= 672288de56ccSmrg non_pic_object= 67232e9c7c8cSmrg 672488de56ccSmrg # Read the .lo file 672588de56ccSmrg func_source "$arg" 67262e9c7c8cSmrg 672788de56ccSmrg if test -z "$pic_object" || 672888de56ccSmrg test -z "$non_pic_object" || 6729862bcd1aSmrg test none = "$pic_object" && 6730862bcd1aSmrg test none = "$non_pic_object"; then 6731862bcd1aSmrg func_fatal_error "cannot find name of object for '$arg'" 673288de56ccSmrg fi 67332e9c7c8cSmrg 673488de56ccSmrg # Extract subdirectory from the argument. 673588de56ccSmrg func_dirname "$arg" "/" "" 6736862bcd1aSmrg xdir=$func_dirname_result 67372e9c7c8cSmrg 6738862bcd1aSmrg if test none != "$pic_object"; then 673988de56ccSmrg # Prepend the subdirectory the object is found in. 6740862bcd1aSmrg pic_object=$xdir$pic_object 67412e9c7c8cSmrg 6742862bcd1aSmrg if test dlfiles = "$prev"; then 6743862bcd1aSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744e9fcaa8aSmrg func_append dlfiles " $pic_object" 674588de56ccSmrg prev= 674688de56ccSmrg continue 674788de56ccSmrg else 674888de56ccSmrg # If libtool objects are unsupported, then we need to preload. 674988de56ccSmrg prev=dlprefiles 675088de56ccSmrg fi 675188de56ccSmrg fi 67522e9c7c8cSmrg 675388de56ccSmrg # CHECK ME: I think I busted this. -Ossama 6754862bcd1aSmrg if test dlprefiles = "$prev"; then 675588de56ccSmrg # Preload the old-style object. 6756e9fcaa8aSmrg func_append dlprefiles " $pic_object" 675788de56ccSmrg prev= 675888de56ccSmrg fi 67592e9c7c8cSmrg 676088de56ccSmrg # A PIC object. 676188de56ccSmrg func_append libobjs " $pic_object" 6762862bcd1aSmrg arg=$pic_object 676388de56ccSmrg fi 67642e9c7c8cSmrg 676588de56ccSmrg # Non-PIC object. 6766862bcd1aSmrg if test none != "$non_pic_object"; then 676788de56ccSmrg # Prepend the subdirectory the object is found in. 6768862bcd1aSmrg non_pic_object=$xdir$non_pic_object 67692e9c7c8cSmrg 677088de56ccSmrg # A standard non-PIC object 677188de56ccSmrg func_append non_pic_objects " $non_pic_object" 6772862bcd1aSmrg if test -z "$pic_object" || test none = "$pic_object"; then 6773862bcd1aSmrg arg=$non_pic_object 677488de56ccSmrg fi 677588de56ccSmrg else 677688de56ccSmrg # If the PIC object exists, use it instead. 677788de56ccSmrg # $xdir was prepended to $pic_object above. 6778862bcd1aSmrg non_pic_object=$pic_object 677988de56ccSmrg func_append non_pic_objects " $non_pic_object" 678088de56ccSmrg fi 678188de56ccSmrg else 678288de56ccSmrg # Only an error if not doing a dry-run. 678388de56ccSmrg if $opt_dry_run; then 678488de56ccSmrg # Extract subdirectory from the argument. 678588de56ccSmrg func_dirname "$arg" "/" "" 6786862bcd1aSmrg xdir=$func_dirname_result 678788de56ccSmrg 678888de56ccSmrg func_lo2o "$arg" 678988de56ccSmrg pic_object=$xdir$objdir/$func_lo2o_result 679088de56ccSmrg non_pic_object=$xdir$func_lo2o_result 679188de56ccSmrg func_append libobjs " $pic_object" 679288de56ccSmrg func_append non_pic_objects " $non_pic_object" 679388de56ccSmrg else 6794862bcd1aSmrg func_fatal_error "'$arg' is not a valid libtool object" 679588de56ccSmrg fi 679688de56ccSmrg fi 679788de56ccSmrg done 6798b4ee4795Smrg else 6799862bcd1aSmrg func_fatal_error "link input file '$arg' does not exist" 6800b4ee4795Smrg fi 680188de56ccSmrg arg=$save_arg 680288de56ccSmrg prev= 680388de56ccSmrg continue 680488de56ccSmrg ;; 6805862bcd1aSmrg os2dllname) 6806862bcd1aSmrg os2dllname=$arg 6807862bcd1aSmrg prev= 6808862bcd1aSmrg continue 6809862bcd1aSmrg ;; 681088de56ccSmrg precious_regex) 6811862bcd1aSmrg precious_files_regex=$arg 681288de56ccSmrg prev= 681388de56ccSmrg continue 681488de56ccSmrg ;; 681588de56ccSmrg release) 6816862bcd1aSmrg release=-$arg 681788de56ccSmrg prev= 681888de56ccSmrg continue 681988de56ccSmrg ;; 682088de56ccSmrg rpath | xrpath) 682188de56ccSmrg # We need an absolute path. 682288de56ccSmrg case $arg in 682388de56ccSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 682488de56ccSmrg *) 682588de56ccSmrg func_fatal_error "only absolute run-paths are allowed" 682688de56ccSmrg ;; 682788de56ccSmrg esac 6828862bcd1aSmrg if test rpath = "$prev"; then 682988de56ccSmrg case "$rpath " in 683088de56ccSmrg *" $arg "*) ;; 6831e9fcaa8aSmrg *) func_append rpath " $arg" ;; 683288de56ccSmrg esac 6833b4ee4795Smrg else 683488de56ccSmrg case "$xrpath " in 683588de56ccSmrg *" $arg "*) ;; 6836e9fcaa8aSmrg *) func_append xrpath " $arg" ;; 683788de56ccSmrg esac 6838b4ee4795Smrg fi 683988de56ccSmrg prev= 684088de56ccSmrg continue 684188de56ccSmrg ;; 684288de56ccSmrg shrext) 6843862bcd1aSmrg shrext_cmds=$arg 684488de56ccSmrg prev= 684588de56ccSmrg continue 684688de56ccSmrg ;; 684788de56ccSmrg weak) 6848e9fcaa8aSmrg func_append weak_libs " $arg" 684988de56ccSmrg prev= 685088de56ccSmrg continue 685188de56ccSmrg ;; 685288de56ccSmrg xcclinker) 6853e9fcaa8aSmrg func_append linker_flags " $qarg" 6854e9fcaa8aSmrg func_append compiler_flags " $qarg" 685588de56ccSmrg prev= 685688de56ccSmrg func_append compile_command " $qarg" 685788de56ccSmrg func_append finalize_command " $qarg" 685888de56ccSmrg continue 685988de56ccSmrg ;; 686088de56ccSmrg xcompiler) 6861e9fcaa8aSmrg func_append compiler_flags " $qarg" 686288de56ccSmrg prev= 686388de56ccSmrg func_append compile_command " $qarg" 686488de56ccSmrg func_append finalize_command " $qarg" 686588de56ccSmrg continue 686688de56ccSmrg ;; 686788de56ccSmrg xlinker) 6868e9fcaa8aSmrg func_append linker_flags " $qarg" 6869e9fcaa8aSmrg func_append compiler_flags " $wl$qarg" 687088de56ccSmrg prev= 687188de56ccSmrg func_append compile_command " $wl$qarg" 687288de56ccSmrg func_append finalize_command " $wl$qarg" 687388de56ccSmrg continue 687488de56ccSmrg ;; 687588de56ccSmrg *) 687688de56ccSmrg eval "$prev=\"\$arg\"" 687788de56ccSmrg prev= 687888de56ccSmrg continue 687988de56ccSmrg ;; 68802e9c7c8cSmrg esac 688188de56ccSmrg fi # test -n "$prev" 68822e9c7c8cSmrg 6883862bcd1aSmrg prevarg=$arg 68842e9c7c8cSmrg 688588de56ccSmrg case $arg in 688688de56ccSmrg -all-static) 688788de56ccSmrg if test -n "$link_static_flag"; then 688888de56ccSmrg # See comment for -static flag below, for more details. 688988de56ccSmrg func_append compile_command " $link_static_flag" 689088de56ccSmrg func_append finalize_command " $link_static_flag" 689188de56ccSmrg fi 689288de56ccSmrg continue 689388de56ccSmrg ;; 68942e9c7c8cSmrg 689588de56ccSmrg -allow-undefined) 689688de56ccSmrg # FIXME: remove this flag sometime in the future. 6897862bcd1aSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 689888de56ccSmrg ;; 68992e9c7c8cSmrg 690088de56ccSmrg -avoid-version) 690188de56ccSmrg avoid_version=yes 690288de56ccSmrg continue 690388de56ccSmrg ;; 69042e9c7c8cSmrg 6905e9fcaa8aSmrg -bindir) 6906e9fcaa8aSmrg prev=bindir 6907e9fcaa8aSmrg continue 6908e9fcaa8aSmrg ;; 6909e9fcaa8aSmrg 691088de56ccSmrg -dlopen) 691188de56ccSmrg prev=dlfiles 691288de56ccSmrg continue 691388de56ccSmrg ;; 69142e9c7c8cSmrg 691588de56ccSmrg -dlpreopen) 691688de56ccSmrg prev=dlprefiles 691788de56ccSmrg continue 691888de56ccSmrg ;; 69192e9c7c8cSmrg 692088de56ccSmrg -export-dynamic) 692188de56ccSmrg export_dynamic=yes 692288de56ccSmrg continue 692388de56ccSmrg ;; 69242e9c7c8cSmrg 692588de56ccSmrg -export-symbols | -export-symbols-regex) 692688de56ccSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 692788de56ccSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 692888de56ccSmrg fi 6929862bcd1aSmrg if test X-export-symbols = "X$arg"; then 693088de56ccSmrg prev=expsyms 693188de56ccSmrg else 693288de56ccSmrg prev=expsyms_regex 693388de56ccSmrg fi 693488de56ccSmrg continue 693588de56ccSmrg ;; 69362e9c7c8cSmrg 693788de56ccSmrg -framework) 693888de56ccSmrg prev=framework 693988de56ccSmrg continue 694088de56ccSmrg ;; 69412e9c7c8cSmrg 694288de56ccSmrg -inst-prefix-dir) 694388de56ccSmrg prev=inst_prefix 694488de56ccSmrg continue 694588de56ccSmrg ;; 69462e9c7c8cSmrg 694788de56ccSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 694888de56ccSmrg # so, if we see these flags be careful not to treat them like -L 694988de56ccSmrg -L[A-Z][A-Z]*:*) 695088de56ccSmrg case $with_gcc/$host in 695188de56ccSmrg no/*-*-irix* | /*-*-irix*) 695288de56ccSmrg func_append compile_command " $arg" 695388de56ccSmrg func_append finalize_command " $arg" 695488de56ccSmrg ;; 695588de56ccSmrg esac 695688de56ccSmrg continue 695788de56ccSmrg ;; 69582e9c7c8cSmrg 695988de56ccSmrg -L*) 6960e9fcaa8aSmrg func_stripname "-L" '' "$arg" 6961e9fcaa8aSmrg if test -z "$func_stripname_result"; then 696288de56ccSmrg if test "$#" -gt 0; then 6963862bcd1aSmrg func_fatal_error "require no space between '-L' and '$1'" 696488de56ccSmrg else 6965862bcd1aSmrg func_fatal_error "need path for '-L' option" 696688de56ccSmrg fi 696788de56ccSmrg fi 6968e9fcaa8aSmrg func_resolve_sysroot "$func_stripname_result" 6969e9fcaa8aSmrg dir=$func_resolve_sysroot_result 697088de56ccSmrg # We need an absolute path. 697188de56ccSmrg case $dir in 697288de56ccSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 697388de56ccSmrg *) 697488de56ccSmrg absdir=`cd "$dir" && pwd` 697588de56ccSmrg test -z "$absdir" && \ 6976862bcd1aSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 6977862bcd1aSmrg dir=$absdir 697888de56ccSmrg ;; 697988de56ccSmrg esac 698088de56ccSmrg case "$deplibs " in 6981e9fcaa8aSmrg *" -L$dir "* | *" $arg "*) 6982e9fcaa8aSmrg # Will only happen for absolute or sysroot arguments 6983e9fcaa8aSmrg ;; 698488de56ccSmrg *) 6985e9fcaa8aSmrg # Preserve sysroot, but never include relative directories 6986e9fcaa8aSmrg case $dir in 6987e9fcaa8aSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988e9fcaa8aSmrg *) func_append deplibs " -L$dir" ;; 6989e9fcaa8aSmrg esac 6990e9fcaa8aSmrg func_append lib_search_path " $dir" 699188de56ccSmrg ;; 699288de56ccSmrg esac 699388de56ccSmrg case $host in 699488de56ccSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995e9fcaa8aSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 699688de56ccSmrg case :$dllsearchpath: in 699788de56ccSmrg *":$dir:"*) ;; 699888de56ccSmrg ::) dllsearchpath=$dir;; 6999e9fcaa8aSmrg *) func_append dllsearchpath ":$dir";; 700088de56ccSmrg esac 700188de56ccSmrg case :$dllsearchpath: in 700288de56ccSmrg *":$testbindir:"*) ;; 700388de56ccSmrg ::) dllsearchpath=$testbindir;; 7004e9fcaa8aSmrg *) func_append dllsearchpath ":$testbindir";; 700588de56ccSmrg esac 700688de56ccSmrg ;; 700788de56ccSmrg esac 700888de56ccSmrg continue 700988de56ccSmrg ;; 70102e9c7c8cSmrg 701188de56ccSmrg -l*) 7012862bcd1aSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 701388de56ccSmrg case $host in 7014e9fcaa8aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 701588de56ccSmrg # These systems don't actually have a C or math library (as such) 701688de56ccSmrg continue 701788de56ccSmrg ;; 701888de56ccSmrg *-*-os2*) 701988de56ccSmrg # These systems don't actually have a C library (as such) 7020862bcd1aSmrg test X-lc = "X$arg" && continue 702188de56ccSmrg ;; 7022862bcd1aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 702388de56ccSmrg # Do not include libc due to us having libc/libc_r. 7024862bcd1aSmrg test X-lc = "X$arg" && continue 702588de56ccSmrg ;; 702688de56ccSmrg *-*-rhapsody* | *-*-darwin1.[012]) 702788de56ccSmrg # Rhapsody C and math libraries are in the System framework 7028e9fcaa8aSmrg func_append deplibs " System.ltframework" 702988de56ccSmrg continue 703088de56ccSmrg ;; 703188de56ccSmrg *-*-sco3.2v5* | *-*-sco5v6*) 703288de56ccSmrg # Causes problems with __ctype 7033862bcd1aSmrg test X-lc = "X$arg" && continue 703488de56ccSmrg ;; 703588de56ccSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 703688de56ccSmrg # Compiler inserts libc in the correct place for threads to work 7037862bcd1aSmrg test X-lc = "X$arg" && continue 703888de56ccSmrg ;; 703988de56ccSmrg esac 7040862bcd1aSmrg elif test X-lc_r = "X$arg"; then 704188de56ccSmrg case $host in 7042862bcd1aSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 704388de56ccSmrg # Do not include libc_r directly, use -pthread flag. 704488de56ccSmrg continue 704588de56ccSmrg ;; 704688de56ccSmrg esac 704788de56ccSmrg fi 7048e9fcaa8aSmrg func_append deplibs " $arg" 704988de56ccSmrg continue 705088de56ccSmrg ;; 70512e9c7c8cSmrg 7052862bcd1aSmrg -mllvm) 7053862bcd1aSmrg prev=mllvm 7054862bcd1aSmrg continue 7055862bcd1aSmrg ;; 7056862bcd1aSmrg 705788de56ccSmrg -module) 705888de56ccSmrg module=yes 705988de56ccSmrg continue 706088de56ccSmrg ;; 70612e9c7c8cSmrg 706288de56ccSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 706388de56ccSmrg # classes, name mangling, and exception handling. 706488de56ccSmrg # Darwin uses the -arch flag to determine output architecture. 7065e9fcaa8aSmrg -model|-arch|-isysroot|--sysroot) 7066e9fcaa8aSmrg func_append compiler_flags " $arg" 706788de56ccSmrg func_append compile_command " $arg" 706888de56ccSmrg func_append finalize_command " $arg" 706988de56ccSmrg prev=xcompiler 707088de56ccSmrg continue 707188de56ccSmrg ;; 70722e9c7c8cSmrg 7073eb411b4bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074eb411b4bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075e9fcaa8aSmrg func_append compiler_flags " $arg" 707688de56ccSmrg func_append compile_command " $arg" 707788de56ccSmrg func_append finalize_command " $arg" 707888de56ccSmrg case "$new_inherited_linker_flags " in 707988de56ccSmrg *" $arg "*) ;; 7080e9fcaa8aSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 708188de56ccSmrg esac 708288de56ccSmrg continue 708388de56ccSmrg ;; 70842e9c7c8cSmrg 708588de56ccSmrg -multi_module) 7086862bcd1aSmrg single_module=$wl-multi_module 708788de56ccSmrg continue 708888de56ccSmrg ;; 70892e9c7c8cSmrg 709088de56ccSmrg -no-fast-install) 709188de56ccSmrg fast_install=no 709288de56ccSmrg continue 709388de56ccSmrg ;; 70942e9c7c8cSmrg 709588de56ccSmrg -no-install) 709688de56ccSmrg case $host in 709788de56ccSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 709888de56ccSmrg # The PATH hackery in wrapper scripts is required on Windows 709988de56ccSmrg # and Darwin in order for the loader to find any dlls it needs. 7100862bcd1aSmrg func_warning "'-no-install' is ignored for $host" 7101862bcd1aSmrg func_warning "assuming '-no-fast-install' instead" 710288de56ccSmrg fast_install=no 710388de56ccSmrg ;; 710488de56ccSmrg *) no_install=yes ;; 710588de56ccSmrg esac 710688de56ccSmrg continue 710788de56ccSmrg ;; 71082e9c7c8cSmrg 710988de56ccSmrg -no-undefined) 711088de56ccSmrg allow_undefined=no 711188de56ccSmrg continue 711288de56ccSmrg ;; 71132e9c7c8cSmrg 711488de56ccSmrg -objectlist) 711588de56ccSmrg prev=objectlist 711688de56ccSmrg continue 711788de56ccSmrg ;; 71182e9c7c8cSmrg 7119862bcd1aSmrg -os2dllname) 7120862bcd1aSmrg prev=os2dllname 7121862bcd1aSmrg continue 7122862bcd1aSmrg ;; 7123862bcd1aSmrg 712488de56ccSmrg -o) prev=output ;; 71252e9c7c8cSmrg 712688de56ccSmrg -precious-files-regex) 712788de56ccSmrg prev=precious_regex 712888de56ccSmrg continue 712988de56ccSmrg ;; 71302e9c7c8cSmrg 713188de56ccSmrg -release) 713288de56ccSmrg prev=release 713388de56ccSmrg continue 713488de56ccSmrg ;; 71352e9c7c8cSmrg 713688de56ccSmrg -rpath) 713788de56ccSmrg prev=rpath 713888de56ccSmrg continue 713988de56ccSmrg ;; 71402e9c7c8cSmrg 714188de56ccSmrg -R) 714288de56ccSmrg prev=xrpath 714388de56ccSmrg continue 714488de56ccSmrg ;; 71452e9c7c8cSmrg 714688de56ccSmrg -R*) 714788de56ccSmrg func_stripname '-R' '' "$arg" 714888de56ccSmrg dir=$func_stripname_result 714988de56ccSmrg # We need an absolute path. 715088de56ccSmrg case $dir in 715188de56ccSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7152e9fcaa8aSmrg =*) 7153e9fcaa8aSmrg func_stripname '=' '' "$dir" 7154e9fcaa8aSmrg dir=$lt_sysroot$func_stripname_result 7155e9fcaa8aSmrg ;; 715688de56ccSmrg *) 715788de56ccSmrg func_fatal_error "only absolute run-paths are allowed" 715888de56ccSmrg ;; 715988de56ccSmrg esac 716088de56ccSmrg case "$xrpath " in 716188de56ccSmrg *" $dir "*) ;; 7162e9fcaa8aSmrg *) func_append xrpath " $dir" ;; 716388de56ccSmrg esac 716488de56ccSmrg continue 716588de56ccSmrg ;; 71662e9c7c8cSmrg 716788de56ccSmrg -shared) 716888de56ccSmrg # The effects of -shared are defined in a previous loop. 716988de56ccSmrg continue 717088de56ccSmrg ;; 71712e9c7c8cSmrg 717288de56ccSmrg -shrext) 717388de56ccSmrg prev=shrext 717488de56ccSmrg continue 717588de56ccSmrg ;; 71762e9c7c8cSmrg 717788de56ccSmrg -static | -static-libtool-libs) 717888de56ccSmrg # The effects of -static are defined in a previous loop. 717988de56ccSmrg # We used to do the same as -all-static on platforms that 718088de56ccSmrg # didn't have a PIC flag, but the assumption that the effects 718188de56ccSmrg # would be equivalent was wrong. It would break on at least 718288de56ccSmrg # Digital Unix and AIX. 718388de56ccSmrg continue 718488de56ccSmrg ;; 71852e9c7c8cSmrg 718688de56ccSmrg -thread-safe) 718788de56ccSmrg thread_safe=yes 718888de56ccSmrg continue 718988de56ccSmrg ;; 71902e9c7c8cSmrg 719188de56ccSmrg -version-info) 719288de56ccSmrg prev=vinfo 719388de56ccSmrg continue 719488de56ccSmrg ;; 71952e9c7c8cSmrg 719688de56ccSmrg -version-number) 719788de56ccSmrg prev=vinfo 719888de56ccSmrg vinfo_number=yes 719988de56ccSmrg continue 720088de56ccSmrg ;; 72012e9c7c8cSmrg 720288de56ccSmrg -weak) 720388de56ccSmrg prev=weak 720488de56ccSmrg continue 720588de56ccSmrg ;; 72061ab64890Smrg 720788de56ccSmrg -Wc,*) 720888de56ccSmrg func_stripname '-Wc,' '' "$arg" 720988de56ccSmrg args=$func_stripname_result 721088de56ccSmrg arg= 7211862bcd1aSmrg save_ifs=$IFS; IFS=, 721288de56ccSmrg for flag in $args; do 7213862bcd1aSmrg IFS=$save_ifs 721488de56ccSmrg func_quote_for_eval "$flag" 7215e9fcaa8aSmrg func_append arg " $func_quote_for_eval_result" 7216e9fcaa8aSmrg func_append compiler_flags " $func_quote_for_eval_result" 721788de56ccSmrg done 7218862bcd1aSmrg IFS=$save_ifs 721988de56ccSmrg func_stripname ' ' '' "$arg" 722088de56ccSmrg arg=$func_stripname_result 722188de56ccSmrg ;; 7222b4ee4795Smrg 722388de56ccSmrg -Wl,*) 722488de56ccSmrg func_stripname '-Wl,' '' "$arg" 722588de56ccSmrg args=$func_stripname_result 722688de56ccSmrg arg= 7227862bcd1aSmrg save_ifs=$IFS; IFS=, 722888de56ccSmrg for flag in $args; do 7229862bcd1aSmrg IFS=$save_ifs 723088de56ccSmrg func_quote_for_eval "$flag" 7231e9fcaa8aSmrg func_append arg " $wl$func_quote_for_eval_result" 7232e9fcaa8aSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7233e9fcaa8aSmrg func_append linker_flags " $func_quote_for_eval_result" 723488de56ccSmrg done 7235862bcd1aSmrg IFS=$save_ifs 723688de56ccSmrg func_stripname ' ' '' "$arg" 723788de56ccSmrg arg=$func_stripname_result 723888de56ccSmrg ;; 7239b4ee4795Smrg 724088de56ccSmrg -Xcompiler) 724188de56ccSmrg prev=xcompiler 724288de56ccSmrg continue 724388de56ccSmrg ;; 7244b4ee4795Smrg 724588de56ccSmrg -Xlinker) 724688de56ccSmrg prev=xlinker 724788de56ccSmrg continue 724888de56ccSmrg ;; 7249b4ee4795Smrg 725088de56ccSmrg -XCClinker) 725188de56ccSmrg prev=xcclinker 725288de56ccSmrg continue 725388de56ccSmrg ;; 7254b4ee4795Smrg 725588de56ccSmrg # -msg_* for osf cc 725688de56ccSmrg -msg_*) 725788de56ccSmrg func_quote_for_eval "$arg" 7258862bcd1aSmrg arg=$func_quote_for_eval_result 725988de56ccSmrg ;; 7260b4ee4795Smrg 7261e9fcaa8aSmrg # Flags to be passed through unchanged, with rationale: 7262e9fcaa8aSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263e9fcaa8aSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 7264e9fcaa8aSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265e9fcaa8aSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7266e9fcaa8aSmrg # -q* compiler args for the IBM compiler 7267e9fcaa8aSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268e9fcaa8aSmrg # -F/path path to uninstalled frameworks, gcc on darwin 7269e9fcaa8aSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270862bcd1aSmrg # -fstack-protector* stack protector flags for GCC 7271e9fcaa8aSmrg # @file GCC response files 7272e9fcaa8aSmrg # -tp=* Portland pgcc target processor selection 7273e9fcaa8aSmrg # --sysroot=* for sysroot support 7274862bcd1aSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275862bcd1aSmrg # -stdlib=* select c++ std lib with clang 727688de56ccSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7277e9fcaa8aSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 727803ea5dc6Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 727988de56ccSmrg func_quote_for_eval "$arg" 7280862bcd1aSmrg arg=$func_quote_for_eval_result 728188de56ccSmrg func_append compile_command " $arg" 728288de56ccSmrg func_append finalize_command " $arg" 7283e9fcaa8aSmrg func_append compiler_flags " $arg" 728488de56ccSmrg continue 728588de56ccSmrg ;; 7286b4ee4795Smrg 7287862bcd1aSmrg -Z*) 7288862bcd1aSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7289862bcd1aSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 7290862bcd1aSmrg compiler_flags="$compiler_flags $arg" 7291862bcd1aSmrg func_append compile_command " $arg" 7292862bcd1aSmrg func_append finalize_command " $arg" 7293862bcd1aSmrg case $arg in 7294862bcd1aSmrg -Zlinker | -Zstack) 7295862bcd1aSmrg prev=xcompiler 7296862bcd1aSmrg ;; 7297862bcd1aSmrg esac 7298862bcd1aSmrg continue 7299862bcd1aSmrg else 7300862bcd1aSmrg # Otherwise treat like 'Some other compiler flag' below 7301862bcd1aSmrg func_quote_for_eval "$arg" 7302862bcd1aSmrg arg=$func_quote_for_eval_result 7303862bcd1aSmrg fi 7304862bcd1aSmrg ;; 7305862bcd1aSmrg 730688de56ccSmrg # Some other compiler flag. 730788de56ccSmrg -* | +*) 730888de56ccSmrg func_quote_for_eval "$arg" 7309862bcd1aSmrg arg=$func_quote_for_eval_result 731088de56ccSmrg ;; 7311b4ee4795Smrg 731288de56ccSmrg *.$objext) 731388de56ccSmrg # A standard object. 7314e9fcaa8aSmrg func_append objs " $arg" 731588de56ccSmrg ;; 7316b4ee4795Smrg 731788de56ccSmrg *.lo) 731888de56ccSmrg # A libtool-controlled object. 7319b4ee4795Smrg 732088de56ccSmrg # Check to see that this really is a libtool object. 732188de56ccSmrg if func_lalib_unsafe_p "$arg"; then 732288de56ccSmrg pic_object= 732388de56ccSmrg non_pic_object= 7324b4ee4795Smrg 732588de56ccSmrg # Read the .lo file 732688de56ccSmrg func_source "$arg" 7327b4ee4795Smrg 732888de56ccSmrg if test -z "$pic_object" || 732988de56ccSmrg test -z "$non_pic_object" || 7330862bcd1aSmrg test none = "$pic_object" && 7331862bcd1aSmrg test none = "$non_pic_object"; then 7332862bcd1aSmrg func_fatal_error "cannot find name of object for '$arg'" 733388de56ccSmrg fi 7334b4ee4795Smrg 733588de56ccSmrg # Extract subdirectory from the argument. 733688de56ccSmrg func_dirname "$arg" "/" "" 7337862bcd1aSmrg xdir=$func_dirname_result 7338b4ee4795Smrg 7339862bcd1aSmrg test none = "$pic_object" || { 734088de56ccSmrg # Prepend the subdirectory the object is found in. 7341862bcd1aSmrg pic_object=$xdir$pic_object 7342b4ee4795Smrg 7343862bcd1aSmrg if test dlfiles = "$prev"; then 7344862bcd1aSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7345e9fcaa8aSmrg func_append dlfiles " $pic_object" 734688de56ccSmrg prev= 734788de56ccSmrg continue 734888de56ccSmrg else 734988de56ccSmrg # If libtool objects are unsupported, then we need to preload. 735088de56ccSmrg prev=dlprefiles 735188de56ccSmrg fi 735288de56ccSmrg fi 7353b4ee4795Smrg 735488de56ccSmrg # CHECK ME: I think I busted this. -Ossama 7355862bcd1aSmrg if test dlprefiles = "$prev"; then 735688de56ccSmrg # Preload the old-style object. 7357e9fcaa8aSmrg func_append dlprefiles " $pic_object" 735888de56ccSmrg prev= 735988de56ccSmrg fi 73601ab64890Smrg 736188de56ccSmrg # A PIC object. 736288de56ccSmrg func_append libobjs " $pic_object" 7363862bcd1aSmrg arg=$pic_object 7364862bcd1aSmrg } 73651ab64890Smrg 736688de56ccSmrg # Non-PIC object. 7367862bcd1aSmrg if test none != "$non_pic_object"; then 736888de56ccSmrg # Prepend the subdirectory the object is found in. 7369862bcd1aSmrg non_pic_object=$xdir$non_pic_object 73701ab64890Smrg 737188de56ccSmrg # A standard non-PIC object 737288de56ccSmrg func_append non_pic_objects " $non_pic_object" 7373862bcd1aSmrg if test -z "$pic_object" || test none = "$pic_object"; then 7374862bcd1aSmrg arg=$non_pic_object 737588de56ccSmrg fi 737688de56ccSmrg else 737788de56ccSmrg # If the PIC object exists, use it instead. 737888de56ccSmrg # $xdir was prepended to $pic_object above. 7379862bcd1aSmrg non_pic_object=$pic_object 738088de56ccSmrg func_append non_pic_objects " $non_pic_object" 738188de56ccSmrg fi 738288de56ccSmrg else 738388de56ccSmrg # Only an error if not doing a dry-run. 738488de56ccSmrg if $opt_dry_run; then 738588de56ccSmrg # Extract subdirectory from the argument. 738688de56ccSmrg func_dirname "$arg" "/" "" 7387862bcd1aSmrg xdir=$func_dirname_result 738888de56ccSmrg 738988de56ccSmrg func_lo2o "$arg" 739088de56ccSmrg pic_object=$xdir$objdir/$func_lo2o_result 739188de56ccSmrg non_pic_object=$xdir$func_lo2o_result 739288de56ccSmrg func_append libobjs " $pic_object" 739388de56ccSmrg func_append non_pic_objects " $non_pic_object" 739488de56ccSmrg else 7395862bcd1aSmrg func_fatal_error "'$arg' is not a valid libtool object" 739688de56ccSmrg fi 739788de56ccSmrg fi 739888de56ccSmrg ;; 73991ab64890Smrg 740088de56ccSmrg *.$libext) 740188de56ccSmrg # An archive. 7402e9fcaa8aSmrg func_append deplibs " $arg" 7403e9fcaa8aSmrg func_append old_deplibs " $arg" 740488de56ccSmrg continue 740588de56ccSmrg ;; 740688de56ccSmrg 740788de56ccSmrg *.la) 740888de56ccSmrg # A libtool-controlled library. 740988de56ccSmrg 7410e9fcaa8aSmrg func_resolve_sysroot "$arg" 7411862bcd1aSmrg if test dlfiles = "$prev"; then 741288de56ccSmrg # This library was specified with -dlopen. 7413e9fcaa8aSmrg func_append dlfiles " $func_resolve_sysroot_result" 741488de56ccSmrg prev= 7415862bcd1aSmrg elif test dlprefiles = "$prev"; then 741688de56ccSmrg # The library was specified with -dlpreopen. 7417e9fcaa8aSmrg func_append dlprefiles " $func_resolve_sysroot_result" 741888de56ccSmrg prev= 741988de56ccSmrg else 7420e9fcaa8aSmrg func_append deplibs " $func_resolve_sysroot_result" 742188de56ccSmrg fi 742288de56ccSmrg continue 742388de56ccSmrg ;; 742488de56ccSmrg 742588de56ccSmrg # Some other compiler argument. 742688de56ccSmrg *) 742788de56ccSmrg # Unknown arguments in both finalize_command and compile_command need 742888de56ccSmrg # to be aesthetically quoted because they are evaled later. 742988de56ccSmrg func_quote_for_eval "$arg" 7430862bcd1aSmrg arg=$func_quote_for_eval_result 743188de56ccSmrg ;; 743288de56ccSmrg esac # arg 743388de56ccSmrg 743488de56ccSmrg # Now actually substitute the argument into the commands. 743588de56ccSmrg if test -n "$arg"; then 743688de56ccSmrg func_append compile_command " $arg" 743788de56ccSmrg func_append finalize_command " $arg" 743888de56ccSmrg fi 743988de56ccSmrg done # argument parsing loop 744088de56ccSmrg 744188de56ccSmrg test -n "$prev" && \ 7442862bcd1aSmrg func_fatal_help "the '$prevarg' option requires an argument" 744388de56ccSmrg 7444862bcd1aSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 744588de56ccSmrg eval arg=\"$export_dynamic_flag_spec\" 744688de56ccSmrg func_append compile_command " $arg" 744788de56ccSmrg func_append finalize_command " $arg" 744888de56ccSmrg fi 744988de56ccSmrg 745088de56ccSmrg oldlibs= 745188de56ccSmrg # calculate the name of the file, without its directory 745288de56ccSmrg func_basename "$output" 7453862bcd1aSmrg outputname=$func_basename_result 7454862bcd1aSmrg libobjs_save=$libobjs 745588de56ccSmrg 745688de56ccSmrg if test -n "$shlibpath_var"; then 745788de56ccSmrg # get the directories listed in $shlibpath_var 7458862bcd1aSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 745988de56ccSmrg else 746088de56ccSmrg shlib_search_path= 746188de56ccSmrg fi 746288de56ccSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 746388de56ccSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 746488de56ccSmrg 7465862bcd1aSmrg # Definition is injected by LT_CONFIG during libtool generation. 7466862bcd1aSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7467862bcd1aSmrg 746888de56ccSmrg func_dirname "$output" "/" "" 7469862bcd1aSmrg output_objdir=$func_dirname_result$objdir 7470e9fcaa8aSmrg func_to_tool_file "$output_objdir/" 7471e9fcaa8aSmrg tool_output_objdir=$func_to_tool_file_result 747288de56ccSmrg # Create the object directory. 747388de56ccSmrg func_mkdir_p "$output_objdir" 747488de56ccSmrg 747588de56ccSmrg # Determine the type of output 747688de56ccSmrg case $output in 747788de56ccSmrg "") 747888de56ccSmrg func_fatal_help "you must specify an output file" 747988de56ccSmrg ;; 748088de56ccSmrg *.$libext) linkmode=oldlib ;; 748188de56ccSmrg *.lo | *.$objext) linkmode=obj ;; 748288de56ccSmrg *.la) linkmode=lib ;; 748388de56ccSmrg *) linkmode=prog ;; # Anything else should be a program. 748488de56ccSmrg esac 748588de56ccSmrg 748688de56ccSmrg specialdeplibs= 748788de56ccSmrg 748888de56ccSmrg libs= 748988de56ccSmrg # Find all interdependent deplibs by searching for libraries 749088de56ccSmrg # that are linked more than once (e.g. -la -lb -la) 749188de56ccSmrg for deplib in $deplibs; do 7492862bcd1aSmrg if $opt_preserve_dup_deps; then 749388de56ccSmrg case "$libs " in 7494e9fcaa8aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 749588de56ccSmrg esac 749688de56ccSmrg fi 7497e9fcaa8aSmrg func_append libs " $deplib" 749888de56ccSmrg done 749988de56ccSmrg 7500862bcd1aSmrg if test lib = "$linkmode"; then 750188de56ccSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 750288de56ccSmrg 750388de56ccSmrg # Compute libraries that are listed more than once in $predeps 750488de56ccSmrg # $postdeps and mark them as special (i.e., whose duplicates are 750588de56ccSmrg # not to be eliminated). 750688de56ccSmrg pre_post_deps= 750788de56ccSmrg if $opt_duplicate_compiler_generated_deps; then 750888de56ccSmrg for pre_post_dep in $predeps $postdeps; do 750988de56ccSmrg case "$pre_post_deps " in 7510e9fcaa8aSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 751188de56ccSmrg esac 7512e9fcaa8aSmrg func_append pre_post_deps " $pre_post_dep" 751388de56ccSmrg done 751488de56ccSmrg fi 751588de56ccSmrg pre_post_deps= 751688de56ccSmrg fi 751788de56ccSmrg 751888de56ccSmrg deplibs= 751988de56ccSmrg newdependency_libs= 752088de56ccSmrg newlib_search_path= 752188de56ccSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 752288de56ccSmrg notinst_deplibs= # not-installed libtool libraries 752388de56ccSmrg notinst_path= # paths that contain not-installed libtool libraries 752488de56ccSmrg 752588de56ccSmrg case $linkmode in 752688de56ccSmrg lib) 752788de56ccSmrg passes="conv dlpreopen link" 752888de56ccSmrg for file in $dlfiles $dlprefiles; do 752988de56ccSmrg case $file in 753088de56ccSmrg *.la) ;; 753188de56ccSmrg *) 7532862bcd1aSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 753388de56ccSmrg ;; 753488de56ccSmrg esac 753588de56ccSmrg done 753688de56ccSmrg ;; 753788de56ccSmrg prog) 753888de56ccSmrg compile_deplibs= 753988de56ccSmrg finalize_deplibs= 7540862bcd1aSmrg alldeplibs=false 754188de56ccSmrg newdlfiles= 754288de56ccSmrg newdlprefiles= 754388de56ccSmrg passes="conv scan dlopen dlpreopen link" 754488de56ccSmrg ;; 754588de56ccSmrg *) passes="conv" 754688de56ccSmrg ;; 754788de56ccSmrg esac 754888de56ccSmrg 754988de56ccSmrg for pass in $passes; do 755088de56ccSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 755188de56ccSmrg # so that -L comes before libs that need it for instance... 7552862bcd1aSmrg if test lib,link = "$linkmode,$pass"; then 755388de56ccSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 755488de56ccSmrg ## order, and fix it there properly 755588de56ccSmrg tmp_deplibs= 755688de56ccSmrg for deplib in $deplibs; do 755788de56ccSmrg tmp_deplibs="$deplib $tmp_deplibs" 755888de56ccSmrg done 7559862bcd1aSmrg deplibs=$tmp_deplibs 756088de56ccSmrg fi 756188de56ccSmrg 7562862bcd1aSmrg if test lib,link = "$linkmode,$pass" || 7563862bcd1aSmrg test prog,scan = "$linkmode,$pass"; then 7564862bcd1aSmrg libs=$deplibs 756588de56ccSmrg deplibs= 756688de56ccSmrg fi 7567862bcd1aSmrg if test prog = "$linkmode"; then 756888de56ccSmrg case $pass in 7569862bcd1aSmrg dlopen) libs=$dlfiles ;; 7570862bcd1aSmrg dlpreopen) libs=$dlprefiles ;; 757103ea5dc6Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 757288de56ccSmrg esac 757388de56ccSmrg fi 7574862bcd1aSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 757588de56ccSmrg # Collect and forward deplibs of preopened libtool libs 757688de56ccSmrg for lib in $dlprefiles; do 757788de56ccSmrg # Ignore non-libtool-libs 757888de56ccSmrg dependency_libs= 7579e9fcaa8aSmrg func_resolve_sysroot "$lib" 758088de56ccSmrg case $lib in 7581e9fcaa8aSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 758288de56ccSmrg esac 758388de56ccSmrg 758488de56ccSmrg # Collect preopened libtool deplibs, except any this library 758588de56ccSmrg # has declared as weak libs 758688de56ccSmrg for deplib in $dependency_libs; do 7587e9fcaa8aSmrg func_basename "$deplib" 7588e9fcaa8aSmrg deplib_base=$func_basename_result 758988de56ccSmrg case " $weak_libs " in 759088de56ccSmrg *" $deplib_base "*) ;; 7591e9fcaa8aSmrg *) func_append deplibs " $deplib" ;; 759288de56ccSmrg esac 759388de56ccSmrg done 759488de56ccSmrg done 7595862bcd1aSmrg libs=$dlprefiles 759688de56ccSmrg fi 7597862bcd1aSmrg if test dlopen = "$pass"; then 759888de56ccSmrg # Collect dlpreopened libraries 7599862bcd1aSmrg save_deplibs=$deplibs 760088de56ccSmrg deplibs= 760188de56ccSmrg fi 760288de56ccSmrg 760388de56ccSmrg for deplib in $libs; do 760488de56ccSmrg lib= 7605862bcd1aSmrg found=false 760688de56ccSmrg case $deplib in 7607eb411b4bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608eb411b4bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7609862bcd1aSmrg if test prog,link = "$linkmode,$pass"; then 761088de56ccSmrg compile_deplibs="$deplib $compile_deplibs" 761188de56ccSmrg finalize_deplibs="$deplib $finalize_deplibs" 761288de56ccSmrg else 7613e9fcaa8aSmrg func_append compiler_flags " $deplib" 7614862bcd1aSmrg if test lib = "$linkmode"; then 761588de56ccSmrg case "$new_inherited_linker_flags " in 761688de56ccSmrg *" $deplib "*) ;; 7617e9fcaa8aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 761888de56ccSmrg esac 761988de56ccSmrg fi 762088de56ccSmrg fi 762188de56ccSmrg continue 762288de56ccSmrg ;; 762388de56ccSmrg -l*) 7624862bcd1aSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7625862bcd1aSmrg func_warning "'-l' is ignored for archives/objects" 762688de56ccSmrg continue 762788de56ccSmrg fi 762888de56ccSmrg func_stripname '-l' '' "$deplib" 762988de56ccSmrg name=$func_stripname_result 7630862bcd1aSmrg if test lib = "$linkmode"; then 763188de56ccSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 763288de56ccSmrg else 763388de56ccSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 763488de56ccSmrg fi 763588de56ccSmrg for searchdir in $searchdirs; do 763688de56ccSmrg for search_ext in .la $std_shrext .so .a; do 763788de56ccSmrg # Search the libtool library 7638862bcd1aSmrg lib=$searchdir/lib$name$search_ext 763988de56ccSmrg if test -f "$lib"; then 7640862bcd1aSmrg if test .la = "$search_ext"; then 7641862bcd1aSmrg found=: 764288de56ccSmrg else 7643862bcd1aSmrg found=false 764488de56ccSmrg fi 764588de56ccSmrg break 2 764688de56ccSmrg fi 764788de56ccSmrg done 764888de56ccSmrg done 7649862bcd1aSmrg if $found; then 7650862bcd1aSmrg # deplib is a libtool library 765188de56ccSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 765288de56ccSmrg # We need to do some special things here, and not later. 7653862bcd1aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 765488de56ccSmrg case " $predeps $postdeps " in 765588de56ccSmrg *" $deplib "*) 765688de56ccSmrg if func_lalib_p "$lib"; then 765788de56ccSmrg library_names= 765888de56ccSmrg old_library= 765988de56ccSmrg func_source "$lib" 766088de56ccSmrg for l in $old_library $library_names; do 7661862bcd1aSmrg ll=$l 766288de56ccSmrg done 7663862bcd1aSmrg if test "X$ll" = "X$old_library"; then # only static version available 7664862bcd1aSmrg found=false 766588de56ccSmrg func_dirname "$lib" "" "." 7666862bcd1aSmrg ladir=$func_dirname_result 766788de56ccSmrg lib=$ladir/$old_library 7668862bcd1aSmrg if test prog,link = "$linkmode,$pass"; then 766988de56ccSmrg compile_deplibs="$deplib $compile_deplibs" 767088de56ccSmrg finalize_deplibs="$deplib $finalize_deplibs" 767188de56ccSmrg else 767288de56ccSmrg deplibs="$deplib $deplibs" 7673862bcd1aSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 767488de56ccSmrg fi 767588de56ccSmrg continue 767688de56ccSmrg fi 767788de56ccSmrg fi 767888de56ccSmrg ;; 767988de56ccSmrg *) ;; 768088de56ccSmrg esac 768188de56ccSmrg fi 7682862bcd1aSmrg else 7683862bcd1aSmrg # deplib doesn't seem to be a libtool library 7684862bcd1aSmrg if test prog,link = "$linkmode,$pass"; then 7685862bcd1aSmrg compile_deplibs="$deplib $compile_deplibs" 7686862bcd1aSmrg finalize_deplibs="$deplib $finalize_deplibs" 7687862bcd1aSmrg else 7688862bcd1aSmrg deplibs="$deplib $deplibs" 7689862bcd1aSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7690862bcd1aSmrg fi 7691862bcd1aSmrg continue 769288de56ccSmrg fi 769388de56ccSmrg ;; # -l 769488de56ccSmrg *.ltframework) 7695862bcd1aSmrg if test prog,link = "$linkmode,$pass"; then 769688de56ccSmrg compile_deplibs="$deplib $compile_deplibs" 769788de56ccSmrg finalize_deplibs="$deplib $finalize_deplibs" 769888de56ccSmrg else 769988de56ccSmrg deplibs="$deplib $deplibs" 7700862bcd1aSmrg if test lib = "$linkmode"; then 770188de56ccSmrg case "$new_inherited_linker_flags " in 770288de56ccSmrg *" $deplib "*) ;; 7703e9fcaa8aSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 770488de56ccSmrg esac 770588de56ccSmrg fi 770688de56ccSmrg fi 770788de56ccSmrg continue 770888de56ccSmrg ;; 770988de56ccSmrg -L*) 771088de56ccSmrg case $linkmode in 771188de56ccSmrg lib) 771288de56ccSmrg deplibs="$deplib $deplibs" 7713862bcd1aSmrg test conv = "$pass" && continue 771488de56ccSmrg newdependency_libs="$deplib $newdependency_libs" 771588de56ccSmrg func_stripname '-L' '' "$deplib" 7716e9fcaa8aSmrg func_resolve_sysroot "$func_stripname_result" 7717e9fcaa8aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 771888de56ccSmrg ;; 771988de56ccSmrg prog) 7720862bcd1aSmrg if test conv = "$pass"; then 772188de56ccSmrg deplibs="$deplib $deplibs" 772288de56ccSmrg continue 772388de56ccSmrg fi 7724862bcd1aSmrg if test scan = "$pass"; then 772588de56ccSmrg deplibs="$deplib $deplibs" 772688de56ccSmrg else 772788de56ccSmrg compile_deplibs="$deplib $compile_deplibs" 772888de56ccSmrg finalize_deplibs="$deplib $finalize_deplibs" 772988de56ccSmrg fi 773088de56ccSmrg func_stripname '-L' '' "$deplib" 7731e9fcaa8aSmrg func_resolve_sysroot "$func_stripname_result" 7732e9fcaa8aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 773388de56ccSmrg ;; 773488de56ccSmrg *) 7735862bcd1aSmrg func_warning "'-L' is ignored for archives/objects" 773688de56ccSmrg ;; 773788de56ccSmrg esac # linkmode 773888de56ccSmrg continue 773988de56ccSmrg ;; # -L 774088de56ccSmrg -R*) 7741862bcd1aSmrg if test link = "$pass"; then 774288de56ccSmrg func_stripname '-R' '' "$deplib" 7743e9fcaa8aSmrg func_resolve_sysroot "$func_stripname_result" 7744e9fcaa8aSmrg dir=$func_resolve_sysroot_result 774588de56ccSmrg # Make sure the xrpath contains only unique directories. 774688de56ccSmrg case "$xrpath " in 774788de56ccSmrg *" $dir "*) ;; 7748e9fcaa8aSmrg *) func_append xrpath " $dir" ;; 774988de56ccSmrg esac 775088de56ccSmrg fi 775188de56ccSmrg deplibs="$deplib $deplibs" 775288de56ccSmrg continue 775388de56ccSmrg ;; 7754e9fcaa8aSmrg *.la) 7755e9fcaa8aSmrg func_resolve_sysroot "$deplib" 7756e9fcaa8aSmrg lib=$func_resolve_sysroot_result 7757e9fcaa8aSmrg ;; 775888de56ccSmrg *.$libext) 7759862bcd1aSmrg if test conv = "$pass"; then 776088de56ccSmrg deplibs="$deplib $deplibs" 776188de56ccSmrg continue 776288de56ccSmrg fi 776388de56ccSmrg case $linkmode in 776488de56ccSmrg lib) 776588de56ccSmrg # Linking convenience modules into shared libraries is allowed, 776688de56ccSmrg # but linking other static libraries is non-portable. 776788de56ccSmrg case " $dlpreconveniencelibs " in 776888de56ccSmrg *" $deplib "*) ;; 776988de56ccSmrg *) 7770862bcd1aSmrg valid_a_lib=false 777188de56ccSmrg case $deplibs_check_method in 777288de56ccSmrg match_pattern*) 777388de56ccSmrg set dummy $deplibs_check_method; shift 777488de56ccSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7775e9fcaa8aSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 777688de56ccSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 7777862bcd1aSmrg valid_a_lib=: 777888de56ccSmrg fi 777988de56ccSmrg ;; 778088de56ccSmrg pass_all) 7781862bcd1aSmrg valid_a_lib=: 778288de56ccSmrg ;; 778388de56ccSmrg esac 7784862bcd1aSmrg if $valid_a_lib; then 7785862bcd1aSmrg echo 7786862bcd1aSmrg $ECHO "*** Warning: Linking the shared library $output against the" 7787862bcd1aSmrg $ECHO "*** static library $deplib is not portable!" 7788862bcd1aSmrg deplibs="$deplib $deplibs" 7789862bcd1aSmrg else 7790e9fcaa8aSmrg echo 779188de56ccSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7792e9fcaa8aSmrg echo "*** I have the capability to make that library automatically link in when" 7793e9fcaa8aSmrg echo "*** you link to this library. But I can only do this if you have a" 7794e9fcaa8aSmrg echo "*** shared version of the library, which you do not appear to have" 7795e9fcaa8aSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 7796e9fcaa8aSmrg echo "*** that it is just a static archive that I should not use here." 779788de56ccSmrg fi 779888de56ccSmrg ;; 779988de56ccSmrg esac 780088de56ccSmrg continue 780188de56ccSmrg ;; 780288de56ccSmrg prog) 7803862bcd1aSmrg if test link != "$pass"; then 780488de56ccSmrg deplibs="$deplib $deplibs" 780588de56ccSmrg else 780688de56ccSmrg compile_deplibs="$deplib $compile_deplibs" 780788de56ccSmrg finalize_deplibs="$deplib $finalize_deplibs" 780888de56ccSmrg fi 780988de56ccSmrg continue 781088de56ccSmrg ;; 781188de56ccSmrg esac # linkmode 781288de56ccSmrg ;; # *.$libext 781388de56ccSmrg *.lo | *.$objext) 7814862bcd1aSmrg if test conv = "$pass"; then 781588de56ccSmrg deplibs="$deplib $deplibs" 7816862bcd1aSmrg elif test prog = "$linkmode"; then 7817862bcd1aSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 781888de56ccSmrg # If there is no dlopen support or we're linking statically, 781988de56ccSmrg # we need to preload. 7820e9fcaa8aSmrg func_append newdlprefiles " $deplib" 782188de56ccSmrg compile_deplibs="$deplib $compile_deplibs" 782288de56ccSmrg finalize_deplibs="$deplib $finalize_deplibs" 782388de56ccSmrg else 7824e9fcaa8aSmrg func_append newdlfiles " $deplib" 782588de56ccSmrg fi 782688de56ccSmrg fi 782788de56ccSmrg continue 782888de56ccSmrg ;; 782988de56ccSmrg %DEPLIBS%) 7830862bcd1aSmrg alldeplibs=: 783188de56ccSmrg continue 783288de56ccSmrg ;; 783388de56ccSmrg esac # case $deplib 783488de56ccSmrg 7835862bcd1aSmrg $found || test -f "$lib" \ 7836862bcd1aSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 783788de56ccSmrg 783888de56ccSmrg # Check to see that this really is a libtool archive. 783988de56ccSmrg func_lalib_unsafe_p "$lib" \ 7840862bcd1aSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 784188de56ccSmrg 784288de56ccSmrg func_dirname "$lib" "" "." 7843862bcd1aSmrg ladir=$func_dirname_result 784488de56ccSmrg 784588de56ccSmrg dlname= 784688de56ccSmrg dlopen= 784788de56ccSmrg dlpreopen= 784888de56ccSmrg libdir= 784988de56ccSmrg library_names= 785088de56ccSmrg old_library= 785188de56ccSmrg inherited_linker_flags= 785288de56ccSmrg # If the library was installed with an old release of libtool, 785388de56ccSmrg # it will not redefine variables installed, or shouldnotlink 785488de56ccSmrg installed=yes 785588de56ccSmrg shouldnotlink=no 785688de56ccSmrg avoidtemprpath= 785788de56ccSmrg 785888de56ccSmrg 785988de56ccSmrg # Read the .la file 786088de56ccSmrg func_source "$lib" 786188de56ccSmrg 786288de56ccSmrg # Convert "-framework foo" to "foo.ltframework" 786388de56ccSmrg if test -n "$inherited_linker_flags"; then 7864e9fcaa8aSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 786588de56ccSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 786688de56ccSmrg case " $new_inherited_linker_flags " in 786788de56ccSmrg *" $tmp_inherited_linker_flag "*) ;; 7868e9fcaa8aSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 786988de56ccSmrg esac 787088de56ccSmrg done 787188de56ccSmrg fi 7872e9fcaa8aSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7873862bcd1aSmrg if test lib,link = "$linkmode,$pass" || 7874862bcd1aSmrg test prog,scan = "$linkmode,$pass" || 7875862bcd1aSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7876e9fcaa8aSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7877e9fcaa8aSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 787888de56ccSmrg fi 787988de56ccSmrg 7880862bcd1aSmrg if test conv = "$pass"; then 788188de56ccSmrg # Only check for convenience libraries 788288de56ccSmrg deplibs="$lib $deplibs" 788388de56ccSmrg if test -z "$libdir"; then 788488de56ccSmrg if test -z "$old_library"; then 7885862bcd1aSmrg func_fatal_error "cannot find name of link library for '$lib'" 788688de56ccSmrg fi 788788de56ccSmrg # It is a libtool convenience library, so add in its objects. 7888e9fcaa8aSmrg func_append convenience " $ladir/$objdir/$old_library" 7889e9fcaa8aSmrg func_append old_convenience " $ladir/$objdir/$old_library" 7890862bcd1aSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 7891862bcd1aSmrg func_fatal_error "'$lib' is not a convenience library" 789288de56ccSmrg fi 789303ea5dc6Smrg tmp_libs= 789403ea5dc6Smrg for deplib in $dependency_libs; do 789503ea5dc6Smrg deplibs="$deplib $deplibs" 789603ea5dc6Smrg if $opt_preserve_dup_deps; then 789703ea5dc6Smrg case "$tmp_libs " in 789803ea5dc6Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 789903ea5dc6Smrg esac 790003ea5dc6Smrg fi 790103ea5dc6Smrg func_append tmp_libs " $deplib" 790203ea5dc6Smrg done 790388de56ccSmrg continue 790488de56ccSmrg fi # $pass = conv 790588de56ccSmrg 790688de56ccSmrg 790788de56ccSmrg # Get the name of the library we link against. 790888de56ccSmrg linklib= 7909e9fcaa8aSmrg if test -n "$old_library" && 7910862bcd1aSmrg { test yes = "$prefer_static_libs" || 7911862bcd1aSmrg test built,no = "$prefer_static_libs,$installed"; }; then 7912e9fcaa8aSmrg linklib=$old_library 7913e9fcaa8aSmrg else 7914e9fcaa8aSmrg for l in $old_library $library_names; do 7915862bcd1aSmrg linklib=$l 7916e9fcaa8aSmrg done 7917e9fcaa8aSmrg fi 791888de56ccSmrg if test -z "$linklib"; then 7919862bcd1aSmrg func_fatal_error "cannot find name of link library for '$lib'" 792088de56ccSmrg fi 792188de56ccSmrg 792288de56ccSmrg # This library was specified with -dlopen. 7923862bcd1aSmrg if test dlopen = "$pass"; then 7924862bcd1aSmrg test -z "$libdir" \ 7925862bcd1aSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 792688de56ccSmrg if test -z "$dlname" || 7927862bcd1aSmrg test yes != "$dlopen_support" || 7928862bcd1aSmrg test no = "$build_libtool_libs" 7929862bcd1aSmrg then 793088de56ccSmrg # If there is no dlname, no dlopen support or we're linking 793188de56ccSmrg # statically, we need to preload. We also need to preload any 793288de56ccSmrg # dependent libraries so libltdl's deplib preloader doesn't 793388de56ccSmrg # bomb out in the load deplibs phase. 7934e9fcaa8aSmrg func_append dlprefiles " $lib $dependency_libs" 793588de56ccSmrg else 7936e9fcaa8aSmrg func_append newdlfiles " $lib" 793788de56ccSmrg fi 793888de56ccSmrg continue 793988de56ccSmrg fi # $pass = dlopen 794088de56ccSmrg 794188de56ccSmrg # We need an absolute path. 794288de56ccSmrg case $ladir in 7943862bcd1aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 794488de56ccSmrg *) 794588de56ccSmrg abs_ladir=`cd "$ladir" && pwd` 794688de56ccSmrg if test -z "$abs_ladir"; then 7947862bcd1aSmrg func_warning "cannot determine absolute directory name of '$ladir'" 794888de56ccSmrg func_warning "passing it literally to the linker, although it might fail" 7949862bcd1aSmrg abs_ladir=$ladir 795088de56ccSmrg fi 795188de56ccSmrg ;; 795288de56ccSmrg esac 795388de56ccSmrg func_basename "$lib" 7954862bcd1aSmrg laname=$func_basename_result 795588de56ccSmrg 795688de56ccSmrg # Find the relevant object directory and library name. 7957862bcd1aSmrg if test yes = "$installed"; then 7958e9fcaa8aSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7959862bcd1aSmrg func_warning "library '$lib' was moved." 7960862bcd1aSmrg dir=$ladir 7961862bcd1aSmrg absdir=$abs_ladir 7962862bcd1aSmrg libdir=$abs_ladir 796388de56ccSmrg else 7964862bcd1aSmrg dir=$lt_sysroot$libdir 7965862bcd1aSmrg absdir=$lt_sysroot$libdir 796688de56ccSmrg fi 7967862bcd1aSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 796888de56ccSmrg else 796988de56ccSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7970862bcd1aSmrg dir=$ladir 7971862bcd1aSmrg absdir=$abs_ladir 797288de56ccSmrg # Remove this search path later 7973e9fcaa8aSmrg func_append notinst_path " $abs_ladir" 797488de56ccSmrg else 7975862bcd1aSmrg dir=$ladir/$objdir 7976862bcd1aSmrg absdir=$abs_ladir/$objdir 797788de56ccSmrg # Remove this search path later 7978e9fcaa8aSmrg func_append notinst_path " $abs_ladir" 797988de56ccSmrg fi 798088de56ccSmrg fi # $installed = yes 798188de56ccSmrg func_stripname 'lib' '.la' "$laname" 798288de56ccSmrg name=$func_stripname_result 798388de56ccSmrg 798488de56ccSmrg # This library was specified with -dlpreopen. 7985862bcd1aSmrg if test dlpreopen = "$pass"; then 7986862bcd1aSmrg if test -z "$libdir" && test prog = "$linkmode"; then 7987862bcd1aSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 798888de56ccSmrg fi 7989862bcd1aSmrg case $host in 7990e9fcaa8aSmrg # special handling for platforms with PE-DLLs. 7991e9fcaa8aSmrg *cygwin* | *mingw* | *cegcc* ) 7992e9fcaa8aSmrg # Linker will automatically link against shared library if both 7993e9fcaa8aSmrg # static and shared are present. Therefore, ensure we extract 7994e9fcaa8aSmrg # symbols from the import library if a shared library is present 7995e9fcaa8aSmrg # (otherwise, the dlopen module name will be incorrect). We do 7996e9fcaa8aSmrg # this by putting the import library name into $newdlprefiles. 7997e9fcaa8aSmrg # We recover the dlopen module name by 'saving' the la file 7998e9fcaa8aSmrg # name in a special purpose variable, and (later) extracting the 7999e9fcaa8aSmrg # dlname from the la file. 8000e9fcaa8aSmrg if test -n "$dlname"; then 8001e9fcaa8aSmrg func_tr_sh "$dir/$linklib" 8002e9fcaa8aSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8003e9fcaa8aSmrg func_append newdlprefiles " $dir/$linklib" 8004e9fcaa8aSmrg else 8005e9fcaa8aSmrg func_append newdlprefiles " $dir/$old_library" 8006e9fcaa8aSmrg # Keep a list of preopened convenience libraries to check 8007e9fcaa8aSmrg # that they are being used correctly in the link pass. 8008e9fcaa8aSmrg test -z "$libdir" && \ 8009e9fcaa8aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8010e9fcaa8aSmrg fi 8011e9fcaa8aSmrg ;; 8012e9fcaa8aSmrg * ) 8013e9fcaa8aSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8014e9fcaa8aSmrg # are required to link). 8015e9fcaa8aSmrg if test -n "$old_library"; then 8016e9fcaa8aSmrg func_append newdlprefiles " $dir/$old_library" 8017e9fcaa8aSmrg # Keep a list of preopened convenience libraries to check 8018e9fcaa8aSmrg # that they are being used correctly in the link pass. 8019e9fcaa8aSmrg test -z "$libdir" && \ 8020e9fcaa8aSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8021e9fcaa8aSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8022e9fcaa8aSmrg elif test -n "$dlname"; then 8023e9fcaa8aSmrg func_append newdlprefiles " $dir/$dlname" 8024e9fcaa8aSmrg else 8025e9fcaa8aSmrg func_append newdlprefiles " $dir/$linklib" 8026e9fcaa8aSmrg fi 8027e9fcaa8aSmrg ;; 8028e9fcaa8aSmrg esac 802988de56ccSmrg fi # $pass = dlpreopen 803088de56ccSmrg 803188de56ccSmrg if test -z "$libdir"; then 803288de56ccSmrg # Link the convenience library 8033862bcd1aSmrg if test lib = "$linkmode"; then 803488de56ccSmrg deplibs="$dir/$old_library $deplibs" 8035862bcd1aSmrg elif test prog,link = "$linkmode,$pass"; then 803688de56ccSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 803788de56ccSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 803888de56ccSmrg else 803988de56ccSmrg deplibs="$lib $deplibs" # used for prog,scan pass 804088de56ccSmrg fi 804188de56ccSmrg continue 804288de56ccSmrg fi 804388de56ccSmrg 804488de56ccSmrg 8045862bcd1aSmrg if test prog = "$linkmode" && test link != "$pass"; then 8046e9fcaa8aSmrg func_append newlib_search_path " $ladir" 804788de56ccSmrg deplibs="$lib $deplibs" 804888de56ccSmrg 8049862bcd1aSmrg linkalldeplibs=false 8050862bcd1aSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8051862bcd1aSmrg test no = "$build_libtool_libs"; then 8052862bcd1aSmrg linkalldeplibs=: 805388de56ccSmrg fi 805488de56ccSmrg 805588de56ccSmrg tmp_libs= 805688de56ccSmrg for deplib in $dependency_libs; do 805788de56ccSmrg case $deplib in 805888de56ccSmrg -L*) func_stripname '-L' '' "$deplib" 8059e9fcaa8aSmrg func_resolve_sysroot "$func_stripname_result" 8060e9fcaa8aSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 806188de56ccSmrg ;; 806288de56ccSmrg esac 806388de56ccSmrg # Need to link against all dependency_libs? 8064862bcd1aSmrg if $linkalldeplibs; then 806588de56ccSmrg deplibs="$deplib $deplibs" 806688de56ccSmrg else 806788de56ccSmrg # Need to hardcode shared library paths 806888de56ccSmrg # or/and link against static libraries 806988de56ccSmrg newdependency_libs="$deplib $newdependency_libs" 807088de56ccSmrg fi 8071862bcd1aSmrg if $opt_preserve_dup_deps; then 807288de56ccSmrg case "$tmp_libs " in 8073e9fcaa8aSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 807488de56ccSmrg esac 807588de56ccSmrg fi 8076e9fcaa8aSmrg func_append tmp_libs " $deplib" 807788de56ccSmrg done # for deplib 807888de56ccSmrg continue 807988de56ccSmrg fi # $linkmode = prog... 808088de56ccSmrg 8081862bcd1aSmrg if test prog,link = "$linkmode,$pass"; then 808288de56ccSmrg if test -n "$library_names" && 8083862bcd1aSmrg { { test no = "$prefer_static_libs" || 8084862bcd1aSmrg test built,yes = "$prefer_static_libs,$installed"; } || 808588de56ccSmrg test -z "$old_library"; }; then 808688de56ccSmrg # We need to hardcode the library path 8087862bcd1aSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 808888de56ccSmrg # Make sure the rpath contains only unique directories. 8089862bcd1aSmrg case $temp_rpath: in 809088de56ccSmrg *"$absdir:"*) ;; 8091e9fcaa8aSmrg *) func_append temp_rpath "$absdir:" ;; 809288de56ccSmrg esac 809388de56ccSmrg fi 809488de56ccSmrg 809588de56ccSmrg # Hardcode the library path. 809688de56ccSmrg # Skip directories that are in the system default run-time 809788de56ccSmrg # search path. 809888de56ccSmrg case " $sys_lib_dlsearch_path " in 809988de56ccSmrg *" $absdir "*) ;; 810088de56ccSmrg *) 810188de56ccSmrg case "$compile_rpath " in 810288de56ccSmrg *" $absdir "*) ;; 8103e9fcaa8aSmrg *) func_append compile_rpath " $absdir" ;; 810488de56ccSmrg esac 810588de56ccSmrg ;; 810688de56ccSmrg esac 810788de56ccSmrg case " $sys_lib_dlsearch_path " in 810888de56ccSmrg *" $libdir "*) ;; 810988de56ccSmrg *) 811088de56ccSmrg case "$finalize_rpath " in 811188de56ccSmrg *" $libdir "*) ;; 8112e9fcaa8aSmrg *) func_append finalize_rpath " $libdir" ;; 811388de56ccSmrg esac 811488de56ccSmrg ;; 811588de56ccSmrg esac 811688de56ccSmrg fi # $linkmode,$pass = prog,link... 811788de56ccSmrg 8118862bcd1aSmrg if $alldeplibs && 8119862bcd1aSmrg { test pass_all = "$deplibs_check_method" || 8120862bcd1aSmrg { test yes = "$build_libtool_libs" && 812188de56ccSmrg test -n "$library_names"; }; }; then 812288de56ccSmrg # We only need to search for static libraries 812388de56ccSmrg continue 812488de56ccSmrg fi 812588de56ccSmrg fi 812688de56ccSmrg 812788de56ccSmrg link_static=no # Whether the deplib will be linked statically 812888de56ccSmrg use_static_libs=$prefer_static_libs 8129862bcd1aSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 813088de56ccSmrg use_static_libs=no 813188de56ccSmrg fi 813288de56ccSmrg if test -n "$library_names" && 8133862bcd1aSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 813488de56ccSmrg case $host in 8135862bcd1aSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 813688de56ccSmrg # No point in relinking DLLs because paths are not encoded 8137e9fcaa8aSmrg func_append notinst_deplibs " $lib" 813888de56ccSmrg need_relink=no 813988de56ccSmrg ;; 814088de56ccSmrg *) 8141862bcd1aSmrg if test no = "$installed"; then 8142e9fcaa8aSmrg func_append notinst_deplibs " $lib" 814388de56ccSmrg need_relink=yes 814488de56ccSmrg fi 814588de56ccSmrg ;; 814688de56ccSmrg esac 814788de56ccSmrg # This is a shared library 814888de56ccSmrg 814988de56ccSmrg # Warn about portability, can't link against -module's on some 815088de56ccSmrg # systems (darwin). Don't bleat about dlopened modules though! 8151862bcd1aSmrg dlopenmodule= 815288de56ccSmrg for dlpremoduletest in $dlprefiles; do 815388de56ccSmrg if test "X$dlpremoduletest" = "X$lib"; then 8154862bcd1aSmrg dlopenmodule=$dlpremoduletest 815588de56ccSmrg break 815688de56ccSmrg fi 815788de56ccSmrg done 8158862bcd1aSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8159e9fcaa8aSmrg echo 8160862bcd1aSmrg if test prog = "$linkmode"; then 816188de56ccSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 816288de56ccSmrg else 816388de56ccSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 816488de56ccSmrg fi 816588de56ccSmrg $ECHO "*** $linklib is not portable!" 816688de56ccSmrg fi 8167862bcd1aSmrg if test lib = "$linkmode" && 8168862bcd1aSmrg test yes = "$hardcode_into_libs"; then 816988de56ccSmrg # Hardcode the library path. 817088de56ccSmrg # Skip directories that are in the system default run-time 817188de56ccSmrg # search path. 817288de56ccSmrg case " $sys_lib_dlsearch_path " in 817388de56ccSmrg *" $absdir "*) ;; 817488de56ccSmrg *) 817588de56ccSmrg case "$compile_rpath " in 817688de56ccSmrg *" $absdir "*) ;; 8177e9fcaa8aSmrg *) func_append compile_rpath " $absdir" ;; 817888de56ccSmrg esac 817988de56ccSmrg ;; 818088de56ccSmrg esac 818188de56ccSmrg case " $sys_lib_dlsearch_path " in 818288de56ccSmrg *" $libdir "*) ;; 818388de56ccSmrg *) 818488de56ccSmrg case "$finalize_rpath " in 818588de56ccSmrg *" $libdir "*) ;; 8186e9fcaa8aSmrg *) func_append finalize_rpath " $libdir" ;; 818788de56ccSmrg esac 818888de56ccSmrg ;; 818988de56ccSmrg esac 819088de56ccSmrg fi 819188de56ccSmrg 819288de56ccSmrg if test -n "$old_archive_from_expsyms_cmds"; then 819388de56ccSmrg # figure out the soname 819488de56ccSmrg set dummy $library_names 819588de56ccSmrg shift 8196862bcd1aSmrg realname=$1 819788de56ccSmrg shift 819888de56ccSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 819988de56ccSmrg # use dlname if we got it. it's perfectly good, no? 820088de56ccSmrg if test -n "$dlname"; then 8201862bcd1aSmrg soname=$dlname 820288de56ccSmrg elif test -n "$soname_spec"; then 820388de56ccSmrg # bleh windows 820488de56ccSmrg case $host in 8205862bcd1aSmrg *cygwin* | mingw* | *cegcc* | *os2*) 820688de56ccSmrg func_arith $current - $age 820788de56ccSmrg major=$func_arith_result 8208862bcd1aSmrg versuffix=-$major 820988de56ccSmrg ;; 821088de56ccSmrg esac 821188de56ccSmrg eval soname=\"$soname_spec\" 821288de56ccSmrg else 8213862bcd1aSmrg soname=$realname 821488de56ccSmrg fi 821588de56ccSmrg 821688de56ccSmrg # Make a new name for the extract_expsyms_cmds to use 8217862bcd1aSmrg soroot=$soname 821888de56ccSmrg func_basename "$soroot" 8219862bcd1aSmrg soname=$func_basename_result 822088de56ccSmrg func_stripname 'lib' '.dll' "$soname" 822188de56ccSmrg newlib=libimp-$func_stripname_result.a 822288de56ccSmrg 822388de56ccSmrg # If the library has no export list, then create one now 822488de56ccSmrg if test -f "$output_objdir/$soname-def"; then : 822588de56ccSmrg else 8226862bcd1aSmrg func_verbose "extracting exported symbol list from '$soname'" 822788de56ccSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 822888de56ccSmrg fi 822988de56ccSmrg 823088de56ccSmrg # Create $newlib 823188de56ccSmrg if test -f "$output_objdir/$newlib"; then :; else 8232862bcd1aSmrg func_verbose "generating import library for '$soname'" 823388de56ccSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 823488de56ccSmrg fi 823588de56ccSmrg # make sure the library variables are pointing to the new library 823688de56ccSmrg dir=$output_objdir 823788de56ccSmrg linklib=$newlib 823888de56ccSmrg fi # test -n "$old_archive_from_expsyms_cmds" 823988de56ccSmrg 8240862bcd1aSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 824188de56ccSmrg add_shlibpath= 824288de56ccSmrg add_dir= 824388de56ccSmrg add= 824488de56ccSmrg lib_linked=yes 824588de56ccSmrg case $hardcode_action in 824688de56ccSmrg immediate | unsupported) 8247862bcd1aSmrg if test no = "$hardcode_direct"; then 8248862bcd1aSmrg add=$dir/$linklib 824988de56ccSmrg case $host in 8250862bcd1aSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8251862bcd1aSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 825288de56ccSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8253862bcd1aSmrg *-*-unixware7*) add_dir=-L$dir ;; 825488de56ccSmrg *-*-darwin* ) 8255862bcd1aSmrg # if the lib is a (non-dlopened) module then we cannot 825688de56ccSmrg # link against it, someone is ignoring the earlier warnings 825788de56ccSmrg if /usr/bin/file -L $add 2> /dev/null | 8258862bcd1aSmrg $GREP ": [^:]* bundle" >/dev/null; then 825988de56ccSmrg if test "X$dlopenmodule" != "X$lib"; then 826088de56ccSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8261862bcd1aSmrg if test -z "$old_library"; then 8262e9fcaa8aSmrg echo 8263e9fcaa8aSmrg echo "*** And there doesn't seem to be a static archive available" 8264e9fcaa8aSmrg echo "*** The link will probably fail, sorry" 826588de56ccSmrg else 8266862bcd1aSmrg add=$dir/$old_library 826788de56ccSmrg fi 826888de56ccSmrg elif test -n "$old_library"; then 8269862bcd1aSmrg add=$dir/$old_library 827088de56ccSmrg fi 827188de56ccSmrg fi 827288de56ccSmrg esac 8273862bcd1aSmrg elif test no = "$hardcode_minus_L"; then 827488de56ccSmrg case $host in 8275862bcd1aSmrg *-*-sunos*) add_shlibpath=$dir ;; 827688de56ccSmrg esac 8277862bcd1aSmrg add_dir=-L$dir 8278862bcd1aSmrg add=-l$name 8279862bcd1aSmrg elif test no = "$hardcode_shlibpath_var"; then 8280862bcd1aSmrg add_shlibpath=$dir 8281862bcd1aSmrg add=-l$name 828288de56ccSmrg else 828388de56ccSmrg lib_linked=no 828488de56ccSmrg fi 828588de56ccSmrg ;; 828688de56ccSmrg relink) 8287862bcd1aSmrg if test yes = "$hardcode_direct" && 8288862bcd1aSmrg test no = "$hardcode_direct_absolute"; then 8289862bcd1aSmrg add=$dir/$linklib 8290862bcd1aSmrg elif test yes = "$hardcode_minus_L"; then 8291862bcd1aSmrg add_dir=-L$absdir 829288de56ccSmrg # Try looking first in the location we're being installed to. 829388de56ccSmrg if test -n "$inst_prefix_dir"; then 829488de56ccSmrg case $libdir in 829588de56ccSmrg [\\/]*) 8296e9fcaa8aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 829788de56ccSmrg ;; 829888de56ccSmrg esac 829988de56ccSmrg fi 8300862bcd1aSmrg add=-l$name 8301862bcd1aSmrg elif test yes = "$hardcode_shlibpath_var"; then 8302862bcd1aSmrg add_shlibpath=$dir 8303862bcd1aSmrg add=-l$name 830488de56ccSmrg else 830588de56ccSmrg lib_linked=no 830688de56ccSmrg fi 830788de56ccSmrg ;; 830888de56ccSmrg *) lib_linked=no ;; 830988de56ccSmrg esac 831088de56ccSmrg 8311862bcd1aSmrg if test yes != "$lib_linked"; then 831288de56ccSmrg func_fatal_configuration "unsupported hardcode properties" 831388de56ccSmrg fi 831488de56ccSmrg 831588de56ccSmrg if test -n "$add_shlibpath"; then 831688de56ccSmrg case :$compile_shlibpath: in 831788de56ccSmrg *":$add_shlibpath:"*) ;; 8318e9fcaa8aSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 831988de56ccSmrg esac 832088de56ccSmrg fi 8321862bcd1aSmrg if test prog = "$linkmode"; then 832288de56ccSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 832388de56ccSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 832488de56ccSmrg else 832588de56ccSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 832688de56ccSmrg test -n "$add" && deplibs="$add $deplibs" 8327862bcd1aSmrg if test yes != "$hardcode_direct" && 8328862bcd1aSmrg test yes != "$hardcode_minus_L" && 8329862bcd1aSmrg test yes = "$hardcode_shlibpath_var"; then 833088de56ccSmrg case :$finalize_shlibpath: in 833188de56ccSmrg *":$libdir:"*) ;; 8332e9fcaa8aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 833388de56ccSmrg esac 833488de56ccSmrg fi 833588de56ccSmrg fi 833688de56ccSmrg fi 833788de56ccSmrg 8338862bcd1aSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 833988de56ccSmrg add_shlibpath= 834088de56ccSmrg add_dir= 834188de56ccSmrg add= 834288de56ccSmrg # Finalize command for both is simple: just hardcode it. 8343862bcd1aSmrg if test yes = "$hardcode_direct" && 8344862bcd1aSmrg test no = "$hardcode_direct_absolute"; then 8345862bcd1aSmrg add=$libdir/$linklib 8346862bcd1aSmrg elif test yes = "$hardcode_minus_L"; then 8347862bcd1aSmrg add_dir=-L$libdir 8348862bcd1aSmrg add=-l$name 8349862bcd1aSmrg elif test yes = "$hardcode_shlibpath_var"; then 835088de56ccSmrg case :$finalize_shlibpath: in 835188de56ccSmrg *":$libdir:"*) ;; 8352e9fcaa8aSmrg *) func_append finalize_shlibpath "$libdir:" ;; 835388de56ccSmrg esac 8354862bcd1aSmrg add=-l$name 8355862bcd1aSmrg elif test yes = "$hardcode_automatic"; then 835688de56ccSmrg if test -n "$inst_prefix_dir" && 8357862bcd1aSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8358862bcd1aSmrg add=$inst_prefix_dir$libdir/$linklib 835988de56ccSmrg else 8360862bcd1aSmrg add=$libdir/$linklib 836188de56ccSmrg fi 836288de56ccSmrg else 836388de56ccSmrg # We cannot seem to hardcode it, guess we'll fake it. 8364862bcd1aSmrg add_dir=-L$libdir 836588de56ccSmrg # Try looking first in the location we're being installed to. 836688de56ccSmrg if test -n "$inst_prefix_dir"; then 836788de56ccSmrg case $libdir in 836888de56ccSmrg [\\/]*) 8369e9fcaa8aSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 837088de56ccSmrg ;; 837188de56ccSmrg esac 837288de56ccSmrg fi 8373862bcd1aSmrg add=-l$name 837488de56ccSmrg fi 837588de56ccSmrg 8376862bcd1aSmrg if test prog = "$linkmode"; then 837788de56ccSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 837888de56ccSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 837988de56ccSmrg else 838088de56ccSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 838188de56ccSmrg test -n "$add" && deplibs="$add $deplibs" 838288de56ccSmrg fi 838388de56ccSmrg fi 8384862bcd1aSmrg elif test prog = "$linkmode"; then 838588de56ccSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 838688de56ccSmrg # is not unsupported. This is valid on all known static and 838788de56ccSmrg # shared platforms. 8388862bcd1aSmrg if test unsupported != "$hardcode_direct"; then 8389862bcd1aSmrg test -n "$old_library" && linklib=$old_library 839088de56ccSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 839188de56ccSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 839288de56ccSmrg else 839388de56ccSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 839488de56ccSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 839588de56ccSmrg fi 8396862bcd1aSmrg elif test yes = "$build_libtool_libs"; then 839788de56ccSmrg # Not a shared library 8398862bcd1aSmrg if test pass_all != "$deplibs_check_method"; then 839988de56ccSmrg # We're trying link a shared library against a static one 840088de56ccSmrg # but the system doesn't support it. 840188de56ccSmrg 840288de56ccSmrg # Just print a warning and add the library to dependency_libs so 840388de56ccSmrg # that the program can be linked against the static library. 8404e9fcaa8aSmrg echo 8405862bcd1aSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8406e9fcaa8aSmrg echo "*** I have the capability to make that library automatically link in when" 8407e9fcaa8aSmrg echo "*** you link to this library. But I can only do this if you have a" 8408e9fcaa8aSmrg echo "*** shared version of the library, which you do not appear to have." 8409862bcd1aSmrg if test yes = "$module"; then 8410e9fcaa8aSmrg echo "*** But as you try to build a module library, libtool will still create " 8411e9fcaa8aSmrg echo "*** a static module, that should work as long as the dlopening application" 8412e9fcaa8aSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 841388de56ccSmrg if test -z "$global_symbol_pipe"; then 8414e9fcaa8aSmrg echo 8415e9fcaa8aSmrg echo "*** However, this would only work if libtool was able to extract symbol" 8416862bcd1aSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8417e9fcaa8aSmrg echo "*** not find such a program. So, this module is probably useless." 8418862bcd1aSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 841988de56ccSmrg fi 8420862bcd1aSmrg if test no = "$build_old_libs"; then 842188de56ccSmrg build_libtool_libs=module 842288de56ccSmrg build_old_libs=yes 842388de56ccSmrg else 842488de56ccSmrg build_libtool_libs=no 842588de56ccSmrg fi 842688de56ccSmrg fi 842788de56ccSmrg else 842888de56ccSmrg deplibs="$dir/$old_library $deplibs" 842988de56ccSmrg link_static=yes 843088de56ccSmrg fi 843188de56ccSmrg fi # link shared/static library? 843288de56ccSmrg 8433862bcd1aSmrg if test lib = "$linkmode"; then 843488de56ccSmrg if test -n "$dependency_libs" && 8435862bcd1aSmrg { test yes != "$hardcode_into_libs" || 8436862bcd1aSmrg test yes = "$build_old_libs" || 8437862bcd1aSmrg test yes = "$link_static"; }; then 843888de56ccSmrg # Extract -R from dependency_libs 843988de56ccSmrg temp_deplibs= 844088de56ccSmrg for libdir in $dependency_libs; do 844188de56ccSmrg case $libdir in 844288de56ccSmrg -R*) func_stripname '-R' '' "$libdir" 844388de56ccSmrg temp_xrpath=$func_stripname_result 844488de56ccSmrg case " $xrpath " in 844588de56ccSmrg *" $temp_xrpath "*) ;; 8446e9fcaa8aSmrg *) func_append xrpath " $temp_xrpath";; 844788de56ccSmrg esac;; 8448e9fcaa8aSmrg *) func_append temp_deplibs " $libdir";; 844988de56ccSmrg esac 845088de56ccSmrg done 8451862bcd1aSmrg dependency_libs=$temp_deplibs 845288de56ccSmrg fi 845388de56ccSmrg 8454e9fcaa8aSmrg func_append newlib_search_path " $absdir" 845588de56ccSmrg # Link against this library 8456862bcd1aSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 845788de56ccSmrg # ... and its dependency_libs 845888de56ccSmrg tmp_libs= 845988de56ccSmrg for deplib in $dependency_libs; do 846088de56ccSmrg newdependency_libs="$deplib $newdependency_libs" 8461e9fcaa8aSmrg case $deplib in 8462e9fcaa8aSmrg -L*) func_stripname '-L' '' "$deplib" 8463e9fcaa8aSmrg func_resolve_sysroot "$func_stripname_result";; 8464e9fcaa8aSmrg *) func_resolve_sysroot "$deplib" ;; 8465e9fcaa8aSmrg esac 8466862bcd1aSmrg if $opt_preserve_dup_deps; then 846788de56ccSmrg case "$tmp_libs " in 8468e9fcaa8aSmrg *" $func_resolve_sysroot_result "*) 8469e9fcaa8aSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 847088de56ccSmrg esac 847188de56ccSmrg fi 8472e9fcaa8aSmrg func_append tmp_libs " $func_resolve_sysroot_result" 847388de56ccSmrg done 847488de56ccSmrg 8475862bcd1aSmrg if test no != "$link_all_deplibs"; then 847688de56ccSmrg # Add the search paths of all dependency libraries 847788de56ccSmrg for deplib in $dependency_libs; do 847847f86ac1Smrg path= 847988de56ccSmrg case $deplib in 8480862bcd1aSmrg -L*) path=$deplib ;; 848188de56ccSmrg *.la) 8482e9fcaa8aSmrg func_resolve_sysroot "$deplib" 8483e9fcaa8aSmrg deplib=$func_resolve_sysroot_result 848488de56ccSmrg func_dirname "$deplib" "" "." 8485e9fcaa8aSmrg dir=$func_dirname_result 848688de56ccSmrg # We need an absolute path. 848788de56ccSmrg case $dir in 8488862bcd1aSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 848988de56ccSmrg *) 849088de56ccSmrg absdir=`cd "$dir" && pwd` 849188de56ccSmrg if test -z "$absdir"; then 8492862bcd1aSmrg func_warning "cannot determine absolute directory name of '$dir'" 8493862bcd1aSmrg absdir=$dir 849488de56ccSmrg fi 849588de56ccSmrg ;; 849688de56ccSmrg esac 849788de56ccSmrg if $GREP "^installed=no" $deplib > /dev/null; then 849888de56ccSmrg case $host in 849988de56ccSmrg *-*-darwin*) 850088de56ccSmrg depdepl= 8501862bcd1aSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8502862bcd1aSmrg if test -n "$deplibrary_names"; then 8503862bcd1aSmrg for tmp in $deplibrary_names; do 850488de56ccSmrg depdepl=$tmp 850588de56ccSmrg done 8506862bcd1aSmrg if test -f "$absdir/$objdir/$depdepl"; then 8507862bcd1aSmrg depdepl=$absdir/$objdir/$depdepl 8508862bcd1aSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 850988de56ccSmrg if test -z "$darwin_install_name"; then 8510862bcd1aSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 851188de56ccSmrg fi 8512862bcd1aSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8513862bcd1aSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 851488de56ccSmrg path= 851588de56ccSmrg fi 851688de56ccSmrg fi 851788de56ccSmrg ;; 851888de56ccSmrg *) 8519862bcd1aSmrg path=-L$absdir/$objdir 852088de56ccSmrg ;; 852188de56ccSmrg esac 852288de56ccSmrg else 8523862bcd1aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 852488de56ccSmrg test -z "$libdir" && \ 8525862bcd1aSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 852688de56ccSmrg test "$absdir" != "$libdir" && \ 8527862bcd1aSmrg func_warning "'$deplib' seems to be moved" 852888de56ccSmrg 8529862bcd1aSmrg path=-L$absdir 853088de56ccSmrg fi 853188de56ccSmrg ;; 853288de56ccSmrg esac 853388de56ccSmrg case " $deplibs " in 853488de56ccSmrg *" $path "*) ;; 853588de56ccSmrg *) deplibs="$path $deplibs" ;; 853688de56ccSmrg esac 853788de56ccSmrg done 853888de56ccSmrg fi # link_all_deplibs != no 853988de56ccSmrg fi # linkmode = lib 854088de56ccSmrg done # for deplib in $libs 8541862bcd1aSmrg if test link = "$pass"; then 8542862bcd1aSmrg if test prog = "$linkmode"; then 854388de56ccSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 854488de56ccSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 854588de56ccSmrg else 8546e9fcaa8aSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 854788de56ccSmrg fi 854888de56ccSmrg fi 8549862bcd1aSmrg dependency_libs=$newdependency_libs 8550862bcd1aSmrg if test dlpreopen = "$pass"; then 855188de56ccSmrg # Link the dlpreopened libraries before other libraries 855288de56ccSmrg for deplib in $save_deplibs; do 855388de56ccSmrg deplibs="$deplib $deplibs" 855488de56ccSmrg done 855588de56ccSmrg fi 8556862bcd1aSmrg if test dlopen != "$pass"; then 8557862bcd1aSmrg test conv = "$pass" || { 855888de56ccSmrg # Make sure lib_search_path contains only unique directories. 855988de56ccSmrg lib_search_path= 856088de56ccSmrg for dir in $newlib_search_path; do 856188de56ccSmrg case "$lib_search_path " in 856288de56ccSmrg *" $dir "*) ;; 8563e9fcaa8aSmrg *) func_append lib_search_path " $dir" ;; 856488de56ccSmrg esac 856588de56ccSmrg done 856688de56ccSmrg newlib_search_path= 8567862bcd1aSmrg } 856888de56ccSmrg 8569862bcd1aSmrg if test prog,link = "$linkmode,$pass"; then 857088de56ccSmrg vars="compile_deplibs finalize_deplibs" 8571862bcd1aSmrg else 8572862bcd1aSmrg vars=deplibs 857388de56ccSmrg fi 857488de56ccSmrg for var in $vars dependency_libs; do 857588de56ccSmrg # Add libraries to $var in reverse order 857688de56ccSmrg eval tmp_libs=\"\$$var\" 857788de56ccSmrg new_libs= 857888de56ccSmrg for deplib in $tmp_libs; do 857988de56ccSmrg # FIXME: Pedantically, this is the right thing to do, so 858088de56ccSmrg # that some nasty dependency loop isn't accidentally 858188de56ccSmrg # broken: 858288de56ccSmrg #new_libs="$deplib $new_libs" 858388de56ccSmrg # Pragmatically, this seems to cause very few problems in 858488de56ccSmrg # practice: 858588de56ccSmrg case $deplib in 858688de56ccSmrg -L*) new_libs="$deplib $new_libs" ;; 858788de56ccSmrg -R*) ;; 858888de56ccSmrg *) 858988de56ccSmrg # And here is the reason: when a library appears more 859088de56ccSmrg # than once as an explicit dependence of a library, or 859188de56ccSmrg # is implicitly linked in more than once by the 859288de56ccSmrg # compiler, it is considered special, and multiple 859388de56ccSmrg # occurrences thereof are not removed. Compare this 859488de56ccSmrg # with having the same library being listed as a 859588de56ccSmrg # dependency of multiple other libraries: in this case, 859688de56ccSmrg # we know (pedantically, we assume) the library does not 859788de56ccSmrg # need to be listed more than once, so we keep only the 859888de56ccSmrg # last copy. This is not always right, but it is rare 859988de56ccSmrg # enough that we require users that really mean to play 860088de56ccSmrg # such unportable linking tricks to link the library 860188de56ccSmrg # using -Wl,-lname, so that libtool does not consider it 860288de56ccSmrg # for duplicate removal. 860388de56ccSmrg case " $specialdeplibs " in 860488de56ccSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 860588de56ccSmrg *) 860688de56ccSmrg case " $new_libs " in 860788de56ccSmrg *" $deplib "*) ;; 860888de56ccSmrg *) new_libs="$deplib $new_libs" ;; 860988de56ccSmrg esac 861088de56ccSmrg ;; 861188de56ccSmrg esac 861288de56ccSmrg ;; 861388de56ccSmrg esac 861488de56ccSmrg done 861588de56ccSmrg tmp_libs= 861688de56ccSmrg for deplib in $new_libs; do 861788de56ccSmrg case $deplib in 861888de56ccSmrg -L*) 861988de56ccSmrg case " $tmp_libs " in 862088de56ccSmrg *" $deplib "*) ;; 8621e9fcaa8aSmrg *) func_append tmp_libs " $deplib" ;; 862288de56ccSmrg esac 862388de56ccSmrg ;; 8624e9fcaa8aSmrg *) func_append tmp_libs " $deplib" ;; 862588de56ccSmrg esac 862688de56ccSmrg done 862788de56ccSmrg eval $var=\"$tmp_libs\" 862888de56ccSmrg done # for var 862988de56ccSmrg fi 8630862bcd1aSmrg 8631862bcd1aSmrg # Add Sun CC postdeps if required: 8632862bcd1aSmrg test CXX = "$tagname" && { 8633862bcd1aSmrg case $host_os in 8634862bcd1aSmrg linux*) 8635862bcd1aSmrg case `$CC -V 2>&1 | sed 5q` in 8636862bcd1aSmrg *Sun\ C*) # Sun C++ 5.9 8637862bcd1aSmrg func_suncc_cstd_abi 8638862bcd1aSmrg 8639862bcd1aSmrg if test no != "$suncc_use_cstd_abi"; then 8640862bcd1aSmrg func_append postdeps ' -library=Cstd -library=Crun' 8641862bcd1aSmrg fi 8642862bcd1aSmrg ;; 8643862bcd1aSmrg esac 8644862bcd1aSmrg ;; 8645862bcd1aSmrg 8646862bcd1aSmrg solaris*) 8647862bcd1aSmrg func_cc_basename "$CC" 8648862bcd1aSmrg case $func_cc_basename_result in 8649862bcd1aSmrg CC* | sunCC*) 8650862bcd1aSmrg func_suncc_cstd_abi 8651862bcd1aSmrg 8652862bcd1aSmrg if test no != "$suncc_use_cstd_abi"; then 8653862bcd1aSmrg func_append postdeps ' -library=Cstd -library=Crun' 8654862bcd1aSmrg fi 8655862bcd1aSmrg ;; 8656862bcd1aSmrg esac 8657862bcd1aSmrg ;; 8658862bcd1aSmrg esac 8659862bcd1aSmrg } 8660862bcd1aSmrg 866188de56ccSmrg # Last step: remove runtime libs from dependency_libs 866288de56ccSmrg # (they stay in deplibs) 866388de56ccSmrg tmp_libs= 8664862bcd1aSmrg for i in $dependency_libs; do 866588de56ccSmrg case " $predeps $postdeps $compiler_lib_search_path " in 866688de56ccSmrg *" $i "*) 8667862bcd1aSmrg i= 866888de56ccSmrg ;; 866988de56ccSmrg esac 8670862bcd1aSmrg if test -n "$i"; then 8671e9fcaa8aSmrg func_append tmp_libs " $i" 867288de56ccSmrg fi 867388de56ccSmrg done 867488de56ccSmrg dependency_libs=$tmp_libs 867588de56ccSmrg done # for pass 8676862bcd1aSmrg if test prog = "$linkmode"; then 8677862bcd1aSmrg dlfiles=$newdlfiles 867888de56ccSmrg fi 8679862bcd1aSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8680862bcd1aSmrg dlprefiles=$newdlprefiles 868188de56ccSmrg fi 868288de56ccSmrg 868388de56ccSmrg case $linkmode in 868488de56ccSmrg oldlib) 8685862bcd1aSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8686862bcd1aSmrg func_warning "'-dlopen' is ignored for archives" 868788de56ccSmrg fi 868888de56ccSmrg 868988de56ccSmrg case " $deplibs" in 869088de56ccSmrg *\ -l* | *\ -L*) 8691862bcd1aSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 869288de56ccSmrg esac 869388de56ccSmrg 869488de56ccSmrg test -n "$rpath" && \ 8695862bcd1aSmrg func_warning "'-rpath' is ignored for archives" 869688de56ccSmrg 869788de56ccSmrg test -n "$xrpath" && \ 8698862bcd1aSmrg func_warning "'-R' is ignored for archives" 869988de56ccSmrg 870088de56ccSmrg test -n "$vinfo" && \ 8701862bcd1aSmrg func_warning "'-version-info/-version-number' is ignored for archives" 870288de56ccSmrg 870388de56ccSmrg test -n "$release" && \ 8704862bcd1aSmrg func_warning "'-release' is ignored for archives" 870588de56ccSmrg 870688de56ccSmrg test -n "$export_symbols$export_symbols_regex" && \ 8707862bcd1aSmrg func_warning "'-export-symbols' is ignored for archives" 870888de56ccSmrg 870988de56ccSmrg # Now set the variables for building old libraries. 871088de56ccSmrg build_libtool_libs=no 8711862bcd1aSmrg oldlibs=$output 8712e9fcaa8aSmrg func_append objs "$old_deplibs" 871388de56ccSmrg ;; 871488de56ccSmrg 871588de56ccSmrg lib) 8716862bcd1aSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 871788de56ccSmrg case $outputname in 871888de56ccSmrg lib*) 871988de56ccSmrg func_stripname 'lib' '.la' "$outputname" 872088de56ccSmrg name=$func_stripname_result 872188de56ccSmrg eval shared_ext=\"$shrext_cmds\" 872288de56ccSmrg eval libname=\"$libname_spec\" 872388de56ccSmrg ;; 872488de56ccSmrg *) 8725862bcd1aSmrg test no = "$module" \ 8726862bcd1aSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 872788de56ccSmrg 8728862bcd1aSmrg if test no != "$need_lib_prefix"; then 872988de56ccSmrg # Add the "lib" prefix for modules if required 873088de56ccSmrg func_stripname '' '.la' "$outputname" 873188de56ccSmrg name=$func_stripname_result 873288de56ccSmrg eval shared_ext=\"$shrext_cmds\" 873388de56ccSmrg eval libname=\"$libname_spec\" 873488de56ccSmrg else 873588de56ccSmrg func_stripname '' '.la' "$outputname" 873688de56ccSmrg libname=$func_stripname_result 873788de56ccSmrg fi 873888de56ccSmrg ;; 873988de56ccSmrg esac 874088de56ccSmrg 874188de56ccSmrg if test -n "$objs"; then 8742862bcd1aSmrg if test pass_all != "$deplibs_check_method"; then 8743862bcd1aSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 874488de56ccSmrg else 8745e9fcaa8aSmrg echo 874688de56ccSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 874788de56ccSmrg $ECHO "*** objects $objs is not portable!" 8748e9fcaa8aSmrg func_append libobjs " $objs" 874988de56ccSmrg fi 875088de56ccSmrg fi 875188de56ccSmrg 8752862bcd1aSmrg test no = "$dlself" \ 8753862bcd1aSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 875488de56ccSmrg 875588de56ccSmrg set dummy $rpath 875688de56ccSmrg shift 8757862bcd1aSmrg test 1 -lt "$#" \ 8758862bcd1aSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 875988de56ccSmrg 8760862bcd1aSmrg install_libdir=$1 876188de56ccSmrg 876288de56ccSmrg oldlibs= 876388de56ccSmrg if test -z "$rpath"; then 8764862bcd1aSmrg if test yes = "$build_libtool_libs"; then 876588de56ccSmrg # Building a libtool convenience library. 8766862bcd1aSmrg # Some compilers have problems with a '.al' extension so 876788de56ccSmrg # convenience libraries should have the same extension an 876888de56ccSmrg # archive normally would. 876988de56ccSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 877088de56ccSmrg build_libtool_libs=convenience 877188de56ccSmrg build_old_libs=yes 877288de56ccSmrg fi 877388de56ccSmrg 877488de56ccSmrg test -n "$vinfo" && \ 8775862bcd1aSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 877688de56ccSmrg 877788de56ccSmrg test -n "$release" && \ 8778862bcd1aSmrg func_warning "'-release' is ignored for convenience libraries" 877988de56ccSmrg else 878088de56ccSmrg 878188de56ccSmrg # Parse the version information argument. 8782862bcd1aSmrg save_ifs=$IFS; IFS=: 878388de56ccSmrg set dummy $vinfo 0 0 0 878488de56ccSmrg shift 8785862bcd1aSmrg IFS=$save_ifs 878688de56ccSmrg 878788de56ccSmrg test -n "$7" && \ 8788862bcd1aSmrg func_fatal_help "too many parameters to '-version-info'" 878988de56ccSmrg 879088de56ccSmrg # convert absolute version numbers to libtool ages 879188de56ccSmrg # this retains compatibility with .la files and attempts 879288de56ccSmrg # to make the code below a bit more comprehensible 879388de56ccSmrg 879488de56ccSmrg case $vinfo_number in 879588de56ccSmrg yes) 8796862bcd1aSmrg number_major=$1 8797862bcd1aSmrg number_minor=$2 8798862bcd1aSmrg number_revision=$3 879988de56ccSmrg # 880088de56ccSmrg # There are really only two kinds -- those that 880188de56ccSmrg # use the current revision as the major version 880288de56ccSmrg # and those that subtract age and use age as 880388de56ccSmrg # a minor version. But, then there is irix 8804862bcd1aSmrg # that has an extra 1 added just for fun 880588de56ccSmrg # 880688de56ccSmrg case $version_type in 8807eb411b4bSmrg # correct linux to gnu/linux during the next big refactor 8808862bcd1aSmrg darwin|freebsd-elf|linux|osf|windows|none) 880988de56ccSmrg func_arith $number_major + $number_minor 881088de56ccSmrg current=$func_arith_result 8811862bcd1aSmrg age=$number_minor 8812862bcd1aSmrg revision=$number_revision 881388de56ccSmrg ;; 8814862bcd1aSmrg freebsd-aout|qnx|sunos) 8815862bcd1aSmrg current=$number_major 8816862bcd1aSmrg revision=$number_minor 8817862bcd1aSmrg age=0 881888de56ccSmrg ;; 881988de56ccSmrg irix|nonstopux) 882088de56ccSmrg func_arith $number_major + $number_minor 882188de56ccSmrg current=$func_arith_result 8822862bcd1aSmrg age=$number_minor 8823862bcd1aSmrg revision=$number_minor 882488de56ccSmrg lt_irix_increment=no 882588de56ccSmrg ;; 882688de56ccSmrg esac 882788de56ccSmrg ;; 882888de56ccSmrg no) 8829862bcd1aSmrg current=$1 8830862bcd1aSmrg revision=$2 8831862bcd1aSmrg age=$3 883288de56ccSmrg ;; 883388de56ccSmrg esac 883488de56ccSmrg 883588de56ccSmrg # Check that each of the things are valid numbers. 883688de56ccSmrg case $current in 883788de56ccSmrg 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]) ;; 883888de56ccSmrg *) 8839862bcd1aSmrg func_error "CURRENT '$current' must be a nonnegative integer" 8840862bcd1aSmrg func_fatal_error "'$vinfo' is not valid version information" 884188de56ccSmrg ;; 884288de56ccSmrg esac 884388de56ccSmrg 884488de56ccSmrg case $revision in 884588de56ccSmrg 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]) ;; 884688de56ccSmrg *) 8847862bcd1aSmrg func_error "REVISION '$revision' must be a nonnegative integer" 8848862bcd1aSmrg func_fatal_error "'$vinfo' is not valid version information" 884988de56ccSmrg ;; 885088de56ccSmrg esac 885188de56ccSmrg 885288de56ccSmrg case $age in 885388de56ccSmrg 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]) ;; 885488de56ccSmrg *) 8855862bcd1aSmrg func_error "AGE '$age' must be a nonnegative integer" 8856862bcd1aSmrg func_fatal_error "'$vinfo' is not valid version information" 885788de56ccSmrg ;; 885888de56ccSmrg esac 885988de56ccSmrg 886088de56ccSmrg if test "$age" -gt "$current"; then 8861862bcd1aSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 8862862bcd1aSmrg func_fatal_error "'$vinfo' is not valid version information" 886388de56ccSmrg fi 886488de56ccSmrg 886588de56ccSmrg # Calculate the version variables. 886688de56ccSmrg major= 886788de56ccSmrg versuffix= 886888de56ccSmrg verstring= 886988de56ccSmrg case $version_type in 887088de56ccSmrg none) ;; 887188de56ccSmrg 887288de56ccSmrg darwin) 887388de56ccSmrg # Like Linux, but with the current version available in 887488de56ccSmrg # verstring for coding it into the library header 887588de56ccSmrg func_arith $current - $age 887688de56ccSmrg major=.$func_arith_result 8877862bcd1aSmrg versuffix=$major.$age.$revision 887888de56ccSmrg # Darwin ld doesn't like 0 for these options... 887988de56ccSmrg func_arith $current + 1 888088de56ccSmrg minor_current=$func_arith_result 8881862bcd1aSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 888288de56ccSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8883862bcd1aSmrg # On Darwin other compilers 8884862bcd1aSmrg case $CC in 8885862bcd1aSmrg nagfor*) 8886862bcd1aSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8887862bcd1aSmrg ;; 8888862bcd1aSmrg *) 8889862bcd1aSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8890862bcd1aSmrg ;; 8891862bcd1aSmrg esac 889288de56ccSmrg ;; 889388de56ccSmrg 889488de56ccSmrg freebsd-aout) 8895862bcd1aSmrg major=.$current 8896862bcd1aSmrg versuffix=.$current.$revision 889788de56ccSmrg ;; 889888de56ccSmrg 889988de56ccSmrg freebsd-elf) 8900862bcd1aSmrg func_arith $current - $age 8901862bcd1aSmrg major=.$func_arith_result 8902862bcd1aSmrg versuffix=$major.$age.$revision 890388de56ccSmrg ;; 890488de56ccSmrg 890588de56ccSmrg irix | nonstopux) 8906862bcd1aSmrg if test no = "$lt_irix_increment"; then 890788de56ccSmrg func_arith $current - $age 890888de56ccSmrg else 890988de56ccSmrg func_arith $current - $age + 1 891088de56ccSmrg fi 891188de56ccSmrg major=$func_arith_result 891288de56ccSmrg 891388de56ccSmrg case $version_type in 891488de56ccSmrg nonstopux) verstring_prefix=nonstopux ;; 891588de56ccSmrg *) verstring_prefix=sgi ;; 891688de56ccSmrg esac 8917862bcd1aSmrg verstring=$verstring_prefix$major.$revision 891888de56ccSmrg 891988de56ccSmrg # Add in all the interfaces that we are compatible with. 892088de56ccSmrg loop=$revision 8921862bcd1aSmrg while test 0 -ne "$loop"; do 892288de56ccSmrg func_arith $revision - $loop 892388de56ccSmrg iface=$func_arith_result 892488de56ccSmrg func_arith $loop - 1 892588de56ccSmrg loop=$func_arith_result 8926862bcd1aSmrg verstring=$verstring_prefix$major.$iface:$verstring 892788de56ccSmrg done 892888de56ccSmrg 8929862bcd1aSmrg # Before this point, $major must not contain '.'. 893088de56ccSmrg major=.$major 8931862bcd1aSmrg versuffix=$major.$revision 893288de56ccSmrg ;; 893388de56ccSmrg 8934eb411b4bSmrg linux) # correct to gnu/linux during the next big refactor 893588de56ccSmrg func_arith $current - $age 893688de56ccSmrg major=.$func_arith_result 8937862bcd1aSmrg versuffix=$major.$age.$revision 893888de56ccSmrg ;; 893988de56ccSmrg 894088de56ccSmrg osf) 894188de56ccSmrg func_arith $current - $age 894288de56ccSmrg major=.$func_arith_result 8943862bcd1aSmrg versuffix=.$current.$age.$revision 8944862bcd1aSmrg verstring=$current.$age.$revision 894588de56ccSmrg 894688de56ccSmrg # Add in all the interfaces that we are compatible with. 894788de56ccSmrg loop=$age 8948862bcd1aSmrg while test 0 -ne "$loop"; do 894988de56ccSmrg func_arith $current - $loop 895088de56ccSmrg iface=$func_arith_result 895188de56ccSmrg func_arith $loop - 1 895288de56ccSmrg loop=$func_arith_result 8953862bcd1aSmrg verstring=$verstring:$iface.0 895488de56ccSmrg done 895588de56ccSmrg 895688de56ccSmrg # Make executables depend on our current version. 8957862bcd1aSmrg func_append verstring ":$current.0" 895888de56ccSmrg ;; 895988de56ccSmrg 896088de56ccSmrg qnx) 8961862bcd1aSmrg major=.$current 8962862bcd1aSmrg versuffix=.$current 8963862bcd1aSmrg ;; 8964862bcd1aSmrg 8965862bcd1aSmrg sco) 8966862bcd1aSmrg major=.$current 8967862bcd1aSmrg versuffix=.$current 896888de56ccSmrg ;; 896988de56ccSmrg 897088de56ccSmrg sunos) 8971862bcd1aSmrg major=.$current 8972862bcd1aSmrg versuffix=.$current.$revision 897388de56ccSmrg ;; 897488de56ccSmrg 897588de56ccSmrg windows) 897688de56ccSmrg # Use '-' rather than '.', since we only want one 8977862bcd1aSmrg # extension on DOS 8.3 file systems. 897888de56ccSmrg func_arith $current - $age 897988de56ccSmrg major=$func_arith_result 8980862bcd1aSmrg versuffix=-$major 898188de56ccSmrg ;; 898288de56ccSmrg 898388de56ccSmrg *) 8984862bcd1aSmrg func_fatal_configuration "unknown library version type '$version_type'" 898588de56ccSmrg ;; 898688de56ccSmrg esac 898788de56ccSmrg 898888de56ccSmrg # Clear the version info if we defaulted, and they specified a release. 898988de56ccSmrg if test -z "$vinfo" && test -n "$release"; then 899088de56ccSmrg major= 899188de56ccSmrg case $version_type in 899288de56ccSmrg darwin) 899388de56ccSmrg # we can't check for "0.0" in archive_cmds due to quoting 899488de56ccSmrg # problems, so we reset it completely 899588de56ccSmrg verstring= 899688de56ccSmrg ;; 899788de56ccSmrg *) 8998862bcd1aSmrg verstring=0.0 899988de56ccSmrg ;; 900088de56ccSmrg esac 9001862bcd1aSmrg if test no = "$need_version"; then 900288de56ccSmrg versuffix= 900388de56ccSmrg else 9004862bcd1aSmrg versuffix=.0.0 900588de56ccSmrg fi 900688de56ccSmrg fi 900788de56ccSmrg 900888de56ccSmrg # Remove version info from name if versioning should be avoided 9009862bcd1aSmrg if test yes,no = "$avoid_version,$need_version"; then 901088de56ccSmrg major= 901188de56ccSmrg versuffix= 9012862bcd1aSmrg verstring= 901388de56ccSmrg fi 901488de56ccSmrg 901588de56ccSmrg # Check to see if the archive will have undefined symbols. 9016862bcd1aSmrg if test yes = "$allow_undefined"; then 9017862bcd1aSmrg if test unsupported = "$allow_undefined_flag"; then 9018862bcd1aSmrg if test yes = "$build_old_libs"; then 9019862bcd1aSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9020862bcd1aSmrg build_libtool_libs=no 9021862bcd1aSmrg else 9022862bcd1aSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9023862bcd1aSmrg fi 902488de56ccSmrg fi 902588de56ccSmrg else 902688de56ccSmrg # Don't allow undefined symbols. 9027862bcd1aSmrg allow_undefined_flag=$no_undefined_flag 902888de56ccSmrg fi 902988de56ccSmrg 903088de56ccSmrg fi 903188de56ccSmrg 9032862bcd1aSmrg func_generate_dlsyms "$libname" "$libname" : 9033e9fcaa8aSmrg func_append libobjs " $symfileobj" 9034862bcd1aSmrg test " " = "$libobjs" && libobjs= 903588de56ccSmrg 9036862bcd1aSmrg if test relink != "$opt_mode"; then 903788de56ccSmrg # Remove our outputs, but don't remove object files since they 903888de56ccSmrg # may have been created when compiling PIC objects. 903988de56ccSmrg removelist= 904088de56ccSmrg tempremovelist=`$ECHO "$output_objdir/*"` 904188de56ccSmrg for p in $tempremovelist; do 904288de56ccSmrg case $p in 904388de56ccSmrg *.$objext | *.gcno) 904488de56ccSmrg ;; 9045862bcd1aSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9046862bcd1aSmrg if test -n "$precious_files_regex"; then 904788de56ccSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 904888de56ccSmrg then 904988de56ccSmrg continue 905088de56ccSmrg fi 905188de56ccSmrg fi 9052e9fcaa8aSmrg func_append removelist " $p" 905388de56ccSmrg ;; 905488de56ccSmrg *) ;; 905588de56ccSmrg esac 905688de56ccSmrg done 905788de56ccSmrg test -n "$removelist" && \ 905888de56ccSmrg func_show_eval "${RM}r \$removelist" 905988de56ccSmrg fi 906088de56ccSmrg 906188de56ccSmrg # Now set the variables for building old libraries. 9062862bcd1aSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9063e9fcaa8aSmrg func_append oldlibs " $output_objdir/$libname.$libext" 906488de56ccSmrg 906588de56ccSmrg # Transform .lo files to .o files. 9066862bcd1aSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 906788de56ccSmrg fi 906888de56ccSmrg 906988de56ccSmrg # Eliminate all temporary directories. 907088de56ccSmrg #for path in $notinst_path; do 9071e9fcaa8aSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9072e9fcaa8aSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9073e9fcaa8aSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 907488de56ccSmrg #done 907588de56ccSmrg 907688de56ccSmrg if test -n "$xrpath"; then 907788de56ccSmrg # If the user specified any rpath flags, then add them. 907888de56ccSmrg temp_xrpath= 907988de56ccSmrg for libdir in $xrpath; do 9080e9fcaa8aSmrg func_replace_sysroot "$libdir" 9081e9fcaa8aSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 908288de56ccSmrg case "$finalize_rpath " in 908388de56ccSmrg *" $libdir "*) ;; 9084e9fcaa8aSmrg *) func_append finalize_rpath " $libdir" ;; 908588de56ccSmrg esac 908688de56ccSmrg done 9087862bcd1aSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 908888de56ccSmrg dependency_libs="$temp_xrpath $dependency_libs" 908988de56ccSmrg fi 909088de56ccSmrg fi 909188de56ccSmrg 909288de56ccSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9093862bcd1aSmrg old_dlfiles=$dlfiles 909488de56ccSmrg dlfiles= 909588de56ccSmrg for lib in $old_dlfiles; do 909688de56ccSmrg case " $dlprefiles $dlfiles " in 909788de56ccSmrg *" $lib "*) ;; 9098e9fcaa8aSmrg *) func_append dlfiles " $lib" ;; 909988de56ccSmrg esac 910088de56ccSmrg done 910188de56ccSmrg 910288de56ccSmrg # Make sure dlprefiles contains only unique files 9103862bcd1aSmrg old_dlprefiles=$dlprefiles 910488de56ccSmrg dlprefiles= 910588de56ccSmrg for lib in $old_dlprefiles; do 910688de56ccSmrg case "$dlprefiles " in 910788de56ccSmrg *" $lib "*) ;; 9108e9fcaa8aSmrg *) func_append dlprefiles " $lib" ;; 910988de56ccSmrg esac 911088de56ccSmrg done 911188de56ccSmrg 9112862bcd1aSmrg if test yes = "$build_libtool_libs"; then 911388de56ccSmrg if test -n "$rpath"; then 911488de56ccSmrg case $host in 9115e9fcaa8aSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 911688de56ccSmrg # these systems don't actually have a c library (as such)! 911788de56ccSmrg ;; 911888de56ccSmrg *-*-rhapsody* | *-*-darwin1.[012]) 911988de56ccSmrg # Rhapsody C library is in the System framework 9120e9fcaa8aSmrg func_append deplibs " System.ltframework" 912188de56ccSmrg ;; 912288de56ccSmrg *-*-netbsd*) 912388de56ccSmrg # Don't link with libc until the a.out ld.so is fixed. 912488de56ccSmrg ;; 912588de56ccSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 912688de56ccSmrg # Do not include libc due to us having libc/libc_r. 912788de56ccSmrg ;; 912888de56ccSmrg *-*-sco3.2v5* | *-*-sco5v6*) 912988de56ccSmrg # Causes problems with __ctype 913088de56ccSmrg ;; 913188de56ccSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 913288de56ccSmrg # Compiler inserts libc in the correct place for threads to work 913388de56ccSmrg ;; 913488de56ccSmrg *) 913588de56ccSmrg # Add libc to deplibs on all other systems if necessary. 9136862bcd1aSmrg if test yes = "$build_libtool_need_lc"; then 9137e9fcaa8aSmrg func_append deplibs " -lc" 913888de56ccSmrg fi 913988de56ccSmrg ;; 914088de56ccSmrg esac 914188de56ccSmrg fi 914288de56ccSmrg 914388de56ccSmrg # Transform deplibs into only deplibs that can be linked in shared. 914488de56ccSmrg name_save=$name 914588de56ccSmrg libname_save=$libname 914688de56ccSmrg release_save=$release 914788de56ccSmrg versuffix_save=$versuffix 914888de56ccSmrg major_save=$major 914988de56ccSmrg # I'm not sure if I'm treating the release correctly. I think 915088de56ccSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 915188de56ccSmrg # add it in twice. Is that correct? 9152862bcd1aSmrg release= 9153862bcd1aSmrg versuffix= 9154862bcd1aSmrg major= 915588de56ccSmrg newdeplibs= 915688de56ccSmrg droppeddeps=no 915788de56ccSmrg case $deplibs_check_method in 915888de56ccSmrg pass_all) 915988de56ccSmrg # Don't check for shared/static. Everything works. 916088de56ccSmrg # This might be a little naive. We might want to check 916188de56ccSmrg # whether the library exists or not. But this is on 916288de56ccSmrg # osf3 & osf4 and I'm not really sure... Just 916388de56ccSmrg # implementing what was already the behavior. 916488de56ccSmrg newdeplibs=$deplibs 916588de56ccSmrg ;; 916688de56ccSmrg test_compile) 916788de56ccSmrg # This code stresses the "libraries are programs" paradigm to its 916888de56ccSmrg # limits. Maybe even breaks it. We compile a program, linking it 916988de56ccSmrg # against the deplibs as a proxy for the library. Then we can check 917088de56ccSmrg # whether they linked in statically or dynamically with ldd. 917188de56ccSmrg $opt_dry_run || $RM conftest.c 917288de56ccSmrg cat > conftest.c <<EOF 917388de56ccSmrg int main() { return 0; } 917488de56ccSmrgEOF 917588de56ccSmrg $opt_dry_run || $RM conftest 917688de56ccSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 917788de56ccSmrg ldd_output=`ldd conftest` 917888de56ccSmrg for i in $deplibs; do 917988de56ccSmrg case $i in 918088de56ccSmrg -l*) 918188de56ccSmrg func_stripname -l '' "$i" 918288de56ccSmrg name=$func_stripname_result 9183862bcd1aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 918488de56ccSmrg case " $predeps $postdeps " in 918588de56ccSmrg *" $i "*) 9186e9fcaa8aSmrg func_append newdeplibs " $i" 9187862bcd1aSmrg i= 918888de56ccSmrg ;; 918988de56ccSmrg esac 919088de56ccSmrg fi 9191862bcd1aSmrg if test -n "$i"; then 919288de56ccSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 919388de56ccSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 919488de56ccSmrg set dummy $deplib_matches; shift 919588de56ccSmrg deplib_match=$1 9196862bcd1aSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9197e9fcaa8aSmrg func_append newdeplibs " $i" 919888de56ccSmrg else 919988de56ccSmrg droppeddeps=yes 9200e9fcaa8aSmrg echo 920188de56ccSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9202e9fcaa8aSmrg echo "*** I have the capability to make that library automatically link in when" 9203e9fcaa8aSmrg echo "*** you link to this library. But I can only do this if you have a" 9204e9fcaa8aSmrg echo "*** shared version of the library, which I believe you do not have" 9205e9fcaa8aSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 9206e9fcaa8aSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 920788de56ccSmrg fi 920888de56ccSmrg fi 920988de56ccSmrg ;; 921088de56ccSmrg *) 9211e9fcaa8aSmrg func_append newdeplibs " $i" 921288de56ccSmrg ;; 921388de56ccSmrg esac 921488de56ccSmrg done 921588de56ccSmrg else 921688de56ccSmrg # Error occurred in the first compile. Let's try to salvage 921788de56ccSmrg # the situation: Compile a separate program for each library. 921888de56ccSmrg for i in $deplibs; do 921988de56ccSmrg case $i in 922088de56ccSmrg -l*) 922188de56ccSmrg func_stripname -l '' "$i" 922288de56ccSmrg name=$func_stripname_result 922388de56ccSmrg $opt_dry_run || $RM conftest 922488de56ccSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 922588de56ccSmrg ldd_output=`ldd conftest` 9226862bcd1aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 922788de56ccSmrg case " $predeps $postdeps " in 922888de56ccSmrg *" $i "*) 9229e9fcaa8aSmrg func_append newdeplibs " $i" 9230862bcd1aSmrg i= 923188de56ccSmrg ;; 923288de56ccSmrg esac 923388de56ccSmrg fi 9234862bcd1aSmrg if test -n "$i"; then 923588de56ccSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 923688de56ccSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 923788de56ccSmrg set dummy $deplib_matches; shift 923888de56ccSmrg deplib_match=$1 9239862bcd1aSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9240e9fcaa8aSmrg func_append newdeplibs " $i" 924188de56ccSmrg else 924288de56ccSmrg droppeddeps=yes 9243e9fcaa8aSmrg echo 924488de56ccSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9245e9fcaa8aSmrg echo "*** I have the capability to make that library automatically link in when" 9246e9fcaa8aSmrg echo "*** you link to this library. But I can only do this if you have a" 9247e9fcaa8aSmrg echo "*** shared version of the library, which you do not appear to have" 9248e9fcaa8aSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 9249e9fcaa8aSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 925088de56ccSmrg fi 925188de56ccSmrg fi 925288de56ccSmrg else 925388de56ccSmrg droppeddeps=yes 9254e9fcaa8aSmrg echo 925588de56ccSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9256e9fcaa8aSmrg echo "*** make it link in! You will probably need to install it or some" 9257e9fcaa8aSmrg echo "*** library that it depends on before this library will be fully" 9258e9fcaa8aSmrg echo "*** functional. Installing it before continuing would be even better." 925988de56ccSmrg fi 926088de56ccSmrg ;; 926188de56ccSmrg *) 9262e9fcaa8aSmrg func_append newdeplibs " $i" 926388de56ccSmrg ;; 926488de56ccSmrg esac 926588de56ccSmrg done 926688de56ccSmrg fi 926788de56ccSmrg ;; 926888de56ccSmrg file_magic*) 926988de56ccSmrg set dummy $deplibs_check_method; shift 927088de56ccSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 927188de56ccSmrg for a_deplib in $deplibs; do 927288de56ccSmrg case $a_deplib in 927388de56ccSmrg -l*) 927488de56ccSmrg func_stripname -l '' "$a_deplib" 927588de56ccSmrg name=$func_stripname_result 9276862bcd1aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 927788de56ccSmrg case " $predeps $postdeps " in 927888de56ccSmrg *" $a_deplib "*) 9279e9fcaa8aSmrg func_append newdeplibs " $a_deplib" 9280862bcd1aSmrg a_deplib= 928188de56ccSmrg ;; 928288de56ccSmrg esac 928388de56ccSmrg fi 9284862bcd1aSmrg if test -n "$a_deplib"; then 928588de56ccSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9286e9fcaa8aSmrg if test -n "$file_magic_glob"; then 9287e9fcaa8aSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9288e9fcaa8aSmrg else 9289e9fcaa8aSmrg libnameglob=$libname 9290e9fcaa8aSmrg fi 9291862bcd1aSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 929288de56ccSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9293862bcd1aSmrg if test yes = "$want_nocaseglob"; then 9294e9fcaa8aSmrg shopt -s nocaseglob 9295e9fcaa8aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9296e9fcaa8aSmrg $nocaseglob 9297e9fcaa8aSmrg else 9298e9fcaa8aSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9299e9fcaa8aSmrg fi 930088de56ccSmrg for potent_lib in $potential_libs; do 930188de56ccSmrg # Follow soft links. 930288de56ccSmrg if ls -lLd "$potent_lib" 2>/dev/null | 930388de56ccSmrg $GREP " -> " >/dev/null; then 930488de56ccSmrg continue 930588de56ccSmrg fi 930688de56ccSmrg # The statement above tries to avoid entering an 930788de56ccSmrg # endless loop below, in case of cyclic links. 930888de56ccSmrg # We might still enter an endless loop, since a link 930988de56ccSmrg # loop can be closed while we follow links, 931088de56ccSmrg # but so what? 9311862bcd1aSmrg potlib=$potent_lib 931288de56ccSmrg while test -h "$potlib" 2>/dev/null; do 9313862bcd1aSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 931488de56ccSmrg case $potliblink in 9315862bcd1aSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9316862bcd1aSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 931788de56ccSmrg esac 931888de56ccSmrg done 931988de56ccSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 932088de56ccSmrg $SED -e 10q | 932188de56ccSmrg $EGREP "$file_magic_regex" > /dev/null; then 9322e9fcaa8aSmrg func_append newdeplibs " $a_deplib" 9323862bcd1aSmrg a_deplib= 932488de56ccSmrg break 2 932588de56ccSmrg fi 932688de56ccSmrg done 932788de56ccSmrg done 932888de56ccSmrg fi 9329862bcd1aSmrg if test -n "$a_deplib"; then 933088de56ccSmrg droppeddeps=yes 9331e9fcaa8aSmrg echo 933288de56ccSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9333e9fcaa8aSmrg echo "*** I have the capability to make that library automatically link in when" 9334e9fcaa8aSmrg echo "*** you link to this library. But I can only do this if you have a" 9335e9fcaa8aSmrg echo "*** shared version of the library, which you do not appear to have" 9336e9fcaa8aSmrg echo "*** because I did check the linker path looking for a file starting" 9337862bcd1aSmrg if test -z "$potlib"; then 933888de56ccSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 933988de56ccSmrg else 934088de56ccSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 934188de56ccSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 934288de56ccSmrg fi 934388de56ccSmrg fi 934488de56ccSmrg ;; 934588de56ccSmrg *) 934688de56ccSmrg # Add a -L argument. 9347e9fcaa8aSmrg func_append newdeplibs " $a_deplib" 934888de56ccSmrg ;; 934988de56ccSmrg esac 935088de56ccSmrg done # Gone through all deplibs. 935188de56ccSmrg ;; 935288de56ccSmrg match_pattern*) 935388de56ccSmrg set dummy $deplibs_check_method; shift 935488de56ccSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 935588de56ccSmrg for a_deplib in $deplibs; do 935688de56ccSmrg case $a_deplib in 935788de56ccSmrg -l*) 935888de56ccSmrg func_stripname -l '' "$a_deplib" 935988de56ccSmrg name=$func_stripname_result 9360862bcd1aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 936188de56ccSmrg case " $predeps $postdeps " in 936288de56ccSmrg *" $a_deplib "*) 9363e9fcaa8aSmrg func_append newdeplibs " $a_deplib" 9364862bcd1aSmrg a_deplib= 936588de56ccSmrg ;; 936688de56ccSmrg esac 936788de56ccSmrg fi 9368862bcd1aSmrg if test -n "$a_deplib"; then 936988de56ccSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 937088de56ccSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 937188de56ccSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 937288de56ccSmrg for potent_lib in $potential_libs; do 9373862bcd1aSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9374e9fcaa8aSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 937588de56ccSmrg $EGREP "$match_pattern_regex" > /dev/null; then 9376e9fcaa8aSmrg func_append newdeplibs " $a_deplib" 9377862bcd1aSmrg a_deplib= 937888de56ccSmrg break 2 937988de56ccSmrg fi 938088de56ccSmrg done 938188de56ccSmrg done 938288de56ccSmrg fi 9383862bcd1aSmrg if test -n "$a_deplib"; then 938488de56ccSmrg droppeddeps=yes 9385e9fcaa8aSmrg echo 938688de56ccSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9387e9fcaa8aSmrg echo "*** I have the capability to make that library automatically link in when" 9388e9fcaa8aSmrg echo "*** you link to this library. But I can only do this if you have a" 9389e9fcaa8aSmrg echo "*** shared version of the library, which you do not appear to have" 9390e9fcaa8aSmrg echo "*** because I did check the linker path looking for a file starting" 9391862bcd1aSmrg if test -z "$potlib"; then 939288de56ccSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 939388de56ccSmrg else 939488de56ccSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 939588de56ccSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 939688de56ccSmrg fi 939788de56ccSmrg fi 939888de56ccSmrg ;; 939988de56ccSmrg *) 940088de56ccSmrg # Add a -L argument. 9401e9fcaa8aSmrg func_append newdeplibs " $a_deplib" 940288de56ccSmrg ;; 940388de56ccSmrg esac 940488de56ccSmrg done # Gone through all deplibs. 940588de56ccSmrg ;; 940688de56ccSmrg none | unknown | *) 9407862bcd1aSmrg newdeplibs= 9408e9fcaa8aSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9409862bcd1aSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9410862bcd1aSmrg for i in $predeps $postdeps; do 941188de56ccSmrg # can't use Xsed below, because $i might contain '/' 9412862bcd1aSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 941388de56ccSmrg done 941488de56ccSmrg fi 9415e9fcaa8aSmrg case $tmp_deplibs in 9416e9fcaa8aSmrg *[!\ \ ]*) 9417e9fcaa8aSmrg echo 9418862bcd1aSmrg if test none = "$deplibs_check_method"; then 9419e9fcaa8aSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 942088de56ccSmrg else 9421e9fcaa8aSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 942288de56ccSmrg fi 9423e9fcaa8aSmrg echo "*** All declared inter-library dependencies are being dropped." 942488de56ccSmrg droppeddeps=yes 9425e9fcaa8aSmrg ;; 9426e9fcaa8aSmrg esac 942788de56ccSmrg ;; 942888de56ccSmrg esac 942988de56ccSmrg versuffix=$versuffix_save 943088de56ccSmrg major=$major_save 943188de56ccSmrg release=$release_save 943288de56ccSmrg libname=$libname_save 943388de56ccSmrg name=$name_save 943488de56ccSmrg 943588de56ccSmrg case $host in 943688de56ccSmrg *-*-rhapsody* | *-*-darwin1.[012]) 943788de56ccSmrg # On Rhapsody replace the C library with the System framework 9438e9fcaa8aSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 943988de56ccSmrg ;; 944088de56ccSmrg esac 944188de56ccSmrg 9442862bcd1aSmrg if test yes = "$droppeddeps"; then 9443862bcd1aSmrg if test yes = "$module"; then 9444e9fcaa8aSmrg echo 9445e9fcaa8aSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 944688de56ccSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9447e9fcaa8aSmrg echo "*** a static module, that should work as long as the dlopening" 9448e9fcaa8aSmrg echo "*** application is linked with the -dlopen flag." 944988de56ccSmrg if test -z "$global_symbol_pipe"; then 9450e9fcaa8aSmrg echo 9451e9fcaa8aSmrg echo "*** However, this would only work if libtool was able to extract symbol" 9452862bcd1aSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9453e9fcaa8aSmrg echo "*** not find such a program. So, this module is probably useless." 9454862bcd1aSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 945588de56ccSmrg fi 9456862bcd1aSmrg if test no = "$build_old_libs"; then 9457862bcd1aSmrg oldlibs=$output_objdir/$libname.$libext 945888de56ccSmrg build_libtool_libs=module 945988de56ccSmrg build_old_libs=yes 946088de56ccSmrg else 946188de56ccSmrg build_libtool_libs=no 946288de56ccSmrg fi 946388de56ccSmrg else 9464e9fcaa8aSmrg echo "*** The inter-library dependencies that have been dropped here will be" 9465e9fcaa8aSmrg echo "*** automatically added whenever a program is linked with this library" 9466e9fcaa8aSmrg echo "*** or is declared to -dlopen it." 946788de56ccSmrg 9468862bcd1aSmrg if test no = "$allow_undefined"; then 9469e9fcaa8aSmrg echo 9470e9fcaa8aSmrg echo "*** Since this library must not contain undefined symbols," 9471e9fcaa8aSmrg echo "*** because either the platform does not support them or" 9472e9fcaa8aSmrg echo "*** it was explicitly requested with -no-undefined," 9473e9fcaa8aSmrg echo "*** libtool will only create a static version of it." 9474862bcd1aSmrg if test no = "$build_old_libs"; then 9475862bcd1aSmrg oldlibs=$output_objdir/$libname.$libext 947688de56ccSmrg build_libtool_libs=module 947788de56ccSmrg build_old_libs=yes 947888de56ccSmrg else 947988de56ccSmrg build_libtool_libs=no 948088de56ccSmrg fi 948188de56ccSmrg fi 948288de56ccSmrg fi 948388de56ccSmrg fi 948488de56ccSmrg # Done checking deplibs! 948588de56ccSmrg deplibs=$newdeplibs 948688de56ccSmrg fi 948788de56ccSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 948888de56ccSmrg case $host in 948988de56ccSmrg *-*-darwin*) 9490e9fcaa8aSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9491e9fcaa8aSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9492e9fcaa8aSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949388de56ccSmrg ;; 949488de56ccSmrg esac 949588de56ccSmrg 949688de56ccSmrg # move library search paths that coincide with paths to not yet 949788de56ccSmrg # installed libraries to the beginning of the library search list 949888de56ccSmrg new_libs= 949988de56ccSmrg for path in $notinst_path; do 950088de56ccSmrg case " $new_libs " in 950188de56ccSmrg *" -L$path/$objdir "*) ;; 950288de56ccSmrg *) 950388de56ccSmrg case " $deplibs " in 950488de56ccSmrg *" -L$path/$objdir "*) 9505e9fcaa8aSmrg func_append new_libs " -L$path/$objdir" ;; 950688de56ccSmrg esac 950788de56ccSmrg ;; 950888de56ccSmrg esac 950988de56ccSmrg done 951088de56ccSmrg for deplib in $deplibs; do 951188de56ccSmrg case $deplib in 951288de56ccSmrg -L*) 951388de56ccSmrg case " $new_libs " in 951488de56ccSmrg *" $deplib "*) ;; 9515e9fcaa8aSmrg *) func_append new_libs " $deplib" ;; 951688de56ccSmrg esac 951788de56ccSmrg ;; 9518e9fcaa8aSmrg *) func_append new_libs " $deplib" ;; 951988de56ccSmrg esac 952088de56ccSmrg done 9521862bcd1aSmrg deplibs=$new_libs 952288de56ccSmrg 952388de56ccSmrg # All the library-specific variables (install_libdir is set above). 952488de56ccSmrg library_names= 952588de56ccSmrg old_library= 952688de56ccSmrg dlname= 952788de56ccSmrg 952888de56ccSmrg # Test again, we may have decided not to build it any more 9529862bcd1aSmrg if test yes = "$build_libtool_libs"; then 9530862bcd1aSmrg # Remove $wl instances when linking with ld. 9531eb411b4bSmrg # FIXME: should test the right _cmds variable. 9532eb411b4bSmrg case $archive_cmds in 9533eb411b4bSmrg *\$LD\ *) wl= ;; 9534eb411b4bSmrg esac 9535862bcd1aSmrg if test yes = "$hardcode_into_libs"; then 953688de56ccSmrg # Hardcode the library paths 953788de56ccSmrg hardcode_libdirs= 953888de56ccSmrg dep_rpath= 9539862bcd1aSmrg rpath=$finalize_rpath 9540862bcd1aSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 954188de56ccSmrg for libdir in $rpath; do 954288de56ccSmrg if test -n "$hardcode_libdir_flag_spec"; then 954388de56ccSmrg if test -n "$hardcode_libdir_separator"; then 9544e9fcaa8aSmrg func_replace_sysroot "$libdir" 9545e9fcaa8aSmrg libdir=$func_replace_sysroot_result 954688de56ccSmrg if test -z "$hardcode_libdirs"; then 9547862bcd1aSmrg hardcode_libdirs=$libdir 954888de56ccSmrg else 954988de56ccSmrg # Just accumulate the unique libdirs. 955088de56ccSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 955188de56ccSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 955288de56ccSmrg ;; 955388de56ccSmrg *) 9554e9fcaa8aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 955588de56ccSmrg ;; 955688de56ccSmrg esac 955788de56ccSmrg fi 955888de56ccSmrg else 955988de56ccSmrg eval flag=\"$hardcode_libdir_flag_spec\" 9560e9fcaa8aSmrg func_append dep_rpath " $flag" 956188de56ccSmrg fi 956288de56ccSmrg elif test -n "$runpath_var"; then 956388de56ccSmrg case "$perm_rpath " in 956488de56ccSmrg *" $libdir "*) ;; 9565eb411b4bSmrg *) func_append perm_rpath " $libdir" ;; 956688de56ccSmrg esac 956788de56ccSmrg fi 956888de56ccSmrg done 956988de56ccSmrg # Substitute the hardcoded libdirs into the rpath. 957088de56ccSmrg if test -n "$hardcode_libdir_separator" && 957188de56ccSmrg test -n "$hardcode_libdirs"; then 9572862bcd1aSmrg libdir=$hardcode_libdirs 9573eb411b4bSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 957488de56ccSmrg fi 957588de56ccSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 957688de56ccSmrg # We should set the runpath_var. 957788de56ccSmrg rpath= 957888de56ccSmrg for dir in $perm_rpath; do 9579e9fcaa8aSmrg func_append rpath "$dir:" 958088de56ccSmrg done 958188de56ccSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 958288de56ccSmrg fi 958388de56ccSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 958488de56ccSmrg fi 95851ab64890Smrg 9586862bcd1aSmrg shlibpath=$finalize_shlibpath 9587862bcd1aSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 958888de56ccSmrg if test -n "$shlibpath"; then 958988de56ccSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 959088de56ccSmrg fi 95911ab64890Smrg 959288de56ccSmrg # Get the real and link names of the library. 959388de56ccSmrg eval shared_ext=\"$shrext_cmds\" 959488de56ccSmrg eval library_names=\"$library_names_spec\" 959588de56ccSmrg set dummy $library_names 959688de56ccSmrg shift 9597862bcd1aSmrg realname=$1 959888de56ccSmrg shift 95991ab64890Smrg 960088de56ccSmrg if test -n "$soname_spec"; then 960188de56ccSmrg eval soname=\"$soname_spec\" 960288de56ccSmrg else 9603862bcd1aSmrg soname=$realname 960488de56ccSmrg fi 960588de56ccSmrg if test -z "$dlname"; then 960688de56ccSmrg dlname=$soname 960788de56ccSmrg fi 96081ab64890Smrg 9609862bcd1aSmrg lib=$output_objdir/$realname 961088de56ccSmrg linknames= 961188de56ccSmrg for link 961288de56ccSmrg do 9613e9fcaa8aSmrg func_append linknames " $link" 961488de56ccSmrg done 96151ab64890Smrg 961688de56ccSmrg # Use standard objects if they are pic 9617e9fcaa8aSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 961888de56ccSmrg test "X$libobjs" = "X " && libobjs= 96191ab64890Smrg 962088de56ccSmrg delfiles= 962188de56ccSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 962288de56ccSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9623862bcd1aSmrg export_symbols=$output_objdir/$libname.uexp 9624e9fcaa8aSmrg func_append delfiles " $export_symbols" 962588de56ccSmrg fi 96261ab64890Smrg 962788de56ccSmrg orig_export_symbols= 962888de56ccSmrg case $host_os in 962988de56ccSmrg cygwin* | mingw* | cegcc*) 963088de56ccSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 963188de56ccSmrg # exporting using user supplied symfile 9632862bcd1aSmrg func_dll_def_p "$export_symbols" || { 963388de56ccSmrg # and it's NOT already a .def file. Must figure out 963488de56ccSmrg # which of the given symbols are data symbols and tag 963588de56ccSmrg # them as such. So, trigger use of export_symbols_cmds. 963688de56ccSmrg # export_symbols gets reassigned inside the "prepare 963788de56ccSmrg # the list of exported symbols" if statement, so the 963888de56ccSmrg # include_expsyms logic still works. 9639862bcd1aSmrg orig_export_symbols=$export_symbols 964088de56ccSmrg export_symbols= 964188de56ccSmrg always_export_symbols=yes 9642862bcd1aSmrg } 964388de56ccSmrg fi 964488de56ccSmrg ;; 964588de56ccSmrg esac 96461ab64890Smrg 964788de56ccSmrg # Prepare the list of exported symbols 964888de56ccSmrg if test -z "$export_symbols"; then 9649862bcd1aSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9650862bcd1aSmrg func_verbose "generating symbol list for '$libname.la'" 9651862bcd1aSmrg export_symbols=$output_objdir/$libname.exp 965288de56ccSmrg $opt_dry_run || $RM $export_symbols 965388de56ccSmrg cmds=$export_symbols_cmds 9654862bcd1aSmrg save_ifs=$IFS; IFS='~' 9655e9fcaa8aSmrg for cmd1 in $cmds; do 9656862bcd1aSmrg IFS=$save_ifs 9657e9fcaa8aSmrg # Take the normal branch if the nm_file_list_spec branch 9658e9fcaa8aSmrg # doesn't work or if tool conversion is not needed. 9659e9fcaa8aSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9660e9fcaa8aSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9661e9fcaa8aSmrg try_normal_branch=yes 9662e9fcaa8aSmrg eval cmd=\"$cmd1\" 9663e9fcaa8aSmrg func_len " $cmd" 9664e9fcaa8aSmrg len=$func_len_result 9665e9fcaa8aSmrg ;; 9666e9fcaa8aSmrg *) 9667e9fcaa8aSmrg try_normal_branch=no 9668e9fcaa8aSmrg ;; 9669e9fcaa8aSmrg esac 9670862bcd1aSmrg if test yes = "$try_normal_branch" \ 9671e9fcaa8aSmrg && { test "$len" -lt "$max_cmd_len" \ 9672e9fcaa8aSmrg || test "$max_cmd_len" -le -1; } 9673e9fcaa8aSmrg then 9674e9fcaa8aSmrg func_show_eval "$cmd" 'exit $?' 9675e9fcaa8aSmrg skipped_export=false 9676e9fcaa8aSmrg elif test -n "$nm_file_list_spec"; then 9677e9fcaa8aSmrg func_basename "$output" 9678e9fcaa8aSmrg output_la=$func_basename_result 9679e9fcaa8aSmrg save_libobjs=$libobjs 9680e9fcaa8aSmrg save_output=$output 9681862bcd1aSmrg output=$output_objdir/$output_la.nm 9682e9fcaa8aSmrg func_to_tool_file "$output" 9683e9fcaa8aSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9684e9fcaa8aSmrg func_append delfiles " $output" 9685e9fcaa8aSmrg func_verbose "creating $NM input file list: $output" 9686e9fcaa8aSmrg for obj in $save_libobjs; do 9687e9fcaa8aSmrg func_to_tool_file "$obj" 9688e9fcaa8aSmrg $ECHO "$func_to_tool_file_result" 9689e9fcaa8aSmrg done > "$output" 9690e9fcaa8aSmrg eval cmd=\"$cmd1\" 969188de56ccSmrg func_show_eval "$cmd" 'exit $?' 9692e9fcaa8aSmrg output=$save_output 9693e9fcaa8aSmrg libobjs=$save_libobjs 969488de56ccSmrg skipped_export=false 969588de56ccSmrg else 969688de56ccSmrg # The command line is too long to execute in one step. 969788de56ccSmrg func_verbose "using reloadable object file for export list..." 969888de56ccSmrg skipped_export=: 969988de56ccSmrg # Break out early, otherwise skipped_export may be 970088de56ccSmrg # set to false by a later but shorter cmd. 970188de56ccSmrg break 970288de56ccSmrg fi 970388de56ccSmrg done 9704862bcd1aSmrg IFS=$save_ifs 9705862bcd1aSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 970688de56ccSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 970788de56ccSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 970888de56ccSmrg fi 970988de56ccSmrg fi 97101ab64890Smrg fi 97111ab64890Smrg 971288de56ccSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9713862bcd1aSmrg tmp_export_symbols=$export_symbols 9714862bcd1aSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9715e9fcaa8aSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 971688de56ccSmrg fi 97171ab64890Smrg 9718862bcd1aSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 971988de56ccSmrg # The given exports_symbols file has to be filtered, so filter it. 9720862bcd1aSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 972188de56ccSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9722862bcd1aSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 972388de56ccSmrg # though. Also, the filter scales superlinearly with the number of 972488de56ccSmrg # global variables. join(1) would be nice here, but unfortunately 972588de56ccSmrg # isn't a blessed tool. 972688de56ccSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9727e9fcaa8aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 972888de56ccSmrg export_symbols=$output_objdir/$libname.def 972988de56ccSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 973088de56ccSmrg fi 97311ab64890Smrg 973288de56ccSmrg tmp_deplibs= 973388de56ccSmrg for test_deplib in $deplibs; do 973488de56ccSmrg case " $convenience " in 973588de56ccSmrg *" $test_deplib "*) ;; 973688de56ccSmrg *) 9737e9fcaa8aSmrg func_append tmp_deplibs " $test_deplib" 973888de56ccSmrg ;; 973988de56ccSmrg esac 974088de56ccSmrg done 9741862bcd1aSmrg deplibs=$tmp_deplibs 97421ab64890Smrg 974388de56ccSmrg if test -n "$convenience"; then 974488de56ccSmrg if test -n "$whole_archive_flag_spec" && 9745862bcd1aSmrg test yes = "$compiler_needs_object" && 974688de56ccSmrg test -z "$libobjs"; then 974788de56ccSmrg # extract the archives, so we have objects to list. 974888de56ccSmrg # TODO: could optimize this to just extract one archive. 974988de56ccSmrg whole_archive_flag_spec= 975088de56ccSmrg fi 975188de56ccSmrg if test -n "$whole_archive_flag_spec"; then 975288de56ccSmrg save_libobjs=$libobjs 975388de56ccSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 975488de56ccSmrg test "X$libobjs" = "X " && libobjs= 975588de56ccSmrg else 9756862bcd1aSmrg gentop=$output_objdir/${outputname}x 9757e9fcaa8aSmrg func_append generated " $gentop" 97581ab64890Smrg 975988de56ccSmrg func_extract_archives $gentop $convenience 9760e9fcaa8aSmrg func_append libobjs " $func_extract_archives_result" 976188de56ccSmrg test "X$libobjs" = "X " && libobjs= 976288de56ccSmrg fi 9763b4ee4795Smrg fi 97641ab64890Smrg 9765862bcd1aSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 976688de56ccSmrg eval flag=\"$thread_safe_flag_spec\" 9767e9fcaa8aSmrg func_append linker_flags " $flag" 9768b4ee4795Smrg fi 97692e9c7c8cSmrg 977088de56ccSmrg # Make a backup of the uninstalled library when relinking 9771862bcd1aSmrg if test relink = "$opt_mode"; then 977288de56ccSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 977388de56ccSmrg fi 97741ab64890Smrg 977588de56ccSmrg # Do each of the archive commands. 9776862bcd1aSmrg if test yes = "$module" && test -n "$module_cmds"; then 977788de56ccSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 977888de56ccSmrg eval test_cmds=\"$module_expsym_cmds\" 977988de56ccSmrg cmds=$module_expsym_cmds 978088de56ccSmrg else 978188de56ccSmrg eval test_cmds=\"$module_cmds\" 978288de56ccSmrg cmds=$module_cmds 978388de56ccSmrg fi 9784b4ee4795Smrg else 978588de56ccSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 978688de56ccSmrg eval test_cmds=\"$archive_expsym_cmds\" 978788de56ccSmrg cmds=$archive_expsym_cmds 978888de56ccSmrg else 978988de56ccSmrg eval test_cmds=\"$archive_cmds\" 979088de56ccSmrg cmds=$archive_cmds 979188de56ccSmrg fi 9792b4ee4795Smrg fi 97931ab64890Smrg 9794862bcd1aSmrg if test : != "$skipped_export" && 979588de56ccSmrg func_len " $test_cmds" && 979688de56ccSmrg len=$func_len_result && 979788de56ccSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 979888de56ccSmrg : 979988de56ccSmrg else 980088de56ccSmrg # The command line is too long to link in one step, link piecewise 980188de56ccSmrg # or, if using GNU ld and skipped_export is not :, use a linker 980288de56ccSmrg # script. 98031ab64890Smrg 980488de56ccSmrg # Save the value of $output and $libobjs because we want to 980588de56ccSmrg # use them later. If we have whole_archive_flag_spec, we 980688de56ccSmrg # want to use save_libobjs as it was before 980788de56ccSmrg # whole_archive_flag_spec was expanded, because we can't 980888de56ccSmrg # assume the linker understands whole_archive_flag_spec. 980988de56ccSmrg # This may have to be revisited, in case too many 981088de56ccSmrg # convenience libraries get linked in and end up exceeding 981188de56ccSmrg # the spec. 981288de56ccSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 981388de56ccSmrg save_libobjs=$libobjs 981488de56ccSmrg fi 981588de56ccSmrg save_output=$output 9816e9fcaa8aSmrg func_basename "$output" 9817e9fcaa8aSmrg output_la=$func_basename_result 98181ab64890Smrg 981988de56ccSmrg # Clear the reloadable object creation command queue and 982088de56ccSmrg # initialize k to one. 982188de56ccSmrg test_cmds= 982288de56ccSmrg concat_cmds= 982388de56ccSmrg objlist= 982488de56ccSmrg last_robj= 982588de56ccSmrg k=1 982688de56ccSmrg 9827862bcd1aSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9828862bcd1aSmrg output=$output_objdir/$output_la.lnkscript 982988de56ccSmrg func_verbose "creating GNU ld script: $output" 9830e9fcaa8aSmrg echo 'INPUT (' > $output 983188de56ccSmrg for obj in $save_libobjs 9832b4ee4795Smrg do 9833e9fcaa8aSmrg func_to_tool_file "$obj" 9834e9fcaa8aSmrg $ECHO "$func_to_tool_file_result" >> $output 983588de56ccSmrg done 9836e9fcaa8aSmrg echo ')' >> $output 9837e9fcaa8aSmrg func_append delfiles " $output" 9838e9fcaa8aSmrg func_to_tool_file "$output" 9839e9fcaa8aSmrg output=$func_to_tool_file_result 9840862bcd1aSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9841862bcd1aSmrg output=$output_objdir/$output_la.lnk 984288de56ccSmrg func_verbose "creating linker input file list: $output" 984388de56ccSmrg : > $output 984488de56ccSmrg set x $save_libobjs 984588de56ccSmrg shift 984688de56ccSmrg firstobj= 9847862bcd1aSmrg if test yes = "$compiler_needs_object"; then 984888de56ccSmrg firstobj="$1 " 984988de56ccSmrg shift 985088de56ccSmrg fi 985188de56ccSmrg for obj 985288de56ccSmrg do 9853e9fcaa8aSmrg func_to_tool_file "$obj" 9854e9fcaa8aSmrg $ECHO "$func_to_tool_file_result" >> $output 985588de56ccSmrg done 9856e9fcaa8aSmrg func_append delfiles " $output" 9857e9fcaa8aSmrg func_to_tool_file "$output" 9858e9fcaa8aSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 985988de56ccSmrg else 986088de56ccSmrg if test -n "$save_libobjs"; then 986188de56ccSmrg func_verbose "creating reloadable object files..." 9862862bcd1aSmrg output=$output_objdir/$output_la-$k.$objext 986388de56ccSmrg eval test_cmds=\"$reload_cmds\" 986488de56ccSmrg func_len " $test_cmds" 986588de56ccSmrg len0=$func_len_result 986688de56ccSmrg len=$len0 986788de56ccSmrg 986888de56ccSmrg # Loop over the list of objects to be linked. 986988de56ccSmrg for obj in $save_libobjs 987088de56ccSmrg do 987188de56ccSmrg func_len " $obj" 987288de56ccSmrg func_arith $len + $func_len_result 987388de56ccSmrg len=$func_arith_result 9874862bcd1aSmrg if test -z "$objlist" || 987588de56ccSmrg test "$len" -lt "$max_cmd_len"; then 987688de56ccSmrg func_append objlist " $obj" 987788de56ccSmrg else 987888de56ccSmrg # The command $test_cmds is almost too long, add a 987988de56ccSmrg # command to the queue. 9880862bcd1aSmrg if test 1 -eq "$k"; then 988188de56ccSmrg # The first file doesn't have a previous command to add. 9882e9fcaa8aSmrg reload_objs=$objlist 9883e9fcaa8aSmrg eval concat_cmds=\"$reload_cmds\" 988488de56ccSmrg else 988588de56ccSmrg # All subsequent reloadable object files will link in 988688de56ccSmrg # the last one created. 9887e9fcaa8aSmrg reload_objs="$objlist $last_robj" 9888e9fcaa8aSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 988988de56ccSmrg fi 9890862bcd1aSmrg last_robj=$output_objdir/$output_la-$k.$objext 989188de56ccSmrg func_arith $k + 1 989288de56ccSmrg k=$func_arith_result 9893862bcd1aSmrg output=$output_objdir/$output_la-$k.$objext 9894e9fcaa8aSmrg objlist=" $obj" 989588de56ccSmrg func_len " $last_robj" 989688de56ccSmrg func_arith $len0 + $func_len_result 989788de56ccSmrg len=$func_arith_result 989888de56ccSmrg fi 989988de56ccSmrg done 990088de56ccSmrg # Handle the remaining objects by creating one last 990188de56ccSmrg # reloadable object file. All subsequent reloadable object 990288de56ccSmrg # files will link in the last one created. 990388de56ccSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9904e9fcaa8aSmrg reload_objs="$objlist $last_robj" 9905862bcd1aSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 990688de56ccSmrg if test -n "$last_robj"; then 9907862bcd1aSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 990888de56ccSmrg fi 9909e9fcaa8aSmrg func_append delfiles " $output" 99101ab64890Smrg 991188de56ccSmrg else 991288de56ccSmrg output= 991388de56ccSmrg fi 99141ab64890Smrg 9915862bcd1aSmrg ${skipped_export-false} && { 9916862bcd1aSmrg func_verbose "generating symbol list for '$libname.la'" 9917862bcd1aSmrg export_symbols=$output_objdir/$libname.exp 991888de56ccSmrg $opt_dry_run || $RM $export_symbols 991988de56ccSmrg libobjs=$output 992088de56ccSmrg # Append the command to create the export file. 992188de56ccSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 992288de56ccSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 992388de56ccSmrg if test -n "$last_robj"; then 992488de56ccSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 992588de56ccSmrg fi 9926862bcd1aSmrg } 99271ab64890Smrg 992888de56ccSmrg test -n "$save_libobjs" && 992988de56ccSmrg func_verbose "creating a temporary reloadable object file: $output" 99301ab64890Smrg 993188de56ccSmrg # Loop through the commands generated above and execute them. 9932862bcd1aSmrg save_ifs=$IFS; IFS='~' 993388de56ccSmrg for cmd in $concat_cmds; do 9934862bcd1aSmrg IFS=$save_ifs 9935862bcd1aSmrg $opt_quiet || { 993688de56ccSmrg func_quote_for_expand "$cmd" 993788de56ccSmrg eval "func_echo $func_quote_for_expand_result" 993888de56ccSmrg } 993988de56ccSmrg $opt_dry_run || eval "$cmd" || { 994088de56ccSmrg lt_exit=$? 994188de56ccSmrg 994288de56ccSmrg # Restore the uninstalled library and exit 9943862bcd1aSmrg if test relink = "$opt_mode"; then 994488de56ccSmrg ( cd "$output_objdir" && \ 994588de56ccSmrg $RM "${realname}T" && \ 994688de56ccSmrg $MV "${realname}U" "$realname" ) 994788de56ccSmrg fi 99481ab64890Smrg 994988de56ccSmrg exit $lt_exit 995088de56ccSmrg } 995188de56ccSmrg done 9952862bcd1aSmrg IFS=$save_ifs 9953b4ee4795Smrg 995488de56ccSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 995588de56ccSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 995688de56ccSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 99571ab64890Smrg fi 99581ab64890Smrg fi 99591ab64890Smrg 9960862bcd1aSmrg ${skipped_export-false} && { 996188de56ccSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9962862bcd1aSmrg tmp_export_symbols=$export_symbols 9963862bcd1aSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9964e9fcaa8aSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 996588de56ccSmrg fi 99662e9c7c8cSmrg 996788de56ccSmrg if test -n "$orig_export_symbols"; then 996888de56ccSmrg # The given exports_symbols file has to be filtered, so filter it. 9969862bcd1aSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 997088de56ccSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9971862bcd1aSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 997288de56ccSmrg # though. Also, the filter scales superlinearly with the number of 997388de56ccSmrg # global variables. join(1) would be nice here, but unfortunately 997488de56ccSmrg # isn't a blessed tool. 997588de56ccSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9976e9fcaa8aSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 997788de56ccSmrg export_symbols=$output_objdir/$libname.def 997888de56ccSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 997988de56ccSmrg fi 9980862bcd1aSmrg } 99811ab64890Smrg 998288de56ccSmrg libobjs=$output 998388de56ccSmrg # Restore the value of output. 998488de56ccSmrg output=$save_output 99851ab64890Smrg 998688de56ccSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 998788de56ccSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 998888de56ccSmrg test "X$libobjs" = "X " && libobjs= 998988de56ccSmrg fi 999088de56ccSmrg # Expand the library linking commands again to reset the 999188de56ccSmrg # value of $libobjs for piecewise linking. 99921ab64890Smrg 999388de56ccSmrg # Do each of the archive commands. 9994862bcd1aSmrg if test yes = "$module" && test -n "$module_cmds"; then 999588de56ccSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 999688de56ccSmrg cmds=$module_expsym_cmds 999788de56ccSmrg else 999888de56ccSmrg cmds=$module_cmds 9999b4ee4795Smrg fi 10000b4ee4795Smrg else 1000188de56ccSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1000288de56ccSmrg cmds=$archive_expsym_cmds 1000388de56ccSmrg else 1000488de56ccSmrg cmds=$archive_cmds 1000588de56ccSmrg fi 10006b4ee4795Smrg fi 1000788de56ccSmrg fi 100081ab64890Smrg 1000988de56ccSmrg if test -n "$delfiles"; then 1001088de56ccSmrg # Append the command to remove temporary files to $cmds. 1001188de56ccSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 1001288de56ccSmrg fi 100131ab64890Smrg 1001488de56ccSmrg # Add any objects from preloaded convenience libraries 1001588de56ccSmrg if test -n "$dlprefiles"; then 10016862bcd1aSmrg gentop=$output_objdir/${outputname}x 10017e9fcaa8aSmrg func_append generated " $gentop" 100181ab64890Smrg 1001988de56ccSmrg func_extract_archives $gentop $dlprefiles 10020e9fcaa8aSmrg func_append libobjs " $func_extract_archives_result" 1002188de56ccSmrg test "X$libobjs" = "X " && libobjs= 1002288de56ccSmrg fi 100231ab64890Smrg 10024862bcd1aSmrg save_ifs=$IFS; IFS='~' 1002588de56ccSmrg for cmd in $cmds; do 10026862bcd1aSmrg IFS=$sp$nl 1002788de56ccSmrg eval cmd=\"$cmd\" 10028862bcd1aSmrg IFS=$save_ifs 10029862bcd1aSmrg $opt_quiet || { 1003088de56ccSmrg func_quote_for_expand "$cmd" 1003188de56ccSmrg eval "func_echo $func_quote_for_expand_result" 1003288de56ccSmrg } 1003388de56ccSmrg $opt_dry_run || eval "$cmd" || { 1003488de56ccSmrg lt_exit=$? 100352e9c7c8cSmrg 1003688de56ccSmrg # Restore the uninstalled library and exit 10037862bcd1aSmrg if test relink = "$opt_mode"; then 1003888de56ccSmrg ( cd "$output_objdir" && \ 1003988de56ccSmrg $RM "${realname}T" && \ 1004088de56ccSmrg $MV "${realname}U" "$realname" ) 1004188de56ccSmrg fi 100422e9c7c8cSmrg 1004388de56ccSmrg exit $lt_exit 1004488de56ccSmrg } 1004588de56ccSmrg done 10046862bcd1aSmrg IFS=$save_ifs 100472e9c7c8cSmrg 1004888de56ccSmrg # Restore the uninstalled library and exit 10049862bcd1aSmrg if test relink = "$opt_mode"; then 1005088de56ccSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 100512e9c7c8cSmrg 1005288de56ccSmrg if test -n "$convenience"; then 1005388de56ccSmrg if test -z "$whole_archive_flag_spec"; then 1005488de56ccSmrg func_show_eval '${RM}r "$gentop"' 1005588de56ccSmrg fi 1005688de56ccSmrg fi 100572e9c7c8cSmrg 1005888de56ccSmrg exit $EXIT_SUCCESS 1005988de56ccSmrg fi 1006088de56ccSmrg 1006188de56ccSmrg # Create links to the real library. 1006288de56ccSmrg for linkname in $linknames; do 1006388de56ccSmrg if test "$realname" != "$linkname"; then 1006488de56ccSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065b4ee4795Smrg fi 10066b4ee4795Smrg done 100672e9c7c8cSmrg 1006888de56ccSmrg # If -module or -export-dynamic was specified, set the dlname. 10069862bcd1aSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 1007088de56ccSmrg # On all known operating systems, these are identical. 10071862bcd1aSmrg dlname=$soname 1007288de56ccSmrg fi 1007388de56ccSmrg fi 100741ab64890Smrg ;; 100751ab64890Smrg 1007688de56ccSmrg obj) 10077862bcd1aSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10078862bcd1aSmrg func_warning "'-dlopen' is ignored for objects" 1007988de56ccSmrg fi 10080b4ee4795Smrg 1008188de56ccSmrg case " $deplibs" in 1008288de56ccSmrg *\ -l* | *\ -L*) 10083862bcd1aSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 100842e9c7c8cSmrg esac 100851ab64890Smrg 1008688de56ccSmrg test -n "$rpath" && \ 10087862bcd1aSmrg func_warning "'-rpath' is ignored for objects" 1008888de56ccSmrg 1008988de56ccSmrg test -n "$xrpath" && \ 10090862bcd1aSmrg func_warning "'-R' is ignored for objects" 100911ab64890Smrg 1009288de56ccSmrg test -n "$vinfo" && \ 10093862bcd1aSmrg func_warning "'-version-info' is ignored for objects" 100942e9c7c8cSmrg 1009588de56ccSmrg test -n "$release" && \ 10096862bcd1aSmrg func_warning "'-release' is ignored for objects" 1009788de56ccSmrg 1009888de56ccSmrg case $output in 1009988de56ccSmrg *.lo) 1010088de56ccSmrg test -n "$objs$old_deplibs" && \ 10101862bcd1aSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 1010288de56ccSmrg 1010388de56ccSmrg libobj=$output 1010488de56ccSmrg func_lo2o "$libobj" 1010588de56ccSmrg obj=$func_lo2o_result 10106b4ee4795Smrg ;; 10107b4ee4795Smrg *) 1010888de56ccSmrg libobj= 10109862bcd1aSmrg obj=$output 101101ab64890Smrg ;; 101112e9c7c8cSmrg esac 101121ab64890Smrg 1011388de56ccSmrg # Delete the old objects. 1011488de56ccSmrg $opt_dry_run || $RM $obj $libobj 101151ab64890Smrg 1011688de56ccSmrg # Objects from convenience libraries. This assumes 1011788de56ccSmrg # single-version convenience libraries. Whenever we create 1011888de56ccSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 1011988de56ccSmrg # the extraction. 1012088de56ccSmrg reload_conv_objs= 1012188de56ccSmrg gentop= 10122862bcd1aSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 10123862bcd1aSmrg # whole_archive_flag_spec and hope we can get by with turning comma 10124862bcd1aSmrg # into space. 10125862bcd1aSmrg case $reload_cmds in 10126862bcd1aSmrg *\$LD[\ \$]*) wl= ;; 10127862bcd1aSmrg esac 1012888de56ccSmrg if test -n "$convenience"; then 1012988de56ccSmrg if test -n "$whole_archive_flag_spec"; then 1013088de56ccSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10131862bcd1aSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10132862bcd1aSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 1013388de56ccSmrg else 10134862bcd1aSmrg gentop=$output_objdir/${obj}x 10135e9fcaa8aSmrg func_append generated " $gentop" 10136b4ee4795Smrg 1013788de56ccSmrg func_extract_archives $gentop $convenience 1013888de56ccSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 1013988de56ccSmrg fi 10140b4ee4795Smrg fi 10141b4ee4795Smrg 10142e9fcaa8aSmrg # If we're not building shared, we need to use non_pic_objs 10143862bcd1aSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144e9fcaa8aSmrg 1014588de56ccSmrg # Create the old-style object. 10146862bcd1aSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147b4ee4795Smrg 10148862bcd1aSmrg output=$obj 1014988de56ccSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10150b4ee4795Smrg 1015188de56ccSmrg # Exit if we aren't doing a library object file. 1015288de56ccSmrg if test -z "$libobj"; then 1015388de56ccSmrg if test -n "$gentop"; then 1015488de56ccSmrg func_show_eval '${RM}r "$gentop"' 1015588de56ccSmrg fi 1015688de56ccSmrg 1015788de56ccSmrg exit $EXIT_SUCCESS 10158b4ee4795Smrg fi 1015988de56ccSmrg 10160862bcd1aSmrg test yes = "$build_libtool_libs" || { 1016188de56ccSmrg if test -n "$gentop"; then 1016288de56ccSmrg func_show_eval '${RM}r "$gentop"' 1016388de56ccSmrg fi 1016488de56ccSmrg 1016588de56ccSmrg # Create an invalid libtool object if no PIC, so that we don't 1016688de56ccSmrg # accidentally link it into a program. 1016788de56ccSmrg # $show "echo timestamp > $libobj" 1016888de56ccSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 1016988de56ccSmrg exit $EXIT_SUCCESS 10170862bcd1aSmrg } 1017188de56ccSmrg 10172862bcd1aSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 1017388de56ccSmrg # Only do commands if we really have different PIC objects. 1017488de56ccSmrg reload_objs="$libobjs $reload_conv_objs" 10175862bcd1aSmrg output=$libobj 1017688de56ccSmrg func_execute_cmds "$reload_cmds" 'exit $?' 1017788de56ccSmrg fi 1017888de56ccSmrg 1017988de56ccSmrg if test -n "$gentop"; then 1018088de56ccSmrg func_show_eval '${RM}r "$gentop"' 1018188de56ccSmrg fi 1018288de56ccSmrg 1018388de56ccSmrg exit $EXIT_SUCCESS 10184b4ee4795Smrg ;; 101851ab64890Smrg 1018688de56ccSmrg prog) 1018788de56ccSmrg case $host in 1018888de56ccSmrg *cygwin*) func_stripname '' '.exe' "$output" 1018988de56ccSmrg output=$func_stripname_result.exe;; 1019088de56ccSmrg esac 1019188de56ccSmrg test -n "$vinfo" && \ 10192862bcd1aSmrg func_warning "'-version-info' is ignored for programs" 101931ab64890Smrg 1019488de56ccSmrg test -n "$release" && \ 10195862bcd1aSmrg func_warning "'-release' is ignored for programs" 101961ab64890Smrg 10197862bcd1aSmrg $preload \ 10198862bcd1aSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10199862bcd1aSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 1020088de56ccSmrg 1020188de56ccSmrg case $host in 1020288de56ccSmrg *-*-rhapsody* | *-*-darwin1.[012]) 1020388de56ccSmrg # On Rhapsody replace the C library is the System framework 10204e9fcaa8aSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10205e9fcaa8aSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206b4ee4795Smrg ;; 1020788de56ccSmrg esac 10208b4ee4795Smrg 1020988de56ccSmrg case $host in 1021088de56ccSmrg *-*-darwin*) 1021188de56ccSmrg # Don't allow lazy linking, it breaks C++ global constructors 1021288de56ccSmrg # But is supposedly fixed on 10.4 or later (yay!). 10213862bcd1aSmrg if test CXX = "$tagname"; then 1021488de56ccSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 1021588de56ccSmrg 10.[0123]) 10216862bcd1aSmrg func_append compile_command " $wl-bind_at_load" 10217862bcd1aSmrg func_append finalize_command " $wl-bind_at_load" 1021888de56ccSmrg ;; 1021988de56ccSmrg esac 10220b4ee4795Smrg fi 1022188de56ccSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10222e9fcaa8aSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10223e9fcaa8aSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1022488de56ccSmrg ;; 1022588de56ccSmrg esac 10226b4ee4795Smrg 10227b4ee4795Smrg 1022888de56ccSmrg # move library search paths that coincide with paths to not yet 1022988de56ccSmrg # installed libraries to the beginning of the library search list 1023088de56ccSmrg new_libs= 1023188de56ccSmrg for path in $notinst_path; do 1023288de56ccSmrg case " $new_libs " in 1023388de56ccSmrg *" -L$path/$objdir "*) ;; 1023488de56ccSmrg *) 1023588de56ccSmrg case " $compile_deplibs " in 1023688de56ccSmrg *" -L$path/$objdir "*) 10237e9fcaa8aSmrg func_append new_libs " -L$path/$objdir" ;; 102382e9c7c8cSmrg esac 1023988de56ccSmrg ;; 1024088de56ccSmrg esac 1024188de56ccSmrg done 1024288de56ccSmrg for deplib in $compile_deplibs; do 1024388de56ccSmrg case $deplib in 1024488de56ccSmrg -L*) 1024588de56ccSmrg case " $new_libs " in 1024688de56ccSmrg *" $deplib "*) ;; 10247e9fcaa8aSmrg *) func_append new_libs " $deplib" ;; 102482e9c7c8cSmrg esac 1024988de56ccSmrg ;; 10250e9fcaa8aSmrg *) func_append new_libs " $deplib" ;; 1025188de56ccSmrg esac 1025288de56ccSmrg done 10253862bcd1aSmrg compile_deplibs=$new_libs 102541ab64890Smrg 10255b4ee4795Smrg 10256e9fcaa8aSmrg func_append compile_command " $compile_deplibs" 10257e9fcaa8aSmrg func_append finalize_command " $finalize_deplibs" 10258b4ee4795Smrg 1025988de56ccSmrg if test -n "$rpath$xrpath"; then 1026088de56ccSmrg # If the user specified any rpath flags, then add them. 1026188de56ccSmrg for libdir in $rpath $xrpath; do 1026288de56ccSmrg # This is the magic to use -rpath. 1026388de56ccSmrg case "$finalize_rpath " in 1026488de56ccSmrg *" $libdir "*) ;; 10265e9fcaa8aSmrg *) func_append finalize_rpath " $libdir" ;; 1026688de56ccSmrg esac 1026788de56ccSmrg done 1026888de56ccSmrg fi 10269b4ee4795Smrg 1027088de56ccSmrg # Now hardcode the library paths 1027188de56ccSmrg rpath= 1027288de56ccSmrg hardcode_libdirs= 1027388de56ccSmrg for libdir in $compile_rpath $finalize_rpath; do 1027488de56ccSmrg if test -n "$hardcode_libdir_flag_spec"; then 1027588de56ccSmrg if test -n "$hardcode_libdir_separator"; then 1027688de56ccSmrg if test -z "$hardcode_libdirs"; then 10277862bcd1aSmrg hardcode_libdirs=$libdir 1027888de56ccSmrg else 1027988de56ccSmrg # Just accumulate the unique libdirs. 1028088de56ccSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1028188de56ccSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1028288de56ccSmrg ;; 1028388de56ccSmrg *) 10284e9fcaa8aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1028588de56ccSmrg ;; 1028688de56ccSmrg esac 1028788de56ccSmrg fi 10288b4ee4795Smrg else 1028988de56ccSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10290e9fcaa8aSmrg func_append rpath " $flag" 10291b4ee4795Smrg fi 1029288de56ccSmrg elif test -n "$runpath_var"; then 1029388de56ccSmrg case "$perm_rpath " in 1029488de56ccSmrg *" $libdir "*) ;; 10295e9fcaa8aSmrg *) func_append perm_rpath " $libdir" ;; 1029688de56ccSmrg esac 1029788de56ccSmrg fi 1029888de56ccSmrg case $host in 1029988de56ccSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10300862bcd1aSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 1030188de56ccSmrg case :$dllsearchpath: in 1030288de56ccSmrg *":$libdir:"*) ;; 1030388de56ccSmrg ::) dllsearchpath=$libdir;; 10304e9fcaa8aSmrg *) func_append dllsearchpath ":$libdir";; 1030588de56ccSmrg esac 1030688de56ccSmrg case :$dllsearchpath: in 1030788de56ccSmrg *":$testbindir:"*) ;; 1030888de56ccSmrg ::) dllsearchpath=$testbindir;; 10309e9fcaa8aSmrg *) func_append dllsearchpath ":$testbindir";; 1031088de56ccSmrg esac 1031188de56ccSmrg ;; 1031288de56ccSmrg esac 1031388de56ccSmrg done 1031488de56ccSmrg # Substitute the hardcoded libdirs into the rpath. 1031588de56ccSmrg if test -n "$hardcode_libdir_separator" && 1031688de56ccSmrg test -n "$hardcode_libdirs"; then 10317862bcd1aSmrg libdir=$hardcode_libdirs 1031888de56ccSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 1031988de56ccSmrg fi 10320862bcd1aSmrg compile_rpath=$rpath 10321b4ee4795Smrg 1032288de56ccSmrg rpath= 1032388de56ccSmrg hardcode_libdirs= 1032488de56ccSmrg for libdir in $finalize_rpath; do 1032588de56ccSmrg if test -n "$hardcode_libdir_flag_spec"; then 1032688de56ccSmrg if test -n "$hardcode_libdir_separator"; then 1032788de56ccSmrg if test -z "$hardcode_libdirs"; then 10328862bcd1aSmrg hardcode_libdirs=$libdir 1032988de56ccSmrg else 1033088de56ccSmrg # Just accumulate the unique libdirs. 1033188de56ccSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1033288de56ccSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1033388de56ccSmrg ;; 1033488de56ccSmrg *) 10335e9fcaa8aSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1033688de56ccSmrg ;; 1033788de56ccSmrg esac 1033888de56ccSmrg fi 103391ab64890Smrg else 1034088de56ccSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10341e9fcaa8aSmrg func_append rpath " $flag" 103421ab64890Smrg fi 1034388de56ccSmrg elif test -n "$runpath_var"; then 1034488de56ccSmrg case "$finalize_perm_rpath " in 1034588de56ccSmrg *" $libdir "*) ;; 10346e9fcaa8aSmrg *) func_append finalize_perm_rpath " $libdir" ;; 1034788de56ccSmrg esac 103481ab64890Smrg fi 1034988de56ccSmrg done 1035088de56ccSmrg # Substitute the hardcoded libdirs into the rpath. 1035188de56ccSmrg if test -n "$hardcode_libdir_separator" && 1035288de56ccSmrg test -n "$hardcode_libdirs"; then 10353862bcd1aSmrg libdir=$hardcode_libdirs 1035488de56ccSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 1035588de56ccSmrg fi 10356862bcd1aSmrg finalize_rpath=$rpath 103571ab64890Smrg 10358862bcd1aSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 1035988de56ccSmrg # Transform all the library objects into standard objects. 10360e9fcaa8aSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10361e9fcaa8aSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036288de56ccSmrg fi 103631ab64890Smrg 10364862bcd1aSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 103651ab64890Smrg 1036688de56ccSmrg # template prelinking step 1036788de56ccSmrg if test -n "$prelink_cmds"; then 1036888de56ccSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 1036988de56ccSmrg fi 103701ab64890Smrg 10371862bcd1aSmrg wrappers_required=: 1037288de56ccSmrg case $host in 10373e9fcaa8aSmrg *cegcc* | *mingw32ce*) 10374e9fcaa8aSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10375862bcd1aSmrg wrappers_required=false 10376e9fcaa8aSmrg ;; 1037788de56ccSmrg *cygwin* | *mingw* ) 10378862bcd1aSmrg test yes = "$build_libtool_libs" || wrappers_required=false 1037988de56ccSmrg ;; 1038088de56ccSmrg *) 10381862bcd1aSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10382862bcd1aSmrg wrappers_required=false 1038388de56ccSmrg fi 1038488de56ccSmrg ;; 1038588de56ccSmrg esac 10386862bcd1aSmrg $wrappers_required || { 1038788de56ccSmrg # Replace the output file specification. 10388e9fcaa8aSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10389862bcd1aSmrg link_command=$compile_command$compile_rpath 103901ab64890Smrg 1039188de56ccSmrg # We have no uninstalled library dependencies, so finalize right now. 1039288de56ccSmrg exit_status=0 1039388de56ccSmrg func_show_eval "$link_command" 'exit_status=$?' 103941ab64890Smrg 10395e9fcaa8aSmrg if test -n "$postlink_cmds"; then 10396e9fcaa8aSmrg func_to_tool_file "$output" 10397e9fcaa8aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10398e9fcaa8aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10399e9fcaa8aSmrg fi 10400e9fcaa8aSmrg 1040188de56ccSmrg # Delete the generated files. 10402862bcd1aSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 10403862bcd1aSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 104041ab64890Smrg fi 104051ab64890Smrg 1040688de56ccSmrg exit $exit_status 10407862bcd1aSmrg } 104081ab64890Smrg 1040988de56ccSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 1041088de56ccSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 1041188de56ccSmrg fi 1041288de56ccSmrg if test -n "$finalize_shlibpath"; then 1041388de56ccSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 1041488de56ccSmrg fi 10415b4ee4795Smrg 1041688de56ccSmrg compile_var= 1041788de56ccSmrg finalize_var= 1041888de56ccSmrg if test -n "$runpath_var"; then 1041988de56ccSmrg if test -n "$perm_rpath"; then 1042088de56ccSmrg # We should set the runpath_var. 1042188de56ccSmrg rpath= 1042288de56ccSmrg for dir in $perm_rpath; do 10423e9fcaa8aSmrg func_append rpath "$dir:" 1042488de56ccSmrg done 1042588de56ccSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 104261ab64890Smrg fi 1042788de56ccSmrg if test -n "$finalize_perm_rpath"; then 1042888de56ccSmrg # We should set the runpath_var. 1042988de56ccSmrg rpath= 1043088de56ccSmrg for dir in $finalize_perm_rpath; do 10431e9fcaa8aSmrg func_append rpath "$dir:" 1043288de56ccSmrg done 1043388de56ccSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 104341ab64890Smrg fi 1043588de56ccSmrg fi 104361ab64890Smrg 10437862bcd1aSmrg if test yes = "$no_install"; then 1043888de56ccSmrg # We don't need to create a wrapper script. 10439862bcd1aSmrg link_command=$compile_var$compile_command$compile_rpath 1044088de56ccSmrg # Replace the output file specification. 10441e9fcaa8aSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1044288de56ccSmrg # Delete the old output file. 1044388de56ccSmrg $opt_dry_run || $RM $output 1044488de56ccSmrg # Link the executable and exit 1044588de56ccSmrg func_show_eval "$link_command" 'exit $?' 10446e9fcaa8aSmrg 10447e9fcaa8aSmrg if test -n "$postlink_cmds"; then 10448e9fcaa8aSmrg func_to_tool_file "$output" 10449e9fcaa8aSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10450e9fcaa8aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10451e9fcaa8aSmrg fi 10452e9fcaa8aSmrg 10453b4ee4795Smrg exit $EXIT_SUCCESS 1045488de56ccSmrg fi 104552e9c7c8cSmrg 10456862bcd1aSmrg case $hardcode_action,$fast_install in 10457862bcd1aSmrg relink,*) 10458862bcd1aSmrg # Fast installation is not supported 10459862bcd1aSmrg link_command=$compile_var$compile_command$compile_rpath 10460862bcd1aSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 1046188de56ccSmrg 10462862bcd1aSmrg func_warning "this platform does not like uninstalled shared libraries" 10463862bcd1aSmrg func_warning "'$output' will be relinked during installation" 10464862bcd1aSmrg ;; 10465862bcd1aSmrg *,yes) 10466862bcd1aSmrg link_command=$finalize_var$compile_command$finalize_rpath 10467862bcd1aSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10468862bcd1aSmrg ;; 10469862bcd1aSmrg *,no) 10470862bcd1aSmrg link_command=$compile_var$compile_command$compile_rpath 10471862bcd1aSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10472862bcd1aSmrg ;; 10473862bcd1aSmrg *,needless) 10474862bcd1aSmrg link_command=$finalize_var$compile_command$finalize_rpath 10475862bcd1aSmrg relink_command= 10476862bcd1aSmrg ;; 10477862bcd1aSmrg esac 104781ab64890Smrg 1047988de56ccSmrg # Replace the output file specification. 10480e9fcaa8aSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 104811ab64890Smrg 1048288de56ccSmrg # Delete the old output files. 1048388de56ccSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 104841ab64890Smrg 1048588de56ccSmrg func_show_eval "$link_command" 'exit $?' 10486b4ee4795Smrg 10487e9fcaa8aSmrg if test -n "$postlink_cmds"; then 10488e9fcaa8aSmrg func_to_tool_file "$output_objdir/$outputname" 10489e9fcaa8aSmrg 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'` 10490e9fcaa8aSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10491e9fcaa8aSmrg fi 10492e9fcaa8aSmrg 1049388de56ccSmrg # Now create the wrapper script. 1049488de56ccSmrg func_verbose "creating $output" 10495b4ee4795Smrg 1049688de56ccSmrg # Quote the relink command for shipping. 1049788de56ccSmrg if test -n "$relink_command"; then 1049888de56ccSmrg # Preserve any variables that may affect compiler behavior 1049988de56ccSmrg for var in $variables_saved_for_relink; do 1050088de56ccSmrg if eval test -z \"\${$var+set}\"; then 1050188de56ccSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1050288de56ccSmrg elif eval var_value=\$$var; test -z "$var_value"; then 1050388de56ccSmrg relink_command="$var=; export $var; $relink_command" 105041ab64890Smrg else 1050588de56ccSmrg func_quote_for_eval "$var_value" 1050688de56ccSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 105071ab64890Smrg fi 1050888de56ccSmrg done 105095afda2e6Smrg relink_command="(cd `pwd`; $relink_command)" 105105afda2e6Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1051188de56ccSmrg fi 1051288de56ccSmrg 1051388de56ccSmrg # Only actually do things if not in dry run mode. 1051488de56ccSmrg $opt_dry_run || { 1051588de56ccSmrg # win32 will think the script is a binary if it has 1051688de56ccSmrg # a .exe suffix, so we strip it off here. 1051788de56ccSmrg case $output in 1051888de56ccSmrg *.exe) func_stripname '' '.exe' "$output" 1051988de56ccSmrg output=$func_stripname_result ;; 1052088de56ccSmrg esac 1052188de56ccSmrg # test for cygwin because mv fails w/o .exe extensions 1052288de56ccSmrg case $host in 1052388de56ccSmrg *cygwin*) 1052488de56ccSmrg exeext=.exe 1052588de56ccSmrg func_stripname '' '.exe' "$outputname" 1052688de56ccSmrg outputname=$func_stripname_result ;; 1052788de56ccSmrg *) exeext= ;; 105281ab64890Smrg esac 1052988de56ccSmrg case $host in 1053088de56ccSmrg *cygwin* | *mingw* ) 1053188de56ccSmrg func_dirname_and_basename "$output" "" "." 1053288de56ccSmrg output_name=$func_basename_result 1053388de56ccSmrg output_path=$func_dirname_result 10534862bcd1aSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10535862bcd1aSmrg cwrapper=$output_path/$output_name.exe 1053688de56ccSmrg $RM $cwrappersource $cwrapper 1053788de56ccSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 1053888de56ccSmrg 1053988de56ccSmrg func_emit_cwrapperexe_src > $cwrappersource 1054088de56ccSmrg 1054188de56ccSmrg # The wrapper executable is built using the $host compiler, 1054288de56ccSmrg # because it contains $host paths and files. If cross- 1054388de56ccSmrg # compiling, it, like the target executable, must be 1054488de56ccSmrg # executed on the $host or under an emulation environment. 1054588de56ccSmrg $opt_dry_run || { 1054688de56ccSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 1054788de56ccSmrg $STRIP $cwrapper 1054888de56ccSmrg } 105491ab64890Smrg 1055088de56ccSmrg # Now, create the wrapper script for func_source use: 1055188de56ccSmrg func_ltwrapper_scriptname $cwrapper 1055288de56ccSmrg $RM $func_ltwrapper_scriptname_result 1055388de56ccSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 1055488de56ccSmrg $opt_dry_run || { 1055588de56ccSmrg # note: this script will not be executed, so do not chmod. 10556862bcd1aSmrg if test "x$build" = "x$host"; then 1055788de56ccSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 1055888de56ccSmrg else 1055988de56ccSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 1056088de56ccSmrg fi 1056188de56ccSmrg } 1056288de56ccSmrg ;; 1056388de56ccSmrg * ) 1056488de56ccSmrg $RM $output 1056588de56ccSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 105661ab64890Smrg 1056788de56ccSmrg func_emit_wrapper no > $output 1056888de56ccSmrg chmod +x $output 1056988de56ccSmrg ;; 1057088de56ccSmrg esac 1057188de56ccSmrg } 1057288de56ccSmrg exit $EXIT_SUCCESS 1057388de56ccSmrg ;; 1057488de56ccSmrg esac 105751ab64890Smrg 1057688de56ccSmrg # See if we need to build an old-fashioned archive. 1057788de56ccSmrg for oldlib in $oldlibs; do 105781ab64890Smrg 10579862bcd1aSmrg case $build_libtool_libs in 10580862bcd1aSmrg convenience) 10581862bcd1aSmrg oldobjs="$libobjs_save $symfileobj" 10582862bcd1aSmrg addlibs=$convenience 1058388de56ccSmrg build_libtool_libs=no 10584862bcd1aSmrg ;; 10585862bcd1aSmrg module) 10586862bcd1aSmrg oldobjs=$libobjs_save 10587862bcd1aSmrg addlibs=$old_convenience 10588862bcd1aSmrg build_libtool_libs=no 10589862bcd1aSmrg ;; 10590862bcd1aSmrg *) 1059188de56ccSmrg oldobjs="$old_deplibs $non_pic_objects" 10592862bcd1aSmrg $preload && test -f "$symfileobj" \ 10593862bcd1aSmrg && func_append oldobjs " $symfileobj" 10594862bcd1aSmrg addlibs=$old_convenience 10595862bcd1aSmrg ;; 10596862bcd1aSmrg esac 105971ab64890Smrg 1059888de56ccSmrg if test -n "$addlibs"; then 10599862bcd1aSmrg gentop=$output_objdir/${outputname}x 10600e9fcaa8aSmrg func_append generated " $gentop" 106011ab64890Smrg 1060288de56ccSmrg func_extract_archives $gentop $addlibs 10603e9fcaa8aSmrg func_append oldobjs " $func_extract_archives_result" 1060488de56ccSmrg fi 106051ab64890Smrg 1060688de56ccSmrg # Do each command in the archive commands. 10607862bcd1aSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 1060888de56ccSmrg cmds=$old_archive_from_new_cmds 1060988de56ccSmrg else 106101ab64890Smrg 1061188de56ccSmrg # Add any objects from preloaded convenience libraries 1061288de56ccSmrg if test -n "$dlprefiles"; then 10613862bcd1aSmrg gentop=$output_objdir/${outputname}x 10614e9fcaa8aSmrg func_append generated " $gentop" 106151ab64890Smrg 1061688de56ccSmrg func_extract_archives $gentop $dlprefiles 10617e9fcaa8aSmrg func_append oldobjs " $func_extract_archives_result" 1061888de56ccSmrg fi 106191ab64890Smrg 1062088de56ccSmrg # POSIX demands no paths to be encoded in archives. We have 1062188de56ccSmrg # to avoid creating archives with duplicate basenames if we 1062288de56ccSmrg # might have to extract them afterwards, e.g., when creating a 1062388de56ccSmrg # static archive out of a convenience library, or when linking 1062488de56ccSmrg # the entirety of a libtool archive into another (currently 1062588de56ccSmrg # not supported by libtool). 1062688de56ccSmrg if (for obj in $oldobjs 1062788de56ccSmrg do 1062888de56ccSmrg func_basename "$obj" 1062988de56ccSmrg $ECHO "$func_basename_result" 1063088de56ccSmrg done | sort | sort -uc >/dev/null 2>&1); then 1063188de56ccSmrg : 1063288de56ccSmrg else 10633e9fcaa8aSmrg echo "copying selected object files to avoid basename conflicts..." 10634862bcd1aSmrg gentop=$output_objdir/${outputname}x 10635e9fcaa8aSmrg func_append generated " $gentop" 1063688de56ccSmrg func_mkdir_p "$gentop" 1063788de56ccSmrg save_oldobjs=$oldobjs 1063888de56ccSmrg oldobjs= 1063988de56ccSmrg counter=1 1064088de56ccSmrg for obj in $save_oldobjs 1064188de56ccSmrg do 1064288de56ccSmrg func_basename "$obj" 10643862bcd1aSmrg objbase=$func_basename_result 1064488de56ccSmrg case " $oldobjs " in 1064588de56ccSmrg " ") oldobjs=$obj ;; 1064688de56ccSmrg *[\ /]"$objbase "*) 1064788de56ccSmrg while :; do 1064888de56ccSmrg # Make sure we don't pick an alternate name that also 1064988de56ccSmrg # overlaps. 1065088de56ccSmrg newobj=lt$counter-$objbase 1065188de56ccSmrg func_arith $counter + 1 1065288de56ccSmrg counter=$func_arith_result 1065388de56ccSmrg case " $oldobjs " in 1065488de56ccSmrg *[\ /]"$newobj "*) ;; 1065588de56ccSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 1065688de56ccSmrg esac 1065788de56ccSmrg done 1065888de56ccSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10659e9fcaa8aSmrg func_append oldobjs " $gentop/$newobj" 1066088de56ccSmrg ;; 10661e9fcaa8aSmrg *) func_append oldobjs " $obj" ;; 1066288de56ccSmrg esac 106631ab64890Smrg done 106642e9c7c8cSmrg fi 10665eb411b4bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666eb411b4bSmrg tool_oldlib=$func_to_tool_file_result 1066788de56ccSmrg eval cmds=\"$old_archive_cmds\" 10668b4ee4795Smrg 1066988de56ccSmrg func_len " $cmds" 1067088de56ccSmrg len=$func_len_result 1067188de56ccSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1067288de56ccSmrg cmds=$old_archive_cmds 10673e9fcaa8aSmrg elif test -n "$archiver_list_spec"; then 10674e9fcaa8aSmrg func_verbose "using command file archive linking..." 10675e9fcaa8aSmrg for obj in $oldobjs 10676e9fcaa8aSmrg do 10677e9fcaa8aSmrg func_to_tool_file "$obj" 10678e9fcaa8aSmrg $ECHO "$func_to_tool_file_result" 10679e9fcaa8aSmrg done > $output_objdir/$libname.libcmd 10680e9fcaa8aSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10681e9fcaa8aSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10682e9fcaa8aSmrg cmds=$old_archive_cmds 1068388de56ccSmrg else 1068488de56ccSmrg # the command line is too long to link in one step, link in parts 1068588de56ccSmrg func_verbose "using piecewise archive linking..." 1068688de56ccSmrg save_RANLIB=$RANLIB 1068788de56ccSmrg RANLIB=: 1068888de56ccSmrg objlist= 1068988de56ccSmrg concat_cmds= 1069088de56ccSmrg save_oldobjs=$oldobjs 1069188de56ccSmrg oldobjs= 1069288de56ccSmrg # Is there a better way of finding the last object in the list? 1069388de56ccSmrg for obj in $save_oldobjs 1069488de56ccSmrg do 1069588de56ccSmrg last_oldobj=$obj 1069688de56ccSmrg done 1069788de56ccSmrg eval test_cmds=\"$old_archive_cmds\" 1069888de56ccSmrg func_len " $test_cmds" 1069988de56ccSmrg len0=$func_len_result 1070088de56ccSmrg len=$len0 1070188de56ccSmrg for obj in $save_oldobjs 1070288de56ccSmrg do 1070388de56ccSmrg func_len " $obj" 1070488de56ccSmrg func_arith $len + $func_len_result 1070588de56ccSmrg len=$func_arith_result 1070688de56ccSmrg func_append objlist " $obj" 1070788de56ccSmrg if test "$len" -lt "$max_cmd_len"; then 1070888de56ccSmrg : 1070988de56ccSmrg else 1071088de56ccSmrg # the above command should be used before it gets too long 1071188de56ccSmrg oldobjs=$objlist 10712862bcd1aSmrg if test "$obj" = "$last_oldobj"; then 1071388de56ccSmrg RANLIB=$save_RANLIB 1071488de56ccSmrg fi 1071588de56ccSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10716862bcd1aSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 1071788de56ccSmrg objlist= 1071888de56ccSmrg len=$len0 1071988de56ccSmrg fi 1072088de56ccSmrg done 1072188de56ccSmrg RANLIB=$save_RANLIB 1072288de56ccSmrg oldobjs=$objlist 10723862bcd1aSmrg if test -z "$oldobjs"; then 1072488de56ccSmrg eval cmds=\"\$concat_cmds\" 1072588de56ccSmrg else 1072688de56ccSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 1072788de56ccSmrg fi 1072888de56ccSmrg fi 1072988de56ccSmrg fi 1073088de56ccSmrg func_execute_cmds "$cmds" 'exit $?' 107311ab64890Smrg done 107321ab64890Smrg 1073388de56ccSmrg test -n "$generated" && \ 1073488de56ccSmrg func_show_eval "${RM}r$generated" 107351ab64890Smrg 1073688de56ccSmrg # Now create the libtool archive. 1073788de56ccSmrg case $output in 1073888de56ccSmrg *.la) 1073988de56ccSmrg old_library= 10740862bcd1aSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 1074188de56ccSmrg func_verbose "creating $output" 107422e9c7c8cSmrg 1074388de56ccSmrg # Preserve any variables that may affect compiler behavior 1074488de56ccSmrg for var in $variables_saved_for_relink; do 1074588de56ccSmrg if eval test -z \"\${$var+set}\"; then 1074688de56ccSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1074788de56ccSmrg elif eval var_value=\$$var; test -z "$var_value"; then 1074888de56ccSmrg relink_command="$var=; export $var; $relink_command" 10749b4ee4795Smrg else 1075088de56ccSmrg func_quote_for_eval "$var_value" 1075188de56ccSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752b4ee4795Smrg fi 1075388de56ccSmrg done 1075488de56ccSmrg # Quote the link command for shipping. 10755862bcd1aSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 107565afda2e6Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10757862bcd1aSmrg if test yes = "$hardcode_automatic"; then 1075888de56ccSmrg relink_command= 1075988de56ccSmrg fi 107601ab64890Smrg 1076188de56ccSmrg # Only create the output if not a dry run. 1076288de56ccSmrg $opt_dry_run || { 1076388de56ccSmrg for installed in no yes; do 10764862bcd1aSmrg if test yes = "$installed"; then 1076588de56ccSmrg if test -z "$install_libdir"; then 1076688de56ccSmrg break 1076788de56ccSmrg fi 10768862bcd1aSmrg output=$output_objdir/${outputname}i 1076988de56ccSmrg # Replace all uninstalled libtool libraries with the installed ones 1077088de56ccSmrg newdependency_libs= 1077188de56ccSmrg for deplib in $dependency_libs; do 1077288de56ccSmrg case $deplib in 1077388de56ccSmrg *.la) 1077488de56ccSmrg func_basename "$deplib" 10775862bcd1aSmrg name=$func_basename_result 10776eb411b4bSmrg func_resolve_sysroot "$deplib" 10777862bcd1aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 1077888de56ccSmrg test -z "$libdir" && \ 10779862bcd1aSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 10780e9fcaa8aSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10781e9fcaa8aSmrg ;; 10782e9fcaa8aSmrg -L*) 10783e9fcaa8aSmrg func_stripname -L '' "$deplib" 10784e9fcaa8aSmrg func_replace_sysroot "$func_stripname_result" 10785e9fcaa8aSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 1078688de56ccSmrg ;; 10787e9fcaa8aSmrg -R*) 10788e9fcaa8aSmrg func_stripname -R '' "$deplib" 10789e9fcaa8aSmrg func_replace_sysroot "$func_stripname_result" 10790e9fcaa8aSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10791e9fcaa8aSmrg ;; 10792e9fcaa8aSmrg *) func_append newdependency_libs " $deplib" ;; 1079388de56ccSmrg esac 1079488de56ccSmrg done 10795862bcd1aSmrg dependency_libs=$newdependency_libs 1079688de56ccSmrg newdlfiles= 1079788de56ccSmrg 1079888de56ccSmrg for lib in $dlfiles; do 1079988de56ccSmrg case $lib in 1080088de56ccSmrg *.la) 1080188de56ccSmrg func_basename "$lib" 10802862bcd1aSmrg name=$func_basename_result 10803862bcd1aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1080488de56ccSmrg test -z "$libdir" && \ 10805862bcd1aSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10806e9fcaa8aSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 1080788de56ccSmrg ;; 10808e9fcaa8aSmrg *) func_append newdlfiles " $lib" ;; 1080988de56ccSmrg esac 1081088de56ccSmrg done 10811862bcd1aSmrg dlfiles=$newdlfiles 1081288de56ccSmrg newdlprefiles= 1081388de56ccSmrg for lib in $dlprefiles; do 1081488de56ccSmrg case $lib in 1081588de56ccSmrg *.la) 1081688de56ccSmrg # Only pass preopened files to the pseudo-archive (for 1081788de56ccSmrg # eventual linking with the app. that links it) if we 1081888de56ccSmrg # didn't already link the preopened objects directly into 1081988de56ccSmrg # the library: 1082088de56ccSmrg func_basename "$lib" 10821862bcd1aSmrg name=$func_basename_result 10822862bcd1aSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1082388de56ccSmrg test -z "$libdir" && \ 10824862bcd1aSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10825e9fcaa8aSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 1082688de56ccSmrg ;; 1082788de56ccSmrg esac 1082888de56ccSmrg done 10829862bcd1aSmrg dlprefiles=$newdlprefiles 1083088de56ccSmrg else 1083188de56ccSmrg newdlfiles= 1083288de56ccSmrg for lib in $dlfiles; do 1083388de56ccSmrg case $lib in 10834862bcd1aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1083588de56ccSmrg *) abs=`pwd`"/$lib" ;; 1083688de56ccSmrg esac 10837e9fcaa8aSmrg func_append newdlfiles " $abs" 1083888de56ccSmrg done 10839862bcd1aSmrg dlfiles=$newdlfiles 1084088de56ccSmrg newdlprefiles= 1084188de56ccSmrg for lib in $dlprefiles; do 1084288de56ccSmrg case $lib in 10843862bcd1aSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1084488de56ccSmrg *) abs=`pwd`"/$lib" ;; 1084588de56ccSmrg esac 10846e9fcaa8aSmrg func_append newdlprefiles " $abs" 1084788de56ccSmrg done 10848862bcd1aSmrg dlprefiles=$newdlprefiles 1084988de56ccSmrg fi 1085088de56ccSmrg $RM $output 1085188de56ccSmrg # place dlname in correct position for cygwin 10852e9fcaa8aSmrg # In fact, it would be nice if we could use this code for all target 10853e9fcaa8aSmrg # systems that can't hard-code library paths into their executables 10854e9fcaa8aSmrg # and that have no shared library path variable independent of PATH, 10855e9fcaa8aSmrg # but it turns out we can't easily determine that from inspecting 10856e9fcaa8aSmrg # libtool variables, so we have to hard-code the OSs to which it 10857e9fcaa8aSmrg # applies here; at the moment, that means platforms that use the PE 10858e9fcaa8aSmrg # object format with DLL files. See the long comment at the top of 10859e9fcaa8aSmrg # tests/bindir.at for full details. 1086088de56ccSmrg tdlname=$dlname 1086188de56ccSmrg case $host,$output,$installed,$module,$dlname in 10862e9fcaa8aSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10863e9fcaa8aSmrg # If a -bindir argument was supplied, place the dll there. 10864862bcd1aSmrg if test -n "$bindir"; then 10865e9fcaa8aSmrg func_relative_path "$install_libdir" "$bindir" 10866862bcd1aSmrg tdlname=$func_relative_path_result/$dlname 10867e9fcaa8aSmrg else 10868e9fcaa8aSmrg # Otherwise fall back on heuristic. 10869e9fcaa8aSmrg tdlname=../bin/$dlname 10870e9fcaa8aSmrg fi 10871e9fcaa8aSmrg ;; 1087288de56ccSmrg esac 1087388de56ccSmrg $ECHO > $output "\ 1087488de56ccSmrg# $outputname - a libtool library file 10875862bcd1aSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 1087688de56ccSmrg# 1087788de56ccSmrg# Please DO NOT delete this file! 1087888de56ccSmrg# It is necessary for linking the library. 108791ab64890Smrg 1088088de56ccSmrg# The name that we can dlopen(3). 1088188de56ccSmrgdlname='$tdlname' 108821ab64890Smrg 1088388de56ccSmrg# Names of this library. 1088488de56ccSmrglibrary_names='$library_names' 108851ab64890Smrg 1088688de56ccSmrg# The name of the static archive. 1088788de56ccSmrgold_library='$old_library' 108881ab64890Smrg 10889862bcd1aSmrg# Linker flags that cannot go in dependency_libs. 1089088de56ccSmrginherited_linker_flags='$new_inherited_linker_flags' 108911ab64890Smrg 1089288de56ccSmrg# Libraries that this one depends upon. 1089388de56ccSmrgdependency_libs='$dependency_libs' 108941ab64890Smrg 1089588de56ccSmrg# Names of additional weak libraries provided by this library 1089688de56ccSmrgweak_library_names='$weak_libs' 108971ab64890Smrg 1089888de56ccSmrg# Version information for $libname. 1089988de56ccSmrgcurrent=$current 1090088de56ccSmrgage=$age 1090188de56ccSmrgrevision=$revision 109021ab64890Smrg 1090388de56ccSmrg# Is this an already installed library? 1090488de56ccSmrginstalled=$installed 109051ab64890Smrg 1090688de56ccSmrg# Should we warn about portability when linking against -modules? 1090788de56ccSmrgshouldnotlink=$module 109081ab64890Smrg 1090988de56ccSmrg# Files to dlopen/dlpreopen 1091088de56ccSmrgdlopen='$dlfiles' 1091188de56ccSmrgdlpreopen='$dlprefiles' 109121ab64890Smrg 1091388de56ccSmrg# Directory that this library needs to be installed in: 1091488de56ccSmrglibdir='$install_libdir'" 10915862bcd1aSmrg if test no,yes = "$installed,$need_relink"; then 1091688de56ccSmrg $ECHO >> $output "\ 1091788de56ccSmrgrelink_command=\"$relink_command\"" 1091888de56ccSmrg fi 1091988de56ccSmrg done 1092088de56ccSmrg } 109211ab64890Smrg 1092288de56ccSmrg # Do a symbolic link so that the libtool archive can be found in 1092388de56ccSmrg # LD_LIBRARY_PATH before the program is installed. 1092488de56ccSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 1092588de56ccSmrg ;; 1092688de56ccSmrg esac 1092788de56ccSmrg exit $EXIT_SUCCESS 1092888de56ccSmrg} 10929b4ee4795Smrg 10930862bcd1aSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 10931862bcd1aSmrg func_mode_link ${1+"$@"} 10932862bcd1aSmrgfi 109331ab64890Smrg 109341ab64890Smrg 1093588de56ccSmrg# func_mode_uninstall arg... 1093688de56ccSmrgfunc_mode_uninstall () 1093788de56ccSmrg{ 10938862bcd1aSmrg $debug_cmd 10939862bcd1aSmrg 10940862bcd1aSmrg RM=$nonopt 109411ab64890Smrg files= 10942862bcd1aSmrg rmforce=false 109431ab64890Smrg exit_status=0 109441ab64890Smrg 109451ab64890Smrg # This variable tells wrapper scripts just to set variables rather 109461ab64890Smrg # than running their programs. 10947862bcd1aSmrg libtool_install_magic=$magic 109481ab64890Smrg 109491ab64890Smrg for arg 109501ab64890Smrg do 109511ab64890Smrg case $arg in 10952862bcd1aSmrg -f) func_append RM " $arg"; rmforce=: ;; 10953e9fcaa8aSmrg -*) func_append RM " $arg" ;; 10954e9fcaa8aSmrg *) func_append files " $arg" ;; 109551ab64890Smrg esac 109561ab64890Smrg done 109571ab64890Smrg 1095888de56ccSmrg test -z "$RM" && \ 1095988de56ccSmrg func_fatal_help "you must specify an RM program" 109601ab64890Smrg 109611ab64890Smrg rmdirs= 109621ab64890Smrg 109631ab64890Smrg for file in $files; do 1096488de56ccSmrg func_dirname "$file" "" "." 10965862bcd1aSmrg dir=$func_dirname_result 10966862bcd1aSmrg if test . = "$dir"; then 10967862bcd1aSmrg odir=$objdir 109681ab64890Smrg else 10969862bcd1aSmrg odir=$dir/$objdir 109701ab64890Smrg fi 1097188de56ccSmrg func_basename "$file" 10972862bcd1aSmrg name=$func_basename_result 10973862bcd1aSmrg test uninstall = "$opt_mode" && odir=$dir 109741ab64890Smrg 10975e9fcaa8aSmrg # Remember odir for removal later, being careful to avoid duplicates 10976862bcd1aSmrg if test clean = "$opt_mode"; then 109771ab64890Smrg case " $rmdirs " in 10978e9fcaa8aSmrg *" $odir "*) ;; 10979e9fcaa8aSmrg *) func_append rmdirs " $odir" ;; 109801ab64890Smrg esac 109811ab64890Smrg fi 109821ab64890Smrg 109831ab64890Smrg # Don't error if the file doesn't exist and rm -f was used. 1098488de56ccSmrg if { test -L "$file"; } >/dev/null 2>&1 || 1098588de56ccSmrg { test -h "$file"; } >/dev/null 2>&1 || 1098688de56ccSmrg test -f "$file"; then 109871ab64890Smrg : 109881ab64890Smrg elif test -d "$file"; then 109891ab64890Smrg exit_status=1 109901ab64890Smrg continue 10991862bcd1aSmrg elif $rmforce; then 109921ab64890Smrg continue 109931ab64890Smrg fi 109941ab64890Smrg 10995862bcd1aSmrg rmfiles=$file 109961ab64890Smrg 109971ab64890Smrg case $name in 109981ab64890Smrg *.la) 109991ab64890Smrg # Possibly a libtool archive, so verify it. 1100088de56ccSmrg if func_lalib_p "$file"; then 1100188de56ccSmrg func_source $dir/$name 110021ab64890Smrg 110031ab64890Smrg # Delete the libtool libraries and symlinks. 110041ab64890Smrg for n in $library_names; do 11005e9fcaa8aSmrg func_append rmfiles " $odir/$n" 110061ab64890Smrg done 11007e9fcaa8aSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 110081ab64890Smrg 11009862bcd1aSmrg case $opt_mode in 110101ab64890Smrg clean) 11011e9fcaa8aSmrg case " $library_names " in 110121ab64890Smrg *" $dlname "*) ;; 11013e9fcaa8aSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 110141ab64890Smrg esac 11015e9fcaa8aSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 110161ab64890Smrg ;; 110171ab64890Smrg uninstall) 110181ab64890Smrg if test -n "$library_names"; then 110191ab64890Smrg # Do each command in the postuninstall commands. 11020862bcd1aSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 110211ab64890Smrg fi 110221ab64890Smrg 110231ab64890Smrg if test -n "$old_library"; then 110241ab64890Smrg # Do each command in the old_postuninstall commands. 11025862bcd1aSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 110261ab64890Smrg fi 110271ab64890Smrg # FIXME: should reinstall the best remaining shared library. 110281ab64890Smrg ;; 110291ab64890Smrg esac 110301ab64890Smrg fi 110311ab64890Smrg ;; 110321ab64890Smrg 110331ab64890Smrg *.lo) 110341ab64890Smrg # Possibly a libtool object, so verify it. 1103588de56ccSmrg if func_lalib_p "$file"; then 110361ab64890Smrg 110371ab64890Smrg # Read the .lo file 1103888de56ccSmrg func_source $dir/$name 110391ab64890Smrg 110401ab64890Smrg # Add PIC object to the list of files to remove. 11041862bcd1aSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11042e9fcaa8aSmrg func_append rmfiles " $dir/$pic_object" 110431ab64890Smrg fi 110441ab64890Smrg 110451ab64890Smrg # Add non-PIC object to the list of files to remove. 11046862bcd1aSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11047e9fcaa8aSmrg func_append rmfiles " $dir/$non_pic_object" 110481ab64890Smrg fi 110491ab64890Smrg fi 110501ab64890Smrg ;; 110511ab64890Smrg 110521ab64890Smrg *) 11053862bcd1aSmrg if test clean = "$opt_mode"; then 110541ab64890Smrg noexename=$name 110551ab64890Smrg case $file in 110561ab64890Smrg *.exe) 1105788de56ccSmrg func_stripname '' '.exe' "$file" 1105888de56ccSmrg file=$func_stripname_result 1105988de56ccSmrg func_stripname '' '.exe' "$name" 1106088de56ccSmrg noexename=$func_stripname_result 110611ab64890Smrg # $file with .exe has already been added to rmfiles, 110621ab64890Smrg # add $file without .exe 11063e9fcaa8aSmrg func_append rmfiles " $file" 110641ab64890Smrg ;; 110651ab64890Smrg esac 110661ab64890Smrg # Do a test to see if this is a libtool program. 1106788de56ccSmrg if func_ltwrapper_p "$file"; then 1106888de56ccSmrg if func_ltwrapper_executable_p "$file"; then 1106988de56ccSmrg func_ltwrapper_scriptname "$file" 1107088de56ccSmrg relink_command= 1107188de56ccSmrg func_source $func_ltwrapper_scriptname_result 11072e9fcaa8aSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 1107388de56ccSmrg else 1107488de56ccSmrg relink_command= 1107588de56ccSmrg func_source $dir/$noexename 1107688de56ccSmrg fi 110771ab64890Smrg 110781ab64890Smrg # note $name still contains .exe if it was in $file originally 110791ab64890Smrg # as does the version of $file that was added into $rmfiles 11080862bcd1aSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11081862bcd1aSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11082e9fcaa8aSmrg func_append rmfiles " $odir/lt-$name" 110831ab64890Smrg fi 11084862bcd1aSmrg if test "X$noexename" != "X$name"; then 11085862bcd1aSmrg func_append rmfiles " $odir/lt-$noexename.c" 110861ab64890Smrg fi 110871ab64890Smrg fi 110881ab64890Smrg fi 110891ab64890Smrg ;; 110901ab64890Smrg esac 1109188de56ccSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 110921ab64890Smrg done 110931ab64890Smrg 11094862bcd1aSmrg # Try to remove the $objdir's in the directories where we deleted files 110951ab64890Smrg for dir in $rmdirs; do 110961ab64890Smrg if test -d "$dir"; then 1109788de56ccSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 110981ab64890Smrg fi 110991ab64890Smrg done 111001ab64890Smrg 111011ab64890Smrg exit $exit_status 1110288de56ccSmrg} 111031ab64890Smrg 11104862bcd1aSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11105862bcd1aSmrg func_mode_uninstall ${1+"$@"} 11106862bcd1aSmrgfi 111072e9c7c8cSmrg 11108e9fcaa8aSmrgtest -z "$opt_mode" && { 11109862bcd1aSmrg help=$generic_help 1111088de56ccSmrg func_fatal_help "you must specify a MODE" 1111188de56ccSmrg} 1111288de56ccSmrg 1111388de56ccSmrgtest -z "$exec_cmd" && \ 11114862bcd1aSmrg func_fatal_help "invalid operation mode '$opt_mode'" 111151ab64890Smrg 111161ab64890Smrgif test -n "$exec_cmd"; then 1111788de56ccSmrg eval exec "$exec_cmd" 111181ab64890Smrg exit $EXIT_FAILURE 111191ab64890Smrgfi 111201ab64890Smrg 1112188de56ccSmrgexit $exit_status 111221ab64890Smrg 111231ab64890Smrg 111241ab64890Smrg# The TAGs below are defined such that we never get into a situation 11125862bcd1aSmrg# where we disable both kinds of libraries. Given conflicting 111261ab64890Smrg# choices, we go for a static library, that is the most portable, 111271ab64890Smrg# since we can't tell whether shared libraries were disabled because 111281ab64890Smrg# the user asked for that or because the platform doesn't support 111291ab64890Smrg# them. This is particularly important on AIX, because we don't 111301ab64890Smrg# support having both static and shared libraries enabled at the same 111311ab64890Smrg# time on that platform, so we default to a shared-only configuration. 111321ab64890Smrg# If a disable-shared tag is given, we'll fallback to a static-only 111331ab64890Smrg# configuration. But we'll never go from static-only to shared-only. 111341ab64890Smrg 111351ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 1113688de56ccSmrgbuild_libtool_libs=no 1113788de56ccSmrgbuild_old_libs=yes 111381ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 111391ab64890Smrg 111401ab64890Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 1114188de56ccSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 111421ab64890Smrg# ### END LIBTOOL TAG CONFIG: disable-static 111431ab64890Smrg 111441ab64890Smrg# Local Variables: 111451ab64890Smrg# mode:shell-script 111461ab64890Smrg# sh-indentation:2 111471ab64890Smrg# End: 11148