ltmain.sh revision a4f78def
1a4f78defSmrg#! /bin/sh 2a4f78defSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3a4f78defSmrg## by inline-source v2014-01-03.01 4a4f78defSmrg 5a4f78defSmrg# libtool (GNU libtool) 2.4.6 6a4f78defSmrg# Provide generalized library-building support services. 7a4f78defSmrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 8a4f78defSmrg 9a4f78defSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 10a4f78defSmrg# This is free software; see the source for copying conditions. There is NO 11a4f78defSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12a4f78defSmrg 13a4f78defSmrg# GNU Libtool is free software; you can redistribute it and/or modify 14a4f78defSmrg# it under the terms of the GNU General Public License as published by 15a4f78defSmrg# the Free Software Foundation; either version 2 of the License, or 16a4f78defSmrg# (at your option) any later version. 17a4f78defSmrg# 18a4f78defSmrg# As a special exception to the GNU General Public License, 19a4f78defSmrg# if you distribute this file as part of a program or library that 20a4f78defSmrg# is built using GNU Libtool, you may include this file under the 21a4f78defSmrg# same distribution terms that you use for the rest of that program. 22a4f78defSmrg# 23a4f78defSmrg# GNU Libtool is distributed in the hope that it will be useful, but 24a4f78defSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25a4f78defSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26a4f78defSmrg# General Public License for more details. 27a4f78defSmrg# 28a4f78defSmrg# You should have received a copy of the GNU General Public License 29a4f78defSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 30a4f78defSmrg 31a4f78defSmrg 32a4f78defSmrgPROGRAM=libtool 33a4f78defSmrgPACKAGE=libtool 34a4f78defSmrgVERSION=2.4.6 35a4f78defSmrgpackage_revision=2.4.6 36a4f78defSmrg 37a4f78defSmrg 38a4f78defSmrg## ------ ## 39a4f78defSmrg## Usage. ## 40a4f78defSmrg## ------ ## 41a4f78defSmrg 42a4f78defSmrg# Run './libtool --help' for help with using this script from the 43a4f78defSmrg# command line. 44a4f78defSmrg 45a4f78defSmrg 46a4f78defSmrg## ------------------------------- ## 47a4f78defSmrg## User overridable command paths. ## 48a4f78defSmrg## ------------------------------- ## 49a4f78defSmrg 50a4f78defSmrg# After configure completes, it has a better idea of some of the 51a4f78defSmrg# shell tools we need than the defaults used by the functions shared 52a4f78defSmrg# with bootstrap, so set those here where they can still be over- 53a4f78defSmrg# ridden by the user, but otherwise take precedence. 54a4f78defSmrg 55a4f78defSmrg: ${AUTOCONF="autoconf"} 56a4f78defSmrg: ${AUTOMAKE="automake"} 57a4f78defSmrg 58a4f78defSmrg 59a4f78defSmrg## -------------------------- ## 60a4f78defSmrg## Source external libraries. ## 61a4f78defSmrg## -------------------------- ## 62a4f78defSmrg 63a4f78defSmrg# Much of our low-level functionality needs to be sourced from external 64a4f78defSmrg# libraries, which are installed to $pkgauxdir. 65a4f78defSmrg 66a4f78defSmrg# Set a version string for this script. 67a4f78defSmrgscriptversion=2015-01-20.17; # UTC 68a4f78defSmrg 69a4f78defSmrg# General shell script boiler plate, and helper functions. 70a4f78defSmrg# Written by Gary V. Vaughan, 2004 71a4f78defSmrg 72a4f78defSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73a4f78defSmrg# This is free software; see the source for copying conditions. There is NO 74a4f78defSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75a4f78defSmrg 76a4f78defSmrg# This program is free software; you can redistribute it and/or modify 77a4f78defSmrg# it under the terms of the GNU General Public License as published by 78a4f78defSmrg# the Free Software Foundation; either version 3 of the License, or 79a4f78defSmrg# (at your option) any later version. 80a4f78defSmrg 81a4f78defSmrg# As a special exception to the GNU General Public License, if you distribute 82a4f78defSmrg# this file as part of a program or library that is built using GNU Libtool, 83a4f78defSmrg# you may include this file under the same distribution terms that you use 84a4f78defSmrg# for the rest of that program. 85a4f78defSmrg 86a4f78defSmrg# This program is distributed in the hope that it will be useful, 87a4f78defSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 88a4f78defSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89a4f78defSmrg# General Public License for more details. 90a4f78defSmrg 91a4f78defSmrg# You should have received a copy of the GNU General Public License 92a4f78defSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 93a4f78defSmrg 94a4f78defSmrg# Please report bugs or propose patches to gary@gnu.org. 95a4f78defSmrg 96a4f78defSmrg 97a4f78defSmrg## ------ ## 98a4f78defSmrg## Usage. ## 99a4f78defSmrg## ------ ## 100a4f78defSmrg 101a4f78defSmrg# Evaluate this file near the top of your script to gain access to 102a4f78defSmrg# the functions and variables defined here: 103a4f78defSmrg# 104a4f78defSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105a4f78defSmrg# 106a4f78defSmrg# If you need to override any of the default environment variable 107a4f78defSmrg# settings, do that before evaluating this file. 108a4f78defSmrg 109a4f78defSmrg 110a4f78defSmrg## -------------------- ## 111a4f78defSmrg## Shell normalisation. ## 112a4f78defSmrg## -------------------- ## 113a4f78defSmrg 114a4f78defSmrg# Some shells need a little help to be as Bourne compatible as possible. 115a4f78defSmrg# Before doing anything else, make sure all that help has been provided! 116a4f78defSmrg 117a4f78defSmrgDUALCASE=1; export DUALCASE # for MKS sh 118a4f78defSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 119a4f78defSmrg emulate sh 120a4f78defSmrg NULLCMD=: 121a4f78defSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 122a4f78defSmrg # is contrary to our usage. Disable this feature. 123a4f78defSmrg alias -g '${1+"$@"}'='"$@"' 124a4f78defSmrg setopt NO_GLOB_SUBST 125a4f78defSmrgelse 126a4f78defSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 127a4f78defSmrgfi 128a4f78defSmrg 129a4f78defSmrg# NLS nuisances: We save the old values in case they are required later. 130a4f78defSmrg_G_user_locale= 131a4f78defSmrg_G_safe_locale= 132a4f78defSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 133a4f78defSmrgdo 134a4f78defSmrg eval "if test set = \"\${$_G_var+set}\"; then 135a4f78defSmrg save_$_G_var=\$$_G_var 136a4f78defSmrg $_G_var=C 137a4f78defSmrg export $_G_var 138a4f78defSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139a4f78defSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 140a4f78defSmrg fi" 141a4f78defSmrgdone 142a4f78defSmrg 143a4f78defSmrg# CDPATH. 144a4f78defSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 145a4f78defSmrg 146a4f78defSmrg# Make sure IFS has a sensible default 147a4f78defSmrgsp=' ' 148a4f78defSmrgnl=' 149a4f78defSmrg' 150a4f78defSmrgIFS="$sp $nl" 151a4f78defSmrg 152a4f78defSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 153a4f78defSmrgif test "${PATH_SEPARATOR+set}" != set; then 154a4f78defSmrg PATH_SEPARATOR=: 155a4f78defSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156a4f78defSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157a4f78defSmrg PATH_SEPARATOR=';' 158a4f78defSmrg } 159a4f78defSmrgfi 160a4f78defSmrg 161a4f78defSmrg 162a4f78defSmrg 163a4f78defSmrg## ------------------------- ## 164a4f78defSmrg## Locate command utilities. ## 165a4f78defSmrg## ------------------------- ## 166a4f78defSmrg 167a4f78defSmrg 168a4f78defSmrg# func_executable_p FILE 169a4f78defSmrg# ---------------------- 170a4f78defSmrg# Check that FILE is an executable regular file. 171a4f78defSmrgfunc_executable_p () 172a4f78defSmrg{ 173a4f78defSmrg test -f "$1" && test -x "$1" 174a4f78defSmrg} 175a4f78defSmrg 176a4f78defSmrg 177a4f78defSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178a4f78defSmrg# -------------------------------------------- 179a4f78defSmrg# Search for either a program that responds to --version with output 180a4f78defSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181a4f78defSmrg# trying all the directories in PATH with each of the elements of 182a4f78defSmrg# PROGS_LIST. 183a4f78defSmrg# 184a4f78defSmrg# CHECK_FUNC should accept the path to a candidate program, and 185a4f78defSmrg# set $func_check_prog_result if it truncates its output less than 186a4f78defSmrg# $_G_path_prog_max characters. 187a4f78defSmrgfunc_path_progs () 188a4f78defSmrg{ 189a4f78defSmrg _G_progs_list=$1 190a4f78defSmrg _G_check_func=$2 191a4f78defSmrg _G_PATH=${3-"$PATH"} 192a4f78defSmrg 193a4f78defSmrg _G_path_prog_max=0 194a4f78defSmrg _G_path_prog_found=false 195a4f78defSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196a4f78defSmrg for _G_dir in $_G_PATH; do 197a4f78defSmrg IFS=$_G_save_IFS 198a4f78defSmrg test -z "$_G_dir" && _G_dir=. 199a4f78defSmrg for _G_prog_name in $_G_progs_list; do 200a4f78defSmrg for _exeext in '' .EXE; do 201a4f78defSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202a4f78defSmrg func_executable_p "$_G_path_prog" || continue 203a4f78defSmrg case `"$_G_path_prog" --version 2>&1` in 204a4f78defSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205a4f78defSmrg *) $_G_check_func $_G_path_prog 206a4f78defSmrg func_path_progs_result=$func_check_prog_result 207a4f78defSmrg ;; 208a4f78defSmrg esac 209a4f78defSmrg $_G_path_prog_found && break 3 210a4f78defSmrg done 211a4f78defSmrg done 212a4f78defSmrg done 213a4f78defSmrg IFS=$_G_save_IFS 214a4f78defSmrg test -z "$func_path_progs_result" && { 215a4f78defSmrg echo "no acceptable sed could be found in \$PATH" >&2 216a4f78defSmrg exit 1 217a4f78defSmrg } 218a4f78defSmrg} 219a4f78defSmrg 220a4f78defSmrg 221a4f78defSmrg# We want to be able to use the functions in this file before configure 222a4f78defSmrg# has figured out where the best binaries are kept, which means we have 223a4f78defSmrg# to search for them ourselves - except when the results are already set 224a4f78defSmrg# where we skip the searches. 225a4f78defSmrg 226a4f78defSmrg# Unless the user overrides by setting SED, search the path for either GNU 227a4f78defSmrg# sed, or the sed that truncates its output the least. 228a4f78defSmrgtest -z "$SED" && { 229a4f78defSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230a4f78defSmrg for _G_i in 1 2 3 4 5 6 7; do 231a4f78defSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 232a4f78defSmrg done 233a4f78defSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234a4f78defSmrg _G_sed_script= 235a4f78defSmrg 236a4f78defSmrg func_check_prog_sed () 237a4f78defSmrg { 238a4f78defSmrg _G_path_prog=$1 239a4f78defSmrg 240a4f78defSmrg _G_count=0 241a4f78defSmrg printf 0123456789 >conftest.in 242a4f78defSmrg while : 243a4f78defSmrg do 244a4f78defSmrg cat conftest.in conftest.in >conftest.tmp 245a4f78defSmrg mv conftest.tmp conftest.in 246a4f78defSmrg cp conftest.in conftest.nl 247a4f78defSmrg echo '' >> conftest.nl 248a4f78defSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249a4f78defSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 250a4f78defSmrg _G_count=`expr $_G_count + 1` 251a4f78defSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 252a4f78defSmrg # Best one so far, save it but keep looking for a better one 253a4f78defSmrg func_check_prog_result=$_G_path_prog 254a4f78defSmrg _G_path_prog_max=$_G_count 255a4f78defSmrg fi 256a4f78defSmrg # 10*(2^10) chars as input seems more than enough 257a4f78defSmrg test 10 -lt "$_G_count" && break 258a4f78defSmrg done 259a4f78defSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 260a4f78defSmrg } 261a4f78defSmrg 262a4f78defSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263a4f78defSmrg rm -f conftest.sed 264a4f78defSmrg SED=$func_path_progs_result 265a4f78defSmrg} 266a4f78defSmrg 267a4f78defSmrg 268a4f78defSmrg# Unless the user overrides by setting GREP, search the path for either GNU 269a4f78defSmrg# grep, or the grep that truncates its output the least. 270a4f78defSmrgtest -z "$GREP" && { 271a4f78defSmrg func_check_prog_grep () 272a4f78defSmrg { 273a4f78defSmrg _G_path_prog=$1 274a4f78defSmrg 275a4f78defSmrg _G_count=0 276a4f78defSmrg _G_path_prog_max=0 277a4f78defSmrg printf 0123456789 >conftest.in 278a4f78defSmrg while : 279a4f78defSmrg do 280a4f78defSmrg cat conftest.in conftest.in >conftest.tmp 281a4f78defSmrg mv conftest.tmp conftest.in 282a4f78defSmrg cp conftest.in conftest.nl 283a4f78defSmrg echo 'GREP' >> conftest.nl 284a4f78defSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285a4f78defSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 286a4f78defSmrg _G_count=`expr $_G_count + 1` 287a4f78defSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 288a4f78defSmrg # Best one so far, save it but keep looking for a better one 289a4f78defSmrg func_check_prog_result=$_G_path_prog 290a4f78defSmrg _G_path_prog_max=$_G_count 291a4f78defSmrg fi 292a4f78defSmrg # 10*(2^10) chars as input seems more than enough 293a4f78defSmrg test 10 -lt "$_G_count" && break 294a4f78defSmrg done 295a4f78defSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 296a4f78defSmrg } 297a4f78defSmrg 298a4f78defSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299a4f78defSmrg GREP=$func_path_progs_result 300a4f78defSmrg} 301a4f78defSmrg 302a4f78defSmrg 303a4f78defSmrg## ------------------------------- ## 304a4f78defSmrg## User overridable command paths. ## 305a4f78defSmrg## ------------------------------- ## 306a4f78defSmrg 307a4f78defSmrg# All uppercase variable names are used for environment variables. These 308a4f78defSmrg# variables can be overridden by the user before calling a script that 309a4f78defSmrg# uses them if a suitable command of that name is not already available 310a4f78defSmrg# in the command search PATH. 311a4f78defSmrg 312a4f78defSmrg: ${CP="cp -f"} 313a4f78defSmrg: ${ECHO="printf %s\n"} 314a4f78defSmrg: ${EGREP="$GREP -E"} 315a4f78defSmrg: ${FGREP="$GREP -F"} 316a4f78defSmrg: ${LN_S="ln -s"} 317a4f78defSmrg: ${MAKE="make"} 318a4f78defSmrg: ${MKDIR="mkdir"} 319a4f78defSmrg: ${MV="mv -f"} 320a4f78defSmrg: ${RM="rm -f"} 321a4f78defSmrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 322a4f78defSmrg 323a4f78defSmrg 324a4f78defSmrg## -------------------- ## 325a4f78defSmrg## Useful sed snippets. ## 326a4f78defSmrg## -------------------- ## 327a4f78defSmrg 328a4f78defSmrgsed_dirname='s|/[^/]*$||' 329a4f78defSmrgsed_basename='s|^.*/||' 330a4f78defSmrg 331a4f78defSmrg# Sed substitution that helps us do robust quoting. It backslashifies 332a4f78defSmrg# metacharacters that are still active within double-quoted strings. 333a4f78defSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334a4f78defSmrg 335a4f78defSmrg# Same as above, but do not quote variable references. 336a4f78defSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337a4f78defSmrg 338a4f78defSmrg# Sed substitution that turns a string into a regex matching for the 339a4f78defSmrg# string literally. 340a4f78defSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341a4f78defSmrg 342a4f78defSmrg# Sed substitution that converts a w32 file name or path 343a4f78defSmrg# that contains forward slashes, into one that contains 344a4f78defSmrg# (escaped) backslashes. A very naive implementation. 345a4f78defSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346a4f78defSmrg 347a4f78defSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 348a4f78defSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 349a4f78defSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 350a4f78defSmrg# expansion. Since each input '\' is now two '\'s, look for any number 351a4f78defSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352a4f78defSmrg_G_bs='\\' 353a4f78defSmrg_G_bs2='\\\\' 354a4f78defSmrg_G_bs4='\\\\\\\\' 355a4f78defSmrg_G_dollar='\$' 356a4f78defSmrgsed_double_backslash="\ 357a4f78defSmrg s/$_G_bs4/&\\ 358a4f78defSmrg/g 359a4f78defSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 360a4f78defSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361a4f78defSmrg s/\n//g" 362a4f78defSmrg 363a4f78defSmrg 364a4f78defSmrg## ----------------- ## 365a4f78defSmrg## Global variables. ## 366a4f78defSmrg## ----------------- ## 367a4f78defSmrg 368a4f78defSmrg# Except for the global variables explicitly listed below, the following 369a4f78defSmrg# functions in the '^func_' namespace, and the '^require_' namespace 370a4f78defSmrg# variables initialised in the 'Resource management' section, sourcing 371a4f78defSmrg# this file will not pollute your global namespace with anything 372a4f78defSmrg# else. There's no portable way to scope variables in Bourne shell 373a4f78defSmrg# though, so actually running these functions will sometimes place 374a4f78defSmrg# results into a variable named after the function, and often use 375a4f78defSmrg# temporary variables in the '^_G_' namespace. If you are careful to 376a4f78defSmrg# avoid using those namespaces casually in your sourcing script, things 377a4f78defSmrg# should continue to work as you expect. And, of course, you can freely 378a4f78defSmrg# overwrite any of the functions or variables defined here before 379a4f78defSmrg# calling anything to customize them. 380a4f78defSmrg 381a4f78defSmrgEXIT_SUCCESS=0 382a4f78defSmrgEXIT_FAILURE=1 383a4f78defSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384a4f78defSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 385a4f78defSmrg 386a4f78defSmrg# Allow overriding, eg assuming that you follow the convention of 387a4f78defSmrg# putting '$debug_cmd' at the start of all your functions, you can get 388a4f78defSmrg# bash to show function call trace with: 389a4f78defSmrg# 390a4f78defSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391a4f78defSmrgdebug_cmd=${debug_cmd-":"} 392a4f78defSmrgexit_cmd=: 393a4f78defSmrg 394a4f78defSmrg# By convention, finish your script with: 395a4f78defSmrg# 396a4f78defSmrg# exit $exit_status 397a4f78defSmrg# 398a4f78defSmrg# so that you can set exit_status to non-zero if you want to indicate 399a4f78defSmrg# something went wrong during execution without actually bailing out at 400a4f78defSmrg# the point of failure. 401a4f78defSmrgexit_status=$EXIT_SUCCESS 402a4f78defSmrg 403a4f78defSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404a4f78defSmrg# is ksh but when the shell is invoked as "sh" and the current value of 405a4f78defSmrg# the _XPG environment variable is not equal to 1 (one), the special 406a4f78defSmrg# positional parameter $0, within a function call, is the name of the 407a4f78defSmrg# function. 408a4f78defSmrgprogpath=$0 409a4f78defSmrg 410a4f78defSmrg# The name of this program. 411a4f78defSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412a4f78defSmrg 413a4f78defSmrg# Make sure we have an absolute progpath for reexecution: 414a4f78defSmrgcase $progpath in 415a4f78defSmrg [\\/]*|[A-Za-z]:\\*) ;; 416a4f78defSmrg *[\\/]*) 417a4f78defSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 418a4f78defSmrg progdir=`cd "$progdir" && pwd` 419a4f78defSmrg progpath=$progdir/$progname 420a4f78defSmrg ;; 421a4f78defSmrg *) 422a4f78defSmrg _G_IFS=$IFS 423a4f78defSmrg IFS=${PATH_SEPARATOR-:} 424a4f78defSmrg for progdir in $PATH; do 425a4f78defSmrg IFS=$_G_IFS 426a4f78defSmrg test -x "$progdir/$progname" && break 427a4f78defSmrg done 428a4f78defSmrg IFS=$_G_IFS 429a4f78defSmrg test -n "$progdir" || progdir=`pwd` 430a4f78defSmrg progpath=$progdir/$progname 431a4f78defSmrg ;; 432a4f78defSmrgesac 433a4f78defSmrg 434a4f78defSmrg 435a4f78defSmrg## ----------------- ## 436a4f78defSmrg## Standard options. ## 437a4f78defSmrg## ----------------- ## 438a4f78defSmrg 439a4f78defSmrg# The following options affect the operation of the functions defined 440a4f78defSmrg# below, and should be set appropriately depending on run-time para- 441a4f78defSmrg# meters passed on the command line. 442a4f78defSmrg 443a4f78defSmrgopt_dry_run=false 444a4f78defSmrgopt_quiet=false 445a4f78defSmrgopt_verbose=false 446a4f78defSmrg 447a4f78defSmrg# Categories 'all' and 'none' are always available. Append any others 448a4f78defSmrg# you will pass as the first argument to func_warning from your own 449a4f78defSmrg# code. 450a4f78defSmrgwarning_categories= 451a4f78defSmrg 452a4f78defSmrg# By default, display warnings according to 'opt_warning_types'. Set 453a4f78defSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454a4f78defSmrg# treat the next displayed warning as a fatal error. 455a4f78defSmrgwarning_func=func_warn_and_continue 456a4f78defSmrg 457a4f78defSmrg# Set to 'all' to display all warnings, 'none' to suppress all 458a4f78defSmrg# warnings, or a space delimited list of some subset of 459a4f78defSmrg# 'warning_categories' to display only the listed warnings. 460a4f78defSmrgopt_warning_types=all 461a4f78defSmrg 462a4f78defSmrg 463a4f78defSmrg## -------------------- ## 464a4f78defSmrg## Resource management. ## 465a4f78defSmrg## -------------------- ## 466a4f78defSmrg 467a4f78defSmrg# This section contains definitions for functions that each ensure a 468a4f78defSmrg# particular resource (a file, or a non-empty configuration variable for 469a4f78defSmrg# example) is available, and if appropriate to extract default values 470a4f78defSmrg# from pertinent package files. Call them using their associated 471a4f78defSmrg# 'require_*' variable to ensure that they are executed, at most, once. 472a4f78defSmrg# 473a4f78defSmrg# It's entirely deliberate that calling these functions can set 474a4f78defSmrg# variables that don't obey the namespace limitations obeyed by the rest 475a4f78defSmrg# of this file, in order that that they be as useful as possible to 476a4f78defSmrg# callers. 477a4f78defSmrg 478a4f78defSmrg 479a4f78defSmrg# require_term_colors 480a4f78defSmrg# ------------------- 481a4f78defSmrg# Allow display of bold text on terminals that support it. 482a4f78defSmrgrequire_term_colors=func_require_term_colors 483a4f78defSmrgfunc_require_term_colors () 484a4f78defSmrg{ 485a4f78defSmrg $debug_cmd 486a4f78defSmrg 487a4f78defSmrg test -t 1 && { 488a4f78defSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 489a4f78defSmrg # precedence, because most terminfo databases neglect to describe 490a4f78defSmrg # whether color sequences are supported. 491a4f78defSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492a4f78defSmrg 493a4f78defSmrg if test 1 = "$USE_ANSI_COLORS"; then 494a4f78defSmrg # Standard ANSI escape sequences 495a4f78defSmrg tc_reset='[0m' 496a4f78defSmrg tc_bold='[1m'; tc_standout='[7m' 497a4f78defSmrg tc_red='[31m'; tc_green='[32m' 498a4f78defSmrg tc_blue='[34m'; tc_cyan='[36m' 499a4f78defSmrg else 500a4f78defSmrg # Otherwise trust the terminfo database after all. 501a4f78defSmrg test -n "`tput sgr0 2>/dev/null`" && { 502a4f78defSmrg tc_reset=`tput sgr0` 503a4f78defSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504a4f78defSmrg tc_standout=$tc_bold 505a4f78defSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506a4f78defSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507a4f78defSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508a4f78defSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509a4f78defSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510a4f78defSmrg } 511a4f78defSmrg fi 512a4f78defSmrg } 513a4f78defSmrg 514a4f78defSmrg require_term_colors=: 515a4f78defSmrg} 516a4f78defSmrg 517a4f78defSmrg 518a4f78defSmrg## ----------------- ## 519a4f78defSmrg## Function library. ## 520a4f78defSmrg## ----------------- ## 521a4f78defSmrg 522a4f78defSmrg# This section contains a variety of useful functions to call in your 523a4f78defSmrg# scripts. Take note of the portable wrappers for features provided by 524a4f78defSmrg# some modern shells, which will fall back to slower equivalents on 525a4f78defSmrg# less featureful shells. 526a4f78defSmrg 527a4f78defSmrg 528a4f78defSmrg# func_append VAR VALUE 529a4f78defSmrg# --------------------- 530a4f78defSmrg# Append VALUE onto the existing contents of VAR. 531a4f78defSmrg 532a4f78defSmrg # We should try to minimise forks, especially on Windows where they are 533a4f78defSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 534a4f78defSmrg # being used: 535a4f78defSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536a4f78defSmrg : ${_G_HAVE_ARITH_OP="yes"} 537a4f78defSmrg : ${_G_HAVE_XSI_OPS="yes"} 538a4f78defSmrg # The += operator was introduced in bash 3.1 539a4f78defSmrg case $BASH_VERSION in 540a4f78defSmrg [12].* | 3.0 | 3.0*) ;; 541a4f78defSmrg *) 542a4f78defSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 543a4f78defSmrg ;; 544a4f78defSmrg esac 545a4f78defSmrg fi 546a4f78defSmrg 547a4f78defSmrg # _G_HAVE_PLUSEQ_OP 548a4f78defSmrg # Can be empty, in which case the shell is probed, "yes" if += is 549a4f78defSmrg # useable or anything else if it does not work. 550a4f78defSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 551a4f78defSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552a4f78defSmrg && _G_HAVE_PLUSEQ_OP=yes 553a4f78defSmrg 554a4f78defSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 555a4f78defSmrgthen 556a4f78defSmrg # This is an XSI compatible shell, allowing a faster implementation... 557a4f78defSmrg eval 'func_append () 558a4f78defSmrg { 559a4f78defSmrg $debug_cmd 560a4f78defSmrg 561a4f78defSmrg eval "$1+=\$2" 562a4f78defSmrg }' 563a4f78defSmrgelse 564a4f78defSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 565a4f78defSmrg func_append () 566a4f78defSmrg { 567a4f78defSmrg $debug_cmd 568a4f78defSmrg 569a4f78defSmrg eval "$1=\$$1\$2" 570a4f78defSmrg } 571a4f78defSmrgfi 572a4f78defSmrg 573a4f78defSmrg 574a4f78defSmrg# func_append_quoted VAR VALUE 575a4f78defSmrg# ---------------------------- 576a4f78defSmrg# Quote VALUE and append to the end of shell variable VAR, separated 577a4f78defSmrg# by a space. 578a4f78defSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579a4f78defSmrg eval 'func_append_quoted () 580a4f78defSmrg { 581a4f78defSmrg $debug_cmd 582a4f78defSmrg 583a4f78defSmrg func_quote_for_eval "$2" 584a4f78defSmrg eval "$1+=\\ \$func_quote_for_eval_result" 585a4f78defSmrg }' 586a4f78defSmrgelse 587a4f78defSmrg func_append_quoted () 588a4f78defSmrg { 589a4f78defSmrg $debug_cmd 590a4f78defSmrg 591a4f78defSmrg func_quote_for_eval "$2" 592a4f78defSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 593a4f78defSmrg } 594a4f78defSmrgfi 595a4f78defSmrg 596a4f78defSmrg 597a4f78defSmrg# func_append_uniq VAR VALUE 598a4f78defSmrg# -------------------------- 599a4f78defSmrg# Append unique VALUE onto the existing contents of VAR, assuming 600a4f78defSmrg# entries are delimited by the first character of VALUE. For example: 601a4f78defSmrg# 602a4f78defSmrg# func_append_uniq options " --another-option option-argument" 603a4f78defSmrg# 604a4f78defSmrg# will only append to $options if " --another-option option-argument " 605a4f78defSmrg# is not already present somewhere in $options already (note spaces at 606a4f78defSmrg# each end implied by leading space in second argument). 607a4f78defSmrgfunc_append_uniq () 608a4f78defSmrg{ 609a4f78defSmrg $debug_cmd 610a4f78defSmrg 611a4f78defSmrg eval _G_current_value='`$ECHO $'$1'`' 612a4f78defSmrg _G_delim=`expr "$2" : '\(.\)'` 613a4f78defSmrg 614a4f78defSmrg case $_G_delim$_G_current_value$_G_delim in 615a4f78defSmrg *"$2$_G_delim"*) ;; 616a4f78defSmrg *) func_append "$@" ;; 617a4f78defSmrg esac 618a4f78defSmrg} 619a4f78defSmrg 620a4f78defSmrg 621a4f78defSmrg# func_arith TERM... 622a4f78defSmrg# ------------------ 623a4f78defSmrg# Set func_arith_result to the result of evaluating TERMs. 624a4f78defSmrg test -z "$_G_HAVE_ARITH_OP" \ 625a4f78defSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626a4f78defSmrg && _G_HAVE_ARITH_OP=yes 627a4f78defSmrg 628a4f78defSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 629a4f78defSmrg eval 'func_arith () 630a4f78defSmrg { 631a4f78defSmrg $debug_cmd 632a4f78defSmrg 633a4f78defSmrg func_arith_result=$(( $* )) 634a4f78defSmrg }' 635a4f78defSmrgelse 636a4f78defSmrg func_arith () 637a4f78defSmrg { 638a4f78defSmrg $debug_cmd 639a4f78defSmrg 640a4f78defSmrg func_arith_result=`expr "$@"` 641a4f78defSmrg } 642a4f78defSmrgfi 643a4f78defSmrg 644a4f78defSmrg 645a4f78defSmrg# func_basename FILE 646a4f78defSmrg# ------------------ 647a4f78defSmrg# Set func_basename_result to FILE with everything up to and including 648a4f78defSmrg# the last / stripped. 649a4f78defSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 650a4f78defSmrg # If this shell supports suffix pattern removal, then use it to avoid 651a4f78defSmrg # forking. Hide the definitions single quotes in case the shell chokes 652a4f78defSmrg # on unsupported syntax... 653a4f78defSmrg _b='func_basename_result=${1##*/}' 654a4f78defSmrg _d='case $1 in 655a4f78defSmrg */*) func_dirname_result=${1%/*}$2 ;; 656a4f78defSmrg * ) func_dirname_result=$3 ;; 657a4f78defSmrg esac' 658a4f78defSmrg 659a4f78defSmrgelse 660a4f78defSmrg # ...otherwise fall back to using sed. 661a4f78defSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662a4f78defSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663a4f78defSmrg if test "X$func_dirname_result" = "X$1"; then 664a4f78defSmrg func_dirname_result=$3 665a4f78defSmrg else 666a4f78defSmrg func_append func_dirname_result "$2" 667a4f78defSmrg fi' 668a4f78defSmrgfi 669a4f78defSmrg 670a4f78defSmrgeval 'func_basename () 671a4f78defSmrg{ 672a4f78defSmrg $debug_cmd 673a4f78defSmrg 674a4f78defSmrg '"$_b"' 675a4f78defSmrg}' 676a4f78defSmrg 677a4f78defSmrg 678a4f78defSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 679a4f78defSmrg# ------------------------------------------- 680a4f78defSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681a4f78defSmrg# otherwise set result to NONDIR_REPLACEMENT. 682a4f78defSmrgeval 'func_dirname () 683a4f78defSmrg{ 684a4f78defSmrg $debug_cmd 685a4f78defSmrg 686a4f78defSmrg '"$_d"' 687a4f78defSmrg}' 688a4f78defSmrg 689a4f78defSmrg 690a4f78defSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691a4f78defSmrg# -------------------------------------------------------- 692a4f78defSmrg# Perform func_basename and func_dirname in a single function 693a4f78defSmrg# call: 694a4f78defSmrg# dirname: Compute the dirname of FILE. If nonempty, 695a4f78defSmrg# add APPEND to the result, otherwise set result 696a4f78defSmrg# to NONDIR_REPLACEMENT. 697a4f78defSmrg# value returned in "$func_dirname_result" 698a4f78defSmrg# basename: Compute filename of FILE. 699a4f78defSmrg# value retuned in "$func_basename_result" 700a4f78defSmrg# For efficiency, we do not delegate to the functions above but instead 701a4f78defSmrg# duplicate the functionality here. 702a4f78defSmrgeval 'func_dirname_and_basename () 703a4f78defSmrg{ 704a4f78defSmrg $debug_cmd 705a4f78defSmrg 706a4f78defSmrg '"$_b"' 707a4f78defSmrg '"$_d"' 708a4f78defSmrg}' 709a4f78defSmrg 710a4f78defSmrg 711a4f78defSmrg# func_echo ARG... 712a4f78defSmrg# ---------------- 713a4f78defSmrg# Echo program name prefixed message. 714a4f78defSmrgfunc_echo () 715a4f78defSmrg{ 716a4f78defSmrg $debug_cmd 717a4f78defSmrg 718a4f78defSmrg _G_message=$* 719a4f78defSmrg 720a4f78defSmrg func_echo_IFS=$IFS 721a4f78defSmrg IFS=$nl 722a4f78defSmrg for _G_line in $_G_message; do 723a4f78defSmrg IFS=$func_echo_IFS 724a4f78defSmrg $ECHO "$progname: $_G_line" 725a4f78defSmrg done 726a4f78defSmrg IFS=$func_echo_IFS 727a4f78defSmrg} 728a4f78defSmrg 729a4f78defSmrg 730a4f78defSmrg# func_echo_all ARG... 731a4f78defSmrg# -------------------- 732a4f78defSmrg# Invoke $ECHO with all args, space-separated. 733a4f78defSmrgfunc_echo_all () 734a4f78defSmrg{ 735a4f78defSmrg $ECHO "$*" 736a4f78defSmrg} 737a4f78defSmrg 738a4f78defSmrg 739a4f78defSmrg# func_echo_infix_1 INFIX ARG... 740a4f78defSmrg# ------------------------------ 741a4f78defSmrg# Echo program name, followed by INFIX on the first line, with any 742a4f78defSmrg# additional lines not showing INFIX. 743a4f78defSmrgfunc_echo_infix_1 () 744a4f78defSmrg{ 745a4f78defSmrg $debug_cmd 746a4f78defSmrg 747a4f78defSmrg $require_term_colors 748a4f78defSmrg 749a4f78defSmrg _G_infix=$1; shift 750a4f78defSmrg _G_indent=$_G_infix 751a4f78defSmrg _G_prefix="$progname: $_G_infix: " 752a4f78defSmrg _G_message=$* 753a4f78defSmrg 754a4f78defSmrg # Strip color escape sequences before counting printable length 755a4f78defSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756a4f78defSmrg do 757a4f78defSmrg test -n "$_G_tc" && { 758a4f78defSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759a4f78defSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760a4f78defSmrg } 761a4f78defSmrg done 762a4f78defSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763a4f78defSmrg 764a4f78defSmrg func_echo_infix_1_IFS=$IFS 765a4f78defSmrg IFS=$nl 766a4f78defSmrg for _G_line in $_G_message; do 767a4f78defSmrg IFS=$func_echo_infix_1_IFS 768a4f78defSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769a4f78defSmrg _G_prefix=$_G_indent 770a4f78defSmrg done 771a4f78defSmrg IFS=$func_echo_infix_1_IFS 772a4f78defSmrg} 773a4f78defSmrg 774a4f78defSmrg 775a4f78defSmrg# func_error ARG... 776a4f78defSmrg# ----------------- 777a4f78defSmrg# Echo program name prefixed message to standard error. 778a4f78defSmrgfunc_error () 779a4f78defSmrg{ 780a4f78defSmrg $debug_cmd 781a4f78defSmrg 782a4f78defSmrg $require_term_colors 783a4f78defSmrg 784a4f78defSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785a4f78defSmrg} 786a4f78defSmrg 787a4f78defSmrg 788a4f78defSmrg# func_fatal_error ARG... 789a4f78defSmrg# ----------------------- 790a4f78defSmrg# Echo program name prefixed message to standard error, and exit. 791a4f78defSmrgfunc_fatal_error () 792a4f78defSmrg{ 793a4f78defSmrg $debug_cmd 794a4f78defSmrg 795a4f78defSmrg func_error "$*" 796a4f78defSmrg exit $EXIT_FAILURE 797a4f78defSmrg} 798a4f78defSmrg 799a4f78defSmrg 800a4f78defSmrg# func_grep EXPRESSION FILENAME 801a4f78defSmrg# ----------------------------- 802a4f78defSmrg# Check whether EXPRESSION matches any line of FILENAME, without output. 803a4f78defSmrgfunc_grep () 804a4f78defSmrg{ 805a4f78defSmrg $debug_cmd 806a4f78defSmrg 807a4f78defSmrg $GREP "$1" "$2" >/dev/null 2>&1 808a4f78defSmrg} 809a4f78defSmrg 810a4f78defSmrg 811a4f78defSmrg# func_len STRING 812a4f78defSmrg# --------------- 813a4f78defSmrg# Set func_len_result to the length of STRING. STRING may not 814a4f78defSmrg# start with a hyphen. 815a4f78defSmrg test -z "$_G_HAVE_XSI_OPS" \ 816a4f78defSmrg && (eval 'x=a/b/c; 817a4f78defSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818a4f78defSmrg && _G_HAVE_XSI_OPS=yes 819a4f78defSmrg 820a4f78defSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 821a4f78defSmrg eval 'func_len () 822a4f78defSmrg { 823a4f78defSmrg $debug_cmd 824a4f78defSmrg 825a4f78defSmrg func_len_result=${#1} 826a4f78defSmrg }' 827a4f78defSmrgelse 828a4f78defSmrg func_len () 829a4f78defSmrg { 830a4f78defSmrg $debug_cmd 831a4f78defSmrg 832a4f78defSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833a4f78defSmrg } 834a4f78defSmrgfi 835a4f78defSmrg 836a4f78defSmrg 837a4f78defSmrg# func_mkdir_p DIRECTORY-PATH 838a4f78defSmrg# --------------------------- 839a4f78defSmrg# Make sure the entire path to DIRECTORY-PATH is available. 840a4f78defSmrgfunc_mkdir_p () 841a4f78defSmrg{ 842a4f78defSmrg $debug_cmd 843a4f78defSmrg 844a4f78defSmrg _G_directory_path=$1 845a4f78defSmrg _G_dir_list= 846a4f78defSmrg 847a4f78defSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 848a4f78defSmrg 849a4f78defSmrg # Protect directory names starting with '-' 850a4f78defSmrg case $_G_directory_path in 851a4f78defSmrg -*) _G_directory_path=./$_G_directory_path ;; 852a4f78defSmrg esac 853a4f78defSmrg 854a4f78defSmrg # While some portion of DIR does not yet exist... 855a4f78defSmrg while test ! -d "$_G_directory_path"; do 856a4f78defSmrg # ...make a list in topmost first order. Use a colon delimited 857a4f78defSmrg # list incase some portion of path contains whitespace. 858a4f78defSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 859a4f78defSmrg 860a4f78defSmrg # If the last portion added has no slash in it, the list is done 861a4f78defSmrg case $_G_directory_path in */*) ;; *) break ;; esac 862a4f78defSmrg 863a4f78defSmrg # ...otherwise throw away the child directory and loop 864a4f78defSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 865a4f78defSmrg done 866a4f78defSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 867a4f78defSmrg 868a4f78defSmrg func_mkdir_p_IFS=$IFS; IFS=: 869a4f78defSmrg for _G_dir in $_G_dir_list; do 870a4f78defSmrg IFS=$func_mkdir_p_IFS 871a4f78defSmrg # mkdir can fail with a 'File exist' error if two processes 872a4f78defSmrg # try to create one of the directories concurrently. Don't 873a4f78defSmrg # stop in that case! 874a4f78defSmrg $MKDIR "$_G_dir" 2>/dev/null || : 875a4f78defSmrg done 876a4f78defSmrg IFS=$func_mkdir_p_IFS 877a4f78defSmrg 878a4f78defSmrg # Bail out if we (or some other process) failed to create a directory. 879a4f78defSmrg test -d "$_G_directory_path" || \ 880a4f78defSmrg func_fatal_error "Failed to create '$1'" 881a4f78defSmrg fi 882a4f78defSmrg} 883a4f78defSmrg 884a4f78defSmrg 885a4f78defSmrg# func_mktempdir [BASENAME] 886a4f78defSmrg# ------------------------- 887a4f78defSmrg# Make a temporary directory that won't clash with other running 888a4f78defSmrg# libtool processes, and avoids race conditions if possible. If 889a4f78defSmrg# given, BASENAME is the basename for that directory. 890a4f78defSmrgfunc_mktempdir () 891a4f78defSmrg{ 892a4f78defSmrg $debug_cmd 893a4f78defSmrg 894a4f78defSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895a4f78defSmrg 896a4f78defSmrg if test : = "$opt_dry_run"; then 897a4f78defSmrg # Return a directory name, but don't create it in dry-run mode 898a4f78defSmrg _G_tmpdir=$_G_template-$$ 899a4f78defSmrg else 900a4f78defSmrg 901a4f78defSmrg # If mktemp works, use that first and foremost 902a4f78defSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903a4f78defSmrg 904a4f78defSmrg if test ! -d "$_G_tmpdir"; then 905a4f78defSmrg # Failing that, at least try and use $RANDOM to avoid a race 906a4f78defSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907a4f78defSmrg 908a4f78defSmrg func_mktempdir_umask=`umask` 909a4f78defSmrg umask 0077 910a4f78defSmrg $MKDIR "$_G_tmpdir" 911a4f78defSmrg umask $func_mktempdir_umask 912a4f78defSmrg fi 913a4f78defSmrg 914a4f78defSmrg # If we're not in dry-run mode, bomb out on failure 915a4f78defSmrg test -d "$_G_tmpdir" || \ 916a4f78defSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917a4f78defSmrg fi 918a4f78defSmrg 919a4f78defSmrg $ECHO "$_G_tmpdir" 920a4f78defSmrg} 921a4f78defSmrg 922a4f78defSmrg 923a4f78defSmrg# func_normal_abspath PATH 924a4f78defSmrg# ------------------------ 925a4f78defSmrg# Remove doubled-up and trailing slashes, "." path components, 926a4f78defSmrg# and cancel out any ".." path components in PATH after making 927a4f78defSmrg# it an absolute path. 928a4f78defSmrgfunc_normal_abspath () 929a4f78defSmrg{ 930a4f78defSmrg $debug_cmd 931a4f78defSmrg 932a4f78defSmrg # These SED scripts presuppose an absolute path with a trailing slash. 933a4f78defSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 934a4f78defSmrg _G_pathcdr='s|^/[^/]*||' 935a4f78defSmrg _G_removedotparts=':dotsl 936a4f78defSmrg s|/\./|/|g 937a4f78defSmrg t dotsl 938a4f78defSmrg s|/\.$|/|' 939a4f78defSmrg _G_collapseslashes='s|/\{1,\}|/|g' 940a4f78defSmrg _G_finalslash='s|/*$|/|' 941a4f78defSmrg 942a4f78defSmrg # Start from root dir and reassemble the path. 943a4f78defSmrg func_normal_abspath_result= 944a4f78defSmrg func_normal_abspath_tpath=$1 945a4f78defSmrg func_normal_abspath_altnamespace= 946a4f78defSmrg case $func_normal_abspath_tpath in 947a4f78defSmrg "") 948a4f78defSmrg # Empty path, that just means $cwd. 949a4f78defSmrg func_stripname '' '/' "`pwd`" 950a4f78defSmrg func_normal_abspath_result=$func_stripname_result 951a4f78defSmrg return 952a4f78defSmrg ;; 953a4f78defSmrg # The next three entries are used to spot a run of precisely 954a4f78defSmrg # two leading slashes without using negated character classes; 955a4f78defSmrg # we take advantage of case's first-match behaviour. 956a4f78defSmrg ///*) 957a4f78defSmrg # Unusual form of absolute path, do nothing. 958a4f78defSmrg ;; 959a4f78defSmrg //*) 960a4f78defSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 961a4f78defSmrg # and for example Cygwin uses it to access remote file shares 962a4f78defSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 963a4f78defSmrg func_normal_abspath_altnamespace=/ 964a4f78defSmrg ;; 965a4f78defSmrg /*) 966a4f78defSmrg # Absolute path, do nothing. 967a4f78defSmrg ;; 968a4f78defSmrg *) 969a4f78defSmrg # Relative path, prepend $cwd. 970a4f78defSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971a4f78defSmrg ;; 972a4f78defSmrg esac 973a4f78defSmrg 974a4f78defSmrg # Cancel out all the simple stuff to save iterations. We also want 975a4f78defSmrg # the path to end with a slash for ease of parsing, so make sure 976a4f78defSmrg # there is one (and only one) here. 977a4f78defSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978a4f78defSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979a4f78defSmrg while :; do 980a4f78defSmrg # Processed it all yet? 981a4f78defSmrg if test / = "$func_normal_abspath_tpath"; then 982a4f78defSmrg # If we ascended to the root using ".." the result may be empty now. 983a4f78defSmrg if test -z "$func_normal_abspath_result"; then 984a4f78defSmrg func_normal_abspath_result=/ 985a4f78defSmrg fi 986a4f78defSmrg break 987a4f78defSmrg fi 988a4f78defSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989a4f78defSmrg -e "$_G_pathcar"` 990a4f78defSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991a4f78defSmrg -e "$_G_pathcdr"` 992a4f78defSmrg # Figure out what to do with it 993a4f78defSmrg case $func_normal_abspath_tcomponent in 994a4f78defSmrg "") 995a4f78defSmrg # Trailing empty path component, ignore it. 996a4f78defSmrg ;; 997a4f78defSmrg ..) 998a4f78defSmrg # Parent dir; strip last assembled component from result. 999a4f78defSmrg func_dirname "$func_normal_abspath_result" 1000a4f78defSmrg func_normal_abspath_result=$func_dirname_result 1001a4f78defSmrg ;; 1002a4f78defSmrg *) 1003a4f78defSmrg # Actual path component, append it. 1004a4f78defSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005a4f78defSmrg ;; 1006a4f78defSmrg esac 1007a4f78defSmrg done 1008a4f78defSmrg # Restore leading double-slash if one was found on entry. 1009a4f78defSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010a4f78defSmrg} 1011a4f78defSmrg 1012a4f78defSmrg 1013a4f78defSmrg# func_notquiet ARG... 1014a4f78defSmrg# -------------------- 1015a4f78defSmrg# Echo program name prefixed message only when not in quiet mode. 1016a4f78defSmrgfunc_notquiet () 1017a4f78defSmrg{ 1018a4f78defSmrg $debug_cmd 1019a4f78defSmrg 1020a4f78defSmrg $opt_quiet || func_echo ${1+"$@"} 1021a4f78defSmrg 1022a4f78defSmrg # A bug in bash halts the script if the last line of a function 1023a4f78defSmrg # fails when set -e is in force, so we need another command to 1024a4f78defSmrg # work around that: 1025a4f78defSmrg : 1026a4f78defSmrg} 1027a4f78defSmrg 1028a4f78defSmrg 1029a4f78defSmrg# func_relative_path SRCDIR DSTDIR 1030a4f78defSmrg# -------------------------------- 1031a4f78defSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032a4f78defSmrgfunc_relative_path () 1033a4f78defSmrg{ 1034a4f78defSmrg $debug_cmd 1035a4f78defSmrg 1036a4f78defSmrg func_relative_path_result= 1037a4f78defSmrg func_normal_abspath "$1" 1038a4f78defSmrg func_relative_path_tlibdir=$func_normal_abspath_result 1039a4f78defSmrg func_normal_abspath "$2" 1040a4f78defSmrg func_relative_path_tbindir=$func_normal_abspath_result 1041a4f78defSmrg 1042a4f78defSmrg # Ascend the tree starting from libdir 1043a4f78defSmrg while :; do 1044a4f78defSmrg # check if we have found a prefix of bindir 1045a4f78defSmrg case $func_relative_path_tbindir in 1046a4f78defSmrg $func_relative_path_tlibdir) 1047a4f78defSmrg # found an exact match 1048a4f78defSmrg func_relative_path_tcancelled= 1049a4f78defSmrg break 1050a4f78defSmrg ;; 1051a4f78defSmrg $func_relative_path_tlibdir*) 1052a4f78defSmrg # found a matching prefix 1053a4f78defSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054a4f78defSmrg func_relative_path_tcancelled=$func_stripname_result 1055a4f78defSmrg if test -z "$func_relative_path_result"; then 1056a4f78defSmrg func_relative_path_result=. 1057a4f78defSmrg fi 1058a4f78defSmrg break 1059a4f78defSmrg ;; 1060a4f78defSmrg *) 1061a4f78defSmrg func_dirname $func_relative_path_tlibdir 1062a4f78defSmrg func_relative_path_tlibdir=$func_dirname_result 1063a4f78defSmrg if test -z "$func_relative_path_tlibdir"; then 1064a4f78defSmrg # Have to descend all the way to the root! 1065a4f78defSmrg func_relative_path_result=../$func_relative_path_result 1066a4f78defSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 1067a4f78defSmrg break 1068a4f78defSmrg fi 1069a4f78defSmrg func_relative_path_result=../$func_relative_path_result 1070a4f78defSmrg ;; 1071a4f78defSmrg esac 1072a4f78defSmrg done 1073a4f78defSmrg 1074a4f78defSmrg # Now calculate path; take care to avoid doubling-up slashes. 1075a4f78defSmrg func_stripname '' '/' "$func_relative_path_result" 1076a4f78defSmrg func_relative_path_result=$func_stripname_result 1077a4f78defSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1078a4f78defSmrg if test -n "$func_stripname_result"; then 1079a4f78defSmrg func_append func_relative_path_result "/$func_stripname_result" 1080a4f78defSmrg fi 1081a4f78defSmrg 1082a4f78defSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 1083a4f78defSmrg if test -n "$func_relative_path_result"; then 1084a4f78defSmrg func_stripname './' '' "$func_relative_path_result" 1085a4f78defSmrg func_relative_path_result=$func_stripname_result 1086a4f78defSmrg fi 1087a4f78defSmrg 1088a4f78defSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 1089a4f78defSmrg 1090a4f78defSmrg : 1091a4f78defSmrg} 1092a4f78defSmrg 1093a4f78defSmrg 1094a4f78defSmrg# func_quote_for_eval ARG... 1095a4f78defSmrg# -------------------------- 1096a4f78defSmrg# Aesthetically quote ARGs to be evaled later. 1097a4f78defSmrg# This function returns two values: 1098a4f78defSmrg# i) func_quote_for_eval_result 1099a4f78defSmrg# double-quoted, suitable for a subsequent eval 1100a4f78defSmrg# ii) func_quote_for_eval_unquoted_result 1101a4f78defSmrg# has all characters that are still active within double 1102a4f78defSmrg# quotes backslashified. 1103a4f78defSmrgfunc_quote_for_eval () 1104a4f78defSmrg{ 1105a4f78defSmrg $debug_cmd 1106a4f78defSmrg 1107a4f78defSmrg func_quote_for_eval_unquoted_result= 1108a4f78defSmrg func_quote_for_eval_result= 1109a4f78defSmrg while test 0 -lt $#; do 1110a4f78defSmrg case $1 in 1111a4f78defSmrg *[\\\`\"\$]*) 1112a4f78defSmrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113a4f78defSmrg *) 1114a4f78defSmrg _G_unquoted_arg=$1 ;; 1115a4f78defSmrg esac 1116a4f78defSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 1117a4f78defSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118a4f78defSmrg else 1119a4f78defSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120a4f78defSmrg fi 1121a4f78defSmrg 1122a4f78defSmrg case $_G_unquoted_arg in 1123a4f78defSmrg # Double-quote args containing shell metacharacters to delay 1124a4f78defSmrg # word splitting, command substitution and variable expansion 1125a4f78defSmrg # for a subsequent eval. 1126a4f78defSmrg # Many Bourne shells cannot handle close brackets correctly 1127a4f78defSmrg # in scan sets, so we specify it separately. 1128a4f78defSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129a4f78defSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 1130a4f78defSmrg ;; 1131a4f78defSmrg *) 1132a4f78defSmrg _G_quoted_arg=$_G_unquoted_arg 1133a4f78defSmrg ;; 1134a4f78defSmrg esac 1135a4f78defSmrg 1136a4f78defSmrg if test -n "$func_quote_for_eval_result"; then 1137a4f78defSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 1138a4f78defSmrg else 1139a4f78defSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 1140a4f78defSmrg fi 1141a4f78defSmrg shift 1142a4f78defSmrg done 1143a4f78defSmrg} 1144a4f78defSmrg 1145a4f78defSmrg 1146a4f78defSmrg# func_quote_for_expand ARG 1147a4f78defSmrg# ------------------------- 1148a4f78defSmrg# Aesthetically quote ARG to be evaled later; same as above, 1149a4f78defSmrg# but do not quote variable references. 1150a4f78defSmrgfunc_quote_for_expand () 1151a4f78defSmrg{ 1152a4f78defSmrg $debug_cmd 1153a4f78defSmrg 1154a4f78defSmrg case $1 in 1155a4f78defSmrg *[\\\`\"]*) 1156a4f78defSmrg _G_arg=`$ECHO "$1" | $SED \ 1157a4f78defSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 1158a4f78defSmrg *) 1159a4f78defSmrg _G_arg=$1 ;; 1160a4f78defSmrg esac 1161a4f78defSmrg 1162a4f78defSmrg case $_G_arg in 1163a4f78defSmrg # Double-quote args containing shell metacharacters to delay 1164a4f78defSmrg # word splitting and command substitution for a subsequent eval. 1165a4f78defSmrg # Many Bourne shells cannot handle close brackets correctly 1166a4f78defSmrg # in scan sets, so we specify it separately. 1167a4f78defSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168a4f78defSmrg _G_arg=\"$_G_arg\" 1169a4f78defSmrg ;; 1170a4f78defSmrg esac 1171a4f78defSmrg 1172a4f78defSmrg func_quote_for_expand_result=$_G_arg 1173a4f78defSmrg} 1174a4f78defSmrg 1175a4f78defSmrg 1176a4f78defSmrg# func_stripname PREFIX SUFFIX NAME 1177a4f78defSmrg# --------------------------------- 1178a4f78defSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179a4f78defSmrg# PREFIX and SUFFIX must not contain globbing or regex special 1180a4f78defSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1181a4f78defSmrg# dot (in which case that matches only a dot). 1182a4f78defSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 1183a4f78defSmrg eval 'func_stripname () 1184a4f78defSmrg { 1185a4f78defSmrg $debug_cmd 1186a4f78defSmrg 1187a4f78defSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188a4f78defSmrg # positional parameters, so assign one to ordinary variable first. 1189a4f78defSmrg func_stripname_result=$3 1190a4f78defSmrg func_stripname_result=${func_stripname_result#"$1"} 1191a4f78defSmrg func_stripname_result=${func_stripname_result%"$2"} 1192a4f78defSmrg }' 1193a4f78defSmrgelse 1194a4f78defSmrg func_stripname () 1195a4f78defSmrg { 1196a4f78defSmrg $debug_cmd 1197a4f78defSmrg 1198a4f78defSmrg case $2 in 1199a4f78defSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200a4f78defSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201a4f78defSmrg esac 1202a4f78defSmrg } 1203a4f78defSmrgfi 1204a4f78defSmrg 1205a4f78defSmrg 1206a4f78defSmrg# func_show_eval CMD [FAIL_EXP] 1207a4f78defSmrg# ----------------------------- 1208a4f78defSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209a4f78defSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210a4f78defSmrg# is given, then evaluate it. 1211a4f78defSmrgfunc_show_eval () 1212a4f78defSmrg{ 1213a4f78defSmrg $debug_cmd 1214a4f78defSmrg 1215a4f78defSmrg _G_cmd=$1 1216a4f78defSmrg _G_fail_exp=${2-':'} 1217a4f78defSmrg 1218a4f78defSmrg func_quote_for_expand "$_G_cmd" 1219a4f78defSmrg eval "func_notquiet $func_quote_for_expand_result" 1220a4f78defSmrg 1221a4f78defSmrg $opt_dry_run || { 1222a4f78defSmrg eval "$_G_cmd" 1223a4f78defSmrg _G_status=$? 1224a4f78defSmrg if test 0 -ne "$_G_status"; then 1225a4f78defSmrg eval "(exit $_G_status); $_G_fail_exp" 1226a4f78defSmrg fi 1227a4f78defSmrg } 1228a4f78defSmrg} 1229a4f78defSmrg 1230a4f78defSmrg 1231a4f78defSmrg# func_show_eval_locale CMD [FAIL_EXP] 1232a4f78defSmrg# ------------------------------------ 1233a4f78defSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234a4f78defSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235a4f78defSmrg# is given, then evaluate it. Use the saved locale for evaluation. 1236a4f78defSmrgfunc_show_eval_locale () 1237a4f78defSmrg{ 1238a4f78defSmrg $debug_cmd 1239a4f78defSmrg 1240a4f78defSmrg _G_cmd=$1 1241a4f78defSmrg _G_fail_exp=${2-':'} 1242a4f78defSmrg 1243a4f78defSmrg $opt_quiet || { 1244a4f78defSmrg func_quote_for_expand "$_G_cmd" 1245a4f78defSmrg eval "func_echo $func_quote_for_expand_result" 1246a4f78defSmrg } 1247a4f78defSmrg 1248a4f78defSmrg $opt_dry_run || { 1249a4f78defSmrg eval "$_G_user_locale 1250a4f78defSmrg $_G_cmd" 1251a4f78defSmrg _G_status=$? 1252a4f78defSmrg eval "$_G_safe_locale" 1253a4f78defSmrg if test 0 -ne "$_G_status"; then 1254a4f78defSmrg eval "(exit $_G_status); $_G_fail_exp" 1255a4f78defSmrg fi 1256a4f78defSmrg } 1257a4f78defSmrg} 1258a4f78defSmrg 1259a4f78defSmrg 1260a4f78defSmrg# func_tr_sh 1261a4f78defSmrg# ---------- 1262a4f78defSmrg# Turn $1 into a string suitable for a shell variable name. 1263a4f78defSmrg# Result is stored in $func_tr_sh_result. All characters 1264a4f78defSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265a4f78defSmrg# if $1 begins with a digit, a '_' is prepended as well. 1266a4f78defSmrgfunc_tr_sh () 1267a4f78defSmrg{ 1268a4f78defSmrg $debug_cmd 1269a4f78defSmrg 1270a4f78defSmrg case $1 in 1271a4f78defSmrg [0-9]* | *[!a-zA-Z0-9_]*) 1272a4f78defSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273a4f78defSmrg ;; 1274a4f78defSmrg * ) 1275a4f78defSmrg func_tr_sh_result=$1 1276a4f78defSmrg ;; 1277a4f78defSmrg esac 1278a4f78defSmrg} 1279a4f78defSmrg 1280a4f78defSmrg 1281a4f78defSmrg# func_verbose ARG... 1282a4f78defSmrg# ------------------- 1283a4f78defSmrg# Echo program name prefixed message in verbose mode only. 1284a4f78defSmrgfunc_verbose () 1285a4f78defSmrg{ 1286a4f78defSmrg $debug_cmd 1287a4f78defSmrg 1288a4f78defSmrg $opt_verbose && func_echo "$*" 1289a4f78defSmrg 1290a4f78defSmrg : 1291a4f78defSmrg} 1292a4f78defSmrg 1293a4f78defSmrg 1294a4f78defSmrg# func_warn_and_continue ARG... 1295a4f78defSmrg# ----------------------------- 1296a4f78defSmrg# Echo program name prefixed warning message to standard error. 1297a4f78defSmrgfunc_warn_and_continue () 1298a4f78defSmrg{ 1299a4f78defSmrg $debug_cmd 1300a4f78defSmrg 1301a4f78defSmrg $require_term_colors 1302a4f78defSmrg 1303a4f78defSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304a4f78defSmrg} 1305a4f78defSmrg 1306a4f78defSmrg 1307a4f78defSmrg# func_warning CATEGORY ARG... 1308a4f78defSmrg# ---------------------------- 1309a4f78defSmrg# Echo program name prefixed warning message to standard error. Warning 1310a4f78defSmrg# messages can be filtered according to CATEGORY, where this function 1311a4f78defSmrg# elides messages where CATEGORY is not listed in the global variable 1312a4f78defSmrg# 'opt_warning_types'. 1313a4f78defSmrgfunc_warning () 1314a4f78defSmrg{ 1315a4f78defSmrg $debug_cmd 1316a4f78defSmrg 1317a4f78defSmrg # CATEGORY must be in the warning_categories list! 1318a4f78defSmrg case " $warning_categories " in 1319a4f78defSmrg *" $1 "*) ;; 1320a4f78defSmrg *) func_internal_error "invalid warning category '$1'" ;; 1321a4f78defSmrg esac 1322a4f78defSmrg 1323a4f78defSmrg _G_category=$1 1324a4f78defSmrg shift 1325a4f78defSmrg 1326a4f78defSmrg case " $opt_warning_types " in 1327a4f78defSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328a4f78defSmrg esac 1329a4f78defSmrg} 1330a4f78defSmrg 1331a4f78defSmrg 1332a4f78defSmrg# func_sort_ver VER1 VER2 1333a4f78defSmrg# ----------------------- 1334a4f78defSmrg# 'sort -V' is not generally available. 1335a4f78defSmrg# Note this deviates from the version comparison in automake 1336a4f78defSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337a4f78defSmrg# but this should suffice as we won't be specifying old 1338a4f78defSmrg# version formats or redundant trailing .0 in bootstrap.conf. 1339a4f78defSmrg# If we did want full compatibility then we should probably 1340a4f78defSmrg# use m4_version_compare from autoconf. 1341a4f78defSmrgfunc_sort_ver () 1342a4f78defSmrg{ 1343a4f78defSmrg $debug_cmd 1344a4f78defSmrg 1345a4f78defSmrg printf '%s\n%s\n' "$1" "$2" \ 1346a4f78defSmrg | 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 1347a4f78defSmrg} 1348a4f78defSmrg 1349a4f78defSmrg# func_lt_ver PREV CURR 1350a4f78defSmrg# --------------------- 1351a4f78defSmrg# Return true if PREV and CURR are in the correct order according to 1352a4f78defSmrg# func_sort_ver, otherwise false. Use it like this: 1353a4f78defSmrg# 1354a4f78defSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355a4f78defSmrgfunc_lt_ver () 1356a4f78defSmrg{ 1357a4f78defSmrg $debug_cmd 1358a4f78defSmrg 1359a4f78defSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360a4f78defSmrg} 1361a4f78defSmrg 1362a4f78defSmrg 1363a4f78defSmrg# Local variables: 1364a4f78defSmrg# mode: shell-script 1365a4f78defSmrg# sh-indentation: 2 1366a4f78defSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1367a4f78defSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368a4f78defSmrg# time-stamp-time-zone: "UTC" 1369a4f78defSmrg# End: 1370a4f78defSmrg#! /bin/sh 1371a4f78defSmrg 1372a4f78defSmrg# Set a version string for this script. 1373a4f78defSmrgscriptversion=2014-01-07.03; # UTC 1374a4f78defSmrg 1375a4f78defSmrg# A portable, pluggable option parser for Bourne shell. 1376a4f78defSmrg# Written by Gary V. Vaughan, 2010 1377a4f78defSmrg 1378a4f78defSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379a4f78defSmrg# This is free software; see the source for copying conditions. There is NO 1380a4f78defSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381a4f78defSmrg 1382a4f78defSmrg# This program is free software: you can redistribute it and/or modify 1383a4f78defSmrg# it under the terms of the GNU General Public License as published by 1384a4f78defSmrg# the Free Software Foundation, either version 3 of the License, or 1385a4f78defSmrg# (at your option) any later version. 1386a4f78defSmrg 1387a4f78defSmrg# This program is distributed in the hope that it will be useful, 1388a4f78defSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389a4f78defSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390a4f78defSmrg# GNU General Public License for more details. 1391a4f78defSmrg 1392a4f78defSmrg# You should have received a copy of the GNU General Public License 1393a4f78defSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394a4f78defSmrg 1395a4f78defSmrg# Please report bugs or propose patches to gary@gnu.org. 1396a4f78defSmrg 1397a4f78defSmrg 1398a4f78defSmrg## ------ ## 1399a4f78defSmrg## Usage. ## 1400a4f78defSmrg## ------ ## 1401a4f78defSmrg 1402a4f78defSmrg# This file is a library for parsing options in your shell scripts along 1403a4f78defSmrg# with assorted other useful supporting features that you can make use 1404a4f78defSmrg# of too. 1405a4f78defSmrg# 1406a4f78defSmrg# For the simplest scripts you might need only: 1407a4f78defSmrg# 1408a4f78defSmrg# #!/bin/sh 1409a4f78defSmrg# . relative/path/to/funclib.sh 1410a4f78defSmrg# . relative/path/to/options-parser 1411a4f78defSmrg# scriptversion=1.0 1412a4f78defSmrg# func_options ${1+"$@"} 1413a4f78defSmrg# eval set dummy "$func_options_result"; shift 1414a4f78defSmrg# ...rest of your script... 1415a4f78defSmrg# 1416a4f78defSmrg# In order for the '--version' option to work, you will need to have a 1417a4f78defSmrg# suitably formatted comment like the one at the top of this file 1418a4f78defSmrg# starting with '# Written by ' and ending with '# warranty; '. 1419a4f78defSmrg# 1420a4f78defSmrg# For '-h' and '--help' to work, you will also need a one line 1421a4f78defSmrg# description of your script's purpose in a comment directly above the 1422a4f78defSmrg# '# Written by ' line, like the one at the top of this file. 1423a4f78defSmrg# 1424a4f78defSmrg# The default options also support '--debug', which will turn on shell 1425a4f78defSmrg# execution tracing (see the comment above debug_cmd below for another 1426a4f78defSmrg# use), and '--verbose' and the func_verbose function to allow your script 1427a4f78defSmrg# to display verbose messages only when your user has specified 1428a4f78defSmrg# '--verbose'. 1429a4f78defSmrg# 1430a4f78defSmrg# After sourcing this file, you can plug processing for additional 1431a4f78defSmrg# options by amending the variables from the 'Configuration' section 1432a4f78defSmrg# below, and following the instructions in the 'Option parsing' 1433a4f78defSmrg# section further down. 1434a4f78defSmrg 1435a4f78defSmrg## -------------- ## 1436a4f78defSmrg## Configuration. ## 1437a4f78defSmrg## -------------- ## 1438a4f78defSmrg 1439a4f78defSmrg# You should override these variables in your script after sourcing this 1440a4f78defSmrg# file so that they reflect the customisations you have added to the 1441a4f78defSmrg# option parser. 1442a4f78defSmrg 1443a4f78defSmrg# The usage line for option parsing errors and the start of '-h' and 1444a4f78defSmrg# '--help' output messages. You can embed shell variables for delayed 1445a4f78defSmrg# expansion at the time the message is displayed, but you will need to 1446a4f78defSmrg# quote other shell meta-characters carefully to prevent them being 1447a4f78defSmrg# expanded when the contents are evaled. 1448a4f78defSmrgusage='$progpath [OPTION]...' 1449a4f78defSmrg 1450a4f78defSmrg# Short help message in response to '-h' and '--help'. Add to this or 1451a4f78defSmrg# override it after sourcing this library to reflect the full set of 1452a4f78defSmrg# options your script accepts. 1453a4f78defSmrgusage_message="\ 1454a4f78defSmrg --debug enable verbose shell tracing 1455a4f78defSmrg -W, --warnings=CATEGORY 1456a4f78defSmrg report the warnings falling in CATEGORY [all] 1457a4f78defSmrg -v, --verbose verbosely report processing 1458a4f78defSmrg --version print version information and exit 1459a4f78defSmrg -h, --help print short or long help message and exit 1460a4f78defSmrg" 1461a4f78defSmrg 1462a4f78defSmrg# Additional text appended to 'usage_message' in response to '--help'. 1463a4f78defSmrglong_help_message=" 1464a4f78defSmrgWarning categories include: 1465a4f78defSmrg 'all' show all warnings 1466a4f78defSmrg 'none' turn off all the warnings 1467a4f78defSmrg 'error' warnings are treated as fatal errors" 1468a4f78defSmrg 1469a4f78defSmrg# Help message printed before fatal option parsing errors. 1470a4f78defSmrgfatal_help="Try '\$progname --help' for more information." 1471a4f78defSmrg 1472a4f78defSmrg 1473a4f78defSmrg 1474a4f78defSmrg## ------------------------- ## 1475a4f78defSmrg## Hook function management. ## 1476a4f78defSmrg## ------------------------- ## 1477a4f78defSmrg 1478a4f78defSmrg# This section contains functions for adding, removing, and running hooks 1479a4f78defSmrg# to the main code. A hook is just a named list of of function, that can 1480a4f78defSmrg# be run in order later on. 1481a4f78defSmrg 1482a4f78defSmrg# func_hookable FUNC_NAME 1483a4f78defSmrg# ----------------------- 1484a4f78defSmrg# Declare that FUNC_NAME will run hooks added with 1485a4f78defSmrg# 'func_add_hook FUNC_NAME ...'. 1486a4f78defSmrgfunc_hookable () 1487a4f78defSmrg{ 1488a4f78defSmrg $debug_cmd 1489a4f78defSmrg 1490a4f78defSmrg func_append hookable_fns " $1" 1491a4f78defSmrg} 1492a4f78defSmrg 1493a4f78defSmrg 1494a4f78defSmrg# func_add_hook FUNC_NAME HOOK_FUNC 1495a4f78defSmrg# --------------------------------- 1496a4f78defSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497a4f78defSmrg# first have been declared "hookable" by a call to 'func_hookable'. 1498a4f78defSmrgfunc_add_hook () 1499a4f78defSmrg{ 1500a4f78defSmrg $debug_cmd 1501a4f78defSmrg 1502a4f78defSmrg case " $hookable_fns " in 1503a4f78defSmrg *" $1 "*) ;; 1504a4f78defSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1505a4f78defSmrg esac 1506a4f78defSmrg 1507a4f78defSmrg eval func_append ${1}_hooks '" $2"' 1508a4f78defSmrg} 1509a4f78defSmrg 1510a4f78defSmrg 1511a4f78defSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 1512a4f78defSmrg# ------------------------------------ 1513a4f78defSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514a4f78defSmrgfunc_remove_hook () 1515a4f78defSmrg{ 1516a4f78defSmrg $debug_cmd 1517a4f78defSmrg 1518a4f78defSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519a4f78defSmrg} 1520a4f78defSmrg 1521a4f78defSmrg 1522a4f78defSmrg# func_run_hooks FUNC_NAME [ARG]... 1523a4f78defSmrg# --------------------------------- 1524a4f78defSmrg# Run all hook functions registered to FUNC_NAME. 1525a4f78defSmrg# It is assumed that the list of hook functions contains nothing more 1526a4f78defSmrg# than a whitespace-delimited list of legal shell function names, and 1527a4f78defSmrg# no effort is wasted trying to catch shell meta-characters or preserve 1528a4f78defSmrg# whitespace. 1529a4f78defSmrgfunc_run_hooks () 1530a4f78defSmrg{ 1531a4f78defSmrg $debug_cmd 1532a4f78defSmrg 1533a4f78defSmrg case " $hookable_fns " in 1534a4f78defSmrg *" $1 "*) ;; 1535a4f78defSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536a4f78defSmrg esac 1537a4f78defSmrg 1538a4f78defSmrg eval _G_hook_fns=\$$1_hooks; shift 1539a4f78defSmrg 1540a4f78defSmrg for _G_hook in $_G_hook_fns; do 1541a4f78defSmrg eval $_G_hook '"$@"' 1542a4f78defSmrg 1543a4f78defSmrg # store returned options list back into positional 1544a4f78defSmrg # parameters for next 'cmd' execution. 1545a4f78defSmrg eval _G_hook_result=\$${_G_hook}_result 1546a4f78defSmrg eval set dummy "$_G_hook_result"; shift 1547a4f78defSmrg done 1548a4f78defSmrg 1549a4f78defSmrg func_quote_for_eval ${1+"$@"} 1550a4f78defSmrg func_run_hooks_result=$func_quote_for_eval_result 1551a4f78defSmrg} 1552a4f78defSmrg 1553a4f78defSmrg 1554a4f78defSmrg 1555a4f78defSmrg## --------------- ## 1556a4f78defSmrg## Option parsing. ## 1557a4f78defSmrg## --------------- ## 1558a4f78defSmrg 1559a4f78defSmrg# In order to add your own option parsing hooks, you must accept the 1560a4f78defSmrg# full positional parameter list in your hook function, remove any 1561a4f78defSmrg# options that you action, and then pass back the remaining unprocessed 1562a4f78defSmrg# options in '<hooked_function_name>_result', escaped suitably for 1563a4f78defSmrg# 'eval'. Like this: 1564a4f78defSmrg# 1565a4f78defSmrg# my_options_prep () 1566a4f78defSmrg# { 1567a4f78defSmrg# $debug_cmd 1568a4f78defSmrg# 1569a4f78defSmrg# # Extend the existing usage message. 1570a4f78defSmrg# usage_message=$usage_message' 1571a4f78defSmrg# -s, --silent don'\''t print informational messages 1572a4f78defSmrg# ' 1573a4f78defSmrg# 1574a4f78defSmrg# func_quote_for_eval ${1+"$@"} 1575a4f78defSmrg# my_options_prep_result=$func_quote_for_eval_result 1576a4f78defSmrg# } 1577a4f78defSmrg# func_add_hook func_options_prep my_options_prep 1578a4f78defSmrg# 1579a4f78defSmrg# 1580a4f78defSmrg# my_silent_option () 1581a4f78defSmrg# { 1582a4f78defSmrg# $debug_cmd 1583a4f78defSmrg# 1584a4f78defSmrg# # Note that for efficiency, we parse as many options as we can 1585a4f78defSmrg# # recognise in a loop before passing the remainder back to the 1586a4f78defSmrg# # caller on the first unrecognised argument we encounter. 1587a4f78defSmrg# while test $# -gt 0; do 1588a4f78defSmrg# opt=$1; shift 1589a4f78defSmrg# case $opt in 1590a4f78defSmrg# --silent|-s) opt_silent=: ;; 1591a4f78defSmrg# # Separate non-argument short options: 1592a4f78defSmrg# -s*) func_split_short_opt "$_G_opt" 1593a4f78defSmrg# set dummy "$func_split_short_opt_name" \ 1594a4f78defSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 1595a4f78defSmrg# shift 1596a4f78defSmrg# ;; 1597a4f78defSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598a4f78defSmrg# esac 1599a4f78defSmrg# done 1600a4f78defSmrg# 1601a4f78defSmrg# func_quote_for_eval ${1+"$@"} 1602a4f78defSmrg# my_silent_option_result=$func_quote_for_eval_result 1603a4f78defSmrg# } 1604a4f78defSmrg# func_add_hook func_parse_options my_silent_option 1605a4f78defSmrg# 1606a4f78defSmrg# 1607a4f78defSmrg# my_option_validation () 1608a4f78defSmrg# { 1609a4f78defSmrg# $debug_cmd 1610a4f78defSmrg# 1611a4f78defSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1612a4f78defSmrg# '--silent' and '--verbose' options are mutually exclusive." 1613a4f78defSmrg# 1614a4f78defSmrg# func_quote_for_eval ${1+"$@"} 1615a4f78defSmrg# my_option_validation_result=$func_quote_for_eval_result 1616a4f78defSmrg# } 1617a4f78defSmrg# func_add_hook func_validate_options my_option_validation 1618a4f78defSmrg# 1619a4f78defSmrg# You'll alse need to manually amend $usage_message to reflect the extra 1620a4f78defSmrg# options you parse. It's preferable to append if you can, so that 1621a4f78defSmrg# multiple option parsing hooks can be added safely. 1622a4f78defSmrg 1623a4f78defSmrg 1624a4f78defSmrg# func_options [ARG]... 1625a4f78defSmrg# --------------------- 1626a4f78defSmrg# All the functions called inside func_options are hookable. See the 1627a4f78defSmrg# individual implementations for details. 1628a4f78defSmrgfunc_hookable func_options 1629a4f78defSmrgfunc_options () 1630a4f78defSmrg{ 1631a4f78defSmrg $debug_cmd 1632a4f78defSmrg 1633a4f78defSmrg func_options_prep ${1+"$@"} 1634a4f78defSmrg eval func_parse_options \ 1635a4f78defSmrg ${func_options_prep_result+"$func_options_prep_result"} 1636a4f78defSmrg eval func_validate_options \ 1637a4f78defSmrg ${func_parse_options_result+"$func_parse_options_result"} 1638a4f78defSmrg 1639a4f78defSmrg eval func_run_hooks func_options \ 1640a4f78defSmrg ${func_validate_options_result+"$func_validate_options_result"} 1641a4f78defSmrg 1642a4f78defSmrg # save modified positional parameters for caller 1643a4f78defSmrg func_options_result=$func_run_hooks_result 1644a4f78defSmrg} 1645a4f78defSmrg 1646a4f78defSmrg 1647a4f78defSmrg# func_options_prep [ARG]... 1648a4f78defSmrg# -------------------------- 1649a4f78defSmrg# All initialisations required before starting the option parse loop. 1650a4f78defSmrg# Note that when calling hook functions, we pass through the list of 1651a4f78defSmrg# positional parameters. If a hook function modifies that list, and 1652a4f78defSmrg# needs to propogate that back to rest of this script, then the complete 1653a4f78defSmrg# modified list must be put in 'func_run_hooks_result' before 1654a4f78defSmrg# returning. 1655a4f78defSmrgfunc_hookable func_options_prep 1656a4f78defSmrgfunc_options_prep () 1657a4f78defSmrg{ 1658a4f78defSmrg $debug_cmd 1659a4f78defSmrg 1660a4f78defSmrg # Option defaults: 1661a4f78defSmrg opt_verbose=false 1662a4f78defSmrg opt_warning_types= 1663a4f78defSmrg 1664a4f78defSmrg func_run_hooks func_options_prep ${1+"$@"} 1665a4f78defSmrg 1666a4f78defSmrg # save modified positional parameters for caller 1667a4f78defSmrg func_options_prep_result=$func_run_hooks_result 1668a4f78defSmrg} 1669a4f78defSmrg 1670a4f78defSmrg 1671a4f78defSmrg# func_parse_options [ARG]... 1672a4f78defSmrg# --------------------------- 1673a4f78defSmrg# The main option parsing loop. 1674a4f78defSmrgfunc_hookable func_parse_options 1675a4f78defSmrgfunc_parse_options () 1676a4f78defSmrg{ 1677a4f78defSmrg $debug_cmd 1678a4f78defSmrg 1679a4f78defSmrg func_parse_options_result= 1680a4f78defSmrg 1681a4f78defSmrg # this just eases exit handling 1682a4f78defSmrg while test $# -gt 0; do 1683a4f78defSmrg # Defer to hook functions for initial option parsing, so they 1684a4f78defSmrg # get priority in the event of reusing an option name. 1685a4f78defSmrg func_run_hooks func_parse_options ${1+"$@"} 1686a4f78defSmrg 1687a4f78defSmrg # Adjust func_parse_options positional parameters to match 1688a4f78defSmrg eval set dummy "$func_run_hooks_result"; shift 1689a4f78defSmrg 1690a4f78defSmrg # Break out of the loop if we already parsed every option. 1691a4f78defSmrg test $# -gt 0 || break 1692a4f78defSmrg 1693a4f78defSmrg _G_opt=$1 1694a4f78defSmrg shift 1695a4f78defSmrg case $_G_opt in 1696a4f78defSmrg --debug|-x) debug_cmd='set -x' 1697a4f78defSmrg func_echo "enabling shell trace mode" 1698a4f78defSmrg $debug_cmd 1699a4f78defSmrg ;; 1700a4f78defSmrg 1701a4f78defSmrg --no-warnings|--no-warning|--no-warn) 1702a4f78defSmrg set dummy --warnings none ${1+"$@"} 1703a4f78defSmrg shift 1704a4f78defSmrg ;; 1705a4f78defSmrg 1706a4f78defSmrg --warnings|--warning|-W) 1707a4f78defSmrg test $# = 0 && func_missing_arg $_G_opt && break 1708a4f78defSmrg case " $warning_categories $1" in 1709a4f78defSmrg *" $1 "*) 1710a4f78defSmrg # trailing space prevents matching last $1 above 1711a4f78defSmrg func_append_uniq opt_warning_types " $1" 1712a4f78defSmrg ;; 1713a4f78defSmrg *all) 1714a4f78defSmrg opt_warning_types=$warning_categories 1715a4f78defSmrg ;; 1716a4f78defSmrg *none) 1717a4f78defSmrg opt_warning_types=none 1718a4f78defSmrg warning_func=: 1719a4f78defSmrg ;; 1720a4f78defSmrg *error) 1721a4f78defSmrg opt_warning_types=$warning_categories 1722a4f78defSmrg warning_func=func_fatal_error 1723a4f78defSmrg ;; 1724a4f78defSmrg *) 1725a4f78defSmrg func_fatal_error \ 1726a4f78defSmrg "unsupported warning category: '$1'" 1727a4f78defSmrg ;; 1728a4f78defSmrg esac 1729a4f78defSmrg shift 1730a4f78defSmrg ;; 1731a4f78defSmrg 1732a4f78defSmrg --verbose|-v) opt_verbose=: ;; 1733a4f78defSmrg --version) func_version ;; 1734a4f78defSmrg -\?|-h) func_usage ;; 1735a4f78defSmrg --help) func_help ;; 1736a4f78defSmrg 1737a4f78defSmrg # Separate optargs to long options (plugins may need this): 1738a4f78defSmrg --*=*) func_split_equals "$_G_opt" 1739a4f78defSmrg set dummy "$func_split_equals_lhs" \ 1740a4f78defSmrg "$func_split_equals_rhs" ${1+"$@"} 1741a4f78defSmrg shift 1742a4f78defSmrg ;; 1743a4f78defSmrg 1744a4f78defSmrg # Separate optargs to short options: 1745a4f78defSmrg -W*) 1746a4f78defSmrg func_split_short_opt "$_G_opt" 1747a4f78defSmrg set dummy "$func_split_short_opt_name" \ 1748a4f78defSmrg "$func_split_short_opt_arg" ${1+"$@"} 1749a4f78defSmrg shift 1750a4f78defSmrg ;; 1751a4f78defSmrg 1752a4f78defSmrg # Separate non-argument short options: 1753a4f78defSmrg -\?*|-h*|-v*|-x*) 1754a4f78defSmrg func_split_short_opt "$_G_opt" 1755a4f78defSmrg set dummy "$func_split_short_opt_name" \ 1756a4f78defSmrg "-$func_split_short_opt_arg" ${1+"$@"} 1757a4f78defSmrg shift 1758a4f78defSmrg ;; 1759a4f78defSmrg 1760a4f78defSmrg --) break ;; 1761a4f78defSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762a4f78defSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763a4f78defSmrg esac 1764a4f78defSmrg done 1765a4f78defSmrg 1766a4f78defSmrg # save modified positional parameters for caller 1767a4f78defSmrg func_quote_for_eval ${1+"$@"} 1768a4f78defSmrg func_parse_options_result=$func_quote_for_eval_result 1769a4f78defSmrg} 1770a4f78defSmrg 1771a4f78defSmrg 1772a4f78defSmrg# func_validate_options [ARG]... 1773a4f78defSmrg# ------------------------------ 1774a4f78defSmrg# Perform any sanity checks on option settings and/or unconsumed 1775a4f78defSmrg# arguments. 1776a4f78defSmrgfunc_hookable func_validate_options 1777a4f78defSmrgfunc_validate_options () 1778a4f78defSmrg{ 1779a4f78defSmrg $debug_cmd 1780a4f78defSmrg 1781a4f78defSmrg # Display all warnings if -W was not given. 1782a4f78defSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783a4f78defSmrg 1784a4f78defSmrg func_run_hooks func_validate_options ${1+"$@"} 1785a4f78defSmrg 1786a4f78defSmrg # Bail if the options were screwed! 1787a4f78defSmrg $exit_cmd $EXIT_FAILURE 1788a4f78defSmrg 1789a4f78defSmrg # save modified positional parameters for caller 1790a4f78defSmrg func_validate_options_result=$func_run_hooks_result 1791a4f78defSmrg} 1792a4f78defSmrg 1793a4f78defSmrg 1794a4f78defSmrg 1795a4f78defSmrg## ----------------- ## 1796a4f78defSmrg## Helper functions. ## 1797a4f78defSmrg## ----------------- ## 1798a4f78defSmrg 1799a4f78defSmrg# This section contains the helper functions used by the rest of the 1800a4f78defSmrg# hookable option parser framework in ascii-betical order. 1801a4f78defSmrg 1802a4f78defSmrg 1803a4f78defSmrg# func_fatal_help ARG... 1804a4f78defSmrg# ---------------------- 1805a4f78defSmrg# Echo program name prefixed message to standard error, followed by 1806a4f78defSmrg# a help hint, and exit. 1807a4f78defSmrgfunc_fatal_help () 1808a4f78defSmrg{ 1809a4f78defSmrg $debug_cmd 1810a4f78defSmrg 1811a4f78defSmrg eval \$ECHO \""Usage: $usage"\" 1812a4f78defSmrg eval \$ECHO \""$fatal_help"\" 1813a4f78defSmrg func_error ${1+"$@"} 1814a4f78defSmrg exit $EXIT_FAILURE 1815a4f78defSmrg} 1816a4f78defSmrg 1817a4f78defSmrg 1818a4f78defSmrg# func_help 1819a4f78defSmrg# --------- 1820a4f78defSmrg# Echo long help message to standard output and exit. 1821a4f78defSmrgfunc_help () 1822a4f78defSmrg{ 1823a4f78defSmrg $debug_cmd 1824a4f78defSmrg 1825a4f78defSmrg func_usage_message 1826a4f78defSmrg $ECHO "$long_help_message" 1827a4f78defSmrg exit 0 1828a4f78defSmrg} 1829a4f78defSmrg 1830a4f78defSmrg 1831a4f78defSmrg# func_missing_arg ARGNAME 1832a4f78defSmrg# ------------------------ 1833a4f78defSmrg# Echo program name prefixed message to standard error and set global 1834a4f78defSmrg# exit_cmd. 1835a4f78defSmrgfunc_missing_arg () 1836a4f78defSmrg{ 1837a4f78defSmrg $debug_cmd 1838a4f78defSmrg 1839a4f78defSmrg func_error "Missing argument for '$1'." 1840a4f78defSmrg exit_cmd=exit 1841a4f78defSmrg} 1842a4f78defSmrg 1843a4f78defSmrg 1844a4f78defSmrg# func_split_equals STRING 1845a4f78defSmrg# ------------------------ 1846a4f78defSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847a4f78defSmrg# splitting STRING at the '=' sign. 1848a4f78defSmrgtest -z "$_G_HAVE_XSI_OPS" \ 1849a4f78defSmrg && (eval 'x=a/b/c; 1850a4f78defSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851a4f78defSmrg && _G_HAVE_XSI_OPS=yes 1852a4f78defSmrg 1853a4f78defSmrgif test yes = "$_G_HAVE_XSI_OPS" 1854a4f78defSmrgthen 1855a4f78defSmrg # This is an XSI compatible shell, allowing a faster implementation... 1856a4f78defSmrg eval 'func_split_equals () 1857a4f78defSmrg { 1858a4f78defSmrg $debug_cmd 1859a4f78defSmrg 1860a4f78defSmrg func_split_equals_lhs=${1%%=*} 1861a4f78defSmrg func_split_equals_rhs=${1#*=} 1862a4f78defSmrg test "x$func_split_equals_lhs" = "x$1" \ 1863a4f78defSmrg && func_split_equals_rhs= 1864a4f78defSmrg }' 1865a4f78defSmrgelse 1866a4f78defSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 1867a4f78defSmrg func_split_equals () 1868a4f78defSmrg { 1869a4f78defSmrg $debug_cmd 1870a4f78defSmrg 1871a4f78defSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872a4f78defSmrg func_split_equals_rhs= 1873a4f78defSmrg test "x$func_split_equals_lhs" = "x$1" \ 1874a4f78defSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875a4f78defSmrg } 1876a4f78defSmrgfi #func_split_equals 1877a4f78defSmrg 1878a4f78defSmrg 1879a4f78defSmrg# func_split_short_opt SHORTOPT 1880a4f78defSmrg# ----------------------------- 1881a4f78defSmrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882a4f78defSmrg# variables after splitting SHORTOPT after the 2nd character. 1883a4f78defSmrgif test yes = "$_G_HAVE_XSI_OPS" 1884a4f78defSmrgthen 1885a4f78defSmrg # This is an XSI compatible shell, allowing a faster implementation... 1886a4f78defSmrg eval 'func_split_short_opt () 1887a4f78defSmrg { 1888a4f78defSmrg $debug_cmd 1889a4f78defSmrg 1890a4f78defSmrg func_split_short_opt_arg=${1#??} 1891a4f78defSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892a4f78defSmrg }' 1893a4f78defSmrgelse 1894a4f78defSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 1895a4f78defSmrg func_split_short_opt () 1896a4f78defSmrg { 1897a4f78defSmrg $debug_cmd 1898a4f78defSmrg 1899a4f78defSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900a4f78defSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901a4f78defSmrg } 1902a4f78defSmrgfi #func_split_short_opt 1903a4f78defSmrg 1904a4f78defSmrg 1905a4f78defSmrg# func_usage 1906a4f78defSmrg# ---------- 1907a4f78defSmrg# Echo short help message to standard output and exit. 1908a4f78defSmrgfunc_usage () 1909a4f78defSmrg{ 1910a4f78defSmrg $debug_cmd 1911a4f78defSmrg 1912a4f78defSmrg func_usage_message 1913a4f78defSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914a4f78defSmrg exit 0 1915a4f78defSmrg} 1916a4f78defSmrg 1917a4f78defSmrg 1918a4f78defSmrg# func_usage_message 1919a4f78defSmrg# ------------------ 1920a4f78defSmrg# Echo short help message to standard output. 1921a4f78defSmrgfunc_usage_message () 1922a4f78defSmrg{ 1923a4f78defSmrg $debug_cmd 1924a4f78defSmrg 1925a4f78defSmrg eval \$ECHO \""Usage: $usage"\" 1926a4f78defSmrg echo 1927a4f78defSmrg $SED -n 's|^# || 1928a4f78defSmrg /^Written by/{ 1929a4f78defSmrg x;p;x 1930a4f78defSmrg } 1931a4f78defSmrg h 1932a4f78defSmrg /^Written by/q' < "$progpath" 1933a4f78defSmrg echo 1934a4f78defSmrg eval \$ECHO \""$usage_message"\" 1935a4f78defSmrg} 1936a4f78defSmrg 1937a4f78defSmrg 1938a4f78defSmrg# func_version 1939a4f78defSmrg# ------------ 1940a4f78defSmrg# Echo version message to standard output and exit. 1941a4f78defSmrgfunc_version () 1942a4f78defSmrg{ 1943a4f78defSmrg $debug_cmd 1944a4f78defSmrg 1945a4f78defSmrg printf '%s\n' "$progname $scriptversion" 1946a4f78defSmrg $SED -n ' 1947a4f78defSmrg /(C)/!b go 1948a4f78defSmrg :more 1949a4f78defSmrg /\./!{ 1950a4f78defSmrg N 1951a4f78defSmrg s|\n# | | 1952a4f78defSmrg b more 1953a4f78defSmrg } 1954a4f78defSmrg :go 1955a4f78defSmrg /^# Written by /,/# warranty; / { 1956a4f78defSmrg s|^# || 1957a4f78defSmrg s|^# *$|| 1958a4f78defSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959a4f78defSmrg p 1960a4f78defSmrg } 1961a4f78defSmrg /^# Written by / { 1962a4f78defSmrg s|^# || 1963a4f78defSmrg p 1964a4f78defSmrg } 1965a4f78defSmrg /^warranty; /q' < "$progpath" 1966a4f78defSmrg 1967a4f78defSmrg exit $? 1968a4f78defSmrg} 1969a4f78defSmrg 1970a4f78defSmrg 1971a4f78defSmrg# Local variables: 1972a4f78defSmrg# mode: shell-script 1973a4f78defSmrg# sh-indentation: 2 1974a4f78defSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1975a4f78defSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976a4f78defSmrg# time-stamp-time-zone: "UTC" 1977a4f78defSmrg# End: 1978a4f78defSmrg 1979a4f78defSmrg# Set a version string. 1980a4f78defSmrgscriptversion='(GNU libtool) 2.4.6' 1981a4f78defSmrg 1982a4f78defSmrg 1983a4f78defSmrg# func_echo ARG... 1984a4f78defSmrg# ---------------- 1985a4f78defSmrg# Libtool also displays the current mode in messages, so override 1986a4f78defSmrg# funclib.sh func_echo with this custom definition. 1987a4f78defSmrgfunc_echo () 1988a4f78defSmrg{ 1989a4f78defSmrg $debug_cmd 1990a4f78defSmrg 1991a4f78defSmrg _G_message=$* 1992a4f78defSmrg 1993a4f78defSmrg func_echo_IFS=$IFS 1994a4f78defSmrg IFS=$nl 1995a4f78defSmrg for _G_line in $_G_message; do 1996a4f78defSmrg IFS=$func_echo_IFS 1997a4f78defSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998a4f78defSmrg done 1999a4f78defSmrg IFS=$func_echo_IFS 2000a4f78defSmrg} 2001a4f78defSmrg 2002a4f78defSmrg 2003a4f78defSmrg# func_warning ARG... 2004a4f78defSmrg# ------------------- 2005a4f78defSmrg# Libtool warnings are not categorized, so override funclib.sh 2006a4f78defSmrg# func_warning with this simpler definition. 2007a4f78defSmrgfunc_warning () 2008a4f78defSmrg{ 2009a4f78defSmrg $debug_cmd 2010a4f78defSmrg 2011a4f78defSmrg $warning_func ${1+"$@"} 2012a4f78defSmrg} 2013a4f78defSmrg 2014a4f78defSmrg 2015a4f78defSmrg## ---------------- ## 2016a4f78defSmrg## Options parsing. ## 2017a4f78defSmrg## ---------------- ## 2018a4f78defSmrg 2019a4f78defSmrg# Hook in the functions to make sure our own options are parsed during 2020a4f78defSmrg# the option parsing loop. 2021a4f78defSmrg 2022a4f78defSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 2023a4f78defSmrg 2024a4f78defSmrg# Short help message in response to '-h'. 2025a4f78defSmrgusage_message="Options: 2026a4f78defSmrg --config show all configuration variables 2027a4f78defSmrg --debug enable verbose shell tracing 2028a4f78defSmrg -n, --dry-run display commands without modifying any files 2029a4f78defSmrg --features display basic configuration information and exit 2030a4f78defSmrg --mode=MODE use operation mode MODE 2031a4f78defSmrg --no-warnings equivalent to '-Wnone' 2032a4f78defSmrg --preserve-dup-deps don't remove duplicate dependency libraries 2033a4f78defSmrg --quiet, --silent don't print informational messages 2034a4f78defSmrg --tag=TAG use configuration variables from tag TAG 2035a4f78defSmrg -v, --verbose print more informational messages than default 2036a4f78defSmrg --version print version information 2037a4f78defSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038a4f78defSmrg -h, --help, --help-all print short, long, or detailed help message 2039a4f78defSmrg" 2040a4f78defSmrg 2041a4f78defSmrg# Additional text appended to 'usage_message' in response to '--help'. 2042a4f78defSmrgfunc_help () 2043a4f78defSmrg{ 2044a4f78defSmrg $debug_cmd 2045a4f78defSmrg 2046a4f78defSmrg func_usage_message 2047a4f78defSmrg $ECHO "$long_help_message 2048a4f78defSmrg 2049a4f78defSmrgMODE must be one of the following: 2050a4f78defSmrg 2051a4f78defSmrg clean remove files from the build directory 2052a4f78defSmrg compile compile a source file into a libtool object 2053a4f78defSmrg execute automatically set library path, then run a program 2054a4f78defSmrg finish complete the installation of libtool libraries 2055a4f78defSmrg install install libraries or executables 2056a4f78defSmrg link create a library or an executable 2057a4f78defSmrg uninstall remove libraries from an installed directory 2058a4f78defSmrg 2059a4f78defSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2060a4f78defSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061a4f78defSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062a4f78defSmrg 2063a4f78defSmrgWhen reporting a bug, please describe a test case to reproduce it and 2064a4f78defSmrginclude the following information: 2065a4f78defSmrg 2066a4f78defSmrg host-triplet: $host 2067a4f78defSmrg shell: $SHELL 2068a4f78defSmrg compiler: $LTCC 2069a4f78defSmrg compiler flags: $LTCFLAGS 2070a4f78defSmrg linker: $LD (gnu? $with_gnu_ld) 2071a4f78defSmrg version: $progname (GNU libtool) 2.4.6 2072a4f78defSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073a4f78defSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074a4f78defSmrg 2075a4f78defSmrgReport bugs to <bug-libtool@gnu.org>. 2076a4f78defSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2077a4f78defSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078a4f78defSmrg exit 0 2079a4f78defSmrg} 2080a4f78defSmrg 2081a4f78defSmrg 2082a4f78defSmrg# func_lo2o OBJECT-NAME 2083a4f78defSmrg# --------------------- 2084a4f78defSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085a4f78defSmrg# object suffix. 2086a4f78defSmrg 2087a4f78defSmrglo2o=s/\\.lo\$/.$objext/ 2088a4f78defSmrgo2lo=s/\\.$objext\$/.lo/ 2089a4f78defSmrg 2090a4f78defSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 2091a4f78defSmrg eval 'func_lo2o () 2092a4f78defSmrg { 2093a4f78defSmrg case $1 in 2094a4f78defSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095a4f78defSmrg * ) func_lo2o_result=$1 ;; 2096a4f78defSmrg esac 2097a4f78defSmrg }' 2098a4f78defSmrg 2099a4f78defSmrg # func_xform LIBOBJ-OR-SOURCE 2100a4f78defSmrg # --------------------------- 2101a4f78defSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102a4f78defSmrg # suffix to a '.lo' libtool-object suffix. 2103a4f78defSmrg eval 'func_xform () 2104a4f78defSmrg { 2105a4f78defSmrg func_xform_result=${1%.*}.lo 2106a4f78defSmrg }' 2107a4f78defSmrgelse 2108a4f78defSmrg # ...otherwise fall back to using sed. 2109a4f78defSmrg func_lo2o () 2110a4f78defSmrg { 2111a4f78defSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112a4f78defSmrg } 2113a4f78defSmrg 2114a4f78defSmrg func_xform () 2115a4f78defSmrg { 2116a4f78defSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117a4f78defSmrg } 2118a4f78defSmrgfi 2119a4f78defSmrg 2120a4f78defSmrg 2121a4f78defSmrg# func_fatal_configuration ARG... 2122a4f78defSmrg# ------------------------------- 2123a4f78defSmrg# Echo program name prefixed message to standard error, followed by 2124a4f78defSmrg# a configuration failure hint, and exit. 2125a4f78defSmrgfunc_fatal_configuration () 2126a4f78defSmrg{ 2127a4f78defSmrg func__fatal_error ${1+"$@"} \ 2128a4f78defSmrg "See the $PACKAGE documentation for more information." \ 2129a4f78defSmrg "Fatal configuration error." 2130a4f78defSmrg} 2131a4f78defSmrg 2132a4f78defSmrg 2133a4f78defSmrg# func_config 2134a4f78defSmrg# ----------- 2135a4f78defSmrg# Display the configuration for all the tags in this script. 2136a4f78defSmrgfunc_config () 2137a4f78defSmrg{ 2138a4f78defSmrg re_begincf='^# ### BEGIN LIBTOOL' 2139a4f78defSmrg re_endcf='^# ### END LIBTOOL' 2140a4f78defSmrg 2141a4f78defSmrg # Default configuration. 2142a4f78defSmrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143a4f78defSmrg 2144a4f78defSmrg # Now print the configurations for the tags. 2145a4f78defSmrg for tagname in $taglist; do 2146a4f78defSmrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147a4f78defSmrg done 2148a4f78defSmrg 2149a4f78defSmrg exit $? 2150a4f78defSmrg} 2151a4f78defSmrg 2152a4f78defSmrg 2153a4f78defSmrg# func_features 2154a4f78defSmrg# ------------- 2155a4f78defSmrg# Display the features supported by this script. 2156a4f78defSmrgfunc_features () 2157a4f78defSmrg{ 2158a4f78defSmrg echo "host: $host" 2159a4f78defSmrg if test yes = "$build_libtool_libs"; then 2160a4f78defSmrg echo "enable shared libraries" 2161a4f78defSmrg else 2162a4f78defSmrg echo "disable shared libraries" 2163a4f78defSmrg fi 2164a4f78defSmrg if test yes = "$build_old_libs"; then 2165a4f78defSmrg echo "enable static libraries" 2166a4f78defSmrg else 2167a4f78defSmrg echo "disable static libraries" 2168a4f78defSmrg fi 2169a4f78defSmrg 2170a4f78defSmrg exit $? 2171a4f78defSmrg} 2172a4f78defSmrg 2173a4f78defSmrg 2174a4f78defSmrg# func_enable_tag TAGNAME 2175a4f78defSmrg# ----------------------- 2176a4f78defSmrg# Verify that TAGNAME is valid, and either flag an error and exit, or 2177a4f78defSmrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2178a4f78defSmrg# variable here. 2179a4f78defSmrgfunc_enable_tag () 2180a4f78defSmrg{ 2181a4f78defSmrg # Global variable: 2182a4f78defSmrg tagname=$1 2183a4f78defSmrg 2184a4f78defSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185a4f78defSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186a4f78defSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187a4f78defSmrg 2188a4f78defSmrg # Validate tagname. 2189a4f78defSmrg case $tagname in 2190a4f78defSmrg *[!-_A-Za-z0-9,/]*) 2191a4f78defSmrg func_fatal_error "invalid tag name: $tagname" 2192a4f78defSmrg ;; 2193a4f78defSmrg esac 2194a4f78defSmrg 2195a4f78defSmrg # Don't test for the "default" C tag, as we know it's 2196a4f78defSmrg # there but not specially marked. 2197a4f78defSmrg case $tagname in 2198a4f78defSmrg CC) ;; 2199a4f78defSmrg *) 2200a4f78defSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201a4f78defSmrg taglist="$taglist $tagname" 2202a4f78defSmrg 2203a4f78defSmrg # Evaluate the configuration. Be careful to quote the path 2204a4f78defSmrg # and the sed script, to avoid splitting on whitespace, but 2205a4f78defSmrg # also don't use non-portable quotes within backquotes within 2206a4f78defSmrg # quotes we have to do it in 2 steps: 2207a4f78defSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208a4f78defSmrg eval "$extractedcf" 2209a4f78defSmrg else 2210a4f78defSmrg func_error "ignoring unknown tag $tagname" 2211a4f78defSmrg fi 2212a4f78defSmrg ;; 2213a4f78defSmrg esac 2214a4f78defSmrg} 2215a4f78defSmrg 2216a4f78defSmrg 2217a4f78defSmrg# func_check_version_match 2218a4f78defSmrg# ------------------------ 2219a4f78defSmrg# Ensure that we are using m4 macros, and libtool script from the same 2220a4f78defSmrg# release of libtool. 2221a4f78defSmrgfunc_check_version_match () 2222a4f78defSmrg{ 2223a4f78defSmrg if test "$package_revision" != "$macro_revision"; then 2224a4f78defSmrg if test "$VERSION" != "$macro_version"; then 2225a4f78defSmrg if test -z "$macro_version"; then 2226a4f78defSmrg cat >&2 <<_LT_EOF 2227a4f78defSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228a4f78defSmrg$progname: definition of this LT_INIT comes from an older release. 2229a4f78defSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230a4f78defSmrg$progname: and run autoconf again. 2231a4f78defSmrg_LT_EOF 2232a4f78defSmrg else 2233a4f78defSmrg cat >&2 <<_LT_EOF 2234a4f78defSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235a4f78defSmrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236a4f78defSmrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237a4f78defSmrg$progname: and run autoconf again. 2238a4f78defSmrg_LT_EOF 2239a4f78defSmrg fi 2240a4f78defSmrg else 2241a4f78defSmrg cat >&2 <<_LT_EOF 2242a4f78defSmrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243a4f78defSmrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244a4f78defSmrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245a4f78defSmrg$progname: of $PACKAGE $VERSION and run autoconf again. 2246a4f78defSmrg_LT_EOF 2247a4f78defSmrg fi 2248a4f78defSmrg 2249a4f78defSmrg exit $EXIT_MISMATCH 2250a4f78defSmrg fi 2251a4f78defSmrg} 2252a4f78defSmrg 2253a4f78defSmrg 2254a4f78defSmrg# libtool_options_prep [ARG]... 2255a4f78defSmrg# ----------------------------- 2256a4f78defSmrg# Preparation for options parsed by libtool. 2257a4f78defSmrglibtool_options_prep () 2258a4f78defSmrg{ 2259a4f78defSmrg $debug_mode 2260a4f78defSmrg 2261a4f78defSmrg # Option defaults: 2262a4f78defSmrg opt_config=false 2263a4f78defSmrg opt_dlopen= 2264a4f78defSmrg opt_dry_run=false 2265a4f78defSmrg opt_help=false 2266a4f78defSmrg opt_mode= 2267a4f78defSmrg opt_preserve_dup_deps=false 2268a4f78defSmrg opt_quiet=false 2269a4f78defSmrg 2270a4f78defSmrg nonopt= 2271a4f78defSmrg preserve_args= 2272a4f78defSmrg 2273a4f78defSmrg # Shorthand for --mode=foo, only valid as the first argument 2274a4f78defSmrg case $1 in 2275a4f78defSmrg clean|clea|cle|cl) 2276a4f78defSmrg shift; set dummy --mode clean ${1+"$@"}; shift 2277a4f78defSmrg ;; 2278a4f78defSmrg compile|compil|compi|comp|com|co|c) 2279a4f78defSmrg shift; set dummy --mode compile ${1+"$@"}; shift 2280a4f78defSmrg ;; 2281a4f78defSmrg execute|execut|execu|exec|exe|ex|e) 2282a4f78defSmrg shift; set dummy --mode execute ${1+"$@"}; shift 2283a4f78defSmrg ;; 2284a4f78defSmrg finish|finis|fini|fin|fi|f) 2285a4f78defSmrg shift; set dummy --mode finish ${1+"$@"}; shift 2286a4f78defSmrg ;; 2287a4f78defSmrg install|instal|insta|inst|ins|in|i) 2288a4f78defSmrg shift; set dummy --mode install ${1+"$@"}; shift 2289a4f78defSmrg ;; 2290a4f78defSmrg link|lin|li|l) 2291a4f78defSmrg shift; set dummy --mode link ${1+"$@"}; shift 2292a4f78defSmrg ;; 2293a4f78defSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294a4f78defSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2295a4f78defSmrg ;; 2296a4f78defSmrg esac 2297a4f78defSmrg 2298a4f78defSmrg # Pass back the list of options. 2299a4f78defSmrg func_quote_for_eval ${1+"$@"} 2300a4f78defSmrg libtool_options_prep_result=$func_quote_for_eval_result 2301a4f78defSmrg} 2302a4f78defSmrgfunc_add_hook func_options_prep libtool_options_prep 2303a4f78defSmrg 2304a4f78defSmrg 2305a4f78defSmrg# libtool_parse_options [ARG]... 2306a4f78defSmrg# --------------------------------- 2307a4f78defSmrg# Provide handling for libtool specific options. 2308a4f78defSmrglibtool_parse_options () 2309a4f78defSmrg{ 2310a4f78defSmrg $debug_cmd 2311a4f78defSmrg 2312a4f78defSmrg # Perform our own loop to consume as many options as possible in 2313a4f78defSmrg # each iteration. 2314a4f78defSmrg while test $# -gt 0; do 2315a4f78defSmrg _G_opt=$1 2316a4f78defSmrg shift 2317a4f78defSmrg case $_G_opt in 2318a4f78defSmrg --dry-run|--dryrun|-n) 2319a4f78defSmrg opt_dry_run=: 2320a4f78defSmrg ;; 2321a4f78defSmrg 2322a4f78defSmrg --config) func_config ;; 2323a4f78defSmrg 2324a4f78defSmrg --dlopen|-dlopen) 2325a4f78defSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 2326a4f78defSmrg}$1" 2327a4f78defSmrg shift 2328a4f78defSmrg ;; 2329a4f78defSmrg 2330a4f78defSmrg --preserve-dup-deps) 2331a4f78defSmrg opt_preserve_dup_deps=: ;; 2332a4f78defSmrg 2333a4f78defSmrg --features) func_features ;; 2334a4f78defSmrg 2335a4f78defSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336a4f78defSmrg 2337a4f78defSmrg --help) opt_help=: ;; 2338a4f78defSmrg 2339a4f78defSmrg --help-all) opt_help=': help-all' ;; 2340a4f78defSmrg 2341a4f78defSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342a4f78defSmrg opt_mode=$1 2343a4f78defSmrg case $1 in 2344a4f78defSmrg # Valid mode arguments: 2345a4f78defSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346a4f78defSmrg 2347a4f78defSmrg # Catch anything else as an error 2348a4f78defSmrg *) func_error "invalid argument for $_G_opt" 2349a4f78defSmrg exit_cmd=exit 2350a4f78defSmrg break 2351a4f78defSmrg ;; 2352a4f78defSmrg esac 2353a4f78defSmrg shift 2354a4f78defSmrg ;; 2355a4f78defSmrg 2356a4f78defSmrg --no-silent|--no-quiet) 2357a4f78defSmrg opt_quiet=false 2358a4f78defSmrg func_append preserve_args " $_G_opt" 2359a4f78defSmrg ;; 2360a4f78defSmrg 2361a4f78defSmrg --no-warnings|--no-warning|--no-warn) 2362a4f78defSmrg opt_warning=false 2363a4f78defSmrg func_append preserve_args " $_G_opt" 2364a4f78defSmrg ;; 2365a4f78defSmrg 2366a4f78defSmrg --no-verbose) 2367a4f78defSmrg opt_verbose=false 2368a4f78defSmrg func_append preserve_args " $_G_opt" 2369a4f78defSmrg ;; 2370a4f78defSmrg 2371a4f78defSmrg --silent|--quiet) 2372a4f78defSmrg opt_quiet=: 2373a4f78defSmrg opt_verbose=false 2374a4f78defSmrg func_append preserve_args " $_G_opt" 2375a4f78defSmrg ;; 2376a4f78defSmrg 2377a4f78defSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378a4f78defSmrg opt_tag=$1 2379a4f78defSmrg func_append preserve_args " $_G_opt $1" 2380a4f78defSmrg func_enable_tag "$1" 2381a4f78defSmrg shift 2382a4f78defSmrg ;; 2383a4f78defSmrg 2384a4f78defSmrg --verbose|-v) opt_quiet=false 2385a4f78defSmrg opt_verbose=: 2386a4f78defSmrg func_append preserve_args " $_G_opt" 2387a4f78defSmrg ;; 2388a4f78defSmrg 2389a4f78defSmrg # An option not handled by this hook function: 2390a4f78defSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391a4f78defSmrg esac 2392a4f78defSmrg done 2393a4f78defSmrg 2394a4f78defSmrg 2395a4f78defSmrg # save modified positional parameters for caller 2396a4f78defSmrg func_quote_for_eval ${1+"$@"} 2397a4f78defSmrg libtool_parse_options_result=$func_quote_for_eval_result 2398a4f78defSmrg} 2399a4f78defSmrgfunc_add_hook func_parse_options libtool_parse_options 2400a4f78defSmrg 2401a4f78defSmrg 2402a4f78defSmrg 2403a4f78defSmrg# libtool_validate_options [ARG]... 2404a4f78defSmrg# --------------------------------- 2405a4f78defSmrg# Perform any sanity checks on option settings and/or unconsumed 2406a4f78defSmrg# arguments. 2407a4f78defSmrglibtool_validate_options () 2408a4f78defSmrg{ 2409a4f78defSmrg # save first non-option argument 2410a4f78defSmrg if test 0 -lt $#; then 2411a4f78defSmrg nonopt=$1 2412a4f78defSmrg shift 2413a4f78defSmrg fi 2414a4f78defSmrg 2415a4f78defSmrg # preserve --debug 2416a4f78defSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2417a4f78defSmrg 2418a4f78defSmrg case $host in 2419a4f78defSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420a4f78defSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421a4f78defSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422a4f78defSmrg # don't eliminate duplications in $postdeps and $predeps 2423a4f78defSmrg opt_duplicate_compiler_generated_deps=: 2424a4f78defSmrg ;; 2425a4f78defSmrg *) 2426a4f78defSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427a4f78defSmrg ;; 2428a4f78defSmrg esac 2429a4f78defSmrg 2430a4f78defSmrg $opt_help || { 2431a4f78defSmrg # Sanity checks first: 2432a4f78defSmrg func_check_version_match 2433a4f78defSmrg 2434a4f78defSmrg test yes != "$build_libtool_libs" \ 2435a4f78defSmrg && test yes != "$build_old_libs" \ 2436a4f78defSmrg && func_fatal_configuration "not configured to build any kind of library" 2437a4f78defSmrg 2438a4f78defSmrg # Darwin sucks 2439a4f78defSmrg eval std_shrext=\"$shrext_cmds\" 2440a4f78defSmrg 2441a4f78defSmrg # Only execute mode is allowed to have -dlopen flags. 2442a4f78defSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443a4f78defSmrg func_error "unrecognized option '-dlopen'" 2444a4f78defSmrg $ECHO "$help" 1>&2 2445a4f78defSmrg exit $EXIT_FAILURE 2446a4f78defSmrg fi 2447a4f78defSmrg 2448a4f78defSmrg # Change the help message to a mode-specific one. 2449a4f78defSmrg generic_help=$help 2450a4f78defSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 2451a4f78defSmrg } 2452a4f78defSmrg 2453a4f78defSmrg # Pass back the unparsed argument list 2454a4f78defSmrg func_quote_for_eval ${1+"$@"} 2455a4f78defSmrg libtool_validate_options_result=$func_quote_for_eval_result 2456a4f78defSmrg} 2457a4f78defSmrgfunc_add_hook func_validate_options libtool_validate_options 2458a4f78defSmrg 2459a4f78defSmrg 2460a4f78defSmrg# Process options as early as possible so that --help and --version 2461a4f78defSmrg# can return quickly. 2462a4f78defSmrgfunc_options ${1+"$@"} 2463a4f78defSmrgeval set dummy "$func_options_result"; shift 2464a4f78defSmrg 2465a4f78defSmrg 2466a4f78defSmrg 2467a4f78defSmrg## ----------- ## 2468a4f78defSmrg## Main. ## 2469a4f78defSmrg## ----------- ## 2470a4f78defSmrg 2471a4f78defSmrgmagic='%%%MAGIC variable%%%' 2472a4f78defSmrgmagic_exe='%%%MAGIC EXE variable%%%' 2473a4f78defSmrg 2474a4f78defSmrg# Global variables. 2475a4f78defSmrgextracted_archives= 2476a4f78defSmrgextracted_serial=0 2477a4f78defSmrg 2478a4f78defSmrg# If this variable is set in any of the actions, the command in it 2479a4f78defSmrg# will be execed at the end. This prevents here-documents from being 2480a4f78defSmrg# left over by shells. 2481a4f78defSmrgexec_cmd= 2482a4f78defSmrg 2483a4f78defSmrg 2484a4f78defSmrg# A function that is used when there is no print builtin or printf. 2485a4f78defSmrgfunc_fallback_echo () 2486a4f78defSmrg{ 2487a4f78defSmrg eval 'cat <<_LTECHO_EOF 2488a4f78defSmrg$1 2489a4f78defSmrg_LTECHO_EOF' 2490a4f78defSmrg} 2491a4f78defSmrg 2492a4f78defSmrg# func_generated_by_libtool 2493a4f78defSmrg# True iff stdin has been generated by Libtool. This function is only 2494a4f78defSmrg# a basic sanity check; it will hardly flush out determined imposters. 2495a4f78defSmrgfunc_generated_by_libtool_p () 2496a4f78defSmrg{ 2497a4f78defSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498a4f78defSmrg} 2499a4f78defSmrg 2500a4f78defSmrg# func_lalib_p file 2501a4f78defSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2502a4f78defSmrg# This function is only a basic sanity check; it will hardly flush out 2503a4f78defSmrg# determined imposters. 2504a4f78defSmrgfunc_lalib_p () 2505a4f78defSmrg{ 2506a4f78defSmrg test -f "$1" && 2507a4f78defSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2508a4f78defSmrg} 2509a4f78defSmrg 2510a4f78defSmrg# func_lalib_unsafe_p file 2511a4f78defSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 2512a4f78defSmrg# This function implements the same check as func_lalib_p without 2513a4f78defSmrg# resorting to external programs. To this end, it redirects stdin and 2514a4f78defSmrg# closes it afterwards, without saving the original file descriptor. 2515a4f78defSmrg# As a safety measure, use it only where a negative result would be 2516a4f78defSmrg# fatal anyway. Works if 'file' does not exist. 2517a4f78defSmrgfunc_lalib_unsafe_p () 2518a4f78defSmrg{ 2519a4f78defSmrg lalib_p=no 2520a4f78defSmrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2521a4f78defSmrg for lalib_p_l in 1 2 3 4 2522a4f78defSmrg do 2523a4f78defSmrg read lalib_p_line 2524a4f78defSmrg case $lalib_p_line in 2525a4f78defSmrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2526a4f78defSmrg esac 2527a4f78defSmrg done 2528a4f78defSmrg exec 0<&5 5<&- 2529a4f78defSmrg fi 2530a4f78defSmrg test yes = "$lalib_p" 2531a4f78defSmrg} 2532a4f78defSmrg 2533a4f78defSmrg# func_ltwrapper_script_p file 2534a4f78defSmrg# True iff FILE is a libtool wrapper script 2535a4f78defSmrg# This function is only a basic sanity check; it will hardly flush out 2536a4f78defSmrg# determined imposters. 2537a4f78defSmrgfunc_ltwrapper_script_p () 2538a4f78defSmrg{ 2539a4f78defSmrg test -f "$1" && 2540a4f78defSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2541a4f78defSmrg} 2542a4f78defSmrg 2543a4f78defSmrg# func_ltwrapper_executable_p file 2544a4f78defSmrg# True iff FILE is a libtool wrapper executable 2545a4f78defSmrg# This function is only a basic sanity check; it will hardly flush out 2546a4f78defSmrg# determined imposters. 2547a4f78defSmrgfunc_ltwrapper_executable_p () 2548a4f78defSmrg{ 2549a4f78defSmrg func_ltwrapper_exec_suffix= 2550a4f78defSmrg case $1 in 2551a4f78defSmrg *.exe) ;; 2552a4f78defSmrg *) func_ltwrapper_exec_suffix=.exe ;; 2553a4f78defSmrg esac 2554a4f78defSmrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2555a4f78defSmrg} 2556a4f78defSmrg 2557a4f78defSmrg# func_ltwrapper_scriptname file 2558a4f78defSmrg# Assumes file is an ltwrapper_executable 2559a4f78defSmrg# uses $file to determine the appropriate filename for a 2560a4f78defSmrg# temporary ltwrapper_script. 2561a4f78defSmrgfunc_ltwrapper_scriptname () 2562a4f78defSmrg{ 2563a4f78defSmrg func_dirname_and_basename "$1" "" "." 2564a4f78defSmrg func_stripname '' '.exe' "$func_basename_result" 2565a4f78defSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2566a4f78defSmrg} 2567a4f78defSmrg 2568a4f78defSmrg# func_ltwrapper_p file 2569a4f78defSmrg# True iff FILE is a libtool wrapper script or wrapper executable 2570a4f78defSmrg# This function is only a basic sanity check; it will hardly flush out 2571a4f78defSmrg# determined imposters. 2572a4f78defSmrgfunc_ltwrapper_p () 2573a4f78defSmrg{ 2574a4f78defSmrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2575a4f78defSmrg} 2576a4f78defSmrg 2577a4f78defSmrg 2578a4f78defSmrg# func_execute_cmds commands fail_cmd 2579a4f78defSmrg# Execute tilde-delimited COMMANDS. 2580a4f78defSmrg# If FAIL_CMD is given, eval that upon failure. 2581a4f78defSmrg# FAIL_CMD may read-access the current command in variable CMD! 2582a4f78defSmrgfunc_execute_cmds () 2583a4f78defSmrg{ 2584a4f78defSmrg $debug_cmd 2585a4f78defSmrg 2586a4f78defSmrg save_ifs=$IFS; IFS='~' 2587a4f78defSmrg for cmd in $1; do 2588a4f78defSmrg IFS=$sp$nl 2589a4f78defSmrg eval cmd=\"$cmd\" 2590a4f78defSmrg IFS=$save_ifs 2591a4f78defSmrg func_show_eval "$cmd" "${2-:}" 2592a4f78defSmrg done 2593a4f78defSmrg IFS=$save_ifs 2594a4f78defSmrg} 2595a4f78defSmrg 2596a4f78defSmrg 2597a4f78defSmrg# func_source file 2598a4f78defSmrg# Source FILE, adding directory component if necessary. 2599a4f78defSmrg# Note that it is not necessary on cygwin/mingw to append a dot to 2600a4f78defSmrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2601a4f78defSmrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602a4f78defSmrg# 'FILE.' does not work on cygwin managed mounts. 2603a4f78defSmrgfunc_source () 2604a4f78defSmrg{ 2605a4f78defSmrg $debug_cmd 2606a4f78defSmrg 2607a4f78defSmrg case $1 in 2608a4f78defSmrg */* | *\\*) . "$1" ;; 2609a4f78defSmrg *) . "./$1" ;; 2610a4f78defSmrg esac 2611a4f78defSmrg} 2612a4f78defSmrg 2613a4f78defSmrg 2614a4f78defSmrg# func_resolve_sysroot PATH 2615a4f78defSmrg# Replace a leading = in PATH with a sysroot. Store the result into 2616a4f78defSmrg# func_resolve_sysroot_result 2617a4f78defSmrgfunc_resolve_sysroot () 2618a4f78defSmrg{ 2619a4f78defSmrg func_resolve_sysroot_result=$1 2620a4f78defSmrg case $func_resolve_sysroot_result in 2621a4f78defSmrg =*) 2622a4f78defSmrg func_stripname '=' '' "$func_resolve_sysroot_result" 2623a4f78defSmrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624a4f78defSmrg ;; 2625a4f78defSmrg esac 2626a4f78defSmrg} 2627a4f78defSmrg 2628a4f78defSmrg# func_replace_sysroot PATH 2629a4f78defSmrg# If PATH begins with the sysroot, replace it with = and 2630a4f78defSmrg# store the result into func_replace_sysroot_result. 2631a4f78defSmrgfunc_replace_sysroot () 2632a4f78defSmrg{ 2633a4f78defSmrg case $lt_sysroot:$1 in 2634a4f78defSmrg ?*:"$lt_sysroot"*) 2635a4f78defSmrg func_stripname "$lt_sysroot" '' "$1" 2636a4f78defSmrg func_replace_sysroot_result='='$func_stripname_result 2637a4f78defSmrg ;; 2638a4f78defSmrg *) 2639a4f78defSmrg # Including no sysroot. 2640a4f78defSmrg func_replace_sysroot_result=$1 2641a4f78defSmrg ;; 2642a4f78defSmrg esac 2643a4f78defSmrg} 2644a4f78defSmrg 2645a4f78defSmrg# func_infer_tag arg 2646a4f78defSmrg# Infer tagged configuration to use if any are available and 2647a4f78defSmrg# if one wasn't chosen via the "--tag" command line option. 2648a4f78defSmrg# Only attempt this if the compiler in the base compile 2649a4f78defSmrg# command doesn't match the default compiler. 2650a4f78defSmrg# arg is usually of the form 'gcc ...' 2651a4f78defSmrgfunc_infer_tag () 2652a4f78defSmrg{ 2653a4f78defSmrg $debug_cmd 2654a4f78defSmrg 2655a4f78defSmrg if test -n "$available_tags" && test -z "$tagname"; then 2656a4f78defSmrg CC_quoted= 2657a4f78defSmrg for arg in $CC; do 2658a4f78defSmrg func_append_quoted CC_quoted "$arg" 2659a4f78defSmrg done 2660a4f78defSmrg CC_expanded=`func_echo_all $CC` 2661a4f78defSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2662a4f78defSmrg case $@ in 2663a4f78defSmrg # Blanks in the command may have been stripped by the calling shell, 2664a4f78defSmrg # but not from the CC environment variable when configure was run. 2665a4f78defSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2666a4f78defSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2667a4f78defSmrg # Blanks at the start of $base_compile will cause this to fail 2668a4f78defSmrg # if we don't check for them as well. 2669a4f78defSmrg *) 2670a4f78defSmrg for z in $available_tags; do 2671a4f78defSmrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2672a4f78defSmrg # Evaluate the configuration. 2673a4f78defSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2674a4f78defSmrg CC_quoted= 2675a4f78defSmrg for arg in $CC; do 2676a4f78defSmrg # Double-quote args containing other shell metacharacters. 2677a4f78defSmrg func_append_quoted CC_quoted "$arg" 2678a4f78defSmrg done 2679a4f78defSmrg CC_expanded=`func_echo_all $CC` 2680a4f78defSmrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2681a4f78defSmrg case "$@ " in 2682a4f78defSmrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2683a4f78defSmrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2684a4f78defSmrg # The compiler in the base compile command matches 2685a4f78defSmrg # the one in the tagged configuration. 2686a4f78defSmrg # Assume this is the tagged configuration we want. 2687a4f78defSmrg tagname=$z 2688a4f78defSmrg break 2689a4f78defSmrg ;; 2690a4f78defSmrg esac 2691a4f78defSmrg fi 2692a4f78defSmrg done 2693a4f78defSmrg # If $tagname still isn't set, then no tagged configuration 2694a4f78defSmrg # was found and let the user know that the "--tag" command 2695a4f78defSmrg # line option must be used. 2696a4f78defSmrg if test -z "$tagname"; then 2697a4f78defSmrg func_echo "unable to infer tagged configuration" 2698a4f78defSmrg func_fatal_error "specify a tag with '--tag'" 2699a4f78defSmrg# else 2700a4f78defSmrg# func_verbose "using $tagname tagged configuration" 2701a4f78defSmrg fi 2702a4f78defSmrg ;; 2703a4f78defSmrg esac 2704a4f78defSmrg fi 2705a4f78defSmrg} 2706a4f78defSmrg 2707a4f78defSmrg 2708a4f78defSmrg 2709a4f78defSmrg# func_write_libtool_object output_name pic_name nonpic_name 2710a4f78defSmrg# Create a libtool object file (analogous to a ".la" file), 2711a4f78defSmrg# but don't create it if we're doing a dry run. 2712a4f78defSmrgfunc_write_libtool_object () 2713a4f78defSmrg{ 2714a4f78defSmrg write_libobj=$1 2715a4f78defSmrg if test yes = "$build_libtool_libs"; then 2716a4f78defSmrg write_lobj=\'$2\' 2717a4f78defSmrg else 2718a4f78defSmrg write_lobj=none 2719a4f78defSmrg fi 2720a4f78defSmrg 2721a4f78defSmrg if test yes = "$build_old_libs"; then 2722a4f78defSmrg write_oldobj=\'$3\' 2723a4f78defSmrg else 2724a4f78defSmrg write_oldobj=none 2725a4f78defSmrg fi 2726a4f78defSmrg 2727a4f78defSmrg $opt_dry_run || { 2728a4f78defSmrg cat >${write_libobj}T <<EOF 2729a4f78defSmrg# $write_libobj - a libtool object file 2730a4f78defSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731a4f78defSmrg# 2732a4f78defSmrg# Please DO NOT delete this file! 2733a4f78defSmrg# It is necessary for linking the library. 2734a4f78defSmrg 2735a4f78defSmrg# Name of the PIC object. 2736a4f78defSmrgpic_object=$write_lobj 2737a4f78defSmrg 2738a4f78defSmrg# Name of the non-PIC object 2739a4f78defSmrgnon_pic_object=$write_oldobj 2740a4f78defSmrg 2741a4f78defSmrgEOF 2742a4f78defSmrg $MV "${write_libobj}T" "$write_libobj" 2743a4f78defSmrg } 2744a4f78defSmrg} 2745a4f78defSmrg 2746a4f78defSmrg 2747a4f78defSmrg################################################## 2748a4f78defSmrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749a4f78defSmrg################################################## 2750a4f78defSmrg 2751a4f78defSmrg# func_convert_core_file_wine_to_w32 ARG 2752a4f78defSmrg# Helper function used by file name conversion functions when $build is *nix, 2753a4f78defSmrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754a4f78defSmrg# correctly configured wine environment available, with the winepath program 2755a4f78defSmrg# in $build's $PATH. 2756a4f78defSmrg# 2757a4f78defSmrg# ARG is the $build file name to be converted to w32 format. 2758a4f78defSmrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759a4f78defSmrg# be empty on error (or when ARG is empty) 2760a4f78defSmrgfunc_convert_core_file_wine_to_w32 () 2761a4f78defSmrg{ 2762a4f78defSmrg $debug_cmd 2763a4f78defSmrg 2764a4f78defSmrg func_convert_core_file_wine_to_w32_result=$1 2765a4f78defSmrg if test -n "$1"; then 2766a4f78defSmrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2767a4f78defSmrg # are forced to check the contents of stdout. On the other hand, if the 2768a4f78defSmrg # command is not found, the shell will set an exit code of 127 and print 2769a4f78defSmrg # *an error message* to stdout. So we must check for both error code of 2770a4f78defSmrg # zero AND non-empty stdout, which explains the odd construction: 2771a4f78defSmrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772a4f78defSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773a4f78defSmrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774a4f78defSmrg $SED -e "$sed_naive_backslashify"` 2775a4f78defSmrg else 2776a4f78defSmrg func_convert_core_file_wine_to_w32_result= 2777a4f78defSmrg fi 2778a4f78defSmrg fi 2779a4f78defSmrg} 2780a4f78defSmrg# end: func_convert_core_file_wine_to_w32 2781a4f78defSmrg 2782a4f78defSmrg 2783a4f78defSmrg# func_convert_core_path_wine_to_w32 ARG 2784a4f78defSmrg# Helper function used by path conversion functions when $build is *nix, and 2785a4f78defSmrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786a4f78defSmrg# configured wine environment available, with the winepath program in $build's 2787a4f78defSmrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788a4f78defSmrg# 2789a4f78defSmrg# ARG is path to be converted from $build format to win32. 2790a4f78defSmrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2791a4f78defSmrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792a4f78defSmrg# are convertible, then the result may be empty. 2793a4f78defSmrgfunc_convert_core_path_wine_to_w32 () 2794a4f78defSmrg{ 2795a4f78defSmrg $debug_cmd 2796a4f78defSmrg 2797a4f78defSmrg # unfortunately, winepath doesn't convert paths, only file names 2798a4f78defSmrg func_convert_core_path_wine_to_w32_result= 2799a4f78defSmrg if test -n "$1"; then 2800a4f78defSmrg oldIFS=$IFS 2801a4f78defSmrg IFS=: 2802a4f78defSmrg for func_convert_core_path_wine_to_w32_f in $1; do 2803a4f78defSmrg IFS=$oldIFS 2804a4f78defSmrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805a4f78defSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806a4f78defSmrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807a4f78defSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808a4f78defSmrg else 2809a4f78defSmrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810a4f78defSmrg fi 2811a4f78defSmrg fi 2812a4f78defSmrg done 2813a4f78defSmrg IFS=$oldIFS 2814a4f78defSmrg fi 2815a4f78defSmrg} 2816a4f78defSmrg# end: func_convert_core_path_wine_to_w32 2817a4f78defSmrg 2818a4f78defSmrg 2819a4f78defSmrg# func_cygpath ARGS... 2820a4f78defSmrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821a4f78defSmrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822a4f78defSmrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823a4f78defSmrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824a4f78defSmrg# file name or path is assumed to be in w32 format, as previously converted 2825a4f78defSmrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826a4f78defSmrg# or path in func_cygpath_result (input file name or path is assumed to be in 2827a4f78defSmrg# Cygwin format). Returns an empty string on error. 2828a4f78defSmrg# 2829a4f78defSmrg# ARGS are passed to cygpath, with the last one being the file name or path to 2830a4f78defSmrg# be converted. 2831a4f78defSmrg# 2832a4f78defSmrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833a4f78defSmrg# environment variable; do not put it in $PATH. 2834a4f78defSmrgfunc_cygpath () 2835a4f78defSmrg{ 2836a4f78defSmrg $debug_cmd 2837a4f78defSmrg 2838a4f78defSmrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839a4f78defSmrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840a4f78defSmrg if test "$?" -ne 0; then 2841a4f78defSmrg # on failure, ensure result is empty 2842a4f78defSmrg func_cygpath_result= 2843a4f78defSmrg fi 2844a4f78defSmrg else 2845a4f78defSmrg func_cygpath_result= 2846a4f78defSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847a4f78defSmrg fi 2848a4f78defSmrg} 2849a4f78defSmrg#end: func_cygpath 2850a4f78defSmrg 2851a4f78defSmrg 2852a4f78defSmrg# func_convert_core_msys_to_w32 ARG 2853a4f78defSmrg# Convert file name or path ARG from MSYS format to w32 format. Return 2854a4f78defSmrg# result in func_convert_core_msys_to_w32_result. 2855a4f78defSmrgfunc_convert_core_msys_to_w32 () 2856a4f78defSmrg{ 2857a4f78defSmrg $debug_cmd 2858a4f78defSmrg 2859a4f78defSmrg # awkward: cmd appends spaces to result 2860a4f78defSmrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861a4f78defSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862a4f78defSmrg} 2863a4f78defSmrg#end: func_convert_core_msys_to_w32 2864a4f78defSmrg 2865a4f78defSmrg 2866a4f78defSmrg# func_convert_file_check ARG1 ARG2 2867a4f78defSmrg# Verify that ARG1 (a file name in $build format) was converted to $host 2868a4f78defSmrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869a4f78defSmrg# func_to_host_file_result to ARG1). 2870a4f78defSmrgfunc_convert_file_check () 2871a4f78defSmrg{ 2872a4f78defSmrg $debug_cmd 2873a4f78defSmrg 2874a4f78defSmrg if test -z "$2" && test -n "$1"; then 2875a4f78defSmrg func_error "Could not determine host file name corresponding to" 2876a4f78defSmrg func_error " '$1'" 2877a4f78defSmrg func_error "Continuing, but uninstalled executables may not work." 2878a4f78defSmrg # Fallback: 2879a4f78defSmrg func_to_host_file_result=$1 2880a4f78defSmrg fi 2881a4f78defSmrg} 2882a4f78defSmrg# end func_convert_file_check 2883a4f78defSmrg 2884a4f78defSmrg 2885a4f78defSmrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886a4f78defSmrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2887a4f78defSmrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888a4f78defSmrg# func_to_host_file_result to a simplistic fallback value (see below). 2889a4f78defSmrgfunc_convert_path_check () 2890a4f78defSmrg{ 2891a4f78defSmrg $debug_cmd 2892a4f78defSmrg 2893a4f78defSmrg if test -z "$4" && test -n "$3"; then 2894a4f78defSmrg func_error "Could not determine the host path corresponding to" 2895a4f78defSmrg func_error " '$3'" 2896a4f78defSmrg func_error "Continuing, but uninstalled executables may not work." 2897a4f78defSmrg # Fallback. This is a deliberately simplistic "conversion" and 2898a4f78defSmrg # should not be "improved". See libtool.info. 2899a4f78defSmrg if test "x$1" != "x$2"; then 2900a4f78defSmrg lt_replace_pathsep_chars="s|$1|$2|g" 2901a4f78defSmrg func_to_host_path_result=`echo "$3" | 2902a4f78defSmrg $SED -e "$lt_replace_pathsep_chars"` 2903a4f78defSmrg else 2904a4f78defSmrg func_to_host_path_result=$3 2905a4f78defSmrg fi 2906a4f78defSmrg fi 2907a4f78defSmrg} 2908a4f78defSmrg# end func_convert_path_check 2909a4f78defSmrg 2910a4f78defSmrg 2911a4f78defSmrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912a4f78defSmrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913a4f78defSmrg# and appending REPL if ORIG matches BACKPAT. 2914a4f78defSmrgfunc_convert_path_front_back_pathsep () 2915a4f78defSmrg{ 2916a4f78defSmrg $debug_cmd 2917a4f78defSmrg 2918a4f78defSmrg case $4 in 2919a4f78defSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920a4f78defSmrg ;; 2921a4f78defSmrg esac 2922a4f78defSmrg case $4 in 2923a4f78defSmrg $2 ) func_append func_to_host_path_result "$3" 2924a4f78defSmrg ;; 2925a4f78defSmrg esac 2926a4f78defSmrg} 2927a4f78defSmrg# end func_convert_path_front_back_pathsep 2928a4f78defSmrg 2929a4f78defSmrg 2930a4f78defSmrg################################################## 2931a4f78defSmrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932a4f78defSmrg################################################## 2933a4f78defSmrg# invoked via '$to_host_file_cmd ARG' 2934a4f78defSmrg# 2935a4f78defSmrg# In each case, ARG is the path to be converted from $build to $host format. 2936a4f78defSmrg# Result will be available in $func_to_host_file_result. 2937a4f78defSmrg 2938a4f78defSmrg 2939a4f78defSmrg# func_to_host_file ARG 2940a4f78defSmrg# Converts the file name ARG from $build format to $host format. Return result 2941a4f78defSmrg# in func_to_host_file_result. 2942a4f78defSmrgfunc_to_host_file () 2943a4f78defSmrg{ 2944a4f78defSmrg $debug_cmd 2945a4f78defSmrg 2946a4f78defSmrg $to_host_file_cmd "$1" 2947a4f78defSmrg} 2948a4f78defSmrg# end func_to_host_file 2949a4f78defSmrg 2950a4f78defSmrg 2951a4f78defSmrg# func_to_tool_file ARG LAZY 2952a4f78defSmrg# converts the file name ARG from $build format to toolchain format. Return 2953a4f78defSmrg# result in func_to_tool_file_result. If the conversion in use is listed 2954a4f78defSmrg# in (the comma separated) LAZY, no conversion takes place. 2955a4f78defSmrgfunc_to_tool_file () 2956a4f78defSmrg{ 2957a4f78defSmrg $debug_cmd 2958a4f78defSmrg 2959a4f78defSmrg case ,$2, in 2960a4f78defSmrg *,"$to_tool_file_cmd",*) 2961a4f78defSmrg func_to_tool_file_result=$1 2962a4f78defSmrg ;; 2963a4f78defSmrg *) 2964a4f78defSmrg $to_tool_file_cmd "$1" 2965a4f78defSmrg func_to_tool_file_result=$func_to_host_file_result 2966a4f78defSmrg ;; 2967a4f78defSmrg esac 2968a4f78defSmrg} 2969a4f78defSmrg# end func_to_tool_file 2970a4f78defSmrg 2971a4f78defSmrg 2972a4f78defSmrg# func_convert_file_noop ARG 2973a4f78defSmrg# Copy ARG to func_to_host_file_result. 2974a4f78defSmrgfunc_convert_file_noop () 2975a4f78defSmrg{ 2976a4f78defSmrg func_to_host_file_result=$1 2977a4f78defSmrg} 2978a4f78defSmrg# end func_convert_file_noop 2979a4f78defSmrg 2980a4f78defSmrg 2981a4f78defSmrg# func_convert_file_msys_to_w32 ARG 2982a4f78defSmrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983a4f78defSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 2984a4f78defSmrg# func_to_host_file_result. 2985a4f78defSmrgfunc_convert_file_msys_to_w32 () 2986a4f78defSmrg{ 2987a4f78defSmrg $debug_cmd 2988a4f78defSmrg 2989a4f78defSmrg func_to_host_file_result=$1 2990a4f78defSmrg if test -n "$1"; then 2991a4f78defSmrg func_convert_core_msys_to_w32 "$1" 2992a4f78defSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993a4f78defSmrg fi 2994a4f78defSmrg func_convert_file_check "$1" "$func_to_host_file_result" 2995a4f78defSmrg} 2996a4f78defSmrg# end func_convert_file_msys_to_w32 2997a4f78defSmrg 2998a4f78defSmrg 2999a4f78defSmrg# func_convert_file_cygwin_to_w32 ARG 3000a4f78defSmrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3001a4f78defSmrg# func_to_host_file_result. 3002a4f78defSmrgfunc_convert_file_cygwin_to_w32 () 3003a4f78defSmrg{ 3004a4f78defSmrg $debug_cmd 3005a4f78defSmrg 3006a4f78defSmrg func_to_host_file_result=$1 3007a4f78defSmrg if test -n "$1"; then 3008a4f78defSmrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009a4f78defSmrg # LT_CYGPATH in this case. 3010a4f78defSmrg func_to_host_file_result=`cygpath -m "$1"` 3011a4f78defSmrg fi 3012a4f78defSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3013a4f78defSmrg} 3014a4f78defSmrg# end func_convert_file_cygwin_to_w32 3015a4f78defSmrg 3016a4f78defSmrg 3017a4f78defSmrg# func_convert_file_nix_to_w32 ARG 3018a4f78defSmrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019a4f78defSmrg# and a working winepath. Returns result in func_to_host_file_result. 3020a4f78defSmrgfunc_convert_file_nix_to_w32 () 3021a4f78defSmrg{ 3022a4f78defSmrg $debug_cmd 3023a4f78defSmrg 3024a4f78defSmrg func_to_host_file_result=$1 3025a4f78defSmrg if test -n "$1"; then 3026a4f78defSmrg func_convert_core_file_wine_to_w32 "$1" 3027a4f78defSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028a4f78defSmrg fi 3029a4f78defSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3030a4f78defSmrg} 3031a4f78defSmrg# end func_convert_file_nix_to_w32 3032a4f78defSmrg 3033a4f78defSmrg 3034a4f78defSmrg# func_convert_file_msys_to_cygwin ARG 3035a4f78defSmrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036a4f78defSmrg# Returns result in func_to_host_file_result. 3037a4f78defSmrgfunc_convert_file_msys_to_cygwin () 3038a4f78defSmrg{ 3039a4f78defSmrg $debug_cmd 3040a4f78defSmrg 3041a4f78defSmrg func_to_host_file_result=$1 3042a4f78defSmrg if test -n "$1"; then 3043a4f78defSmrg func_convert_core_msys_to_w32 "$1" 3044a4f78defSmrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045a4f78defSmrg func_to_host_file_result=$func_cygpath_result 3046a4f78defSmrg fi 3047a4f78defSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3048a4f78defSmrg} 3049a4f78defSmrg# end func_convert_file_msys_to_cygwin 3050a4f78defSmrg 3051a4f78defSmrg 3052a4f78defSmrg# func_convert_file_nix_to_cygwin ARG 3053a4f78defSmrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054a4f78defSmrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055a4f78defSmrg# in func_to_host_file_result. 3056a4f78defSmrgfunc_convert_file_nix_to_cygwin () 3057a4f78defSmrg{ 3058a4f78defSmrg $debug_cmd 3059a4f78defSmrg 3060a4f78defSmrg func_to_host_file_result=$1 3061a4f78defSmrg if test -n "$1"; then 3062a4f78defSmrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063a4f78defSmrg func_convert_core_file_wine_to_w32 "$1" 3064a4f78defSmrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065a4f78defSmrg func_to_host_file_result=$func_cygpath_result 3066a4f78defSmrg fi 3067a4f78defSmrg func_convert_file_check "$1" "$func_to_host_file_result" 3068a4f78defSmrg} 3069a4f78defSmrg# end func_convert_file_nix_to_cygwin 3070a4f78defSmrg 3071a4f78defSmrg 3072a4f78defSmrg############################################# 3073a4f78defSmrg# $build to $host PATH CONVERSION FUNCTIONS # 3074a4f78defSmrg############################################# 3075a4f78defSmrg# invoked via '$to_host_path_cmd ARG' 3076a4f78defSmrg# 3077a4f78defSmrg# In each case, ARG is the path to be converted from $build to $host format. 3078a4f78defSmrg# The result will be available in $func_to_host_path_result. 3079a4f78defSmrg# 3080a4f78defSmrg# Path separators are also converted from $build format to $host format. If 3081a4f78defSmrg# ARG begins or ends with a path separator character, it is preserved (but 3082a4f78defSmrg# converted to $host format) on output. 3083a4f78defSmrg# 3084a4f78defSmrg# All path conversion functions are named using the following convention: 3085a4f78defSmrg# file name conversion function : func_convert_file_X_to_Y () 3086a4f78defSmrg# path conversion function : func_convert_path_X_to_Y () 3087a4f78defSmrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3088a4f78defSmrg# same. If conversion functions are added for new $build/$host combinations, 3089a4f78defSmrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090a4f78defSmrg# will break. 3091a4f78defSmrg 3092a4f78defSmrg 3093a4f78defSmrg# func_init_to_host_path_cmd 3094a4f78defSmrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095a4f78defSmrg# appropriate value, based on the value of $to_host_file_cmd. 3096a4f78defSmrgto_host_path_cmd= 3097a4f78defSmrgfunc_init_to_host_path_cmd () 3098a4f78defSmrg{ 3099a4f78defSmrg $debug_cmd 3100a4f78defSmrg 3101a4f78defSmrg if test -z "$to_host_path_cmd"; then 3102a4f78defSmrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103a4f78defSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3104a4f78defSmrg fi 3105a4f78defSmrg} 3106a4f78defSmrg 3107a4f78defSmrg 3108a4f78defSmrg# func_to_host_path ARG 3109a4f78defSmrg# Converts the path ARG from $build format to $host format. Return result 3110a4f78defSmrg# in func_to_host_path_result. 3111a4f78defSmrgfunc_to_host_path () 3112a4f78defSmrg{ 3113a4f78defSmrg $debug_cmd 3114a4f78defSmrg 3115a4f78defSmrg func_init_to_host_path_cmd 3116a4f78defSmrg $to_host_path_cmd "$1" 3117a4f78defSmrg} 3118a4f78defSmrg# end func_to_host_path 3119a4f78defSmrg 3120a4f78defSmrg 3121a4f78defSmrg# func_convert_path_noop ARG 3122a4f78defSmrg# Copy ARG to func_to_host_path_result. 3123a4f78defSmrgfunc_convert_path_noop () 3124a4f78defSmrg{ 3125a4f78defSmrg func_to_host_path_result=$1 3126a4f78defSmrg} 3127a4f78defSmrg# end func_convert_path_noop 3128a4f78defSmrg 3129a4f78defSmrg 3130a4f78defSmrg# func_convert_path_msys_to_w32 ARG 3131a4f78defSmrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132a4f78defSmrg# conversion to w32 is not available inside the cwrapper. Returns result in 3133a4f78defSmrg# func_to_host_path_result. 3134a4f78defSmrgfunc_convert_path_msys_to_w32 () 3135a4f78defSmrg{ 3136a4f78defSmrg $debug_cmd 3137a4f78defSmrg 3138a4f78defSmrg func_to_host_path_result=$1 3139a4f78defSmrg if test -n "$1"; then 3140a4f78defSmrg # Remove leading and trailing path separator characters from ARG. MSYS 3141a4f78defSmrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142a4f78defSmrg # and winepath ignores them completely. 3143a4f78defSmrg func_stripname : : "$1" 3144a4f78defSmrg func_to_host_path_tmp1=$func_stripname_result 3145a4f78defSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146a4f78defSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147a4f78defSmrg func_convert_path_check : ";" \ 3148a4f78defSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149a4f78defSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150a4f78defSmrg fi 3151a4f78defSmrg} 3152a4f78defSmrg# end func_convert_path_msys_to_w32 3153a4f78defSmrg 3154a4f78defSmrg 3155a4f78defSmrg# func_convert_path_cygwin_to_w32 ARG 3156a4f78defSmrg# Convert path ARG from Cygwin to w32 format. Returns result in 3157a4f78defSmrg# func_to_host_file_result. 3158a4f78defSmrgfunc_convert_path_cygwin_to_w32 () 3159a4f78defSmrg{ 3160a4f78defSmrg $debug_cmd 3161a4f78defSmrg 3162a4f78defSmrg func_to_host_path_result=$1 3163a4f78defSmrg if test -n "$1"; then 3164a4f78defSmrg # See func_convert_path_msys_to_w32: 3165a4f78defSmrg func_stripname : : "$1" 3166a4f78defSmrg func_to_host_path_tmp1=$func_stripname_result 3167a4f78defSmrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168a4f78defSmrg func_convert_path_check : ";" \ 3169a4f78defSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170a4f78defSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171a4f78defSmrg fi 3172a4f78defSmrg} 3173a4f78defSmrg# end func_convert_path_cygwin_to_w32 3174a4f78defSmrg 3175a4f78defSmrg 3176a4f78defSmrg# func_convert_path_nix_to_w32 ARG 3177a4f78defSmrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178a4f78defSmrg# a working winepath. Returns result in func_to_host_file_result. 3179a4f78defSmrgfunc_convert_path_nix_to_w32 () 3180a4f78defSmrg{ 3181a4f78defSmrg $debug_cmd 3182a4f78defSmrg 3183a4f78defSmrg func_to_host_path_result=$1 3184a4f78defSmrg if test -n "$1"; then 3185a4f78defSmrg # See func_convert_path_msys_to_w32: 3186a4f78defSmrg func_stripname : : "$1" 3187a4f78defSmrg func_to_host_path_tmp1=$func_stripname_result 3188a4f78defSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189a4f78defSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190a4f78defSmrg func_convert_path_check : ";" \ 3191a4f78defSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192a4f78defSmrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193a4f78defSmrg fi 3194a4f78defSmrg} 3195a4f78defSmrg# end func_convert_path_nix_to_w32 3196a4f78defSmrg 3197a4f78defSmrg 3198a4f78defSmrg# func_convert_path_msys_to_cygwin ARG 3199a4f78defSmrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200a4f78defSmrg# Returns result in func_to_host_file_result. 3201a4f78defSmrgfunc_convert_path_msys_to_cygwin () 3202a4f78defSmrg{ 3203a4f78defSmrg $debug_cmd 3204a4f78defSmrg 3205a4f78defSmrg func_to_host_path_result=$1 3206a4f78defSmrg if test -n "$1"; then 3207a4f78defSmrg # See func_convert_path_msys_to_w32: 3208a4f78defSmrg func_stripname : : "$1" 3209a4f78defSmrg func_to_host_path_tmp1=$func_stripname_result 3210a4f78defSmrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211a4f78defSmrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212a4f78defSmrg func_to_host_path_result=$func_cygpath_result 3213a4f78defSmrg func_convert_path_check : : \ 3214a4f78defSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215a4f78defSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216a4f78defSmrg fi 3217a4f78defSmrg} 3218a4f78defSmrg# end func_convert_path_msys_to_cygwin 3219a4f78defSmrg 3220a4f78defSmrg 3221a4f78defSmrg# func_convert_path_nix_to_cygwin ARG 3222a4f78defSmrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223a4f78defSmrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224a4f78defSmrg# func_to_host_file_result. 3225a4f78defSmrgfunc_convert_path_nix_to_cygwin () 3226a4f78defSmrg{ 3227a4f78defSmrg $debug_cmd 3228a4f78defSmrg 3229a4f78defSmrg func_to_host_path_result=$1 3230a4f78defSmrg if test -n "$1"; then 3231a4f78defSmrg # Remove leading and trailing path separator characters from 3232a4f78defSmrg # ARG. msys behavior is inconsistent here, cygpath turns them 3233a4f78defSmrg # into '.;' and ';.', and winepath ignores them completely. 3234a4f78defSmrg func_stripname : : "$1" 3235a4f78defSmrg func_to_host_path_tmp1=$func_stripname_result 3236a4f78defSmrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237a4f78defSmrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238a4f78defSmrg func_to_host_path_result=$func_cygpath_result 3239a4f78defSmrg func_convert_path_check : : \ 3240a4f78defSmrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241a4f78defSmrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242a4f78defSmrg fi 3243a4f78defSmrg} 3244a4f78defSmrg# end func_convert_path_nix_to_cygwin 3245a4f78defSmrg 3246a4f78defSmrg 3247a4f78defSmrg# func_dll_def_p FILE 3248a4f78defSmrg# True iff FILE is a Windows DLL '.def' file. 3249a4f78defSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250a4f78defSmrgfunc_dll_def_p () 3251a4f78defSmrg{ 3252a4f78defSmrg $debug_cmd 3253a4f78defSmrg 3254a4f78defSmrg func_dll_def_p_tmp=`$SED -n \ 3255a4f78defSmrg -e 's/^[ ]*//' \ 3256a4f78defSmrg -e '/^\(;.*\)*$/d' \ 3257a4f78defSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258a4f78defSmrg -e q \ 3259a4f78defSmrg "$1"` 3260a4f78defSmrg test DEF = "$func_dll_def_p_tmp" 3261a4f78defSmrg} 3262a4f78defSmrg 3263a4f78defSmrg 3264a4f78defSmrg# func_mode_compile arg... 3265a4f78defSmrgfunc_mode_compile () 3266a4f78defSmrg{ 3267a4f78defSmrg $debug_cmd 3268a4f78defSmrg 3269a4f78defSmrg # Get the compilation command and the source file. 3270a4f78defSmrg base_compile= 3271a4f78defSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3272a4f78defSmrg suppress_opt=yes 3273a4f78defSmrg suppress_output= 3274a4f78defSmrg arg_mode=normal 3275a4f78defSmrg libobj= 3276a4f78defSmrg later= 3277a4f78defSmrg pie_flag= 3278a4f78defSmrg 3279a4f78defSmrg for arg 3280a4f78defSmrg do 3281a4f78defSmrg case $arg_mode in 3282a4f78defSmrg arg ) 3283a4f78defSmrg # do not "continue". Instead, add this to base_compile 3284a4f78defSmrg lastarg=$arg 3285a4f78defSmrg arg_mode=normal 3286a4f78defSmrg ;; 3287a4f78defSmrg 3288a4f78defSmrg target ) 3289a4f78defSmrg libobj=$arg 3290a4f78defSmrg arg_mode=normal 3291a4f78defSmrg continue 3292a4f78defSmrg ;; 3293a4f78defSmrg 3294a4f78defSmrg normal ) 3295a4f78defSmrg # Accept any command-line options. 3296a4f78defSmrg case $arg in 3297a4f78defSmrg -o) 3298a4f78defSmrg test -n "$libobj" && \ 3299a4f78defSmrg func_fatal_error "you cannot specify '-o' more than once" 3300a4f78defSmrg arg_mode=target 3301a4f78defSmrg continue 3302a4f78defSmrg ;; 3303a4f78defSmrg 3304a4f78defSmrg -pie | -fpie | -fPIE) 3305a4f78defSmrg func_append pie_flag " $arg" 3306a4f78defSmrg continue 3307a4f78defSmrg ;; 3308a4f78defSmrg 3309a4f78defSmrg -shared | -static | -prefer-pic | -prefer-non-pic) 3310a4f78defSmrg func_append later " $arg" 3311a4f78defSmrg continue 3312a4f78defSmrg ;; 3313a4f78defSmrg 3314a4f78defSmrg -no-suppress) 3315a4f78defSmrg suppress_opt=no 3316a4f78defSmrg continue 3317a4f78defSmrg ;; 3318a4f78defSmrg 3319a4f78defSmrg -Xcompiler) 3320a4f78defSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 3321a4f78defSmrg continue # The current "srcfile" will either be retained or 3322a4f78defSmrg ;; # replaced later. I would guess that would be a bug. 3323a4f78defSmrg 3324a4f78defSmrg -Wc,*) 3325a4f78defSmrg func_stripname '-Wc,' '' "$arg" 3326a4f78defSmrg args=$func_stripname_result 3327a4f78defSmrg lastarg= 3328a4f78defSmrg save_ifs=$IFS; IFS=, 3329a4f78defSmrg for arg in $args; do 3330a4f78defSmrg IFS=$save_ifs 3331a4f78defSmrg func_append_quoted lastarg "$arg" 3332a4f78defSmrg done 3333a4f78defSmrg IFS=$save_ifs 3334a4f78defSmrg func_stripname ' ' '' "$lastarg" 3335a4f78defSmrg lastarg=$func_stripname_result 3336a4f78defSmrg 3337a4f78defSmrg # Add the arguments to base_compile. 3338a4f78defSmrg func_append base_compile " $lastarg" 3339a4f78defSmrg continue 3340a4f78defSmrg ;; 3341a4f78defSmrg 3342a4f78defSmrg *) 3343a4f78defSmrg # Accept the current argument as the source file. 3344a4f78defSmrg # The previous "srcfile" becomes the current argument. 3345a4f78defSmrg # 3346a4f78defSmrg lastarg=$srcfile 3347a4f78defSmrg srcfile=$arg 3348a4f78defSmrg ;; 3349a4f78defSmrg esac # case $arg 3350a4f78defSmrg ;; 3351a4f78defSmrg esac # case $arg_mode 3352a4f78defSmrg 3353a4f78defSmrg # Aesthetically quote the previous argument. 3354a4f78defSmrg func_append_quoted base_compile "$lastarg" 3355a4f78defSmrg done # for arg 3356a4f78defSmrg 3357a4f78defSmrg case $arg_mode in 3358a4f78defSmrg arg) 3359a4f78defSmrg func_fatal_error "you must specify an argument for -Xcompile" 3360a4f78defSmrg ;; 3361a4f78defSmrg target) 3362a4f78defSmrg func_fatal_error "you must specify a target with '-o'" 3363a4f78defSmrg ;; 3364a4f78defSmrg *) 3365a4f78defSmrg # Get the name of the library object. 3366a4f78defSmrg test -z "$libobj" && { 3367a4f78defSmrg func_basename "$srcfile" 3368a4f78defSmrg libobj=$func_basename_result 3369a4f78defSmrg } 3370a4f78defSmrg ;; 3371a4f78defSmrg esac 3372a4f78defSmrg 3373a4f78defSmrg # Recognize several different file suffixes. 3374a4f78defSmrg # If the user specifies -o file.o, it is replaced with file.lo 3375a4f78defSmrg case $libobj in 3376a4f78defSmrg *.[cCFSifmso] | \ 3377a4f78defSmrg *.ada | *.adb | *.ads | *.asm | \ 3378a4f78defSmrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379a4f78defSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3380a4f78defSmrg func_xform "$libobj" 3381a4f78defSmrg libobj=$func_xform_result 3382a4f78defSmrg ;; 3383a4f78defSmrg esac 3384a4f78defSmrg 3385a4f78defSmrg case $libobj in 3386a4f78defSmrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387a4f78defSmrg *) 3388a4f78defSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3389a4f78defSmrg ;; 3390a4f78defSmrg esac 3391a4f78defSmrg 3392a4f78defSmrg func_infer_tag $base_compile 3393a4f78defSmrg 3394a4f78defSmrg for arg in $later; do 3395a4f78defSmrg case $arg in 3396a4f78defSmrg -shared) 3397a4f78defSmrg test yes = "$build_libtool_libs" \ 3398a4f78defSmrg || func_fatal_configuration "cannot build a shared library" 3399a4f78defSmrg build_old_libs=no 3400a4f78defSmrg continue 3401a4f78defSmrg ;; 3402a4f78defSmrg 3403a4f78defSmrg -static) 3404a4f78defSmrg build_libtool_libs=no 3405a4f78defSmrg build_old_libs=yes 3406a4f78defSmrg continue 3407a4f78defSmrg ;; 3408a4f78defSmrg 3409a4f78defSmrg -prefer-pic) 3410a4f78defSmrg pic_mode=yes 3411a4f78defSmrg continue 3412a4f78defSmrg ;; 3413a4f78defSmrg 3414a4f78defSmrg -prefer-non-pic) 3415a4f78defSmrg pic_mode=no 3416a4f78defSmrg continue 3417a4f78defSmrg ;; 3418a4f78defSmrg esac 3419a4f78defSmrg done 3420a4f78defSmrg 3421a4f78defSmrg func_quote_for_eval "$libobj" 3422a4f78defSmrg test "X$libobj" != "X$func_quote_for_eval_result" \ 3423a4f78defSmrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424a4f78defSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3425a4f78defSmrg func_dirname_and_basename "$obj" "/" "" 3426a4f78defSmrg objname=$func_basename_result 3427a4f78defSmrg xdir=$func_dirname_result 3428a4f78defSmrg lobj=$xdir$objdir/$objname 3429a4f78defSmrg 3430a4f78defSmrg test -z "$base_compile" && \ 3431a4f78defSmrg func_fatal_help "you must specify a compilation command" 3432a4f78defSmrg 3433a4f78defSmrg # Delete any leftover library objects. 3434a4f78defSmrg if test yes = "$build_old_libs"; then 3435a4f78defSmrg removelist="$obj $lobj $libobj ${libobj}T" 3436a4f78defSmrg else 3437a4f78defSmrg removelist="$lobj $libobj ${libobj}T" 3438a4f78defSmrg fi 3439a4f78defSmrg 3440a4f78defSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 3441a4f78defSmrg case $host_os in 3442a4f78defSmrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3443a4f78defSmrg pic_mode=default 3444a4f78defSmrg ;; 3445a4f78defSmrg esac 3446a4f78defSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447a4f78defSmrg # non-PIC code in shared libraries is not supported 3448a4f78defSmrg pic_mode=default 3449a4f78defSmrg fi 3450a4f78defSmrg 3451a4f78defSmrg # Calculate the filename of the output object if compiler does 3452a4f78defSmrg # not support -o with -c 3453a4f78defSmrg if test no = "$compiler_c_o"; then 3454a4f78defSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455a4f78defSmrg lockfile=$output_obj.lock 3456a4f78defSmrg else 3457a4f78defSmrg output_obj= 3458a4f78defSmrg need_locks=no 3459a4f78defSmrg lockfile= 3460a4f78defSmrg fi 3461a4f78defSmrg 3462a4f78defSmrg # Lock this critical section if it is needed 3463a4f78defSmrg # We use this script file to make the link, it avoids creating a new file 3464a4f78defSmrg if test yes = "$need_locks"; then 3465a4f78defSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3466a4f78defSmrg func_echo "Waiting for $lockfile to be removed" 3467a4f78defSmrg sleep 2 3468a4f78defSmrg done 3469a4f78defSmrg elif test warn = "$need_locks"; then 3470a4f78defSmrg if test -f "$lockfile"; then 3471a4f78defSmrg $ECHO "\ 3472a4f78defSmrg*** ERROR, $lockfile exists and contains: 3473a4f78defSmrg`cat $lockfile 2>/dev/null` 3474a4f78defSmrg 3475a4f78defSmrgThis indicates that another process is trying to use the same 3476a4f78defSmrgtemporary object file, and libtool could not work around it because 3477a4f78defSmrgyour compiler does not support '-c' and '-o' together. If you 3478a4f78defSmrgrepeat this compilation, it may succeed, by chance, but you had better 3479a4f78defSmrgavoid parallel builds (make -j) in this platform, or get a better 3480a4f78defSmrgcompiler." 3481a4f78defSmrg 3482a4f78defSmrg $opt_dry_run || $RM $removelist 3483a4f78defSmrg exit $EXIT_FAILURE 3484a4f78defSmrg fi 3485a4f78defSmrg func_append removelist " $output_obj" 3486a4f78defSmrg $ECHO "$srcfile" > "$lockfile" 3487a4f78defSmrg fi 3488a4f78defSmrg 3489a4f78defSmrg $opt_dry_run || $RM $removelist 3490a4f78defSmrg func_append removelist " $lockfile" 3491a4f78defSmrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3492a4f78defSmrg 3493a4f78defSmrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494a4f78defSmrg srcfile=$func_to_tool_file_result 3495a4f78defSmrg func_quote_for_eval "$srcfile" 3496a4f78defSmrg qsrcfile=$func_quote_for_eval_result 3497a4f78defSmrg 3498a4f78defSmrg # Only build a PIC object if we are building libtool libraries. 3499a4f78defSmrg if test yes = "$build_libtool_libs"; then 3500a4f78defSmrg # Without this assignment, base_compile gets emptied. 3501a4f78defSmrg fbsd_hideous_sh_bug=$base_compile 3502a4f78defSmrg 3503a4f78defSmrg if test no != "$pic_mode"; then 3504a4f78defSmrg command="$base_compile $qsrcfile $pic_flag" 3505a4f78defSmrg else 3506a4f78defSmrg # Don't build PIC code 3507a4f78defSmrg command="$base_compile $qsrcfile" 3508a4f78defSmrg fi 3509a4f78defSmrg 3510a4f78defSmrg func_mkdir_p "$xdir$objdir" 3511a4f78defSmrg 3512a4f78defSmrg if test -z "$output_obj"; then 3513a4f78defSmrg # Place PIC objects in $objdir 3514a4f78defSmrg func_append command " -o $lobj" 3515a4f78defSmrg fi 3516a4f78defSmrg 3517a4f78defSmrg func_show_eval_locale "$command" \ 3518a4f78defSmrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519a4f78defSmrg 3520a4f78defSmrg if test warn = "$need_locks" && 3521a4f78defSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3522a4f78defSmrg $ECHO "\ 3523a4f78defSmrg*** ERROR, $lockfile contains: 3524a4f78defSmrg`cat $lockfile 2>/dev/null` 3525a4f78defSmrg 3526a4f78defSmrgbut it should contain: 3527a4f78defSmrg$srcfile 3528a4f78defSmrg 3529a4f78defSmrgThis indicates that another process is trying to use the same 3530a4f78defSmrgtemporary object file, and libtool could not work around it because 3531a4f78defSmrgyour compiler does not support '-c' and '-o' together. If you 3532a4f78defSmrgrepeat this compilation, it may succeed, by chance, but you had better 3533a4f78defSmrgavoid parallel builds (make -j) in this platform, or get a better 3534a4f78defSmrgcompiler." 3535a4f78defSmrg 3536a4f78defSmrg $opt_dry_run || $RM $removelist 3537a4f78defSmrg exit $EXIT_FAILURE 3538a4f78defSmrg fi 3539a4f78defSmrg 3540a4f78defSmrg # Just move the object if needed, then go on to compile the next one 3541a4f78defSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3542a4f78defSmrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3543a4f78defSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544a4f78defSmrg fi 3545a4f78defSmrg 3546a4f78defSmrg # Allow error messages only from the first compilation. 3547a4f78defSmrg if test yes = "$suppress_opt"; then 3548a4f78defSmrg suppress_output=' >/dev/null 2>&1' 3549a4f78defSmrg fi 3550a4f78defSmrg fi 3551a4f78defSmrg 3552a4f78defSmrg # Only build a position-dependent object if we build old libraries. 3553a4f78defSmrg if test yes = "$build_old_libs"; then 3554a4f78defSmrg if test yes != "$pic_mode"; then 3555a4f78defSmrg # Don't build PIC code 3556a4f78defSmrg command="$base_compile $qsrcfile$pie_flag" 3557a4f78defSmrg else 3558a4f78defSmrg command="$base_compile $qsrcfile $pic_flag" 3559a4f78defSmrg fi 3560a4f78defSmrg if test yes = "$compiler_c_o"; then 3561a4f78defSmrg func_append command " -o $obj" 3562a4f78defSmrg fi 3563a4f78defSmrg 3564a4f78defSmrg # Suppress compiler output if we already did a PIC compilation. 3565a4f78defSmrg func_append command "$suppress_output" 3566a4f78defSmrg func_show_eval_locale "$command" \ 3567a4f78defSmrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568a4f78defSmrg 3569a4f78defSmrg if test warn = "$need_locks" && 3570a4f78defSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3571a4f78defSmrg $ECHO "\ 3572a4f78defSmrg*** ERROR, $lockfile contains: 3573a4f78defSmrg`cat $lockfile 2>/dev/null` 3574a4f78defSmrg 3575a4f78defSmrgbut it should contain: 3576a4f78defSmrg$srcfile 3577a4f78defSmrg 3578a4f78defSmrgThis indicates that another process is trying to use the same 3579a4f78defSmrgtemporary object file, and libtool could not work around it because 3580a4f78defSmrgyour compiler does not support '-c' and '-o' together. If you 3581a4f78defSmrgrepeat this compilation, it may succeed, by chance, but you had better 3582a4f78defSmrgavoid parallel builds (make -j) in this platform, or get a better 3583a4f78defSmrgcompiler." 3584a4f78defSmrg 3585a4f78defSmrg $opt_dry_run || $RM $removelist 3586a4f78defSmrg exit $EXIT_FAILURE 3587a4f78defSmrg fi 3588a4f78defSmrg 3589a4f78defSmrg # Just move the object if needed 3590a4f78defSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3591a4f78defSmrg func_show_eval '$MV "$output_obj" "$obj"' \ 3592a4f78defSmrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593a4f78defSmrg fi 3594a4f78defSmrg fi 3595a4f78defSmrg 3596a4f78defSmrg $opt_dry_run || { 3597a4f78defSmrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598a4f78defSmrg 3599a4f78defSmrg # Unlock the critical section if it was locked 3600a4f78defSmrg if test no != "$need_locks"; then 3601a4f78defSmrg removelist=$lockfile 3602a4f78defSmrg $RM "$lockfile" 3603a4f78defSmrg fi 3604a4f78defSmrg } 3605a4f78defSmrg 3606a4f78defSmrg exit $EXIT_SUCCESS 3607a4f78defSmrg} 3608a4f78defSmrg 3609a4f78defSmrg$opt_help || { 3610a4f78defSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3611a4f78defSmrg} 3612a4f78defSmrg 3613a4f78defSmrgfunc_mode_help () 3614a4f78defSmrg{ 3615a4f78defSmrg # We need to display help for each of the modes. 3616a4f78defSmrg case $opt_mode in 3617a4f78defSmrg "") 3618a4f78defSmrg # Generic help is extracted from the usage comments 3619a4f78defSmrg # at the start of this file. 3620a4f78defSmrg func_help 3621a4f78defSmrg ;; 3622a4f78defSmrg 3623a4f78defSmrg clean) 3624a4f78defSmrg $ECHO \ 3625a4f78defSmrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626a4f78defSmrg 3627a4f78defSmrgRemove files from the build directory. 3628a4f78defSmrg 3629a4f78defSmrgRM is the name of the program to use to delete files associated with each FILE 3630a4f78defSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3631a4f78defSmrgto RM. 3632a4f78defSmrg 3633a4f78defSmrgIf FILE is a libtool library, object or program, all the files associated 3634a4f78defSmrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 3635a4f78defSmrg ;; 3636a4f78defSmrg 3637a4f78defSmrg compile) 3638a4f78defSmrg $ECHO \ 3639a4f78defSmrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640a4f78defSmrg 3641a4f78defSmrgCompile a source file into a libtool library object. 3642a4f78defSmrg 3643a4f78defSmrgThis mode accepts the following additional options: 3644a4f78defSmrg 3645a4f78defSmrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3646a4f78defSmrg -no-suppress do not suppress compiler output for multiple passes 3647a4f78defSmrg -prefer-pic try to build PIC objects only 3648a4f78defSmrg -prefer-non-pic try to build non-PIC objects only 3649a4f78defSmrg -shared do not build a '.o' file suitable for static linking 3650a4f78defSmrg -static only build a '.o' file suitable for static linking 3651a4f78defSmrg -Wc,FLAG pass FLAG directly to the compiler 3652a4f78defSmrg 3653a4f78defSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 3654a4f78defSmrgfrom the given SOURCEFILE. 3655a4f78defSmrg 3656a4f78defSmrgThe output file name is determined by removing the directory component from 3657a4f78defSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3658a4f78defSmrglibrary object suffix, '.lo'." 3659a4f78defSmrg ;; 3660a4f78defSmrg 3661a4f78defSmrg execute) 3662a4f78defSmrg $ECHO \ 3663a4f78defSmrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664a4f78defSmrg 3665a4f78defSmrgAutomatically set library path, then run a program. 3666a4f78defSmrg 3667a4f78defSmrgThis mode accepts the following additional options: 3668a4f78defSmrg 3669a4f78defSmrg -dlopen FILE add the directory containing FILE to the library path 3670a4f78defSmrg 3671a4f78defSmrgThis mode sets the library path environment variable according to '-dlopen' 3672a4f78defSmrgflags. 3673a4f78defSmrg 3674a4f78defSmrgIf any of the ARGS are libtool executable wrappers, then they are translated 3675a4f78defSmrginto their corresponding uninstalled binary, and any of their required library 3676a4f78defSmrgdirectories are added to the library path. 3677a4f78defSmrg 3678a4f78defSmrgThen, COMMAND is executed, with ARGS as arguments." 3679a4f78defSmrg ;; 3680a4f78defSmrg 3681a4f78defSmrg finish) 3682a4f78defSmrg $ECHO \ 3683a4f78defSmrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684a4f78defSmrg 3685a4f78defSmrgComplete the installation of libtool libraries. 3686a4f78defSmrg 3687a4f78defSmrgEach LIBDIR is a directory that contains libtool libraries. 3688a4f78defSmrg 3689a4f78defSmrgThe commands that this mode executes may require superuser privileges. Use 3690a4f78defSmrgthe '--dry-run' option if you just want to see what would be executed." 3691a4f78defSmrg ;; 3692a4f78defSmrg 3693a4f78defSmrg install) 3694a4f78defSmrg $ECHO \ 3695a4f78defSmrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696a4f78defSmrg 3697a4f78defSmrgInstall executables or libraries. 3698a4f78defSmrg 3699a4f78defSmrgINSTALL-COMMAND is the installation command. The first component should be 3700a4f78defSmrgeither the 'install' or 'cp' program. 3701a4f78defSmrg 3702a4f78defSmrgThe following components of INSTALL-COMMAND are treated specially: 3703a4f78defSmrg 3704a4f78defSmrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705a4f78defSmrg 3706a4f78defSmrgThe rest of the components are interpreted as arguments to that command (only 3707a4f78defSmrgBSD-compatible install options are recognized)." 3708a4f78defSmrg ;; 3709a4f78defSmrg 3710a4f78defSmrg link) 3711a4f78defSmrg $ECHO \ 3712a4f78defSmrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713a4f78defSmrg 3714a4f78defSmrgLink object files or libraries together to form another library, or to 3715a4f78defSmrgcreate an executable program. 3716a4f78defSmrg 3717a4f78defSmrgLINK-COMMAND is a command using the C compiler that you would use to create 3718a4f78defSmrga program from several object files. 3719a4f78defSmrg 3720a4f78defSmrgThe following components of LINK-COMMAND are treated specially: 3721a4f78defSmrg 3722a4f78defSmrg -all-static do not do any dynamic linking at all 3723a4f78defSmrg -avoid-version do not add a version suffix if possible 3724a4f78defSmrg -bindir BINDIR specify path to binaries directory (for systems where 3725a4f78defSmrg libraries must be found in the PATH setting at runtime) 3726a4f78defSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3727a4f78defSmrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3728a4f78defSmrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3729a4f78defSmrg -export-symbols SYMFILE 3730a4f78defSmrg try to export only the symbols listed in SYMFILE 3731a4f78defSmrg -export-symbols-regex REGEX 3732a4f78defSmrg try to export only the symbols matching REGEX 3733a4f78defSmrg -LLIBDIR search LIBDIR for required installed libraries 3734a4f78defSmrg -lNAME OUTPUT-FILE requires the installed library libNAME 3735a4f78defSmrg -module build a library that can dlopened 3736a4f78defSmrg -no-fast-install disable the fast-install mode 3737a4f78defSmrg -no-install link a not-installable executable 3738a4f78defSmrg -no-undefined declare that a library does not refer to external symbols 3739a4f78defSmrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740a4f78defSmrg -objectlist FILE use a list of object files found in FILE to specify objects 3741a4f78defSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3742a4f78defSmrg -precious-files-regex REGEX 3743a4f78defSmrg don't remove output files matching REGEX 3744a4f78defSmrg -release RELEASE specify package release information 3745a4f78defSmrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 3746a4f78defSmrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 3747a4f78defSmrg -shared only do dynamic linking of libtool libraries 3748a4f78defSmrg -shrext SUFFIX override the standard shared library file extension 3749a4f78defSmrg -static do not do any dynamic linking of uninstalled libtool libraries 3750a4f78defSmrg -static-libtool-libs 3751a4f78defSmrg do not do any dynamic linking of libtool libraries 3752a4f78defSmrg -version-info CURRENT[:REVISION[:AGE]] 3753a4f78defSmrg specify library version info [each variable defaults to 0] 3754a4f78defSmrg -weak LIBNAME declare that the target provides the LIBNAME interface 3755a4f78defSmrg -Wc,FLAG 3756a4f78defSmrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 3757a4f78defSmrg -Wl,FLAG 3758a4f78defSmrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 3759a4f78defSmrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760a4f78defSmrg 3761a4f78defSmrgAll other options (arguments beginning with '-') are ignored. 3762a4f78defSmrg 3763a4f78defSmrgEvery other argument is treated as a filename. Files ending in '.la' are 3764a4f78defSmrgtreated as uninstalled libtool libraries, other files are standard or library 3765a4f78defSmrgobject files. 3766a4f78defSmrg 3767a4f78defSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768a4f78defSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 3769a4f78defSmrgrequired, except when creating a convenience library. 3770a4f78defSmrg 3771a4f78defSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772a4f78defSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773a4f78defSmrg 3774a4f78defSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 3775a4f78defSmrgis created, otherwise an executable program is created." 3776a4f78defSmrg ;; 3777a4f78defSmrg 3778a4f78defSmrg uninstall) 3779a4f78defSmrg $ECHO \ 3780a4f78defSmrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781a4f78defSmrg 3782a4f78defSmrgRemove libraries from an installation directory. 3783a4f78defSmrg 3784a4f78defSmrgRM is the name of the program to use to delete files associated with each FILE 3785a4f78defSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3786a4f78defSmrgto RM. 3787a4f78defSmrg 3788a4f78defSmrgIf FILE is a libtool library, all the files associated with it are deleted. 3789a4f78defSmrgOtherwise, only FILE itself is deleted using RM." 3790a4f78defSmrg ;; 3791a4f78defSmrg 3792a4f78defSmrg *) 3793a4f78defSmrg func_fatal_help "invalid operation mode '$opt_mode'" 3794a4f78defSmrg ;; 3795a4f78defSmrg esac 3796a4f78defSmrg 3797a4f78defSmrg echo 3798a4f78defSmrg $ECHO "Try '$progname --help' for more information about other modes." 3799a4f78defSmrg} 3800a4f78defSmrg 3801a4f78defSmrg# Now that we've collected a possible --mode arg, show help if necessary 3802a4f78defSmrgif $opt_help; then 3803a4f78defSmrg if test : = "$opt_help"; then 3804a4f78defSmrg func_mode_help 3805a4f78defSmrg else 3806a4f78defSmrg { 3807a4f78defSmrg func_help noexit 3808a4f78defSmrg for opt_mode in compile link execute install finish uninstall clean; do 3809a4f78defSmrg func_mode_help 3810a4f78defSmrg done 3811a4f78defSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 3812a4f78defSmrg { 3813a4f78defSmrg func_help noexit 3814a4f78defSmrg for opt_mode in compile link execute install finish uninstall clean; do 3815a4f78defSmrg echo 3816a4f78defSmrg func_mode_help 3817a4f78defSmrg done 3818a4f78defSmrg } | 3819a4f78defSmrg $SED '1d 3820a4f78defSmrg /^When reporting/,/^Report/{ 3821a4f78defSmrg H 3822a4f78defSmrg d 3823a4f78defSmrg } 3824a4f78defSmrg $x 3825a4f78defSmrg /information about other modes/d 3826a4f78defSmrg /more detailed .*MODE/d 3827a4f78defSmrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 3828a4f78defSmrg fi 3829a4f78defSmrg exit $? 3830a4f78defSmrgfi 3831a4f78defSmrg 3832a4f78defSmrg 3833a4f78defSmrg# func_mode_execute arg... 3834a4f78defSmrgfunc_mode_execute () 3835a4f78defSmrg{ 3836a4f78defSmrg $debug_cmd 3837a4f78defSmrg 3838a4f78defSmrg # The first argument is the command name. 3839a4f78defSmrg cmd=$nonopt 3840a4f78defSmrg test -z "$cmd" && \ 3841a4f78defSmrg func_fatal_help "you must specify a COMMAND" 3842a4f78defSmrg 3843a4f78defSmrg # Handle -dlopen flags immediately. 3844a4f78defSmrg for file in $opt_dlopen; do 3845a4f78defSmrg test -f "$file" \ 3846a4f78defSmrg || func_fatal_help "'$file' is not a file" 3847a4f78defSmrg 3848a4f78defSmrg dir= 3849a4f78defSmrg case $file in 3850a4f78defSmrg *.la) 3851a4f78defSmrg func_resolve_sysroot "$file" 3852a4f78defSmrg file=$func_resolve_sysroot_result 3853a4f78defSmrg 3854a4f78defSmrg # Check to see that this really is a libtool archive. 3855a4f78defSmrg func_lalib_unsafe_p "$file" \ 3856a4f78defSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857a4f78defSmrg 3858a4f78defSmrg # Read the libtool library. 3859a4f78defSmrg dlname= 3860a4f78defSmrg library_names= 3861a4f78defSmrg func_source "$file" 3862a4f78defSmrg 3863a4f78defSmrg # Skip this library if it cannot be dlopened. 3864a4f78defSmrg if test -z "$dlname"; then 3865a4f78defSmrg # Warn if it was a shared library. 3866a4f78defSmrg test -n "$library_names" && \ 3867a4f78defSmrg func_warning "'$file' was not linked with '-export-dynamic'" 3868a4f78defSmrg continue 3869a4f78defSmrg fi 3870a4f78defSmrg 3871a4f78defSmrg func_dirname "$file" "" "." 3872a4f78defSmrg dir=$func_dirname_result 3873a4f78defSmrg 3874a4f78defSmrg if test -f "$dir/$objdir/$dlname"; then 3875a4f78defSmrg func_append dir "/$objdir" 3876a4f78defSmrg else 3877a4f78defSmrg if test ! -f "$dir/$dlname"; then 3878a4f78defSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 3879a4f78defSmrg fi 3880a4f78defSmrg fi 3881a4f78defSmrg ;; 3882a4f78defSmrg 3883a4f78defSmrg *.lo) 3884a4f78defSmrg # Just add the directory containing the .lo file. 3885a4f78defSmrg func_dirname "$file" "" "." 3886a4f78defSmrg dir=$func_dirname_result 3887a4f78defSmrg ;; 3888a4f78defSmrg 3889a4f78defSmrg *) 3890a4f78defSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891a4f78defSmrg continue 3892a4f78defSmrg ;; 3893a4f78defSmrg esac 3894a4f78defSmrg 3895a4f78defSmrg # Get the absolute pathname. 3896a4f78defSmrg absdir=`cd "$dir" && pwd` 3897a4f78defSmrg test -n "$absdir" && dir=$absdir 3898a4f78defSmrg 3899a4f78defSmrg # Now add the directory to shlibpath_var. 3900a4f78defSmrg if eval "test -z \"\$$shlibpath_var\""; then 3901a4f78defSmrg eval "$shlibpath_var=\"\$dir\"" 3902a4f78defSmrg else 3903a4f78defSmrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 3904a4f78defSmrg fi 3905a4f78defSmrg done 3906a4f78defSmrg 3907a4f78defSmrg # This variable tells wrapper scripts just to set shlibpath_var 3908a4f78defSmrg # rather than running their programs. 3909a4f78defSmrg libtool_execute_magic=$magic 3910a4f78defSmrg 3911a4f78defSmrg # Check if any of the arguments is a wrapper script. 3912a4f78defSmrg args= 3913a4f78defSmrg for file 3914a4f78defSmrg do 3915a4f78defSmrg case $file in 3916a4f78defSmrg -* | *.la | *.lo ) ;; 3917a4f78defSmrg *) 3918a4f78defSmrg # Do a test to see if this is really a libtool program. 3919a4f78defSmrg if func_ltwrapper_script_p "$file"; then 3920a4f78defSmrg func_source "$file" 3921a4f78defSmrg # Transform arg to wrapped name. 3922a4f78defSmrg file=$progdir/$program 3923a4f78defSmrg elif func_ltwrapper_executable_p "$file"; then 3924a4f78defSmrg func_ltwrapper_scriptname "$file" 3925a4f78defSmrg func_source "$func_ltwrapper_scriptname_result" 3926a4f78defSmrg # Transform arg to wrapped name. 3927a4f78defSmrg file=$progdir/$program 3928a4f78defSmrg fi 3929a4f78defSmrg ;; 3930a4f78defSmrg esac 3931a4f78defSmrg # Quote arguments (to preserve shell metacharacters). 3932a4f78defSmrg func_append_quoted args "$file" 3933a4f78defSmrg done 3934a4f78defSmrg 3935a4f78defSmrg if $opt_dry_run; then 3936a4f78defSmrg # Display what would be done. 3937a4f78defSmrg if test -n "$shlibpath_var"; then 3938a4f78defSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939a4f78defSmrg echo "export $shlibpath_var" 3940a4f78defSmrg fi 3941a4f78defSmrg $ECHO "$cmd$args" 3942a4f78defSmrg exit $EXIT_SUCCESS 3943a4f78defSmrg else 3944a4f78defSmrg if test -n "$shlibpath_var"; then 3945a4f78defSmrg # Export the shlibpath_var. 3946a4f78defSmrg eval "export $shlibpath_var" 3947a4f78defSmrg fi 3948a4f78defSmrg 3949a4f78defSmrg # Restore saved environment variables 3950a4f78defSmrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 3951a4f78defSmrg do 3952a4f78defSmrg eval "if test \"\${save_$lt_var+set}\" = set; then 3953a4f78defSmrg $lt_var=\$save_$lt_var; export $lt_var 3954a4f78defSmrg else 3955a4f78defSmrg $lt_unset $lt_var 3956a4f78defSmrg fi" 3957a4f78defSmrg done 3958a4f78defSmrg 3959a4f78defSmrg # Now prepare to actually exec the command. 3960a4f78defSmrg exec_cmd=\$cmd$args 3961a4f78defSmrg fi 3962a4f78defSmrg} 3963a4f78defSmrg 3964a4f78defSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965a4f78defSmrg 3966a4f78defSmrg 3967a4f78defSmrg# func_mode_finish arg... 3968a4f78defSmrgfunc_mode_finish () 3969a4f78defSmrg{ 3970a4f78defSmrg $debug_cmd 3971a4f78defSmrg 3972a4f78defSmrg libs= 3973a4f78defSmrg libdirs= 3974a4f78defSmrg admincmds= 3975a4f78defSmrg 3976a4f78defSmrg for opt in "$nonopt" ${1+"$@"} 3977a4f78defSmrg do 3978a4f78defSmrg if test -d "$opt"; then 3979a4f78defSmrg func_append libdirs " $opt" 3980a4f78defSmrg 3981a4f78defSmrg elif test -f "$opt"; then 3982a4f78defSmrg if func_lalib_unsafe_p "$opt"; then 3983a4f78defSmrg func_append libs " $opt" 3984a4f78defSmrg else 3985a4f78defSmrg func_warning "'$opt' is not a valid libtool archive" 3986a4f78defSmrg fi 3987a4f78defSmrg 3988a4f78defSmrg else 3989a4f78defSmrg func_fatal_error "invalid argument '$opt'" 3990a4f78defSmrg fi 3991a4f78defSmrg done 3992a4f78defSmrg 3993a4f78defSmrg if test -n "$libs"; then 3994a4f78defSmrg if test -n "$lt_sysroot"; then 3995a4f78defSmrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996a4f78defSmrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997a4f78defSmrg else 3998a4f78defSmrg sysroot_cmd= 3999a4f78defSmrg fi 4000a4f78defSmrg 4001a4f78defSmrg # Remove sysroot references 4002a4f78defSmrg if $opt_dry_run; then 4003a4f78defSmrg for lib in $libs; do 4004a4f78defSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005a4f78defSmrg done 4006a4f78defSmrg else 4007a4f78defSmrg tmpdir=`func_mktempdir` 4008a4f78defSmrg for lib in $libs; do 4009a4f78defSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010a4f78defSmrg > $tmpdir/tmp-la 4011a4f78defSmrg mv -f $tmpdir/tmp-la $lib 4012a4f78defSmrg done 4013a4f78defSmrg ${RM}r "$tmpdir" 4014a4f78defSmrg fi 4015a4f78defSmrg fi 4016a4f78defSmrg 4017a4f78defSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4018a4f78defSmrg for libdir in $libdirs; do 4019a4f78defSmrg if test -n "$finish_cmds"; then 4020a4f78defSmrg # Do each command in the finish commands. 4021a4f78defSmrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4022a4f78defSmrg'"$cmd"'"' 4023a4f78defSmrg fi 4024a4f78defSmrg if test -n "$finish_eval"; then 4025a4f78defSmrg # Do the single finish_eval. 4026a4f78defSmrg eval cmds=\"$finish_eval\" 4027a4f78defSmrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4028a4f78defSmrg $cmds" 4029a4f78defSmrg fi 4030a4f78defSmrg done 4031a4f78defSmrg fi 4032a4f78defSmrg 4033a4f78defSmrg # Exit here if they wanted silent mode. 4034a4f78defSmrg $opt_quiet && exit $EXIT_SUCCESS 4035a4f78defSmrg 4036a4f78defSmrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037a4f78defSmrg echo "----------------------------------------------------------------------" 4038a4f78defSmrg echo "Libraries have been installed in:" 4039a4f78defSmrg for libdir in $libdirs; do 4040a4f78defSmrg $ECHO " $libdir" 4041a4f78defSmrg done 4042a4f78defSmrg echo 4043a4f78defSmrg echo "If you ever happen to want to link against installed libraries" 4044a4f78defSmrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4045a4f78defSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046a4f78defSmrg echo "flag during linking and do at least one of the following:" 4047a4f78defSmrg if test -n "$shlibpath_var"; then 4048a4f78defSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049a4f78defSmrg echo " during execution" 4050a4f78defSmrg fi 4051a4f78defSmrg if test -n "$runpath_var"; then 4052a4f78defSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4053a4f78defSmrg echo " during linking" 4054a4f78defSmrg fi 4055a4f78defSmrg if test -n "$hardcode_libdir_flag_spec"; then 4056a4f78defSmrg libdir=LIBDIR 4057a4f78defSmrg eval flag=\"$hardcode_libdir_flag_spec\" 4058a4f78defSmrg 4059a4f78defSmrg $ECHO " - use the '$flag' linker flag" 4060a4f78defSmrg fi 4061a4f78defSmrg if test -n "$admincmds"; then 4062a4f78defSmrg $ECHO " - have your system administrator run these commands:$admincmds" 4063a4f78defSmrg fi 4064a4f78defSmrg if test -f /etc/ld.so.conf; then 4065a4f78defSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066a4f78defSmrg fi 4067a4f78defSmrg echo 4068a4f78defSmrg 4069a4f78defSmrg echo "See any operating system documentation about shared libraries for" 4070a4f78defSmrg case $host in 4071a4f78defSmrg solaris2.[6789]|solaris2.1[0-9]) 4072a4f78defSmrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073a4f78defSmrg echo "pages." 4074a4f78defSmrg ;; 4075a4f78defSmrg *) 4076a4f78defSmrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077a4f78defSmrg ;; 4078a4f78defSmrg esac 4079a4f78defSmrg echo "----------------------------------------------------------------------" 4080a4f78defSmrg fi 4081a4f78defSmrg exit $EXIT_SUCCESS 4082a4f78defSmrg} 4083a4f78defSmrg 4084a4f78defSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085a4f78defSmrg 4086a4f78defSmrg 4087a4f78defSmrg# func_mode_install arg... 4088a4f78defSmrgfunc_mode_install () 4089a4f78defSmrg{ 4090a4f78defSmrg $debug_cmd 4091a4f78defSmrg 4092a4f78defSmrg # There may be an optional sh(1) argument at the beginning of 4093a4f78defSmrg # install_prog (especially on Windows NT). 4094a4f78defSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4095a4f78defSmrg # Allow the use of GNU shtool's install command. 4096a4f78defSmrg case $nonopt in *shtool*) :;; *) false;; esac 4097a4f78defSmrg then 4098a4f78defSmrg # Aesthetically quote it. 4099a4f78defSmrg func_quote_for_eval "$nonopt" 4100a4f78defSmrg install_prog="$func_quote_for_eval_result " 4101a4f78defSmrg arg=$1 4102a4f78defSmrg shift 4103a4f78defSmrg else 4104a4f78defSmrg install_prog= 4105a4f78defSmrg arg=$nonopt 4106a4f78defSmrg fi 4107a4f78defSmrg 4108a4f78defSmrg # The real first argument should be the name of the installation program. 4109a4f78defSmrg # Aesthetically quote it. 4110a4f78defSmrg func_quote_for_eval "$arg" 4111a4f78defSmrg func_append install_prog "$func_quote_for_eval_result" 4112a4f78defSmrg install_shared_prog=$install_prog 4113a4f78defSmrg case " $install_prog " in 4114a4f78defSmrg *[\\\ /]cp\ *) install_cp=: ;; 4115a4f78defSmrg *) install_cp=false ;; 4116a4f78defSmrg esac 4117a4f78defSmrg 4118a4f78defSmrg # We need to accept at least all the BSD install flags. 4119a4f78defSmrg dest= 4120a4f78defSmrg files= 4121a4f78defSmrg opts= 4122a4f78defSmrg prev= 4123a4f78defSmrg install_type= 4124a4f78defSmrg isdir=false 4125a4f78defSmrg stripme= 4126a4f78defSmrg no_mode=: 4127a4f78defSmrg for arg 4128a4f78defSmrg do 4129a4f78defSmrg arg2= 4130a4f78defSmrg if test -n "$dest"; then 4131a4f78defSmrg func_append files " $dest" 4132a4f78defSmrg dest=$arg 4133a4f78defSmrg continue 4134a4f78defSmrg fi 4135a4f78defSmrg 4136a4f78defSmrg case $arg in 4137a4f78defSmrg -d) isdir=: ;; 4138a4f78defSmrg -f) 4139a4f78defSmrg if $install_cp; then :; else 4140a4f78defSmrg prev=$arg 4141a4f78defSmrg fi 4142a4f78defSmrg ;; 4143a4f78defSmrg -g | -m | -o) 4144a4f78defSmrg prev=$arg 4145a4f78defSmrg ;; 4146a4f78defSmrg -s) 4147a4f78defSmrg stripme=" -s" 4148a4f78defSmrg continue 4149a4f78defSmrg ;; 4150a4f78defSmrg -*) 4151a4f78defSmrg ;; 4152a4f78defSmrg *) 4153a4f78defSmrg # If the previous option needed an argument, then skip it. 4154a4f78defSmrg if test -n "$prev"; then 4155a4f78defSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4156a4f78defSmrg arg2=$install_override_mode 4157a4f78defSmrg no_mode=false 4158a4f78defSmrg fi 4159a4f78defSmrg prev= 4160a4f78defSmrg else 4161a4f78defSmrg dest=$arg 4162a4f78defSmrg continue 4163a4f78defSmrg fi 4164a4f78defSmrg ;; 4165a4f78defSmrg esac 4166a4f78defSmrg 4167a4f78defSmrg # Aesthetically quote the argument. 4168a4f78defSmrg func_quote_for_eval "$arg" 4169a4f78defSmrg func_append install_prog " $func_quote_for_eval_result" 4170a4f78defSmrg if test -n "$arg2"; then 4171a4f78defSmrg func_quote_for_eval "$arg2" 4172a4f78defSmrg fi 4173a4f78defSmrg func_append install_shared_prog " $func_quote_for_eval_result" 4174a4f78defSmrg done 4175a4f78defSmrg 4176a4f78defSmrg test -z "$install_prog" && \ 4177a4f78defSmrg func_fatal_help "you must specify an install program" 4178a4f78defSmrg 4179a4f78defSmrg test -n "$prev" && \ 4180a4f78defSmrg func_fatal_help "the '$prev' option requires an argument" 4181a4f78defSmrg 4182a4f78defSmrg if test -n "$install_override_mode" && $no_mode; then 4183a4f78defSmrg if $install_cp; then :; else 4184a4f78defSmrg func_quote_for_eval "$install_override_mode" 4185a4f78defSmrg func_append install_shared_prog " -m $func_quote_for_eval_result" 4186a4f78defSmrg fi 4187a4f78defSmrg fi 4188a4f78defSmrg 4189a4f78defSmrg if test -z "$files"; then 4190a4f78defSmrg if test -z "$dest"; then 4191a4f78defSmrg func_fatal_help "no file or destination specified" 4192a4f78defSmrg else 4193a4f78defSmrg func_fatal_help "you must specify a destination" 4194a4f78defSmrg fi 4195a4f78defSmrg fi 4196a4f78defSmrg 4197a4f78defSmrg # Strip any trailing slash from the destination. 4198a4f78defSmrg func_stripname '' '/' "$dest" 4199a4f78defSmrg dest=$func_stripname_result 4200a4f78defSmrg 4201a4f78defSmrg # Check to see that the destination is a directory. 4202a4f78defSmrg test -d "$dest" && isdir=: 4203a4f78defSmrg if $isdir; then 4204a4f78defSmrg destdir=$dest 4205a4f78defSmrg destname= 4206a4f78defSmrg else 4207a4f78defSmrg func_dirname_and_basename "$dest" "" "." 4208a4f78defSmrg destdir=$func_dirname_result 4209a4f78defSmrg destname=$func_basename_result 4210a4f78defSmrg 4211a4f78defSmrg # Not a directory, so check to see that there is only one file specified. 4212a4f78defSmrg set dummy $files; shift 4213a4f78defSmrg test "$#" -gt 1 && \ 4214a4f78defSmrg func_fatal_help "'$dest' is not a directory" 4215a4f78defSmrg fi 4216a4f78defSmrg case $destdir in 4217a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218a4f78defSmrg *) 4219a4f78defSmrg for file in $files; do 4220a4f78defSmrg case $file in 4221a4f78defSmrg *.lo) ;; 4222a4f78defSmrg *) 4223a4f78defSmrg func_fatal_help "'$destdir' must be an absolute directory name" 4224a4f78defSmrg ;; 4225a4f78defSmrg esac 4226a4f78defSmrg done 4227a4f78defSmrg ;; 4228a4f78defSmrg esac 4229a4f78defSmrg 4230a4f78defSmrg # This variable tells wrapper scripts just to set variables rather 4231a4f78defSmrg # than running their programs. 4232a4f78defSmrg libtool_install_magic=$magic 4233a4f78defSmrg 4234a4f78defSmrg staticlibs= 4235a4f78defSmrg future_libdirs= 4236a4f78defSmrg current_libdirs= 4237a4f78defSmrg for file in $files; do 4238a4f78defSmrg 4239a4f78defSmrg # Do each installation. 4240a4f78defSmrg case $file in 4241a4f78defSmrg *.$libext) 4242a4f78defSmrg # Do the static libraries later. 4243a4f78defSmrg func_append staticlibs " $file" 4244a4f78defSmrg ;; 4245a4f78defSmrg 4246a4f78defSmrg *.la) 4247a4f78defSmrg func_resolve_sysroot "$file" 4248a4f78defSmrg file=$func_resolve_sysroot_result 4249a4f78defSmrg 4250a4f78defSmrg # Check to see that this really is a libtool archive. 4251a4f78defSmrg func_lalib_unsafe_p "$file" \ 4252a4f78defSmrg || func_fatal_help "'$file' is not a valid libtool archive" 4253a4f78defSmrg 4254a4f78defSmrg library_names= 4255a4f78defSmrg old_library= 4256a4f78defSmrg relink_command= 4257a4f78defSmrg func_source "$file" 4258a4f78defSmrg 4259a4f78defSmrg # Add the libdir to current_libdirs if it is the destination. 4260a4f78defSmrg if test "X$destdir" = "X$libdir"; then 4261a4f78defSmrg case "$current_libdirs " in 4262a4f78defSmrg *" $libdir "*) ;; 4263a4f78defSmrg *) func_append current_libdirs " $libdir" ;; 4264a4f78defSmrg esac 4265a4f78defSmrg else 4266a4f78defSmrg # Note the libdir as a future libdir. 4267a4f78defSmrg case "$future_libdirs " in 4268a4f78defSmrg *" $libdir "*) ;; 4269a4f78defSmrg *) func_append future_libdirs " $libdir" ;; 4270a4f78defSmrg esac 4271a4f78defSmrg fi 4272a4f78defSmrg 4273a4f78defSmrg func_dirname "$file" "/" "" 4274a4f78defSmrg dir=$func_dirname_result 4275a4f78defSmrg func_append dir "$objdir" 4276a4f78defSmrg 4277a4f78defSmrg if test -n "$relink_command"; then 4278a4f78defSmrg # Determine the prefix the user has applied to our future dir. 4279a4f78defSmrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4280a4f78defSmrg 4281a4f78defSmrg # Don't allow the user to place us outside of our expected 4282a4f78defSmrg # location b/c this prevents finding dependent libraries that 4283a4f78defSmrg # are installed to the same prefix. 4284a4f78defSmrg # At present, this check doesn't affect windows .dll's that 4285a4f78defSmrg # are installed into $libdir/../bin (currently, that works fine) 4286a4f78defSmrg # but it's something to keep an eye on. 4287a4f78defSmrg test "$inst_prefix_dir" = "$destdir" && \ 4288a4f78defSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4289a4f78defSmrg 4290a4f78defSmrg if test -n "$inst_prefix_dir"; then 4291a4f78defSmrg # Stick the inst_prefix_dir data into the link command. 4292a4f78defSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4293a4f78defSmrg else 4294a4f78defSmrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4295a4f78defSmrg fi 4296a4f78defSmrg 4297a4f78defSmrg func_warning "relinking '$file'" 4298a4f78defSmrg func_show_eval "$relink_command" \ 4299a4f78defSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4300a4f78defSmrg fi 4301a4f78defSmrg 4302a4f78defSmrg # See the names of the shared library. 4303a4f78defSmrg set dummy $library_names; shift 4304a4f78defSmrg if test -n "$1"; then 4305a4f78defSmrg realname=$1 4306a4f78defSmrg shift 4307a4f78defSmrg 4308a4f78defSmrg srcname=$realname 4309a4f78defSmrg test -n "$relink_command" && srcname=${realname}T 4310a4f78defSmrg 4311a4f78defSmrg # Install the shared library and build the symlinks. 4312a4f78defSmrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4313a4f78defSmrg 'exit $?' 4314a4f78defSmrg tstripme=$stripme 4315a4f78defSmrg case $host_os in 4316a4f78defSmrg cygwin* | mingw* | pw32* | cegcc*) 4317a4f78defSmrg case $realname in 4318a4f78defSmrg *.dll.a) 4319a4f78defSmrg tstripme= 4320a4f78defSmrg ;; 4321a4f78defSmrg esac 4322a4f78defSmrg ;; 4323a4f78defSmrg os2*) 4324a4f78defSmrg case $realname in 4325a4f78defSmrg *_dll.a) 4326a4f78defSmrg tstripme= 4327a4f78defSmrg ;; 4328a4f78defSmrg esac 4329a4f78defSmrg ;; 4330a4f78defSmrg esac 4331a4f78defSmrg if test -n "$tstripme" && test -n "$striplib"; then 4332a4f78defSmrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333a4f78defSmrg fi 4334a4f78defSmrg 4335a4f78defSmrg if test "$#" -gt 0; then 4336a4f78defSmrg # Delete the old symlinks, and create new ones. 4337a4f78defSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4338a4f78defSmrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4339a4f78defSmrg # so we also need to try rm && ln -s. 4340a4f78defSmrg for linkname 4341a4f78defSmrg do 4342a4f78defSmrg test "$linkname" != "$realname" \ 4343a4f78defSmrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344a4f78defSmrg done 4345a4f78defSmrg fi 4346a4f78defSmrg 4347a4f78defSmrg # Do each command in the postinstall commands. 4348a4f78defSmrg lib=$destdir/$realname 4349a4f78defSmrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350a4f78defSmrg fi 4351a4f78defSmrg 4352a4f78defSmrg # Install the pseudo-library for information purposes. 4353a4f78defSmrg func_basename "$file" 4354a4f78defSmrg name=$func_basename_result 4355a4f78defSmrg instname=$dir/${name}i 4356a4f78defSmrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357a4f78defSmrg 4358a4f78defSmrg # Maybe install the static library, too. 4359a4f78defSmrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4360a4f78defSmrg ;; 4361a4f78defSmrg 4362a4f78defSmrg *.lo) 4363a4f78defSmrg # Install (i.e. copy) a libtool object. 4364a4f78defSmrg 4365a4f78defSmrg # Figure out destination file name, if it wasn't already specified. 4366a4f78defSmrg if test -n "$destname"; then 4367a4f78defSmrg destfile=$destdir/$destname 4368a4f78defSmrg else 4369a4f78defSmrg func_basename "$file" 4370a4f78defSmrg destfile=$func_basename_result 4371a4f78defSmrg destfile=$destdir/$destfile 4372a4f78defSmrg fi 4373a4f78defSmrg 4374a4f78defSmrg # Deduce the name of the destination old-style object file. 4375a4f78defSmrg case $destfile in 4376a4f78defSmrg *.lo) 4377a4f78defSmrg func_lo2o "$destfile" 4378a4f78defSmrg staticdest=$func_lo2o_result 4379a4f78defSmrg ;; 4380a4f78defSmrg *.$objext) 4381a4f78defSmrg staticdest=$destfile 4382a4f78defSmrg destfile= 4383a4f78defSmrg ;; 4384a4f78defSmrg *) 4385a4f78defSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4386a4f78defSmrg ;; 4387a4f78defSmrg esac 4388a4f78defSmrg 4389a4f78defSmrg # Install the libtool object if requested. 4390a4f78defSmrg test -n "$destfile" && \ 4391a4f78defSmrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4392a4f78defSmrg 4393a4f78defSmrg # Install the old object if enabled. 4394a4f78defSmrg if test yes = "$build_old_libs"; then 4395a4f78defSmrg # Deduce the name of the old-style object file. 4396a4f78defSmrg func_lo2o "$file" 4397a4f78defSmrg staticobj=$func_lo2o_result 4398a4f78defSmrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399a4f78defSmrg fi 4400a4f78defSmrg exit $EXIT_SUCCESS 4401a4f78defSmrg ;; 4402a4f78defSmrg 4403a4f78defSmrg *) 4404a4f78defSmrg # Figure out destination file name, if it wasn't already specified. 4405a4f78defSmrg if test -n "$destname"; then 4406a4f78defSmrg destfile=$destdir/$destname 4407a4f78defSmrg else 4408a4f78defSmrg func_basename "$file" 4409a4f78defSmrg destfile=$func_basename_result 4410a4f78defSmrg destfile=$destdir/$destfile 4411a4f78defSmrg fi 4412a4f78defSmrg 4413a4f78defSmrg # If the file is missing, and there is a .exe on the end, strip it 4414a4f78defSmrg # because it is most likely a libtool script we actually want to 4415a4f78defSmrg # install 4416a4f78defSmrg stripped_ext= 4417a4f78defSmrg case $file in 4418a4f78defSmrg *.exe) 4419a4f78defSmrg if test ! -f "$file"; then 4420a4f78defSmrg func_stripname '' '.exe' "$file" 4421a4f78defSmrg file=$func_stripname_result 4422a4f78defSmrg stripped_ext=.exe 4423a4f78defSmrg fi 4424a4f78defSmrg ;; 4425a4f78defSmrg esac 4426a4f78defSmrg 4427a4f78defSmrg # Do a test to see if this is really a libtool program. 4428a4f78defSmrg case $host in 4429a4f78defSmrg *cygwin* | *mingw*) 4430a4f78defSmrg if func_ltwrapper_executable_p "$file"; then 4431a4f78defSmrg func_ltwrapper_scriptname "$file" 4432a4f78defSmrg wrapper=$func_ltwrapper_scriptname_result 4433a4f78defSmrg else 4434a4f78defSmrg func_stripname '' '.exe' "$file" 4435a4f78defSmrg wrapper=$func_stripname_result 4436a4f78defSmrg fi 4437a4f78defSmrg ;; 4438a4f78defSmrg *) 4439a4f78defSmrg wrapper=$file 4440a4f78defSmrg ;; 4441a4f78defSmrg esac 4442a4f78defSmrg if func_ltwrapper_script_p "$wrapper"; then 4443a4f78defSmrg notinst_deplibs= 4444a4f78defSmrg relink_command= 4445a4f78defSmrg 4446a4f78defSmrg func_source "$wrapper" 4447a4f78defSmrg 4448a4f78defSmrg # Check the variables that should have been set. 4449a4f78defSmrg test -z "$generated_by_libtool_version" && \ 4450a4f78defSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4451a4f78defSmrg 4452a4f78defSmrg finalize=: 4453a4f78defSmrg for lib in $notinst_deplibs; do 4454a4f78defSmrg # Check to see that each library is installed. 4455a4f78defSmrg libdir= 4456a4f78defSmrg if test -f "$lib"; then 4457a4f78defSmrg func_source "$lib" 4458a4f78defSmrg fi 4459a4f78defSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4460a4f78defSmrg if test -n "$libdir" && test ! -f "$libfile"; then 4461a4f78defSmrg func_warning "'$lib' has not been installed in '$libdir'" 4462a4f78defSmrg finalize=false 4463a4f78defSmrg fi 4464a4f78defSmrg done 4465a4f78defSmrg 4466a4f78defSmrg relink_command= 4467a4f78defSmrg func_source "$wrapper" 4468a4f78defSmrg 4469a4f78defSmrg outputname= 4470a4f78defSmrg if test no = "$fast_install" && test -n "$relink_command"; then 4471a4f78defSmrg $opt_dry_run || { 4472a4f78defSmrg if $finalize; then 4473a4f78defSmrg tmpdir=`func_mktempdir` 4474a4f78defSmrg func_basename "$file$stripped_ext" 4475a4f78defSmrg file=$func_basename_result 4476a4f78defSmrg outputname=$tmpdir/$file 4477a4f78defSmrg # Replace the output file specification. 4478a4f78defSmrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4479a4f78defSmrg 4480a4f78defSmrg $opt_quiet || { 4481a4f78defSmrg func_quote_for_expand "$relink_command" 4482a4f78defSmrg eval "func_echo $func_quote_for_expand_result" 4483a4f78defSmrg } 4484a4f78defSmrg if eval "$relink_command"; then : 4485a4f78defSmrg else 4486a4f78defSmrg func_error "error: relink '$file' with the above command before installing it" 4487a4f78defSmrg $opt_dry_run || ${RM}r "$tmpdir" 4488a4f78defSmrg continue 4489a4f78defSmrg fi 4490a4f78defSmrg file=$outputname 4491a4f78defSmrg else 4492a4f78defSmrg func_warning "cannot relink '$file'" 4493a4f78defSmrg fi 4494a4f78defSmrg } 4495a4f78defSmrg else 4496a4f78defSmrg # Install the binary that we compiled earlier. 4497a4f78defSmrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498a4f78defSmrg fi 4499a4f78defSmrg fi 4500a4f78defSmrg 4501a4f78defSmrg # remove .exe since cygwin /usr/bin/install will append another 4502a4f78defSmrg # one anyway 4503a4f78defSmrg case $install_prog,$host in 4504a4f78defSmrg */usr/bin/install*,*cygwin*) 4505a4f78defSmrg case $file:$destfile in 4506a4f78defSmrg *.exe:*.exe) 4507a4f78defSmrg # this is ok 4508a4f78defSmrg ;; 4509a4f78defSmrg *.exe:*) 4510a4f78defSmrg destfile=$destfile.exe 4511a4f78defSmrg ;; 4512a4f78defSmrg *:*.exe) 4513a4f78defSmrg func_stripname '' '.exe' "$destfile" 4514a4f78defSmrg destfile=$func_stripname_result 4515a4f78defSmrg ;; 4516a4f78defSmrg esac 4517a4f78defSmrg ;; 4518a4f78defSmrg esac 4519a4f78defSmrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4520a4f78defSmrg $opt_dry_run || if test -n "$outputname"; then 4521a4f78defSmrg ${RM}r "$tmpdir" 4522a4f78defSmrg fi 4523a4f78defSmrg ;; 4524a4f78defSmrg esac 4525a4f78defSmrg done 4526a4f78defSmrg 4527a4f78defSmrg for file in $staticlibs; do 4528a4f78defSmrg func_basename "$file" 4529a4f78defSmrg name=$func_basename_result 4530a4f78defSmrg 4531a4f78defSmrg # Set up the ranlib parameters. 4532a4f78defSmrg oldlib=$destdir/$name 4533a4f78defSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534a4f78defSmrg tool_oldlib=$func_to_tool_file_result 4535a4f78defSmrg 4536a4f78defSmrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537a4f78defSmrg 4538a4f78defSmrg if test -n "$stripme" && test -n "$old_striplib"; then 4539a4f78defSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4540a4f78defSmrg fi 4541a4f78defSmrg 4542a4f78defSmrg # Do each command in the postinstall commands. 4543a4f78defSmrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4544a4f78defSmrg done 4545a4f78defSmrg 4546a4f78defSmrg test -n "$future_libdirs" && \ 4547a4f78defSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4548a4f78defSmrg 4549a4f78defSmrg if test -n "$current_libdirs"; then 4550a4f78defSmrg # Maybe just do a dry run. 4551a4f78defSmrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552a4f78defSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4553a4f78defSmrg else 4554a4f78defSmrg exit $EXIT_SUCCESS 4555a4f78defSmrg fi 4556a4f78defSmrg} 4557a4f78defSmrg 4558a4f78defSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559a4f78defSmrg 4560a4f78defSmrg 4561a4f78defSmrg# func_generate_dlsyms outputname originator pic_p 4562a4f78defSmrg# Extract symbols from dlprefiles and create ${outputname}S.o with 4563a4f78defSmrg# a dlpreopen symbol table. 4564a4f78defSmrgfunc_generate_dlsyms () 4565a4f78defSmrg{ 4566a4f78defSmrg $debug_cmd 4567a4f78defSmrg 4568a4f78defSmrg my_outputname=$1 4569a4f78defSmrg my_originator=$2 4570a4f78defSmrg my_pic_p=${3-false} 4571a4f78defSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4572a4f78defSmrg my_dlsyms= 4573a4f78defSmrg 4574a4f78defSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4575a4f78defSmrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576a4f78defSmrg my_dlsyms=${my_outputname}S.c 4577a4f78defSmrg else 4578a4f78defSmrg func_error "not configured to extract global symbols from dlpreopened files" 4579a4f78defSmrg fi 4580a4f78defSmrg fi 4581a4f78defSmrg 4582a4f78defSmrg if test -n "$my_dlsyms"; then 4583a4f78defSmrg case $my_dlsyms in 4584a4f78defSmrg "") ;; 4585a4f78defSmrg *.c) 4586a4f78defSmrg # Discover the nlist of each of the dlfiles. 4587a4f78defSmrg nlist=$output_objdir/$my_outputname.nm 4588a4f78defSmrg 4589a4f78defSmrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4590a4f78defSmrg 4591a4f78defSmrg # Parse the name list into a source file. 4592a4f78defSmrg func_verbose "creating $output_objdir/$my_dlsyms" 4593a4f78defSmrg 4594a4f78defSmrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595a4f78defSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596a4f78defSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4597a4f78defSmrg 4598a4f78defSmrg#ifdef __cplusplus 4599a4f78defSmrgextern \"C\" { 4600a4f78defSmrg#endif 4601a4f78defSmrg 4602a4f78defSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4603a4f78defSmrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4604a4f78defSmrg#endif 4605a4f78defSmrg 4606a4f78defSmrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607a4f78defSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608a4f78defSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609a4f78defSmrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610a4f78defSmrg# define LT_DLSYM_CONST 4611a4f78defSmrg#elif defined __osf__ 4612a4f78defSmrg/* This system does not cope well with relocations in const data. */ 4613a4f78defSmrg# define LT_DLSYM_CONST 4614a4f78defSmrg#else 4615a4f78defSmrg# define LT_DLSYM_CONST const 4616a4f78defSmrg#endif 4617a4f78defSmrg 4618a4f78defSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619a4f78defSmrg 4620a4f78defSmrg/* External symbol declarations for the compiler. */\ 4621a4f78defSmrg" 4622a4f78defSmrg 4623a4f78defSmrg if test yes = "$dlself"; then 4624a4f78defSmrg func_verbose "generating symbol list for '$output'" 4625a4f78defSmrg 4626a4f78defSmrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4627a4f78defSmrg 4628a4f78defSmrg # Add our own program objects to the symbol list. 4629a4f78defSmrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4630a4f78defSmrg for progfile in $progfiles; do 4631a4f78defSmrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632a4f78defSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633a4f78defSmrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4634a4f78defSmrg done 4635a4f78defSmrg 4636a4f78defSmrg if test -n "$exclude_expsyms"; then 4637a4f78defSmrg $opt_dry_run || { 4638a4f78defSmrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4639a4f78defSmrg eval '$MV "$nlist"T "$nlist"' 4640a4f78defSmrg } 4641a4f78defSmrg fi 4642a4f78defSmrg 4643a4f78defSmrg if test -n "$export_symbols_regex"; then 4644a4f78defSmrg $opt_dry_run || { 4645a4f78defSmrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4646a4f78defSmrg eval '$MV "$nlist"T "$nlist"' 4647a4f78defSmrg } 4648a4f78defSmrg fi 4649a4f78defSmrg 4650a4f78defSmrg # Prepare the list of exported symbols 4651a4f78defSmrg if test -z "$export_symbols"; then 4652a4f78defSmrg export_symbols=$output_objdir/$outputname.exp 4653a4f78defSmrg $opt_dry_run || { 4654a4f78defSmrg $RM $export_symbols 4655a4f78defSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4656a4f78defSmrg case $host in 4657a4f78defSmrg *cygwin* | *mingw* | *cegcc* ) 4658a4f78defSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4659a4f78defSmrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4660a4f78defSmrg ;; 4661a4f78defSmrg esac 4662a4f78defSmrg } 4663a4f78defSmrg else 4664a4f78defSmrg $opt_dry_run || { 4665a4f78defSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4666a4f78defSmrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4667a4f78defSmrg eval '$MV "$nlist"T "$nlist"' 4668a4f78defSmrg case $host in 4669a4f78defSmrg *cygwin* | *mingw* | *cegcc* ) 4670a4f78defSmrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4671a4f78defSmrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4672a4f78defSmrg ;; 4673a4f78defSmrg esac 4674a4f78defSmrg } 4675a4f78defSmrg fi 4676a4f78defSmrg fi 4677a4f78defSmrg 4678a4f78defSmrg for dlprefile in $dlprefiles; do 4679a4f78defSmrg func_verbose "extracting global C symbols from '$dlprefile'" 4680a4f78defSmrg func_basename "$dlprefile" 4681a4f78defSmrg name=$func_basename_result 4682a4f78defSmrg case $host in 4683a4f78defSmrg *cygwin* | *mingw* | *cegcc* ) 4684a4f78defSmrg # if an import library, we need to obtain dlname 4685a4f78defSmrg if func_win32_import_lib_p "$dlprefile"; then 4686a4f78defSmrg func_tr_sh "$dlprefile" 4687a4f78defSmrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688a4f78defSmrg dlprefile_dlbasename= 4689a4f78defSmrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690a4f78defSmrg # Use subshell, to avoid clobbering current variable values 4691a4f78defSmrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692a4f78defSmrg if test -n "$dlprefile_dlname"; then 4693a4f78defSmrg func_basename "$dlprefile_dlname" 4694a4f78defSmrg dlprefile_dlbasename=$func_basename_result 4695a4f78defSmrg else 4696a4f78defSmrg # no lafile. user explicitly requested -dlpreopen <import library>. 4697a4f78defSmrg $sharedlib_from_linklib_cmd "$dlprefile" 4698a4f78defSmrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4699a4f78defSmrg fi 4700a4f78defSmrg fi 4701a4f78defSmrg $opt_dry_run || { 4702a4f78defSmrg if test -n "$dlprefile_dlbasename"; then 4703a4f78defSmrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704a4f78defSmrg else 4705a4f78defSmrg func_warning "Could not compute DLL name from $name" 4706a4f78defSmrg eval '$ECHO ": $name " >> "$nlist"' 4707a4f78defSmrg fi 4708a4f78defSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709a4f78defSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710a4f78defSmrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711a4f78defSmrg } 4712a4f78defSmrg else # not an import lib 4713a4f78defSmrg $opt_dry_run || { 4714a4f78defSmrg eval '$ECHO ": $name " >> "$nlist"' 4715a4f78defSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716a4f78defSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717a4f78defSmrg } 4718a4f78defSmrg fi 4719a4f78defSmrg ;; 4720a4f78defSmrg *) 4721a4f78defSmrg $opt_dry_run || { 4722a4f78defSmrg eval '$ECHO ": $name " >> "$nlist"' 4723a4f78defSmrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724a4f78defSmrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725a4f78defSmrg } 4726a4f78defSmrg ;; 4727a4f78defSmrg esac 4728a4f78defSmrg done 4729a4f78defSmrg 4730a4f78defSmrg $opt_dry_run || { 4731a4f78defSmrg # Make sure we have at least an empty file. 4732a4f78defSmrg test -f "$nlist" || : > "$nlist" 4733a4f78defSmrg 4734a4f78defSmrg if test -n "$exclude_expsyms"; then 4735a4f78defSmrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4736a4f78defSmrg $MV "$nlist"T "$nlist" 4737a4f78defSmrg fi 4738a4f78defSmrg 4739a4f78defSmrg # Try sorting and uniquifying the output. 4740a4f78defSmrg if $GREP -v "^: " < "$nlist" | 4741a4f78defSmrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4742a4f78defSmrg sort -k 3 4743a4f78defSmrg else 4744a4f78defSmrg sort +2 4745a4f78defSmrg fi | 4746a4f78defSmrg uniq > "$nlist"S; then 4747a4f78defSmrg : 4748a4f78defSmrg else 4749a4f78defSmrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750a4f78defSmrg fi 4751a4f78defSmrg 4752a4f78defSmrg if test -f "$nlist"S; then 4753a4f78defSmrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754a4f78defSmrg else 4755a4f78defSmrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756a4f78defSmrg fi 4757a4f78defSmrg 4758a4f78defSmrg func_show_eval '$RM "${nlist}I"' 4759a4f78defSmrg if test -n "$global_symbol_to_import"; then 4760a4f78defSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761a4f78defSmrg fi 4762a4f78defSmrg 4763a4f78defSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4764a4f78defSmrg 4765a4f78defSmrg/* The mapping between symbol names and symbols. */ 4766a4f78defSmrgtypedef struct { 4767a4f78defSmrg const char *name; 4768a4f78defSmrg void *address; 4769a4f78defSmrg} lt_dlsymlist; 4770a4f78defSmrgextern LT_DLSYM_CONST lt_dlsymlist 4771a4f78defSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4772a4f78defSmrg" 4773a4f78defSmrg 4774a4f78defSmrg if test -s "$nlist"I; then 4775a4f78defSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4776a4f78defSmrgstatic void lt_syminit(void) 4777a4f78defSmrg{ 4778a4f78defSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779a4f78defSmrg for (; symbol->name; ++symbol) 4780a4f78defSmrg {" 4781a4f78defSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782a4f78defSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4783a4f78defSmrg } 4784a4f78defSmrg}" 4785a4f78defSmrg fi 4786a4f78defSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4787a4f78defSmrgLT_DLSYM_CONST lt_dlsymlist 4788a4f78defSmrglt_${my_prefix}_LTX_preloaded_symbols[] = 4789a4f78defSmrg{ {\"$my_originator\", (void *) 0}," 4790a4f78defSmrg 4791a4f78defSmrg if test -s "$nlist"I; then 4792a4f78defSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4793a4f78defSmrg {\"@INIT@\", (void *) <_syminit}," 4794a4f78defSmrg fi 4795a4f78defSmrg 4796a4f78defSmrg case $need_lib_prefix in 4797a4f78defSmrg no) 4798a4f78defSmrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 4799a4f78defSmrg ;; 4800a4f78defSmrg *) 4801a4f78defSmrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 4802a4f78defSmrg ;; 4803a4f78defSmrg esac 4804a4f78defSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4805a4f78defSmrg {0, (void *) 0} 4806a4f78defSmrg}; 4807a4f78defSmrg 4808a4f78defSmrg/* This works around a problem in FreeBSD linker */ 4809a4f78defSmrg#ifdef FREEBSD_WORKAROUND 4810a4f78defSmrgstatic const void *lt_preloaded_setup() { 4811a4f78defSmrg return lt_${my_prefix}_LTX_preloaded_symbols; 4812a4f78defSmrg} 4813a4f78defSmrg#endif 4814a4f78defSmrg 4815a4f78defSmrg#ifdef __cplusplus 4816a4f78defSmrg} 4817a4f78defSmrg#endif\ 4818a4f78defSmrg" 4819a4f78defSmrg } # !$opt_dry_run 4820a4f78defSmrg 4821a4f78defSmrg pic_flag_for_symtable= 4822a4f78defSmrg case "$compile_command " in 4823a4f78defSmrg *" -static "*) ;; 4824a4f78defSmrg *) 4825a4f78defSmrg case $host in 4826a4f78defSmrg # compiling the symbol table file with pic_flag works around 4827a4f78defSmrg # a FreeBSD bug that causes programs to crash when -lm is 4828a4f78defSmrg # linked before any other PIC object. But we must not use 4829a4f78defSmrg # pic_flag when linking with -static. The problem exists in 4830a4f78defSmrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831a4f78defSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 4832a4f78defSmrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 4833a4f78defSmrg *-*-hpux*) 4834a4f78defSmrg pic_flag_for_symtable=" $pic_flag" ;; 4835a4f78defSmrg *) 4836a4f78defSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 4837a4f78defSmrg ;; 4838a4f78defSmrg esac 4839a4f78defSmrg ;; 4840a4f78defSmrg esac 4841a4f78defSmrg symtab_cflags= 4842a4f78defSmrg for arg in $LTCFLAGS; do 4843a4f78defSmrg case $arg in 4844a4f78defSmrg -pie | -fpie | -fPIE) ;; 4845a4f78defSmrg *) func_append symtab_cflags " $arg" ;; 4846a4f78defSmrg esac 4847a4f78defSmrg done 4848a4f78defSmrg 4849a4f78defSmrg # Now compile the dynamic symbol file. 4850a4f78defSmrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851a4f78defSmrg 4852a4f78defSmrg # Clean up the generated files. 4853a4f78defSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 4854a4f78defSmrg 4855a4f78defSmrg # Transform the symbol file into the correct name. 4856a4f78defSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 4857a4f78defSmrg case $host in 4858a4f78defSmrg *cygwin* | *mingw* | *cegcc* ) 4859a4f78defSmrg if test -f "$output_objdir/$my_outputname.def"; then 4860a4f78defSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4861a4f78defSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 4862a4f78defSmrg else 4863a4f78defSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4864a4f78defSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4865a4f78defSmrg fi 4866a4f78defSmrg ;; 4867a4f78defSmrg *) 4868a4f78defSmrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4869a4f78defSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870a4f78defSmrg ;; 4871a4f78defSmrg esac 4872a4f78defSmrg ;; 4873a4f78defSmrg *) 4874a4f78defSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 4875a4f78defSmrg ;; 4876a4f78defSmrg esac 4877a4f78defSmrg else 4878a4f78defSmrg # We keep going just in case the user didn't refer to 4879a4f78defSmrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 4880a4f78defSmrg # really was required. 4881a4f78defSmrg 4882a4f78defSmrg # Nullify the symbol file. 4883a4f78defSmrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 4884a4f78defSmrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885a4f78defSmrg fi 4886a4f78defSmrg} 4887a4f78defSmrg 4888a4f78defSmrg# func_cygming_gnu_implib_p ARG 4889a4f78defSmrg# This predicate returns with zero status (TRUE) if 4890a4f78defSmrg# ARG is a GNU/binutils-style import library. Returns 4891a4f78defSmrg# with nonzero status (FALSE) otherwise. 4892a4f78defSmrgfunc_cygming_gnu_implib_p () 4893a4f78defSmrg{ 4894a4f78defSmrg $debug_cmd 4895a4f78defSmrg 4896a4f78defSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4897a4f78defSmrg 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)$'` 4898a4f78defSmrg test -n "$func_cygming_gnu_implib_tmp" 4899a4f78defSmrg} 4900a4f78defSmrg 4901a4f78defSmrg# func_cygming_ms_implib_p ARG 4902a4f78defSmrg# This predicate returns with zero status (TRUE) if 4903a4f78defSmrg# ARG is an MS-style import library. Returns 4904a4f78defSmrg# with nonzero status (FALSE) otherwise. 4905a4f78defSmrgfunc_cygming_ms_implib_p () 4906a4f78defSmrg{ 4907a4f78defSmrg $debug_cmd 4908a4f78defSmrg 4909a4f78defSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4910a4f78defSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911a4f78defSmrg test -n "$func_cygming_ms_implib_tmp" 4912a4f78defSmrg} 4913a4f78defSmrg 4914a4f78defSmrg# func_win32_libid arg 4915a4f78defSmrg# return the library type of file 'arg' 4916a4f78defSmrg# 4917a4f78defSmrg# Need a lot of goo to handle *both* DLLs and import libs 4918a4f78defSmrg# Has to be a shell function in order to 'eat' the argument 4919a4f78defSmrg# that is supplied when $file_magic_command is called. 4920a4f78defSmrg# Despite the name, also deal with 64 bit binaries. 4921a4f78defSmrgfunc_win32_libid () 4922a4f78defSmrg{ 4923a4f78defSmrg $debug_cmd 4924a4f78defSmrg 4925a4f78defSmrg win32_libid_type=unknown 4926a4f78defSmrg win32_fileres=`file -L $1 2>/dev/null` 4927a4f78defSmrg case $win32_fileres in 4928a4f78defSmrg *ar\ archive\ import\ library*) # definitely import 4929a4f78defSmrg win32_libid_type="x86 archive import" 4930a4f78defSmrg ;; 4931a4f78defSmrg *ar\ archive*) # could be an import, or static 4932a4f78defSmrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 4933a4f78defSmrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 4934a4f78defSmrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935a4f78defSmrg case $nm_interface in 4936a4f78defSmrg "MS dumpbin") 4937a4f78defSmrg if func_cygming_ms_implib_p "$1" || 4938a4f78defSmrg func_cygming_gnu_implib_p "$1" 4939a4f78defSmrg then 4940a4f78defSmrg win32_nmres=import 4941a4f78defSmrg else 4942a4f78defSmrg win32_nmres= 4943a4f78defSmrg fi 4944a4f78defSmrg ;; 4945a4f78defSmrg *) 4946a4f78defSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4947a4f78defSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948a4f78defSmrg $SED -n -e ' 4949a4f78defSmrg 1,100{ 4950a4f78defSmrg / I /{ 4951a4f78defSmrg s|.*|import| 4952a4f78defSmrg p 4953a4f78defSmrg q 4954a4f78defSmrg } 4955a4f78defSmrg }'` 4956a4f78defSmrg ;; 4957a4f78defSmrg esac 4958a4f78defSmrg case $win32_nmres in 4959a4f78defSmrg import*) win32_libid_type="x86 archive import";; 4960a4f78defSmrg *) win32_libid_type="x86 archive static";; 4961a4f78defSmrg esac 4962a4f78defSmrg fi 4963a4f78defSmrg ;; 4964a4f78defSmrg *DLL*) 4965a4f78defSmrg win32_libid_type="x86 DLL" 4966a4f78defSmrg ;; 4967a4f78defSmrg *executable*) # but shell scripts are "executable" too... 4968a4f78defSmrg case $win32_fileres in 4969a4f78defSmrg *MS\ Windows\ PE\ Intel*) 4970a4f78defSmrg win32_libid_type="x86 DLL" 4971a4f78defSmrg ;; 4972a4f78defSmrg esac 4973a4f78defSmrg ;; 4974a4f78defSmrg esac 4975a4f78defSmrg $ECHO "$win32_libid_type" 4976a4f78defSmrg} 4977a4f78defSmrg 4978a4f78defSmrg# func_cygming_dll_for_implib ARG 4979a4f78defSmrg# 4980a4f78defSmrg# Platform-specific function to extract the 4981a4f78defSmrg# name of the DLL associated with the specified 4982a4f78defSmrg# import library ARG. 4983a4f78defSmrg# Invoked by eval'ing the libtool variable 4984a4f78defSmrg# $sharedlib_from_linklib_cmd 4985a4f78defSmrg# Result is available in the variable 4986a4f78defSmrg# $sharedlib_from_linklib_result 4987a4f78defSmrgfunc_cygming_dll_for_implib () 4988a4f78defSmrg{ 4989a4f78defSmrg $debug_cmd 4990a4f78defSmrg 4991a4f78defSmrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992a4f78defSmrg} 4993a4f78defSmrg 4994a4f78defSmrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995a4f78defSmrg# 4996a4f78defSmrg# The is the core of a fallback implementation of a 4997a4f78defSmrg# platform-specific function to extract the name of the 4998a4f78defSmrg# DLL associated with the specified import library LIBNAME. 4999a4f78defSmrg# 5000a4f78defSmrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5001a4f78defSmrg# on the platform and compiler that created the implib. 5002a4f78defSmrg# 5003a4f78defSmrg# Echos the name of the DLL associated with the 5004a4f78defSmrg# specified import library. 5005a4f78defSmrgfunc_cygming_dll_for_implib_fallback_core () 5006a4f78defSmrg{ 5007a4f78defSmrg $debug_cmd 5008a4f78defSmrg 5009a4f78defSmrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010a4f78defSmrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011a4f78defSmrg $SED '/^Contents of section '"$match_literal"':/{ 5012a4f78defSmrg # Place marker at beginning of archive member dllname section 5013a4f78defSmrg s/.*/====MARK====/ 5014a4f78defSmrg p 5015a4f78defSmrg d 5016a4f78defSmrg } 5017a4f78defSmrg # These lines can sometimes be longer than 43 characters, but 5018a4f78defSmrg # are always uninteresting 5019a4f78defSmrg /:[ ]*file format pe[i]\{,1\}-/d 5020a4f78defSmrg /^In archive [^:]*:/d 5021a4f78defSmrg # Ensure marker is printed 5022a4f78defSmrg /^====MARK====/p 5023a4f78defSmrg # Remove all lines with less than 43 characters 5024a4f78defSmrg /^.\{43\}/!d 5025a4f78defSmrg # From remaining lines, remove first 43 characters 5026a4f78defSmrg s/^.\{43\}//' | 5027a4f78defSmrg $SED -n ' 5028a4f78defSmrg # Join marker and all lines until next marker into a single line 5029a4f78defSmrg /^====MARK====/ b para 5030a4f78defSmrg H 5031a4f78defSmrg $ b para 5032a4f78defSmrg b 5033a4f78defSmrg :para 5034a4f78defSmrg x 5035a4f78defSmrg s/\n//g 5036a4f78defSmrg # Remove the marker 5037a4f78defSmrg s/^====MARK====// 5038a4f78defSmrg # Remove trailing dots and whitespace 5039a4f78defSmrg s/[\. \t]*$// 5040a4f78defSmrg # Print 5041a4f78defSmrg /./p' | 5042a4f78defSmrg # we now have a list, one entry per line, of the stringified 5043a4f78defSmrg # contents of the appropriate section of all members of the 5044a4f78defSmrg # archive that possess that section. Heuristic: eliminate 5045a4f78defSmrg # all those that have a first or second character that is 5046a4f78defSmrg # a '.' (that is, objdump's representation of an unprintable 5047a4f78defSmrg # character.) This should work for all archives with less than 5048a4f78defSmrg # 0x302f exports -- but will fail for DLLs whose name actually 5049a4f78defSmrg # begins with a literal '.' or a single character followed by 5050a4f78defSmrg # a '.'. 5051a4f78defSmrg # 5052a4f78defSmrg # Of those that remain, print the first one. 5053a4f78defSmrg $SED -e '/^\./d;/^.\./d;q' 5054a4f78defSmrg} 5055a4f78defSmrg 5056a4f78defSmrg# func_cygming_dll_for_implib_fallback ARG 5057a4f78defSmrg# Platform-specific function to extract the 5058a4f78defSmrg# name of the DLL associated with the specified 5059a4f78defSmrg# import library ARG. 5060a4f78defSmrg# 5061a4f78defSmrg# This fallback implementation is for use when $DLLTOOL 5062a4f78defSmrg# does not support the --identify-strict option. 5063a4f78defSmrg# Invoked by eval'ing the libtool variable 5064a4f78defSmrg# $sharedlib_from_linklib_cmd 5065a4f78defSmrg# Result is available in the variable 5066a4f78defSmrg# $sharedlib_from_linklib_result 5067a4f78defSmrgfunc_cygming_dll_for_implib_fallback () 5068a4f78defSmrg{ 5069a4f78defSmrg $debug_cmd 5070a4f78defSmrg 5071a4f78defSmrg if func_cygming_gnu_implib_p "$1"; then 5072a4f78defSmrg # binutils import library 5073a4f78defSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074a4f78defSmrg elif func_cygming_ms_implib_p "$1"; then 5075a4f78defSmrg # ms-generated import library 5076a4f78defSmrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077a4f78defSmrg else 5078a4f78defSmrg # unknown 5079a4f78defSmrg sharedlib_from_linklib_result= 5080a4f78defSmrg fi 5081a4f78defSmrg} 5082a4f78defSmrg 5083a4f78defSmrg 5084a4f78defSmrg# func_extract_an_archive dir oldlib 5085a4f78defSmrgfunc_extract_an_archive () 5086a4f78defSmrg{ 5087a4f78defSmrg $debug_cmd 5088a4f78defSmrg 5089a4f78defSmrg f_ex_an_ar_dir=$1; shift 5090a4f78defSmrg f_ex_an_ar_oldlib=$1 5091a4f78defSmrg if test yes = "$lock_old_archive_extraction"; then 5092a4f78defSmrg lockfile=$f_ex_an_ar_oldlib.lock 5093a4f78defSmrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5094a4f78defSmrg func_echo "Waiting for $lockfile to be removed" 5095a4f78defSmrg sleep 2 5096a4f78defSmrg done 5097a4f78defSmrg fi 5098a4f78defSmrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5099a4f78defSmrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5100a4f78defSmrg if test yes = "$lock_old_archive_extraction"; then 5101a4f78defSmrg $opt_dry_run || rm -f "$lockfile" 5102a4f78defSmrg fi 5103a4f78defSmrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5104a4f78defSmrg : 5105a4f78defSmrg else 5106a4f78defSmrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5107a4f78defSmrg fi 5108a4f78defSmrg} 5109a4f78defSmrg 5110a4f78defSmrg 5111a4f78defSmrg# func_extract_archives gentop oldlib ... 5112a4f78defSmrgfunc_extract_archives () 5113a4f78defSmrg{ 5114a4f78defSmrg $debug_cmd 5115a4f78defSmrg 5116a4f78defSmrg my_gentop=$1; shift 5117a4f78defSmrg my_oldlibs=${1+"$@"} 5118a4f78defSmrg my_oldobjs= 5119a4f78defSmrg my_xlib= 5120a4f78defSmrg my_xabs= 5121a4f78defSmrg my_xdir= 5122a4f78defSmrg 5123a4f78defSmrg for my_xlib in $my_oldlibs; do 5124a4f78defSmrg # Extract the objects. 5125a4f78defSmrg case $my_xlib in 5126a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5127a4f78defSmrg *) my_xabs=`pwd`"/$my_xlib" ;; 5128a4f78defSmrg esac 5129a4f78defSmrg func_basename "$my_xlib" 5130a4f78defSmrg my_xlib=$func_basename_result 5131a4f78defSmrg my_xlib_u=$my_xlib 5132a4f78defSmrg while :; do 5133a4f78defSmrg case " $extracted_archives " in 5134a4f78defSmrg *" $my_xlib_u "*) 5135a4f78defSmrg func_arith $extracted_serial + 1 5136a4f78defSmrg extracted_serial=$func_arith_result 5137a4f78defSmrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5138a4f78defSmrg *) break ;; 5139a4f78defSmrg esac 5140a4f78defSmrg done 5141a4f78defSmrg extracted_archives="$extracted_archives $my_xlib_u" 5142a4f78defSmrg my_xdir=$my_gentop/$my_xlib_u 5143a4f78defSmrg 5144a4f78defSmrg func_mkdir_p "$my_xdir" 5145a4f78defSmrg 5146a4f78defSmrg case $host in 5147a4f78defSmrg *-darwin*) 5148a4f78defSmrg func_verbose "Extracting $my_xabs" 5149a4f78defSmrg # Do not bother doing anything if just a dry run 5150a4f78defSmrg $opt_dry_run || { 5151a4f78defSmrg darwin_orig_dir=`pwd` 5152a4f78defSmrg cd $my_xdir || exit $? 5153a4f78defSmrg darwin_archive=$my_xabs 5154a4f78defSmrg darwin_curdir=`pwd` 5155a4f78defSmrg func_basename "$darwin_archive" 5156a4f78defSmrg darwin_base_archive=$func_basename_result 5157a4f78defSmrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5158a4f78defSmrg if test -n "$darwin_arches"; then 5159a4f78defSmrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5160a4f78defSmrg darwin_arch= 5161a4f78defSmrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162a4f78defSmrg for darwin_arch in $darwin_arches; do 5163a4f78defSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164a4f78defSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165a4f78defSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166a4f78defSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5167a4f78defSmrg cd "$darwin_curdir" 5168a4f78defSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5169a4f78defSmrg done # $darwin_arches 5170a4f78defSmrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171a4f78defSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5172a4f78defSmrg darwin_file= 5173a4f78defSmrg darwin_files= 5174a4f78defSmrg for darwin_file in $darwin_filelist; do 5175a4f78defSmrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5176a4f78defSmrg $LIPO -create -output "$darwin_file" $darwin_files 5177a4f78defSmrg done # $darwin_filelist 5178a4f78defSmrg $RM -rf unfat-$$ 5179a4f78defSmrg cd "$darwin_orig_dir" 5180a4f78defSmrg else 5181a4f78defSmrg cd $darwin_orig_dir 5182a4f78defSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5183a4f78defSmrg fi # $darwin_arches 5184a4f78defSmrg } # !$opt_dry_run 5185a4f78defSmrg ;; 5186a4f78defSmrg *) 5187a4f78defSmrg func_extract_an_archive "$my_xdir" "$my_xabs" 5188a4f78defSmrg ;; 5189a4f78defSmrg esac 5190a4f78defSmrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5191a4f78defSmrg done 5192a4f78defSmrg 5193a4f78defSmrg func_extract_archives_result=$my_oldobjs 5194a4f78defSmrg} 5195a4f78defSmrg 5196a4f78defSmrg 5197a4f78defSmrg# func_emit_wrapper [arg=no] 5198a4f78defSmrg# 5199a4f78defSmrg# Emit a libtool wrapper script on stdout. 5200a4f78defSmrg# Don't directly open a file because we may want to 5201a4f78defSmrg# incorporate the script contents within a cygwin/mingw 5202a4f78defSmrg# wrapper executable. Must ONLY be called from within 5203a4f78defSmrg# func_mode_link because it depends on a number of variables 5204a4f78defSmrg# set therein. 5205a4f78defSmrg# 5206a4f78defSmrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5207a4f78defSmrg# variable will take. If 'yes', then the emitted script 5208a4f78defSmrg# will assume that the directory where it is stored is 5209a4f78defSmrg# the $objdir directory. This is a cygwin/mingw-specific 5210a4f78defSmrg# behavior. 5211a4f78defSmrgfunc_emit_wrapper () 5212a4f78defSmrg{ 5213a4f78defSmrg func_emit_wrapper_arg1=${1-no} 5214a4f78defSmrg 5215a4f78defSmrg $ECHO "\ 5216a4f78defSmrg#! $SHELL 5217a4f78defSmrg 5218a4f78defSmrg# $output - temporary wrapper script for $objdir/$outputname 5219a4f78defSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5220a4f78defSmrg# 5221a4f78defSmrg# The $output program cannot be directly executed until all the libtool 5222a4f78defSmrg# libraries that it depends on are installed. 5223a4f78defSmrg# 5224a4f78defSmrg# This wrapper script should never be moved out of the build directory. 5225a4f78defSmrg# If it is, it will not operate correctly. 5226a4f78defSmrg 5227a4f78defSmrg# Sed substitution that helps us do robust quoting. It backslashifies 5228a4f78defSmrg# metacharacters that are still active within double-quoted strings. 5229a4f78defSmrgsed_quote_subst='$sed_quote_subst' 5230a4f78defSmrg 5231a4f78defSmrg# Be Bourne compatible 5232a4f78defSmrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5233a4f78defSmrg emulate sh 5234a4f78defSmrg NULLCMD=: 5235a4f78defSmrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5236a4f78defSmrg # is contrary to our usage. Disable this feature. 5237a4f78defSmrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5238a4f78defSmrg setopt NO_GLOB_SUBST 5239a4f78defSmrgelse 5240a4f78defSmrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5241a4f78defSmrgfi 5242a4f78defSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 5243a4f78defSmrgDUALCASE=1; export DUALCASE # for MKS sh 5244a4f78defSmrg 5245a4f78defSmrg# The HP-UX ksh and POSIX shell print the target directory to stdout 5246a4f78defSmrg# if CDPATH is set. 5247a4f78defSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248a4f78defSmrg 5249a4f78defSmrgrelink_command=\"$relink_command\" 5250a4f78defSmrg 5251a4f78defSmrg# This environment variable determines our operation mode. 5252a4f78defSmrgif test \"\$libtool_install_magic\" = \"$magic\"; then 5253a4f78defSmrg # install mode needs the following variables: 5254a4f78defSmrg generated_by_libtool_version='$macro_version' 5255a4f78defSmrg notinst_deplibs='$notinst_deplibs' 5256a4f78defSmrgelse 5257a4f78defSmrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5258a4f78defSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5259a4f78defSmrg file=\"\$0\"" 5260a4f78defSmrg 5261a4f78defSmrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 5262a4f78defSmrg $ECHO "\ 5263a4f78defSmrg 5264a4f78defSmrg# A function that is used when there is no print builtin or printf. 5265a4f78defSmrgfunc_fallback_echo () 5266a4f78defSmrg{ 5267a4f78defSmrg eval 'cat <<_LTECHO_EOF 5268a4f78defSmrg\$1 5269a4f78defSmrg_LTECHO_EOF' 5270a4f78defSmrg} 5271a4f78defSmrg ECHO=\"$qECHO\" 5272a4f78defSmrg fi 5273a4f78defSmrg 5274a4f78defSmrg# Very basic option parsing. These options are (a) specific to 5275a4f78defSmrg# the libtool wrapper, (b) are identical between the wrapper 5276a4f78defSmrg# /script/ and the wrapper /executable/ that is used only on 5277a4f78defSmrg# windows platforms, and (c) all begin with the string "--lt-" 5278a4f78defSmrg# (application programs are unlikely to have options that match 5279a4f78defSmrg# this pattern). 5280a4f78defSmrg# 5281a4f78defSmrg# There are only two supported options: --lt-debug and 5282a4f78defSmrg# --lt-dump-script. There is, deliberately, no --lt-help. 5283a4f78defSmrg# 5284a4f78defSmrg# The first argument to this parsing function should be the 5285a4f78defSmrg# script's $0 value, followed by "$@". 5286a4f78defSmrglt_option_debug= 5287a4f78defSmrgfunc_parse_lt_options () 5288a4f78defSmrg{ 5289a4f78defSmrg lt_script_arg0=\$0 5290a4f78defSmrg shift 5291a4f78defSmrg for lt_opt 5292a4f78defSmrg do 5293a4f78defSmrg case \"\$lt_opt\" in 5294a4f78defSmrg --lt-debug) lt_option_debug=1 ;; 5295a4f78defSmrg --lt-dump-script) 5296a4f78defSmrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5297a4f78defSmrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5298a4f78defSmrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5299a4f78defSmrg cat \"\$lt_dump_D/\$lt_dump_F\" 5300a4f78defSmrg exit 0 5301a4f78defSmrg ;; 5302a4f78defSmrg --lt-*) 5303a4f78defSmrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5304a4f78defSmrg exit 1 5305a4f78defSmrg ;; 5306a4f78defSmrg esac 5307a4f78defSmrg done 5308a4f78defSmrg 5309a4f78defSmrg # Print the debug banner immediately: 5310a4f78defSmrg if test -n \"\$lt_option_debug\"; then 5311a4f78defSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5312a4f78defSmrg fi 5313a4f78defSmrg} 5314a4f78defSmrg 5315a4f78defSmrg# Used when --lt-debug. Prints its arguments to stdout 5316a4f78defSmrg# (redirection is the responsibility of the caller) 5317a4f78defSmrgfunc_lt_dump_args () 5318a4f78defSmrg{ 5319a4f78defSmrg lt_dump_args_N=1; 5320a4f78defSmrg for lt_arg 5321a4f78defSmrg do 5322a4f78defSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5323a4f78defSmrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5324a4f78defSmrg done 5325a4f78defSmrg} 5326a4f78defSmrg 5327a4f78defSmrg# Core function for launching the target application 5328a4f78defSmrgfunc_exec_program_core () 5329a4f78defSmrg{ 5330a4f78defSmrg" 5331a4f78defSmrg case $host in 5332a4f78defSmrg # Backslashes separate directories on plain windows 5333a4f78defSmrg *-*-mingw | *-*-os2* | *-cegcc*) 5334a4f78defSmrg $ECHO "\ 5335a4f78defSmrg if test -n \"\$lt_option_debug\"; then 5336a4f78defSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5337a4f78defSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5338a4f78defSmrg fi 5339a4f78defSmrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5340a4f78defSmrg" 5341a4f78defSmrg ;; 5342a4f78defSmrg 5343a4f78defSmrg *) 5344a4f78defSmrg $ECHO "\ 5345a4f78defSmrg if test -n \"\$lt_option_debug\"; then 5346a4f78defSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5347a4f78defSmrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5348a4f78defSmrg fi 5349a4f78defSmrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5350a4f78defSmrg" 5351a4f78defSmrg ;; 5352a4f78defSmrg esac 5353a4f78defSmrg $ECHO "\ 5354a4f78defSmrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5355a4f78defSmrg exit 1 5356a4f78defSmrg} 5357a4f78defSmrg 5358a4f78defSmrg# A function to encapsulate launching the target application 5359a4f78defSmrg# Strips options in the --lt-* namespace from \$@ and 5360a4f78defSmrg# launches target application with the remaining arguments. 5361a4f78defSmrgfunc_exec_program () 5362a4f78defSmrg{ 5363a4f78defSmrg case \" \$* \" in 5364a4f78defSmrg *\\ --lt-*) 5365a4f78defSmrg for lt_wr_arg 5366a4f78defSmrg do 5367a4f78defSmrg case \$lt_wr_arg in 5368a4f78defSmrg --lt-*) ;; 5369a4f78defSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370a4f78defSmrg esac 5371a4f78defSmrg shift 5372a4f78defSmrg done ;; 5373a4f78defSmrg esac 5374a4f78defSmrg func_exec_program_core \${1+\"\$@\"} 5375a4f78defSmrg} 5376a4f78defSmrg 5377a4f78defSmrg # Parse options 5378a4f78defSmrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379a4f78defSmrg 5380a4f78defSmrg # Find the directory that this script lives in. 5381a4f78defSmrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5382a4f78defSmrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383a4f78defSmrg 5384a4f78defSmrg # Follow symbolic links until we get to the real thisdir. 5385a4f78defSmrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5386a4f78defSmrg while test -n \"\$file\"; do 5387a4f78defSmrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388a4f78defSmrg 5389a4f78defSmrg # If there was a directory component, then change thisdir. 5390a4f78defSmrg if test \"x\$destdir\" != \"x\$file\"; then 5391a4f78defSmrg case \"\$destdir\" in 5392a4f78defSmrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5393a4f78defSmrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5394a4f78defSmrg esac 5395a4f78defSmrg fi 5396a4f78defSmrg 5397a4f78defSmrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5398a4f78defSmrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5399a4f78defSmrg done 5400a4f78defSmrg 5401a4f78defSmrg # Usually 'no', except on cygwin/mingw when embedded into 5402a4f78defSmrg # the cwrapper. 5403a4f78defSmrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5404a4f78defSmrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5405a4f78defSmrg # special case for '.' 5406a4f78defSmrg if test \"\$thisdir\" = \".\"; then 5407a4f78defSmrg thisdir=\`pwd\` 5408a4f78defSmrg fi 5409a4f78defSmrg # remove .libs from thisdir 5410a4f78defSmrg case \"\$thisdir\" in 5411a4f78defSmrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5412a4f78defSmrg $objdir ) thisdir=. ;; 5413a4f78defSmrg esac 5414a4f78defSmrg fi 5415a4f78defSmrg 5416a4f78defSmrg # Try to get the absolute directory name. 5417a4f78defSmrg absdir=\`cd \"\$thisdir\" && pwd\` 5418a4f78defSmrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5419a4f78defSmrg" 5420a4f78defSmrg 5421a4f78defSmrg if test yes = "$fast_install"; then 5422a4f78defSmrg $ECHO "\ 5423a4f78defSmrg program=lt-'$outputname'$exeext 5424a4f78defSmrg progdir=\"\$thisdir/$objdir\" 5425a4f78defSmrg 5426a4f78defSmrg if test ! -f \"\$progdir/\$program\" || 5427a4f78defSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5428a4f78defSmrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429a4f78defSmrg 5430a4f78defSmrg file=\"\$\$-\$program\" 5431a4f78defSmrg 5432a4f78defSmrg if test ! -d \"\$progdir\"; then 5433a4f78defSmrg $MKDIR \"\$progdir\" 5434a4f78defSmrg else 5435a4f78defSmrg $RM \"\$progdir/\$file\" 5436a4f78defSmrg fi" 5437a4f78defSmrg 5438a4f78defSmrg $ECHO "\ 5439a4f78defSmrg 5440a4f78defSmrg # relink executable if necessary 5441a4f78defSmrg if test -n \"\$relink_command\"; then 5442a4f78defSmrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5443a4f78defSmrg else 5444a4f78defSmrg \$ECHO \"\$relink_command_output\" >&2 5445a4f78defSmrg $RM \"\$progdir/\$file\" 5446a4f78defSmrg exit 1 5447a4f78defSmrg fi 5448a4f78defSmrg fi 5449a4f78defSmrg 5450a4f78defSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5451a4f78defSmrg { $RM \"\$progdir/\$program\"; 5452a4f78defSmrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5453a4f78defSmrg $RM \"\$progdir/\$file\" 5454a4f78defSmrg fi" 5455a4f78defSmrg else 5456a4f78defSmrg $ECHO "\ 5457a4f78defSmrg program='$outputname' 5458a4f78defSmrg progdir=\"\$thisdir/$objdir\" 5459a4f78defSmrg" 5460a4f78defSmrg fi 5461a4f78defSmrg 5462a4f78defSmrg $ECHO "\ 5463a4f78defSmrg 5464a4f78defSmrg if test -f \"\$progdir/\$program\"; then" 5465a4f78defSmrg 5466a4f78defSmrg # fixup the dll searchpath if we need to. 5467a4f78defSmrg # 5468a4f78defSmrg # Fix the DLL searchpath if we need to. Do this before prepending 5469a4f78defSmrg # to shlibpath, because on Windows, both are PATH and uninstalled 5470a4f78defSmrg # libraries must come first. 5471a4f78defSmrg if test -n "$dllsearchpath"; then 5472a4f78defSmrg $ECHO "\ 5473a4f78defSmrg # Add the dll search path components to the executable PATH 5474a4f78defSmrg PATH=$dllsearchpath:\$PATH 5475a4f78defSmrg" 5476a4f78defSmrg fi 5477a4f78defSmrg 5478a4f78defSmrg # Export our shlibpath_var if we have one. 5479a4f78defSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5480a4f78defSmrg $ECHO "\ 5481a4f78defSmrg # Add our own library path to $shlibpath_var 5482a4f78defSmrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483a4f78defSmrg 5484a4f78defSmrg # Some systems cannot cope with colon-terminated $shlibpath_var 5485a4f78defSmrg # The second colon is a workaround for a bug in BeOS R4 sed 5486a4f78defSmrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487a4f78defSmrg 5488a4f78defSmrg export $shlibpath_var 5489a4f78defSmrg" 5490a4f78defSmrg fi 5491a4f78defSmrg 5492a4f78defSmrg $ECHO "\ 5493a4f78defSmrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5494a4f78defSmrg # Run the actual program with our arguments. 5495a4f78defSmrg func_exec_program \${1+\"\$@\"} 5496a4f78defSmrg fi 5497a4f78defSmrg else 5498a4f78defSmrg # The program doesn't exist. 5499a4f78defSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5500a4f78defSmrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5501a4f78defSmrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5502a4f78defSmrg exit 1 5503a4f78defSmrg fi 5504a4f78defSmrgfi\ 5505a4f78defSmrg" 5506a4f78defSmrg} 5507a4f78defSmrg 5508a4f78defSmrg 5509a4f78defSmrg# func_emit_cwrapperexe_src 5510a4f78defSmrg# emit the source code for a wrapper executable on stdout 5511a4f78defSmrg# Must ONLY be called from within func_mode_link because 5512a4f78defSmrg# it depends on a number of variable set therein. 5513a4f78defSmrgfunc_emit_cwrapperexe_src () 5514a4f78defSmrg{ 5515a4f78defSmrg cat <<EOF 5516a4f78defSmrg 5517a4f78defSmrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518a4f78defSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519a4f78defSmrg 5520a4f78defSmrg The $output program cannot be directly executed until all the libtool 5521a4f78defSmrg libraries that it depends on are installed. 5522a4f78defSmrg 5523a4f78defSmrg This wrapper executable should never be moved out of the build directory. 5524a4f78defSmrg If it is, it will not operate correctly. 5525a4f78defSmrg*/ 5526a4f78defSmrgEOF 5527a4f78defSmrg cat <<"EOF" 5528a4f78defSmrg#ifdef _MSC_VER 5529a4f78defSmrg# define _CRT_SECURE_NO_DEPRECATE 1 5530a4f78defSmrg#endif 5531a4f78defSmrg#include <stdio.h> 5532a4f78defSmrg#include <stdlib.h> 5533a4f78defSmrg#ifdef _MSC_VER 5534a4f78defSmrg# include <direct.h> 5535a4f78defSmrg# include <process.h> 5536a4f78defSmrg# include <io.h> 5537a4f78defSmrg#else 5538a4f78defSmrg# include <unistd.h> 5539a4f78defSmrg# include <stdint.h> 5540a4f78defSmrg# ifdef __CYGWIN__ 5541a4f78defSmrg# include <io.h> 5542a4f78defSmrg# endif 5543a4f78defSmrg#endif 5544a4f78defSmrg#include <malloc.h> 5545a4f78defSmrg#include <stdarg.h> 5546a4f78defSmrg#include <assert.h> 5547a4f78defSmrg#include <string.h> 5548a4f78defSmrg#include <ctype.h> 5549a4f78defSmrg#include <errno.h> 5550a4f78defSmrg#include <fcntl.h> 5551a4f78defSmrg#include <sys/stat.h> 5552a4f78defSmrg 5553a4f78defSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554a4f78defSmrg 5555a4f78defSmrg/* declarations of non-ANSI functions */ 5556a4f78defSmrg#if defined __MINGW32__ 5557a4f78defSmrg# ifdef __STRICT_ANSI__ 5558a4f78defSmrgint _putenv (const char *); 5559a4f78defSmrg# endif 5560a4f78defSmrg#elif defined __CYGWIN__ 5561a4f78defSmrg# ifdef __STRICT_ANSI__ 5562a4f78defSmrgchar *realpath (const char *, char *); 5563a4f78defSmrgint putenv (char *); 5564a4f78defSmrgint setenv (const char *, const char *, int); 5565a4f78defSmrg# endif 5566a4f78defSmrg/* #elif defined other_platform || defined ... */ 5567a4f78defSmrg#endif 5568a4f78defSmrg 5569a4f78defSmrg/* portability defines, excluding path handling macros */ 5570a4f78defSmrg#if defined _MSC_VER 5571a4f78defSmrg# define setmode _setmode 5572a4f78defSmrg# define stat _stat 5573a4f78defSmrg# define chmod _chmod 5574a4f78defSmrg# define getcwd _getcwd 5575a4f78defSmrg# define putenv _putenv 5576a4f78defSmrg# define S_IXUSR _S_IEXEC 5577a4f78defSmrg#elif defined __MINGW32__ 5578a4f78defSmrg# define setmode _setmode 5579a4f78defSmrg# define stat _stat 5580a4f78defSmrg# define chmod _chmod 5581a4f78defSmrg# define getcwd _getcwd 5582a4f78defSmrg# define putenv _putenv 5583a4f78defSmrg#elif defined __CYGWIN__ 5584a4f78defSmrg# define HAVE_SETENV 5585a4f78defSmrg# define FOPEN_WB "wb" 5586a4f78defSmrg/* #elif defined other platforms ... */ 5587a4f78defSmrg#endif 5588a4f78defSmrg 5589a4f78defSmrg#if defined PATH_MAX 5590a4f78defSmrg# define LT_PATHMAX PATH_MAX 5591a4f78defSmrg#elif defined MAXPATHLEN 5592a4f78defSmrg# define LT_PATHMAX MAXPATHLEN 5593a4f78defSmrg#else 5594a4f78defSmrg# define LT_PATHMAX 1024 5595a4f78defSmrg#endif 5596a4f78defSmrg 5597a4f78defSmrg#ifndef S_IXOTH 5598a4f78defSmrg# define S_IXOTH 0 5599a4f78defSmrg#endif 5600a4f78defSmrg#ifndef S_IXGRP 5601a4f78defSmrg# define S_IXGRP 0 5602a4f78defSmrg#endif 5603a4f78defSmrg 5604a4f78defSmrg/* path handling portability macros */ 5605a4f78defSmrg#ifndef DIR_SEPARATOR 5606a4f78defSmrg# define DIR_SEPARATOR '/' 5607a4f78defSmrg# define PATH_SEPARATOR ':' 5608a4f78defSmrg#endif 5609a4f78defSmrg 5610a4f78defSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611a4f78defSmrg defined __OS2__ 5612a4f78defSmrg# define HAVE_DOS_BASED_FILE_SYSTEM 5613a4f78defSmrg# define FOPEN_WB "wb" 5614a4f78defSmrg# ifndef DIR_SEPARATOR_2 5615a4f78defSmrg# define DIR_SEPARATOR_2 '\\' 5616a4f78defSmrg# endif 5617a4f78defSmrg# ifndef PATH_SEPARATOR_2 5618a4f78defSmrg# define PATH_SEPARATOR_2 ';' 5619a4f78defSmrg# endif 5620a4f78defSmrg#endif 5621a4f78defSmrg 5622a4f78defSmrg#ifndef DIR_SEPARATOR_2 5623a4f78defSmrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5624a4f78defSmrg#else /* DIR_SEPARATOR_2 */ 5625a4f78defSmrg# define IS_DIR_SEPARATOR(ch) \ 5626a4f78defSmrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5627a4f78defSmrg#endif /* DIR_SEPARATOR_2 */ 5628a4f78defSmrg 5629a4f78defSmrg#ifndef PATH_SEPARATOR_2 5630a4f78defSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5631a4f78defSmrg#else /* PATH_SEPARATOR_2 */ 5632a4f78defSmrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5633a4f78defSmrg#endif /* PATH_SEPARATOR_2 */ 5634a4f78defSmrg 5635a4f78defSmrg#ifndef FOPEN_WB 5636a4f78defSmrg# define FOPEN_WB "w" 5637a4f78defSmrg#endif 5638a4f78defSmrg#ifndef _O_BINARY 5639a4f78defSmrg# define _O_BINARY 0 5640a4f78defSmrg#endif 5641a4f78defSmrg 5642a4f78defSmrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5643a4f78defSmrg#define XFREE(stale) do { \ 5644a4f78defSmrg if (stale) { free (stale); stale = 0; } \ 5645a4f78defSmrg} while (0) 5646a4f78defSmrg 5647a4f78defSmrg#if defined LT_DEBUGWRAPPER 5648a4f78defSmrgstatic int lt_debug = 1; 5649a4f78defSmrg#else 5650a4f78defSmrgstatic int lt_debug = 0; 5651a4f78defSmrg#endif 5652a4f78defSmrg 5653a4f78defSmrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5654a4f78defSmrg 5655a4f78defSmrgvoid *xmalloc (size_t num); 5656a4f78defSmrgchar *xstrdup (const char *string); 5657a4f78defSmrgconst char *base_name (const char *name); 5658a4f78defSmrgchar *find_executable (const char *wrapper); 5659a4f78defSmrgchar *chase_symlinks (const char *pathspec); 5660a4f78defSmrgint make_executable (const char *path); 5661a4f78defSmrgint check_executable (const char *path); 5662a4f78defSmrgchar *strendzap (char *str, const char *pat); 5663a4f78defSmrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 5664a4f78defSmrgvoid lt_fatal (const char *file, int line, const char *message, ...); 5665a4f78defSmrgstatic const char *nonnull (const char *s); 5666a4f78defSmrgstatic const char *nonempty (const char *s); 5667a4f78defSmrgvoid lt_setenv (const char *name, const char *value); 5668a4f78defSmrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 5669a4f78defSmrgvoid lt_update_exe_path (const char *name, const char *value); 5670a4f78defSmrgvoid lt_update_lib_path (const char *name, const char *value); 5671a4f78defSmrgchar **prepare_spawn (char **argv); 5672a4f78defSmrgvoid lt_dump_script (FILE *f); 5673a4f78defSmrgEOF 5674a4f78defSmrg 5675a4f78defSmrg cat <<EOF 5676a4f78defSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677a4f78defSmrg# define externally_visible volatile 5678a4f78defSmrg#else 5679a4f78defSmrg# define externally_visible __attribute__((externally_visible)) volatile 5680a4f78defSmrg#endif 5681a4f78defSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 5682a4f78defSmrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 5683a4f78defSmrgEOF 5684a4f78defSmrg 5685a4f78defSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686a4f78defSmrg func_to_host_path "$temp_rpath" 5687a4f78defSmrg cat <<EOF 5688a4f78defSmrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689a4f78defSmrgEOF 5690a4f78defSmrg else 5691a4f78defSmrg cat <<"EOF" 5692a4f78defSmrgconst char * LIB_PATH_VALUE = ""; 5693a4f78defSmrgEOF 5694a4f78defSmrg fi 5695a4f78defSmrg 5696a4f78defSmrg if test -n "$dllsearchpath"; then 5697a4f78defSmrg func_to_host_path "$dllsearchpath:" 5698a4f78defSmrg cat <<EOF 5699a4f78defSmrgconst char * EXE_PATH_VARNAME = "PATH"; 5700a4f78defSmrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5701a4f78defSmrgEOF 5702a4f78defSmrg else 5703a4f78defSmrg cat <<"EOF" 5704a4f78defSmrgconst char * EXE_PATH_VARNAME = ""; 5705a4f78defSmrgconst char * EXE_PATH_VALUE = ""; 5706a4f78defSmrgEOF 5707a4f78defSmrg fi 5708a4f78defSmrg 5709a4f78defSmrg if test yes = "$fast_install"; then 5710a4f78defSmrg cat <<EOF 5711a4f78defSmrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5712a4f78defSmrgEOF 5713a4f78defSmrg else 5714a4f78defSmrg cat <<EOF 5715a4f78defSmrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5716a4f78defSmrgEOF 5717a4f78defSmrg fi 5718a4f78defSmrg 5719a4f78defSmrg 5720a4f78defSmrg cat <<"EOF" 5721a4f78defSmrg 5722a4f78defSmrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723a4f78defSmrg 5724a4f78defSmrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5725a4f78defSmrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5726a4f78defSmrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727a4f78defSmrg 5728a4f78defSmrgint 5729a4f78defSmrgmain (int argc, char *argv[]) 5730a4f78defSmrg{ 5731a4f78defSmrg char **newargz; 5732a4f78defSmrg int newargc; 5733a4f78defSmrg char *tmp_pathspec; 5734a4f78defSmrg char *actual_cwrapper_path; 5735a4f78defSmrg char *actual_cwrapper_name; 5736a4f78defSmrg char *target_name; 5737a4f78defSmrg char *lt_argv_zero; 5738a4f78defSmrg int rval = 127; 5739a4f78defSmrg 5740a4f78defSmrg int i; 5741a4f78defSmrg 5742a4f78defSmrg program_name = (char *) xstrdup (base_name (argv[0])); 5743a4f78defSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744a4f78defSmrg 5745a4f78defSmrg /* very simple arg parsing; don't want to rely on getopt 5746a4f78defSmrg * also, copy all non cwrapper options to newargz, except 5747a4f78defSmrg * argz[0], which is handled differently 5748a4f78defSmrg */ 5749a4f78defSmrg newargc=0; 5750a4f78defSmrg for (i = 1; i < argc; i++) 5751a4f78defSmrg { 5752a4f78defSmrg if (STREQ (argv[i], dumpscript_opt)) 5753a4f78defSmrg { 5754a4f78defSmrgEOF 5755a4f78defSmrg case $host in 5756a4f78defSmrg *mingw* | *cygwin* ) 5757a4f78defSmrg # make stdout use "unix" line endings 5758a4f78defSmrg echo " setmode(1,_O_BINARY);" 5759a4f78defSmrg ;; 5760a4f78defSmrg esac 5761a4f78defSmrg 5762a4f78defSmrg cat <<"EOF" 5763a4f78defSmrg lt_dump_script (stdout); 5764a4f78defSmrg return 0; 5765a4f78defSmrg } 5766a4f78defSmrg if (STREQ (argv[i], debug_opt)) 5767a4f78defSmrg { 5768a4f78defSmrg lt_debug = 1; 5769a4f78defSmrg continue; 5770a4f78defSmrg } 5771a4f78defSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 5772a4f78defSmrg { 5773a4f78defSmrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 5774a4f78defSmrg namespace, but it is not one of the ones we know about and 5775a4f78defSmrg have already dealt with, above (inluding dump-script), then 5776a4f78defSmrg report an error. Otherwise, targets might begin to believe 5777a4f78defSmrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 5778a4f78defSmrg namespace. The first time any user complains about this, we'll 5779a4f78defSmrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 5780a4f78defSmrg or a configure.ac-settable value. 5781a4f78defSmrg */ 5782a4f78defSmrg lt_fatal (__FILE__, __LINE__, 5783a4f78defSmrg "unrecognized %s option: '%s'", 5784a4f78defSmrg ltwrapper_option_prefix, argv[i]); 5785a4f78defSmrg } 5786a4f78defSmrg /* otherwise ... */ 5787a4f78defSmrg newargz[++newargc] = xstrdup (argv[i]); 5788a4f78defSmrg } 5789a4f78defSmrg newargz[++newargc] = NULL; 5790a4f78defSmrg 5791a4f78defSmrgEOF 5792a4f78defSmrg cat <<EOF 5793a4f78defSmrg /* The GNU banner must be the first non-error debug message */ 5794a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 5795a4f78defSmrgEOF 5796a4f78defSmrg cat <<"EOF" 5797a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 5798a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799a4f78defSmrg 5800a4f78defSmrg tmp_pathspec = find_executable (argv[0]); 5801a4f78defSmrg if (tmp_pathspec == NULL) 5802a4f78defSmrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 5803a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, 5804a4f78defSmrg "(main) found exe (before symlink chase) at: %s\n", 5805a4f78defSmrg tmp_pathspec); 5806a4f78defSmrg 5807a4f78defSmrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 5808a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, 5809a4f78defSmrg "(main) found exe (after symlink chase) at: %s\n", 5810a4f78defSmrg actual_cwrapper_path); 5811a4f78defSmrg XFREE (tmp_pathspec); 5812a4f78defSmrg 5813a4f78defSmrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 5814a4f78defSmrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 5815a4f78defSmrg 5816a4f78defSmrg /* wrapper name transforms */ 5817a4f78defSmrg strendzap (actual_cwrapper_name, ".exe"); 5818a4f78defSmrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 5819a4f78defSmrg XFREE (actual_cwrapper_name); 5820a4f78defSmrg actual_cwrapper_name = tmp_pathspec; 5821a4f78defSmrg tmp_pathspec = 0; 5822a4f78defSmrg 5823a4f78defSmrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 5824a4f78defSmrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 5825a4f78defSmrg strendzap (target_name, ".exe"); 5826a4f78defSmrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 5827a4f78defSmrg XFREE (target_name); 5828a4f78defSmrg target_name = tmp_pathspec; 5829a4f78defSmrg tmp_pathspec = 0; 5830a4f78defSmrg 5831a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, 5832a4f78defSmrg "(main) libtool target name: %s\n", 5833a4f78defSmrg target_name); 5834a4f78defSmrgEOF 5835a4f78defSmrg 5836a4f78defSmrg cat <<EOF 5837a4f78defSmrg newargz[0] = 5838a4f78defSmrg XMALLOC (char, (strlen (actual_cwrapper_path) + 5839a4f78defSmrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 5840a4f78defSmrg strcpy (newargz[0], actual_cwrapper_path); 5841a4f78defSmrg strcat (newargz[0], "$objdir"); 5842a4f78defSmrg strcat (newargz[0], "/"); 5843a4f78defSmrgEOF 5844a4f78defSmrg 5845a4f78defSmrg cat <<"EOF" 5846a4f78defSmrg /* stop here, and copy so we don't have to do this twice */ 5847a4f78defSmrg tmp_pathspec = xstrdup (newargz[0]); 5848a4f78defSmrg 5849a4f78defSmrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 5850a4f78defSmrg strcat (newargz[0], actual_cwrapper_name); 5851a4f78defSmrg 5852a4f78defSmrg /* DO want the lt- prefix here if it exists, so use target_name */ 5853a4f78defSmrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 5854a4f78defSmrg XFREE (tmp_pathspec); 5855a4f78defSmrg tmp_pathspec = NULL; 5856a4f78defSmrgEOF 5857a4f78defSmrg 5858a4f78defSmrg case $host_os in 5859a4f78defSmrg mingw*) 5860a4f78defSmrg cat <<"EOF" 5861a4f78defSmrg { 5862a4f78defSmrg char* p; 5863a4f78defSmrg while ((p = strchr (newargz[0], '\\')) != NULL) 5864a4f78defSmrg { 5865a4f78defSmrg *p = '/'; 5866a4f78defSmrg } 5867a4f78defSmrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 5868a4f78defSmrg { 5869a4f78defSmrg *p = '/'; 5870a4f78defSmrg } 5871a4f78defSmrg } 5872a4f78defSmrgEOF 5873a4f78defSmrg ;; 5874a4f78defSmrg esac 5875a4f78defSmrg 5876a4f78defSmrg cat <<"EOF" 5877a4f78defSmrg XFREE (target_name); 5878a4f78defSmrg XFREE (actual_cwrapper_path); 5879a4f78defSmrg XFREE (actual_cwrapper_name); 5880a4f78defSmrg 5881a4f78defSmrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 5882a4f78defSmrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883a4f78defSmrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884a4f78defSmrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885a4f78defSmrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5886a4f78defSmrg libraries must come first. */ 5887a4f78defSmrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888a4f78defSmrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889a4f78defSmrg 5890a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 5891a4f78defSmrg nonnull (lt_argv_zero)); 5892a4f78defSmrg for (i = 0; i < newargc; i++) 5893a4f78defSmrg { 5894a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 5895a4f78defSmrg i, nonnull (newargz[i])); 5896a4f78defSmrg } 5897a4f78defSmrg 5898a4f78defSmrgEOF 5899a4f78defSmrg 5900a4f78defSmrg case $host_os in 5901a4f78defSmrg mingw*) 5902a4f78defSmrg cat <<"EOF" 5903a4f78defSmrg /* execv doesn't actually work on mingw as expected on unix */ 5904a4f78defSmrg newargz = prepare_spawn (newargz); 5905a4f78defSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 5906a4f78defSmrg if (rval == -1) 5907a4f78defSmrg { 5908a4f78defSmrg /* failed to start process */ 5909a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, 5910a4f78defSmrg "(main) failed to launch target \"%s\": %s\n", 5911a4f78defSmrg lt_argv_zero, nonnull (strerror (errno))); 5912a4f78defSmrg return 127; 5913a4f78defSmrg } 5914a4f78defSmrg return rval; 5915a4f78defSmrgEOF 5916a4f78defSmrg ;; 5917a4f78defSmrg *) 5918a4f78defSmrg cat <<"EOF" 5919a4f78defSmrg execv (lt_argv_zero, newargz); 5920a4f78defSmrg return rval; /* =127, but avoids unused variable warning */ 5921a4f78defSmrgEOF 5922a4f78defSmrg ;; 5923a4f78defSmrg esac 5924a4f78defSmrg 5925a4f78defSmrg cat <<"EOF" 5926a4f78defSmrg} 5927a4f78defSmrg 5928a4f78defSmrgvoid * 5929a4f78defSmrgxmalloc (size_t num) 5930a4f78defSmrg{ 5931a4f78defSmrg void *p = (void *) malloc (num); 5932a4f78defSmrg if (!p) 5933a4f78defSmrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934a4f78defSmrg 5935a4f78defSmrg return p; 5936a4f78defSmrg} 5937a4f78defSmrg 5938a4f78defSmrgchar * 5939a4f78defSmrgxstrdup (const char *string) 5940a4f78defSmrg{ 5941a4f78defSmrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 5942a4f78defSmrg string) : NULL; 5943a4f78defSmrg} 5944a4f78defSmrg 5945a4f78defSmrgconst char * 5946a4f78defSmrgbase_name (const char *name) 5947a4f78defSmrg{ 5948a4f78defSmrg const char *base; 5949a4f78defSmrg 5950a4f78defSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 5951a4f78defSmrg /* Skip over the disk name in MSDOS pathnames. */ 5952a4f78defSmrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 5953a4f78defSmrg name += 2; 5954a4f78defSmrg#endif 5955a4f78defSmrg 5956a4f78defSmrg for (base = name; *name; name++) 5957a4f78defSmrg if (IS_DIR_SEPARATOR (*name)) 5958a4f78defSmrg base = name + 1; 5959a4f78defSmrg return base; 5960a4f78defSmrg} 5961a4f78defSmrg 5962a4f78defSmrgint 5963a4f78defSmrgcheck_executable (const char *path) 5964a4f78defSmrg{ 5965a4f78defSmrg struct stat st; 5966a4f78defSmrg 5967a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 5968a4f78defSmrg nonempty (path)); 5969a4f78defSmrg if ((!path) || (!*path)) 5970a4f78defSmrg return 0; 5971a4f78defSmrg 5972a4f78defSmrg if ((stat (path, &st) >= 0) 5973a4f78defSmrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 5974a4f78defSmrg return 1; 5975a4f78defSmrg else 5976a4f78defSmrg return 0; 5977a4f78defSmrg} 5978a4f78defSmrg 5979a4f78defSmrgint 5980a4f78defSmrgmake_executable (const char *path) 5981a4f78defSmrg{ 5982a4f78defSmrg int rval = 0; 5983a4f78defSmrg struct stat st; 5984a4f78defSmrg 5985a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 5986a4f78defSmrg nonempty (path)); 5987a4f78defSmrg if ((!path) || (!*path)) 5988a4f78defSmrg return 0; 5989a4f78defSmrg 5990a4f78defSmrg if (stat (path, &st) >= 0) 5991a4f78defSmrg { 5992a4f78defSmrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 5993a4f78defSmrg } 5994a4f78defSmrg return rval; 5995a4f78defSmrg} 5996a4f78defSmrg 5997a4f78defSmrg/* Searches for the full path of the wrapper. Returns 5998a4f78defSmrg newly allocated full path name if found, NULL otherwise 5999a4f78defSmrg Does not chase symlinks, even on platforms that support them. 6000a4f78defSmrg*/ 6001a4f78defSmrgchar * 6002a4f78defSmrgfind_executable (const char *wrapper) 6003a4f78defSmrg{ 6004a4f78defSmrg int has_slash = 0; 6005a4f78defSmrg const char *p; 6006a4f78defSmrg const char *p_next; 6007a4f78defSmrg /* static buffer for getcwd */ 6008a4f78defSmrg char tmp[LT_PATHMAX + 1]; 6009a4f78defSmrg size_t tmp_len; 6010a4f78defSmrg char *concat_name; 6011a4f78defSmrg 6012a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6013a4f78defSmrg nonempty (wrapper)); 6014a4f78defSmrg 6015a4f78defSmrg if ((wrapper == NULL) || (*wrapper == '\0')) 6016a4f78defSmrg return NULL; 6017a4f78defSmrg 6018a4f78defSmrg /* Absolute path? */ 6019a4f78defSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6020a4f78defSmrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6021a4f78defSmrg { 6022a4f78defSmrg concat_name = xstrdup (wrapper); 6023a4f78defSmrg if (check_executable (concat_name)) 6024a4f78defSmrg return concat_name; 6025a4f78defSmrg XFREE (concat_name); 6026a4f78defSmrg } 6027a4f78defSmrg else 6028a4f78defSmrg { 6029a4f78defSmrg#endif 6030a4f78defSmrg if (IS_DIR_SEPARATOR (wrapper[0])) 6031a4f78defSmrg { 6032a4f78defSmrg concat_name = xstrdup (wrapper); 6033a4f78defSmrg if (check_executable (concat_name)) 6034a4f78defSmrg return concat_name; 6035a4f78defSmrg XFREE (concat_name); 6036a4f78defSmrg } 6037a4f78defSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 6038a4f78defSmrg } 6039a4f78defSmrg#endif 6040a4f78defSmrg 6041a4f78defSmrg for (p = wrapper; *p; p++) 6042a4f78defSmrg if (*p == '/') 6043a4f78defSmrg { 6044a4f78defSmrg has_slash = 1; 6045a4f78defSmrg break; 6046a4f78defSmrg } 6047a4f78defSmrg if (!has_slash) 6048a4f78defSmrg { 6049a4f78defSmrg /* no slashes; search PATH */ 6050a4f78defSmrg const char *path = getenv ("PATH"); 6051a4f78defSmrg if (path != NULL) 6052a4f78defSmrg { 6053a4f78defSmrg for (p = path; *p; p = p_next) 6054a4f78defSmrg { 6055a4f78defSmrg const char *q; 6056a4f78defSmrg size_t p_len; 6057a4f78defSmrg for (q = p; *q; q++) 6058a4f78defSmrg if (IS_PATH_SEPARATOR (*q)) 6059a4f78defSmrg break; 6060a4f78defSmrg p_len = (size_t) (q - p); 6061a4f78defSmrg p_next = (*q == '\0' ? q : q + 1); 6062a4f78defSmrg if (p_len == 0) 6063a4f78defSmrg { 6064a4f78defSmrg /* empty path: current directory */ 6065a4f78defSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6066a4f78defSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6067a4f78defSmrg nonnull (strerror (errno))); 6068a4f78defSmrg tmp_len = strlen (tmp); 6069a4f78defSmrg concat_name = 6070a4f78defSmrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6071a4f78defSmrg memcpy (concat_name, tmp, tmp_len); 6072a4f78defSmrg concat_name[tmp_len] = '/'; 6073a4f78defSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6074a4f78defSmrg } 6075a4f78defSmrg else 6076a4f78defSmrg { 6077a4f78defSmrg concat_name = 6078a4f78defSmrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6079a4f78defSmrg memcpy (concat_name, p, p_len); 6080a4f78defSmrg concat_name[p_len] = '/'; 6081a4f78defSmrg strcpy (concat_name + p_len + 1, wrapper); 6082a4f78defSmrg } 6083a4f78defSmrg if (check_executable (concat_name)) 6084a4f78defSmrg return concat_name; 6085a4f78defSmrg XFREE (concat_name); 6086a4f78defSmrg } 6087a4f78defSmrg } 6088a4f78defSmrg /* not found in PATH; assume curdir */ 6089a4f78defSmrg } 6090a4f78defSmrg /* Relative path | not found in path: prepend cwd */ 6091a4f78defSmrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6092a4f78defSmrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6093a4f78defSmrg nonnull (strerror (errno))); 6094a4f78defSmrg tmp_len = strlen (tmp); 6095a4f78defSmrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6096a4f78defSmrg memcpy (concat_name, tmp, tmp_len); 6097a4f78defSmrg concat_name[tmp_len] = '/'; 6098a4f78defSmrg strcpy (concat_name + tmp_len + 1, wrapper); 6099a4f78defSmrg 6100a4f78defSmrg if (check_executable (concat_name)) 6101a4f78defSmrg return concat_name; 6102a4f78defSmrg XFREE (concat_name); 6103a4f78defSmrg return NULL; 6104a4f78defSmrg} 6105a4f78defSmrg 6106a4f78defSmrgchar * 6107a4f78defSmrgchase_symlinks (const char *pathspec) 6108a4f78defSmrg{ 6109a4f78defSmrg#ifndef S_ISLNK 6110a4f78defSmrg return xstrdup (pathspec); 6111a4f78defSmrg#else 6112a4f78defSmrg char buf[LT_PATHMAX]; 6113a4f78defSmrg struct stat s; 6114a4f78defSmrg char *tmp_pathspec = xstrdup (pathspec); 6115a4f78defSmrg char *p; 6116a4f78defSmrg int has_symlinks = 0; 6117a4f78defSmrg while (strlen (tmp_pathspec) && !has_symlinks) 6118a4f78defSmrg { 6119a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, 6120a4f78defSmrg "checking path component for symlinks: %s\n", 6121a4f78defSmrg tmp_pathspec); 6122a4f78defSmrg if (lstat (tmp_pathspec, &s) == 0) 6123a4f78defSmrg { 6124a4f78defSmrg if (S_ISLNK (s.st_mode) != 0) 6125a4f78defSmrg { 6126a4f78defSmrg has_symlinks = 1; 6127a4f78defSmrg break; 6128a4f78defSmrg } 6129a4f78defSmrg 6130a4f78defSmrg /* search backwards for last DIR_SEPARATOR */ 6131a4f78defSmrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6132a4f78defSmrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6133a4f78defSmrg p--; 6134a4f78defSmrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6135a4f78defSmrg { 6136a4f78defSmrg /* no more DIR_SEPARATORS left */ 6137a4f78defSmrg break; 6138a4f78defSmrg } 6139a4f78defSmrg *p = '\0'; 6140a4f78defSmrg } 6141a4f78defSmrg else 6142a4f78defSmrg { 6143a4f78defSmrg lt_fatal (__FILE__, __LINE__, 6144a4f78defSmrg "error accessing file \"%s\": %s", 6145a4f78defSmrg tmp_pathspec, nonnull (strerror (errno))); 6146a4f78defSmrg } 6147a4f78defSmrg } 6148a4f78defSmrg XFREE (tmp_pathspec); 6149a4f78defSmrg 6150a4f78defSmrg if (!has_symlinks) 6151a4f78defSmrg { 6152a4f78defSmrg return xstrdup (pathspec); 6153a4f78defSmrg } 6154a4f78defSmrg 6155a4f78defSmrg tmp_pathspec = realpath (pathspec, buf); 6156a4f78defSmrg if (tmp_pathspec == 0) 6157a4f78defSmrg { 6158a4f78defSmrg lt_fatal (__FILE__, __LINE__, 6159a4f78defSmrg "could not follow symlinks for %s", pathspec); 6160a4f78defSmrg } 6161a4f78defSmrg return xstrdup (tmp_pathspec); 6162a4f78defSmrg#endif 6163a4f78defSmrg} 6164a4f78defSmrg 6165a4f78defSmrgchar * 6166a4f78defSmrgstrendzap (char *str, const char *pat) 6167a4f78defSmrg{ 6168a4f78defSmrg size_t len, patlen; 6169a4f78defSmrg 6170a4f78defSmrg assert (str != NULL); 6171a4f78defSmrg assert (pat != NULL); 6172a4f78defSmrg 6173a4f78defSmrg len = strlen (str); 6174a4f78defSmrg patlen = strlen (pat); 6175a4f78defSmrg 6176a4f78defSmrg if (patlen <= len) 6177a4f78defSmrg { 6178a4f78defSmrg str += len - patlen; 6179a4f78defSmrg if (STREQ (str, pat)) 6180a4f78defSmrg *str = '\0'; 6181a4f78defSmrg } 6182a4f78defSmrg return str; 6183a4f78defSmrg} 6184a4f78defSmrg 6185a4f78defSmrgvoid 6186a4f78defSmrglt_debugprintf (const char *file, int line, const char *fmt, ...) 6187a4f78defSmrg{ 6188a4f78defSmrg va_list args; 6189a4f78defSmrg if (lt_debug) 6190a4f78defSmrg { 6191a4f78defSmrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6192a4f78defSmrg va_start (args, fmt); 6193a4f78defSmrg (void) vfprintf (stderr, fmt, args); 6194a4f78defSmrg va_end (args); 6195a4f78defSmrg } 6196a4f78defSmrg} 6197a4f78defSmrg 6198a4f78defSmrgstatic void 6199a4f78defSmrglt_error_core (int exit_status, const char *file, 6200a4f78defSmrg int line, const char *mode, 6201a4f78defSmrg const char *message, va_list ap) 6202a4f78defSmrg{ 6203a4f78defSmrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6204a4f78defSmrg vfprintf (stderr, message, ap); 6205a4f78defSmrg fprintf (stderr, ".\n"); 6206a4f78defSmrg 6207a4f78defSmrg if (exit_status >= 0) 6208a4f78defSmrg exit (exit_status); 6209a4f78defSmrg} 6210a4f78defSmrg 6211a4f78defSmrgvoid 6212a4f78defSmrglt_fatal (const char *file, int line, const char *message, ...) 6213a4f78defSmrg{ 6214a4f78defSmrg va_list ap; 6215a4f78defSmrg va_start (ap, message); 6216a4f78defSmrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6217a4f78defSmrg va_end (ap); 6218a4f78defSmrg} 6219a4f78defSmrg 6220a4f78defSmrgstatic const char * 6221a4f78defSmrgnonnull (const char *s) 6222a4f78defSmrg{ 6223a4f78defSmrg return s ? s : "(null)"; 6224a4f78defSmrg} 6225a4f78defSmrg 6226a4f78defSmrgstatic const char * 6227a4f78defSmrgnonempty (const char *s) 6228a4f78defSmrg{ 6229a4f78defSmrg return (s && !*s) ? "(empty)" : nonnull (s); 6230a4f78defSmrg} 6231a4f78defSmrg 6232a4f78defSmrgvoid 6233a4f78defSmrglt_setenv (const char *name, const char *value) 6234a4f78defSmrg{ 6235a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, 6236a4f78defSmrg "(lt_setenv) setting '%s' to '%s'\n", 6237a4f78defSmrg nonnull (name), nonnull (value)); 6238a4f78defSmrg { 6239a4f78defSmrg#ifdef HAVE_SETENV 6240a4f78defSmrg /* always make a copy, for consistency with !HAVE_SETENV */ 6241a4f78defSmrg char *str = xstrdup (value); 6242a4f78defSmrg setenv (name, str, 1); 6243a4f78defSmrg#else 6244a4f78defSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6245a4f78defSmrg char *str = XMALLOC (char, len); 6246a4f78defSmrg sprintf (str, "%s=%s", name, value); 6247a4f78defSmrg if (putenv (str) != EXIT_SUCCESS) 6248a4f78defSmrg { 6249a4f78defSmrg XFREE (str); 6250a4f78defSmrg } 6251a4f78defSmrg#endif 6252a4f78defSmrg } 6253a4f78defSmrg} 6254a4f78defSmrg 6255a4f78defSmrgchar * 6256a4f78defSmrglt_extend_str (const char *orig_value, const char *add, int to_end) 6257a4f78defSmrg{ 6258a4f78defSmrg char *new_value; 6259a4f78defSmrg if (orig_value && *orig_value) 6260a4f78defSmrg { 6261a4f78defSmrg size_t orig_value_len = strlen (orig_value); 6262a4f78defSmrg size_t add_len = strlen (add); 6263a4f78defSmrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6264a4f78defSmrg if (to_end) 6265a4f78defSmrg { 6266a4f78defSmrg strcpy (new_value, orig_value); 6267a4f78defSmrg strcpy (new_value + orig_value_len, add); 6268a4f78defSmrg } 6269a4f78defSmrg else 6270a4f78defSmrg { 6271a4f78defSmrg strcpy (new_value, add); 6272a4f78defSmrg strcpy (new_value + add_len, orig_value); 6273a4f78defSmrg } 6274a4f78defSmrg } 6275a4f78defSmrg else 6276a4f78defSmrg { 6277a4f78defSmrg new_value = xstrdup (add); 6278a4f78defSmrg } 6279a4f78defSmrg return new_value; 6280a4f78defSmrg} 6281a4f78defSmrg 6282a4f78defSmrgvoid 6283a4f78defSmrglt_update_exe_path (const char *name, const char *value) 6284a4f78defSmrg{ 6285a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, 6286a4f78defSmrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6287a4f78defSmrg nonnull (name), nonnull (value)); 6288a4f78defSmrg 6289a4f78defSmrg if (name && *name && value && *value) 6290a4f78defSmrg { 6291a4f78defSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6292a4f78defSmrg /* some systems can't cope with a ':'-terminated path #' */ 6293a4f78defSmrg size_t len = strlen (new_value); 6294a4f78defSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6295a4f78defSmrg { 6296a4f78defSmrg new_value[--len] = '\0'; 6297a4f78defSmrg } 6298a4f78defSmrg lt_setenv (name, new_value); 6299a4f78defSmrg XFREE (new_value); 6300a4f78defSmrg } 6301a4f78defSmrg} 6302a4f78defSmrg 6303a4f78defSmrgvoid 6304a4f78defSmrglt_update_lib_path (const char *name, const char *value) 6305a4f78defSmrg{ 6306a4f78defSmrg lt_debugprintf (__FILE__, __LINE__, 6307a4f78defSmrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6308a4f78defSmrg nonnull (name), nonnull (value)); 6309a4f78defSmrg 6310a4f78defSmrg if (name && *name && value && *value) 6311a4f78defSmrg { 6312a4f78defSmrg char *new_value = lt_extend_str (getenv (name), value, 0); 6313a4f78defSmrg lt_setenv (name, new_value); 6314a4f78defSmrg XFREE (new_value); 6315a4f78defSmrg } 6316a4f78defSmrg} 6317a4f78defSmrg 6318a4f78defSmrgEOF 6319a4f78defSmrg case $host_os in 6320a4f78defSmrg mingw*) 6321a4f78defSmrg cat <<"EOF" 6322a4f78defSmrg 6323a4f78defSmrg/* Prepares an argument vector before calling spawn(). 6324a4f78defSmrg Note that spawn() does not by itself call the command interpreter 6325a4f78defSmrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6326a4f78defSmrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6327a4f78defSmrg GetVersionEx(&v); 6328a4f78defSmrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6329a4f78defSmrg }) ? "cmd.exe" : "command.com"). 6330a4f78defSmrg Instead it simply concatenates the arguments, separated by ' ', and calls 6331a4f78defSmrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6332a4f78defSmrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6333a4f78defSmrg special way: 6334a4f78defSmrg - Space and tab are interpreted as delimiters. They are not treated as 6335a4f78defSmrg delimiters if they are surrounded by double quotes: "...". 6336a4f78defSmrg - Unescaped double quotes are removed from the input. Their only effect is 6337a4f78defSmrg that within double quotes, space and tab are treated like normal 6338a4f78defSmrg characters. 6339a4f78defSmrg - Backslashes not followed by double quotes are not special. 6340a4f78defSmrg - But 2*n+1 backslashes followed by a double quote become 6341a4f78defSmrg n backslashes followed by a double quote (n >= 0): 6342a4f78defSmrg \" -> " 6343a4f78defSmrg \\\" -> \" 6344a4f78defSmrg \\\\\" -> \\" 6345a4f78defSmrg */ 6346a4f78defSmrg#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" 6347a4f78defSmrg#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" 6348a4f78defSmrgchar ** 6349a4f78defSmrgprepare_spawn (char **argv) 6350a4f78defSmrg{ 6351a4f78defSmrg size_t argc; 6352a4f78defSmrg char **new_argv; 6353a4f78defSmrg size_t i; 6354a4f78defSmrg 6355a4f78defSmrg /* Count number of arguments. */ 6356a4f78defSmrg for (argc = 0; argv[argc] != NULL; argc++) 6357a4f78defSmrg ; 6358a4f78defSmrg 6359a4f78defSmrg /* Allocate new argument vector. */ 6360a4f78defSmrg new_argv = XMALLOC (char *, argc + 1); 6361a4f78defSmrg 6362a4f78defSmrg /* Put quoted arguments into the new argument vector. */ 6363a4f78defSmrg for (i = 0; i < argc; i++) 6364a4f78defSmrg { 6365a4f78defSmrg const char *string = argv[i]; 6366a4f78defSmrg 6367a4f78defSmrg if (string[0] == '\0') 6368a4f78defSmrg new_argv[i] = xstrdup ("\"\""); 6369a4f78defSmrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6370a4f78defSmrg { 6371a4f78defSmrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6372a4f78defSmrg size_t length; 6373a4f78defSmrg unsigned int backslashes; 6374a4f78defSmrg const char *s; 6375a4f78defSmrg char *quoted_string; 6376a4f78defSmrg char *p; 6377a4f78defSmrg 6378a4f78defSmrg length = 0; 6379a4f78defSmrg backslashes = 0; 6380a4f78defSmrg if (quote_around) 6381a4f78defSmrg length++; 6382a4f78defSmrg for (s = string; *s != '\0'; s++) 6383a4f78defSmrg { 6384a4f78defSmrg char c = *s; 6385a4f78defSmrg if (c == '"') 6386a4f78defSmrg length += backslashes + 1; 6387a4f78defSmrg length++; 6388a4f78defSmrg if (c == '\\') 6389a4f78defSmrg backslashes++; 6390a4f78defSmrg else 6391a4f78defSmrg backslashes = 0; 6392a4f78defSmrg } 6393a4f78defSmrg if (quote_around) 6394a4f78defSmrg length += backslashes + 1; 6395a4f78defSmrg 6396a4f78defSmrg quoted_string = XMALLOC (char, length + 1); 6397a4f78defSmrg 6398a4f78defSmrg p = quoted_string; 6399a4f78defSmrg backslashes = 0; 6400a4f78defSmrg if (quote_around) 6401a4f78defSmrg *p++ = '"'; 6402a4f78defSmrg for (s = string; *s != '\0'; s++) 6403a4f78defSmrg { 6404a4f78defSmrg char c = *s; 6405a4f78defSmrg if (c == '"') 6406a4f78defSmrg { 6407a4f78defSmrg unsigned int j; 6408a4f78defSmrg for (j = backslashes + 1; j > 0; j--) 6409a4f78defSmrg *p++ = '\\'; 6410a4f78defSmrg } 6411a4f78defSmrg *p++ = c; 6412a4f78defSmrg if (c == '\\') 6413a4f78defSmrg backslashes++; 6414a4f78defSmrg else 6415a4f78defSmrg backslashes = 0; 6416a4f78defSmrg } 6417a4f78defSmrg if (quote_around) 6418a4f78defSmrg { 6419a4f78defSmrg unsigned int j; 6420a4f78defSmrg for (j = backslashes; j > 0; j--) 6421a4f78defSmrg *p++ = '\\'; 6422a4f78defSmrg *p++ = '"'; 6423a4f78defSmrg } 6424a4f78defSmrg *p = '\0'; 6425a4f78defSmrg 6426a4f78defSmrg new_argv[i] = quoted_string; 6427a4f78defSmrg } 6428a4f78defSmrg else 6429a4f78defSmrg new_argv[i] = (char *) string; 6430a4f78defSmrg } 6431a4f78defSmrg new_argv[argc] = NULL; 6432a4f78defSmrg 6433a4f78defSmrg return new_argv; 6434a4f78defSmrg} 6435a4f78defSmrgEOF 6436a4f78defSmrg ;; 6437a4f78defSmrg esac 6438a4f78defSmrg 6439a4f78defSmrg cat <<"EOF" 6440a4f78defSmrgvoid lt_dump_script (FILE* f) 6441a4f78defSmrg{ 6442a4f78defSmrgEOF 6443a4f78defSmrg func_emit_wrapper yes | 6444a4f78defSmrg $SED -n -e ' 6445a4f78defSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6446a4f78defSmrg\2/ 6447a4f78defSmrgh 6448a4f78defSmrgs/\([\\"]\)/\\\1/g 6449a4f78defSmrgs/$/\\n/ 6450a4f78defSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451a4f78defSmrgg 6452a4f78defSmrgD' 6453a4f78defSmrg cat <<"EOF" 6454a4f78defSmrg} 6455a4f78defSmrgEOF 6456a4f78defSmrg} 6457a4f78defSmrg# end: func_emit_cwrapperexe_src 6458a4f78defSmrg 6459a4f78defSmrg# func_win32_import_lib_p ARG 6460a4f78defSmrg# True if ARG is an import lib, as indicated by $file_magic_cmd 6461a4f78defSmrgfunc_win32_import_lib_p () 6462a4f78defSmrg{ 6463a4f78defSmrg $debug_cmd 6464a4f78defSmrg 6465a4f78defSmrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6466a4f78defSmrg *import*) : ;; 6467a4f78defSmrg *) false ;; 6468a4f78defSmrg esac 6469a4f78defSmrg} 6470a4f78defSmrg 6471a4f78defSmrg# func_suncc_cstd_abi 6472a4f78defSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473a4f78defSmrg# Several compiler flags select an ABI that is incompatible with the 6474a4f78defSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475a4f78defSmrgfunc_suncc_cstd_abi () 6476a4f78defSmrg{ 6477a4f78defSmrg $debug_cmd 6478a4f78defSmrg 6479a4f78defSmrg case " $compile_command " in 6480a4f78defSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481a4f78defSmrg suncc_use_cstd_abi=no 6482a4f78defSmrg ;; 6483a4f78defSmrg *) 6484a4f78defSmrg suncc_use_cstd_abi=yes 6485a4f78defSmrg ;; 6486a4f78defSmrg esac 6487a4f78defSmrg} 6488a4f78defSmrg 6489a4f78defSmrg# func_mode_link arg... 6490a4f78defSmrgfunc_mode_link () 6491a4f78defSmrg{ 6492a4f78defSmrg $debug_cmd 6493a4f78defSmrg 6494a4f78defSmrg case $host in 6495a4f78defSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6496a4f78defSmrg # It is impossible to link a dll without this setting, and 6497a4f78defSmrg # we shouldn't force the makefile maintainer to figure out 6498a4f78defSmrg # what system we are compiling for in order to pass an extra 6499a4f78defSmrg # flag for every libtool invocation. 6500a4f78defSmrg # allow_undefined=no 6501a4f78defSmrg 6502a4f78defSmrg # FIXME: Unfortunately, there are problems with the above when trying 6503a4f78defSmrg # to make a dll that has undefined symbols, in which case not 6504a4f78defSmrg # even a static library is built. For now, we need to specify 6505a4f78defSmrg # -no-undefined on the libtool link line when we can be certain 6506a4f78defSmrg # that all symbols are satisfied, otherwise we get a static library. 6507a4f78defSmrg allow_undefined=yes 6508a4f78defSmrg ;; 6509a4f78defSmrg *) 6510a4f78defSmrg allow_undefined=yes 6511a4f78defSmrg ;; 6512a4f78defSmrg esac 6513a4f78defSmrg libtool_args=$nonopt 6514a4f78defSmrg base_compile="$nonopt $@" 6515a4f78defSmrg compile_command=$nonopt 6516a4f78defSmrg finalize_command=$nonopt 6517a4f78defSmrg 6518a4f78defSmrg compile_rpath= 6519a4f78defSmrg finalize_rpath= 6520a4f78defSmrg compile_shlibpath= 6521a4f78defSmrg finalize_shlibpath= 6522a4f78defSmrg convenience= 6523a4f78defSmrg old_convenience= 6524a4f78defSmrg deplibs= 6525a4f78defSmrg old_deplibs= 6526a4f78defSmrg compiler_flags= 6527a4f78defSmrg linker_flags= 6528a4f78defSmrg dllsearchpath= 6529a4f78defSmrg lib_search_path=`pwd` 6530a4f78defSmrg inst_prefix_dir= 6531a4f78defSmrg new_inherited_linker_flags= 6532a4f78defSmrg 6533a4f78defSmrg avoid_version=no 6534a4f78defSmrg bindir= 6535a4f78defSmrg dlfiles= 6536a4f78defSmrg dlprefiles= 6537a4f78defSmrg dlself=no 6538a4f78defSmrg export_dynamic=no 6539a4f78defSmrg export_symbols= 6540a4f78defSmrg export_symbols_regex= 6541a4f78defSmrg generated= 6542a4f78defSmrg libobjs= 6543a4f78defSmrg ltlibs= 6544a4f78defSmrg module=no 6545a4f78defSmrg no_install=no 6546a4f78defSmrg objs= 6547a4f78defSmrg os2dllname= 6548a4f78defSmrg non_pic_objects= 6549a4f78defSmrg precious_files_regex= 6550a4f78defSmrg prefer_static_libs=no 6551a4f78defSmrg preload=false 6552a4f78defSmrg prev= 6553a4f78defSmrg prevarg= 6554a4f78defSmrg release= 6555a4f78defSmrg rpath= 6556a4f78defSmrg xrpath= 6557a4f78defSmrg perm_rpath= 6558a4f78defSmrg temp_rpath= 6559a4f78defSmrg thread_safe=no 6560a4f78defSmrg vinfo= 6561a4f78defSmrg vinfo_number=no 6562a4f78defSmrg weak_libs= 6563a4f78defSmrg single_module=$wl-single_module 6564a4f78defSmrg func_infer_tag $base_compile 6565a4f78defSmrg 6566a4f78defSmrg # We need to know -static, to get the right output filenames. 6567a4f78defSmrg for arg 6568a4f78defSmrg do 6569a4f78defSmrg case $arg in 6570a4f78defSmrg -shared) 6571a4f78defSmrg test yes != "$build_libtool_libs" \ 6572a4f78defSmrg && func_fatal_configuration "cannot build a shared library" 6573a4f78defSmrg build_old_libs=no 6574a4f78defSmrg break 6575a4f78defSmrg ;; 6576a4f78defSmrg -all-static | -static | -static-libtool-libs) 6577a4f78defSmrg case $arg in 6578a4f78defSmrg -all-static) 6579a4f78defSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6580a4f78defSmrg func_warning "complete static linking is impossible in this configuration" 6581a4f78defSmrg fi 6582a4f78defSmrg if test -n "$link_static_flag"; then 6583a4f78defSmrg dlopen_self=$dlopen_self_static 6584a4f78defSmrg fi 6585a4f78defSmrg prefer_static_libs=yes 6586a4f78defSmrg ;; 6587a4f78defSmrg -static) 6588a4f78defSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6589a4f78defSmrg dlopen_self=$dlopen_self_static 6590a4f78defSmrg fi 6591a4f78defSmrg prefer_static_libs=built 6592a4f78defSmrg ;; 6593a4f78defSmrg -static-libtool-libs) 6594a4f78defSmrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6595a4f78defSmrg dlopen_self=$dlopen_self_static 6596a4f78defSmrg fi 6597a4f78defSmrg prefer_static_libs=yes 6598a4f78defSmrg ;; 6599a4f78defSmrg esac 6600a4f78defSmrg build_libtool_libs=no 6601a4f78defSmrg build_old_libs=yes 6602a4f78defSmrg break 6603a4f78defSmrg ;; 6604a4f78defSmrg esac 6605a4f78defSmrg done 6606a4f78defSmrg 6607a4f78defSmrg # See if our shared archives depend on static archives. 6608a4f78defSmrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609a4f78defSmrg 6610a4f78defSmrg # Go through the arguments, transforming them on the way. 6611a4f78defSmrg while test "$#" -gt 0; do 6612a4f78defSmrg arg=$1 6613a4f78defSmrg shift 6614a4f78defSmrg func_quote_for_eval "$arg" 6615a4f78defSmrg qarg=$func_quote_for_eval_unquoted_result 6616a4f78defSmrg func_append libtool_args " $func_quote_for_eval_result" 6617a4f78defSmrg 6618a4f78defSmrg # If the previous option needs an argument, assign it. 6619a4f78defSmrg if test -n "$prev"; then 6620a4f78defSmrg case $prev in 6621a4f78defSmrg output) 6622a4f78defSmrg func_append compile_command " @OUTPUT@" 6623a4f78defSmrg func_append finalize_command " @OUTPUT@" 6624a4f78defSmrg ;; 6625a4f78defSmrg esac 6626a4f78defSmrg 6627a4f78defSmrg case $prev in 6628a4f78defSmrg bindir) 6629a4f78defSmrg bindir=$arg 6630a4f78defSmrg prev= 6631a4f78defSmrg continue 6632a4f78defSmrg ;; 6633a4f78defSmrg dlfiles|dlprefiles) 6634a4f78defSmrg $preload || { 6635a4f78defSmrg # Add the symbol object into the linking commands. 6636a4f78defSmrg func_append compile_command " @SYMFILE@" 6637a4f78defSmrg func_append finalize_command " @SYMFILE@" 6638a4f78defSmrg preload=: 6639a4f78defSmrg } 6640a4f78defSmrg case $arg in 6641a4f78defSmrg *.la | *.lo) ;; # We handle these cases below. 6642a4f78defSmrg force) 6643a4f78defSmrg if test no = "$dlself"; then 6644a4f78defSmrg dlself=needless 6645a4f78defSmrg export_dynamic=yes 6646a4f78defSmrg fi 6647a4f78defSmrg prev= 6648a4f78defSmrg continue 6649a4f78defSmrg ;; 6650a4f78defSmrg self) 6651a4f78defSmrg if test dlprefiles = "$prev"; then 6652a4f78defSmrg dlself=yes 6653a4f78defSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6654a4f78defSmrg dlself=yes 6655a4f78defSmrg else 6656a4f78defSmrg dlself=needless 6657a4f78defSmrg export_dynamic=yes 6658a4f78defSmrg fi 6659a4f78defSmrg prev= 6660a4f78defSmrg continue 6661a4f78defSmrg ;; 6662a4f78defSmrg *) 6663a4f78defSmrg if test dlfiles = "$prev"; then 6664a4f78defSmrg func_append dlfiles " $arg" 6665a4f78defSmrg else 6666a4f78defSmrg func_append dlprefiles " $arg" 6667a4f78defSmrg fi 6668a4f78defSmrg prev= 6669a4f78defSmrg continue 6670a4f78defSmrg ;; 6671a4f78defSmrg esac 6672a4f78defSmrg ;; 6673a4f78defSmrg expsyms) 6674a4f78defSmrg export_symbols=$arg 6675a4f78defSmrg test -f "$arg" \ 6676a4f78defSmrg || func_fatal_error "symbol file '$arg' does not exist" 6677a4f78defSmrg prev= 6678a4f78defSmrg continue 6679a4f78defSmrg ;; 6680a4f78defSmrg expsyms_regex) 6681a4f78defSmrg export_symbols_regex=$arg 6682a4f78defSmrg prev= 6683a4f78defSmrg continue 6684a4f78defSmrg ;; 6685a4f78defSmrg framework) 6686a4f78defSmrg case $host in 6687a4f78defSmrg *-*-darwin*) 6688a4f78defSmrg case "$deplibs " in 6689a4f78defSmrg *" $qarg.ltframework "*) ;; 6690a4f78defSmrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6691a4f78defSmrg ;; 6692a4f78defSmrg esac 6693a4f78defSmrg ;; 6694a4f78defSmrg esac 6695a4f78defSmrg prev= 6696a4f78defSmrg continue 6697a4f78defSmrg ;; 6698a4f78defSmrg inst_prefix) 6699a4f78defSmrg inst_prefix_dir=$arg 6700a4f78defSmrg prev= 6701a4f78defSmrg continue 6702a4f78defSmrg ;; 6703a4f78defSmrg mllvm) 6704a4f78defSmrg # Clang does not use LLVM to link, so we can simply discard any 6705a4f78defSmrg # '-mllvm $arg' options when doing the link step. 6706a4f78defSmrg prev= 6707a4f78defSmrg continue 6708a4f78defSmrg ;; 6709a4f78defSmrg objectlist) 6710a4f78defSmrg if test -f "$arg"; then 6711a4f78defSmrg save_arg=$arg 6712a4f78defSmrg moreargs= 6713a4f78defSmrg for fil in `cat "$save_arg"` 6714a4f78defSmrg do 6715a4f78defSmrg# func_append moreargs " $fil" 6716a4f78defSmrg arg=$fil 6717a4f78defSmrg # A libtool-controlled object. 6718a4f78defSmrg 6719a4f78defSmrg # Check to see that this really is a libtool object. 6720a4f78defSmrg if func_lalib_unsafe_p "$arg"; then 6721a4f78defSmrg pic_object= 6722a4f78defSmrg non_pic_object= 6723a4f78defSmrg 6724a4f78defSmrg # Read the .lo file 6725a4f78defSmrg func_source "$arg" 6726a4f78defSmrg 6727a4f78defSmrg if test -z "$pic_object" || 6728a4f78defSmrg test -z "$non_pic_object" || 6729a4f78defSmrg test none = "$pic_object" && 6730a4f78defSmrg test none = "$non_pic_object"; then 6731a4f78defSmrg func_fatal_error "cannot find name of object for '$arg'" 6732a4f78defSmrg fi 6733a4f78defSmrg 6734a4f78defSmrg # Extract subdirectory from the argument. 6735a4f78defSmrg func_dirname "$arg" "/" "" 6736a4f78defSmrg xdir=$func_dirname_result 6737a4f78defSmrg 6738a4f78defSmrg if test none != "$pic_object"; then 6739a4f78defSmrg # Prepend the subdirectory the object is found in. 6740a4f78defSmrg pic_object=$xdir$pic_object 6741a4f78defSmrg 6742a4f78defSmrg if test dlfiles = "$prev"; then 6743a4f78defSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744a4f78defSmrg func_append dlfiles " $pic_object" 6745a4f78defSmrg prev= 6746a4f78defSmrg continue 6747a4f78defSmrg else 6748a4f78defSmrg # If libtool objects are unsupported, then we need to preload. 6749a4f78defSmrg prev=dlprefiles 6750a4f78defSmrg fi 6751a4f78defSmrg fi 6752a4f78defSmrg 6753a4f78defSmrg # CHECK ME: I think I busted this. -Ossama 6754a4f78defSmrg if test dlprefiles = "$prev"; then 6755a4f78defSmrg # Preload the old-style object. 6756a4f78defSmrg func_append dlprefiles " $pic_object" 6757a4f78defSmrg prev= 6758a4f78defSmrg fi 6759a4f78defSmrg 6760a4f78defSmrg # A PIC object. 6761a4f78defSmrg func_append libobjs " $pic_object" 6762a4f78defSmrg arg=$pic_object 6763a4f78defSmrg fi 6764a4f78defSmrg 6765a4f78defSmrg # Non-PIC object. 6766a4f78defSmrg if test none != "$non_pic_object"; then 6767a4f78defSmrg # Prepend the subdirectory the object is found in. 6768a4f78defSmrg non_pic_object=$xdir$non_pic_object 6769a4f78defSmrg 6770a4f78defSmrg # A standard non-PIC object 6771a4f78defSmrg func_append non_pic_objects " $non_pic_object" 6772a4f78defSmrg if test -z "$pic_object" || test none = "$pic_object"; then 6773a4f78defSmrg arg=$non_pic_object 6774a4f78defSmrg fi 6775a4f78defSmrg else 6776a4f78defSmrg # If the PIC object exists, use it instead. 6777a4f78defSmrg # $xdir was prepended to $pic_object above. 6778a4f78defSmrg non_pic_object=$pic_object 6779a4f78defSmrg func_append non_pic_objects " $non_pic_object" 6780a4f78defSmrg fi 6781a4f78defSmrg else 6782a4f78defSmrg # Only an error if not doing a dry-run. 6783a4f78defSmrg if $opt_dry_run; then 6784a4f78defSmrg # Extract subdirectory from the argument. 6785a4f78defSmrg func_dirname "$arg" "/" "" 6786a4f78defSmrg xdir=$func_dirname_result 6787a4f78defSmrg 6788a4f78defSmrg func_lo2o "$arg" 6789a4f78defSmrg pic_object=$xdir$objdir/$func_lo2o_result 6790a4f78defSmrg non_pic_object=$xdir$func_lo2o_result 6791a4f78defSmrg func_append libobjs " $pic_object" 6792a4f78defSmrg func_append non_pic_objects " $non_pic_object" 6793a4f78defSmrg else 6794a4f78defSmrg func_fatal_error "'$arg' is not a valid libtool object" 6795a4f78defSmrg fi 6796a4f78defSmrg fi 6797a4f78defSmrg done 6798a4f78defSmrg else 6799a4f78defSmrg func_fatal_error "link input file '$arg' does not exist" 6800a4f78defSmrg fi 6801a4f78defSmrg arg=$save_arg 6802a4f78defSmrg prev= 6803a4f78defSmrg continue 6804a4f78defSmrg ;; 6805a4f78defSmrg os2dllname) 6806a4f78defSmrg os2dllname=$arg 6807a4f78defSmrg prev= 6808a4f78defSmrg continue 6809a4f78defSmrg ;; 6810a4f78defSmrg precious_regex) 6811a4f78defSmrg precious_files_regex=$arg 6812a4f78defSmrg prev= 6813a4f78defSmrg continue 6814a4f78defSmrg ;; 6815a4f78defSmrg release) 6816a4f78defSmrg release=-$arg 6817a4f78defSmrg prev= 6818a4f78defSmrg continue 6819a4f78defSmrg ;; 6820a4f78defSmrg rpath | xrpath) 6821a4f78defSmrg # We need an absolute path. 6822a4f78defSmrg case $arg in 6823a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6824a4f78defSmrg *) 6825a4f78defSmrg func_fatal_error "only absolute run-paths are allowed" 6826a4f78defSmrg ;; 6827a4f78defSmrg esac 6828a4f78defSmrg if test rpath = "$prev"; then 6829a4f78defSmrg case "$rpath " in 6830a4f78defSmrg *" $arg "*) ;; 6831a4f78defSmrg *) func_append rpath " $arg" ;; 6832a4f78defSmrg esac 6833a4f78defSmrg else 6834a4f78defSmrg case "$xrpath " in 6835a4f78defSmrg *" $arg "*) ;; 6836a4f78defSmrg *) func_append xrpath " $arg" ;; 6837a4f78defSmrg esac 6838a4f78defSmrg fi 6839a4f78defSmrg prev= 6840a4f78defSmrg continue 6841a4f78defSmrg ;; 6842a4f78defSmrg shrext) 6843a4f78defSmrg shrext_cmds=$arg 6844a4f78defSmrg prev= 6845a4f78defSmrg continue 6846a4f78defSmrg ;; 6847a4f78defSmrg weak) 6848a4f78defSmrg func_append weak_libs " $arg" 6849a4f78defSmrg prev= 6850a4f78defSmrg continue 6851a4f78defSmrg ;; 6852a4f78defSmrg xcclinker) 6853a4f78defSmrg func_append linker_flags " $qarg" 6854a4f78defSmrg func_append compiler_flags " $qarg" 6855a4f78defSmrg prev= 6856a4f78defSmrg func_append compile_command " $qarg" 6857a4f78defSmrg func_append finalize_command " $qarg" 6858a4f78defSmrg continue 6859a4f78defSmrg ;; 6860a4f78defSmrg xcompiler) 6861a4f78defSmrg func_append compiler_flags " $qarg" 6862a4f78defSmrg prev= 6863a4f78defSmrg func_append compile_command " $qarg" 6864a4f78defSmrg func_append finalize_command " $qarg" 6865a4f78defSmrg continue 6866a4f78defSmrg ;; 6867a4f78defSmrg xlinker) 6868a4f78defSmrg func_append linker_flags " $qarg" 6869a4f78defSmrg func_append compiler_flags " $wl$qarg" 6870a4f78defSmrg prev= 6871a4f78defSmrg func_append compile_command " $wl$qarg" 6872a4f78defSmrg func_append finalize_command " $wl$qarg" 6873a4f78defSmrg continue 6874a4f78defSmrg ;; 6875a4f78defSmrg *) 6876a4f78defSmrg eval "$prev=\"\$arg\"" 6877a4f78defSmrg prev= 6878a4f78defSmrg continue 6879a4f78defSmrg ;; 6880a4f78defSmrg esac 6881a4f78defSmrg fi # test -n "$prev" 6882a4f78defSmrg 6883a4f78defSmrg prevarg=$arg 6884a4f78defSmrg 6885a4f78defSmrg case $arg in 6886a4f78defSmrg -all-static) 6887a4f78defSmrg if test -n "$link_static_flag"; then 6888a4f78defSmrg # See comment for -static flag below, for more details. 6889a4f78defSmrg func_append compile_command " $link_static_flag" 6890a4f78defSmrg func_append finalize_command " $link_static_flag" 6891a4f78defSmrg fi 6892a4f78defSmrg continue 6893a4f78defSmrg ;; 6894a4f78defSmrg 6895a4f78defSmrg -allow-undefined) 6896a4f78defSmrg # FIXME: remove this flag sometime in the future. 6897a4f78defSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 6898a4f78defSmrg ;; 6899a4f78defSmrg 6900a4f78defSmrg -avoid-version) 6901a4f78defSmrg avoid_version=yes 6902a4f78defSmrg continue 6903a4f78defSmrg ;; 6904a4f78defSmrg 6905a4f78defSmrg -bindir) 6906a4f78defSmrg prev=bindir 6907a4f78defSmrg continue 6908a4f78defSmrg ;; 6909a4f78defSmrg 6910a4f78defSmrg -dlopen) 6911a4f78defSmrg prev=dlfiles 6912a4f78defSmrg continue 6913a4f78defSmrg ;; 6914a4f78defSmrg 6915a4f78defSmrg -dlpreopen) 6916a4f78defSmrg prev=dlprefiles 6917a4f78defSmrg continue 6918a4f78defSmrg ;; 6919a4f78defSmrg 6920a4f78defSmrg -export-dynamic) 6921a4f78defSmrg export_dynamic=yes 6922a4f78defSmrg continue 6923a4f78defSmrg ;; 6924a4f78defSmrg 6925a4f78defSmrg -export-symbols | -export-symbols-regex) 6926a4f78defSmrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 6927a4f78defSmrg func_fatal_error "more than one -exported-symbols argument is not allowed" 6928a4f78defSmrg fi 6929a4f78defSmrg if test X-export-symbols = "X$arg"; then 6930a4f78defSmrg prev=expsyms 6931a4f78defSmrg else 6932a4f78defSmrg prev=expsyms_regex 6933a4f78defSmrg fi 6934a4f78defSmrg continue 6935a4f78defSmrg ;; 6936a4f78defSmrg 6937a4f78defSmrg -framework) 6938a4f78defSmrg prev=framework 6939a4f78defSmrg continue 6940a4f78defSmrg ;; 6941a4f78defSmrg 6942a4f78defSmrg -inst-prefix-dir) 6943a4f78defSmrg prev=inst_prefix 6944a4f78defSmrg continue 6945a4f78defSmrg ;; 6946a4f78defSmrg 6947a4f78defSmrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 6948a4f78defSmrg # so, if we see these flags be careful not to treat them like -L 6949a4f78defSmrg -L[A-Z][A-Z]*:*) 6950a4f78defSmrg case $with_gcc/$host in 6951a4f78defSmrg no/*-*-irix* | /*-*-irix*) 6952a4f78defSmrg func_append compile_command " $arg" 6953a4f78defSmrg func_append finalize_command " $arg" 6954a4f78defSmrg ;; 6955a4f78defSmrg esac 6956a4f78defSmrg continue 6957a4f78defSmrg ;; 6958a4f78defSmrg 6959a4f78defSmrg -L*) 6960a4f78defSmrg func_stripname "-L" '' "$arg" 6961a4f78defSmrg if test -z "$func_stripname_result"; then 6962a4f78defSmrg if test "$#" -gt 0; then 6963a4f78defSmrg func_fatal_error "require no space between '-L' and '$1'" 6964a4f78defSmrg else 6965a4f78defSmrg func_fatal_error "need path for '-L' option" 6966a4f78defSmrg fi 6967a4f78defSmrg fi 6968a4f78defSmrg func_resolve_sysroot "$func_stripname_result" 6969a4f78defSmrg dir=$func_resolve_sysroot_result 6970a4f78defSmrg # We need an absolute path. 6971a4f78defSmrg case $dir in 6972a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 6973a4f78defSmrg *) 6974a4f78defSmrg absdir=`cd "$dir" && pwd` 6975a4f78defSmrg test -z "$absdir" && \ 6976a4f78defSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 6977a4f78defSmrg dir=$absdir 6978a4f78defSmrg ;; 6979a4f78defSmrg esac 6980a4f78defSmrg case "$deplibs " in 6981a4f78defSmrg *" -L$dir "* | *" $arg "*) 6982a4f78defSmrg # Will only happen for absolute or sysroot arguments 6983a4f78defSmrg ;; 6984a4f78defSmrg *) 6985a4f78defSmrg # Preserve sysroot, but never include relative directories 6986a4f78defSmrg case $dir in 6987a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988a4f78defSmrg *) func_append deplibs " -L$dir" ;; 6989a4f78defSmrg esac 6990a4f78defSmrg func_append lib_search_path " $dir" 6991a4f78defSmrg ;; 6992a4f78defSmrg esac 6993a4f78defSmrg case $host in 6994a4f78defSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6995a4f78defSmrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 6996a4f78defSmrg case :$dllsearchpath: in 6997a4f78defSmrg *":$dir:"*) ;; 6998a4f78defSmrg ::) dllsearchpath=$dir;; 6999a4f78defSmrg *) func_append dllsearchpath ":$dir";; 7000a4f78defSmrg esac 7001a4f78defSmrg case :$dllsearchpath: in 7002a4f78defSmrg *":$testbindir:"*) ;; 7003a4f78defSmrg ::) dllsearchpath=$testbindir;; 7004a4f78defSmrg *) func_append dllsearchpath ":$testbindir";; 7005a4f78defSmrg esac 7006a4f78defSmrg ;; 7007a4f78defSmrg esac 7008a4f78defSmrg continue 7009a4f78defSmrg ;; 7010a4f78defSmrg 7011a4f78defSmrg -l*) 7012a4f78defSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7013a4f78defSmrg case $host in 7014a4f78defSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7015a4f78defSmrg # These systems don't actually have a C or math library (as such) 7016a4f78defSmrg continue 7017a4f78defSmrg ;; 7018a4f78defSmrg *-*-os2*) 7019a4f78defSmrg # These systems don't actually have a C library (as such) 7020a4f78defSmrg test X-lc = "X$arg" && continue 7021a4f78defSmrg ;; 7022a4f78defSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7023a4f78defSmrg # Do not include libc due to us having libc/libc_r. 7024a4f78defSmrg test X-lc = "X$arg" && continue 7025a4f78defSmrg ;; 7026a4f78defSmrg *-*-rhapsody* | *-*-darwin1.[012]) 7027a4f78defSmrg # Rhapsody C and math libraries are in the System framework 7028a4f78defSmrg func_append deplibs " System.ltframework" 7029a4f78defSmrg continue 7030a4f78defSmrg ;; 7031a4f78defSmrg *-*-sco3.2v5* | *-*-sco5v6*) 7032a4f78defSmrg # Causes problems with __ctype 7033a4f78defSmrg test X-lc = "X$arg" && continue 7034a4f78defSmrg ;; 7035a4f78defSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7036a4f78defSmrg # Compiler inserts libc in the correct place for threads to work 7037a4f78defSmrg test X-lc = "X$arg" && continue 7038a4f78defSmrg ;; 7039a4f78defSmrg esac 7040a4f78defSmrg elif test X-lc_r = "X$arg"; then 7041a4f78defSmrg case $host in 7042a4f78defSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 7043a4f78defSmrg # Do not include libc_r directly, use -pthread flag. 7044a4f78defSmrg continue 7045a4f78defSmrg ;; 7046a4f78defSmrg esac 7047a4f78defSmrg fi 7048a4f78defSmrg func_append deplibs " $arg" 7049a4f78defSmrg continue 7050a4f78defSmrg ;; 7051a4f78defSmrg 7052a4f78defSmrg -mllvm) 7053a4f78defSmrg prev=mllvm 7054a4f78defSmrg continue 7055a4f78defSmrg ;; 7056a4f78defSmrg 7057a4f78defSmrg -module) 7058a4f78defSmrg module=yes 7059a4f78defSmrg continue 7060a4f78defSmrg ;; 7061a4f78defSmrg 7062a4f78defSmrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7063a4f78defSmrg # classes, name mangling, and exception handling. 7064a4f78defSmrg # Darwin uses the -arch flag to determine output architecture. 7065a4f78defSmrg -model|-arch|-isysroot|--sysroot) 7066a4f78defSmrg func_append compiler_flags " $arg" 7067a4f78defSmrg func_append compile_command " $arg" 7068a4f78defSmrg func_append finalize_command " $arg" 7069a4f78defSmrg prev=xcompiler 7070a4f78defSmrg continue 7071a4f78defSmrg ;; 7072a4f78defSmrg 7073a4f78defSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074a4f78defSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075a4f78defSmrg func_append compiler_flags " $arg" 7076a4f78defSmrg func_append compile_command " $arg" 7077a4f78defSmrg func_append finalize_command " $arg" 7078a4f78defSmrg case "$new_inherited_linker_flags " in 7079a4f78defSmrg *" $arg "*) ;; 7080a4f78defSmrg * ) func_append new_inherited_linker_flags " $arg" ;; 7081a4f78defSmrg esac 7082a4f78defSmrg continue 7083a4f78defSmrg ;; 7084a4f78defSmrg 7085a4f78defSmrg -multi_module) 7086a4f78defSmrg single_module=$wl-multi_module 7087a4f78defSmrg continue 7088a4f78defSmrg ;; 7089a4f78defSmrg 7090a4f78defSmrg -no-fast-install) 7091a4f78defSmrg fast_install=no 7092a4f78defSmrg continue 7093a4f78defSmrg ;; 7094a4f78defSmrg 7095a4f78defSmrg -no-install) 7096a4f78defSmrg case $host in 7097a4f78defSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7098a4f78defSmrg # The PATH hackery in wrapper scripts is required on Windows 7099a4f78defSmrg # and Darwin in order for the loader to find any dlls it needs. 7100a4f78defSmrg func_warning "'-no-install' is ignored for $host" 7101a4f78defSmrg func_warning "assuming '-no-fast-install' instead" 7102a4f78defSmrg fast_install=no 7103a4f78defSmrg ;; 7104a4f78defSmrg *) no_install=yes ;; 7105a4f78defSmrg esac 7106a4f78defSmrg continue 7107a4f78defSmrg ;; 7108a4f78defSmrg 7109a4f78defSmrg -no-undefined) 7110a4f78defSmrg allow_undefined=no 7111a4f78defSmrg continue 7112a4f78defSmrg ;; 7113a4f78defSmrg 7114a4f78defSmrg -objectlist) 7115a4f78defSmrg prev=objectlist 7116a4f78defSmrg continue 7117a4f78defSmrg ;; 7118a4f78defSmrg 7119a4f78defSmrg -os2dllname) 7120a4f78defSmrg prev=os2dllname 7121a4f78defSmrg continue 7122a4f78defSmrg ;; 7123a4f78defSmrg 7124a4f78defSmrg -o) prev=output ;; 7125a4f78defSmrg 7126a4f78defSmrg -precious-files-regex) 7127a4f78defSmrg prev=precious_regex 7128a4f78defSmrg continue 7129a4f78defSmrg ;; 7130a4f78defSmrg 7131a4f78defSmrg -release) 7132a4f78defSmrg prev=release 7133a4f78defSmrg continue 7134a4f78defSmrg ;; 7135a4f78defSmrg 7136a4f78defSmrg -rpath) 7137a4f78defSmrg prev=rpath 7138a4f78defSmrg continue 7139a4f78defSmrg ;; 7140a4f78defSmrg 7141a4f78defSmrg -R) 7142a4f78defSmrg prev=xrpath 7143a4f78defSmrg continue 7144a4f78defSmrg ;; 7145a4f78defSmrg 7146a4f78defSmrg -R*) 7147a4f78defSmrg func_stripname '-R' '' "$arg" 7148a4f78defSmrg dir=$func_stripname_result 7149a4f78defSmrg # We need an absolute path. 7150a4f78defSmrg case $dir in 7151a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7152a4f78defSmrg =*) 7153a4f78defSmrg func_stripname '=' '' "$dir" 7154a4f78defSmrg dir=$lt_sysroot$func_stripname_result 7155a4f78defSmrg ;; 7156a4f78defSmrg *) 7157a4f78defSmrg func_fatal_error "only absolute run-paths are allowed" 7158a4f78defSmrg ;; 7159a4f78defSmrg esac 7160a4f78defSmrg case "$xrpath " in 7161a4f78defSmrg *" $dir "*) ;; 7162a4f78defSmrg *) func_append xrpath " $dir" ;; 7163a4f78defSmrg esac 7164a4f78defSmrg continue 7165a4f78defSmrg ;; 7166a4f78defSmrg 7167a4f78defSmrg -shared) 7168a4f78defSmrg # The effects of -shared are defined in a previous loop. 7169a4f78defSmrg continue 7170a4f78defSmrg ;; 7171a4f78defSmrg 7172a4f78defSmrg -shrext) 7173a4f78defSmrg prev=shrext 7174a4f78defSmrg continue 7175a4f78defSmrg ;; 7176a4f78defSmrg 7177a4f78defSmrg -static | -static-libtool-libs) 7178a4f78defSmrg # The effects of -static are defined in a previous loop. 7179a4f78defSmrg # We used to do the same as -all-static on platforms that 7180a4f78defSmrg # didn't have a PIC flag, but the assumption that the effects 7181a4f78defSmrg # would be equivalent was wrong. It would break on at least 7182a4f78defSmrg # Digital Unix and AIX. 7183a4f78defSmrg continue 7184a4f78defSmrg ;; 7185a4f78defSmrg 7186a4f78defSmrg -thread-safe) 7187a4f78defSmrg thread_safe=yes 7188a4f78defSmrg continue 7189a4f78defSmrg ;; 7190a4f78defSmrg 7191a4f78defSmrg -version-info) 7192a4f78defSmrg prev=vinfo 7193a4f78defSmrg continue 7194a4f78defSmrg ;; 7195a4f78defSmrg 7196a4f78defSmrg -version-number) 7197a4f78defSmrg prev=vinfo 7198a4f78defSmrg vinfo_number=yes 7199a4f78defSmrg continue 7200a4f78defSmrg ;; 7201a4f78defSmrg 7202a4f78defSmrg -weak) 7203a4f78defSmrg prev=weak 7204a4f78defSmrg continue 7205a4f78defSmrg ;; 7206a4f78defSmrg 7207a4f78defSmrg -Wc,*) 7208a4f78defSmrg func_stripname '-Wc,' '' "$arg" 7209a4f78defSmrg args=$func_stripname_result 7210a4f78defSmrg arg= 7211a4f78defSmrg save_ifs=$IFS; IFS=, 7212a4f78defSmrg for flag in $args; do 7213a4f78defSmrg IFS=$save_ifs 7214a4f78defSmrg func_quote_for_eval "$flag" 7215a4f78defSmrg func_append arg " $func_quote_for_eval_result" 7216a4f78defSmrg func_append compiler_flags " $func_quote_for_eval_result" 7217a4f78defSmrg done 7218a4f78defSmrg IFS=$save_ifs 7219a4f78defSmrg func_stripname ' ' '' "$arg" 7220a4f78defSmrg arg=$func_stripname_result 7221a4f78defSmrg ;; 7222a4f78defSmrg 7223a4f78defSmrg -Wl,*) 7224a4f78defSmrg func_stripname '-Wl,' '' "$arg" 7225a4f78defSmrg args=$func_stripname_result 7226a4f78defSmrg arg= 7227a4f78defSmrg save_ifs=$IFS; IFS=, 7228a4f78defSmrg for flag in $args; do 7229a4f78defSmrg IFS=$save_ifs 7230a4f78defSmrg func_quote_for_eval "$flag" 7231a4f78defSmrg func_append arg " $wl$func_quote_for_eval_result" 7232a4f78defSmrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7233a4f78defSmrg func_append linker_flags " $func_quote_for_eval_result" 7234a4f78defSmrg done 7235a4f78defSmrg IFS=$save_ifs 7236a4f78defSmrg func_stripname ' ' '' "$arg" 7237a4f78defSmrg arg=$func_stripname_result 7238a4f78defSmrg ;; 7239a4f78defSmrg 7240a4f78defSmrg -Xcompiler) 7241a4f78defSmrg prev=xcompiler 7242a4f78defSmrg continue 7243a4f78defSmrg ;; 7244a4f78defSmrg 7245a4f78defSmrg -Xlinker) 7246a4f78defSmrg prev=xlinker 7247a4f78defSmrg continue 7248a4f78defSmrg ;; 7249a4f78defSmrg 7250a4f78defSmrg -XCClinker) 7251a4f78defSmrg prev=xcclinker 7252a4f78defSmrg continue 7253a4f78defSmrg ;; 7254a4f78defSmrg 7255a4f78defSmrg # -msg_* for osf cc 7256a4f78defSmrg -msg_*) 7257a4f78defSmrg func_quote_for_eval "$arg" 7258a4f78defSmrg arg=$func_quote_for_eval_result 7259a4f78defSmrg ;; 7260a4f78defSmrg 7261a4f78defSmrg # Flags to be passed through unchanged, with rationale: 7262a4f78defSmrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7263a4f78defSmrg # -r[0-9][0-9]* specify processor for the SGI compiler 7264a4f78defSmrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7265a4f78defSmrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7266a4f78defSmrg # -q* compiler args for the IBM compiler 7267a4f78defSmrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7268a4f78defSmrg # -F/path path to uninstalled frameworks, gcc on darwin 7269a4f78defSmrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270a4f78defSmrg # -fstack-protector* stack protector flags for GCC 7271a4f78defSmrg # @file GCC response files 7272a4f78defSmrg # -tp=* Portland pgcc target processor selection 7273a4f78defSmrg # --sysroot=* for sysroot support 7274a4f78defSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275a4f78defSmrg # -stdlib=* select c++ std lib with clang 7276a4f78defSmrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7277a4f78defSmrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7278a4f78defSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) 7279a4f78defSmrg func_quote_for_eval "$arg" 7280a4f78defSmrg arg=$func_quote_for_eval_result 7281a4f78defSmrg func_append compile_command " $arg" 7282a4f78defSmrg func_append finalize_command " $arg" 7283a4f78defSmrg func_append compiler_flags " $arg" 7284a4f78defSmrg continue 7285a4f78defSmrg ;; 7286a4f78defSmrg 7287a4f78defSmrg -Z*) 7288a4f78defSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7289a4f78defSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 7290a4f78defSmrg compiler_flags="$compiler_flags $arg" 7291a4f78defSmrg func_append compile_command " $arg" 7292a4f78defSmrg func_append finalize_command " $arg" 7293a4f78defSmrg case $arg in 7294a4f78defSmrg -Zlinker | -Zstack) 7295a4f78defSmrg prev=xcompiler 7296a4f78defSmrg ;; 7297a4f78defSmrg esac 7298a4f78defSmrg continue 7299a4f78defSmrg else 7300a4f78defSmrg # Otherwise treat like 'Some other compiler flag' below 7301a4f78defSmrg func_quote_for_eval "$arg" 7302a4f78defSmrg arg=$func_quote_for_eval_result 7303a4f78defSmrg fi 7304a4f78defSmrg ;; 7305a4f78defSmrg 7306a4f78defSmrg # Some other compiler flag. 7307a4f78defSmrg -* | +*) 7308a4f78defSmrg func_quote_for_eval "$arg" 7309a4f78defSmrg arg=$func_quote_for_eval_result 7310a4f78defSmrg ;; 7311a4f78defSmrg 7312a4f78defSmrg *.$objext) 7313a4f78defSmrg # A standard object. 7314a4f78defSmrg func_append objs " $arg" 7315a4f78defSmrg ;; 7316a4f78defSmrg 7317a4f78defSmrg *.lo) 7318a4f78defSmrg # A libtool-controlled object. 7319a4f78defSmrg 7320a4f78defSmrg # Check to see that this really is a libtool object. 7321a4f78defSmrg if func_lalib_unsafe_p "$arg"; then 7322a4f78defSmrg pic_object= 7323a4f78defSmrg non_pic_object= 7324a4f78defSmrg 7325a4f78defSmrg # Read the .lo file 7326a4f78defSmrg func_source "$arg" 7327a4f78defSmrg 7328a4f78defSmrg if test -z "$pic_object" || 7329a4f78defSmrg test -z "$non_pic_object" || 7330a4f78defSmrg test none = "$pic_object" && 7331a4f78defSmrg test none = "$non_pic_object"; then 7332a4f78defSmrg func_fatal_error "cannot find name of object for '$arg'" 7333a4f78defSmrg fi 7334a4f78defSmrg 7335a4f78defSmrg # Extract subdirectory from the argument. 7336a4f78defSmrg func_dirname "$arg" "/" "" 7337a4f78defSmrg xdir=$func_dirname_result 7338a4f78defSmrg 7339a4f78defSmrg test none = "$pic_object" || { 7340a4f78defSmrg # Prepend the subdirectory the object is found in. 7341a4f78defSmrg pic_object=$xdir$pic_object 7342a4f78defSmrg 7343a4f78defSmrg if test dlfiles = "$prev"; then 7344a4f78defSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7345a4f78defSmrg func_append dlfiles " $pic_object" 7346a4f78defSmrg prev= 7347a4f78defSmrg continue 7348a4f78defSmrg else 7349a4f78defSmrg # If libtool objects are unsupported, then we need to preload. 7350a4f78defSmrg prev=dlprefiles 7351a4f78defSmrg fi 7352a4f78defSmrg fi 7353a4f78defSmrg 7354a4f78defSmrg # CHECK ME: I think I busted this. -Ossama 7355a4f78defSmrg if test dlprefiles = "$prev"; then 7356a4f78defSmrg # Preload the old-style object. 7357a4f78defSmrg func_append dlprefiles " $pic_object" 7358a4f78defSmrg prev= 7359a4f78defSmrg fi 7360a4f78defSmrg 7361a4f78defSmrg # A PIC object. 7362a4f78defSmrg func_append libobjs " $pic_object" 7363a4f78defSmrg arg=$pic_object 7364a4f78defSmrg } 7365a4f78defSmrg 7366a4f78defSmrg # Non-PIC object. 7367a4f78defSmrg if test none != "$non_pic_object"; then 7368a4f78defSmrg # Prepend the subdirectory the object is found in. 7369a4f78defSmrg non_pic_object=$xdir$non_pic_object 7370a4f78defSmrg 7371a4f78defSmrg # A standard non-PIC object 7372a4f78defSmrg func_append non_pic_objects " $non_pic_object" 7373a4f78defSmrg if test -z "$pic_object" || test none = "$pic_object"; then 7374a4f78defSmrg arg=$non_pic_object 7375a4f78defSmrg fi 7376a4f78defSmrg else 7377a4f78defSmrg # If the PIC object exists, use it instead. 7378a4f78defSmrg # $xdir was prepended to $pic_object above. 7379a4f78defSmrg non_pic_object=$pic_object 7380a4f78defSmrg func_append non_pic_objects " $non_pic_object" 7381a4f78defSmrg fi 7382a4f78defSmrg else 7383a4f78defSmrg # Only an error if not doing a dry-run. 7384a4f78defSmrg if $opt_dry_run; then 7385a4f78defSmrg # Extract subdirectory from the argument. 7386a4f78defSmrg func_dirname "$arg" "/" "" 7387a4f78defSmrg xdir=$func_dirname_result 7388a4f78defSmrg 7389a4f78defSmrg func_lo2o "$arg" 7390a4f78defSmrg pic_object=$xdir$objdir/$func_lo2o_result 7391a4f78defSmrg non_pic_object=$xdir$func_lo2o_result 7392a4f78defSmrg func_append libobjs " $pic_object" 7393a4f78defSmrg func_append non_pic_objects " $non_pic_object" 7394a4f78defSmrg else 7395a4f78defSmrg func_fatal_error "'$arg' is not a valid libtool object" 7396a4f78defSmrg fi 7397a4f78defSmrg fi 7398a4f78defSmrg ;; 7399a4f78defSmrg 7400a4f78defSmrg *.$libext) 7401a4f78defSmrg # An archive. 7402a4f78defSmrg func_append deplibs " $arg" 7403a4f78defSmrg func_append old_deplibs " $arg" 7404a4f78defSmrg continue 7405a4f78defSmrg ;; 7406a4f78defSmrg 7407a4f78defSmrg *.la) 7408a4f78defSmrg # A libtool-controlled library. 7409a4f78defSmrg 7410a4f78defSmrg func_resolve_sysroot "$arg" 7411a4f78defSmrg if test dlfiles = "$prev"; then 7412a4f78defSmrg # This library was specified with -dlopen. 7413a4f78defSmrg func_append dlfiles " $func_resolve_sysroot_result" 7414a4f78defSmrg prev= 7415a4f78defSmrg elif test dlprefiles = "$prev"; then 7416a4f78defSmrg # The library was specified with -dlpreopen. 7417a4f78defSmrg func_append dlprefiles " $func_resolve_sysroot_result" 7418a4f78defSmrg prev= 7419a4f78defSmrg else 7420a4f78defSmrg func_append deplibs " $func_resolve_sysroot_result" 7421a4f78defSmrg fi 7422a4f78defSmrg continue 7423a4f78defSmrg ;; 7424a4f78defSmrg 7425a4f78defSmrg # Some other compiler argument. 7426a4f78defSmrg *) 7427a4f78defSmrg # Unknown arguments in both finalize_command and compile_command need 7428a4f78defSmrg # to be aesthetically quoted because they are evaled later. 7429a4f78defSmrg func_quote_for_eval "$arg" 7430a4f78defSmrg arg=$func_quote_for_eval_result 7431a4f78defSmrg ;; 7432a4f78defSmrg esac # arg 7433a4f78defSmrg 7434a4f78defSmrg # Now actually substitute the argument into the commands. 7435a4f78defSmrg if test -n "$arg"; then 7436a4f78defSmrg func_append compile_command " $arg" 7437a4f78defSmrg func_append finalize_command " $arg" 7438a4f78defSmrg fi 7439a4f78defSmrg done # argument parsing loop 7440a4f78defSmrg 7441a4f78defSmrg test -n "$prev" && \ 7442a4f78defSmrg func_fatal_help "the '$prevarg' option requires an argument" 7443a4f78defSmrg 7444a4f78defSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7445a4f78defSmrg eval arg=\"$export_dynamic_flag_spec\" 7446a4f78defSmrg func_append compile_command " $arg" 7447a4f78defSmrg func_append finalize_command " $arg" 7448a4f78defSmrg fi 7449a4f78defSmrg 7450a4f78defSmrg oldlibs= 7451a4f78defSmrg # calculate the name of the file, without its directory 7452a4f78defSmrg func_basename "$output" 7453a4f78defSmrg outputname=$func_basename_result 7454a4f78defSmrg libobjs_save=$libobjs 7455a4f78defSmrg 7456a4f78defSmrg if test -n "$shlibpath_var"; then 7457a4f78defSmrg # get the directories listed in $shlibpath_var 7458a4f78defSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7459a4f78defSmrg else 7460a4f78defSmrg shlib_search_path= 7461a4f78defSmrg fi 7462a4f78defSmrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7463a4f78defSmrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7464a4f78defSmrg 7465a4f78defSmrg # Definition is injected by LT_CONFIG during libtool generation. 7466a4f78defSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7467a4f78defSmrg 7468a4f78defSmrg func_dirname "$output" "/" "" 7469a4f78defSmrg output_objdir=$func_dirname_result$objdir 7470a4f78defSmrg func_to_tool_file "$output_objdir/" 7471a4f78defSmrg tool_output_objdir=$func_to_tool_file_result 7472a4f78defSmrg # Create the object directory. 7473a4f78defSmrg func_mkdir_p "$output_objdir" 7474a4f78defSmrg 7475a4f78defSmrg # Determine the type of output 7476a4f78defSmrg case $output in 7477a4f78defSmrg "") 7478a4f78defSmrg func_fatal_help "you must specify an output file" 7479a4f78defSmrg ;; 7480a4f78defSmrg *.$libext) linkmode=oldlib ;; 7481a4f78defSmrg *.lo | *.$objext) linkmode=obj ;; 7482a4f78defSmrg *.la) linkmode=lib ;; 7483a4f78defSmrg *) linkmode=prog ;; # Anything else should be a program. 7484a4f78defSmrg esac 7485a4f78defSmrg 7486a4f78defSmrg specialdeplibs= 7487a4f78defSmrg 7488a4f78defSmrg libs= 7489a4f78defSmrg # Find all interdependent deplibs by searching for libraries 7490a4f78defSmrg # that are linked more than once (e.g. -la -lb -la) 7491a4f78defSmrg for deplib in $deplibs; do 7492a4f78defSmrg if $opt_preserve_dup_deps; then 7493a4f78defSmrg case "$libs " in 7494a4f78defSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7495a4f78defSmrg esac 7496a4f78defSmrg fi 7497a4f78defSmrg func_append libs " $deplib" 7498a4f78defSmrg done 7499a4f78defSmrg 7500a4f78defSmrg if test lib = "$linkmode"; then 7501a4f78defSmrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7502a4f78defSmrg 7503a4f78defSmrg # Compute libraries that are listed more than once in $predeps 7504a4f78defSmrg # $postdeps and mark them as special (i.e., whose duplicates are 7505a4f78defSmrg # not to be eliminated). 7506a4f78defSmrg pre_post_deps= 7507a4f78defSmrg if $opt_duplicate_compiler_generated_deps; then 7508a4f78defSmrg for pre_post_dep in $predeps $postdeps; do 7509a4f78defSmrg case "$pre_post_deps " in 7510a4f78defSmrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7511a4f78defSmrg esac 7512a4f78defSmrg func_append pre_post_deps " $pre_post_dep" 7513a4f78defSmrg done 7514a4f78defSmrg fi 7515a4f78defSmrg pre_post_deps= 7516a4f78defSmrg fi 7517a4f78defSmrg 7518a4f78defSmrg deplibs= 7519a4f78defSmrg newdependency_libs= 7520a4f78defSmrg newlib_search_path= 7521a4f78defSmrg need_relink=no # whether we're linking any uninstalled libtool libraries 7522a4f78defSmrg notinst_deplibs= # not-installed libtool libraries 7523a4f78defSmrg notinst_path= # paths that contain not-installed libtool libraries 7524a4f78defSmrg 7525a4f78defSmrg case $linkmode in 7526a4f78defSmrg lib) 7527a4f78defSmrg passes="conv dlpreopen link" 7528a4f78defSmrg for file in $dlfiles $dlprefiles; do 7529a4f78defSmrg case $file in 7530a4f78defSmrg *.la) ;; 7531a4f78defSmrg *) 7532a4f78defSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7533a4f78defSmrg ;; 7534a4f78defSmrg esac 7535a4f78defSmrg done 7536a4f78defSmrg ;; 7537a4f78defSmrg prog) 7538a4f78defSmrg compile_deplibs= 7539a4f78defSmrg finalize_deplibs= 7540a4f78defSmrg alldeplibs=false 7541a4f78defSmrg newdlfiles= 7542a4f78defSmrg newdlprefiles= 7543a4f78defSmrg passes="conv scan dlopen dlpreopen link" 7544a4f78defSmrg ;; 7545a4f78defSmrg *) passes="conv" 7546a4f78defSmrg ;; 7547a4f78defSmrg esac 7548a4f78defSmrg 7549a4f78defSmrg for pass in $passes; do 7550a4f78defSmrg # The preopen pass in lib mode reverses $deplibs; put it back here 7551a4f78defSmrg # so that -L comes before libs that need it for instance... 7552a4f78defSmrg if test lib,link = "$linkmode,$pass"; then 7553a4f78defSmrg ## FIXME: Find the place where the list is rebuilt in the wrong 7554a4f78defSmrg ## order, and fix it there properly 7555a4f78defSmrg tmp_deplibs= 7556a4f78defSmrg for deplib in $deplibs; do 7557a4f78defSmrg tmp_deplibs="$deplib $tmp_deplibs" 7558a4f78defSmrg done 7559a4f78defSmrg deplibs=$tmp_deplibs 7560a4f78defSmrg fi 7561a4f78defSmrg 7562a4f78defSmrg if test lib,link = "$linkmode,$pass" || 7563a4f78defSmrg test prog,scan = "$linkmode,$pass"; then 7564a4f78defSmrg libs=$deplibs 7565a4f78defSmrg deplibs= 7566a4f78defSmrg fi 7567a4f78defSmrg if test prog = "$linkmode"; then 7568a4f78defSmrg case $pass in 7569a4f78defSmrg dlopen) libs=$dlfiles ;; 7570a4f78defSmrg dlpreopen) libs=$dlprefiles ;; 7571a4f78defSmrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7572a4f78defSmrg esac 7573a4f78defSmrg fi 7574a4f78defSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 7575a4f78defSmrg # Collect and forward deplibs of preopened libtool libs 7576a4f78defSmrg for lib in $dlprefiles; do 7577a4f78defSmrg # Ignore non-libtool-libs 7578a4f78defSmrg dependency_libs= 7579a4f78defSmrg func_resolve_sysroot "$lib" 7580a4f78defSmrg case $lib in 7581a4f78defSmrg *.la) func_source "$func_resolve_sysroot_result" ;; 7582a4f78defSmrg esac 7583a4f78defSmrg 7584a4f78defSmrg # Collect preopened libtool deplibs, except any this library 7585a4f78defSmrg # has declared as weak libs 7586a4f78defSmrg for deplib in $dependency_libs; do 7587a4f78defSmrg func_basename "$deplib" 7588a4f78defSmrg deplib_base=$func_basename_result 7589a4f78defSmrg case " $weak_libs " in 7590a4f78defSmrg *" $deplib_base "*) ;; 7591a4f78defSmrg *) func_append deplibs " $deplib" ;; 7592a4f78defSmrg esac 7593a4f78defSmrg done 7594a4f78defSmrg done 7595a4f78defSmrg libs=$dlprefiles 7596a4f78defSmrg fi 7597a4f78defSmrg if test dlopen = "$pass"; then 7598a4f78defSmrg # Collect dlpreopened libraries 7599a4f78defSmrg save_deplibs=$deplibs 7600a4f78defSmrg deplibs= 7601a4f78defSmrg fi 7602a4f78defSmrg 7603a4f78defSmrg for deplib in $libs; do 7604a4f78defSmrg lib= 7605a4f78defSmrg found=false 7606a4f78defSmrg case $deplib in 7607a4f78defSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7608a4f78defSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7609a4f78defSmrg if test prog,link = "$linkmode,$pass"; then 7610a4f78defSmrg compile_deplibs="$deplib $compile_deplibs" 7611a4f78defSmrg finalize_deplibs="$deplib $finalize_deplibs" 7612a4f78defSmrg else 7613a4f78defSmrg func_append compiler_flags " $deplib" 7614a4f78defSmrg if test lib = "$linkmode"; then 7615a4f78defSmrg case "$new_inherited_linker_flags " in 7616a4f78defSmrg *" $deplib "*) ;; 7617a4f78defSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7618a4f78defSmrg esac 7619a4f78defSmrg fi 7620a4f78defSmrg fi 7621a4f78defSmrg continue 7622a4f78defSmrg ;; 7623a4f78defSmrg -l*) 7624a4f78defSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7625a4f78defSmrg func_warning "'-l' is ignored for archives/objects" 7626a4f78defSmrg continue 7627a4f78defSmrg fi 7628a4f78defSmrg func_stripname '-l' '' "$deplib" 7629a4f78defSmrg name=$func_stripname_result 7630a4f78defSmrg if test lib = "$linkmode"; then 7631a4f78defSmrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7632a4f78defSmrg else 7633a4f78defSmrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7634a4f78defSmrg fi 7635a4f78defSmrg for searchdir in $searchdirs; do 7636a4f78defSmrg for search_ext in .la $std_shrext .so .a; do 7637a4f78defSmrg # Search the libtool library 7638a4f78defSmrg lib=$searchdir/lib$name$search_ext 7639a4f78defSmrg if test -f "$lib"; then 7640a4f78defSmrg if test .la = "$search_ext"; then 7641a4f78defSmrg found=: 7642a4f78defSmrg else 7643a4f78defSmrg found=false 7644a4f78defSmrg fi 7645a4f78defSmrg break 2 7646a4f78defSmrg fi 7647a4f78defSmrg done 7648a4f78defSmrg done 7649a4f78defSmrg if $found; then 7650a4f78defSmrg # deplib is a libtool library 7651a4f78defSmrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7652a4f78defSmrg # We need to do some special things here, and not later. 7653a4f78defSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7654a4f78defSmrg case " $predeps $postdeps " in 7655a4f78defSmrg *" $deplib "*) 7656a4f78defSmrg if func_lalib_p "$lib"; then 7657a4f78defSmrg library_names= 7658a4f78defSmrg old_library= 7659a4f78defSmrg func_source "$lib" 7660a4f78defSmrg for l in $old_library $library_names; do 7661a4f78defSmrg ll=$l 7662a4f78defSmrg done 7663a4f78defSmrg if test "X$ll" = "X$old_library"; then # only static version available 7664a4f78defSmrg found=false 7665a4f78defSmrg func_dirname "$lib" "" "." 7666a4f78defSmrg ladir=$func_dirname_result 7667a4f78defSmrg lib=$ladir/$old_library 7668a4f78defSmrg if test prog,link = "$linkmode,$pass"; then 7669a4f78defSmrg compile_deplibs="$deplib $compile_deplibs" 7670a4f78defSmrg finalize_deplibs="$deplib $finalize_deplibs" 7671a4f78defSmrg else 7672a4f78defSmrg deplibs="$deplib $deplibs" 7673a4f78defSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7674a4f78defSmrg fi 7675a4f78defSmrg continue 7676a4f78defSmrg fi 7677a4f78defSmrg fi 7678a4f78defSmrg ;; 7679a4f78defSmrg *) ;; 7680a4f78defSmrg esac 7681a4f78defSmrg fi 7682a4f78defSmrg else 7683a4f78defSmrg # deplib doesn't seem to be a libtool library 7684a4f78defSmrg if test prog,link = "$linkmode,$pass"; then 7685a4f78defSmrg compile_deplibs="$deplib $compile_deplibs" 7686a4f78defSmrg finalize_deplibs="$deplib $finalize_deplibs" 7687a4f78defSmrg else 7688a4f78defSmrg deplibs="$deplib $deplibs" 7689a4f78defSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7690a4f78defSmrg fi 7691a4f78defSmrg continue 7692a4f78defSmrg fi 7693a4f78defSmrg ;; # -l 7694a4f78defSmrg *.ltframework) 7695a4f78defSmrg if test prog,link = "$linkmode,$pass"; then 7696a4f78defSmrg compile_deplibs="$deplib $compile_deplibs" 7697a4f78defSmrg finalize_deplibs="$deplib $finalize_deplibs" 7698a4f78defSmrg else 7699a4f78defSmrg deplibs="$deplib $deplibs" 7700a4f78defSmrg if test lib = "$linkmode"; then 7701a4f78defSmrg case "$new_inherited_linker_flags " in 7702a4f78defSmrg *" $deplib "*) ;; 7703a4f78defSmrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7704a4f78defSmrg esac 7705a4f78defSmrg fi 7706a4f78defSmrg fi 7707a4f78defSmrg continue 7708a4f78defSmrg ;; 7709a4f78defSmrg -L*) 7710a4f78defSmrg case $linkmode in 7711a4f78defSmrg lib) 7712a4f78defSmrg deplibs="$deplib $deplibs" 7713a4f78defSmrg test conv = "$pass" && continue 7714a4f78defSmrg newdependency_libs="$deplib $newdependency_libs" 7715a4f78defSmrg func_stripname '-L' '' "$deplib" 7716a4f78defSmrg func_resolve_sysroot "$func_stripname_result" 7717a4f78defSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7718a4f78defSmrg ;; 7719a4f78defSmrg prog) 7720a4f78defSmrg if test conv = "$pass"; then 7721a4f78defSmrg deplibs="$deplib $deplibs" 7722a4f78defSmrg continue 7723a4f78defSmrg fi 7724a4f78defSmrg if test scan = "$pass"; then 7725a4f78defSmrg deplibs="$deplib $deplibs" 7726a4f78defSmrg else 7727a4f78defSmrg compile_deplibs="$deplib $compile_deplibs" 7728a4f78defSmrg finalize_deplibs="$deplib $finalize_deplibs" 7729a4f78defSmrg fi 7730a4f78defSmrg func_stripname '-L' '' "$deplib" 7731a4f78defSmrg func_resolve_sysroot "$func_stripname_result" 7732a4f78defSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 7733a4f78defSmrg ;; 7734a4f78defSmrg *) 7735a4f78defSmrg func_warning "'-L' is ignored for archives/objects" 7736a4f78defSmrg ;; 7737a4f78defSmrg esac # linkmode 7738a4f78defSmrg continue 7739a4f78defSmrg ;; # -L 7740a4f78defSmrg -R*) 7741a4f78defSmrg if test link = "$pass"; then 7742a4f78defSmrg func_stripname '-R' '' "$deplib" 7743a4f78defSmrg func_resolve_sysroot "$func_stripname_result" 7744a4f78defSmrg dir=$func_resolve_sysroot_result 7745a4f78defSmrg # Make sure the xrpath contains only unique directories. 7746a4f78defSmrg case "$xrpath " in 7747a4f78defSmrg *" $dir "*) ;; 7748a4f78defSmrg *) func_append xrpath " $dir" ;; 7749a4f78defSmrg esac 7750a4f78defSmrg fi 7751a4f78defSmrg deplibs="$deplib $deplibs" 7752a4f78defSmrg continue 7753a4f78defSmrg ;; 7754a4f78defSmrg *.la) 7755a4f78defSmrg func_resolve_sysroot "$deplib" 7756a4f78defSmrg lib=$func_resolve_sysroot_result 7757a4f78defSmrg ;; 7758a4f78defSmrg *.$libext) 7759a4f78defSmrg if test conv = "$pass"; then 7760a4f78defSmrg deplibs="$deplib $deplibs" 7761a4f78defSmrg continue 7762a4f78defSmrg fi 7763a4f78defSmrg case $linkmode in 7764a4f78defSmrg lib) 7765a4f78defSmrg # Linking convenience modules into shared libraries is allowed, 7766a4f78defSmrg # but linking other static libraries is non-portable. 7767a4f78defSmrg case " $dlpreconveniencelibs " in 7768a4f78defSmrg *" $deplib "*) ;; 7769a4f78defSmrg *) 7770a4f78defSmrg valid_a_lib=false 7771a4f78defSmrg case $deplibs_check_method in 7772a4f78defSmrg match_pattern*) 7773a4f78defSmrg set dummy $deplibs_check_method; shift 7774a4f78defSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7775a4f78defSmrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 7776a4f78defSmrg | $EGREP "$match_pattern_regex" > /dev/null; then 7777a4f78defSmrg valid_a_lib=: 7778a4f78defSmrg fi 7779a4f78defSmrg ;; 7780a4f78defSmrg pass_all) 7781a4f78defSmrg valid_a_lib=: 7782a4f78defSmrg ;; 7783a4f78defSmrg esac 7784a4f78defSmrg if $valid_a_lib; then 7785a4f78defSmrg echo 7786a4f78defSmrg $ECHO "*** Warning: Linking the shared library $output against the" 7787a4f78defSmrg $ECHO "*** static library $deplib is not portable!" 7788a4f78defSmrg deplibs="$deplib $deplibs" 7789a4f78defSmrg else 7790a4f78defSmrg echo 7791a4f78defSmrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 7792a4f78defSmrg echo "*** I have the capability to make that library automatically link in when" 7793a4f78defSmrg echo "*** you link to this library. But I can only do this if you have a" 7794a4f78defSmrg echo "*** shared version of the library, which you do not appear to have" 7795a4f78defSmrg echo "*** because the file extensions .$libext of this argument makes me believe" 7796a4f78defSmrg echo "*** that it is just a static archive that I should not use here." 7797a4f78defSmrg fi 7798a4f78defSmrg ;; 7799a4f78defSmrg esac 7800a4f78defSmrg continue 7801a4f78defSmrg ;; 7802a4f78defSmrg prog) 7803a4f78defSmrg if test link != "$pass"; then 7804a4f78defSmrg deplibs="$deplib $deplibs" 7805a4f78defSmrg else 7806a4f78defSmrg compile_deplibs="$deplib $compile_deplibs" 7807a4f78defSmrg finalize_deplibs="$deplib $finalize_deplibs" 7808a4f78defSmrg fi 7809a4f78defSmrg continue 7810a4f78defSmrg ;; 7811a4f78defSmrg esac # linkmode 7812a4f78defSmrg ;; # *.$libext 7813a4f78defSmrg *.lo | *.$objext) 7814a4f78defSmrg if test conv = "$pass"; then 7815a4f78defSmrg deplibs="$deplib $deplibs" 7816a4f78defSmrg elif test prog = "$linkmode"; then 7817a4f78defSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 7818a4f78defSmrg # If there is no dlopen support or we're linking statically, 7819a4f78defSmrg # we need to preload. 7820a4f78defSmrg func_append newdlprefiles " $deplib" 7821a4f78defSmrg compile_deplibs="$deplib $compile_deplibs" 7822a4f78defSmrg finalize_deplibs="$deplib $finalize_deplibs" 7823a4f78defSmrg else 7824a4f78defSmrg func_append newdlfiles " $deplib" 7825a4f78defSmrg fi 7826a4f78defSmrg fi 7827a4f78defSmrg continue 7828a4f78defSmrg ;; 7829a4f78defSmrg %DEPLIBS%) 7830a4f78defSmrg alldeplibs=: 7831a4f78defSmrg continue 7832a4f78defSmrg ;; 7833a4f78defSmrg esac # case $deplib 7834a4f78defSmrg 7835a4f78defSmrg $found || test -f "$lib" \ 7836a4f78defSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 7837a4f78defSmrg 7838a4f78defSmrg # Check to see that this really is a libtool archive. 7839a4f78defSmrg func_lalib_unsafe_p "$lib" \ 7840a4f78defSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 7841a4f78defSmrg 7842a4f78defSmrg func_dirname "$lib" "" "." 7843a4f78defSmrg ladir=$func_dirname_result 7844a4f78defSmrg 7845a4f78defSmrg dlname= 7846a4f78defSmrg dlopen= 7847a4f78defSmrg dlpreopen= 7848a4f78defSmrg libdir= 7849a4f78defSmrg library_names= 7850a4f78defSmrg old_library= 7851a4f78defSmrg inherited_linker_flags= 7852a4f78defSmrg # If the library was installed with an old release of libtool, 7853a4f78defSmrg # it will not redefine variables installed, or shouldnotlink 7854a4f78defSmrg installed=yes 7855a4f78defSmrg shouldnotlink=no 7856a4f78defSmrg avoidtemprpath= 7857a4f78defSmrg 7858a4f78defSmrg 7859a4f78defSmrg # Read the .la file 7860a4f78defSmrg func_source "$lib" 7861a4f78defSmrg 7862a4f78defSmrg # Convert "-framework foo" to "foo.ltframework" 7863a4f78defSmrg if test -n "$inherited_linker_flags"; then 7864a4f78defSmrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 7865a4f78defSmrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 7866a4f78defSmrg case " $new_inherited_linker_flags " in 7867a4f78defSmrg *" $tmp_inherited_linker_flag "*) ;; 7868a4f78defSmrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 7869a4f78defSmrg esac 7870a4f78defSmrg done 7871a4f78defSmrg fi 7872a4f78defSmrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7873a4f78defSmrg if test lib,link = "$linkmode,$pass" || 7874a4f78defSmrg test prog,scan = "$linkmode,$pass" || 7875a4f78defSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7876a4f78defSmrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7877a4f78defSmrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 7878a4f78defSmrg fi 7879a4f78defSmrg 7880a4f78defSmrg if test conv = "$pass"; then 7881a4f78defSmrg # Only check for convenience libraries 7882a4f78defSmrg deplibs="$lib $deplibs" 7883a4f78defSmrg if test -z "$libdir"; then 7884a4f78defSmrg if test -z "$old_library"; then 7885a4f78defSmrg func_fatal_error "cannot find name of link library for '$lib'" 7886a4f78defSmrg fi 7887a4f78defSmrg # It is a libtool convenience library, so add in its objects. 7888a4f78defSmrg func_append convenience " $ladir/$objdir/$old_library" 7889a4f78defSmrg func_append old_convenience " $ladir/$objdir/$old_library" 7890a4f78defSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 7891a4f78defSmrg func_fatal_error "'$lib' is not a convenience library" 7892a4f78defSmrg fi 7893a4f78defSmrg tmp_libs= 7894a4f78defSmrg for deplib in $dependency_libs; do 7895a4f78defSmrg deplibs="$deplib $deplibs" 7896a4f78defSmrg if $opt_preserve_dup_deps; then 7897a4f78defSmrg case "$tmp_libs " in 7898a4f78defSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7899a4f78defSmrg esac 7900a4f78defSmrg fi 7901a4f78defSmrg func_append tmp_libs " $deplib" 7902a4f78defSmrg done 7903a4f78defSmrg continue 7904a4f78defSmrg fi # $pass = conv 7905a4f78defSmrg 7906a4f78defSmrg 7907a4f78defSmrg # Get the name of the library we link against. 7908a4f78defSmrg linklib= 7909a4f78defSmrg if test -n "$old_library" && 7910a4f78defSmrg { test yes = "$prefer_static_libs" || 7911a4f78defSmrg test built,no = "$prefer_static_libs,$installed"; }; then 7912a4f78defSmrg linklib=$old_library 7913a4f78defSmrg else 7914a4f78defSmrg for l in $old_library $library_names; do 7915a4f78defSmrg linklib=$l 7916a4f78defSmrg done 7917a4f78defSmrg fi 7918a4f78defSmrg if test -z "$linklib"; then 7919a4f78defSmrg func_fatal_error "cannot find name of link library for '$lib'" 7920a4f78defSmrg fi 7921a4f78defSmrg 7922a4f78defSmrg # This library was specified with -dlopen. 7923a4f78defSmrg if test dlopen = "$pass"; then 7924a4f78defSmrg test -z "$libdir" \ 7925a4f78defSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 7926a4f78defSmrg if test -z "$dlname" || 7927a4f78defSmrg test yes != "$dlopen_support" || 7928a4f78defSmrg test no = "$build_libtool_libs" 7929a4f78defSmrg then 7930a4f78defSmrg # If there is no dlname, no dlopen support or we're linking 7931a4f78defSmrg # statically, we need to preload. We also need to preload any 7932a4f78defSmrg # dependent libraries so libltdl's deplib preloader doesn't 7933a4f78defSmrg # bomb out in the load deplibs phase. 7934a4f78defSmrg func_append dlprefiles " $lib $dependency_libs" 7935a4f78defSmrg else 7936a4f78defSmrg func_append newdlfiles " $lib" 7937a4f78defSmrg fi 7938a4f78defSmrg continue 7939a4f78defSmrg fi # $pass = dlopen 7940a4f78defSmrg 7941a4f78defSmrg # We need an absolute path. 7942a4f78defSmrg case $ladir in 7943a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 7944a4f78defSmrg *) 7945a4f78defSmrg abs_ladir=`cd "$ladir" && pwd` 7946a4f78defSmrg if test -z "$abs_ladir"; then 7947a4f78defSmrg func_warning "cannot determine absolute directory name of '$ladir'" 7948a4f78defSmrg func_warning "passing it literally to the linker, although it might fail" 7949a4f78defSmrg abs_ladir=$ladir 7950a4f78defSmrg fi 7951a4f78defSmrg ;; 7952a4f78defSmrg esac 7953a4f78defSmrg func_basename "$lib" 7954a4f78defSmrg laname=$func_basename_result 7955a4f78defSmrg 7956a4f78defSmrg # Find the relevant object directory and library name. 7957a4f78defSmrg if test yes = "$installed"; then 7958a4f78defSmrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7959a4f78defSmrg func_warning "library '$lib' was moved." 7960a4f78defSmrg dir=$ladir 7961a4f78defSmrg absdir=$abs_ladir 7962a4f78defSmrg libdir=$abs_ladir 7963a4f78defSmrg else 7964a4f78defSmrg dir=$lt_sysroot$libdir 7965a4f78defSmrg absdir=$lt_sysroot$libdir 7966a4f78defSmrg fi 7967a4f78defSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 7968a4f78defSmrg else 7969a4f78defSmrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7970a4f78defSmrg dir=$ladir 7971a4f78defSmrg absdir=$abs_ladir 7972a4f78defSmrg # Remove this search path later 7973a4f78defSmrg func_append notinst_path " $abs_ladir" 7974a4f78defSmrg else 7975a4f78defSmrg dir=$ladir/$objdir 7976a4f78defSmrg absdir=$abs_ladir/$objdir 7977a4f78defSmrg # Remove this search path later 7978a4f78defSmrg func_append notinst_path " $abs_ladir" 7979a4f78defSmrg fi 7980a4f78defSmrg fi # $installed = yes 7981a4f78defSmrg func_stripname 'lib' '.la' "$laname" 7982a4f78defSmrg name=$func_stripname_result 7983a4f78defSmrg 7984a4f78defSmrg # This library was specified with -dlpreopen. 7985a4f78defSmrg if test dlpreopen = "$pass"; then 7986a4f78defSmrg if test -z "$libdir" && test prog = "$linkmode"; then 7987a4f78defSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 7988a4f78defSmrg fi 7989a4f78defSmrg case $host in 7990a4f78defSmrg # special handling for platforms with PE-DLLs. 7991a4f78defSmrg *cygwin* | *mingw* | *cegcc* ) 7992a4f78defSmrg # Linker will automatically link against shared library if both 7993a4f78defSmrg # static and shared are present. Therefore, ensure we extract 7994a4f78defSmrg # symbols from the import library if a shared library is present 7995a4f78defSmrg # (otherwise, the dlopen module name will be incorrect). We do 7996a4f78defSmrg # this by putting the import library name into $newdlprefiles. 7997a4f78defSmrg # We recover the dlopen module name by 'saving' the la file 7998a4f78defSmrg # name in a special purpose variable, and (later) extracting the 7999a4f78defSmrg # dlname from the la file. 8000a4f78defSmrg if test -n "$dlname"; then 8001a4f78defSmrg func_tr_sh "$dir/$linklib" 8002a4f78defSmrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8003a4f78defSmrg func_append newdlprefiles " $dir/$linklib" 8004a4f78defSmrg else 8005a4f78defSmrg func_append newdlprefiles " $dir/$old_library" 8006a4f78defSmrg # Keep a list of preopened convenience libraries to check 8007a4f78defSmrg # that they are being used correctly in the link pass. 8008a4f78defSmrg test -z "$libdir" && \ 8009a4f78defSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8010a4f78defSmrg fi 8011a4f78defSmrg ;; 8012a4f78defSmrg * ) 8013a4f78defSmrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8014a4f78defSmrg # are required to link). 8015a4f78defSmrg if test -n "$old_library"; then 8016a4f78defSmrg func_append newdlprefiles " $dir/$old_library" 8017a4f78defSmrg # Keep a list of preopened convenience libraries to check 8018a4f78defSmrg # that they are being used correctly in the link pass. 8019a4f78defSmrg test -z "$libdir" && \ 8020a4f78defSmrg func_append dlpreconveniencelibs " $dir/$old_library" 8021a4f78defSmrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8022a4f78defSmrg elif test -n "$dlname"; then 8023a4f78defSmrg func_append newdlprefiles " $dir/$dlname" 8024a4f78defSmrg else 8025a4f78defSmrg func_append newdlprefiles " $dir/$linklib" 8026a4f78defSmrg fi 8027a4f78defSmrg ;; 8028a4f78defSmrg esac 8029a4f78defSmrg fi # $pass = dlpreopen 8030a4f78defSmrg 8031a4f78defSmrg if test -z "$libdir"; then 8032a4f78defSmrg # Link the convenience library 8033a4f78defSmrg if test lib = "$linkmode"; then 8034a4f78defSmrg deplibs="$dir/$old_library $deplibs" 8035a4f78defSmrg elif test prog,link = "$linkmode,$pass"; then 8036a4f78defSmrg compile_deplibs="$dir/$old_library $compile_deplibs" 8037a4f78defSmrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8038a4f78defSmrg else 8039a4f78defSmrg deplibs="$lib $deplibs" # used for prog,scan pass 8040a4f78defSmrg fi 8041a4f78defSmrg continue 8042a4f78defSmrg fi 8043a4f78defSmrg 8044a4f78defSmrg 8045a4f78defSmrg if test prog = "$linkmode" && test link != "$pass"; then 8046a4f78defSmrg func_append newlib_search_path " $ladir" 8047a4f78defSmrg deplibs="$lib $deplibs" 8048a4f78defSmrg 8049a4f78defSmrg linkalldeplibs=false 8050a4f78defSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8051a4f78defSmrg test no = "$build_libtool_libs"; then 8052a4f78defSmrg linkalldeplibs=: 8053a4f78defSmrg fi 8054a4f78defSmrg 8055a4f78defSmrg tmp_libs= 8056a4f78defSmrg for deplib in $dependency_libs; do 8057a4f78defSmrg case $deplib in 8058a4f78defSmrg -L*) func_stripname '-L' '' "$deplib" 8059a4f78defSmrg func_resolve_sysroot "$func_stripname_result" 8060a4f78defSmrg func_append newlib_search_path " $func_resolve_sysroot_result" 8061a4f78defSmrg ;; 8062a4f78defSmrg esac 8063a4f78defSmrg # Need to link against all dependency_libs? 8064a4f78defSmrg if $linkalldeplibs; then 8065a4f78defSmrg deplibs="$deplib $deplibs" 8066a4f78defSmrg else 8067a4f78defSmrg # Need to hardcode shared library paths 8068a4f78defSmrg # or/and link against static libraries 8069a4f78defSmrg newdependency_libs="$deplib $newdependency_libs" 8070a4f78defSmrg fi 8071a4f78defSmrg if $opt_preserve_dup_deps; then 8072a4f78defSmrg case "$tmp_libs " in 8073a4f78defSmrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8074a4f78defSmrg esac 8075a4f78defSmrg fi 8076a4f78defSmrg func_append tmp_libs " $deplib" 8077a4f78defSmrg done # for deplib 8078a4f78defSmrg continue 8079a4f78defSmrg fi # $linkmode = prog... 8080a4f78defSmrg 8081a4f78defSmrg if test prog,link = "$linkmode,$pass"; then 8082a4f78defSmrg if test -n "$library_names" && 8083a4f78defSmrg { { test no = "$prefer_static_libs" || 8084a4f78defSmrg test built,yes = "$prefer_static_libs,$installed"; } || 8085a4f78defSmrg test -z "$old_library"; }; then 8086a4f78defSmrg # We need to hardcode the library path 8087a4f78defSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8088a4f78defSmrg # Make sure the rpath contains only unique directories. 8089a4f78defSmrg case $temp_rpath: in 8090a4f78defSmrg *"$absdir:"*) ;; 8091a4f78defSmrg *) func_append temp_rpath "$absdir:" ;; 8092a4f78defSmrg esac 8093a4f78defSmrg fi 8094a4f78defSmrg 8095a4f78defSmrg # Hardcode the library path. 8096a4f78defSmrg # Skip directories that are in the system default run-time 8097a4f78defSmrg # search path. 8098a4f78defSmrg case " $sys_lib_dlsearch_path " in 8099a4f78defSmrg *" $absdir "*) ;; 8100a4f78defSmrg *) 8101a4f78defSmrg case "$compile_rpath " in 8102a4f78defSmrg *" $absdir "*) ;; 8103a4f78defSmrg *) func_append compile_rpath " $absdir" ;; 8104a4f78defSmrg esac 8105a4f78defSmrg ;; 8106a4f78defSmrg esac 8107a4f78defSmrg case " $sys_lib_dlsearch_path " in 8108a4f78defSmrg *" $libdir "*) ;; 8109a4f78defSmrg *) 8110a4f78defSmrg case "$finalize_rpath " in 8111a4f78defSmrg *" $libdir "*) ;; 8112a4f78defSmrg *) func_append finalize_rpath " $libdir" ;; 8113a4f78defSmrg esac 8114a4f78defSmrg ;; 8115a4f78defSmrg esac 8116a4f78defSmrg fi # $linkmode,$pass = prog,link... 8117a4f78defSmrg 8118a4f78defSmrg if $alldeplibs && 8119a4f78defSmrg { test pass_all = "$deplibs_check_method" || 8120a4f78defSmrg { test yes = "$build_libtool_libs" && 8121a4f78defSmrg test -n "$library_names"; }; }; then 8122a4f78defSmrg # We only need to search for static libraries 8123a4f78defSmrg continue 8124a4f78defSmrg fi 8125a4f78defSmrg fi 8126a4f78defSmrg 8127a4f78defSmrg link_static=no # Whether the deplib will be linked statically 8128a4f78defSmrg use_static_libs=$prefer_static_libs 8129a4f78defSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 8130a4f78defSmrg use_static_libs=no 8131a4f78defSmrg fi 8132a4f78defSmrg if test -n "$library_names" && 8133a4f78defSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8134a4f78defSmrg case $host in 8135a4f78defSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 8136a4f78defSmrg # No point in relinking DLLs because paths are not encoded 8137a4f78defSmrg func_append notinst_deplibs " $lib" 8138a4f78defSmrg need_relink=no 8139a4f78defSmrg ;; 8140a4f78defSmrg *) 8141a4f78defSmrg if test no = "$installed"; then 8142a4f78defSmrg func_append notinst_deplibs " $lib" 8143a4f78defSmrg need_relink=yes 8144a4f78defSmrg fi 8145a4f78defSmrg ;; 8146a4f78defSmrg esac 8147a4f78defSmrg # This is a shared library 8148a4f78defSmrg 8149a4f78defSmrg # Warn about portability, can't link against -module's on some 8150a4f78defSmrg # systems (darwin). Don't bleat about dlopened modules though! 8151a4f78defSmrg dlopenmodule= 8152a4f78defSmrg for dlpremoduletest in $dlprefiles; do 8153a4f78defSmrg if test "X$dlpremoduletest" = "X$lib"; then 8154a4f78defSmrg dlopenmodule=$dlpremoduletest 8155a4f78defSmrg break 8156a4f78defSmrg fi 8157a4f78defSmrg done 8158a4f78defSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8159a4f78defSmrg echo 8160a4f78defSmrg if test prog = "$linkmode"; then 8161a4f78defSmrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8162a4f78defSmrg else 8163a4f78defSmrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8164a4f78defSmrg fi 8165a4f78defSmrg $ECHO "*** $linklib is not portable!" 8166a4f78defSmrg fi 8167a4f78defSmrg if test lib = "$linkmode" && 8168a4f78defSmrg test yes = "$hardcode_into_libs"; then 8169a4f78defSmrg # Hardcode the library path. 8170a4f78defSmrg # Skip directories that are in the system default run-time 8171a4f78defSmrg # search path. 8172a4f78defSmrg case " $sys_lib_dlsearch_path " in 8173a4f78defSmrg *" $absdir "*) ;; 8174a4f78defSmrg *) 8175a4f78defSmrg case "$compile_rpath " in 8176a4f78defSmrg *" $absdir "*) ;; 8177a4f78defSmrg *) func_append compile_rpath " $absdir" ;; 8178a4f78defSmrg esac 8179a4f78defSmrg ;; 8180a4f78defSmrg esac 8181a4f78defSmrg case " $sys_lib_dlsearch_path " in 8182a4f78defSmrg *" $libdir "*) ;; 8183a4f78defSmrg *) 8184a4f78defSmrg case "$finalize_rpath " in 8185a4f78defSmrg *" $libdir "*) ;; 8186a4f78defSmrg *) func_append finalize_rpath " $libdir" ;; 8187a4f78defSmrg esac 8188a4f78defSmrg ;; 8189a4f78defSmrg esac 8190a4f78defSmrg fi 8191a4f78defSmrg 8192a4f78defSmrg if test -n "$old_archive_from_expsyms_cmds"; then 8193a4f78defSmrg # figure out the soname 8194a4f78defSmrg set dummy $library_names 8195a4f78defSmrg shift 8196a4f78defSmrg realname=$1 8197a4f78defSmrg shift 8198a4f78defSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 8199a4f78defSmrg # use dlname if we got it. it's perfectly good, no? 8200a4f78defSmrg if test -n "$dlname"; then 8201a4f78defSmrg soname=$dlname 8202a4f78defSmrg elif test -n "$soname_spec"; then 8203a4f78defSmrg # bleh windows 8204a4f78defSmrg case $host in 8205a4f78defSmrg *cygwin* | mingw* | *cegcc* | *os2*) 8206a4f78defSmrg func_arith $current - $age 8207a4f78defSmrg major=$func_arith_result 8208a4f78defSmrg versuffix=-$major 8209a4f78defSmrg ;; 8210a4f78defSmrg esac 8211a4f78defSmrg eval soname=\"$soname_spec\" 8212a4f78defSmrg else 8213a4f78defSmrg soname=$realname 8214a4f78defSmrg fi 8215a4f78defSmrg 8216a4f78defSmrg # Make a new name for the extract_expsyms_cmds to use 8217a4f78defSmrg soroot=$soname 8218a4f78defSmrg func_basename "$soroot" 8219a4f78defSmrg soname=$func_basename_result 8220a4f78defSmrg func_stripname 'lib' '.dll' "$soname" 8221a4f78defSmrg newlib=libimp-$func_stripname_result.a 8222a4f78defSmrg 8223a4f78defSmrg # If the library has no export list, then create one now 8224a4f78defSmrg if test -f "$output_objdir/$soname-def"; then : 8225a4f78defSmrg else 8226a4f78defSmrg func_verbose "extracting exported symbol list from '$soname'" 8227a4f78defSmrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8228a4f78defSmrg fi 8229a4f78defSmrg 8230a4f78defSmrg # Create $newlib 8231a4f78defSmrg if test -f "$output_objdir/$newlib"; then :; else 8232a4f78defSmrg func_verbose "generating import library for '$soname'" 8233a4f78defSmrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8234a4f78defSmrg fi 8235a4f78defSmrg # make sure the library variables are pointing to the new library 8236a4f78defSmrg dir=$output_objdir 8237a4f78defSmrg linklib=$newlib 8238a4f78defSmrg fi # test -n "$old_archive_from_expsyms_cmds" 8239a4f78defSmrg 8240a4f78defSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8241a4f78defSmrg add_shlibpath= 8242a4f78defSmrg add_dir= 8243a4f78defSmrg add= 8244a4f78defSmrg lib_linked=yes 8245a4f78defSmrg case $hardcode_action in 8246a4f78defSmrg immediate | unsupported) 8247a4f78defSmrg if test no = "$hardcode_direct"; then 8248a4f78defSmrg add=$dir/$linklib 8249a4f78defSmrg case $host in 8250a4f78defSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8251a4f78defSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8252a4f78defSmrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8253a4f78defSmrg *-*-unixware7*) add_dir=-L$dir ;; 8254a4f78defSmrg *-*-darwin* ) 8255a4f78defSmrg # if the lib is a (non-dlopened) module then we cannot 8256a4f78defSmrg # link against it, someone is ignoring the earlier warnings 8257a4f78defSmrg if /usr/bin/file -L $add 2> /dev/null | 8258a4f78defSmrg $GREP ": [^:]* bundle" >/dev/null; then 8259a4f78defSmrg if test "X$dlopenmodule" != "X$lib"; then 8260a4f78defSmrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8261a4f78defSmrg if test -z "$old_library"; then 8262a4f78defSmrg echo 8263a4f78defSmrg echo "*** And there doesn't seem to be a static archive available" 8264a4f78defSmrg echo "*** The link will probably fail, sorry" 8265a4f78defSmrg else 8266a4f78defSmrg add=$dir/$old_library 8267a4f78defSmrg fi 8268a4f78defSmrg elif test -n "$old_library"; then 8269a4f78defSmrg add=$dir/$old_library 8270a4f78defSmrg fi 8271a4f78defSmrg fi 8272a4f78defSmrg esac 8273a4f78defSmrg elif test no = "$hardcode_minus_L"; then 8274a4f78defSmrg case $host in 8275a4f78defSmrg *-*-sunos*) add_shlibpath=$dir ;; 8276a4f78defSmrg esac 8277a4f78defSmrg add_dir=-L$dir 8278a4f78defSmrg add=-l$name 8279a4f78defSmrg elif test no = "$hardcode_shlibpath_var"; then 8280a4f78defSmrg add_shlibpath=$dir 8281a4f78defSmrg add=-l$name 8282a4f78defSmrg else 8283a4f78defSmrg lib_linked=no 8284a4f78defSmrg fi 8285a4f78defSmrg ;; 8286a4f78defSmrg relink) 8287a4f78defSmrg if test yes = "$hardcode_direct" && 8288a4f78defSmrg test no = "$hardcode_direct_absolute"; then 8289a4f78defSmrg add=$dir/$linklib 8290a4f78defSmrg elif test yes = "$hardcode_minus_L"; then 8291a4f78defSmrg add_dir=-L$absdir 8292a4f78defSmrg # Try looking first in the location we're being installed to. 8293a4f78defSmrg if test -n "$inst_prefix_dir"; then 8294a4f78defSmrg case $libdir in 8295a4f78defSmrg [\\/]*) 8296a4f78defSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8297a4f78defSmrg ;; 8298a4f78defSmrg esac 8299a4f78defSmrg fi 8300a4f78defSmrg add=-l$name 8301a4f78defSmrg elif test yes = "$hardcode_shlibpath_var"; then 8302a4f78defSmrg add_shlibpath=$dir 8303a4f78defSmrg add=-l$name 8304a4f78defSmrg else 8305a4f78defSmrg lib_linked=no 8306a4f78defSmrg fi 8307a4f78defSmrg ;; 8308a4f78defSmrg *) lib_linked=no ;; 8309a4f78defSmrg esac 8310a4f78defSmrg 8311a4f78defSmrg if test yes != "$lib_linked"; then 8312a4f78defSmrg func_fatal_configuration "unsupported hardcode properties" 8313a4f78defSmrg fi 8314a4f78defSmrg 8315a4f78defSmrg if test -n "$add_shlibpath"; then 8316a4f78defSmrg case :$compile_shlibpath: in 8317a4f78defSmrg *":$add_shlibpath:"*) ;; 8318a4f78defSmrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8319a4f78defSmrg esac 8320a4f78defSmrg fi 8321a4f78defSmrg if test prog = "$linkmode"; then 8322a4f78defSmrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8323a4f78defSmrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8324a4f78defSmrg else 8325a4f78defSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8326a4f78defSmrg test -n "$add" && deplibs="$add $deplibs" 8327a4f78defSmrg if test yes != "$hardcode_direct" && 8328a4f78defSmrg test yes != "$hardcode_minus_L" && 8329a4f78defSmrg test yes = "$hardcode_shlibpath_var"; then 8330a4f78defSmrg case :$finalize_shlibpath: in 8331a4f78defSmrg *":$libdir:"*) ;; 8332a4f78defSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8333a4f78defSmrg esac 8334a4f78defSmrg fi 8335a4f78defSmrg fi 8336a4f78defSmrg fi 8337a4f78defSmrg 8338a4f78defSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8339a4f78defSmrg add_shlibpath= 8340a4f78defSmrg add_dir= 8341a4f78defSmrg add= 8342a4f78defSmrg # Finalize command for both is simple: just hardcode it. 8343a4f78defSmrg if test yes = "$hardcode_direct" && 8344a4f78defSmrg test no = "$hardcode_direct_absolute"; then 8345a4f78defSmrg add=$libdir/$linklib 8346a4f78defSmrg elif test yes = "$hardcode_minus_L"; then 8347a4f78defSmrg add_dir=-L$libdir 8348a4f78defSmrg add=-l$name 8349a4f78defSmrg elif test yes = "$hardcode_shlibpath_var"; then 8350a4f78defSmrg case :$finalize_shlibpath: in 8351a4f78defSmrg *":$libdir:"*) ;; 8352a4f78defSmrg *) func_append finalize_shlibpath "$libdir:" ;; 8353a4f78defSmrg esac 8354a4f78defSmrg add=-l$name 8355a4f78defSmrg elif test yes = "$hardcode_automatic"; then 8356a4f78defSmrg if test -n "$inst_prefix_dir" && 8357a4f78defSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8358a4f78defSmrg add=$inst_prefix_dir$libdir/$linklib 8359a4f78defSmrg else 8360a4f78defSmrg add=$libdir/$linklib 8361a4f78defSmrg fi 8362a4f78defSmrg else 8363a4f78defSmrg # We cannot seem to hardcode it, guess we'll fake it. 8364a4f78defSmrg add_dir=-L$libdir 8365a4f78defSmrg # Try looking first in the location we're being installed to. 8366a4f78defSmrg if test -n "$inst_prefix_dir"; then 8367a4f78defSmrg case $libdir in 8368a4f78defSmrg [\\/]*) 8369a4f78defSmrg func_append add_dir " -L$inst_prefix_dir$libdir" 8370a4f78defSmrg ;; 8371a4f78defSmrg esac 8372a4f78defSmrg fi 8373a4f78defSmrg add=-l$name 8374a4f78defSmrg fi 8375a4f78defSmrg 8376a4f78defSmrg if test prog = "$linkmode"; then 8377a4f78defSmrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8378a4f78defSmrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8379a4f78defSmrg else 8380a4f78defSmrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8381a4f78defSmrg test -n "$add" && deplibs="$add $deplibs" 8382a4f78defSmrg fi 8383a4f78defSmrg fi 8384a4f78defSmrg elif test prog = "$linkmode"; then 8385a4f78defSmrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8386a4f78defSmrg # is not unsupported. This is valid on all known static and 8387a4f78defSmrg # shared platforms. 8388a4f78defSmrg if test unsupported != "$hardcode_direct"; then 8389a4f78defSmrg test -n "$old_library" && linklib=$old_library 8390a4f78defSmrg compile_deplibs="$dir/$linklib $compile_deplibs" 8391a4f78defSmrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8392a4f78defSmrg else 8393a4f78defSmrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8394a4f78defSmrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8395a4f78defSmrg fi 8396a4f78defSmrg elif test yes = "$build_libtool_libs"; then 8397a4f78defSmrg # Not a shared library 8398a4f78defSmrg if test pass_all != "$deplibs_check_method"; then 8399a4f78defSmrg # We're trying link a shared library against a static one 8400a4f78defSmrg # but the system doesn't support it. 8401a4f78defSmrg 8402a4f78defSmrg # Just print a warning and add the library to dependency_libs so 8403a4f78defSmrg # that the program can be linked against the static library. 8404a4f78defSmrg echo 8405a4f78defSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8406a4f78defSmrg echo "*** I have the capability to make that library automatically link in when" 8407a4f78defSmrg echo "*** you link to this library. But I can only do this if you have a" 8408a4f78defSmrg echo "*** shared version of the library, which you do not appear to have." 8409a4f78defSmrg if test yes = "$module"; then 8410a4f78defSmrg echo "*** But as you try to build a module library, libtool will still create " 8411a4f78defSmrg echo "*** a static module, that should work as long as the dlopening application" 8412a4f78defSmrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8413a4f78defSmrg if test -z "$global_symbol_pipe"; then 8414a4f78defSmrg echo 8415a4f78defSmrg echo "*** However, this would only work if libtool was able to extract symbol" 8416a4f78defSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8417a4f78defSmrg echo "*** not find such a program. So, this module is probably useless." 8418a4f78defSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8419a4f78defSmrg fi 8420a4f78defSmrg if test no = "$build_old_libs"; then 8421a4f78defSmrg build_libtool_libs=module 8422a4f78defSmrg build_old_libs=yes 8423a4f78defSmrg else 8424a4f78defSmrg build_libtool_libs=no 8425a4f78defSmrg fi 8426a4f78defSmrg fi 8427a4f78defSmrg else 8428a4f78defSmrg deplibs="$dir/$old_library $deplibs" 8429a4f78defSmrg link_static=yes 8430a4f78defSmrg fi 8431a4f78defSmrg fi # link shared/static library? 8432a4f78defSmrg 8433a4f78defSmrg if test lib = "$linkmode"; then 8434a4f78defSmrg if test -n "$dependency_libs" && 8435a4f78defSmrg { test yes != "$hardcode_into_libs" || 8436a4f78defSmrg test yes = "$build_old_libs" || 8437a4f78defSmrg test yes = "$link_static"; }; then 8438a4f78defSmrg # Extract -R from dependency_libs 8439a4f78defSmrg temp_deplibs= 8440a4f78defSmrg for libdir in $dependency_libs; do 8441a4f78defSmrg case $libdir in 8442a4f78defSmrg -R*) func_stripname '-R' '' "$libdir" 8443a4f78defSmrg temp_xrpath=$func_stripname_result 8444a4f78defSmrg case " $xrpath " in 8445a4f78defSmrg *" $temp_xrpath "*) ;; 8446a4f78defSmrg *) func_append xrpath " $temp_xrpath";; 8447a4f78defSmrg esac;; 8448a4f78defSmrg *) func_append temp_deplibs " $libdir";; 8449a4f78defSmrg esac 8450a4f78defSmrg done 8451a4f78defSmrg dependency_libs=$temp_deplibs 8452a4f78defSmrg fi 8453a4f78defSmrg 8454a4f78defSmrg func_append newlib_search_path " $absdir" 8455a4f78defSmrg # Link against this library 8456a4f78defSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8457a4f78defSmrg # ... and its dependency_libs 8458a4f78defSmrg tmp_libs= 8459a4f78defSmrg for deplib in $dependency_libs; do 8460a4f78defSmrg newdependency_libs="$deplib $newdependency_libs" 8461a4f78defSmrg case $deplib in 8462a4f78defSmrg -L*) func_stripname '-L' '' "$deplib" 8463a4f78defSmrg func_resolve_sysroot "$func_stripname_result";; 8464a4f78defSmrg *) func_resolve_sysroot "$deplib" ;; 8465a4f78defSmrg esac 8466a4f78defSmrg if $opt_preserve_dup_deps; then 8467a4f78defSmrg case "$tmp_libs " in 8468a4f78defSmrg *" $func_resolve_sysroot_result "*) 8469a4f78defSmrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8470a4f78defSmrg esac 8471a4f78defSmrg fi 8472a4f78defSmrg func_append tmp_libs " $func_resolve_sysroot_result" 8473a4f78defSmrg done 8474a4f78defSmrg 8475a4f78defSmrg if test no != "$link_all_deplibs"; then 8476a4f78defSmrg # Add the search paths of all dependency libraries 8477a4f78defSmrg for deplib in $dependency_libs; do 8478a4f78defSmrg path= 8479a4f78defSmrg case $deplib in 8480a4f78defSmrg -L*) path=$deplib ;; 8481a4f78defSmrg *.la) 8482a4f78defSmrg func_resolve_sysroot "$deplib" 8483a4f78defSmrg deplib=$func_resolve_sysroot_result 8484a4f78defSmrg func_dirname "$deplib" "" "." 8485a4f78defSmrg dir=$func_dirname_result 8486a4f78defSmrg # We need an absolute path. 8487a4f78defSmrg case $dir in 8488a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8489a4f78defSmrg *) 8490a4f78defSmrg absdir=`cd "$dir" && pwd` 8491a4f78defSmrg if test -z "$absdir"; then 8492a4f78defSmrg func_warning "cannot determine absolute directory name of '$dir'" 8493a4f78defSmrg absdir=$dir 8494a4f78defSmrg fi 8495a4f78defSmrg ;; 8496a4f78defSmrg esac 8497a4f78defSmrg if $GREP "^installed=no" $deplib > /dev/null; then 8498a4f78defSmrg case $host in 8499a4f78defSmrg *-*-darwin*) 8500a4f78defSmrg depdepl= 8501a4f78defSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8502a4f78defSmrg if test -n "$deplibrary_names"; then 8503a4f78defSmrg for tmp in $deplibrary_names; do 8504a4f78defSmrg depdepl=$tmp 8505a4f78defSmrg done 8506a4f78defSmrg if test -f "$absdir/$objdir/$depdepl"; then 8507a4f78defSmrg depdepl=$absdir/$objdir/$depdepl 8508a4f78defSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8509a4f78defSmrg if test -z "$darwin_install_name"; then 8510a4f78defSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8511a4f78defSmrg fi 8512a4f78defSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8513a4f78defSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8514a4f78defSmrg path= 8515a4f78defSmrg fi 8516a4f78defSmrg fi 8517a4f78defSmrg ;; 8518a4f78defSmrg *) 8519a4f78defSmrg path=-L$absdir/$objdir 8520a4f78defSmrg ;; 8521a4f78defSmrg esac 8522a4f78defSmrg else 8523a4f78defSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8524a4f78defSmrg test -z "$libdir" && \ 8525a4f78defSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 8526a4f78defSmrg test "$absdir" != "$libdir" && \ 8527a4f78defSmrg func_warning "'$deplib' seems to be moved" 8528a4f78defSmrg 8529a4f78defSmrg path=-L$absdir 8530a4f78defSmrg fi 8531a4f78defSmrg ;; 8532a4f78defSmrg esac 8533a4f78defSmrg case " $deplibs " in 8534a4f78defSmrg *" $path "*) ;; 8535a4f78defSmrg *) deplibs="$path $deplibs" ;; 8536a4f78defSmrg esac 8537a4f78defSmrg done 8538a4f78defSmrg fi # link_all_deplibs != no 8539a4f78defSmrg fi # linkmode = lib 8540a4f78defSmrg done # for deplib in $libs 8541a4f78defSmrg if test link = "$pass"; then 8542a4f78defSmrg if test prog = "$linkmode"; then 8543a4f78defSmrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8544a4f78defSmrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8545a4f78defSmrg else 8546a4f78defSmrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8547a4f78defSmrg fi 8548a4f78defSmrg fi 8549a4f78defSmrg dependency_libs=$newdependency_libs 8550a4f78defSmrg if test dlpreopen = "$pass"; then 8551a4f78defSmrg # Link the dlpreopened libraries before other libraries 8552a4f78defSmrg for deplib in $save_deplibs; do 8553a4f78defSmrg deplibs="$deplib $deplibs" 8554a4f78defSmrg done 8555a4f78defSmrg fi 8556a4f78defSmrg if test dlopen != "$pass"; then 8557a4f78defSmrg test conv = "$pass" || { 8558a4f78defSmrg # Make sure lib_search_path contains only unique directories. 8559a4f78defSmrg lib_search_path= 8560a4f78defSmrg for dir in $newlib_search_path; do 8561a4f78defSmrg case "$lib_search_path " in 8562a4f78defSmrg *" $dir "*) ;; 8563a4f78defSmrg *) func_append lib_search_path " $dir" ;; 8564a4f78defSmrg esac 8565a4f78defSmrg done 8566a4f78defSmrg newlib_search_path= 8567a4f78defSmrg } 8568a4f78defSmrg 8569a4f78defSmrg if test prog,link = "$linkmode,$pass"; then 8570a4f78defSmrg vars="compile_deplibs finalize_deplibs" 8571a4f78defSmrg else 8572a4f78defSmrg vars=deplibs 8573a4f78defSmrg fi 8574a4f78defSmrg for var in $vars dependency_libs; do 8575a4f78defSmrg # Add libraries to $var in reverse order 8576a4f78defSmrg eval tmp_libs=\"\$$var\" 8577a4f78defSmrg new_libs= 8578a4f78defSmrg for deplib in $tmp_libs; do 8579a4f78defSmrg # FIXME: Pedantically, this is the right thing to do, so 8580a4f78defSmrg # that some nasty dependency loop isn't accidentally 8581a4f78defSmrg # broken: 8582a4f78defSmrg #new_libs="$deplib $new_libs" 8583a4f78defSmrg # Pragmatically, this seems to cause very few problems in 8584a4f78defSmrg # practice: 8585a4f78defSmrg case $deplib in 8586a4f78defSmrg -L*) new_libs="$deplib $new_libs" ;; 8587a4f78defSmrg -R*) ;; 8588a4f78defSmrg *) 8589a4f78defSmrg # And here is the reason: when a library appears more 8590a4f78defSmrg # than once as an explicit dependence of a library, or 8591a4f78defSmrg # is implicitly linked in more than once by the 8592a4f78defSmrg # compiler, it is considered special, and multiple 8593a4f78defSmrg # occurrences thereof are not removed. Compare this 8594a4f78defSmrg # with having the same library being listed as a 8595a4f78defSmrg # dependency of multiple other libraries: in this case, 8596a4f78defSmrg # we know (pedantically, we assume) the library does not 8597a4f78defSmrg # need to be listed more than once, so we keep only the 8598a4f78defSmrg # last copy. This is not always right, but it is rare 8599a4f78defSmrg # enough that we require users that really mean to play 8600a4f78defSmrg # such unportable linking tricks to link the library 8601a4f78defSmrg # using -Wl,-lname, so that libtool does not consider it 8602a4f78defSmrg # for duplicate removal. 8603a4f78defSmrg case " $specialdeplibs " in 8604a4f78defSmrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8605a4f78defSmrg *) 8606a4f78defSmrg case " $new_libs " in 8607a4f78defSmrg *" $deplib "*) ;; 8608a4f78defSmrg *) new_libs="$deplib $new_libs" ;; 8609a4f78defSmrg esac 8610a4f78defSmrg ;; 8611a4f78defSmrg esac 8612a4f78defSmrg ;; 8613a4f78defSmrg esac 8614a4f78defSmrg done 8615a4f78defSmrg tmp_libs= 8616a4f78defSmrg for deplib in $new_libs; do 8617a4f78defSmrg case $deplib in 8618a4f78defSmrg -L*) 8619a4f78defSmrg case " $tmp_libs " in 8620a4f78defSmrg *" $deplib "*) ;; 8621a4f78defSmrg *) func_append tmp_libs " $deplib" ;; 8622a4f78defSmrg esac 8623a4f78defSmrg ;; 8624a4f78defSmrg *) func_append tmp_libs " $deplib" ;; 8625a4f78defSmrg esac 8626a4f78defSmrg done 8627a4f78defSmrg eval $var=\"$tmp_libs\" 8628a4f78defSmrg done # for var 8629a4f78defSmrg fi 8630a4f78defSmrg 8631a4f78defSmrg # Add Sun CC postdeps if required: 8632a4f78defSmrg test CXX = "$tagname" && { 8633a4f78defSmrg case $host_os in 8634a4f78defSmrg linux*) 8635a4f78defSmrg case `$CC -V 2>&1 | sed 5q` in 8636a4f78defSmrg *Sun\ C*) # Sun C++ 5.9 8637a4f78defSmrg func_suncc_cstd_abi 8638a4f78defSmrg 8639a4f78defSmrg if test no != "$suncc_use_cstd_abi"; then 8640a4f78defSmrg func_append postdeps ' -library=Cstd -library=Crun' 8641a4f78defSmrg fi 8642a4f78defSmrg ;; 8643a4f78defSmrg esac 8644a4f78defSmrg ;; 8645a4f78defSmrg 8646a4f78defSmrg solaris*) 8647a4f78defSmrg func_cc_basename "$CC" 8648a4f78defSmrg case $func_cc_basename_result in 8649a4f78defSmrg CC* | sunCC*) 8650a4f78defSmrg func_suncc_cstd_abi 8651a4f78defSmrg 8652a4f78defSmrg if test no != "$suncc_use_cstd_abi"; then 8653a4f78defSmrg func_append postdeps ' -library=Cstd -library=Crun' 8654a4f78defSmrg fi 8655a4f78defSmrg ;; 8656a4f78defSmrg esac 8657a4f78defSmrg ;; 8658a4f78defSmrg esac 8659a4f78defSmrg } 8660a4f78defSmrg 8661a4f78defSmrg # Last step: remove runtime libs from dependency_libs 8662a4f78defSmrg # (they stay in deplibs) 8663a4f78defSmrg tmp_libs= 8664a4f78defSmrg for i in $dependency_libs; do 8665a4f78defSmrg case " $predeps $postdeps $compiler_lib_search_path " in 8666a4f78defSmrg *" $i "*) 8667a4f78defSmrg i= 8668a4f78defSmrg ;; 8669a4f78defSmrg esac 8670a4f78defSmrg if test -n "$i"; then 8671a4f78defSmrg func_append tmp_libs " $i" 8672a4f78defSmrg fi 8673a4f78defSmrg done 8674a4f78defSmrg dependency_libs=$tmp_libs 8675a4f78defSmrg done # for pass 8676a4f78defSmrg if test prog = "$linkmode"; then 8677a4f78defSmrg dlfiles=$newdlfiles 8678a4f78defSmrg fi 8679a4f78defSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8680a4f78defSmrg dlprefiles=$newdlprefiles 8681a4f78defSmrg fi 8682a4f78defSmrg 8683a4f78defSmrg case $linkmode in 8684a4f78defSmrg oldlib) 8685a4f78defSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8686a4f78defSmrg func_warning "'-dlopen' is ignored for archives" 8687a4f78defSmrg fi 8688a4f78defSmrg 8689a4f78defSmrg case " $deplibs" in 8690a4f78defSmrg *\ -l* | *\ -L*) 8691a4f78defSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 8692a4f78defSmrg esac 8693a4f78defSmrg 8694a4f78defSmrg test -n "$rpath" && \ 8695a4f78defSmrg func_warning "'-rpath' is ignored for archives" 8696a4f78defSmrg 8697a4f78defSmrg test -n "$xrpath" && \ 8698a4f78defSmrg func_warning "'-R' is ignored for archives" 8699a4f78defSmrg 8700a4f78defSmrg test -n "$vinfo" && \ 8701a4f78defSmrg func_warning "'-version-info/-version-number' is ignored for archives" 8702a4f78defSmrg 8703a4f78defSmrg test -n "$release" && \ 8704a4f78defSmrg func_warning "'-release' is ignored for archives" 8705a4f78defSmrg 8706a4f78defSmrg test -n "$export_symbols$export_symbols_regex" && \ 8707a4f78defSmrg func_warning "'-export-symbols' is ignored for archives" 8708a4f78defSmrg 8709a4f78defSmrg # Now set the variables for building old libraries. 8710a4f78defSmrg build_libtool_libs=no 8711a4f78defSmrg oldlibs=$output 8712a4f78defSmrg func_append objs "$old_deplibs" 8713a4f78defSmrg ;; 8714a4f78defSmrg 8715a4f78defSmrg lib) 8716a4f78defSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 8717a4f78defSmrg case $outputname in 8718a4f78defSmrg lib*) 8719a4f78defSmrg func_stripname 'lib' '.la' "$outputname" 8720a4f78defSmrg name=$func_stripname_result 8721a4f78defSmrg eval shared_ext=\"$shrext_cmds\" 8722a4f78defSmrg eval libname=\"$libname_spec\" 8723a4f78defSmrg ;; 8724a4f78defSmrg *) 8725a4f78defSmrg test no = "$module" \ 8726a4f78defSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 8727a4f78defSmrg 8728a4f78defSmrg if test no != "$need_lib_prefix"; then 8729a4f78defSmrg # Add the "lib" prefix for modules if required 8730a4f78defSmrg func_stripname '' '.la' "$outputname" 8731a4f78defSmrg name=$func_stripname_result 8732a4f78defSmrg eval shared_ext=\"$shrext_cmds\" 8733a4f78defSmrg eval libname=\"$libname_spec\" 8734a4f78defSmrg else 8735a4f78defSmrg func_stripname '' '.la' "$outputname" 8736a4f78defSmrg libname=$func_stripname_result 8737a4f78defSmrg fi 8738a4f78defSmrg ;; 8739a4f78defSmrg esac 8740a4f78defSmrg 8741a4f78defSmrg if test -n "$objs"; then 8742a4f78defSmrg if test pass_all != "$deplibs_check_method"; then 8743a4f78defSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 8744a4f78defSmrg else 8745a4f78defSmrg echo 8746a4f78defSmrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 8747a4f78defSmrg $ECHO "*** objects $objs is not portable!" 8748a4f78defSmrg func_append libobjs " $objs" 8749a4f78defSmrg fi 8750a4f78defSmrg fi 8751a4f78defSmrg 8752a4f78defSmrg test no = "$dlself" \ 8753a4f78defSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 8754a4f78defSmrg 8755a4f78defSmrg set dummy $rpath 8756a4f78defSmrg shift 8757a4f78defSmrg test 1 -lt "$#" \ 8758a4f78defSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 8759a4f78defSmrg 8760a4f78defSmrg install_libdir=$1 8761a4f78defSmrg 8762a4f78defSmrg oldlibs= 8763a4f78defSmrg if test -z "$rpath"; then 8764a4f78defSmrg if test yes = "$build_libtool_libs"; then 8765a4f78defSmrg # Building a libtool convenience library. 8766a4f78defSmrg # Some compilers have problems with a '.al' extension so 8767a4f78defSmrg # convenience libraries should have the same extension an 8768a4f78defSmrg # archive normally would. 8769a4f78defSmrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 8770a4f78defSmrg build_libtool_libs=convenience 8771a4f78defSmrg build_old_libs=yes 8772a4f78defSmrg fi 8773a4f78defSmrg 8774a4f78defSmrg test -n "$vinfo" && \ 8775a4f78defSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 8776a4f78defSmrg 8777a4f78defSmrg test -n "$release" && \ 8778a4f78defSmrg func_warning "'-release' is ignored for convenience libraries" 8779a4f78defSmrg else 8780a4f78defSmrg 8781a4f78defSmrg # Parse the version information argument. 8782a4f78defSmrg save_ifs=$IFS; IFS=: 8783a4f78defSmrg set dummy $vinfo 0 0 0 8784a4f78defSmrg shift 8785a4f78defSmrg IFS=$save_ifs 8786a4f78defSmrg 8787a4f78defSmrg test -n "$7" && \ 8788a4f78defSmrg func_fatal_help "too many parameters to '-version-info'" 8789a4f78defSmrg 8790a4f78defSmrg # convert absolute version numbers to libtool ages 8791a4f78defSmrg # this retains compatibility with .la files and attempts 8792a4f78defSmrg # to make the code below a bit more comprehensible 8793a4f78defSmrg 8794a4f78defSmrg case $vinfo_number in 8795a4f78defSmrg yes) 8796a4f78defSmrg number_major=$1 8797a4f78defSmrg number_minor=$2 8798a4f78defSmrg number_revision=$3 8799a4f78defSmrg # 8800a4f78defSmrg # There are really only two kinds -- those that 8801a4f78defSmrg # use the current revision as the major version 8802a4f78defSmrg # and those that subtract age and use age as 8803a4f78defSmrg # a minor version. But, then there is irix 8804a4f78defSmrg # that has an extra 1 added just for fun 8805a4f78defSmrg # 8806a4f78defSmrg case $version_type in 8807a4f78defSmrg # correct linux to gnu/linux during the next big refactor 8808a4f78defSmrg darwin|freebsd-elf|linux|osf|windows|none) 8809a4f78defSmrg func_arith $number_major + $number_minor 8810a4f78defSmrg current=$func_arith_result 8811a4f78defSmrg age=$number_minor 8812a4f78defSmrg revision=$number_revision 8813a4f78defSmrg ;; 8814a4f78defSmrg freebsd-aout|qnx|sunos) 8815a4f78defSmrg current=$number_major 8816a4f78defSmrg revision=$number_minor 8817a4f78defSmrg age=0 8818a4f78defSmrg ;; 8819a4f78defSmrg irix|nonstopux) 8820a4f78defSmrg func_arith $number_major + $number_minor 8821a4f78defSmrg current=$func_arith_result 8822a4f78defSmrg age=$number_minor 8823a4f78defSmrg revision=$number_minor 8824a4f78defSmrg lt_irix_increment=no 8825a4f78defSmrg ;; 8826a4f78defSmrg esac 8827a4f78defSmrg ;; 8828a4f78defSmrg no) 8829a4f78defSmrg current=$1 8830a4f78defSmrg revision=$2 8831a4f78defSmrg age=$3 8832a4f78defSmrg ;; 8833a4f78defSmrg esac 8834a4f78defSmrg 8835a4f78defSmrg # Check that each of the things are valid numbers. 8836a4f78defSmrg case $current in 8837a4f78defSmrg 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]) ;; 8838a4f78defSmrg *) 8839a4f78defSmrg func_error "CURRENT '$current' must be a nonnegative integer" 8840a4f78defSmrg func_fatal_error "'$vinfo' is not valid version information" 8841a4f78defSmrg ;; 8842a4f78defSmrg esac 8843a4f78defSmrg 8844a4f78defSmrg case $revision in 8845a4f78defSmrg 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]) ;; 8846a4f78defSmrg *) 8847a4f78defSmrg func_error "REVISION '$revision' must be a nonnegative integer" 8848a4f78defSmrg func_fatal_error "'$vinfo' is not valid version information" 8849a4f78defSmrg ;; 8850a4f78defSmrg esac 8851a4f78defSmrg 8852a4f78defSmrg case $age in 8853a4f78defSmrg 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]) ;; 8854a4f78defSmrg *) 8855a4f78defSmrg func_error "AGE '$age' must be a nonnegative integer" 8856a4f78defSmrg func_fatal_error "'$vinfo' is not valid version information" 8857a4f78defSmrg ;; 8858a4f78defSmrg esac 8859a4f78defSmrg 8860a4f78defSmrg if test "$age" -gt "$current"; then 8861a4f78defSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 8862a4f78defSmrg func_fatal_error "'$vinfo' is not valid version information" 8863a4f78defSmrg fi 8864a4f78defSmrg 8865a4f78defSmrg # Calculate the version variables. 8866a4f78defSmrg major= 8867a4f78defSmrg versuffix= 8868a4f78defSmrg verstring= 8869a4f78defSmrg case $version_type in 8870a4f78defSmrg none) ;; 8871a4f78defSmrg 8872a4f78defSmrg darwin) 8873a4f78defSmrg # Like Linux, but with the current version available in 8874a4f78defSmrg # verstring for coding it into the library header 8875a4f78defSmrg func_arith $current - $age 8876a4f78defSmrg major=.$func_arith_result 8877a4f78defSmrg versuffix=$major.$age.$revision 8878a4f78defSmrg # Darwin ld doesn't like 0 for these options... 8879a4f78defSmrg func_arith $current + 1 8880a4f78defSmrg minor_current=$func_arith_result 8881a4f78defSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8882a4f78defSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8883a4f78defSmrg # On Darwin other compilers 8884a4f78defSmrg case $CC in 8885a4f78defSmrg nagfor*) 8886a4f78defSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8887a4f78defSmrg ;; 8888a4f78defSmrg *) 8889a4f78defSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8890a4f78defSmrg ;; 8891a4f78defSmrg esac 8892a4f78defSmrg ;; 8893a4f78defSmrg 8894a4f78defSmrg freebsd-aout) 8895a4f78defSmrg major=.$current 8896a4f78defSmrg versuffix=.$current.$revision 8897a4f78defSmrg ;; 8898a4f78defSmrg 8899a4f78defSmrg freebsd-elf) 8900a4f78defSmrg func_arith $current - $age 8901a4f78defSmrg major=.$func_arith_result 8902a4f78defSmrg versuffix=$major.$age.$revision 8903a4f78defSmrg ;; 8904a4f78defSmrg 8905a4f78defSmrg irix | nonstopux) 8906a4f78defSmrg if test no = "$lt_irix_increment"; then 8907a4f78defSmrg func_arith $current - $age 8908a4f78defSmrg else 8909a4f78defSmrg func_arith $current - $age + 1 8910a4f78defSmrg fi 8911a4f78defSmrg major=$func_arith_result 8912a4f78defSmrg 8913a4f78defSmrg case $version_type in 8914a4f78defSmrg nonstopux) verstring_prefix=nonstopux ;; 8915a4f78defSmrg *) verstring_prefix=sgi ;; 8916a4f78defSmrg esac 8917a4f78defSmrg verstring=$verstring_prefix$major.$revision 8918a4f78defSmrg 8919a4f78defSmrg # Add in all the interfaces that we are compatible with. 8920a4f78defSmrg loop=$revision 8921a4f78defSmrg while test 0 -ne "$loop"; do 8922a4f78defSmrg func_arith $revision - $loop 8923a4f78defSmrg iface=$func_arith_result 8924a4f78defSmrg func_arith $loop - 1 8925a4f78defSmrg loop=$func_arith_result 8926a4f78defSmrg verstring=$verstring_prefix$major.$iface:$verstring 8927a4f78defSmrg done 8928a4f78defSmrg 8929a4f78defSmrg # Before this point, $major must not contain '.'. 8930a4f78defSmrg major=.$major 8931a4f78defSmrg versuffix=$major.$revision 8932a4f78defSmrg ;; 8933a4f78defSmrg 8934a4f78defSmrg linux) # correct to gnu/linux during the next big refactor 8935a4f78defSmrg func_arith $current - $age 8936a4f78defSmrg major=.$func_arith_result 8937a4f78defSmrg versuffix=$major.$age.$revision 8938a4f78defSmrg ;; 8939a4f78defSmrg 8940a4f78defSmrg osf) 8941a4f78defSmrg func_arith $current - $age 8942a4f78defSmrg major=.$func_arith_result 8943a4f78defSmrg versuffix=.$current.$age.$revision 8944a4f78defSmrg verstring=$current.$age.$revision 8945a4f78defSmrg 8946a4f78defSmrg # Add in all the interfaces that we are compatible with. 8947a4f78defSmrg loop=$age 8948a4f78defSmrg while test 0 -ne "$loop"; do 8949a4f78defSmrg func_arith $current - $loop 8950a4f78defSmrg iface=$func_arith_result 8951a4f78defSmrg func_arith $loop - 1 8952a4f78defSmrg loop=$func_arith_result 8953a4f78defSmrg verstring=$verstring:$iface.0 8954a4f78defSmrg done 8955a4f78defSmrg 8956a4f78defSmrg # Make executables depend on our current version. 8957a4f78defSmrg func_append verstring ":$current.0" 8958a4f78defSmrg ;; 8959a4f78defSmrg 8960a4f78defSmrg qnx) 8961a4f78defSmrg major=.$current 8962a4f78defSmrg versuffix=.$current 8963a4f78defSmrg ;; 8964a4f78defSmrg 8965a4f78defSmrg sco) 8966a4f78defSmrg major=.$current 8967a4f78defSmrg versuffix=.$current 8968a4f78defSmrg ;; 8969a4f78defSmrg 8970a4f78defSmrg sunos) 8971a4f78defSmrg major=.$current 8972a4f78defSmrg versuffix=.$current.$revision 8973a4f78defSmrg ;; 8974a4f78defSmrg 8975a4f78defSmrg windows) 8976a4f78defSmrg # Use '-' rather than '.', since we only want one 8977a4f78defSmrg # extension on DOS 8.3 file systems. 8978a4f78defSmrg func_arith $current - $age 8979a4f78defSmrg major=$func_arith_result 8980a4f78defSmrg versuffix=-$major 8981a4f78defSmrg ;; 8982a4f78defSmrg 8983a4f78defSmrg *) 8984a4f78defSmrg func_fatal_configuration "unknown library version type '$version_type'" 8985a4f78defSmrg ;; 8986a4f78defSmrg esac 8987a4f78defSmrg 8988a4f78defSmrg # Clear the version info if we defaulted, and they specified a release. 8989a4f78defSmrg if test -z "$vinfo" && test -n "$release"; then 8990a4f78defSmrg major= 8991a4f78defSmrg case $version_type in 8992a4f78defSmrg darwin) 8993a4f78defSmrg # we can't check for "0.0" in archive_cmds due to quoting 8994a4f78defSmrg # problems, so we reset it completely 8995a4f78defSmrg verstring= 8996a4f78defSmrg ;; 8997a4f78defSmrg *) 8998a4f78defSmrg verstring=0.0 8999a4f78defSmrg ;; 9000a4f78defSmrg esac 9001a4f78defSmrg if test no = "$need_version"; then 9002a4f78defSmrg versuffix= 9003a4f78defSmrg else 9004a4f78defSmrg versuffix=.0.0 9005a4f78defSmrg fi 9006a4f78defSmrg fi 9007a4f78defSmrg 9008a4f78defSmrg # Remove version info from name if versioning should be avoided 9009a4f78defSmrg if test yes,no = "$avoid_version,$need_version"; then 9010a4f78defSmrg major= 9011a4f78defSmrg versuffix= 9012a4f78defSmrg verstring= 9013a4f78defSmrg fi 9014a4f78defSmrg 9015a4f78defSmrg # Check to see if the archive will have undefined symbols. 9016a4f78defSmrg if test yes = "$allow_undefined"; then 9017a4f78defSmrg if test unsupported = "$allow_undefined_flag"; then 9018a4f78defSmrg if test yes = "$build_old_libs"; then 9019a4f78defSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9020a4f78defSmrg build_libtool_libs=no 9021a4f78defSmrg else 9022a4f78defSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9023a4f78defSmrg fi 9024a4f78defSmrg fi 9025a4f78defSmrg else 9026a4f78defSmrg # Don't allow undefined symbols. 9027a4f78defSmrg allow_undefined_flag=$no_undefined_flag 9028a4f78defSmrg fi 9029a4f78defSmrg 9030a4f78defSmrg fi 9031a4f78defSmrg 9032a4f78defSmrg func_generate_dlsyms "$libname" "$libname" : 9033a4f78defSmrg func_append libobjs " $symfileobj" 9034a4f78defSmrg test " " = "$libobjs" && libobjs= 9035a4f78defSmrg 9036a4f78defSmrg if test relink != "$opt_mode"; then 9037a4f78defSmrg # Remove our outputs, but don't remove object files since they 9038a4f78defSmrg # may have been created when compiling PIC objects. 9039a4f78defSmrg removelist= 9040a4f78defSmrg tempremovelist=`$ECHO "$output_objdir/*"` 9041a4f78defSmrg for p in $tempremovelist; do 9042a4f78defSmrg case $p in 9043a4f78defSmrg *.$objext | *.gcno) 9044a4f78defSmrg ;; 9045a4f78defSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9046a4f78defSmrg if test -n "$precious_files_regex"; then 9047a4f78defSmrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9048a4f78defSmrg then 9049a4f78defSmrg continue 9050a4f78defSmrg fi 9051a4f78defSmrg fi 9052a4f78defSmrg func_append removelist " $p" 9053a4f78defSmrg ;; 9054a4f78defSmrg *) ;; 9055a4f78defSmrg esac 9056a4f78defSmrg done 9057a4f78defSmrg test -n "$removelist" && \ 9058a4f78defSmrg func_show_eval "${RM}r \$removelist" 9059a4f78defSmrg fi 9060a4f78defSmrg 9061a4f78defSmrg # Now set the variables for building old libraries. 9062a4f78defSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9063a4f78defSmrg func_append oldlibs " $output_objdir/$libname.$libext" 9064a4f78defSmrg 9065a4f78defSmrg # Transform .lo files to .o files. 9066a4f78defSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9067a4f78defSmrg fi 9068a4f78defSmrg 9069a4f78defSmrg # Eliminate all temporary directories. 9070a4f78defSmrg #for path in $notinst_path; do 9071a4f78defSmrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9072a4f78defSmrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9073a4f78defSmrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9074a4f78defSmrg #done 9075a4f78defSmrg 9076a4f78defSmrg if test -n "$xrpath"; then 9077a4f78defSmrg # If the user specified any rpath flags, then add them. 9078a4f78defSmrg temp_xrpath= 9079a4f78defSmrg for libdir in $xrpath; do 9080a4f78defSmrg func_replace_sysroot "$libdir" 9081a4f78defSmrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9082a4f78defSmrg case "$finalize_rpath " in 9083a4f78defSmrg *" $libdir "*) ;; 9084a4f78defSmrg *) func_append finalize_rpath " $libdir" ;; 9085a4f78defSmrg esac 9086a4f78defSmrg done 9087a4f78defSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9088a4f78defSmrg dependency_libs="$temp_xrpath $dependency_libs" 9089a4f78defSmrg fi 9090a4f78defSmrg fi 9091a4f78defSmrg 9092a4f78defSmrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9093a4f78defSmrg old_dlfiles=$dlfiles 9094a4f78defSmrg dlfiles= 9095a4f78defSmrg for lib in $old_dlfiles; do 9096a4f78defSmrg case " $dlprefiles $dlfiles " in 9097a4f78defSmrg *" $lib "*) ;; 9098a4f78defSmrg *) func_append dlfiles " $lib" ;; 9099a4f78defSmrg esac 9100a4f78defSmrg done 9101a4f78defSmrg 9102a4f78defSmrg # Make sure dlprefiles contains only unique files 9103a4f78defSmrg old_dlprefiles=$dlprefiles 9104a4f78defSmrg dlprefiles= 9105a4f78defSmrg for lib in $old_dlprefiles; do 9106a4f78defSmrg case "$dlprefiles " in 9107a4f78defSmrg *" $lib "*) ;; 9108a4f78defSmrg *) func_append dlprefiles " $lib" ;; 9109a4f78defSmrg esac 9110a4f78defSmrg done 9111a4f78defSmrg 9112a4f78defSmrg if test yes = "$build_libtool_libs"; then 9113a4f78defSmrg if test -n "$rpath"; then 9114a4f78defSmrg case $host in 9115a4f78defSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9116a4f78defSmrg # these systems don't actually have a c library (as such)! 9117a4f78defSmrg ;; 9118a4f78defSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9119a4f78defSmrg # Rhapsody C library is in the System framework 9120a4f78defSmrg func_append deplibs " System.ltframework" 9121a4f78defSmrg ;; 9122a4f78defSmrg *-*-netbsd*) 9123a4f78defSmrg # Don't link with libc until the a.out ld.so is fixed. 9124a4f78defSmrg ;; 9125a4f78defSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 9126a4f78defSmrg # Do not include libc due to us having libc/libc_r. 9127a4f78defSmrg ;; 9128a4f78defSmrg *-*-sco3.2v5* | *-*-sco5v6*) 9129a4f78defSmrg # Causes problems with __ctype 9130a4f78defSmrg ;; 9131a4f78defSmrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9132a4f78defSmrg # Compiler inserts libc in the correct place for threads to work 9133a4f78defSmrg ;; 9134a4f78defSmrg *) 9135a4f78defSmrg # Add libc to deplibs on all other systems if necessary. 9136a4f78defSmrg if test yes = "$build_libtool_need_lc"; then 9137a4f78defSmrg func_append deplibs " -lc" 9138a4f78defSmrg fi 9139a4f78defSmrg ;; 9140a4f78defSmrg esac 9141a4f78defSmrg fi 9142a4f78defSmrg 9143a4f78defSmrg # Transform deplibs into only deplibs that can be linked in shared. 9144a4f78defSmrg name_save=$name 9145a4f78defSmrg libname_save=$libname 9146a4f78defSmrg release_save=$release 9147a4f78defSmrg versuffix_save=$versuffix 9148a4f78defSmrg major_save=$major 9149a4f78defSmrg # I'm not sure if I'm treating the release correctly. I think 9150a4f78defSmrg # release should show up in the -l (ie -lgmp5) so we don't want to 9151a4f78defSmrg # add it in twice. Is that correct? 9152a4f78defSmrg release= 9153a4f78defSmrg versuffix= 9154a4f78defSmrg major= 9155a4f78defSmrg newdeplibs= 9156a4f78defSmrg droppeddeps=no 9157a4f78defSmrg case $deplibs_check_method in 9158a4f78defSmrg pass_all) 9159a4f78defSmrg # Don't check for shared/static. Everything works. 9160a4f78defSmrg # This might be a little naive. We might want to check 9161a4f78defSmrg # whether the library exists or not. But this is on 9162a4f78defSmrg # osf3 & osf4 and I'm not really sure... Just 9163a4f78defSmrg # implementing what was already the behavior. 9164a4f78defSmrg newdeplibs=$deplibs 9165a4f78defSmrg ;; 9166a4f78defSmrg test_compile) 9167a4f78defSmrg # This code stresses the "libraries are programs" paradigm to its 9168a4f78defSmrg # limits. Maybe even breaks it. We compile a program, linking it 9169a4f78defSmrg # against the deplibs as a proxy for the library. Then we can check 9170a4f78defSmrg # whether they linked in statically or dynamically with ldd. 9171a4f78defSmrg $opt_dry_run || $RM conftest.c 9172a4f78defSmrg cat > conftest.c <<EOF 9173a4f78defSmrg int main() { return 0; } 9174a4f78defSmrgEOF 9175a4f78defSmrg $opt_dry_run || $RM conftest 9176a4f78defSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9177a4f78defSmrg ldd_output=`ldd conftest` 9178a4f78defSmrg for i in $deplibs; do 9179a4f78defSmrg case $i in 9180a4f78defSmrg -l*) 9181a4f78defSmrg func_stripname -l '' "$i" 9182a4f78defSmrg name=$func_stripname_result 9183a4f78defSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9184a4f78defSmrg case " $predeps $postdeps " in 9185a4f78defSmrg *" $i "*) 9186a4f78defSmrg func_append newdeplibs " $i" 9187a4f78defSmrg i= 9188a4f78defSmrg ;; 9189a4f78defSmrg esac 9190a4f78defSmrg fi 9191a4f78defSmrg if test -n "$i"; then 9192a4f78defSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9193a4f78defSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9194a4f78defSmrg set dummy $deplib_matches; shift 9195a4f78defSmrg deplib_match=$1 9196a4f78defSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9197a4f78defSmrg func_append newdeplibs " $i" 9198a4f78defSmrg else 9199a4f78defSmrg droppeddeps=yes 9200a4f78defSmrg echo 9201a4f78defSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9202a4f78defSmrg echo "*** I have the capability to make that library automatically link in when" 9203a4f78defSmrg echo "*** you link to this library. But I can only do this if you have a" 9204a4f78defSmrg echo "*** shared version of the library, which I believe you do not have" 9205a4f78defSmrg echo "*** because a test_compile did reveal that the linker did not use it for" 9206a4f78defSmrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9207a4f78defSmrg fi 9208a4f78defSmrg fi 9209a4f78defSmrg ;; 9210a4f78defSmrg *) 9211a4f78defSmrg func_append newdeplibs " $i" 9212a4f78defSmrg ;; 9213a4f78defSmrg esac 9214a4f78defSmrg done 9215a4f78defSmrg else 9216a4f78defSmrg # Error occurred in the first compile. Let's try to salvage 9217a4f78defSmrg # the situation: Compile a separate program for each library. 9218a4f78defSmrg for i in $deplibs; do 9219a4f78defSmrg case $i in 9220a4f78defSmrg -l*) 9221a4f78defSmrg func_stripname -l '' "$i" 9222a4f78defSmrg name=$func_stripname_result 9223a4f78defSmrg $opt_dry_run || $RM conftest 9224a4f78defSmrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9225a4f78defSmrg ldd_output=`ldd conftest` 9226a4f78defSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9227a4f78defSmrg case " $predeps $postdeps " in 9228a4f78defSmrg *" $i "*) 9229a4f78defSmrg func_append newdeplibs " $i" 9230a4f78defSmrg i= 9231a4f78defSmrg ;; 9232a4f78defSmrg esac 9233a4f78defSmrg fi 9234a4f78defSmrg if test -n "$i"; then 9235a4f78defSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9236a4f78defSmrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9237a4f78defSmrg set dummy $deplib_matches; shift 9238a4f78defSmrg deplib_match=$1 9239a4f78defSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9240a4f78defSmrg func_append newdeplibs " $i" 9241a4f78defSmrg else 9242a4f78defSmrg droppeddeps=yes 9243a4f78defSmrg echo 9244a4f78defSmrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9245a4f78defSmrg echo "*** I have the capability to make that library automatically link in when" 9246a4f78defSmrg echo "*** you link to this library. But I can only do this if you have a" 9247a4f78defSmrg echo "*** shared version of the library, which you do not appear to have" 9248a4f78defSmrg echo "*** because a test_compile did reveal that the linker did not use this one" 9249a4f78defSmrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9250a4f78defSmrg fi 9251a4f78defSmrg fi 9252a4f78defSmrg else 9253a4f78defSmrg droppeddeps=yes 9254a4f78defSmrg echo 9255a4f78defSmrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9256a4f78defSmrg echo "*** make it link in! You will probably need to install it or some" 9257a4f78defSmrg echo "*** library that it depends on before this library will be fully" 9258a4f78defSmrg echo "*** functional. Installing it before continuing would be even better." 9259a4f78defSmrg fi 9260a4f78defSmrg ;; 9261a4f78defSmrg *) 9262a4f78defSmrg func_append newdeplibs " $i" 9263a4f78defSmrg ;; 9264a4f78defSmrg esac 9265a4f78defSmrg done 9266a4f78defSmrg fi 9267a4f78defSmrg ;; 9268a4f78defSmrg file_magic*) 9269a4f78defSmrg set dummy $deplibs_check_method; shift 9270a4f78defSmrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9271a4f78defSmrg for a_deplib in $deplibs; do 9272a4f78defSmrg case $a_deplib in 9273a4f78defSmrg -l*) 9274a4f78defSmrg func_stripname -l '' "$a_deplib" 9275a4f78defSmrg name=$func_stripname_result 9276a4f78defSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9277a4f78defSmrg case " $predeps $postdeps " in 9278a4f78defSmrg *" $a_deplib "*) 9279a4f78defSmrg func_append newdeplibs " $a_deplib" 9280a4f78defSmrg a_deplib= 9281a4f78defSmrg ;; 9282a4f78defSmrg esac 9283a4f78defSmrg fi 9284a4f78defSmrg if test -n "$a_deplib"; then 9285a4f78defSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9286a4f78defSmrg if test -n "$file_magic_glob"; then 9287a4f78defSmrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9288a4f78defSmrg else 9289a4f78defSmrg libnameglob=$libname 9290a4f78defSmrg fi 9291a4f78defSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9292a4f78defSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9293a4f78defSmrg if test yes = "$want_nocaseglob"; then 9294a4f78defSmrg shopt -s nocaseglob 9295a4f78defSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9296a4f78defSmrg $nocaseglob 9297a4f78defSmrg else 9298a4f78defSmrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9299a4f78defSmrg fi 9300a4f78defSmrg for potent_lib in $potential_libs; do 9301a4f78defSmrg # Follow soft links. 9302a4f78defSmrg if ls -lLd "$potent_lib" 2>/dev/null | 9303a4f78defSmrg $GREP " -> " >/dev/null; then 9304a4f78defSmrg continue 9305a4f78defSmrg fi 9306a4f78defSmrg # The statement above tries to avoid entering an 9307a4f78defSmrg # endless loop below, in case of cyclic links. 9308a4f78defSmrg # We might still enter an endless loop, since a link 9309a4f78defSmrg # loop can be closed while we follow links, 9310a4f78defSmrg # but so what? 9311a4f78defSmrg potlib=$potent_lib 9312a4f78defSmrg while test -h "$potlib" 2>/dev/null; do 9313a4f78defSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9314a4f78defSmrg case $potliblink in 9315a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9316a4f78defSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9317a4f78defSmrg esac 9318a4f78defSmrg done 9319a4f78defSmrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9320a4f78defSmrg $SED -e 10q | 9321a4f78defSmrg $EGREP "$file_magic_regex" > /dev/null; then 9322a4f78defSmrg func_append newdeplibs " $a_deplib" 9323a4f78defSmrg a_deplib= 9324a4f78defSmrg break 2 9325a4f78defSmrg fi 9326a4f78defSmrg done 9327a4f78defSmrg done 9328a4f78defSmrg fi 9329a4f78defSmrg if test -n "$a_deplib"; then 9330a4f78defSmrg droppeddeps=yes 9331a4f78defSmrg echo 9332a4f78defSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9333a4f78defSmrg echo "*** I have the capability to make that library automatically link in when" 9334a4f78defSmrg echo "*** you link to this library. But I can only do this if you have a" 9335a4f78defSmrg echo "*** shared version of the library, which you do not appear to have" 9336a4f78defSmrg echo "*** because I did check the linker path looking for a file starting" 9337a4f78defSmrg if test -z "$potlib"; then 9338a4f78defSmrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9339a4f78defSmrg else 9340a4f78defSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9341a4f78defSmrg $ECHO "*** using a file magic. Last file checked: $potlib" 9342a4f78defSmrg fi 9343a4f78defSmrg fi 9344a4f78defSmrg ;; 9345a4f78defSmrg *) 9346a4f78defSmrg # Add a -L argument. 9347a4f78defSmrg func_append newdeplibs " $a_deplib" 9348a4f78defSmrg ;; 9349a4f78defSmrg esac 9350a4f78defSmrg done # Gone through all deplibs. 9351a4f78defSmrg ;; 9352a4f78defSmrg match_pattern*) 9353a4f78defSmrg set dummy $deplibs_check_method; shift 9354a4f78defSmrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9355a4f78defSmrg for a_deplib in $deplibs; do 9356a4f78defSmrg case $a_deplib in 9357a4f78defSmrg -l*) 9358a4f78defSmrg func_stripname -l '' "$a_deplib" 9359a4f78defSmrg name=$func_stripname_result 9360a4f78defSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9361a4f78defSmrg case " $predeps $postdeps " in 9362a4f78defSmrg *" $a_deplib "*) 9363a4f78defSmrg func_append newdeplibs " $a_deplib" 9364a4f78defSmrg a_deplib= 9365a4f78defSmrg ;; 9366a4f78defSmrg esac 9367a4f78defSmrg fi 9368a4f78defSmrg if test -n "$a_deplib"; then 9369a4f78defSmrg libname=`eval "\\$ECHO \"$libname_spec\""` 9370a4f78defSmrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9371a4f78defSmrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9372a4f78defSmrg for potent_lib in $potential_libs; do 9373a4f78defSmrg potlib=$potent_lib # see symlink-check above in file_magic test 9374a4f78defSmrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9375a4f78defSmrg $EGREP "$match_pattern_regex" > /dev/null; then 9376a4f78defSmrg func_append newdeplibs " $a_deplib" 9377a4f78defSmrg a_deplib= 9378a4f78defSmrg break 2 9379a4f78defSmrg fi 9380a4f78defSmrg done 9381a4f78defSmrg done 9382a4f78defSmrg fi 9383a4f78defSmrg if test -n "$a_deplib"; then 9384a4f78defSmrg droppeddeps=yes 9385a4f78defSmrg echo 9386a4f78defSmrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9387a4f78defSmrg echo "*** I have the capability to make that library automatically link in when" 9388a4f78defSmrg echo "*** you link to this library. But I can only do this if you have a" 9389a4f78defSmrg echo "*** shared version of the library, which you do not appear to have" 9390a4f78defSmrg echo "*** because I did check the linker path looking for a file starting" 9391a4f78defSmrg if test -z "$potlib"; then 9392a4f78defSmrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9393a4f78defSmrg else 9394a4f78defSmrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9395a4f78defSmrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9396a4f78defSmrg fi 9397a4f78defSmrg fi 9398a4f78defSmrg ;; 9399a4f78defSmrg *) 9400a4f78defSmrg # Add a -L argument. 9401a4f78defSmrg func_append newdeplibs " $a_deplib" 9402a4f78defSmrg ;; 9403a4f78defSmrg esac 9404a4f78defSmrg done # Gone through all deplibs. 9405a4f78defSmrg ;; 9406a4f78defSmrg none | unknown | *) 9407a4f78defSmrg newdeplibs= 9408a4f78defSmrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9409a4f78defSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9410a4f78defSmrg for i in $predeps $postdeps; do 9411a4f78defSmrg # can't use Xsed below, because $i might contain '/' 9412a4f78defSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9413a4f78defSmrg done 9414a4f78defSmrg fi 9415a4f78defSmrg case $tmp_deplibs in 9416a4f78defSmrg *[!\ \ ]*) 9417a4f78defSmrg echo 9418a4f78defSmrg if test none = "$deplibs_check_method"; then 9419a4f78defSmrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9420a4f78defSmrg else 9421a4f78defSmrg echo "*** Warning: inter-library dependencies are not known to be supported." 9422a4f78defSmrg fi 9423a4f78defSmrg echo "*** All declared inter-library dependencies are being dropped." 9424a4f78defSmrg droppeddeps=yes 9425a4f78defSmrg ;; 9426a4f78defSmrg esac 9427a4f78defSmrg ;; 9428a4f78defSmrg esac 9429a4f78defSmrg versuffix=$versuffix_save 9430a4f78defSmrg major=$major_save 9431a4f78defSmrg release=$release_save 9432a4f78defSmrg libname=$libname_save 9433a4f78defSmrg name=$name_save 9434a4f78defSmrg 9435a4f78defSmrg case $host in 9436a4f78defSmrg *-*-rhapsody* | *-*-darwin1.[012]) 9437a4f78defSmrg # On Rhapsody replace the C library with the System framework 9438a4f78defSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9439a4f78defSmrg ;; 9440a4f78defSmrg esac 9441a4f78defSmrg 9442a4f78defSmrg if test yes = "$droppeddeps"; then 9443a4f78defSmrg if test yes = "$module"; then 9444a4f78defSmrg echo 9445a4f78defSmrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9446a4f78defSmrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9447a4f78defSmrg echo "*** a static module, that should work as long as the dlopening" 9448a4f78defSmrg echo "*** application is linked with the -dlopen flag." 9449a4f78defSmrg if test -z "$global_symbol_pipe"; then 9450a4f78defSmrg echo 9451a4f78defSmrg echo "*** However, this would only work if libtool was able to extract symbol" 9452a4f78defSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9453a4f78defSmrg echo "*** not find such a program. So, this module is probably useless." 9454a4f78defSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9455a4f78defSmrg fi 9456a4f78defSmrg if test no = "$build_old_libs"; then 9457a4f78defSmrg oldlibs=$output_objdir/$libname.$libext 9458a4f78defSmrg build_libtool_libs=module 9459a4f78defSmrg build_old_libs=yes 9460a4f78defSmrg else 9461a4f78defSmrg build_libtool_libs=no 9462a4f78defSmrg fi 9463a4f78defSmrg else 9464a4f78defSmrg echo "*** The inter-library dependencies that have been dropped here will be" 9465a4f78defSmrg echo "*** automatically added whenever a program is linked with this library" 9466a4f78defSmrg echo "*** or is declared to -dlopen it." 9467a4f78defSmrg 9468a4f78defSmrg if test no = "$allow_undefined"; then 9469a4f78defSmrg echo 9470a4f78defSmrg echo "*** Since this library must not contain undefined symbols," 9471a4f78defSmrg echo "*** because either the platform does not support them or" 9472a4f78defSmrg echo "*** it was explicitly requested with -no-undefined," 9473a4f78defSmrg echo "*** libtool will only create a static version of it." 9474a4f78defSmrg if test no = "$build_old_libs"; then 9475a4f78defSmrg oldlibs=$output_objdir/$libname.$libext 9476a4f78defSmrg build_libtool_libs=module 9477a4f78defSmrg build_old_libs=yes 9478a4f78defSmrg else 9479a4f78defSmrg build_libtool_libs=no 9480a4f78defSmrg fi 9481a4f78defSmrg fi 9482a4f78defSmrg fi 9483a4f78defSmrg fi 9484a4f78defSmrg # Done checking deplibs! 9485a4f78defSmrg deplibs=$newdeplibs 9486a4f78defSmrg fi 9487a4f78defSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9488a4f78defSmrg case $host in 9489a4f78defSmrg *-*-darwin*) 9490a4f78defSmrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9491a4f78defSmrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9492a4f78defSmrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9493a4f78defSmrg ;; 9494a4f78defSmrg esac 9495a4f78defSmrg 9496a4f78defSmrg # move library search paths that coincide with paths to not yet 9497a4f78defSmrg # installed libraries to the beginning of the library search list 9498a4f78defSmrg new_libs= 9499a4f78defSmrg for path in $notinst_path; do 9500a4f78defSmrg case " $new_libs " in 9501a4f78defSmrg *" -L$path/$objdir "*) ;; 9502a4f78defSmrg *) 9503a4f78defSmrg case " $deplibs " in 9504a4f78defSmrg *" -L$path/$objdir "*) 9505a4f78defSmrg func_append new_libs " -L$path/$objdir" ;; 9506a4f78defSmrg esac 9507a4f78defSmrg ;; 9508a4f78defSmrg esac 9509a4f78defSmrg done 9510a4f78defSmrg for deplib in $deplibs; do 9511a4f78defSmrg case $deplib in 9512a4f78defSmrg -L*) 9513a4f78defSmrg case " $new_libs " in 9514a4f78defSmrg *" $deplib "*) ;; 9515a4f78defSmrg *) func_append new_libs " $deplib" ;; 9516a4f78defSmrg esac 9517a4f78defSmrg ;; 9518a4f78defSmrg *) func_append new_libs " $deplib" ;; 9519a4f78defSmrg esac 9520a4f78defSmrg done 9521a4f78defSmrg deplibs=$new_libs 9522a4f78defSmrg 9523a4f78defSmrg # All the library-specific variables (install_libdir is set above). 9524a4f78defSmrg library_names= 9525a4f78defSmrg old_library= 9526a4f78defSmrg dlname= 9527a4f78defSmrg 9528a4f78defSmrg # Test again, we may have decided not to build it any more 9529a4f78defSmrg if test yes = "$build_libtool_libs"; then 9530a4f78defSmrg # Remove $wl instances when linking with ld. 9531a4f78defSmrg # FIXME: should test the right _cmds variable. 9532a4f78defSmrg case $archive_cmds in 9533a4f78defSmrg *\$LD\ *) wl= ;; 9534a4f78defSmrg esac 9535a4f78defSmrg if test yes = "$hardcode_into_libs"; then 9536a4f78defSmrg # Hardcode the library paths 9537a4f78defSmrg hardcode_libdirs= 9538a4f78defSmrg dep_rpath= 9539a4f78defSmrg rpath=$finalize_rpath 9540a4f78defSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9541a4f78defSmrg for libdir in $rpath; do 9542a4f78defSmrg if test -n "$hardcode_libdir_flag_spec"; then 9543a4f78defSmrg if test -n "$hardcode_libdir_separator"; then 9544a4f78defSmrg func_replace_sysroot "$libdir" 9545a4f78defSmrg libdir=$func_replace_sysroot_result 9546a4f78defSmrg if test -z "$hardcode_libdirs"; then 9547a4f78defSmrg hardcode_libdirs=$libdir 9548a4f78defSmrg else 9549a4f78defSmrg # Just accumulate the unique libdirs. 9550a4f78defSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9551a4f78defSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9552a4f78defSmrg ;; 9553a4f78defSmrg *) 9554a4f78defSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9555a4f78defSmrg ;; 9556a4f78defSmrg esac 9557a4f78defSmrg fi 9558a4f78defSmrg else 9559a4f78defSmrg eval flag=\"$hardcode_libdir_flag_spec\" 9560a4f78defSmrg func_append dep_rpath " $flag" 9561a4f78defSmrg fi 9562a4f78defSmrg elif test -n "$runpath_var"; then 9563a4f78defSmrg case "$perm_rpath " in 9564a4f78defSmrg *" $libdir "*) ;; 9565a4f78defSmrg *) func_append perm_rpath " $libdir" ;; 9566a4f78defSmrg esac 9567a4f78defSmrg fi 9568a4f78defSmrg done 9569a4f78defSmrg # Substitute the hardcoded libdirs into the rpath. 9570a4f78defSmrg if test -n "$hardcode_libdir_separator" && 9571a4f78defSmrg test -n "$hardcode_libdirs"; then 9572a4f78defSmrg libdir=$hardcode_libdirs 9573a4f78defSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9574a4f78defSmrg fi 9575a4f78defSmrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9576a4f78defSmrg # We should set the runpath_var. 9577a4f78defSmrg rpath= 9578a4f78defSmrg for dir in $perm_rpath; do 9579a4f78defSmrg func_append rpath "$dir:" 9580a4f78defSmrg done 9581a4f78defSmrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9582a4f78defSmrg fi 9583a4f78defSmrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9584a4f78defSmrg fi 9585a4f78defSmrg 9586a4f78defSmrg shlibpath=$finalize_shlibpath 9587a4f78defSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9588a4f78defSmrg if test -n "$shlibpath"; then 9589a4f78defSmrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9590a4f78defSmrg fi 9591a4f78defSmrg 9592a4f78defSmrg # Get the real and link names of the library. 9593a4f78defSmrg eval shared_ext=\"$shrext_cmds\" 9594a4f78defSmrg eval library_names=\"$library_names_spec\" 9595a4f78defSmrg set dummy $library_names 9596a4f78defSmrg shift 9597a4f78defSmrg realname=$1 9598a4f78defSmrg shift 9599a4f78defSmrg 9600a4f78defSmrg if test -n "$soname_spec"; then 9601a4f78defSmrg eval soname=\"$soname_spec\" 9602a4f78defSmrg else 9603a4f78defSmrg soname=$realname 9604a4f78defSmrg fi 9605a4f78defSmrg if test -z "$dlname"; then 9606a4f78defSmrg dlname=$soname 9607a4f78defSmrg fi 9608a4f78defSmrg 9609a4f78defSmrg lib=$output_objdir/$realname 9610a4f78defSmrg linknames= 9611a4f78defSmrg for link 9612a4f78defSmrg do 9613a4f78defSmrg func_append linknames " $link" 9614a4f78defSmrg done 9615a4f78defSmrg 9616a4f78defSmrg # Use standard objects if they are pic 9617a4f78defSmrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9618a4f78defSmrg test "X$libobjs" = "X " && libobjs= 9619a4f78defSmrg 9620a4f78defSmrg delfiles= 9621a4f78defSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9622a4f78defSmrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9623a4f78defSmrg export_symbols=$output_objdir/$libname.uexp 9624a4f78defSmrg func_append delfiles " $export_symbols" 9625a4f78defSmrg fi 9626a4f78defSmrg 9627a4f78defSmrg orig_export_symbols= 9628a4f78defSmrg case $host_os in 9629a4f78defSmrg cygwin* | mingw* | cegcc*) 9630a4f78defSmrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9631a4f78defSmrg # exporting using user supplied symfile 9632a4f78defSmrg func_dll_def_p "$export_symbols" || { 9633a4f78defSmrg # and it's NOT already a .def file. Must figure out 9634a4f78defSmrg # which of the given symbols are data symbols and tag 9635a4f78defSmrg # them as such. So, trigger use of export_symbols_cmds. 9636a4f78defSmrg # export_symbols gets reassigned inside the "prepare 9637a4f78defSmrg # the list of exported symbols" if statement, so the 9638a4f78defSmrg # include_expsyms logic still works. 9639a4f78defSmrg orig_export_symbols=$export_symbols 9640a4f78defSmrg export_symbols= 9641a4f78defSmrg always_export_symbols=yes 9642a4f78defSmrg } 9643a4f78defSmrg fi 9644a4f78defSmrg ;; 9645a4f78defSmrg esac 9646a4f78defSmrg 9647a4f78defSmrg # Prepare the list of exported symbols 9648a4f78defSmrg if test -z "$export_symbols"; then 9649a4f78defSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9650a4f78defSmrg func_verbose "generating symbol list for '$libname.la'" 9651a4f78defSmrg export_symbols=$output_objdir/$libname.exp 9652a4f78defSmrg $opt_dry_run || $RM $export_symbols 9653a4f78defSmrg cmds=$export_symbols_cmds 9654a4f78defSmrg save_ifs=$IFS; IFS='~' 9655a4f78defSmrg for cmd1 in $cmds; do 9656a4f78defSmrg IFS=$save_ifs 9657a4f78defSmrg # Take the normal branch if the nm_file_list_spec branch 9658a4f78defSmrg # doesn't work or if tool conversion is not needed. 9659a4f78defSmrg case $nm_file_list_spec~$to_tool_file_cmd in 9660a4f78defSmrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9661a4f78defSmrg try_normal_branch=yes 9662a4f78defSmrg eval cmd=\"$cmd1\" 9663a4f78defSmrg func_len " $cmd" 9664a4f78defSmrg len=$func_len_result 9665a4f78defSmrg ;; 9666a4f78defSmrg *) 9667a4f78defSmrg try_normal_branch=no 9668a4f78defSmrg ;; 9669a4f78defSmrg esac 9670a4f78defSmrg if test yes = "$try_normal_branch" \ 9671a4f78defSmrg && { test "$len" -lt "$max_cmd_len" \ 9672a4f78defSmrg || test "$max_cmd_len" -le -1; } 9673a4f78defSmrg then 9674a4f78defSmrg func_show_eval "$cmd" 'exit $?' 9675a4f78defSmrg skipped_export=false 9676a4f78defSmrg elif test -n "$nm_file_list_spec"; then 9677a4f78defSmrg func_basename "$output" 9678a4f78defSmrg output_la=$func_basename_result 9679a4f78defSmrg save_libobjs=$libobjs 9680a4f78defSmrg save_output=$output 9681a4f78defSmrg output=$output_objdir/$output_la.nm 9682a4f78defSmrg func_to_tool_file "$output" 9683a4f78defSmrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9684a4f78defSmrg func_append delfiles " $output" 9685a4f78defSmrg func_verbose "creating $NM input file list: $output" 9686a4f78defSmrg for obj in $save_libobjs; do 9687a4f78defSmrg func_to_tool_file "$obj" 9688a4f78defSmrg $ECHO "$func_to_tool_file_result" 9689a4f78defSmrg done > "$output" 9690a4f78defSmrg eval cmd=\"$cmd1\" 9691a4f78defSmrg func_show_eval "$cmd" 'exit $?' 9692a4f78defSmrg output=$save_output 9693a4f78defSmrg libobjs=$save_libobjs 9694a4f78defSmrg skipped_export=false 9695a4f78defSmrg else 9696a4f78defSmrg # The command line is too long to execute in one step. 9697a4f78defSmrg func_verbose "using reloadable object file for export list..." 9698a4f78defSmrg skipped_export=: 9699a4f78defSmrg # Break out early, otherwise skipped_export may be 9700a4f78defSmrg # set to false by a later but shorter cmd. 9701a4f78defSmrg break 9702a4f78defSmrg fi 9703a4f78defSmrg done 9704a4f78defSmrg IFS=$save_ifs 9705a4f78defSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9706a4f78defSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9707a4f78defSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9708a4f78defSmrg fi 9709a4f78defSmrg fi 9710a4f78defSmrg fi 9711a4f78defSmrg 9712a4f78defSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9713a4f78defSmrg tmp_export_symbols=$export_symbols 9714a4f78defSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9715a4f78defSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9716a4f78defSmrg fi 9717a4f78defSmrg 9718a4f78defSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 9719a4f78defSmrg # The given exports_symbols file has to be filtered, so filter it. 9720a4f78defSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9721a4f78defSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9722a4f78defSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9723a4f78defSmrg # though. Also, the filter scales superlinearly with the number of 9724a4f78defSmrg # global variables. join(1) would be nice here, but unfortunately 9725a4f78defSmrg # isn't a blessed tool. 9726a4f78defSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9727a4f78defSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9728a4f78defSmrg export_symbols=$output_objdir/$libname.def 9729a4f78defSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9730a4f78defSmrg fi 9731a4f78defSmrg 9732a4f78defSmrg tmp_deplibs= 9733a4f78defSmrg for test_deplib in $deplibs; do 9734a4f78defSmrg case " $convenience " in 9735a4f78defSmrg *" $test_deplib "*) ;; 9736a4f78defSmrg *) 9737a4f78defSmrg func_append tmp_deplibs " $test_deplib" 9738a4f78defSmrg ;; 9739a4f78defSmrg esac 9740a4f78defSmrg done 9741a4f78defSmrg deplibs=$tmp_deplibs 9742a4f78defSmrg 9743a4f78defSmrg if test -n "$convenience"; then 9744a4f78defSmrg if test -n "$whole_archive_flag_spec" && 9745a4f78defSmrg test yes = "$compiler_needs_object" && 9746a4f78defSmrg test -z "$libobjs"; then 9747a4f78defSmrg # extract the archives, so we have objects to list. 9748a4f78defSmrg # TODO: could optimize this to just extract one archive. 9749a4f78defSmrg whole_archive_flag_spec= 9750a4f78defSmrg fi 9751a4f78defSmrg if test -n "$whole_archive_flag_spec"; then 9752a4f78defSmrg save_libobjs=$libobjs 9753a4f78defSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9754a4f78defSmrg test "X$libobjs" = "X " && libobjs= 9755a4f78defSmrg else 9756a4f78defSmrg gentop=$output_objdir/${outputname}x 9757a4f78defSmrg func_append generated " $gentop" 9758a4f78defSmrg 9759a4f78defSmrg func_extract_archives $gentop $convenience 9760a4f78defSmrg func_append libobjs " $func_extract_archives_result" 9761a4f78defSmrg test "X$libobjs" = "X " && libobjs= 9762a4f78defSmrg fi 9763a4f78defSmrg fi 9764a4f78defSmrg 9765a4f78defSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 9766a4f78defSmrg eval flag=\"$thread_safe_flag_spec\" 9767a4f78defSmrg func_append linker_flags " $flag" 9768a4f78defSmrg fi 9769a4f78defSmrg 9770a4f78defSmrg # Make a backup of the uninstalled library when relinking 9771a4f78defSmrg if test relink = "$opt_mode"; then 9772a4f78defSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9773a4f78defSmrg fi 9774a4f78defSmrg 9775a4f78defSmrg # Do each of the archive commands. 9776a4f78defSmrg if test yes = "$module" && test -n "$module_cmds"; then 9777a4f78defSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9778a4f78defSmrg eval test_cmds=\"$module_expsym_cmds\" 9779a4f78defSmrg cmds=$module_expsym_cmds 9780a4f78defSmrg else 9781a4f78defSmrg eval test_cmds=\"$module_cmds\" 9782a4f78defSmrg cmds=$module_cmds 9783a4f78defSmrg fi 9784a4f78defSmrg else 9785a4f78defSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 9786a4f78defSmrg eval test_cmds=\"$archive_expsym_cmds\" 9787a4f78defSmrg cmds=$archive_expsym_cmds 9788a4f78defSmrg else 9789a4f78defSmrg eval test_cmds=\"$archive_cmds\" 9790a4f78defSmrg cmds=$archive_cmds 9791a4f78defSmrg fi 9792a4f78defSmrg fi 9793a4f78defSmrg 9794a4f78defSmrg if test : != "$skipped_export" && 9795a4f78defSmrg func_len " $test_cmds" && 9796a4f78defSmrg len=$func_len_result && 9797a4f78defSmrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9798a4f78defSmrg : 9799a4f78defSmrg else 9800a4f78defSmrg # The command line is too long to link in one step, link piecewise 9801a4f78defSmrg # or, if using GNU ld and skipped_export is not :, use a linker 9802a4f78defSmrg # script. 9803a4f78defSmrg 9804a4f78defSmrg # Save the value of $output and $libobjs because we want to 9805a4f78defSmrg # use them later. If we have whole_archive_flag_spec, we 9806a4f78defSmrg # want to use save_libobjs as it was before 9807a4f78defSmrg # whole_archive_flag_spec was expanded, because we can't 9808a4f78defSmrg # assume the linker understands whole_archive_flag_spec. 9809a4f78defSmrg # This may have to be revisited, in case too many 9810a4f78defSmrg # convenience libraries get linked in and end up exceeding 9811a4f78defSmrg # the spec. 9812a4f78defSmrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 9813a4f78defSmrg save_libobjs=$libobjs 9814a4f78defSmrg fi 9815a4f78defSmrg save_output=$output 9816a4f78defSmrg func_basename "$output" 9817a4f78defSmrg output_la=$func_basename_result 9818a4f78defSmrg 9819a4f78defSmrg # Clear the reloadable object creation command queue and 9820a4f78defSmrg # initialize k to one. 9821a4f78defSmrg test_cmds= 9822a4f78defSmrg concat_cmds= 9823a4f78defSmrg objlist= 9824a4f78defSmrg last_robj= 9825a4f78defSmrg k=1 9826a4f78defSmrg 9827a4f78defSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9828a4f78defSmrg output=$output_objdir/$output_la.lnkscript 9829a4f78defSmrg func_verbose "creating GNU ld script: $output" 9830a4f78defSmrg echo 'INPUT (' > $output 9831a4f78defSmrg for obj in $save_libobjs 9832a4f78defSmrg do 9833a4f78defSmrg func_to_tool_file "$obj" 9834a4f78defSmrg $ECHO "$func_to_tool_file_result" >> $output 9835a4f78defSmrg done 9836a4f78defSmrg echo ')' >> $output 9837a4f78defSmrg func_append delfiles " $output" 9838a4f78defSmrg func_to_tool_file "$output" 9839a4f78defSmrg output=$func_to_tool_file_result 9840a4f78defSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9841a4f78defSmrg output=$output_objdir/$output_la.lnk 9842a4f78defSmrg func_verbose "creating linker input file list: $output" 9843a4f78defSmrg : > $output 9844a4f78defSmrg set x $save_libobjs 9845a4f78defSmrg shift 9846a4f78defSmrg firstobj= 9847a4f78defSmrg if test yes = "$compiler_needs_object"; then 9848a4f78defSmrg firstobj="$1 " 9849a4f78defSmrg shift 9850a4f78defSmrg fi 9851a4f78defSmrg for obj 9852a4f78defSmrg do 9853a4f78defSmrg func_to_tool_file "$obj" 9854a4f78defSmrg $ECHO "$func_to_tool_file_result" >> $output 9855a4f78defSmrg done 9856a4f78defSmrg func_append delfiles " $output" 9857a4f78defSmrg func_to_tool_file "$output" 9858a4f78defSmrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 9859a4f78defSmrg else 9860a4f78defSmrg if test -n "$save_libobjs"; then 9861a4f78defSmrg func_verbose "creating reloadable object files..." 9862a4f78defSmrg output=$output_objdir/$output_la-$k.$objext 9863a4f78defSmrg eval test_cmds=\"$reload_cmds\" 9864a4f78defSmrg func_len " $test_cmds" 9865a4f78defSmrg len0=$func_len_result 9866a4f78defSmrg len=$len0 9867a4f78defSmrg 9868a4f78defSmrg # Loop over the list of objects to be linked. 9869a4f78defSmrg for obj in $save_libobjs 9870a4f78defSmrg do 9871a4f78defSmrg func_len " $obj" 9872a4f78defSmrg func_arith $len + $func_len_result 9873a4f78defSmrg len=$func_arith_result 9874a4f78defSmrg if test -z "$objlist" || 9875a4f78defSmrg test "$len" -lt "$max_cmd_len"; then 9876a4f78defSmrg func_append objlist " $obj" 9877a4f78defSmrg else 9878a4f78defSmrg # The command $test_cmds is almost too long, add a 9879a4f78defSmrg # command to the queue. 9880a4f78defSmrg if test 1 -eq "$k"; then 9881a4f78defSmrg # The first file doesn't have a previous command to add. 9882a4f78defSmrg reload_objs=$objlist 9883a4f78defSmrg eval concat_cmds=\"$reload_cmds\" 9884a4f78defSmrg else 9885a4f78defSmrg # All subsequent reloadable object files will link in 9886a4f78defSmrg # the last one created. 9887a4f78defSmrg reload_objs="$objlist $last_robj" 9888a4f78defSmrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 9889a4f78defSmrg fi 9890a4f78defSmrg last_robj=$output_objdir/$output_la-$k.$objext 9891a4f78defSmrg func_arith $k + 1 9892a4f78defSmrg k=$func_arith_result 9893a4f78defSmrg output=$output_objdir/$output_la-$k.$objext 9894a4f78defSmrg objlist=" $obj" 9895a4f78defSmrg func_len " $last_robj" 9896a4f78defSmrg func_arith $len0 + $func_len_result 9897a4f78defSmrg len=$func_arith_result 9898a4f78defSmrg fi 9899a4f78defSmrg done 9900a4f78defSmrg # Handle the remaining objects by creating one last 9901a4f78defSmrg # reloadable object file. All subsequent reloadable object 9902a4f78defSmrg # files will link in the last one created. 9903a4f78defSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9904a4f78defSmrg reload_objs="$objlist $last_robj" 9905a4f78defSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 9906a4f78defSmrg if test -n "$last_robj"; then 9907a4f78defSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9908a4f78defSmrg fi 9909a4f78defSmrg func_append delfiles " $output" 9910a4f78defSmrg 9911a4f78defSmrg else 9912a4f78defSmrg output= 9913a4f78defSmrg fi 9914a4f78defSmrg 9915a4f78defSmrg ${skipped_export-false} && { 9916a4f78defSmrg func_verbose "generating symbol list for '$libname.la'" 9917a4f78defSmrg export_symbols=$output_objdir/$libname.exp 9918a4f78defSmrg $opt_dry_run || $RM $export_symbols 9919a4f78defSmrg libobjs=$output 9920a4f78defSmrg # Append the command to create the export file. 9921a4f78defSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9922a4f78defSmrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 9923a4f78defSmrg if test -n "$last_robj"; then 9924a4f78defSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 9925a4f78defSmrg fi 9926a4f78defSmrg } 9927a4f78defSmrg 9928a4f78defSmrg test -n "$save_libobjs" && 9929a4f78defSmrg func_verbose "creating a temporary reloadable object file: $output" 9930a4f78defSmrg 9931a4f78defSmrg # Loop through the commands generated above and execute them. 9932a4f78defSmrg save_ifs=$IFS; IFS='~' 9933a4f78defSmrg for cmd in $concat_cmds; do 9934a4f78defSmrg IFS=$save_ifs 9935a4f78defSmrg $opt_quiet || { 9936a4f78defSmrg func_quote_for_expand "$cmd" 9937a4f78defSmrg eval "func_echo $func_quote_for_expand_result" 9938a4f78defSmrg } 9939a4f78defSmrg $opt_dry_run || eval "$cmd" || { 9940a4f78defSmrg lt_exit=$? 9941a4f78defSmrg 9942a4f78defSmrg # Restore the uninstalled library and exit 9943a4f78defSmrg if test relink = "$opt_mode"; then 9944a4f78defSmrg ( cd "$output_objdir" && \ 9945a4f78defSmrg $RM "${realname}T" && \ 9946a4f78defSmrg $MV "${realname}U" "$realname" ) 9947a4f78defSmrg fi 9948a4f78defSmrg 9949a4f78defSmrg exit $lt_exit 9950a4f78defSmrg } 9951a4f78defSmrg done 9952a4f78defSmrg IFS=$save_ifs 9953a4f78defSmrg 9954a4f78defSmrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 9955a4f78defSmrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9956a4f78defSmrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9957a4f78defSmrg fi 9958a4f78defSmrg fi 9959a4f78defSmrg 9960a4f78defSmrg ${skipped_export-false} && { 9961a4f78defSmrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9962a4f78defSmrg tmp_export_symbols=$export_symbols 9963a4f78defSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 9964a4f78defSmrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 9965a4f78defSmrg fi 9966a4f78defSmrg 9967a4f78defSmrg if test -n "$orig_export_symbols"; then 9968a4f78defSmrg # The given exports_symbols file has to be filtered, so filter it. 9969a4f78defSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 9970a4f78defSmrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9971a4f78defSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 9972a4f78defSmrg # though. Also, the filter scales superlinearly with the number of 9973a4f78defSmrg # global variables. join(1) would be nice here, but unfortunately 9974a4f78defSmrg # isn't a blessed tool. 9975a4f78defSmrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9976a4f78defSmrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 9977a4f78defSmrg export_symbols=$output_objdir/$libname.def 9978a4f78defSmrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9979a4f78defSmrg fi 9980a4f78defSmrg } 9981a4f78defSmrg 9982a4f78defSmrg libobjs=$output 9983a4f78defSmrg # Restore the value of output. 9984a4f78defSmrg output=$save_output 9985a4f78defSmrg 9986a4f78defSmrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 9987a4f78defSmrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 9988a4f78defSmrg test "X$libobjs" = "X " && libobjs= 9989a4f78defSmrg fi 9990a4f78defSmrg # Expand the library linking commands again to reset the 9991a4f78defSmrg # value of $libobjs for piecewise linking. 9992a4f78defSmrg 9993a4f78defSmrg # Do each of the archive commands. 9994a4f78defSmrg if test yes = "$module" && test -n "$module_cmds"; then 9995a4f78defSmrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 9996a4f78defSmrg cmds=$module_expsym_cmds 9997a4f78defSmrg else 9998a4f78defSmrg cmds=$module_cmds 9999a4f78defSmrg fi 10000a4f78defSmrg else 10001a4f78defSmrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10002a4f78defSmrg cmds=$archive_expsym_cmds 10003a4f78defSmrg else 10004a4f78defSmrg cmds=$archive_cmds 10005a4f78defSmrg fi 10006a4f78defSmrg fi 10007a4f78defSmrg fi 10008a4f78defSmrg 10009a4f78defSmrg if test -n "$delfiles"; then 10010a4f78defSmrg # Append the command to remove temporary files to $cmds. 10011a4f78defSmrg eval cmds=\"\$cmds~\$RM $delfiles\" 10012a4f78defSmrg fi 10013a4f78defSmrg 10014a4f78defSmrg # Add any objects from preloaded convenience libraries 10015a4f78defSmrg if test -n "$dlprefiles"; then 10016a4f78defSmrg gentop=$output_objdir/${outputname}x 10017a4f78defSmrg func_append generated " $gentop" 10018a4f78defSmrg 10019a4f78defSmrg func_extract_archives $gentop $dlprefiles 10020a4f78defSmrg func_append libobjs " $func_extract_archives_result" 10021a4f78defSmrg test "X$libobjs" = "X " && libobjs= 10022a4f78defSmrg fi 10023a4f78defSmrg 10024a4f78defSmrg save_ifs=$IFS; IFS='~' 10025a4f78defSmrg for cmd in $cmds; do 10026a4f78defSmrg IFS=$sp$nl 10027a4f78defSmrg eval cmd=\"$cmd\" 10028a4f78defSmrg IFS=$save_ifs 10029a4f78defSmrg $opt_quiet || { 10030a4f78defSmrg func_quote_for_expand "$cmd" 10031a4f78defSmrg eval "func_echo $func_quote_for_expand_result" 10032a4f78defSmrg } 10033a4f78defSmrg $opt_dry_run || eval "$cmd" || { 10034a4f78defSmrg lt_exit=$? 10035a4f78defSmrg 10036a4f78defSmrg # Restore the uninstalled library and exit 10037a4f78defSmrg if test relink = "$opt_mode"; then 10038a4f78defSmrg ( cd "$output_objdir" && \ 10039a4f78defSmrg $RM "${realname}T" && \ 10040a4f78defSmrg $MV "${realname}U" "$realname" ) 10041a4f78defSmrg fi 10042a4f78defSmrg 10043a4f78defSmrg exit $lt_exit 10044a4f78defSmrg } 10045a4f78defSmrg done 10046a4f78defSmrg IFS=$save_ifs 10047a4f78defSmrg 10048a4f78defSmrg # Restore the uninstalled library and exit 10049a4f78defSmrg if test relink = "$opt_mode"; then 10050a4f78defSmrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10051a4f78defSmrg 10052a4f78defSmrg if test -n "$convenience"; then 10053a4f78defSmrg if test -z "$whole_archive_flag_spec"; then 10054a4f78defSmrg func_show_eval '${RM}r "$gentop"' 10055a4f78defSmrg fi 10056a4f78defSmrg fi 10057a4f78defSmrg 10058a4f78defSmrg exit $EXIT_SUCCESS 10059a4f78defSmrg fi 10060a4f78defSmrg 10061a4f78defSmrg # Create links to the real library. 10062a4f78defSmrg for linkname in $linknames; do 10063a4f78defSmrg if test "$realname" != "$linkname"; then 10064a4f78defSmrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10065a4f78defSmrg fi 10066a4f78defSmrg done 10067a4f78defSmrg 10068a4f78defSmrg # If -module or -export-dynamic was specified, set the dlname. 10069a4f78defSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 10070a4f78defSmrg # On all known operating systems, these are identical. 10071a4f78defSmrg dlname=$soname 10072a4f78defSmrg fi 10073a4f78defSmrg fi 10074a4f78defSmrg ;; 10075a4f78defSmrg 10076a4f78defSmrg obj) 10077a4f78defSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10078a4f78defSmrg func_warning "'-dlopen' is ignored for objects" 10079a4f78defSmrg fi 10080a4f78defSmrg 10081a4f78defSmrg case " $deplibs" in 10082a4f78defSmrg *\ -l* | *\ -L*) 10083a4f78defSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 10084a4f78defSmrg esac 10085a4f78defSmrg 10086a4f78defSmrg test -n "$rpath" && \ 10087a4f78defSmrg func_warning "'-rpath' is ignored for objects" 10088a4f78defSmrg 10089a4f78defSmrg test -n "$xrpath" && \ 10090a4f78defSmrg func_warning "'-R' is ignored for objects" 10091a4f78defSmrg 10092a4f78defSmrg test -n "$vinfo" && \ 10093a4f78defSmrg func_warning "'-version-info' is ignored for objects" 10094a4f78defSmrg 10095a4f78defSmrg test -n "$release" && \ 10096a4f78defSmrg func_warning "'-release' is ignored for objects" 10097a4f78defSmrg 10098a4f78defSmrg case $output in 10099a4f78defSmrg *.lo) 10100a4f78defSmrg test -n "$objs$old_deplibs" && \ 10101a4f78defSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10102a4f78defSmrg 10103a4f78defSmrg libobj=$output 10104a4f78defSmrg func_lo2o "$libobj" 10105a4f78defSmrg obj=$func_lo2o_result 10106a4f78defSmrg ;; 10107a4f78defSmrg *) 10108a4f78defSmrg libobj= 10109a4f78defSmrg obj=$output 10110a4f78defSmrg ;; 10111a4f78defSmrg esac 10112a4f78defSmrg 10113a4f78defSmrg # Delete the old objects. 10114a4f78defSmrg $opt_dry_run || $RM $obj $libobj 10115a4f78defSmrg 10116a4f78defSmrg # Objects from convenience libraries. This assumes 10117a4f78defSmrg # single-version convenience libraries. Whenever we create 10118a4f78defSmrg # different ones for PIC/non-PIC, this we'll have to duplicate 10119a4f78defSmrg # the extraction. 10120a4f78defSmrg reload_conv_objs= 10121a4f78defSmrg gentop= 10122a4f78defSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 10123a4f78defSmrg # whole_archive_flag_spec and hope we can get by with turning comma 10124a4f78defSmrg # into space. 10125a4f78defSmrg case $reload_cmds in 10126a4f78defSmrg *\$LD[\ \$]*) wl= ;; 10127a4f78defSmrg esac 10128a4f78defSmrg if test -n "$convenience"; then 10129a4f78defSmrg if test -n "$whole_archive_flag_spec"; then 10130a4f78defSmrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10131a4f78defSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10132a4f78defSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10133a4f78defSmrg else 10134a4f78defSmrg gentop=$output_objdir/${obj}x 10135a4f78defSmrg func_append generated " $gentop" 10136a4f78defSmrg 10137a4f78defSmrg func_extract_archives $gentop $convenience 10138a4f78defSmrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10139a4f78defSmrg fi 10140a4f78defSmrg fi 10141a4f78defSmrg 10142a4f78defSmrg # If we're not building shared, we need to use non_pic_objs 10143a4f78defSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10144a4f78defSmrg 10145a4f78defSmrg # Create the old-style object. 10146a4f78defSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10147a4f78defSmrg 10148a4f78defSmrg output=$obj 10149a4f78defSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10150a4f78defSmrg 10151a4f78defSmrg # Exit if we aren't doing a library object file. 10152a4f78defSmrg if test -z "$libobj"; then 10153a4f78defSmrg if test -n "$gentop"; then 10154a4f78defSmrg func_show_eval '${RM}r "$gentop"' 10155a4f78defSmrg fi 10156a4f78defSmrg 10157a4f78defSmrg exit $EXIT_SUCCESS 10158a4f78defSmrg fi 10159a4f78defSmrg 10160a4f78defSmrg test yes = "$build_libtool_libs" || { 10161a4f78defSmrg if test -n "$gentop"; then 10162a4f78defSmrg func_show_eval '${RM}r "$gentop"' 10163a4f78defSmrg fi 10164a4f78defSmrg 10165a4f78defSmrg # Create an invalid libtool object if no PIC, so that we don't 10166a4f78defSmrg # accidentally link it into a program. 10167a4f78defSmrg # $show "echo timestamp > $libobj" 10168a4f78defSmrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10169a4f78defSmrg exit $EXIT_SUCCESS 10170a4f78defSmrg } 10171a4f78defSmrg 10172a4f78defSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10173a4f78defSmrg # Only do commands if we really have different PIC objects. 10174a4f78defSmrg reload_objs="$libobjs $reload_conv_objs" 10175a4f78defSmrg output=$libobj 10176a4f78defSmrg func_execute_cmds "$reload_cmds" 'exit $?' 10177a4f78defSmrg fi 10178a4f78defSmrg 10179a4f78defSmrg if test -n "$gentop"; then 10180a4f78defSmrg func_show_eval '${RM}r "$gentop"' 10181a4f78defSmrg fi 10182a4f78defSmrg 10183a4f78defSmrg exit $EXIT_SUCCESS 10184a4f78defSmrg ;; 10185a4f78defSmrg 10186a4f78defSmrg prog) 10187a4f78defSmrg case $host in 10188a4f78defSmrg *cygwin*) func_stripname '' '.exe' "$output" 10189a4f78defSmrg output=$func_stripname_result.exe;; 10190a4f78defSmrg esac 10191a4f78defSmrg test -n "$vinfo" && \ 10192a4f78defSmrg func_warning "'-version-info' is ignored for programs" 10193a4f78defSmrg 10194a4f78defSmrg test -n "$release" && \ 10195a4f78defSmrg func_warning "'-release' is ignored for programs" 10196a4f78defSmrg 10197a4f78defSmrg $preload \ 10198a4f78defSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10199a4f78defSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10200a4f78defSmrg 10201a4f78defSmrg case $host in 10202a4f78defSmrg *-*-rhapsody* | *-*-darwin1.[012]) 10203a4f78defSmrg # On Rhapsody replace the C library is the System framework 10204a4f78defSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10205a4f78defSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10206a4f78defSmrg ;; 10207a4f78defSmrg esac 10208a4f78defSmrg 10209a4f78defSmrg case $host in 10210a4f78defSmrg *-*-darwin*) 10211a4f78defSmrg # Don't allow lazy linking, it breaks C++ global constructors 10212a4f78defSmrg # But is supposedly fixed on 10.4 or later (yay!). 10213a4f78defSmrg if test CXX = "$tagname"; then 10214a4f78defSmrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10215a4f78defSmrg 10.[0123]) 10216a4f78defSmrg func_append compile_command " $wl-bind_at_load" 10217a4f78defSmrg func_append finalize_command " $wl-bind_at_load" 10218a4f78defSmrg ;; 10219a4f78defSmrg esac 10220a4f78defSmrg fi 10221a4f78defSmrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10222a4f78defSmrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10223a4f78defSmrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10224a4f78defSmrg ;; 10225a4f78defSmrg esac 10226a4f78defSmrg 10227a4f78defSmrg 10228a4f78defSmrg # move library search paths that coincide with paths to not yet 10229a4f78defSmrg # installed libraries to the beginning of the library search list 10230a4f78defSmrg new_libs= 10231a4f78defSmrg for path in $notinst_path; do 10232a4f78defSmrg case " $new_libs " in 10233a4f78defSmrg *" -L$path/$objdir "*) ;; 10234a4f78defSmrg *) 10235a4f78defSmrg case " $compile_deplibs " in 10236a4f78defSmrg *" -L$path/$objdir "*) 10237a4f78defSmrg func_append new_libs " -L$path/$objdir" ;; 10238a4f78defSmrg esac 10239a4f78defSmrg ;; 10240a4f78defSmrg esac 10241a4f78defSmrg done 10242a4f78defSmrg for deplib in $compile_deplibs; do 10243a4f78defSmrg case $deplib in 10244a4f78defSmrg -L*) 10245a4f78defSmrg case " $new_libs " in 10246a4f78defSmrg *" $deplib "*) ;; 10247a4f78defSmrg *) func_append new_libs " $deplib" ;; 10248a4f78defSmrg esac 10249a4f78defSmrg ;; 10250a4f78defSmrg *) func_append new_libs " $deplib" ;; 10251a4f78defSmrg esac 10252a4f78defSmrg done 10253a4f78defSmrg compile_deplibs=$new_libs 10254a4f78defSmrg 10255a4f78defSmrg 10256a4f78defSmrg func_append compile_command " $compile_deplibs" 10257a4f78defSmrg func_append finalize_command " $finalize_deplibs" 10258a4f78defSmrg 10259a4f78defSmrg if test -n "$rpath$xrpath"; then 10260a4f78defSmrg # If the user specified any rpath flags, then add them. 10261a4f78defSmrg for libdir in $rpath $xrpath; do 10262a4f78defSmrg # This is the magic to use -rpath. 10263a4f78defSmrg case "$finalize_rpath " in 10264a4f78defSmrg *" $libdir "*) ;; 10265a4f78defSmrg *) func_append finalize_rpath " $libdir" ;; 10266a4f78defSmrg esac 10267a4f78defSmrg done 10268a4f78defSmrg fi 10269a4f78defSmrg 10270a4f78defSmrg # Now hardcode the library paths 10271a4f78defSmrg rpath= 10272a4f78defSmrg hardcode_libdirs= 10273a4f78defSmrg for libdir in $compile_rpath $finalize_rpath; do 10274a4f78defSmrg if test -n "$hardcode_libdir_flag_spec"; then 10275a4f78defSmrg if test -n "$hardcode_libdir_separator"; then 10276a4f78defSmrg if test -z "$hardcode_libdirs"; then 10277a4f78defSmrg hardcode_libdirs=$libdir 10278a4f78defSmrg else 10279a4f78defSmrg # Just accumulate the unique libdirs. 10280a4f78defSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10281a4f78defSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10282a4f78defSmrg ;; 10283a4f78defSmrg *) 10284a4f78defSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10285a4f78defSmrg ;; 10286a4f78defSmrg esac 10287a4f78defSmrg fi 10288a4f78defSmrg else 10289a4f78defSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10290a4f78defSmrg func_append rpath " $flag" 10291a4f78defSmrg fi 10292a4f78defSmrg elif test -n "$runpath_var"; then 10293a4f78defSmrg case "$perm_rpath " in 10294a4f78defSmrg *" $libdir "*) ;; 10295a4f78defSmrg *) func_append perm_rpath " $libdir" ;; 10296a4f78defSmrg esac 10297a4f78defSmrg fi 10298a4f78defSmrg case $host in 10299a4f78defSmrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10300a4f78defSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10301a4f78defSmrg case :$dllsearchpath: in 10302a4f78defSmrg *":$libdir:"*) ;; 10303a4f78defSmrg ::) dllsearchpath=$libdir;; 10304a4f78defSmrg *) func_append dllsearchpath ":$libdir";; 10305a4f78defSmrg esac 10306a4f78defSmrg case :$dllsearchpath: in 10307a4f78defSmrg *":$testbindir:"*) ;; 10308a4f78defSmrg ::) dllsearchpath=$testbindir;; 10309a4f78defSmrg *) func_append dllsearchpath ":$testbindir";; 10310a4f78defSmrg esac 10311a4f78defSmrg ;; 10312a4f78defSmrg esac 10313a4f78defSmrg done 10314a4f78defSmrg # Substitute the hardcoded libdirs into the rpath. 10315a4f78defSmrg if test -n "$hardcode_libdir_separator" && 10316a4f78defSmrg test -n "$hardcode_libdirs"; then 10317a4f78defSmrg libdir=$hardcode_libdirs 10318a4f78defSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10319a4f78defSmrg fi 10320a4f78defSmrg compile_rpath=$rpath 10321a4f78defSmrg 10322a4f78defSmrg rpath= 10323a4f78defSmrg hardcode_libdirs= 10324a4f78defSmrg for libdir in $finalize_rpath; do 10325a4f78defSmrg if test -n "$hardcode_libdir_flag_spec"; then 10326a4f78defSmrg if test -n "$hardcode_libdir_separator"; then 10327a4f78defSmrg if test -z "$hardcode_libdirs"; then 10328a4f78defSmrg hardcode_libdirs=$libdir 10329a4f78defSmrg else 10330a4f78defSmrg # Just accumulate the unique libdirs. 10331a4f78defSmrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10332a4f78defSmrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10333a4f78defSmrg ;; 10334a4f78defSmrg *) 10335a4f78defSmrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10336a4f78defSmrg ;; 10337a4f78defSmrg esac 10338a4f78defSmrg fi 10339a4f78defSmrg else 10340a4f78defSmrg eval flag=\"$hardcode_libdir_flag_spec\" 10341a4f78defSmrg func_append rpath " $flag" 10342a4f78defSmrg fi 10343a4f78defSmrg elif test -n "$runpath_var"; then 10344a4f78defSmrg case "$finalize_perm_rpath " in 10345a4f78defSmrg *" $libdir "*) ;; 10346a4f78defSmrg *) func_append finalize_perm_rpath " $libdir" ;; 10347a4f78defSmrg esac 10348a4f78defSmrg fi 10349a4f78defSmrg done 10350a4f78defSmrg # Substitute the hardcoded libdirs into the rpath. 10351a4f78defSmrg if test -n "$hardcode_libdir_separator" && 10352a4f78defSmrg test -n "$hardcode_libdirs"; then 10353a4f78defSmrg libdir=$hardcode_libdirs 10354a4f78defSmrg eval rpath=\" $hardcode_libdir_flag_spec\" 10355a4f78defSmrg fi 10356a4f78defSmrg finalize_rpath=$rpath 10357a4f78defSmrg 10358a4f78defSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10359a4f78defSmrg # Transform all the library objects into standard objects. 10360a4f78defSmrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10361a4f78defSmrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10362a4f78defSmrg fi 10363a4f78defSmrg 10364a4f78defSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10365a4f78defSmrg 10366a4f78defSmrg # template prelinking step 10367a4f78defSmrg if test -n "$prelink_cmds"; then 10368a4f78defSmrg func_execute_cmds "$prelink_cmds" 'exit $?' 10369a4f78defSmrg fi 10370a4f78defSmrg 10371a4f78defSmrg wrappers_required=: 10372a4f78defSmrg case $host in 10373a4f78defSmrg *cegcc* | *mingw32ce*) 10374a4f78defSmrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10375a4f78defSmrg wrappers_required=false 10376a4f78defSmrg ;; 10377a4f78defSmrg *cygwin* | *mingw* ) 10378a4f78defSmrg test yes = "$build_libtool_libs" || wrappers_required=false 10379a4f78defSmrg ;; 10380a4f78defSmrg *) 10381a4f78defSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10382a4f78defSmrg wrappers_required=false 10383a4f78defSmrg fi 10384a4f78defSmrg ;; 10385a4f78defSmrg esac 10386a4f78defSmrg $wrappers_required || { 10387a4f78defSmrg # Replace the output file specification. 10388a4f78defSmrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10389a4f78defSmrg link_command=$compile_command$compile_rpath 10390a4f78defSmrg 10391a4f78defSmrg # We have no uninstalled library dependencies, so finalize right now. 10392a4f78defSmrg exit_status=0 10393a4f78defSmrg func_show_eval "$link_command" 'exit_status=$?' 10394a4f78defSmrg 10395a4f78defSmrg if test -n "$postlink_cmds"; then 10396a4f78defSmrg func_to_tool_file "$output" 10397a4f78defSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10398a4f78defSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10399a4f78defSmrg fi 10400a4f78defSmrg 10401a4f78defSmrg # Delete the generated files. 10402a4f78defSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 10403a4f78defSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10404a4f78defSmrg fi 10405a4f78defSmrg 10406a4f78defSmrg exit $exit_status 10407a4f78defSmrg } 10408a4f78defSmrg 10409a4f78defSmrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10410a4f78defSmrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10411a4f78defSmrg fi 10412a4f78defSmrg if test -n "$finalize_shlibpath"; then 10413a4f78defSmrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10414a4f78defSmrg fi 10415a4f78defSmrg 10416a4f78defSmrg compile_var= 10417a4f78defSmrg finalize_var= 10418a4f78defSmrg if test -n "$runpath_var"; then 10419a4f78defSmrg if test -n "$perm_rpath"; then 10420a4f78defSmrg # We should set the runpath_var. 10421a4f78defSmrg rpath= 10422a4f78defSmrg for dir in $perm_rpath; do 10423a4f78defSmrg func_append rpath "$dir:" 10424a4f78defSmrg done 10425a4f78defSmrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10426a4f78defSmrg fi 10427a4f78defSmrg if test -n "$finalize_perm_rpath"; then 10428a4f78defSmrg # We should set the runpath_var. 10429a4f78defSmrg rpath= 10430a4f78defSmrg for dir in $finalize_perm_rpath; do 10431a4f78defSmrg func_append rpath "$dir:" 10432a4f78defSmrg done 10433a4f78defSmrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10434a4f78defSmrg fi 10435a4f78defSmrg fi 10436a4f78defSmrg 10437a4f78defSmrg if test yes = "$no_install"; then 10438a4f78defSmrg # We don't need to create a wrapper script. 10439a4f78defSmrg link_command=$compile_var$compile_command$compile_rpath 10440a4f78defSmrg # Replace the output file specification. 10441a4f78defSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10442a4f78defSmrg # Delete the old output file. 10443a4f78defSmrg $opt_dry_run || $RM $output 10444a4f78defSmrg # Link the executable and exit 10445a4f78defSmrg func_show_eval "$link_command" 'exit $?' 10446a4f78defSmrg 10447a4f78defSmrg if test -n "$postlink_cmds"; then 10448a4f78defSmrg func_to_tool_file "$output" 10449a4f78defSmrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10450a4f78defSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10451a4f78defSmrg fi 10452a4f78defSmrg 10453a4f78defSmrg exit $EXIT_SUCCESS 10454a4f78defSmrg fi 10455a4f78defSmrg 10456a4f78defSmrg case $hardcode_action,$fast_install in 10457a4f78defSmrg relink,*) 10458a4f78defSmrg # Fast installation is not supported 10459a4f78defSmrg link_command=$compile_var$compile_command$compile_rpath 10460a4f78defSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10461a4f78defSmrg 10462a4f78defSmrg func_warning "this platform does not like uninstalled shared libraries" 10463a4f78defSmrg func_warning "'$output' will be relinked during installation" 10464a4f78defSmrg ;; 10465a4f78defSmrg *,yes) 10466a4f78defSmrg link_command=$finalize_var$compile_command$finalize_rpath 10467a4f78defSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10468a4f78defSmrg ;; 10469a4f78defSmrg *,no) 10470a4f78defSmrg link_command=$compile_var$compile_command$compile_rpath 10471a4f78defSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10472a4f78defSmrg ;; 10473a4f78defSmrg *,needless) 10474a4f78defSmrg link_command=$finalize_var$compile_command$finalize_rpath 10475a4f78defSmrg relink_command= 10476a4f78defSmrg ;; 10477a4f78defSmrg esac 10478a4f78defSmrg 10479a4f78defSmrg # Replace the output file specification. 10480a4f78defSmrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10481a4f78defSmrg 10482a4f78defSmrg # Delete the old output files. 10483a4f78defSmrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10484a4f78defSmrg 10485a4f78defSmrg func_show_eval "$link_command" 'exit $?' 10486a4f78defSmrg 10487a4f78defSmrg if test -n "$postlink_cmds"; then 10488a4f78defSmrg func_to_tool_file "$output_objdir/$outputname" 10489a4f78defSmrg 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'` 10490a4f78defSmrg func_execute_cmds "$postlink_cmds" 'exit $?' 10491a4f78defSmrg fi 10492a4f78defSmrg 10493a4f78defSmrg # Now create the wrapper script. 10494a4f78defSmrg func_verbose "creating $output" 10495a4f78defSmrg 10496a4f78defSmrg # Quote the relink command for shipping. 10497a4f78defSmrg if test -n "$relink_command"; then 10498a4f78defSmrg # Preserve any variables that may affect compiler behavior 10499a4f78defSmrg for var in $variables_saved_for_relink; do 10500a4f78defSmrg if eval test -z \"\${$var+set}\"; then 10501a4f78defSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10502a4f78defSmrg elif eval var_value=\$$var; test -z "$var_value"; then 10503a4f78defSmrg relink_command="$var=; export $var; $relink_command" 10504a4f78defSmrg else 10505a4f78defSmrg func_quote_for_eval "$var_value" 10506a4f78defSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10507a4f78defSmrg fi 10508a4f78defSmrg done 10509a4f78defSmrg relink_command="(cd `pwd`; $relink_command)" 10510a4f78defSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10511a4f78defSmrg fi 10512a4f78defSmrg 10513a4f78defSmrg # Only actually do things if not in dry run mode. 10514a4f78defSmrg $opt_dry_run || { 10515a4f78defSmrg # win32 will think the script is a binary if it has 10516a4f78defSmrg # a .exe suffix, so we strip it off here. 10517a4f78defSmrg case $output in 10518a4f78defSmrg *.exe) func_stripname '' '.exe' "$output" 10519a4f78defSmrg output=$func_stripname_result ;; 10520a4f78defSmrg esac 10521a4f78defSmrg # test for cygwin because mv fails w/o .exe extensions 10522a4f78defSmrg case $host in 10523a4f78defSmrg *cygwin*) 10524a4f78defSmrg exeext=.exe 10525a4f78defSmrg func_stripname '' '.exe' "$outputname" 10526a4f78defSmrg outputname=$func_stripname_result ;; 10527a4f78defSmrg *) exeext= ;; 10528a4f78defSmrg esac 10529a4f78defSmrg case $host in 10530a4f78defSmrg *cygwin* | *mingw* ) 10531a4f78defSmrg func_dirname_and_basename "$output" "" "." 10532a4f78defSmrg output_name=$func_basename_result 10533a4f78defSmrg output_path=$func_dirname_result 10534a4f78defSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10535a4f78defSmrg cwrapper=$output_path/$output_name.exe 10536a4f78defSmrg $RM $cwrappersource $cwrapper 10537a4f78defSmrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10538a4f78defSmrg 10539a4f78defSmrg func_emit_cwrapperexe_src > $cwrappersource 10540a4f78defSmrg 10541a4f78defSmrg # The wrapper executable is built using the $host compiler, 10542a4f78defSmrg # because it contains $host paths and files. If cross- 10543a4f78defSmrg # compiling, it, like the target executable, must be 10544a4f78defSmrg # executed on the $host or under an emulation environment. 10545a4f78defSmrg $opt_dry_run || { 10546a4f78defSmrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10547a4f78defSmrg $STRIP $cwrapper 10548a4f78defSmrg } 10549a4f78defSmrg 10550a4f78defSmrg # Now, create the wrapper script for func_source use: 10551a4f78defSmrg func_ltwrapper_scriptname $cwrapper 10552a4f78defSmrg $RM $func_ltwrapper_scriptname_result 10553a4f78defSmrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10554a4f78defSmrg $opt_dry_run || { 10555a4f78defSmrg # note: this script will not be executed, so do not chmod. 10556a4f78defSmrg if test "x$build" = "x$host"; then 10557a4f78defSmrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10558a4f78defSmrg else 10559a4f78defSmrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10560a4f78defSmrg fi 10561a4f78defSmrg } 10562a4f78defSmrg ;; 10563a4f78defSmrg * ) 10564a4f78defSmrg $RM $output 10565a4f78defSmrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10566a4f78defSmrg 10567a4f78defSmrg func_emit_wrapper no > $output 10568a4f78defSmrg chmod +x $output 10569a4f78defSmrg ;; 10570a4f78defSmrg esac 10571a4f78defSmrg } 10572a4f78defSmrg exit $EXIT_SUCCESS 10573a4f78defSmrg ;; 10574a4f78defSmrg esac 10575a4f78defSmrg 10576a4f78defSmrg # See if we need to build an old-fashioned archive. 10577a4f78defSmrg for oldlib in $oldlibs; do 10578a4f78defSmrg 10579a4f78defSmrg case $build_libtool_libs in 10580a4f78defSmrg convenience) 10581a4f78defSmrg oldobjs="$libobjs_save $symfileobj" 10582a4f78defSmrg addlibs=$convenience 10583a4f78defSmrg build_libtool_libs=no 10584a4f78defSmrg ;; 10585a4f78defSmrg module) 10586a4f78defSmrg oldobjs=$libobjs_save 10587a4f78defSmrg addlibs=$old_convenience 10588a4f78defSmrg build_libtool_libs=no 10589a4f78defSmrg ;; 10590a4f78defSmrg *) 10591a4f78defSmrg oldobjs="$old_deplibs $non_pic_objects" 10592a4f78defSmrg $preload && test -f "$symfileobj" \ 10593a4f78defSmrg && func_append oldobjs " $symfileobj" 10594a4f78defSmrg addlibs=$old_convenience 10595a4f78defSmrg ;; 10596a4f78defSmrg esac 10597a4f78defSmrg 10598a4f78defSmrg if test -n "$addlibs"; then 10599a4f78defSmrg gentop=$output_objdir/${outputname}x 10600a4f78defSmrg func_append generated " $gentop" 10601a4f78defSmrg 10602a4f78defSmrg func_extract_archives $gentop $addlibs 10603a4f78defSmrg func_append oldobjs " $func_extract_archives_result" 10604a4f78defSmrg fi 10605a4f78defSmrg 10606a4f78defSmrg # Do each command in the archive commands. 10607a4f78defSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10608a4f78defSmrg cmds=$old_archive_from_new_cmds 10609a4f78defSmrg else 10610a4f78defSmrg 10611a4f78defSmrg # Add any objects from preloaded convenience libraries 10612a4f78defSmrg if test -n "$dlprefiles"; then 10613a4f78defSmrg gentop=$output_objdir/${outputname}x 10614a4f78defSmrg func_append generated " $gentop" 10615a4f78defSmrg 10616a4f78defSmrg func_extract_archives $gentop $dlprefiles 10617a4f78defSmrg func_append oldobjs " $func_extract_archives_result" 10618a4f78defSmrg fi 10619a4f78defSmrg 10620a4f78defSmrg # POSIX demands no paths to be encoded in archives. We have 10621a4f78defSmrg # to avoid creating archives with duplicate basenames if we 10622a4f78defSmrg # might have to extract them afterwards, e.g., when creating a 10623a4f78defSmrg # static archive out of a convenience library, or when linking 10624a4f78defSmrg # the entirety of a libtool archive into another (currently 10625a4f78defSmrg # not supported by libtool). 10626a4f78defSmrg if (for obj in $oldobjs 10627a4f78defSmrg do 10628a4f78defSmrg func_basename "$obj" 10629a4f78defSmrg $ECHO "$func_basename_result" 10630a4f78defSmrg done | sort | sort -uc >/dev/null 2>&1); then 10631a4f78defSmrg : 10632a4f78defSmrg else 10633a4f78defSmrg echo "copying selected object files to avoid basename conflicts..." 10634a4f78defSmrg gentop=$output_objdir/${outputname}x 10635a4f78defSmrg func_append generated " $gentop" 10636a4f78defSmrg func_mkdir_p "$gentop" 10637a4f78defSmrg save_oldobjs=$oldobjs 10638a4f78defSmrg oldobjs= 10639a4f78defSmrg counter=1 10640a4f78defSmrg for obj in $save_oldobjs 10641a4f78defSmrg do 10642a4f78defSmrg func_basename "$obj" 10643a4f78defSmrg objbase=$func_basename_result 10644a4f78defSmrg case " $oldobjs " in 10645a4f78defSmrg " ") oldobjs=$obj ;; 10646a4f78defSmrg *[\ /]"$objbase "*) 10647a4f78defSmrg while :; do 10648a4f78defSmrg # Make sure we don't pick an alternate name that also 10649a4f78defSmrg # overlaps. 10650a4f78defSmrg newobj=lt$counter-$objbase 10651a4f78defSmrg func_arith $counter + 1 10652a4f78defSmrg counter=$func_arith_result 10653a4f78defSmrg case " $oldobjs " in 10654a4f78defSmrg *[\ /]"$newobj "*) ;; 10655a4f78defSmrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10656a4f78defSmrg esac 10657a4f78defSmrg done 10658a4f78defSmrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10659a4f78defSmrg func_append oldobjs " $gentop/$newobj" 10660a4f78defSmrg ;; 10661a4f78defSmrg *) func_append oldobjs " $obj" ;; 10662a4f78defSmrg esac 10663a4f78defSmrg done 10664a4f78defSmrg fi 10665a4f78defSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10666a4f78defSmrg tool_oldlib=$func_to_tool_file_result 10667a4f78defSmrg eval cmds=\"$old_archive_cmds\" 10668a4f78defSmrg 10669a4f78defSmrg func_len " $cmds" 10670a4f78defSmrg len=$func_len_result 10671a4f78defSmrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10672a4f78defSmrg cmds=$old_archive_cmds 10673a4f78defSmrg elif test -n "$archiver_list_spec"; then 10674a4f78defSmrg func_verbose "using command file archive linking..." 10675a4f78defSmrg for obj in $oldobjs 10676a4f78defSmrg do 10677a4f78defSmrg func_to_tool_file "$obj" 10678a4f78defSmrg $ECHO "$func_to_tool_file_result" 10679a4f78defSmrg done > $output_objdir/$libname.libcmd 10680a4f78defSmrg func_to_tool_file "$output_objdir/$libname.libcmd" 10681a4f78defSmrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10682a4f78defSmrg cmds=$old_archive_cmds 10683a4f78defSmrg else 10684a4f78defSmrg # the command line is too long to link in one step, link in parts 10685a4f78defSmrg func_verbose "using piecewise archive linking..." 10686a4f78defSmrg save_RANLIB=$RANLIB 10687a4f78defSmrg RANLIB=: 10688a4f78defSmrg objlist= 10689a4f78defSmrg concat_cmds= 10690a4f78defSmrg save_oldobjs=$oldobjs 10691a4f78defSmrg oldobjs= 10692a4f78defSmrg # Is there a better way of finding the last object in the list? 10693a4f78defSmrg for obj in $save_oldobjs 10694a4f78defSmrg do 10695a4f78defSmrg last_oldobj=$obj 10696a4f78defSmrg done 10697a4f78defSmrg eval test_cmds=\"$old_archive_cmds\" 10698a4f78defSmrg func_len " $test_cmds" 10699a4f78defSmrg len0=$func_len_result 10700a4f78defSmrg len=$len0 10701a4f78defSmrg for obj in $save_oldobjs 10702a4f78defSmrg do 10703a4f78defSmrg func_len " $obj" 10704a4f78defSmrg func_arith $len + $func_len_result 10705a4f78defSmrg len=$func_arith_result 10706a4f78defSmrg func_append objlist " $obj" 10707a4f78defSmrg if test "$len" -lt "$max_cmd_len"; then 10708a4f78defSmrg : 10709a4f78defSmrg else 10710a4f78defSmrg # the above command should be used before it gets too long 10711a4f78defSmrg oldobjs=$objlist 10712a4f78defSmrg if test "$obj" = "$last_oldobj"; then 10713a4f78defSmrg RANLIB=$save_RANLIB 10714a4f78defSmrg fi 10715a4f78defSmrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10716a4f78defSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 10717a4f78defSmrg objlist= 10718a4f78defSmrg len=$len0 10719a4f78defSmrg fi 10720a4f78defSmrg done 10721a4f78defSmrg RANLIB=$save_RANLIB 10722a4f78defSmrg oldobjs=$objlist 10723a4f78defSmrg if test -z "$oldobjs"; then 10724a4f78defSmrg eval cmds=\"\$concat_cmds\" 10725a4f78defSmrg else 10726a4f78defSmrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 10727a4f78defSmrg fi 10728a4f78defSmrg fi 10729a4f78defSmrg fi 10730a4f78defSmrg func_execute_cmds "$cmds" 'exit $?' 10731a4f78defSmrg done 10732a4f78defSmrg 10733a4f78defSmrg test -n "$generated" && \ 10734a4f78defSmrg func_show_eval "${RM}r$generated" 10735a4f78defSmrg 10736a4f78defSmrg # Now create the libtool archive. 10737a4f78defSmrg case $output in 10738a4f78defSmrg *.la) 10739a4f78defSmrg old_library= 10740a4f78defSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 10741a4f78defSmrg func_verbose "creating $output" 10742a4f78defSmrg 10743a4f78defSmrg # Preserve any variables that may affect compiler behavior 10744a4f78defSmrg for var in $variables_saved_for_relink; do 10745a4f78defSmrg if eval test -z \"\${$var+set}\"; then 10746a4f78defSmrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10747a4f78defSmrg elif eval var_value=\$$var; test -z "$var_value"; then 10748a4f78defSmrg relink_command="$var=; export $var; $relink_command" 10749a4f78defSmrg else 10750a4f78defSmrg func_quote_for_eval "$var_value" 10751a4f78defSmrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10752a4f78defSmrg fi 10753a4f78defSmrg done 10754a4f78defSmrg # Quote the link command for shipping. 10755a4f78defSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 10756a4f78defSmrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10757a4f78defSmrg if test yes = "$hardcode_automatic"; then 10758a4f78defSmrg relink_command= 10759a4f78defSmrg fi 10760a4f78defSmrg 10761a4f78defSmrg # Only create the output if not a dry run. 10762a4f78defSmrg $opt_dry_run || { 10763a4f78defSmrg for installed in no yes; do 10764a4f78defSmrg if test yes = "$installed"; then 10765a4f78defSmrg if test -z "$install_libdir"; then 10766a4f78defSmrg break 10767a4f78defSmrg fi 10768a4f78defSmrg output=$output_objdir/${outputname}i 10769a4f78defSmrg # Replace all uninstalled libtool libraries with the installed ones 10770a4f78defSmrg newdependency_libs= 10771a4f78defSmrg for deplib in $dependency_libs; do 10772a4f78defSmrg case $deplib in 10773a4f78defSmrg *.la) 10774a4f78defSmrg func_basename "$deplib" 10775a4f78defSmrg name=$func_basename_result 10776a4f78defSmrg func_resolve_sysroot "$deplib" 10777a4f78defSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 10778a4f78defSmrg test -z "$libdir" && \ 10779a4f78defSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 10780a4f78defSmrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10781a4f78defSmrg ;; 10782a4f78defSmrg -L*) 10783a4f78defSmrg func_stripname -L '' "$deplib" 10784a4f78defSmrg func_replace_sysroot "$func_stripname_result" 10785a4f78defSmrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10786a4f78defSmrg ;; 10787a4f78defSmrg -R*) 10788a4f78defSmrg func_stripname -R '' "$deplib" 10789a4f78defSmrg func_replace_sysroot "$func_stripname_result" 10790a4f78defSmrg func_append newdependency_libs " -R$func_replace_sysroot_result" 10791a4f78defSmrg ;; 10792a4f78defSmrg *) func_append newdependency_libs " $deplib" ;; 10793a4f78defSmrg esac 10794a4f78defSmrg done 10795a4f78defSmrg dependency_libs=$newdependency_libs 10796a4f78defSmrg newdlfiles= 10797a4f78defSmrg 10798a4f78defSmrg for lib in $dlfiles; do 10799a4f78defSmrg case $lib in 10800a4f78defSmrg *.la) 10801a4f78defSmrg func_basename "$lib" 10802a4f78defSmrg name=$func_basename_result 10803a4f78defSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10804a4f78defSmrg test -z "$libdir" && \ 10805a4f78defSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10806a4f78defSmrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 10807a4f78defSmrg ;; 10808a4f78defSmrg *) func_append newdlfiles " $lib" ;; 10809a4f78defSmrg esac 10810a4f78defSmrg done 10811a4f78defSmrg dlfiles=$newdlfiles 10812a4f78defSmrg newdlprefiles= 10813a4f78defSmrg for lib in $dlprefiles; do 10814a4f78defSmrg case $lib in 10815a4f78defSmrg *.la) 10816a4f78defSmrg # Only pass preopened files to the pseudo-archive (for 10817a4f78defSmrg # eventual linking with the app. that links it) if we 10818a4f78defSmrg # didn't already link the preopened objects directly into 10819a4f78defSmrg # the library: 10820a4f78defSmrg func_basename "$lib" 10821a4f78defSmrg name=$func_basename_result 10822a4f78defSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 10823a4f78defSmrg test -z "$libdir" && \ 10824a4f78defSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10825a4f78defSmrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 10826a4f78defSmrg ;; 10827a4f78defSmrg esac 10828a4f78defSmrg done 10829a4f78defSmrg dlprefiles=$newdlprefiles 10830a4f78defSmrg else 10831a4f78defSmrg newdlfiles= 10832a4f78defSmrg for lib in $dlfiles; do 10833a4f78defSmrg case $lib in 10834a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10835a4f78defSmrg *) abs=`pwd`"/$lib" ;; 10836a4f78defSmrg esac 10837a4f78defSmrg func_append newdlfiles " $abs" 10838a4f78defSmrg done 10839a4f78defSmrg dlfiles=$newdlfiles 10840a4f78defSmrg newdlprefiles= 10841a4f78defSmrg for lib in $dlprefiles; do 10842a4f78defSmrg case $lib in 10843a4f78defSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 10844a4f78defSmrg *) abs=`pwd`"/$lib" ;; 10845a4f78defSmrg esac 10846a4f78defSmrg func_append newdlprefiles " $abs" 10847a4f78defSmrg done 10848a4f78defSmrg dlprefiles=$newdlprefiles 10849a4f78defSmrg fi 10850a4f78defSmrg $RM $output 10851a4f78defSmrg # place dlname in correct position for cygwin 10852a4f78defSmrg # In fact, it would be nice if we could use this code for all target 10853a4f78defSmrg # systems that can't hard-code library paths into their executables 10854a4f78defSmrg # and that have no shared library path variable independent of PATH, 10855a4f78defSmrg # but it turns out we can't easily determine that from inspecting 10856a4f78defSmrg # libtool variables, so we have to hard-code the OSs to which it 10857a4f78defSmrg # applies here; at the moment, that means platforms that use the PE 10858a4f78defSmrg # object format with DLL files. See the long comment at the top of 10859a4f78defSmrg # tests/bindir.at for full details. 10860a4f78defSmrg tdlname=$dlname 10861a4f78defSmrg case $host,$output,$installed,$module,$dlname in 10862a4f78defSmrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 10863a4f78defSmrg # If a -bindir argument was supplied, place the dll there. 10864a4f78defSmrg if test -n "$bindir"; then 10865a4f78defSmrg func_relative_path "$install_libdir" "$bindir" 10866a4f78defSmrg tdlname=$func_relative_path_result/$dlname 10867a4f78defSmrg else 10868a4f78defSmrg # Otherwise fall back on heuristic. 10869a4f78defSmrg tdlname=../bin/$dlname 10870a4f78defSmrg fi 10871a4f78defSmrg ;; 10872a4f78defSmrg esac 10873a4f78defSmrg $ECHO > $output "\ 10874a4f78defSmrg# $outputname - a libtool library file 10875a4f78defSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 10876a4f78defSmrg# 10877a4f78defSmrg# Please DO NOT delete this file! 10878a4f78defSmrg# It is necessary for linking the library. 10879a4f78defSmrg 10880a4f78defSmrg# The name that we can dlopen(3). 10881a4f78defSmrgdlname='$tdlname' 10882a4f78defSmrg 10883a4f78defSmrg# Names of this library. 10884a4f78defSmrglibrary_names='$library_names' 10885a4f78defSmrg 10886a4f78defSmrg# The name of the static archive. 10887a4f78defSmrgold_library='$old_library' 10888a4f78defSmrg 10889a4f78defSmrg# Linker flags that cannot go in dependency_libs. 10890a4f78defSmrginherited_linker_flags='$new_inherited_linker_flags' 10891a4f78defSmrg 10892a4f78defSmrg# Libraries that this one depends upon. 10893a4f78defSmrgdependency_libs='$dependency_libs' 10894a4f78defSmrg 10895a4f78defSmrg# Names of additional weak libraries provided by this library 10896a4f78defSmrgweak_library_names='$weak_libs' 10897a4f78defSmrg 10898a4f78defSmrg# Version information for $libname. 10899a4f78defSmrgcurrent=$current 10900a4f78defSmrgage=$age 10901a4f78defSmrgrevision=$revision 10902a4f78defSmrg 10903a4f78defSmrg# Is this an already installed library? 10904a4f78defSmrginstalled=$installed 10905a4f78defSmrg 10906a4f78defSmrg# Should we warn about portability when linking against -modules? 10907a4f78defSmrgshouldnotlink=$module 10908a4f78defSmrg 10909a4f78defSmrg# Files to dlopen/dlpreopen 10910a4f78defSmrgdlopen='$dlfiles' 10911a4f78defSmrgdlpreopen='$dlprefiles' 10912a4f78defSmrg 10913a4f78defSmrg# Directory that this library needs to be installed in: 10914a4f78defSmrglibdir='$install_libdir'" 10915a4f78defSmrg if test no,yes = "$installed,$need_relink"; then 10916a4f78defSmrg $ECHO >> $output "\ 10917a4f78defSmrgrelink_command=\"$relink_command\"" 10918a4f78defSmrg fi 10919a4f78defSmrg done 10920a4f78defSmrg } 10921a4f78defSmrg 10922a4f78defSmrg # Do a symbolic link so that the libtool archive can be found in 10923a4f78defSmrg # LD_LIBRARY_PATH before the program is installed. 10924a4f78defSmrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 10925a4f78defSmrg ;; 10926a4f78defSmrg esac 10927a4f78defSmrg exit $EXIT_SUCCESS 10928a4f78defSmrg} 10929a4f78defSmrg 10930a4f78defSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 10931a4f78defSmrg func_mode_link ${1+"$@"} 10932a4f78defSmrgfi 10933a4f78defSmrg 10934a4f78defSmrg 10935a4f78defSmrg# func_mode_uninstall arg... 10936a4f78defSmrgfunc_mode_uninstall () 10937a4f78defSmrg{ 10938a4f78defSmrg $debug_cmd 10939a4f78defSmrg 10940a4f78defSmrg RM=$nonopt 10941a4f78defSmrg files= 10942a4f78defSmrg rmforce=false 10943a4f78defSmrg exit_status=0 10944a4f78defSmrg 10945a4f78defSmrg # This variable tells wrapper scripts just to set variables rather 10946a4f78defSmrg # than running their programs. 10947a4f78defSmrg libtool_install_magic=$magic 10948a4f78defSmrg 10949a4f78defSmrg for arg 10950a4f78defSmrg do 10951a4f78defSmrg case $arg in 10952a4f78defSmrg -f) func_append RM " $arg"; rmforce=: ;; 10953a4f78defSmrg -*) func_append RM " $arg" ;; 10954a4f78defSmrg *) func_append files " $arg" ;; 10955a4f78defSmrg esac 10956a4f78defSmrg done 10957a4f78defSmrg 10958a4f78defSmrg test -z "$RM" && \ 10959a4f78defSmrg func_fatal_help "you must specify an RM program" 10960a4f78defSmrg 10961a4f78defSmrg rmdirs= 10962a4f78defSmrg 10963a4f78defSmrg for file in $files; do 10964a4f78defSmrg func_dirname "$file" "" "." 10965a4f78defSmrg dir=$func_dirname_result 10966a4f78defSmrg if test . = "$dir"; then 10967a4f78defSmrg odir=$objdir 10968a4f78defSmrg else 10969a4f78defSmrg odir=$dir/$objdir 10970a4f78defSmrg fi 10971a4f78defSmrg func_basename "$file" 10972a4f78defSmrg name=$func_basename_result 10973a4f78defSmrg test uninstall = "$opt_mode" && odir=$dir 10974a4f78defSmrg 10975a4f78defSmrg # Remember odir for removal later, being careful to avoid duplicates 10976a4f78defSmrg if test clean = "$opt_mode"; then 10977a4f78defSmrg case " $rmdirs " in 10978a4f78defSmrg *" $odir "*) ;; 10979a4f78defSmrg *) func_append rmdirs " $odir" ;; 10980a4f78defSmrg esac 10981a4f78defSmrg fi 10982a4f78defSmrg 10983a4f78defSmrg # Don't error if the file doesn't exist and rm -f was used. 10984a4f78defSmrg if { test -L "$file"; } >/dev/null 2>&1 || 10985a4f78defSmrg { test -h "$file"; } >/dev/null 2>&1 || 10986a4f78defSmrg test -f "$file"; then 10987a4f78defSmrg : 10988a4f78defSmrg elif test -d "$file"; then 10989a4f78defSmrg exit_status=1 10990a4f78defSmrg continue 10991a4f78defSmrg elif $rmforce; then 10992a4f78defSmrg continue 10993a4f78defSmrg fi 10994a4f78defSmrg 10995a4f78defSmrg rmfiles=$file 10996a4f78defSmrg 10997a4f78defSmrg case $name in 10998a4f78defSmrg *.la) 10999a4f78defSmrg # Possibly a libtool archive, so verify it. 11000a4f78defSmrg if func_lalib_p "$file"; then 11001a4f78defSmrg func_source $dir/$name 11002a4f78defSmrg 11003a4f78defSmrg # Delete the libtool libraries and symlinks. 11004a4f78defSmrg for n in $library_names; do 11005a4f78defSmrg func_append rmfiles " $odir/$n" 11006a4f78defSmrg done 11007a4f78defSmrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11008a4f78defSmrg 11009a4f78defSmrg case $opt_mode in 11010a4f78defSmrg clean) 11011a4f78defSmrg case " $library_names " in 11012a4f78defSmrg *" $dlname "*) ;; 11013a4f78defSmrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11014a4f78defSmrg esac 11015a4f78defSmrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11016a4f78defSmrg ;; 11017a4f78defSmrg uninstall) 11018a4f78defSmrg if test -n "$library_names"; then 11019a4f78defSmrg # Do each command in the postuninstall commands. 11020a4f78defSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11021a4f78defSmrg fi 11022a4f78defSmrg 11023a4f78defSmrg if test -n "$old_library"; then 11024a4f78defSmrg # Do each command in the old_postuninstall commands. 11025a4f78defSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11026a4f78defSmrg fi 11027a4f78defSmrg # FIXME: should reinstall the best remaining shared library. 11028a4f78defSmrg ;; 11029a4f78defSmrg esac 11030a4f78defSmrg fi 11031a4f78defSmrg ;; 11032a4f78defSmrg 11033a4f78defSmrg *.lo) 11034a4f78defSmrg # Possibly a libtool object, so verify it. 11035a4f78defSmrg if func_lalib_p "$file"; then 11036a4f78defSmrg 11037a4f78defSmrg # Read the .lo file 11038a4f78defSmrg func_source $dir/$name 11039a4f78defSmrg 11040a4f78defSmrg # Add PIC object to the list of files to remove. 11041a4f78defSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11042a4f78defSmrg func_append rmfiles " $dir/$pic_object" 11043a4f78defSmrg fi 11044a4f78defSmrg 11045a4f78defSmrg # Add non-PIC object to the list of files to remove. 11046a4f78defSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11047a4f78defSmrg func_append rmfiles " $dir/$non_pic_object" 11048a4f78defSmrg fi 11049a4f78defSmrg fi 11050a4f78defSmrg ;; 11051a4f78defSmrg 11052a4f78defSmrg *) 11053a4f78defSmrg if test clean = "$opt_mode"; then 11054a4f78defSmrg noexename=$name 11055a4f78defSmrg case $file in 11056a4f78defSmrg *.exe) 11057a4f78defSmrg func_stripname '' '.exe' "$file" 11058a4f78defSmrg file=$func_stripname_result 11059a4f78defSmrg func_stripname '' '.exe' "$name" 11060a4f78defSmrg noexename=$func_stripname_result 11061a4f78defSmrg # $file with .exe has already been added to rmfiles, 11062a4f78defSmrg # add $file without .exe 11063a4f78defSmrg func_append rmfiles " $file" 11064a4f78defSmrg ;; 11065a4f78defSmrg esac 11066a4f78defSmrg # Do a test to see if this is a libtool program. 11067a4f78defSmrg if func_ltwrapper_p "$file"; then 11068a4f78defSmrg if func_ltwrapper_executable_p "$file"; then 11069a4f78defSmrg func_ltwrapper_scriptname "$file" 11070a4f78defSmrg relink_command= 11071a4f78defSmrg func_source $func_ltwrapper_scriptname_result 11072a4f78defSmrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11073a4f78defSmrg else 11074a4f78defSmrg relink_command= 11075a4f78defSmrg func_source $dir/$noexename 11076a4f78defSmrg fi 11077a4f78defSmrg 11078a4f78defSmrg # note $name still contains .exe if it was in $file originally 11079a4f78defSmrg # as does the version of $file that was added into $rmfiles 11080a4f78defSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11081a4f78defSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11082a4f78defSmrg func_append rmfiles " $odir/lt-$name" 11083a4f78defSmrg fi 11084a4f78defSmrg if test "X$noexename" != "X$name"; then 11085a4f78defSmrg func_append rmfiles " $odir/lt-$noexename.c" 11086a4f78defSmrg fi 11087a4f78defSmrg fi 11088a4f78defSmrg fi 11089a4f78defSmrg ;; 11090a4f78defSmrg esac 11091a4f78defSmrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11092a4f78defSmrg done 11093a4f78defSmrg 11094a4f78defSmrg # Try to remove the $objdir's in the directories where we deleted files 11095a4f78defSmrg for dir in $rmdirs; do 11096a4f78defSmrg if test -d "$dir"; then 11097a4f78defSmrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11098a4f78defSmrg fi 11099a4f78defSmrg done 11100a4f78defSmrg 11101a4f78defSmrg exit $exit_status 11102a4f78defSmrg} 11103a4f78defSmrg 11104a4f78defSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11105a4f78defSmrg func_mode_uninstall ${1+"$@"} 11106a4f78defSmrgfi 11107a4f78defSmrg 11108a4f78defSmrgtest -z "$opt_mode" && { 11109a4f78defSmrg help=$generic_help 11110a4f78defSmrg func_fatal_help "you must specify a MODE" 11111a4f78defSmrg} 11112a4f78defSmrg 11113a4f78defSmrgtest -z "$exec_cmd" && \ 11114a4f78defSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11115a4f78defSmrg 11116a4f78defSmrgif test -n "$exec_cmd"; then 11117a4f78defSmrg eval exec "$exec_cmd" 11118a4f78defSmrg exit $EXIT_FAILURE 11119a4f78defSmrgfi 11120a4f78defSmrg 11121a4f78defSmrgexit $exit_status 11122a4f78defSmrg 11123a4f78defSmrg 11124a4f78defSmrg# The TAGs below are defined such that we never get into a situation 11125a4f78defSmrg# where we disable both kinds of libraries. Given conflicting 11126a4f78defSmrg# choices, we go for a static library, that is the most portable, 11127a4f78defSmrg# since we can't tell whether shared libraries were disabled because 11128a4f78defSmrg# the user asked for that or because the platform doesn't support 11129a4f78defSmrg# them. This is particularly important on AIX, because we don't 11130a4f78defSmrg# support having both static and shared libraries enabled at the same 11131a4f78defSmrg# time on that platform, so we default to a shared-only configuration. 11132a4f78defSmrg# If a disable-shared tag is given, we'll fallback to a static-only 11133a4f78defSmrg# configuration. But we'll never go from static-only to shared-only. 11134a4f78defSmrg 11135a4f78defSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11136a4f78defSmrgbuild_libtool_libs=no 11137a4f78defSmrgbuild_old_libs=yes 11138a4f78defSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 11139a4f78defSmrg 11140a4f78defSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 11141a4f78defSmrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11142a4f78defSmrg# ### END LIBTOOL TAG CONFIG: disable-static 11143a4f78defSmrg 11144a4f78defSmrg# Local Variables: 11145a4f78defSmrg# mode:shell-script 11146a4f78defSmrg# sh-indentation:2 11147a4f78defSmrg# End: 11148