ltmain.sh revision 1c235774
11c235774Smrg#! /bin/sh 2edce3322Smrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 31c235774Smrg## by inline-source v2014-01-03.01 46e7d3316Smrg 51c235774Smrg# libtool (GNU libtool) 2.4.6 6edce3322Smrg# Provide generalized library-building support services. 76e7d3316Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 86e7d3316Smrg 91c235774Smrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 106e7d3316Smrg# This is free software; see the source for copying conditions. There is NO 116e7d3316Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 126e7d3316Smrg 136e7d3316Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14a966c04fSmrg# it under the terms of the GNU General Public License as published by 15a966c04fSmrg# the Free Software Foundation; either version 2 of the License, or 16a966c04fSmrg# (at your option) any later version. 17a966c04fSmrg# 186e7d3316Smrg# As a special exception to the GNU General Public License, 196e7d3316Smrg# if you distribute this file as part of a program or library that 206e7d3316Smrg# is built using GNU Libtool, you may include this file under the 216e7d3316Smrg# same distribution terms that you use for the rest of that program. 226e7d3316Smrg# 236e7d3316Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24a966c04fSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25a966c04fSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26a966c04fSmrg# General Public License for more details. 27a966c04fSmrg# 28a966c04fSmrg# You should have received a copy of the GNU General Public License 29edce3322Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30a966c04fSmrg 31a966c04fSmrg 326e7d3316SmrgPROGRAM=libtool 33a966c04fSmrgPACKAGE=libtool 341c235774SmrgVERSION=2.4.6 351c235774Smrgpackage_revision=2.4.6 362e2dd055Smrg 37edce3322Smrg 38edce3322Smrg## ------ ## 39edce3322Smrg## Usage. ## 40edce3322Smrg## ------ ## 41edce3322Smrg 42edce3322Smrg# Run './libtool --help' for help with using this script from the 43edce3322Smrg# command line. 44edce3322Smrg 45edce3322Smrg 46edce3322Smrg## ------------------------------- ## 47edce3322Smrg## User overridable command paths. ## 48edce3322Smrg## ------------------------------- ## 49edce3322Smrg 50edce3322Smrg# After configure completes, it has a better idea of some of the 51edce3322Smrg# shell tools we need than the defaults used by the functions shared 52edce3322Smrg# with bootstrap, so set those here where they can still be over- 53edce3322Smrg# ridden by the user, but otherwise take precedence. 54edce3322Smrg 55edce3322Smrg: ${AUTOCONF="autoconf"} 56edce3322Smrg: ${AUTOMAKE="automake"} 57edce3322Smrg 58edce3322Smrg 59edce3322Smrg## -------------------------- ## 60edce3322Smrg## Source external libraries. ## 61edce3322Smrg## -------------------------- ## 62edce3322Smrg 63edce3322Smrg# Much of our low-level functionality needs to be sourced from external 64edce3322Smrg# libraries, which are installed to $pkgauxdir. 65edce3322Smrg 66edce3322Smrg# Set a version string for this script. 671c235774Smrgscriptversion=2015-01-20.17; # UTC 68edce3322Smrg 69edce3322Smrg# General shell script boiler plate, and helper functions. 70edce3322Smrg# Written by Gary V. Vaughan, 2004 71edce3322Smrg 721c235774Smrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 731c235774Smrg# This is free software; see the source for copying conditions. There is NO 741c235774Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 751c235774Smrg 761c235774Smrg# This program is free software; you can redistribute it and/or modify 771c235774Smrg# it under the terms of the GNU General Public License as published by 781c235774Smrg# the Free Software Foundation; either version 3 of the License, or 791c235774Smrg# (at your option) any later version. 801c235774Smrg 811c235774Smrg# As a special exception to the GNU General Public License, if you distribute 821c235774Smrg# this file as part of a program or library that is built using GNU Libtool, 831c235774Smrg# you may include this file under the same distribution terms that you use 841c235774Smrg# for the rest of that program. 85edce3322Smrg 861c235774Smrg# This program is distributed in the hope that it will be useful, 871c235774Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 881c235774Smrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 891c235774Smrg# General Public License for more details. 901c235774Smrg 911c235774Smrg# You should have received a copy of the GNU General Public License 921c235774Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 931c235774Smrg 941c235774Smrg# Please report bugs or propose patches to gary@gnu.org. 95edce3322Smrg 96edce3322Smrg 97edce3322Smrg## ------ ## 98edce3322Smrg## Usage. ## 99edce3322Smrg## ------ ## 100edce3322Smrg 101edce3322Smrg# Evaluate this file near the top of your script to gain access to 102edce3322Smrg# the functions and variables defined here: 103edce3322Smrg# 104edce3322Smrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105edce3322Smrg# 106edce3322Smrg# If you need to override any of the default environment variable 107edce3322Smrg# settings, do that before evaluating this file. 108edce3322Smrg 109edce3322Smrg 110edce3322Smrg## -------------------- ## 111edce3322Smrg## Shell normalisation. ## 112edce3322Smrg## -------------------- ## 113edce3322Smrg 114edce3322Smrg# Some shells need a little help to be as Bourne compatible as possible. 115edce3322Smrg# Before doing anything else, make sure all that help has been provided! 116edce3322Smrg 117edce3322SmrgDUALCASE=1; export DUALCASE # for MKS sh 118edce3322Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 1192e2dd055Smrg emulate sh 1202e2dd055Smrg NULLCMD=: 121edce3322Smrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 1222e2dd055Smrg # is contrary to our usage. Disable this feature. 1232e2dd055Smrg alias -g '${1+"$@"}'='"$@"' 124a966c04fSmrg setopt NO_GLOB_SUBST 1252e2dd055Smrgelse 126edce3322Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127a966c04fSmrgfi 128a966c04fSmrg 129edce3322Smrg# NLS nuisances: We save the old values in case they are required later. 130edce3322Smrg_G_user_locale= 131edce3322Smrg_G_safe_locale= 132edce3322Smrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1332e2dd055Smrgdo 134edce3322Smrg eval "if test set = \"\${$_G_var+set}\"; then 135edce3322Smrg save_$_G_var=\$$_G_var 136edce3322Smrg $_G_var=C 137edce3322Smrg export $_G_var 138edce3322Smrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139edce3322Smrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 1402e2dd055Smrg fi" 1412e2dd055Smrgdone 1421c235774Smrg 1431c235774Smrg# CDPATH. 1441c235774Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 1456e7d3316Smrg 146edce3322Smrg# Make sure IFS has a sensible default 147edce3322Smrgsp=' ' 148edce3322Smrgnl=' 149edce3322Smrg' 150edce3322SmrgIFS="$sp $nl" 151edce3322Smrg 152edce3322Smrg# There are apparently some retarded systems that use ';' as a PATH separator! 153edce3322Smrgif test "${PATH_SEPARATOR+set}" != set; then 154edce3322Smrg PATH_SEPARATOR=: 155edce3322Smrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156edce3322Smrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157edce3322Smrg PATH_SEPARATOR=';' 158edce3322Smrg } 159edce3322Smrgfi 1606e7d3316Smrg 1616e7d3316Smrg 1626e7d3316Smrg 163edce3322Smrg## ------------------------- ## 164edce3322Smrg## Locate command utilities. ## 165edce3322Smrg## ------------------------- ## 166edce3322Smrg 167edce3322Smrg 168edce3322Smrg# func_executable_p FILE 169edce3322Smrg# ---------------------- 170edce3322Smrg# Check that FILE is an executable regular file. 171edce3322Smrgfunc_executable_p () 172edce3322Smrg{ 173edce3322Smrg test -f "$1" && test -x "$1" 174edce3322Smrg} 175edce3322Smrg 176edce3322Smrg 177edce3322Smrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178edce3322Smrg# -------------------------------------------- 179edce3322Smrg# Search for either a program that responds to --version with output 180edce3322Smrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181edce3322Smrg# trying all the directories in PATH with each of the elements of 182edce3322Smrg# PROGS_LIST. 183edce3322Smrg# 184edce3322Smrg# CHECK_FUNC should accept the path to a candidate program, and 185edce3322Smrg# set $func_check_prog_result if it truncates its output less than 186edce3322Smrg# $_G_path_prog_max characters. 187edce3322Smrgfunc_path_progs () 188edce3322Smrg{ 189edce3322Smrg _G_progs_list=$1 190edce3322Smrg _G_check_func=$2 191edce3322Smrg _G_PATH=${3-"$PATH"} 192edce3322Smrg 193edce3322Smrg _G_path_prog_max=0 194edce3322Smrg _G_path_prog_found=false 195edce3322Smrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196edce3322Smrg for _G_dir in $_G_PATH; do 197edce3322Smrg IFS=$_G_save_IFS 198edce3322Smrg test -z "$_G_dir" && _G_dir=. 199edce3322Smrg for _G_prog_name in $_G_progs_list; do 200edce3322Smrg for _exeext in '' .EXE; do 201edce3322Smrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202edce3322Smrg func_executable_p "$_G_path_prog" || continue 203edce3322Smrg case `"$_G_path_prog" --version 2>&1` in 204edce3322Smrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205edce3322Smrg *) $_G_check_func $_G_path_prog 206edce3322Smrg func_path_progs_result=$func_check_prog_result 207edce3322Smrg ;; 208edce3322Smrg esac 209edce3322Smrg $_G_path_prog_found && break 3 210edce3322Smrg done 211edce3322Smrg done 212edce3322Smrg done 213edce3322Smrg IFS=$_G_save_IFS 214edce3322Smrg test -z "$func_path_progs_result" && { 215edce3322Smrg echo "no acceptable sed could be found in \$PATH" >&2 216edce3322Smrg exit 1 217edce3322Smrg } 218edce3322Smrg} 219edce3322Smrg 220edce3322Smrg 221edce3322Smrg# We want to be able to use the functions in this file before configure 222edce3322Smrg# has figured out where the best binaries are kept, which means we have 223edce3322Smrg# to search for them ourselves - except when the results are already set 224edce3322Smrg# where we skip the searches. 225edce3322Smrg 226edce3322Smrg# Unless the user overrides by setting SED, search the path for either GNU 227edce3322Smrg# sed, or the sed that truncates its output the least. 228edce3322Smrgtest -z "$SED" && { 229edce3322Smrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230edce3322Smrg for _G_i in 1 2 3 4 5 6 7; do 231edce3322Smrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 232edce3322Smrg done 233edce3322Smrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234edce3322Smrg _G_sed_script= 235edce3322Smrg 236edce3322Smrg func_check_prog_sed () 237edce3322Smrg { 238edce3322Smrg _G_path_prog=$1 239edce3322Smrg 240edce3322Smrg _G_count=0 241edce3322Smrg printf 0123456789 >conftest.in 242edce3322Smrg while : 243edce3322Smrg do 244edce3322Smrg cat conftest.in conftest.in >conftest.tmp 245edce3322Smrg mv conftest.tmp conftest.in 246edce3322Smrg cp conftest.in conftest.nl 247edce3322Smrg echo '' >> conftest.nl 248edce3322Smrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249edce3322Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 250edce3322Smrg _G_count=`expr $_G_count + 1` 251edce3322Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 252edce3322Smrg # Best one so far, save it but keep looking for a better one 253edce3322Smrg func_check_prog_result=$_G_path_prog 254edce3322Smrg _G_path_prog_max=$_G_count 255edce3322Smrg fi 256edce3322Smrg # 10*(2^10) chars as input seems more than enough 257edce3322Smrg test 10 -lt "$_G_count" && break 258edce3322Smrg done 259edce3322Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 260edce3322Smrg } 261edce3322Smrg 2621c235774Smrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263edce3322Smrg rm -f conftest.sed 264edce3322Smrg SED=$func_path_progs_result 265edce3322Smrg} 266edce3322Smrg 267edce3322Smrg 268edce3322Smrg# Unless the user overrides by setting GREP, search the path for either GNU 269edce3322Smrg# grep, or the grep that truncates its output the least. 270edce3322Smrgtest -z "$GREP" && { 271edce3322Smrg func_check_prog_grep () 272edce3322Smrg { 273edce3322Smrg _G_path_prog=$1 274edce3322Smrg 275edce3322Smrg _G_count=0 276edce3322Smrg _G_path_prog_max=0 277edce3322Smrg printf 0123456789 >conftest.in 278edce3322Smrg while : 279edce3322Smrg do 280edce3322Smrg cat conftest.in conftest.in >conftest.tmp 281edce3322Smrg mv conftest.tmp conftest.in 282edce3322Smrg cp conftest.in conftest.nl 283edce3322Smrg echo 'GREP' >> conftest.nl 284edce3322Smrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285edce3322Smrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 286edce3322Smrg _G_count=`expr $_G_count + 1` 287edce3322Smrg if test "$_G_count" -gt "$_G_path_prog_max"; then 288edce3322Smrg # Best one so far, save it but keep looking for a better one 289edce3322Smrg func_check_prog_result=$_G_path_prog 290edce3322Smrg _G_path_prog_max=$_G_count 291edce3322Smrg fi 292edce3322Smrg # 10*(2^10) chars as input seems more than enough 293edce3322Smrg test 10 -lt "$_G_count" && break 294edce3322Smrg done 295edce3322Smrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 296edce3322Smrg } 297edce3322Smrg 2981c235774Smrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299edce3322Smrg GREP=$func_path_progs_result 300edce3322Smrg} 301edce3322Smrg 302edce3322Smrg 303edce3322Smrg## ------------------------------- ## 304edce3322Smrg## User overridable command paths. ## 305edce3322Smrg## ------------------------------- ## 306edce3322Smrg 307edce3322Smrg# All uppercase variable names are used for environment variables. These 308edce3322Smrg# variables can be overridden by the user before calling a script that 309edce3322Smrg# uses them if a suitable command of that name is not already available 310edce3322Smrg# in the command search PATH. 3116e7d3316Smrg 3126e7d3316Smrg: ${CP="cp -f"} 313edce3322Smrg: ${ECHO="printf %s\n"} 314edce3322Smrg: ${EGREP="$GREP -E"} 315edce3322Smrg: ${FGREP="$GREP -F"} 316edce3322Smrg: ${LN_S="ln -s"} 3176e7d3316Smrg: ${MAKE="make"} 3186e7d3316Smrg: ${MKDIR="mkdir"} 3196e7d3316Smrg: ${MV="mv -f"} 3206e7d3316Smrg: ${RM="rm -f"} 3216e7d3316Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322a966c04fSmrg 3236e7d3316Smrg 324edce3322Smrg## -------------------- ## 325edce3322Smrg## Useful sed snippets. ## 326edce3322Smrg## -------------------- ## 32797cf2ee2Smrg 328edce3322Smrgsed_dirname='s|/[^/]*$||' 329edce3322Smrgsed_basename='s|^.*/||' 33097cf2ee2Smrg 331edce3322Smrg# Sed substitution that helps us do robust quoting. It backslashifies 332edce3322Smrg# metacharacters that are still active within double-quoted strings. 333edce3322Smrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 33497cf2ee2Smrg 335edce3322Smrg# Same as above, but do not quote variable references. 336edce3322Smrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 33797cf2ee2Smrg 338edce3322Smrg# Sed substitution that turns a string into a regex matching for the 339edce3322Smrg# string literally. 340edce3322Smrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 34197cf2ee2Smrg 342edce3322Smrg# Sed substitution that converts a w32 file name or path 343edce3322Smrg# that contains forward slashes, into one that contains 344edce3322Smrg# (escaped) backslashes. A very naive implementation. 345edce3322Smrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346edce3322Smrg 347edce3322Smrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 348edce3322Smrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 349edce3322Smrg# '$' in input to sed_double_quote_subst, that '$' was protected from 350edce3322Smrg# expansion. Since each input '\' is now two '\'s, look for any number 351edce3322Smrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352edce3322Smrg_G_bs='\\' 353edce3322Smrg_G_bs2='\\\\' 354edce3322Smrg_G_bs4='\\\\\\\\' 355edce3322Smrg_G_dollar='\$' 356edce3322Smrgsed_double_backslash="\ 357edce3322Smrg s/$_G_bs4/&\\ 358edce3322Smrg/g 359edce3322Smrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 360edce3322Smrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361edce3322Smrg s/\n//g" 36297cf2ee2Smrg 363a966c04fSmrg 364edce3322Smrg## ----------------- ## 365edce3322Smrg## Global variables. ## 366edce3322Smrg## ----------------- ## 3676e7d3316Smrg 368edce3322Smrg# Except for the global variables explicitly listed below, the following 369edce3322Smrg# functions in the '^func_' namespace, and the '^require_' namespace 370edce3322Smrg# variables initialised in the 'Resource management' section, sourcing 371edce3322Smrg# this file will not pollute your global namespace with anything 372edce3322Smrg# else. There's no portable way to scope variables in Bourne shell 373edce3322Smrg# though, so actually running these functions will sometimes place 374edce3322Smrg# results into a variable named after the function, and often use 375edce3322Smrg# temporary variables in the '^_G_' namespace. If you are careful to 376edce3322Smrg# avoid using those namespaces casually in your sourcing script, things 377edce3322Smrg# should continue to work as you expect. And, of course, you can freely 378edce3322Smrg# overwrite any of the functions or variables defined here before 379edce3322Smrg# calling anything to customize them. 3806e7d3316Smrg 381edce3322SmrgEXIT_SUCCESS=0 382edce3322SmrgEXIT_FAILURE=1 383edce3322SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384edce3322SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 3856e7d3316Smrg 386edce3322Smrg# Allow overriding, eg assuming that you follow the convention of 387edce3322Smrg# putting '$debug_cmd' at the start of all your functions, you can get 388edce3322Smrg# bash to show function call trace with: 389edce3322Smrg# 390edce3322Smrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391edce3322Smrgdebug_cmd=${debug_cmd-":"} 392edce3322Smrgexit_cmd=: 3936e7d3316Smrg 394edce3322Smrg# By convention, finish your script with: 395edce3322Smrg# 396edce3322Smrg# exit $exit_status 397edce3322Smrg# 398edce3322Smrg# so that you can set exit_status to non-zero if you want to indicate 399edce3322Smrg# something went wrong during execution without actually bailing out at 400edce3322Smrg# the point of failure. 401edce3322Smrgexit_status=$EXIT_SUCCESS 4026e7d3316Smrg 403edce3322Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404edce3322Smrg# is ksh but when the shell is invoked as "sh" and the current value of 405edce3322Smrg# the _XPG environment variable is not equal to 1 (one), the special 406edce3322Smrg# positional parameter $0, within a function call, is the name of the 407edce3322Smrg# function. 408edce3322Smrgprogpath=$0 4096e7d3316Smrg 410edce3322Smrg# The name of this program. 411edce3322Smrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 4126e7d3316Smrg 413edce3322Smrg# Make sure we have an absolute progpath for reexecution: 4146e7d3316Smrgcase $progpath in 4156e7d3316Smrg [\\/]*|[A-Za-z]:\\*) ;; 4166e7d3316Smrg *[\\/]*) 417edce3322Smrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 4186e7d3316Smrg progdir=`cd "$progdir" && pwd` 419edce3322Smrg progpath=$progdir/$progname 4206e7d3316Smrg ;; 4216e7d3316Smrg *) 422edce3322Smrg _G_IFS=$IFS 423ac92798bSmrg IFS=${PATH_SEPARATOR-:} 4246e7d3316Smrg for progdir in $PATH; do 425edce3322Smrg IFS=$_G_IFS 4266e7d3316Smrg test -x "$progdir/$progname" && break 4276e7d3316Smrg done 428edce3322Smrg IFS=$_G_IFS 4296e7d3316Smrg test -n "$progdir" || progdir=`pwd` 430edce3322Smrg progpath=$progdir/$progname 4316e7d3316Smrg ;; 4326e7d3316Smrgesac 4336e7d3316Smrg 4346e7d3316Smrg 435edce3322Smrg## ----------------- ## 436edce3322Smrg## Standard options. ## 437edce3322Smrg## ----------------- ## 43897cf2ee2Smrg 439edce3322Smrg# The following options affect the operation of the functions defined 440edce3322Smrg# below, and should be set appropriately depending on run-time para- 441edce3322Smrg# meters passed on the command line. 4426e7d3316Smrg 4436e7d3316Smrgopt_dry_run=false 4446e7d3316Smrgopt_quiet=false 4456e7d3316Smrgopt_verbose=false 4466e7d3316Smrg 447edce3322Smrg# Categories 'all' and 'none' are always available. Append any others 448edce3322Smrg# you will pass as the first argument to func_warning from your own 449edce3322Smrg# code. 450edce3322Smrgwarning_categories= 4516e7d3316Smrg 452edce3322Smrg# By default, display warnings according to 'opt_warning_types'. Set 453edce3322Smrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454edce3322Smrg# treat the next displayed warning as a fatal error. 455edce3322Smrgwarning_func=func_warn_and_continue 4566e7d3316Smrg 457edce3322Smrg# Set to 'all' to display all warnings, 'none' to suppress all 458edce3322Smrg# warnings, or a space delimited list of some subset of 459edce3322Smrg# 'warning_categories' to display only the listed warnings. 460edce3322Smrgopt_warning_types=all 4616e7d3316Smrg 4626e7d3316Smrg 463edce3322Smrg## -------------------- ## 464edce3322Smrg## Resource management. ## 465edce3322Smrg## -------------------- ## 4666e7d3316Smrg 467edce3322Smrg# This section contains definitions for functions that each ensure a 468edce3322Smrg# particular resource (a file, or a non-empty configuration variable for 469edce3322Smrg# example) is available, and if appropriate to extract default values 470edce3322Smrg# from pertinent package files. Call them using their associated 471edce3322Smrg# 'require_*' variable to ensure that they are executed, at most, once. 472edce3322Smrg# 473edce3322Smrg# It's entirely deliberate that calling these functions can set 474edce3322Smrg# variables that don't obey the namespace limitations obeyed by the rest 475edce3322Smrg# of this file, in order that that they be as useful as possible to 476edce3322Smrg# callers. 4776e7d3316Smrg 4786e7d3316Smrg 479edce3322Smrg# require_term_colors 480edce3322Smrg# ------------------- 481edce3322Smrg# Allow display of bold text on terminals that support it. 482edce3322Smrgrequire_term_colors=func_require_term_colors 483edce3322Smrgfunc_require_term_colors () 4846e7d3316Smrg{ 485edce3322Smrg $debug_cmd 486edce3322Smrg 487edce3322Smrg test -t 1 && { 488edce3322Smrg # COLORTERM and USE_ANSI_COLORS environment variables take 489edce3322Smrg # precedence, because most terminfo databases neglect to describe 490edce3322Smrg # whether color sequences are supported. 491edce3322Smrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492edce3322Smrg 493edce3322Smrg if test 1 = "$USE_ANSI_COLORS"; then 494edce3322Smrg # Standard ANSI escape sequences 495edce3322Smrg tc_reset='[0m' 496edce3322Smrg tc_bold='[1m'; tc_standout='[7m' 497edce3322Smrg tc_red='[31m'; tc_green='[32m' 498edce3322Smrg tc_blue='[34m'; tc_cyan='[36m' 499edce3322Smrg else 500edce3322Smrg # Otherwise trust the terminfo database after all. 501edce3322Smrg test -n "`tput sgr0 2>/dev/null`" && { 502edce3322Smrg tc_reset=`tput sgr0` 503edce3322Smrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504edce3322Smrg tc_standout=$tc_bold 505edce3322Smrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506edce3322Smrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507edce3322Smrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508edce3322Smrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509edce3322Smrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510edce3322Smrg } 511edce3322Smrg fi 512edce3322Smrg } 5136e7d3316Smrg 514edce3322Smrg require_term_colors=: 5156e7d3316Smrg} 5166e7d3316Smrg 5176e7d3316Smrg 518edce3322Smrg## ----------------- ## 519edce3322Smrg## Function library. ## 520edce3322Smrg## ----------------- ## 521edce3322Smrg 522edce3322Smrg# This section contains a variety of useful functions to call in your 523edce3322Smrg# scripts. Take note of the portable wrappers for features provided by 524edce3322Smrg# some modern shells, which will fall back to slower equivalents on 525edce3322Smrg# less featureful shells. 526edce3322Smrg 527edce3322Smrg 528edce3322Smrg# func_append VAR VALUE 529edce3322Smrg# --------------------- 530edce3322Smrg# Append VALUE onto the existing contents of VAR. 531edce3322Smrg 532edce3322Smrg # We should try to minimise forks, especially on Windows where they are 533edce3322Smrg # unreasonably slow, so skip the feature probes when bash or zsh are 534edce3322Smrg # being used: 535edce3322Smrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536edce3322Smrg : ${_G_HAVE_ARITH_OP="yes"} 537edce3322Smrg : ${_G_HAVE_XSI_OPS="yes"} 538edce3322Smrg # The += operator was introduced in bash 3.1 539edce3322Smrg case $BASH_VERSION in 540edce3322Smrg [12].* | 3.0 | 3.0*) ;; 541edce3322Smrg *) 542edce3322Smrg : ${_G_HAVE_PLUSEQ_OP="yes"} 543edce3322Smrg ;; 544edce3322Smrg esac 545edce3322Smrg fi 546edce3322Smrg 547edce3322Smrg # _G_HAVE_PLUSEQ_OP 548edce3322Smrg # Can be empty, in which case the shell is probed, "yes" if += is 549edce3322Smrg # useable or anything else if it does not work. 550edce3322Smrg test -z "$_G_HAVE_PLUSEQ_OP" \ 551edce3322Smrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552edce3322Smrg && _G_HAVE_PLUSEQ_OP=yes 553edce3322Smrg 554edce3322Smrgif test yes = "$_G_HAVE_PLUSEQ_OP" 555edce3322Smrgthen 556edce3322Smrg # This is an XSI compatible shell, allowing a faster implementation... 557edce3322Smrg eval 'func_append () 558edce3322Smrg { 559edce3322Smrg $debug_cmd 560edce3322Smrg 561edce3322Smrg eval "$1+=\$2" 562edce3322Smrg }' 563edce3322Smrgelse 564edce3322Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 565edce3322Smrg func_append () 566edce3322Smrg { 567edce3322Smrg $debug_cmd 568edce3322Smrg 569edce3322Smrg eval "$1=\$$1\$2" 570edce3322Smrg } 571edce3322Smrgfi 572edce3322Smrg 573edce3322Smrg 574edce3322Smrg# func_append_quoted VAR VALUE 575edce3322Smrg# ---------------------------- 576edce3322Smrg# Quote VALUE and append to the end of shell variable VAR, separated 577edce3322Smrg# by a space. 578edce3322Smrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579edce3322Smrg eval 'func_append_quoted () 580edce3322Smrg { 581edce3322Smrg $debug_cmd 582edce3322Smrg 5831c235774Smrg func_quote_for_eval "$2" 5841c235774Smrg eval "$1+=\\ \$func_quote_for_eval_result" 585edce3322Smrg }' 586edce3322Smrgelse 587edce3322Smrg func_append_quoted () 588edce3322Smrg { 589edce3322Smrg $debug_cmd 590edce3322Smrg 5911c235774Smrg func_quote_for_eval "$2" 5921c235774Smrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 593edce3322Smrg } 594edce3322Smrgfi 595edce3322Smrg 596edce3322Smrg 597edce3322Smrg# func_append_uniq VAR VALUE 598edce3322Smrg# -------------------------- 599edce3322Smrg# Append unique VALUE onto the existing contents of VAR, assuming 600edce3322Smrg# entries are delimited by the first character of VALUE. For example: 601edce3322Smrg# 602edce3322Smrg# func_append_uniq options " --another-option option-argument" 603edce3322Smrg# 604edce3322Smrg# will only append to $options if " --another-option option-argument " 605edce3322Smrg# is not already present somewhere in $options already (note spaces at 606edce3322Smrg# each end implied by leading space in second argument). 607edce3322Smrgfunc_append_uniq () 608edce3322Smrg{ 609edce3322Smrg $debug_cmd 610edce3322Smrg 611edce3322Smrg eval _G_current_value='`$ECHO $'$1'`' 612edce3322Smrg _G_delim=`expr "$2" : '\(.\)'` 613edce3322Smrg 614edce3322Smrg case $_G_delim$_G_current_value$_G_delim in 615edce3322Smrg *"$2$_G_delim"*) ;; 616edce3322Smrg *) func_append "$@" ;; 617edce3322Smrg esac 618edce3322Smrg} 619edce3322Smrg 620edce3322Smrg 621edce3322Smrg# func_arith TERM... 622edce3322Smrg# ------------------ 623edce3322Smrg# Set func_arith_result to the result of evaluating TERMs. 624edce3322Smrg test -z "$_G_HAVE_ARITH_OP" \ 625edce3322Smrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626edce3322Smrg && _G_HAVE_ARITH_OP=yes 627edce3322Smrg 628edce3322Smrgif test yes = "$_G_HAVE_ARITH_OP"; then 629edce3322Smrg eval 'func_arith () 630edce3322Smrg { 631edce3322Smrg $debug_cmd 632edce3322Smrg 633edce3322Smrg func_arith_result=$(( $* )) 634edce3322Smrg }' 635edce3322Smrgelse 636edce3322Smrg func_arith () 637edce3322Smrg { 638edce3322Smrg $debug_cmd 639edce3322Smrg 640edce3322Smrg func_arith_result=`expr "$@"` 641edce3322Smrg } 642edce3322Smrgfi 643edce3322Smrg 644edce3322Smrg 645edce3322Smrg# func_basename FILE 646edce3322Smrg# ------------------ 647edce3322Smrg# Set func_basename_result to FILE with everything up to and including 648edce3322Smrg# the last / stripped. 649edce3322Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 650edce3322Smrg # If this shell supports suffix pattern removal, then use it to avoid 651edce3322Smrg # forking. Hide the definitions single quotes in case the shell chokes 652edce3322Smrg # on unsupported syntax... 653edce3322Smrg _b='func_basename_result=${1##*/}' 654edce3322Smrg _d='case $1 in 655edce3322Smrg */*) func_dirname_result=${1%/*}$2 ;; 656edce3322Smrg * ) func_dirname_result=$3 ;; 657edce3322Smrg esac' 658edce3322Smrg 659edce3322Smrgelse 660edce3322Smrg # ...otherwise fall back to using sed. 661edce3322Smrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662edce3322Smrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663edce3322Smrg if test "X$func_dirname_result" = "X$1"; then 664edce3322Smrg func_dirname_result=$3 665edce3322Smrg else 666edce3322Smrg func_append func_dirname_result "$2" 667edce3322Smrg fi' 668edce3322Smrgfi 669edce3322Smrg 670edce3322Smrgeval 'func_basename () 671edce3322Smrg{ 672edce3322Smrg $debug_cmd 673edce3322Smrg 674edce3322Smrg '"$_b"' 675edce3322Smrg}' 676edce3322Smrg 677edce3322Smrg 678edce3322Smrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 679edce3322Smrg# ------------------------------------------- 680edce3322Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681edce3322Smrg# otherwise set result to NONDIR_REPLACEMENT. 682edce3322Smrgeval 'func_dirname () 683edce3322Smrg{ 684edce3322Smrg $debug_cmd 685edce3322Smrg 686edce3322Smrg '"$_d"' 687edce3322Smrg}' 688edce3322Smrg 689edce3322Smrg 690edce3322Smrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691edce3322Smrg# -------------------------------------------------------- 692edce3322Smrg# Perform func_basename and func_dirname in a single function 693edce3322Smrg# call: 694edce3322Smrg# dirname: Compute the dirname of FILE. If nonempty, 695edce3322Smrg# add APPEND to the result, otherwise set result 696edce3322Smrg# to NONDIR_REPLACEMENT. 697edce3322Smrg# value returned in "$func_dirname_result" 698edce3322Smrg# basename: Compute filename of FILE. 699edce3322Smrg# value retuned in "$func_basename_result" 700edce3322Smrg# For efficiency, we do not delegate to the functions above but instead 701edce3322Smrg# duplicate the functionality here. 702edce3322Smrgeval 'func_dirname_and_basename () 703edce3322Smrg{ 704edce3322Smrg $debug_cmd 705edce3322Smrg 706edce3322Smrg '"$_b"' 707edce3322Smrg '"$_d"' 708edce3322Smrg}' 709edce3322Smrg 710edce3322Smrg 711edce3322Smrg# func_echo ARG... 712edce3322Smrg# ---------------- 713edce3322Smrg# Echo program name prefixed message. 714edce3322Smrgfunc_echo () 715edce3322Smrg{ 716edce3322Smrg $debug_cmd 717edce3322Smrg 718edce3322Smrg _G_message=$* 719edce3322Smrg 720edce3322Smrg func_echo_IFS=$IFS 721edce3322Smrg IFS=$nl 722edce3322Smrg for _G_line in $_G_message; do 723edce3322Smrg IFS=$func_echo_IFS 724edce3322Smrg $ECHO "$progname: $_G_line" 725edce3322Smrg done 726edce3322Smrg IFS=$func_echo_IFS 727edce3322Smrg} 728edce3322Smrg 729edce3322Smrg 730edce3322Smrg# func_echo_all ARG... 731edce3322Smrg# -------------------- 732edce3322Smrg# Invoke $ECHO with all args, space-separated. 733edce3322Smrgfunc_echo_all () 734edce3322Smrg{ 735edce3322Smrg $ECHO "$*" 736edce3322Smrg} 737edce3322Smrg 738edce3322Smrg 739edce3322Smrg# func_echo_infix_1 INFIX ARG... 740edce3322Smrg# ------------------------------ 741edce3322Smrg# Echo program name, followed by INFIX on the first line, with any 742edce3322Smrg# additional lines not showing INFIX. 743edce3322Smrgfunc_echo_infix_1 () 744edce3322Smrg{ 745edce3322Smrg $debug_cmd 746edce3322Smrg 747edce3322Smrg $require_term_colors 748edce3322Smrg 749edce3322Smrg _G_infix=$1; shift 750edce3322Smrg _G_indent=$_G_infix 751edce3322Smrg _G_prefix="$progname: $_G_infix: " 752edce3322Smrg _G_message=$* 753edce3322Smrg 754edce3322Smrg # Strip color escape sequences before counting printable length 755edce3322Smrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756edce3322Smrg do 757edce3322Smrg test -n "$_G_tc" && { 758edce3322Smrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759edce3322Smrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760edce3322Smrg } 761edce3322Smrg done 762edce3322Smrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763edce3322Smrg 764edce3322Smrg func_echo_infix_1_IFS=$IFS 765edce3322Smrg IFS=$nl 766edce3322Smrg for _G_line in $_G_message; do 767edce3322Smrg IFS=$func_echo_infix_1_IFS 768edce3322Smrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769edce3322Smrg _G_prefix=$_G_indent 770edce3322Smrg done 771edce3322Smrg IFS=$func_echo_infix_1_IFS 772edce3322Smrg} 773edce3322Smrg 774edce3322Smrg 775edce3322Smrg# func_error ARG... 776edce3322Smrg# ----------------- 777edce3322Smrg# Echo program name prefixed message to standard error. 778edce3322Smrgfunc_error () 779edce3322Smrg{ 780edce3322Smrg $debug_cmd 781edce3322Smrg 782edce3322Smrg $require_term_colors 783edce3322Smrg 784edce3322Smrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785edce3322Smrg} 786edce3322Smrg 787edce3322Smrg 788edce3322Smrg# func_fatal_error ARG... 789edce3322Smrg# ----------------------- 790edce3322Smrg# Echo program name prefixed message to standard error, and exit. 791edce3322Smrgfunc_fatal_error () 792edce3322Smrg{ 793edce3322Smrg $debug_cmd 794edce3322Smrg 795edce3322Smrg func_error "$*" 796edce3322Smrg exit $EXIT_FAILURE 797edce3322Smrg} 798edce3322Smrg 799edce3322Smrg 800edce3322Smrg# func_grep EXPRESSION FILENAME 801edce3322Smrg# ----------------------------- 8026e7d3316Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 8036e7d3316Smrgfunc_grep () 8046e7d3316Smrg{ 805edce3322Smrg $debug_cmd 806edce3322Smrg 8076e7d3316Smrg $GREP "$1" "$2" >/dev/null 2>&1 8086e7d3316Smrg} 8096e7d3316Smrg 8106e7d3316Smrg 811edce3322Smrg# func_len STRING 812edce3322Smrg# --------------- 813edce3322Smrg# Set func_len_result to the length of STRING. STRING may not 814edce3322Smrg# start with a hyphen. 815edce3322Smrg test -z "$_G_HAVE_XSI_OPS" \ 816edce3322Smrg && (eval 'x=a/b/c; 817edce3322Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818edce3322Smrg && _G_HAVE_XSI_OPS=yes 819edce3322Smrg 820edce3322Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 821edce3322Smrg eval 'func_len () 822edce3322Smrg { 823edce3322Smrg $debug_cmd 824edce3322Smrg 825edce3322Smrg func_len_result=${#1} 826edce3322Smrg }' 827edce3322Smrgelse 828edce3322Smrg func_len () 829edce3322Smrg { 830edce3322Smrg $debug_cmd 831edce3322Smrg 832edce3322Smrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833edce3322Smrg } 834edce3322Smrgfi 835edce3322Smrg 836edce3322Smrg 837edce3322Smrg# func_mkdir_p DIRECTORY-PATH 838edce3322Smrg# --------------------------- 8396e7d3316Smrg# Make sure the entire path to DIRECTORY-PATH is available. 8406e7d3316Smrgfunc_mkdir_p () 8416e7d3316Smrg{ 842edce3322Smrg $debug_cmd 843edce3322Smrg 844edce3322Smrg _G_directory_path=$1 845edce3322Smrg _G_dir_list= 8466e7d3316Smrg 847edce3322Smrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 8486e7d3316Smrg 849edce3322Smrg # Protect directory names starting with '-' 850edce3322Smrg case $_G_directory_path in 851edce3322Smrg -*) _G_directory_path=./$_G_directory_path ;; 8526e7d3316Smrg esac 8536e7d3316Smrg 8546e7d3316Smrg # While some portion of DIR does not yet exist... 855edce3322Smrg while test ! -d "$_G_directory_path"; do 8566e7d3316Smrg # ...make a list in topmost first order. Use a colon delimited 8576e7d3316Smrg # list incase some portion of path contains whitespace. 858edce3322Smrg _G_dir_list=$_G_directory_path:$_G_dir_list 8596e7d3316Smrg 8606e7d3316Smrg # If the last portion added has no slash in it, the list is done 861edce3322Smrg case $_G_directory_path in */*) ;; *) break ;; esac 8626e7d3316Smrg 8636e7d3316Smrg # ...otherwise throw away the child directory and loop 864edce3322Smrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 8656e7d3316Smrg done 866edce3322Smrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 8676e7d3316Smrg 868edce3322Smrg func_mkdir_p_IFS=$IFS; IFS=: 869edce3322Smrg for _G_dir in $_G_dir_list; do 870edce3322Smrg IFS=$func_mkdir_p_IFS 871edce3322Smrg # mkdir can fail with a 'File exist' error if two processes 8726e7d3316Smrg # try to create one of the directories concurrently. Don't 8736e7d3316Smrg # stop in that case! 874edce3322Smrg $MKDIR "$_G_dir" 2>/dev/null || : 8756e7d3316Smrg done 876edce3322Smrg IFS=$func_mkdir_p_IFS 8776e7d3316Smrg 8786e7d3316Smrg # Bail out if we (or some other process) failed to create a directory. 879edce3322Smrg test -d "$_G_directory_path" || \ 880edce3322Smrg func_fatal_error "Failed to create '$1'" 8816e7d3316Smrg fi 8826e7d3316Smrg} 883a966c04fSmrg 884a966c04fSmrg 885edce3322Smrg# func_mktempdir [BASENAME] 886edce3322Smrg# ------------------------- 887a966c04fSmrg# Make a temporary directory that won't clash with other running 888a966c04fSmrg# libtool processes, and avoids race conditions if possible. If 889edce3322Smrg# given, BASENAME is the basename for that directory. 890a966c04fSmrgfunc_mktempdir () 891a966c04fSmrg{ 892edce3322Smrg $debug_cmd 893edce3322Smrg 894edce3322Smrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895a966c04fSmrg 896edce3322Smrg if test : = "$opt_dry_run"; then 897a966c04fSmrg # Return a directory name, but don't create it in dry-run mode 898edce3322Smrg _G_tmpdir=$_G_template-$$ 899a966c04fSmrg else 900a966c04fSmrg 901a966c04fSmrg # If mktemp works, use that first and foremost 902edce3322Smrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903a966c04fSmrg 904edce3322Smrg if test ! -d "$_G_tmpdir"; then 9056e7d3316Smrg # Failing that, at least try and use $RANDOM to avoid a race 906edce3322Smrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907a966c04fSmrg 908edce3322Smrg func_mktempdir_umask=`umask` 9096e7d3316Smrg umask 0077 910edce3322Smrg $MKDIR "$_G_tmpdir" 911edce3322Smrg umask $func_mktempdir_umask 912a966c04fSmrg fi 913a966c04fSmrg 914a966c04fSmrg # If we're not in dry-run mode, bomb out on failure 915edce3322Smrg test -d "$_G_tmpdir" || \ 916edce3322Smrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917a966c04fSmrg fi 918a966c04fSmrg 919edce3322Smrg $ECHO "$_G_tmpdir" 920a966c04fSmrg} 921a966c04fSmrg 922a966c04fSmrg 923edce3322Smrg# func_normal_abspath PATH 924edce3322Smrg# ------------------------ 925edce3322Smrg# Remove doubled-up and trailing slashes, "." path components, 926edce3322Smrg# and cancel out any ".." path components in PATH after making 927edce3322Smrg# it an absolute path. 928edce3322Smrgfunc_normal_abspath () 929a966c04fSmrg{ 930edce3322Smrg $debug_cmd 9316e7d3316Smrg 932edce3322Smrg # These SED scripts presuppose an absolute path with a trailing slash. 933edce3322Smrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 934edce3322Smrg _G_pathcdr='s|^/[^/]*||' 935edce3322Smrg _G_removedotparts=':dotsl 936edce3322Smrg s|/\./|/|g 937edce3322Smrg t dotsl 938edce3322Smrg s|/\.$|/|' 939edce3322Smrg _G_collapseslashes='s|/\{1,\}|/|g' 940edce3322Smrg _G_finalslash='s|/*$|/|' 941edce3322Smrg 942edce3322Smrg # Start from root dir and reassemble the path. 943edce3322Smrg func_normal_abspath_result= 944edce3322Smrg func_normal_abspath_tpath=$1 945edce3322Smrg func_normal_abspath_altnamespace= 946edce3322Smrg case $func_normal_abspath_tpath in 947edce3322Smrg "") 948edce3322Smrg # Empty path, that just means $cwd. 949edce3322Smrg func_stripname '' '/' "`pwd`" 950edce3322Smrg func_normal_abspath_result=$func_stripname_result 951edce3322Smrg return 952edce3322Smrg ;; 953edce3322Smrg # The next three entries are used to spot a run of precisely 954edce3322Smrg # two leading slashes without using negated character classes; 955edce3322Smrg # we take advantage of case's first-match behaviour. 956edce3322Smrg ///*) 957edce3322Smrg # Unusual form of absolute path, do nothing. 958edce3322Smrg ;; 959edce3322Smrg //*) 960edce3322Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 961edce3322Smrg # and for example Cygwin uses it to access remote file shares 962edce3322Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 963edce3322Smrg func_normal_abspath_altnamespace=/ 964edce3322Smrg ;; 965edce3322Smrg /*) 966edce3322Smrg # Absolute path, do nothing. 9676e7d3316Smrg ;; 9686e7d3316Smrg *) 969edce3322Smrg # Relative path, prepend $cwd. 970edce3322Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971edce3322Smrg ;; 972a966c04fSmrg esac 973edce3322Smrg 974edce3322Smrg # Cancel out all the simple stuff to save iterations. We also want 975edce3322Smrg # the path to end with a slash for ease of parsing, so make sure 976edce3322Smrg # there is one (and only one) here. 977edce3322Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978edce3322Smrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979edce3322Smrg while :; do 980edce3322Smrg # Processed it all yet? 981edce3322Smrg if test / = "$func_normal_abspath_tpath"; then 982edce3322Smrg # If we ascended to the root using ".." the result may be empty now. 983edce3322Smrg if test -z "$func_normal_abspath_result"; then 984edce3322Smrg func_normal_abspath_result=/ 985edce3322Smrg fi 986edce3322Smrg break 987edce3322Smrg fi 988edce3322Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989edce3322Smrg -e "$_G_pathcar"` 990edce3322Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991edce3322Smrg -e "$_G_pathcdr"` 992edce3322Smrg # Figure out what to do with it 993edce3322Smrg case $func_normal_abspath_tcomponent in 994edce3322Smrg "") 995edce3322Smrg # Trailing empty path component, ignore it. 996edce3322Smrg ;; 997edce3322Smrg ..) 998edce3322Smrg # Parent dir; strip last assembled component from result. 999edce3322Smrg func_dirname "$func_normal_abspath_result" 1000edce3322Smrg func_normal_abspath_result=$func_dirname_result 1001edce3322Smrg ;; 1002edce3322Smrg *) 1003edce3322Smrg # Actual path component, append it. 1004edce3322Smrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005edce3322Smrg ;; 1006edce3322Smrg esac 1007edce3322Smrg done 1008edce3322Smrg # Restore leading double-slash if one was found on entry. 1009edce3322Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010edce3322Smrg} 1011edce3322Smrg 1012edce3322Smrg 1013edce3322Smrg# func_notquiet ARG... 1014edce3322Smrg# -------------------- 1015edce3322Smrg# Echo program name prefixed message only when not in quiet mode. 1016edce3322Smrgfunc_notquiet () 1017edce3322Smrg{ 1018edce3322Smrg $debug_cmd 1019edce3322Smrg 1020edce3322Smrg $opt_quiet || func_echo ${1+"$@"} 1021edce3322Smrg 1022edce3322Smrg # A bug in bash halts the script if the last line of a function 1023edce3322Smrg # fails when set -e is in force, so we need another command to 1024edce3322Smrg # work around that: 1025edce3322Smrg : 1026edce3322Smrg} 1027edce3322Smrg 1028edce3322Smrg 1029edce3322Smrg# func_relative_path SRCDIR DSTDIR 1030edce3322Smrg# -------------------------------- 1031edce3322Smrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032edce3322Smrgfunc_relative_path () 1033edce3322Smrg{ 1034edce3322Smrg $debug_cmd 1035edce3322Smrg 1036edce3322Smrg func_relative_path_result= 1037edce3322Smrg func_normal_abspath "$1" 1038edce3322Smrg func_relative_path_tlibdir=$func_normal_abspath_result 1039edce3322Smrg func_normal_abspath "$2" 1040edce3322Smrg func_relative_path_tbindir=$func_normal_abspath_result 1041edce3322Smrg 1042edce3322Smrg # Ascend the tree starting from libdir 1043edce3322Smrg while :; do 1044edce3322Smrg # check if we have found a prefix of bindir 1045edce3322Smrg case $func_relative_path_tbindir in 1046edce3322Smrg $func_relative_path_tlibdir) 1047edce3322Smrg # found an exact match 1048edce3322Smrg func_relative_path_tcancelled= 1049edce3322Smrg break 1050edce3322Smrg ;; 1051edce3322Smrg $func_relative_path_tlibdir*) 1052edce3322Smrg # found a matching prefix 1053edce3322Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054edce3322Smrg func_relative_path_tcancelled=$func_stripname_result 1055edce3322Smrg if test -z "$func_relative_path_result"; then 1056edce3322Smrg func_relative_path_result=. 1057edce3322Smrg fi 1058edce3322Smrg break 1059edce3322Smrg ;; 1060edce3322Smrg *) 1061edce3322Smrg func_dirname $func_relative_path_tlibdir 1062edce3322Smrg func_relative_path_tlibdir=$func_dirname_result 1063edce3322Smrg if test -z "$func_relative_path_tlibdir"; then 1064edce3322Smrg # Have to descend all the way to the root! 1065edce3322Smrg func_relative_path_result=../$func_relative_path_result 1066edce3322Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 1067edce3322Smrg break 1068edce3322Smrg fi 1069edce3322Smrg func_relative_path_result=../$func_relative_path_result 1070edce3322Smrg ;; 1071edce3322Smrg esac 1072edce3322Smrg done 1073edce3322Smrg 1074edce3322Smrg # Now calculate path; take care to avoid doubling-up slashes. 1075edce3322Smrg func_stripname '' '/' "$func_relative_path_result" 1076edce3322Smrg func_relative_path_result=$func_stripname_result 1077edce3322Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1078edce3322Smrg if test -n "$func_stripname_result"; then 1079edce3322Smrg func_append func_relative_path_result "/$func_stripname_result" 1080edce3322Smrg fi 1081edce3322Smrg 1082edce3322Smrg # Normalisation. If bindir is libdir, return '.' else relative path. 1083edce3322Smrg if test -n "$func_relative_path_result"; then 1084edce3322Smrg func_stripname './' '' "$func_relative_path_result" 1085edce3322Smrg func_relative_path_result=$func_stripname_result 1086edce3322Smrg fi 1087edce3322Smrg 1088edce3322Smrg test -n "$func_relative_path_result" || func_relative_path_result=. 1089edce3322Smrg 1090edce3322Smrg : 1091a966c04fSmrg} 1092a966c04fSmrg 1093a966c04fSmrg 10941c235774Smrg# func_quote_for_eval ARG... 10951c235774Smrg# -------------------------- 10961c235774Smrg# Aesthetically quote ARGs to be evaled later. 10971c235774Smrg# This function returns two values: 10981c235774Smrg# i) func_quote_for_eval_result 10991c235774Smrg# double-quoted, suitable for a subsequent eval 11001c235774Smrg# ii) func_quote_for_eval_unquoted_result 11011c235774Smrg# has all characters that are still active within double 11021c235774Smrg# quotes backslashified. 11031c235774Smrgfunc_quote_for_eval () 1104edce3322Smrg{ 1105edce3322Smrg $debug_cmd 1106edce3322Smrg 11071c235774Smrg func_quote_for_eval_unquoted_result= 11081c235774Smrg func_quote_for_eval_result= 11091c235774Smrg while test 0 -lt $#; do 11101c235774Smrg case $1 in 111119569120Smrg *[\\\`\"\$]*) 11121c235774Smrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 11131c235774Smrg *) 11141c235774Smrg _G_unquoted_arg=$1 ;; 11151c235774Smrg esac 11161c235774Smrg if test -n "$func_quote_for_eval_unquoted_result"; then 11171c235774Smrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 11181c235774Smrg else 11191c235774Smrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 11201c235774Smrg fi 112119569120Smrg 11221c235774Smrg case $_G_unquoted_arg in 11231c235774Smrg # Double-quote args containing shell metacharacters to delay 11241c235774Smrg # word splitting, command substitution and variable expansion 11251c235774Smrg # for a subsequent eval. 11261c235774Smrg # Many Bourne shells cannot handle close brackets correctly 11271c235774Smrg # in scan sets, so we specify it separately. 11281c235774Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 11291c235774Smrg _G_quoted_arg=\"$_G_unquoted_arg\" 1130edce3322Smrg ;; 11311c235774Smrg *) 11321c235774Smrg _G_quoted_arg=$_G_unquoted_arg 11331c235774Smrg ;; 1134edce3322Smrg esac 113519569120Smrg 11361c235774Smrg if test -n "$func_quote_for_eval_result"; then 11371c235774Smrg func_append func_quote_for_eval_result " $_G_quoted_arg" 11381c235774Smrg else 11391c235774Smrg func_append func_quote_for_eval_result "$_G_quoted_arg" 11401c235774Smrg fi 11411c235774Smrg shift 11421c235774Smrg done 1143edce3322Smrg} 1144edce3322Smrg 1145edce3322Smrg 11461c235774Smrg# func_quote_for_expand ARG 11471c235774Smrg# ------------------------- 11481c235774Smrg# Aesthetically quote ARG to be evaled later; same as above, 11491c235774Smrg# but do not quote variable references. 11501c235774Smrgfunc_quote_for_expand () 11511c235774Smrg{ 11521c235774Smrg $debug_cmd 115319569120Smrg 11541c235774Smrg case $1 in 11551c235774Smrg *[\\\`\"]*) 11561c235774Smrg _G_arg=`$ECHO "$1" | $SED \ 11571c235774Smrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 11581c235774Smrg *) 11591c235774Smrg _G_arg=$1 ;; 11606e7d3316Smrg esac 11616e7d3316Smrg 11621c235774Smrg case $_G_arg in 11631c235774Smrg # Double-quote args containing shell metacharacters to delay 11641c235774Smrg # word splitting and command substitution for a subsequent eval. 11651c235774Smrg # Many Bourne shells cannot handle close brackets correctly 11661c235774Smrg # in scan sets, so we specify it separately. 11671c235774Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 11681c235774Smrg _G_arg=\"$_G_arg\" 11696e7d3316Smrg ;; 11706e7d3316Smrg esac 11716e7d3316Smrg 11721c235774Smrg func_quote_for_expand_result=$_G_arg 1173edce3322Smrg} 1174edce3322Smrg 1175edce3322Smrg 1176edce3322Smrg# func_stripname PREFIX SUFFIX NAME 1177edce3322Smrg# --------------------------------- 1178edce3322Smrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179edce3322Smrg# PREFIX and SUFFIX must not contain globbing or regex special 1180edce3322Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1181edce3322Smrg# dot (in which case that matches only a dot). 1182edce3322Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 1183edce3322Smrg eval 'func_stripname () 1184edce3322Smrg { 1185edce3322Smrg $debug_cmd 1186edce3322Smrg 1187edce3322Smrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188edce3322Smrg # positional parameters, so assign one to ordinary variable first. 1189edce3322Smrg func_stripname_result=$3 1190edce3322Smrg func_stripname_result=${func_stripname_result#"$1"} 1191edce3322Smrg func_stripname_result=${func_stripname_result%"$2"} 1192edce3322Smrg }' 1193edce3322Smrgelse 1194edce3322Smrg func_stripname () 1195edce3322Smrg { 1196edce3322Smrg $debug_cmd 1197edce3322Smrg 1198edce3322Smrg case $2 in 1199edce3322Smrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200edce3322Smrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201edce3322Smrg esac 1202edce3322Smrg } 1203edce3322Smrgfi 1204edce3322Smrg 1205edce3322Smrg 1206edce3322Smrg# func_show_eval CMD [FAIL_EXP] 1207edce3322Smrg# ----------------------------- 1208edce3322Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209edce3322Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210edce3322Smrg# is given, then evaluate it. 1211edce3322Smrgfunc_show_eval () 1212edce3322Smrg{ 1213edce3322Smrg $debug_cmd 1214edce3322Smrg 1215edce3322Smrg _G_cmd=$1 1216edce3322Smrg _G_fail_exp=${2-':'} 1217edce3322Smrg 12181c235774Smrg func_quote_for_expand "$_G_cmd" 12191c235774Smrg eval "func_notquiet $func_quote_for_expand_result" 1220edce3322Smrg 1221edce3322Smrg $opt_dry_run || { 1222edce3322Smrg eval "$_G_cmd" 1223edce3322Smrg _G_status=$? 1224edce3322Smrg if test 0 -ne "$_G_status"; then 1225edce3322Smrg eval "(exit $_G_status); $_G_fail_exp" 1226edce3322Smrg fi 1227edce3322Smrg } 1228edce3322Smrg} 1229edce3322Smrg 1230edce3322Smrg 1231edce3322Smrg# func_show_eval_locale CMD [FAIL_EXP] 1232edce3322Smrg# ------------------------------------ 1233edce3322Smrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234edce3322Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235edce3322Smrg# is given, then evaluate it. Use the saved locale for evaluation. 1236edce3322Smrgfunc_show_eval_locale () 1237edce3322Smrg{ 1238edce3322Smrg $debug_cmd 1239edce3322Smrg 1240edce3322Smrg _G_cmd=$1 1241edce3322Smrg _G_fail_exp=${2-':'} 1242edce3322Smrg 1243edce3322Smrg $opt_quiet || { 12441c235774Smrg func_quote_for_expand "$_G_cmd" 12451c235774Smrg eval "func_echo $func_quote_for_expand_result" 1246edce3322Smrg } 1247edce3322Smrg 1248edce3322Smrg $opt_dry_run || { 1249edce3322Smrg eval "$_G_user_locale 1250edce3322Smrg $_G_cmd" 1251edce3322Smrg _G_status=$? 1252edce3322Smrg eval "$_G_safe_locale" 1253edce3322Smrg if test 0 -ne "$_G_status"; then 1254edce3322Smrg eval "(exit $_G_status); $_G_fail_exp" 1255edce3322Smrg fi 1256edce3322Smrg } 1257edce3322Smrg} 1258edce3322Smrg 1259edce3322Smrg 1260edce3322Smrg# func_tr_sh 1261edce3322Smrg# ---------- 1262edce3322Smrg# Turn $1 into a string suitable for a shell variable name. 1263edce3322Smrg# Result is stored in $func_tr_sh_result. All characters 1264edce3322Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265edce3322Smrg# if $1 begins with a digit, a '_' is prepended as well. 1266edce3322Smrgfunc_tr_sh () 1267edce3322Smrg{ 1268edce3322Smrg $debug_cmd 1269edce3322Smrg 1270edce3322Smrg case $1 in 1271edce3322Smrg [0-9]* | *[!a-zA-Z0-9_]*) 1272edce3322Smrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273edce3322Smrg ;; 1274edce3322Smrg * ) 1275edce3322Smrg func_tr_sh_result=$1 1276edce3322Smrg ;; 1277edce3322Smrg esac 1278edce3322Smrg} 1279edce3322Smrg 1280edce3322Smrg 1281edce3322Smrg# func_verbose ARG... 1282edce3322Smrg# ------------------- 1283edce3322Smrg# Echo program name prefixed message in verbose mode only. 1284edce3322Smrgfunc_verbose () 1285edce3322Smrg{ 1286edce3322Smrg $debug_cmd 1287edce3322Smrg 1288edce3322Smrg $opt_verbose && func_echo "$*" 1289edce3322Smrg 1290edce3322Smrg : 1291edce3322Smrg} 1292edce3322Smrg 1293edce3322Smrg 1294edce3322Smrg# func_warn_and_continue ARG... 1295edce3322Smrg# ----------------------------- 1296edce3322Smrg# Echo program name prefixed warning message to standard error. 1297edce3322Smrgfunc_warn_and_continue () 1298edce3322Smrg{ 1299edce3322Smrg $debug_cmd 1300edce3322Smrg 1301edce3322Smrg $require_term_colors 1302edce3322Smrg 1303edce3322Smrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304edce3322Smrg} 1305edce3322Smrg 1306edce3322Smrg 1307edce3322Smrg# func_warning CATEGORY ARG... 1308edce3322Smrg# ---------------------------- 1309edce3322Smrg# Echo program name prefixed warning message to standard error. Warning 1310edce3322Smrg# messages can be filtered according to CATEGORY, where this function 1311edce3322Smrg# elides messages where CATEGORY is not listed in the global variable 1312edce3322Smrg# 'opt_warning_types'. 1313edce3322Smrgfunc_warning () 1314edce3322Smrg{ 1315edce3322Smrg $debug_cmd 1316edce3322Smrg 1317edce3322Smrg # CATEGORY must be in the warning_categories list! 1318edce3322Smrg case " $warning_categories " in 1319edce3322Smrg *" $1 "*) ;; 1320edce3322Smrg *) func_internal_error "invalid warning category '$1'" ;; 1321edce3322Smrg esac 1322edce3322Smrg 1323edce3322Smrg _G_category=$1 1324edce3322Smrg shift 1325edce3322Smrg 1326edce3322Smrg case " $opt_warning_types " in 1327edce3322Smrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328edce3322Smrg esac 1329a966c04fSmrg} 1330a966c04fSmrg 1331a966c04fSmrg 1332edce3322Smrg# func_sort_ver VER1 VER2 1333edce3322Smrg# ----------------------- 1334edce3322Smrg# 'sort -V' is not generally available. 1335edce3322Smrg# Note this deviates from the version comparison in automake 1336edce3322Smrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337edce3322Smrg# but this should suffice as we won't be specifying old 1338edce3322Smrg# version formats or redundant trailing .0 in bootstrap.conf. 1339edce3322Smrg# If we did want full compatibility then we should probably 1340edce3322Smrg# use m4_version_compare from autoconf. 1341edce3322Smrgfunc_sort_ver () 1342edce3322Smrg{ 1343edce3322Smrg $debug_cmd 1344edce3322Smrg 1345edce3322Smrg printf '%s\n%s\n' "$1" "$2" \ 1346edce3322Smrg | 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 1347edce3322Smrg} 1348edce3322Smrg 1349edce3322Smrg# func_lt_ver PREV CURR 1350edce3322Smrg# --------------------- 1351edce3322Smrg# Return true if PREV and CURR are in the correct order according to 1352edce3322Smrg# func_sort_ver, otherwise false. Use it like this: 1353edce3322Smrg# 1354edce3322Smrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355edce3322Smrgfunc_lt_ver () 1356edce3322Smrg{ 1357edce3322Smrg $debug_cmd 1358edce3322Smrg 1359edce3322Smrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360edce3322Smrg} 1361edce3322Smrg 1362edce3322Smrg 1363edce3322Smrg# Local variables: 1364edce3322Smrg# mode: shell-script 1365edce3322Smrg# sh-indentation: 2 1366edce3322Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 1367edce3322Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368edce3322Smrg# time-stamp-time-zone: "UTC" 1369edce3322Smrg# End: 1370edce3322Smrg#! /bin/sh 1371edce3322Smrg 13721c235774Smrg# Set a version string for this script. 13731c235774Smrgscriptversion=2014-01-07.03; # UTC 13741c235774Smrg 1375edce3322Smrg# A portable, pluggable option parser for Bourne shell. 1376edce3322Smrg# Written by Gary V. Vaughan, 2010 1377edce3322Smrg 13781c235774Smrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 13791c235774Smrg# This is free software; see the source for copying conditions. There is NO 13801c235774Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381edce3322Smrg 13821c235774Smrg# This program is free software: you can redistribute it and/or modify 13831c235774Smrg# it under the terms of the GNU General Public License as published by 13841c235774Smrg# the Free Software Foundation, either version 3 of the License, or 13851c235774Smrg# (at your option) any later version. 1386edce3322Smrg 13871c235774Smrg# This program is distributed in the hope that it will be useful, 13881c235774Smrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 13891c235774Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13901c235774Smrg# GNU General Public License for more details. 13911c235774Smrg 13921c235774Smrg# You should have received a copy of the GNU General Public License 13931c235774Smrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 13941c235774Smrg 13951c235774Smrg# Please report bugs or propose patches to gary@gnu.org. 1396edce3322Smrg 1397edce3322Smrg 1398edce3322Smrg## ------ ## 1399edce3322Smrg## Usage. ## 1400edce3322Smrg## ------ ## 1401edce3322Smrg 1402edce3322Smrg# This file is a library for parsing options in your shell scripts along 1403edce3322Smrg# with assorted other useful supporting features that you can make use 1404edce3322Smrg# of too. 1405edce3322Smrg# 1406edce3322Smrg# For the simplest scripts you might need only: 1407edce3322Smrg# 1408edce3322Smrg# #!/bin/sh 1409edce3322Smrg# . relative/path/to/funclib.sh 1410edce3322Smrg# . relative/path/to/options-parser 1411edce3322Smrg# scriptversion=1.0 1412edce3322Smrg# func_options ${1+"$@"} 1413edce3322Smrg# eval set dummy "$func_options_result"; shift 1414edce3322Smrg# ...rest of your script... 1415edce3322Smrg# 1416edce3322Smrg# In order for the '--version' option to work, you will need to have a 1417edce3322Smrg# suitably formatted comment like the one at the top of this file 14181c235774Smrg# starting with '# Written by ' and ending with '# warranty; '. 1419edce3322Smrg# 1420edce3322Smrg# For '-h' and '--help' to work, you will also need a one line 1421edce3322Smrg# description of your script's purpose in a comment directly above the 1422edce3322Smrg# '# Written by ' line, like the one at the top of this file. 1423edce3322Smrg# 1424edce3322Smrg# The default options also support '--debug', which will turn on shell 1425edce3322Smrg# execution tracing (see the comment above debug_cmd below for another 1426edce3322Smrg# use), and '--verbose' and the func_verbose function to allow your script 1427edce3322Smrg# to display verbose messages only when your user has specified 1428edce3322Smrg# '--verbose'. 1429edce3322Smrg# 14301c235774Smrg# After sourcing this file, you can plug processing for additional 1431edce3322Smrg# options by amending the variables from the 'Configuration' section 1432edce3322Smrg# below, and following the instructions in the 'Option parsing' 1433edce3322Smrg# section further down. 1434edce3322Smrg 1435edce3322Smrg## -------------- ## 1436edce3322Smrg## Configuration. ## 1437edce3322Smrg## -------------- ## 1438edce3322Smrg 1439edce3322Smrg# You should override these variables in your script after sourcing this 1440edce3322Smrg# file so that they reflect the customisations you have added to the 1441edce3322Smrg# option parser. 1442edce3322Smrg 1443edce3322Smrg# The usage line for option parsing errors and the start of '-h' and 1444edce3322Smrg# '--help' output messages. You can embed shell variables for delayed 1445edce3322Smrg# expansion at the time the message is displayed, but you will need to 1446edce3322Smrg# quote other shell meta-characters carefully to prevent them being 1447edce3322Smrg# expanded when the contents are evaled. 1448edce3322Smrgusage='$progpath [OPTION]...' 1449edce3322Smrg 1450edce3322Smrg# Short help message in response to '-h' and '--help'. Add to this or 1451edce3322Smrg# override it after sourcing this library to reflect the full set of 1452edce3322Smrg# options your script accepts. 1453edce3322Smrgusage_message="\ 1454edce3322Smrg --debug enable verbose shell tracing 1455edce3322Smrg -W, --warnings=CATEGORY 1456edce3322Smrg report the warnings falling in CATEGORY [all] 1457edce3322Smrg -v, --verbose verbosely report processing 1458edce3322Smrg --version print version information and exit 1459edce3322Smrg -h, --help print short or long help message and exit 1460edce3322Smrg" 1461edce3322Smrg 1462edce3322Smrg# Additional text appended to 'usage_message' in response to '--help'. 1463edce3322Smrglong_help_message=" 1464edce3322SmrgWarning categories include: 1465edce3322Smrg 'all' show all warnings 1466edce3322Smrg 'none' turn off all the warnings 1467edce3322Smrg 'error' warnings are treated as fatal errors" 1468edce3322Smrg 1469edce3322Smrg# Help message printed before fatal option parsing errors. 1470edce3322Smrgfatal_help="Try '\$progname --help' for more information." 1471edce3322Smrg 1472edce3322Smrg 1473edce3322Smrg 1474edce3322Smrg## ------------------------- ## 1475edce3322Smrg## Hook function management. ## 1476edce3322Smrg## ------------------------- ## 1477edce3322Smrg 1478edce3322Smrg# This section contains functions for adding, removing, and running hooks 14791c235774Smrg# to the main code. A hook is just a named list of of function, that can 14801c235774Smrg# be run in order later on. 1481edce3322Smrg 1482edce3322Smrg# func_hookable FUNC_NAME 1483edce3322Smrg# ----------------------- 1484edce3322Smrg# Declare that FUNC_NAME will run hooks added with 1485edce3322Smrg# 'func_add_hook FUNC_NAME ...'. 1486edce3322Smrgfunc_hookable () 1487edce3322Smrg{ 1488edce3322Smrg $debug_cmd 1489edce3322Smrg 1490edce3322Smrg func_append hookable_fns " $1" 1491edce3322Smrg} 1492edce3322Smrg 1493edce3322Smrg 1494edce3322Smrg# func_add_hook FUNC_NAME HOOK_FUNC 1495edce3322Smrg# --------------------------------- 1496edce3322Smrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497edce3322Smrg# first have been declared "hookable" by a call to 'func_hookable'. 1498edce3322Smrgfunc_add_hook () 1499edce3322Smrg{ 1500edce3322Smrg $debug_cmd 1501edce3322Smrg 1502edce3322Smrg case " $hookable_fns " in 1503edce3322Smrg *" $1 "*) ;; 1504edce3322Smrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1505edce3322Smrg esac 1506edce3322Smrg 1507edce3322Smrg eval func_append ${1}_hooks '" $2"' 1508edce3322Smrg} 1509edce3322Smrg 1510edce3322Smrg 1511edce3322Smrg# func_remove_hook FUNC_NAME HOOK_FUNC 1512edce3322Smrg# ------------------------------------ 15131c235774Smrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514edce3322Smrgfunc_remove_hook () 1515edce3322Smrg{ 1516edce3322Smrg $debug_cmd 1517edce3322Smrg 1518edce3322Smrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519edce3322Smrg} 1520edce3322Smrg 1521edce3322Smrg 1522edce3322Smrg# func_run_hooks FUNC_NAME [ARG]... 1523edce3322Smrg# --------------------------------- 1524edce3322Smrg# Run all hook functions registered to FUNC_NAME. 15251c235774Smrg# It is assumed that the list of hook functions contains nothing more 1526edce3322Smrg# than a whitespace-delimited list of legal shell function names, and 1527edce3322Smrg# no effort is wasted trying to catch shell meta-characters or preserve 1528edce3322Smrg# whitespace. 1529edce3322Smrgfunc_run_hooks () 1530edce3322Smrg{ 1531edce3322Smrg $debug_cmd 1532edce3322Smrg 1533edce3322Smrg case " $hookable_fns " in 1534edce3322Smrg *" $1 "*) ;; 15351c235774Smrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536edce3322Smrg esac 1537edce3322Smrg 1538edce3322Smrg eval _G_hook_fns=\$$1_hooks; shift 1539edce3322Smrg 1540edce3322Smrg for _G_hook in $_G_hook_fns; do 15411c235774Smrg eval $_G_hook '"$@"' 15421c235774Smrg 15431c235774Smrg # store returned options list back into positional 15441c235774Smrg # parameters for next 'cmd' execution. 15451c235774Smrg eval _G_hook_result=\$${_G_hook}_result 15461c235774Smrg eval set dummy "$_G_hook_result"; shift 1547edce3322Smrg done 15481c235774Smrg 15491c235774Smrg func_quote_for_eval ${1+"$@"} 15501c235774Smrg func_run_hooks_result=$func_quote_for_eval_result 1551edce3322Smrg} 1552edce3322Smrg 1553edce3322Smrg 1554edce3322Smrg 1555edce3322Smrg## --------------- ## 1556edce3322Smrg## Option parsing. ## 1557edce3322Smrg## --------------- ## 1558edce3322Smrg 1559edce3322Smrg# In order to add your own option parsing hooks, you must accept the 15601c235774Smrg# full positional parameter list in your hook function, remove any 15611c235774Smrg# options that you action, and then pass back the remaining unprocessed 15621c235774Smrg# options in '<hooked_function_name>_result', escaped suitably for 15631c235774Smrg# 'eval'. Like this: 1564edce3322Smrg# 1565edce3322Smrg# my_options_prep () 1566edce3322Smrg# { 1567edce3322Smrg# $debug_cmd 1568edce3322Smrg# 1569edce3322Smrg# # Extend the existing usage message. 1570edce3322Smrg# usage_message=$usage_message' 1571edce3322Smrg# -s, --silent don'\''t print informational messages 1572edce3322Smrg# ' 15731c235774Smrg# 15741c235774Smrg# func_quote_for_eval ${1+"$@"} 15751c235774Smrg# my_options_prep_result=$func_quote_for_eval_result 1576edce3322Smrg# } 1577edce3322Smrg# func_add_hook func_options_prep my_options_prep 1578edce3322Smrg# 1579edce3322Smrg# 1580edce3322Smrg# my_silent_option () 1581edce3322Smrg# { 1582edce3322Smrg# $debug_cmd 1583edce3322Smrg# 15841c235774Smrg# # Note that for efficiency, we parse as many options as we can 1585edce3322Smrg# # recognise in a loop before passing the remainder back to the 1586edce3322Smrg# # caller on the first unrecognised argument we encounter. 1587edce3322Smrg# while test $# -gt 0; do 1588edce3322Smrg# opt=$1; shift 1589edce3322Smrg# case $opt in 15901c235774Smrg# --silent|-s) opt_silent=: ;; 1591edce3322Smrg# # Separate non-argument short options: 1592edce3322Smrg# -s*) func_split_short_opt "$_G_opt" 1593edce3322Smrg# set dummy "$func_split_short_opt_name" \ 1594edce3322Smrg# "-$func_split_short_opt_arg" ${1+"$@"} 1595edce3322Smrg# shift 1596edce3322Smrg# ;; 15971c235774Smrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598edce3322Smrg# esac 1599edce3322Smrg# done 1600edce3322Smrg# 16011c235774Smrg# func_quote_for_eval ${1+"$@"} 16021c235774Smrg# my_silent_option_result=$func_quote_for_eval_result 1603edce3322Smrg# } 1604edce3322Smrg# func_add_hook func_parse_options my_silent_option 1605edce3322Smrg# 1606edce3322Smrg# 1607edce3322Smrg# my_option_validation () 1608edce3322Smrg# { 1609edce3322Smrg# $debug_cmd 1610edce3322Smrg# 1611edce3322Smrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1612edce3322Smrg# '--silent' and '--verbose' options are mutually exclusive." 16131c235774Smrg# 16141c235774Smrg# func_quote_for_eval ${1+"$@"} 16151c235774Smrg# my_option_validation_result=$func_quote_for_eval_result 1616edce3322Smrg# } 1617edce3322Smrg# func_add_hook func_validate_options my_option_validation 1618edce3322Smrg# 16191c235774Smrg# You'll alse need to manually amend $usage_message to reflect the extra 1620edce3322Smrg# options you parse. It's preferable to append if you can, so that 1621edce3322Smrg# multiple option parsing hooks can be added safely. 1622edce3322Smrg 1623edce3322Smrg 1624edce3322Smrg# func_options [ARG]... 1625edce3322Smrg# --------------------- 1626edce3322Smrg# All the functions called inside func_options are hookable. See the 1627edce3322Smrg# individual implementations for details. 1628edce3322Smrgfunc_hookable func_options 1629edce3322Smrgfunc_options () 1630a966c04fSmrg{ 1631edce3322Smrg $debug_cmd 1632a966c04fSmrg 16331c235774Smrg func_options_prep ${1+"$@"} 16341c235774Smrg eval func_parse_options \ 16351c235774Smrg ${func_options_prep_result+"$func_options_prep_result"} 16361c235774Smrg eval func_validate_options \ 16371c235774Smrg ${func_parse_options_result+"$func_parse_options_result"} 16386e7d3316Smrg 16391c235774Smrg eval func_run_hooks func_options \ 16401c235774Smrg ${func_validate_options_result+"$func_validate_options_result"} 1641edce3322Smrg 16421c235774Smrg # save modified positional parameters for caller 16431c235774Smrg func_options_result=$func_run_hooks_result 1644a966c04fSmrg} 1645a966c04fSmrg 16466e7d3316Smrg 1647edce3322Smrg# func_options_prep [ARG]... 1648edce3322Smrg# -------------------------- 1649edce3322Smrg# All initialisations required before starting the option parse loop. 1650edce3322Smrg# Note that when calling hook functions, we pass through the list of 1651edce3322Smrg# positional parameters. If a hook function modifies that list, and 16521c235774Smrg# needs to propogate that back to rest of this script, then the complete 16531c235774Smrg# modified list must be put in 'func_run_hooks_result' before 16541c235774Smrg# returning. 1655edce3322Smrgfunc_hookable func_options_prep 1656edce3322Smrgfunc_options_prep () 1657a966c04fSmrg{ 1658edce3322Smrg $debug_cmd 1659a966c04fSmrg 1660edce3322Smrg # Option defaults: 1661edce3322Smrg opt_verbose=false 1662edce3322Smrg opt_warning_types= 1663a966c04fSmrg 1664edce3322Smrg func_run_hooks func_options_prep ${1+"$@"} 16651c235774Smrg 16661c235774Smrg # save modified positional parameters for caller 16671c235774Smrg func_options_prep_result=$func_run_hooks_result 1668a966c04fSmrg} 1669a966c04fSmrg 1670edce3322Smrg 1671edce3322Smrg# func_parse_options [ARG]... 1672edce3322Smrg# --------------------------- 1673edce3322Smrg# The main option parsing loop. 1674edce3322Smrgfunc_hookable func_parse_options 1675edce3322Smrgfunc_parse_options () 167697cf2ee2Smrg{ 1677edce3322Smrg $debug_cmd 1678edce3322Smrg 16791c235774Smrg func_parse_options_result= 16801c235774Smrg 1681edce3322Smrg # this just eases exit handling 1682edce3322Smrg while test $# -gt 0; do 1683edce3322Smrg # Defer to hook functions for initial option parsing, so they 1684edce3322Smrg # get priority in the event of reusing an option name. 1685edce3322Smrg func_run_hooks func_parse_options ${1+"$@"} 16861c235774Smrg 16871c235774Smrg # Adjust func_parse_options positional parameters to match 16881c235774Smrg eval set dummy "$func_run_hooks_result"; shift 1689edce3322Smrg 1690edce3322Smrg # Break out of the loop if we already parsed every option. 1691edce3322Smrg test $# -gt 0 || break 1692edce3322Smrg 1693edce3322Smrg _G_opt=$1 1694edce3322Smrg shift 1695edce3322Smrg case $_G_opt in 1696edce3322Smrg --debug|-x) debug_cmd='set -x' 16971c235774Smrg func_echo "enabling shell trace mode" 1698edce3322Smrg $debug_cmd 1699edce3322Smrg ;; 1700edce3322Smrg 1701edce3322Smrg --no-warnings|--no-warning|--no-warn) 1702edce3322Smrg set dummy --warnings none ${1+"$@"} 1703edce3322Smrg shift 1704edce3322Smrg ;; 1705edce3322Smrg 1706edce3322Smrg --warnings|--warning|-W) 17071c235774Smrg test $# = 0 && func_missing_arg $_G_opt && break 1708edce3322Smrg case " $warning_categories $1" in 1709edce3322Smrg *" $1 "*) 1710edce3322Smrg # trailing space prevents matching last $1 above 1711edce3322Smrg func_append_uniq opt_warning_types " $1" 1712edce3322Smrg ;; 1713edce3322Smrg *all) 1714edce3322Smrg opt_warning_types=$warning_categories 1715edce3322Smrg ;; 1716edce3322Smrg *none) 1717edce3322Smrg opt_warning_types=none 1718edce3322Smrg warning_func=: 1719edce3322Smrg ;; 1720edce3322Smrg *error) 1721edce3322Smrg opt_warning_types=$warning_categories 1722edce3322Smrg warning_func=func_fatal_error 1723edce3322Smrg ;; 1724edce3322Smrg *) 1725edce3322Smrg func_fatal_error \ 1726edce3322Smrg "unsupported warning category: '$1'" 1727edce3322Smrg ;; 1728edce3322Smrg esac 1729edce3322Smrg shift 1730edce3322Smrg ;; 1731edce3322Smrg 1732edce3322Smrg --verbose|-v) opt_verbose=: ;; 1733edce3322Smrg --version) func_version ;; 1734edce3322Smrg -\?|-h) func_usage ;; 1735edce3322Smrg --help) func_help ;; 1736edce3322Smrg 1737edce3322Smrg # Separate optargs to long options (plugins may need this): 1738edce3322Smrg --*=*) func_split_equals "$_G_opt" 1739edce3322Smrg set dummy "$func_split_equals_lhs" \ 1740edce3322Smrg "$func_split_equals_rhs" ${1+"$@"} 1741edce3322Smrg shift 1742edce3322Smrg ;; 1743edce3322Smrg 1744edce3322Smrg # Separate optargs to short options: 1745edce3322Smrg -W*) 1746edce3322Smrg func_split_short_opt "$_G_opt" 1747edce3322Smrg set dummy "$func_split_short_opt_name" \ 1748edce3322Smrg "$func_split_short_opt_arg" ${1+"$@"} 1749edce3322Smrg shift 1750edce3322Smrg ;; 1751edce3322Smrg 1752edce3322Smrg # Separate non-argument short options: 1753edce3322Smrg -\?*|-h*|-v*|-x*) 1754edce3322Smrg func_split_short_opt "$_G_opt" 1755edce3322Smrg set dummy "$func_split_short_opt_name" \ 1756edce3322Smrg "-$func_split_short_opt_arg" ${1+"$@"} 1757edce3322Smrg shift 1758edce3322Smrg ;; 1759edce3322Smrg 17601c235774Smrg --) break ;; 1761edce3322Smrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 17621c235774Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763edce3322Smrg esac 1764edce3322Smrg done 1765edce3322Smrg 17661c235774Smrg # save modified positional parameters for caller 17671c235774Smrg func_quote_for_eval ${1+"$@"} 17681c235774Smrg func_parse_options_result=$func_quote_for_eval_result 176997cf2ee2Smrg} 177097cf2ee2Smrg 1771a966c04fSmrg 1772edce3322Smrg# func_validate_options [ARG]... 1773edce3322Smrg# ------------------------------ 1774edce3322Smrg# Perform any sanity checks on option settings and/or unconsumed 1775edce3322Smrg# arguments. 1776edce3322Smrgfunc_hookable func_validate_options 1777edce3322Smrgfunc_validate_options () 17786e7d3316Smrg{ 1779edce3322Smrg $debug_cmd 178097cf2ee2Smrg 1781edce3322Smrg # Display all warnings if -W was not given. 1782edce3322Smrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783edce3322Smrg 1784edce3322Smrg func_run_hooks func_validate_options ${1+"$@"} 1785edce3322Smrg 1786edce3322Smrg # Bail if the options were screwed! 1787edce3322Smrg $exit_cmd $EXIT_FAILURE 17881c235774Smrg 17891c235774Smrg # save modified positional parameters for caller 17901c235774Smrg func_validate_options_result=$func_run_hooks_result 17916e7d3316Smrg} 1792a966c04fSmrg 1793edce3322Smrg 1794edce3322Smrg 1795edce3322Smrg## ----------------- ## 1796edce3322Smrg## Helper functions. ## 1797edce3322Smrg## ----------------- ## 1798edce3322Smrg 1799edce3322Smrg# This section contains the helper functions used by the rest of the 1800edce3322Smrg# hookable option parser framework in ascii-betical order. 1801edce3322Smrg 1802edce3322Smrg 1803edce3322Smrg# func_fatal_help ARG... 1804edce3322Smrg# ---------------------- 1805edce3322Smrg# Echo program name prefixed message to standard error, followed by 1806edce3322Smrg# a help hint, and exit. 1807edce3322Smrgfunc_fatal_help () 18086e7d3316Smrg{ 1809edce3322Smrg $debug_cmd 181097cf2ee2Smrg 1811edce3322Smrg eval \$ECHO \""Usage: $usage"\" 1812edce3322Smrg eval \$ECHO \""$fatal_help"\" 1813edce3322Smrg func_error ${1+"$@"} 1814edce3322Smrg exit $EXIT_FAILURE 18156e7d3316Smrg} 1816a966c04fSmrg 1817edce3322Smrg 1818edce3322Smrg# func_help 1819edce3322Smrg# --------- 1820edce3322Smrg# Echo long help message to standard output and exit. 18216e7d3316Smrgfunc_help () 18226e7d3316Smrg{ 1823edce3322Smrg $debug_cmd 1824edce3322Smrg 1825edce3322Smrg func_usage_message 1826edce3322Smrg $ECHO "$long_help_message" 1827edce3322Smrg exit 0 18286e7d3316Smrg} 1829a966c04fSmrg 1830edce3322Smrg 1831edce3322Smrg# func_missing_arg ARGNAME 1832edce3322Smrg# ------------------------ 18336e7d3316Smrg# Echo program name prefixed message to standard error and set global 18346e7d3316Smrg# exit_cmd. 18356e7d3316Smrgfunc_missing_arg () 18366e7d3316Smrg{ 1837edce3322Smrg $debug_cmd 183897cf2ee2Smrg 1839edce3322Smrg func_error "Missing argument for '$1'." 18406e7d3316Smrg exit_cmd=exit 18416e7d3316Smrg} 1842a966c04fSmrg 1843a966c04fSmrg 1844edce3322Smrg# func_split_equals STRING 1845edce3322Smrg# ------------------------ 18461c235774Smrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 18471c235774Smrg# splitting STRING at the '=' sign. 1848edce3322Smrgtest -z "$_G_HAVE_XSI_OPS" \ 1849edce3322Smrg && (eval 'x=a/b/c; 1850edce3322Smrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851edce3322Smrg && _G_HAVE_XSI_OPS=yes 1852edce3322Smrg 1853edce3322Smrgif test yes = "$_G_HAVE_XSI_OPS" 1854edce3322Smrgthen 1855edce3322Smrg # This is an XSI compatible shell, allowing a faster implementation... 1856edce3322Smrg eval 'func_split_equals () 1857edce3322Smrg { 1858edce3322Smrg $debug_cmd 1859edce3322Smrg 1860edce3322Smrg func_split_equals_lhs=${1%%=*} 1861edce3322Smrg func_split_equals_rhs=${1#*=} 18621c235774Smrg test "x$func_split_equals_lhs" = "x$1" \ 18631c235774Smrg && func_split_equals_rhs= 1864edce3322Smrg }' 1865edce3322Smrgelse 1866edce3322Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1867edce3322Smrg func_split_equals () 1868edce3322Smrg { 1869edce3322Smrg $debug_cmd 1870edce3322Smrg 1871edce3322Smrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872edce3322Smrg func_split_equals_rhs= 18731c235774Smrg test "x$func_split_equals_lhs" = "x$1" \ 1874edce3322Smrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875edce3322Smrg } 1876edce3322Smrgfi #func_split_equals 1877edce3322Smrg 1878edce3322Smrg 1879edce3322Smrg# func_split_short_opt SHORTOPT 1880edce3322Smrg# ----------------------------- 188197cf2ee2Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 188297cf2ee2Smrg# variables after splitting SHORTOPT after the 2nd character. 1883edce3322Smrgif test yes = "$_G_HAVE_XSI_OPS" 1884edce3322Smrgthen 1885edce3322Smrg # This is an XSI compatible shell, allowing a faster implementation... 1886edce3322Smrg eval 'func_split_short_opt () 1887edce3322Smrg { 1888edce3322Smrg $debug_cmd 1889edce3322Smrg 1890edce3322Smrg func_split_short_opt_arg=${1#??} 1891edce3322Smrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892edce3322Smrg }' 1893edce3322Smrgelse 1894edce3322Smrg # ...otherwise fall back to using expr, which is often a shell builtin. 1895edce3322Smrg func_split_short_opt () 1896edce3322Smrg { 1897edce3322Smrg $debug_cmd 1898edce3322Smrg 18991c235774Smrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900edce3322Smrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901edce3322Smrg } 1902edce3322Smrgfi #func_split_short_opt 1903edce3322Smrg 1904edce3322Smrg 1905edce3322Smrg# func_usage 1906edce3322Smrg# ---------- 1907edce3322Smrg# Echo short help message to standard output and exit. 1908edce3322Smrgfunc_usage () 190997cf2ee2Smrg{ 1910edce3322Smrg $debug_cmd 191197cf2ee2Smrg 1912edce3322Smrg func_usage_message 1913edce3322Smrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914edce3322Smrg exit 0 1915edce3322Smrg} 191697cf2ee2Smrg 191797cf2ee2Smrg 1918edce3322Smrg# func_usage_message 1919edce3322Smrg# ------------------ 1920edce3322Smrg# Echo short help message to standard output. 1921edce3322Smrgfunc_usage_message () 192297cf2ee2Smrg{ 1923edce3322Smrg $debug_cmd 192497cf2ee2Smrg 1925edce3322Smrg eval \$ECHO \""Usage: $usage"\" 1926edce3322Smrg echo 1927edce3322Smrg $SED -n 's|^# || 1928edce3322Smrg /^Written by/{ 1929edce3322Smrg x;p;x 1930edce3322Smrg } 1931edce3322Smrg h 1932edce3322Smrg /^Written by/q' < "$progpath" 1933edce3322Smrg echo 1934edce3322Smrg eval \$ECHO \""$usage_message"\" 1935edce3322Smrg} 193697cf2ee2Smrg 1937a966c04fSmrg 1938edce3322Smrg# func_version 1939edce3322Smrg# ------------ 1940edce3322Smrg# Echo version message to standard output and exit. 1941edce3322Smrgfunc_version () 1942edce3322Smrg{ 1943edce3322Smrg $debug_cmd 1944a966c04fSmrg 1945edce3322Smrg printf '%s\n' "$progname $scriptversion" 1946edce3322Smrg $SED -n ' 19471c235774Smrg /(C)/!b go 19481c235774Smrg :more 19491c235774Smrg /\./!{ 19501c235774Smrg N 19511c235774Smrg s|\n# | | 19521c235774Smrg b more 1953edce3322Smrg } 19541c235774Smrg :go 19551c235774Smrg /^# Written by /,/# warranty; / { 19561c235774Smrg s|^# || 19571c235774Smrg s|^# *$|| 19581c235774Smrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 19591c235774Smrg p 1960edce3322Smrg } 19611c235774Smrg /^# Written by / { 19621c235774Smrg s|^# || 19631c235774Smrg p 19641c235774Smrg } 19651c235774Smrg /^warranty; /q' < "$progpath" 19662e2dd055Smrg 1967edce3322Smrg exit $? 1968edce3322Smrg} 1969a966c04fSmrg 19706e7d3316Smrg 1971edce3322Smrg# Local variables: 1972edce3322Smrg# mode: shell-script 1973edce3322Smrg# sh-indentation: 2 1974edce3322Smrg# eval: (add-hook 'before-save-hook 'time-stamp) 19751c235774Smrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976edce3322Smrg# time-stamp-time-zone: "UTC" 1977edce3322Smrg# End: 19786e7d3316Smrg 1979edce3322Smrg# Set a version string. 19801c235774Smrgscriptversion='(GNU libtool) 2.4.6' 19816e7d3316Smrg 19826e7d3316Smrg 1983edce3322Smrg# func_echo ARG... 1984edce3322Smrg# ---------------- 1985edce3322Smrg# Libtool also displays the current mode in messages, so override 1986edce3322Smrg# funclib.sh func_echo with this custom definition. 1987edce3322Smrgfunc_echo () 198897cf2ee2Smrg{ 1989edce3322Smrg $debug_cmd 199097cf2ee2Smrg 1991edce3322Smrg _G_message=$* 1992edce3322Smrg 1993edce3322Smrg func_echo_IFS=$IFS 1994edce3322Smrg IFS=$nl 1995edce3322Smrg for _G_line in $_G_message; do 1996edce3322Smrg IFS=$func_echo_IFS 1997edce3322Smrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998edce3322Smrg done 1999edce3322Smrg IFS=$func_echo_IFS 2000edce3322Smrg} 200197cf2ee2Smrg 200297cf2ee2Smrg 2003edce3322Smrg# func_warning ARG... 2004edce3322Smrg# ------------------- 2005edce3322Smrg# Libtool warnings are not categorized, so override funclib.sh 2006edce3322Smrg# func_warning with this simpler definition. 2007edce3322Smrgfunc_warning () 200897cf2ee2Smrg{ 2009edce3322Smrg $debug_cmd 2010edce3322Smrg 2011edce3322Smrg $warning_func ${1+"$@"} 2012edce3322Smrg} 2013edce3322Smrg 201497cf2ee2Smrg 2015edce3322Smrg## ---------------- ## 2016edce3322Smrg## Options parsing. ## 2017edce3322Smrg## ---------------- ## 2018edce3322Smrg 2019edce3322Smrg# Hook in the functions to make sure our own options are parsed during 2020edce3322Smrg# the option parsing loop. 2021edce3322Smrg 2022edce3322Smrgusage='$progpath [OPTION]... [MODE-ARG]...' 2023edce3322Smrg 2024edce3322Smrg# Short help message in response to '-h'. 2025edce3322Smrgusage_message="Options: 2026edce3322Smrg --config show all configuration variables 2027edce3322Smrg --debug enable verbose shell tracing 2028edce3322Smrg -n, --dry-run display commands without modifying any files 2029edce3322Smrg --features display basic configuration information and exit 2030edce3322Smrg --mode=MODE use operation mode MODE 2031edce3322Smrg --no-warnings equivalent to '-Wnone' 2032edce3322Smrg --preserve-dup-deps don't remove duplicate dependency libraries 2033edce3322Smrg --quiet, --silent don't print informational messages 2034edce3322Smrg --tag=TAG use configuration variables from tag TAG 2035edce3322Smrg -v, --verbose print more informational messages than default 2036edce3322Smrg --version print version information 2037edce3322Smrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038edce3322Smrg -h, --help, --help-all print short, long, or detailed help message 2039edce3322Smrg" 204097cf2ee2Smrg 2041edce3322Smrg# Additional text appended to 'usage_message' in response to '--help'. 2042edce3322Smrgfunc_help () 204397cf2ee2Smrg{ 2044edce3322Smrg $debug_cmd 2045edce3322Smrg 2046edce3322Smrg func_usage_message 2047edce3322Smrg $ECHO "$long_help_message 2048edce3322Smrg 2049edce3322SmrgMODE must be one of the following: 2050edce3322Smrg 2051edce3322Smrg clean remove files from the build directory 2052edce3322Smrg compile compile a source file into a libtool object 2053edce3322Smrg execute automatically set library path, then run a program 2054edce3322Smrg finish complete the installation of libtool libraries 2055edce3322Smrg install install libraries or executables 2056edce3322Smrg link create a library or an executable 2057edce3322Smrg uninstall remove libraries from an installed directory 2058edce3322Smrg 2059edce3322SmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2060edce3322Smrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061edce3322SmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062edce3322Smrg 2063edce3322SmrgWhen reporting a bug, please describe a test case to reproduce it and 2064edce3322Smrginclude the following information: 2065edce3322Smrg 2066edce3322Smrg host-triplet: $host 2067edce3322Smrg shell: $SHELL 2068edce3322Smrg compiler: $LTCC 2069edce3322Smrg compiler flags: $LTCFLAGS 2070edce3322Smrg linker: $LD (gnu? $with_gnu_ld) 20711c235774Smrg version: $progname (GNU libtool) 2.4.6 2072edce3322Smrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073edce3322Smrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074edce3322Smrg 2075edce3322SmrgReport bugs to <bug-libtool@gnu.org>. 20761c235774SmrgGNU libtool home page: <http://www.gnu.org/s/libtool/>. 2077edce3322SmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078edce3322Smrg exit 0 2079edce3322Smrg} 208097cf2ee2Smrg 208197cf2ee2Smrg 2082edce3322Smrg# func_lo2o OBJECT-NAME 2083edce3322Smrg# --------------------- 2084edce3322Smrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085edce3322Smrg# object suffix. 208697cf2ee2Smrg 2087edce3322Smrglo2o=s/\\.lo\$/.$objext/ 2088edce3322Smrgo2lo=s/\\.$objext\$/.lo/ 208997cf2ee2Smrg 2090edce3322Smrgif test yes = "$_G_HAVE_XSI_OPS"; then 2091edce3322Smrg eval 'func_lo2o () 2092edce3322Smrg { 2093edce3322Smrg case $1 in 2094edce3322Smrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095edce3322Smrg * ) func_lo2o_result=$1 ;; 2096edce3322Smrg esac 2097edce3322Smrg }' 2098edce3322Smrg 2099edce3322Smrg # func_xform LIBOBJ-OR-SOURCE 2100edce3322Smrg # --------------------------- 2101edce3322Smrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102edce3322Smrg # suffix to a '.lo' libtool-object suffix. 2103edce3322Smrg eval 'func_xform () 2104edce3322Smrg { 2105edce3322Smrg func_xform_result=${1%.*}.lo 2106edce3322Smrg }' 2107edce3322Smrgelse 2108edce3322Smrg # ...otherwise fall back to using sed. 2109edce3322Smrg func_lo2o () 2110edce3322Smrg { 2111edce3322Smrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112edce3322Smrg } 2113edce3322Smrg 2114edce3322Smrg func_xform () 2115edce3322Smrg { 2116edce3322Smrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117edce3322Smrg } 2118edce3322Smrgfi 211997cf2ee2Smrg 212097cf2ee2Smrg 2121edce3322Smrg# func_fatal_configuration ARG... 2122edce3322Smrg# ------------------------------- 21236e7d3316Smrg# Echo program name prefixed message to standard error, followed by 21246e7d3316Smrg# a configuration failure hint, and exit. 21256e7d3316Smrgfunc_fatal_configuration () 21266e7d3316Smrg{ 21271c235774Smrg func__fatal_error ${1+"$@"} \ 2128edce3322Smrg "See the $PACKAGE documentation for more information." \ 2129edce3322Smrg "Fatal configuration error." 21306e7d3316Smrg} 21316e7d3316Smrg 21326e7d3316Smrg 21336e7d3316Smrg# func_config 2134edce3322Smrg# ----------- 21356e7d3316Smrg# Display the configuration for all the tags in this script. 21366e7d3316Smrgfunc_config () 21376e7d3316Smrg{ 21386e7d3316Smrg re_begincf='^# ### BEGIN LIBTOOL' 21396e7d3316Smrg re_endcf='^# ### END LIBTOOL' 21406e7d3316Smrg 21416e7d3316Smrg # Default configuration. 21426e7d3316Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 21436e7d3316Smrg 2144a966c04fSmrg # Now print the configurations for the tags. 2145a966c04fSmrg for tagname in $taglist; do 21466e7d3316Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147a966c04fSmrg done 2148a966c04fSmrg 21496e7d3316Smrg exit $? 21506e7d3316Smrg} 2151a966c04fSmrg 2152edce3322Smrg 21536e7d3316Smrg# func_features 2154edce3322Smrg# ------------- 21556e7d3316Smrg# Display the features supported by this script. 21566e7d3316Smrgfunc_features () 21576e7d3316Smrg{ 21586e7d3316Smrg echo "host: $host" 2159edce3322Smrg if test yes = "$build_libtool_libs"; then 21606e7d3316Smrg echo "enable shared libraries" 2161a966c04fSmrg else 21626e7d3316Smrg echo "disable shared libraries" 2163a966c04fSmrg fi 2164edce3322Smrg if test yes = "$build_old_libs"; then 21656e7d3316Smrg echo "enable static libraries" 2166a966c04fSmrg else 21676e7d3316Smrg echo "disable static libraries" 2168a966c04fSmrg fi 21696e7d3316Smrg 2170a966c04fSmrg exit $? 21716e7d3316Smrg} 2172a966c04fSmrg 2173edce3322Smrg 2174edce3322Smrg# func_enable_tag TAGNAME 2175edce3322Smrg# ----------------------- 21766e7d3316Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 21776e7d3316Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 21786e7d3316Smrg# variable here. 21796e7d3316Smrgfunc_enable_tag () 21806e7d3316Smrg{ 2181edce3322Smrg # Global variable: 2182edce3322Smrg tagname=$1 2183a966c04fSmrg 2184edce3322Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185edce3322Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186edce3322Smrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187a966c04fSmrg 2188edce3322Smrg # Validate tagname. 2189edce3322Smrg case $tagname in 2190edce3322Smrg *[!-_A-Za-z0-9,/]*) 2191edce3322Smrg func_fatal_error "invalid tag name: $tagname" 2192edce3322Smrg ;; 2193edce3322Smrg esac 2194a966c04fSmrg 2195edce3322Smrg # Don't test for the "default" C tag, as we know it's 2196edce3322Smrg # there but not specially marked. 2197edce3322Smrg case $tagname in 2198edce3322Smrg CC) ;; 21996e7d3316Smrg *) 2200edce3322Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201edce3322Smrg taglist="$taglist $tagname" 2202edce3322Smrg 2203edce3322Smrg # Evaluate the configuration. Be careful to quote the path 2204edce3322Smrg # and the sed script, to avoid splitting on whitespace, but 2205edce3322Smrg # also don't use non-portable quotes within backquotes within 2206edce3322Smrg # quotes we have to do it in 2 steps: 2207edce3322Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208edce3322Smrg eval "$extractedcf" 2209edce3322Smrg else 2210edce3322Smrg func_error "ignoring unknown tag $tagname" 2211edce3322Smrg fi 2212edce3322Smrg ;; 2213edce3322Smrg esac 22146e7d3316Smrg} 22156e7d3316Smrg 2216edce3322Smrg 221797cf2ee2Smrg# func_check_version_match 2218edce3322Smrg# ------------------------ 221997cf2ee2Smrg# Ensure that we are using m4 macros, and libtool script from the same 222097cf2ee2Smrg# release of libtool. 222197cf2ee2Smrgfunc_check_version_match () 22226e7d3316Smrg{ 2223edce3322Smrg if test "$package_revision" != "$macro_revision"; then 2224edce3322Smrg if test "$VERSION" != "$macro_version"; then 2225edce3322Smrg if test -z "$macro_version"; then 2226edce3322Smrg cat >&2 <<_LT_EOF 222797cf2ee2Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 222897cf2ee2Smrg$progname: definition of this LT_INIT comes from an older release. 222997cf2ee2Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223097cf2ee2Smrg$progname: and run autoconf again. 223197cf2ee2Smrg_LT_EOF 2232edce3322Smrg else 2233edce3322Smrg cat >&2 <<_LT_EOF 223497cf2ee2Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 223597cf2ee2Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 223697cf2ee2Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 223797cf2ee2Smrg$progname: and run autoconf again. 223897cf2ee2Smrg_LT_EOF 2239edce3322Smrg fi 2240edce3322Smrg else 2241edce3322Smrg cat >&2 <<_LT_EOF 224297cf2ee2Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 224397cf2ee2Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 224497cf2ee2Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 224597cf2ee2Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 224697cf2ee2Smrg_LT_EOF 2247edce3322Smrg fi 2248a966c04fSmrg 2249edce3322Smrg exit $EXIT_MISMATCH 2250edce3322Smrg fi 225197cf2ee2Smrg} 225297cf2ee2Smrg 225397cf2ee2Smrg 2254edce3322Smrg# libtool_options_prep [ARG]... 2255edce3322Smrg# ----------------------------- 2256edce3322Smrg# Preparation for options parsed by libtool. 2257edce3322Smrglibtool_options_prep () 2258edce3322Smrg{ 2259edce3322Smrg $debug_mode 2260a966c04fSmrg 2261edce3322Smrg # Option defaults: 2262edce3322Smrg opt_config=false 2263edce3322Smrg opt_dlopen= 2264edce3322Smrg opt_dry_run=false 2265edce3322Smrg opt_help=false 2266edce3322Smrg opt_mode= 2267edce3322Smrg opt_preserve_dup_deps=false 2268edce3322Smrg opt_quiet=false 226997cf2ee2Smrg 2270edce3322Smrg nonopt= 2271edce3322Smrg preserve_args= 227297cf2ee2Smrg 2273edce3322Smrg # Shorthand for --mode=foo, only valid as the first argument 2274edce3322Smrg case $1 in 2275edce3322Smrg clean|clea|cle|cl) 2276edce3322Smrg shift; set dummy --mode clean ${1+"$@"}; shift 2277edce3322Smrg ;; 2278edce3322Smrg compile|compil|compi|comp|com|co|c) 2279edce3322Smrg shift; set dummy --mode compile ${1+"$@"}; shift 2280edce3322Smrg ;; 2281edce3322Smrg execute|execut|execu|exec|exe|ex|e) 2282edce3322Smrg shift; set dummy --mode execute ${1+"$@"}; shift 2283edce3322Smrg ;; 2284edce3322Smrg finish|finis|fini|fin|fi|f) 2285edce3322Smrg shift; set dummy --mode finish ${1+"$@"}; shift 2286edce3322Smrg ;; 2287edce3322Smrg install|instal|insta|inst|ins|in|i) 2288edce3322Smrg shift; set dummy --mode install ${1+"$@"}; shift 2289edce3322Smrg ;; 2290edce3322Smrg link|lin|li|l) 2291edce3322Smrg shift; set dummy --mode link ${1+"$@"}; shift 2292edce3322Smrg ;; 2293edce3322Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294edce3322Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2295edce3322Smrg ;; 2296edce3322Smrg esac 2297edce3322Smrg 22981c235774Smrg # Pass back the list of options. 22991c235774Smrg func_quote_for_eval ${1+"$@"} 23001c235774Smrg libtool_options_prep_result=$func_quote_for_eval_result 2301edce3322Smrg} 2302edce3322Smrgfunc_add_hook func_options_prep libtool_options_prep 230397cf2ee2Smrg 230497cf2ee2Smrg 2305edce3322Smrg# libtool_parse_options [ARG]... 2306edce3322Smrg# --------------------------------- 2307edce3322Smrg# Provide handling for libtool specific options. 2308edce3322Smrglibtool_parse_options () 230997cf2ee2Smrg{ 2310edce3322Smrg $debug_cmd 23116e7d3316Smrg 2312edce3322Smrg # Perform our own loop to consume as many options as possible in 2313edce3322Smrg # each iteration. 2314edce3322Smrg while test $# -gt 0; do 2315edce3322Smrg _G_opt=$1 2316edce3322Smrg shift 2317edce3322Smrg case $_G_opt in 2318edce3322Smrg --dry-run|--dryrun|-n) 2319edce3322Smrg opt_dry_run=: 2320edce3322Smrg ;; 2321edce3322Smrg 2322edce3322Smrg --config) func_config ;; 2323edce3322Smrg 2324edce3322Smrg --dlopen|-dlopen) 2325edce3322Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 2326edce3322Smrg}$1" 2327edce3322Smrg shift 2328edce3322Smrg ;; 2329edce3322Smrg 2330edce3322Smrg --preserve-dup-deps) 2331edce3322Smrg opt_preserve_dup_deps=: ;; 2332edce3322Smrg 2333edce3322Smrg --features) func_features ;; 2334edce3322Smrg 2335edce3322Smrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336edce3322Smrg 2337edce3322Smrg --help) opt_help=: ;; 2338edce3322Smrg 2339edce3322Smrg --help-all) opt_help=': help-all' ;; 2340edce3322Smrg 2341edce3322Smrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342edce3322Smrg opt_mode=$1 2343edce3322Smrg case $1 in 2344edce3322Smrg # Valid mode arguments: 2345edce3322Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346edce3322Smrg 2347edce3322Smrg # Catch anything else as an error 2348edce3322Smrg *) func_error "invalid argument for $_G_opt" 2349edce3322Smrg exit_cmd=exit 2350edce3322Smrg break 2351edce3322Smrg ;; 2352edce3322Smrg esac 2353edce3322Smrg shift 2354edce3322Smrg ;; 2355edce3322Smrg 2356edce3322Smrg --no-silent|--no-quiet) 2357edce3322Smrg opt_quiet=false 2358edce3322Smrg func_append preserve_args " $_G_opt" 2359edce3322Smrg ;; 2360edce3322Smrg 2361edce3322Smrg --no-warnings|--no-warning|--no-warn) 2362edce3322Smrg opt_warning=false 2363edce3322Smrg func_append preserve_args " $_G_opt" 2364edce3322Smrg ;; 2365edce3322Smrg 2366edce3322Smrg --no-verbose) 2367edce3322Smrg opt_verbose=false 2368edce3322Smrg func_append preserve_args " $_G_opt" 2369edce3322Smrg ;; 2370edce3322Smrg 2371edce3322Smrg --silent|--quiet) 2372edce3322Smrg opt_quiet=: 2373edce3322Smrg opt_verbose=false 2374edce3322Smrg func_append preserve_args " $_G_opt" 2375edce3322Smrg ;; 2376edce3322Smrg 2377edce3322Smrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378edce3322Smrg opt_tag=$1 2379edce3322Smrg func_append preserve_args " $_G_opt $1" 2380edce3322Smrg func_enable_tag "$1" 2381edce3322Smrg shift 2382edce3322Smrg ;; 2383edce3322Smrg 2384edce3322Smrg --verbose|-v) opt_quiet=false 2385edce3322Smrg opt_verbose=: 2386edce3322Smrg func_append preserve_args " $_G_opt" 2387edce3322Smrg ;; 2388edce3322Smrg 23891c235774Smrg # An option not handled by this hook function: 23901c235774Smrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391edce3322Smrg esac 2392edce3322Smrg done 239397cf2ee2Smrg 23941c235774Smrg 23951c235774Smrg # save modified positional parameters for caller 23961c235774Smrg func_quote_for_eval ${1+"$@"} 23971c235774Smrg libtool_parse_options_result=$func_quote_for_eval_result 2398edce3322Smrg} 2399edce3322Smrgfunc_add_hook func_parse_options libtool_parse_options 24006e7d3316Smrg 2401a966c04fSmrg 24026e7d3316Smrg 2403edce3322Smrg# libtool_validate_options [ARG]... 2404edce3322Smrg# --------------------------------- 2405edce3322Smrg# Perform any sanity checks on option settings and/or unconsumed 2406edce3322Smrg# arguments. 2407edce3322Smrglibtool_validate_options () 2408edce3322Smrg{ 2409edce3322Smrg # save first non-option argument 2410edce3322Smrg if test 0 -lt $#; then 2411edce3322Smrg nonopt=$1 2412edce3322Smrg shift 24136e7d3316Smrg fi 24146e7d3316Smrg 2415edce3322Smrg # preserve --debug 2416edce3322Smrg test : = "$debug_cmd" || func_append preserve_args " --debug" 24176e7d3316Smrg 2418edce3322Smrg case $host in 2419edce3322Smrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420edce3322Smrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421edce3322Smrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422edce3322Smrg # don't eliminate duplications in $postdeps and $predeps 2423edce3322Smrg opt_duplicate_compiler_generated_deps=: 2424edce3322Smrg ;; 2425edce3322Smrg *) 2426edce3322Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427edce3322Smrg ;; 2428edce3322Smrg esac 24296e7d3316Smrg 2430edce3322Smrg $opt_help || { 2431edce3322Smrg # Sanity checks first: 2432edce3322Smrg func_check_version_match 24336e7d3316Smrg 2434edce3322Smrg test yes != "$build_libtool_libs" \ 2435edce3322Smrg && test yes != "$build_old_libs" \ 2436edce3322Smrg && func_fatal_configuration "not configured to build any kind of library" 24376e7d3316Smrg 2438edce3322Smrg # Darwin sucks 2439edce3322Smrg eval std_shrext=\"$shrext_cmds\" 2440edce3322Smrg 2441edce3322Smrg # Only execute mode is allowed to have -dlopen flags. 2442edce3322Smrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443edce3322Smrg func_error "unrecognized option '-dlopen'" 2444edce3322Smrg $ECHO "$help" 1>&2 2445edce3322Smrg exit $EXIT_FAILURE 2446edce3322Smrg fi 2447edce3322Smrg 2448edce3322Smrg # Change the help message to a mode-specific one. 2449edce3322Smrg generic_help=$help 2450edce3322Smrg help="Try '$progname --help --mode=$opt_mode' for more information." 2451edce3322Smrg } 2452edce3322Smrg 2453edce3322Smrg # Pass back the unparsed argument list 24541c235774Smrg func_quote_for_eval ${1+"$@"} 24551c235774Smrg libtool_validate_options_result=$func_quote_for_eval_result 245697cf2ee2Smrg} 2457edce3322Smrgfunc_add_hook func_validate_options libtool_validate_options 2458edce3322Smrg 24596e7d3316Smrg 2460edce3322Smrg# Process options as early as possible so that --help and --version 2461edce3322Smrg# can return quickly. 2462edce3322Smrgfunc_options ${1+"$@"} 2463edce3322Smrgeval set dummy "$func_options_result"; shift 24646e7d3316Smrg 2465a966c04fSmrg 2466a966c04fSmrg 246797cf2ee2Smrg## ----------- ## 246897cf2ee2Smrg## Main. ## 246997cf2ee2Smrg## ----------- ## 2470a966c04fSmrg 2471edce3322Smrgmagic='%%%MAGIC variable%%%' 2472edce3322Smrgmagic_exe='%%%MAGIC EXE variable%%%' 2473edce3322Smrg 2474edce3322Smrg# Global variables. 2475edce3322Smrgextracted_archives= 2476edce3322Smrgextracted_serial=0 2477edce3322Smrg 2478edce3322Smrg# If this variable is set in any of the actions, the command in it 2479edce3322Smrg# will be execed at the end. This prevents here-documents from being 2480edce3322Smrg# left over by shells. 2481edce3322Smrgexec_cmd= 2482edce3322Smrg 2483edce3322Smrg 2484edce3322Smrg# A function that is used when there is no print builtin or printf. 2485edce3322Smrgfunc_fallback_echo () 2486edce3322Smrg{ 2487edce3322Smrg eval 'cat <<_LTECHO_EOF 2488edce3322Smrg$1 2489edce3322Smrg_LTECHO_EOF' 2490edce3322Smrg} 2491edce3322Smrg 2492edce3322Smrg# func_generated_by_libtool 2493edce3322Smrg# True iff stdin has been generated by Libtool. This function is only 2494edce3322Smrg# a basic sanity check; it will hardly flush out determined imposters. 2495edce3322Smrgfunc_generated_by_libtool_p () 2496edce3322Smrg{ 2497edce3322Smrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498edce3322Smrg} 2499edce3322Smrg 25006e7d3316Smrg# func_lalib_p file 2501edce3322Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25026e7d3316Smrg# This function is only a basic sanity check; it will hardly flush out 25036e7d3316Smrg# determined imposters. 25046e7d3316Smrgfunc_lalib_p () 25056e7d3316Smrg{ 25066e7d3316Smrg test -f "$1" && 2507edce3322Smrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 25086e7d3316Smrg} 2509a966c04fSmrg 25106e7d3316Smrg# func_lalib_unsafe_p file 2511edce3322Smrg# True iff FILE is a libtool '.la' library or '.lo' object file. 25126e7d3316Smrg# This function implements the same check as func_lalib_p without 25136e7d3316Smrg# resorting to external programs. To this end, it redirects stdin and 25146e7d3316Smrg# closes it afterwards, without saving the original file descriptor. 25156e7d3316Smrg# As a safety measure, use it only where a negative result would be 2516edce3322Smrg# fatal anyway. Works if 'file' does not exist. 25176e7d3316Smrgfunc_lalib_unsafe_p () 25186e7d3316Smrg{ 25196e7d3316Smrg lalib_p=no 25206e7d3316Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 25216e7d3316Smrg for lalib_p_l in 1 2 3 4 25226e7d3316Smrg do 25236e7d3316Smrg read lalib_p_line 2524edce3322Smrg case $lalib_p_line in 25256e7d3316Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 25266e7d3316Smrg esac 25276e7d3316Smrg done 25286e7d3316Smrg exec 0<&5 5<&- 25296e7d3316Smrg fi 2530edce3322Smrg test yes = "$lalib_p" 25316e7d3316Smrg} 2532a966c04fSmrg 25336e7d3316Smrg# func_ltwrapper_script_p file 25346e7d3316Smrg# True iff FILE is a libtool wrapper script 25356e7d3316Smrg# This function is only a basic sanity check; it will hardly flush out 25366e7d3316Smrg# determined imposters. 25376e7d3316Smrgfunc_ltwrapper_script_p () 25386e7d3316Smrg{ 2539edce3322Smrg test -f "$1" && 2540edce3322Smrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 25416e7d3316Smrg} 2542a966c04fSmrg 25436e7d3316Smrg# func_ltwrapper_executable_p file 25446e7d3316Smrg# True iff FILE is a libtool wrapper executable 25456e7d3316Smrg# This function is only a basic sanity check; it will hardly flush out 25466e7d3316Smrg# determined imposters. 25476e7d3316Smrgfunc_ltwrapper_executable_p () 25486e7d3316Smrg{ 25496e7d3316Smrg func_ltwrapper_exec_suffix= 25506e7d3316Smrg case $1 in 25516e7d3316Smrg *.exe) ;; 25526e7d3316Smrg *) func_ltwrapper_exec_suffix=.exe ;; 25536e7d3316Smrg esac 25546e7d3316Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 25556e7d3316Smrg} 25566e7d3316Smrg 25576e7d3316Smrg# func_ltwrapper_scriptname file 25586e7d3316Smrg# Assumes file is an ltwrapper_executable 25596e7d3316Smrg# uses $file to determine the appropriate filename for a 25606e7d3316Smrg# temporary ltwrapper_script. 25616e7d3316Smrgfunc_ltwrapper_scriptname () 25626e7d3316Smrg{ 256397cf2ee2Smrg func_dirname_and_basename "$1" "" "." 256497cf2ee2Smrg func_stripname '' '.exe' "$func_basename_result" 2565edce3322Smrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 25666e7d3316Smrg} 25676e7d3316Smrg 25686e7d3316Smrg# func_ltwrapper_p file 25696e7d3316Smrg# True iff FILE is a libtool wrapper script or wrapper executable 25706e7d3316Smrg# This function is only a basic sanity check; it will hardly flush out 25716e7d3316Smrg# determined imposters. 25726e7d3316Smrgfunc_ltwrapper_p () 25736e7d3316Smrg{ 25746e7d3316Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 25756e7d3316Smrg} 25766e7d3316Smrg 25776e7d3316Smrg 25786e7d3316Smrg# func_execute_cmds commands fail_cmd 25796e7d3316Smrg# Execute tilde-delimited COMMANDS. 25806e7d3316Smrg# If FAIL_CMD is given, eval that upon failure. 25816e7d3316Smrg# FAIL_CMD may read-access the current command in variable CMD! 25826e7d3316Smrgfunc_execute_cmds () 25836e7d3316Smrg{ 2584edce3322Smrg $debug_cmd 2585edce3322Smrg 25866e7d3316Smrg save_ifs=$IFS; IFS='~' 25876e7d3316Smrg for cmd in $1; do 2588edce3322Smrg IFS=$sp$nl 25896e7d3316Smrg eval cmd=\"$cmd\" 2590edce3322Smrg IFS=$save_ifs 25916e7d3316Smrg func_show_eval "$cmd" "${2-:}" 25926e7d3316Smrg done 25936e7d3316Smrg IFS=$save_ifs 25946e7d3316Smrg} 25956e7d3316Smrg 25966e7d3316Smrg 25976e7d3316Smrg# func_source file 25986e7d3316Smrg# Source FILE, adding directory component if necessary. 25996e7d3316Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 26006e7d3316Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 26016e7d3316Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602edce3322Smrg# 'FILE.' does not work on cygwin managed mounts. 26036e7d3316Smrgfunc_source () 26046e7d3316Smrg{ 2605edce3322Smrg $debug_cmd 2606edce3322Smrg 26076e7d3316Smrg case $1 in 26086e7d3316Smrg */* | *\\*) . "$1" ;; 26096e7d3316Smrg *) . "./$1" ;; 26106e7d3316Smrg esac 26116e7d3316Smrg} 26126e7d3316Smrg 26136e7d3316Smrg 261497cf2ee2Smrg# func_resolve_sysroot PATH 261597cf2ee2Smrg# Replace a leading = in PATH with a sysroot. Store the result into 261697cf2ee2Smrg# func_resolve_sysroot_result 261797cf2ee2Smrgfunc_resolve_sysroot () 261897cf2ee2Smrg{ 261997cf2ee2Smrg func_resolve_sysroot_result=$1 262097cf2ee2Smrg case $func_resolve_sysroot_result in 262197cf2ee2Smrg =*) 262297cf2ee2Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 262397cf2ee2Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 262497cf2ee2Smrg ;; 262597cf2ee2Smrg esac 262697cf2ee2Smrg} 262797cf2ee2Smrg 262897cf2ee2Smrg# func_replace_sysroot PATH 262997cf2ee2Smrg# If PATH begins with the sysroot, replace it with = and 263097cf2ee2Smrg# store the result into func_replace_sysroot_result. 263197cf2ee2Smrgfunc_replace_sysroot () 263297cf2ee2Smrg{ 2633edce3322Smrg case $lt_sysroot:$1 in 263497cf2ee2Smrg ?*:"$lt_sysroot"*) 263597cf2ee2Smrg func_stripname "$lt_sysroot" '' "$1" 2636edce3322Smrg func_replace_sysroot_result='='$func_stripname_result 263797cf2ee2Smrg ;; 263897cf2ee2Smrg *) 263997cf2ee2Smrg # Including no sysroot. 264097cf2ee2Smrg func_replace_sysroot_result=$1 264197cf2ee2Smrg ;; 264297cf2ee2Smrg esac 264397cf2ee2Smrg} 264497cf2ee2Smrg 26456e7d3316Smrg# func_infer_tag arg 26466e7d3316Smrg# Infer tagged configuration to use if any are available and 26476e7d3316Smrg# if one wasn't chosen via the "--tag" command line option. 26486e7d3316Smrg# Only attempt this if the compiler in the base compile 26496e7d3316Smrg# command doesn't match the default compiler. 26506e7d3316Smrg# arg is usually of the form 'gcc ...' 26516e7d3316Smrgfunc_infer_tag () 26526e7d3316Smrg{ 2653edce3322Smrg $debug_cmd 2654edce3322Smrg 26556e7d3316Smrg if test -n "$available_tags" && test -z "$tagname"; then 26566e7d3316Smrg CC_quoted= 26576e7d3316Smrg for arg in $CC; do 265897cf2ee2Smrg func_append_quoted CC_quoted "$arg" 26596e7d3316Smrg done 26606e7d3316Smrg CC_expanded=`func_echo_all $CC` 26616e7d3316Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26626e7d3316Smrg case $@ in 26636e7d3316Smrg # Blanks in the command may have been stripped by the calling shell, 26646e7d3316Smrg # but not from the CC environment variable when configure was run. 26656e7d3316Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 26666e7d3316Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 26676e7d3316Smrg # Blanks at the start of $base_compile will cause this to fail 26686e7d3316Smrg # if we don't check for them as well. 26696e7d3316Smrg *) 26706e7d3316Smrg for z in $available_tags; do 26716e7d3316Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 26726e7d3316Smrg # Evaluate the configuration. 2673edce3322Smrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 26746e7d3316Smrg CC_quoted= 26756e7d3316Smrg for arg in $CC; do 26766e7d3316Smrg # Double-quote args containing other shell metacharacters. 267797cf2ee2Smrg func_append_quoted CC_quoted "$arg" 26786e7d3316Smrg done 26796e7d3316Smrg CC_expanded=`func_echo_all $CC` 26806e7d3316Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 26816e7d3316Smrg case "$@ " in 26826e7d3316Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 26836e7d3316Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 26846e7d3316Smrg # The compiler in the base compile command matches 26856e7d3316Smrg # the one in the tagged configuration. 26866e7d3316Smrg # Assume this is the tagged configuration we want. 26876e7d3316Smrg tagname=$z 26886e7d3316Smrg break 26896e7d3316Smrg ;; 26906e7d3316Smrg esac 26916e7d3316Smrg fi 26926e7d3316Smrg done 26936e7d3316Smrg # If $tagname still isn't set, then no tagged configuration 26946e7d3316Smrg # was found and let the user know that the "--tag" command 26956e7d3316Smrg # line option must be used. 26966e7d3316Smrg if test -z "$tagname"; then 26976e7d3316Smrg func_echo "unable to infer tagged configuration" 2698edce3322Smrg func_fatal_error "specify a tag with '--tag'" 26996e7d3316Smrg# else 27006e7d3316Smrg# func_verbose "using $tagname tagged configuration" 27016e7d3316Smrg fi 27026e7d3316Smrg ;; 27036e7d3316Smrg esac 27046e7d3316Smrg fi 27056e7d3316Smrg} 27066e7d3316Smrg 27076e7d3316Smrg 27086e7d3316Smrg 270997cf2ee2Smrg# func_write_libtool_object output_name pic_name nonpic_name 271097cf2ee2Smrg# Create a libtool object file (analogous to a ".la" file), 271197cf2ee2Smrg# but don't create it if we're doing a dry run. 271297cf2ee2Smrgfunc_write_libtool_object () 271397cf2ee2Smrg{ 2714edce3322Smrg write_libobj=$1 2715edce3322Smrg if test yes = "$build_libtool_libs"; then 2716edce3322Smrg write_lobj=\'$2\' 271797cf2ee2Smrg else 271897cf2ee2Smrg write_lobj=none 271997cf2ee2Smrg fi 272097cf2ee2Smrg 2721edce3322Smrg if test yes = "$build_old_libs"; then 2722edce3322Smrg write_oldobj=\'$3\' 272397cf2ee2Smrg else 272497cf2ee2Smrg write_oldobj=none 272597cf2ee2Smrg fi 272697cf2ee2Smrg 272797cf2ee2Smrg $opt_dry_run || { 272897cf2ee2Smrg cat >${write_libobj}T <<EOF 272997cf2ee2Smrg# $write_libobj - a libtool object file 2730edce3322Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 273197cf2ee2Smrg# 273297cf2ee2Smrg# Please DO NOT delete this file! 273397cf2ee2Smrg# It is necessary for linking the library. 273497cf2ee2Smrg 273597cf2ee2Smrg# Name of the PIC object. 273697cf2ee2Smrgpic_object=$write_lobj 273797cf2ee2Smrg 273897cf2ee2Smrg# Name of the non-PIC object 273997cf2ee2Smrgnon_pic_object=$write_oldobj 274097cf2ee2Smrg 274197cf2ee2SmrgEOF 2742edce3322Smrg $MV "${write_libobj}T" "$write_libobj" 274397cf2ee2Smrg } 274497cf2ee2Smrg} 274597cf2ee2Smrg 274697cf2ee2Smrg 274797cf2ee2Smrg################################################## 274897cf2ee2Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 274997cf2ee2Smrg################################################## 275097cf2ee2Smrg 275197cf2ee2Smrg# func_convert_core_file_wine_to_w32 ARG 275297cf2ee2Smrg# Helper function used by file name conversion functions when $build is *nix, 275397cf2ee2Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 275497cf2ee2Smrg# correctly configured wine environment available, with the winepath program 275597cf2ee2Smrg# in $build's $PATH. 275697cf2ee2Smrg# 275797cf2ee2Smrg# ARG is the $build file name to be converted to w32 format. 275897cf2ee2Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 275997cf2ee2Smrg# be empty on error (or when ARG is empty) 276097cf2ee2Smrgfunc_convert_core_file_wine_to_w32 () 276197cf2ee2Smrg{ 2762edce3322Smrg $debug_cmd 2763edce3322Smrg 2764edce3322Smrg func_convert_core_file_wine_to_w32_result=$1 276597cf2ee2Smrg if test -n "$1"; then 276697cf2ee2Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 276797cf2ee2Smrg # are forced to check the contents of stdout. On the other hand, if the 276897cf2ee2Smrg # command is not found, the shell will set an exit code of 127 and print 276997cf2ee2Smrg # *an error message* to stdout. So we must check for both error code of 277097cf2ee2Smrg # zero AND non-empty stdout, which explains the odd construction: 277197cf2ee2Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772edce3322Smrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 277397cf2ee2Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774edce3322Smrg $SED -e "$sed_naive_backslashify"` 277597cf2ee2Smrg else 277697cf2ee2Smrg func_convert_core_file_wine_to_w32_result= 277797cf2ee2Smrg fi 277897cf2ee2Smrg fi 277997cf2ee2Smrg} 278097cf2ee2Smrg# end: func_convert_core_file_wine_to_w32 278197cf2ee2Smrg 278297cf2ee2Smrg 278397cf2ee2Smrg# func_convert_core_path_wine_to_w32 ARG 278497cf2ee2Smrg# Helper function used by path conversion functions when $build is *nix, and 278597cf2ee2Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 278697cf2ee2Smrg# configured wine environment available, with the winepath program in $build's 278797cf2ee2Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 278897cf2ee2Smrg# 278997cf2ee2Smrg# ARG is path to be converted from $build format to win32. 279097cf2ee2Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 279197cf2ee2Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 279297cf2ee2Smrg# are convertible, then the result may be empty. 279397cf2ee2Smrgfunc_convert_core_path_wine_to_w32 () 279497cf2ee2Smrg{ 2795edce3322Smrg $debug_cmd 2796edce3322Smrg 279797cf2ee2Smrg # unfortunately, winepath doesn't convert paths, only file names 2798edce3322Smrg func_convert_core_path_wine_to_w32_result= 279997cf2ee2Smrg if test -n "$1"; then 280097cf2ee2Smrg oldIFS=$IFS 280197cf2ee2Smrg IFS=: 280297cf2ee2Smrg for func_convert_core_path_wine_to_w32_f in $1; do 280397cf2ee2Smrg IFS=$oldIFS 280497cf2ee2Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805edce3322Smrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 280697cf2ee2Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807edce3322Smrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 280897cf2ee2Smrg else 280997cf2ee2Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 281097cf2ee2Smrg fi 281197cf2ee2Smrg fi 281297cf2ee2Smrg done 281397cf2ee2Smrg IFS=$oldIFS 281497cf2ee2Smrg fi 281597cf2ee2Smrg} 281697cf2ee2Smrg# end: func_convert_core_path_wine_to_w32 281797cf2ee2Smrg 281897cf2ee2Smrg 281997cf2ee2Smrg# func_cygpath ARGS... 282097cf2ee2Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 282197cf2ee2Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 282297cf2ee2Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 282397cf2ee2Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 282497cf2ee2Smrg# file name or path is assumed to be in w32 format, as previously converted 282597cf2ee2Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 282697cf2ee2Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 282797cf2ee2Smrg# Cygwin format). Returns an empty string on error. 282897cf2ee2Smrg# 282997cf2ee2Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 283097cf2ee2Smrg# be converted. 283197cf2ee2Smrg# 283297cf2ee2Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 283397cf2ee2Smrg# environment variable; do not put it in $PATH. 283497cf2ee2Smrgfunc_cygpath () 283597cf2ee2Smrg{ 2836edce3322Smrg $debug_cmd 2837edce3322Smrg 283897cf2ee2Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 283997cf2ee2Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 284097cf2ee2Smrg if test "$?" -ne 0; then 284197cf2ee2Smrg # on failure, ensure result is empty 284297cf2ee2Smrg func_cygpath_result= 284397cf2ee2Smrg fi 284497cf2ee2Smrg else 284597cf2ee2Smrg func_cygpath_result= 2846edce3322Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 284797cf2ee2Smrg fi 284897cf2ee2Smrg} 284997cf2ee2Smrg#end: func_cygpath 285097cf2ee2Smrg 285197cf2ee2Smrg 285297cf2ee2Smrg# func_convert_core_msys_to_w32 ARG 285397cf2ee2Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 285497cf2ee2Smrg# result in func_convert_core_msys_to_w32_result. 285597cf2ee2Smrgfunc_convert_core_msys_to_w32 () 285697cf2ee2Smrg{ 2857edce3322Smrg $debug_cmd 2858edce3322Smrg 285997cf2ee2Smrg # awkward: cmd appends spaces to result 286097cf2ee2Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861edce3322Smrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 286297cf2ee2Smrg} 286397cf2ee2Smrg#end: func_convert_core_msys_to_w32 286497cf2ee2Smrg 286597cf2ee2Smrg 286697cf2ee2Smrg# func_convert_file_check ARG1 ARG2 286797cf2ee2Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 286897cf2ee2Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 286997cf2ee2Smrg# func_to_host_file_result to ARG1). 287097cf2ee2Smrgfunc_convert_file_check () 287197cf2ee2Smrg{ 2872edce3322Smrg $debug_cmd 2873edce3322Smrg 2874edce3322Smrg if test -z "$2" && test -n "$1"; then 287597cf2ee2Smrg func_error "Could not determine host file name corresponding to" 2876edce3322Smrg func_error " '$1'" 287797cf2ee2Smrg func_error "Continuing, but uninstalled executables may not work." 287897cf2ee2Smrg # Fallback: 2879edce3322Smrg func_to_host_file_result=$1 288097cf2ee2Smrg fi 288197cf2ee2Smrg} 288297cf2ee2Smrg# end func_convert_file_check 288397cf2ee2Smrg 288497cf2ee2Smrg 288597cf2ee2Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 288697cf2ee2Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 288797cf2ee2Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 288897cf2ee2Smrg# func_to_host_file_result to a simplistic fallback value (see below). 288997cf2ee2Smrgfunc_convert_path_check () 289097cf2ee2Smrg{ 2891edce3322Smrg $debug_cmd 2892edce3322Smrg 289397cf2ee2Smrg if test -z "$4" && test -n "$3"; then 289497cf2ee2Smrg func_error "Could not determine the host path corresponding to" 2895edce3322Smrg func_error " '$3'" 289697cf2ee2Smrg func_error "Continuing, but uninstalled executables may not work." 289797cf2ee2Smrg # Fallback. This is a deliberately simplistic "conversion" and 289897cf2ee2Smrg # should not be "improved". See libtool.info. 289997cf2ee2Smrg if test "x$1" != "x$2"; then 290097cf2ee2Smrg lt_replace_pathsep_chars="s|$1|$2|g" 290197cf2ee2Smrg func_to_host_path_result=`echo "$3" | 290297cf2ee2Smrg $SED -e "$lt_replace_pathsep_chars"` 290397cf2ee2Smrg else 2904edce3322Smrg func_to_host_path_result=$3 290597cf2ee2Smrg fi 290697cf2ee2Smrg fi 290797cf2ee2Smrg} 290897cf2ee2Smrg# end func_convert_path_check 290997cf2ee2Smrg 291097cf2ee2Smrg 291197cf2ee2Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 291297cf2ee2Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 291397cf2ee2Smrg# and appending REPL if ORIG matches BACKPAT. 291497cf2ee2Smrgfunc_convert_path_front_back_pathsep () 291597cf2ee2Smrg{ 2916edce3322Smrg $debug_cmd 2917edce3322Smrg 291897cf2ee2Smrg case $4 in 2919edce3322Smrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 292097cf2ee2Smrg ;; 292197cf2ee2Smrg esac 292297cf2ee2Smrg case $4 in 292397cf2ee2Smrg $2 ) func_append func_to_host_path_result "$3" 292497cf2ee2Smrg ;; 292597cf2ee2Smrg esac 292697cf2ee2Smrg} 292797cf2ee2Smrg# end func_convert_path_front_back_pathsep 292897cf2ee2Smrg 292997cf2ee2Smrg 293097cf2ee2Smrg################################################## 293197cf2ee2Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 293297cf2ee2Smrg################################################## 2933edce3322Smrg# invoked via '$to_host_file_cmd ARG' 293497cf2ee2Smrg# 293597cf2ee2Smrg# In each case, ARG is the path to be converted from $build to $host format. 293697cf2ee2Smrg# Result will be available in $func_to_host_file_result. 293797cf2ee2Smrg 293897cf2ee2Smrg 293997cf2ee2Smrg# func_to_host_file ARG 294097cf2ee2Smrg# Converts the file name ARG from $build format to $host format. Return result 294197cf2ee2Smrg# in func_to_host_file_result. 294297cf2ee2Smrgfunc_to_host_file () 294397cf2ee2Smrg{ 2944edce3322Smrg $debug_cmd 2945edce3322Smrg 294697cf2ee2Smrg $to_host_file_cmd "$1" 294797cf2ee2Smrg} 294897cf2ee2Smrg# end func_to_host_file 294997cf2ee2Smrg 295097cf2ee2Smrg 295197cf2ee2Smrg# func_to_tool_file ARG LAZY 295297cf2ee2Smrg# converts the file name ARG from $build format to toolchain format. Return 295397cf2ee2Smrg# result in func_to_tool_file_result. If the conversion in use is listed 295497cf2ee2Smrg# in (the comma separated) LAZY, no conversion takes place. 295597cf2ee2Smrgfunc_to_tool_file () 295697cf2ee2Smrg{ 2957edce3322Smrg $debug_cmd 2958edce3322Smrg 295997cf2ee2Smrg case ,$2, in 296097cf2ee2Smrg *,"$to_tool_file_cmd",*) 296197cf2ee2Smrg func_to_tool_file_result=$1 296297cf2ee2Smrg ;; 296397cf2ee2Smrg *) 296497cf2ee2Smrg $to_tool_file_cmd "$1" 296597cf2ee2Smrg func_to_tool_file_result=$func_to_host_file_result 296697cf2ee2Smrg ;; 296797cf2ee2Smrg esac 296897cf2ee2Smrg} 296997cf2ee2Smrg# end func_to_tool_file 297097cf2ee2Smrg 297197cf2ee2Smrg 297297cf2ee2Smrg# func_convert_file_noop ARG 297397cf2ee2Smrg# Copy ARG to func_to_host_file_result. 297497cf2ee2Smrgfunc_convert_file_noop () 297597cf2ee2Smrg{ 2976edce3322Smrg func_to_host_file_result=$1 297797cf2ee2Smrg} 297897cf2ee2Smrg# end func_convert_file_noop 297997cf2ee2Smrg 298097cf2ee2Smrg 298197cf2ee2Smrg# func_convert_file_msys_to_w32 ARG 298297cf2ee2Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 298397cf2ee2Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 298497cf2ee2Smrg# func_to_host_file_result. 298597cf2ee2Smrgfunc_convert_file_msys_to_w32 () 298697cf2ee2Smrg{ 2987edce3322Smrg $debug_cmd 2988edce3322Smrg 2989edce3322Smrg func_to_host_file_result=$1 299097cf2ee2Smrg if test -n "$1"; then 299197cf2ee2Smrg func_convert_core_msys_to_w32 "$1" 2992edce3322Smrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 299397cf2ee2Smrg fi 299497cf2ee2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 299597cf2ee2Smrg} 299697cf2ee2Smrg# end func_convert_file_msys_to_w32 299797cf2ee2Smrg 299897cf2ee2Smrg 299997cf2ee2Smrg# func_convert_file_cygwin_to_w32 ARG 300097cf2ee2Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 300197cf2ee2Smrg# func_to_host_file_result. 300297cf2ee2Smrgfunc_convert_file_cygwin_to_w32 () 300397cf2ee2Smrg{ 3004edce3322Smrg $debug_cmd 3005edce3322Smrg 3006edce3322Smrg func_to_host_file_result=$1 300797cf2ee2Smrg if test -n "$1"; then 300897cf2ee2Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 300997cf2ee2Smrg # LT_CYGPATH in this case. 301097cf2ee2Smrg func_to_host_file_result=`cygpath -m "$1"` 301197cf2ee2Smrg fi 301297cf2ee2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 301397cf2ee2Smrg} 301497cf2ee2Smrg# end func_convert_file_cygwin_to_w32 301597cf2ee2Smrg 301697cf2ee2Smrg 301797cf2ee2Smrg# func_convert_file_nix_to_w32 ARG 301897cf2ee2Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 301997cf2ee2Smrg# and a working winepath. Returns result in func_to_host_file_result. 302097cf2ee2Smrgfunc_convert_file_nix_to_w32 () 302197cf2ee2Smrg{ 3022edce3322Smrg $debug_cmd 3023edce3322Smrg 3024edce3322Smrg func_to_host_file_result=$1 302597cf2ee2Smrg if test -n "$1"; then 302697cf2ee2Smrg func_convert_core_file_wine_to_w32 "$1" 3027edce3322Smrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 302897cf2ee2Smrg fi 302997cf2ee2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 303097cf2ee2Smrg} 303197cf2ee2Smrg# end func_convert_file_nix_to_w32 303297cf2ee2Smrg 303397cf2ee2Smrg 303497cf2ee2Smrg# func_convert_file_msys_to_cygwin ARG 303597cf2ee2Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 303697cf2ee2Smrg# Returns result in func_to_host_file_result. 303797cf2ee2Smrgfunc_convert_file_msys_to_cygwin () 303897cf2ee2Smrg{ 3039edce3322Smrg $debug_cmd 3040edce3322Smrg 3041edce3322Smrg func_to_host_file_result=$1 304297cf2ee2Smrg if test -n "$1"; then 304397cf2ee2Smrg func_convert_core_msys_to_w32 "$1" 304497cf2ee2Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045edce3322Smrg func_to_host_file_result=$func_cygpath_result 304697cf2ee2Smrg fi 304797cf2ee2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 304897cf2ee2Smrg} 304997cf2ee2Smrg# end func_convert_file_msys_to_cygwin 305097cf2ee2Smrg 305197cf2ee2Smrg 305297cf2ee2Smrg# func_convert_file_nix_to_cygwin ARG 305397cf2ee2Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 305497cf2ee2Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 305597cf2ee2Smrg# in func_to_host_file_result. 305697cf2ee2Smrgfunc_convert_file_nix_to_cygwin () 305797cf2ee2Smrg{ 3058edce3322Smrg $debug_cmd 3059edce3322Smrg 3060edce3322Smrg func_to_host_file_result=$1 306197cf2ee2Smrg if test -n "$1"; then 306297cf2ee2Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 306397cf2ee2Smrg func_convert_core_file_wine_to_w32 "$1" 306497cf2ee2Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065edce3322Smrg func_to_host_file_result=$func_cygpath_result 306697cf2ee2Smrg fi 306797cf2ee2Smrg func_convert_file_check "$1" "$func_to_host_file_result" 306897cf2ee2Smrg} 306997cf2ee2Smrg# end func_convert_file_nix_to_cygwin 307097cf2ee2Smrg 307197cf2ee2Smrg 307297cf2ee2Smrg############################################# 307397cf2ee2Smrg# $build to $host PATH CONVERSION FUNCTIONS # 307497cf2ee2Smrg############################################# 3075edce3322Smrg# invoked via '$to_host_path_cmd ARG' 307697cf2ee2Smrg# 307797cf2ee2Smrg# In each case, ARG is the path to be converted from $build to $host format. 307897cf2ee2Smrg# The result will be available in $func_to_host_path_result. 307997cf2ee2Smrg# 308097cf2ee2Smrg# Path separators are also converted from $build format to $host format. If 308197cf2ee2Smrg# ARG begins or ends with a path separator character, it is preserved (but 308297cf2ee2Smrg# converted to $host format) on output. 308397cf2ee2Smrg# 308497cf2ee2Smrg# All path conversion functions are named using the following convention: 308597cf2ee2Smrg# file name conversion function : func_convert_file_X_to_Y () 308697cf2ee2Smrg# path conversion function : func_convert_path_X_to_Y () 308797cf2ee2Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 308897cf2ee2Smrg# same. If conversion functions are added for new $build/$host combinations, 308997cf2ee2Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 309097cf2ee2Smrg# will break. 309197cf2ee2Smrg 309297cf2ee2Smrg 309397cf2ee2Smrg# func_init_to_host_path_cmd 309497cf2ee2Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 309597cf2ee2Smrg# appropriate value, based on the value of $to_host_file_cmd. 309697cf2ee2Smrgto_host_path_cmd= 309797cf2ee2Smrgfunc_init_to_host_path_cmd () 309897cf2ee2Smrg{ 3099edce3322Smrg $debug_cmd 3100edce3322Smrg 310197cf2ee2Smrg if test -z "$to_host_path_cmd"; then 310297cf2ee2Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103edce3322Smrg to_host_path_cmd=func_convert_path_$func_stripname_result 310497cf2ee2Smrg fi 310597cf2ee2Smrg} 310697cf2ee2Smrg 310797cf2ee2Smrg 310897cf2ee2Smrg# func_to_host_path ARG 310997cf2ee2Smrg# Converts the path ARG from $build format to $host format. Return result 311097cf2ee2Smrg# in func_to_host_path_result. 311197cf2ee2Smrgfunc_to_host_path () 311297cf2ee2Smrg{ 3113edce3322Smrg $debug_cmd 3114edce3322Smrg 311597cf2ee2Smrg func_init_to_host_path_cmd 311697cf2ee2Smrg $to_host_path_cmd "$1" 311797cf2ee2Smrg} 311897cf2ee2Smrg# end func_to_host_path 311997cf2ee2Smrg 312097cf2ee2Smrg 312197cf2ee2Smrg# func_convert_path_noop ARG 312297cf2ee2Smrg# Copy ARG to func_to_host_path_result. 312397cf2ee2Smrgfunc_convert_path_noop () 312497cf2ee2Smrg{ 3125edce3322Smrg func_to_host_path_result=$1 312697cf2ee2Smrg} 312797cf2ee2Smrg# end func_convert_path_noop 312897cf2ee2Smrg 312997cf2ee2Smrg 313097cf2ee2Smrg# func_convert_path_msys_to_w32 ARG 313197cf2ee2Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 313297cf2ee2Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 313397cf2ee2Smrg# func_to_host_path_result. 313497cf2ee2Smrgfunc_convert_path_msys_to_w32 () 31356e7d3316Smrg{ 3136edce3322Smrg $debug_cmd 3137edce3322Smrg 3138edce3322Smrg func_to_host_path_result=$1 313997cf2ee2Smrg if test -n "$1"; then 314097cf2ee2Smrg # Remove leading and trailing path separator characters from ARG. MSYS 314197cf2ee2Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 314297cf2ee2Smrg # and winepath ignores them completely. 314397cf2ee2Smrg func_stripname : : "$1" 314497cf2ee2Smrg func_to_host_path_tmp1=$func_stripname_result 314597cf2ee2Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146edce3322Smrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 314797cf2ee2Smrg func_convert_path_check : ";" \ 314897cf2ee2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 314997cf2ee2Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 315097cf2ee2Smrg fi 315197cf2ee2Smrg} 315297cf2ee2Smrg# end func_convert_path_msys_to_w32 31536e7d3316Smrg 31546e7d3316Smrg 315597cf2ee2Smrg# func_convert_path_cygwin_to_w32 ARG 315697cf2ee2Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 315797cf2ee2Smrg# func_to_host_file_result. 315897cf2ee2Smrgfunc_convert_path_cygwin_to_w32 () 315997cf2ee2Smrg{ 3160edce3322Smrg $debug_cmd 3161edce3322Smrg 3162edce3322Smrg func_to_host_path_result=$1 316397cf2ee2Smrg if test -n "$1"; then 316497cf2ee2Smrg # See func_convert_path_msys_to_w32: 316597cf2ee2Smrg func_stripname : : "$1" 316697cf2ee2Smrg func_to_host_path_tmp1=$func_stripname_result 316797cf2ee2Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 316897cf2ee2Smrg func_convert_path_check : ";" \ 316997cf2ee2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 317097cf2ee2Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 317197cf2ee2Smrg fi 317297cf2ee2Smrg} 317397cf2ee2Smrg# end func_convert_path_cygwin_to_w32 31746e7d3316Smrg 31756e7d3316Smrg 317697cf2ee2Smrg# func_convert_path_nix_to_w32 ARG 317797cf2ee2Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 317897cf2ee2Smrg# a working winepath. Returns result in func_to_host_file_result. 317997cf2ee2Smrgfunc_convert_path_nix_to_w32 () 318097cf2ee2Smrg{ 3181edce3322Smrg $debug_cmd 3182edce3322Smrg 3183edce3322Smrg func_to_host_path_result=$1 318497cf2ee2Smrg if test -n "$1"; then 318597cf2ee2Smrg # See func_convert_path_msys_to_w32: 318697cf2ee2Smrg func_stripname : : "$1" 318797cf2ee2Smrg func_to_host_path_tmp1=$func_stripname_result 318897cf2ee2Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189edce3322Smrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 319097cf2ee2Smrg func_convert_path_check : ";" \ 319197cf2ee2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 319297cf2ee2Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 319397cf2ee2Smrg fi 319497cf2ee2Smrg} 319597cf2ee2Smrg# end func_convert_path_nix_to_w32 31966e7d3316Smrg 319797cf2ee2Smrg 319897cf2ee2Smrg# func_convert_path_msys_to_cygwin ARG 319997cf2ee2Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 320097cf2ee2Smrg# Returns result in func_to_host_file_result. 320197cf2ee2Smrgfunc_convert_path_msys_to_cygwin () 320297cf2ee2Smrg{ 3203edce3322Smrg $debug_cmd 3204edce3322Smrg 3205edce3322Smrg func_to_host_path_result=$1 320697cf2ee2Smrg if test -n "$1"; then 320797cf2ee2Smrg # See func_convert_path_msys_to_w32: 320897cf2ee2Smrg func_stripname : : "$1" 320997cf2ee2Smrg func_to_host_path_tmp1=$func_stripname_result 321097cf2ee2Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 321197cf2ee2Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212edce3322Smrg func_to_host_path_result=$func_cygpath_result 321397cf2ee2Smrg func_convert_path_check : : \ 321497cf2ee2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 321597cf2ee2Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 321697cf2ee2Smrg fi 321797cf2ee2Smrg} 321897cf2ee2Smrg# end func_convert_path_msys_to_cygwin 321997cf2ee2Smrg 322097cf2ee2Smrg 322197cf2ee2Smrg# func_convert_path_nix_to_cygwin ARG 322297cf2ee2Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 322397cf2ee2Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 322497cf2ee2Smrg# func_to_host_file_result. 322597cf2ee2Smrgfunc_convert_path_nix_to_cygwin () 322697cf2ee2Smrg{ 3227edce3322Smrg $debug_cmd 3228edce3322Smrg 3229edce3322Smrg func_to_host_path_result=$1 323097cf2ee2Smrg if test -n "$1"; then 323197cf2ee2Smrg # Remove leading and trailing path separator characters from 323297cf2ee2Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 323397cf2ee2Smrg # into '.;' and ';.', and winepath ignores them completely. 323497cf2ee2Smrg func_stripname : : "$1" 323597cf2ee2Smrg func_to_host_path_tmp1=$func_stripname_result 323697cf2ee2Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 323797cf2ee2Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238edce3322Smrg func_to_host_path_result=$func_cygpath_result 323997cf2ee2Smrg func_convert_path_check : : \ 324097cf2ee2Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 324197cf2ee2Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 324297cf2ee2Smrg fi 32436e7d3316Smrg} 324497cf2ee2Smrg# end func_convert_path_nix_to_cygwin 324597cf2ee2Smrg 32466e7d3316Smrg 3247edce3322Smrg# func_dll_def_p FILE 3248edce3322Smrg# True iff FILE is a Windows DLL '.def' file. 3249edce3322Smrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250edce3322Smrgfunc_dll_def_p () 3251edce3322Smrg{ 3252edce3322Smrg $debug_cmd 3253edce3322Smrg 3254edce3322Smrg func_dll_def_p_tmp=`$SED -n \ 3255edce3322Smrg -e 's/^[ ]*//' \ 3256edce3322Smrg -e '/^\(;.*\)*$/d' \ 3257edce3322Smrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258edce3322Smrg -e q \ 3259edce3322Smrg "$1"` 3260edce3322Smrg test DEF = "$func_dll_def_p_tmp" 3261edce3322Smrg} 3262edce3322Smrg 3263edce3322Smrg 32646e7d3316Smrg# func_mode_compile arg... 32656e7d3316Smrgfunc_mode_compile () 32666e7d3316Smrg{ 3267edce3322Smrg $debug_cmd 3268edce3322Smrg 32696e7d3316Smrg # Get the compilation command and the source file. 32706e7d3316Smrg base_compile= 3271edce3322Smrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 32726e7d3316Smrg suppress_opt=yes 32736e7d3316Smrg suppress_output= 32746e7d3316Smrg arg_mode=normal 32756e7d3316Smrg libobj= 32766e7d3316Smrg later= 32776e7d3316Smrg pie_flag= 32786e7d3316Smrg 32796e7d3316Smrg for arg 32806e7d3316Smrg do 32816e7d3316Smrg case $arg_mode in 32826e7d3316Smrg arg ) 32836e7d3316Smrg # do not "continue". Instead, add this to base_compile 3284edce3322Smrg lastarg=$arg 32856e7d3316Smrg arg_mode=normal 32866e7d3316Smrg ;; 32876e7d3316Smrg 32886e7d3316Smrg target ) 3289edce3322Smrg libobj=$arg 32906e7d3316Smrg arg_mode=normal 32916e7d3316Smrg continue 32926e7d3316Smrg ;; 32936e7d3316Smrg 32946e7d3316Smrg normal ) 32956e7d3316Smrg # Accept any command-line options. 32966e7d3316Smrg case $arg in 32976e7d3316Smrg -o) 32986e7d3316Smrg test -n "$libobj" && \ 3299edce3322Smrg func_fatal_error "you cannot specify '-o' more than once" 33006e7d3316Smrg arg_mode=target 33016e7d3316Smrg continue 33026e7d3316Smrg ;; 33036e7d3316Smrg 33046e7d3316Smrg -pie | -fpie | -fPIE) 330597cf2ee2Smrg func_append pie_flag " $arg" 33066e7d3316Smrg continue 33076e7d3316Smrg ;; 33086e7d3316Smrg 33096e7d3316Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 331097cf2ee2Smrg func_append later " $arg" 33116e7d3316Smrg continue 33126e7d3316Smrg ;; 3313a966c04fSmrg 3314a966c04fSmrg -no-suppress) 3315a966c04fSmrg suppress_opt=no 3316a966c04fSmrg continue 3317a966c04fSmrg ;; 3318a966c04fSmrg 3319a966c04fSmrg -Xcompiler) 3320a966c04fSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 3321a966c04fSmrg continue # The current "srcfile" will either be retained or 3322a966c04fSmrg ;; # replaced later. I would guess that would be a bug. 3323a966c04fSmrg 3324a966c04fSmrg -Wc,*) 33256e7d3316Smrg func_stripname '-Wc,' '' "$arg" 33266e7d3316Smrg args=$func_stripname_result 3327a966c04fSmrg lastarg= 3328edce3322Smrg save_ifs=$IFS; IFS=, 33296e7d3316Smrg for arg in $args; do 3330edce3322Smrg IFS=$save_ifs 333197cf2ee2Smrg func_append_quoted lastarg "$arg" 3332a966c04fSmrg done 3333edce3322Smrg IFS=$save_ifs 33346e7d3316Smrg func_stripname ' ' '' "$lastarg" 33356e7d3316Smrg lastarg=$func_stripname_result 3336a966c04fSmrg 3337a966c04fSmrg # Add the arguments to base_compile. 333897cf2ee2Smrg func_append base_compile " $lastarg" 3339a966c04fSmrg continue 3340a966c04fSmrg ;; 3341a966c04fSmrg 33426e7d3316Smrg *) 3343a966c04fSmrg # Accept the current argument as the source file. 3344a966c04fSmrg # The previous "srcfile" becomes the current argument. 3345a966c04fSmrg # 3346edce3322Smrg lastarg=$srcfile 3347edce3322Smrg srcfile=$arg 3348a966c04fSmrg ;; 3349a966c04fSmrg esac # case $arg 3350a966c04fSmrg ;; 3351a966c04fSmrg esac # case $arg_mode 3352a966c04fSmrg 3353a966c04fSmrg # Aesthetically quote the previous argument. 335497cf2ee2Smrg func_append_quoted base_compile "$lastarg" 3355a966c04fSmrg done # for arg 3356a966c04fSmrg 3357a966c04fSmrg case $arg_mode in 3358a966c04fSmrg arg) 33596e7d3316Smrg func_fatal_error "you must specify an argument for -Xcompile" 3360a966c04fSmrg ;; 3361a966c04fSmrg target) 3362edce3322Smrg func_fatal_error "you must specify a target with '-o'" 3363a966c04fSmrg ;; 3364a966c04fSmrg *) 3365a966c04fSmrg # Get the name of the library object. 33666e7d3316Smrg test -z "$libobj" && { 33676e7d3316Smrg func_basename "$srcfile" 3368edce3322Smrg libobj=$func_basename_result 33696e7d3316Smrg } 3370a966c04fSmrg ;; 3371a966c04fSmrg esac 3372a966c04fSmrg 3373a966c04fSmrg # Recognize several different file suffixes. 3374a966c04fSmrg # If the user specifies -o file.o, it is replaced with file.lo 3375a966c04fSmrg case $libobj in 33766e7d3316Smrg *.[cCFSifmso] | \ 33776e7d3316Smrg *.ada | *.adb | *.ads | *.asm | \ 33786e7d3316Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379ac92798bSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 33806e7d3316Smrg func_xform "$libobj" 33816e7d3316Smrg libobj=$func_xform_result 33826e7d3316Smrg ;; 3383a966c04fSmrg esac 3384a966c04fSmrg 3385a966c04fSmrg case $libobj in 33866e7d3316Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387a966c04fSmrg *) 3388edce3322Smrg func_fatal_error "cannot determine name of library object from '$libobj'" 3389a966c04fSmrg ;; 3390a966c04fSmrg esac 3391a966c04fSmrg 3392a966c04fSmrg func_infer_tag $base_compile 3393a966c04fSmrg 3394a966c04fSmrg for arg in $later; do 3395a966c04fSmrg case $arg in 33966e7d3316Smrg -shared) 3397edce3322Smrg test yes = "$build_libtool_libs" \ 3398edce3322Smrg || func_fatal_configuration "cannot build a shared library" 33996e7d3316Smrg build_old_libs=no 34006e7d3316Smrg continue 34016e7d3316Smrg ;; 34026e7d3316Smrg 3403a966c04fSmrg -static) 34046e7d3316Smrg build_libtool_libs=no 3405a966c04fSmrg build_old_libs=yes 3406a966c04fSmrg continue 3407a966c04fSmrg ;; 3408a966c04fSmrg 3409a966c04fSmrg -prefer-pic) 3410a966c04fSmrg pic_mode=yes 3411a966c04fSmrg continue 3412a966c04fSmrg ;; 3413a966c04fSmrg 3414a966c04fSmrg -prefer-non-pic) 3415a966c04fSmrg pic_mode=no 3416a966c04fSmrg continue 3417a966c04fSmrg ;; 3418a966c04fSmrg esac 3419a966c04fSmrg done 3420a966c04fSmrg 34211c235774Smrg func_quote_for_eval "$libobj" 34221c235774Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 34236e7d3316Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424edce3322Smrg && func_warning "libobj name '$libobj' may not contain shell special characters." 34256e7d3316Smrg func_dirname_and_basename "$obj" "/" "" 3426edce3322Smrg objname=$func_basename_result 3427edce3322Smrg xdir=$func_dirname_result 3428edce3322Smrg lobj=$xdir$objdir/$objname 3429a966c04fSmrg 34306e7d3316Smrg test -z "$base_compile" && \ 34316e7d3316Smrg func_fatal_help "you must specify a compilation command" 3432a966c04fSmrg 3433a966c04fSmrg # Delete any leftover library objects. 3434edce3322Smrg if test yes = "$build_old_libs"; then 3435a966c04fSmrg removelist="$obj $lobj $libobj ${libobj}T" 3436a966c04fSmrg else 3437a966c04fSmrg removelist="$lobj $libobj ${libobj}T" 3438a966c04fSmrg fi 3439a966c04fSmrg 3440a966c04fSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 3441a966c04fSmrg case $host_os in 34426e7d3316Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3443a966c04fSmrg pic_mode=default 3444a966c04fSmrg ;; 3445a966c04fSmrg esac 3446edce3322Smrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447a966c04fSmrg # non-PIC code in shared libraries is not supported 3448a966c04fSmrg pic_mode=default 3449a966c04fSmrg fi 3450a966c04fSmrg 3451a966c04fSmrg # Calculate the filename of the output object if compiler does 3452a966c04fSmrg # not support -o with -c 3453edce3322Smrg if test no = "$compiler_c_o"; then 3454edce3322Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455edce3322Smrg lockfile=$output_obj.lock 3456a966c04fSmrg else 3457a966c04fSmrg output_obj= 3458a966c04fSmrg need_locks=no 3459a966c04fSmrg lockfile= 3460a966c04fSmrg fi 3461a966c04fSmrg 3462a966c04fSmrg # Lock this critical section if it is needed 3463a966c04fSmrg # We use this script file to make the link, it avoids creating a new file 3464edce3322Smrg if test yes = "$need_locks"; then 34656e7d3316Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 34666e7d3316Smrg func_echo "Waiting for $lockfile to be removed" 3467a966c04fSmrg sleep 2 3468a966c04fSmrg done 3469edce3322Smrg elif test warn = "$need_locks"; then 3470a966c04fSmrg if test -f "$lockfile"; then 34716e7d3316Smrg $ECHO "\ 3472a966c04fSmrg*** ERROR, $lockfile exists and contains: 3473a966c04fSmrg`cat $lockfile 2>/dev/null` 3474a966c04fSmrg 3475a966c04fSmrgThis indicates that another process is trying to use the same 3476a966c04fSmrgtemporary object file, and libtool could not work around it because 3477edce3322Smrgyour compiler does not support '-c' and '-o' together. If you 3478a966c04fSmrgrepeat this compilation, it may succeed, by chance, but you had better 3479a966c04fSmrgavoid parallel builds (make -j) in this platform, or get a better 3480a966c04fSmrgcompiler." 3481a966c04fSmrg 34826e7d3316Smrg $opt_dry_run || $RM $removelist 3483a966c04fSmrg exit $EXIT_FAILURE 3484a966c04fSmrg fi 348597cf2ee2Smrg func_append removelist " $output_obj" 34866e7d3316Smrg $ECHO "$srcfile" > "$lockfile" 3487a966c04fSmrg fi 3488a966c04fSmrg 34896e7d3316Smrg $opt_dry_run || $RM $removelist 349097cf2ee2Smrg func_append removelist " $lockfile" 34916e7d3316Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 34926e7d3316Smrg 349397cf2ee2Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 349497cf2ee2Smrg srcfile=$func_to_tool_file_result 34951c235774Smrg func_quote_for_eval "$srcfile" 34961c235774Smrg qsrcfile=$func_quote_for_eval_result 3497a966c04fSmrg 3498a966c04fSmrg # Only build a PIC object if we are building libtool libraries. 3499edce3322Smrg if test yes = "$build_libtool_libs"; then 3500a966c04fSmrg # Without this assignment, base_compile gets emptied. 3501a966c04fSmrg fbsd_hideous_sh_bug=$base_compile 3502a966c04fSmrg 3503edce3322Smrg if test no != "$pic_mode"; then 3504a966c04fSmrg command="$base_compile $qsrcfile $pic_flag" 3505a966c04fSmrg else 3506a966c04fSmrg # Don't build PIC code 3507a966c04fSmrg command="$base_compile $qsrcfile" 3508a966c04fSmrg fi 3509a966c04fSmrg 35106e7d3316Smrg func_mkdir_p "$xdir$objdir" 3511a966c04fSmrg 3512a966c04fSmrg if test -z "$output_obj"; then 3513a966c04fSmrg # Place PIC objects in $objdir 351497cf2ee2Smrg func_append command " -o $lobj" 3515a966c04fSmrg fi 3516a966c04fSmrg 35176e7d3316Smrg func_show_eval_locale "$command" \ 35186e7d3316Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519a966c04fSmrg 3520edce3322Smrg if test warn = "$need_locks" && 3521a966c04fSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35226e7d3316Smrg $ECHO "\ 3523a966c04fSmrg*** ERROR, $lockfile contains: 3524a966c04fSmrg`cat $lockfile 2>/dev/null` 3525a966c04fSmrg 3526a966c04fSmrgbut it should contain: 3527a966c04fSmrg$srcfile 3528a966c04fSmrg 3529a966c04fSmrgThis indicates that another process is trying to use the same 3530a966c04fSmrgtemporary object file, and libtool could not work around it because 3531edce3322Smrgyour compiler does not support '-c' and '-o' together. If you 3532a966c04fSmrgrepeat this compilation, it may succeed, by chance, but you had better 3533a966c04fSmrgavoid parallel builds (make -j) in this platform, or get a better 3534a966c04fSmrgcompiler." 3535a966c04fSmrg 35366e7d3316Smrg $opt_dry_run || $RM $removelist 3537a966c04fSmrg exit $EXIT_FAILURE 3538a966c04fSmrg fi 3539a966c04fSmrg 3540a966c04fSmrg # Just move the object if needed, then go on to compile the next one 3541a966c04fSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 35426e7d3316Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 35436e7d3316Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544a966c04fSmrg fi 3545a966c04fSmrg 3546a966c04fSmrg # Allow error messages only from the first compilation. 3547edce3322Smrg if test yes = "$suppress_opt"; then 35486e7d3316Smrg suppress_output=' >/dev/null 2>&1' 3549a966c04fSmrg fi 3550a966c04fSmrg fi 3551a966c04fSmrg 3552a966c04fSmrg # Only build a position-dependent object if we build old libraries. 3553edce3322Smrg if test yes = "$build_old_libs"; then 3554edce3322Smrg if test yes != "$pic_mode"; then 3555a966c04fSmrg # Don't build PIC code 35566e7d3316Smrg command="$base_compile $qsrcfile$pie_flag" 3557a966c04fSmrg else 3558a966c04fSmrg command="$base_compile $qsrcfile $pic_flag" 3559a966c04fSmrg fi 3560edce3322Smrg if test yes = "$compiler_c_o"; then 356197cf2ee2Smrg func_append command " -o $obj" 3562a966c04fSmrg fi 3563a966c04fSmrg 3564a966c04fSmrg # Suppress compiler output if we already did a PIC compilation. 356597cf2ee2Smrg func_append command "$suppress_output" 35666e7d3316Smrg func_show_eval_locale "$command" \ 35676e7d3316Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568a966c04fSmrg 3569edce3322Smrg if test warn = "$need_locks" && 3570a966c04fSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 35716e7d3316Smrg $ECHO "\ 3572a966c04fSmrg*** ERROR, $lockfile contains: 3573a966c04fSmrg`cat $lockfile 2>/dev/null` 3574a966c04fSmrg 3575a966c04fSmrgbut it should contain: 3576a966c04fSmrg$srcfile 3577a966c04fSmrg 3578a966c04fSmrgThis indicates that another process is trying to use the same 3579a966c04fSmrgtemporary object file, and libtool could not work around it because 3580edce3322Smrgyour compiler does not support '-c' and '-o' together. If you 3581a966c04fSmrgrepeat this compilation, it may succeed, by chance, but you had better 3582a966c04fSmrgavoid parallel builds (make -j) in this platform, or get a better 3583a966c04fSmrgcompiler." 3584a966c04fSmrg 35856e7d3316Smrg $opt_dry_run || $RM $removelist 3586a966c04fSmrg exit $EXIT_FAILURE 3587a966c04fSmrg fi 3588a966c04fSmrg 3589a966c04fSmrg # Just move the object if needed 3590a966c04fSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 35916e7d3316Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 35926e7d3316Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593a966c04fSmrg fi 3594a966c04fSmrg fi 3595a966c04fSmrg 35966e7d3316Smrg $opt_dry_run || { 35976e7d3316Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598a966c04fSmrg 35996e7d3316Smrg # Unlock the critical section if it was locked 3600edce3322Smrg if test no != "$need_locks"; then 36016e7d3316Smrg removelist=$lockfile 36026e7d3316Smrg $RM "$lockfile" 36036e7d3316Smrg fi 36046e7d3316Smrg } 3605a966c04fSmrg 3606a966c04fSmrg exit $EXIT_SUCCESS 36076e7d3316Smrg} 3608a966c04fSmrg 36096e7d3316Smrg$opt_help || { 3610edce3322Smrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 36116e7d3316Smrg} 3612a966c04fSmrg 36136e7d3316Smrgfunc_mode_help () 36146e7d3316Smrg{ 36156e7d3316Smrg # We need to display help for each of the modes. 361697cf2ee2Smrg case $opt_mode in 36176e7d3316Smrg "") 36186e7d3316Smrg # Generic help is extracted from the usage comments 36196e7d3316Smrg # at the start of this file. 36206e7d3316Smrg func_help 36216e7d3316Smrg ;; 3622a966c04fSmrg 36236e7d3316Smrg clean) 36246e7d3316Smrg $ECHO \ 36256e7d3316Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626a966c04fSmrg 36276e7d3316SmrgRemove files from the build directory. 3628a966c04fSmrg 36296e7d3316SmrgRM is the name of the program to use to delete files associated with each FILE 3630edce3322Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 36316e7d3316Smrgto RM. 3632a966c04fSmrg 36336e7d3316SmrgIf FILE is a libtool library, object or program, all the files associated 36346e7d3316Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 36356e7d3316Smrg ;; 3636a966c04fSmrg 36376e7d3316Smrg compile) 36386e7d3316Smrg $ECHO \ 36396e7d3316Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640a966c04fSmrg 36416e7d3316SmrgCompile a source file into a libtool library object. 3642a966c04fSmrg 36436e7d3316SmrgThis mode accepts the following additional options: 3644a966c04fSmrg 36456e7d3316Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 36466e7d3316Smrg -no-suppress do not suppress compiler output for multiple passes 36476e7d3316Smrg -prefer-pic try to build PIC objects only 36486e7d3316Smrg -prefer-non-pic try to build non-PIC objects only 3649edce3322Smrg -shared do not build a '.o' file suitable for static linking 3650edce3322Smrg -static only build a '.o' file suitable for static linking 36511c235774Smrg -Wc,FLAG pass FLAG directly to the compiler 3652a966c04fSmrg 3653edce3322SmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 36546e7d3316Smrgfrom the given SOURCEFILE. 3655a966c04fSmrg 36566e7d3316SmrgThe output file name is determined by removing the directory component from 3657edce3322SmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3658edce3322Smrglibrary object suffix, '.lo'." 36596e7d3316Smrg ;; 3660a966c04fSmrg 36616e7d3316Smrg execute) 36626e7d3316Smrg $ECHO \ 36636e7d3316Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664a966c04fSmrg 36656e7d3316SmrgAutomatically set library path, then run a program. 3666a966c04fSmrg 36676e7d3316SmrgThis mode accepts the following additional options: 3668a966c04fSmrg 36696e7d3316Smrg -dlopen FILE add the directory containing FILE to the library path 3670a966c04fSmrg 3671edce3322SmrgThis mode sets the library path environment variable according to '-dlopen' 36726e7d3316Smrgflags. 3673a966c04fSmrg 36746e7d3316SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 36756e7d3316Smrginto their corresponding uninstalled binary, and any of their required library 36766e7d3316Smrgdirectories are added to the library path. 3677a966c04fSmrg 36786e7d3316SmrgThen, COMMAND is executed, with ARGS as arguments." 36796e7d3316Smrg ;; 3680a966c04fSmrg 36816e7d3316Smrg finish) 36826e7d3316Smrg $ECHO \ 36836e7d3316Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684a966c04fSmrg 36856e7d3316SmrgComplete the installation of libtool libraries. 3686a966c04fSmrg 36876e7d3316SmrgEach LIBDIR is a directory that contains libtool libraries. 3688a966c04fSmrg 36896e7d3316SmrgThe commands that this mode executes may require superuser privileges. Use 3690edce3322Smrgthe '--dry-run' option if you just want to see what would be executed." 36916e7d3316Smrg ;; 3692a966c04fSmrg 36936e7d3316Smrg install) 36946e7d3316Smrg $ECHO \ 36956e7d3316Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696a966c04fSmrg 36976e7d3316SmrgInstall executables or libraries. 3698a966c04fSmrg 36996e7d3316SmrgINSTALL-COMMAND is the installation command. The first component should be 3700edce3322Smrgeither the 'install' or 'cp' program. 3701a966c04fSmrg 37026e7d3316SmrgThe following components of INSTALL-COMMAND are treated specially: 3703a966c04fSmrg 37046e7d3316Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705a966c04fSmrg 37066e7d3316SmrgThe rest of the components are interpreted as arguments to that command (only 37076e7d3316SmrgBSD-compatible install options are recognized)." 37086e7d3316Smrg ;; 3709a966c04fSmrg 37106e7d3316Smrg link) 37116e7d3316Smrg $ECHO \ 37126e7d3316Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713a966c04fSmrg 37146e7d3316SmrgLink object files or libraries together to form another library, or to 37156e7d3316Smrgcreate an executable program. 3716a966c04fSmrg 37176e7d3316SmrgLINK-COMMAND is a command using the C compiler that you would use to create 37186e7d3316Smrga program from several object files. 3719a966c04fSmrg 37206e7d3316SmrgThe following components of LINK-COMMAND are treated specially: 3721a966c04fSmrg 37226e7d3316Smrg -all-static do not do any dynamic linking at all 37236e7d3316Smrg -avoid-version do not add a version suffix if possible 37246e7d3316Smrg -bindir BINDIR specify path to binaries directory (for systems where 37256e7d3316Smrg libraries must be found in the PATH setting at runtime) 3726edce3322Smrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 37276e7d3316Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 37286e7d3316Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 37296e7d3316Smrg -export-symbols SYMFILE 37306e7d3316Smrg try to export only the symbols listed in SYMFILE 37316e7d3316Smrg -export-symbols-regex REGEX 37326e7d3316Smrg try to export only the symbols matching REGEX 37336e7d3316Smrg -LLIBDIR search LIBDIR for required installed libraries 37346e7d3316Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 37356e7d3316Smrg -module build a library that can dlopened 37366e7d3316Smrg -no-fast-install disable the fast-install mode 37376e7d3316Smrg -no-install link a not-installable executable 37386e7d3316Smrg -no-undefined declare that a library does not refer to external symbols 37396e7d3316Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740edce3322Smrg -objectlist FILE use a list of object files found in FILE to specify objects 3741edce3322Smrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 37426e7d3316Smrg -precious-files-regex REGEX 37436e7d3316Smrg don't remove output files matching REGEX 37446e7d3316Smrg -release RELEASE specify package release information 37456e7d3316Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 37466e7d3316Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 37476e7d3316Smrg -shared only do dynamic linking of libtool libraries 37486e7d3316Smrg -shrext SUFFIX override the standard shared library file extension 37496e7d3316Smrg -static do not do any dynamic linking of uninstalled libtool libraries 37506e7d3316Smrg -static-libtool-libs 37516e7d3316Smrg do not do any dynamic linking of libtool libraries 37526e7d3316Smrg -version-info CURRENT[:REVISION[:AGE]] 37536e7d3316Smrg specify library version info [each variable defaults to 0] 37546e7d3316Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 37556e7d3316Smrg -Wc,FLAG 37566e7d3316Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 37576e7d3316Smrg -Wl,FLAG 37586e7d3316Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 37596e7d3316Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760a966c04fSmrg 3761edce3322SmrgAll other options (arguments beginning with '-') are ignored. 3762a966c04fSmrg 3763edce3322SmrgEvery other argument is treated as a filename. Files ending in '.la' are 37646e7d3316Smrgtreated as uninstalled libtool libraries, other files are standard or library 37656e7d3316Smrgobject files. 3766a966c04fSmrg 3767edce3322SmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768edce3322Smrgonly library objects ('.lo' files) may be specified, and '-rpath' is 37696e7d3316Smrgrequired, except when creating a convenience library. 3770a966c04fSmrg 3771edce3322SmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772edce3322Smrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 37732e2dd055Smrg 3774edce3322SmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 37756e7d3316Smrgis created, otherwise an executable program is created." 37766e7d3316Smrg ;; 3777a966c04fSmrg 37786e7d3316Smrg uninstall) 37796e7d3316Smrg $ECHO \ 37806e7d3316Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781a966c04fSmrg 37826e7d3316SmrgRemove libraries from an installation directory. 3783a966c04fSmrg 37846e7d3316SmrgRM is the name of the program to use to delete files associated with each FILE 3785edce3322Smrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 37866e7d3316Smrgto RM. 3787a966c04fSmrg 37886e7d3316SmrgIf FILE is a libtool library, all the files associated with it are deleted. 37896e7d3316SmrgOtherwise, only FILE itself is deleted using RM." 37906e7d3316Smrg ;; 3791a966c04fSmrg 37926e7d3316Smrg *) 3793edce3322Smrg func_fatal_help "invalid operation mode '$opt_mode'" 37946e7d3316Smrg ;; 37956e7d3316Smrg esac 3796a966c04fSmrg 37976e7d3316Smrg echo 3798edce3322Smrg $ECHO "Try '$progname --help' for more information about other modes." 37996e7d3316Smrg} 3800a966c04fSmrg 38016e7d3316Smrg# Now that we've collected a possible --mode arg, show help if necessary 38026e7d3316Smrgif $opt_help; then 3803edce3322Smrg if test : = "$opt_help"; then 38046e7d3316Smrg func_mode_help 38056e7d3316Smrg else 38066e7d3316Smrg { 38076e7d3316Smrg func_help noexit 380897cf2ee2Smrg for opt_mode in compile link execute install finish uninstall clean; do 38096e7d3316Smrg func_mode_help 38106e7d3316Smrg done 3811edce3322Smrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 38126e7d3316Smrg { 38136e7d3316Smrg func_help noexit 381497cf2ee2Smrg for opt_mode in compile link execute install finish uninstall clean; do 38156e7d3316Smrg echo 38166e7d3316Smrg func_mode_help 38176e7d3316Smrg done 38186e7d3316Smrg } | 3819edce3322Smrg $SED '1d 38206e7d3316Smrg /^When reporting/,/^Report/{ 38216e7d3316Smrg H 38226e7d3316Smrg d 38236e7d3316Smrg } 38246e7d3316Smrg $x 38256e7d3316Smrg /information about other modes/d 38266e7d3316Smrg /more detailed .*MODE/d 38276e7d3316Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 38286e7d3316Smrg fi 38296e7d3316Smrg exit $? 38306e7d3316Smrgfi 3831a966c04fSmrg 3832a966c04fSmrg 38336e7d3316Smrg# func_mode_execute arg... 38346e7d3316Smrgfunc_mode_execute () 38356e7d3316Smrg{ 3836edce3322Smrg $debug_cmd 3837edce3322Smrg 38386e7d3316Smrg # The first argument is the command name. 3839edce3322Smrg cmd=$nonopt 38406e7d3316Smrg test -z "$cmd" && \ 38416e7d3316Smrg func_fatal_help "you must specify a COMMAND" 3842a966c04fSmrg 38436e7d3316Smrg # Handle -dlopen flags immediately. 384497cf2ee2Smrg for file in $opt_dlopen; do 38456e7d3316Smrg test -f "$file" \ 3846edce3322Smrg || func_fatal_help "'$file' is not a file" 3847a966c04fSmrg 38486e7d3316Smrg dir= 38496e7d3316Smrg case $file in 38506e7d3316Smrg *.la) 385197cf2ee2Smrg func_resolve_sysroot "$file" 385297cf2ee2Smrg file=$func_resolve_sysroot_result 385397cf2ee2Smrg 38546e7d3316Smrg # Check to see that this really is a libtool archive. 38556e7d3316Smrg func_lalib_unsafe_p "$file" \ 3856edce3322Smrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857a966c04fSmrg 38586e7d3316Smrg # Read the libtool library. 38596e7d3316Smrg dlname= 38606e7d3316Smrg library_names= 38616e7d3316Smrg func_source "$file" 3862a966c04fSmrg 38636e7d3316Smrg # Skip this library if it cannot be dlopened. 38646e7d3316Smrg if test -z "$dlname"; then 38656e7d3316Smrg # Warn if it was a shared library. 38666e7d3316Smrg test -n "$library_names" && \ 3867edce3322Smrg func_warning "'$file' was not linked with '-export-dynamic'" 38686e7d3316Smrg continue 38696e7d3316Smrg fi 3870a966c04fSmrg 38716e7d3316Smrg func_dirname "$file" "" "." 3872edce3322Smrg dir=$func_dirname_result 3873a966c04fSmrg 38746e7d3316Smrg if test -f "$dir/$objdir/$dlname"; then 387597cf2ee2Smrg func_append dir "/$objdir" 38766e7d3316Smrg else 38776e7d3316Smrg if test ! -f "$dir/$dlname"; then 3878edce3322Smrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 38796e7d3316Smrg fi 38806e7d3316Smrg fi 3881a966c04fSmrg ;; 3882a966c04fSmrg 38836e7d3316Smrg *.lo) 38846e7d3316Smrg # Just add the directory containing the .lo file. 38856e7d3316Smrg func_dirname "$file" "" "." 3886edce3322Smrg dir=$func_dirname_result 3887a966c04fSmrg ;; 38886e7d3316Smrg 38896e7d3316Smrg *) 3890edce3322Smrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891a966c04fSmrg continue 3892a966c04fSmrg ;; 38936e7d3316Smrg esac 3894a966c04fSmrg 38956e7d3316Smrg # Get the absolute pathname. 38966e7d3316Smrg absdir=`cd "$dir" && pwd` 3897edce3322Smrg test -n "$absdir" && dir=$absdir 3898a966c04fSmrg 38996e7d3316Smrg # Now add the directory to shlibpath_var. 39006e7d3316Smrg if eval "test -z \"\$$shlibpath_var\""; then 39016e7d3316Smrg eval "$shlibpath_var=\"\$dir\"" 39026e7d3316Smrg else 39036e7d3316Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 39046e7d3316Smrg fi 39056e7d3316Smrg done 3906a966c04fSmrg 39076e7d3316Smrg # This variable tells wrapper scripts just to set shlibpath_var 39086e7d3316Smrg # rather than running their programs. 3909edce3322Smrg libtool_execute_magic=$magic 3910a966c04fSmrg 39116e7d3316Smrg # Check if any of the arguments is a wrapper script. 39126e7d3316Smrg args= 39136e7d3316Smrg for file 39146e7d3316Smrg do 39156e7d3316Smrg case $file in 39166e7d3316Smrg -* | *.la | *.lo ) ;; 39176e7d3316Smrg *) 39186e7d3316Smrg # Do a test to see if this is really a libtool program. 39196e7d3316Smrg if func_ltwrapper_script_p "$file"; then 39206e7d3316Smrg func_source "$file" 39216e7d3316Smrg # Transform arg to wrapped name. 3922edce3322Smrg file=$progdir/$program 39236e7d3316Smrg elif func_ltwrapper_executable_p "$file"; then 39246e7d3316Smrg func_ltwrapper_scriptname "$file" 39256e7d3316Smrg func_source "$func_ltwrapper_scriptname_result" 39266e7d3316Smrg # Transform arg to wrapped name. 3927edce3322Smrg file=$progdir/$program 39286e7d3316Smrg fi 3929a966c04fSmrg ;; 39306e7d3316Smrg esac 39316e7d3316Smrg # Quote arguments (to preserve shell metacharacters). 393297cf2ee2Smrg func_append_quoted args "$file" 39336e7d3316Smrg done 3934a966c04fSmrg 3935edce3322Smrg if $opt_dry_run; then 3936edce3322Smrg # Display what would be done. 3937edce3322Smrg if test -n "$shlibpath_var"; then 3938edce3322Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939edce3322Smrg echo "export $shlibpath_var" 3940edce3322Smrg fi 3941edce3322Smrg $ECHO "$cmd$args" 3942edce3322Smrg exit $EXIT_SUCCESS 3943edce3322Smrg else 39446e7d3316Smrg if test -n "$shlibpath_var"; then 39456e7d3316Smrg # Export the shlibpath_var. 39466e7d3316Smrg eval "export $shlibpath_var" 39476e7d3316Smrg fi 3948a966c04fSmrg 39496e7d3316Smrg # Restore saved environment variables 39506e7d3316Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 39516e7d3316Smrg do 39526e7d3316Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 39536e7d3316Smrg $lt_var=\$save_$lt_var; export $lt_var 39546e7d3316Smrg else 39556e7d3316Smrg $lt_unset $lt_var 39566e7d3316Smrg fi" 39576e7d3316Smrg done 3958a966c04fSmrg 39596e7d3316Smrg # Now prepare to actually exec the command. 3960edce3322Smrg exec_cmd=\$cmd$args 39616e7d3316Smrg fi 39626e7d3316Smrg} 3963a966c04fSmrg 3964edce3322Smrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965a966c04fSmrg 3966a966c04fSmrg 39676e7d3316Smrg# func_mode_finish arg... 39686e7d3316Smrgfunc_mode_finish () 39696e7d3316Smrg{ 3970edce3322Smrg $debug_cmd 3971edce3322Smrg 397297cf2ee2Smrg libs= 397397cf2ee2Smrg libdirs= 39746e7d3316Smrg admincmds= 3975a966c04fSmrg 397697cf2ee2Smrg for opt in "$nonopt" ${1+"$@"} 397797cf2ee2Smrg do 397897cf2ee2Smrg if test -d "$opt"; then 397997cf2ee2Smrg func_append libdirs " $opt" 398097cf2ee2Smrg 398197cf2ee2Smrg elif test -f "$opt"; then 398297cf2ee2Smrg if func_lalib_unsafe_p "$opt"; then 398397cf2ee2Smrg func_append libs " $opt" 398497cf2ee2Smrg else 3985edce3322Smrg func_warning "'$opt' is not a valid libtool archive" 398697cf2ee2Smrg fi 398797cf2ee2Smrg 398897cf2ee2Smrg else 3989edce3322Smrg func_fatal_error "invalid argument '$opt'" 399097cf2ee2Smrg fi 399197cf2ee2Smrg done 399297cf2ee2Smrg 399397cf2ee2Smrg if test -n "$libs"; then 399497cf2ee2Smrg if test -n "$lt_sysroot"; then 399597cf2ee2Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 399697cf2ee2Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 399797cf2ee2Smrg else 399897cf2ee2Smrg sysroot_cmd= 399997cf2ee2Smrg fi 400097cf2ee2Smrg 400197cf2ee2Smrg # Remove sysroot references 400297cf2ee2Smrg if $opt_dry_run; then 400397cf2ee2Smrg for lib in $libs; do 4004edce3322Smrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 400597cf2ee2Smrg done 400697cf2ee2Smrg else 400797cf2ee2Smrg tmpdir=`func_mktempdir` 400897cf2ee2Smrg for lib in $libs; do 4009edce3322Smrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 401097cf2ee2Smrg > $tmpdir/tmp-la 401197cf2ee2Smrg mv -f $tmpdir/tmp-la $lib 401297cf2ee2Smrg done 401397cf2ee2Smrg ${RM}r "$tmpdir" 401497cf2ee2Smrg fi 401597cf2ee2Smrg fi 4016a966c04fSmrg 401797cf2ee2Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 40186e7d3316Smrg for libdir in $libdirs; do 40196e7d3316Smrg if test -n "$finish_cmds"; then 40206e7d3316Smrg # Do each command in the finish commands. 40216e7d3316Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 40226e7d3316Smrg'"$cmd"'"' 40236e7d3316Smrg fi 40246e7d3316Smrg if test -n "$finish_eval"; then 40256e7d3316Smrg # Do the single finish_eval. 40266e7d3316Smrg eval cmds=\"$finish_eval\" 402797cf2ee2Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 40286e7d3316Smrg $cmds" 40296e7d3316Smrg fi 40306e7d3316Smrg done 40316e7d3316Smrg fi 4032a966c04fSmrg 40336e7d3316Smrg # Exit here if they wanted silent mode. 4034edce3322Smrg $opt_quiet && exit $EXIT_SUCCESS 4035a966c04fSmrg 403697cf2ee2Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 403797cf2ee2Smrg echo "----------------------------------------------------------------------" 403897cf2ee2Smrg echo "Libraries have been installed in:" 403997cf2ee2Smrg for libdir in $libdirs; do 404097cf2ee2Smrg $ECHO " $libdir" 404197cf2ee2Smrg done 404297cf2ee2Smrg echo 404397cf2ee2Smrg echo "If you ever happen to want to link against installed libraries" 404497cf2ee2Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4045edce3322Smrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 404697cf2ee2Smrg echo "flag during linking and do at least one of the following:" 404797cf2ee2Smrg if test -n "$shlibpath_var"; then 4048edce3322Smrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 404997cf2ee2Smrg echo " during execution" 405097cf2ee2Smrg fi 405197cf2ee2Smrg if test -n "$runpath_var"; then 4052edce3322Smrg echo " - add LIBDIR to the '$runpath_var' environment variable" 405397cf2ee2Smrg echo " during linking" 405497cf2ee2Smrg fi 405597cf2ee2Smrg if test -n "$hardcode_libdir_flag_spec"; then 405697cf2ee2Smrg libdir=LIBDIR 405797cf2ee2Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4058a966c04fSmrg 4059edce3322Smrg $ECHO " - use the '$flag' linker flag" 406097cf2ee2Smrg fi 406197cf2ee2Smrg if test -n "$admincmds"; then 406297cf2ee2Smrg $ECHO " - have your system administrator run these commands:$admincmds" 406397cf2ee2Smrg fi 406497cf2ee2Smrg if test -f /etc/ld.so.conf; then 4065edce3322Smrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 406697cf2ee2Smrg fi 406797cf2ee2Smrg echo 4068a966c04fSmrg 406997cf2ee2Smrg echo "See any operating system documentation about shared libraries for" 407097cf2ee2Smrg case $host in 407197cf2ee2Smrg solaris2.[6789]|solaris2.1[0-9]) 407297cf2ee2Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 407397cf2ee2Smrg echo "pages." 407497cf2ee2Smrg ;; 407597cf2ee2Smrg *) 407697cf2ee2Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 407797cf2ee2Smrg ;; 407897cf2ee2Smrg esac 407997cf2ee2Smrg echo "----------------------------------------------------------------------" 408097cf2ee2Smrg fi 40816e7d3316Smrg exit $EXIT_SUCCESS 40826e7d3316Smrg} 4083a966c04fSmrg 4084edce3322Smrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085a966c04fSmrg 4086a966c04fSmrg 40876e7d3316Smrg# func_mode_install arg... 40886e7d3316Smrgfunc_mode_install () 40896e7d3316Smrg{ 4090edce3322Smrg $debug_cmd 4091edce3322Smrg 40926e7d3316Smrg # There may be an optional sh(1) argument at the beginning of 40936e7d3316Smrg # install_prog (especially on Windows NT). 4094edce3322Smrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 40956e7d3316Smrg # Allow the use of GNU shtool's install command. 4096edce3322Smrg case $nonopt in *shtool*) :;; *) false;; esac 4097edce3322Smrg then 40986e7d3316Smrg # Aesthetically quote it. 40991c235774Smrg func_quote_for_eval "$nonopt" 41001c235774Smrg install_prog="$func_quote_for_eval_result " 41016e7d3316Smrg arg=$1 41026e7d3316Smrg shift 41036e7d3316Smrg else 41046e7d3316Smrg install_prog= 41056e7d3316Smrg arg=$nonopt 41066e7d3316Smrg fi 4107a966c04fSmrg 41086e7d3316Smrg # The real first argument should be the name of the installation program. 41096e7d3316Smrg # Aesthetically quote it. 41101c235774Smrg func_quote_for_eval "$arg" 41111c235774Smrg func_append install_prog "$func_quote_for_eval_result" 41126e7d3316Smrg install_shared_prog=$install_prog 41136e7d3316Smrg case " $install_prog " in 41146e7d3316Smrg *[\\\ /]cp\ *) install_cp=: ;; 41156e7d3316Smrg *) install_cp=false ;; 41166e7d3316Smrg esac 4117a966c04fSmrg 41186e7d3316Smrg # We need to accept at least all the BSD install flags. 41196e7d3316Smrg dest= 41206e7d3316Smrg files= 41216e7d3316Smrg opts= 41226e7d3316Smrg prev= 41236e7d3316Smrg install_type= 4124edce3322Smrg isdir=false 41256e7d3316Smrg stripme= 41266e7d3316Smrg no_mode=: 41276e7d3316Smrg for arg 41286e7d3316Smrg do 41296e7d3316Smrg arg2= 41306e7d3316Smrg if test -n "$dest"; then 413197cf2ee2Smrg func_append files " $dest" 41326e7d3316Smrg dest=$arg 4133a966c04fSmrg continue 41346e7d3316Smrg fi 4135a966c04fSmrg 41366e7d3316Smrg case $arg in 4137edce3322Smrg -d) isdir=: ;; 41386e7d3316Smrg -f) 41396e7d3316Smrg if $install_cp; then :; else 41406e7d3316Smrg prev=$arg 4141a966c04fSmrg fi 41426e7d3316Smrg ;; 41436e7d3316Smrg -g | -m | -o) 41446e7d3316Smrg prev=$arg 41456e7d3316Smrg ;; 41466e7d3316Smrg -s) 41476e7d3316Smrg stripme=" -s" 4148a966c04fSmrg continue 4149a966c04fSmrg ;; 41506e7d3316Smrg -*) 41516e7d3316Smrg ;; 4152a966c04fSmrg *) 41536e7d3316Smrg # If the previous option needed an argument, then skip it. 41546e7d3316Smrg if test -n "$prev"; then 4155edce3322Smrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 41566e7d3316Smrg arg2=$install_override_mode 41576e7d3316Smrg no_mode=false 41586e7d3316Smrg fi 41596e7d3316Smrg prev= 41606e7d3316Smrg else 41616e7d3316Smrg dest=$arg 41626e7d3316Smrg continue 41636e7d3316Smrg fi 4164a966c04fSmrg ;; 41656e7d3316Smrg esac 4166a966c04fSmrg 41676e7d3316Smrg # Aesthetically quote the argument. 41681c235774Smrg func_quote_for_eval "$arg" 41691c235774Smrg func_append install_prog " $func_quote_for_eval_result" 41706e7d3316Smrg if test -n "$arg2"; then 41711c235774Smrg func_quote_for_eval "$arg2" 4172a966c04fSmrg fi 41731c235774Smrg func_append install_shared_prog " $func_quote_for_eval_result" 41746e7d3316Smrg done 4175a966c04fSmrg 41766e7d3316Smrg test -z "$install_prog" && \ 41776e7d3316Smrg func_fatal_help "you must specify an install program" 4178a966c04fSmrg 41796e7d3316Smrg test -n "$prev" && \ 4180edce3322Smrg func_fatal_help "the '$prev' option requires an argument" 4181a966c04fSmrg 41826e7d3316Smrg if test -n "$install_override_mode" && $no_mode; then 41836e7d3316Smrg if $install_cp; then :; else 41841c235774Smrg func_quote_for_eval "$install_override_mode" 41851c235774Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 41866e7d3316Smrg fi 4187a966c04fSmrg fi 4188a966c04fSmrg 41896e7d3316Smrg if test -z "$files"; then 41906e7d3316Smrg if test -z "$dest"; then 41916e7d3316Smrg func_fatal_help "no file or destination specified" 41926e7d3316Smrg else 41936e7d3316Smrg func_fatal_help "you must specify a destination" 4194a966c04fSmrg fi 4195a966c04fSmrg fi 4196a966c04fSmrg 41976e7d3316Smrg # Strip any trailing slash from the destination. 41986e7d3316Smrg func_stripname '' '/' "$dest" 41996e7d3316Smrg dest=$func_stripname_result 4200a966c04fSmrg 42016e7d3316Smrg # Check to see that the destination is a directory. 4202edce3322Smrg test -d "$dest" && isdir=: 4203edce3322Smrg if $isdir; then 4204edce3322Smrg destdir=$dest 42056e7d3316Smrg destname= 42066e7d3316Smrg else 42076e7d3316Smrg func_dirname_and_basename "$dest" "" "." 4208edce3322Smrg destdir=$func_dirname_result 4209edce3322Smrg destname=$func_basename_result 42106e7d3316Smrg 42116e7d3316Smrg # Not a directory, so check to see that there is only one file specified. 42126e7d3316Smrg set dummy $files; shift 42136e7d3316Smrg test "$#" -gt 1 && \ 4214edce3322Smrg func_fatal_help "'$dest' is not a directory" 42156e7d3316Smrg fi 42166e7d3316Smrg case $destdir in 42176e7d3316Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218a966c04fSmrg *) 42196e7d3316Smrg for file in $files; do 42206e7d3316Smrg case $file in 42216e7d3316Smrg *.lo) ;; 42226e7d3316Smrg *) 4223edce3322Smrg func_fatal_help "'$destdir' must be an absolute directory name" 42246e7d3316Smrg ;; 42256e7d3316Smrg esac 42266e7d3316Smrg done 4227a966c04fSmrg ;; 4228a966c04fSmrg esac 4229a966c04fSmrg 42306e7d3316Smrg # This variable tells wrapper scripts just to set variables rather 42316e7d3316Smrg # than running their programs. 4232edce3322Smrg libtool_install_magic=$magic 4233a966c04fSmrg 42346e7d3316Smrg staticlibs= 42356e7d3316Smrg future_libdirs= 42366e7d3316Smrg current_libdirs= 42376e7d3316Smrg for file in $files; do 4238a966c04fSmrg 42396e7d3316Smrg # Do each installation. 42406e7d3316Smrg case $file in 42416e7d3316Smrg *.$libext) 42426e7d3316Smrg # Do the static libraries later. 424397cf2ee2Smrg func_append staticlibs " $file" 42446e7d3316Smrg ;; 42456e7d3316Smrg 42466e7d3316Smrg *.la) 424797cf2ee2Smrg func_resolve_sysroot "$file" 424897cf2ee2Smrg file=$func_resolve_sysroot_result 424997cf2ee2Smrg 42506e7d3316Smrg # Check to see that this really is a libtool archive. 42516e7d3316Smrg func_lalib_unsafe_p "$file" \ 4252edce3322Smrg || func_fatal_help "'$file' is not a valid libtool archive" 42536e7d3316Smrg 42546e7d3316Smrg library_names= 42556e7d3316Smrg old_library= 42566e7d3316Smrg relink_command= 42576e7d3316Smrg func_source "$file" 42586e7d3316Smrg 42596e7d3316Smrg # Add the libdir to current_libdirs if it is the destination. 42606e7d3316Smrg if test "X$destdir" = "X$libdir"; then 42616e7d3316Smrg case "$current_libdirs " in 42626e7d3316Smrg *" $libdir "*) ;; 426397cf2ee2Smrg *) func_append current_libdirs " $libdir" ;; 4264a966c04fSmrg esac 42656e7d3316Smrg else 42666e7d3316Smrg # Note the libdir as a future libdir. 42676e7d3316Smrg case "$future_libdirs " in 42686e7d3316Smrg *" $libdir "*) ;; 426997cf2ee2Smrg *) func_append future_libdirs " $libdir" ;; 42706e7d3316Smrg esac 42716e7d3316Smrg fi 4272a966c04fSmrg 42736e7d3316Smrg func_dirname "$file" "/" "" 4274edce3322Smrg dir=$func_dirname_result 427597cf2ee2Smrg func_append dir "$objdir" 42766e7d3316Smrg 42776e7d3316Smrg if test -n "$relink_command"; then 42786e7d3316Smrg # Determine the prefix the user has applied to our future dir. 42796e7d3316Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 42806e7d3316Smrg 42816e7d3316Smrg # Don't allow the user to place us outside of our expected 42826e7d3316Smrg # location b/c this prevents finding dependent libraries that 42836e7d3316Smrg # are installed to the same prefix. 42846e7d3316Smrg # At present, this check doesn't affect windows .dll's that 42856e7d3316Smrg # are installed into $libdir/../bin (currently, that works fine) 42866e7d3316Smrg # but it's something to keep an eye on. 42876e7d3316Smrg test "$inst_prefix_dir" = "$destdir" && \ 4288edce3322Smrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 42896e7d3316Smrg 42906e7d3316Smrg if test -n "$inst_prefix_dir"; then 42916e7d3316Smrg # Stick the inst_prefix_dir data into the link command. 42926e7d3316Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 42936e7d3316Smrg else 42946e7d3316Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 42956e7d3316Smrg fi 42966e7d3316Smrg 4297edce3322Smrg func_warning "relinking '$file'" 42986e7d3316Smrg func_show_eval "$relink_command" \ 4299edce3322Smrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 43006e7d3316Smrg fi 43016e7d3316Smrg 43026e7d3316Smrg # See the names of the shared library. 43036e7d3316Smrg set dummy $library_names; shift 43046e7d3316Smrg if test -n "$1"; then 4305edce3322Smrg realname=$1 43066e7d3316Smrg shift 43076e7d3316Smrg 4308edce3322Smrg srcname=$realname 4309edce3322Smrg test -n "$relink_command" && srcname=${realname}T 43106e7d3316Smrg 43116e7d3316Smrg # Install the shared library and build the symlinks. 43126e7d3316Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 43136e7d3316Smrg 'exit $?' 4314edce3322Smrg tstripme=$stripme 43156e7d3316Smrg case $host_os in 43166e7d3316Smrg cygwin* | mingw* | pw32* | cegcc*) 43176e7d3316Smrg case $realname in 43186e7d3316Smrg *.dll.a) 4319edce3322Smrg tstripme= 4320edce3322Smrg ;; 4321edce3322Smrg esac 4322edce3322Smrg ;; 4323edce3322Smrg os2*) 4324edce3322Smrg case $realname in 4325edce3322Smrg *_dll.a) 4326edce3322Smrg tstripme= 43276e7d3316Smrg ;; 43286e7d3316Smrg esac 4329a966c04fSmrg ;; 4330a966c04fSmrg esac 43316e7d3316Smrg if test -n "$tstripme" && test -n "$striplib"; then 43326e7d3316Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 43336e7d3316Smrg fi 43346e7d3316Smrg 43356e7d3316Smrg if test "$#" -gt 0; then 43366e7d3316Smrg # Delete the old symlinks, and create new ones. 4337edce3322Smrg # Try 'ln -sf' first, because the 'ln' binary might depend on 43386e7d3316Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 43396e7d3316Smrg # so we also need to try rm && ln -s. 43406e7d3316Smrg for linkname 43416e7d3316Smrg do 43426e7d3316Smrg test "$linkname" != "$realname" \ 43436e7d3316Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 43446e7d3316Smrg done 43456e7d3316Smrg fi 43466e7d3316Smrg 43476e7d3316Smrg # Do each command in the postinstall commands. 4348edce3322Smrg lib=$destdir/$realname 43496e7d3316Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 43506e7d3316Smrg fi 43516e7d3316Smrg 43526e7d3316Smrg # Install the pseudo-library for information purposes. 43536e7d3316Smrg func_basename "$file" 4354edce3322Smrg name=$func_basename_result 4355edce3322Smrg instname=$dir/${name}i 43566e7d3316Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 43576e7d3316Smrg 43586e7d3316Smrg # Maybe install the static library, too. 435997cf2ee2Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360a966c04fSmrg ;; 43616e7d3316Smrg 43626e7d3316Smrg *.lo) 43636e7d3316Smrg # Install (i.e. copy) a libtool object. 43646e7d3316Smrg 43656e7d3316Smrg # Figure out destination file name, if it wasn't already specified. 43666e7d3316Smrg if test -n "$destname"; then 4367edce3322Smrg destfile=$destdir/$destname 43686e7d3316Smrg else 43696e7d3316Smrg func_basename "$file" 4370edce3322Smrg destfile=$func_basename_result 4371edce3322Smrg destfile=$destdir/$destfile 43726e7d3316Smrg fi 43736e7d3316Smrg 43746e7d3316Smrg # Deduce the name of the destination old-style object file. 43756e7d3316Smrg case $destfile in 43766e7d3316Smrg *.lo) 43776e7d3316Smrg func_lo2o "$destfile" 43786e7d3316Smrg staticdest=$func_lo2o_result 4379a966c04fSmrg ;; 43806e7d3316Smrg *.$objext) 4381edce3322Smrg staticdest=$destfile 43826e7d3316Smrg destfile= 4383a966c04fSmrg ;; 43846e7d3316Smrg *) 4385edce3322Smrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386a966c04fSmrg ;; 43876e7d3316Smrg esac 43886e7d3316Smrg 43896e7d3316Smrg # Install the libtool object if requested. 43906e7d3316Smrg test -n "$destfile" && \ 43916e7d3316Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 43926e7d3316Smrg 43936e7d3316Smrg # Install the old object if enabled. 4394edce3322Smrg if test yes = "$build_old_libs"; then 43956e7d3316Smrg # Deduce the name of the old-style object file. 43966e7d3316Smrg func_lo2o "$file" 43976e7d3316Smrg staticobj=$func_lo2o_result 43986e7d3316Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399a966c04fSmrg fi 44006e7d3316Smrg exit $EXIT_SUCCESS 44016e7d3316Smrg ;; 4402a966c04fSmrg 44036e7d3316Smrg *) 44046e7d3316Smrg # Figure out destination file name, if it wasn't already specified. 44056e7d3316Smrg if test -n "$destname"; then 4406edce3322Smrg destfile=$destdir/$destname 4407a966c04fSmrg else 44086e7d3316Smrg func_basename "$file" 4409edce3322Smrg destfile=$func_basename_result 4410edce3322Smrg destfile=$destdir/$destfile 4411a966c04fSmrg fi 4412a966c04fSmrg 44136e7d3316Smrg # If the file is missing, and there is a .exe on the end, strip it 44146e7d3316Smrg # because it is most likely a libtool script we actually want to 44156e7d3316Smrg # install 4416edce3322Smrg stripped_ext= 44176e7d3316Smrg case $file in 44186e7d3316Smrg *.exe) 44196e7d3316Smrg if test ! -f "$file"; then 44206e7d3316Smrg func_stripname '' '.exe' "$file" 44216e7d3316Smrg file=$func_stripname_result 4422edce3322Smrg stripped_ext=.exe 44236e7d3316Smrg fi 44246e7d3316Smrg ;; 44256e7d3316Smrg esac 4426a966c04fSmrg 44276e7d3316Smrg # Do a test to see if this is really a libtool program. 44286e7d3316Smrg case $host in 44296e7d3316Smrg *cygwin* | *mingw*) 44306e7d3316Smrg if func_ltwrapper_executable_p "$file"; then 44316e7d3316Smrg func_ltwrapper_scriptname "$file" 44326e7d3316Smrg wrapper=$func_ltwrapper_scriptname_result 44336e7d3316Smrg else 44346e7d3316Smrg func_stripname '' '.exe' "$file" 44356e7d3316Smrg wrapper=$func_stripname_result 44366e7d3316Smrg fi 44376e7d3316Smrg ;; 44386e7d3316Smrg *) 44396e7d3316Smrg wrapper=$file 44406e7d3316Smrg ;; 44416e7d3316Smrg esac 44426e7d3316Smrg if func_ltwrapper_script_p "$wrapper"; then 44436e7d3316Smrg notinst_deplibs= 44446e7d3316Smrg relink_command= 4445a966c04fSmrg 44466e7d3316Smrg func_source "$wrapper" 4447a966c04fSmrg 44486e7d3316Smrg # Check the variables that should have been set. 44496e7d3316Smrg test -z "$generated_by_libtool_version" && \ 4450edce3322Smrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451a966c04fSmrg 4452edce3322Smrg finalize=: 44536e7d3316Smrg for lib in $notinst_deplibs; do 44546e7d3316Smrg # Check to see that each library is installed. 44556e7d3316Smrg libdir= 44566e7d3316Smrg if test -f "$lib"; then 44576e7d3316Smrg func_source "$lib" 4458a966c04fSmrg fi 4459edce3322Smrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 44606e7d3316Smrg if test -n "$libdir" && test ! -f "$libfile"; then 4461edce3322Smrg func_warning "'$lib' has not been installed in '$libdir'" 4462edce3322Smrg finalize=false 44636e7d3316Smrg fi 44646e7d3316Smrg done 4465a966c04fSmrg 44666e7d3316Smrg relink_command= 44676e7d3316Smrg func_source "$wrapper" 4468a966c04fSmrg 44696e7d3316Smrg outputname= 4470edce3322Smrg if test no = "$fast_install" && test -n "$relink_command"; then 44716e7d3316Smrg $opt_dry_run || { 4472edce3322Smrg if $finalize; then 44736e7d3316Smrg tmpdir=`func_mktempdir` 44746e7d3316Smrg func_basename "$file$stripped_ext" 4475edce3322Smrg file=$func_basename_result 4476edce3322Smrg outputname=$tmpdir/$file 44776e7d3316Smrg # Replace the output file specification. 44786e7d3316Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 44796e7d3316Smrg 4480edce3322Smrg $opt_quiet || { 44811c235774Smrg func_quote_for_expand "$relink_command" 44821c235774Smrg eval "func_echo $func_quote_for_expand_result" 44836e7d3316Smrg } 44846e7d3316Smrg if eval "$relink_command"; then : 44856e7d3316Smrg else 4486edce3322Smrg func_error "error: relink '$file' with the above command before installing it" 44876e7d3316Smrg $opt_dry_run || ${RM}r "$tmpdir" 44886e7d3316Smrg continue 44896e7d3316Smrg fi 4490edce3322Smrg file=$outputname 44916e7d3316Smrg else 4492edce3322Smrg func_warning "cannot relink '$file'" 44936e7d3316Smrg fi 44946e7d3316Smrg } 4495a966c04fSmrg else 44966e7d3316Smrg # Install the binary that we compiled earlier. 44976e7d3316Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498a966c04fSmrg fi 44996e7d3316Smrg fi 4500a966c04fSmrg 45016e7d3316Smrg # remove .exe since cygwin /usr/bin/install will append another 45026e7d3316Smrg # one anyway 45036e7d3316Smrg case $install_prog,$host in 45046e7d3316Smrg */usr/bin/install*,*cygwin*) 45056e7d3316Smrg case $file:$destfile in 45066e7d3316Smrg *.exe:*.exe) 45076e7d3316Smrg # this is ok 45086e7d3316Smrg ;; 45096e7d3316Smrg *.exe:*) 45106e7d3316Smrg destfile=$destfile.exe 45116e7d3316Smrg ;; 45126e7d3316Smrg *:*.exe) 45136e7d3316Smrg func_stripname '' '.exe' "$destfile" 45146e7d3316Smrg destfile=$func_stripname_result 45156e7d3316Smrg ;; 45166e7d3316Smrg esac 4517a966c04fSmrg ;; 4518a966c04fSmrg esac 45196e7d3316Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 45206e7d3316Smrg $opt_dry_run || if test -n "$outputname"; then 45216e7d3316Smrg ${RM}r "$tmpdir" 45226e7d3316Smrg fi 45236e7d3316Smrg ;; 45246e7d3316Smrg esac 45256e7d3316Smrg done 4526a966c04fSmrg 45276e7d3316Smrg for file in $staticlibs; do 45286e7d3316Smrg func_basename "$file" 4529edce3322Smrg name=$func_basename_result 45306e7d3316Smrg 45316e7d3316Smrg # Set up the ranlib parameters. 4532edce3322Smrg oldlib=$destdir/$name 4533ac92798bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534ac92798bSmrg tool_oldlib=$func_to_tool_file_result 45356e7d3316Smrg 45366e7d3316Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 45376e7d3316Smrg 45386e7d3316Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4539ac92798bSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 45406e7d3316Smrg fi 45416e7d3316Smrg 45426e7d3316Smrg # Do each command in the postinstall commands. 45436e7d3316Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 45446e7d3316Smrg done 45456e7d3316Smrg 45466e7d3316Smrg test -n "$future_libdirs" && \ 4547edce3322Smrg func_warning "remember to run '$progname --finish$future_libdirs'" 45486e7d3316Smrg 45496e7d3316Smrg if test -n "$current_libdirs"; then 45506e7d3316Smrg # Maybe just do a dry run. 45516e7d3316Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552edce3322Smrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 45536e7d3316Smrg else 45546e7d3316Smrg exit $EXIT_SUCCESS 45556e7d3316Smrg fi 45566e7d3316Smrg} 45576e7d3316Smrg 4558edce3322Smrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 45596e7d3316Smrg 45606e7d3316Smrg 45616e7d3316Smrg# func_generate_dlsyms outputname originator pic_p 45626e7d3316Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 45636e7d3316Smrg# a dlpreopen symbol table. 45646e7d3316Smrgfunc_generate_dlsyms () 45656e7d3316Smrg{ 4566edce3322Smrg $debug_cmd 4567edce3322Smrg 4568edce3322Smrg my_outputname=$1 4569edce3322Smrg my_originator=$2 4570edce3322Smrg my_pic_p=${3-false} 4571edce3322Smrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 45726e7d3316Smrg my_dlsyms= 45736e7d3316Smrg 4574edce3322Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 45756e7d3316Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576edce3322Smrg my_dlsyms=${my_outputname}S.c 45776e7d3316Smrg else 45786e7d3316Smrg func_error "not configured to extract global symbols from dlpreopened files" 45796e7d3316Smrg fi 45806e7d3316Smrg fi 45816e7d3316Smrg 45826e7d3316Smrg if test -n "$my_dlsyms"; then 45836e7d3316Smrg case $my_dlsyms in 45846e7d3316Smrg "") ;; 45856e7d3316Smrg *.c) 45866e7d3316Smrg # Discover the nlist of each of the dlfiles. 4587edce3322Smrg nlist=$output_objdir/$my_outputname.nm 45886e7d3316Smrg 45896e7d3316Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 45906e7d3316Smrg 45916e7d3316Smrg # Parse the name list into a source file. 45926e7d3316Smrg func_verbose "creating $output_objdir/$my_dlsyms" 45936e7d3316Smrg 45946e7d3316Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595edce3322Smrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596edce3322Smrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 45976e7d3316Smrg 45986e7d3316Smrg#ifdef __cplusplus 45996e7d3316Smrgextern \"C\" { 46006e7d3316Smrg#endif 46016e7d3316Smrg 4602edce3322Smrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 46036e7d3316Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 46046e7d3316Smrg#endif 46056e7d3316Smrg 460697cf2ee2Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607edce3322Smrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608edce3322Smrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 460997cf2ee2Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 461097cf2ee2Smrg# define LT_DLSYM_CONST 4611edce3322Smrg#elif defined __osf__ 461297cf2ee2Smrg/* This system does not cope well with relocations in const data. */ 461397cf2ee2Smrg# define LT_DLSYM_CONST 461497cf2ee2Smrg#else 461597cf2ee2Smrg# define LT_DLSYM_CONST const 461697cf2ee2Smrg#endif 461797cf2ee2Smrg 4618edce3322Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619edce3322Smrg 46206e7d3316Smrg/* External symbol declarations for the compiler. */\ 46216e7d3316Smrg" 46226e7d3316Smrg 4623edce3322Smrg if test yes = "$dlself"; then 4624edce3322Smrg func_verbose "generating symbol list for '$output'" 46256e7d3316Smrg 46266e7d3316Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 46276e7d3316Smrg 46286e7d3316Smrg # Add our own program objects to the symbol list. 46296e7d3316Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 46306e7d3316Smrg for progfile in $progfiles; do 463197cf2ee2Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632edce3322Smrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 463397cf2ee2Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 46346e7d3316Smrg done 46356e7d3316Smrg 46366e7d3316Smrg if test -n "$exclude_expsyms"; then 46376e7d3316Smrg $opt_dry_run || { 46386e7d3316Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 46396e7d3316Smrg eval '$MV "$nlist"T "$nlist"' 46406e7d3316Smrg } 4641a966c04fSmrg fi 46426e7d3316Smrg 46436e7d3316Smrg if test -n "$export_symbols_regex"; then 46446e7d3316Smrg $opt_dry_run || { 46456e7d3316Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 46466e7d3316Smrg eval '$MV "$nlist"T "$nlist"' 46476e7d3316Smrg } 46486e7d3316Smrg fi 46496e7d3316Smrg 46506e7d3316Smrg # Prepare the list of exported symbols 46516e7d3316Smrg if test -z "$export_symbols"; then 4652edce3322Smrg export_symbols=$output_objdir/$outputname.exp 46536e7d3316Smrg $opt_dry_run || { 46546e7d3316Smrg $RM $export_symbols 4655edce3322Smrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 46566e7d3316Smrg case $host in 46576e7d3316Smrg *cygwin* | *mingw* | *cegcc* ) 46586e7d3316Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46596e7d3316Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 46606e7d3316Smrg ;; 46616e7d3316Smrg esac 46626e7d3316Smrg } 4663a966c04fSmrg else 46646e7d3316Smrg $opt_dry_run || { 4665edce3322Smrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 46666e7d3316Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 46676e7d3316Smrg eval '$MV "$nlist"T "$nlist"' 46686e7d3316Smrg case $host in 46696e7d3316Smrg *cygwin* | *mingw* | *cegcc* ) 46706e7d3316Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 46716e7d3316Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 46726e7d3316Smrg ;; 46736e7d3316Smrg esac 46746e7d3316Smrg } 4675a966c04fSmrg fi 46766e7d3316Smrg fi 4677a966c04fSmrg 46786e7d3316Smrg for dlprefile in $dlprefiles; do 4679edce3322Smrg func_verbose "extracting global C symbols from '$dlprefile'" 46806e7d3316Smrg func_basename "$dlprefile" 4681edce3322Smrg name=$func_basename_result 468297cf2ee2Smrg case $host in 468397cf2ee2Smrg *cygwin* | *mingw* | *cegcc* ) 468497cf2ee2Smrg # if an import library, we need to obtain dlname 468597cf2ee2Smrg if func_win32_import_lib_p "$dlprefile"; then 468697cf2ee2Smrg func_tr_sh "$dlprefile" 468797cf2ee2Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688edce3322Smrg dlprefile_dlbasename= 468997cf2ee2Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 469097cf2ee2Smrg # Use subshell, to avoid clobbering current variable values 469197cf2ee2Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692edce3322Smrg if test -n "$dlprefile_dlname"; then 469397cf2ee2Smrg func_basename "$dlprefile_dlname" 4694edce3322Smrg dlprefile_dlbasename=$func_basename_result 469597cf2ee2Smrg else 469697cf2ee2Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 469797cf2ee2Smrg $sharedlib_from_linklib_cmd "$dlprefile" 469897cf2ee2Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 469997cf2ee2Smrg fi 470097cf2ee2Smrg fi 470197cf2ee2Smrg $opt_dry_run || { 4702edce3322Smrg if test -n "$dlprefile_dlbasename"; then 470397cf2ee2Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 470497cf2ee2Smrg else 470597cf2ee2Smrg func_warning "Could not compute DLL name from $name" 470697cf2ee2Smrg eval '$ECHO ": $name " >> "$nlist"' 470797cf2ee2Smrg fi 470897cf2ee2Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 470997cf2ee2Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 471097cf2ee2Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 471197cf2ee2Smrg } 471297cf2ee2Smrg else # not an import lib 471397cf2ee2Smrg $opt_dry_run || { 471497cf2ee2Smrg eval '$ECHO ": $name " >> "$nlist"' 471597cf2ee2Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 471697cf2ee2Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 471797cf2ee2Smrg } 471897cf2ee2Smrg fi 471997cf2ee2Smrg ;; 472097cf2ee2Smrg *) 472197cf2ee2Smrg $opt_dry_run || { 472297cf2ee2Smrg eval '$ECHO ": $name " >> "$nlist"' 472397cf2ee2Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 472497cf2ee2Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 472597cf2ee2Smrg } 472697cf2ee2Smrg ;; 472797cf2ee2Smrg esac 47286e7d3316Smrg done 47296e7d3316Smrg 47306e7d3316Smrg $opt_dry_run || { 47316e7d3316Smrg # Make sure we have at least an empty file. 47326e7d3316Smrg test -f "$nlist" || : > "$nlist" 47336e7d3316Smrg 47346e7d3316Smrg if test -n "$exclude_expsyms"; then 47356e7d3316Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 47366e7d3316Smrg $MV "$nlist"T "$nlist" 4737a966c04fSmrg fi 47386e7d3316Smrg 47396e7d3316Smrg # Try sorting and uniquifying the output. 47406e7d3316Smrg if $GREP -v "^: " < "$nlist" | 47416e7d3316Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 47426e7d3316Smrg sort -k 3 47436e7d3316Smrg else 47446e7d3316Smrg sort +2 47456e7d3316Smrg fi | 47466e7d3316Smrg uniq > "$nlist"S; then 47476e7d3316Smrg : 4748a966c04fSmrg else 47496e7d3316Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750a966c04fSmrg fi 4751a966c04fSmrg 47526e7d3316Smrg if test -f "$nlist"S; then 47536e7d3316Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754a966c04fSmrg else 47556e7d3316Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756a966c04fSmrg fi 4757a966c04fSmrg 4758edce3322Smrg func_show_eval '$RM "${nlist}I"' 4759edce3322Smrg if test -n "$global_symbol_to_import"; then 4760edce3322Smrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761edce3322Smrg fi 4762edce3322Smrg 47636e7d3316Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4764a966c04fSmrg 47656e7d3316Smrg/* The mapping between symbol names and symbols. */ 47666e7d3316Smrgtypedef struct { 47676e7d3316Smrg const char *name; 47686e7d3316Smrg void *address; 47696e7d3316Smrg} lt_dlsymlist; 477097cf2ee2Smrgextern LT_DLSYM_CONST lt_dlsymlist 4771edce3322Smrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4772edce3322Smrg" 4773edce3322Smrg 4774edce3322Smrg if test -s "$nlist"I; then 4775edce3322Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4776edce3322Smrgstatic void lt_syminit(void) 4777edce3322Smrg{ 4778edce3322Smrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779edce3322Smrg for (; symbol->name; ++symbol) 4780edce3322Smrg {" 4781edce3322Smrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782edce3322Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4783edce3322Smrg } 4784edce3322Smrg}" 4785edce3322Smrg fi 4786edce3322Smrg echo >> "$output_objdir/$my_dlsyms" "\ 478797cf2ee2SmrgLT_DLSYM_CONST lt_dlsymlist 47886e7d3316Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 4789edce3322Smrg{ {\"$my_originator\", (void *) 0}," 4790edce3322Smrg 4791edce3322Smrg if test -s "$nlist"I; then 4792edce3322Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4793edce3322Smrg {\"@INIT@\", (void *) <_syminit}," 4794edce3322Smrg fi 4795a966c04fSmrg 47966e7d3316Smrg case $need_lib_prefix in 47976e7d3316Smrg no) 47986e7d3316Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 47996e7d3316Smrg ;; 48006e7d3316Smrg *) 48016e7d3316Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 48026e7d3316Smrg ;; 48036e7d3316Smrg esac 48046e7d3316Smrg echo >> "$output_objdir/$my_dlsyms" "\ 48056e7d3316Smrg {0, (void *) 0} 48066e7d3316Smrg}; 4807a966c04fSmrg 48086e7d3316Smrg/* This works around a problem in FreeBSD linker */ 48096e7d3316Smrg#ifdef FREEBSD_WORKAROUND 48106e7d3316Smrgstatic const void *lt_preloaded_setup() { 48116e7d3316Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 48126e7d3316Smrg} 48136e7d3316Smrg#endif 4814a966c04fSmrg 48156e7d3316Smrg#ifdef __cplusplus 48166e7d3316Smrg} 48176e7d3316Smrg#endif\ 48186e7d3316Smrg" 48196e7d3316Smrg } # !$opt_dry_run 4820a966c04fSmrg 48216e7d3316Smrg pic_flag_for_symtable= 48226e7d3316Smrg case "$compile_command " in 48236e7d3316Smrg *" -static "*) ;; 48246e7d3316Smrg *) 48256e7d3316Smrg case $host in 48266e7d3316Smrg # compiling the symbol table file with pic_flag works around 48276e7d3316Smrg # a FreeBSD bug that causes programs to crash when -lm is 48286e7d3316Smrg # linked before any other PIC object. But we must not use 48296e7d3316Smrg # pic_flag when linking with -static. The problem exists in 48306e7d3316Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831ac92798bSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 48326e7d3316Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 48336e7d3316Smrg *-*-hpux*) 48346e7d3316Smrg pic_flag_for_symtable=" $pic_flag" ;; 48356e7d3316Smrg *) 4836edce3322Smrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 48376e7d3316Smrg ;; 48386e7d3316Smrg esac 48396e7d3316Smrg ;; 48406e7d3316Smrg esac 48416e7d3316Smrg symtab_cflags= 48426e7d3316Smrg for arg in $LTCFLAGS; do 48436e7d3316Smrg case $arg in 48446e7d3316Smrg -pie | -fpie | -fPIE) ;; 484597cf2ee2Smrg *) func_append symtab_cflags " $arg" ;; 48466e7d3316Smrg esac 48476e7d3316Smrg done 4848a966c04fSmrg 48496e7d3316Smrg # Now compile the dynamic symbol file. 48506e7d3316Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851a966c04fSmrg 48526e7d3316Smrg # Clean up the generated files. 4853edce3322Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854a966c04fSmrg 48556e7d3316Smrg # Transform the symbol file into the correct name. 4856edce3322Smrg symfileobj=$output_objdir/${my_outputname}S.$objext 48576e7d3316Smrg case $host in 48586e7d3316Smrg *cygwin* | *mingw* | *cegcc* ) 48596e7d3316Smrg if test -f "$output_objdir/$my_outputname.def"; then 48606e7d3316Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48616e7d3316Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 48626e7d3316Smrg else 48636e7d3316Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48646e7d3316Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48656e7d3316Smrg fi 48666e7d3316Smrg ;; 48676e7d3316Smrg *) 48686e7d3316Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48696e7d3316Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 48706e7d3316Smrg ;; 48716e7d3316Smrg esac 48726e7d3316Smrg ;; 48736e7d3316Smrg *) 4874edce3322Smrg func_fatal_error "unknown suffix for '$my_dlsyms'" 48756e7d3316Smrg ;; 48766e7d3316Smrg esac 48776e7d3316Smrg else 48786e7d3316Smrg # We keep going just in case the user didn't refer to 48796e7d3316Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 48806e7d3316Smrg # really was required. 4881a966c04fSmrg 48826e7d3316Smrg # Nullify the symbol file. 48836e7d3316Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 48846e7d3316Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 48856e7d3316Smrg fi 48866e7d3316Smrg} 4887a966c04fSmrg 4888edce3322Smrg# func_cygming_gnu_implib_p ARG 4889edce3322Smrg# This predicate returns with zero status (TRUE) if 4890edce3322Smrg# ARG is a GNU/binutils-style import library. Returns 4891edce3322Smrg# with nonzero status (FALSE) otherwise. 4892edce3322Smrgfunc_cygming_gnu_implib_p () 4893edce3322Smrg{ 4894edce3322Smrg $debug_cmd 4895edce3322Smrg 4896edce3322Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4897edce3322Smrg 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)$'` 4898edce3322Smrg test -n "$func_cygming_gnu_implib_tmp" 4899edce3322Smrg} 4900edce3322Smrg 4901edce3322Smrg# func_cygming_ms_implib_p ARG 4902edce3322Smrg# This predicate returns with zero status (TRUE) if 4903edce3322Smrg# ARG is an MS-style import library. Returns 4904edce3322Smrg# with nonzero status (FALSE) otherwise. 4905edce3322Smrgfunc_cygming_ms_implib_p () 4906edce3322Smrg{ 4907edce3322Smrg $debug_cmd 4908edce3322Smrg 4909edce3322Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4910edce3322Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911edce3322Smrg test -n "$func_cygming_ms_implib_tmp" 4912edce3322Smrg} 4913edce3322Smrg 49146e7d3316Smrg# func_win32_libid arg 49156e7d3316Smrg# return the library type of file 'arg' 49166e7d3316Smrg# 49176e7d3316Smrg# Need a lot of goo to handle *both* DLLs and import libs 49186e7d3316Smrg# Has to be a shell function in order to 'eat' the argument 49196e7d3316Smrg# that is supplied when $file_magic_command is called. 49206e7d3316Smrg# Despite the name, also deal with 64 bit binaries. 49216e7d3316Smrgfunc_win32_libid () 49226e7d3316Smrg{ 4923edce3322Smrg $debug_cmd 4924edce3322Smrg 4925edce3322Smrg win32_libid_type=unknown 49266e7d3316Smrg win32_fileres=`file -L $1 2>/dev/null` 49276e7d3316Smrg case $win32_fileres in 49286e7d3316Smrg *ar\ archive\ import\ library*) # definitely import 49296e7d3316Smrg win32_libid_type="x86 archive import" 49306e7d3316Smrg ;; 49316e7d3316Smrg *ar\ archive*) # could be an import, or static 49326e7d3316Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 49336e7d3316Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 49346e7d3316Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935edce3322Smrg case $nm_interface in 4936edce3322Smrg "MS dumpbin") 4937edce3322Smrg if func_cygming_ms_implib_p "$1" || 4938edce3322Smrg func_cygming_gnu_implib_p "$1" 4939edce3322Smrg then 4940edce3322Smrg win32_nmres=import 4941edce3322Smrg else 4942edce3322Smrg win32_nmres= 4943edce3322Smrg fi 4944edce3322Smrg ;; 4945edce3322Smrg *) 4946edce3322Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4947edce3322Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948edce3322Smrg $SED -n -e ' 49496e7d3316Smrg 1,100{ 49506e7d3316Smrg / I /{ 4951edce3322Smrg s|.*|import| 49526e7d3316Smrg p 49536e7d3316Smrg q 49546e7d3316Smrg } 49556e7d3316Smrg }'` 4956edce3322Smrg ;; 4957edce3322Smrg esac 49586e7d3316Smrg case $win32_nmres in 49596e7d3316Smrg import*) win32_libid_type="x86 archive import";; 49606e7d3316Smrg *) win32_libid_type="x86 archive static";; 49616e7d3316Smrg esac 49626e7d3316Smrg fi 49636e7d3316Smrg ;; 49646e7d3316Smrg *DLL*) 49656e7d3316Smrg win32_libid_type="x86 DLL" 49666e7d3316Smrg ;; 49676e7d3316Smrg *executable*) # but shell scripts are "executable" too... 49686e7d3316Smrg case $win32_fileres in 49696e7d3316Smrg *MS\ Windows\ PE\ Intel*) 49706e7d3316Smrg win32_libid_type="x86 DLL" 49716e7d3316Smrg ;; 49726e7d3316Smrg esac 49736e7d3316Smrg ;; 49746e7d3316Smrg esac 49756e7d3316Smrg $ECHO "$win32_libid_type" 49766e7d3316Smrg} 4977a966c04fSmrg 497897cf2ee2Smrg# func_cygming_dll_for_implib ARG 497997cf2ee2Smrg# 498097cf2ee2Smrg# Platform-specific function to extract the 498197cf2ee2Smrg# name of the DLL associated with the specified 498297cf2ee2Smrg# import library ARG. 498397cf2ee2Smrg# Invoked by eval'ing the libtool variable 498497cf2ee2Smrg# $sharedlib_from_linklib_cmd 498597cf2ee2Smrg# Result is available in the variable 498697cf2ee2Smrg# $sharedlib_from_linklib_result 498797cf2ee2Smrgfunc_cygming_dll_for_implib () 498897cf2ee2Smrg{ 4989edce3322Smrg $debug_cmd 4990edce3322Smrg 499197cf2ee2Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 499297cf2ee2Smrg} 499397cf2ee2Smrg 499497cf2ee2Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 499597cf2ee2Smrg# 499697cf2ee2Smrg# The is the core of a fallback implementation of a 499797cf2ee2Smrg# platform-specific function to extract the name of the 499897cf2ee2Smrg# DLL associated with the specified import library LIBNAME. 499997cf2ee2Smrg# 500097cf2ee2Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 500197cf2ee2Smrg# on the platform and compiler that created the implib. 500297cf2ee2Smrg# 500397cf2ee2Smrg# Echos the name of the DLL associated with the 500497cf2ee2Smrg# specified import library. 500597cf2ee2Smrgfunc_cygming_dll_for_implib_fallback_core () 500697cf2ee2Smrg{ 5007edce3322Smrg $debug_cmd 5008edce3322Smrg 500997cf2ee2Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 501097cf2ee2Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 501197cf2ee2Smrg $SED '/^Contents of section '"$match_literal"':/{ 501297cf2ee2Smrg # Place marker at beginning of archive member dllname section 501397cf2ee2Smrg s/.*/====MARK====/ 501497cf2ee2Smrg p 501597cf2ee2Smrg d 501697cf2ee2Smrg } 501797cf2ee2Smrg # These lines can sometimes be longer than 43 characters, but 501897cf2ee2Smrg # are always uninteresting 501997cf2ee2Smrg /:[ ]*file format pe[i]\{,1\}-/d 502097cf2ee2Smrg /^In archive [^:]*:/d 502197cf2ee2Smrg # Ensure marker is printed 502297cf2ee2Smrg /^====MARK====/p 502397cf2ee2Smrg # Remove all lines with less than 43 characters 502497cf2ee2Smrg /^.\{43\}/!d 502597cf2ee2Smrg # From remaining lines, remove first 43 characters 502697cf2ee2Smrg s/^.\{43\}//' | 502797cf2ee2Smrg $SED -n ' 502897cf2ee2Smrg # Join marker and all lines until next marker into a single line 502997cf2ee2Smrg /^====MARK====/ b para 503097cf2ee2Smrg H 503197cf2ee2Smrg $ b para 503297cf2ee2Smrg b 503397cf2ee2Smrg :para 503497cf2ee2Smrg x 503597cf2ee2Smrg s/\n//g 503697cf2ee2Smrg # Remove the marker 503797cf2ee2Smrg s/^====MARK====// 503897cf2ee2Smrg # Remove trailing dots and whitespace 503997cf2ee2Smrg s/[\. \t]*$// 504097cf2ee2Smrg # Print 504197cf2ee2Smrg /./p' | 504297cf2ee2Smrg # we now have a list, one entry per line, of the stringified 504397cf2ee2Smrg # contents of the appropriate section of all members of the 5044edce3322Smrg # archive that possess that section. Heuristic: eliminate 5045edce3322Smrg # all those that have a first or second character that is 504697cf2ee2Smrg # a '.' (that is, objdump's representation of an unprintable 504797cf2ee2Smrg # character.) This should work for all archives with less than 504897cf2ee2Smrg # 0x302f exports -- but will fail for DLLs whose name actually 504997cf2ee2Smrg # begins with a literal '.' or a single character followed by 505097cf2ee2Smrg # a '.'. 505197cf2ee2Smrg # 505297cf2ee2Smrg # Of those that remain, print the first one. 505397cf2ee2Smrg $SED -e '/^\./d;/^.\./d;q' 505497cf2ee2Smrg} 505597cf2ee2Smrg 505697cf2ee2Smrg# func_cygming_dll_for_implib_fallback ARG 505797cf2ee2Smrg# Platform-specific function to extract the 505897cf2ee2Smrg# name of the DLL associated with the specified 505997cf2ee2Smrg# import library ARG. 506097cf2ee2Smrg# 506197cf2ee2Smrg# This fallback implementation is for use when $DLLTOOL 506297cf2ee2Smrg# does not support the --identify-strict option. 506397cf2ee2Smrg# Invoked by eval'ing the libtool variable 506497cf2ee2Smrg# $sharedlib_from_linklib_cmd 506597cf2ee2Smrg# Result is available in the variable 506697cf2ee2Smrg# $sharedlib_from_linklib_result 506797cf2ee2Smrgfunc_cygming_dll_for_implib_fallback () 506897cf2ee2Smrg{ 5069edce3322Smrg $debug_cmd 5070edce3322Smrg 5071edce3322Smrg if func_cygming_gnu_implib_p "$1"; then 507297cf2ee2Smrg # binutils import library 507397cf2ee2Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074edce3322Smrg elif func_cygming_ms_implib_p "$1"; then 507597cf2ee2Smrg # ms-generated import library 507697cf2ee2Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 507797cf2ee2Smrg else 507897cf2ee2Smrg # unknown 5079edce3322Smrg sharedlib_from_linklib_result= 508097cf2ee2Smrg fi 508197cf2ee2Smrg} 5082a966c04fSmrg 5083a966c04fSmrg 50846e7d3316Smrg# func_extract_an_archive dir oldlib 50856e7d3316Smrgfunc_extract_an_archive () 50866e7d3316Smrg{ 5087edce3322Smrg $debug_cmd 5088edce3322Smrg 5089edce3322Smrg f_ex_an_ar_dir=$1; shift 5090edce3322Smrg f_ex_an_ar_oldlib=$1 5091edce3322Smrg if test yes = "$lock_old_archive_extraction"; then 50926e7d3316Smrg lockfile=$f_ex_an_ar_oldlib.lock 50936e7d3316Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 50946e7d3316Smrg func_echo "Waiting for $lockfile to be removed" 50956e7d3316Smrg sleep 2 50966e7d3316Smrg done 50976e7d3316Smrg fi 50986e7d3316Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 50996e7d3316Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5100edce3322Smrg if test yes = "$lock_old_archive_extraction"; then 51016e7d3316Smrg $opt_dry_run || rm -f "$lockfile" 51026e7d3316Smrg fi 51036e7d3316Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 51046e7d3316Smrg : 51056e7d3316Smrg else 51066e7d3316Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 51076e7d3316Smrg fi 51086e7d3316Smrg} 5109a966c04fSmrg 5110a966c04fSmrg 51116e7d3316Smrg# func_extract_archives gentop oldlib ... 51126e7d3316Smrgfunc_extract_archives () 51136e7d3316Smrg{ 5114edce3322Smrg $debug_cmd 5115edce3322Smrg 5116edce3322Smrg my_gentop=$1; shift 51176e7d3316Smrg my_oldlibs=${1+"$@"} 5118edce3322Smrg my_oldobjs= 5119edce3322Smrg my_xlib= 5120edce3322Smrg my_xabs= 5121edce3322Smrg my_xdir= 5122a966c04fSmrg 51236e7d3316Smrg for my_xlib in $my_oldlibs; do 51246e7d3316Smrg # Extract the objects. 51256e7d3316Smrg case $my_xlib in 5126edce3322Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 51276e7d3316Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 51286e7d3316Smrg esac 51296e7d3316Smrg func_basename "$my_xlib" 5130edce3322Smrg my_xlib=$func_basename_result 51316e7d3316Smrg my_xlib_u=$my_xlib 51326e7d3316Smrg while :; do 51336e7d3316Smrg case " $extracted_archives " in 51346e7d3316Smrg *" $my_xlib_u "*) 51356e7d3316Smrg func_arith $extracted_serial + 1 51366e7d3316Smrg extracted_serial=$func_arith_result 51376e7d3316Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 51386e7d3316Smrg *) break ;; 51396e7d3316Smrg esac 51406e7d3316Smrg done 51416e7d3316Smrg extracted_archives="$extracted_archives $my_xlib_u" 5142edce3322Smrg my_xdir=$my_gentop/$my_xlib_u 5143a966c04fSmrg 51446e7d3316Smrg func_mkdir_p "$my_xdir" 51456e7d3316Smrg 51466e7d3316Smrg case $host in 51476e7d3316Smrg *-darwin*) 51486e7d3316Smrg func_verbose "Extracting $my_xabs" 51496e7d3316Smrg # Do not bother doing anything if just a dry run 51506e7d3316Smrg $opt_dry_run || { 51516e7d3316Smrg darwin_orig_dir=`pwd` 51526e7d3316Smrg cd $my_xdir || exit $? 51536e7d3316Smrg darwin_archive=$my_xabs 51546e7d3316Smrg darwin_curdir=`pwd` 5155edce3322Smrg func_basename "$darwin_archive" 5156edce3322Smrg darwin_base_archive=$func_basename_result 51576e7d3316Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 51586e7d3316Smrg if test -n "$darwin_arches"; then 51596e7d3316Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 51606e7d3316Smrg darwin_arch= 51616e7d3316Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162edce3322Smrg for darwin_arch in $darwin_arches; do 5163edce3322Smrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164edce3322Smrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165edce3322Smrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166edce3322Smrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 51676e7d3316Smrg cd "$darwin_curdir" 5168edce3322Smrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 51696e7d3316Smrg done # $darwin_arches 51706e7d3316Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171edce3322Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 51726e7d3316Smrg darwin_file= 51736e7d3316Smrg darwin_files= 51746e7d3316Smrg for darwin_file in $darwin_filelist; do 51756e7d3316Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 51766e7d3316Smrg $LIPO -create -output "$darwin_file" $darwin_files 51776e7d3316Smrg done # $darwin_filelist 51786e7d3316Smrg $RM -rf unfat-$$ 51796e7d3316Smrg cd "$darwin_orig_dir" 5180a966c04fSmrg else 51816e7d3316Smrg cd $darwin_orig_dir 51826e7d3316Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 51836e7d3316Smrg fi # $darwin_arches 51846e7d3316Smrg } # !$opt_dry_run 51856e7d3316Smrg ;; 51866e7d3316Smrg *) 51876e7d3316Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 51886e7d3316Smrg ;; 51896e7d3316Smrg esac 51906e7d3316Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 51916e7d3316Smrg done 5192a966c04fSmrg 5193edce3322Smrg func_extract_archives_result=$my_oldobjs 51946e7d3316Smrg} 5195a966c04fSmrg 5196a966c04fSmrg 51976e7d3316Smrg# func_emit_wrapper [arg=no] 51986e7d3316Smrg# 51996e7d3316Smrg# Emit a libtool wrapper script on stdout. 52006e7d3316Smrg# Don't directly open a file because we may want to 52016e7d3316Smrg# incorporate the script contents within a cygwin/mingw 52026e7d3316Smrg# wrapper executable. Must ONLY be called from within 52036e7d3316Smrg# func_mode_link because it depends on a number of variables 52046e7d3316Smrg# set therein. 52056e7d3316Smrg# 52066e7d3316Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 52076e7d3316Smrg# variable will take. If 'yes', then the emitted script 5208edce3322Smrg# will assume that the directory where it is stored is 52096e7d3316Smrg# the $objdir directory. This is a cygwin/mingw-specific 52106e7d3316Smrg# behavior. 52116e7d3316Smrgfunc_emit_wrapper () 52126e7d3316Smrg{ 52136e7d3316Smrg func_emit_wrapper_arg1=${1-no} 5214a966c04fSmrg 52156e7d3316Smrg $ECHO "\ 52166e7d3316Smrg#! $SHELL 5217a966c04fSmrg 52186e7d3316Smrg# $output - temporary wrapper script for $objdir/$outputname 5219edce3322Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 52206e7d3316Smrg# 52216e7d3316Smrg# The $output program cannot be directly executed until all the libtool 52226e7d3316Smrg# libraries that it depends on are installed. 52236e7d3316Smrg# 52246e7d3316Smrg# This wrapper script should never be moved out of the build directory. 52256e7d3316Smrg# If it is, it will not operate correctly. 5226a966c04fSmrg 52276e7d3316Smrg# Sed substitution that helps us do robust quoting. It backslashifies 52286e7d3316Smrg# metacharacters that are still active within double-quoted strings. 52296e7d3316Smrgsed_quote_subst='$sed_quote_subst' 5230a966c04fSmrg 52316e7d3316Smrg# Be Bourne compatible 52326e7d3316Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 52336e7d3316Smrg emulate sh 52346e7d3316Smrg NULLCMD=: 52356e7d3316Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 52366e7d3316Smrg # is contrary to our usage. Disable this feature. 52376e7d3316Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 52386e7d3316Smrg setopt NO_GLOB_SUBST 52396e7d3316Smrgelse 52406e7d3316Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 52416e7d3316Smrgfi 52426e7d3316SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 52436e7d3316SmrgDUALCASE=1; export DUALCASE # for MKS sh 5244a966c04fSmrg 52456e7d3316Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 52466e7d3316Smrg# if CDPATH is set. 52476e7d3316Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248a966c04fSmrg 52496e7d3316Smrgrelink_command=\"$relink_command\" 5250a966c04fSmrg 52516e7d3316Smrg# This environment variable determines our operation mode. 52526e7d3316Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 52536e7d3316Smrg # install mode needs the following variables: 52546e7d3316Smrg generated_by_libtool_version='$macro_version' 52556e7d3316Smrg notinst_deplibs='$notinst_deplibs' 52566e7d3316Smrgelse 52576e7d3316Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 52586e7d3316Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 52596e7d3316Smrg file=\"\$0\"" 5260a966c04fSmrg 52611c235774Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 52626e7d3316Smrg $ECHO "\ 5263a966c04fSmrg 52646e7d3316Smrg# A function that is used when there is no print builtin or printf. 52656e7d3316Smrgfunc_fallback_echo () 52666e7d3316Smrg{ 52676e7d3316Smrg eval 'cat <<_LTECHO_EOF 52686e7d3316Smrg\$1 52696e7d3316Smrg_LTECHO_EOF' 52706e7d3316Smrg} 52711c235774Smrg ECHO=\"$qECHO\" 52726e7d3316Smrg fi 52736e7d3316Smrg 52746e7d3316Smrg# Very basic option parsing. These options are (a) specific to 52756e7d3316Smrg# the libtool wrapper, (b) are identical between the wrapper 5276edce3322Smrg# /script/ and the wrapper /executable/ that is used only on 52776e7d3316Smrg# windows platforms, and (c) all begin with the string "--lt-" 5278edce3322Smrg# (application programs are unlikely to have options that match 52796e7d3316Smrg# this pattern). 52806e7d3316Smrg# 52816e7d3316Smrg# There are only two supported options: --lt-debug and 52826e7d3316Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 52836e7d3316Smrg# 52846e7d3316Smrg# The first argument to this parsing function should be the 52856e7d3316Smrg# script's $0 value, followed by "$@". 52866e7d3316Smrglt_option_debug= 52876e7d3316Smrgfunc_parse_lt_options () 52886e7d3316Smrg{ 52896e7d3316Smrg lt_script_arg0=\$0 52906e7d3316Smrg shift 52916e7d3316Smrg for lt_opt 52926e7d3316Smrg do 52936e7d3316Smrg case \"\$lt_opt\" in 52946e7d3316Smrg --lt-debug) lt_option_debug=1 ;; 52956e7d3316Smrg --lt-dump-script) 52966e7d3316Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 52976e7d3316Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 52986e7d3316Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 52996e7d3316Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 53006e7d3316Smrg exit 0 53016e7d3316Smrg ;; 53026e7d3316Smrg --lt-*) 53036e7d3316Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 53046e7d3316Smrg exit 1 5305a966c04fSmrg ;; 53066e7d3316Smrg esac 53076e7d3316Smrg done 5308a966c04fSmrg 53096e7d3316Smrg # Print the debug banner immediately: 53106e7d3316Smrg if test -n \"\$lt_option_debug\"; then 5311edce3322Smrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 53126e7d3316Smrg fi 53136e7d3316Smrg} 5314a966c04fSmrg 53156e7d3316Smrg# Used when --lt-debug. Prints its arguments to stdout 53166e7d3316Smrg# (redirection is the responsibility of the caller) 53176e7d3316Smrgfunc_lt_dump_args () 53186e7d3316Smrg{ 53196e7d3316Smrg lt_dump_args_N=1; 53206e7d3316Smrg for lt_arg 53216e7d3316Smrg do 5322edce3322Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 53236e7d3316Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 53246e7d3316Smrg done 53256e7d3316Smrg} 5326a966c04fSmrg 53276e7d3316Smrg# Core function for launching the target application 53286e7d3316Smrgfunc_exec_program_core () 53296e7d3316Smrg{ 53306e7d3316Smrg" 53316e7d3316Smrg case $host in 53326e7d3316Smrg # Backslashes separate directories on plain windows 53336e7d3316Smrg *-*-mingw | *-*-os2* | *-cegcc*) 53346e7d3316Smrg $ECHO "\ 53356e7d3316Smrg if test -n \"\$lt_option_debug\"; then 5336edce3322Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 53376e7d3316Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5338a966c04fSmrg fi 53396e7d3316Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 53406e7d3316Smrg" 53416e7d3316Smrg ;; 5342a966c04fSmrg 53436e7d3316Smrg *) 53446e7d3316Smrg $ECHO "\ 53456e7d3316Smrg if test -n \"\$lt_option_debug\"; then 5346edce3322Smrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 53476e7d3316Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5348a966c04fSmrg fi 53496e7d3316Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 53506e7d3316Smrg" 53516e7d3316Smrg ;; 53526e7d3316Smrg esac 53536e7d3316Smrg $ECHO "\ 53546e7d3316Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 53556e7d3316Smrg exit 1 53566e7d3316Smrg} 5357a966c04fSmrg 53586e7d3316Smrg# A function to encapsulate launching the target application 53596e7d3316Smrg# Strips options in the --lt-* namespace from \$@ and 53606e7d3316Smrg# launches target application with the remaining arguments. 53616e7d3316Smrgfunc_exec_program () 53626e7d3316Smrg{ 5363ac92798bSmrg case \" \$* \" in 5364ac92798bSmrg *\\ --lt-*) 5365ac92798bSmrg for lt_wr_arg 5366ac92798bSmrg do 5367ac92798bSmrg case \$lt_wr_arg in 5368ac92798bSmrg --lt-*) ;; 5369ac92798bSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370ac92798bSmrg esac 5371ac92798bSmrg shift 5372ac92798bSmrg done ;; 5373ac92798bSmrg esac 53746e7d3316Smrg func_exec_program_core \${1+\"\$@\"} 53756e7d3316Smrg} 5376a966c04fSmrg 53776e7d3316Smrg # Parse options 53786e7d3316Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379a966c04fSmrg 53806e7d3316Smrg # Find the directory that this script lives in. 53816e7d3316Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 53826e7d3316Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383a966c04fSmrg 53846e7d3316Smrg # Follow symbolic links until we get to the real thisdir. 53856e7d3316Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 53866e7d3316Smrg while test -n \"\$file\"; do 53876e7d3316Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388a966c04fSmrg 53896e7d3316Smrg # If there was a directory component, then change thisdir. 53906e7d3316Smrg if test \"x\$destdir\" != \"x\$file\"; then 53916e7d3316Smrg case \"\$destdir\" in 53926e7d3316Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 53936e7d3316Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 53946e7d3316Smrg esac 53956e7d3316Smrg fi 5396a966c04fSmrg 53976e7d3316Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 53986e7d3316Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 53996e7d3316Smrg done 5400a966c04fSmrg 54016e7d3316Smrg # Usually 'no', except on cygwin/mingw when embedded into 54026e7d3316Smrg # the cwrapper. 54036e7d3316Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 54046e7d3316Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 54056e7d3316Smrg # special case for '.' 54066e7d3316Smrg if test \"\$thisdir\" = \".\"; then 54076e7d3316Smrg thisdir=\`pwd\` 54086e7d3316Smrg fi 54096e7d3316Smrg # remove .libs from thisdir 54106e7d3316Smrg case \"\$thisdir\" in 54116e7d3316Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 54126e7d3316Smrg $objdir ) thisdir=. ;; 54136e7d3316Smrg esac 54146e7d3316Smrg fi 5415a966c04fSmrg 54166e7d3316Smrg # Try to get the absolute directory name. 54176e7d3316Smrg absdir=\`cd \"\$thisdir\" && pwd\` 54186e7d3316Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 54196e7d3316Smrg" 5420a966c04fSmrg 5421edce3322Smrg if test yes = "$fast_install"; then 54226e7d3316Smrg $ECHO "\ 54236e7d3316Smrg program=lt-'$outputname'$exeext 54246e7d3316Smrg progdir=\"\$thisdir/$objdir\" 5425a966c04fSmrg 54266e7d3316Smrg if test ! -f \"\$progdir/\$program\" || 5427edce3322Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 54286e7d3316Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429a966c04fSmrg 54306e7d3316Smrg file=\"\$\$-\$program\" 5431a966c04fSmrg 54326e7d3316Smrg if test ! -d \"\$progdir\"; then 54336e7d3316Smrg $MKDIR \"\$progdir\" 54346e7d3316Smrg else 54356e7d3316Smrg $RM \"\$progdir/\$file\" 54366e7d3316Smrg fi" 5437a966c04fSmrg 54386e7d3316Smrg $ECHO "\ 5439a966c04fSmrg 54406e7d3316Smrg # relink executable if necessary 54416e7d3316Smrg if test -n \"\$relink_command\"; then 54426e7d3316Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 54436e7d3316Smrg else 5444edce3322Smrg \$ECHO \"\$relink_command_output\" >&2 54456e7d3316Smrg $RM \"\$progdir/\$file\" 54466e7d3316Smrg exit 1 54476e7d3316Smrg fi 54486e7d3316Smrg fi 5449a966c04fSmrg 54506e7d3316Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 54516e7d3316Smrg { $RM \"\$progdir/\$program\"; 54526e7d3316Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 54536e7d3316Smrg $RM \"\$progdir/\$file\" 54546e7d3316Smrg fi" 54556e7d3316Smrg else 54566e7d3316Smrg $ECHO "\ 54576e7d3316Smrg program='$outputname' 54586e7d3316Smrg progdir=\"\$thisdir/$objdir\" 54596e7d3316Smrg" 54606e7d3316Smrg fi 5461a966c04fSmrg 54626e7d3316Smrg $ECHO "\ 5463a966c04fSmrg 54646e7d3316Smrg if test -f \"\$progdir/\$program\"; then" 5465a966c04fSmrg 546697cf2ee2Smrg # fixup the dll searchpath if we need to. 546797cf2ee2Smrg # 546897cf2ee2Smrg # Fix the DLL searchpath if we need to. Do this before prepending 546997cf2ee2Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 547097cf2ee2Smrg # libraries must come first. 547197cf2ee2Smrg if test -n "$dllsearchpath"; then 547297cf2ee2Smrg $ECHO "\ 547397cf2ee2Smrg # Add the dll search path components to the executable PATH 547497cf2ee2Smrg PATH=$dllsearchpath:\$PATH 547597cf2ee2Smrg" 547697cf2ee2Smrg fi 547797cf2ee2Smrg 54786e7d3316Smrg # Export our shlibpath_var if we have one. 5479edce3322Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 54806e7d3316Smrg $ECHO "\ 54816e7d3316Smrg # Add our own library path to $shlibpath_var 54826e7d3316Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483a966c04fSmrg 54846e7d3316Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 54856e7d3316Smrg # The second colon is a workaround for a bug in BeOS R4 sed 54866e7d3316Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487a966c04fSmrg 54886e7d3316Smrg export $shlibpath_var 54896e7d3316Smrg" 54906e7d3316Smrg fi 5491a966c04fSmrg 54926e7d3316Smrg $ECHO "\ 54936e7d3316Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 54946e7d3316Smrg # Run the actual program with our arguments. 54956e7d3316Smrg func_exec_program \${1+\"\$@\"} 54966e7d3316Smrg fi 54976e7d3316Smrg else 54986e7d3316Smrg # The program doesn't exist. 5499edce3322Smrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 55006e7d3316Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 55016e7d3316Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 55026e7d3316Smrg exit 1 55036e7d3316Smrg fi 55046e7d3316Smrgfi\ 55056e7d3316Smrg" 55066e7d3316Smrg} 5507a966c04fSmrg 5508a966c04fSmrg 55096e7d3316Smrg# func_emit_cwrapperexe_src 55106e7d3316Smrg# emit the source code for a wrapper executable on stdout 55116e7d3316Smrg# Must ONLY be called from within func_mode_link because 55126e7d3316Smrg# it depends on a number of variable set therein. 55136e7d3316Smrgfunc_emit_cwrapperexe_src () 55146e7d3316Smrg{ 55156e7d3316Smrg cat <<EOF 5516a966c04fSmrg 55176e7d3316Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518edce3322Smrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519a966c04fSmrg 55206e7d3316Smrg The $output program cannot be directly executed until all the libtool 55216e7d3316Smrg libraries that it depends on are installed. 5522a966c04fSmrg 55236e7d3316Smrg This wrapper executable should never be moved out of the build directory. 55246e7d3316Smrg If it is, it will not operate correctly. 55256e7d3316Smrg*/ 55266e7d3316SmrgEOF 55276e7d3316Smrg cat <<"EOF" 55286e7d3316Smrg#ifdef _MSC_VER 55296e7d3316Smrg# define _CRT_SECURE_NO_DEPRECATE 1 55306e7d3316Smrg#endif 55316e7d3316Smrg#include <stdio.h> 55326e7d3316Smrg#include <stdlib.h> 55336e7d3316Smrg#ifdef _MSC_VER 55346e7d3316Smrg# include <direct.h> 55356e7d3316Smrg# include <process.h> 55366e7d3316Smrg# include <io.h> 55376e7d3316Smrg#else 55386e7d3316Smrg# include <unistd.h> 55396e7d3316Smrg# include <stdint.h> 55406e7d3316Smrg# ifdef __CYGWIN__ 55416e7d3316Smrg# include <io.h> 55426e7d3316Smrg# endif 55436e7d3316Smrg#endif 55446e7d3316Smrg#include <malloc.h> 55456e7d3316Smrg#include <stdarg.h> 55466e7d3316Smrg#include <assert.h> 55476e7d3316Smrg#include <string.h> 55486e7d3316Smrg#include <ctype.h> 55496e7d3316Smrg#include <errno.h> 55506e7d3316Smrg#include <fcntl.h> 55516e7d3316Smrg#include <sys/stat.h> 5552a966c04fSmrg 5553edce3322Smrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554edce3322Smrg 55556e7d3316Smrg/* declarations of non-ANSI functions */ 5556edce3322Smrg#if defined __MINGW32__ 55576e7d3316Smrg# ifdef __STRICT_ANSI__ 55586e7d3316Smrgint _putenv (const char *); 55596e7d3316Smrg# endif 5560edce3322Smrg#elif defined __CYGWIN__ 55616e7d3316Smrg# ifdef __STRICT_ANSI__ 55626e7d3316Smrgchar *realpath (const char *, char *); 55636e7d3316Smrgint putenv (char *); 55646e7d3316Smrgint setenv (const char *, const char *, int); 55656e7d3316Smrg# endif 5566edce3322Smrg/* #elif defined other_platform || defined ... */ 55676e7d3316Smrg#endif 5568a966c04fSmrg 55696e7d3316Smrg/* portability defines, excluding path handling macros */ 5570edce3322Smrg#if defined _MSC_VER 55716e7d3316Smrg# define setmode _setmode 55726e7d3316Smrg# define stat _stat 55736e7d3316Smrg# define chmod _chmod 55746e7d3316Smrg# define getcwd _getcwd 55756e7d3316Smrg# define putenv _putenv 55766e7d3316Smrg# define S_IXUSR _S_IEXEC 5577edce3322Smrg#elif defined __MINGW32__ 55786e7d3316Smrg# define setmode _setmode 55796e7d3316Smrg# define stat _stat 55806e7d3316Smrg# define chmod _chmod 55816e7d3316Smrg# define getcwd _getcwd 55826e7d3316Smrg# define putenv _putenv 5583edce3322Smrg#elif defined __CYGWIN__ 55846e7d3316Smrg# define HAVE_SETENV 55856e7d3316Smrg# define FOPEN_WB "wb" 5586edce3322Smrg/* #elif defined other platforms ... */ 55876e7d3316Smrg#endif 5588a966c04fSmrg 5589edce3322Smrg#if defined PATH_MAX 55906e7d3316Smrg# define LT_PATHMAX PATH_MAX 5591edce3322Smrg#elif defined MAXPATHLEN 55926e7d3316Smrg# define LT_PATHMAX MAXPATHLEN 55936e7d3316Smrg#else 55946e7d3316Smrg# define LT_PATHMAX 1024 55956e7d3316Smrg#endif 5596a966c04fSmrg 55976e7d3316Smrg#ifndef S_IXOTH 55986e7d3316Smrg# define S_IXOTH 0 55996e7d3316Smrg#endif 56006e7d3316Smrg#ifndef S_IXGRP 56016e7d3316Smrg# define S_IXGRP 0 56026e7d3316Smrg#endif 5603a966c04fSmrg 56046e7d3316Smrg/* path handling portability macros */ 56056e7d3316Smrg#ifndef DIR_SEPARATOR 56066e7d3316Smrg# define DIR_SEPARATOR '/' 56076e7d3316Smrg# define PATH_SEPARATOR ':' 56086e7d3316Smrg#endif 5609a966c04fSmrg 5610edce3322Smrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611edce3322Smrg defined __OS2__ 56126e7d3316Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 56136e7d3316Smrg# define FOPEN_WB "wb" 56146e7d3316Smrg# ifndef DIR_SEPARATOR_2 56156e7d3316Smrg# define DIR_SEPARATOR_2 '\\' 56166e7d3316Smrg# endif 56176e7d3316Smrg# ifndef PATH_SEPARATOR_2 56186e7d3316Smrg# define PATH_SEPARATOR_2 ';' 56196e7d3316Smrg# endif 56206e7d3316Smrg#endif 5621a966c04fSmrg 56226e7d3316Smrg#ifndef DIR_SEPARATOR_2 56236e7d3316Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 56246e7d3316Smrg#else /* DIR_SEPARATOR_2 */ 56256e7d3316Smrg# define IS_DIR_SEPARATOR(ch) \ 56266e7d3316Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 56276e7d3316Smrg#endif /* DIR_SEPARATOR_2 */ 5628a966c04fSmrg 56296e7d3316Smrg#ifndef PATH_SEPARATOR_2 56306e7d3316Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 56316e7d3316Smrg#else /* PATH_SEPARATOR_2 */ 56326e7d3316Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 56336e7d3316Smrg#endif /* PATH_SEPARATOR_2 */ 56346e7d3316Smrg 56356e7d3316Smrg#ifndef FOPEN_WB 56366e7d3316Smrg# define FOPEN_WB "w" 56376e7d3316Smrg#endif 56386e7d3316Smrg#ifndef _O_BINARY 56396e7d3316Smrg# define _O_BINARY 0 56406e7d3316Smrg#endif 56416e7d3316Smrg 56426e7d3316Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 56436e7d3316Smrg#define XFREE(stale) do { \ 5644edce3322Smrg if (stale) { free (stale); stale = 0; } \ 56456e7d3316Smrg} while (0) 56466e7d3316Smrg 5647edce3322Smrg#if defined LT_DEBUGWRAPPER 56486e7d3316Smrgstatic int lt_debug = 1; 56496e7d3316Smrg#else 56506e7d3316Smrgstatic int lt_debug = 0; 56516e7d3316Smrg#endif 56526e7d3316Smrg 56536e7d3316Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 56546e7d3316Smrg 56556e7d3316Smrgvoid *xmalloc (size_t num); 56566e7d3316Smrgchar *xstrdup (const char *string); 56576e7d3316Smrgconst char *base_name (const char *name); 56586e7d3316Smrgchar *find_executable (const char *wrapper); 56596e7d3316Smrgchar *chase_symlinks (const char *pathspec); 56606e7d3316Smrgint make_executable (const char *path); 56616e7d3316Smrgint check_executable (const char *path); 56626e7d3316Smrgchar *strendzap (char *str, const char *pat); 56636e7d3316Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 56646e7d3316Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 56656e7d3316Smrgstatic const char *nonnull (const char *s); 56666e7d3316Smrgstatic const char *nonempty (const char *s); 56676e7d3316Smrgvoid lt_setenv (const char *name, const char *value); 56686e7d3316Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 56696e7d3316Smrgvoid lt_update_exe_path (const char *name, const char *value); 56706e7d3316Smrgvoid lt_update_lib_path (const char *name, const char *value); 56716e7d3316Smrgchar **prepare_spawn (char **argv); 56726e7d3316Smrgvoid lt_dump_script (FILE *f); 56736e7d3316SmrgEOF 56746e7d3316Smrg 56756e7d3316Smrg cat <<EOF 5676edce3322Smrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677edce3322Smrg# define externally_visible volatile 5678edce3322Smrg#else 5679edce3322Smrg# define externally_visible __attribute__((externally_visible)) volatile 5680edce3322Smrg#endif 5681edce3322Smrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 56826e7d3316Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 56836e7d3316SmrgEOF 56846e7d3316Smrg 5685edce3322Smrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 568697cf2ee2Smrg func_to_host_path "$temp_rpath" 56876e7d3316Smrg cat <<EOF 568897cf2ee2Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689a966c04fSmrgEOF 5690a966c04fSmrg else 56916e7d3316Smrg cat <<"EOF" 56926e7d3316Smrgconst char * LIB_PATH_VALUE = ""; 56936e7d3316SmrgEOF 5694a966c04fSmrg fi 56956e7d3316Smrg 56966e7d3316Smrg if test -n "$dllsearchpath"; then 569797cf2ee2Smrg func_to_host_path "$dllsearchpath:" 56986e7d3316Smrg cat <<EOF 56996e7d3316Smrgconst char * EXE_PATH_VARNAME = "PATH"; 570097cf2ee2Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 57016e7d3316SmrgEOF 5702a966c04fSmrg else 57036e7d3316Smrg cat <<"EOF" 57046e7d3316Smrgconst char * EXE_PATH_VARNAME = ""; 57056e7d3316Smrgconst char * EXE_PATH_VALUE = ""; 57066e7d3316SmrgEOF 5707a966c04fSmrg fi 57086e7d3316Smrg 5709edce3322Smrg if test yes = "$fast_install"; then 57106e7d3316Smrg cat <<EOF 57116e7d3316Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 57126e7d3316SmrgEOF 5713a966c04fSmrg else 57146e7d3316Smrg cat <<EOF 57156e7d3316Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 57166e7d3316SmrgEOF 5717a966c04fSmrg fi 5718a966c04fSmrg 5719a966c04fSmrg 57206e7d3316Smrg cat <<"EOF" 5721a966c04fSmrg 57226e7d3316Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723a966c04fSmrg 57246e7d3316Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 57256e7d3316Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 57266e7d3316Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727a966c04fSmrg 57286e7d3316Smrgint 57296e7d3316Smrgmain (int argc, char *argv[]) 57306e7d3316Smrg{ 57316e7d3316Smrg char **newargz; 57326e7d3316Smrg int newargc; 57336e7d3316Smrg char *tmp_pathspec; 57346e7d3316Smrg char *actual_cwrapper_path; 57356e7d3316Smrg char *actual_cwrapper_name; 57366e7d3316Smrg char *target_name; 57376e7d3316Smrg char *lt_argv_zero; 5738edce3322Smrg int rval = 127; 5739a966c04fSmrg 57406e7d3316Smrg int i; 5741a966c04fSmrg 57426e7d3316Smrg program_name = (char *) xstrdup (base_name (argv[0])); 5743edce3322Smrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744a966c04fSmrg 57456e7d3316Smrg /* very simple arg parsing; don't want to rely on getopt 57466e7d3316Smrg * also, copy all non cwrapper options to newargz, except 57476e7d3316Smrg * argz[0], which is handled differently 57486e7d3316Smrg */ 57496e7d3316Smrg newargc=0; 57506e7d3316Smrg for (i = 1; i < argc; i++) 57516e7d3316Smrg { 5752edce3322Smrg if (STREQ (argv[i], dumpscript_opt)) 57536e7d3316Smrg { 57546e7d3316SmrgEOF 5755edce3322Smrg case $host in 57566e7d3316Smrg *mingw* | *cygwin* ) 57576e7d3316Smrg # make stdout use "unix" line endings 57586e7d3316Smrg echo " setmode(1,_O_BINARY);" 57596e7d3316Smrg ;; 57602e2dd055Smrg esac 5761a966c04fSmrg 57626e7d3316Smrg cat <<"EOF" 57636e7d3316Smrg lt_dump_script (stdout); 57646e7d3316Smrg return 0; 57656e7d3316Smrg } 5766edce3322Smrg if (STREQ (argv[i], debug_opt)) 57676e7d3316Smrg { 57686e7d3316Smrg lt_debug = 1; 57696e7d3316Smrg continue; 57706e7d3316Smrg } 5771edce3322Smrg if (STREQ (argv[i], ltwrapper_option_prefix)) 57726e7d3316Smrg { 57736e7d3316Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 57746e7d3316Smrg namespace, but it is not one of the ones we know about and 57756e7d3316Smrg have already dealt with, above (inluding dump-script), then 57766e7d3316Smrg report an error. Otherwise, targets might begin to believe 57776e7d3316Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 57786e7d3316Smrg namespace. The first time any user complains about this, we'll 57796e7d3316Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 57806e7d3316Smrg or a configure.ac-settable value. 57816e7d3316Smrg */ 57826e7d3316Smrg lt_fatal (__FILE__, __LINE__, 57836e7d3316Smrg "unrecognized %s option: '%s'", 57846e7d3316Smrg ltwrapper_option_prefix, argv[i]); 57856e7d3316Smrg } 57866e7d3316Smrg /* otherwise ... */ 57876e7d3316Smrg newargz[++newargc] = xstrdup (argv[i]); 57886e7d3316Smrg } 57896e7d3316Smrg newargz[++newargc] = NULL; 5790a966c04fSmrg 57916e7d3316SmrgEOF 57926e7d3316Smrg cat <<EOF 57936e7d3316Smrg /* The GNU banner must be the first non-error debug message */ 5794edce3322Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 57956e7d3316SmrgEOF 57966e7d3316Smrg cat <<"EOF" 57976e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 57986e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 57996e7d3316Smrg 58006e7d3316Smrg tmp_pathspec = find_executable (argv[0]); 58016e7d3316Smrg if (tmp_pathspec == NULL) 58026e7d3316Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 58036e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, 58046e7d3316Smrg "(main) found exe (before symlink chase) at: %s\n", 58056e7d3316Smrg tmp_pathspec); 58066e7d3316Smrg 58076e7d3316Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 58086e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, 58096e7d3316Smrg "(main) found exe (after symlink chase) at: %s\n", 58106e7d3316Smrg actual_cwrapper_path); 58116e7d3316Smrg XFREE (tmp_pathspec); 58126e7d3316Smrg 58136e7d3316Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 58146e7d3316Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 58156e7d3316Smrg 58166e7d3316Smrg /* wrapper name transforms */ 58176e7d3316Smrg strendzap (actual_cwrapper_name, ".exe"); 58186e7d3316Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 58196e7d3316Smrg XFREE (actual_cwrapper_name); 58206e7d3316Smrg actual_cwrapper_name = tmp_pathspec; 58216e7d3316Smrg tmp_pathspec = 0; 58226e7d3316Smrg 58236e7d3316Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 58246e7d3316Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 58256e7d3316Smrg strendzap (target_name, ".exe"); 58266e7d3316Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 58276e7d3316Smrg XFREE (target_name); 58286e7d3316Smrg target_name = tmp_pathspec; 58296e7d3316Smrg tmp_pathspec = 0; 58306e7d3316Smrg 58316e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, 58326e7d3316Smrg "(main) libtool target name: %s\n", 58336e7d3316Smrg target_name); 58346e7d3316SmrgEOF 5835a966c04fSmrg 58366e7d3316Smrg cat <<EOF 58376e7d3316Smrg newargz[0] = 58386e7d3316Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 58396e7d3316Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 58406e7d3316Smrg strcpy (newargz[0], actual_cwrapper_path); 58416e7d3316Smrg strcat (newargz[0], "$objdir"); 58426e7d3316Smrg strcat (newargz[0], "/"); 58436e7d3316SmrgEOF 5844a966c04fSmrg 58456e7d3316Smrg cat <<"EOF" 58466e7d3316Smrg /* stop here, and copy so we don't have to do this twice */ 58476e7d3316Smrg tmp_pathspec = xstrdup (newargz[0]); 5848a966c04fSmrg 58496e7d3316Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 58506e7d3316Smrg strcat (newargz[0], actual_cwrapper_name); 5851a966c04fSmrg 58526e7d3316Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 58536e7d3316Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 58546e7d3316Smrg XFREE (tmp_pathspec); 58556e7d3316Smrg tmp_pathspec = NULL; 58566e7d3316SmrgEOF 5857a966c04fSmrg 58586e7d3316Smrg case $host_os in 58596e7d3316Smrg mingw*) 58606e7d3316Smrg cat <<"EOF" 58616e7d3316Smrg { 58626e7d3316Smrg char* p; 58636e7d3316Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 58646e7d3316Smrg { 58656e7d3316Smrg *p = '/'; 58666e7d3316Smrg } 58676e7d3316Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 58686e7d3316Smrg { 58696e7d3316Smrg *p = '/'; 58706e7d3316Smrg } 58716e7d3316Smrg } 58726e7d3316SmrgEOF 58736e7d3316Smrg ;; 58746e7d3316Smrg esac 5875a966c04fSmrg 58766e7d3316Smrg cat <<"EOF" 58776e7d3316Smrg XFREE (target_name); 58786e7d3316Smrg XFREE (actual_cwrapper_path); 58796e7d3316Smrg XFREE (actual_cwrapper_name); 5880a966c04fSmrg 58816e7d3316Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 58826e7d3316Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 588397cf2ee2Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 588497cf2ee2Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 588597cf2ee2Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 588697cf2ee2Smrg libraries must come first. */ 58876e7d3316Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 588897cf2ee2Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889a966c04fSmrg 58906e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 58916e7d3316Smrg nonnull (lt_argv_zero)); 58926e7d3316Smrg for (i = 0; i < newargc; i++) 58936e7d3316Smrg { 58946e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 58956e7d3316Smrg i, nonnull (newargz[i])); 58966e7d3316Smrg } 5897a966c04fSmrg 58986e7d3316SmrgEOF 5899a966c04fSmrg 59006e7d3316Smrg case $host_os in 59016e7d3316Smrg mingw*) 59026e7d3316Smrg cat <<"EOF" 59036e7d3316Smrg /* execv doesn't actually work on mingw as expected on unix */ 59046e7d3316Smrg newargz = prepare_spawn (newargz); 5905edce3322Smrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 59066e7d3316Smrg if (rval == -1) 59076e7d3316Smrg { 59086e7d3316Smrg /* failed to start process */ 59096e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, 59106e7d3316Smrg "(main) failed to launch target \"%s\": %s\n", 59116e7d3316Smrg lt_argv_zero, nonnull (strerror (errno))); 59126e7d3316Smrg return 127; 59136e7d3316Smrg } 59146e7d3316Smrg return rval; 59156e7d3316SmrgEOF 59166e7d3316Smrg ;; 59176e7d3316Smrg *) 59186e7d3316Smrg cat <<"EOF" 59196e7d3316Smrg execv (lt_argv_zero, newargz); 59206e7d3316Smrg return rval; /* =127, but avoids unused variable warning */ 59216e7d3316SmrgEOF 59226e7d3316Smrg ;; 59236e7d3316Smrg esac 5924a966c04fSmrg 59256e7d3316Smrg cat <<"EOF" 59266e7d3316Smrg} 5927a966c04fSmrg 59286e7d3316Smrgvoid * 59296e7d3316Smrgxmalloc (size_t num) 59306e7d3316Smrg{ 59316e7d3316Smrg void *p = (void *) malloc (num); 59326e7d3316Smrg if (!p) 59336e7d3316Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934a966c04fSmrg 59356e7d3316Smrg return p; 59366e7d3316Smrg} 5937a966c04fSmrg 59386e7d3316Smrgchar * 59396e7d3316Smrgxstrdup (const char *string) 59406e7d3316Smrg{ 59416e7d3316Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 59426e7d3316Smrg string) : NULL; 59436e7d3316Smrg} 5944a966c04fSmrg 59456e7d3316Smrgconst char * 59466e7d3316Smrgbase_name (const char *name) 59476e7d3316Smrg{ 59486e7d3316Smrg const char *base; 5949a966c04fSmrg 5950edce3322Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 59516e7d3316Smrg /* Skip over the disk name in MSDOS pathnames. */ 59526e7d3316Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 59536e7d3316Smrg name += 2; 59546e7d3316Smrg#endif 5955a966c04fSmrg 59566e7d3316Smrg for (base = name; *name; name++) 59576e7d3316Smrg if (IS_DIR_SEPARATOR (*name)) 59586e7d3316Smrg base = name + 1; 59596e7d3316Smrg return base; 59606e7d3316Smrg} 5961a966c04fSmrg 59626e7d3316Smrgint 59636e7d3316Smrgcheck_executable (const char *path) 59646e7d3316Smrg{ 59656e7d3316Smrg struct stat st; 5966a966c04fSmrg 59676e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 59686e7d3316Smrg nonempty (path)); 59696e7d3316Smrg if ((!path) || (!*path)) 59706e7d3316Smrg return 0; 5971a966c04fSmrg 59726e7d3316Smrg if ((stat (path, &st) >= 0) 59736e7d3316Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 59746e7d3316Smrg return 1; 59756e7d3316Smrg else 59766e7d3316Smrg return 0; 59776e7d3316Smrg} 5978a966c04fSmrg 59796e7d3316Smrgint 59806e7d3316Smrgmake_executable (const char *path) 59816e7d3316Smrg{ 59826e7d3316Smrg int rval = 0; 59836e7d3316Smrg struct stat st; 5984a966c04fSmrg 59856e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 59866e7d3316Smrg nonempty (path)); 59876e7d3316Smrg if ((!path) || (!*path)) 59886e7d3316Smrg return 0; 5989a966c04fSmrg 59906e7d3316Smrg if (stat (path, &st) >= 0) 59916e7d3316Smrg { 59926e7d3316Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 59936e7d3316Smrg } 59946e7d3316Smrg return rval; 59956e7d3316Smrg} 5996a966c04fSmrg 59976e7d3316Smrg/* Searches for the full path of the wrapper. Returns 59986e7d3316Smrg newly allocated full path name if found, NULL otherwise 59996e7d3316Smrg Does not chase symlinks, even on platforms that support them. 60006e7d3316Smrg*/ 60016e7d3316Smrgchar * 60026e7d3316Smrgfind_executable (const char *wrapper) 60036e7d3316Smrg{ 60046e7d3316Smrg int has_slash = 0; 60056e7d3316Smrg const char *p; 60066e7d3316Smrg const char *p_next; 60076e7d3316Smrg /* static buffer for getcwd */ 60086e7d3316Smrg char tmp[LT_PATHMAX + 1]; 6009edce3322Smrg size_t tmp_len; 60106e7d3316Smrg char *concat_name; 6011a966c04fSmrg 60126e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 60136e7d3316Smrg nonempty (wrapper)); 6014a966c04fSmrg 60156e7d3316Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 60166e7d3316Smrg return NULL; 6017a966c04fSmrg 60186e7d3316Smrg /* Absolute path? */ 6019edce3322Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60206e7d3316Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 60216e7d3316Smrg { 60226e7d3316Smrg concat_name = xstrdup (wrapper); 60236e7d3316Smrg if (check_executable (concat_name)) 60246e7d3316Smrg return concat_name; 60256e7d3316Smrg XFREE (concat_name); 60266e7d3316Smrg } 60276e7d3316Smrg else 60286e7d3316Smrg { 60296e7d3316Smrg#endif 60306e7d3316Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 60316e7d3316Smrg { 60326e7d3316Smrg concat_name = xstrdup (wrapper); 60336e7d3316Smrg if (check_executable (concat_name)) 60346e7d3316Smrg return concat_name; 60356e7d3316Smrg XFREE (concat_name); 60366e7d3316Smrg } 6037edce3322Smrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 60386e7d3316Smrg } 60396e7d3316Smrg#endif 6040a966c04fSmrg 60416e7d3316Smrg for (p = wrapper; *p; p++) 60426e7d3316Smrg if (*p == '/') 60436e7d3316Smrg { 60446e7d3316Smrg has_slash = 1; 60456e7d3316Smrg break; 60466e7d3316Smrg } 60476e7d3316Smrg if (!has_slash) 60486e7d3316Smrg { 60496e7d3316Smrg /* no slashes; search PATH */ 60506e7d3316Smrg const char *path = getenv ("PATH"); 60516e7d3316Smrg if (path != NULL) 60526e7d3316Smrg { 60536e7d3316Smrg for (p = path; *p; p = p_next) 60546e7d3316Smrg { 60556e7d3316Smrg const char *q; 60566e7d3316Smrg size_t p_len; 60576e7d3316Smrg for (q = p; *q; q++) 60586e7d3316Smrg if (IS_PATH_SEPARATOR (*q)) 60596e7d3316Smrg break; 6060edce3322Smrg p_len = (size_t) (q - p); 60616e7d3316Smrg p_next = (*q == '\0' ? q : q + 1); 60626e7d3316Smrg if (p_len == 0) 60636e7d3316Smrg { 60646e7d3316Smrg /* empty path: current directory */ 60656e7d3316Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 60666e7d3316Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 60676e7d3316Smrg nonnull (strerror (errno))); 60686e7d3316Smrg tmp_len = strlen (tmp); 60696e7d3316Smrg concat_name = 60706e7d3316Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60716e7d3316Smrg memcpy (concat_name, tmp, tmp_len); 60726e7d3316Smrg concat_name[tmp_len] = '/'; 60736e7d3316Smrg strcpy (concat_name + tmp_len + 1, wrapper); 60746e7d3316Smrg } 60756e7d3316Smrg else 60766e7d3316Smrg { 60776e7d3316Smrg concat_name = 60786e7d3316Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 60796e7d3316Smrg memcpy (concat_name, p, p_len); 60806e7d3316Smrg concat_name[p_len] = '/'; 60816e7d3316Smrg strcpy (concat_name + p_len + 1, wrapper); 60826e7d3316Smrg } 60836e7d3316Smrg if (check_executable (concat_name)) 60846e7d3316Smrg return concat_name; 60856e7d3316Smrg XFREE (concat_name); 60866e7d3316Smrg } 60876e7d3316Smrg } 60886e7d3316Smrg /* not found in PATH; assume curdir */ 60896e7d3316Smrg } 60906e7d3316Smrg /* Relative path | not found in path: prepend cwd */ 60916e7d3316Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 60926e7d3316Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 60936e7d3316Smrg nonnull (strerror (errno))); 60946e7d3316Smrg tmp_len = strlen (tmp); 60956e7d3316Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 60966e7d3316Smrg memcpy (concat_name, tmp, tmp_len); 60976e7d3316Smrg concat_name[tmp_len] = '/'; 60986e7d3316Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6099a966c04fSmrg 61006e7d3316Smrg if (check_executable (concat_name)) 61016e7d3316Smrg return concat_name; 61026e7d3316Smrg XFREE (concat_name); 61036e7d3316Smrg return NULL; 61046e7d3316Smrg} 6105a966c04fSmrg 61066e7d3316Smrgchar * 61076e7d3316Smrgchase_symlinks (const char *pathspec) 61086e7d3316Smrg{ 61096e7d3316Smrg#ifndef S_ISLNK 61106e7d3316Smrg return xstrdup (pathspec); 61116e7d3316Smrg#else 61126e7d3316Smrg char buf[LT_PATHMAX]; 61136e7d3316Smrg struct stat s; 61146e7d3316Smrg char *tmp_pathspec = xstrdup (pathspec); 61156e7d3316Smrg char *p; 61166e7d3316Smrg int has_symlinks = 0; 61176e7d3316Smrg while (strlen (tmp_pathspec) && !has_symlinks) 61186e7d3316Smrg { 61196e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, 61206e7d3316Smrg "checking path component for symlinks: %s\n", 61216e7d3316Smrg tmp_pathspec); 61226e7d3316Smrg if (lstat (tmp_pathspec, &s) == 0) 61236e7d3316Smrg { 61246e7d3316Smrg if (S_ISLNK (s.st_mode) != 0) 61256e7d3316Smrg { 61266e7d3316Smrg has_symlinks = 1; 61276e7d3316Smrg break; 61286e7d3316Smrg } 6129a966c04fSmrg 61306e7d3316Smrg /* search backwards for last DIR_SEPARATOR */ 61316e7d3316Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 61326e7d3316Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61336e7d3316Smrg p--; 61346e7d3316Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 61356e7d3316Smrg { 61366e7d3316Smrg /* no more DIR_SEPARATORS left */ 61376e7d3316Smrg break; 61386e7d3316Smrg } 61396e7d3316Smrg *p = '\0'; 61406e7d3316Smrg } 61416e7d3316Smrg else 61426e7d3316Smrg { 61436e7d3316Smrg lt_fatal (__FILE__, __LINE__, 61446e7d3316Smrg "error accessing file \"%s\": %s", 61456e7d3316Smrg tmp_pathspec, nonnull (strerror (errno))); 61466e7d3316Smrg } 61476e7d3316Smrg } 61486e7d3316Smrg XFREE (tmp_pathspec); 6149a966c04fSmrg 61506e7d3316Smrg if (!has_symlinks) 61516e7d3316Smrg { 61526e7d3316Smrg return xstrdup (pathspec); 61536e7d3316Smrg } 6154a966c04fSmrg 61556e7d3316Smrg tmp_pathspec = realpath (pathspec, buf); 61566e7d3316Smrg if (tmp_pathspec == 0) 61576e7d3316Smrg { 61586e7d3316Smrg lt_fatal (__FILE__, __LINE__, 61596e7d3316Smrg "could not follow symlinks for %s", pathspec); 61606e7d3316Smrg } 61616e7d3316Smrg return xstrdup (tmp_pathspec); 61626e7d3316Smrg#endif 61636e7d3316Smrg} 6164a966c04fSmrg 61656e7d3316Smrgchar * 61666e7d3316Smrgstrendzap (char *str, const char *pat) 61676e7d3316Smrg{ 61686e7d3316Smrg size_t len, patlen; 6169a966c04fSmrg 61706e7d3316Smrg assert (str != NULL); 61716e7d3316Smrg assert (pat != NULL); 6172a966c04fSmrg 61736e7d3316Smrg len = strlen (str); 61746e7d3316Smrg patlen = strlen (pat); 6175a966c04fSmrg 61766e7d3316Smrg if (patlen <= len) 61776e7d3316Smrg { 61786e7d3316Smrg str += len - patlen; 6179edce3322Smrg if (STREQ (str, pat)) 61806e7d3316Smrg *str = '\0'; 61816e7d3316Smrg } 61826e7d3316Smrg return str; 61836e7d3316Smrg} 6184a966c04fSmrg 61856e7d3316Smrgvoid 61866e7d3316Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 61876e7d3316Smrg{ 61886e7d3316Smrg va_list args; 61896e7d3316Smrg if (lt_debug) 61906e7d3316Smrg { 61916e7d3316Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 61926e7d3316Smrg va_start (args, fmt); 61936e7d3316Smrg (void) vfprintf (stderr, fmt, args); 61946e7d3316Smrg va_end (args); 61956e7d3316Smrg } 61966e7d3316Smrg} 6197a966c04fSmrg 61986e7d3316Smrgstatic void 61996e7d3316Smrglt_error_core (int exit_status, const char *file, 62006e7d3316Smrg int line, const char *mode, 62016e7d3316Smrg const char *message, va_list ap) 62026e7d3316Smrg{ 62036e7d3316Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 62046e7d3316Smrg vfprintf (stderr, message, ap); 62056e7d3316Smrg fprintf (stderr, ".\n"); 6206a966c04fSmrg 62076e7d3316Smrg if (exit_status >= 0) 62086e7d3316Smrg exit (exit_status); 62096e7d3316Smrg} 6210a966c04fSmrg 62116e7d3316Smrgvoid 62126e7d3316Smrglt_fatal (const char *file, int line, const char *message, ...) 62136e7d3316Smrg{ 62146e7d3316Smrg va_list ap; 62156e7d3316Smrg va_start (ap, message); 62166e7d3316Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 62176e7d3316Smrg va_end (ap); 62186e7d3316Smrg} 6219a966c04fSmrg 62206e7d3316Smrgstatic const char * 62216e7d3316Smrgnonnull (const char *s) 62226e7d3316Smrg{ 62236e7d3316Smrg return s ? s : "(null)"; 62246e7d3316Smrg} 6225a966c04fSmrg 62266e7d3316Smrgstatic const char * 62276e7d3316Smrgnonempty (const char *s) 62286e7d3316Smrg{ 62296e7d3316Smrg return (s && !*s) ? "(empty)" : nonnull (s); 62306e7d3316Smrg} 6231a966c04fSmrg 62326e7d3316Smrgvoid 62336e7d3316Smrglt_setenv (const char *name, const char *value) 62346e7d3316Smrg{ 62356e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, 62366e7d3316Smrg "(lt_setenv) setting '%s' to '%s'\n", 62376e7d3316Smrg nonnull (name), nonnull (value)); 62386e7d3316Smrg { 62396e7d3316Smrg#ifdef HAVE_SETENV 62406e7d3316Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 62416e7d3316Smrg char *str = xstrdup (value); 62426e7d3316Smrg setenv (name, str, 1); 62436e7d3316Smrg#else 6244edce3322Smrg size_t len = strlen (name) + 1 + strlen (value) + 1; 62456e7d3316Smrg char *str = XMALLOC (char, len); 62466e7d3316Smrg sprintf (str, "%s=%s", name, value); 62476e7d3316Smrg if (putenv (str) != EXIT_SUCCESS) 62486e7d3316Smrg { 62496e7d3316Smrg XFREE (str); 62506e7d3316Smrg } 62516e7d3316Smrg#endif 62526e7d3316Smrg } 62536e7d3316Smrg} 6254a966c04fSmrg 62556e7d3316Smrgchar * 62566e7d3316Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 62576e7d3316Smrg{ 62586e7d3316Smrg char *new_value; 62596e7d3316Smrg if (orig_value && *orig_value) 62606e7d3316Smrg { 6261edce3322Smrg size_t orig_value_len = strlen (orig_value); 6262edce3322Smrg size_t add_len = strlen (add); 62636e7d3316Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 62646e7d3316Smrg if (to_end) 62656e7d3316Smrg { 62666e7d3316Smrg strcpy (new_value, orig_value); 62676e7d3316Smrg strcpy (new_value + orig_value_len, add); 62686e7d3316Smrg } 62696e7d3316Smrg else 62706e7d3316Smrg { 62716e7d3316Smrg strcpy (new_value, add); 62726e7d3316Smrg strcpy (new_value + add_len, orig_value); 62736e7d3316Smrg } 62746e7d3316Smrg } 62756e7d3316Smrg else 62766e7d3316Smrg { 62776e7d3316Smrg new_value = xstrdup (add); 62786e7d3316Smrg } 62796e7d3316Smrg return new_value; 62806e7d3316Smrg} 6281a966c04fSmrg 62826e7d3316Smrgvoid 62836e7d3316Smrglt_update_exe_path (const char *name, const char *value) 62846e7d3316Smrg{ 62856e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, 62866e7d3316Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 62876e7d3316Smrg nonnull (name), nonnull (value)); 6288a966c04fSmrg 62896e7d3316Smrg if (name && *name && value && *value) 62906e7d3316Smrg { 62916e7d3316Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 62926e7d3316Smrg /* some systems can't cope with a ':'-terminated path #' */ 6293edce3322Smrg size_t len = strlen (new_value); 6294edce3322Smrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 62956e7d3316Smrg { 6296edce3322Smrg new_value[--len] = '\0'; 62976e7d3316Smrg } 62986e7d3316Smrg lt_setenv (name, new_value); 62996e7d3316Smrg XFREE (new_value); 63006e7d3316Smrg } 63016e7d3316Smrg} 6302a966c04fSmrg 63036e7d3316Smrgvoid 63046e7d3316Smrglt_update_lib_path (const char *name, const char *value) 63056e7d3316Smrg{ 63066e7d3316Smrg lt_debugprintf (__FILE__, __LINE__, 63076e7d3316Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 63086e7d3316Smrg nonnull (name), nonnull (value)); 6309a966c04fSmrg 63106e7d3316Smrg if (name && *name && value && *value) 63116e7d3316Smrg { 63126e7d3316Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 63136e7d3316Smrg lt_setenv (name, new_value); 63146e7d3316Smrg XFREE (new_value); 63156e7d3316Smrg } 63166e7d3316Smrg} 6317a966c04fSmrg 63186e7d3316SmrgEOF 63196e7d3316Smrg case $host_os in 63206e7d3316Smrg mingw*) 63216e7d3316Smrg cat <<"EOF" 63226e7d3316Smrg 63236e7d3316Smrg/* Prepares an argument vector before calling spawn(). 63246e7d3316Smrg Note that spawn() does not by itself call the command interpreter 63256e7d3316Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 63266e7d3316Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 63276e7d3316Smrg GetVersionEx(&v); 63286e7d3316Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 63296e7d3316Smrg }) ? "cmd.exe" : "command.com"). 63306e7d3316Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 63316e7d3316Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 63326e7d3316Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 63336e7d3316Smrg special way: 63346e7d3316Smrg - Space and tab are interpreted as delimiters. They are not treated as 63356e7d3316Smrg delimiters if they are surrounded by double quotes: "...". 63366e7d3316Smrg - Unescaped double quotes are removed from the input. Their only effect is 63376e7d3316Smrg that within double quotes, space and tab are treated like normal 63386e7d3316Smrg characters. 63396e7d3316Smrg - Backslashes not followed by double quotes are not special. 63406e7d3316Smrg - But 2*n+1 backslashes followed by a double quote become 63416e7d3316Smrg n backslashes followed by a double quote (n >= 0): 63426e7d3316Smrg \" -> " 63436e7d3316Smrg \\\" -> \" 63446e7d3316Smrg \\\\\" -> \\" 63456e7d3316Smrg */ 63466e7d3316Smrg#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" 63476e7d3316Smrg#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" 63486e7d3316Smrgchar ** 63496e7d3316Smrgprepare_spawn (char **argv) 63506e7d3316Smrg{ 63516e7d3316Smrg size_t argc; 63526e7d3316Smrg char **new_argv; 63536e7d3316Smrg size_t i; 6354a966c04fSmrg 63556e7d3316Smrg /* Count number of arguments. */ 63566e7d3316Smrg for (argc = 0; argv[argc] != NULL; argc++) 63576e7d3316Smrg ; 6358a966c04fSmrg 63596e7d3316Smrg /* Allocate new argument vector. */ 63606e7d3316Smrg new_argv = XMALLOC (char *, argc + 1); 6361a966c04fSmrg 63626e7d3316Smrg /* Put quoted arguments into the new argument vector. */ 63636e7d3316Smrg for (i = 0; i < argc; i++) 63646e7d3316Smrg { 63656e7d3316Smrg const char *string = argv[i]; 63666e7d3316Smrg 63676e7d3316Smrg if (string[0] == '\0') 63686e7d3316Smrg new_argv[i] = xstrdup ("\"\""); 63696e7d3316Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 63706e7d3316Smrg { 63716e7d3316Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 63726e7d3316Smrg size_t length; 63736e7d3316Smrg unsigned int backslashes; 63746e7d3316Smrg const char *s; 63756e7d3316Smrg char *quoted_string; 63766e7d3316Smrg char *p; 63776e7d3316Smrg 63786e7d3316Smrg length = 0; 63796e7d3316Smrg backslashes = 0; 63806e7d3316Smrg if (quote_around) 63816e7d3316Smrg length++; 63826e7d3316Smrg for (s = string; *s != '\0'; s++) 63836e7d3316Smrg { 63846e7d3316Smrg char c = *s; 63856e7d3316Smrg if (c == '"') 63866e7d3316Smrg length += backslashes + 1; 63876e7d3316Smrg length++; 63886e7d3316Smrg if (c == '\\') 63896e7d3316Smrg backslashes++; 63906e7d3316Smrg else 63916e7d3316Smrg backslashes = 0; 63926e7d3316Smrg } 63936e7d3316Smrg if (quote_around) 63946e7d3316Smrg length += backslashes + 1; 63956e7d3316Smrg 63966e7d3316Smrg quoted_string = XMALLOC (char, length + 1); 63976e7d3316Smrg 63986e7d3316Smrg p = quoted_string; 63996e7d3316Smrg backslashes = 0; 64006e7d3316Smrg if (quote_around) 64016e7d3316Smrg *p++ = '"'; 64026e7d3316Smrg for (s = string; *s != '\0'; s++) 64036e7d3316Smrg { 64046e7d3316Smrg char c = *s; 64056e7d3316Smrg if (c == '"') 64066e7d3316Smrg { 64076e7d3316Smrg unsigned int j; 64086e7d3316Smrg for (j = backslashes + 1; j > 0; j--) 64096e7d3316Smrg *p++ = '\\'; 64106e7d3316Smrg } 64116e7d3316Smrg *p++ = c; 64126e7d3316Smrg if (c == '\\') 64136e7d3316Smrg backslashes++; 64146e7d3316Smrg else 64156e7d3316Smrg backslashes = 0; 64166e7d3316Smrg } 64176e7d3316Smrg if (quote_around) 64186e7d3316Smrg { 64196e7d3316Smrg unsigned int j; 64206e7d3316Smrg for (j = backslashes; j > 0; j--) 64216e7d3316Smrg *p++ = '\\'; 64226e7d3316Smrg *p++ = '"'; 64236e7d3316Smrg } 64246e7d3316Smrg *p = '\0'; 6425a966c04fSmrg 64266e7d3316Smrg new_argv[i] = quoted_string; 64276e7d3316Smrg } 64286e7d3316Smrg else 64296e7d3316Smrg new_argv[i] = (char *) string; 64306e7d3316Smrg } 64316e7d3316Smrg new_argv[argc] = NULL; 6432a966c04fSmrg 64336e7d3316Smrg return new_argv; 64346e7d3316Smrg} 64356e7d3316SmrgEOF 6436a966c04fSmrg ;; 64376e7d3316Smrg esac 6438a966c04fSmrg 64396e7d3316Smrg cat <<"EOF" 64406e7d3316Smrgvoid lt_dump_script (FILE* f) 64416e7d3316Smrg{ 64426e7d3316SmrgEOF 64436e7d3316Smrg func_emit_wrapper yes | 6444ac92798bSmrg $SED -n -e ' 6445ac92798bSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6446ac92798bSmrg\2/ 6447ac92798bSmrgh 6448ac92798bSmrgs/\([\\"]\)/\\\1/g 6449ac92798bSmrgs/$/\\n/ 6450ac92798bSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451ac92798bSmrgg 6452ac92798bSmrgD' 64536e7d3316Smrg cat <<"EOF" 64546e7d3316Smrg} 64556e7d3316SmrgEOF 64566e7d3316Smrg} 64576e7d3316Smrg# end: func_emit_cwrapperexe_src 6458a966c04fSmrg 64596e7d3316Smrg# func_win32_import_lib_p ARG 64606e7d3316Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 64616e7d3316Smrgfunc_win32_import_lib_p () 64626e7d3316Smrg{ 6463edce3322Smrg $debug_cmd 6464edce3322Smrg 64656e7d3316Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 64666e7d3316Smrg *import*) : ;; 64676e7d3316Smrg *) false ;; 64686e7d3316Smrg esac 64696e7d3316Smrg} 6470a966c04fSmrg 6471edce3322Smrg# func_suncc_cstd_abi 6472edce3322Smrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473edce3322Smrg# Several compiler flags select an ABI that is incompatible with the 6474edce3322Smrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475edce3322Smrgfunc_suncc_cstd_abi () 6476edce3322Smrg{ 6477edce3322Smrg $debug_cmd 6478edce3322Smrg 6479edce3322Smrg case " $compile_command " in 6480edce3322Smrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481edce3322Smrg suncc_use_cstd_abi=no 6482edce3322Smrg ;; 6483edce3322Smrg *) 6484edce3322Smrg suncc_use_cstd_abi=yes 6485edce3322Smrg ;; 6486edce3322Smrg esac 6487edce3322Smrg} 6488edce3322Smrg 64896e7d3316Smrg# func_mode_link arg... 64906e7d3316Smrgfunc_mode_link () 64916e7d3316Smrg{ 6492edce3322Smrg $debug_cmd 6493edce3322Smrg 64946e7d3316Smrg case $host in 64956e7d3316Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 64966e7d3316Smrg # It is impossible to link a dll without this setting, and 64976e7d3316Smrg # we shouldn't force the makefile maintainer to figure out 6498edce3322Smrg # what system we are compiling for in order to pass an extra 64996e7d3316Smrg # flag for every libtool invocation. 65006e7d3316Smrg # allow_undefined=no 6501a966c04fSmrg 65026e7d3316Smrg # FIXME: Unfortunately, there are problems with the above when trying 6503edce3322Smrg # to make a dll that has undefined symbols, in which case not 65046e7d3316Smrg # even a static library is built. For now, we need to specify 65056e7d3316Smrg # -no-undefined on the libtool link line when we can be certain 65066e7d3316Smrg # that all symbols are satisfied, otherwise we get a static library. 65076e7d3316Smrg allow_undefined=yes 65086e7d3316Smrg ;; 65096e7d3316Smrg *) 65106e7d3316Smrg allow_undefined=yes 65116e7d3316Smrg ;; 65126e7d3316Smrg esac 65136e7d3316Smrg libtool_args=$nonopt 65146e7d3316Smrg base_compile="$nonopt $@" 65156e7d3316Smrg compile_command=$nonopt 65166e7d3316Smrg finalize_command=$nonopt 6517a966c04fSmrg 65186e7d3316Smrg compile_rpath= 65196e7d3316Smrg finalize_rpath= 65206e7d3316Smrg compile_shlibpath= 65216e7d3316Smrg finalize_shlibpath= 65226e7d3316Smrg convenience= 65236e7d3316Smrg old_convenience= 65246e7d3316Smrg deplibs= 65256e7d3316Smrg old_deplibs= 65266e7d3316Smrg compiler_flags= 65276e7d3316Smrg linker_flags= 65286e7d3316Smrg dllsearchpath= 65296e7d3316Smrg lib_search_path=`pwd` 65306e7d3316Smrg inst_prefix_dir= 65316e7d3316Smrg new_inherited_linker_flags= 6532a966c04fSmrg 65336e7d3316Smrg avoid_version=no 65346e7d3316Smrg bindir= 65356e7d3316Smrg dlfiles= 65366e7d3316Smrg dlprefiles= 65376e7d3316Smrg dlself=no 65386e7d3316Smrg export_dynamic=no 65396e7d3316Smrg export_symbols= 65406e7d3316Smrg export_symbols_regex= 65416e7d3316Smrg generated= 65426e7d3316Smrg libobjs= 65436e7d3316Smrg ltlibs= 65446e7d3316Smrg module=no 65456e7d3316Smrg no_install=no 65466e7d3316Smrg objs= 6547edce3322Smrg os2dllname= 65486e7d3316Smrg non_pic_objects= 65496e7d3316Smrg precious_files_regex= 65506e7d3316Smrg prefer_static_libs=no 6551edce3322Smrg preload=false 65526e7d3316Smrg prev= 65536e7d3316Smrg prevarg= 65546e7d3316Smrg release= 65556e7d3316Smrg rpath= 65566e7d3316Smrg xrpath= 65576e7d3316Smrg perm_rpath= 65586e7d3316Smrg temp_rpath= 65596e7d3316Smrg thread_safe=no 65606e7d3316Smrg vinfo= 65616e7d3316Smrg vinfo_number=no 65626e7d3316Smrg weak_libs= 6563edce3322Smrg single_module=$wl-single_module 65646e7d3316Smrg func_infer_tag $base_compile 6565a966c04fSmrg 65666e7d3316Smrg # We need to know -static, to get the right output filenames. 65676e7d3316Smrg for arg 65686e7d3316Smrg do 65696e7d3316Smrg case $arg in 65706e7d3316Smrg -shared) 6571edce3322Smrg test yes != "$build_libtool_libs" \ 6572edce3322Smrg && func_fatal_configuration "cannot build a shared library" 65736e7d3316Smrg build_old_libs=no 65746e7d3316Smrg break 65756e7d3316Smrg ;; 65766e7d3316Smrg -all-static | -static | -static-libtool-libs) 65776e7d3316Smrg case $arg in 65786e7d3316Smrg -all-static) 6579edce3322Smrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 65806e7d3316Smrg func_warning "complete static linking is impossible in this configuration" 65816e7d3316Smrg fi 65826e7d3316Smrg if test -n "$link_static_flag"; then 65836e7d3316Smrg dlopen_self=$dlopen_self_static 65846e7d3316Smrg fi 65856e7d3316Smrg prefer_static_libs=yes 65866e7d3316Smrg ;; 65876e7d3316Smrg -static) 65886e7d3316Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65896e7d3316Smrg dlopen_self=$dlopen_self_static 65906e7d3316Smrg fi 65916e7d3316Smrg prefer_static_libs=built 65926e7d3316Smrg ;; 65936e7d3316Smrg -static-libtool-libs) 65946e7d3316Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 65956e7d3316Smrg dlopen_self=$dlopen_self_static 65966e7d3316Smrg fi 65976e7d3316Smrg prefer_static_libs=yes 65986e7d3316Smrg ;; 65996e7d3316Smrg esac 66006e7d3316Smrg build_libtool_libs=no 66016e7d3316Smrg build_old_libs=yes 66026e7d3316Smrg break 66036e7d3316Smrg ;; 66046e7d3316Smrg esac 66056e7d3316Smrg done 6606a966c04fSmrg 66076e7d3316Smrg # See if our shared archives depend on static archives. 66086e7d3316Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609a966c04fSmrg 66106e7d3316Smrg # Go through the arguments, transforming them on the way. 66116e7d3316Smrg while test "$#" -gt 0; do 6612edce3322Smrg arg=$1 66136e7d3316Smrg shift 66141c235774Smrg func_quote_for_eval "$arg" 66151c235774Smrg qarg=$func_quote_for_eval_unquoted_result 66161c235774Smrg func_append libtool_args " $func_quote_for_eval_result" 6617a966c04fSmrg 66186e7d3316Smrg # If the previous option needs an argument, assign it. 66196e7d3316Smrg if test -n "$prev"; then 66206e7d3316Smrg case $prev in 66216e7d3316Smrg output) 66226e7d3316Smrg func_append compile_command " @OUTPUT@" 66236e7d3316Smrg func_append finalize_command " @OUTPUT@" 66246e7d3316Smrg ;; 66256e7d3316Smrg esac 6626a966c04fSmrg 66276e7d3316Smrg case $prev in 66286e7d3316Smrg bindir) 6629edce3322Smrg bindir=$arg 66306e7d3316Smrg prev= 66316e7d3316Smrg continue 66326e7d3316Smrg ;; 66336e7d3316Smrg dlfiles|dlprefiles) 6634edce3322Smrg $preload || { 66356e7d3316Smrg # Add the symbol object into the linking commands. 66366e7d3316Smrg func_append compile_command " @SYMFILE@" 66376e7d3316Smrg func_append finalize_command " @SYMFILE@" 6638edce3322Smrg preload=: 6639edce3322Smrg } 66406e7d3316Smrg case $arg in 66416e7d3316Smrg *.la | *.lo) ;; # We handle these cases below. 66426e7d3316Smrg force) 6643edce3322Smrg if test no = "$dlself"; then 66446e7d3316Smrg dlself=needless 66456e7d3316Smrg export_dynamic=yes 6646a966c04fSmrg fi 66476e7d3316Smrg prev= 66486e7d3316Smrg continue 66496e7d3316Smrg ;; 66506e7d3316Smrg self) 6651edce3322Smrg if test dlprefiles = "$prev"; then 66526e7d3316Smrg dlself=yes 6653edce3322Smrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 66546e7d3316Smrg dlself=yes 6655a966c04fSmrg else 66566e7d3316Smrg dlself=needless 66576e7d3316Smrg export_dynamic=yes 6658a966c04fSmrg fi 66596e7d3316Smrg prev= 66606e7d3316Smrg continue 66616e7d3316Smrg ;; 66626e7d3316Smrg *) 6663edce3322Smrg if test dlfiles = "$prev"; then 666497cf2ee2Smrg func_append dlfiles " $arg" 6665a966c04fSmrg else 666697cf2ee2Smrg func_append dlprefiles " $arg" 6667a966c04fSmrg fi 66686e7d3316Smrg prev= 66696e7d3316Smrg continue 66706e7d3316Smrg ;; 66716e7d3316Smrg esac 66726e7d3316Smrg ;; 66736e7d3316Smrg expsyms) 6674edce3322Smrg export_symbols=$arg 66756e7d3316Smrg test -f "$arg" \ 6676edce3322Smrg || func_fatal_error "symbol file '$arg' does not exist" 66776e7d3316Smrg prev= 66786e7d3316Smrg continue 66796e7d3316Smrg ;; 66806e7d3316Smrg expsyms_regex) 6681edce3322Smrg export_symbols_regex=$arg 66826e7d3316Smrg prev= 66836e7d3316Smrg continue 66846e7d3316Smrg ;; 66856e7d3316Smrg framework) 6686a966c04fSmrg case $host in 66876e7d3316Smrg *-*-darwin*) 66886e7d3316Smrg case "$deplibs " in 66896e7d3316Smrg *" $qarg.ltframework "*) ;; 669097cf2ee2Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 66916e7d3316Smrg ;; 66926e7d3316Smrg esac 66936e7d3316Smrg ;; 6694a966c04fSmrg esac 66956e7d3316Smrg prev= 66966e7d3316Smrg continue 6697a966c04fSmrg ;; 66986e7d3316Smrg inst_prefix) 6699edce3322Smrg inst_prefix_dir=$arg 6700edce3322Smrg prev= 6701edce3322Smrg continue 6702edce3322Smrg ;; 6703edce3322Smrg mllvm) 6704edce3322Smrg # Clang does not use LLVM to link, so we can simply discard any 6705edce3322Smrg # '-mllvm $arg' options when doing the link step. 67066e7d3316Smrg prev= 67076e7d3316Smrg continue 6708a966c04fSmrg ;; 67096e7d3316Smrg objectlist) 67106e7d3316Smrg if test -f "$arg"; then 67116e7d3316Smrg save_arg=$arg 67126e7d3316Smrg moreargs= 67136e7d3316Smrg for fil in `cat "$save_arg"` 67146e7d3316Smrg do 671597cf2ee2Smrg# func_append moreargs " $fil" 67166e7d3316Smrg arg=$fil 67176e7d3316Smrg # A libtool-controlled object. 6718a966c04fSmrg 67196e7d3316Smrg # Check to see that this really is a libtool object. 67206e7d3316Smrg if func_lalib_unsafe_p "$arg"; then 67216e7d3316Smrg pic_object= 67226e7d3316Smrg non_pic_object= 6723a966c04fSmrg 67246e7d3316Smrg # Read the .lo file 67256e7d3316Smrg func_source "$arg" 6726a966c04fSmrg 67276e7d3316Smrg if test -z "$pic_object" || 67286e7d3316Smrg test -z "$non_pic_object" || 6729edce3322Smrg test none = "$pic_object" && 6730edce3322Smrg test none = "$non_pic_object"; then 6731edce3322Smrg func_fatal_error "cannot find name of object for '$arg'" 67326e7d3316Smrg fi 6733a966c04fSmrg 67346e7d3316Smrg # Extract subdirectory from the argument. 67356e7d3316Smrg func_dirname "$arg" "/" "" 6736edce3322Smrg xdir=$func_dirname_result 6737a966c04fSmrg 6738edce3322Smrg if test none != "$pic_object"; then 67396e7d3316Smrg # Prepend the subdirectory the object is found in. 6740edce3322Smrg pic_object=$xdir$pic_object 6741a966c04fSmrg 6742edce3322Smrg if test dlfiles = "$prev"; then 6743edce3322Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 674497cf2ee2Smrg func_append dlfiles " $pic_object" 67456e7d3316Smrg prev= 67466e7d3316Smrg continue 67476e7d3316Smrg else 67486e7d3316Smrg # If libtool objects are unsupported, then we need to preload. 67496e7d3316Smrg prev=dlprefiles 67506e7d3316Smrg fi 67516e7d3316Smrg fi 6752a966c04fSmrg 67536e7d3316Smrg # CHECK ME: I think I busted this. -Ossama 6754edce3322Smrg if test dlprefiles = "$prev"; then 67556e7d3316Smrg # Preload the old-style object. 675697cf2ee2Smrg func_append dlprefiles " $pic_object" 67576e7d3316Smrg prev= 67586e7d3316Smrg fi 6759a966c04fSmrg 67606e7d3316Smrg # A PIC object. 67616e7d3316Smrg func_append libobjs " $pic_object" 6762edce3322Smrg arg=$pic_object 67636e7d3316Smrg fi 6764a966c04fSmrg 67656e7d3316Smrg # Non-PIC object. 6766edce3322Smrg if test none != "$non_pic_object"; then 67676e7d3316Smrg # Prepend the subdirectory the object is found in. 6768edce3322Smrg non_pic_object=$xdir$non_pic_object 6769a966c04fSmrg 67706e7d3316Smrg # A standard non-PIC object 67716e7d3316Smrg func_append non_pic_objects " $non_pic_object" 6772edce3322Smrg if test -z "$pic_object" || test none = "$pic_object"; then 6773edce3322Smrg arg=$non_pic_object 67746e7d3316Smrg fi 67756e7d3316Smrg else 67766e7d3316Smrg # If the PIC object exists, use it instead. 67776e7d3316Smrg # $xdir was prepended to $pic_object above. 6778edce3322Smrg non_pic_object=$pic_object 67796e7d3316Smrg func_append non_pic_objects " $non_pic_object" 67806e7d3316Smrg fi 67816e7d3316Smrg else 67826e7d3316Smrg # Only an error if not doing a dry-run. 67836e7d3316Smrg if $opt_dry_run; then 67846e7d3316Smrg # Extract subdirectory from the argument. 67856e7d3316Smrg func_dirname "$arg" "/" "" 6786edce3322Smrg xdir=$func_dirname_result 67876e7d3316Smrg 67886e7d3316Smrg func_lo2o "$arg" 67896e7d3316Smrg pic_object=$xdir$objdir/$func_lo2o_result 67906e7d3316Smrg non_pic_object=$xdir$func_lo2o_result 67916e7d3316Smrg func_append libobjs " $pic_object" 67926e7d3316Smrg func_append non_pic_objects " $non_pic_object" 67936e7d3316Smrg else 6794edce3322Smrg func_fatal_error "'$arg' is not a valid libtool object" 67956e7d3316Smrg fi 67966e7d3316Smrg fi 67976e7d3316Smrg done 6798a966c04fSmrg else 6799edce3322Smrg func_fatal_error "link input file '$arg' does not exist" 6800a966c04fSmrg fi 68016e7d3316Smrg arg=$save_arg 68026e7d3316Smrg prev= 68036e7d3316Smrg continue 68046e7d3316Smrg ;; 6805edce3322Smrg os2dllname) 6806edce3322Smrg os2dllname=$arg 6807edce3322Smrg prev= 6808edce3322Smrg continue 6809edce3322Smrg ;; 68106e7d3316Smrg precious_regex) 6811edce3322Smrg precious_files_regex=$arg 68126e7d3316Smrg prev= 68136e7d3316Smrg continue 68146e7d3316Smrg ;; 68156e7d3316Smrg release) 6816edce3322Smrg release=-$arg 68176e7d3316Smrg prev= 68186e7d3316Smrg continue 68196e7d3316Smrg ;; 68206e7d3316Smrg rpath | xrpath) 68216e7d3316Smrg # We need an absolute path. 68226e7d3316Smrg case $arg in 68236e7d3316Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 68246e7d3316Smrg *) 68256e7d3316Smrg func_fatal_error "only absolute run-paths are allowed" 68266e7d3316Smrg ;; 68276e7d3316Smrg esac 6828edce3322Smrg if test rpath = "$prev"; then 68296e7d3316Smrg case "$rpath " in 68306e7d3316Smrg *" $arg "*) ;; 683197cf2ee2Smrg *) func_append rpath " $arg" ;; 68326e7d3316Smrg esac 6833a966c04fSmrg else 68346e7d3316Smrg case "$xrpath " in 68356e7d3316Smrg *" $arg "*) ;; 683697cf2ee2Smrg *) func_append xrpath " $arg" ;; 68376e7d3316Smrg esac 6838a966c04fSmrg fi 68396e7d3316Smrg prev= 68406e7d3316Smrg continue 68416e7d3316Smrg ;; 68426e7d3316Smrg shrext) 6843edce3322Smrg shrext_cmds=$arg 68446e7d3316Smrg prev= 68456e7d3316Smrg continue 68466e7d3316Smrg ;; 68476e7d3316Smrg weak) 684897cf2ee2Smrg func_append weak_libs " $arg" 68496e7d3316Smrg prev= 68506e7d3316Smrg continue 68516e7d3316Smrg ;; 68526e7d3316Smrg xcclinker) 685397cf2ee2Smrg func_append linker_flags " $qarg" 685497cf2ee2Smrg func_append compiler_flags " $qarg" 68556e7d3316Smrg prev= 68566e7d3316Smrg func_append compile_command " $qarg" 68576e7d3316Smrg func_append finalize_command " $qarg" 68586e7d3316Smrg continue 68596e7d3316Smrg ;; 68606e7d3316Smrg xcompiler) 686197cf2ee2Smrg func_append compiler_flags " $qarg" 68626e7d3316Smrg prev= 68636e7d3316Smrg func_append compile_command " $qarg" 68646e7d3316Smrg func_append finalize_command " $qarg" 68656e7d3316Smrg continue 68666e7d3316Smrg ;; 68676e7d3316Smrg xlinker) 686897cf2ee2Smrg func_append linker_flags " $qarg" 686997cf2ee2Smrg func_append compiler_flags " $wl$qarg" 68706e7d3316Smrg prev= 68716e7d3316Smrg func_append compile_command " $wl$qarg" 68726e7d3316Smrg func_append finalize_command " $wl$qarg" 68736e7d3316Smrg continue 68746e7d3316Smrg ;; 68756e7d3316Smrg *) 68766e7d3316Smrg eval "$prev=\"\$arg\"" 68776e7d3316Smrg prev= 68786e7d3316Smrg continue 68796e7d3316Smrg ;; 6880a966c04fSmrg esac 68816e7d3316Smrg fi # test -n "$prev" 6882a966c04fSmrg 6883edce3322Smrg prevarg=$arg 6884a966c04fSmrg 68856e7d3316Smrg case $arg in 68866e7d3316Smrg -all-static) 68876e7d3316Smrg if test -n "$link_static_flag"; then 68886e7d3316Smrg # See comment for -static flag below, for more details. 68896e7d3316Smrg func_append compile_command " $link_static_flag" 68906e7d3316Smrg func_append finalize_command " $link_static_flag" 68916e7d3316Smrg fi 68926e7d3316Smrg continue 68936e7d3316Smrg ;; 6894a966c04fSmrg 68956e7d3316Smrg -allow-undefined) 68966e7d3316Smrg # FIXME: remove this flag sometime in the future. 6897edce3322Smrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 68986e7d3316Smrg ;; 6899a966c04fSmrg 69006e7d3316Smrg -avoid-version) 69016e7d3316Smrg avoid_version=yes 69026e7d3316Smrg continue 69036e7d3316Smrg ;; 6904a966c04fSmrg 69056e7d3316Smrg -bindir) 69066e7d3316Smrg prev=bindir 69076e7d3316Smrg continue 69086e7d3316Smrg ;; 6909a966c04fSmrg 69106e7d3316Smrg -dlopen) 69116e7d3316Smrg prev=dlfiles 69126e7d3316Smrg continue 69136e7d3316Smrg ;; 6914a966c04fSmrg 69156e7d3316Smrg -dlpreopen) 69166e7d3316Smrg prev=dlprefiles 69176e7d3316Smrg continue 69186e7d3316Smrg ;; 6919a966c04fSmrg 69206e7d3316Smrg -export-dynamic) 69216e7d3316Smrg export_dynamic=yes 69226e7d3316Smrg continue 69236e7d3316Smrg ;; 6924a966c04fSmrg 69256e7d3316Smrg -export-symbols | -export-symbols-regex) 69266e7d3316Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 69276e7d3316Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 69286e7d3316Smrg fi 6929edce3322Smrg if test X-export-symbols = "X$arg"; then 69306e7d3316Smrg prev=expsyms 69316e7d3316Smrg else 69326e7d3316Smrg prev=expsyms_regex 69336e7d3316Smrg fi 69346e7d3316Smrg continue 69356e7d3316Smrg ;; 6936a966c04fSmrg 69376e7d3316Smrg -framework) 69386e7d3316Smrg prev=framework 69396e7d3316Smrg continue 69406e7d3316Smrg ;; 6941a966c04fSmrg 69426e7d3316Smrg -inst-prefix-dir) 69436e7d3316Smrg prev=inst_prefix 69446e7d3316Smrg continue 69456e7d3316Smrg ;; 6946a966c04fSmrg 69476e7d3316Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 69486e7d3316Smrg # so, if we see these flags be careful not to treat them like -L 69496e7d3316Smrg -L[A-Z][A-Z]*:*) 69506e7d3316Smrg case $with_gcc/$host in 69516e7d3316Smrg no/*-*-irix* | /*-*-irix*) 69526e7d3316Smrg func_append compile_command " $arg" 69536e7d3316Smrg func_append finalize_command " $arg" 69546e7d3316Smrg ;; 69556e7d3316Smrg esac 69566e7d3316Smrg continue 69576e7d3316Smrg ;; 6958a966c04fSmrg 69596e7d3316Smrg -L*) 696097cf2ee2Smrg func_stripname "-L" '' "$arg" 696197cf2ee2Smrg if test -z "$func_stripname_result"; then 69626e7d3316Smrg if test "$#" -gt 0; then 6963edce3322Smrg func_fatal_error "require no space between '-L' and '$1'" 69646e7d3316Smrg else 6965edce3322Smrg func_fatal_error "need path for '-L' option" 69666e7d3316Smrg fi 69676e7d3316Smrg fi 696897cf2ee2Smrg func_resolve_sysroot "$func_stripname_result" 696997cf2ee2Smrg dir=$func_resolve_sysroot_result 69706e7d3316Smrg # We need an absolute path. 69716e7d3316Smrg case $dir in 69726e7d3316Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 69736e7d3316Smrg *) 69746e7d3316Smrg absdir=`cd "$dir" && pwd` 69756e7d3316Smrg test -z "$absdir" && \ 6976edce3322Smrg func_fatal_error "cannot determine absolute directory name of '$dir'" 6977edce3322Smrg dir=$absdir 69786e7d3316Smrg ;; 69796e7d3316Smrg esac 69806e7d3316Smrg case "$deplibs " in 698197cf2ee2Smrg *" -L$dir "* | *" $arg "*) 698297cf2ee2Smrg # Will only happen for absolute or sysroot arguments 698397cf2ee2Smrg ;; 69846e7d3316Smrg *) 698597cf2ee2Smrg # Preserve sysroot, but never include relative directories 698697cf2ee2Smrg case $dir in 698797cf2ee2Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 698897cf2ee2Smrg *) func_append deplibs " -L$dir" ;; 698997cf2ee2Smrg esac 699097cf2ee2Smrg func_append lib_search_path " $dir" 69916e7d3316Smrg ;; 69926e7d3316Smrg esac 69936e7d3316Smrg case $host in 69946e7d3316Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 69956e7d3316Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 69966e7d3316Smrg case :$dllsearchpath: in 69976e7d3316Smrg *":$dir:"*) ;; 69986e7d3316Smrg ::) dllsearchpath=$dir;; 699997cf2ee2Smrg *) func_append dllsearchpath ":$dir";; 70006e7d3316Smrg esac 70016e7d3316Smrg case :$dllsearchpath: in 70026e7d3316Smrg *":$testbindir:"*) ;; 70036e7d3316Smrg ::) dllsearchpath=$testbindir;; 700497cf2ee2Smrg *) func_append dllsearchpath ":$testbindir";; 70056e7d3316Smrg esac 70066e7d3316Smrg ;; 70076e7d3316Smrg esac 70086e7d3316Smrg continue 70096e7d3316Smrg ;; 7010a966c04fSmrg 70116e7d3316Smrg -l*) 7012edce3322Smrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 70136e7d3316Smrg case $host in 70146e7d3316Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 70156e7d3316Smrg # These systems don't actually have a C or math library (as such) 70166e7d3316Smrg continue 70176e7d3316Smrg ;; 70186e7d3316Smrg *-*-os2*) 70196e7d3316Smrg # These systems don't actually have a C library (as such) 7020edce3322Smrg test X-lc = "X$arg" && continue 70216e7d3316Smrg ;; 70221c235774Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70236e7d3316Smrg # Do not include libc due to us having libc/libc_r. 7024edce3322Smrg test X-lc = "X$arg" && continue 70256e7d3316Smrg ;; 70266e7d3316Smrg *-*-rhapsody* | *-*-darwin1.[012]) 70276e7d3316Smrg # Rhapsody C and math libraries are in the System framework 702897cf2ee2Smrg func_append deplibs " System.ltframework" 70296e7d3316Smrg continue 70306e7d3316Smrg ;; 70316e7d3316Smrg *-*-sco3.2v5* | *-*-sco5v6*) 70326e7d3316Smrg # Causes problems with __ctype 7033edce3322Smrg test X-lc = "X$arg" && continue 70346e7d3316Smrg ;; 70356e7d3316Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 70366e7d3316Smrg # Compiler inserts libc in the correct place for threads to work 7037edce3322Smrg test X-lc = "X$arg" && continue 70386e7d3316Smrg ;; 70396e7d3316Smrg esac 7040edce3322Smrg elif test X-lc_r = "X$arg"; then 70416e7d3316Smrg case $host in 70421c235774Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 70436e7d3316Smrg # Do not include libc_r directly, use -pthread flag. 70446e7d3316Smrg continue 70456e7d3316Smrg ;; 70466e7d3316Smrg esac 70476e7d3316Smrg fi 704897cf2ee2Smrg func_append deplibs " $arg" 70496e7d3316Smrg continue 70506e7d3316Smrg ;; 7051a966c04fSmrg 7052edce3322Smrg -mllvm) 7053edce3322Smrg prev=mllvm 7054edce3322Smrg continue 7055edce3322Smrg ;; 7056edce3322Smrg 70576e7d3316Smrg -module) 70586e7d3316Smrg module=yes 70596e7d3316Smrg continue 70606e7d3316Smrg ;; 7061a966c04fSmrg 70626e7d3316Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 70636e7d3316Smrg # classes, name mangling, and exception handling. 70646e7d3316Smrg # Darwin uses the -arch flag to determine output architecture. 706597cf2ee2Smrg -model|-arch|-isysroot|--sysroot) 706697cf2ee2Smrg func_append compiler_flags " $arg" 70676e7d3316Smrg func_append compile_command " $arg" 70686e7d3316Smrg func_append finalize_command " $arg" 70696e7d3316Smrg prev=xcompiler 70706e7d3316Smrg continue 70716e7d3316Smrg ;; 70721c235774Smrg 70731c235774Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074ac92798bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 707597cf2ee2Smrg func_append compiler_flags " $arg" 70766e7d3316Smrg func_append compile_command " $arg" 70776e7d3316Smrg func_append finalize_command " $arg" 70786e7d3316Smrg case "$new_inherited_linker_flags " in 70796e7d3316Smrg *" $arg "*) ;; 708097cf2ee2Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 70816e7d3316Smrg esac 70826e7d3316Smrg continue 70836e7d3316Smrg ;; 7084a966c04fSmrg 70856e7d3316Smrg -multi_module) 7086edce3322Smrg single_module=$wl-multi_module 70876e7d3316Smrg continue 70886e7d3316Smrg ;; 7089a966c04fSmrg 70906e7d3316Smrg -no-fast-install) 70916e7d3316Smrg fast_install=no 70926e7d3316Smrg continue 70936e7d3316Smrg ;; 7094a966c04fSmrg 70956e7d3316Smrg -no-install) 70966e7d3316Smrg case $host in 70976e7d3316Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 70986e7d3316Smrg # The PATH hackery in wrapper scripts is required on Windows 70996e7d3316Smrg # and Darwin in order for the loader to find any dlls it needs. 7100edce3322Smrg func_warning "'-no-install' is ignored for $host" 7101edce3322Smrg func_warning "assuming '-no-fast-install' instead" 71026e7d3316Smrg fast_install=no 71036e7d3316Smrg ;; 71046e7d3316Smrg *) no_install=yes ;; 71056e7d3316Smrg esac 71066e7d3316Smrg continue 71076e7d3316Smrg ;; 7108a966c04fSmrg 71096e7d3316Smrg -no-undefined) 71106e7d3316Smrg allow_undefined=no 71116e7d3316Smrg continue 71126e7d3316Smrg ;; 7113a966c04fSmrg 71146e7d3316Smrg -objectlist) 71156e7d3316Smrg prev=objectlist 71166e7d3316Smrg continue 71176e7d3316Smrg ;; 7118a966c04fSmrg 7119edce3322Smrg -os2dllname) 7120edce3322Smrg prev=os2dllname 7121edce3322Smrg continue 7122edce3322Smrg ;; 7123edce3322Smrg 71246e7d3316Smrg -o) prev=output ;; 7125a966c04fSmrg 71266e7d3316Smrg -precious-files-regex) 71276e7d3316Smrg prev=precious_regex 71286e7d3316Smrg continue 71296e7d3316Smrg ;; 7130a966c04fSmrg 71316e7d3316Smrg -release) 71326e7d3316Smrg prev=release 71336e7d3316Smrg continue 71346e7d3316Smrg ;; 7135a966c04fSmrg 71366e7d3316Smrg -rpath) 71376e7d3316Smrg prev=rpath 71386e7d3316Smrg continue 71396e7d3316Smrg ;; 7140a966c04fSmrg 71416e7d3316Smrg -R) 71426e7d3316Smrg prev=xrpath 71436e7d3316Smrg continue 71446e7d3316Smrg ;; 7145a966c04fSmrg 71466e7d3316Smrg -R*) 71476e7d3316Smrg func_stripname '-R' '' "$arg" 71486e7d3316Smrg dir=$func_stripname_result 71496e7d3316Smrg # We need an absolute path. 71506e7d3316Smrg case $dir in 71516e7d3316Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 715297cf2ee2Smrg =*) 715397cf2ee2Smrg func_stripname '=' '' "$dir" 715497cf2ee2Smrg dir=$lt_sysroot$func_stripname_result 715597cf2ee2Smrg ;; 71566e7d3316Smrg *) 71576e7d3316Smrg func_fatal_error "only absolute run-paths are allowed" 71586e7d3316Smrg ;; 71596e7d3316Smrg esac 71606e7d3316Smrg case "$xrpath " in 71616e7d3316Smrg *" $dir "*) ;; 716297cf2ee2Smrg *) func_append xrpath " $dir" ;; 71636e7d3316Smrg esac 71646e7d3316Smrg continue 71656e7d3316Smrg ;; 7166a966c04fSmrg 71676e7d3316Smrg -shared) 71686e7d3316Smrg # The effects of -shared are defined in a previous loop. 71696e7d3316Smrg continue 71706e7d3316Smrg ;; 7171a966c04fSmrg 71726e7d3316Smrg -shrext) 71736e7d3316Smrg prev=shrext 71746e7d3316Smrg continue 71756e7d3316Smrg ;; 7176a966c04fSmrg 71776e7d3316Smrg -static | -static-libtool-libs) 71786e7d3316Smrg # The effects of -static are defined in a previous loop. 71796e7d3316Smrg # We used to do the same as -all-static on platforms that 71806e7d3316Smrg # didn't have a PIC flag, but the assumption that the effects 71816e7d3316Smrg # would be equivalent was wrong. It would break on at least 71826e7d3316Smrg # Digital Unix and AIX. 71836e7d3316Smrg continue 71846e7d3316Smrg ;; 7185a966c04fSmrg 71866e7d3316Smrg -thread-safe) 71876e7d3316Smrg thread_safe=yes 71886e7d3316Smrg continue 71896e7d3316Smrg ;; 7190a966c04fSmrg 71916e7d3316Smrg -version-info) 71926e7d3316Smrg prev=vinfo 71936e7d3316Smrg continue 71946e7d3316Smrg ;; 7195a966c04fSmrg 71966e7d3316Smrg -version-number) 71976e7d3316Smrg prev=vinfo 71986e7d3316Smrg vinfo_number=yes 71996e7d3316Smrg continue 72006e7d3316Smrg ;; 7201a966c04fSmrg 72026e7d3316Smrg -weak) 72036e7d3316Smrg prev=weak 72046e7d3316Smrg continue 72056e7d3316Smrg ;; 7206a966c04fSmrg 72076e7d3316Smrg -Wc,*) 72086e7d3316Smrg func_stripname '-Wc,' '' "$arg" 72096e7d3316Smrg args=$func_stripname_result 72106e7d3316Smrg arg= 7211edce3322Smrg save_ifs=$IFS; IFS=, 72126e7d3316Smrg for flag in $args; do 7213edce3322Smrg IFS=$save_ifs 72141c235774Smrg func_quote_for_eval "$flag" 72151c235774Smrg func_append arg " $func_quote_for_eval_result" 72161c235774Smrg func_append compiler_flags " $func_quote_for_eval_result" 72176e7d3316Smrg done 7218edce3322Smrg IFS=$save_ifs 72196e7d3316Smrg func_stripname ' ' '' "$arg" 72206e7d3316Smrg arg=$func_stripname_result 72216e7d3316Smrg ;; 7222a966c04fSmrg 72236e7d3316Smrg -Wl,*) 72246e7d3316Smrg func_stripname '-Wl,' '' "$arg" 72256e7d3316Smrg args=$func_stripname_result 72266e7d3316Smrg arg= 7227edce3322Smrg save_ifs=$IFS; IFS=, 72286e7d3316Smrg for flag in $args; do 7229edce3322Smrg IFS=$save_ifs 72301c235774Smrg func_quote_for_eval "$flag" 72311c235774Smrg func_append arg " $wl$func_quote_for_eval_result" 72321c235774Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 72331c235774Smrg func_append linker_flags " $func_quote_for_eval_result" 72346e7d3316Smrg done 7235edce3322Smrg IFS=$save_ifs 72366e7d3316Smrg func_stripname ' ' '' "$arg" 72376e7d3316Smrg arg=$func_stripname_result 72386e7d3316Smrg ;; 7239a966c04fSmrg 72406e7d3316Smrg -Xcompiler) 72416e7d3316Smrg prev=xcompiler 72426e7d3316Smrg continue 72436e7d3316Smrg ;; 7244a966c04fSmrg 72456e7d3316Smrg -Xlinker) 72466e7d3316Smrg prev=xlinker 72476e7d3316Smrg continue 72486e7d3316Smrg ;; 7249a966c04fSmrg 72506e7d3316Smrg -XCClinker) 72516e7d3316Smrg prev=xcclinker 72526e7d3316Smrg continue 72536e7d3316Smrg ;; 7254a966c04fSmrg 72556e7d3316Smrg # -msg_* for osf cc 72566e7d3316Smrg -msg_*) 72571c235774Smrg func_quote_for_eval "$arg" 72581c235774Smrg arg=$func_quote_for_eval_result 72596e7d3316Smrg ;; 7260a966c04fSmrg 72616e7d3316Smrg # Flags to be passed through unchanged, with rationale: 72626e7d3316Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 72636e7d3316Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 72646e7d3316Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 72656e7d3316Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 72666e7d3316Smrg # -q* compiler args for the IBM compiler 72676e7d3316Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 72686e7d3316Smrg # -F/path path to uninstalled frameworks, gcc on darwin 72696e7d3316Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270edce3322Smrg # -fstack-protector* stack protector flags for GCC 72716e7d3316Smrg # @file GCC response files 72726e7d3316Smrg # -tp=* Portland pgcc target processor selection 727397cf2ee2Smrg # --sysroot=* for sysroot support 7274edce3322Smrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275edce3322Smrg # -stdlib=* select c++ std lib with clang 72766e7d3316Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 727797cf2ee2Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 72781c235774Smrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 72791c235774Smrg func_quote_for_eval "$arg" 72801c235774Smrg arg=$func_quote_for_eval_result 72816e7d3316Smrg func_append compile_command " $arg" 72826e7d3316Smrg func_append finalize_command " $arg" 728397cf2ee2Smrg func_append compiler_flags " $arg" 72846e7d3316Smrg continue 72856e7d3316Smrg ;; 7286a966c04fSmrg 7287edce3322Smrg -Z*) 7288edce3322Smrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7289edce3322Smrg # OS/2 uses -Zxxx to specify OS/2-specific options 7290edce3322Smrg compiler_flags="$compiler_flags $arg" 7291edce3322Smrg func_append compile_command " $arg" 7292edce3322Smrg func_append finalize_command " $arg" 7293edce3322Smrg case $arg in 7294edce3322Smrg -Zlinker | -Zstack) 7295edce3322Smrg prev=xcompiler 7296edce3322Smrg ;; 7297edce3322Smrg esac 7298edce3322Smrg continue 7299edce3322Smrg else 7300edce3322Smrg # Otherwise treat like 'Some other compiler flag' below 73011c235774Smrg func_quote_for_eval "$arg" 73021c235774Smrg arg=$func_quote_for_eval_result 7303edce3322Smrg fi 7304edce3322Smrg ;; 7305edce3322Smrg 73066e7d3316Smrg # Some other compiler flag. 73076e7d3316Smrg -* | +*) 73081c235774Smrg func_quote_for_eval "$arg" 73091c235774Smrg arg=$func_quote_for_eval_result 73106e7d3316Smrg ;; 7311a966c04fSmrg 73126e7d3316Smrg *.$objext) 73136e7d3316Smrg # A standard object. 731497cf2ee2Smrg func_append objs " $arg" 73156e7d3316Smrg ;; 7316a966c04fSmrg 73176e7d3316Smrg *.lo) 73186e7d3316Smrg # A libtool-controlled object. 7319a966c04fSmrg 73206e7d3316Smrg # Check to see that this really is a libtool object. 73216e7d3316Smrg if func_lalib_unsafe_p "$arg"; then 73226e7d3316Smrg pic_object= 73236e7d3316Smrg non_pic_object= 7324a966c04fSmrg 73256e7d3316Smrg # Read the .lo file 73266e7d3316Smrg func_source "$arg" 7327a966c04fSmrg 73286e7d3316Smrg if test -z "$pic_object" || 73296e7d3316Smrg test -z "$non_pic_object" || 7330edce3322Smrg test none = "$pic_object" && 7331edce3322Smrg test none = "$non_pic_object"; then 7332edce3322Smrg func_fatal_error "cannot find name of object for '$arg'" 73336e7d3316Smrg fi 73342e2dd055Smrg 73356e7d3316Smrg # Extract subdirectory from the argument. 73366e7d3316Smrg func_dirname "$arg" "/" "" 7337edce3322Smrg xdir=$func_dirname_result 7338a966c04fSmrg 7339edce3322Smrg test none = "$pic_object" || { 73406e7d3316Smrg # Prepend the subdirectory the object is found in. 7341edce3322Smrg pic_object=$xdir$pic_object 7342a966c04fSmrg 7343edce3322Smrg if test dlfiles = "$prev"; then 7344edce3322Smrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 734597cf2ee2Smrg func_append dlfiles " $pic_object" 73466e7d3316Smrg prev= 73476e7d3316Smrg continue 73486e7d3316Smrg else 73496e7d3316Smrg # If libtool objects are unsupported, then we need to preload. 73506e7d3316Smrg prev=dlprefiles 73516e7d3316Smrg fi 73526e7d3316Smrg fi 73536e7d3316Smrg 73546e7d3316Smrg # CHECK ME: I think I busted this. -Ossama 7355edce3322Smrg if test dlprefiles = "$prev"; then 73566e7d3316Smrg # Preload the old-style object. 735797cf2ee2Smrg func_append dlprefiles " $pic_object" 73586e7d3316Smrg prev= 73596e7d3316Smrg fi 73606e7d3316Smrg 73616e7d3316Smrg # A PIC object. 73626e7d3316Smrg func_append libobjs " $pic_object" 7363edce3322Smrg arg=$pic_object 7364edce3322Smrg } 73656e7d3316Smrg 73666e7d3316Smrg # Non-PIC object. 7367edce3322Smrg if test none != "$non_pic_object"; then 73686e7d3316Smrg # Prepend the subdirectory the object is found in. 7369edce3322Smrg non_pic_object=$xdir$non_pic_object 73706e7d3316Smrg 73716e7d3316Smrg # A standard non-PIC object 73726e7d3316Smrg func_append non_pic_objects " $non_pic_object" 7373edce3322Smrg if test -z "$pic_object" || test none = "$pic_object"; then 7374edce3322Smrg arg=$non_pic_object 73756e7d3316Smrg fi 73766e7d3316Smrg else 73776e7d3316Smrg # If the PIC object exists, use it instead. 73786e7d3316Smrg # $xdir was prepended to $pic_object above. 7379edce3322Smrg non_pic_object=$pic_object 73806e7d3316Smrg func_append non_pic_objects " $non_pic_object" 73816e7d3316Smrg fi 73826e7d3316Smrg else 73836e7d3316Smrg # Only an error if not doing a dry-run. 73846e7d3316Smrg if $opt_dry_run; then 73856e7d3316Smrg # Extract subdirectory from the argument. 73866e7d3316Smrg func_dirname "$arg" "/" "" 7387edce3322Smrg xdir=$func_dirname_result 73886e7d3316Smrg 73896e7d3316Smrg func_lo2o "$arg" 73906e7d3316Smrg pic_object=$xdir$objdir/$func_lo2o_result 73916e7d3316Smrg non_pic_object=$xdir$func_lo2o_result 73926e7d3316Smrg func_append libobjs " $pic_object" 73936e7d3316Smrg func_append non_pic_objects " $non_pic_object" 73946e7d3316Smrg else 7395edce3322Smrg func_fatal_error "'$arg' is not a valid libtool object" 73966e7d3316Smrg fi 73976e7d3316Smrg fi 73986e7d3316Smrg ;; 73996e7d3316Smrg 74006e7d3316Smrg *.$libext) 74016e7d3316Smrg # An archive. 740297cf2ee2Smrg func_append deplibs " $arg" 740397cf2ee2Smrg func_append old_deplibs " $arg" 74046e7d3316Smrg continue 74056e7d3316Smrg ;; 74066e7d3316Smrg 74076e7d3316Smrg *.la) 74086e7d3316Smrg # A libtool-controlled library. 74096e7d3316Smrg 741097cf2ee2Smrg func_resolve_sysroot "$arg" 7411edce3322Smrg if test dlfiles = "$prev"; then 74126e7d3316Smrg # This library was specified with -dlopen. 741397cf2ee2Smrg func_append dlfiles " $func_resolve_sysroot_result" 74146e7d3316Smrg prev= 7415edce3322Smrg elif test dlprefiles = "$prev"; then 74166e7d3316Smrg # The library was specified with -dlpreopen. 741797cf2ee2Smrg func_append dlprefiles " $func_resolve_sysroot_result" 74186e7d3316Smrg prev= 74196e7d3316Smrg else 742097cf2ee2Smrg func_append deplibs " $func_resolve_sysroot_result" 74216e7d3316Smrg fi 74226e7d3316Smrg continue 74236e7d3316Smrg ;; 74246e7d3316Smrg 74256e7d3316Smrg # Some other compiler argument. 74266e7d3316Smrg *) 74276e7d3316Smrg # Unknown arguments in both finalize_command and compile_command need 74286e7d3316Smrg # to be aesthetically quoted because they are evaled later. 74291c235774Smrg func_quote_for_eval "$arg" 74301c235774Smrg arg=$func_quote_for_eval_result 74316e7d3316Smrg ;; 74326e7d3316Smrg esac # arg 74336e7d3316Smrg 74346e7d3316Smrg # Now actually substitute the argument into the commands. 74356e7d3316Smrg if test -n "$arg"; then 74366e7d3316Smrg func_append compile_command " $arg" 74376e7d3316Smrg func_append finalize_command " $arg" 74386e7d3316Smrg fi 74396e7d3316Smrg done # argument parsing loop 74406e7d3316Smrg 74416e7d3316Smrg test -n "$prev" && \ 7442edce3322Smrg func_fatal_help "the '$prevarg' option requires an argument" 74436e7d3316Smrg 7444edce3322Smrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 74456e7d3316Smrg eval arg=\"$export_dynamic_flag_spec\" 74466e7d3316Smrg func_append compile_command " $arg" 74476e7d3316Smrg func_append finalize_command " $arg" 74486e7d3316Smrg fi 74496e7d3316Smrg 74506e7d3316Smrg oldlibs= 74516e7d3316Smrg # calculate the name of the file, without its directory 74526e7d3316Smrg func_basename "$output" 7453edce3322Smrg outputname=$func_basename_result 7454edce3322Smrg libobjs_save=$libobjs 74556e7d3316Smrg 74566e7d3316Smrg if test -n "$shlibpath_var"; then 74576e7d3316Smrg # get the directories listed in $shlibpath_var 7458edce3322Smrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7459a966c04fSmrg else 74606e7d3316Smrg shlib_search_path= 7461a966c04fSmrg fi 74626e7d3316Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 74636e7d3316Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7464a966c04fSmrg 7465edce3322Smrg # Definition is injected by LT_CONFIG during libtool generation. 7466edce3322Smrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7467edce3322Smrg 74686e7d3316Smrg func_dirname "$output" "/" "" 7469edce3322Smrg output_objdir=$func_dirname_result$objdir 747097cf2ee2Smrg func_to_tool_file "$output_objdir/" 747197cf2ee2Smrg tool_output_objdir=$func_to_tool_file_result 74726e7d3316Smrg # Create the object directory. 74736e7d3316Smrg func_mkdir_p "$output_objdir" 7474a966c04fSmrg 74756e7d3316Smrg # Determine the type of output 74766e7d3316Smrg case $output in 74776e7d3316Smrg "") 74786e7d3316Smrg func_fatal_help "you must specify an output file" 74796e7d3316Smrg ;; 74806e7d3316Smrg *.$libext) linkmode=oldlib ;; 74816e7d3316Smrg *.lo | *.$objext) linkmode=obj ;; 74826e7d3316Smrg *.la) linkmode=lib ;; 74836e7d3316Smrg *) linkmode=prog ;; # Anything else should be a program. 74846e7d3316Smrg esac 74856e7d3316Smrg 74866e7d3316Smrg specialdeplibs= 74876e7d3316Smrg 74886e7d3316Smrg libs= 74896e7d3316Smrg # Find all interdependent deplibs by searching for libraries 74906e7d3316Smrg # that are linked more than once (e.g. -la -lb -la) 74916e7d3316Smrg for deplib in $deplibs; do 7492edce3322Smrg if $opt_preserve_dup_deps; then 74936e7d3316Smrg case "$libs " in 749497cf2ee2Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 74956e7d3316Smrg esac 74966e7d3316Smrg fi 749797cf2ee2Smrg func_append libs " $deplib" 74986e7d3316Smrg done 74996e7d3316Smrg 7500edce3322Smrg if test lib = "$linkmode"; then 75016e7d3316Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 75026e7d3316Smrg 75036e7d3316Smrg # Compute libraries that are listed more than once in $predeps 75046e7d3316Smrg # $postdeps and mark them as special (i.e., whose duplicates are 75056e7d3316Smrg # not to be eliminated). 75066e7d3316Smrg pre_post_deps= 75076e7d3316Smrg if $opt_duplicate_compiler_generated_deps; then 75086e7d3316Smrg for pre_post_dep in $predeps $postdeps; do 75096e7d3316Smrg case "$pre_post_deps " in 751097cf2ee2Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 75116e7d3316Smrg esac 751297cf2ee2Smrg func_append pre_post_deps " $pre_post_dep" 75136e7d3316Smrg done 75146e7d3316Smrg fi 75156e7d3316Smrg pre_post_deps= 75166e7d3316Smrg fi 75176e7d3316Smrg 75186e7d3316Smrg deplibs= 75196e7d3316Smrg newdependency_libs= 75206e7d3316Smrg newlib_search_path= 75216e7d3316Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 75226e7d3316Smrg notinst_deplibs= # not-installed libtool libraries 75236e7d3316Smrg notinst_path= # paths that contain not-installed libtool libraries 75246e7d3316Smrg 75256e7d3316Smrg case $linkmode in 75266e7d3316Smrg lib) 75276e7d3316Smrg passes="conv dlpreopen link" 75286e7d3316Smrg for file in $dlfiles $dlprefiles; do 75296e7d3316Smrg case $file in 75306e7d3316Smrg *.la) ;; 75316e7d3316Smrg *) 7532edce3322Smrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 75336e7d3316Smrg ;; 75346e7d3316Smrg esac 75356e7d3316Smrg done 75366e7d3316Smrg ;; 75376e7d3316Smrg prog) 75386e7d3316Smrg compile_deplibs= 75396e7d3316Smrg finalize_deplibs= 7540edce3322Smrg alldeplibs=false 75416e7d3316Smrg newdlfiles= 75426e7d3316Smrg newdlprefiles= 75436e7d3316Smrg passes="conv scan dlopen dlpreopen link" 75446e7d3316Smrg ;; 75456e7d3316Smrg *) passes="conv" 75466e7d3316Smrg ;; 75476e7d3316Smrg esac 75486e7d3316Smrg 75496e7d3316Smrg for pass in $passes; do 75506e7d3316Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 75516e7d3316Smrg # so that -L comes before libs that need it for instance... 7552edce3322Smrg if test lib,link = "$linkmode,$pass"; then 75536e7d3316Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 75546e7d3316Smrg ## order, and fix it there properly 75556e7d3316Smrg tmp_deplibs= 75566e7d3316Smrg for deplib in $deplibs; do 75576e7d3316Smrg tmp_deplibs="$deplib $tmp_deplibs" 75586e7d3316Smrg done 7559edce3322Smrg deplibs=$tmp_deplibs 75606e7d3316Smrg fi 75616e7d3316Smrg 7562edce3322Smrg if test lib,link = "$linkmode,$pass" || 7563edce3322Smrg test prog,scan = "$linkmode,$pass"; then 7564edce3322Smrg libs=$deplibs 75656e7d3316Smrg deplibs= 75666e7d3316Smrg fi 7567edce3322Smrg if test prog = "$linkmode"; then 75686e7d3316Smrg case $pass in 7569edce3322Smrg dlopen) libs=$dlfiles ;; 7570edce3322Smrg dlpreopen) libs=$dlprefiles ;; 7571edce3322Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 75726e7d3316Smrg esac 75736e7d3316Smrg fi 7574edce3322Smrg if test lib,dlpreopen = "$linkmode,$pass"; then 75756e7d3316Smrg # Collect and forward deplibs of preopened libtool libs 75766e7d3316Smrg for lib in $dlprefiles; do 75776e7d3316Smrg # Ignore non-libtool-libs 75786e7d3316Smrg dependency_libs= 757997cf2ee2Smrg func_resolve_sysroot "$lib" 75806e7d3316Smrg case $lib in 758197cf2ee2Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 75826e7d3316Smrg esac 75836e7d3316Smrg 75846e7d3316Smrg # Collect preopened libtool deplibs, except any this library 75856e7d3316Smrg # has declared as weak libs 75866e7d3316Smrg for deplib in $dependency_libs; do 75876e7d3316Smrg func_basename "$deplib" 75886e7d3316Smrg deplib_base=$func_basename_result 75896e7d3316Smrg case " $weak_libs " in 75906e7d3316Smrg *" $deplib_base "*) ;; 759197cf2ee2Smrg *) func_append deplibs " $deplib" ;; 75926e7d3316Smrg esac 75936e7d3316Smrg done 75946e7d3316Smrg done 7595edce3322Smrg libs=$dlprefiles 75966e7d3316Smrg fi 7597edce3322Smrg if test dlopen = "$pass"; then 75986e7d3316Smrg # Collect dlpreopened libraries 7599edce3322Smrg save_deplibs=$deplibs 76006e7d3316Smrg deplibs= 76016e7d3316Smrg fi 76026e7d3316Smrg 76036e7d3316Smrg for deplib in $libs; do 76046e7d3316Smrg lib= 7605edce3322Smrg found=false 76066e7d3316Smrg case $deplib in 7607ac92798bSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608ac92798bSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7609edce3322Smrg if test prog,link = "$linkmode,$pass"; then 76106e7d3316Smrg compile_deplibs="$deplib $compile_deplibs" 76116e7d3316Smrg finalize_deplibs="$deplib $finalize_deplibs" 76126e7d3316Smrg else 761397cf2ee2Smrg func_append compiler_flags " $deplib" 7614edce3322Smrg if test lib = "$linkmode"; then 76156e7d3316Smrg case "$new_inherited_linker_flags " in 76166e7d3316Smrg *" $deplib "*) ;; 761797cf2ee2Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 76186e7d3316Smrg esac 76196e7d3316Smrg fi 76206e7d3316Smrg fi 76216e7d3316Smrg continue 76226e7d3316Smrg ;; 76236e7d3316Smrg -l*) 7624edce3322Smrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7625edce3322Smrg func_warning "'-l' is ignored for archives/objects" 76266e7d3316Smrg continue 76276e7d3316Smrg fi 76286e7d3316Smrg func_stripname '-l' '' "$deplib" 76296e7d3316Smrg name=$func_stripname_result 7630edce3322Smrg if test lib = "$linkmode"; then 76316e7d3316Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 76326e7d3316Smrg else 76336e7d3316Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 76346e7d3316Smrg fi 76356e7d3316Smrg for searchdir in $searchdirs; do 76366e7d3316Smrg for search_ext in .la $std_shrext .so .a; do 76376e7d3316Smrg # Search the libtool library 7638edce3322Smrg lib=$searchdir/lib$name$search_ext 76396e7d3316Smrg if test -f "$lib"; then 7640edce3322Smrg if test .la = "$search_ext"; then 7641edce3322Smrg found=: 76426e7d3316Smrg else 7643edce3322Smrg found=false 76446e7d3316Smrg fi 76456e7d3316Smrg break 2 76466e7d3316Smrg fi 76476e7d3316Smrg done 76486e7d3316Smrg done 7649edce3322Smrg if $found; then 7650edce3322Smrg # deplib is a libtool library 76516e7d3316Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 76526e7d3316Smrg # We need to do some special things here, and not later. 7653edce3322Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 76546e7d3316Smrg case " $predeps $postdeps " in 76556e7d3316Smrg *" $deplib "*) 76566e7d3316Smrg if func_lalib_p "$lib"; then 76576e7d3316Smrg library_names= 76586e7d3316Smrg old_library= 76596e7d3316Smrg func_source "$lib" 76606e7d3316Smrg for l in $old_library $library_names; do 7661edce3322Smrg ll=$l 76626e7d3316Smrg done 7663edce3322Smrg if test "X$ll" = "X$old_library"; then # only static version available 7664edce3322Smrg found=false 76656e7d3316Smrg func_dirname "$lib" "" "." 7666edce3322Smrg ladir=$func_dirname_result 76676e7d3316Smrg lib=$ladir/$old_library 7668edce3322Smrg if test prog,link = "$linkmode,$pass"; then 76696e7d3316Smrg compile_deplibs="$deplib $compile_deplibs" 76706e7d3316Smrg finalize_deplibs="$deplib $finalize_deplibs" 76716e7d3316Smrg else 76726e7d3316Smrg deplibs="$deplib $deplibs" 7673edce3322Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 76746e7d3316Smrg fi 76756e7d3316Smrg continue 76766e7d3316Smrg fi 76776e7d3316Smrg fi 76786e7d3316Smrg ;; 76796e7d3316Smrg *) ;; 76806e7d3316Smrg esac 76816e7d3316Smrg fi 7682edce3322Smrg else 7683edce3322Smrg # deplib doesn't seem to be a libtool library 7684edce3322Smrg if test prog,link = "$linkmode,$pass"; then 7685edce3322Smrg compile_deplibs="$deplib $compile_deplibs" 7686edce3322Smrg finalize_deplibs="$deplib $finalize_deplibs" 7687edce3322Smrg else 7688edce3322Smrg deplibs="$deplib $deplibs" 7689edce3322Smrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7690edce3322Smrg fi 7691edce3322Smrg continue 76926e7d3316Smrg fi 76936e7d3316Smrg ;; # -l 76946e7d3316Smrg *.ltframework) 7695edce3322Smrg if test prog,link = "$linkmode,$pass"; then 76966e7d3316Smrg compile_deplibs="$deplib $compile_deplibs" 76976e7d3316Smrg finalize_deplibs="$deplib $finalize_deplibs" 76986e7d3316Smrg else 76996e7d3316Smrg deplibs="$deplib $deplibs" 7700edce3322Smrg if test lib = "$linkmode"; then 77016e7d3316Smrg case "$new_inherited_linker_flags " in 77026e7d3316Smrg *" $deplib "*) ;; 770397cf2ee2Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 77046e7d3316Smrg esac 77056e7d3316Smrg fi 77066e7d3316Smrg fi 77076e7d3316Smrg continue 77086e7d3316Smrg ;; 77096e7d3316Smrg -L*) 77106e7d3316Smrg case $linkmode in 77116e7d3316Smrg lib) 77126e7d3316Smrg deplibs="$deplib $deplibs" 7713edce3322Smrg test conv = "$pass" && continue 77146e7d3316Smrg newdependency_libs="$deplib $newdependency_libs" 77156e7d3316Smrg func_stripname '-L' '' "$deplib" 771697cf2ee2Smrg func_resolve_sysroot "$func_stripname_result" 771797cf2ee2Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77186e7d3316Smrg ;; 77196e7d3316Smrg prog) 7720edce3322Smrg if test conv = "$pass"; then 77216e7d3316Smrg deplibs="$deplib $deplibs" 77226e7d3316Smrg continue 77236e7d3316Smrg fi 7724edce3322Smrg if test scan = "$pass"; then 77256e7d3316Smrg deplibs="$deplib $deplibs" 77266e7d3316Smrg else 77276e7d3316Smrg compile_deplibs="$deplib $compile_deplibs" 77286e7d3316Smrg finalize_deplibs="$deplib $finalize_deplibs" 77296e7d3316Smrg fi 77306e7d3316Smrg func_stripname '-L' '' "$deplib" 773197cf2ee2Smrg func_resolve_sysroot "$func_stripname_result" 773297cf2ee2Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 77336e7d3316Smrg ;; 77346e7d3316Smrg *) 7735edce3322Smrg func_warning "'-L' is ignored for archives/objects" 77366e7d3316Smrg ;; 77376e7d3316Smrg esac # linkmode 77386e7d3316Smrg continue 77396e7d3316Smrg ;; # -L 77406e7d3316Smrg -R*) 7741edce3322Smrg if test link = "$pass"; then 77426e7d3316Smrg func_stripname '-R' '' "$deplib" 774397cf2ee2Smrg func_resolve_sysroot "$func_stripname_result" 774497cf2ee2Smrg dir=$func_resolve_sysroot_result 77456e7d3316Smrg # Make sure the xrpath contains only unique directories. 77466e7d3316Smrg case "$xrpath " in 77476e7d3316Smrg *" $dir "*) ;; 774897cf2ee2Smrg *) func_append xrpath " $dir" ;; 77496e7d3316Smrg esac 77506e7d3316Smrg fi 77516e7d3316Smrg deplibs="$deplib $deplibs" 77526e7d3316Smrg continue 77536e7d3316Smrg ;; 775497cf2ee2Smrg *.la) 775597cf2ee2Smrg func_resolve_sysroot "$deplib" 775697cf2ee2Smrg lib=$func_resolve_sysroot_result 775797cf2ee2Smrg ;; 77586e7d3316Smrg *.$libext) 7759edce3322Smrg if test conv = "$pass"; then 77606e7d3316Smrg deplibs="$deplib $deplibs" 77616e7d3316Smrg continue 77626e7d3316Smrg fi 77636e7d3316Smrg case $linkmode in 77646e7d3316Smrg lib) 77656e7d3316Smrg # Linking convenience modules into shared libraries is allowed, 77666e7d3316Smrg # but linking other static libraries is non-portable. 77676e7d3316Smrg case " $dlpreconveniencelibs " in 77686e7d3316Smrg *" $deplib "*) ;; 77696e7d3316Smrg *) 7770edce3322Smrg valid_a_lib=false 77716e7d3316Smrg case $deplibs_check_method in 77726e7d3316Smrg match_pattern*) 77736e7d3316Smrg set dummy $deplibs_check_method; shift 77746e7d3316Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 77756e7d3316Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 77766e7d3316Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 7777edce3322Smrg valid_a_lib=: 77786e7d3316Smrg fi 77796e7d3316Smrg ;; 77806e7d3316Smrg pass_all) 7781edce3322Smrg valid_a_lib=: 77826e7d3316Smrg ;; 77836e7d3316Smrg esac 7784edce3322Smrg if $valid_a_lib; then 7785edce3322Smrg echo 7786edce3322Smrg $ECHO "*** Warning: Linking the shared library $output against the" 7787edce3322Smrg $ECHO "*** static library $deplib is not portable!" 7788edce3322Smrg deplibs="$deplib $deplibs" 7789edce3322Smrg else 77906e7d3316Smrg echo 77916e7d3316Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 77926e7d3316Smrg echo "*** I have the capability to make that library automatically link in when" 77936e7d3316Smrg echo "*** you link to this library. But I can only do this if you have a" 77946e7d3316Smrg echo "*** shared version of the library, which you do not appear to have" 77956e7d3316Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 77966e7d3316Smrg echo "*** that it is just a static archive that I should not use here." 77976e7d3316Smrg fi 77986e7d3316Smrg ;; 77996e7d3316Smrg esac 78006e7d3316Smrg continue 78016e7d3316Smrg ;; 78026e7d3316Smrg prog) 7803edce3322Smrg if test link != "$pass"; then 78046e7d3316Smrg deplibs="$deplib $deplibs" 78056e7d3316Smrg else 78066e7d3316Smrg compile_deplibs="$deplib $compile_deplibs" 78076e7d3316Smrg finalize_deplibs="$deplib $finalize_deplibs" 78086e7d3316Smrg fi 78096e7d3316Smrg continue 78106e7d3316Smrg ;; 78116e7d3316Smrg esac # linkmode 78126e7d3316Smrg ;; # *.$libext 78136e7d3316Smrg *.lo | *.$objext) 7814edce3322Smrg if test conv = "$pass"; then 78156e7d3316Smrg deplibs="$deplib $deplibs" 7816edce3322Smrg elif test prog = "$linkmode"; then 7817edce3322Smrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 78186e7d3316Smrg # If there is no dlopen support or we're linking statically, 78196e7d3316Smrg # we need to preload. 782097cf2ee2Smrg func_append newdlprefiles " $deplib" 78216e7d3316Smrg compile_deplibs="$deplib $compile_deplibs" 78226e7d3316Smrg finalize_deplibs="$deplib $finalize_deplibs" 78236e7d3316Smrg else 782497cf2ee2Smrg func_append newdlfiles " $deplib" 78256e7d3316Smrg fi 78266e7d3316Smrg fi 78276e7d3316Smrg continue 78286e7d3316Smrg ;; 78296e7d3316Smrg %DEPLIBS%) 7830edce3322Smrg alldeplibs=: 78316e7d3316Smrg continue 78326e7d3316Smrg ;; 78336e7d3316Smrg esac # case $deplib 78346e7d3316Smrg 7835edce3322Smrg $found || test -f "$lib" \ 7836edce3322Smrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 78376e7d3316Smrg 78386e7d3316Smrg # Check to see that this really is a libtool archive. 78396e7d3316Smrg func_lalib_unsafe_p "$lib" \ 7840edce3322Smrg || func_fatal_error "'$lib' is not a valid libtool archive" 78416e7d3316Smrg 78426e7d3316Smrg func_dirname "$lib" "" "." 7843edce3322Smrg ladir=$func_dirname_result 78446e7d3316Smrg 78456e7d3316Smrg dlname= 78466e7d3316Smrg dlopen= 78476e7d3316Smrg dlpreopen= 78486e7d3316Smrg libdir= 78496e7d3316Smrg library_names= 78506e7d3316Smrg old_library= 78516e7d3316Smrg inherited_linker_flags= 78526e7d3316Smrg # If the library was installed with an old release of libtool, 78536e7d3316Smrg # it will not redefine variables installed, or shouldnotlink 78546e7d3316Smrg installed=yes 78556e7d3316Smrg shouldnotlink=no 78566e7d3316Smrg avoidtemprpath= 78576e7d3316Smrg 78586e7d3316Smrg 78596e7d3316Smrg # Read the .la file 78606e7d3316Smrg func_source "$lib" 78616e7d3316Smrg 78626e7d3316Smrg # Convert "-framework foo" to "foo.ltframework" 78636e7d3316Smrg if test -n "$inherited_linker_flags"; then 78646e7d3316Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 78656e7d3316Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 78666e7d3316Smrg case " $new_inherited_linker_flags " in 78676e7d3316Smrg *" $tmp_inherited_linker_flag "*) ;; 786897cf2ee2Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 78696e7d3316Smrg esac 78706e7d3316Smrg done 78716e7d3316Smrg fi 78726e7d3316Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7873edce3322Smrg if test lib,link = "$linkmode,$pass" || 7874edce3322Smrg test prog,scan = "$linkmode,$pass" || 7875edce3322Smrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 787697cf2ee2Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 787797cf2ee2Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 78786e7d3316Smrg fi 78796e7d3316Smrg 7880edce3322Smrg if test conv = "$pass"; then 78816e7d3316Smrg # Only check for convenience libraries 78826e7d3316Smrg deplibs="$lib $deplibs" 78836e7d3316Smrg if test -z "$libdir"; then 78846e7d3316Smrg if test -z "$old_library"; then 7885edce3322Smrg func_fatal_error "cannot find name of link library for '$lib'" 78866e7d3316Smrg fi 78876e7d3316Smrg # It is a libtool convenience library, so add in its objects. 788897cf2ee2Smrg func_append convenience " $ladir/$objdir/$old_library" 788997cf2ee2Smrg func_append old_convenience " $ladir/$objdir/$old_library" 7890edce3322Smrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 7891edce3322Smrg func_fatal_error "'$lib' is not a convenience library" 78926e7d3316Smrg fi 7893edce3322Smrg tmp_libs= 7894edce3322Smrg for deplib in $dependency_libs; do 7895edce3322Smrg deplibs="$deplib $deplibs" 7896edce3322Smrg if $opt_preserve_dup_deps; then 7897edce3322Smrg case "$tmp_libs " in 7898edce3322Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899edce3322Smrg esac 7900edce3322Smrg fi 7901edce3322Smrg func_append tmp_libs " $deplib" 7902edce3322Smrg done 79036e7d3316Smrg continue 79046e7d3316Smrg fi # $pass = conv 79056e7d3316Smrg 79066e7d3316Smrg 79076e7d3316Smrg # Get the name of the library we link against. 79086e7d3316Smrg linklib= 790997cf2ee2Smrg if test -n "$old_library" && 7910edce3322Smrg { test yes = "$prefer_static_libs" || 7911edce3322Smrg test built,no = "$prefer_static_libs,$installed"; }; then 791297cf2ee2Smrg linklib=$old_library 791397cf2ee2Smrg else 791497cf2ee2Smrg for l in $old_library $library_names; do 7915edce3322Smrg linklib=$l 791697cf2ee2Smrg done 791797cf2ee2Smrg fi 79186e7d3316Smrg if test -z "$linklib"; then 7919edce3322Smrg func_fatal_error "cannot find name of link library for '$lib'" 79206e7d3316Smrg fi 79216e7d3316Smrg 79226e7d3316Smrg # This library was specified with -dlopen. 7923edce3322Smrg if test dlopen = "$pass"; then 7924edce3322Smrg test -z "$libdir" \ 7925edce3322Smrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 79266e7d3316Smrg if test -z "$dlname" || 7927edce3322Smrg test yes != "$dlopen_support" || 7928edce3322Smrg test no = "$build_libtool_libs" 7929edce3322Smrg then 79306e7d3316Smrg # If there is no dlname, no dlopen support or we're linking 79316e7d3316Smrg # statically, we need to preload. We also need to preload any 79326e7d3316Smrg # dependent libraries so libltdl's deplib preloader doesn't 79336e7d3316Smrg # bomb out in the load deplibs phase. 793497cf2ee2Smrg func_append dlprefiles " $lib $dependency_libs" 79356e7d3316Smrg else 793697cf2ee2Smrg func_append newdlfiles " $lib" 79376e7d3316Smrg fi 79386e7d3316Smrg continue 79396e7d3316Smrg fi # $pass = dlopen 79406e7d3316Smrg 79416e7d3316Smrg # We need an absolute path. 79426e7d3316Smrg case $ladir in 7943edce3322Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 79446e7d3316Smrg *) 79456e7d3316Smrg abs_ladir=`cd "$ladir" && pwd` 79466e7d3316Smrg if test -z "$abs_ladir"; then 7947edce3322Smrg func_warning "cannot determine absolute directory name of '$ladir'" 79486e7d3316Smrg func_warning "passing it literally to the linker, although it might fail" 7949edce3322Smrg abs_ladir=$ladir 79506e7d3316Smrg fi 79516e7d3316Smrg ;; 79526e7d3316Smrg esac 79536e7d3316Smrg func_basename "$lib" 7954edce3322Smrg laname=$func_basename_result 79556e7d3316Smrg 79566e7d3316Smrg # Find the relevant object directory and library name. 7957edce3322Smrg if test yes = "$installed"; then 795897cf2ee2Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7959edce3322Smrg func_warning "library '$lib' was moved." 7960edce3322Smrg dir=$ladir 7961edce3322Smrg absdir=$abs_ladir 7962edce3322Smrg libdir=$abs_ladir 79636e7d3316Smrg else 7964edce3322Smrg dir=$lt_sysroot$libdir 7965edce3322Smrg absdir=$lt_sysroot$libdir 79666e7d3316Smrg fi 7967edce3322Smrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 79686e7d3316Smrg else 79696e7d3316Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7970edce3322Smrg dir=$ladir 7971edce3322Smrg absdir=$abs_ladir 79726e7d3316Smrg # Remove this search path later 797397cf2ee2Smrg func_append notinst_path " $abs_ladir" 79746e7d3316Smrg else 7975edce3322Smrg dir=$ladir/$objdir 7976edce3322Smrg absdir=$abs_ladir/$objdir 79776e7d3316Smrg # Remove this search path later 797897cf2ee2Smrg func_append notinst_path " $abs_ladir" 79796e7d3316Smrg fi 79806e7d3316Smrg fi # $installed = yes 79816e7d3316Smrg func_stripname 'lib' '.la' "$laname" 79826e7d3316Smrg name=$func_stripname_result 79836e7d3316Smrg 79846e7d3316Smrg # This library was specified with -dlpreopen. 7985edce3322Smrg if test dlpreopen = "$pass"; then 7986edce3322Smrg if test -z "$libdir" && test prog = "$linkmode"; then 7987edce3322Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 79886e7d3316Smrg fi 7989edce3322Smrg case $host in 799097cf2ee2Smrg # special handling for platforms with PE-DLLs. 799197cf2ee2Smrg *cygwin* | *mingw* | *cegcc* ) 799297cf2ee2Smrg # Linker will automatically link against shared library if both 799397cf2ee2Smrg # static and shared are present. Therefore, ensure we extract 799497cf2ee2Smrg # symbols from the import library if a shared library is present 799597cf2ee2Smrg # (otherwise, the dlopen module name will be incorrect). We do 799697cf2ee2Smrg # this by putting the import library name into $newdlprefiles. 799797cf2ee2Smrg # We recover the dlopen module name by 'saving' the la file 799897cf2ee2Smrg # name in a special purpose variable, and (later) extracting the 799997cf2ee2Smrg # dlname from the la file. 800097cf2ee2Smrg if test -n "$dlname"; then 800197cf2ee2Smrg func_tr_sh "$dir/$linklib" 800297cf2ee2Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 800397cf2ee2Smrg func_append newdlprefiles " $dir/$linklib" 800497cf2ee2Smrg else 800597cf2ee2Smrg func_append newdlprefiles " $dir/$old_library" 800697cf2ee2Smrg # Keep a list of preopened convenience libraries to check 800797cf2ee2Smrg # that they are being used correctly in the link pass. 800897cf2ee2Smrg test -z "$libdir" && \ 800997cf2ee2Smrg func_append dlpreconveniencelibs " $dir/$old_library" 801097cf2ee2Smrg fi 801197cf2ee2Smrg ;; 801297cf2ee2Smrg * ) 801397cf2ee2Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 801497cf2ee2Smrg # are required to link). 801597cf2ee2Smrg if test -n "$old_library"; then 801697cf2ee2Smrg func_append newdlprefiles " $dir/$old_library" 801797cf2ee2Smrg # Keep a list of preopened convenience libraries to check 801897cf2ee2Smrg # that they are being used correctly in the link pass. 801997cf2ee2Smrg test -z "$libdir" && \ 802097cf2ee2Smrg func_append dlpreconveniencelibs " $dir/$old_library" 802197cf2ee2Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 802297cf2ee2Smrg elif test -n "$dlname"; then 802397cf2ee2Smrg func_append newdlprefiles " $dir/$dlname" 802497cf2ee2Smrg else 802597cf2ee2Smrg func_append newdlprefiles " $dir/$linklib" 802697cf2ee2Smrg fi 802797cf2ee2Smrg ;; 802897cf2ee2Smrg esac 80296e7d3316Smrg fi # $pass = dlpreopen 80306e7d3316Smrg 80316e7d3316Smrg if test -z "$libdir"; then 80326e7d3316Smrg # Link the convenience library 8033edce3322Smrg if test lib = "$linkmode"; then 80346e7d3316Smrg deplibs="$dir/$old_library $deplibs" 8035edce3322Smrg elif test prog,link = "$linkmode,$pass"; then 80366e7d3316Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 80376e7d3316Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 80386e7d3316Smrg else 80396e7d3316Smrg deplibs="$lib $deplibs" # used for prog,scan pass 80406e7d3316Smrg fi 80416e7d3316Smrg continue 80426e7d3316Smrg fi 80436e7d3316Smrg 80446e7d3316Smrg 8045edce3322Smrg if test prog = "$linkmode" && test link != "$pass"; then 804697cf2ee2Smrg func_append newlib_search_path " $ladir" 80476e7d3316Smrg deplibs="$lib $deplibs" 80486e7d3316Smrg 8049edce3322Smrg linkalldeplibs=false 8050edce3322Smrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8051edce3322Smrg test no = "$build_libtool_libs"; then 8052edce3322Smrg linkalldeplibs=: 80536e7d3316Smrg fi 80546e7d3316Smrg 80556e7d3316Smrg tmp_libs= 80566e7d3316Smrg for deplib in $dependency_libs; do 80576e7d3316Smrg case $deplib in 80586e7d3316Smrg -L*) func_stripname '-L' '' "$deplib" 805997cf2ee2Smrg func_resolve_sysroot "$func_stripname_result" 806097cf2ee2Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 80616e7d3316Smrg ;; 80626e7d3316Smrg esac 80636e7d3316Smrg # Need to link against all dependency_libs? 8064edce3322Smrg if $linkalldeplibs; then 80656e7d3316Smrg deplibs="$deplib $deplibs" 80666e7d3316Smrg else 80676e7d3316Smrg # Need to hardcode shared library paths 80686e7d3316Smrg # or/and link against static libraries 80696e7d3316Smrg newdependency_libs="$deplib $newdependency_libs" 80706e7d3316Smrg fi 8071edce3322Smrg if $opt_preserve_dup_deps; then 80726e7d3316Smrg case "$tmp_libs " in 807397cf2ee2Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 80746e7d3316Smrg esac 80756e7d3316Smrg fi 807697cf2ee2Smrg func_append tmp_libs " $deplib" 80776e7d3316Smrg done # for deplib 80786e7d3316Smrg continue 80796e7d3316Smrg fi # $linkmode = prog... 80806e7d3316Smrg 8081edce3322Smrg if test prog,link = "$linkmode,$pass"; then 80826e7d3316Smrg if test -n "$library_names" && 8083edce3322Smrg { { test no = "$prefer_static_libs" || 8084edce3322Smrg test built,yes = "$prefer_static_libs,$installed"; } || 80856e7d3316Smrg test -z "$old_library"; }; then 80866e7d3316Smrg # We need to hardcode the library path 8087edce3322Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 80886e7d3316Smrg # Make sure the rpath contains only unique directories. 8089edce3322Smrg case $temp_rpath: in 80906e7d3316Smrg *"$absdir:"*) ;; 809197cf2ee2Smrg *) func_append temp_rpath "$absdir:" ;; 80926e7d3316Smrg esac 80936e7d3316Smrg fi 80946e7d3316Smrg 80956e7d3316Smrg # Hardcode the library path. 80966e7d3316Smrg # Skip directories that are in the system default run-time 80976e7d3316Smrg # search path. 80986e7d3316Smrg case " $sys_lib_dlsearch_path " in 80996e7d3316Smrg *" $absdir "*) ;; 81006e7d3316Smrg *) 81016e7d3316Smrg case "$compile_rpath " in 81026e7d3316Smrg *" $absdir "*) ;; 810397cf2ee2Smrg *) func_append compile_rpath " $absdir" ;; 81046e7d3316Smrg esac 81056e7d3316Smrg ;; 81066e7d3316Smrg esac 81076e7d3316Smrg case " $sys_lib_dlsearch_path " in 81086e7d3316Smrg *" $libdir "*) ;; 81096e7d3316Smrg *) 81106e7d3316Smrg case "$finalize_rpath " in 81116e7d3316Smrg *" $libdir "*) ;; 811297cf2ee2Smrg *) func_append finalize_rpath " $libdir" ;; 81136e7d3316Smrg esac 81146e7d3316Smrg ;; 81156e7d3316Smrg esac 81166e7d3316Smrg fi # $linkmode,$pass = prog,link... 81176e7d3316Smrg 8118edce3322Smrg if $alldeplibs && 8119edce3322Smrg { test pass_all = "$deplibs_check_method" || 8120edce3322Smrg { test yes = "$build_libtool_libs" && 81216e7d3316Smrg test -n "$library_names"; }; }; then 81226e7d3316Smrg # We only need to search for static libraries 81236e7d3316Smrg continue 81246e7d3316Smrg fi 81256e7d3316Smrg fi 81266e7d3316Smrg 81276e7d3316Smrg link_static=no # Whether the deplib will be linked statically 81286e7d3316Smrg use_static_libs=$prefer_static_libs 8129edce3322Smrg if test built = "$use_static_libs" && test yes = "$installed"; then 81306e7d3316Smrg use_static_libs=no 81316e7d3316Smrg fi 81326e7d3316Smrg if test -n "$library_names" && 8133edce3322Smrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 81346e7d3316Smrg case $host in 8135edce3322Smrg *cygwin* | *mingw* | *cegcc* | *os2*) 81366e7d3316Smrg # No point in relinking DLLs because paths are not encoded 813797cf2ee2Smrg func_append notinst_deplibs " $lib" 81386e7d3316Smrg need_relink=no 81396e7d3316Smrg ;; 81406e7d3316Smrg *) 8141edce3322Smrg if test no = "$installed"; then 814297cf2ee2Smrg func_append notinst_deplibs " $lib" 81436e7d3316Smrg need_relink=yes 81446e7d3316Smrg fi 81456e7d3316Smrg ;; 81466e7d3316Smrg esac 81476e7d3316Smrg # This is a shared library 81486e7d3316Smrg 81496e7d3316Smrg # Warn about portability, can't link against -module's on some 81506e7d3316Smrg # systems (darwin). Don't bleat about dlopened modules though! 8151edce3322Smrg dlopenmodule= 81526e7d3316Smrg for dlpremoduletest in $dlprefiles; do 81536e7d3316Smrg if test "X$dlpremoduletest" = "X$lib"; then 8154edce3322Smrg dlopenmodule=$dlpremoduletest 81556e7d3316Smrg break 81566e7d3316Smrg fi 81576e7d3316Smrg done 8158edce3322Smrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 81596e7d3316Smrg echo 8160edce3322Smrg if test prog = "$linkmode"; then 81616e7d3316Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 81626e7d3316Smrg else 81636e7d3316Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 81646e7d3316Smrg fi 81656e7d3316Smrg $ECHO "*** $linklib is not portable!" 81666e7d3316Smrg fi 8167edce3322Smrg if test lib = "$linkmode" && 8168edce3322Smrg test yes = "$hardcode_into_libs"; then 81696e7d3316Smrg # Hardcode the library path. 81706e7d3316Smrg # Skip directories that are in the system default run-time 81716e7d3316Smrg # search path. 81726e7d3316Smrg case " $sys_lib_dlsearch_path " in 81736e7d3316Smrg *" $absdir "*) ;; 81746e7d3316Smrg *) 81756e7d3316Smrg case "$compile_rpath " in 81766e7d3316Smrg *" $absdir "*) ;; 817797cf2ee2Smrg *) func_append compile_rpath " $absdir" ;; 81786e7d3316Smrg esac 81796e7d3316Smrg ;; 81806e7d3316Smrg esac 81816e7d3316Smrg case " $sys_lib_dlsearch_path " in 81826e7d3316Smrg *" $libdir "*) ;; 81836e7d3316Smrg *) 81846e7d3316Smrg case "$finalize_rpath " in 81856e7d3316Smrg *" $libdir "*) ;; 818697cf2ee2Smrg *) func_append finalize_rpath " $libdir" ;; 81876e7d3316Smrg esac 81886e7d3316Smrg ;; 81896e7d3316Smrg esac 81906e7d3316Smrg fi 81916e7d3316Smrg 81926e7d3316Smrg if test -n "$old_archive_from_expsyms_cmds"; then 81936e7d3316Smrg # figure out the soname 81946e7d3316Smrg set dummy $library_names 81956e7d3316Smrg shift 8196edce3322Smrg realname=$1 81976e7d3316Smrg shift 81986e7d3316Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 81996e7d3316Smrg # use dlname if we got it. it's perfectly good, no? 82006e7d3316Smrg if test -n "$dlname"; then 8201edce3322Smrg soname=$dlname 82026e7d3316Smrg elif test -n "$soname_spec"; then 82036e7d3316Smrg # bleh windows 82046e7d3316Smrg case $host in 8205edce3322Smrg *cygwin* | mingw* | *cegcc* | *os2*) 82066e7d3316Smrg func_arith $current - $age 82076e7d3316Smrg major=$func_arith_result 8208edce3322Smrg versuffix=-$major 82096e7d3316Smrg ;; 82106e7d3316Smrg esac 82116e7d3316Smrg eval soname=\"$soname_spec\" 82126e7d3316Smrg else 8213edce3322Smrg soname=$realname 82146e7d3316Smrg fi 82156e7d3316Smrg 82166e7d3316Smrg # Make a new name for the extract_expsyms_cmds to use 8217edce3322Smrg soroot=$soname 82186e7d3316Smrg func_basename "$soroot" 8219edce3322Smrg soname=$func_basename_result 82206e7d3316Smrg func_stripname 'lib' '.dll' "$soname" 82216e7d3316Smrg newlib=libimp-$func_stripname_result.a 82226e7d3316Smrg 82236e7d3316Smrg # If the library has no export list, then create one now 82246e7d3316Smrg if test -f "$output_objdir/$soname-def"; then : 82256e7d3316Smrg else 8226edce3322Smrg func_verbose "extracting exported symbol list from '$soname'" 82276e7d3316Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 82286e7d3316Smrg fi 82296e7d3316Smrg 82306e7d3316Smrg # Create $newlib 82316e7d3316Smrg if test -f "$output_objdir/$newlib"; then :; else 8232edce3322Smrg func_verbose "generating import library for '$soname'" 82336e7d3316Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 82346e7d3316Smrg fi 82356e7d3316Smrg # make sure the library variables are pointing to the new library 82366e7d3316Smrg dir=$output_objdir 82376e7d3316Smrg linklib=$newlib 82386e7d3316Smrg fi # test -n "$old_archive_from_expsyms_cmds" 82396e7d3316Smrg 8240edce3322Smrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 82416e7d3316Smrg add_shlibpath= 82426e7d3316Smrg add_dir= 82436e7d3316Smrg add= 82446e7d3316Smrg lib_linked=yes 82456e7d3316Smrg case $hardcode_action in 82466e7d3316Smrg immediate | unsupported) 8247edce3322Smrg if test no = "$hardcode_direct"; then 8248edce3322Smrg add=$dir/$linklib 82496e7d3316Smrg case $host in 8250edce3322Smrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8251edce3322Smrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 82526e7d3316Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8253edce3322Smrg *-*-unixware7*) add_dir=-L$dir ;; 82546e7d3316Smrg *-*-darwin* ) 8255edce3322Smrg # if the lib is a (non-dlopened) module then we cannot 82566e7d3316Smrg # link against it, someone is ignoring the earlier warnings 82576e7d3316Smrg if /usr/bin/file -L $add 2> /dev/null | 8258edce3322Smrg $GREP ": [^:]* bundle" >/dev/null; then 82596e7d3316Smrg if test "X$dlopenmodule" != "X$lib"; then 82606e7d3316Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8261edce3322Smrg if test -z "$old_library"; then 82626e7d3316Smrg echo 82636e7d3316Smrg echo "*** And there doesn't seem to be a static archive available" 82646e7d3316Smrg echo "*** The link will probably fail, sorry" 82656e7d3316Smrg else 8266edce3322Smrg add=$dir/$old_library 82676e7d3316Smrg fi 82686e7d3316Smrg elif test -n "$old_library"; then 8269edce3322Smrg add=$dir/$old_library 82706e7d3316Smrg fi 82716e7d3316Smrg fi 82726e7d3316Smrg esac 8273edce3322Smrg elif test no = "$hardcode_minus_L"; then 82746e7d3316Smrg case $host in 8275edce3322Smrg *-*-sunos*) add_shlibpath=$dir ;; 82766e7d3316Smrg esac 8277edce3322Smrg add_dir=-L$dir 8278edce3322Smrg add=-l$name 8279edce3322Smrg elif test no = "$hardcode_shlibpath_var"; then 8280edce3322Smrg add_shlibpath=$dir 8281edce3322Smrg add=-l$name 82826e7d3316Smrg else 82836e7d3316Smrg lib_linked=no 82846e7d3316Smrg fi 82856e7d3316Smrg ;; 82866e7d3316Smrg relink) 8287edce3322Smrg if test yes = "$hardcode_direct" && 8288edce3322Smrg test no = "$hardcode_direct_absolute"; then 8289edce3322Smrg add=$dir/$linklib 8290edce3322Smrg elif test yes = "$hardcode_minus_L"; then 8291edce3322Smrg add_dir=-L$absdir 82926e7d3316Smrg # Try looking first in the location we're being installed to. 82936e7d3316Smrg if test -n "$inst_prefix_dir"; then 82946e7d3316Smrg case $libdir in 82956e7d3316Smrg [\\/]*) 829697cf2ee2Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 82976e7d3316Smrg ;; 82986e7d3316Smrg esac 82996e7d3316Smrg fi 8300edce3322Smrg add=-l$name 8301edce3322Smrg elif test yes = "$hardcode_shlibpath_var"; then 8302edce3322Smrg add_shlibpath=$dir 8303edce3322Smrg add=-l$name 83046e7d3316Smrg else 83056e7d3316Smrg lib_linked=no 83066e7d3316Smrg fi 83076e7d3316Smrg ;; 83086e7d3316Smrg *) lib_linked=no ;; 83096e7d3316Smrg esac 83106e7d3316Smrg 8311edce3322Smrg if test yes != "$lib_linked"; then 83126e7d3316Smrg func_fatal_configuration "unsupported hardcode properties" 83136e7d3316Smrg fi 83146e7d3316Smrg 83156e7d3316Smrg if test -n "$add_shlibpath"; then 83166e7d3316Smrg case :$compile_shlibpath: in 83176e7d3316Smrg *":$add_shlibpath:"*) ;; 831897cf2ee2Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 83196e7d3316Smrg esac 83206e7d3316Smrg fi 8321edce3322Smrg if test prog = "$linkmode"; then 83226e7d3316Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 83236e7d3316Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 83246e7d3316Smrg else 83256e7d3316Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83266e7d3316Smrg test -n "$add" && deplibs="$add $deplibs" 8327edce3322Smrg if test yes != "$hardcode_direct" && 8328edce3322Smrg test yes != "$hardcode_minus_L" && 8329edce3322Smrg test yes = "$hardcode_shlibpath_var"; then 83306e7d3316Smrg case :$finalize_shlibpath: in 83316e7d3316Smrg *":$libdir:"*) ;; 833297cf2ee2Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83336e7d3316Smrg esac 83346e7d3316Smrg fi 83356e7d3316Smrg fi 83366e7d3316Smrg fi 83376e7d3316Smrg 8338edce3322Smrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 83396e7d3316Smrg add_shlibpath= 83406e7d3316Smrg add_dir= 83416e7d3316Smrg add= 83426e7d3316Smrg # Finalize command for both is simple: just hardcode it. 8343edce3322Smrg if test yes = "$hardcode_direct" && 8344edce3322Smrg test no = "$hardcode_direct_absolute"; then 8345edce3322Smrg add=$libdir/$linklib 8346edce3322Smrg elif test yes = "$hardcode_minus_L"; then 8347edce3322Smrg add_dir=-L$libdir 8348edce3322Smrg add=-l$name 8349edce3322Smrg elif test yes = "$hardcode_shlibpath_var"; then 83506e7d3316Smrg case :$finalize_shlibpath: in 83516e7d3316Smrg *":$libdir:"*) ;; 835297cf2ee2Smrg *) func_append finalize_shlibpath "$libdir:" ;; 83536e7d3316Smrg esac 8354edce3322Smrg add=-l$name 8355edce3322Smrg elif test yes = "$hardcode_automatic"; then 83566e7d3316Smrg if test -n "$inst_prefix_dir" && 8357edce3322Smrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8358edce3322Smrg add=$inst_prefix_dir$libdir/$linklib 83596e7d3316Smrg else 8360edce3322Smrg add=$libdir/$linklib 83616e7d3316Smrg fi 83626e7d3316Smrg else 83636e7d3316Smrg # We cannot seem to hardcode it, guess we'll fake it. 8364edce3322Smrg add_dir=-L$libdir 83656e7d3316Smrg # Try looking first in the location we're being installed to. 83666e7d3316Smrg if test -n "$inst_prefix_dir"; then 83676e7d3316Smrg case $libdir in 83686e7d3316Smrg [\\/]*) 836997cf2ee2Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 83706e7d3316Smrg ;; 83716e7d3316Smrg esac 83726e7d3316Smrg fi 8373edce3322Smrg add=-l$name 83746e7d3316Smrg fi 83756e7d3316Smrg 8376edce3322Smrg if test prog = "$linkmode"; then 83776e7d3316Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 83786e7d3316Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 83796e7d3316Smrg else 83806e7d3316Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 83816e7d3316Smrg test -n "$add" && deplibs="$add $deplibs" 83826e7d3316Smrg fi 83836e7d3316Smrg fi 8384edce3322Smrg elif test prog = "$linkmode"; then 83856e7d3316Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 83866e7d3316Smrg # is not unsupported. This is valid on all known static and 83876e7d3316Smrg # shared platforms. 8388edce3322Smrg if test unsupported != "$hardcode_direct"; then 8389edce3322Smrg test -n "$old_library" && linklib=$old_library 83906e7d3316Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 83916e7d3316Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 83926e7d3316Smrg else 83936e7d3316Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 83946e7d3316Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 83956e7d3316Smrg fi 8396edce3322Smrg elif test yes = "$build_libtool_libs"; then 83976e7d3316Smrg # Not a shared library 8398edce3322Smrg if test pass_all != "$deplibs_check_method"; then 83996e7d3316Smrg # We're trying link a shared library against a static one 84006e7d3316Smrg # but the system doesn't support it. 84016e7d3316Smrg 84026e7d3316Smrg # Just print a warning and add the library to dependency_libs so 84036e7d3316Smrg # that the program can be linked against the static library. 84046e7d3316Smrg echo 8405edce3322Smrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 84066e7d3316Smrg echo "*** I have the capability to make that library automatically link in when" 84076e7d3316Smrg echo "*** you link to this library. But I can only do this if you have a" 84086e7d3316Smrg echo "*** shared version of the library, which you do not appear to have." 8409edce3322Smrg if test yes = "$module"; then 84106e7d3316Smrg echo "*** But as you try to build a module library, libtool will still create " 84116e7d3316Smrg echo "*** a static module, that should work as long as the dlopening application" 84126e7d3316Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 84136e7d3316Smrg if test -z "$global_symbol_pipe"; then 84146e7d3316Smrg echo 84156e7d3316Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8416edce3322Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 84176e7d3316Smrg echo "*** not find such a program. So, this module is probably useless." 8418edce3322Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 84196e7d3316Smrg fi 8420edce3322Smrg if test no = "$build_old_libs"; then 84216e7d3316Smrg build_libtool_libs=module 84226e7d3316Smrg build_old_libs=yes 84236e7d3316Smrg else 84246e7d3316Smrg build_libtool_libs=no 84256e7d3316Smrg fi 84266e7d3316Smrg fi 84276e7d3316Smrg else 84286e7d3316Smrg deplibs="$dir/$old_library $deplibs" 84296e7d3316Smrg link_static=yes 84306e7d3316Smrg fi 84316e7d3316Smrg fi # link shared/static library? 84326e7d3316Smrg 8433edce3322Smrg if test lib = "$linkmode"; then 84346e7d3316Smrg if test -n "$dependency_libs" && 8435edce3322Smrg { test yes != "$hardcode_into_libs" || 8436edce3322Smrg test yes = "$build_old_libs" || 8437edce3322Smrg test yes = "$link_static"; }; then 84386e7d3316Smrg # Extract -R from dependency_libs 84396e7d3316Smrg temp_deplibs= 84406e7d3316Smrg for libdir in $dependency_libs; do 84416e7d3316Smrg case $libdir in 84426e7d3316Smrg -R*) func_stripname '-R' '' "$libdir" 84436e7d3316Smrg temp_xrpath=$func_stripname_result 84446e7d3316Smrg case " $xrpath " in 84456e7d3316Smrg *" $temp_xrpath "*) ;; 844697cf2ee2Smrg *) func_append xrpath " $temp_xrpath";; 84476e7d3316Smrg esac;; 844897cf2ee2Smrg *) func_append temp_deplibs " $libdir";; 84496e7d3316Smrg esac 84506e7d3316Smrg done 8451edce3322Smrg dependency_libs=$temp_deplibs 84526e7d3316Smrg fi 84536e7d3316Smrg 845497cf2ee2Smrg func_append newlib_search_path " $absdir" 84556e7d3316Smrg # Link against this library 8456edce3322Smrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 84576e7d3316Smrg # ... and its dependency_libs 84586e7d3316Smrg tmp_libs= 84596e7d3316Smrg for deplib in $dependency_libs; do 84606e7d3316Smrg newdependency_libs="$deplib $newdependency_libs" 846197cf2ee2Smrg case $deplib in 846297cf2ee2Smrg -L*) func_stripname '-L' '' "$deplib" 846397cf2ee2Smrg func_resolve_sysroot "$func_stripname_result";; 846497cf2ee2Smrg *) func_resolve_sysroot "$deplib" ;; 846597cf2ee2Smrg esac 8466edce3322Smrg if $opt_preserve_dup_deps; then 84676e7d3316Smrg case "$tmp_libs " in 846897cf2ee2Smrg *" $func_resolve_sysroot_result "*) 846997cf2ee2Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 84706e7d3316Smrg esac 84716e7d3316Smrg fi 847297cf2ee2Smrg func_append tmp_libs " $func_resolve_sysroot_result" 84736e7d3316Smrg done 84746e7d3316Smrg 8475edce3322Smrg if test no != "$link_all_deplibs"; then 84766e7d3316Smrg # Add the search paths of all dependency libraries 84776e7d3316Smrg for deplib in $dependency_libs; do 84786e7d3316Smrg path= 84796e7d3316Smrg case $deplib in 8480edce3322Smrg -L*) path=$deplib ;; 84816e7d3316Smrg *.la) 848297cf2ee2Smrg func_resolve_sysroot "$deplib" 848397cf2ee2Smrg deplib=$func_resolve_sysroot_result 84846e7d3316Smrg func_dirname "$deplib" "" "." 848597cf2ee2Smrg dir=$func_dirname_result 84866e7d3316Smrg # We need an absolute path. 84876e7d3316Smrg case $dir in 8488edce3322Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 84896e7d3316Smrg *) 84906e7d3316Smrg absdir=`cd "$dir" && pwd` 84916e7d3316Smrg if test -z "$absdir"; then 8492edce3322Smrg func_warning "cannot determine absolute directory name of '$dir'" 8493edce3322Smrg absdir=$dir 84946e7d3316Smrg fi 84956e7d3316Smrg ;; 84966e7d3316Smrg esac 84976e7d3316Smrg if $GREP "^installed=no" $deplib > /dev/null; then 84986e7d3316Smrg case $host in 84996e7d3316Smrg *-*-darwin*) 85006e7d3316Smrg depdepl= 8501edce3322Smrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8502edce3322Smrg if test -n "$deplibrary_names"; then 8503edce3322Smrg for tmp in $deplibrary_names; do 85046e7d3316Smrg depdepl=$tmp 85056e7d3316Smrg done 8506edce3322Smrg if test -f "$absdir/$objdir/$depdepl"; then 8507edce3322Smrg depdepl=$absdir/$objdir/$depdepl 8508edce3322Smrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85096e7d3316Smrg if test -z "$darwin_install_name"; then 8510edce3322Smrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 85116e7d3316Smrg fi 8512edce3322Smrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8513edce3322Smrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 85146e7d3316Smrg path= 85156e7d3316Smrg fi 85166e7d3316Smrg fi 85176e7d3316Smrg ;; 85186e7d3316Smrg *) 8519edce3322Smrg path=-L$absdir/$objdir 85206e7d3316Smrg ;; 85216e7d3316Smrg esac 85226e7d3316Smrg else 8523edce3322Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 85246e7d3316Smrg test -z "$libdir" && \ 8525edce3322Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 85266e7d3316Smrg test "$absdir" != "$libdir" && \ 8527edce3322Smrg func_warning "'$deplib' seems to be moved" 85286e7d3316Smrg 8529edce3322Smrg path=-L$absdir 85306e7d3316Smrg fi 85316e7d3316Smrg ;; 85326e7d3316Smrg esac 85336e7d3316Smrg case " $deplibs " in 85346e7d3316Smrg *" $path "*) ;; 85356e7d3316Smrg *) deplibs="$path $deplibs" ;; 85366e7d3316Smrg esac 85376e7d3316Smrg done 85386e7d3316Smrg fi # link_all_deplibs != no 85396e7d3316Smrg fi # linkmode = lib 85406e7d3316Smrg done # for deplib in $libs 8541edce3322Smrg if test link = "$pass"; then 8542edce3322Smrg if test prog = "$linkmode"; then 85436e7d3316Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 85446e7d3316Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 85456e7d3316Smrg else 85466e7d3316Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 85476e7d3316Smrg fi 85486e7d3316Smrg fi 8549edce3322Smrg dependency_libs=$newdependency_libs 8550edce3322Smrg if test dlpreopen = "$pass"; then 85516e7d3316Smrg # Link the dlpreopened libraries before other libraries 85526e7d3316Smrg for deplib in $save_deplibs; do 85536e7d3316Smrg deplibs="$deplib $deplibs" 85546e7d3316Smrg done 85556e7d3316Smrg fi 8556edce3322Smrg if test dlopen != "$pass"; then 8557edce3322Smrg test conv = "$pass" || { 85586e7d3316Smrg # Make sure lib_search_path contains only unique directories. 85596e7d3316Smrg lib_search_path= 85606e7d3316Smrg for dir in $newlib_search_path; do 85616e7d3316Smrg case "$lib_search_path " in 85626e7d3316Smrg *" $dir "*) ;; 856397cf2ee2Smrg *) func_append lib_search_path " $dir" ;; 85646e7d3316Smrg esac 85656e7d3316Smrg done 85666e7d3316Smrg newlib_search_path= 8567edce3322Smrg } 85686e7d3316Smrg 8569edce3322Smrg if test prog,link = "$linkmode,$pass"; then 85706e7d3316Smrg vars="compile_deplibs finalize_deplibs" 8571edce3322Smrg else 8572edce3322Smrg vars=deplibs 85736e7d3316Smrg fi 85746e7d3316Smrg for var in $vars dependency_libs; do 85756e7d3316Smrg # Add libraries to $var in reverse order 85766e7d3316Smrg eval tmp_libs=\"\$$var\" 85776e7d3316Smrg new_libs= 85786e7d3316Smrg for deplib in $tmp_libs; do 85796e7d3316Smrg # FIXME: Pedantically, this is the right thing to do, so 85806e7d3316Smrg # that some nasty dependency loop isn't accidentally 85816e7d3316Smrg # broken: 85826e7d3316Smrg #new_libs="$deplib $new_libs" 85836e7d3316Smrg # Pragmatically, this seems to cause very few problems in 85846e7d3316Smrg # practice: 85856e7d3316Smrg case $deplib in 85866e7d3316Smrg -L*) new_libs="$deplib $new_libs" ;; 85876e7d3316Smrg -R*) ;; 85886e7d3316Smrg *) 85896e7d3316Smrg # And here is the reason: when a library appears more 85906e7d3316Smrg # than once as an explicit dependence of a library, or 85916e7d3316Smrg # is implicitly linked in more than once by the 85926e7d3316Smrg # compiler, it is considered special, and multiple 85936e7d3316Smrg # occurrences thereof are not removed. Compare this 85946e7d3316Smrg # with having the same library being listed as a 85956e7d3316Smrg # dependency of multiple other libraries: in this case, 85966e7d3316Smrg # we know (pedantically, we assume) the library does not 85976e7d3316Smrg # need to be listed more than once, so we keep only the 85986e7d3316Smrg # last copy. This is not always right, but it is rare 85996e7d3316Smrg # enough that we require users that really mean to play 86006e7d3316Smrg # such unportable linking tricks to link the library 86016e7d3316Smrg # using -Wl,-lname, so that libtool does not consider it 86026e7d3316Smrg # for duplicate removal. 86036e7d3316Smrg case " $specialdeplibs " in 86046e7d3316Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 86056e7d3316Smrg *) 86066e7d3316Smrg case " $new_libs " in 86076e7d3316Smrg *" $deplib "*) ;; 86086e7d3316Smrg *) new_libs="$deplib $new_libs" ;; 86096e7d3316Smrg esac 86106e7d3316Smrg ;; 86116e7d3316Smrg esac 86126e7d3316Smrg ;; 86136e7d3316Smrg esac 86146e7d3316Smrg done 86156e7d3316Smrg tmp_libs= 86166e7d3316Smrg for deplib in $new_libs; do 86176e7d3316Smrg case $deplib in 86186e7d3316Smrg -L*) 86196e7d3316Smrg case " $tmp_libs " in 86206e7d3316Smrg *" $deplib "*) ;; 862197cf2ee2Smrg *) func_append tmp_libs " $deplib" ;; 86226e7d3316Smrg esac 86236e7d3316Smrg ;; 862497cf2ee2Smrg *) func_append tmp_libs " $deplib" ;; 86256e7d3316Smrg esac 86266e7d3316Smrg done 86276e7d3316Smrg eval $var=\"$tmp_libs\" 86286e7d3316Smrg done # for var 86296e7d3316Smrg fi 8630edce3322Smrg 8631edce3322Smrg # Add Sun CC postdeps if required: 8632edce3322Smrg test CXX = "$tagname" && { 8633edce3322Smrg case $host_os in 8634edce3322Smrg linux*) 86351c235774Smrg case `$CC -V 2>&1 | sed 5q` in 8636edce3322Smrg *Sun\ C*) # Sun C++ 5.9 8637edce3322Smrg func_suncc_cstd_abi 8638edce3322Smrg 8639edce3322Smrg if test no != "$suncc_use_cstd_abi"; then 8640edce3322Smrg func_append postdeps ' -library=Cstd -library=Crun' 8641edce3322Smrg fi 8642edce3322Smrg ;; 8643edce3322Smrg esac 8644edce3322Smrg ;; 8645edce3322Smrg 8646edce3322Smrg solaris*) 8647edce3322Smrg func_cc_basename "$CC" 8648edce3322Smrg case $func_cc_basename_result in 8649edce3322Smrg CC* | sunCC*) 8650edce3322Smrg func_suncc_cstd_abi 8651edce3322Smrg 8652edce3322Smrg if test no != "$suncc_use_cstd_abi"; then 8653edce3322Smrg func_append postdeps ' -library=Cstd -library=Crun' 8654edce3322Smrg fi 8655edce3322Smrg ;; 8656edce3322Smrg esac 8657edce3322Smrg ;; 8658edce3322Smrg esac 8659edce3322Smrg } 8660edce3322Smrg 86616e7d3316Smrg # Last step: remove runtime libs from dependency_libs 86626e7d3316Smrg # (they stay in deplibs) 86636e7d3316Smrg tmp_libs= 8664edce3322Smrg for i in $dependency_libs; do 86656e7d3316Smrg case " $predeps $postdeps $compiler_lib_search_path " in 86666e7d3316Smrg *" $i "*) 8667edce3322Smrg i= 86686e7d3316Smrg ;; 86696e7d3316Smrg esac 8670edce3322Smrg if test -n "$i"; then 867197cf2ee2Smrg func_append tmp_libs " $i" 86726e7d3316Smrg fi 86736e7d3316Smrg done 86746e7d3316Smrg dependency_libs=$tmp_libs 86756e7d3316Smrg done # for pass 8676edce3322Smrg if test prog = "$linkmode"; then 8677edce3322Smrg dlfiles=$newdlfiles 86786e7d3316Smrg fi 8679edce3322Smrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8680edce3322Smrg dlprefiles=$newdlprefiles 86816e7d3316Smrg fi 86826e7d3316Smrg 86836e7d3316Smrg case $linkmode in 86846e7d3316Smrg oldlib) 8685edce3322Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8686edce3322Smrg func_warning "'-dlopen' is ignored for archives" 86876e7d3316Smrg fi 86886e7d3316Smrg 86896e7d3316Smrg case " $deplibs" in 86906e7d3316Smrg *\ -l* | *\ -L*) 8691edce3322Smrg func_warning "'-l' and '-L' are ignored for archives" ;; 86926e7d3316Smrg esac 86936e7d3316Smrg 86946e7d3316Smrg test -n "$rpath" && \ 8695edce3322Smrg func_warning "'-rpath' is ignored for archives" 86966e7d3316Smrg 86976e7d3316Smrg test -n "$xrpath" && \ 8698edce3322Smrg func_warning "'-R' is ignored for archives" 86996e7d3316Smrg 87006e7d3316Smrg test -n "$vinfo" && \ 8701edce3322Smrg func_warning "'-version-info/-version-number' is ignored for archives" 87026e7d3316Smrg 87036e7d3316Smrg test -n "$release" && \ 8704edce3322Smrg func_warning "'-release' is ignored for archives" 87056e7d3316Smrg 87066e7d3316Smrg test -n "$export_symbols$export_symbols_regex" && \ 8707edce3322Smrg func_warning "'-export-symbols' is ignored for archives" 87086e7d3316Smrg 87096e7d3316Smrg # Now set the variables for building old libraries. 87106e7d3316Smrg build_libtool_libs=no 8711edce3322Smrg oldlibs=$output 871297cf2ee2Smrg func_append objs "$old_deplibs" 87136e7d3316Smrg ;; 87146e7d3316Smrg 87156e7d3316Smrg lib) 8716edce3322Smrg # Make sure we only generate libraries of the form 'libNAME.la'. 87176e7d3316Smrg case $outputname in 87186e7d3316Smrg lib*) 87196e7d3316Smrg func_stripname 'lib' '.la' "$outputname" 87206e7d3316Smrg name=$func_stripname_result 87216e7d3316Smrg eval shared_ext=\"$shrext_cmds\" 87226e7d3316Smrg eval libname=\"$libname_spec\" 87236e7d3316Smrg ;; 87246e7d3316Smrg *) 8725edce3322Smrg test no = "$module" \ 8726edce3322Smrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 87276e7d3316Smrg 8728edce3322Smrg if test no != "$need_lib_prefix"; then 87296e7d3316Smrg # Add the "lib" prefix for modules if required 87306e7d3316Smrg func_stripname '' '.la' "$outputname" 87316e7d3316Smrg name=$func_stripname_result 87326e7d3316Smrg eval shared_ext=\"$shrext_cmds\" 87336e7d3316Smrg eval libname=\"$libname_spec\" 87346e7d3316Smrg else 87356e7d3316Smrg func_stripname '' '.la' "$outputname" 87366e7d3316Smrg libname=$func_stripname_result 87376e7d3316Smrg fi 87386e7d3316Smrg ;; 87396e7d3316Smrg esac 87406e7d3316Smrg 87416e7d3316Smrg if test -n "$objs"; then 8742edce3322Smrg if test pass_all != "$deplibs_check_method"; then 8743edce3322Smrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 87446e7d3316Smrg else 87456e7d3316Smrg echo 87466e7d3316Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 87476e7d3316Smrg $ECHO "*** objects $objs is not portable!" 874897cf2ee2Smrg func_append libobjs " $objs" 87496e7d3316Smrg fi 87506e7d3316Smrg fi 87516e7d3316Smrg 8752edce3322Smrg test no = "$dlself" \ 8753edce3322Smrg || func_warning "'-dlopen self' is ignored for libtool libraries" 87546e7d3316Smrg 87556e7d3316Smrg set dummy $rpath 87566e7d3316Smrg shift 8757edce3322Smrg test 1 -lt "$#" \ 8758edce3322Smrg && func_warning "ignoring multiple '-rpath's for a libtool library" 87596e7d3316Smrg 8760edce3322Smrg install_libdir=$1 87616e7d3316Smrg 87626e7d3316Smrg oldlibs= 87636e7d3316Smrg if test -z "$rpath"; then 8764edce3322Smrg if test yes = "$build_libtool_libs"; then 87656e7d3316Smrg # Building a libtool convenience library. 8766edce3322Smrg # Some compilers have problems with a '.al' extension so 87676e7d3316Smrg # convenience libraries should have the same extension an 87686e7d3316Smrg # archive normally would. 87696e7d3316Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 87706e7d3316Smrg build_libtool_libs=convenience 87716e7d3316Smrg build_old_libs=yes 87726e7d3316Smrg fi 87736e7d3316Smrg 87746e7d3316Smrg test -n "$vinfo" && \ 8775edce3322Smrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 87766e7d3316Smrg 87776e7d3316Smrg test -n "$release" && \ 8778edce3322Smrg func_warning "'-release' is ignored for convenience libraries" 87796e7d3316Smrg else 87806e7d3316Smrg 87816e7d3316Smrg # Parse the version information argument. 8782edce3322Smrg save_ifs=$IFS; IFS=: 87836e7d3316Smrg set dummy $vinfo 0 0 0 87846e7d3316Smrg shift 8785edce3322Smrg IFS=$save_ifs 87866e7d3316Smrg 87876e7d3316Smrg test -n "$7" && \ 8788edce3322Smrg func_fatal_help "too many parameters to '-version-info'" 87896e7d3316Smrg 87906e7d3316Smrg # convert absolute version numbers to libtool ages 87916e7d3316Smrg # this retains compatibility with .la files and attempts 87926e7d3316Smrg # to make the code below a bit more comprehensible 87936e7d3316Smrg 87946e7d3316Smrg case $vinfo_number in 87956e7d3316Smrg yes) 8796edce3322Smrg number_major=$1 8797edce3322Smrg number_minor=$2 8798edce3322Smrg number_revision=$3 87996e7d3316Smrg # 88006e7d3316Smrg # There are really only two kinds -- those that 88016e7d3316Smrg # use the current revision as the major version 88026e7d3316Smrg # and those that subtract age and use age as 88036e7d3316Smrg # a minor version. But, then there is irix 8804edce3322Smrg # that has an extra 1 added just for fun 88056e7d3316Smrg # 88066e7d3316Smrg case $version_type in 8807ac92798bSmrg # correct linux to gnu/linux during the next big refactor 88081c235774Smrg darwin|freebsd-elf|linux|osf|windows|none) 88096e7d3316Smrg func_arith $number_major + $number_minor 88106e7d3316Smrg current=$func_arith_result 8811edce3322Smrg age=$number_minor 8812edce3322Smrg revision=$number_revision 88136e7d3316Smrg ;; 8814edce3322Smrg freebsd-aout|qnx|sunos) 8815edce3322Smrg current=$number_major 8816edce3322Smrg revision=$number_minor 8817edce3322Smrg age=0 88186e7d3316Smrg ;; 88196e7d3316Smrg irix|nonstopux) 88206e7d3316Smrg func_arith $number_major + $number_minor 88216e7d3316Smrg current=$func_arith_result 8822edce3322Smrg age=$number_minor 8823edce3322Smrg revision=$number_minor 88246e7d3316Smrg lt_irix_increment=no 88256e7d3316Smrg ;; 88266e7d3316Smrg esac 88276e7d3316Smrg ;; 88286e7d3316Smrg no) 8829edce3322Smrg current=$1 8830edce3322Smrg revision=$2 8831edce3322Smrg age=$3 88326e7d3316Smrg ;; 88336e7d3316Smrg esac 88346e7d3316Smrg 88356e7d3316Smrg # Check that each of the things are valid numbers. 88366e7d3316Smrg case $current in 88376e7d3316Smrg 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]) ;; 88386e7d3316Smrg *) 8839edce3322Smrg func_error "CURRENT '$current' must be a nonnegative integer" 8840edce3322Smrg func_fatal_error "'$vinfo' is not valid version information" 88416e7d3316Smrg ;; 88426e7d3316Smrg esac 88436e7d3316Smrg 88446e7d3316Smrg case $revision in 88456e7d3316Smrg 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]) ;; 88466e7d3316Smrg *) 8847edce3322Smrg func_error "REVISION '$revision' must be a nonnegative integer" 8848edce3322Smrg func_fatal_error "'$vinfo' is not valid version information" 88496e7d3316Smrg ;; 88506e7d3316Smrg esac 88516e7d3316Smrg 88526e7d3316Smrg case $age in 88536e7d3316Smrg 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]) ;; 88546e7d3316Smrg *) 8855edce3322Smrg func_error "AGE '$age' must be a nonnegative integer" 8856edce3322Smrg func_fatal_error "'$vinfo' is not valid version information" 88576e7d3316Smrg ;; 88586e7d3316Smrg esac 88596e7d3316Smrg 88606e7d3316Smrg if test "$age" -gt "$current"; then 8861edce3322Smrg func_error "AGE '$age' is greater than the current interface number '$current'" 8862edce3322Smrg func_fatal_error "'$vinfo' is not valid version information" 88636e7d3316Smrg fi 88646e7d3316Smrg 88656e7d3316Smrg # Calculate the version variables. 88666e7d3316Smrg major= 88676e7d3316Smrg versuffix= 88686e7d3316Smrg verstring= 88696e7d3316Smrg case $version_type in 88706e7d3316Smrg none) ;; 88716e7d3316Smrg 88726e7d3316Smrg darwin) 88736e7d3316Smrg # Like Linux, but with the current version available in 88746e7d3316Smrg # verstring for coding it into the library header 88756e7d3316Smrg func_arith $current - $age 88766e7d3316Smrg major=.$func_arith_result 8877edce3322Smrg versuffix=$major.$age.$revision 88786e7d3316Smrg # Darwin ld doesn't like 0 for these options... 88796e7d3316Smrg func_arith $current + 1 88806e7d3316Smrg minor_current=$func_arith_result 8881edce3322Smrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 88826e7d3316Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8883edce3322Smrg # On Darwin other compilers 8884edce3322Smrg case $CC in 8885edce3322Smrg nagfor*) 8886edce3322Smrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8887edce3322Smrg ;; 8888edce3322Smrg *) 8889edce3322Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8890edce3322Smrg ;; 8891edce3322Smrg esac 88926e7d3316Smrg ;; 88936e7d3316Smrg 88946e7d3316Smrg freebsd-aout) 8895edce3322Smrg major=.$current 8896edce3322Smrg versuffix=.$current.$revision 88976e7d3316Smrg ;; 88986e7d3316Smrg 88991c235774Smrg freebsd-elf) 8900edce3322Smrg func_arith $current - $age 8901edce3322Smrg major=.$func_arith_result 8902edce3322Smrg versuffix=$major.$age.$revision 89036e7d3316Smrg ;; 89046e7d3316Smrg 89056e7d3316Smrg irix | nonstopux) 8906edce3322Smrg if test no = "$lt_irix_increment"; then 89076e7d3316Smrg func_arith $current - $age 89086e7d3316Smrg else 89096e7d3316Smrg func_arith $current - $age + 1 89106e7d3316Smrg fi 89116e7d3316Smrg major=$func_arith_result 89126e7d3316Smrg 89136e7d3316Smrg case $version_type in 89146e7d3316Smrg nonstopux) verstring_prefix=nonstopux ;; 89156e7d3316Smrg *) verstring_prefix=sgi ;; 89166e7d3316Smrg esac 8917edce3322Smrg verstring=$verstring_prefix$major.$revision 89186e7d3316Smrg 89196e7d3316Smrg # Add in all the interfaces that we are compatible with. 89206e7d3316Smrg loop=$revision 8921edce3322Smrg while test 0 -ne "$loop"; do 89226e7d3316Smrg func_arith $revision - $loop 89236e7d3316Smrg iface=$func_arith_result 89246e7d3316Smrg func_arith $loop - 1 89256e7d3316Smrg loop=$func_arith_result 8926edce3322Smrg verstring=$verstring_prefix$major.$iface:$verstring 89276e7d3316Smrg done 89286e7d3316Smrg 8929edce3322Smrg # Before this point, $major must not contain '.'. 89306e7d3316Smrg major=.$major 8931edce3322Smrg versuffix=$major.$revision 89326e7d3316Smrg ;; 89336e7d3316Smrg 8934ac92798bSmrg linux) # correct to gnu/linux during the next big refactor 89356e7d3316Smrg func_arith $current - $age 89366e7d3316Smrg major=.$func_arith_result 8937edce3322Smrg versuffix=$major.$age.$revision 89386e7d3316Smrg ;; 89396e7d3316Smrg 89406e7d3316Smrg osf) 89416e7d3316Smrg func_arith $current - $age 89426e7d3316Smrg major=.$func_arith_result 8943edce3322Smrg versuffix=.$current.$age.$revision 8944edce3322Smrg verstring=$current.$age.$revision 89456e7d3316Smrg 89466e7d3316Smrg # Add in all the interfaces that we are compatible with. 89476e7d3316Smrg loop=$age 8948edce3322Smrg while test 0 -ne "$loop"; do 89496e7d3316Smrg func_arith $current - $loop 89506e7d3316Smrg iface=$func_arith_result 89516e7d3316Smrg func_arith $loop - 1 89526e7d3316Smrg loop=$func_arith_result 8953edce3322Smrg verstring=$verstring:$iface.0 89546e7d3316Smrg done 89556e7d3316Smrg 89566e7d3316Smrg # Make executables depend on our current version. 8957edce3322Smrg func_append verstring ":$current.0" 89586e7d3316Smrg ;; 89596e7d3316Smrg 89606e7d3316Smrg qnx) 8961edce3322Smrg major=.$current 8962edce3322Smrg versuffix=.$current 8963edce3322Smrg ;; 8964edce3322Smrg 8965edce3322Smrg sco) 8966edce3322Smrg major=.$current 8967edce3322Smrg versuffix=.$current 89686e7d3316Smrg ;; 89696e7d3316Smrg 89706e7d3316Smrg sunos) 8971edce3322Smrg major=.$current 8972edce3322Smrg versuffix=.$current.$revision 89736e7d3316Smrg ;; 89746e7d3316Smrg 89756e7d3316Smrg windows) 89766e7d3316Smrg # Use '-' rather than '.', since we only want one 8977edce3322Smrg # extension on DOS 8.3 file systems. 89786e7d3316Smrg func_arith $current - $age 89796e7d3316Smrg major=$func_arith_result 8980edce3322Smrg versuffix=-$major 89816e7d3316Smrg ;; 89826e7d3316Smrg 89836e7d3316Smrg *) 8984edce3322Smrg func_fatal_configuration "unknown library version type '$version_type'" 89856e7d3316Smrg ;; 89866e7d3316Smrg esac 89876e7d3316Smrg 89886e7d3316Smrg # Clear the version info if we defaulted, and they specified a release. 89896e7d3316Smrg if test -z "$vinfo" && test -n "$release"; then 89906e7d3316Smrg major= 89916e7d3316Smrg case $version_type in 89926e7d3316Smrg darwin) 89936e7d3316Smrg # we can't check for "0.0" in archive_cmds due to quoting 89946e7d3316Smrg # problems, so we reset it completely 89956e7d3316Smrg verstring= 89966e7d3316Smrg ;; 89976e7d3316Smrg *) 8998edce3322Smrg verstring=0.0 89996e7d3316Smrg ;; 90006e7d3316Smrg esac 9001edce3322Smrg if test no = "$need_version"; then 90026e7d3316Smrg versuffix= 90036e7d3316Smrg else 9004edce3322Smrg versuffix=.0.0 90056e7d3316Smrg fi 90066e7d3316Smrg fi 90076e7d3316Smrg 90086e7d3316Smrg # Remove version info from name if versioning should be avoided 9009edce3322Smrg if test yes,no = "$avoid_version,$need_version"; then 90106e7d3316Smrg major= 90116e7d3316Smrg versuffix= 9012edce3322Smrg verstring= 90136e7d3316Smrg fi 90146e7d3316Smrg 90156e7d3316Smrg # Check to see if the archive will have undefined symbols. 9016edce3322Smrg if test yes = "$allow_undefined"; then 9017edce3322Smrg if test unsupported = "$allow_undefined_flag"; then 9018edce3322Smrg if test yes = "$build_old_libs"; then 9019edce3322Smrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9020edce3322Smrg build_libtool_libs=no 9021edce3322Smrg else 9022edce3322Smrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9023edce3322Smrg fi 90246e7d3316Smrg fi 90256e7d3316Smrg else 90266e7d3316Smrg # Don't allow undefined symbols. 9027edce3322Smrg allow_undefined_flag=$no_undefined_flag 90286e7d3316Smrg fi 90296e7d3316Smrg 90306e7d3316Smrg fi 90316e7d3316Smrg 9032edce3322Smrg func_generate_dlsyms "$libname" "$libname" : 903397cf2ee2Smrg func_append libobjs " $symfileobj" 9034edce3322Smrg test " " = "$libobjs" && libobjs= 90356e7d3316Smrg 9036edce3322Smrg if test relink != "$opt_mode"; then 90376e7d3316Smrg # Remove our outputs, but don't remove object files since they 90386e7d3316Smrg # may have been created when compiling PIC objects. 90396e7d3316Smrg removelist= 90406e7d3316Smrg tempremovelist=`$ECHO "$output_objdir/*"` 90416e7d3316Smrg for p in $tempremovelist; do 90426e7d3316Smrg case $p in 90436e7d3316Smrg *.$objext | *.gcno) 90446e7d3316Smrg ;; 9045edce3322Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9046edce3322Smrg if test -n "$precious_files_regex"; then 90476e7d3316Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 90486e7d3316Smrg then 90496e7d3316Smrg continue 90506e7d3316Smrg fi 90516e7d3316Smrg fi 905297cf2ee2Smrg func_append removelist " $p" 90536e7d3316Smrg ;; 90546e7d3316Smrg *) ;; 90556e7d3316Smrg esac 90566e7d3316Smrg done 90576e7d3316Smrg test -n "$removelist" && \ 90586e7d3316Smrg func_show_eval "${RM}r \$removelist" 90596e7d3316Smrg fi 90606e7d3316Smrg 90616e7d3316Smrg # Now set the variables for building old libraries. 9062edce3322Smrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 906397cf2ee2Smrg func_append oldlibs " $output_objdir/$libname.$libext" 90646e7d3316Smrg 90656e7d3316Smrg # Transform .lo files to .o files. 9066edce3322Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 90676e7d3316Smrg fi 90686e7d3316Smrg 90696e7d3316Smrg # Eliminate all temporary directories. 90706e7d3316Smrg #for path in $notinst_path; do 90716e7d3316Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 90726e7d3316Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 90736e7d3316Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 90746e7d3316Smrg #done 90756e7d3316Smrg 90766e7d3316Smrg if test -n "$xrpath"; then 90776e7d3316Smrg # If the user specified any rpath flags, then add them. 90786e7d3316Smrg temp_xrpath= 90796e7d3316Smrg for libdir in $xrpath; do 908097cf2ee2Smrg func_replace_sysroot "$libdir" 908197cf2ee2Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 90826e7d3316Smrg case "$finalize_rpath " in 90836e7d3316Smrg *" $libdir "*) ;; 908497cf2ee2Smrg *) func_append finalize_rpath " $libdir" ;; 90856e7d3316Smrg esac 90866e7d3316Smrg done 9087edce3322Smrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 90886e7d3316Smrg dependency_libs="$temp_xrpath $dependency_libs" 90896e7d3316Smrg fi 90906e7d3316Smrg fi 90916e7d3316Smrg 90926e7d3316Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9093edce3322Smrg old_dlfiles=$dlfiles 90946e7d3316Smrg dlfiles= 90956e7d3316Smrg for lib in $old_dlfiles; do 90966e7d3316Smrg case " $dlprefiles $dlfiles " in 90976e7d3316Smrg *" $lib "*) ;; 909897cf2ee2Smrg *) func_append dlfiles " $lib" ;; 90996e7d3316Smrg esac 91006e7d3316Smrg done 91016e7d3316Smrg 91026e7d3316Smrg # Make sure dlprefiles contains only unique files 9103edce3322Smrg old_dlprefiles=$dlprefiles 91046e7d3316Smrg dlprefiles= 91056e7d3316Smrg for lib in $old_dlprefiles; do 91066e7d3316Smrg case "$dlprefiles " in 91076e7d3316Smrg *" $lib "*) ;; 910897cf2ee2Smrg *) func_append dlprefiles " $lib" ;; 91096e7d3316Smrg esac 91106e7d3316Smrg done 91116e7d3316Smrg 9112edce3322Smrg if test yes = "$build_libtool_libs"; then 91136e7d3316Smrg if test -n "$rpath"; then 91146e7d3316Smrg case $host in 91156e7d3316Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 91166e7d3316Smrg # these systems don't actually have a c library (as such)! 91176e7d3316Smrg ;; 91186e7d3316Smrg *-*-rhapsody* | *-*-darwin1.[012]) 91196e7d3316Smrg # Rhapsody C library is in the System framework 912097cf2ee2Smrg func_append deplibs " System.ltframework" 91216e7d3316Smrg ;; 91226e7d3316Smrg *-*-netbsd*) 91236e7d3316Smrg # Don't link with libc until the a.out ld.so is fixed. 91246e7d3316Smrg ;; 91251c235774Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 91266e7d3316Smrg # Do not include libc due to us having libc/libc_r. 91276e7d3316Smrg ;; 91286e7d3316Smrg *-*-sco3.2v5* | *-*-sco5v6*) 91296e7d3316Smrg # Causes problems with __ctype 91306e7d3316Smrg ;; 91316e7d3316Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 91326e7d3316Smrg # Compiler inserts libc in the correct place for threads to work 91336e7d3316Smrg ;; 91346e7d3316Smrg *) 91356e7d3316Smrg # Add libc to deplibs on all other systems if necessary. 9136edce3322Smrg if test yes = "$build_libtool_need_lc"; then 913797cf2ee2Smrg func_append deplibs " -lc" 91386e7d3316Smrg fi 91396e7d3316Smrg ;; 91406e7d3316Smrg esac 91416e7d3316Smrg fi 91426e7d3316Smrg 91436e7d3316Smrg # Transform deplibs into only deplibs that can be linked in shared. 91446e7d3316Smrg name_save=$name 91456e7d3316Smrg libname_save=$libname 91466e7d3316Smrg release_save=$release 91476e7d3316Smrg versuffix_save=$versuffix 91486e7d3316Smrg major_save=$major 91496e7d3316Smrg # I'm not sure if I'm treating the release correctly. I think 91506e7d3316Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 91516e7d3316Smrg # add it in twice. Is that correct? 9152edce3322Smrg release= 9153edce3322Smrg versuffix= 9154edce3322Smrg major= 91556e7d3316Smrg newdeplibs= 91566e7d3316Smrg droppeddeps=no 91576e7d3316Smrg case $deplibs_check_method in 91586e7d3316Smrg pass_all) 91596e7d3316Smrg # Don't check for shared/static. Everything works. 91606e7d3316Smrg # This might be a little naive. We might want to check 91616e7d3316Smrg # whether the library exists or not. But this is on 91626e7d3316Smrg # osf3 & osf4 and I'm not really sure... Just 91636e7d3316Smrg # implementing what was already the behavior. 91646e7d3316Smrg newdeplibs=$deplibs 91656e7d3316Smrg ;; 91666e7d3316Smrg test_compile) 91676e7d3316Smrg # This code stresses the "libraries are programs" paradigm to its 91686e7d3316Smrg # limits. Maybe even breaks it. We compile a program, linking it 91696e7d3316Smrg # against the deplibs as a proxy for the library. Then we can check 91706e7d3316Smrg # whether they linked in statically or dynamically with ldd. 91716e7d3316Smrg $opt_dry_run || $RM conftest.c 91726e7d3316Smrg cat > conftest.c <<EOF 91736e7d3316Smrg int main() { return 0; } 91746e7d3316SmrgEOF 91756e7d3316Smrg $opt_dry_run || $RM conftest 91766e7d3316Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 91776e7d3316Smrg ldd_output=`ldd conftest` 91786e7d3316Smrg for i in $deplibs; do 91796e7d3316Smrg case $i in 91806e7d3316Smrg -l*) 91816e7d3316Smrg func_stripname -l '' "$i" 91826e7d3316Smrg name=$func_stripname_result 9183edce3322Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 91846e7d3316Smrg case " $predeps $postdeps " in 91856e7d3316Smrg *" $i "*) 918697cf2ee2Smrg func_append newdeplibs " $i" 9187edce3322Smrg i= 91886e7d3316Smrg ;; 91896e7d3316Smrg esac 91906e7d3316Smrg fi 9191edce3322Smrg if test -n "$i"; then 91926e7d3316Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 91936e7d3316Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 91946e7d3316Smrg set dummy $deplib_matches; shift 91956e7d3316Smrg deplib_match=$1 9196edce3322Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 919797cf2ee2Smrg func_append newdeplibs " $i" 91986e7d3316Smrg else 91996e7d3316Smrg droppeddeps=yes 92006e7d3316Smrg echo 92016e7d3316Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 92026e7d3316Smrg echo "*** I have the capability to make that library automatically link in when" 92036e7d3316Smrg echo "*** you link to this library. But I can only do this if you have a" 92046e7d3316Smrg echo "*** shared version of the library, which I believe you do not have" 92056e7d3316Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 92066e7d3316Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 92076e7d3316Smrg fi 92086e7d3316Smrg fi 92096e7d3316Smrg ;; 92106e7d3316Smrg *) 921197cf2ee2Smrg func_append newdeplibs " $i" 92126e7d3316Smrg ;; 92136e7d3316Smrg esac 92146e7d3316Smrg done 92156e7d3316Smrg else 92166e7d3316Smrg # Error occurred in the first compile. Let's try to salvage 92176e7d3316Smrg # the situation: Compile a separate program for each library. 92186e7d3316Smrg for i in $deplibs; do 92196e7d3316Smrg case $i in 92206e7d3316Smrg -l*) 92216e7d3316Smrg func_stripname -l '' "$i" 92226e7d3316Smrg name=$func_stripname_result 92236e7d3316Smrg $opt_dry_run || $RM conftest 92246e7d3316Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 92256e7d3316Smrg ldd_output=`ldd conftest` 9226edce3322Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92276e7d3316Smrg case " $predeps $postdeps " in 92286e7d3316Smrg *" $i "*) 922997cf2ee2Smrg func_append newdeplibs " $i" 9230edce3322Smrg i= 92316e7d3316Smrg ;; 92326e7d3316Smrg esac 92336e7d3316Smrg fi 9234edce3322Smrg if test -n "$i"; then 92356e7d3316Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 92366e7d3316Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 92376e7d3316Smrg set dummy $deplib_matches; shift 92386e7d3316Smrg deplib_match=$1 9239edce3322Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 924097cf2ee2Smrg func_append newdeplibs " $i" 92416e7d3316Smrg else 92426e7d3316Smrg droppeddeps=yes 92436e7d3316Smrg echo 92446e7d3316Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 92456e7d3316Smrg echo "*** I have the capability to make that library automatically link in when" 92466e7d3316Smrg echo "*** you link to this library. But I can only do this if you have a" 92476e7d3316Smrg echo "*** shared version of the library, which you do not appear to have" 92486e7d3316Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 92496e7d3316Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 92506e7d3316Smrg fi 92516e7d3316Smrg fi 92526e7d3316Smrg else 92536e7d3316Smrg droppeddeps=yes 92546e7d3316Smrg echo 92556e7d3316Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 92566e7d3316Smrg echo "*** make it link in! You will probably need to install it or some" 92576e7d3316Smrg echo "*** library that it depends on before this library will be fully" 92586e7d3316Smrg echo "*** functional. Installing it before continuing would be even better." 92596e7d3316Smrg fi 92606e7d3316Smrg ;; 92616e7d3316Smrg *) 926297cf2ee2Smrg func_append newdeplibs " $i" 92636e7d3316Smrg ;; 92646e7d3316Smrg esac 92656e7d3316Smrg done 92666e7d3316Smrg fi 92676e7d3316Smrg ;; 92686e7d3316Smrg file_magic*) 92696e7d3316Smrg set dummy $deplibs_check_method; shift 92706e7d3316Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 92716e7d3316Smrg for a_deplib in $deplibs; do 92726e7d3316Smrg case $a_deplib in 92736e7d3316Smrg -l*) 92746e7d3316Smrg func_stripname -l '' "$a_deplib" 92756e7d3316Smrg name=$func_stripname_result 9276edce3322Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 92776e7d3316Smrg case " $predeps $postdeps " in 92786e7d3316Smrg *" $a_deplib "*) 927997cf2ee2Smrg func_append newdeplibs " $a_deplib" 9280edce3322Smrg a_deplib= 92816e7d3316Smrg ;; 92826e7d3316Smrg esac 92836e7d3316Smrg fi 9284edce3322Smrg if test -n "$a_deplib"; then 92856e7d3316Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 928697cf2ee2Smrg if test -n "$file_magic_glob"; then 928797cf2ee2Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 928897cf2ee2Smrg else 928997cf2ee2Smrg libnameglob=$libname 929097cf2ee2Smrg fi 9291edce3322Smrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 92926e7d3316Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9293edce3322Smrg if test yes = "$want_nocaseglob"; then 929497cf2ee2Smrg shopt -s nocaseglob 929597cf2ee2Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 929697cf2ee2Smrg $nocaseglob 929797cf2ee2Smrg else 929897cf2ee2Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 929997cf2ee2Smrg fi 93006e7d3316Smrg for potent_lib in $potential_libs; do 93016e7d3316Smrg # Follow soft links. 93026e7d3316Smrg if ls -lLd "$potent_lib" 2>/dev/null | 93036e7d3316Smrg $GREP " -> " >/dev/null; then 93046e7d3316Smrg continue 93056e7d3316Smrg fi 93066e7d3316Smrg # The statement above tries to avoid entering an 93076e7d3316Smrg # endless loop below, in case of cyclic links. 93086e7d3316Smrg # We might still enter an endless loop, since a link 93096e7d3316Smrg # loop can be closed while we follow links, 93106e7d3316Smrg # but so what? 9311edce3322Smrg potlib=$potent_lib 93126e7d3316Smrg while test -h "$potlib" 2>/dev/null; do 9313edce3322Smrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 93146e7d3316Smrg case $potliblink in 9315edce3322Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9316edce3322Smrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 93176e7d3316Smrg esac 93186e7d3316Smrg done 93196e7d3316Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 93206e7d3316Smrg $SED -e 10q | 93216e7d3316Smrg $EGREP "$file_magic_regex" > /dev/null; then 932297cf2ee2Smrg func_append newdeplibs " $a_deplib" 9323edce3322Smrg a_deplib= 93246e7d3316Smrg break 2 93256e7d3316Smrg fi 93266e7d3316Smrg done 93276e7d3316Smrg done 93286e7d3316Smrg fi 9329edce3322Smrg if test -n "$a_deplib"; then 93306e7d3316Smrg droppeddeps=yes 93316e7d3316Smrg echo 93326e7d3316Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 93336e7d3316Smrg echo "*** I have the capability to make that library automatically link in when" 93346e7d3316Smrg echo "*** you link to this library. But I can only do this if you have a" 93356e7d3316Smrg echo "*** shared version of the library, which you do not appear to have" 93366e7d3316Smrg echo "*** because I did check the linker path looking for a file starting" 9337edce3322Smrg if test -z "$potlib"; then 93386e7d3316Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 93396e7d3316Smrg else 93406e7d3316Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93416e7d3316Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 93426e7d3316Smrg fi 93436e7d3316Smrg fi 93446e7d3316Smrg ;; 93456e7d3316Smrg *) 93466e7d3316Smrg # Add a -L argument. 934797cf2ee2Smrg func_append newdeplibs " $a_deplib" 93486e7d3316Smrg ;; 93496e7d3316Smrg esac 93506e7d3316Smrg done # Gone through all deplibs. 93516e7d3316Smrg ;; 93526e7d3316Smrg match_pattern*) 93536e7d3316Smrg set dummy $deplibs_check_method; shift 93546e7d3316Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 93556e7d3316Smrg for a_deplib in $deplibs; do 93566e7d3316Smrg case $a_deplib in 93576e7d3316Smrg -l*) 93586e7d3316Smrg func_stripname -l '' "$a_deplib" 93596e7d3316Smrg name=$func_stripname_result 9360edce3322Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 93616e7d3316Smrg case " $predeps $postdeps " in 93626e7d3316Smrg *" $a_deplib "*) 936397cf2ee2Smrg func_append newdeplibs " $a_deplib" 9364edce3322Smrg a_deplib= 93656e7d3316Smrg ;; 93666e7d3316Smrg esac 93676e7d3316Smrg fi 9368edce3322Smrg if test -n "$a_deplib"; then 93696e7d3316Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 93706e7d3316Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 93716e7d3316Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 93726e7d3316Smrg for potent_lib in $potential_libs; do 9373edce3322Smrg potlib=$potent_lib # see symlink-check above in file_magic test 93746e7d3316Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 93756e7d3316Smrg $EGREP "$match_pattern_regex" > /dev/null; then 937697cf2ee2Smrg func_append newdeplibs " $a_deplib" 9377edce3322Smrg a_deplib= 93786e7d3316Smrg break 2 93796e7d3316Smrg fi 93806e7d3316Smrg done 93816e7d3316Smrg done 93826e7d3316Smrg fi 9383edce3322Smrg if test -n "$a_deplib"; then 93846e7d3316Smrg droppeddeps=yes 93856e7d3316Smrg echo 93866e7d3316Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 93876e7d3316Smrg echo "*** I have the capability to make that library automatically link in when" 93886e7d3316Smrg echo "*** you link to this library. But I can only do this if you have a" 93896e7d3316Smrg echo "*** shared version of the library, which you do not appear to have" 93906e7d3316Smrg echo "*** because I did check the linker path looking for a file starting" 9391edce3322Smrg if test -z "$potlib"; then 93926e7d3316Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 93936e7d3316Smrg else 93946e7d3316Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 93956e7d3316Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 93966e7d3316Smrg fi 93976e7d3316Smrg fi 93986e7d3316Smrg ;; 93996e7d3316Smrg *) 94006e7d3316Smrg # Add a -L argument. 940197cf2ee2Smrg func_append newdeplibs " $a_deplib" 94026e7d3316Smrg ;; 94036e7d3316Smrg esac 94046e7d3316Smrg done # Gone through all deplibs. 94056e7d3316Smrg ;; 94066e7d3316Smrg none | unknown | *) 9407edce3322Smrg newdeplibs= 94086e7d3316Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9409edce3322Smrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9410edce3322Smrg for i in $predeps $postdeps; do 94116e7d3316Smrg # can't use Xsed below, because $i might contain '/' 9412edce3322Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 94136e7d3316Smrg done 94146e7d3316Smrg fi 94156e7d3316Smrg case $tmp_deplibs in 94166e7d3316Smrg *[!\ \ ]*) 94176e7d3316Smrg echo 9418edce3322Smrg if test none = "$deplibs_check_method"; then 94196e7d3316Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 94206e7d3316Smrg else 94216e7d3316Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 94226e7d3316Smrg fi 94236e7d3316Smrg echo "*** All declared inter-library dependencies are being dropped." 94246e7d3316Smrg droppeddeps=yes 94256e7d3316Smrg ;; 94266e7d3316Smrg esac 94276e7d3316Smrg ;; 94286e7d3316Smrg esac 94296e7d3316Smrg versuffix=$versuffix_save 94306e7d3316Smrg major=$major_save 94316e7d3316Smrg release=$release_save 94326e7d3316Smrg libname=$libname_save 94336e7d3316Smrg name=$name_save 94346e7d3316Smrg 94356e7d3316Smrg case $host in 94366e7d3316Smrg *-*-rhapsody* | *-*-darwin1.[012]) 94376e7d3316Smrg # On Rhapsody replace the C library with the System framework 94386e7d3316Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 94396e7d3316Smrg ;; 94406e7d3316Smrg esac 94416e7d3316Smrg 9442edce3322Smrg if test yes = "$droppeddeps"; then 9443edce3322Smrg if test yes = "$module"; then 94446e7d3316Smrg echo 94456e7d3316Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 94466e7d3316Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 94476e7d3316Smrg echo "*** a static module, that should work as long as the dlopening" 94486e7d3316Smrg echo "*** application is linked with the -dlopen flag." 94496e7d3316Smrg if test -z "$global_symbol_pipe"; then 94506e7d3316Smrg echo 94516e7d3316Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9452edce3322Smrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 94536e7d3316Smrg echo "*** not find such a program. So, this module is probably useless." 9454edce3322Smrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 94556e7d3316Smrg fi 9456edce3322Smrg if test no = "$build_old_libs"; then 9457edce3322Smrg oldlibs=$output_objdir/$libname.$libext 94586e7d3316Smrg build_libtool_libs=module 94596e7d3316Smrg build_old_libs=yes 94606e7d3316Smrg else 94616e7d3316Smrg build_libtool_libs=no 94626e7d3316Smrg fi 94636e7d3316Smrg else 94646e7d3316Smrg echo "*** The inter-library dependencies that have been dropped here will be" 94656e7d3316Smrg echo "*** automatically added whenever a program is linked with this library" 94666e7d3316Smrg echo "*** or is declared to -dlopen it." 94676e7d3316Smrg 9468edce3322Smrg if test no = "$allow_undefined"; then 94696e7d3316Smrg echo 94706e7d3316Smrg echo "*** Since this library must not contain undefined symbols," 94716e7d3316Smrg echo "*** because either the platform does not support them or" 94726e7d3316Smrg echo "*** it was explicitly requested with -no-undefined," 94736e7d3316Smrg echo "*** libtool will only create a static version of it." 9474edce3322Smrg if test no = "$build_old_libs"; then 9475edce3322Smrg oldlibs=$output_objdir/$libname.$libext 94766e7d3316Smrg build_libtool_libs=module 94776e7d3316Smrg build_old_libs=yes 94786e7d3316Smrg else 94796e7d3316Smrg build_libtool_libs=no 94806e7d3316Smrg fi 94816e7d3316Smrg fi 94826e7d3316Smrg fi 94836e7d3316Smrg fi 94846e7d3316Smrg # Done checking deplibs! 94856e7d3316Smrg deplibs=$newdeplibs 94866e7d3316Smrg fi 94876e7d3316Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 94886e7d3316Smrg case $host in 94896e7d3316Smrg *-*-darwin*) 94906e7d3316Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94916e7d3316Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94926e7d3316Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 94936e7d3316Smrg ;; 94946e7d3316Smrg esac 94956e7d3316Smrg 94966e7d3316Smrg # move library search paths that coincide with paths to not yet 94976e7d3316Smrg # installed libraries to the beginning of the library search list 94986e7d3316Smrg new_libs= 94996e7d3316Smrg for path in $notinst_path; do 95006e7d3316Smrg case " $new_libs " in 95016e7d3316Smrg *" -L$path/$objdir "*) ;; 95026e7d3316Smrg *) 95036e7d3316Smrg case " $deplibs " in 95046e7d3316Smrg *" -L$path/$objdir "*) 950597cf2ee2Smrg func_append new_libs " -L$path/$objdir" ;; 95066e7d3316Smrg esac 95076e7d3316Smrg ;; 95086e7d3316Smrg esac 95096e7d3316Smrg done 95106e7d3316Smrg for deplib in $deplibs; do 95116e7d3316Smrg case $deplib in 95126e7d3316Smrg -L*) 95136e7d3316Smrg case " $new_libs " in 95146e7d3316Smrg *" $deplib "*) ;; 951597cf2ee2Smrg *) func_append new_libs " $deplib" ;; 95166e7d3316Smrg esac 95176e7d3316Smrg ;; 951897cf2ee2Smrg *) func_append new_libs " $deplib" ;; 95196e7d3316Smrg esac 95206e7d3316Smrg done 9521edce3322Smrg deplibs=$new_libs 95226e7d3316Smrg 95236e7d3316Smrg # All the library-specific variables (install_libdir is set above). 95246e7d3316Smrg library_names= 95256e7d3316Smrg old_library= 95266e7d3316Smrg dlname= 95276e7d3316Smrg 95286e7d3316Smrg # Test again, we may have decided not to build it any more 9529edce3322Smrg if test yes = "$build_libtool_libs"; then 9530edce3322Smrg # Remove $wl instances when linking with ld. 9531ac92798bSmrg # FIXME: should test the right _cmds variable. 9532ac92798bSmrg case $archive_cmds in 9533ac92798bSmrg *\$LD\ *) wl= ;; 9534ac92798bSmrg esac 9535edce3322Smrg if test yes = "$hardcode_into_libs"; then 95366e7d3316Smrg # Hardcode the library paths 95376e7d3316Smrg hardcode_libdirs= 95386e7d3316Smrg dep_rpath= 9539edce3322Smrg rpath=$finalize_rpath 9540edce3322Smrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 95416e7d3316Smrg for libdir in $rpath; do 95426e7d3316Smrg if test -n "$hardcode_libdir_flag_spec"; then 95436e7d3316Smrg if test -n "$hardcode_libdir_separator"; then 954497cf2ee2Smrg func_replace_sysroot "$libdir" 954597cf2ee2Smrg libdir=$func_replace_sysroot_result 95466e7d3316Smrg if test -z "$hardcode_libdirs"; then 9547edce3322Smrg hardcode_libdirs=$libdir 95486e7d3316Smrg else 95496e7d3316Smrg # Just accumulate the unique libdirs. 95506e7d3316Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 95516e7d3316Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 95526e7d3316Smrg ;; 95536e7d3316Smrg *) 955497cf2ee2Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 95556e7d3316Smrg ;; 95566e7d3316Smrg esac 95576e7d3316Smrg fi 95586e7d3316Smrg else 95596e7d3316Smrg eval flag=\"$hardcode_libdir_flag_spec\" 956097cf2ee2Smrg func_append dep_rpath " $flag" 95616e7d3316Smrg fi 95626e7d3316Smrg elif test -n "$runpath_var"; then 95636e7d3316Smrg case "$perm_rpath " in 95646e7d3316Smrg *" $libdir "*) ;; 9565ac92798bSmrg *) func_append perm_rpath " $libdir" ;; 95666e7d3316Smrg esac 95676e7d3316Smrg fi 95686e7d3316Smrg done 95696e7d3316Smrg # Substitute the hardcoded libdirs into the rpath. 95706e7d3316Smrg if test -n "$hardcode_libdir_separator" && 95716e7d3316Smrg test -n "$hardcode_libdirs"; then 9572edce3322Smrg libdir=$hardcode_libdirs 9573ac92798bSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 95746e7d3316Smrg fi 95756e7d3316Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 95766e7d3316Smrg # We should set the runpath_var. 95776e7d3316Smrg rpath= 95786e7d3316Smrg for dir in $perm_rpath; do 957997cf2ee2Smrg func_append rpath "$dir:" 95806e7d3316Smrg done 95816e7d3316Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 95826e7d3316Smrg fi 95836e7d3316Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 95846e7d3316Smrg fi 9585a966c04fSmrg 9586edce3322Smrg shlibpath=$finalize_shlibpath 9587edce3322Smrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 95886e7d3316Smrg if test -n "$shlibpath"; then 95896e7d3316Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 95906e7d3316Smrg fi 9591a966c04fSmrg 95926e7d3316Smrg # Get the real and link names of the library. 95936e7d3316Smrg eval shared_ext=\"$shrext_cmds\" 95946e7d3316Smrg eval library_names=\"$library_names_spec\" 95956e7d3316Smrg set dummy $library_names 95966e7d3316Smrg shift 9597edce3322Smrg realname=$1 95986e7d3316Smrg shift 9599a966c04fSmrg 96006e7d3316Smrg if test -n "$soname_spec"; then 96016e7d3316Smrg eval soname=\"$soname_spec\" 96026e7d3316Smrg else 9603edce3322Smrg soname=$realname 96046e7d3316Smrg fi 96056e7d3316Smrg if test -z "$dlname"; then 96066e7d3316Smrg dlname=$soname 96076e7d3316Smrg fi 9608a966c04fSmrg 9609edce3322Smrg lib=$output_objdir/$realname 96106e7d3316Smrg linknames= 96116e7d3316Smrg for link 96126e7d3316Smrg do 961397cf2ee2Smrg func_append linknames " $link" 96146e7d3316Smrg done 9615a966c04fSmrg 96166e7d3316Smrg # Use standard objects if they are pic 96176e7d3316Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 96186e7d3316Smrg test "X$libobjs" = "X " && libobjs= 9619a966c04fSmrg 96206e7d3316Smrg delfiles= 96216e7d3316Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 96226e7d3316Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9623edce3322Smrg export_symbols=$output_objdir/$libname.uexp 962497cf2ee2Smrg func_append delfiles " $export_symbols" 96256e7d3316Smrg fi 9626a966c04fSmrg 96276e7d3316Smrg orig_export_symbols= 96286e7d3316Smrg case $host_os in 96296e7d3316Smrg cygwin* | mingw* | cegcc*) 96306e7d3316Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 96316e7d3316Smrg # exporting using user supplied symfile 9632edce3322Smrg func_dll_def_p "$export_symbols" || { 96336e7d3316Smrg # and it's NOT already a .def file. Must figure out 96346e7d3316Smrg # which of the given symbols are data symbols and tag 96356e7d3316Smrg # them as such. So, trigger use of export_symbols_cmds. 96366e7d3316Smrg # export_symbols gets reassigned inside the "prepare 96376e7d3316Smrg # the list of exported symbols" if statement, so the 96386e7d3316Smrg # include_expsyms logic still works. 9639edce3322Smrg orig_export_symbols=$export_symbols 96406e7d3316Smrg export_symbols= 96416e7d3316Smrg always_export_symbols=yes 9642edce3322Smrg } 96436e7d3316Smrg fi 96446e7d3316Smrg ;; 96456e7d3316Smrg esac 9646a966c04fSmrg 96476e7d3316Smrg # Prepare the list of exported symbols 96486e7d3316Smrg if test -z "$export_symbols"; then 9649edce3322Smrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9650edce3322Smrg func_verbose "generating symbol list for '$libname.la'" 9651edce3322Smrg export_symbols=$output_objdir/$libname.exp 96526e7d3316Smrg $opt_dry_run || $RM $export_symbols 96536e7d3316Smrg cmds=$export_symbols_cmds 9654edce3322Smrg save_ifs=$IFS; IFS='~' 965597cf2ee2Smrg for cmd1 in $cmds; do 9656edce3322Smrg IFS=$save_ifs 965797cf2ee2Smrg # Take the normal branch if the nm_file_list_spec branch 965897cf2ee2Smrg # doesn't work or if tool conversion is not needed. 965997cf2ee2Smrg case $nm_file_list_spec~$to_tool_file_cmd in 966097cf2ee2Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 966197cf2ee2Smrg try_normal_branch=yes 966297cf2ee2Smrg eval cmd=\"$cmd1\" 966397cf2ee2Smrg func_len " $cmd" 966497cf2ee2Smrg len=$func_len_result 966597cf2ee2Smrg ;; 966697cf2ee2Smrg *) 966797cf2ee2Smrg try_normal_branch=no 966897cf2ee2Smrg ;; 966997cf2ee2Smrg esac 9670edce3322Smrg if test yes = "$try_normal_branch" \ 967197cf2ee2Smrg && { test "$len" -lt "$max_cmd_len" \ 967297cf2ee2Smrg || test "$max_cmd_len" -le -1; } 967397cf2ee2Smrg then 967497cf2ee2Smrg func_show_eval "$cmd" 'exit $?' 967597cf2ee2Smrg skipped_export=false 967697cf2ee2Smrg elif test -n "$nm_file_list_spec"; then 967797cf2ee2Smrg func_basename "$output" 967897cf2ee2Smrg output_la=$func_basename_result 967997cf2ee2Smrg save_libobjs=$libobjs 968097cf2ee2Smrg save_output=$output 9681edce3322Smrg output=$output_objdir/$output_la.nm 968297cf2ee2Smrg func_to_tool_file "$output" 968397cf2ee2Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 968497cf2ee2Smrg func_append delfiles " $output" 968597cf2ee2Smrg func_verbose "creating $NM input file list: $output" 968697cf2ee2Smrg for obj in $save_libobjs; do 968797cf2ee2Smrg func_to_tool_file "$obj" 968897cf2ee2Smrg $ECHO "$func_to_tool_file_result" 968997cf2ee2Smrg done > "$output" 969097cf2ee2Smrg eval cmd=\"$cmd1\" 96916e7d3316Smrg func_show_eval "$cmd" 'exit $?' 969297cf2ee2Smrg output=$save_output 969397cf2ee2Smrg libobjs=$save_libobjs 96946e7d3316Smrg skipped_export=false 96956e7d3316Smrg else 96966e7d3316Smrg # The command line is too long to execute in one step. 96976e7d3316Smrg func_verbose "using reloadable object file for export list..." 96986e7d3316Smrg skipped_export=: 96996e7d3316Smrg # Break out early, otherwise skipped_export may be 97006e7d3316Smrg # set to false by a later but shorter cmd. 97016e7d3316Smrg break 97026e7d3316Smrg fi 97036e7d3316Smrg done 9704edce3322Smrg IFS=$save_ifs 9705edce3322Smrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 97066e7d3316Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 97076e7d3316Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 97086e7d3316Smrg fi 97096e7d3316Smrg fi 97106e7d3316Smrg fi 9711a966c04fSmrg 97126e7d3316Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9713edce3322Smrg tmp_export_symbols=$export_symbols 9714edce3322Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 97156e7d3316Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 97166e7d3316Smrg fi 9717a966c04fSmrg 9718edce3322Smrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 97196e7d3316Smrg # The given exports_symbols file has to be filtered, so filter it. 9720edce3322Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 97216e7d3316Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9722edce3322Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 97236e7d3316Smrg # though. Also, the filter scales superlinearly with the number of 97246e7d3316Smrg # global variables. join(1) would be nice here, but unfortunately 97256e7d3316Smrg # isn't a blessed tool. 97266e7d3316Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 972797cf2ee2Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 97286e7d3316Smrg export_symbols=$output_objdir/$libname.def 97296e7d3316Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9730a966c04fSmrg fi 9731a966c04fSmrg 97326e7d3316Smrg tmp_deplibs= 97336e7d3316Smrg for test_deplib in $deplibs; do 97346e7d3316Smrg case " $convenience " in 97356e7d3316Smrg *" $test_deplib "*) ;; 97366e7d3316Smrg *) 973797cf2ee2Smrg func_append tmp_deplibs " $test_deplib" 97386e7d3316Smrg ;; 97396e7d3316Smrg esac 97406e7d3316Smrg done 9741edce3322Smrg deplibs=$tmp_deplibs 9742a966c04fSmrg 97436e7d3316Smrg if test -n "$convenience"; then 97446e7d3316Smrg if test -n "$whole_archive_flag_spec" && 9745edce3322Smrg test yes = "$compiler_needs_object" && 97466e7d3316Smrg test -z "$libobjs"; then 97476e7d3316Smrg # extract the archives, so we have objects to list. 97486e7d3316Smrg # TODO: could optimize this to just extract one archive. 97496e7d3316Smrg whole_archive_flag_spec= 97506e7d3316Smrg fi 97516e7d3316Smrg if test -n "$whole_archive_flag_spec"; then 97526e7d3316Smrg save_libobjs=$libobjs 97536e7d3316Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 97546e7d3316Smrg test "X$libobjs" = "X " && libobjs= 97556e7d3316Smrg else 9756edce3322Smrg gentop=$output_objdir/${outputname}x 975797cf2ee2Smrg func_append generated " $gentop" 9758a966c04fSmrg 97596e7d3316Smrg func_extract_archives $gentop $convenience 976097cf2ee2Smrg func_append libobjs " $func_extract_archives_result" 97616e7d3316Smrg test "X$libobjs" = "X " && libobjs= 97626e7d3316Smrg fi 97636e7d3316Smrg fi 9764a966c04fSmrg 9765edce3322Smrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 97666e7d3316Smrg eval flag=\"$thread_safe_flag_spec\" 976797cf2ee2Smrg func_append linker_flags " $flag" 97686e7d3316Smrg fi 9769a966c04fSmrg 97706e7d3316Smrg # Make a backup of the uninstalled library when relinking 9771edce3322Smrg if test relink = "$opt_mode"; then 97726e7d3316Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9773a966c04fSmrg fi 9774a966c04fSmrg 97756e7d3316Smrg # Do each of the archive commands. 9776edce3322Smrg if test yes = "$module" && test -n "$module_cmds"; then 97776e7d3316Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 97786e7d3316Smrg eval test_cmds=\"$module_expsym_cmds\" 97796e7d3316Smrg cmds=$module_expsym_cmds 97806e7d3316Smrg else 97816e7d3316Smrg eval test_cmds=\"$module_cmds\" 97826e7d3316Smrg cmds=$module_cmds 97836e7d3316Smrg fi 97846e7d3316Smrg else 97856e7d3316Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 97866e7d3316Smrg eval test_cmds=\"$archive_expsym_cmds\" 97876e7d3316Smrg cmds=$archive_expsym_cmds 97886e7d3316Smrg else 97896e7d3316Smrg eval test_cmds=\"$archive_cmds\" 97906e7d3316Smrg cmds=$archive_cmds 97916e7d3316Smrg fi 9792a966c04fSmrg fi 9793a966c04fSmrg 9794edce3322Smrg if test : != "$skipped_export" && 97956e7d3316Smrg func_len " $test_cmds" && 97966e7d3316Smrg len=$func_len_result && 97976e7d3316Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 97986e7d3316Smrg : 97996e7d3316Smrg else 98006e7d3316Smrg # The command line is too long to link in one step, link piecewise 98016e7d3316Smrg # or, if using GNU ld and skipped_export is not :, use a linker 98026e7d3316Smrg # script. 9803a966c04fSmrg 98046e7d3316Smrg # Save the value of $output and $libobjs because we want to 98056e7d3316Smrg # use them later. If we have whole_archive_flag_spec, we 98066e7d3316Smrg # want to use save_libobjs as it was before 98076e7d3316Smrg # whole_archive_flag_spec was expanded, because we can't 98086e7d3316Smrg # assume the linker understands whole_archive_flag_spec. 98096e7d3316Smrg # This may have to be revisited, in case too many 98106e7d3316Smrg # convenience libraries get linked in and end up exceeding 98116e7d3316Smrg # the spec. 98126e7d3316Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 98136e7d3316Smrg save_libobjs=$libobjs 98146e7d3316Smrg fi 98156e7d3316Smrg save_output=$output 98166e7d3316Smrg func_basename "$output" 98176e7d3316Smrg output_la=$func_basename_result 9818a966c04fSmrg 98196e7d3316Smrg # Clear the reloadable object creation command queue and 98206e7d3316Smrg # initialize k to one. 98216e7d3316Smrg test_cmds= 98226e7d3316Smrg concat_cmds= 98236e7d3316Smrg objlist= 98246e7d3316Smrg last_robj= 98256e7d3316Smrg k=1 9826a966c04fSmrg 9827edce3322Smrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9828edce3322Smrg output=$output_objdir/$output_la.lnkscript 98296e7d3316Smrg func_verbose "creating GNU ld script: $output" 98306e7d3316Smrg echo 'INPUT (' > $output 98316e7d3316Smrg for obj in $save_libobjs 98326e7d3316Smrg do 983397cf2ee2Smrg func_to_tool_file "$obj" 983497cf2ee2Smrg $ECHO "$func_to_tool_file_result" >> $output 98356e7d3316Smrg done 98366e7d3316Smrg echo ')' >> $output 983797cf2ee2Smrg func_append delfiles " $output" 983897cf2ee2Smrg func_to_tool_file "$output" 983997cf2ee2Smrg output=$func_to_tool_file_result 9840edce3322Smrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9841edce3322Smrg output=$output_objdir/$output_la.lnk 98426e7d3316Smrg func_verbose "creating linker input file list: $output" 98436e7d3316Smrg : > $output 98446e7d3316Smrg set x $save_libobjs 98456e7d3316Smrg shift 98466e7d3316Smrg firstobj= 9847edce3322Smrg if test yes = "$compiler_needs_object"; then 98486e7d3316Smrg firstobj="$1 " 98496e7d3316Smrg shift 98506e7d3316Smrg fi 98516e7d3316Smrg for obj 98526e7d3316Smrg do 985397cf2ee2Smrg func_to_tool_file "$obj" 985497cf2ee2Smrg $ECHO "$func_to_tool_file_result" >> $output 98556e7d3316Smrg done 985697cf2ee2Smrg func_append delfiles " $output" 985797cf2ee2Smrg func_to_tool_file "$output" 985897cf2ee2Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 98596e7d3316Smrg else 98606e7d3316Smrg if test -n "$save_libobjs"; then 98616e7d3316Smrg func_verbose "creating reloadable object files..." 9862edce3322Smrg output=$output_objdir/$output_la-$k.$objext 98636e7d3316Smrg eval test_cmds=\"$reload_cmds\" 98646e7d3316Smrg func_len " $test_cmds" 98656e7d3316Smrg len0=$func_len_result 98666e7d3316Smrg len=$len0 98676e7d3316Smrg 98686e7d3316Smrg # Loop over the list of objects to be linked. 98696e7d3316Smrg for obj in $save_libobjs 98706e7d3316Smrg do 98716e7d3316Smrg func_len " $obj" 98726e7d3316Smrg func_arith $len + $func_len_result 98736e7d3316Smrg len=$func_arith_result 9874edce3322Smrg if test -z "$objlist" || 98756e7d3316Smrg test "$len" -lt "$max_cmd_len"; then 98766e7d3316Smrg func_append objlist " $obj" 98776e7d3316Smrg else 98786e7d3316Smrg # The command $test_cmds is almost too long, add a 98796e7d3316Smrg # command to the queue. 9880edce3322Smrg if test 1 -eq "$k"; then 98816e7d3316Smrg # The first file doesn't have a previous command to add. 98826e7d3316Smrg reload_objs=$objlist 98836e7d3316Smrg eval concat_cmds=\"$reload_cmds\" 98846e7d3316Smrg else 98856e7d3316Smrg # All subsequent reloadable object files will link in 98866e7d3316Smrg # the last one created. 98876e7d3316Smrg reload_objs="$objlist $last_robj" 98886e7d3316Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 98896e7d3316Smrg fi 9890edce3322Smrg last_robj=$output_objdir/$output_la-$k.$objext 98916e7d3316Smrg func_arith $k + 1 98926e7d3316Smrg k=$func_arith_result 9893edce3322Smrg output=$output_objdir/$output_la-$k.$objext 98946e7d3316Smrg objlist=" $obj" 98956e7d3316Smrg func_len " $last_robj" 98966e7d3316Smrg func_arith $len0 + $func_len_result 98976e7d3316Smrg len=$func_arith_result 98986e7d3316Smrg fi 98996e7d3316Smrg done 99006e7d3316Smrg # Handle the remaining objects by creating one last 99016e7d3316Smrg # reloadable object file. All subsequent reloadable object 99026e7d3316Smrg # files will link in the last one created. 99036e7d3316Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99046e7d3316Smrg reload_objs="$objlist $last_robj" 9905edce3322Smrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 99066e7d3316Smrg if test -n "$last_robj"; then 9907edce3322Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99086e7d3316Smrg fi 990997cf2ee2Smrg func_append delfiles " $output" 99106e7d3316Smrg 99116e7d3316Smrg else 99126e7d3316Smrg output= 99136e7d3316Smrg fi 9914a966c04fSmrg 9915edce3322Smrg ${skipped_export-false} && { 9916edce3322Smrg func_verbose "generating symbol list for '$libname.la'" 9917edce3322Smrg export_symbols=$output_objdir/$libname.exp 99186e7d3316Smrg $opt_dry_run || $RM $export_symbols 99196e7d3316Smrg libobjs=$output 99206e7d3316Smrg # Append the command to create the export file. 99216e7d3316Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 99226e7d3316Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 99236e7d3316Smrg if test -n "$last_robj"; then 99246e7d3316Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 99256e7d3316Smrg fi 9926edce3322Smrg } 9927a966c04fSmrg 99286e7d3316Smrg test -n "$save_libobjs" && 99296e7d3316Smrg func_verbose "creating a temporary reloadable object file: $output" 9930a966c04fSmrg 99316e7d3316Smrg # Loop through the commands generated above and execute them. 9932edce3322Smrg save_ifs=$IFS; IFS='~' 99336e7d3316Smrg for cmd in $concat_cmds; do 9934edce3322Smrg IFS=$save_ifs 9935edce3322Smrg $opt_quiet || { 99361c235774Smrg func_quote_for_expand "$cmd" 99371c235774Smrg eval "func_echo $func_quote_for_expand_result" 99386e7d3316Smrg } 99396e7d3316Smrg $opt_dry_run || eval "$cmd" || { 99406e7d3316Smrg lt_exit=$? 99416e7d3316Smrg 99426e7d3316Smrg # Restore the uninstalled library and exit 9943edce3322Smrg if test relink = "$opt_mode"; then 99446e7d3316Smrg ( cd "$output_objdir" && \ 99456e7d3316Smrg $RM "${realname}T" && \ 99466e7d3316Smrg $MV "${realname}U" "$realname" ) 99476e7d3316Smrg fi 9948a966c04fSmrg 99496e7d3316Smrg exit $lt_exit 99506e7d3316Smrg } 99516e7d3316Smrg done 9952edce3322Smrg IFS=$save_ifs 9953a966c04fSmrg 99546e7d3316Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 99556e7d3316Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 99566e7d3316Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9957a966c04fSmrg fi 9958a966c04fSmrg fi 9959a966c04fSmrg 9960edce3322Smrg ${skipped_export-false} && { 99616e7d3316Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9962edce3322Smrg tmp_export_symbols=$export_symbols 9963edce3322Smrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 99646e7d3316Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 99656e7d3316Smrg fi 9966a966c04fSmrg 99676e7d3316Smrg if test -n "$orig_export_symbols"; then 99686e7d3316Smrg # The given exports_symbols file has to be filtered, so filter it. 9969edce3322Smrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 99706e7d3316Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9971edce3322Smrg # 's' commands, which not all seds can handle. GNU sed should be fine 99726e7d3316Smrg # though. Also, the filter scales superlinearly with the number of 99736e7d3316Smrg # global variables. join(1) would be nice here, but unfortunately 99746e7d3316Smrg # isn't a blessed tool. 99756e7d3316Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 997697cf2ee2Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 99776e7d3316Smrg export_symbols=$output_objdir/$libname.def 99786e7d3316Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 99796e7d3316Smrg fi 9980edce3322Smrg } 9981a966c04fSmrg 99826e7d3316Smrg libobjs=$output 99836e7d3316Smrg # Restore the value of output. 99846e7d3316Smrg output=$save_output 9985a966c04fSmrg 99866e7d3316Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 99876e7d3316Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 99886e7d3316Smrg test "X$libobjs" = "X " && libobjs= 99896e7d3316Smrg fi 99906e7d3316Smrg # Expand the library linking commands again to reset the 99916e7d3316Smrg # value of $libobjs for piecewise linking. 99926e7d3316Smrg 99936e7d3316Smrg # Do each of the archive commands. 9994edce3322Smrg if test yes = "$module" && test -n "$module_cmds"; then 99956e7d3316Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 99966e7d3316Smrg cmds=$module_expsym_cmds 9997a966c04fSmrg else 99986e7d3316Smrg cmds=$module_cmds 9999a966c04fSmrg fi 10000a966c04fSmrg else 100016e7d3316Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 100026e7d3316Smrg cmds=$archive_expsym_cmds 100036e7d3316Smrg else 100046e7d3316Smrg cmds=$archive_cmds 100056e7d3316Smrg fi 10006a966c04fSmrg fi 10007a966c04fSmrg fi 10008a966c04fSmrg 100096e7d3316Smrg if test -n "$delfiles"; then 100106e7d3316Smrg # Append the command to remove temporary files to $cmds. 100116e7d3316Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 100126e7d3316Smrg fi 10013a966c04fSmrg 100146e7d3316Smrg # Add any objects from preloaded convenience libraries 100156e7d3316Smrg if test -n "$dlprefiles"; then 10016edce3322Smrg gentop=$output_objdir/${outputname}x 1001797cf2ee2Smrg func_append generated " $gentop" 10018a966c04fSmrg 100196e7d3316Smrg func_extract_archives $gentop $dlprefiles 1002097cf2ee2Smrg func_append libobjs " $func_extract_archives_result" 100216e7d3316Smrg test "X$libobjs" = "X " && libobjs= 10022a966c04fSmrg fi 10023a966c04fSmrg 10024edce3322Smrg save_ifs=$IFS; IFS='~' 100256e7d3316Smrg for cmd in $cmds; do 10026edce3322Smrg IFS=$sp$nl 100276e7d3316Smrg eval cmd=\"$cmd\" 10028edce3322Smrg IFS=$save_ifs 10029edce3322Smrg $opt_quiet || { 100301c235774Smrg func_quote_for_expand "$cmd" 100311c235774Smrg eval "func_echo $func_quote_for_expand_result" 100326e7d3316Smrg } 100336e7d3316Smrg $opt_dry_run || eval "$cmd" || { 100346e7d3316Smrg lt_exit=$? 10035a966c04fSmrg 100366e7d3316Smrg # Restore the uninstalled library and exit 10037edce3322Smrg if test relink = "$opt_mode"; then 100386e7d3316Smrg ( cd "$output_objdir" && \ 100396e7d3316Smrg $RM "${realname}T" && \ 100406e7d3316Smrg $MV "${realname}U" "$realname" ) 10041a966c04fSmrg fi 10042a966c04fSmrg 100436e7d3316Smrg exit $lt_exit 100446e7d3316Smrg } 100456e7d3316Smrg done 10046edce3322Smrg IFS=$save_ifs 10047a966c04fSmrg 100486e7d3316Smrg # Restore the uninstalled library and exit 10049edce3322Smrg if test relink = "$opt_mode"; then 100506e7d3316Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051a966c04fSmrg 100526e7d3316Smrg if test -n "$convenience"; then 100536e7d3316Smrg if test -z "$whole_archive_flag_spec"; then 100546e7d3316Smrg func_show_eval '${RM}r "$gentop"' 100556e7d3316Smrg fi 100566e7d3316Smrg fi 10057a966c04fSmrg 100586e7d3316Smrg exit $EXIT_SUCCESS 100596e7d3316Smrg fi 10060a966c04fSmrg 100616e7d3316Smrg # Create links to the real library. 100626e7d3316Smrg for linkname in $linknames; do 100636e7d3316Smrg if test "$realname" != "$linkname"; then 100646e7d3316Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 100656e7d3316Smrg fi 100666e7d3316Smrg done 10067a966c04fSmrg 100686e7d3316Smrg # If -module or -export-dynamic was specified, set the dlname. 10069edce3322Smrg if test yes = "$module" || test yes = "$export_dynamic"; then 100706e7d3316Smrg # On all known operating systems, these are identical. 10071edce3322Smrg dlname=$soname 100726e7d3316Smrg fi 100736e7d3316Smrg fi 100746e7d3316Smrg ;; 10075a966c04fSmrg 100766e7d3316Smrg obj) 10077edce3322Smrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10078edce3322Smrg func_warning "'-dlopen' is ignored for objects" 100796e7d3316Smrg fi 10080a966c04fSmrg 100816e7d3316Smrg case " $deplibs" in 100826e7d3316Smrg *\ -l* | *\ -L*) 10083edce3322Smrg func_warning "'-l' and '-L' are ignored for objects" ;; 100846e7d3316Smrg esac 10085a966c04fSmrg 100866e7d3316Smrg test -n "$rpath" && \ 10087edce3322Smrg func_warning "'-rpath' is ignored for objects" 10088a966c04fSmrg 100896e7d3316Smrg test -n "$xrpath" && \ 10090edce3322Smrg func_warning "'-R' is ignored for objects" 100916e7d3316Smrg 100926e7d3316Smrg test -n "$vinfo" && \ 10093edce3322Smrg func_warning "'-version-info' is ignored for objects" 10094a966c04fSmrg 100956e7d3316Smrg test -n "$release" && \ 10096edce3322Smrg func_warning "'-release' is ignored for objects" 10097a966c04fSmrg 100986e7d3316Smrg case $output in 100996e7d3316Smrg *.lo) 101006e7d3316Smrg test -n "$objs$old_deplibs" && \ 10101edce3322Smrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 101026e7d3316Smrg 101036e7d3316Smrg libobj=$output 101046e7d3316Smrg func_lo2o "$libobj" 101056e7d3316Smrg obj=$func_lo2o_result 101066e7d3316Smrg ;; 101076e7d3316Smrg *) 101086e7d3316Smrg libobj= 10109edce3322Smrg obj=$output 10110a966c04fSmrg ;; 10111a966c04fSmrg esac 10112a966c04fSmrg 101136e7d3316Smrg # Delete the old objects. 101146e7d3316Smrg $opt_dry_run || $RM $obj $libobj 10115a966c04fSmrg 101166e7d3316Smrg # Objects from convenience libraries. This assumes 101176e7d3316Smrg # single-version convenience libraries. Whenever we create 101186e7d3316Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 101196e7d3316Smrg # the extraction. 101206e7d3316Smrg reload_conv_objs= 101216e7d3316Smrg gentop= 10122edce3322Smrg # if reload_cmds runs $LD directly, get rid of -Wl from 10123edce3322Smrg # whole_archive_flag_spec and hope we can get by with turning comma 10124edce3322Smrg # into space. 10125edce3322Smrg case $reload_cmds in 10126edce3322Smrg *\$LD[\ \$]*) wl= ;; 10127edce3322Smrg esac 101286e7d3316Smrg if test -n "$convenience"; then 101296e7d3316Smrg if test -n "$whole_archive_flag_spec"; then 101306e7d3316Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10131edce3322Smrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10132edce3322Smrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133a966c04fSmrg else 10134edce3322Smrg gentop=$output_objdir/${obj}x 1013597cf2ee2Smrg func_append generated " $gentop" 101366e7d3316Smrg 101376e7d3316Smrg func_extract_archives $gentop $convenience 101386e7d3316Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10139a966c04fSmrg fi 101406e7d3316Smrg fi 10141a966c04fSmrg 1014297cf2ee2Smrg # If we're not building shared, we need to use non_pic_objs 10143edce3322Smrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 1014497cf2ee2Smrg 101456e7d3316Smrg # Create the old-style object. 10146edce3322Smrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147a966c04fSmrg 10148edce3322Smrg output=$obj 101496e7d3316Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10150a966c04fSmrg 101516e7d3316Smrg # Exit if we aren't doing a library object file. 101526e7d3316Smrg if test -z "$libobj"; then 101536e7d3316Smrg if test -n "$gentop"; then 101546e7d3316Smrg func_show_eval '${RM}r "$gentop"' 101556e7d3316Smrg fi 10156a966c04fSmrg 101576e7d3316Smrg exit $EXIT_SUCCESS 10158a966c04fSmrg fi 10159a966c04fSmrg 10160edce3322Smrg test yes = "$build_libtool_libs" || { 101616e7d3316Smrg if test -n "$gentop"; then 101626e7d3316Smrg func_show_eval '${RM}r "$gentop"' 101636e7d3316Smrg fi 10164a966c04fSmrg 101656e7d3316Smrg # Create an invalid libtool object if no PIC, so that we don't 101666e7d3316Smrg # accidentally link it into a program. 101676e7d3316Smrg # $show "echo timestamp > $libobj" 101686e7d3316Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 101696e7d3316Smrg exit $EXIT_SUCCESS 10170edce3322Smrg } 10171a966c04fSmrg 10172edce3322Smrg if test -n "$pic_flag" || test default != "$pic_mode"; then 101736e7d3316Smrg # Only do commands if we really have different PIC objects. 101746e7d3316Smrg reload_objs="$libobjs $reload_conv_objs" 10175edce3322Smrg output=$libobj 101766e7d3316Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10177a966c04fSmrg fi 101786e7d3316Smrg 101796e7d3316Smrg if test -n "$gentop"; then 101806e7d3316Smrg func_show_eval '${RM}r "$gentop"' 101816e7d3316Smrg fi 101826e7d3316Smrg 101836e7d3316Smrg exit $EXIT_SUCCESS 10184a966c04fSmrg ;; 10185a966c04fSmrg 101866e7d3316Smrg prog) 101876e7d3316Smrg case $host in 101886e7d3316Smrg *cygwin*) func_stripname '' '.exe' "$output" 101896e7d3316Smrg output=$func_stripname_result.exe;; 101906e7d3316Smrg esac 101916e7d3316Smrg test -n "$vinfo" && \ 10192edce3322Smrg func_warning "'-version-info' is ignored for programs" 10193a966c04fSmrg 101946e7d3316Smrg test -n "$release" && \ 10195edce3322Smrg func_warning "'-release' is ignored for programs" 10196a966c04fSmrg 10197edce3322Smrg $preload \ 10198edce3322Smrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10199edce3322Smrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 102006e7d3316Smrg 102016e7d3316Smrg case $host in 102026e7d3316Smrg *-*-rhapsody* | *-*-darwin1.[012]) 102036e7d3316Smrg # On Rhapsody replace the C library is the System framework 102046e7d3316Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 102056e7d3316Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206a966c04fSmrg ;; 102076e7d3316Smrg esac 10208a966c04fSmrg 102096e7d3316Smrg case $host in 102106e7d3316Smrg *-*-darwin*) 102116e7d3316Smrg # Don't allow lazy linking, it breaks C++ global constructors 102126e7d3316Smrg # But is supposedly fixed on 10.4 or later (yay!). 10213edce3322Smrg if test CXX = "$tagname"; then 102146e7d3316Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 102156e7d3316Smrg 10.[0123]) 10216edce3322Smrg func_append compile_command " $wl-bind_at_load" 10217edce3322Smrg func_append finalize_command " $wl-bind_at_load" 102186e7d3316Smrg ;; 102196e7d3316Smrg esac 10220a966c04fSmrg fi 102216e7d3316Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 102226e7d3316Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102236e7d3316Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 102246e7d3316Smrg ;; 102256e7d3316Smrg esac 10226a966c04fSmrg 10227a966c04fSmrg 102286e7d3316Smrg # move library search paths that coincide with paths to not yet 102296e7d3316Smrg # installed libraries to the beginning of the library search list 102306e7d3316Smrg new_libs= 102316e7d3316Smrg for path in $notinst_path; do 102326e7d3316Smrg case " $new_libs " in 102336e7d3316Smrg *" -L$path/$objdir "*) ;; 102346e7d3316Smrg *) 102356e7d3316Smrg case " $compile_deplibs " in 102366e7d3316Smrg *" -L$path/$objdir "*) 1023797cf2ee2Smrg func_append new_libs " -L$path/$objdir" ;; 10238a966c04fSmrg esac 102396e7d3316Smrg ;; 102406e7d3316Smrg esac 102416e7d3316Smrg done 102426e7d3316Smrg for deplib in $compile_deplibs; do 102436e7d3316Smrg case $deplib in 102446e7d3316Smrg -L*) 102456e7d3316Smrg case " $new_libs " in 102466e7d3316Smrg *" $deplib "*) ;; 1024797cf2ee2Smrg *) func_append new_libs " $deplib" ;; 10248a966c04fSmrg esac 102496e7d3316Smrg ;; 1025097cf2ee2Smrg *) func_append new_libs " $deplib" ;; 102516e7d3316Smrg esac 102526e7d3316Smrg done 10253edce3322Smrg compile_deplibs=$new_libs 10254a966c04fSmrg 10255a966c04fSmrg 1025697cf2ee2Smrg func_append compile_command " $compile_deplibs" 1025797cf2ee2Smrg func_append finalize_command " $finalize_deplibs" 10258a966c04fSmrg 102596e7d3316Smrg if test -n "$rpath$xrpath"; then 102606e7d3316Smrg # If the user specified any rpath flags, then add them. 102616e7d3316Smrg for libdir in $rpath $xrpath; do 102626e7d3316Smrg # This is the magic to use -rpath. 102636e7d3316Smrg case "$finalize_rpath " in 102646e7d3316Smrg *" $libdir "*) ;; 1026597cf2ee2Smrg *) func_append finalize_rpath " $libdir" ;; 102666e7d3316Smrg esac 102676e7d3316Smrg done 102686e7d3316Smrg fi 10269a966c04fSmrg 102706e7d3316Smrg # Now hardcode the library paths 102716e7d3316Smrg rpath= 102726e7d3316Smrg hardcode_libdirs= 102736e7d3316Smrg for libdir in $compile_rpath $finalize_rpath; do 102746e7d3316Smrg if test -n "$hardcode_libdir_flag_spec"; then 102756e7d3316Smrg if test -n "$hardcode_libdir_separator"; then 102766e7d3316Smrg if test -z "$hardcode_libdirs"; then 10277edce3322Smrg hardcode_libdirs=$libdir 102786e7d3316Smrg else 102796e7d3316Smrg # Just accumulate the unique libdirs. 102806e7d3316Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 102816e7d3316Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 102826e7d3316Smrg ;; 102836e7d3316Smrg *) 1028497cf2ee2Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 102856e7d3316Smrg ;; 102866e7d3316Smrg esac 102876e7d3316Smrg fi 10288a966c04fSmrg else 102896e7d3316Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1029097cf2ee2Smrg func_append rpath " $flag" 10291a966c04fSmrg fi 102926e7d3316Smrg elif test -n "$runpath_var"; then 102936e7d3316Smrg case "$perm_rpath " in 102946e7d3316Smrg *" $libdir "*) ;; 1029597cf2ee2Smrg *) func_append perm_rpath " $libdir" ;; 102966e7d3316Smrg esac 102976e7d3316Smrg fi 102986e7d3316Smrg case $host in 102996e7d3316Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10300edce3322Smrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 103016e7d3316Smrg case :$dllsearchpath: in 103026e7d3316Smrg *":$libdir:"*) ;; 103036e7d3316Smrg ::) dllsearchpath=$libdir;; 1030497cf2ee2Smrg *) func_append dllsearchpath ":$libdir";; 103056e7d3316Smrg esac 103066e7d3316Smrg case :$dllsearchpath: in 103076e7d3316Smrg *":$testbindir:"*) ;; 103086e7d3316Smrg ::) dllsearchpath=$testbindir;; 1030997cf2ee2Smrg *) func_append dllsearchpath ":$testbindir";; 103106e7d3316Smrg esac 103116e7d3316Smrg ;; 103126e7d3316Smrg esac 103136e7d3316Smrg done 103146e7d3316Smrg # Substitute the hardcoded libdirs into the rpath. 103156e7d3316Smrg if test -n "$hardcode_libdir_separator" && 103166e7d3316Smrg test -n "$hardcode_libdirs"; then 10317edce3322Smrg libdir=$hardcode_libdirs 103186e7d3316Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 103196e7d3316Smrg fi 10320edce3322Smrg compile_rpath=$rpath 10321a966c04fSmrg 103226e7d3316Smrg rpath= 103236e7d3316Smrg hardcode_libdirs= 103246e7d3316Smrg for libdir in $finalize_rpath; do 103256e7d3316Smrg if test -n "$hardcode_libdir_flag_spec"; then 103266e7d3316Smrg if test -n "$hardcode_libdir_separator"; then 103276e7d3316Smrg if test -z "$hardcode_libdirs"; then 10328edce3322Smrg hardcode_libdirs=$libdir 103296e7d3316Smrg else 103306e7d3316Smrg # Just accumulate the unique libdirs. 103316e7d3316Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 103326e7d3316Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 103336e7d3316Smrg ;; 103346e7d3316Smrg *) 1033597cf2ee2Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 103366e7d3316Smrg ;; 103376e7d3316Smrg esac 103386e7d3316Smrg fi 10339a966c04fSmrg else 103406e7d3316Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1034197cf2ee2Smrg func_append rpath " $flag" 10342a966c04fSmrg fi 103436e7d3316Smrg elif test -n "$runpath_var"; then 103446e7d3316Smrg case "$finalize_perm_rpath " in 103456e7d3316Smrg *" $libdir "*) ;; 1034697cf2ee2Smrg *) func_append finalize_perm_rpath " $libdir" ;; 103476e7d3316Smrg esac 10348a966c04fSmrg fi 103496e7d3316Smrg done 103506e7d3316Smrg # Substitute the hardcoded libdirs into the rpath. 103516e7d3316Smrg if test -n "$hardcode_libdir_separator" && 103526e7d3316Smrg test -n "$hardcode_libdirs"; then 10353edce3322Smrg libdir=$hardcode_libdirs 103546e7d3316Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 103556e7d3316Smrg fi 10356edce3322Smrg finalize_rpath=$rpath 10357a966c04fSmrg 10358edce3322Smrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 103596e7d3316Smrg # Transform all the library objects into standard objects. 103606e7d3316Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103616e7d3316Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 103626e7d3316Smrg fi 10363a966c04fSmrg 10364edce3322Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365a966c04fSmrg 103666e7d3316Smrg # template prelinking step 103676e7d3316Smrg if test -n "$prelink_cmds"; then 103686e7d3316Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 103696e7d3316Smrg fi 10370a966c04fSmrg 10371edce3322Smrg wrappers_required=: 103726e7d3316Smrg case $host in 103736e7d3316Smrg *cegcc* | *mingw32ce*) 103746e7d3316Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10375edce3322Smrg wrappers_required=false 103766e7d3316Smrg ;; 103776e7d3316Smrg *cygwin* | *mingw* ) 10378edce3322Smrg test yes = "$build_libtool_libs" || wrappers_required=false 103796e7d3316Smrg ;; 103806e7d3316Smrg *) 10381edce3322Smrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10382edce3322Smrg wrappers_required=false 103836e7d3316Smrg fi 103846e7d3316Smrg ;; 103856e7d3316Smrg esac 10386edce3322Smrg $wrappers_required || { 103876e7d3316Smrg # Replace the output file specification. 103886e7d3316Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10389edce3322Smrg link_command=$compile_command$compile_rpath 10390a966c04fSmrg 103916e7d3316Smrg # We have no uninstalled library dependencies, so finalize right now. 103926e7d3316Smrg exit_status=0 103936e7d3316Smrg func_show_eval "$link_command" 'exit_status=$?' 10394a966c04fSmrg 1039597cf2ee2Smrg if test -n "$postlink_cmds"; then 1039697cf2ee2Smrg func_to_tool_file "$output" 1039797cf2ee2Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1039897cf2ee2Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1039997cf2ee2Smrg fi 1040097cf2ee2Smrg 104016e7d3316Smrg # Delete the generated files. 10402edce3322Smrg if test -f "$output_objdir/${outputname}S.$objext"; then 10403edce3322Smrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404a966c04fSmrg fi 10405a966c04fSmrg 104066e7d3316Smrg exit $exit_status 10407edce3322Smrg } 10408a966c04fSmrg 104096e7d3316Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 104106e7d3316Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 104116e7d3316Smrg fi 104126e7d3316Smrg if test -n "$finalize_shlibpath"; then 104136e7d3316Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 104146e7d3316Smrg fi 10415a966c04fSmrg 104166e7d3316Smrg compile_var= 104176e7d3316Smrg finalize_var= 104186e7d3316Smrg if test -n "$runpath_var"; then 104196e7d3316Smrg if test -n "$perm_rpath"; then 104206e7d3316Smrg # We should set the runpath_var. 104216e7d3316Smrg rpath= 104226e7d3316Smrg for dir in $perm_rpath; do 1042397cf2ee2Smrg func_append rpath "$dir:" 104246e7d3316Smrg done 104256e7d3316Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426a966c04fSmrg fi 104276e7d3316Smrg if test -n "$finalize_perm_rpath"; then 104286e7d3316Smrg # We should set the runpath_var. 104296e7d3316Smrg rpath= 104306e7d3316Smrg for dir in $finalize_perm_rpath; do 1043197cf2ee2Smrg func_append rpath "$dir:" 104326e7d3316Smrg done 104336e7d3316Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434a966c04fSmrg fi 104356e7d3316Smrg fi 10436a966c04fSmrg 10437edce3322Smrg if test yes = "$no_install"; then 104386e7d3316Smrg # We don't need to create a wrapper script. 10439edce3322Smrg link_command=$compile_var$compile_command$compile_rpath 104406e7d3316Smrg # Replace the output file specification. 104416e7d3316Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 104426e7d3316Smrg # Delete the old output file. 104436e7d3316Smrg $opt_dry_run || $RM $output 104446e7d3316Smrg # Link the executable and exit 104456e7d3316Smrg func_show_eval "$link_command" 'exit $?' 1044697cf2ee2Smrg 1044797cf2ee2Smrg if test -n "$postlink_cmds"; then 1044897cf2ee2Smrg func_to_tool_file "$output" 1044997cf2ee2Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 1045097cf2ee2Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1045197cf2ee2Smrg fi 1045297cf2ee2Smrg 10453a966c04fSmrg exit $EXIT_SUCCESS 104546e7d3316Smrg fi 10455a966c04fSmrg 10456edce3322Smrg case $hardcode_action,$fast_install in 10457edce3322Smrg relink,*) 10458edce3322Smrg # Fast installation is not supported 10459edce3322Smrg link_command=$compile_var$compile_command$compile_rpath 10460edce3322Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 104616e7d3316Smrg 10462edce3322Smrg func_warning "this platform does not like uninstalled shared libraries" 10463edce3322Smrg func_warning "'$output' will be relinked during installation" 10464edce3322Smrg ;; 10465edce3322Smrg *,yes) 10466edce3322Smrg link_command=$finalize_var$compile_command$finalize_rpath 10467edce3322Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10468edce3322Smrg ;; 10469edce3322Smrg *,no) 10470edce3322Smrg link_command=$compile_var$compile_command$compile_rpath 10471edce3322Smrg relink_command=$finalize_var$finalize_command$finalize_rpath 10472edce3322Smrg ;; 10473edce3322Smrg *,needless) 10474edce3322Smrg link_command=$finalize_var$compile_command$finalize_rpath 10475edce3322Smrg relink_command= 10476edce3322Smrg ;; 10477edce3322Smrg esac 10478a966c04fSmrg 104796e7d3316Smrg # Replace the output file specification. 104806e7d3316Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481a966c04fSmrg 104826e7d3316Smrg # Delete the old output files. 104836e7d3316Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484a966c04fSmrg 104856e7d3316Smrg func_show_eval "$link_command" 'exit $?' 10486a966c04fSmrg 1048797cf2ee2Smrg if test -n "$postlink_cmds"; then 1048897cf2ee2Smrg func_to_tool_file "$output_objdir/$outputname" 1048997cf2ee2Smrg 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'` 1049097cf2ee2Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 1049197cf2ee2Smrg fi 1049297cf2ee2Smrg 104936e7d3316Smrg # Now create the wrapper script. 104946e7d3316Smrg func_verbose "creating $output" 10495a966c04fSmrg 104966e7d3316Smrg # Quote the relink command for shipping. 104976e7d3316Smrg if test -n "$relink_command"; then 104986e7d3316Smrg # Preserve any variables that may affect compiler behavior 104996e7d3316Smrg for var in $variables_saved_for_relink; do 105006e7d3316Smrg if eval test -z \"\${$var+set}\"; then 105016e7d3316Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 105026e7d3316Smrg elif eval var_value=\$$var; test -z "$var_value"; then 105036e7d3316Smrg relink_command="$var=; export $var; $relink_command" 10504a966c04fSmrg else 105051c235774Smrg func_quote_for_eval "$var_value" 105061c235774Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507a966c04fSmrg fi 105086e7d3316Smrg done 105091c235774Smrg relink_command="(cd `pwd`; $relink_command)" 105101c235774Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 105116e7d3316Smrg fi 10512a966c04fSmrg 105136e7d3316Smrg # Only actually do things if not in dry run mode. 105146e7d3316Smrg $opt_dry_run || { 105156e7d3316Smrg # win32 will think the script is a binary if it has 105166e7d3316Smrg # a .exe suffix, so we strip it off here. 105176e7d3316Smrg case $output in 105186e7d3316Smrg *.exe) func_stripname '' '.exe' "$output" 105196e7d3316Smrg output=$func_stripname_result ;; 105206e7d3316Smrg esac 105216e7d3316Smrg # test for cygwin because mv fails w/o .exe extensions 105226e7d3316Smrg case $host in 105236e7d3316Smrg *cygwin*) 105246e7d3316Smrg exeext=.exe 105256e7d3316Smrg func_stripname '' '.exe' "$outputname" 105266e7d3316Smrg outputname=$func_stripname_result ;; 105276e7d3316Smrg *) exeext= ;; 10528a966c04fSmrg esac 105296e7d3316Smrg case $host in 105306e7d3316Smrg *cygwin* | *mingw* ) 105316e7d3316Smrg func_dirname_and_basename "$output" "" "." 105326e7d3316Smrg output_name=$func_basename_result 105336e7d3316Smrg output_path=$func_dirname_result 10534edce3322Smrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10535edce3322Smrg cwrapper=$output_path/$output_name.exe 105366e7d3316Smrg $RM $cwrappersource $cwrapper 105376e7d3316Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 105386e7d3316Smrg 105396e7d3316Smrg func_emit_cwrapperexe_src > $cwrappersource 105406e7d3316Smrg 105416e7d3316Smrg # The wrapper executable is built using the $host compiler, 105426e7d3316Smrg # because it contains $host paths and files. If cross- 105436e7d3316Smrg # compiling, it, like the target executable, must be 105446e7d3316Smrg # executed on the $host or under an emulation environment. 105456e7d3316Smrg $opt_dry_run || { 105466e7d3316Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 105476e7d3316Smrg $STRIP $cwrapper 105486e7d3316Smrg } 10549a966c04fSmrg 105506e7d3316Smrg # Now, create the wrapper script for func_source use: 105516e7d3316Smrg func_ltwrapper_scriptname $cwrapper 105526e7d3316Smrg $RM $func_ltwrapper_scriptname_result 105536e7d3316Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 105546e7d3316Smrg $opt_dry_run || { 105556e7d3316Smrg # note: this script will not be executed, so do not chmod. 10556edce3322Smrg if test "x$build" = "x$host"; then 105576e7d3316Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 105586e7d3316Smrg else 105596e7d3316Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 105606e7d3316Smrg fi 105616e7d3316Smrg } 105626e7d3316Smrg ;; 105636e7d3316Smrg * ) 105646e7d3316Smrg $RM $output 105656e7d3316Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566a966c04fSmrg 105676e7d3316Smrg func_emit_wrapper no > $output 105686e7d3316Smrg chmod +x $output 105696e7d3316Smrg ;; 105706e7d3316Smrg esac 105716e7d3316Smrg } 105726e7d3316Smrg exit $EXIT_SUCCESS 105736e7d3316Smrg ;; 105746e7d3316Smrg esac 10575a966c04fSmrg 105766e7d3316Smrg # See if we need to build an old-fashioned archive. 105776e7d3316Smrg for oldlib in $oldlibs; do 10578a966c04fSmrg 10579edce3322Smrg case $build_libtool_libs in 10580edce3322Smrg convenience) 10581edce3322Smrg oldobjs="$libobjs_save $symfileobj" 10582edce3322Smrg addlibs=$convenience 105836e7d3316Smrg build_libtool_libs=no 10584edce3322Smrg ;; 10585edce3322Smrg module) 10586edce3322Smrg oldobjs=$libobjs_save 10587edce3322Smrg addlibs=$old_convenience 10588edce3322Smrg build_libtool_libs=no 10589edce3322Smrg ;; 10590edce3322Smrg *) 105916e7d3316Smrg oldobjs="$old_deplibs $non_pic_objects" 10592edce3322Smrg $preload && test -f "$symfileobj" \ 10593edce3322Smrg && func_append oldobjs " $symfileobj" 10594edce3322Smrg addlibs=$old_convenience 10595edce3322Smrg ;; 10596edce3322Smrg esac 10597a966c04fSmrg 105986e7d3316Smrg if test -n "$addlibs"; then 10599edce3322Smrg gentop=$output_objdir/${outputname}x 1060097cf2ee2Smrg func_append generated " $gentop" 10601a966c04fSmrg 106026e7d3316Smrg func_extract_archives $gentop $addlibs 1060397cf2ee2Smrg func_append oldobjs " $func_extract_archives_result" 106046e7d3316Smrg fi 10605a966c04fSmrg 106066e7d3316Smrg # Do each command in the archive commands. 10607edce3322Smrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 106086e7d3316Smrg cmds=$old_archive_from_new_cmds 106096e7d3316Smrg else 10610a966c04fSmrg 106116e7d3316Smrg # Add any objects from preloaded convenience libraries 106126e7d3316Smrg if test -n "$dlprefiles"; then 10613edce3322Smrg gentop=$output_objdir/${outputname}x 1061497cf2ee2Smrg func_append generated " $gentop" 10615a966c04fSmrg 106166e7d3316Smrg func_extract_archives $gentop $dlprefiles 1061797cf2ee2Smrg func_append oldobjs " $func_extract_archives_result" 106186e7d3316Smrg fi 10619a966c04fSmrg 106206e7d3316Smrg # POSIX demands no paths to be encoded in archives. We have 106216e7d3316Smrg # to avoid creating archives with duplicate basenames if we 106226e7d3316Smrg # might have to extract them afterwards, e.g., when creating a 106236e7d3316Smrg # static archive out of a convenience library, or when linking 106246e7d3316Smrg # the entirety of a libtool archive into another (currently 106256e7d3316Smrg # not supported by libtool). 106266e7d3316Smrg if (for obj in $oldobjs 106276e7d3316Smrg do 106286e7d3316Smrg func_basename "$obj" 106296e7d3316Smrg $ECHO "$func_basename_result" 106306e7d3316Smrg done | sort | sort -uc >/dev/null 2>&1); then 106316e7d3316Smrg : 106326e7d3316Smrg else 106336e7d3316Smrg echo "copying selected object files to avoid basename conflicts..." 10634edce3322Smrg gentop=$output_objdir/${outputname}x 1063597cf2ee2Smrg func_append generated " $gentop" 106366e7d3316Smrg func_mkdir_p "$gentop" 106376e7d3316Smrg save_oldobjs=$oldobjs 106386e7d3316Smrg oldobjs= 106396e7d3316Smrg counter=1 106406e7d3316Smrg for obj in $save_oldobjs 106416e7d3316Smrg do 106426e7d3316Smrg func_basename "$obj" 10643edce3322Smrg objbase=$func_basename_result 106446e7d3316Smrg case " $oldobjs " in 106456e7d3316Smrg " ") oldobjs=$obj ;; 106466e7d3316Smrg *[\ /]"$objbase "*) 106476e7d3316Smrg while :; do 106486e7d3316Smrg # Make sure we don't pick an alternate name that also 106496e7d3316Smrg # overlaps. 106506e7d3316Smrg newobj=lt$counter-$objbase 106516e7d3316Smrg func_arith $counter + 1 106526e7d3316Smrg counter=$func_arith_result 106536e7d3316Smrg case " $oldobjs " in 106546e7d3316Smrg *[\ /]"$newobj "*) ;; 106556e7d3316Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 106566e7d3316Smrg esac 106576e7d3316Smrg done 106586e7d3316Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 1065997cf2ee2Smrg func_append oldobjs " $gentop/$newobj" 106606e7d3316Smrg ;; 1066197cf2ee2Smrg *) func_append oldobjs " $obj" ;; 106626e7d3316Smrg esac 10663a966c04fSmrg done 10664a966c04fSmrg fi 10665ac92798bSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666ac92798bSmrg tool_oldlib=$func_to_tool_file_result 106676e7d3316Smrg eval cmds=\"$old_archive_cmds\" 10668a966c04fSmrg 106696e7d3316Smrg func_len " $cmds" 106706e7d3316Smrg len=$func_len_result 106716e7d3316Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 106726e7d3316Smrg cmds=$old_archive_cmds 1067397cf2ee2Smrg elif test -n "$archiver_list_spec"; then 1067497cf2ee2Smrg func_verbose "using command file archive linking..." 1067597cf2ee2Smrg for obj in $oldobjs 1067697cf2ee2Smrg do 1067797cf2ee2Smrg func_to_tool_file "$obj" 1067897cf2ee2Smrg $ECHO "$func_to_tool_file_result" 1067997cf2ee2Smrg done > $output_objdir/$libname.libcmd 1068097cf2ee2Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 1068197cf2ee2Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 1068297cf2ee2Smrg cmds=$old_archive_cmds 106836e7d3316Smrg else 106846e7d3316Smrg # the command line is too long to link in one step, link in parts 106856e7d3316Smrg func_verbose "using piecewise archive linking..." 106866e7d3316Smrg save_RANLIB=$RANLIB 106876e7d3316Smrg RANLIB=: 106886e7d3316Smrg objlist= 106896e7d3316Smrg concat_cmds= 106906e7d3316Smrg save_oldobjs=$oldobjs 106916e7d3316Smrg oldobjs= 106926e7d3316Smrg # Is there a better way of finding the last object in the list? 106936e7d3316Smrg for obj in $save_oldobjs 106946e7d3316Smrg do 106956e7d3316Smrg last_oldobj=$obj 106966e7d3316Smrg done 106976e7d3316Smrg eval test_cmds=\"$old_archive_cmds\" 106986e7d3316Smrg func_len " $test_cmds" 106996e7d3316Smrg len0=$func_len_result 107006e7d3316Smrg len=$len0 107016e7d3316Smrg for obj in $save_oldobjs 107026e7d3316Smrg do 107036e7d3316Smrg func_len " $obj" 107046e7d3316Smrg func_arith $len + $func_len_result 107056e7d3316Smrg len=$func_arith_result 107066e7d3316Smrg func_append objlist " $obj" 107076e7d3316Smrg if test "$len" -lt "$max_cmd_len"; then 107086e7d3316Smrg : 107096e7d3316Smrg else 107106e7d3316Smrg # the above command should be used before it gets too long 107116e7d3316Smrg oldobjs=$objlist 10712edce3322Smrg if test "$obj" = "$last_oldobj"; then 107136e7d3316Smrg RANLIB=$save_RANLIB 107146e7d3316Smrg fi 107156e7d3316Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10716edce3322Smrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 107176e7d3316Smrg objlist= 107186e7d3316Smrg len=$len0 107196e7d3316Smrg fi 107206e7d3316Smrg done 107216e7d3316Smrg RANLIB=$save_RANLIB 107226e7d3316Smrg oldobjs=$objlist 10723edce3322Smrg if test -z "$oldobjs"; then 107246e7d3316Smrg eval cmds=\"\$concat_cmds\" 107256e7d3316Smrg else 107266e7d3316Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 107276e7d3316Smrg fi 107286e7d3316Smrg fi 107296e7d3316Smrg fi 107306e7d3316Smrg func_execute_cmds "$cmds" 'exit $?' 10731a966c04fSmrg done 10732a966c04fSmrg 107336e7d3316Smrg test -n "$generated" && \ 107346e7d3316Smrg func_show_eval "${RM}r$generated" 10735a966c04fSmrg 107366e7d3316Smrg # Now create the libtool archive. 107376e7d3316Smrg case $output in 107386e7d3316Smrg *.la) 107396e7d3316Smrg old_library= 10740edce3322Smrg test yes = "$build_old_libs" && old_library=$libname.$libext 107416e7d3316Smrg func_verbose "creating $output" 10742a966c04fSmrg 107436e7d3316Smrg # Preserve any variables that may affect compiler behavior 107446e7d3316Smrg for var in $variables_saved_for_relink; do 107456e7d3316Smrg if eval test -z \"\${$var+set}\"; then 107466e7d3316Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 107476e7d3316Smrg elif eval var_value=\$$var; test -z "$var_value"; then 107486e7d3316Smrg relink_command="$var=; export $var; $relink_command" 10749a966c04fSmrg else 107501c235774Smrg func_quote_for_eval "$var_value" 107511c235774Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752a966c04fSmrg fi 107536e7d3316Smrg done 107546e7d3316Smrg # Quote the link command for shipping. 107551c235774Smrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 107561c235774Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10757edce3322Smrg if test yes = "$hardcode_automatic"; then 107586e7d3316Smrg relink_command= 107596e7d3316Smrg fi 10760a966c04fSmrg 107616e7d3316Smrg # Only create the output if not a dry run. 107626e7d3316Smrg $opt_dry_run || { 107636e7d3316Smrg for installed in no yes; do 10764edce3322Smrg if test yes = "$installed"; then 107656e7d3316Smrg if test -z "$install_libdir"; then 107666e7d3316Smrg break 107676e7d3316Smrg fi 10768edce3322Smrg output=$output_objdir/${outputname}i 107696e7d3316Smrg # Replace all uninstalled libtool libraries with the installed ones 107706e7d3316Smrg newdependency_libs= 107716e7d3316Smrg for deplib in $dependency_libs; do 107726e7d3316Smrg case $deplib in 107736e7d3316Smrg *.la) 107746e7d3316Smrg func_basename "$deplib" 10775edce3322Smrg name=$func_basename_result 10776ac92798bSmrg func_resolve_sysroot "$deplib" 10777edce3322Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 107786e7d3316Smrg test -z "$libdir" && \ 10779edce3322Smrg func_fatal_error "'$deplib' is not a valid libtool archive" 1078097cf2ee2Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 1078197cf2ee2Smrg ;; 1078297cf2ee2Smrg -L*) 1078397cf2ee2Smrg func_stripname -L '' "$deplib" 1078497cf2ee2Smrg func_replace_sysroot "$func_stripname_result" 1078597cf2ee2Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 1078697cf2ee2Smrg ;; 1078797cf2ee2Smrg -R*) 1078897cf2ee2Smrg func_stripname -R '' "$deplib" 1078997cf2ee2Smrg func_replace_sysroot "$func_stripname_result" 1079097cf2ee2Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 107916e7d3316Smrg ;; 1079297cf2ee2Smrg *) func_append newdependency_libs " $deplib" ;; 107936e7d3316Smrg esac 107946e7d3316Smrg done 10795edce3322Smrg dependency_libs=$newdependency_libs 107966e7d3316Smrg newdlfiles= 107976e7d3316Smrg 107986e7d3316Smrg for lib in $dlfiles; do 107996e7d3316Smrg case $lib in 108006e7d3316Smrg *.la) 108016e7d3316Smrg func_basename "$lib" 10802edce3322Smrg name=$func_basename_result 10803edce3322Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108046e7d3316Smrg test -z "$libdir" && \ 10805edce3322Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1080697cf2ee2Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 108076e7d3316Smrg ;; 1080897cf2ee2Smrg *) func_append newdlfiles " $lib" ;; 108096e7d3316Smrg esac 108106e7d3316Smrg done 10811edce3322Smrg dlfiles=$newdlfiles 108126e7d3316Smrg newdlprefiles= 108136e7d3316Smrg for lib in $dlprefiles; do 108146e7d3316Smrg case $lib in 108156e7d3316Smrg *.la) 108166e7d3316Smrg # Only pass preopened files to the pseudo-archive (for 108176e7d3316Smrg # eventual linking with the app. that links it) if we 108186e7d3316Smrg # didn't already link the preopened objects directly into 108196e7d3316Smrg # the library: 108206e7d3316Smrg func_basename "$lib" 10821edce3322Smrg name=$func_basename_result 10822edce3322Smrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 108236e7d3316Smrg test -z "$libdir" && \ 10824edce3322Smrg func_fatal_error "'$lib' is not a valid libtool archive" 1082597cf2ee2Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 108266e7d3316Smrg ;; 108276e7d3316Smrg esac 108286e7d3316Smrg done 10829edce3322Smrg dlprefiles=$newdlprefiles 108306e7d3316Smrg else 108316e7d3316Smrg newdlfiles= 108326e7d3316Smrg for lib in $dlfiles; do 108336e7d3316Smrg case $lib in 10834edce3322Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108356e7d3316Smrg *) abs=`pwd`"/$lib" ;; 108366e7d3316Smrg esac 1083797cf2ee2Smrg func_append newdlfiles " $abs" 108386e7d3316Smrg done 10839edce3322Smrg dlfiles=$newdlfiles 108406e7d3316Smrg newdlprefiles= 108416e7d3316Smrg for lib in $dlprefiles; do 108426e7d3316Smrg case $lib in 10843edce3322Smrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 108446e7d3316Smrg *) abs=`pwd`"/$lib" ;; 108456e7d3316Smrg esac 1084697cf2ee2Smrg func_append newdlprefiles " $abs" 108476e7d3316Smrg done 10848edce3322Smrg dlprefiles=$newdlprefiles 108496e7d3316Smrg fi 108506e7d3316Smrg $RM $output 108516e7d3316Smrg # place dlname in correct position for cygwin 108526e7d3316Smrg # In fact, it would be nice if we could use this code for all target 108536e7d3316Smrg # systems that can't hard-code library paths into their executables 108546e7d3316Smrg # and that have no shared library path variable independent of PATH, 108556e7d3316Smrg # but it turns out we can't easily determine that from inspecting 108566e7d3316Smrg # libtool variables, so we have to hard-code the OSs to which it 108576e7d3316Smrg # applies here; at the moment, that means platforms that use the PE 108586e7d3316Smrg # object format with DLL files. See the long comment at the top of 108596e7d3316Smrg # tests/bindir.at for full details. 108606e7d3316Smrg tdlname=$dlname 108616e7d3316Smrg case $host,$output,$installed,$module,$dlname in 108626e7d3316Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 108636e7d3316Smrg # If a -bindir argument was supplied, place the dll there. 10864edce3322Smrg if test -n "$bindir"; then 108656e7d3316Smrg func_relative_path "$install_libdir" "$bindir" 10866edce3322Smrg tdlname=$func_relative_path_result/$dlname 108676e7d3316Smrg else 108686e7d3316Smrg # Otherwise fall back on heuristic. 108696e7d3316Smrg tdlname=../bin/$dlname 108706e7d3316Smrg fi 108716e7d3316Smrg ;; 108726e7d3316Smrg esac 108736e7d3316Smrg $ECHO > $output "\ 108746e7d3316Smrg# $outputname - a libtool library file 10875edce3322Smrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 108766e7d3316Smrg# 108776e7d3316Smrg# Please DO NOT delete this file! 108786e7d3316Smrg# It is necessary for linking the library. 10879a966c04fSmrg 108806e7d3316Smrg# The name that we can dlopen(3). 108816e7d3316Smrgdlname='$tdlname' 10882a966c04fSmrg 108836e7d3316Smrg# Names of this library. 108846e7d3316Smrglibrary_names='$library_names' 10885a966c04fSmrg 108866e7d3316Smrg# The name of the static archive. 108876e7d3316Smrgold_library='$old_library' 10888a966c04fSmrg 10889edce3322Smrg# Linker flags that cannot go in dependency_libs. 108906e7d3316Smrginherited_linker_flags='$new_inherited_linker_flags' 10891a966c04fSmrg 108926e7d3316Smrg# Libraries that this one depends upon. 108936e7d3316Smrgdependency_libs='$dependency_libs' 10894a966c04fSmrg 108956e7d3316Smrg# Names of additional weak libraries provided by this library 108966e7d3316Smrgweak_library_names='$weak_libs' 10897a966c04fSmrg 108986e7d3316Smrg# Version information for $libname. 108996e7d3316Smrgcurrent=$current 109006e7d3316Smrgage=$age 109016e7d3316Smrgrevision=$revision 10902a966c04fSmrg 109036e7d3316Smrg# Is this an already installed library? 109046e7d3316Smrginstalled=$installed 10905a966c04fSmrg 109066e7d3316Smrg# Should we warn about portability when linking against -modules? 109076e7d3316Smrgshouldnotlink=$module 10908a966c04fSmrg 109096e7d3316Smrg# Files to dlopen/dlpreopen 109106e7d3316Smrgdlopen='$dlfiles' 109116e7d3316Smrgdlpreopen='$dlprefiles' 10912a966c04fSmrg 109136e7d3316Smrg# Directory that this library needs to be installed in: 109146e7d3316Smrglibdir='$install_libdir'" 10915edce3322Smrg if test no,yes = "$installed,$need_relink"; then 109166e7d3316Smrg $ECHO >> $output "\ 109176e7d3316Smrgrelink_command=\"$relink_command\"" 109186e7d3316Smrg fi 109196e7d3316Smrg done 109206e7d3316Smrg } 10921a966c04fSmrg 109226e7d3316Smrg # Do a symbolic link so that the libtool archive can be found in 109236e7d3316Smrg # LD_LIBRARY_PATH before the program is installed. 109246e7d3316Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 109256e7d3316Smrg ;; 109266e7d3316Smrg esac 109276e7d3316Smrg exit $EXIT_SUCCESS 109286e7d3316Smrg} 10929a966c04fSmrg 10930edce3322Smrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 10931edce3322Smrg func_mode_link ${1+"$@"} 10932edce3322Smrgfi 10933a966c04fSmrg 10934a966c04fSmrg 109356e7d3316Smrg# func_mode_uninstall arg... 109366e7d3316Smrgfunc_mode_uninstall () 109376e7d3316Smrg{ 10938edce3322Smrg $debug_cmd 10939edce3322Smrg 10940edce3322Smrg RM=$nonopt 10941a966c04fSmrg files= 10942edce3322Smrg rmforce=false 10943a966c04fSmrg exit_status=0 10944a966c04fSmrg 10945a966c04fSmrg # This variable tells wrapper scripts just to set variables rather 10946a966c04fSmrg # than running their programs. 10947edce3322Smrg libtool_install_magic=$magic 10948a966c04fSmrg 10949a966c04fSmrg for arg 10950a966c04fSmrg do 10951a966c04fSmrg case $arg in 10952edce3322Smrg -f) func_append RM " $arg"; rmforce=: ;; 1095397cf2ee2Smrg -*) func_append RM " $arg" ;; 1095497cf2ee2Smrg *) func_append files " $arg" ;; 10955a966c04fSmrg esac 10956a966c04fSmrg done 10957a966c04fSmrg 109586e7d3316Smrg test -z "$RM" && \ 109596e7d3316Smrg func_fatal_help "you must specify an RM program" 10960a966c04fSmrg 10961a966c04fSmrg rmdirs= 10962a966c04fSmrg 10963a966c04fSmrg for file in $files; do 109646e7d3316Smrg func_dirname "$file" "" "." 10965edce3322Smrg dir=$func_dirname_result 10966edce3322Smrg if test . = "$dir"; then 10967edce3322Smrg odir=$objdir 10968a966c04fSmrg else 10969edce3322Smrg odir=$dir/$objdir 10970a966c04fSmrg fi 109716e7d3316Smrg func_basename "$file" 10972edce3322Smrg name=$func_basename_result 10973edce3322Smrg test uninstall = "$opt_mode" && odir=$dir 10974a966c04fSmrg 1097597cf2ee2Smrg # Remember odir for removal later, being careful to avoid duplicates 10976edce3322Smrg if test clean = "$opt_mode"; then 10977a966c04fSmrg case " $rmdirs " in 1097897cf2ee2Smrg *" $odir "*) ;; 1097997cf2ee2Smrg *) func_append rmdirs " $odir" ;; 10980a966c04fSmrg esac 10981a966c04fSmrg fi 10982a966c04fSmrg 10983a966c04fSmrg # Don't error if the file doesn't exist and rm -f was used. 109846e7d3316Smrg if { test -L "$file"; } >/dev/null 2>&1 || 109856e7d3316Smrg { test -h "$file"; } >/dev/null 2>&1 || 109866e7d3316Smrg test -f "$file"; then 10987a966c04fSmrg : 10988a966c04fSmrg elif test -d "$file"; then 10989a966c04fSmrg exit_status=1 10990a966c04fSmrg continue 10991edce3322Smrg elif $rmforce; then 10992a966c04fSmrg continue 10993a966c04fSmrg fi 10994a966c04fSmrg 10995edce3322Smrg rmfiles=$file 10996a966c04fSmrg 10997a966c04fSmrg case $name in 10998a966c04fSmrg *.la) 10999a966c04fSmrg # Possibly a libtool archive, so verify it. 110006e7d3316Smrg if func_lalib_p "$file"; then 110016e7d3316Smrg func_source $dir/$name 11002a966c04fSmrg 11003a966c04fSmrg # Delete the libtool libraries and symlinks. 11004a966c04fSmrg for n in $library_names; do 1100597cf2ee2Smrg func_append rmfiles " $odir/$n" 11006a966c04fSmrg done 1100797cf2ee2Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008a966c04fSmrg 11009edce3322Smrg case $opt_mode in 11010a966c04fSmrg clean) 1101197cf2ee2Smrg case " $library_names " in 11012a966c04fSmrg *" $dlname "*) ;; 1101397cf2ee2Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014a966c04fSmrg esac 1101597cf2ee2Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016a966c04fSmrg ;; 11017a966c04fSmrg uninstall) 11018a966c04fSmrg if test -n "$library_names"; then 11019a966c04fSmrg # Do each command in the postuninstall commands. 11020edce3322Smrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021a966c04fSmrg fi 11022a966c04fSmrg 11023a966c04fSmrg if test -n "$old_library"; then 11024a966c04fSmrg # Do each command in the old_postuninstall commands. 11025edce3322Smrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026a966c04fSmrg fi 11027a966c04fSmrg # FIXME: should reinstall the best remaining shared library. 11028a966c04fSmrg ;; 11029a966c04fSmrg esac 11030a966c04fSmrg fi 11031a966c04fSmrg ;; 11032a966c04fSmrg 11033a966c04fSmrg *.lo) 11034a966c04fSmrg # Possibly a libtool object, so verify it. 110356e7d3316Smrg if func_lalib_p "$file"; then 11036a966c04fSmrg 11037a966c04fSmrg # Read the .lo file 110386e7d3316Smrg func_source $dir/$name 11039a966c04fSmrg 11040a966c04fSmrg # Add PIC object to the list of files to remove. 11041edce3322Smrg if test -n "$pic_object" && test none != "$pic_object"; then 1104297cf2ee2Smrg func_append rmfiles " $dir/$pic_object" 11043a966c04fSmrg fi 11044a966c04fSmrg 11045a966c04fSmrg # Add non-PIC object to the list of files to remove. 11046edce3322Smrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 1104797cf2ee2Smrg func_append rmfiles " $dir/$non_pic_object" 11048a966c04fSmrg fi 11049a966c04fSmrg fi 11050a966c04fSmrg ;; 11051a966c04fSmrg 11052a966c04fSmrg *) 11053edce3322Smrg if test clean = "$opt_mode"; then 11054a966c04fSmrg noexename=$name 11055a966c04fSmrg case $file in 11056a966c04fSmrg *.exe) 110576e7d3316Smrg func_stripname '' '.exe' "$file" 110586e7d3316Smrg file=$func_stripname_result 110596e7d3316Smrg func_stripname '' '.exe' "$name" 110606e7d3316Smrg noexename=$func_stripname_result 11061a966c04fSmrg # $file with .exe has already been added to rmfiles, 11062a966c04fSmrg # add $file without .exe 1106397cf2ee2Smrg func_append rmfiles " $file" 11064a966c04fSmrg ;; 11065a966c04fSmrg esac 11066a966c04fSmrg # Do a test to see if this is a libtool program. 110676e7d3316Smrg if func_ltwrapper_p "$file"; then 110686e7d3316Smrg if func_ltwrapper_executable_p "$file"; then 110696e7d3316Smrg func_ltwrapper_scriptname "$file" 110706e7d3316Smrg relink_command= 110716e7d3316Smrg func_source $func_ltwrapper_scriptname_result 1107297cf2ee2Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 110736e7d3316Smrg else 110746e7d3316Smrg relink_command= 110756e7d3316Smrg func_source $dir/$noexename 110766e7d3316Smrg fi 11077a966c04fSmrg 11078a966c04fSmrg # note $name still contains .exe if it was in $file originally 11079a966c04fSmrg # as does the version of $file that was added into $rmfiles 11080edce3322Smrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11081edce3322Smrg if test yes = "$fast_install" && test -n "$relink_command"; then 1108297cf2ee2Smrg func_append rmfiles " $odir/lt-$name" 11083a966c04fSmrg fi 11084edce3322Smrg if test "X$noexename" != "X$name"; then 11085edce3322Smrg func_append rmfiles " $odir/lt-$noexename.c" 11086a966c04fSmrg fi 11087a966c04fSmrg fi 11088a966c04fSmrg fi 11089a966c04fSmrg ;; 11090a966c04fSmrg esac 110916e7d3316Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11092a966c04fSmrg done 11093a966c04fSmrg 11094edce3322Smrg # Try to remove the $objdir's in the directories where we deleted files 11095a966c04fSmrg for dir in $rmdirs; do 11096a966c04fSmrg if test -d "$dir"; then 110976e7d3316Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11098a966c04fSmrg fi 11099a966c04fSmrg done 11100a966c04fSmrg 11101a966c04fSmrg exit $exit_status 111026e7d3316Smrg} 11103a966c04fSmrg 11104edce3322Smrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11105edce3322Smrg func_mode_uninstall ${1+"$@"} 11106edce3322Smrgfi 11107a966c04fSmrg 1110897cf2ee2Smrgtest -z "$opt_mode" && { 11109edce3322Smrg help=$generic_help 111106e7d3316Smrg func_fatal_help "you must specify a MODE" 111116e7d3316Smrg} 111126e7d3316Smrg 111136e7d3316Smrgtest -z "$exec_cmd" && \ 11114edce3322Smrg func_fatal_help "invalid operation mode '$opt_mode'" 11115a966c04fSmrg 11116a966c04fSmrgif test -n "$exec_cmd"; then 111176e7d3316Smrg eval exec "$exec_cmd" 11118a966c04fSmrg exit $EXIT_FAILURE 11119a966c04fSmrgfi 11120a966c04fSmrg 111216e7d3316Smrgexit $exit_status 11122a966c04fSmrg 11123a966c04fSmrg 11124a966c04fSmrg# The TAGs below are defined such that we never get into a situation 11125edce3322Smrg# where we disable both kinds of libraries. Given conflicting 11126a966c04fSmrg# choices, we go for a static library, that is the most portable, 11127a966c04fSmrg# since we can't tell whether shared libraries were disabled because 11128a966c04fSmrg# the user asked for that or because the platform doesn't support 11129a966c04fSmrg# them. This is particularly important on AIX, because we don't 11130a966c04fSmrg# support having both static and shared libraries enabled at the same 11131a966c04fSmrg# time on that platform, so we default to a shared-only configuration. 11132a966c04fSmrg# If a disable-shared tag is given, we'll fallback to a static-only 11133a966c04fSmrg# configuration. But we'll never go from static-only to shared-only. 11134a966c04fSmrg 11135a966c04fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 111366e7d3316Smrgbuild_libtool_libs=no 111376e7d3316Smrgbuild_old_libs=yes 11138a966c04fSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 11139a966c04fSmrg 11140a966c04fSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 111416e7d3316Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142a966c04fSmrg# ### END LIBTOOL TAG CONFIG: disable-static 11143a966c04fSmrg 11144a966c04fSmrg# Local Variables: 11145a966c04fSmrg# mode:shell-script 11146a966c04fSmrg# sh-indentation:2 11147a966c04fSmrg# End: 11148