ltmain.sh revision b312a94c
1b312a94cSmrg#! /bin/sh 2b312a94cSmrg## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3b312a94cSmrg## by inline-source v2014-01-03.01 465eef222Smrg 5b312a94cSmrg# libtool (GNU libtool) 2.4.6 6b312a94cSmrg# Provide generalized library-building support services. 765eef222Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 865eef222Smrg 9b312a94cSmrg# Copyright (C) 1996-2015 Free Software Foundation, Inc. 1065eef222Smrg# This is free software; see the source for copying conditions. There is NO 1165eef222Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1265eef222Smrg 1365eef222Smrg# GNU Libtool is free software; you can redistribute it and/or modify 14ef981d24Smrg# it under the terms of the GNU General Public License as published by 15ef981d24Smrg# the Free Software Foundation; either version 2 of the License, or 16ef981d24Smrg# (at your option) any later version. 17ef981d24Smrg# 1865eef222Smrg# As a special exception to the GNU General Public License, 1965eef222Smrg# if you distribute this file as part of a program or library that 2065eef222Smrg# is built using GNU Libtool, you may include this file under the 2165eef222Smrg# same distribution terms that you use for the rest of that program. 2265eef222Smrg# 2365eef222Smrg# GNU Libtool is distributed in the hope that it will be useful, but 24ef981d24Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 25ef981d24Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26ef981d24Smrg# General Public License for more details. 27ef981d24Smrg# 28ef981d24Smrg# You should have received a copy of the GNU General Public License 29b312a94cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 3065eef222Smrg 3165eef222Smrg 3256957a04SmrgPROGRAM=libtool 3365eef222SmrgPACKAGE=libtool 34b312a94cSmrgVERSION=2.4.6 35b312a94cSmrgpackage_revision=2.4.6 3665eef222Smrg 37b312a94cSmrg 38b312a94cSmrg## ------ ## 39b312a94cSmrg## Usage. ## 40b312a94cSmrg## ------ ## 41b312a94cSmrg 42b312a94cSmrg# Run './libtool --help' for help with using this script from the 43b312a94cSmrg# command line. 44b312a94cSmrg 45b312a94cSmrg 46b312a94cSmrg## ------------------------------- ## 47b312a94cSmrg## User overridable command paths. ## 48b312a94cSmrg## ------------------------------- ## 49b312a94cSmrg 50b312a94cSmrg# After configure completes, it has a better idea of some of the 51b312a94cSmrg# shell tools we need than the defaults used by the functions shared 52b312a94cSmrg# with bootstrap, so set those here where they can still be over- 53b312a94cSmrg# ridden by the user, but otherwise take precedence. 54b312a94cSmrg 55b312a94cSmrg: ${AUTOCONF="autoconf"} 56b312a94cSmrg: ${AUTOMAKE="automake"} 57b312a94cSmrg 58b312a94cSmrg 59b312a94cSmrg## -------------------------- ## 60b312a94cSmrg## Source external libraries. ## 61b312a94cSmrg## -------------------------- ## 62b312a94cSmrg 63b312a94cSmrg# Much of our low-level functionality needs to be sourced from external 64b312a94cSmrg# libraries, which are installed to $pkgauxdir. 65b312a94cSmrg 66b312a94cSmrg# Set a version string for this script. 67b312a94cSmrgscriptversion=2015-01-20.17; # UTC 68b312a94cSmrg 69b312a94cSmrg# General shell script boiler plate, and helper functions. 70b312a94cSmrg# Written by Gary V. Vaughan, 2004 71b312a94cSmrg 72b312a94cSmrg# Copyright (C) 2004-2015 Free Software Foundation, Inc. 73b312a94cSmrg# This is free software; see the source for copying conditions. There is NO 74b312a94cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 75b312a94cSmrg 76b312a94cSmrg# This program is free software; you can redistribute it and/or modify 77b312a94cSmrg# it under the terms of the GNU General Public License as published by 78b312a94cSmrg# the Free Software Foundation; either version 3 of the License, or 79b312a94cSmrg# (at your option) any later version. 80b312a94cSmrg 81b312a94cSmrg# As a special exception to the GNU General Public License, if you distribute 82b312a94cSmrg# this file as part of a program or library that is built using GNU Libtool, 83b312a94cSmrg# you may include this file under the same distribution terms that you use 84b312a94cSmrg# for the rest of that program. 85b312a94cSmrg 86b312a94cSmrg# This program is distributed in the hope that it will be useful, 87b312a94cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 88b312a94cSmrg# MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU 89b312a94cSmrg# General Public License for more details. 90b312a94cSmrg 91b312a94cSmrg# You should have received a copy of the GNU General Public License 92b312a94cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 93b312a94cSmrg 94b312a94cSmrg# Please report bugs or propose patches to gary@gnu.org. 95b312a94cSmrg 96b312a94cSmrg 97b312a94cSmrg## ------ ## 98b312a94cSmrg## Usage. ## 99b312a94cSmrg## ------ ## 100b312a94cSmrg 101b312a94cSmrg# Evaluate this file near the top of your script to gain access to 102b312a94cSmrg# the functions and variables defined here: 103b312a94cSmrg# 104b312a94cSmrg# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 105b312a94cSmrg# 106b312a94cSmrg# If you need to override any of the default environment variable 107b312a94cSmrg# settings, do that before evaluating this file. 108b312a94cSmrg 109b312a94cSmrg 110b312a94cSmrg## -------------------- ## 111b312a94cSmrg## Shell normalisation. ## 112b312a94cSmrg## -------------------- ## 113b312a94cSmrg 114b312a94cSmrg# Some shells need a little help to be as Bourne compatible as possible. 115b312a94cSmrg# Before doing anything else, make sure all that help has been provided! 116b312a94cSmrg 117b312a94cSmrgDUALCASE=1; export DUALCASE # for MKS sh 118b312a94cSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 11965eef222Smrg emulate sh 12065eef222Smrg NULLCMD=: 121b312a94cSmrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 12265eef222Smrg # is contrary to our usage. Disable this feature. 12365eef222Smrg alias -g '${1+"$@"}'='"$@"' 12465eef222Smrg setopt NO_GLOB_SUBST 12565eef222Smrgelse 126b312a94cSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 12765eef222Smrgfi 12856957a04Smrg 129b312a94cSmrg# NLS nuisances: We save the old values in case they are required later. 130b312a94cSmrg_G_user_locale= 131b312a94cSmrg_G_safe_locale= 132b312a94cSmrgfor _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 13365eef222Smrgdo 134b312a94cSmrg eval "if test set = \"\${$_G_var+set}\"; then 135b312a94cSmrg save_$_G_var=\$$_G_var 136b312a94cSmrg $_G_var=C 137b312a94cSmrg export $_G_var 138b312a94cSmrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 139b312a94cSmrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 14065eef222Smrg fi" 14165eef222Smrgdone 14265eef222Smrg 143b312a94cSmrg# CDPATH. 144b312a94cSmrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 14565eef222Smrg 146b312a94cSmrg# Make sure IFS has a sensible default 147b312a94cSmrgsp=' ' 148b312a94cSmrgnl=' 149b312a94cSmrg' 150b312a94cSmrgIFS="$sp $nl" 151b312a94cSmrg 152b312a94cSmrg# There are apparently some retarded systems that use ';' as a PATH separator! 153b312a94cSmrgif test "${PATH_SEPARATOR+set}" != set; then 154b312a94cSmrg PATH_SEPARATOR=: 155b312a94cSmrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 156b312a94cSmrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 157b312a94cSmrg PATH_SEPARATOR=';' 158b312a94cSmrg } 159b312a94cSmrgfi 16065eef222Smrg 16165eef222Smrg 16265eef222Smrg 163b312a94cSmrg## ------------------------- ## 164b312a94cSmrg## Locate command utilities. ## 165b312a94cSmrg## ------------------------- ## 166b312a94cSmrg 167b312a94cSmrg 168b312a94cSmrg# func_executable_p FILE 169b312a94cSmrg# ---------------------- 170b312a94cSmrg# Check that FILE is an executable regular file. 171b312a94cSmrgfunc_executable_p () 172b312a94cSmrg{ 173b312a94cSmrg test -f "$1" && test -x "$1" 174b312a94cSmrg} 175b312a94cSmrg 176b312a94cSmrg 177b312a94cSmrg# func_path_progs PROGS_LIST CHECK_FUNC [PATH] 178b312a94cSmrg# -------------------------------------------- 179b312a94cSmrg# Search for either a program that responds to --version with output 180b312a94cSmrg# containing "GNU", or else returned by CHECK_FUNC otherwise, by 181b312a94cSmrg# trying all the directories in PATH with each of the elements of 182b312a94cSmrg# PROGS_LIST. 183b312a94cSmrg# 184b312a94cSmrg# CHECK_FUNC should accept the path to a candidate program, and 185b312a94cSmrg# set $func_check_prog_result if it truncates its output less than 186b312a94cSmrg# $_G_path_prog_max characters. 187b312a94cSmrgfunc_path_progs () 188b312a94cSmrg{ 189b312a94cSmrg _G_progs_list=$1 190b312a94cSmrg _G_check_func=$2 191b312a94cSmrg _G_PATH=${3-"$PATH"} 192b312a94cSmrg 193b312a94cSmrg _G_path_prog_max=0 194b312a94cSmrg _G_path_prog_found=false 195b312a94cSmrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 196b312a94cSmrg for _G_dir in $_G_PATH; do 197b312a94cSmrg IFS=$_G_save_IFS 198b312a94cSmrg test -z "$_G_dir" && _G_dir=. 199b312a94cSmrg for _G_prog_name in $_G_progs_list; do 200b312a94cSmrg for _exeext in '' .EXE; do 201b312a94cSmrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 202b312a94cSmrg func_executable_p "$_G_path_prog" || continue 203b312a94cSmrg case `"$_G_path_prog" --version 2>&1` in 204b312a94cSmrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 205b312a94cSmrg *) $_G_check_func $_G_path_prog 206b312a94cSmrg func_path_progs_result=$func_check_prog_result 207b312a94cSmrg ;; 208b312a94cSmrg esac 209b312a94cSmrg $_G_path_prog_found && break 3 210b312a94cSmrg done 211b312a94cSmrg done 212b312a94cSmrg done 213b312a94cSmrg IFS=$_G_save_IFS 214b312a94cSmrg test -z "$func_path_progs_result" && { 215b312a94cSmrg echo "no acceptable sed could be found in \$PATH" >&2 216b312a94cSmrg exit 1 217b312a94cSmrg } 218b312a94cSmrg} 219b312a94cSmrg 220b312a94cSmrg 221b312a94cSmrg# We want to be able to use the functions in this file before configure 222b312a94cSmrg# has figured out where the best binaries are kept, which means we have 223b312a94cSmrg# to search for them ourselves - except when the results are already set 224b312a94cSmrg# where we skip the searches. 225b312a94cSmrg 226b312a94cSmrg# Unless the user overrides by setting SED, search the path for either GNU 227b312a94cSmrg# sed, or the sed that truncates its output the least. 228b312a94cSmrgtest -z "$SED" && { 229b312a94cSmrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 230b312a94cSmrg for _G_i in 1 2 3 4 5 6 7; do 231b312a94cSmrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 232b312a94cSmrg done 233b312a94cSmrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 234b312a94cSmrg _G_sed_script= 235b312a94cSmrg 236b312a94cSmrg func_check_prog_sed () 237b312a94cSmrg { 238b312a94cSmrg _G_path_prog=$1 239b312a94cSmrg 240b312a94cSmrg _G_count=0 241b312a94cSmrg printf 0123456789 >conftest.in 242b312a94cSmrg while : 243b312a94cSmrg do 244b312a94cSmrg cat conftest.in conftest.in >conftest.tmp 245b312a94cSmrg mv conftest.tmp conftest.in 246b312a94cSmrg cp conftest.in conftest.nl 247b312a94cSmrg echo '' >> conftest.nl 248b312a94cSmrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 249b312a94cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 250b312a94cSmrg _G_count=`expr $_G_count + 1` 251b312a94cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 252b312a94cSmrg # Best one so far, save it but keep looking for a better one 253b312a94cSmrg func_check_prog_result=$_G_path_prog 254b312a94cSmrg _G_path_prog_max=$_G_count 255b312a94cSmrg fi 256b312a94cSmrg # 10*(2^10) chars as input seems more than enough 257b312a94cSmrg test 10 -lt "$_G_count" && break 258b312a94cSmrg done 259b312a94cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 260b312a94cSmrg } 261b312a94cSmrg 262b312a94cSmrg func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin 263b312a94cSmrg rm -f conftest.sed 264b312a94cSmrg SED=$func_path_progs_result 265b312a94cSmrg} 266b312a94cSmrg 267b312a94cSmrg 268b312a94cSmrg# Unless the user overrides by setting GREP, search the path for either GNU 269b312a94cSmrg# grep, or the grep that truncates its output the least. 270b312a94cSmrgtest -z "$GREP" && { 271b312a94cSmrg func_check_prog_grep () 272b312a94cSmrg { 273b312a94cSmrg _G_path_prog=$1 274b312a94cSmrg 275b312a94cSmrg _G_count=0 276b312a94cSmrg _G_path_prog_max=0 277b312a94cSmrg printf 0123456789 >conftest.in 278b312a94cSmrg while : 279b312a94cSmrg do 280b312a94cSmrg cat conftest.in conftest.in >conftest.tmp 281b312a94cSmrg mv conftest.tmp conftest.in 282b312a94cSmrg cp conftest.in conftest.nl 283b312a94cSmrg echo 'GREP' >> conftest.nl 284b312a94cSmrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 285b312a94cSmrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 286b312a94cSmrg _G_count=`expr $_G_count + 1` 287b312a94cSmrg if test "$_G_count" -gt "$_G_path_prog_max"; then 288b312a94cSmrg # Best one so far, save it but keep looking for a better one 289b312a94cSmrg func_check_prog_result=$_G_path_prog 290b312a94cSmrg _G_path_prog_max=$_G_count 291b312a94cSmrg fi 292b312a94cSmrg # 10*(2^10) chars as input seems more than enough 293b312a94cSmrg test 10 -lt "$_G_count" && break 294b312a94cSmrg done 295b312a94cSmrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 296b312a94cSmrg } 297b312a94cSmrg 298b312a94cSmrg func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin 299b312a94cSmrg GREP=$func_path_progs_result 300b312a94cSmrg} 301b312a94cSmrg 302b312a94cSmrg 303b312a94cSmrg## ------------------------------- ## 304b312a94cSmrg## User overridable command paths. ## 305b312a94cSmrg## ------------------------------- ## 306b312a94cSmrg 307b312a94cSmrg# All uppercase variable names are used for environment variables. These 308b312a94cSmrg# variables can be overridden by the user before calling a script that 309b312a94cSmrg# uses them if a suitable command of that name is not already available 310b312a94cSmrg# in the command search PATH. 31165eef222Smrg 31265eef222Smrg: ${CP="cp -f"} 313b312a94cSmrg: ${ECHO="printf %s\n"} 314b312a94cSmrg: ${EGREP="$GREP -E"} 315b312a94cSmrg: ${FGREP="$GREP -F"} 31665eef222Smrg: ${LN_S="ln -s"} 31765eef222Smrg: ${MAKE="make"} 31865eef222Smrg: ${MKDIR="mkdir"} 31965eef222Smrg: ${MV="mv -f"} 32065eef222Smrg: ${RM="rm -f"} 32165eef222Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 32265eef222Smrg 32365eef222Smrg 324b312a94cSmrg## -------------------- ## 325b312a94cSmrg## Useful sed snippets. ## 326b312a94cSmrg## -------------------- ## 327200d7199Smrg 328b312a94cSmrgsed_dirname='s|/[^/]*$||' 329b312a94cSmrgsed_basename='s|^.*/||' 330200d7199Smrg 331b312a94cSmrg# Sed substitution that helps us do robust quoting. It backslashifies 332b312a94cSmrg# metacharacters that are still active within double-quoted strings. 333b312a94cSmrgsed_quote_subst='s|\([`"$\\]\)|\\\1|g' 334200d7199Smrg 335b312a94cSmrg# Same as above, but do not quote variable references. 336b312a94cSmrgsed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 337200d7199Smrg 338b312a94cSmrg# Sed substitution that turns a string into a regex matching for the 339b312a94cSmrg# string literally. 340b312a94cSmrgsed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 341200d7199Smrg 342b312a94cSmrg# Sed substitution that converts a w32 file name or path 343b312a94cSmrg# that contains forward slashes, into one that contains 344b312a94cSmrg# (escaped) backslashes. A very naive implementation. 345b312a94cSmrgsed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 346b312a94cSmrg 347b312a94cSmrg# Re-'\' parameter expansions in output of sed_double_quote_subst that 348b312a94cSmrg# were '\'-ed in input to the same. If an odd number of '\' preceded a 349b312a94cSmrg# '$' in input to sed_double_quote_subst, that '$' was protected from 350b312a94cSmrg# expansion. Since each input '\' is now two '\'s, look for any number 351b312a94cSmrg# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 352b312a94cSmrg_G_bs='\\' 353b312a94cSmrg_G_bs2='\\\\' 354b312a94cSmrg_G_bs4='\\\\\\\\' 355b312a94cSmrg_G_dollar='\$' 356b312a94cSmrgsed_double_backslash="\ 357b312a94cSmrg s/$_G_bs4/&\\ 358b312a94cSmrg/g 359b312a94cSmrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 360b312a94cSmrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 361b312a94cSmrg s/\n//g" 362200d7199Smrg 36365eef222Smrg 364b312a94cSmrg## ----------------- ## 365b312a94cSmrg## Global variables. ## 366b312a94cSmrg## ----------------- ## 367ef981d24Smrg 368b312a94cSmrg# Except for the global variables explicitly listed below, the following 369b312a94cSmrg# functions in the '^func_' namespace, and the '^require_' namespace 370b312a94cSmrg# variables initialised in the 'Resource management' section, sourcing 371b312a94cSmrg# this file will not pollute your global namespace with anything 372b312a94cSmrg# else. There's no portable way to scope variables in Bourne shell 373b312a94cSmrg# though, so actually running these functions will sometimes place 374b312a94cSmrg# results into a variable named after the function, and often use 375b312a94cSmrg# temporary variables in the '^_G_' namespace. If you are careful to 376b312a94cSmrg# avoid using those namespaces casually in your sourcing script, things 377b312a94cSmrg# should continue to work as you expect. And, of course, you can freely 378b312a94cSmrg# overwrite any of the functions or variables defined here before 379b312a94cSmrg# calling anything to customize them. 38056957a04Smrg 381b312a94cSmrgEXIT_SUCCESS=0 382b312a94cSmrgEXIT_FAILURE=1 383b312a94cSmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 384b312a94cSmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 38556957a04Smrg 386b312a94cSmrg# Allow overriding, eg assuming that you follow the convention of 387b312a94cSmrg# putting '$debug_cmd' at the start of all your functions, you can get 388b312a94cSmrg# bash to show function call trace with: 389b312a94cSmrg# 390b312a94cSmrg# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 391b312a94cSmrgdebug_cmd=${debug_cmd-":"} 392b312a94cSmrgexit_cmd=: 39356957a04Smrg 394b312a94cSmrg# By convention, finish your script with: 395b312a94cSmrg# 396b312a94cSmrg# exit $exit_status 397b312a94cSmrg# 398b312a94cSmrg# so that you can set exit_status to non-zero if you want to indicate 399b312a94cSmrg# something went wrong during execution without actually bailing out at 400b312a94cSmrg# the point of failure. 401b312a94cSmrgexit_status=$EXIT_SUCCESS 40256957a04Smrg 403b312a94cSmrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 404b312a94cSmrg# is ksh but when the shell is invoked as "sh" and the current value of 405b312a94cSmrg# the _XPG environment variable is not equal to 1 (one), the special 406b312a94cSmrg# positional parameter $0, within a function call, is the name of the 407b312a94cSmrg# function. 408b312a94cSmrgprogpath=$0 409ef981d24Smrg 410b312a94cSmrg# The name of this program. 411b312a94cSmrgprogname=`$ECHO "$progpath" |$SED "$sed_basename"` 412ef981d24Smrg 413b312a94cSmrg# Make sure we have an absolute progpath for reexecution: 41465eef222Smrgcase $progpath in 41565eef222Smrg [\\/]*|[A-Za-z]:\\*) ;; 41665eef222Smrg *[\\/]*) 417b312a94cSmrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 41865eef222Smrg progdir=`cd "$progdir" && pwd` 419b312a94cSmrg progpath=$progdir/$progname 42065eef222Smrg ;; 42165eef222Smrg *) 422b312a94cSmrg _G_IFS=$IFS 423b312a94cSmrg IFS=${PATH_SEPARATOR-:} 42465eef222Smrg for progdir in $PATH; do 425b312a94cSmrg IFS=$_G_IFS 42665eef222Smrg test -x "$progdir/$progname" && break 42765eef222Smrg done 428b312a94cSmrg IFS=$_G_IFS 42965eef222Smrg test -n "$progdir" || progdir=`pwd` 430b312a94cSmrg progpath=$progdir/$progname 43165eef222Smrg ;; 43265eef222Smrgesac 433ef981d24Smrg 43465eef222Smrg 435b312a94cSmrg## ----------------- ## 436b312a94cSmrg## Standard options. ## 437b312a94cSmrg## ----------------- ## 438200d7199Smrg 439b312a94cSmrg# The following options affect the operation of the functions defined 440b312a94cSmrg# below, and should be set appropriately depending on run-time para- 441b312a94cSmrg# meters passed on the command line. 44265eef222Smrg 44365eef222Smrgopt_dry_run=false 44465eef222Smrgopt_quiet=false 44565eef222Smrgopt_verbose=false 44665eef222Smrg 447b312a94cSmrg# Categories 'all' and 'none' are always available. Append any others 448b312a94cSmrg# you will pass as the first argument to func_warning from your own 449b312a94cSmrg# code. 450b312a94cSmrgwarning_categories= 451ef981d24Smrg 452b312a94cSmrg# By default, display warnings according to 'opt_warning_types'. Set 453b312a94cSmrg# 'warning_func' to ':' to elide all warnings, or func_fatal_error to 454b312a94cSmrg# treat the next displayed warning as a fatal error. 455b312a94cSmrgwarning_func=func_warn_and_continue 456ef981d24Smrg 457b312a94cSmrg# Set to 'all' to display all warnings, 'none' to suppress all 458b312a94cSmrg# warnings, or a space delimited list of some subset of 459b312a94cSmrg# 'warning_categories' to display only the listed warnings. 460b312a94cSmrgopt_warning_types=all 461ef981d24Smrg 46256957a04Smrg 463b312a94cSmrg## -------------------- ## 464b312a94cSmrg## Resource management. ## 465b312a94cSmrg## -------------------- ## 466ef981d24Smrg 467b312a94cSmrg# This section contains definitions for functions that each ensure a 468b312a94cSmrg# particular resource (a file, or a non-empty configuration variable for 469b312a94cSmrg# example) is available, and if appropriate to extract default values 470b312a94cSmrg# from pertinent package files. Call them using their associated 471b312a94cSmrg# 'require_*' variable to ensure that they are executed, at most, once. 472b312a94cSmrg# 473b312a94cSmrg# It's entirely deliberate that calling these functions can set 474b312a94cSmrg# variables that don't obey the namespace limitations obeyed by the rest 475b312a94cSmrg# of this file, in order that that they be as useful as possible to 476b312a94cSmrg# callers. 477ef981d24Smrg 478ef981d24Smrg 479b312a94cSmrg# require_term_colors 480b312a94cSmrg# ------------------- 481b312a94cSmrg# Allow display of bold text on terminals that support it. 482b312a94cSmrgrequire_term_colors=func_require_term_colors 483b312a94cSmrgfunc_require_term_colors () 48465eef222Smrg{ 485b312a94cSmrg $debug_cmd 486b312a94cSmrg 487b312a94cSmrg test -t 1 && { 488b312a94cSmrg # COLORTERM and USE_ANSI_COLORS environment variables take 489b312a94cSmrg # precedence, because most terminfo databases neglect to describe 490b312a94cSmrg # whether color sequences are supported. 491b312a94cSmrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 492b312a94cSmrg 493b312a94cSmrg if test 1 = "$USE_ANSI_COLORS"; then 494b312a94cSmrg # Standard ANSI escape sequences 495b312a94cSmrg tc_reset='[0m' 496b312a94cSmrg tc_bold='[1m'; tc_standout='[7m' 497b312a94cSmrg tc_red='[31m'; tc_green='[32m' 498b312a94cSmrg tc_blue='[34m'; tc_cyan='[36m' 499b312a94cSmrg else 500b312a94cSmrg # Otherwise trust the terminfo database after all. 501b312a94cSmrg test -n "`tput sgr0 2>/dev/null`" && { 502b312a94cSmrg tc_reset=`tput sgr0` 503b312a94cSmrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 504b312a94cSmrg tc_standout=$tc_bold 505b312a94cSmrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 506b312a94cSmrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 507b312a94cSmrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 508b312a94cSmrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 509b312a94cSmrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 510b312a94cSmrg } 511b312a94cSmrg fi 512b312a94cSmrg } 513ef981d24Smrg 514b312a94cSmrg require_term_colors=: 51565eef222Smrg} 516ef981d24Smrg 517ef981d24Smrg 518b312a94cSmrg## ----------------- ## 519b312a94cSmrg## Function library. ## 520b312a94cSmrg## ----------------- ## 521b312a94cSmrg 522b312a94cSmrg# This section contains a variety of useful functions to call in your 523b312a94cSmrg# scripts. Take note of the portable wrappers for features provided by 524b312a94cSmrg# some modern shells, which will fall back to slower equivalents on 525b312a94cSmrg# less featureful shells. 526b312a94cSmrg 527b312a94cSmrg 528b312a94cSmrg# func_append VAR VALUE 529b312a94cSmrg# --------------------- 530b312a94cSmrg# Append VALUE onto the existing contents of VAR. 531b312a94cSmrg 532b312a94cSmrg # We should try to minimise forks, especially on Windows where they are 533b312a94cSmrg # unreasonably slow, so skip the feature probes when bash or zsh are 534b312a94cSmrg # being used: 535b312a94cSmrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 536b312a94cSmrg : ${_G_HAVE_ARITH_OP="yes"} 537b312a94cSmrg : ${_G_HAVE_XSI_OPS="yes"} 538b312a94cSmrg # The += operator was introduced in bash 3.1 539b312a94cSmrg case $BASH_VERSION in 540b312a94cSmrg [12].* | 3.0 | 3.0*) ;; 541b312a94cSmrg *) 542b312a94cSmrg : ${_G_HAVE_PLUSEQ_OP="yes"} 543b312a94cSmrg ;; 544b312a94cSmrg esac 545b312a94cSmrg fi 546b312a94cSmrg 547b312a94cSmrg # _G_HAVE_PLUSEQ_OP 548b312a94cSmrg # Can be empty, in which case the shell is probed, "yes" if += is 549b312a94cSmrg # useable or anything else if it does not work. 550b312a94cSmrg test -z "$_G_HAVE_PLUSEQ_OP" \ 551b312a94cSmrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 552b312a94cSmrg && _G_HAVE_PLUSEQ_OP=yes 553b312a94cSmrg 554b312a94cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP" 555b312a94cSmrgthen 556b312a94cSmrg # This is an XSI compatible shell, allowing a faster implementation... 557b312a94cSmrg eval 'func_append () 558b312a94cSmrg { 559b312a94cSmrg $debug_cmd 560b312a94cSmrg 561b312a94cSmrg eval "$1+=\$2" 562b312a94cSmrg }' 563b312a94cSmrgelse 564b312a94cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 565b312a94cSmrg func_append () 566b312a94cSmrg { 567b312a94cSmrg $debug_cmd 568b312a94cSmrg 569b312a94cSmrg eval "$1=\$$1\$2" 570b312a94cSmrg } 571b312a94cSmrgfi 572b312a94cSmrg 573b312a94cSmrg 574b312a94cSmrg# func_append_quoted VAR VALUE 575b312a94cSmrg# ---------------------------- 576b312a94cSmrg# Quote VALUE and append to the end of shell variable VAR, separated 577b312a94cSmrg# by a space. 578b312a94cSmrgif test yes = "$_G_HAVE_PLUSEQ_OP"; then 579b312a94cSmrg eval 'func_append_quoted () 580b312a94cSmrg { 581b312a94cSmrg $debug_cmd 582b312a94cSmrg 583b312a94cSmrg func_quote_for_eval "$2" 584b312a94cSmrg eval "$1+=\\ \$func_quote_for_eval_result" 585b312a94cSmrg }' 586b312a94cSmrgelse 587b312a94cSmrg func_append_quoted () 588b312a94cSmrg { 589b312a94cSmrg $debug_cmd 590b312a94cSmrg 591b312a94cSmrg func_quote_for_eval "$2" 592b312a94cSmrg eval "$1=\$$1\\ \$func_quote_for_eval_result" 593b312a94cSmrg } 594b312a94cSmrgfi 595b312a94cSmrg 596b312a94cSmrg 597b312a94cSmrg# func_append_uniq VAR VALUE 598b312a94cSmrg# -------------------------- 599b312a94cSmrg# Append unique VALUE onto the existing contents of VAR, assuming 600b312a94cSmrg# entries are delimited by the first character of VALUE. For example: 601b312a94cSmrg# 602b312a94cSmrg# func_append_uniq options " --another-option option-argument" 603b312a94cSmrg# 604b312a94cSmrg# will only append to $options if " --another-option option-argument " 605b312a94cSmrg# is not already present somewhere in $options already (note spaces at 606b312a94cSmrg# each end implied by leading space in second argument). 607b312a94cSmrgfunc_append_uniq () 608b312a94cSmrg{ 609b312a94cSmrg $debug_cmd 610b312a94cSmrg 611b312a94cSmrg eval _G_current_value='`$ECHO $'$1'`' 612b312a94cSmrg _G_delim=`expr "$2" : '\(.\)'` 613b312a94cSmrg 614b312a94cSmrg case $_G_delim$_G_current_value$_G_delim in 615b312a94cSmrg *"$2$_G_delim"*) ;; 616b312a94cSmrg *) func_append "$@" ;; 617b312a94cSmrg esac 618b312a94cSmrg} 619b312a94cSmrg 620b312a94cSmrg 621b312a94cSmrg# func_arith TERM... 622b312a94cSmrg# ------------------ 623b312a94cSmrg# Set func_arith_result to the result of evaluating TERMs. 624b312a94cSmrg test -z "$_G_HAVE_ARITH_OP" \ 625b312a94cSmrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 626b312a94cSmrg && _G_HAVE_ARITH_OP=yes 627b312a94cSmrg 628b312a94cSmrgif test yes = "$_G_HAVE_ARITH_OP"; then 629b312a94cSmrg eval 'func_arith () 630b312a94cSmrg { 631b312a94cSmrg $debug_cmd 632b312a94cSmrg 633b312a94cSmrg func_arith_result=$(( $* )) 634b312a94cSmrg }' 635b312a94cSmrgelse 636b312a94cSmrg func_arith () 637b312a94cSmrg { 638b312a94cSmrg $debug_cmd 639b312a94cSmrg 640b312a94cSmrg func_arith_result=`expr "$@"` 641b312a94cSmrg } 642b312a94cSmrgfi 643b312a94cSmrg 644b312a94cSmrg 645b312a94cSmrg# func_basename FILE 646b312a94cSmrg# ------------------ 647b312a94cSmrg# Set func_basename_result to FILE with everything up to and including 648b312a94cSmrg# the last / stripped. 649b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 650b312a94cSmrg # If this shell supports suffix pattern removal, then use it to avoid 651b312a94cSmrg # forking. Hide the definitions single quotes in case the shell chokes 652b312a94cSmrg # on unsupported syntax... 653b312a94cSmrg _b='func_basename_result=${1##*/}' 654b312a94cSmrg _d='case $1 in 655b312a94cSmrg */*) func_dirname_result=${1%/*}$2 ;; 656b312a94cSmrg * ) func_dirname_result=$3 ;; 657b312a94cSmrg esac' 658b312a94cSmrg 659b312a94cSmrgelse 660b312a94cSmrg # ...otherwise fall back to using sed. 661b312a94cSmrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 662b312a94cSmrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 663b312a94cSmrg if test "X$func_dirname_result" = "X$1"; then 664b312a94cSmrg func_dirname_result=$3 665b312a94cSmrg else 666b312a94cSmrg func_append func_dirname_result "$2" 667b312a94cSmrg fi' 668b312a94cSmrgfi 669b312a94cSmrg 670b312a94cSmrgeval 'func_basename () 671b312a94cSmrg{ 672b312a94cSmrg $debug_cmd 673b312a94cSmrg 674b312a94cSmrg '"$_b"' 675b312a94cSmrg}' 676b312a94cSmrg 677b312a94cSmrg 678b312a94cSmrg# func_dirname FILE APPEND NONDIR_REPLACEMENT 679b312a94cSmrg# ------------------------------------------- 680b312a94cSmrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 681b312a94cSmrg# otherwise set result to NONDIR_REPLACEMENT. 682b312a94cSmrgeval 'func_dirname () 683b312a94cSmrg{ 684b312a94cSmrg $debug_cmd 685b312a94cSmrg 686b312a94cSmrg '"$_d"' 687b312a94cSmrg}' 688b312a94cSmrg 689b312a94cSmrg 690b312a94cSmrg# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 691b312a94cSmrg# -------------------------------------------------------- 692b312a94cSmrg# Perform func_basename and func_dirname in a single function 693b312a94cSmrg# call: 694b312a94cSmrg# dirname: Compute the dirname of FILE. If nonempty, 695b312a94cSmrg# add APPEND to the result, otherwise set result 696b312a94cSmrg# to NONDIR_REPLACEMENT. 697b312a94cSmrg# value returned in "$func_dirname_result" 698b312a94cSmrg# basename: Compute filename of FILE. 699b312a94cSmrg# value retuned in "$func_basename_result" 700b312a94cSmrg# For efficiency, we do not delegate to the functions above but instead 701b312a94cSmrg# duplicate the functionality here. 702b312a94cSmrgeval 'func_dirname_and_basename () 703b312a94cSmrg{ 704b312a94cSmrg $debug_cmd 705b312a94cSmrg 706b312a94cSmrg '"$_b"' 707b312a94cSmrg '"$_d"' 708b312a94cSmrg}' 709b312a94cSmrg 710b312a94cSmrg 711b312a94cSmrg# func_echo ARG... 712b312a94cSmrg# ---------------- 713b312a94cSmrg# Echo program name prefixed message. 714b312a94cSmrgfunc_echo () 715b312a94cSmrg{ 716b312a94cSmrg $debug_cmd 717b312a94cSmrg 718b312a94cSmrg _G_message=$* 719b312a94cSmrg 720b312a94cSmrg func_echo_IFS=$IFS 721b312a94cSmrg IFS=$nl 722b312a94cSmrg for _G_line in $_G_message; do 723b312a94cSmrg IFS=$func_echo_IFS 724b312a94cSmrg $ECHO "$progname: $_G_line" 725b312a94cSmrg done 726b312a94cSmrg IFS=$func_echo_IFS 727b312a94cSmrg} 728b312a94cSmrg 729b312a94cSmrg 730b312a94cSmrg# func_echo_all ARG... 731b312a94cSmrg# -------------------- 732b312a94cSmrg# Invoke $ECHO with all args, space-separated. 733b312a94cSmrgfunc_echo_all () 734b312a94cSmrg{ 735b312a94cSmrg $ECHO "$*" 736b312a94cSmrg} 737b312a94cSmrg 738b312a94cSmrg 739b312a94cSmrg# func_echo_infix_1 INFIX ARG... 740b312a94cSmrg# ------------------------------ 741b312a94cSmrg# Echo program name, followed by INFIX on the first line, with any 742b312a94cSmrg# additional lines not showing INFIX. 743b312a94cSmrgfunc_echo_infix_1 () 744b312a94cSmrg{ 745b312a94cSmrg $debug_cmd 746b312a94cSmrg 747b312a94cSmrg $require_term_colors 748b312a94cSmrg 749b312a94cSmrg _G_infix=$1; shift 750b312a94cSmrg _G_indent=$_G_infix 751b312a94cSmrg _G_prefix="$progname: $_G_infix: " 752b312a94cSmrg _G_message=$* 753b312a94cSmrg 754b312a94cSmrg # Strip color escape sequences before counting printable length 755b312a94cSmrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 756b312a94cSmrg do 757b312a94cSmrg test -n "$_G_tc" && { 758b312a94cSmrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 759b312a94cSmrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 760b312a94cSmrg } 761b312a94cSmrg done 762b312a94cSmrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 763b312a94cSmrg 764b312a94cSmrg func_echo_infix_1_IFS=$IFS 765b312a94cSmrg IFS=$nl 766b312a94cSmrg for _G_line in $_G_message; do 767b312a94cSmrg IFS=$func_echo_infix_1_IFS 768b312a94cSmrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 769b312a94cSmrg _G_prefix=$_G_indent 770b312a94cSmrg done 771b312a94cSmrg IFS=$func_echo_infix_1_IFS 772b312a94cSmrg} 773b312a94cSmrg 774b312a94cSmrg 775b312a94cSmrg# func_error ARG... 776b312a94cSmrg# ----------------- 777b312a94cSmrg# Echo program name prefixed message to standard error. 778b312a94cSmrgfunc_error () 779b312a94cSmrg{ 780b312a94cSmrg $debug_cmd 781b312a94cSmrg 782b312a94cSmrg $require_term_colors 783b312a94cSmrg 784b312a94cSmrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 785b312a94cSmrg} 786b312a94cSmrg 787b312a94cSmrg 788b312a94cSmrg# func_fatal_error ARG... 789b312a94cSmrg# ----------------------- 790b312a94cSmrg# Echo program name prefixed message to standard error, and exit. 791b312a94cSmrgfunc_fatal_error () 792b312a94cSmrg{ 793b312a94cSmrg $debug_cmd 794b312a94cSmrg 795b312a94cSmrg func_error "$*" 796b312a94cSmrg exit $EXIT_FAILURE 797b312a94cSmrg} 798b312a94cSmrg 799b312a94cSmrg 800b312a94cSmrg# func_grep EXPRESSION FILENAME 801b312a94cSmrg# ----------------------------- 80265eef222Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 80365eef222Smrgfunc_grep () 80465eef222Smrg{ 805b312a94cSmrg $debug_cmd 806b312a94cSmrg 80765eef222Smrg $GREP "$1" "$2" >/dev/null 2>&1 80865eef222Smrg} 80965eef222Smrg 81065eef222Smrg 811b312a94cSmrg# func_len STRING 812b312a94cSmrg# --------------- 813b312a94cSmrg# Set func_len_result to the length of STRING. STRING may not 814b312a94cSmrg# start with a hyphen. 815b312a94cSmrg test -z "$_G_HAVE_XSI_OPS" \ 816b312a94cSmrg && (eval 'x=a/b/c; 817b312a94cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 818b312a94cSmrg && _G_HAVE_XSI_OPS=yes 819b312a94cSmrg 820b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 821b312a94cSmrg eval 'func_len () 822b312a94cSmrg { 823b312a94cSmrg $debug_cmd 824b312a94cSmrg 825b312a94cSmrg func_len_result=${#1} 826b312a94cSmrg }' 827b312a94cSmrgelse 828b312a94cSmrg func_len () 829b312a94cSmrg { 830b312a94cSmrg $debug_cmd 831b312a94cSmrg 832b312a94cSmrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 833b312a94cSmrg } 834b312a94cSmrgfi 835b312a94cSmrg 836b312a94cSmrg 837b312a94cSmrg# func_mkdir_p DIRECTORY-PATH 838b312a94cSmrg# --------------------------- 83965eef222Smrg# Make sure the entire path to DIRECTORY-PATH is available. 84065eef222Smrgfunc_mkdir_p () 84165eef222Smrg{ 842b312a94cSmrg $debug_cmd 843b312a94cSmrg 844b312a94cSmrg _G_directory_path=$1 845b312a94cSmrg _G_dir_list= 84665eef222Smrg 847b312a94cSmrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 84865eef222Smrg 849b312a94cSmrg # Protect directory names starting with '-' 850b312a94cSmrg case $_G_directory_path in 851b312a94cSmrg -*) _G_directory_path=./$_G_directory_path ;; 85265eef222Smrg esac 85365eef222Smrg 85465eef222Smrg # While some portion of DIR does not yet exist... 855b312a94cSmrg while test ! -d "$_G_directory_path"; do 85665eef222Smrg # ...make a list in topmost first order. Use a colon delimited 85765eef222Smrg # list incase some portion of path contains whitespace. 858b312a94cSmrg _G_dir_list=$_G_directory_path:$_G_dir_list 85965eef222Smrg 86065eef222Smrg # If the last portion added has no slash in it, the list is done 861b312a94cSmrg case $_G_directory_path in */*) ;; *) break ;; esac 86265eef222Smrg 86365eef222Smrg # ...otherwise throw away the child directory and loop 864b312a94cSmrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 86565eef222Smrg done 866b312a94cSmrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 86765eef222Smrg 868b312a94cSmrg func_mkdir_p_IFS=$IFS; IFS=: 869b312a94cSmrg for _G_dir in $_G_dir_list; do 870b312a94cSmrg IFS=$func_mkdir_p_IFS 871b312a94cSmrg # mkdir can fail with a 'File exist' error if two processes 87265eef222Smrg # try to create one of the directories concurrently. Don't 87365eef222Smrg # stop in that case! 874b312a94cSmrg $MKDIR "$_G_dir" 2>/dev/null || : 87565eef222Smrg done 876b312a94cSmrg IFS=$func_mkdir_p_IFS 87765eef222Smrg 87865eef222Smrg # Bail out if we (or some other process) failed to create a directory. 879b312a94cSmrg test -d "$_G_directory_path" || \ 880b312a94cSmrg func_fatal_error "Failed to create '$1'" 88165eef222Smrg fi 88265eef222Smrg} 883ef981d24Smrg 884ef981d24Smrg 885b312a94cSmrg# func_mktempdir [BASENAME] 886b312a94cSmrg# ------------------------- 887ef981d24Smrg# Make a temporary directory that won't clash with other running 888ef981d24Smrg# libtool processes, and avoids race conditions if possible. If 889b312a94cSmrg# given, BASENAME is the basename for that directory. 890ef981d24Smrgfunc_mktempdir () 891ef981d24Smrg{ 892b312a94cSmrg $debug_cmd 893ef981d24Smrg 894b312a94cSmrg _G_template=${TMPDIR-/tmp}/${1-$progname} 895b312a94cSmrg 896b312a94cSmrg if test : = "$opt_dry_run"; then 897ef981d24Smrg # Return a directory name, but don't create it in dry-run mode 898b312a94cSmrg _G_tmpdir=$_G_template-$$ 899ef981d24Smrg else 900ef981d24Smrg 901ef981d24Smrg # If mktemp works, use that first and foremost 902b312a94cSmrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 903ef981d24Smrg 904b312a94cSmrg if test ! -d "$_G_tmpdir"; then 90565eef222Smrg # Failing that, at least try and use $RANDOM to avoid a race 906b312a94cSmrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 907ef981d24Smrg 908b312a94cSmrg func_mktempdir_umask=`umask` 90965eef222Smrg umask 0077 910b312a94cSmrg $MKDIR "$_G_tmpdir" 911b312a94cSmrg umask $func_mktempdir_umask 912ef981d24Smrg fi 913ef981d24Smrg 914ef981d24Smrg # If we're not in dry-run mode, bomb out on failure 915b312a94cSmrg test -d "$_G_tmpdir" || \ 916b312a94cSmrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 917ef981d24Smrg fi 918ef981d24Smrg 919b312a94cSmrg $ECHO "$_G_tmpdir" 920ef981d24Smrg} 921ef981d24Smrg 922ef981d24Smrg 923b312a94cSmrg# func_normal_abspath PATH 924b312a94cSmrg# ------------------------ 925b312a94cSmrg# Remove doubled-up and trailing slashes, "." path components, 926b312a94cSmrg# and cancel out any ".." path components in PATH after making 927b312a94cSmrg# it an absolute path. 928b312a94cSmrgfunc_normal_abspath () 929b312a94cSmrg{ 930b312a94cSmrg $debug_cmd 931b312a94cSmrg 932b312a94cSmrg # These SED scripts presuppose an absolute path with a trailing slash. 933b312a94cSmrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 934b312a94cSmrg _G_pathcdr='s|^/[^/]*||' 935b312a94cSmrg _G_removedotparts=':dotsl 936b312a94cSmrg s|/\./|/|g 937b312a94cSmrg t dotsl 938b312a94cSmrg s|/\.$|/|' 939b312a94cSmrg _G_collapseslashes='s|/\{1,\}|/|g' 940b312a94cSmrg _G_finalslash='s|/*$|/|' 941b312a94cSmrg 942b312a94cSmrg # Start from root dir and reassemble the path. 943b312a94cSmrg func_normal_abspath_result= 944b312a94cSmrg func_normal_abspath_tpath=$1 945b312a94cSmrg func_normal_abspath_altnamespace= 946b312a94cSmrg case $func_normal_abspath_tpath in 947b312a94cSmrg "") 948b312a94cSmrg # Empty path, that just means $cwd. 949b312a94cSmrg func_stripname '' '/' "`pwd`" 950b312a94cSmrg func_normal_abspath_result=$func_stripname_result 951b312a94cSmrg return 952b312a94cSmrg ;; 953b312a94cSmrg # The next three entries are used to spot a run of precisely 954b312a94cSmrg # two leading slashes without using negated character classes; 955b312a94cSmrg # we take advantage of case's first-match behaviour. 956b312a94cSmrg ///*) 957b312a94cSmrg # Unusual form of absolute path, do nothing. 958b312a94cSmrg ;; 959b312a94cSmrg //*) 960b312a94cSmrg # Not necessarily an ordinary path; POSIX reserves leading '//' 961b312a94cSmrg # and for example Cygwin uses it to access remote file shares 962b312a94cSmrg # over CIFS/SMB, so we conserve a leading double slash if found. 963b312a94cSmrg func_normal_abspath_altnamespace=/ 964b312a94cSmrg ;; 965b312a94cSmrg /*) 966b312a94cSmrg # Absolute path, do nothing. 967b312a94cSmrg ;; 968b312a94cSmrg *) 969b312a94cSmrg # Relative path, prepend $cwd. 970b312a94cSmrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 971b312a94cSmrg ;; 972b312a94cSmrg esac 973b312a94cSmrg 974b312a94cSmrg # Cancel out all the simple stuff to save iterations. We also want 975b312a94cSmrg # the path to end with a slash for ease of parsing, so make sure 976b312a94cSmrg # there is one (and only one) here. 977b312a94cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 978b312a94cSmrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 979b312a94cSmrg while :; do 980b312a94cSmrg # Processed it all yet? 981b312a94cSmrg if test / = "$func_normal_abspath_tpath"; then 982b312a94cSmrg # If we ascended to the root using ".." the result may be empty now. 983b312a94cSmrg if test -z "$func_normal_abspath_result"; then 984b312a94cSmrg func_normal_abspath_result=/ 985b312a94cSmrg fi 986b312a94cSmrg break 987b312a94cSmrg fi 988b312a94cSmrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 989b312a94cSmrg -e "$_G_pathcar"` 990b312a94cSmrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 991b312a94cSmrg -e "$_G_pathcdr"` 992b312a94cSmrg # Figure out what to do with it 993b312a94cSmrg case $func_normal_abspath_tcomponent in 994b312a94cSmrg "") 995b312a94cSmrg # Trailing empty path component, ignore it. 996b312a94cSmrg ;; 997b312a94cSmrg ..) 998b312a94cSmrg # Parent dir; strip last assembled component from result. 999b312a94cSmrg func_dirname "$func_normal_abspath_result" 1000b312a94cSmrg func_normal_abspath_result=$func_dirname_result 1001b312a94cSmrg ;; 1002b312a94cSmrg *) 1003b312a94cSmrg # Actual path component, append it. 1004b312a94cSmrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1005b312a94cSmrg ;; 1006b312a94cSmrg esac 1007b312a94cSmrg done 1008b312a94cSmrg # Restore leading double-slash if one was found on entry. 1009b312a94cSmrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1010b312a94cSmrg} 1011b312a94cSmrg 1012b312a94cSmrg 1013b312a94cSmrg# func_notquiet ARG... 1014b312a94cSmrg# -------------------- 1015b312a94cSmrg# Echo program name prefixed message only when not in quiet mode. 1016b312a94cSmrgfunc_notquiet () 1017b312a94cSmrg{ 1018b312a94cSmrg $debug_cmd 1019b312a94cSmrg 1020b312a94cSmrg $opt_quiet || func_echo ${1+"$@"} 1021b312a94cSmrg 1022b312a94cSmrg # A bug in bash halts the script if the last line of a function 1023b312a94cSmrg # fails when set -e is in force, so we need another command to 1024b312a94cSmrg # work around that: 1025b312a94cSmrg : 1026b312a94cSmrg} 1027b312a94cSmrg 1028b312a94cSmrg 1029b312a94cSmrg# func_relative_path SRCDIR DSTDIR 1030b312a94cSmrg# -------------------------------- 1031b312a94cSmrg# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1032b312a94cSmrgfunc_relative_path () 1033b312a94cSmrg{ 1034b312a94cSmrg $debug_cmd 1035b312a94cSmrg 1036b312a94cSmrg func_relative_path_result= 1037b312a94cSmrg func_normal_abspath "$1" 1038b312a94cSmrg func_relative_path_tlibdir=$func_normal_abspath_result 1039b312a94cSmrg func_normal_abspath "$2" 1040b312a94cSmrg func_relative_path_tbindir=$func_normal_abspath_result 1041b312a94cSmrg 1042b312a94cSmrg # Ascend the tree starting from libdir 1043b312a94cSmrg while :; do 1044b312a94cSmrg # check if we have found a prefix of bindir 1045b312a94cSmrg case $func_relative_path_tbindir in 1046b312a94cSmrg $func_relative_path_tlibdir) 1047b312a94cSmrg # found an exact match 1048b312a94cSmrg func_relative_path_tcancelled= 1049b312a94cSmrg break 1050b312a94cSmrg ;; 1051b312a94cSmrg $func_relative_path_tlibdir*) 1052b312a94cSmrg # found a matching prefix 1053b312a94cSmrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1054b312a94cSmrg func_relative_path_tcancelled=$func_stripname_result 1055b312a94cSmrg if test -z "$func_relative_path_result"; then 1056b312a94cSmrg func_relative_path_result=. 1057b312a94cSmrg fi 1058b312a94cSmrg break 1059b312a94cSmrg ;; 1060b312a94cSmrg *) 1061b312a94cSmrg func_dirname $func_relative_path_tlibdir 1062b312a94cSmrg func_relative_path_tlibdir=$func_dirname_result 1063b312a94cSmrg if test -z "$func_relative_path_tlibdir"; then 1064b312a94cSmrg # Have to descend all the way to the root! 1065b312a94cSmrg func_relative_path_result=../$func_relative_path_result 1066b312a94cSmrg func_relative_path_tcancelled=$func_relative_path_tbindir 1067b312a94cSmrg break 1068b312a94cSmrg fi 1069b312a94cSmrg func_relative_path_result=../$func_relative_path_result 1070b312a94cSmrg ;; 1071b312a94cSmrg esac 1072b312a94cSmrg done 1073b312a94cSmrg 1074b312a94cSmrg # Now calculate path; take care to avoid doubling-up slashes. 1075b312a94cSmrg func_stripname '' '/' "$func_relative_path_result" 1076b312a94cSmrg func_relative_path_result=$func_stripname_result 1077b312a94cSmrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1078b312a94cSmrg if test -n "$func_stripname_result"; then 1079b312a94cSmrg func_append func_relative_path_result "/$func_stripname_result" 1080b312a94cSmrg fi 1081b312a94cSmrg 1082b312a94cSmrg # Normalisation. If bindir is libdir, return '.' else relative path. 1083b312a94cSmrg if test -n "$func_relative_path_result"; then 1084b312a94cSmrg func_stripname './' '' "$func_relative_path_result" 1085b312a94cSmrg func_relative_path_result=$func_stripname_result 1086b312a94cSmrg fi 1087b312a94cSmrg 1088b312a94cSmrg test -n "$func_relative_path_result" || func_relative_path_result=. 1089b312a94cSmrg 1090b312a94cSmrg : 1091b312a94cSmrg} 1092b312a94cSmrg 1093b312a94cSmrg 1094b312a94cSmrg# func_quote_for_eval ARG... 1095b312a94cSmrg# -------------------------- 1096b312a94cSmrg# Aesthetically quote ARGs to be evaled later. 1097b312a94cSmrg# This function returns two values: 1098b312a94cSmrg# i) func_quote_for_eval_result 1099b312a94cSmrg# double-quoted, suitable for a subsequent eval 1100b312a94cSmrg# ii) func_quote_for_eval_unquoted_result 1101b312a94cSmrg# has all characters that are still active within double 1102b312a94cSmrg# quotes backslashified. 110365eef222Smrgfunc_quote_for_eval () 1104ef981d24Smrg{ 1105b312a94cSmrg $debug_cmd 1106b312a94cSmrg 1107b312a94cSmrg func_quote_for_eval_unquoted_result= 1108b312a94cSmrg func_quote_for_eval_result= 1109b312a94cSmrg while test 0 -lt $#; do 1110b312a94cSmrg case $1 in 1111b312a94cSmrg *[\\\`\"\$]*) 1112b312a94cSmrg _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; 1113b312a94cSmrg *) 1114b312a94cSmrg _G_unquoted_arg=$1 ;; 1115b312a94cSmrg esac 1116b312a94cSmrg if test -n "$func_quote_for_eval_unquoted_result"; then 1117b312a94cSmrg func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" 1118b312a94cSmrg else 1119b312a94cSmrg func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" 1120b312a94cSmrg fi 1121b312a94cSmrg 1122b312a94cSmrg case $_G_unquoted_arg in 1123b312a94cSmrg # Double-quote args containing shell metacharacters to delay 1124b312a94cSmrg # word splitting, command substitution and variable expansion 1125b312a94cSmrg # for a subsequent eval. 1126b312a94cSmrg # Many Bourne shells cannot handle close brackets correctly 1127b312a94cSmrg # in scan sets, so we specify it separately. 1128b312a94cSmrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1129b312a94cSmrg _G_quoted_arg=\"$_G_unquoted_arg\" 1130b312a94cSmrg ;; 1131b312a94cSmrg *) 1132b312a94cSmrg _G_quoted_arg=$_G_unquoted_arg 1133b312a94cSmrg ;; 1134b312a94cSmrg esac 1135b312a94cSmrg 1136b312a94cSmrg if test -n "$func_quote_for_eval_result"; then 1137b312a94cSmrg func_append func_quote_for_eval_result " $_G_quoted_arg" 1138b312a94cSmrg else 1139b312a94cSmrg func_append func_quote_for_eval_result "$_G_quoted_arg" 1140b312a94cSmrg fi 1141b312a94cSmrg shift 1142b312a94cSmrg done 1143b312a94cSmrg} 1144b312a94cSmrg 1145b312a94cSmrg 1146b312a94cSmrg# func_quote_for_expand ARG 1147b312a94cSmrg# ------------------------- 1148b312a94cSmrg# Aesthetically quote ARG to be evaled later; same as above, 1149b312a94cSmrg# but do not quote variable references. 1150b312a94cSmrgfunc_quote_for_expand () 1151b312a94cSmrg{ 1152b312a94cSmrg $debug_cmd 1153b312a94cSmrg 115465eef222Smrg case $1 in 1155b312a94cSmrg *[\\\`\"]*) 1156b312a94cSmrg _G_arg=`$ECHO "$1" | $SED \ 1157b312a94cSmrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; 115865eef222Smrg *) 1159b312a94cSmrg _G_arg=$1 ;; 116065eef222Smrg esac 116165eef222Smrg 1162b312a94cSmrg case $_G_arg in 116365eef222Smrg # Double-quote args containing shell metacharacters to delay 1164b312a94cSmrg # word splitting and command substitution for a subsequent eval. 116565eef222Smrg # Many Bourne shells cannot handle close brackets correctly 116665eef222Smrg # in scan sets, so we specify it separately. 116765eef222Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1168b312a94cSmrg _G_arg=\"$_G_arg\" 116965eef222Smrg ;; 1170ef981d24Smrg esac 1171b312a94cSmrg 1172b312a94cSmrg func_quote_for_expand_result=$_G_arg 1173b312a94cSmrg} 1174b312a94cSmrg 1175b312a94cSmrg 1176b312a94cSmrg# func_stripname PREFIX SUFFIX NAME 1177b312a94cSmrg# --------------------------------- 1178b312a94cSmrg# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1179b312a94cSmrg# PREFIX and SUFFIX must not contain globbing or regex special 1180b312a94cSmrg# characters, hashes, percent signs, but SUFFIX may contain a leading 1181b312a94cSmrg# dot (in which case that matches only a dot). 1182b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 1183b312a94cSmrg eval 'func_stripname () 1184b312a94cSmrg { 1185b312a94cSmrg $debug_cmd 1186b312a94cSmrg 1187b312a94cSmrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1188b312a94cSmrg # positional parameters, so assign one to ordinary variable first. 1189b312a94cSmrg func_stripname_result=$3 1190b312a94cSmrg func_stripname_result=${func_stripname_result#"$1"} 1191b312a94cSmrg func_stripname_result=${func_stripname_result%"$2"} 1192b312a94cSmrg }' 1193b312a94cSmrgelse 1194b312a94cSmrg func_stripname () 1195b312a94cSmrg { 1196b312a94cSmrg $debug_cmd 1197b312a94cSmrg 1198b312a94cSmrg case $2 in 1199b312a94cSmrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1200b312a94cSmrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1201b312a94cSmrg esac 1202b312a94cSmrg } 1203b312a94cSmrgfi 1204b312a94cSmrg 1205b312a94cSmrg 1206b312a94cSmrg# func_show_eval CMD [FAIL_EXP] 1207b312a94cSmrg# ----------------------------- 1208b312a94cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1209b312a94cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1210b312a94cSmrg# is given, then evaluate it. 1211b312a94cSmrgfunc_show_eval () 1212b312a94cSmrg{ 1213b312a94cSmrg $debug_cmd 1214b312a94cSmrg 1215b312a94cSmrg _G_cmd=$1 1216b312a94cSmrg _G_fail_exp=${2-':'} 1217b312a94cSmrg 1218b312a94cSmrg func_quote_for_expand "$_G_cmd" 1219b312a94cSmrg eval "func_notquiet $func_quote_for_expand_result" 1220b312a94cSmrg 1221b312a94cSmrg $opt_dry_run || { 1222b312a94cSmrg eval "$_G_cmd" 1223b312a94cSmrg _G_status=$? 1224b312a94cSmrg if test 0 -ne "$_G_status"; then 1225b312a94cSmrg eval "(exit $_G_status); $_G_fail_exp" 1226b312a94cSmrg fi 1227b312a94cSmrg } 1228b312a94cSmrg} 1229b312a94cSmrg 1230b312a94cSmrg 1231b312a94cSmrg# func_show_eval_locale CMD [FAIL_EXP] 1232b312a94cSmrg# ------------------------------------ 1233b312a94cSmrg# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1234b312a94cSmrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1235b312a94cSmrg# is given, then evaluate it. Use the saved locale for evaluation. 1236b312a94cSmrgfunc_show_eval_locale () 1237b312a94cSmrg{ 1238b312a94cSmrg $debug_cmd 1239b312a94cSmrg 1240b312a94cSmrg _G_cmd=$1 1241b312a94cSmrg _G_fail_exp=${2-':'} 1242b312a94cSmrg 1243b312a94cSmrg $opt_quiet || { 1244b312a94cSmrg func_quote_for_expand "$_G_cmd" 1245b312a94cSmrg eval "func_echo $func_quote_for_expand_result" 1246b312a94cSmrg } 1247b312a94cSmrg 1248b312a94cSmrg $opt_dry_run || { 1249b312a94cSmrg eval "$_G_user_locale 1250b312a94cSmrg $_G_cmd" 1251b312a94cSmrg _G_status=$? 1252b312a94cSmrg eval "$_G_safe_locale" 1253b312a94cSmrg if test 0 -ne "$_G_status"; then 1254b312a94cSmrg eval "(exit $_G_status); $_G_fail_exp" 1255b312a94cSmrg fi 1256b312a94cSmrg } 1257b312a94cSmrg} 1258b312a94cSmrg 1259b312a94cSmrg 1260b312a94cSmrg# func_tr_sh 1261b312a94cSmrg# ---------- 1262b312a94cSmrg# Turn $1 into a string suitable for a shell variable name. 1263b312a94cSmrg# Result is stored in $func_tr_sh_result. All characters 1264b312a94cSmrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1265b312a94cSmrg# if $1 begins with a digit, a '_' is prepended as well. 1266b312a94cSmrgfunc_tr_sh () 1267b312a94cSmrg{ 1268b312a94cSmrg $debug_cmd 1269b312a94cSmrg 1270b312a94cSmrg case $1 in 1271b312a94cSmrg [0-9]* | *[!a-zA-Z0-9_]*) 1272b312a94cSmrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1273b312a94cSmrg ;; 1274b312a94cSmrg * ) 1275b312a94cSmrg func_tr_sh_result=$1 1276b312a94cSmrg ;; 1277b312a94cSmrg esac 1278b312a94cSmrg} 1279b312a94cSmrg 1280b312a94cSmrg 1281b312a94cSmrg# func_verbose ARG... 1282b312a94cSmrg# ------------------- 1283b312a94cSmrg# Echo program name prefixed message in verbose mode only. 1284b312a94cSmrgfunc_verbose () 1285b312a94cSmrg{ 1286b312a94cSmrg $debug_cmd 1287b312a94cSmrg 1288b312a94cSmrg $opt_verbose && func_echo "$*" 1289b312a94cSmrg 1290b312a94cSmrg : 1291b312a94cSmrg} 1292b312a94cSmrg 1293b312a94cSmrg 1294b312a94cSmrg# func_warn_and_continue ARG... 1295b312a94cSmrg# ----------------------------- 1296b312a94cSmrg# Echo program name prefixed warning message to standard error. 1297b312a94cSmrgfunc_warn_and_continue () 1298b312a94cSmrg{ 1299b312a94cSmrg $debug_cmd 1300b312a94cSmrg 1301b312a94cSmrg $require_term_colors 1302b312a94cSmrg 1303b312a94cSmrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1304b312a94cSmrg} 1305b312a94cSmrg 1306b312a94cSmrg 1307b312a94cSmrg# func_warning CATEGORY ARG... 1308b312a94cSmrg# ---------------------------- 1309b312a94cSmrg# Echo program name prefixed warning message to standard error. Warning 1310b312a94cSmrg# messages can be filtered according to CATEGORY, where this function 1311b312a94cSmrg# elides messages where CATEGORY is not listed in the global variable 1312b312a94cSmrg# 'opt_warning_types'. 1313b312a94cSmrgfunc_warning () 1314b312a94cSmrg{ 1315b312a94cSmrg $debug_cmd 1316b312a94cSmrg 1317b312a94cSmrg # CATEGORY must be in the warning_categories list! 1318b312a94cSmrg case " $warning_categories " in 1319b312a94cSmrg *" $1 "*) ;; 1320b312a94cSmrg *) func_internal_error "invalid warning category '$1'" ;; 1321b312a94cSmrg esac 1322b312a94cSmrg 1323b312a94cSmrg _G_category=$1 1324b312a94cSmrg shift 1325b312a94cSmrg 1326b312a94cSmrg case " $opt_warning_types " in 1327b312a94cSmrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1328b312a94cSmrg esac 1329b312a94cSmrg} 1330b312a94cSmrg 1331b312a94cSmrg 1332b312a94cSmrg# func_sort_ver VER1 VER2 1333b312a94cSmrg# ----------------------- 1334b312a94cSmrg# 'sort -V' is not generally available. 1335b312a94cSmrg# Note this deviates from the version comparison in automake 1336b312a94cSmrg# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1337b312a94cSmrg# but this should suffice as we won't be specifying old 1338b312a94cSmrg# version formats or redundant trailing .0 in bootstrap.conf. 1339b312a94cSmrg# If we did want full compatibility then we should probably 1340b312a94cSmrg# use m4_version_compare from autoconf. 1341b312a94cSmrgfunc_sort_ver () 1342b312a94cSmrg{ 1343b312a94cSmrg $debug_cmd 1344b312a94cSmrg 1345b312a94cSmrg printf '%s\n%s\n' "$1" "$2" \ 1346b312a94cSmrg | 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 1347b312a94cSmrg} 1348b312a94cSmrg 1349b312a94cSmrg# func_lt_ver PREV CURR 1350b312a94cSmrg# --------------------- 1351b312a94cSmrg# Return true if PREV and CURR are in the correct order according to 1352b312a94cSmrg# func_sort_ver, otherwise false. Use it like this: 1353b312a94cSmrg# 1354b312a94cSmrg# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1355b312a94cSmrgfunc_lt_ver () 1356b312a94cSmrg{ 1357b312a94cSmrg $debug_cmd 1358b312a94cSmrg 1359b312a94cSmrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1360b312a94cSmrg} 1361b312a94cSmrg 1362b312a94cSmrg 1363b312a94cSmrg# Local variables: 1364b312a94cSmrg# mode: shell-script 1365b312a94cSmrg# sh-indentation: 2 1366b312a94cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1367b312a94cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1368b312a94cSmrg# time-stamp-time-zone: "UTC" 1369b312a94cSmrg# End: 1370b312a94cSmrg#! /bin/sh 1371b312a94cSmrg 1372b312a94cSmrg# Set a version string for this script. 1373b312a94cSmrgscriptversion=2014-01-07.03; # UTC 1374b312a94cSmrg 1375b312a94cSmrg# A portable, pluggable option parser for Bourne shell. 1376b312a94cSmrg# Written by Gary V. Vaughan, 2010 1377b312a94cSmrg 1378b312a94cSmrg# Copyright (C) 2010-2015 Free Software Foundation, Inc. 1379b312a94cSmrg# This is free software; see the source for copying conditions. There is NO 1380b312a94cSmrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1381b312a94cSmrg 1382b312a94cSmrg# This program is free software: you can redistribute it and/or modify 1383b312a94cSmrg# it under the terms of the GNU General Public License as published by 1384b312a94cSmrg# the Free Software Foundation, either version 3 of the License, or 1385b312a94cSmrg# (at your option) any later version. 1386b312a94cSmrg 1387b312a94cSmrg# This program is distributed in the hope that it will be useful, 1388b312a94cSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of 1389b312a94cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1390b312a94cSmrg# GNU General Public License for more details. 1391b312a94cSmrg 1392b312a94cSmrg# You should have received a copy of the GNU General Public License 1393b312a94cSmrg# along with this program. If not, see <http://www.gnu.org/licenses/>. 1394b312a94cSmrg 1395b312a94cSmrg# Please report bugs or propose patches to gary@gnu.org. 1396b312a94cSmrg 1397b312a94cSmrg 1398b312a94cSmrg## ------ ## 1399b312a94cSmrg## Usage. ## 1400b312a94cSmrg## ------ ## 1401b312a94cSmrg 1402b312a94cSmrg# This file is a library for parsing options in your shell scripts along 1403b312a94cSmrg# with assorted other useful supporting features that you can make use 1404b312a94cSmrg# of too. 1405b312a94cSmrg# 1406b312a94cSmrg# For the simplest scripts you might need only: 1407b312a94cSmrg# 1408b312a94cSmrg# #!/bin/sh 1409b312a94cSmrg# . relative/path/to/funclib.sh 1410b312a94cSmrg# . relative/path/to/options-parser 1411b312a94cSmrg# scriptversion=1.0 1412b312a94cSmrg# func_options ${1+"$@"} 1413b312a94cSmrg# eval set dummy "$func_options_result"; shift 1414b312a94cSmrg# ...rest of your script... 1415b312a94cSmrg# 1416b312a94cSmrg# In order for the '--version' option to work, you will need to have a 1417b312a94cSmrg# suitably formatted comment like the one at the top of this file 1418b312a94cSmrg# starting with '# Written by ' and ending with '# warranty; '. 1419b312a94cSmrg# 1420b312a94cSmrg# For '-h' and '--help' to work, you will also need a one line 1421b312a94cSmrg# description of your script's purpose in a comment directly above the 1422b312a94cSmrg# '# Written by ' line, like the one at the top of this file. 1423b312a94cSmrg# 1424b312a94cSmrg# The default options also support '--debug', which will turn on shell 1425b312a94cSmrg# execution tracing (see the comment above debug_cmd below for another 1426b312a94cSmrg# use), and '--verbose' and the func_verbose function to allow your script 1427b312a94cSmrg# to display verbose messages only when your user has specified 1428b312a94cSmrg# '--verbose'. 1429b312a94cSmrg# 1430b312a94cSmrg# After sourcing this file, you can plug processing for additional 1431b312a94cSmrg# options by amending the variables from the 'Configuration' section 1432b312a94cSmrg# below, and following the instructions in the 'Option parsing' 1433b312a94cSmrg# section further down. 1434b312a94cSmrg 1435b312a94cSmrg## -------------- ## 1436b312a94cSmrg## Configuration. ## 1437b312a94cSmrg## -------------- ## 1438b312a94cSmrg 1439b312a94cSmrg# You should override these variables in your script after sourcing this 1440b312a94cSmrg# file so that they reflect the customisations you have added to the 1441b312a94cSmrg# option parser. 1442b312a94cSmrg 1443b312a94cSmrg# The usage line for option parsing errors and the start of '-h' and 1444b312a94cSmrg# '--help' output messages. You can embed shell variables for delayed 1445b312a94cSmrg# expansion at the time the message is displayed, but you will need to 1446b312a94cSmrg# quote other shell meta-characters carefully to prevent them being 1447b312a94cSmrg# expanded when the contents are evaled. 1448b312a94cSmrgusage='$progpath [OPTION]...' 1449b312a94cSmrg 1450b312a94cSmrg# Short help message in response to '-h' and '--help'. Add to this or 1451b312a94cSmrg# override it after sourcing this library to reflect the full set of 1452b312a94cSmrg# options your script accepts. 1453b312a94cSmrgusage_message="\ 1454b312a94cSmrg --debug enable verbose shell tracing 1455b312a94cSmrg -W, --warnings=CATEGORY 1456b312a94cSmrg report the warnings falling in CATEGORY [all] 1457b312a94cSmrg -v, --verbose verbosely report processing 1458b312a94cSmrg --version print version information and exit 1459b312a94cSmrg -h, --help print short or long help message and exit 1460b312a94cSmrg" 1461b312a94cSmrg 1462b312a94cSmrg# Additional text appended to 'usage_message' in response to '--help'. 1463b312a94cSmrglong_help_message=" 1464b312a94cSmrgWarning categories include: 1465b312a94cSmrg 'all' show all warnings 1466b312a94cSmrg 'none' turn off all the warnings 1467b312a94cSmrg 'error' warnings are treated as fatal errors" 1468b312a94cSmrg 1469b312a94cSmrg# Help message printed before fatal option parsing errors. 1470b312a94cSmrgfatal_help="Try '\$progname --help' for more information." 1471b312a94cSmrg 1472b312a94cSmrg 1473b312a94cSmrg 1474b312a94cSmrg## ------------------------- ## 1475b312a94cSmrg## Hook function management. ## 1476b312a94cSmrg## ------------------------- ## 1477b312a94cSmrg 1478b312a94cSmrg# This section contains functions for adding, removing, and running hooks 1479b312a94cSmrg# to the main code. A hook is just a named list of of function, that can 1480b312a94cSmrg# be run in order later on. 1481b312a94cSmrg 1482b312a94cSmrg# func_hookable FUNC_NAME 1483b312a94cSmrg# ----------------------- 1484b312a94cSmrg# Declare that FUNC_NAME will run hooks added with 1485b312a94cSmrg# 'func_add_hook FUNC_NAME ...'. 1486b312a94cSmrgfunc_hookable () 1487b312a94cSmrg{ 1488b312a94cSmrg $debug_cmd 1489b312a94cSmrg 1490b312a94cSmrg func_append hookable_fns " $1" 1491b312a94cSmrg} 1492b312a94cSmrg 1493b312a94cSmrg 1494b312a94cSmrg# func_add_hook FUNC_NAME HOOK_FUNC 1495b312a94cSmrg# --------------------------------- 1496b312a94cSmrg# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1497b312a94cSmrg# first have been declared "hookable" by a call to 'func_hookable'. 1498b312a94cSmrgfunc_add_hook () 1499b312a94cSmrg{ 1500b312a94cSmrg $debug_cmd 1501b312a94cSmrg 1502b312a94cSmrg case " $hookable_fns " in 1503b312a94cSmrg *" $1 "*) ;; 1504b312a94cSmrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1505b312a94cSmrg esac 1506b312a94cSmrg 1507b312a94cSmrg eval func_append ${1}_hooks '" $2"' 1508b312a94cSmrg} 1509b312a94cSmrg 1510b312a94cSmrg 1511b312a94cSmrg# func_remove_hook FUNC_NAME HOOK_FUNC 1512b312a94cSmrg# ------------------------------------ 1513b312a94cSmrg# Remove HOOK_FUNC from the list of functions called by FUNC_NAME. 1514b312a94cSmrgfunc_remove_hook () 1515b312a94cSmrg{ 1516b312a94cSmrg $debug_cmd 1517b312a94cSmrg 1518b312a94cSmrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1519b312a94cSmrg} 1520b312a94cSmrg 1521b312a94cSmrg 1522b312a94cSmrg# func_run_hooks FUNC_NAME [ARG]... 1523b312a94cSmrg# --------------------------------- 1524b312a94cSmrg# Run all hook functions registered to FUNC_NAME. 1525b312a94cSmrg# It is assumed that the list of hook functions contains nothing more 1526b312a94cSmrg# than a whitespace-delimited list of legal shell function names, and 1527b312a94cSmrg# no effort is wasted trying to catch shell meta-characters or preserve 1528b312a94cSmrg# whitespace. 1529b312a94cSmrgfunc_run_hooks () 1530b312a94cSmrg{ 1531b312a94cSmrg $debug_cmd 1532b312a94cSmrg 1533b312a94cSmrg case " $hookable_fns " in 1534b312a94cSmrg *" $1 "*) ;; 1535b312a94cSmrg *) func_fatal_error "'$1' does not support hook funcions.n" ;; 1536b312a94cSmrg esac 1537b312a94cSmrg 1538b312a94cSmrg eval _G_hook_fns=\$$1_hooks; shift 1539b312a94cSmrg 1540b312a94cSmrg for _G_hook in $_G_hook_fns; do 1541b312a94cSmrg eval $_G_hook '"$@"' 1542b312a94cSmrg 1543b312a94cSmrg # store returned options list back into positional 1544b312a94cSmrg # parameters for next 'cmd' execution. 1545b312a94cSmrg eval _G_hook_result=\$${_G_hook}_result 1546b312a94cSmrg eval set dummy "$_G_hook_result"; shift 1547b312a94cSmrg done 1548b312a94cSmrg 1549b312a94cSmrg func_quote_for_eval ${1+"$@"} 1550b312a94cSmrg func_run_hooks_result=$func_quote_for_eval_result 1551b312a94cSmrg} 1552b312a94cSmrg 1553b312a94cSmrg 1554b312a94cSmrg 1555b312a94cSmrg## --------------- ## 1556b312a94cSmrg## Option parsing. ## 1557b312a94cSmrg## --------------- ## 1558b312a94cSmrg 1559b312a94cSmrg# In order to add your own option parsing hooks, you must accept the 1560b312a94cSmrg# full positional parameter list in your hook function, remove any 1561b312a94cSmrg# options that you action, and then pass back the remaining unprocessed 1562b312a94cSmrg# options in '<hooked_function_name>_result', escaped suitably for 1563b312a94cSmrg# 'eval'. Like this: 1564b312a94cSmrg# 1565b312a94cSmrg# my_options_prep () 1566b312a94cSmrg# { 1567b312a94cSmrg# $debug_cmd 1568b312a94cSmrg# 1569b312a94cSmrg# # Extend the existing usage message. 1570b312a94cSmrg# usage_message=$usage_message' 1571b312a94cSmrg# -s, --silent don'\''t print informational messages 1572b312a94cSmrg# ' 1573b312a94cSmrg# 1574b312a94cSmrg# func_quote_for_eval ${1+"$@"} 1575b312a94cSmrg# my_options_prep_result=$func_quote_for_eval_result 1576b312a94cSmrg# } 1577b312a94cSmrg# func_add_hook func_options_prep my_options_prep 1578b312a94cSmrg# 1579b312a94cSmrg# 1580b312a94cSmrg# my_silent_option () 1581b312a94cSmrg# { 1582b312a94cSmrg# $debug_cmd 1583b312a94cSmrg# 1584b312a94cSmrg# # Note that for efficiency, we parse as many options as we can 1585b312a94cSmrg# # recognise in a loop before passing the remainder back to the 1586b312a94cSmrg# # caller on the first unrecognised argument we encounter. 1587b312a94cSmrg# while test $# -gt 0; do 1588b312a94cSmrg# opt=$1; shift 1589b312a94cSmrg# case $opt in 1590b312a94cSmrg# --silent|-s) opt_silent=: ;; 1591b312a94cSmrg# # Separate non-argument short options: 1592b312a94cSmrg# -s*) func_split_short_opt "$_G_opt" 1593b312a94cSmrg# set dummy "$func_split_short_opt_name" \ 1594b312a94cSmrg# "-$func_split_short_opt_arg" ${1+"$@"} 1595b312a94cSmrg# shift 1596b312a94cSmrg# ;; 1597b312a94cSmrg# *) set dummy "$_G_opt" "$*"; shift; break ;; 1598b312a94cSmrg# esac 1599b312a94cSmrg# done 1600b312a94cSmrg# 1601b312a94cSmrg# func_quote_for_eval ${1+"$@"} 1602b312a94cSmrg# my_silent_option_result=$func_quote_for_eval_result 1603b312a94cSmrg# } 1604b312a94cSmrg# func_add_hook func_parse_options my_silent_option 1605b312a94cSmrg# 1606b312a94cSmrg# 1607b312a94cSmrg# my_option_validation () 1608b312a94cSmrg# { 1609b312a94cSmrg# $debug_cmd 1610b312a94cSmrg# 1611b312a94cSmrg# $opt_silent && $opt_verbose && func_fatal_help "\ 1612b312a94cSmrg# '--silent' and '--verbose' options are mutually exclusive." 1613b312a94cSmrg# 1614b312a94cSmrg# func_quote_for_eval ${1+"$@"} 1615b312a94cSmrg# my_option_validation_result=$func_quote_for_eval_result 1616b312a94cSmrg# } 1617b312a94cSmrg# func_add_hook func_validate_options my_option_validation 1618b312a94cSmrg# 1619b312a94cSmrg# You'll alse need to manually amend $usage_message to reflect the extra 1620b312a94cSmrg# options you parse. It's preferable to append if you can, so that 1621b312a94cSmrg# multiple option parsing hooks can be added safely. 1622b312a94cSmrg 1623b312a94cSmrg 1624b312a94cSmrg# func_options [ARG]... 1625b312a94cSmrg# --------------------- 1626b312a94cSmrg# All the functions called inside func_options are hookable. See the 1627b312a94cSmrg# individual implementations for details. 1628b312a94cSmrgfunc_hookable func_options 1629b312a94cSmrgfunc_options () 1630b312a94cSmrg{ 1631b312a94cSmrg $debug_cmd 1632b312a94cSmrg 1633b312a94cSmrg func_options_prep ${1+"$@"} 1634b312a94cSmrg eval func_parse_options \ 1635b312a94cSmrg ${func_options_prep_result+"$func_options_prep_result"} 1636b312a94cSmrg eval func_validate_options \ 1637b312a94cSmrg ${func_parse_options_result+"$func_parse_options_result"} 1638b312a94cSmrg 1639b312a94cSmrg eval func_run_hooks func_options \ 1640b312a94cSmrg ${func_validate_options_result+"$func_validate_options_result"} 1641b312a94cSmrg 1642b312a94cSmrg # save modified positional parameters for caller 1643b312a94cSmrg func_options_result=$func_run_hooks_result 1644ef981d24Smrg} 1645ef981d24Smrg 1646ef981d24Smrg 1647b312a94cSmrg# func_options_prep [ARG]... 1648b312a94cSmrg# -------------------------- 1649b312a94cSmrg# All initialisations required before starting the option parse loop. 1650b312a94cSmrg# Note that when calling hook functions, we pass through the list of 1651b312a94cSmrg# positional parameters. If a hook function modifies that list, and 1652b312a94cSmrg# needs to propogate that back to rest of this script, then the complete 1653b312a94cSmrg# modified list must be put in 'func_run_hooks_result' before 1654b312a94cSmrg# returning. 1655b312a94cSmrgfunc_hookable func_options_prep 1656b312a94cSmrgfunc_options_prep () 1657ef981d24Smrg{ 1658b312a94cSmrg $debug_cmd 165965eef222Smrg 1660b312a94cSmrg # Option defaults: 1661b312a94cSmrg opt_verbose=false 1662b312a94cSmrg opt_warning_types= 1663b312a94cSmrg 1664b312a94cSmrg func_run_hooks func_options_prep ${1+"$@"} 166565eef222Smrg 1666b312a94cSmrg # save modified positional parameters for caller 1667b312a94cSmrg func_options_prep_result=$func_run_hooks_result 1668ef981d24Smrg} 1669ef981d24Smrg 1670ef981d24Smrg 1671b312a94cSmrg# func_parse_options [ARG]... 1672b312a94cSmrg# --------------------------- 1673b312a94cSmrg# The main option parsing loop. 1674b312a94cSmrgfunc_hookable func_parse_options 1675b312a94cSmrgfunc_parse_options () 1676ef981d24Smrg{ 1677b312a94cSmrg $debug_cmd 1678ef981d24Smrg 1679b312a94cSmrg func_parse_options_result= 168065eef222Smrg 1681b312a94cSmrg # this just eases exit handling 1682b312a94cSmrg while test $# -gt 0; do 1683b312a94cSmrg # Defer to hook functions for initial option parsing, so they 1684b312a94cSmrg # get priority in the event of reusing an option name. 1685b312a94cSmrg func_run_hooks func_parse_options ${1+"$@"} 1686ef981d24Smrg 1687b312a94cSmrg # Adjust func_parse_options positional parameters to match 1688b312a94cSmrg eval set dummy "$func_run_hooks_result"; shift 168965eef222Smrg 1690b312a94cSmrg # Break out of the loop if we already parsed every option. 1691b312a94cSmrg test $# -gt 0 || break 1692ef981d24Smrg 1693b312a94cSmrg _G_opt=$1 1694b312a94cSmrg shift 1695b312a94cSmrg case $_G_opt in 1696b312a94cSmrg --debug|-x) debug_cmd='set -x' 1697b312a94cSmrg func_echo "enabling shell trace mode" 1698b312a94cSmrg $debug_cmd 1699b312a94cSmrg ;; 1700b312a94cSmrg 1701b312a94cSmrg --no-warnings|--no-warning|--no-warn) 1702b312a94cSmrg set dummy --warnings none ${1+"$@"} 1703b312a94cSmrg shift 1704b312a94cSmrg ;; 170565eef222Smrg 1706b312a94cSmrg --warnings|--warning|-W) 1707b312a94cSmrg test $# = 0 && func_missing_arg $_G_opt && break 1708b312a94cSmrg case " $warning_categories $1" in 1709b312a94cSmrg *" $1 "*) 1710b312a94cSmrg # trailing space prevents matching last $1 above 1711b312a94cSmrg func_append_uniq opt_warning_types " $1" 1712b312a94cSmrg ;; 1713b312a94cSmrg *all) 1714b312a94cSmrg opt_warning_types=$warning_categories 1715b312a94cSmrg ;; 1716b312a94cSmrg *none) 1717b312a94cSmrg opt_warning_types=none 1718b312a94cSmrg warning_func=: 1719b312a94cSmrg ;; 1720b312a94cSmrg *error) 1721b312a94cSmrg opt_warning_types=$warning_categories 1722b312a94cSmrg warning_func=func_fatal_error 1723b312a94cSmrg ;; 1724b312a94cSmrg *) 1725b312a94cSmrg func_fatal_error \ 1726b312a94cSmrg "unsupported warning category: '$1'" 1727b312a94cSmrg ;; 1728b312a94cSmrg esac 1729b312a94cSmrg shift 1730b312a94cSmrg ;; 1731b312a94cSmrg 1732b312a94cSmrg --verbose|-v) opt_verbose=: ;; 1733b312a94cSmrg --version) func_version ;; 1734b312a94cSmrg -\?|-h) func_usage ;; 1735b312a94cSmrg --help) func_help ;; 1736b312a94cSmrg 1737b312a94cSmrg # Separate optargs to long options (plugins may need this): 1738b312a94cSmrg --*=*) func_split_equals "$_G_opt" 1739b312a94cSmrg set dummy "$func_split_equals_lhs" \ 1740b312a94cSmrg "$func_split_equals_rhs" ${1+"$@"} 1741b312a94cSmrg shift 1742b312a94cSmrg ;; 1743b312a94cSmrg 1744b312a94cSmrg # Separate optargs to short options: 1745b312a94cSmrg -W*) 1746b312a94cSmrg func_split_short_opt "$_G_opt" 1747b312a94cSmrg set dummy "$func_split_short_opt_name" \ 1748b312a94cSmrg "$func_split_short_opt_arg" ${1+"$@"} 1749b312a94cSmrg shift 1750b312a94cSmrg ;; 1751b312a94cSmrg 1752b312a94cSmrg # Separate non-argument short options: 1753b312a94cSmrg -\?*|-h*|-v*|-x*) 1754b312a94cSmrg func_split_short_opt "$_G_opt" 1755b312a94cSmrg set dummy "$func_split_short_opt_name" \ 1756b312a94cSmrg "-$func_split_short_opt_arg" ${1+"$@"} 1757b312a94cSmrg shift 1758b312a94cSmrg ;; 1759b312a94cSmrg 1760b312a94cSmrg --) break ;; 1761b312a94cSmrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1762b312a94cSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1763b312a94cSmrg esac 1764b312a94cSmrg done 1765ef981d24Smrg 1766b312a94cSmrg # save modified positional parameters for caller 1767b312a94cSmrg func_quote_for_eval ${1+"$@"} 1768b312a94cSmrg func_parse_options_result=$func_quote_for_eval_result 1769200d7199Smrg} 1770200d7199Smrg 1771ef981d24Smrg 1772b312a94cSmrg# func_validate_options [ARG]... 1773b312a94cSmrg# ------------------------------ 1774b312a94cSmrg# Perform any sanity checks on option settings and/or unconsumed 1775b312a94cSmrg# arguments. 1776b312a94cSmrgfunc_hookable func_validate_options 1777b312a94cSmrgfunc_validate_options () 177865eef222Smrg{ 1779b312a94cSmrg $debug_cmd 1780200d7199Smrg 1781b312a94cSmrg # Display all warnings if -W was not given. 1782b312a94cSmrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 1783b312a94cSmrg 1784b312a94cSmrg func_run_hooks func_validate_options ${1+"$@"} 1785b312a94cSmrg 1786b312a94cSmrg # Bail if the options were screwed! 1787b312a94cSmrg $exit_cmd $EXIT_FAILURE 1788b312a94cSmrg 1789b312a94cSmrg # save modified positional parameters for caller 1790b312a94cSmrg func_validate_options_result=$func_run_hooks_result 179165eef222Smrg} 179265eef222Smrg 1793b312a94cSmrg 1794b312a94cSmrg 1795b312a94cSmrg## ----------------- ## 1796b312a94cSmrg## Helper functions. ## 1797b312a94cSmrg## ----------------- ## 1798b312a94cSmrg 1799b312a94cSmrg# This section contains the helper functions used by the rest of the 1800b312a94cSmrg# hookable option parser framework in ascii-betical order. 1801b312a94cSmrg 1802b312a94cSmrg 1803b312a94cSmrg# func_fatal_help ARG... 1804b312a94cSmrg# ---------------------- 1805b312a94cSmrg# Echo program name prefixed message to standard error, followed by 1806b312a94cSmrg# a help hint, and exit. 1807b312a94cSmrgfunc_fatal_help () 180865eef222Smrg{ 1809b312a94cSmrg $debug_cmd 1810200d7199Smrg 1811b312a94cSmrg eval \$ECHO \""Usage: $usage"\" 1812b312a94cSmrg eval \$ECHO \""$fatal_help"\" 1813b312a94cSmrg func_error ${1+"$@"} 1814b312a94cSmrg exit $EXIT_FAILURE 181565eef222Smrg} 181665eef222Smrg 1817b312a94cSmrg 1818b312a94cSmrg# func_help 1819b312a94cSmrg# --------- 1820b312a94cSmrg# Echo long help message to standard output and exit. 182165eef222Smrgfunc_help () 182265eef222Smrg{ 1823b312a94cSmrg $debug_cmd 1824b312a94cSmrg 1825b312a94cSmrg func_usage_message 1826b312a94cSmrg $ECHO "$long_help_message" 1827b312a94cSmrg exit 0 182865eef222Smrg} 182965eef222Smrg 1830b312a94cSmrg 1831b312a94cSmrg# func_missing_arg ARGNAME 1832b312a94cSmrg# ------------------------ 183365eef222Smrg# Echo program name prefixed message to standard error and set global 183465eef222Smrg# exit_cmd. 183565eef222Smrgfunc_missing_arg () 183665eef222Smrg{ 1837b312a94cSmrg $debug_cmd 1838200d7199Smrg 1839b312a94cSmrg func_error "Missing argument for '$1'." 184065eef222Smrg exit_cmd=exit 184165eef222Smrg} 184265eef222Smrg 184365eef222Smrg 1844b312a94cSmrg# func_split_equals STRING 1845b312a94cSmrg# ------------------------ 1846b312a94cSmrg# Set func_split_equals_lhs and func_split_equals_rhs shell variables after 1847b312a94cSmrg# splitting STRING at the '=' sign. 1848b312a94cSmrgtest -z "$_G_HAVE_XSI_OPS" \ 1849b312a94cSmrg && (eval 'x=a/b/c; 1850b312a94cSmrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 1851b312a94cSmrg && _G_HAVE_XSI_OPS=yes 1852b312a94cSmrg 1853b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS" 1854b312a94cSmrgthen 1855b312a94cSmrg # This is an XSI compatible shell, allowing a faster implementation... 1856b312a94cSmrg eval 'func_split_equals () 1857b312a94cSmrg { 1858b312a94cSmrg $debug_cmd 1859b312a94cSmrg 1860b312a94cSmrg func_split_equals_lhs=${1%%=*} 1861b312a94cSmrg func_split_equals_rhs=${1#*=} 1862b312a94cSmrg test "x$func_split_equals_lhs" = "x$1" \ 1863b312a94cSmrg && func_split_equals_rhs= 1864b312a94cSmrg }' 1865b312a94cSmrgelse 1866b312a94cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 1867b312a94cSmrg func_split_equals () 1868b312a94cSmrg { 1869b312a94cSmrg $debug_cmd 1870b312a94cSmrg 1871b312a94cSmrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 1872b312a94cSmrg func_split_equals_rhs= 1873b312a94cSmrg test "x$func_split_equals_lhs" = "x$1" \ 1874b312a94cSmrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 1875b312a94cSmrg } 1876b312a94cSmrgfi #func_split_equals 1877b312a94cSmrg 1878b312a94cSmrg 1879b312a94cSmrg# func_split_short_opt SHORTOPT 1880b312a94cSmrg# ----------------------------- 1881200d7199Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 1882200d7199Smrg# variables after splitting SHORTOPT after the 2nd character. 1883b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS" 1884b312a94cSmrgthen 1885b312a94cSmrg # This is an XSI compatible shell, allowing a faster implementation... 1886b312a94cSmrg eval 'func_split_short_opt () 1887b312a94cSmrg { 1888b312a94cSmrg $debug_cmd 1889b312a94cSmrg 1890b312a94cSmrg func_split_short_opt_arg=${1#??} 1891b312a94cSmrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 1892b312a94cSmrg }' 1893b312a94cSmrgelse 1894b312a94cSmrg # ...otherwise fall back to using expr, which is often a shell builtin. 1895b312a94cSmrg func_split_short_opt () 1896b312a94cSmrg { 1897b312a94cSmrg $debug_cmd 1898b312a94cSmrg 1899b312a94cSmrg func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` 1900b312a94cSmrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 1901b312a94cSmrg } 1902b312a94cSmrgfi #func_split_short_opt 1903b312a94cSmrg 1904b312a94cSmrg 1905b312a94cSmrg# func_usage 1906b312a94cSmrg# ---------- 1907b312a94cSmrg# Echo short help message to standard output and exit. 1908b312a94cSmrgfunc_usage () 1909200d7199Smrg{ 1910b312a94cSmrg $debug_cmd 1911200d7199Smrg 1912b312a94cSmrg func_usage_message 1913b312a94cSmrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 1914b312a94cSmrg exit 0 1915b312a94cSmrg} 1916200d7199Smrg 1917200d7199Smrg 1918b312a94cSmrg# func_usage_message 1919b312a94cSmrg# ------------------ 1920b312a94cSmrg# Echo short help message to standard output. 1921b312a94cSmrgfunc_usage_message () 1922200d7199Smrg{ 1923b312a94cSmrg $debug_cmd 1924200d7199Smrg 1925b312a94cSmrg eval \$ECHO \""Usage: $usage"\" 1926b312a94cSmrg echo 1927b312a94cSmrg $SED -n 's|^# || 1928b312a94cSmrg /^Written by/{ 1929b312a94cSmrg x;p;x 1930b312a94cSmrg } 1931b312a94cSmrg h 1932b312a94cSmrg /^Written by/q' < "$progpath" 1933b312a94cSmrg echo 1934b312a94cSmrg eval \$ECHO \""$usage_message"\" 1935b312a94cSmrg} 1936200d7199Smrg 193765eef222Smrg 1938b312a94cSmrg# func_version 1939b312a94cSmrg# ------------ 1940b312a94cSmrg# Echo version message to standard output and exit. 1941b312a94cSmrgfunc_version () 1942b312a94cSmrg{ 1943b312a94cSmrg $debug_cmd 194465eef222Smrg 1945b312a94cSmrg printf '%s\n' "$progname $scriptversion" 1946b312a94cSmrg $SED -n ' 1947b312a94cSmrg /(C)/!b go 1948b312a94cSmrg :more 1949b312a94cSmrg /\./!{ 1950b312a94cSmrg N 1951b312a94cSmrg s|\n# | | 1952b312a94cSmrg b more 1953b312a94cSmrg } 1954b312a94cSmrg :go 1955b312a94cSmrg /^# Written by /,/# warranty; / { 1956b312a94cSmrg s|^# || 1957b312a94cSmrg s|^# *$|| 1958b312a94cSmrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 1959b312a94cSmrg p 1960b312a94cSmrg } 1961b312a94cSmrg /^# Written by / { 1962b312a94cSmrg s|^# || 1963b312a94cSmrg p 1964b312a94cSmrg } 1965b312a94cSmrg /^warranty; /q' < "$progpath" 196665eef222Smrg 1967b312a94cSmrg exit $? 1968b312a94cSmrg} 196965eef222Smrg 1970ef981d24Smrg 1971b312a94cSmrg# Local variables: 1972b312a94cSmrg# mode: shell-script 1973b312a94cSmrg# sh-indentation: 2 1974b312a94cSmrg# eval: (add-hook 'before-save-hook 'time-stamp) 1975b312a94cSmrg# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1976b312a94cSmrg# time-stamp-time-zone: "UTC" 1977b312a94cSmrg# End: 1978ef981d24Smrg 1979b312a94cSmrg# Set a version string. 1980b312a94cSmrgscriptversion='(GNU libtool) 2.4.6' 1981ef981d24Smrg 1982ef981d24Smrg 1983b312a94cSmrg# func_echo ARG... 1984b312a94cSmrg# ---------------- 1985b312a94cSmrg# Libtool also displays the current mode in messages, so override 1986b312a94cSmrg# funclib.sh func_echo with this custom definition. 1987b312a94cSmrgfunc_echo () 1988200d7199Smrg{ 1989b312a94cSmrg $debug_cmd 1990200d7199Smrg 1991b312a94cSmrg _G_message=$* 1992b312a94cSmrg 1993b312a94cSmrg func_echo_IFS=$IFS 1994b312a94cSmrg IFS=$nl 1995b312a94cSmrg for _G_line in $_G_message; do 1996b312a94cSmrg IFS=$func_echo_IFS 1997b312a94cSmrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 1998b312a94cSmrg done 1999b312a94cSmrg IFS=$func_echo_IFS 2000b312a94cSmrg} 2001200d7199Smrg 2002200d7199Smrg 2003b312a94cSmrg# func_warning ARG... 2004b312a94cSmrg# ------------------- 2005b312a94cSmrg# Libtool warnings are not categorized, so override funclib.sh 2006b312a94cSmrg# func_warning with this simpler definition. 2007b312a94cSmrgfunc_warning () 2008200d7199Smrg{ 2009b312a94cSmrg $debug_cmd 2010200d7199Smrg 2011b312a94cSmrg $warning_func ${1+"$@"} 2012b312a94cSmrg} 2013200d7199Smrg 2014200d7199Smrg 2015b312a94cSmrg## ---------------- ## 2016b312a94cSmrg## Options parsing. ## 2017b312a94cSmrg## ---------------- ## 2018b312a94cSmrg 2019b312a94cSmrg# Hook in the functions to make sure our own options are parsed during 2020b312a94cSmrg# the option parsing loop. 2021b312a94cSmrg 2022b312a94cSmrgusage='$progpath [OPTION]... [MODE-ARG]...' 2023b312a94cSmrg 2024b312a94cSmrg# Short help message in response to '-h'. 2025b312a94cSmrgusage_message="Options: 2026b312a94cSmrg --config show all configuration variables 2027b312a94cSmrg --debug enable verbose shell tracing 2028b312a94cSmrg -n, --dry-run display commands without modifying any files 2029b312a94cSmrg --features display basic configuration information and exit 2030b312a94cSmrg --mode=MODE use operation mode MODE 2031b312a94cSmrg --no-warnings equivalent to '-Wnone' 2032b312a94cSmrg --preserve-dup-deps don't remove duplicate dependency libraries 2033b312a94cSmrg --quiet, --silent don't print informational messages 2034b312a94cSmrg --tag=TAG use configuration variables from tag TAG 2035b312a94cSmrg -v, --verbose print more informational messages than default 2036b312a94cSmrg --version print version information 2037b312a94cSmrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2038b312a94cSmrg -h, --help, --help-all print short, long, or detailed help message 2039b312a94cSmrg" 2040200d7199Smrg 2041b312a94cSmrg# Additional text appended to 'usage_message' in response to '--help'. 2042b312a94cSmrgfunc_help () 2043200d7199Smrg{ 2044b312a94cSmrg $debug_cmd 2045b312a94cSmrg 2046b312a94cSmrg func_usage_message 2047b312a94cSmrg $ECHO "$long_help_message 2048b312a94cSmrg 2049b312a94cSmrgMODE must be one of the following: 2050b312a94cSmrg 2051b312a94cSmrg clean remove files from the build directory 2052b312a94cSmrg compile compile a source file into a libtool object 2053b312a94cSmrg execute automatically set library path, then run a program 2054b312a94cSmrg finish complete the installation of libtool libraries 2055b312a94cSmrg install install libraries or executables 2056b312a94cSmrg link create a library or an executable 2057b312a94cSmrg uninstall remove libraries from an installed directory 2058b312a94cSmrg 2059b312a94cSmrgMODE-ARGS vary depending on the MODE. When passed as first option, 2060b312a94cSmrg'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2061b312a94cSmrgTry '$progname --help --mode=MODE' for a more detailed description of MODE. 2062b312a94cSmrg 2063b312a94cSmrgWhen reporting a bug, please describe a test case to reproduce it and 2064b312a94cSmrginclude the following information: 2065b312a94cSmrg 2066b312a94cSmrg host-triplet: $host 2067b312a94cSmrg shell: $SHELL 2068b312a94cSmrg compiler: $LTCC 2069b312a94cSmrg compiler flags: $LTCFLAGS 2070b312a94cSmrg linker: $LD (gnu? $with_gnu_ld) 2071b312a94cSmrg version: $progname (GNU libtool) 2.4.6 2072b312a94cSmrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2073b312a94cSmrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2074b312a94cSmrg 2075b312a94cSmrgReport bugs to <bug-libtool@gnu.org>. 2076b312a94cSmrgGNU libtool home page: <http://www.gnu.org/software/libtool/>. 2077b312a94cSmrgGeneral help using GNU software: <http://www.gnu.org/gethelp/>." 2078b312a94cSmrg exit 0 2079b312a94cSmrg} 2080200d7199Smrg 2081200d7199Smrg 2082b312a94cSmrg# func_lo2o OBJECT-NAME 2083b312a94cSmrg# --------------------- 2084b312a94cSmrg# Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2085b312a94cSmrg# object suffix. 2086b312a94cSmrg 2087b312a94cSmrglo2o=s/\\.lo\$/.$objext/ 2088b312a94cSmrgo2lo=s/\\.$objext\$/.lo/ 2089b312a94cSmrg 2090b312a94cSmrgif test yes = "$_G_HAVE_XSI_OPS"; then 2091b312a94cSmrg eval 'func_lo2o () 2092b312a94cSmrg { 2093b312a94cSmrg case $1 in 2094b312a94cSmrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2095b312a94cSmrg * ) func_lo2o_result=$1 ;; 2096b312a94cSmrg esac 2097b312a94cSmrg }' 2098b312a94cSmrg 2099b312a94cSmrg # func_xform LIBOBJ-OR-SOURCE 2100b312a94cSmrg # --------------------------- 2101b312a94cSmrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2102b312a94cSmrg # suffix to a '.lo' libtool-object suffix. 2103b312a94cSmrg eval 'func_xform () 2104b312a94cSmrg { 2105b312a94cSmrg func_xform_result=${1%.*}.lo 2106b312a94cSmrg }' 2107b312a94cSmrgelse 2108b312a94cSmrg # ...otherwise fall back to using sed. 2109b312a94cSmrg func_lo2o () 2110b312a94cSmrg { 2111b312a94cSmrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2112b312a94cSmrg } 2113b312a94cSmrg 2114b312a94cSmrg func_xform () 2115b312a94cSmrg { 2116b312a94cSmrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2117b312a94cSmrg } 2118b312a94cSmrgfi 2119200d7199Smrg 2120200d7199Smrg 2121b312a94cSmrg# func_fatal_configuration ARG... 2122b312a94cSmrg# ------------------------------- 212365eef222Smrg# Echo program name prefixed message to standard error, followed by 212465eef222Smrg# a configuration failure hint, and exit. 212565eef222Smrgfunc_fatal_configuration () 212665eef222Smrg{ 2127b312a94cSmrg func__fatal_error ${1+"$@"} \ 2128b312a94cSmrg "See the $PACKAGE documentation for more information." \ 2129b312a94cSmrg "Fatal configuration error." 213065eef222Smrg} 213165eef222Smrg 213265eef222Smrg 213365eef222Smrg# func_config 2134b312a94cSmrg# ----------- 213565eef222Smrg# Display the configuration for all the tags in this script. 213665eef222Smrgfunc_config () 213765eef222Smrg{ 213865eef222Smrg re_begincf='^# ### BEGIN LIBTOOL' 213965eef222Smrg re_endcf='^# ### END LIBTOOL' 214065eef222Smrg 214165eef222Smrg # Default configuration. 214265eef222Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2143ef981d24Smrg 2144ef981d24Smrg # Now print the configurations for the tags. 2145ef981d24Smrg for tagname in $taglist; do 214665eef222Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2147ef981d24Smrg done 2148ef981d24Smrg 214965eef222Smrg exit $? 215065eef222Smrg} 2151ef981d24Smrg 2152b312a94cSmrg 215365eef222Smrg# func_features 2154b312a94cSmrg# ------------- 215565eef222Smrg# Display the features supported by this script. 215665eef222Smrgfunc_features () 215765eef222Smrg{ 215856957a04Smrg echo "host: $host" 2159b312a94cSmrg if test yes = "$build_libtool_libs"; then 216056957a04Smrg echo "enable shared libraries" 2161ef981d24Smrg else 216256957a04Smrg echo "disable shared libraries" 2163ef981d24Smrg fi 2164b312a94cSmrg if test yes = "$build_old_libs"; then 216556957a04Smrg echo "enable static libraries" 2166ef981d24Smrg else 216756957a04Smrg echo "disable static libraries" 2168ef981d24Smrg fi 216965eef222Smrg 2170ef981d24Smrg exit $? 217165eef222Smrg} 217265eef222Smrg 2173b312a94cSmrg 2174b312a94cSmrg# func_enable_tag TAGNAME 2175b312a94cSmrg# ----------------------- 217665eef222Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 217765eef222Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 217865eef222Smrg# variable here. 217965eef222Smrgfunc_enable_tag () 218065eef222Smrg{ 2181b312a94cSmrg # Global variable: 2182b312a94cSmrg tagname=$1 2183ef981d24Smrg 2184b312a94cSmrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2185b312a94cSmrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2186b312a94cSmrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2187ef981d24Smrg 2188b312a94cSmrg # Validate tagname. 2189b312a94cSmrg case $tagname in 2190b312a94cSmrg *[!-_A-Za-z0-9,/]*) 2191b312a94cSmrg func_fatal_error "invalid tag name: $tagname" 2192b312a94cSmrg ;; 2193b312a94cSmrg esac 2194ef981d24Smrg 2195b312a94cSmrg # Don't test for the "default" C tag, as we know it's 2196b312a94cSmrg # there but not specially marked. 2197b312a94cSmrg case $tagname in 2198b312a94cSmrg CC) ;; 219965eef222Smrg *) 2200b312a94cSmrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2201b312a94cSmrg taglist="$taglist $tagname" 2202b312a94cSmrg 2203b312a94cSmrg # Evaluate the configuration. Be careful to quote the path 2204b312a94cSmrg # and the sed script, to avoid splitting on whitespace, but 2205b312a94cSmrg # also don't use non-portable quotes within backquotes within 2206b312a94cSmrg # quotes we have to do it in 2 steps: 2207b312a94cSmrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2208b312a94cSmrg eval "$extractedcf" 2209b312a94cSmrg else 2210b312a94cSmrg func_error "ignoring unknown tag $tagname" 2211b312a94cSmrg fi 2212b312a94cSmrg ;; 2213b312a94cSmrg esac 221465eef222Smrg} 2215ef981d24Smrg 2216b312a94cSmrg 2217200d7199Smrg# func_check_version_match 2218b312a94cSmrg# ------------------------ 2219200d7199Smrg# Ensure that we are using m4 macros, and libtool script from the same 2220200d7199Smrg# release of libtool. 2221200d7199Smrgfunc_check_version_match () 222265eef222Smrg{ 2223b312a94cSmrg if test "$package_revision" != "$macro_revision"; then 2224b312a94cSmrg if test "$VERSION" != "$macro_version"; then 2225b312a94cSmrg if test -z "$macro_version"; then 2226b312a94cSmrg cat >&2 <<_LT_EOF 2227200d7199Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2228200d7199Smrg$progname: definition of this LT_INIT comes from an older release. 2229200d7199Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2230200d7199Smrg$progname: and run autoconf again. 2231200d7199Smrg_LT_EOF 2232b312a94cSmrg else 2233b312a94cSmrg cat >&2 <<_LT_EOF 2234200d7199Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2235200d7199Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2236200d7199Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2237200d7199Smrg$progname: and run autoconf again. 2238200d7199Smrg_LT_EOF 2239b312a94cSmrg fi 2240b312a94cSmrg else 2241b312a94cSmrg cat >&2 <<_LT_EOF 2242200d7199Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2243200d7199Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 2244200d7199Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 2245200d7199Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 2246200d7199Smrg_LT_EOF 2247b312a94cSmrg fi 2248ef981d24Smrg 2249b312a94cSmrg exit $EXIT_MISMATCH 2250b312a94cSmrg fi 2251200d7199Smrg} 2252200d7199Smrg 2253200d7199Smrg 2254b312a94cSmrg# libtool_options_prep [ARG]... 2255b312a94cSmrg# ----------------------------- 2256b312a94cSmrg# Preparation for options parsed by libtool. 2257b312a94cSmrglibtool_options_prep () 2258b312a94cSmrg{ 2259b312a94cSmrg $debug_mode 2260ef981d24Smrg 2261b312a94cSmrg # Option defaults: 2262b312a94cSmrg opt_config=false 2263b312a94cSmrg opt_dlopen= 2264b312a94cSmrg opt_dry_run=false 2265b312a94cSmrg opt_help=false 2266b312a94cSmrg opt_mode= 2267b312a94cSmrg opt_preserve_dup_deps=false 2268b312a94cSmrg opt_quiet=false 2269200d7199Smrg 2270b312a94cSmrg nonopt= 2271b312a94cSmrg preserve_args= 2272200d7199Smrg 2273b312a94cSmrg # Shorthand for --mode=foo, only valid as the first argument 2274b312a94cSmrg case $1 in 2275b312a94cSmrg clean|clea|cle|cl) 2276b312a94cSmrg shift; set dummy --mode clean ${1+"$@"}; shift 2277b312a94cSmrg ;; 2278b312a94cSmrg compile|compil|compi|comp|com|co|c) 2279b312a94cSmrg shift; set dummy --mode compile ${1+"$@"}; shift 2280b312a94cSmrg ;; 2281b312a94cSmrg execute|execut|execu|exec|exe|ex|e) 2282b312a94cSmrg shift; set dummy --mode execute ${1+"$@"}; shift 2283b312a94cSmrg ;; 2284b312a94cSmrg finish|finis|fini|fin|fi|f) 2285b312a94cSmrg shift; set dummy --mode finish ${1+"$@"}; shift 2286b312a94cSmrg ;; 2287b312a94cSmrg install|instal|insta|inst|ins|in|i) 2288b312a94cSmrg shift; set dummy --mode install ${1+"$@"}; shift 2289b312a94cSmrg ;; 2290b312a94cSmrg link|lin|li|l) 2291b312a94cSmrg shift; set dummy --mode link ${1+"$@"}; shift 2292b312a94cSmrg ;; 2293b312a94cSmrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2294b312a94cSmrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2295b312a94cSmrg ;; 2296b312a94cSmrg esac 2297b312a94cSmrg 2298b312a94cSmrg # Pass back the list of options. 2299b312a94cSmrg func_quote_for_eval ${1+"$@"} 2300b312a94cSmrg libtool_options_prep_result=$func_quote_for_eval_result 2301b312a94cSmrg} 2302b312a94cSmrgfunc_add_hook func_options_prep libtool_options_prep 2303200d7199Smrg 2304200d7199Smrg 2305b312a94cSmrg# libtool_parse_options [ARG]... 2306b312a94cSmrg# --------------------------------- 2307b312a94cSmrg# Provide handling for libtool specific options. 2308b312a94cSmrglibtool_parse_options () 2309200d7199Smrg{ 2310b312a94cSmrg $debug_cmd 231165eef222Smrg 2312b312a94cSmrg # Perform our own loop to consume as many options as possible in 2313b312a94cSmrg # each iteration. 2314b312a94cSmrg while test $# -gt 0; do 2315b312a94cSmrg _G_opt=$1 2316b312a94cSmrg shift 2317b312a94cSmrg case $_G_opt in 2318b312a94cSmrg --dry-run|--dryrun|-n) 2319b312a94cSmrg opt_dry_run=: 2320b312a94cSmrg ;; 2321b312a94cSmrg 2322b312a94cSmrg --config) func_config ;; 2323b312a94cSmrg 2324b312a94cSmrg --dlopen|-dlopen) 2325b312a94cSmrg opt_dlopen="${opt_dlopen+$opt_dlopen 2326b312a94cSmrg}$1" 2327b312a94cSmrg shift 2328b312a94cSmrg ;; 2329b312a94cSmrg 2330b312a94cSmrg --preserve-dup-deps) 2331b312a94cSmrg opt_preserve_dup_deps=: ;; 2332b312a94cSmrg 2333b312a94cSmrg --features) func_features ;; 2334b312a94cSmrg 2335b312a94cSmrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2336b312a94cSmrg 2337b312a94cSmrg --help) opt_help=: ;; 2338b312a94cSmrg 2339b312a94cSmrg --help-all) opt_help=': help-all' ;; 2340b312a94cSmrg 2341b312a94cSmrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2342b312a94cSmrg opt_mode=$1 2343b312a94cSmrg case $1 in 2344b312a94cSmrg # Valid mode arguments: 2345b312a94cSmrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2346b312a94cSmrg 2347b312a94cSmrg # Catch anything else as an error 2348b312a94cSmrg *) func_error "invalid argument for $_G_opt" 2349b312a94cSmrg exit_cmd=exit 2350b312a94cSmrg break 2351b312a94cSmrg ;; 2352b312a94cSmrg esac 2353b312a94cSmrg shift 2354b312a94cSmrg ;; 2355b312a94cSmrg 2356b312a94cSmrg --no-silent|--no-quiet) 2357b312a94cSmrg opt_quiet=false 2358b312a94cSmrg func_append preserve_args " $_G_opt" 2359b312a94cSmrg ;; 2360b312a94cSmrg 2361b312a94cSmrg --no-warnings|--no-warning|--no-warn) 2362b312a94cSmrg opt_warning=false 2363b312a94cSmrg func_append preserve_args " $_G_opt" 2364b312a94cSmrg ;; 2365b312a94cSmrg 2366b312a94cSmrg --no-verbose) 2367b312a94cSmrg opt_verbose=false 2368b312a94cSmrg func_append preserve_args " $_G_opt" 2369b312a94cSmrg ;; 2370b312a94cSmrg 2371b312a94cSmrg --silent|--quiet) 2372b312a94cSmrg opt_quiet=: 2373b312a94cSmrg opt_verbose=false 2374b312a94cSmrg func_append preserve_args " $_G_opt" 2375b312a94cSmrg ;; 2376b312a94cSmrg 2377b312a94cSmrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2378b312a94cSmrg opt_tag=$1 2379b312a94cSmrg func_append preserve_args " $_G_opt $1" 2380b312a94cSmrg func_enable_tag "$1" 2381b312a94cSmrg shift 2382b312a94cSmrg ;; 2383b312a94cSmrg 2384b312a94cSmrg --verbose|-v) opt_quiet=false 2385b312a94cSmrg opt_verbose=: 2386b312a94cSmrg func_append preserve_args " $_G_opt" 2387b312a94cSmrg ;; 2388b312a94cSmrg 2389b312a94cSmrg # An option not handled by this hook function: 2390b312a94cSmrg *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 2391b312a94cSmrg esac 2392b312a94cSmrg done 2393200d7199Smrg 2394200d7199Smrg 2395b312a94cSmrg # save modified positional parameters for caller 2396b312a94cSmrg func_quote_for_eval ${1+"$@"} 2397b312a94cSmrg libtool_parse_options_result=$func_quote_for_eval_result 2398b312a94cSmrg} 2399b312a94cSmrgfunc_add_hook func_parse_options libtool_parse_options 240065eef222Smrg 2401ef981d24Smrg 240265eef222Smrg 2403b312a94cSmrg# libtool_validate_options [ARG]... 2404b312a94cSmrg# --------------------------------- 2405b312a94cSmrg# Perform any sanity checks on option settings and/or unconsumed 2406b312a94cSmrg# arguments. 2407b312a94cSmrglibtool_validate_options () 2408b312a94cSmrg{ 2409b312a94cSmrg # save first non-option argument 2410b312a94cSmrg if test 0 -lt $#; then 2411b312a94cSmrg nonopt=$1 2412b312a94cSmrg shift 241365eef222Smrg fi 241465eef222Smrg 2415b312a94cSmrg # preserve --debug 2416b312a94cSmrg test : = "$debug_cmd" || func_append preserve_args " --debug" 241765eef222Smrg 2418b312a94cSmrg case $host in 2419b312a94cSmrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2420b312a94cSmrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2421b312a94cSmrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2422b312a94cSmrg # don't eliminate duplications in $postdeps and $predeps 2423b312a94cSmrg opt_duplicate_compiler_generated_deps=: 2424b312a94cSmrg ;; 2425b312a94cSmrg *) 2426b312a94cSmrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2427b312a94cSmrg ;; 2428b312a94cSmrg esac 242965eef222Smrg 2430b312a94cSmrg $opt_help || { 2431b312a94cSmrg # Sanity checks first: 2432b312a94cSmrg func_check_version_match 2433b312a94cSmrg 2434b312a94cSmrg test yes != "$build_libtool_libs" \ 2435b312a94cSmrg && test yes != "$build_old_libs" \ 2436b312a94cSmrg && func_fatal_configuration "not configured to build any kind of library" 243765eef222Smrg 2438b312a94cSmrg # Darwin sucks 2439b312a94cSmrg eval std_shrext=\"$shrext_cmds\" 244065eef222Smrg 2441b312a94cSmrg # Only execute mode is allowed to have -dlopen flags. 2442b312a94cSmrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2443b312a94cSmrg func_error "unrecognized option '-dlopen'" 2444b312a94cSmrg $ECHO "$help" 1>&2 2445b312a94cSmrg exit $EXIT_FAILURE 2446b312a94cSmrg fi 2447b312a94cSmrg 2448b312a94cSmrg # Change the help message to a mode-specific one. 2449b312a94cSmrg generic_help=$help 2450b312a94cSmrg help="Try '$progname --help --mode=$opt_mode' for more information." 2451b312a94cSmrg } 2452b312a94cSmrg 2453b312a94cSmrg # Pass back the unparsed argument list 2454b312a94cSmrg func_quote_for_eval ${1+"$@"} 2455b312a94cSmrg libtool_validate_options_result=$func_quote_for_eval_result 2456200d7199Smrg} 2457b312a94cSmrgfunc_add_hook func_validate_options libtool_validate_options 245865eef222Smrg 245965eef222Smrg 2460b312a94cSmrg# Process options as early as possible so that --help and --version 2461b312a94cSmrg# can return quickly. 2462b312a94cSmrgfunc_options ${1+"$@"} 2463b312a94cSmrgeval set dummy "$func_options_result"; shift 2464b312a94cSmrg 2465ef981d24Smrg 2466ef981d24Smrg 2467200d7199Smrg## ----------- ## 2468200d7199Smrg## Main. ## 2469200d7199Smrg## ----------- ## 2470ef981d24Smrg 2471b312a94cSmrgmagic='%%%MAGIC variable%%%' 2472b312a94cSmrgmagic_exe='%%%MAGIC EXE variable%%%' 2473b312a94cSmrg 2474b312a94cSmrg# Global variables. 2475b312a94cSmrgextracted_archives= 2476b312a94cSmrgextracted_serial=0 2477b312a94cSmrg 2478b312a94cSmrg# If this variable is set in any of the actions, the command in it 2479b312a94cSmrg# will be execed at the end. This prevents here-documents from being 2480b312a94cSmrg# left over by shells. 2481b312a94cSmrgexec_cmd= 2482b312a94cSmrg 2483b312a94cSmrg 2484b312a94cSmrg# A function that is used when there is no print builtin or printf. 2485b312a94cSmrgfunc_fallback_echo () 2486b312a94cSmrg{ 2487b312a94cSmrg eval 'cat <<_LTECHO_EOF 2488b312a94cSmrg$1 2489b312a94cSmrg_LTECHO_EOF' 2490b312a94cSmrg} 2491b312a94cSmrg 2492b312a94cSmrg# func_generated_by_libtool 2493b312a94cSmrg# True iff stdin has been generated by Libtool. This function is only 2494b312a94cSmrg# a basic sanity check; it will hardly flush out determined imposters. 2495b312a94cSmrgfunc_generated_by_libtool_p () 2496b312a94cSmrg{ 2497b312a94cSmrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2498b312a94cSmrg} 2499b312a94cSmrg 250065eef222Smrg# func_lalib_p file 2501b312a94cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 250265eef222Smrg# This function is only a basic sanity check; it will hardly flush out 250365eef222Smrg# determined imposters. 250465eef222Smrgfunc_lalib_p () 250565eef222Smrg{ 250665eef222Smrg test -f "$1" && 2507b312a94cSmrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 250865eef222Smrg} 2509ef981d24Smrg 251065eef222Smrg# func_lalib_unsafe_p file 2511b312a94cSmrg# True iff FILE is a libtool '.la' library or '.lo' object file. 251265eef222Smrg# This function implements the same check as func_lalib_p without 251365eef222Smrg# resorting to external programs. To this end, it redirects stdin and 251465eef222Smrg# closes it afterwards, without saving the original file descriptor. 251565eef222Smrg# As a safety measure, use it only where a negative result would be 2516b312a94cSmrg# fatal anyway. Works if 'file' does not exist. 251765eef222Smrgfunc_lalib_unsafe_p () 251865eef222Smrg{ 251965eef222Smrg lalib_p=no 252065eef222Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 252165eef222Smrg for lalib_p_l in 1 2 3 4 252265eef222Smrg do 252365eef222Smrg read lalib_p_line 2524b312a94cSmrg case $lalib_p_line in 252565eef222Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 252665eef222Smrg esac 252765eef222Smrg done 252865eef222Smrg exec 0<&5 5<&- 252965eef222Smrg fi 2530b312a94cSmrg test yes = "$lalib_p" 253165eef222Smrg} 2532ef981d24Smrg 253365eef222Smrg# func_ltwrapper_script_p file 253465eef222Smrg# True iff FILE is a libtool wrapper script 253565eef222Smrg# This function is only a basic sanity check; it will hardly flush out 253665eef222Smrg# determined imposters. 253765eef222Smrgfunc_ltwrapper_script_p () 253865eef222Smrg{ 2539b312a94cSmrg test -f "$1" && 2540b312a94cSmrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 254165eef222Smrg} 2542ef981d24Smrg 254365eef222Smrg# func_ltwrapper_executable_p file 254465eef222Smrg# True iff FILE is a libtool wrapper executable 254565eef222Smrg# This function is only a basic sanity check; it will hardly flush out 254665eef222Smrg# determined imposters. 254765eef222Smrgfunc_ltwrapper_executable_p () 254865eef222Smrg{ 254965eef222Smrg func_ltwrapper_exec_suffix= 255065eef222Smrg case $1 in 255165eef222Smrg *.exe) ;; 255265eef222Smrg *) func_ltwrapper_exec_suffix=.exe ;; 255365eef222Smrg esac 255465eef222Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 255565eef222Smrg} 2556ef981d24Smrg 255765eef222Smrg# func_ltwrapper_scriptname file 255865eef222Smrg# Assumes file is an ltwrapper_executable 255965eef222Smrg# uses $file to determine the appropriate filename for a 256065eef222Smrg# temporary ltwrapper_script. 256165eef222Smrgfunc_ltwrapper_scriptname () 256265eef222Smrg{ 2563200d7199Smrg func_dirname_and_basename "$1" "" "." 2564200d7199Smrg func_stripname '' '.exe' "$func_basename_result" 2565b312a94cSmrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 256665eef222Smrg} 2567ef981d24Smrg 256865eef222Smrg# func_ltwrapper_p file 256965eef222Smrg# True iff FILE is a libtool wrapper script or wrapper executable 257065eef222Smrg# This function is only a basic sanity check; it will hardly flush out 257165eef222Smrg# determined imposters. 257265eef222Smrgfunc_ltwrapper_p () 257365eef222Smrg{ 257465eef222Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 257565eef222Smrg} 2576ef981d24Smrg 2577ef981d24Smrg 257865eef222Smrg# func_execute_cmds commands fail_cmd 257965eef222Smrg# Execute tilde-delimited COMMANDS. 258065eef222Smrg# If FAIL_CMD is given, eval that upon failure. 258165eef222Smrg# FAIL_CMD may read-access the current command in variable CMD! 258265eef222Smrgfunc_execute_cmds () 258365eef222Smrg{ 2584b312a94cSmrg $debug_cmd 2585b312a94cSmrg 258665eef222Smrg save_ifs=$IFS; IFS='~' 258765eef222Smrg for cmd in $1; do 2588b312a94cSmrg IFS=$sp$nl 258965eef222Smrg eval cmd=\"$cmd\" 2590b312a94cSmrg IFS=$save_ifs 259165eef222Smrg func_show_eval "$cmd" "${2-:}" 259265eef222Smrg done 259365eef222Smrg IFS=$save_ifs 259465eef222Smrg} 259565eef222Smrg 259665eef222Smrg 259765eef222Smrg# func_source file 259865eef222Smrg# Source FILE, adding directory component if necessary. 259965eef222Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 260065eef222Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 260165eef222Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 2602b312a94cSmrg# 'FILE.' does not work on cygwin managed mounts. 260365eef222Smrgfunc_source () 260465eef222Smrg{ 2605b312a94cSmrg $debug_cmd 2606b312a94cSmrg 260765eef222Smrg case $1 in 260865eef222Smrg */* | *\\*) . "$1" ;; 260965eef222Smrg *) . "./$1" ;; 261065eef222Smrg esac 261165eef222Smrg} 261265eef222Smrg 261365eef222Smrg 2614200d7199Smrg# func_resolve_sysroot PATH 2615200d7199Smrg# Replace a leading = in PATH with a sysroot. Store the result into 2616200d7199Smrg# func_resolve_sysroot_result 2617200d7199Smrgfunc_resolve_sysroot () 2618200d7199Smrg{ 2619200d7199Smrg func_resolve_sysroot_result=$1 2620200d7199Smrg case $func_resolve_sysroot_result in 2621200d7199Smrg =*) 2622200d7199Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 2623200d7199Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2624200d7199Smrg ;; 2625200d7199Smrg esac 2626200d7199Smrg} 2627200d7199Smrg 2628200d7199Smrg# func_replace_sysroot PATH 2629200d7199Smrg# If PATH begins with the sysroot, replace it with = and 2630200d7199Smrg# store the result into func_replace_sysroot_result. 2631200d7199Smrgfunc_replace_sysroot () 2632200d7199Smrg{ 2633b312a94cSmrg case $lt_sysroot:$1 in 2634200d7199Smrg ?*:"$lt_sysroot"*) 2635200d7199Smrg func_stripname "$lt_sysroot" '' "$1" 2636b312a94cSmrg func_replace_sysroot_result='='$func_stripname_result 2637200d7199Smrg ;; 2638200d7199Smrg *) 2639200d7199Smrg # Including no sysroot. 2640200d7199Smrg func_replace_sysroot_result=$1 2641200d7199Smrg ;; 2642200d7199Smrg esac 2643200d7199Smrg} 2644200d7199Smrg 264565eef222Smrg# func_infer_tag arg 264665eef222Smrg# Infer tagged configuration to use if any are available and 264765eef222Smrg# if one wasn't chosen via the "--tag" command line option. 264865eef222Smrg# Only attempt this if the compiler in the base compile 264965eef222Smrg# command doesn't match the default compiler. 265065eef222Smrg# arg is usually of the form 'gcc ...' 265165eef222Smrgfunc_infer_tag () 265265eef222Smrg{ 2653b312a94cSmrg $debug_cmd 2654b312a94cSmrg 265565eef222Smrg if test -n "$available_tags" && test -z "$tagname"; then 265665eef222Smrg CC_quoted= 265765eef222Smrg for arg in $CC; do 2658200d7199Smrg func_append_quoted CC_quoted "$arg" 265965eef222Smrg done 266056957a04Smrg CC_expanded=`func_echo_all $CC` 266156957a04Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 266265eef222Smrg case $@ in 266365eef222Smrg # Blanks in the command may have been stripped by the calling shell, 266465eef222Smrg # but not from the CC environment variable when configure was run. 266556957a04Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 266656957a04Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 266765eef222Smrg # Blanks at the start of $base_compile will cause this to fail 266865eef222Smrg # if we don't check for them as well. 266965eef222Smrg *) 267065eef222Smrg for z in $available_tags; do 267165eef222Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 267265eef222Smrg # Evaluate the configuration. 2673b312a94cSmrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 267465eef222Smrg CC_quoted= 267565eef222Smrg for arg in $CC; do 267665eef222Smrg # Double-quote args containing other shell metacharacters. 2677200d7199Smrg func_append_quoted CC_quoted "$arg" 267865eef222Smrg done 267956957a04Smrg CC_expanded=`func_echo_all $CC` 268056957a04Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 268165eef222Smrg case "$@ " in 268256957a04Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 268356957a04Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 268465eef222Smrg # The compiler in the base compile command matches 268565eef222Smrg # the one in the tagged configuration. 268665eef222Smrg # Assume this is the tagged configuration we want. 268765eef222Smrg tagname=$z 268865eef222Smrg break 268965eef222Smrg ;; 2690ef981d24Smrg esac 269165eef222Smrg fi 269265eef222Smrg done 269365eef222Smrg # If $tagname still isn't set, then no tagged configuration 269465eef222Smrg # was found and let the user know that the "--tag" command 269565eef222Smrg # line option must be used. 269665eef222Smrg if test -z "$tagname"; then 269765eef222Smrg func_echo "unable to infer tagged configuration" 2698b312a94cSmrg func_fatal_error "specify a tag with '--tag'" 269965eef222Smrg# else 270065eef222Smrg# func_verbose "using $tagname tagged configuration" 270165eef222Smrg fi 270265eef222Smrg ;; 270365eef222Smrg esac 270465eef222Smrg fi 270565eef222Smrg} 270665eef222Smrg 270765eef222Smrg 270865eef222Smrg 2709200d7199Smrg# func_write_libtool_object output_name pic_name nonpic_name 2710200d7199Smrg# Create a libtool object file (analogous to a ".la" file), 2711200d7199Smrg# but don't create it if we're doing a dry run. 2712200d7199Smrgfunc_write_libtool_object () 2713200d7199Smrg{ 2714b312a94cSmrg write_libobj=$1 2715b312a94cSmrg if test yes = "$build_libtool_libs"; then 2716b312a94cSmrg write_lobj=\'$2\' 2717200d7199Smrg else 2718200d7199Smrg write_lobj=none 2719200d7199Smrg fi 2720200d7199Smrg 2721b312a94cSmrg if test yes = "$build_old_libs"; then 2722b312a94cSmrg write_oldobj=\'$3\' 2723200d7199Smrg else 2724200d7199Smrg write_oldobj=none 2725200d7199Smrg fi 2726200d7199Smrg 2727200d7199Smrg $opt_dry_run || { 2728200d7199Smrg cat >${write_libobj}T <<EOF 2729200d7199Smrg# $write_libobj - a libtool object file 2730b312a94cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2731200d7199Smrg# 2732200d7199Smrg# Please DO NOT delete this file! 2733200d7199Smrg# It is necessary for linking the library. 2734200d7199Smrg 2735200d7199Smrg# Name of the PIC object. 2736200d7199Smrgpic_object=$write_lobj 2737200d7199Smrg 2738200d7199Smrg# Name of the non-PIC object 2739200d7199Smrgnon_pic_object=$write_oldobj 2740200d7199Smrg 2741200d7199SmrgEOF 2742b312a94cSmrg $MV "${write_libobj}T" "$write_libobj" 2743200d7199Smrg } 2744200d7199Smrg} 2745200d7199Smrg 2746200d7199Smrg 2747200d7199Smrg################################################## 2748200d7199Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 2749200d7199Smrg################################################## 2750200d7199Smrg 2751200d7199Smrg# func_convert_core_file_wine_to_w32 ARG 2752200d7199Smrg# Helper function used by file name conversion functions when $build is *nix, 2753200d7199Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 2754200d7199Smrg# correctly configured wine environment available, with the winepath program 2755200d7199Smrg# in $build's $PATH. 2756200d7199Smrg# 2757200d7199Smrg# ARG is the $build file name to be converted to w32 format. 2758200d7199Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 2759200d7199Smrg# be empty on error (or when ARG is empty) 2760200d7199Smrgfunc_convert_core_file_wine_to_w32 () 2761200d7199Smrg{ 2762b312a94cSmrg $debug_cmd 2763b312a94cSmrg 2764b312a94cSmrg func_convert_core_file_wine_to_w32_result=$1 2765200d7199Smrg if test -n "$1"; then 2766200d7199Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 2767200d7199Smrg # are forced to check the contents of stdout. On the other hand, if the 2768200d7199Smrg # command is not found, the shell will set an exit code of 127 and print 2769200d7199Smrg # *an error message* to stdout. So we must check for both error code of 2770200d7199Smrg # zero AND non-empty stdout, which explains the odd construction: 2771200d7199Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 2772b312a94cSmrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 2773200d7199Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 2774b312a94cSmrg $SED -e "$sed_naive_backslashify"` 2775200d7199Smrg else 2776200d7199Smrg func_convert_core_file_wine_to_w32_result= 2777200d7199Smrg fi 2778200d7199Smrg fi 2779200d7199Smrg} 2780200d7199Smrg# end: func_convert_core_file_wine_to_w32 2781200d7199Smrg 2782200d7199Smrg 2783200d7199Smrg# func_convert_core_path_wine_to_w32 ARG 2784200d7199Smrg# Helper function used by path conversion functions when $build is *nix, and 2785200d7199Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 2786200d7199Smrg# configured wine environment available, with the winepath program in $build's 2787200d7199Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 2788200d7199Smrg# 2789200d7199Smrg# ARG is path to be converted from $build format to win32. 2790200d7199Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 2791200d7199Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 2792200d7199Smrg# are convertible, then the result may be empty. 2793200d7199Smrgfunc_convert_core_path_wine_to_w32 () 2794200d7199Smrg{ 2795b312a94cSmrg $debug_cmd 2796b312a94cSmrg 2797200d7199Smrg # unfortunately, winepath doesn't convert paths, only file names 2798b312a94cSmrg func_convert_core_path_wine_to_w32_result= 2799200d7199Smrg if test -n "$1"; then 2800200d7199Smrg oldIFS=$IFS 2801200d7199Smrg IFS=: 2802200d7199Smrg for func_convert_core_path_wine_to_w32_f in $1; do 2803200d7199Smrg IFS=$oldIFS 2804200d7199Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 2805b312a94cSmrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 2806200d7199Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 2807b312a94cSmrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 2808200d7199Smrg else 2809200d7199Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 2810200d7199Smrg fi 2811200d7199Smrg fi 2812200d7199Smrg done 2813200d7199Smrg IFS=$oldIFS 2814200d7199Smrg fi 2815200d7199Smrg} 2816200d7199Smrg# end: func_convert_core_path_wine_to_w32 2817200d7199Smrg 2818200d7199Smrg 2819200d7199Smrg# func_cygpath ARGS... 2820200d7199Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 2821200d7199Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 2822200d7199Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 2823200d7199Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 2824200d7199Smrg# file name or path is assumed to be in w32 format, as previously converted 2825200d7199Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 2826200d7199Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 2827200d7199Smrg# Cygwin format). Returns an empty string on error. 2828200d7199Smrg# 2829200d7199Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 2830200d7199Smrg# be converted. 2831200d7199Smrg# 2832200d7199Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 2833200d7199Smrg# environment variable; do not put it in $PATH. 2834200d7199Smrgfunc_cygpath () 2835200d7199Smrg{ 2836b312a94cSmrg $debug_cmd 2837b312a94cSmrg 2838200d7199Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 2839200d7199Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 2840200d7199Smrg if test "$?" -ne 0; then 2841200d7199Smrg # on failure, ensure result is empty 2842200d7199Smrg func_cygpath_result= 2843200d7199Smrg fi 2844200d7199Smrg else 2845200d7199Smrg func_cygpath_result= 2846b312a94cSmrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 2847200d7199Smrg fi 2848200d7199Smrg} 2849200d7199Smrg#end: func_cygpath 2850200d7199Smrg 2851200d7199Smrg 2852200d7199Smrg# func_convert_core_msys_to_w32 ARG 2853200d7199Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 2854200d7199Smrg# result in func_convert_core_msys_to_w32_result. 2855200d7199Smrgfunc_convert_core_msys_to_w32 () 2856200d7199Smrg{ 2857b312a94cSmrg $debug_cmd 2858b312a94cSmrg 2859200d7199Smrg # awkward: cmd appends spaces to result 2860200d7199Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 2861b312a94cSmrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 2862200d7199Smrg} 2863200d7199Smrg#end: func_convert_core_msys_to_w32 2864200d7199Smrg 2865200d7199Smrg 2866200d7199Smrg# func_convert_file_check ARG1 ARG2 2867200d7199Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 2868200d7199Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 2869200d7199Smrg# func_to_host_file_result to ARG1). 2870200d7199Smrgfunc_convert_file_check () 2871200d7199Smrg{ 2872b312a94cSmrg $debug_cmd 2873b312a94cSmrg 2874b312a94cSmrg if test -z "$2" && test -n "$1"; then 2875200d7199Smrg func_error "Could not determine host file name corresponding to" 2876b312a94cSmrg func_error " '$1'" 2877200d7199Smrg func_error "Continuing, but uninstalled executables may not work." 2878200d7199Smrg # Fallback: 2879b312a94cSmrg func_to_host_file_result=$1 2880200d7199Smrg fi 2881200d7199Smrg} 2882200d7199Smrg# end func_convert_file_check 2883200d7199Smrg 2884200d7199Smrg 2885200d7199Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 2886200d7199Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 2887200d7199Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 2888200d7199Smrg# func_to_host_file_result to a simplistic fallback value (see below). 2889200d7199Smrgfunc_convert_path_check () 2890200d7199Smrg{ 2891b312a94cSmrg $debug_cmd 2892b312a94cSmrg 2893200d7199Smrg if test -z "$4" && test -n "$3"; then 2894200d7199Smrg func_error "Could not determine the host path corresponding to" 2895b312a94cSmrg func_error " '$3'" 2896200d7199Smrg func_error "Continuing, but uninstalled executables may not work." 2897200d7199Smrg # Fallback. This is a deliberately simplistic "conversion" and 2898200d7199Smrg # should not be "improved". See libtool.info. 2899200d7199Smrg if test "x$1" != "x$2"; then 2900200d7199Smrg lt_replace_pathsep_chars="s|$1|$2|g" 2901200d7199Smrg func_to_host_path_result=`echo "$3" | 2902200d7199Smrg $SED -e "$lt_replace_pathsep_chars"` 2903200d7199Smrg else 2904b312a94cSmrg func_to_host_path_result=$3 2905200d7199Smrg fi 2906200d7199Smrg fi 2907200d7199Smrg} 2908200d7199Smrg# end func_convert_path_check 2909200d7199Smrg 2910200d7199Smrg 2911200d7199Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 2912200d7199Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 2913200d7199Smrg# and appending REPL if ORIG matches BACKPAT. 2914200d7199Smrgfunc_convert_path_front_back_pathsep () 2915200d7199Smrg{ 2916b312a94cSmrg $debug_cmd 2917b312a94cSmrg 2918200d7199Smrg case $4 in 2919b312a94cSmrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 2920200d7199Smrg ;; 2921200d7199Smrg esac 2922200d7199Smrg case $4 in 2923200d7199Smrg $2 ) func_append func_to_host_path_result "$3" 2924200d7199Smrg ;; 2925200d7199Smrg esac 2926200d7199Smrg} 2927200d7199Smrg# end func_convert_path_front_back_pathsep 2928200d7199Smrg 2929200d7199Smrg 2930200d7199Smrg################################################## 2931200d7199Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 2932200d7199Smrg################################################## 2933b312a94cSmrg# invoked via '$to_host_file_cmd ARG' 2934200d7199Smrg# 2935200d7199Smrg# In each case, ARG is the path to be converted from $build to $host format. 2936200d7199Smrg# Result will be available in $func_to_host_file_result. 2937200d7199Smrg 2938200d7199Smrg 2939200d7199Smrg# func_to_host_file ARG 2940200d7199Smrg# Converts the file name ARG from $build format to $host format. Return result 2941200d7199Smrg# in func_to_host_file_result. 2942200d7199Smrgfunc_to_host_file () 2943200d7199Smrg{ 2944b312a94cSmrg $debug_cmd 2945b312a94cSmrg 2946200d7199Smrg $to_host_file_cmd "$1" 2947200d7199Smrg} 2948200d7199Smrg# end func_to_host_file 2949200d7199Smrg 2950200d7199Smrg 2951200d7199Smrg# func_to_tool_file ARG LAZY 2952200d7199Smrg# converts the file name ARG from $build format to toolchain format. Return 2953200d7199Smrg# result in func_to_tool_file_result. If the conversion in use is listed 2954200d7199Smrg# in (the comma separated) LAZY, no conversion takes place. 2955200d7199Smrgfunc_to_tool_file () 2956200d7199Smrg{ 2957b312a94cSmrg $debug_cmd 2958b312a94cSmrg 2959200d7199Smrg case ,$2, in 2960200d7199Smrg *,"$to_tool_file_cmd",*) 2961200d7199Smrg func_to_tool_file_result=$1 2962200d7199Smrg ;; 2963200d7199Smrg *) 2964200d7199Smrg $to_tool_file_cmd "$1" 2965200d7199Smrg func_to_tool_file_result=$func_to_host_file_result 2966200d7199Smrg ;; 2967200d7199Smrg esac 2968200d7199Smrg} 2969200d7199Smrg# end func_to_tool_file 2970200d7199Smrg 2971200d7199Smrg 2972200d7199Smrg# func_convert_file_noop ARG 2973200d7199Smrg# Copy ARG to func_to_host_file_result. 2974200d7199Smrgfunc_convert_file_noop () 2975200d7199Smrg{ 2976b312a94cSmrg func_to_host_file_result=$1 2977200d7199Smrg} 2978200d7199Smrg# end func_convert_file_noop 2979200d7199Smrg 2980200d7199Smrg 2981200d7199Smrg# func_convert_file_msys_to_w32 ARG 2982200d7199Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 2983200d7199Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 2984200d7199Smrg# func_to_host_file_result. 2985200d7199Smrgfunc_convert_file_msys_to_w32 () 2986200d7199Smrg{ 2987b312a94cSmrg $debug_cmd 2988b312a94cSmrg 2989b312a94cSmrg func_to_host_file_result=$1 2990200d7199Smrg if test -n "$1"; then 2991200d7199Smrg func_convert_core_msys_to_w32 "$1" 2992b312a94cSmrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 2993200d7199Smrg fi 2994200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 2995200d7199Smrg} 2996200d7199Smrg# end func_convert_file_msys_to_w32 2997200d7199Smrg 2998200d7199Smrg 2999200d7199Smrg# func_convert_file_cygwin_to_w32 ARG 3000200d7199Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 3001200d7199Smrg# func_to_host_file_result. 3002200d7199Smrgfunc_convert_file_cygwin_to_w32 () 3003200d7199Smrg{ 3004b312a94cSmrg $debug_cmd 3005b312a94cSmrg 3006b312a94cSmrg func_to_host_file_result=$1 3007200d7199Smrg if test -n "$1"; then 3008200d7199Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3009200d7199Smrg # LT_CYGPATH in this case. 3010200d7199Smrg func_to_host_file_result=`cygpath -m "$1"` 3011200d7199Smrg fi 3012200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3013200d7199Smrg} 3014200d7199Smrg# end func_convert_file_cygwin_to_w32 3015200d7199Smrg 3016200d7199Smrg 3017200d7199Smrg# func_convert_file_nix_to_w32 ARG 3018200d7199Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 3019200d7199Smrg# and a working winepath. Returns result in func_to_host_file_result. 3020200d7199Smrgfunc_convert_file_nix_to_w32 () 3021200d7199Smrg{ 3022b312a94cSmrg $debug_cmd 3023b312a94cSmrg 3024b312a94cSmrg func_to_host_file_result=$1 3025200d7199Smrg if test -n "$1"; then 3026200d7199Smrg func_convert_core_file_wine_to_w32 "$1" 3027b312a94cSmrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3028200d7199Smrg fi 3029200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3030200d7199Smrg} 3031200d7199Smrg# end func_convert_file_nix_to_w32 3032200d7199Smrg 3033200d7199Smrg 3034200d7199Smrg# func_convert_file_msys_to_cygwin ARG 3035200d7199Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3036200d7199Smrg# Returns result in func_to_host_file_result. 3037200d7199Smrgfunc_convert_file_msys_to_cygwin () 3038200d7199Smrg{ 3039b312a94cSmrg $debug_cmd 3040b312a94cSmrg 3041b312a94cSmrg func_to_host_file_result=$1 3042200d7199Smrg if test -n "$1"; then 3043200d7199Smrg func_convert_core_msys_to_w32 "$1" 3044200d7199Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3045b312a94cSmrg func_to_host_file_result=$func_cygpath_result 3046200d7199Smrg fi 3047200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3048200d7199Smrg} 3049200d7199Smrg# end func_convert_file_msys_to_cygwin 3050200d7199Smrg 3051200d7199Smrg 3052200d7199Smrg# func_convert_file_nix_to_cygwin ARG 3053200d7199Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3054200d7199Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3055200d7199Smrg# in func_to_host_file_result. 3056200d7199Smrgfunc_convert_file_nix_to_cygwin () 3057200d7199Smrg{ 3058b312a94cSmrg $debug_cmd 3059b312a94cSmrg 3060b312a94cSmrg func_to_host_file_result=$1 3061200d7199Smrg if test -n "$1"; then 3062200d7199Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3063200d7199Smrg func_convert_core_file_wine_to_w32 "$1" 3064200d7199Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3065b312a94cSmrg func_to_host_file_result=$func_cygpath_result 3066200d7199Smrg fi 3067200d7199Smrg func_convert_file_check "$1" "$func_to_host_file_result" 3068200d7199Smrg} 3069200d7199Smrg# end func_convert_file_nix_to_cygwin 3070200d7199Smrg 3071200d7199Smrg 3072200d7199Smrg############################################# 3073200d7199Smrg# $build to $host PATH CONVERSION FUNCTIONS # 3074200d7199Smrg############################################# 3075b312a94cSmrg# invoked via '$to_host_path_cmd ARG' 3076200d7199Smrg# 3077200d7199Smrg# In each case, ARG is the path to be converted from $build to $host format. 3078200d7199Smrg# The result will be available in $func_to_host_path_result. 3079200d7199Smrg# 3080200d7199Smrg# Path separators are also converted from $build format to $host format. If 3081200d7199Smrg# ARG begins or ends with a path separator character, it is preserved (but 3082200d7199Smrg# converted to $host format) on output. 3083200d7199Smrg# 3084200d7199Smrg# All path conversion functions are named using the following convention: 3085200d7199Smrg# file name conversion function : func_convert_file_X_to_Y () 3086200d7199Smrg# path conversion function : func_convert_path_X_to_Y () 3087200d7199Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 3088200d7199Smrg# same. If conversion functions are added for new $build/$host combinations, 3089200d7199Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 3090200d7199Smrg# will break. 3091200d7199Smrg 3092200d7199Smrg 3093200d7199Smrg# func_init_to_host_path_cmd 3094200d7199Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 3095200d7199Smrg# appropriate value, based on the value of $to_host_file_cmd. 3096200d7199Smrgto_host_path_cmd= 3097200d7199Smrgfunc_init_to_host_path_cmd () 3098200d7199Smrg{ 3099b312a94cSmrg $debug_cmd 3100b312a94cSmrg 3101200d7199Smrg if test -z "$to_host_path_cmd"; then 3102200d7199Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3103b312a94cSmrg to_host_path_cmd=func_convert_path_$func_stripname_result 3104200d7199Smrg fi 3105200d7199Smrg} 3106200d7199Smrg 3107200d7199Smrg 3108200d7199Smrg# func_to_host_path ARG 3109200d7199Smrg# Converts the path ARG from $build format to $host format. Return result 3110200d7199Smrg# in func_to_host_path_result. 3111200d7199Smrgfunc_to_host_path () 3112200d7199Smrg{ 3113b312a94cSmrg $debug_cmd 3114b312a94cSmrg 3115200d7199Smrg func_init_to_host_path_cmd 3116200d7199Smrg $to_host_path_cmd "$1" 3117200d7199Smrg} 3118200d7199Smrg# end func_to_host_path 3119200d7199Smrg 3120200d7199Smrg 3121200d7199Smrg# func_convert_path_noop ARG 3122200d7199Smrg# Copy ARG to func_to_host_path_result. 3123200d7199Smrgfunc_convert_path_noop () 3124200d7199Smrg{ 3125b312a94cSmrg func_to_host_path_result=$1 3126200d7199Smrg} 3127200d7199Smrg# end func_convert_path_noop 3128200d7199Smrg 3129200d7199Smrg 3130200d7199Smrg# func_convert_path_msys_to_w32 ARG 3131200d7199Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3132200d7199Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 3133200d7199Smrg# func_to_host_path_result. 3134200d7199Smrgfunc_convert_path_msys_to_w32 () 313565eef222Smrg{ 3136b312a94cSmrg $debug_cmd 3137b312a94cSmrg 3138b312a94cSmrg func_to_host_path_result=$1 3139200d7199Smrg if test -n "$1"; then 3140200d7199Smrg # Remove leading and trailing path separator characters from ARG. MSYS 3141200d7199Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3142200d7199Smrg # and winepath ignores them completely. 3143200d7199Smrg func_stripname : : "$1" 3144200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3145200d7199Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3146b312a94cSmrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3147200d7199Smrg func_convert_path_check : ";" \ 3148200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3149200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3150200d7199Smrg fi 3151200d7199Smrg} 3152200d7199Smrg# end func_convert_path_msys_to_w32 315365eef222Smrg 315465eef222Smrg 3155200d7199Smrg# func_convert_path_cygwin_to_w32 ARG 3156200d7199Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 3157200d7199Smrg# func_to_host_file_result. 3158200d7199Smrgfunc_convert_path_cygwin_to_w32 () 3159200d7199Smrg{ 3160b312a94cSmrg $debug_cmd 3161b312a94cSmrg 3162b312a94cSmrg func_to_host_path_result=$1 3163200d7199Smrg if test -n "$1"; then 3164200d7199Smrg # See func_convert_path_msys_to_w32: 3165200d7199Smrg func_stripname : : "$1" 3166200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3167200d7199Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3168200d7199Smrg func_convert_path_check : ";" \ 3169200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3170200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3171200d7199Smrg fi 3172200d7199Smrg} 3173200d7199Smrg# end func_convert_path_cygwin_to_w32 317465eef222Smrg 317565eef222Smrg 3176200d7199Smrg# func_convert_path_nix_to_w32 ARG 3177200d7199Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 3178200d7199Smrg# a working winepath. Returns result in func_to_host_file_result. 3179200d7199Smrgfunc_convert_path_nix_to_w32 () 3180200d7199Smrg{ 3181b312a94cSmrg $debug_cmd 3182b312a94cSmrg 3183b312a94cSmrg func_to_host_path_result=$1 3184200d7199Smrg if test -n "$1"; then 3185200d7199Smrg # See func_convert_path_msys_to_w32: 3186200d7199Smrg func_stripname : : "$1" 3187200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3188200d7199Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3189b312a94cSmrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3190200d7199Smrg func_convert_path_check : ";" \ 3191200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3192200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3193200d7199Smrg fi 3194200d7199Smrg} 3195200d7199Smrg# end func_convert_path_nix_to_w32 319665eef222Smrg 3197200d7199Smrg 3198200d7199Smrg# func_convert_path_msys_to_cygwin ARG 3199200d7199Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3200200d7199Smrg# Returns result in func_to_host_file_result. 3201200d7199Smrgfunc_convert_path_msys_to_cygwin () 3202200d7199Smrg{ 3203b312a94cSmrg $debug_cmd 3204b312a94cSmrg 3205b312a94cSmrg func_to_host_path_result=$1 3206200d7199Smrg if test -n "$1"; then 3207200d7199Smrg # See func_convert_path_msys_to_w32: 3208200d7199Smrg func_stripname : : "$1" 3209200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3210200d7199Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3211200d7199Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3212b312a94cSmrg func_to_host_path_result=$func_cygpath_result 3213200d7199Smrg func_convert_path_check : : \ 3214200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3215200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3216200d7199Smrg fi 3217200d7199Smrg} 3218200d7199Smrg# end func_convert_path_msys_to_cygwin 3219200d7199Smrg 3220200d7199Smrg 3221200d7199Smrg# func_convert_path_nix_to_cygwin ARG 3222200d7199Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3223200d7199Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3224200d7199Smrg# func_to_host_file_result. 3225200d7199Smrgfunc_convert_path_nix_to_cygwin () 3226200d7199Smrg{ 3227b312a94cSmrg $debug_cmd 3228b312a94cSmrg 3229b312a94cSmrg func_to_host_path_result=$1 3230200d7199Smrg if test -n "$1"; then 3231200d7199Smrg # Remove leading and trailing path separator characters from 3232200d7199Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 3233200d7199Smrg # into '.;' and ';.', and winepath ignores them completely. 3234200d7199Smrg func_stripname : : "$1" 3235200d7199Smrg func_to_host_path_tmp1=$func_stripname_result 3236200d7199Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3237200d7199Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3238b312a94cSmrg func_to_host_path_result=$func_cygpath_result 3239200d7199Smrg func_convert_path_check : : \ 3240200d7199Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3241200d7199Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3242200d7199Smrg fi 324365eef222Smrg} 3244200d7199Smrg# end func_convert_path_nix_to_cygwin 3245200d7199Smrg 324665eef222Smrg 3247b312a94cSmrg# func_dll_def_p FILE 3248b312a94cSmrg# True iff FILE is a Windows DLL '.def' file. 3249b312a94cSmrg# Keep in sync with _LT_DLL_DEF_P in libtool.m4 3250b312a94cSmrgfunc_dll_def_p () 3251b312a94cSmrg{ 3252b312a94cSmrg $debug_cmd 3253b312a94cSmrg 3254b312a94cSmrg func_dll_def_p_tmp=`$SED -n \ 3255b312a94cSmrg -e 's/^[ ]*//' \ 3256b312a94cSmrg -e '/^\(;.*\)*$/d' \ 3257b312a94cSmrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3258b312a94cSmrg -e q \ 3259b312a94cSmrg "$1"` 3260b312a94cSmrg test DEF = "$func_dll_def_p_tmp" 3261b312a94cSmrg} 3262b312a94cSmrg 3263b312a94cSmrg 326465eef222Smrg# func_mode_compile arg... 326565eef222Smrgfunc_mode_compile () 326665eef222Smrg{ 3267b312a94cSmrg $debug_cmd 3268b312a94cSmrg 326965eef222Smrg # Get the compilation command and the source file. 327065eef222Smrg base_compile= 3271b312a94cSmrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 327265eef222Smrg suppress_opt=yes 327365eef222Smrg suppress_output= 327465eef222Smrg arg_mode=normal 327565eef222Smrg libobj= 327665eef222Smrg later= 327765eef222Smrg pie_flag= 327865eef222Smrg 327965eef222Smrg for arg 328065eef222Smrg do 328165eef222Smrg case $arg_mode in 328265eef222Smrg arg ) 328365eef222Smrg # do not "continue". Instead, add this to base_compile 3284b312a94cSmrg lastarg=$arg 328565eef222Smrg arg_mode=normal 328665eef222Smrg ;; 328765eef222Smrg 328865eef222Smrg target ) 3289b312a94cSmrg libobj=$arg 329065eef222Smrg arg_mode=normal 329165eef222Smrg continue 329265eef222Smrg ;; 329365eef222Smrg 329465eef222Smrg normal ) 329565eef222Smrg # Accept any command-line options. 329665eef222Smrg case $arg in 329765eef222Smrg -o) 329865eef222Smrg test -n "$libobj" && \ 3299b312a94cSmrg func_fatal_error "you cannot specify '-o' more than once" 330065eef222Smrg arg_mode=target 330165eef222Smrg continue 330265eef222Smrg ;; 330365eef222Smrg 330465eef222Smrg -pie | -fpie | -fPIE) 3305200d7199Smrg func_append pie_flag " $arg" 330665eef222Smrg continue 330765eef222Smrg ;; 330865eef222Smrg 330965eef222Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 3310200d7199Smrg func_append later " $arg" 331165eef222Smrg continue 331265eef222Smrg ;; 331365eef222Smrg 331465eef222Smrg -no-suppress) 331565eef222Smrg suppress_opt=no 331665eef222Smrg continue 331765eef222Smrg ;; 331865eef222Smrg 331965eef222Smrg -Xcompiler) 332065eef222Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 332165eef222Smrg continue # The current "srcfile" will either be retained or 332265eef222Smrg ;; # replaced later. I would guess that would be a bug. 332365eef222Smrg 332465eef222Smrg -Wc,*) 332565eef222Smrg func_stripname '-Wc,' '' "$arg" 332665eef222Smrg args=$func_stripname_result 332765eef222Smrg lastarg= 3328b312a94cSmrg save_ifs=$IFS; IFS=, 332965eef222Smrg for arg in $args; do 3330b312a94cSmrg IFS=$save_ifs 3331200d7199Smrg func_append_quoted lastarg "$arg" 3332ef981d24Smrg done 3333b312a94cSmrg IFS=$save_ifs 333465eef222Smrg func_stripname ' ' '' "$lastarg" 333565eef222Smrg lastarg=$func_stripname_result 3336ef981d24Smrg 3337ef981d24Smrg # Add the arguments to base_compile. 3338200d7199Smrg func_append base_compile " $lastarg" 3339ef981d24Smrg continue 3340ef981d24Smrg ;; 3341ef981d24Smrg 334265eef222Smrg *) 3343ef981d24Smrg # Accept the current argument as the source file. 3344ef981d24Smrg # The previous "srcfile" becomes the current argument. 3345ef981d24Smrg # 3346b312a94cSmrg lastarg=$srcfile 3347b312a94cSmrg srcfile=$arg 3348ef981d24Smrg ;; 3349ef981d24Smrg esac # case $arg 3350ef981d24Smrg ;; 3351ef981d24Smrg esac # case $arg_mode 3352ef981d24Smrg 3353ef981d24Smrg # Aesthetically quote the previous argument. 3354200d7199Smrg func_append_quoted base_compile "$lastarg" 3355ef981d24Smrg done # for arg 3356ef981d24Smrg 3357ef981d24Smrg case $arg_mode in 3358ef981d24Smrg arg) 335965eef222Smrg func_fatal_error "you must specify an argument for -Xcompile" 3360ef981d24Smrg ;; 3361ef981d24Smrg target) 3362b312a94cSmrg func_fatal_error "you must specify a target with '-o'" 3363ef981d24Smrg ;; 3364ef981d24Smrg *) 3365ef981d24Smrg # Get the name of the library object. 336665eef222Smrg test -z "$libobj" && { 336765eef222Smrg func_basename "$srcfile" 3368b312a94cSmrg libobj=$func_basename_result 336965eef222Smrg } 3370ef981d24Smrg ;; 3371ef981d24Smrg esac 3372ef981d24Smrg 3373ef981d24Smrg # Recognize several different file suffixes. 3374ef981d24Smrg # If the user specifies -o file.o, it is replaced with file.lo 3375ef981d24Smrg case $libobj in 337665eef222Smrg *.[cCFSifmso] | \ 337765eef222Smrg *.ada | *.adb | *.ads | *.asm | \ 337865eef222Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3379b312a94cSmrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 338065eef222Smrg func_xform "$libobj" 338165eef222Smrg libobj=$func_xform_result 338265eef222Smrg ;; 3383ef981d24Smrg esac 3384ef981d24Smrg 3385ef981d24Smrg case $libobj in 338665eef222Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3387ef981d24Smrg *) 3388b312a94cSmrg func_fatal_error "cannot determine name of library object from '$libobj'" 3389ef981d24Smrg ;; 3390ef981d24Smrg esac 3391ef981d24Smrg 3392ef981d24Smrg func_infer_tag $base_compile 3393ef981d24Smrg 3394ef981d24Smrg for arg in $later; do 3395ef981d24Smrg case $arg in 339665eef222Smrg -shared) 3397b312a94cSmrg test yes = "$build_libtool_libs" \ 3398b312a94cSmrg || func_fatal_configuration "cannot build a shared library" 339965eef222Smrg build_old_libs=no 340065eef222Smrg continue 340165eef222Smrg ;; 340265eef222Smrg 3403ef981d24Smrg -static) 340465eef222Smrg build_libtool_libs=no 3405ef981d24Smrg build_old_libs=yes 3406ef981d24Smrg continue 3407ef981d24Smrg ;; 3408ef981d24Smrg 3409ef981d24Smrg -prefer-pic) 3410ef981d24Smrg pic_mode=yes 3411ef981d24Smrg continue 3412ef981d24Smrg ;; 3413ef981d24Smrg 3414ef981d24Smrg -prefer-non-pic) 3415ef981d24Smrg pic_mode=no 3416ef981d24Smrg continue 3417ef981d24Smrg ;; 3418ef981d24Smrg esac 3419ef981d24Smrg done 3420ef981d24Smrg 342165eef222Smrg func_quote_for_eval "$libobj" 342265eef222Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 342365eef222Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3424b312a94cSmrg && func_warning "libobj name '$libobj' may not contain shell special characters." 342565eef222Smrg func_dirname_and_basename "$obj" "/" "" 3426b312a94cSmrg objname=$func_basename_result 3427b312a94cSmrg xdir=$func_dirname_result 3428b312a94cSmrg lobj=$xdir$objdir/$objname 3429ef981d24Smrg 343065eef222Smrg test -z "$base_compile" && \ 343165eef222Smrg func_fatal_help "you must specify a compilation command" 3432ef981d24Smrg 3433ef981d24Smrg # Delete any leftover library objects. 3434b312a94cSmrg if test yes = "$build_old_libs"; then 3435ef981d24Smrg removelist="$obj $lobj $libobj ${libobj}T" 3436ef981d24Smrg else 3437ef981d24Smrg removelist="$lobj $libobj ${libobj}T" 3438ef981d24Smrg fi 3439ef981d24Smrg 3440ef981d24Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 3441ef981d24Smrg case $host_os in 344265eef222Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3443ef981d24Smrg pic_mode=default 3444ef981d24Smrg ;; 3445ef981d24Smrg esac 3446b312a94cSmrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3447ef981d24Smrg # non-PIC code in shared libraries is not supported 3448ef981d24Smrg pic_mode=default 3449ef981d24Smrg fi 3450ef981d24Smrg 3451ef981d24Smrg # Calculate the filename of the output object if compiler does 3452ef981d24Smrg # not support -o with -c 3453b312a94cSmrg if test no = "$compiler_c_o"; then 3454b312a94cSmrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3455b312a94cSmrg lockfile=$output_obj.lock 3456ef981d24Smrg else 3457ef981d24Smrg output_obj= 3458ef981d24Smrg need_locks=no 3459ef981d24Smrg lockfile= 3460ef981d24Smrg fi 3461ef981d24Smrg 3462ef981d24Smrg # Lock this critical section if it is needed 3463ef981d24Smrg # We use this script file to make the link, it avoids creating a new file 3464b312a94cSmrg if test yes = "$need_locks"; then 346565eef222Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 346665eef222Smrg func_echo "Waiting for $lockfile to be removed" 3467ef981d24Smrg sleep 2 3468ef981d24Smrg done 3469b312a94cSmrg elif test warn = "$need_locks"; then 3470ef981d24Smrg if test -f "$lockfile"; then 347165eef222Smrg $ECHO "\ 3472ef981d24Smrg*** ERROR, $lockfile exists and contains: 3473ef981d24Smrg`cat $lockfile 2>/dev/null` 3474ef981d24Smrg 3475ef981d24SmrgThis indicates that another process is trying to use the same 3476ef981d24Smrgtemporary object file, and libtool could not work around it because 3477b312a94cSmrgyour compiler does not support '-c' and '-o' together. If you 3478ef981d24Smrgrepeat this compilation, it may succeed, by chance, but you had better 3479ef981d24Smrgavoid parallel builds (make -j) in this platform, or get a better 3480ef981d24Smrgcompiler." 3481ef981d24Smrg 348265eef222Smrg $opt_dry_run || $RM $removelist 3483ef981d24Smrg exit $EXIT_FAILURE 3484ef981d24Smrg fi 3485200d7199Smrg func_append removelist " $output_obj" 348665eef222Smrg $ECHO "$srcfile" > "$lockfile" 3487ef981d24Smrg fi 3488ef981d24Smrg 348965eef222Smrg $opt_dry_run || $RM $removelist 3490200d7199Smrg func_append removelist " $lockfile" 349165eef222Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 349265eef222Smrg 3493200d7199Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3494200d7199Smrg srcfile=$func_to_tool_file_result 349565eef222Smrg func_quote_for_eval "$srcfile" 349665eef222Smrg qsrcfile=$func_quote_for_eval_result 3497ef981d24Smrg 3498ef981d24Smrg # Only build a PIC object if we are building libtool libraries. 3499b312a94cSmrg if test yes = "$build_libtool_libs"; then 3500ef981d24Smrg # Without this assignment, base_compile gets emptied. 3501ef981d24Smrg fbsd_hideous_sh_bug=$base_compile 3502ef981d24Smrg 3503b312a94cSmrg if test no != "$pic_mode"; then 3504ef981d24Smrg command="$base_compile $qsrcfile $pic_flag" 3505ef981d24Smrg else 3506ef981d24Smrg # Don't build PIC code 3507ef981d24Smrg command="$base_compile $qsrcfile" 3508ef981d24Smrg fi 3509ef981d24Smrg 351065eef222Smrg func_mkdir_p "$xdir$objdir" 3511ef981d24Smrg 3512ef981d24Smrg if test -z "$output_obj"; then 3513ef981d24Smrg # Place PIC objects in $objdir 3514200d7199Smrg func_append command " -o $lobj" 3515ef981d24Smrg fi 3516ef981d24Smrg 351765eef222Smrg func_show_eval_locale "$command" \ 351865eef222Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3519ef981d24Smrg 3520b312a94cSmrg if test warn = "$need_locks" && 3521ef981d24Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 352265eef222Smrg $ECHO "\ 3523ef981d24Smrg*** ERROR, $lockfile contains: 3524ef981d24Smrg`cat $lockfile 2>/dev/null` 3525ef981d24Smrg 3526ef981d24Smrgbut it should contain: 3527ef981d24Smrg$srcfile 3528ef981d24Smrg 3529ef981d24SmrgThis indicates that another process is trying to use the same 3530ef981d24Smrgtemporary object file, and libtool could not work around it because 3531b312a94cSmrgyour compiler does not support '-c' and '-o' together. If you 3532ef981d24Smrgrepeat this compilation, it may succeed, by chance, but you had better 3533ef981d24Smrgavoid parallel builds (make -j) in this platform, or get a better 3534ef981d24Smrgcompiler." 3535ef981d24Smrg 353665eef222Smrg $opt_dry_run || $RM $removelist 3537ef981d24Smrg exit $EXIT_FAILURE 3538ef981d24Smrg fi 3539ef981d24Smrg 3540ef981d24Smrg # Just move the object if needed, then go on to compile the next one 3541ef981d24Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 354265eef222Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 354365eef222Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3544ef981d24Smrg fi 3545ef981d24Smrg 3546ef981d24Smrg # Allow error messages only from the first compilation. 3547b312a94cSmrg if test yes = "$suppress_opt"; then 354865eef222Smrg suppress_output=' >/dev/null 2>&1' 3549ef981d24Smrg fi 3550ef981d24Smrg fi 3551ef981d24Smrg 3552ef981d24Smrg # Only build a position-dependent object if we build old libraries. 3553b312a94cSmrg if test yes = "$build_old_libs"; then 3554b312a94cSmrg if test yes != "$pic_mode"; then 3555ef981d24Smrg # Don't build PIC code 355665eef222Smrg command="$base_compile $qsrcfile$pie_flag" 3557ef981d24Smrg else 3558ef981d24Smrg command="$base_compile $qsrcfile $pic_flag" 3559ef981d24Smrg fi 3560b312a94cSmrg if test yes = "$compiler_c_o"; then 3561200d7199Smrg func_append command " -o $obj" 3562ef981d24Smrg fi 3563ef981d24Smrg 3564ef981d24Smrg # Suppress compiler output if we already did a PIC compilation. 3565200d7199Smrg func_append command "$suppress_output" 356665eef222Smrg func_show_eval_locale "$command" \ 356765eef222Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3568ef981d24Smrg 3569b312a94cSmrg if test warn = "$need_locks" && 3570ef981d24Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 357165eef222Smrg $ECHO "\ 3572ef981d24Smrg*** ERROR, $lockfile contains: 3573ef981d24Smrg`cat $lockfile 2>/dev/null` 3574ef981d24Smrg 3575ef981d24Smrgbut it should contain: 3576ef981d24Smrg$srcfile 3577ef981d24Smrg 3578ef981d24SmrgThis indicates that another process is trying to use the same 3579ef981d24Smrgtemporary object file, and libtool could not work around it because 3580b312a94cSmrgyour compiler does not support '-c' and '-o' together. If you 3581ef981d24Smrgrepeat this compilation, it may succeed, by chance, but you had better 3582ef981d24Smrgavoid parallel builds (make -j) in this platform, or get a better 3583ef981d24Smrgcompiler." 3584ef981d24Smrg 358565eef222Smrg $opt_dry_run || $RM $removelist 3586ef981d24Smrg exit $EXIT_FAILURE 3587ef981d24Smrg fi 3588ef981d24Smrg 3589ef981d24Smrg # Just move the object if needed 3590ef981d24Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 359165eef222Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 359265eef222Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3593ef981d24Smrg fi 3594ef981d24Smrg fi 3595ef981d24Smrg 359665eef222Smrg $opt_dry_run || { 359765eef222Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3598ef981d24Smrg 359965eef222Smrg # Unlock the critical section if it was locked 3600b312a94cSmrg if test no != "$need_locks"; then 360165eef222Smrg removelist=$lockfile 360265eef222Smrg $RM "$lockfile" 360365eef222Smrg fi 360465eef222Smrg } 3605ef981d24Smrg 3606ef981d24Smrg exit $EXIT_SUCCESS 360765eef222Smrg} 3608ef981d24Smrg 360965eef222Smrg$opt_help || { 3610b312a94cSmrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 361165eef222Smrg} 3612ef981d24Smrg 361365eef222Smrgfunc_mode_help () 361465eef222Smrg{ 361565eef222Smrg # We need to display help for each of the modes. 3616200d7199Smrg case $opt_mode in 361765eef222Smrg "") 361865eef222Smrg # Generic help is extracted from the usage comments 361965eef222Smrg # at the start of this file. 362065eef222Smrg func_help 362165eef222Smrg ;; 3622ef981d24Smrg 362365eef222Smrg clean) 362465eef222Smrg $ECHO \ 362565eef222Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3626ef981d24Smrg 362765eef222SmrgRemove files from the build directory. 3628ef981d24Smrg 362965eef222SmrgRM is the name of the program to use to delete files associated with each FILE 3630b312a94cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 363165eef222Smrgto RM. 3632ef981d24Smrg 363365eef222SmrgIf FILE is a libtool library, object or program, all the files associated 363465eef222Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 363565eef222Smrg ;; 3636ef981d24Smrg 363765eef222Smrg compile) 363865eef222Smrg $ECHO \ 363965eef222Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3640ef981d24Smrg 364165eef222SmrgCompile a source file into a libtool library object. 3642ef981d24Smrg 364365eef222SmrgThis mode accepts the following additional options: 3644ef981d24Smrg 364565eef222Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 364665eef222Smrg -no-suppress do not suppress compiler output for multiple passes 364756957a04Smrg -prefer-pic try to build PIC objects only 364856957a04Smrg -prefer-non-pic try to build non-PIC objects only 3649b312a94cSmrg -shared do not build a '.o' file suitable for static linking 3650b312a94cSmrg -static only build a '.o' file suitable for static linking 365156957a04Smrg -Wc,FLAG pass FLAG directly to the compiler 3652ef981d24Smrg 3653b312a94cSmrgCOMPILE-COMMAND is a command to be used in creating a 'standard' object file 365465eef222Smrgfrom the given SOURCEFILE. 3655ef981d24Smrg 365665eef222SmrgThe output file name is determined by removing the directory component from 3657b312a94cSmrgSOURCEFILE, then substituting the C source code suffix '.c' with the 3658b312a94cSmrglibrary object suffix, '.lo'." 365965eef222Smrg ;; 3660ef981d24Smrg 366165eef222Smrg execute) 366265eef222Smrg $ECHO \ 366365eef222Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3664ef981d24Smrg 366565eef222SmrgAutomatically set library path, then run a program. 3666ef981d24Smrg 366765eef222SmrgThis mode accepts the following additional options: 3668ef981d24Smrg 366965eef222Smrg -dlopen FILE add the directory containing FILE to the library path 3670ef981d24Smrg 3671b312a94cSmrgThis mode sets the library path environment variable according to '-dlopen' 367265eef222Smrgflags. 3673ef981d24Smrg 367465eef222SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 367565eef222Smrginto their corresponding uninstalled binary, and any of their required library 367665eef222Smrgdirectories are added to the library path. 3677ef981d24Smrg 367865eef222SmrgThen, COMMAND is executed, with ARGS as arguments." 367965eef222Smrg ;; 3680ef981d24Smrg 368165eef222Smrg finish) 368265eef222Smrg $ECHO \ 368365eef222Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3684ef981d24Smrg 368565eef222SmrgComplete the installation of libtool libraries. 3686ef981d24Smrg 368765eef222SmrgEach LIBDIR is a directory that contains libtool libraries. 3688ef981d24Smrg 368965eef222SmrgThe commands that this mode executes may require superuser privileges. Use 3690b312a94cSmrgthe '--dry-run' option if you just want to see what would be executed." 369165eef222Smrg ;; 3692ef981d24Smrg 369365eef222Smrg install) 369465eef222Smrg $ECHO \ 369565eef222Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3696ef981d24Smrg 369765eef222SmrgInstall executables or libraries. 3698ef981d24Smrg 369965eef222SmrgINSTALL-COMMAND is the installation command. The first component should be 3700b312a94cSmrgeither the 'install' or 'cp' program. 3701ef981d24Smrg 370265eef222SmrgThe following components of INSTALL-COMMAND are treated specially: 3703ef981d24Smrg 370456957a04Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3705ef981d24Smrg 370665eef222SmrgThe rest of the components are interpreted as arguments to that command (only 370765eef222SmrgBSD-compatible install options are recognized)." 370865eef222Smrg ;; 3709ef981d24Smrg 371065eef222Smrg link) 371165eef222Smrg $ECHO \ 371265eef222Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3713ef981d24Smrg 371465eef222SmrgLink object files or libraries together to form another library, or to 371565eef222Smrgcreate an executable program. 3716ef981d24Smrg 371765eef222SmrgLINK-COMMAND is a command using the C compiler that you would use to create 371865eef222Smrga program from several object files. 3719ef981d24Smrg 372065eef222SmrgThe following components of LINK-COMMAND are treated specially: 3721ef981d24Smrg 372265eef222Smrg -all-static do not do any dynamic linking at all 372365eef222Smrg -avoid-version do not add a version suffix if possible 372456957a04Smrg -bindir BINDIR specify path to binaries directory (for systems where 372556957a04Smrg libraries must be found in the PATH setting at runtime) 3726b312a94cSmrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 372765eef222Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 372865eef222Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 372965eef222Smrg -export-symbols SYMFILE 373065eef222Smrg try to export only the symbols listed in SYMFILE 373165eef222Smrg -export-symbols-regex REGEX 373265eef222Smrg try to export only the symbols matching REGEX 373365eef222Smrg -LLIBDIR search LIBDIR for required installed libraries 373465eef222Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 373565eef222Smrg -module build a library that can dlopened 373665eef222Smrg -no-fast-install disable the fast-install mode 373765eef222Smrg -no-install link a not-installable executable 373865eef222Smrg -no-undefined declare that a library does not refer to external symbols 373965eef222Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3740b312a94cSmrg -objectlist FILE use a list of object files found in FILE to specify objects 3741b312a94cSmrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 374265eef222Smrg -precious-files-regex REGEX 374365eef222Smrg don't remove output files matching REGEX 374465eef222Smrg -release RELEASE specify package release information 374565eef222Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 374665eef222Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 374765eef222Smrg -shared only do dynamic linking of libtool libraries 374865eef222Smrg -shrext SUFFIX override the standard shared library file extension 374965eef222Smrg -static do not do any dynamic linking of uninstalled libtool libraries 375065eef222Smrg -static-libtool-libs 375165eef222Smrg do not do any dynamic linking of libtool libraries 375265eef222Smrg -version-info CURRENT[:REVISION[:AGE]] 375365eef222Smrg specify library version info [each variable defaults to 0] 375465eef222Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 375556957a04Smrg -Wc,FLAG 375656957a04Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 375756957a04Smrg -Wl,FLAG 375856957a04Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 375956957a04Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 3760ef981d24Smrg 3761b312a94cSmrgAll other options (arguments beginning with '-') are ignored. 3762ef981d24Smrg 3763b312a94cSmrgEvery other argument is treated as a filename. Files ending in '.la' are 376465eef222Smrgtreated as uninstalled libtool libraries, other files are standard or library 376565eef222Smrgobject files. 3766ef981d24Smrg 3767b312a94cSmrgIf the OUTPUT-FILE ends in '.la', then a libtool library is created, 3768b312a94cSmrgonly library objects ('.lo' files) may be specified, and '-rpath' is 376965eef222Smrgrequired, except when creating a convenience library. 3770ef981d24Smrg 3771b312a94cSmrgIf OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 3772b312a94cSmrgusing 'ar' and 'ranlib', or on Windows using 'lib'. 3773ef981d24Smrg 3774b312a94cSmrgIf OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 377565eef222Smrgis created, otherwise an executable program is created." 3776ef981d24Smrg ;; 3777ef981d24Smrg 377865eef222Smrg uninstall) 377965eef222Smrg $ECHO \ 378065eef222Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 3781ef981d24Smrg 378265eef222SmrgRemove libraries from an installation directory. 3783ef981d24Smrg 378465eef222SmrgRM is the name of the program to use to delete files associated with each FILE 3785b312a94cSmrg(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 378665eef222Smrgto RM. 3787ef981d24Smrg 378865eef222SmrgIf FILE is a libtool library, all the files associated with it are deleted. 378965eef222SmrgOtherwise, only FILE itself is deleted using RM." 379065eef222Smrg ;; 3791ef981d24Smrg 379265eef222Smrg *) 3793b312a94cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 379465eef222Smrg ;; 379565eef222Smrg esac 3796ef981d24Smrg 379756957a04Smrg echo 3798b312a94cSmrg $ECHO "Try '$progname --help' for more information about other modes." 379965eef222Smrg} 3800ef981d24Smrg 380156957a04Smrg# Now that we've collected a possible --mode arg, show help if necessary 380256957a04Smrgif $opt_help; then 3803b312a94cSmrg if test : = "$opt_help"; then 380456957a04Smrg func_mode_help 380556957a04Smrg else 380656957a04Smrg { 380756957a04Smrg func_help noexit 3808200d7199Smrg for opt_mode in compile link execute install finish uninstall clean; do 380956957a04Smrg func_mode_help 381056957a04Smrg done 3811b312a94cSmrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 381256957a04Smrg { 381356957a04Smrg func_help noexit 3814200d7199Smrg for opt_mode in compile link execute install finish uninstall clean; do 381556957a04Smrg echo 381656957a04Smrg func_mode_help 381756957a04Smrg done 381856957a04Smrg } | 3819b312a94cSmrg $SED '1d 382056957a04Smrg /^When reporting/,/^Report/{ 382156957a04Smrg H 382256957a04Smrg d 382356957a04Smrg } 382456957a04Smrg $x 382556957a04Smrg /information about other modes/d 382656957a04Smrg /more detailed .*MODE/d 382756957a04Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 382856957a04Smrg fi 382956957a04Smrg exit $? 383056957a04Smrgfi 3831ef981d24Smrg 3832ef981d24Smrg 383365eef222Smrg# func_mode_execute arg... 383465eef222Smrgfunc_mode_execute () 383565eef222Smrg{ 3836b312a94cSmrg $debug_cmd 3837b312a94cSmrg 383865eef222Smrg # The first argument is the command name. 3839b312a94cSmrg cmd=$nonopt 384065eef222Smrg test -z "$cmd" && \ 384165eef222Smrg func_fatal_help "you must specify a COMMAND" 3842ef981d24Smrg 384365eef222Smrg # Handle -dlopen flags immediately. 3844200d7199Smrg for file in $opt_dlopen; do 384565eef222Smrg test -f "$file" \ 3846b312a94cSmrg || func_fatal_help "'$file' is not a file" 3847ef981d24Smrg 384865eef222Smrg dir= 384965eef222Smrg case $file in 385065eef222Smrg *.la) 3851200d7199Smrg func_resolve_sysroot "$file" 3852200d7199Smrg file=$func_resolve_sysroot_result 3853200d7199Smrg 385465eef222Smrg # Check to see that this really is a libtool archive. 385565eef222Smrg func_lalib_unsafe_p "$file" \ 3856b312a94cSmrg || func_fatal_help "'$lib' is not a valid libtool archive" 3857ef981d24Smrg 385865eef222Smrg # Read the libtool library. 385965eef222Smrg dlname= 386065eef222Smrg library_names= 386165eef222Smrg func_source "$file" 3862ef981d24Smrg 386365eef222Smrg # Skip this library if it cannot be dlopened. 386465eef222Smrg if test -z "$dlname"; then 386565eef222Smrg # Warn if it was a shared library. 386665eef222Smrg test -n "$library_names" && \ 3867b312a94cSmrg func_warning "'$file' was not linked with '-export-dynamic'" 386865eef222Smrg continue 386965eef222Smrg fi 3870ef981d24Smrg 387165eef222Smrg func_dirname "$file" "" "." 3872b312a94cSmrg dir=$func_dirname_result 3873ef981d24Smrg 387465eef222Smrg if test -f "$dir/$objdir/$dlname"; then 3875200d7199Smrg func_append dir "/$objdir" 387665eef222Smrg else 387765eef222Smrg if test ! -f "$dir/$dlname"; then 3878b312a94cSmrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 387965eef222Smrg fi 388065eef222Smrg fi 3881ef981d24Smrg ;; 3882ef981d24Smrg 388365eef222Smrg *.lo) 388465eef222Smrg # Just add the directory containing the .lo file. 388565eef222Smrg func_dirname "$file" "" "." 3886b312a94cSmrg dir=$func_dirname_result 3887ef981d24Smrg ;; 3888ef981d24Smrg 388965eef222Smrg *) 3890b312a94cSmrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 3891ef981d24Smrg continue 3892ef981d24Smrg ;; 389365eef222Smrg esac 3894ef981d24Smrg 389565eef222Smrg # Get the absolute pathname. 389665eef222Smrg absdir=`cd "$dir" && pwd` 3897b312a94cSmrg test -n "$absdir" && dir=$absdir 3898ef981d24Smrg 389965eef222Smrg # Now add the directory to shlibpath_var. 390065eef222Smrg if eval "test -z \"\$$shlibpath_var\""; then 390165eef222Smrg eval "$shlibpath_var=\"\$dir\"" 390265eef222Smrg else 390365eef222Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 390465eef222Smrg fi 390565eef222Smrg done 3906ef981d24Smrg 390765eef222Smrg # This variable tells wrapper scripts just to set shlibpath_var 390865eef222Smrg # rather than running their programs. 3909b312a94cSmrg libtool_execute_magic=$magic 3910ef981d24Smrg 391165eef222Smrg # Check if any of the arguments is a wrapper script. 391265eef222Smrg args= 391365eef222Smrg for file 391465eef222Smrg do 391565eef222Smrg case $file in 391656957a04Smrg -* | *.la | *.lo ) ;; 391765eef222Smrg *) 391865eef222Smrg # Do a test to see if this is really a libtool program. 391965eef222Smrg if func_ltwrapper_script_p "$file"; then 392065eef222Smrg func_source "$file" 392165eef222Smrg # Transform arg to wrapped name. 3922b312a94cSmrg file=$progdir/$program 392365eef222Smrg elif func_ltwrapper_executable_p "$file"; then 392465eef222Smrg func_ltwrapper_scriptname "$file" 392565eef222Smrg func_source "$func_ltwrapper_scriptname_result" 392665eef222Smrg # Transform arg to wrapped name. 3927b312a94cSmrg file=$progdir/$program 392865eef222Smrg fi 392965eef222Smrg ;; 393065eef222Smrg esac 393165eef222Smrg # Quote arguments (to preserve shell metacharacters). 3932200d7199Smrg func_append_quoted args "$file" 393365eef222Smrg done 3934ef981d24Smrg 3935b312a94cSmrg if $opt_dry_run; then 3936b312a94cSmrg # Display what would be done. 3937b312a94cSmrg if test -n "$shlibpath_var"; then 3938b312a94cSmrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 3939b312a94cSmrg echo "export $shlibpath_var" 3940b312a94cSmrg fi 3941b312a94cSmrg $ECHO "$cmd$args" 3942b312a94cSmrg exit $EXIT_SUCCESS 3943b312a94cSmrg else 394465eef222Smrg if test -n "$shlibpath_var"; then 394565eef222Smrg # Export the shlibpath_var. 394665eef222Smrg eval "export $shlibpath_var" 394765eef222Smrg fi 3948ef981d24Smrg 394965eef222Smrg # Restore saved environment variables 395065eef222Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 395165eef222Smrg do 395265eef222Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 395365eef222Smrg $lt_var=\$save_$lt_var; export $lt_var 395465eef222Smrg else 395565eef222Smrg $lt_unset $lt_var 395665eef222Smrg fi" 395765eef222Smrg done 3958ef981d24Smrg 395965eef222Smrg # Now prepare to actually exec the command. 3960b312a94cSmrg exec_cmd=\$cmd$args 396165eef222Smrg fi 396265eef222Smrg} 3963ef981d24Smrg 3964b312a94cSmrgtest execute = "$opt_mode" && func_mode_execute ${1+"$@"} 3965ef981d24Smrg 3966ef981d24Smrg 396765eef222Smrg# func_mode_finish arg... 396865eef222Smrgfunc_mode_finish () 396965eef222Smrg{ 3970b312a94cSmrg $debug_cmd 3971b312a94cSmrg 3972200d7199Smrg libs= 3973200d7199Smrg libdirs= 397465eef222Smrg admincmds= 3975ef981d24Smrg 3976200d7199Smrg for opt in "$nonopt" ${1+"$@"} 3977200d7199Smrg do 3978200d7199Smrg if test -d "$opt"; then 3979200d7199Smrg func_append libdirs " $opt" 3980200d7199Smrg 3981200d7199Smrg elif test -f "$opt"; then 3982200d7199Smrg if func_lalib_unsafe_p "$opt"; then 3983200d7199Smrg func_append libs " $opt" 3984200d7199Smrg else 3985b312a94cSmrg func_warning "'$opt' is not a valid libtool archive" 3986200d7199Smrg fi 3987200d7199Smrg 3988200d7199Smrg else 3989b312a94cSmrg func_fatal_error "invalid argument '$opt'" 3990200d7199Smrg fi 3991200d7199Smrg done 3992200d7199Smrg 3993200d7199Smrg if test -n "$libs"; then 3994200d7199Smrg if test -n "$lt_sysroot"; then 3995200d7199Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 3996200d7199Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 3997200d7199Smrg else 3998200d7199Smrg sysroot_cmd= 3999200d7199Smrg fi 4000200d7199Smrg 4001200d7199Smrg # Remove sysroot references 4002200d7199Smrg if $opt_dry_run; then 4003200d7199Smrg for lib in $libs; do 4004b312a94cSmrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4005200d7199Smrg done 4006200d7199Smrg else 4007200d7199Smrg tmpdir=`func_mktempdir` 4008200d7199Smrg for lib in $libs; do 4009b312a94cSmrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4010200d7199Smrg > $tmpdir/tmp-la 4011200d7199Smrg mv -f $tmpdir/tmp-la $lib 4012200d7199Smrg done 4013200d7199Smrg ${RM}r "$tmpdir" 4014200d7199Smrg fi 4015200d7199Smrg fi 4016ef981d24Smrg 4017200d7199Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 401865eef222Smrg for libdir in $libdirs; do 401965eef222Smrg if test -n "$finish_cmds"; then 402065eef222Smrg # Do each command in the finish commands. 402165eef222Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 402265eef222Smrg'"$cmd"'"' 402365eef222Smrg fi 402465eef222Smrg if test -n "$finish_eval"; then 402565eef222Smrg # Do the single finish_eval. 402665eef222Smrg eval cmds=\"$finish_eval\" 4027200d7199Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 402865eef222Smrg $cmds" 402965eef222Smrg fi 403065eef222Smrg done 403165eef222Smrg fi 4032ef981d24Smrg 403365eef222Smrg # Exit here if they wanted silent mode. 4034b312a94cSmrg $opt_quiet && exit $EXIT_SUCCESS 4035ef981d24Smrg 4036200d7199Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4037200d7199Smrg echo "----------------------------------------------------------------------" 4038200d7199Smrg echo "Libraries have been installed in:" 4039200d7199Smrg for libdir in $libdirs; do 4040200d7199Smrg $ECHO " $libdir" 4041200d7199Smrg done 4042200d7199Smrg echo 4043200d7199Smrg echo "If you ever happen to want to link against installed libraries" 4044200d7199Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4045b312a94cSmrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4046200d7199Smrg echo "flag during linking and do at least one of the following:" 4047200d7199Smrg if test -n "$shlibpath_var"; then 4048b312a94cSmrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4049200d7199Smrg echo " during execution" 4050200d7199Smrg fi 4051200d7199Smrg if test -n "$runpath_var"; then 4052b312a94cSmrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4053200d7199Smrg echo " during linking" 4054200d7199Smrg fi 4055200d7199Smrg if test -n "$hardcode_libdir_flag_spec"; then 4056200d7199Smrg libdir=LIBDIR 4057200d7199Smrg eval flag=\"$hardcode_libdir_flag_spec\" 4058ef981d24Smrg 4059b312a94cSmrg $ECHO " - use the '$flag' linker flag" 4060200d7199Smrg fi 4061200d7199Smrg if test -n "$admincmds"; then 4062200d7199Smrg $ECHO " - have your system administrator run these commands:$admincmds" 4063200d7199Smrg fi 4064200d7199Smrg if test -f /etc/ld.so.conf; then 4065b312a94cSmrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4066200d7199Smrg fi 4067200d7199Smrg echo 4068ef981d24Smrg 4069200d7199Smrg echo "See any operating system documentation about shared libraries for" 4070200d7199Smrg case $host in 4071200d7199Smrg solaris2.[6789]|solaris2.1[0-9]) 4072200d7199Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4073200d7199Smrg echo "pages." 4074200d7199Smrg ;; 4075200d7199Smrg *) 4076200d7199Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4077200d7199Smrg ;; 4078200d7199Smrg esac 4079200d7199Smrg echo "----------------------------------------------------------------------" 4080200d7199Smrg fi 408165eef222Smrg exit $EXIT_SUCCESS 408265eef222Smrg} 4083ef981d24Smrg 4084b312a94cSmrgtest finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4085ef981d24Smrg 4086ef981d24Smrg 408765eef222Smrg# func_mode_install arg... 408865eef222Smrgfunc_mode_install () 408965eef222Smrg{ 4090b312a94cSmrg $debug_cmd 4091b312a94cSmrg 409265eef222Smrg # There may be an optional sh(1) argument at the beginning of 409365eef222Smrg # install_prog (especially on Windows NT). 4094b312a94cSmrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 409565eef222Smrg # Allow the use of GNU shtool's install command. 4096b312a94cSmrg case $nonopt in *shtool*) :;; *) false;; esac 4097b312a94cSmrg then 409865eef222Smrg # Aesthetically quote it. 409965eef222Smrg func_quote_for_eval "$nonopt" 410065eef222Smrg install_prog="$func_quote_for_eval_result " 410165eef222Smrg arg=$1 410265eef222Smrg shift 410365eef222Smrg else 410465eef222Smrg install_prog= 410565eef222Smrg arg=$nonopt 410665eef222Smrg fi 4107ef981d24Smrg 410865eef222Smrg # The real first argument should be the name of the installation program. 410965eef222Smrg # Aesthetically quote it. 411065eef222Smrg func_quote_for_eval "$arg" 4111200d7199Smrg func_append install_prog "$func_quote_for_eval_result" 411256957a04Smrg install_shared_prog=$install_prog 411356957a04Smrg case " $install_prog " in 411456957a04Smrg *[\\\ /]cp\ *) install_cp=: ;; 411556957a04Smrg *) install_cp=false ;; 411656957a04Smrg esac 411765eef222Smrg 411865eef222Smrg # We need to accept at least all the BSD install flags. 411965eef222Smrg dest= 412065eef222Smrg files= 412165eef222Smrg opts= 412265eef222Smrg prev= 412365eef222Smrg install_type= 4124b312a94cSmrg isdir=false 412565eef222Smrg stripme= 412656957a04Smrg no_mode=: 412765eef222Smrg for arg 412865eef222Smrg do 412956957a04Smrg arg2= 413065eef222Smrg if test -n "$dest"; then 4131200d7199Smrg func_append files " $dest" 413265eef222Smrg dest=$arg 413365eef222Smrg continue 4134ef981d24Smrg fi 4135ef981d24Smrg 413665eef222Smrg case $arg in 4137b312a94cSmrg -d) isdir=: ;; 413865eef222Smrg -f) 413956957a04Smrg if $install_cp; then :; else 414056957a04Smrg prev=$arg 414156957a04Smrg fi 414265eef222Smrg ;; 414365eef222Smrg -g | -m | -o) 414465eef222Smrg prev=$arg 414565eef222Smrg ;; 414665eef222Smrg -s) 414765eef222Smrg stripme=" -s" 414865eef222Smrg continue 414965eef222Smrg ;; 415065eef222Smrg -*) 415165eef222Smrg ;; 415265eef222Smrg *) 415365eef222Smrg # If the previous option needed an argument, then skip it. 415465eef222Smrg if test -n "$prev"; then 4155b312a94cSmrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 415656957a04Smrg arg2=$install_override_mode 415756957a04Smrg no_mode=false 415856957a04Smrg fi 415965eef222Smrg prev= 416065eef222Smrg else 416165eef222Smrg dest=$arg 416265eef222Smrg continue 416365eef222Smrg fi 416465eef222Smrg ;; 416565eef222Smrg esac 4166ef981d24Smrg 416765eef222Smrg # Aesthetically quote the argument. 416865eef222Smrg func_quote_for_eval "$arg" 4169200d7199Smrg func_append install_prog " $func_quote_for_eval_result" 417056957a04Smrg if test -n "$arg2"; then 417156957a04Smrg func_quote_for_eval "$arg2" 417256957a04Smrg fi 4173200d7199Smrg func_append install_shared_prog " $func_quote_for_eval_result" 417465eef222Smrg done 4175ef981d24Smrg 417665eef222Smrg test -z "$install_prog" && \ 417765eef222Smrg func_fatal_help "you must specify an install program" 4178ef981d24Smrg 417965eef222Smrg test -n "$prev" && \ 4180b312a94cSmrg func_fatal_help "the '$prev' option requires an argument" 4181ef981d24Smrg 418256957a04Smrg if test -n "$install_override_mode" && $no_mode; then 418356957a04Smrg if $install_cp; then :; else 418456957a04Smrg func_quote_for_eval "$install_override_mode" 4185200d7199Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 418656957a04Smrg fi 418756957a04Smrg fi 418856957a04Smrg 418965eef222Smrg if test -z "$files"; then 419065eef222Smrg if test -z "$dest"; then 419165eef222Smrg func_fatal_help "no file or destination specified" 419265eef222Smrg else 419365eef222Smrg func_fatal_help "you must specify a destination" 4194ef981d24Smrg fi 4195ef981d24Smrg fi 4196ef981d24Smrg 419765eef222Smrg # Strip any trailing slash from the destination. 419865eef222Smrg func_stripname '' '/' "$dest" 419965eef222Smrg dest=$func_stripname_result 4200ef981d24Smrg 420165eef222Smrg # Check to see that the destination is a directory. 4202b312a94cSmrg test -d "$dest" && isdir=: 4203b312a94cSmrg if $isdir; then 4204b312a94cSmrg destdir=$dest 420565eef222Smrg destname= 420665eef222Smrg else 420765eef222Smrg func_dirname_and_basename "$dest" "" "." 4208b312a94cSmrg destdir=$func_dirname_result 4209b312a94cSmrg destname=$func_basename_result 421065eef222Smrg 421165eef222Smrg # Not a directory, so check to see that there is only one file specified. 421265eef222Smrg set dummy $files; shift 421365eef222Smrg test "$#" -gt 1 && \ 4214b312a94cSmrg func_fatal_help "'$dest' is not a directory" 421565eef222Smrg fi 421665eef222Smrg case $destdir in 421765eef222Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4218ef981d24Smrg *) 421965eef222Smrg for file in $files; do 422065eef222Smrg case $file in 422165eef222Smrg *.lo) ;; 422265eef222Smrg *) 4223b312a94cSmrg func_fatal_help "'$destdir' must be an absolute directory name" 422465eef222Smrg ;; 422565eef222Smrg esac 422665eef222Smrg done 4227ef981d24Smrg ;; 4228ef981d24Smrg esac 4229ef981d24Smrg 423065eef222Smrg # This variable tells wrapper scripts just to set variables rather 423165eef222Smrg # than running their programs. 4232b312a94cSmrg libtool_install_magic=$magic 4233ef981d24Smrg 423465eef222Smrg staticlibs= 423565eef222Smrg future_libdirs= 423665eef222Smrg current_libdirs= 423765eef222Smrg for file in $files; do 4238ef981d24Smrg 423965eef222Smrg # Do each installation. 424065eef222Smrg case $file in 424165eef222Smrg *.$libext) 424265eef222Smrg # Do the static libraries later. 4243200d7199Smrg func_append staticlibs " $file" 424465eef222Smrg ;; 424565eef222Smrg 424665eef222Smrg *.la) 4247200d7199Smrg func_resolve_sysroot "$file" 4248200d7199Smrg file=$func_resolve_sysroot_result 4249200d7199Smrg 425065eef222Smrg # Check to see that this really is a libtool archive. 425165eef222Smrg func_lalib_unsafe_p "$file" \ 4252b312a94cSmrg || func_fatal_help "'$file' is not a valid libtool archive" 425365eef222Smrg 425465eef222Smrg library_names= 425565eef222Smrg old_library= 425665eef222Smrg relink_command= 425765eef222Smrg func_source "$file" 425865eef222Smrg 425965eef222Smrg # Add the libdir to current_libdirs if it is the destination. 426065eef222Smrg if test "X$destdir" = "X$libdir"; then 426165eef222Smrg case "$current_libdirs " in 426265eef222Smrg *" $libdir "*) ;; 4263200d7199Smrg *) func_append current_libdirs " $libdir" ;; 4264ef981d24Smrg esac 426565eef222Smrg else 426665eef222Smrg # Note the libdir as a future libdir. 426765eef222Smrg case "$future_libdirs " in 426865eef222Smrg *" $libdir "*) ;; 4269200d7199Smrg *) func_append future_libdirs " $libdir" ;; 427065eef222Smrg esac 427165eef222Smrg fi 4272ef981d24Smrg 427365eef222Smrg func_dirname "$file" "/" "" 4274b312a94cSmrg dir=$func_dirname_result 4275200d7199Smrg func_append dir "$objdir" 427665eef222Smrg 427765eef222Smrg if test -n "$relink_command"; then 427865eef222Smrg # Determine the prefix the user has applied to our future dir. 427956957a04Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 428065eef222Smrg 428165eef222Smrg # Don't allow the user to place us outside of our expected 428265eef222Smrg # location b/c this prevents finding dependent libraries that 428365eef222Smrg # are installed to the same prefix. 428465eef222Smrg # At present, this check doesn't affect windows .dll's that 428565eef222Smrg # are installed into $libdir/../bin (currently, that works fine) 428665eef222Smrg # but it's something to keep an eye on. 428765eef222Smrg test "$inst_prefix_dir" = "$destdir" && \ 4288b312a94cSmrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 428965eef222Smrg 429065eef222Smrg if test -n "$inst_prefix_dir"; then 429165eef222Smrg # Stick the inst_prefix_dir data into the link command. 429256957a04Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 429365eef222Smrg else 429456957a04Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 429565eef222Smrg fi 429665eef222Smrg 4297b312a94cSmrg func_warning "relinking '$file'" 429865eef222Smrg func_show_eval "$relink_command" \ 4299b312a94cSmrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 430065eef222Smrg fi 430165eef222Smrg 430265eef222Smrg # See the names of the shared library. 430365eef222Smrg set dummy $library_names; shift 430465eef222Smrg if test -n "$1"; then 4305b312a94cSmrg realname=$1 430665eef222Smrg shift 430765eef222Smrg 4308b312a94cSmrg srcname=$realname 4309b312a94cSmrg test -n "$relink_command" && srcname=${realname}T 431065eef222Smrg 431165eef222Smrg # Install the shared library and build the symlinks. 431256957a04Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 431365eef222Smrg 'exit $?' 4314b312a94cSmrg tstripme=$stripme 431565eef222Smrg case $host_os in 431665eef222Smrg cygwin* | mingw* | pw32* | cegcc*) 431765eef222Smrg case $realname in 431865eef222Smrg *.dll.a) 4319b312a94cSmrg tstripme= 4320b312a94cSmrg ;; 4321b312a94cSmrg esac 4322b312a94cSmrg ;; 4323b312a94cSmrg os2*) 4324b312a94cSmrg case $realname in 4325b312a94cSmrg *_dll.a) 4326b312a94cSmrg tstripme= 432765eef222Smrg ;; 432865eef222Smrg esac 4329ef981d24Smrg ;; 4330ef981d24Smrg esac 433165eef222Smrg if test -n "$tstripme" && test -n "$striplib"; then 433265eef222Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4333ef981d24Smrg fi 433465eef222Smrg 433565eef222Smrg if test "$#" -gt 0; then 433665eef222Smrg # Delete the old symlinks, and create new ones. 4337b312a94cSmrg # Try 'ln -sf' first, because the 'ln' binary might depend on 433865eef222Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 433965eef222Smrg # so we also need to try rm && ln -s. 434065eef222Smrg for linkname 434165eef222Smrg do 434265eef222Smrg test "$linkname" != "$realname" \ 434365eef222Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4344ef981d24Smrg done 4345ef981d24Smrg fi 4346ef981d24Smrg 434765eef222Smrg # Do each command in the postinstall commands. 4348b312a94cSmrg lib=$destdir/$realname 434965eef222Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4350ef981d24Smrg fi 4351ef981d24Smrg 435265eef222Smrg # Install the pseudo-library for information purposes. 435365eef222Smrg func_basename "$file" 4354b312a94cSmrg name=$func_basename_result 4355b312a94cSmrg instname=$dir/${name}i 435665eef222Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4357ef981d24Smrg 435865eef222Smrg # Maybe install the static library, too. 4359200d7199Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 436065eef222Smrg ;; 4361ef981d24Smrg 436265eef222Smrg *.lo) 436365eef222Smrg # Install (i.e. copy) a libtool object. 4364ef981d24Smrg 436565eef222Smrg # Figure out destination file name, if it wasn't already specified. 436665eef222Smrg if test -n "$destname"; then 4367b312a94cSmrg destfile=$destdir/$destname 436865eef222Smrg else 436965eef222Smrg func_basename "$file" 4370b312a94cSmrg destfile=$func_basename_result 4371b312a94cSmrg destfile=$destdir/$destfile 437265eef222Smrg fi 437365eef222Smrg 437465eef222Smrg # Deduce the name of the destination old-style object file. 437565eef222Smrg case $destfile in 437665eef222Smrg *.lo) 437765eef222Smrg func_lo2o "$destfile" 437865eef222Smrg staticdest=$func_lo2o_result 437965eef222Smrg ;; 438065eef222Smrg *.$objext) 4381b312a94cSmrg staticdest=$destfile 438265eef222Smrg destfile= 438365eef222Smrg ;; 438465eef222Smrg *) 4385b312a94cSmrg func_fatal_help "cannot copy a libtool object to '$destfile'" 438665eef222Smrg ;; 4387ef981d24Smrg esac 4388ef981d24Smrg 438965eef222Smrg # Install the libtool object if requested. 439065eef222Smrg test -n "$destfile" && \ 439165eef222Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 439265eef222Smrg 439365eef222Smrg # Install the old object if enabled. 4394b312a94cSmrg if test yes = "$build_old_libs"; then 439565eef222Smrg # Deduce the name of the old-style object file. 439665eef222Smrg func_lo2o "$file" 439765eef222Smrg staticobj=$func_lo2o_result 439865eef222Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4399ef981d24Smrg fi 440065eef222Smrg exit $EXIT_SUCCESS 440165eef222Smrg ;; 4402ef981d24Smrg 440365eef222Smrg *) 440465eef222Smrg # Figure out destination file name, if it wasn't already specified. 440565eef222Smrg if test -n "$destname"; then 4406b312a94cSmrg destfile=$destdir/$destname 440765eef222Smrg else 440865eef222Smrg func_basename "$file" 4409b312a94cSmrg destfile=$func_basename_result 4410b312a94cSmrg destfile=$destdir/$destfile 441165eef222Smrg fi 441265eef222Smrg 441365eef222Smrg # If the file is missing, and there is a .exe on the end, strip it 441465eef222Smrg # because it is most likely a libtool script we actually want to 441565eef222Smrg # install 4416b312a94cSmrg stripped_ext= 441765eef222Smrg case $file in 441865eef222Smrg *.exe) 441965eef222Smrg if test ! -f "$file"; then 442065eef222Smrg func_stripname '' '.exe' "$file" 442165eef222Smrg file=$func_stripname_result 4422b312a94cSmrg stripped_ext=.exe 4423ef981d24Smrg fi 442465eef222Smrg ;; 442565eef222Smrg esac 4426ef981d24Smrg 442765eef222Smrg # Do a test to see if this is really a libtool program. 442865eef222Smrg case $host in 442965eef222Smrg *cygwin* | *mingw*) 443065eef222Smrg if func_ltwrapper_executable_p "$file"; then 443165eef222Smrg func_ltwrapper_scriptname "$file" 443265eef222Smrg wrapper=$func_ltwrapper_scriptname_result 443365eef222Smrg else 443465eef222Smrg func_stripname '' '.exe' "$file" 443565eef222Smrg wrapper=$func_stripname_result 443665eef222Smrg fi 443765eef222Smrg ;; 443865eef222Smrg *) 443965eef222Smrg wrapper=$file 444065eef222Smrg ;; 444165eef222Smrg esac 444265eef222Smrg if func_ltwrapper_script_p "$wrapper"; then 444365eef222Smrg notinst_deplibs= 444465eef222Smrg relink_command= 4445ef981d24Smrg 444665eef222Smrg func_source "$wrapper" 4447ef981d24Smrg 444865eef222Smrg # Check the variables that should have been set. 444965eef222Smrg test -z "$generated_by_libtool_version" && \ 4450b312a94cSmrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 445165eef222Smrg 4452b312a94cSmrg finalize=: 445365eef222Smrg for lib in $notinst_deplibs; do 445465eef222Smrg # Check to see that each library is installed. 445565eef222Smrg libdir= 445665eef222Smrg if test -f "$lib"; then 445765eef222Smrg func_source "$lib" 445865eef222Smrg fi 4459b312a94cSmrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 446065eef222Smrg if test -n "$libdir" && test ! -f "$libfile"; then 4461b312a94cSmrg func_warning "'$lib' has not been installed in '$libdir'" 4462b312a94cSmrg finalize=false 446365eef222Smrg fi 446465eef222Smrg done 446565eef222Smrg 446665eef222Smrg relink_command= 446765eef222Smrg func_source "$wrapper" 446865eef222Smrg 446965eef222Smrg outputname= 4470b312a94cSmrg if test no = "$fast_install" && test -n "$relink_command"; then 447165eef222Smrg $opt_dry_run || { 4472b312a94cSmrg if $finalize; then 447365eef222Smrg tmpdir=`func_mktempdir` 447465eef222Smrg func_basename "$file$stripped_ext" 4475b312a94cSmrg file=$func_basename_result 4476b312a94cSmrg outputname=$tmpdir/$file 447765eef222Smrg # Replace the output file specification. 447856957a04Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 447965eef222Smrg 4480b312a94cSmrg $opt_quiet || { 448165eef222Smrg func_quote_for_expand "$relink_command" 448265eef222Smrg eval "func_echo $func_quote_for_expand_result" 448365eef222Smrg } 448465eef222Smrg if eval "$relink_command"; then : 448565eef222Smrg else 4486b312a94cSmrg func_error "error: relink '$file' with the above command before installing it" 448765eef222Smrg $opt_dry_run || ${RM}r "$tmpdir" 448865eef222Smrg continue 448965eef222Smrg fi 4490b312a94cSmrg file=$outputname 449165eef222Smrg else 4492b312a94cSmrg func_warning "cannot relink '$file'" 449365eef222Smrg fi 449465eef222Smrg } 4495ef981d24Smrg else 449665eef222Smrg # Install the binary that we compiled earlier. 449756957a04Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4498ef981d24Smrg fi 449965eef222Smrg fi 4500ef981d24Smrg 450165eef222Smrg # remove .exe since cygwin /usr/bin/install will append another 450265eef222Smrg # one anyway 450365eef222Smrg case $install_prog,$host in 450465eef222Smrg */usr/bin/install*,*cygwin*) 450565eef222Smrg case $file:$destfile in 450665eef222Smrg *.exe:*.exe) 450765eef222Smrg # this is ok 450865eef222Smrg ;; 450965eef222Smrg *.exe:*) 451065eef222Smrg destfile=$destfile.exe 451165eef222Smrg ;; 451265eef222Smrg *:*.exe) 451365eef222Smrg func_stripname '' '.exe' "$destfile" 451465eef222Smrg destfile=$func_stripname_result 451565eef222Smrg ;; 451665eef222Smrg esac 4517ef981d24Smrg ;; 4518ef981d24Smrg esac 451965eef222Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 452065eef222Smrg $opt_dry_run || if test -n "$outputname"; then 452165eef222Smrg ${RM}r "$tmpdir" 452265eef222Smrg fi 452365eef222Smrg ;; 452465eef222Smrg esac 452565eef222Smrg done 4526ef981d24Smrg 452765eef222Smrg for file in $staticlibs; do 452865eef222Smrg func_basename "$file" 4529b312a94cSmrg name=$func_basename_result 4530ef981d24Smrg 453165eef222Smrg # Set up the ranlib parameters. 4532b312a94cSmrg oldlib=$destdir/$name 4533b312a94cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4534b312a94cSmrg tool_oldlib=$func_to_tool_file_result 4535ef981d24Smrg 453665eef222Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4537ef981d24Smrg 453865eef222Smrg if test -n "$stripme" && test -n "$old_striplib"; then 4539b312a94cSmrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 454065eef222Smrg fi 4541ef981d24Smrg 454265eef222Smrg # Do each command in the postinstall commands. 454365eef222Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 454465eef222Smrg done 4545ef981d24Smrg 454665eef222Smrg test -n "$future_libdirs" && \ 4547b312a94cSmrg func_warning "remember to run '$progname --finish$future_libdirs'" 4548ef981d24Smrg 454965eef222Smrg if test -n "$current_libdirs"; then 455065eef222Smrg # Maybe just do a dry run. 455165eef222Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4552b312a94cSmrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 455365eef222Smrg else 455465eef222Smrg exit $EXIT_SUCCESS 455565eef222Smrg fi 455665eef222Smrg} 4557ef981d24Smrg 4558b312a94cSmrgtest install = "$opt_mode" && func_mode_install ${1+"$@"} 4559ef981d24Smrg 4560ef981d24Smrg 456165eef222Smrg# func_generate_dlsyms outputname originator pic_p 456265eef222Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 456365eef222Smrg# a dlpreopen symbol table. 456465eef222Smrgfunc_generate_dlsyms () 456565eef222Smrg{ 4566b312a94cSmrg $debug_cmd 4567b312a94cSmrg 4568b312a94cSmrg my_outputname=$1 4569b312a94cSmrg my_originator=$2 4570b312a94cSmrg my_pic_p=${3-false} 4571b312a94cSmrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 457265eef222Smrg my_dlsyms= 457365eef222Smrg 4574b312a94cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 457565eef222Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4576b312a94cSmrg my_dlsyms=${my_outputname}S.c 457765eef222Smrg else 457865eef222Smrg func_error "not configured to extract global symbols from dlpreopened files" 457965eef222Smrg fi 458065eef222Smrg fi 4581ef981d24Smrg 458265eef222Smrg if test -n "$my_dlsyms"; then 458365eef222Smrg case $my_dlsyms in 458465eef222Smrg "") ;; 458565eef222Smrg *.c) 458665eef222Smrg # Discover the nlist of each of the dlfiles. 4587b312a94cSmrg nlist=$output_objdir/$my_outputname.nm 458865eef222Smrg 458965eef222Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 459065eef222Smrg 459165eef222Smrg # Parse the name list into a source file. 459265eef222Smrg func_verbose "creating $output_objdir/$my_dlsyms" 459365eef222Smrg 459465eef222Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4595b312a94cSmrg/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4596b312a94cSmrg/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 459765eef222Smrg 459865eef222Smrg#ifdef __cplusplus 459965eef222Smrgextern \"C\" { 460065eef222Smrg#endif 460165eef222Smrg 4602b312a94cSmrg#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 460356957a04Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 460456957a04Smrg#endif 460556957a04Smrg 4606200d7199Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4607b312a94cSmrg#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4608b312a94cSmrg/* DATA imports from DLLs on WIN32 can't be const, because runtime 4609200d7199Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4610200d7199Smrg# define LT_DLSYM_CONST 4611b312a94cSmrg#elif defined __osf__ 4612200d7199Smrg/* This system does not cope well with relocations in const data. */ 4613200d7199Smrg# define LT_DLSYM_CONST 4614200d7199Smrg#else 4615200d7199Smrg# define LT_DLSYM_CONST const 4616200d7199Smrg#endif 4617200d7199Smrg 4618b312a94cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4619b312a94cSmrg 462065eef222Smrg/* External symbol declarations for the compiler. */\ 462165eef222Smrg" 462265eef222Smrg 4623b312a94cSmrg if test yes = "$dlself"; then 4624b312a94cSmrg func_verbose "generating symbol list for '$output'" 462565eef222Smrg 462665eef222Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 462765eef222Smrg 462865eef222Smrg # Add our own program objects to the symbol list. 462956957a04Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 463065eef222Smrg for progfile in $progfiles; do 4631200d7199Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4632b312a94cSmrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4633200d7199Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 463465eef222Smrg done 463565eef222Smrg 463665eef222Smrg if test -n "$exclude_expsyms"; then 463765eef222Smrg $opt_dry_run || { 463865eef222Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 463965eef222Smrg eval '$MV "$nlist"T "$nlist"' 464065eef222Smrg } 4641ef981d24Smrg fi 4642ef981d24Smrg 464365eef222Smrg if test -n "$export_symbols_regex"; then 464465eef222Smrg $opt_dry_run || { 464565eef222Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 464665eef222Smrg eval '$MV "$nlist"T "$nlist"' 464765eef222Smrg } 4648ef981d24Smrg fi 464965eef222Smrg 465065eef222Smrg # Prepare the list of exported symbols 465165eef222Smrg if test -z "$export_symbols"; then 4652b312a94cSmrg export_symbols=$output_objdir/$outputname.exp 465365eef222Smrg $opt_dry_run || { 465465eef222Smrg $RM $export_symbols 4655b312a94cSmrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 465665eef222Smrg case $host in 465765eef222Smrg *cygwin* | *mingw* | *cegcc* ) 465865eef222Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 465965eef222Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 466065eef222Smrg ;; 4661ef981d24Smrg esac 466265eef222Smrg } 466365eef222Smrg else 466465eef222Smrg $opt_dry_run || { 4665b312a94cSmrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 466665eef222Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 466765eef222Smrg eval '$MV "$nlist"T "$nlist"' 466865eef222Smrg case $host in 466956957a04Smrg *cygwin* | *mingw* | *cegcc* ) 467065eef222Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 467165eef222Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 467265eef222Smrg ;; 4673ef981d24Smrg esac 467465eef222Smrg } 4675ef981d24Smrg fi 467665eef222Smrg fi 4677ef981d24Smrg 467865eef222Smrg for dlprefile in $dlprefiles; do 4679b312a94cSmrg func_verbose "extracting global C symbols from '$dlprefile'" 468065eef222Smrg func_basename "$dlprefile" 4681b312a94cSmrg name=$func_basename_result 4682200d7199Smrg case $host in 4683200d7199Smrg *cygwin* | *mingw* | *cegcc* ) 4684200d7199Smrg # if an import library, we need to obtain dlname 4685200d7199Smrg if func_win32_import_lib_p "$dlprefile"; then 4686200d7199Smrg func_tr_sh "$dlprefile" 4687200d7199Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4688b312a94cSmrg dlprefile_dlbasename= 4689200d7199Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4690200d7199Smrg # Use subshell, to avoid clobbering current variable values 4691200d7199Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4692b312a94cSmrg if test -n "$dlprefile_dlname"; then 4693200d7199Smrg func_basename "$dlprefile_dlname" 4694b312a94cSmrg dlprefile_dlbasename=$func_basename_result 4695200d7199Smrg else 4696200d7199Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 4697200d7199Smrg $sharedlib_from_linklib_cmd "$dlprefile" 4698200d7199Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4699200d7199Smrg fi 4700200d7199Smrg fi 4701200d7199Smrg $opt_dry_run || { 4702b312a94cSmrg if test -n "$dlprefile_dlbasename"; then 4703200d7199Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4704200d7199Smrg else 4705200d7199Smrg func_warning "Could not compute DLL name from $name" 4706200d7199Smrg eval '$ECHO ": $name " >> "$nlist"' 4707200d7199Smrg fi 4708200d7199Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4709200d7199Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4710200d7199Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4711200d7199Smrg } 4712200d7199Smrg else # not an import lib 4713200d7199Smrg $opt_dry_run || { 4714200d7199Smrg eval '$ECHO ": $name " >> "$nlist"' 4715200d7199Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4716200d7199Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4717200d7199Smrg } 4718200d7199Smrg fi 4719200d7199Smrg ;; 4720200d7199Smrg *) 4721200d7199Smrg $opt_dry_run || { 4722200d7199Smrg eval '$ECHO ": $name " >> "$nlist"' 4723200d7199Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4724200d7199Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4725200d7199Smrg } 4726200d7199Smrg ;; 4727200d7199Smrg esac 472865eef222Smrg done 4729ef981d24Smrg 473065eef222Smrg $opt_dry_run || { 473165eef222Smrg # Make sure we have at least an empty file. 473265eef222Smrg test -f "$nlist" || : > "$nlist" 4733ef981d24Smrg 473465eef222Smrg if test -n "$exclude_expsyms"; then 473565eef222Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 473665eef222Smrg $MV "$nlist"T "$nlist" 4737ef981d24Smrg fi 4738ef981d24Smrg 473965eef222Smrg # Try sorting and uniquifying the output. 474065eef222Smrg if $GREP -v "^: " < "$nlist" | 474165eef222Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 474265eef222Smrg sort -k 3 4743ef981d24Smrg else 474465eef222Smrg sort +2 474565eef222Smrg fi | 474665eef222Smrg uniq > "$nlist"S; then 474765eef222Smrg : 4748ef981d24Smrg else 474965eef222Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 4750ef981d24Smrg fi 4751ef981d24Smrg 475265eef222Smrg if test -f "$nlist"S; then 475365eef222Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 4754ef981d24Smrg else 475556957a04Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 4756ef981d24Smrg fi 4757ef981d24Smrg 4758b312a94cSmrg func_show_eval '$RM "${nlist}I"' 4759b312a94cSmrg if test -n "$global_symbol_to_import"; then 4760b312a94cSmrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 4761b312a94cSmrg fi 4762b312a94cSmrg 476356957a04Smrg echo >> "$output_objdir/$my_dlsyms" "\ 4764ef981d24Smrg 476565eef222Smrg/* The mapping between symbol names and symbols. */ 476665eef222Smrgtypedef struct { 476765eef222Smrg const char *name; 476865eef222Smrg void *address; 476965eef222Smrg} lt_dlsymlist; 4770200d7199Smrgextern LT_DLSYM_CONST lt_dlsymlist 4771b312a94cSmrglt_${my_prefix}_LTX_preloaded_symbols[];\ 4772b312a94cSmrg" 4773b312a94cSmrg 4774b312a94cSmrg if test -s "$nlist"I; then 4775b312a94cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4776b312a94cSmrgstatic void lt_syminit(void) 4777b312a94cSmrg{ 4778b312a94cSmrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 4779b312a94cSmrg for (; symbol->name; ++symbol) 4780b312a94cSmrg {" 4781b312a94cSmrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 4782b312a94cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4783b312a94cSmrg } 4784b312a94cSmrg}" 4785b312a94cSmrg fi 4786b312a94cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4787200d7199SmrgLT_DLSYM_CONST lt_dlsymlist 478865eef222Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 4789b312a94cSmrg{ {\"$my_originator\", (void *) 0}," 4790b312a94cSmrg 4791b312a94cSmrg if test -s "$nlist"I; then 4792b312a94cSmrg echo >> "$output_objdir/$my_dlsyms" "\ 4793b312a94cSmrg {\"@INIT@\", (void *) <_syminit}," 4794b312a94cSmrg fi 479565eef222Smrg 479665eef222Smrg case $need_lib_prefix in 479765eef222Smrg no) 479865eef222Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 479965eef222Smrg ;; 480065eef222Smrg *) 480165eef222Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 480265eef222Smrg ;; 480365eef222Smrg esac 480456957a04Smrg echo >> "$output_objdir/$my_dlsyms" "\ 480565eef222Smrg {0, (void *) 0} 480665eef222Smrg}; 480765eef222Smrg 480865eef222Smrg/* This works around a problem in FreeBSD linker */ 480965eef222Smrg#ifdef FREEBSD_WORKAROUND 481065eef222Smrgstatic const void *lt_preloaded_setup() { 481165eef222Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 481265eef222Smrg} 481365eef222Smrg#endif 481465eef222Smrg 481565eef222Smrg#ifdef __cplusplus 481665eef222Smrg} 481765eef222Smrg#endif\ 481865eef222Smrg" 481965eef222Smrg } # !$opt_dry_run 482065eef222Smrg 482165eef222Smrg pic_flag_for_symtable= 482265eef222Smrg case "$compile_command " in 482365eef222Smrg *" -static "*) ;; 482465eef222Smrg *) 482565eef222Smrg case $host in 482665eef222Smrg # compiling the symbol table file with pic_flag works around 482765eef222Smrg # a FreeBSD bug that causes programs to crash when -lm is 482865eef222Smrg # linked before any other PIC object. But we must not use 482965eef222Smrg # pic_flag when linking with -static. The problem exists in 483065eef222Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 4831b312a94cSmrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 483265eef222Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 483365eef222Smrg *-*-hpux*) 483465eef222Smrg pic_flag_for_symtable=" $pic_flag" ;; 483565eef222Smrg *) 4836b312a94cSmrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 483765eef222Smrg ;; 483865eef222Smrg esac 483965eef222Smrg ;; 484065eef222Smrg esac 484165eef222Smrg symtab_cflags= 484265eef222Smrg for arg in $LTCFLAGS; do 484365eef222Smrg case $arg in 484465eef222Smrg -pie | -fpie | -fPIE) ;; 4845200d7199Smrg *) func_append symtab_cflags " $arg" ;; 484665eef222Smrg esac 484765eef222Smrg done 4848ef981d24Smrg 484965eef222Smrg # Now compile the dynamic symbol file. 485065eef222Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 4851ef981d24Smrg 485265eef222Smrg # Clean up the generated files. 4853b312a94cSmrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 485465eef222Smrg 485565eef222Smrg # Transform the symbol file into the correct name. 4856b312a94cSmrg symfileobj=$output_objdir/${my_outputname}S.$objext 485765eef222Smrg case $host in 485865eef222Smrg *cygwin* | *mingw* | *cegcc* ) 485965eef222Smrg if test -f "$output_objdir/$my_outputname.def"; then 486056957a04Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486156957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 486265eef222Smrg else 486356957a04Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486456957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486565eef222Smrg fi 486665eef222Smrg ;; 486765eef222Smrg *) 486856957a04Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 486956957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 4870ef981d24Smrg ;; 4871ef981d24Smrg esac 487265eef222Smrg ;; 487365eef222Smrg *) 4874b312a94cSmrg func_fatal_error "unknown suffix for '$my_dlsyms'" 487565eef222Smrg ;; 487665eef222Smrg esac 487765eef222Smrg else 487865eef222Smrg # We keep going just in case the user didn't refer to 487965eef222Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 488065eef222Smrg # really was required. 488165eef222Smrg 488265eef222Smrg # Nullify the symbol file. 488356957a04Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 488456957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 4885ef981d24Smrg fi 488665eef222Smrg} 4887ef981d24Smrg 4888b312a94cSmrg# func_cygming_gnu_implib_p ARG 4889b312a94cSmrg# This predicate returns with zero status (TRUE) if 4890b312a94cSmrg# ARG is a GNU/binutils-style import library. Returns 4891b312a94cSmrg# with nonzero status (FALSE) otherwise. 4892b312a94cSmrgfunc_cygming_gnu_implib_p () 4893b312a94cSmrg{ 4894b312a94cSmrg $debug_cmd 4895b312a94cSmrg 4896b312a94cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4897b312a94cSmrg 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)$'` 4898b312a94cSmrg test -n "$func_cygming_gnu_implib_tmp" 4899b312a94cSmrg} 4900b312a94cSmrg 4901b312a94cSmrg# func_cygming_ms_implib_p ARG 4902b312a94cSmrg# This predicate returns with zero status (TRUE) if 4903b312a94cSmrg# ARG is an MS-style import library. Returns 4904b312a94cSmrg# with nonzero status (FALSE) otherwise. 4905b312a94cSmrgfunc_cygming_ms_implib_p () 4906b312a94cSmrg{ 4907b312a94cSmrg $debug_cmd 4908b312a94cSmrg 4909b312a94cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4910b312a94cSmrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 4911b312a94cSmrg test -n "$func_cygming_ms_implib_tmp" 4912b312a94cSmrg} 4913b312a94cSmrg 491465eef222Smrg# func_win32_libid arg 491565eef222Smrg# return the library type of file 'arg' 491665eef222Smrg# 491765eef222Smrg# Need a lot of goo to handle *both* DLLs and import libs 491865eef222Smrg# Has to be a shell function in order to 'eat' the argument 491965eef222Smrg# that is supplied when $file_magic_command is called. 492056957a04Smrg# Despite the name, also deal with 64 bit binaries. 492165eef222Smrgfunc_win32_libid () 492265eef222Smrg{ 4923b312a94cSmrg $debug_cmd 4924b312a94cSmrg 4925b312a94cSmrg win32_libid_type=unknown 492665eef222Smrg win32_fileres=`file -L $1 2>/dev/null` 492765eef222Smrg case $win32_fileres in 492865eef222Smrg *ar\ archive\ import\ library*) # definitely import 492965eef222Smrg win32_libid_type="x86 archive import" 493065eef222Smrg ;; 493165eef222Smrg *ar\ archive*) # could be an import, or static 493256957a04Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 493365eef222Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 493456957a04Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 4935b312a94cSmrg case $nm_interface in 4936b312a94cSmrg "MS dumpbin") 4937b312a94cSmrg if func_cygming_ms_implib_p "$1" || 4938b312a94cSmrg func_cygming_gnu_implib_p "$1" 4939b312a94cSmrg then 4940b312a94cSmrg win32_nmres=import 4941b312a94cSmrg else 4942b312a94cSmrg win32_nmres= 4943b312a94cSmrg fi 4944b312a94cSmrg ;; 4945b312a94cSmrg *) 4946b312a94cSmrg func_to_tool_file "$1" func_convert_file_msys_to_w32 4947b312a94cSmrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 4948b312a94cSmrg $SED -n -e ' 494965eef222Smrg 1,100{ 495065eef222Smrg / I /{ 4951b312a94cSmrg s|.*|import| 495265eef222Smrg p 495365eef222Smrg q 495465eef222Smrg } 495565eef222Smrg }'` 4956b312a94cSmrg ;; 4957b312a94cSmrg esac 495865eef222Smrg case $win32_nmres in 495965eef222Smrg import*) win32_libid_type="x86 archive import";; 496065eef222Smrg *) win32_libid_type="x86 archive static";; 496165eef222Smrg esac 496265eef222Smrg fi 496365eef222Smrg ;; 496465eef222Smrg *DLL*) 496565eef222Smrg win32_libid_type="x86 DLL" 496665eef222Smrg ;; 496765eef222Smrg *executable*) # but shell scripts are "executable" too... 496865eef222Smrg case $win32_fileres in 496965eef222Smrg *MS\ Windows\ PE\ Intel*) 497065eef222Smrg win32_libid_type="x86 DLL" 497165eef222Smrg ;; 497265eef222Smrg esac 497365eef222Smrg ;; 497465eef222Smrg esac 497565eef222Smrg $ECHO "$win32_libid_type" 497665eef222Smrg} 4977ef981d24Smrg 4978200d7199Smrg# func_cygming_dll_for_implib ARG 4979200d7199Smrg# 4980200d7199Smrg# Platform-specific function to extract the 4981200d7199Smrg# name of the DLL associated with the specified 4982200d7199Smrg# import library ARG. 4983200d7199Smrg# Invoked by eval'ing the libtool variable 4984200d7199Smrg# $sharedlib_from_linklib_cmd 4985200d7199Smrg# Result is available in the variable 4986200d7199Smrg# $sharedlib_from_linklib_result 4987200d7199Smrgfunc_cygming_dll_for_implib () 4988200d7199Smrg{ 4989b312a94cSmrg $debug_cmd 4990b312a94cSmrg 4991200d7199Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 4992200d7199Smrg} 4993200d7199Smrg 4994200d7199Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 4995200d7199Smrg# 4996200d7199Smrg# The is the core of a fallback implementation of a 4997200d7199Smrg# platform-specific function to extract the name of the 4998200d7199Smrg# DLL associated with the specified import library LIBNAME. 4999200d7199Smrg# 5000200d7199Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 5001200d7199Smrg# on the platform and compiler that created the implib. 5002200d7199Smrg# 5003200d7199Smrg# Echos the name of the DLL associated with the 5004200d7199Smrg# specified import library. 5005200d7199Smrgfunc_cygming_dll_for_implib_fallback_core () 5006200d7199Smrg{ 5007b312a94cSmrg $debug_cmd 5008b312a94cSmrg 5009200d7199Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5010200d7199Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5011200d7199Smrg $SED '/^Contents of section '"$match_literal"':/{ 5012200d7199Smrg # Place marker at beginning of archive member dllname section 5013200d7199Smrg s/.*/====MARK====/ 5014200d7199Smrg p 5015200d7199Smrg d 5016200d7199Smrg } 5017200d7199Smrg # These lines can sometimes be longer than 43 characters, but 5018200d7199Smrg # are always uninteresting 5019200d7199Smrg /:[ ]*file format pe[i]\{,1\}-/d 5020200d7199Smrg /^In archive [^:]*:/d 5021200d7199Smrg # Ensure marker is printed 5022200d7199Smrg /^====MARK====/p 5023200d7199Smrg # Remove all lines with less than 43 characters 5024200d7199Smrg /^.\{43\}/!d 5025200d7199Smrg # From remaining lines, remove first 43 characters 5026200d7199Smrg s/^.\{43\}//' | 5027200d7199Smrg $SED -n ' 5028200d7199Smrg # Join marker and all lines until next marker into a single line 5029200d7199Smrg /^====MARK====/ b para 5030200d7199Smrg H 5031200d7199Smrg $ b para 5032200d7199Smrg b 5033200d7199Smrg :para 5034200d7199Smrg x 5035200d7199Smrg s/\n//g 5036200d7199Smrg # Remove the marker 5037200d7199Smrg s/^====MARK====// 5038200d7199Smrg # Remove trailing dots and whitespace 5039200d7199Smrg s/[\. \t]*$// 5040200d7199Smrg # Print 5041200d7199Smrg /./p' | 5042200d7199Smrg # we now have a list, one entry per line, of the stringified 5043200d7199Smrg # contents of the appropriate section of all members of the 5044b312a94cSmrg # archive that possess that section. Heuristic: eliminate 5045b312a94cSmrg # all those that have a first or second character that is 5046200d7199Smrg # a '.' (that is, objdump's representation of an unprintable 5047200d7199Smrg # character.) This should work for all archives with less than 5048200d7199Smrg # 0x302f exports -- but will fail for DLLs whose name actually 5049200d7199Smrg # begins with a literal '.' or a single character followed by 5050200d7199Smrg # a '.'. 5051200d7199Smrg # 5052200d7199Smrg # Of those that remain, print the first one. 5053200d7199Smrg $SED -e '/^\./d;/^.\./d;q' 5054200d7199Smrg} 5055200d7199Smrg 5056200d7199Smrg# func_cygming_dll_for_implib_fallback ARG 5057200d7199Smrg# Platform-specific function to extract the 5058200d7199Smrg# name of the DLL associated with the specified 5059200d7199Smrg# import library ARG. 5060200d7199Smrg# 5061200d7199Smrg# This fallback implementation is for use when $DLLTOOL 5062200d7199Smrg# does not support the --identify-strict option. 5063200d7199Smrg# Invoked by eval'ing the libtool variable 5064200d7199Smrg# $sharedlib_from_linklib_cmd 5065200d7199Smrg# Result is available in the variable 5066200d7199Smrg# $sharedlib_from_linklib_result 5067200d7199Smrgfunc_cygming_dll_for_implib_fallback () 5068200d7199Smrg{ 5069b312a94cSmrg $debug_cmd 5070b312a94cSmrg 5071b312a94cSmrg if func_cygming_gnu_implib_p "$1"; then 5072200d7199Smrg # binutils import library 5073200d7199Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5074b312a94cSmrg elif func_cygming_ms_implib_p "$1"; then 5075200d7199Smrg # ms-generated import library 5076200d7199Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5077200d7199Smrg else 5078200d7199Smrg # unknown 5079b312a94cSmrg sharedlib_from_linklib_result= 5080200d7199Smrg fi 5081200d7199Smrg} 5082ef981d24Smrg 5083ef981d24Smrg 508465eef222Smrg# func_extract_an_archive dir oldlib 508565eef222Smrgfunc_extract_an_archive () 508665eef222Smrg{ 5087b312a94cSmrg $debug_cmd 5088b312a94cSmrg 5089b312a94cSmrg f_ex_an_ar_dir=$1; shift 5090b312a94cSmrg f_ex_an_ar_oldlib=$1 5091b312a94cSmrg if test yes = "$lock_old_archive_extraction"; then 509256957a04Smrg lockfile=$f_ex_an_ar_oldlib.lock 509356957a04Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 509456957a04Smrg func_echo "Waiting for $lockfile to be removed" 509556957a04Smrg sleep 2 509656957a04Smrg done 509756957a04Smrg fi 509856957a04Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 509956957a04Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5100b312a94cSmrg if test yes = "$lock_old_archive_extraction"; then 510156957a04Smrg $opt_dry_run || rm -f "$lockfile" 510256957a04Smrg fi 510365eef222Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 510465eef222Smrg : 510565eef222Smrg else 510665eef222Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 510765eef222Smrg fi 510865eef222Smrg} 5109ef981d24Smrg 5110ef981d24Smrg 511165eef222Smrg# func_extract_archives gentop oldlib ... 511265eef222Smrgfunc_extract_archives () 511365eef222Smrg{ 5114b312a94cSmrg $debug_cmd 5115b312a94cSmrg 5116b312a94cSmrg my_gentop=$1; shift 511765eef222Smrg my_oldlibs=${1+"$@"} 5118b312a94cSmrg my_oldobjs= 5119b312a94cSmrg my_xlib= 5120b312a94cSmrg my_xabs= 5121b312a94cSmrg my_xdir= 5122ef981d24Smrg 512365eef222Smrg for my_xlib in $my_oldlibs; do 512465eef222Smrg # Extract the objects. 512565eef222Smrg case $my_xlib in 5126b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 512765eef222Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 512865eef222Smrg esac 512965eef222Smrg func_basename "$my_xlib" 5130b312a94cSmrg my_xlib=$func_basename_result 513165eef222Smrg my_xlib_u=$my_xlib 513265eef222Smrg while :; do 513365eef222Smrg case " $extracted_archives " in 513465eef222Smrg *" $my_xlib_u "*) 513565eef222Smrg func_arith $extracted_serial + 1 513665eef222Smrg extracted_serial=$func_arith_result 513765eef222Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 513865eef222Smrg *) break ;; 513965eef222Smrg esac 514065eef222Smrg done 514165eef222Smrg extracted_archives="$extracted_archives $my_xlib_u" 5142b312a94cSmrg my_xdir=$my_gentop/$my_xlib_u 5143ef981d24Smrg 514465eef222Smrg func_mkdir_p "$my_xdir" 5145ef981d24Smrg 514665eef222Smrg case $host in 514765eef222Smrg *-darwin*) 514865eef222Smrg func_verbose "Extracting $my_xabs" 514965eef222Smrg # Do not bother doing anything if just a dry run 515065eef222Smrg $opt_dry_run || { 515165eef222Smrg darwin_orig_dir=`pwd` 515265eef222Smrg cd $my_xdir || exit $? 515365eef222Smrg darwin_archive=$my_xabs 515465eef222Smrg darwin_curdir=`pwd` 5155b312a94cSmrg func_basename "$darwin_archive" 5156b312a94cSmrg darwin_base_archive=$func_basename_result 515765eef222Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 515865eef222Smrg if test -n "$darwin_arches"; then 515965eef222Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 516065eef222Smrg darwin_arch= 516165eef222Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5162b312a94cSmrg for darwin_arch in $darwin_arches; do 5163b312a94cSmrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5164b312a94cSmrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5165b312a94cSmrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5166b312a94cSmrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 516765eef222Smrg cd "$darwin_curdir" 5168b312a94cSmrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 516965eef222Smrg done # $darwin_arches 517065eef222Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5171b312a94cSmrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 517265eef222Smrg darwin_file= 517365eef222Smrg darwin_files= 517465eef222Smrg for darwin_file in $darwin_filelist; do 517556957a04Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 517665eef222Smrg $LIPO -create -output "$darwin_file" $darwin_files 517765eef222Smrg done # $darwin_filelist 517865eef222Smrg $RM -rf unfat-$$ 517965eef222Smrg cd "$darwin_orig_dir" 518065eef222Smrg else 518165eef222Smrg cd $darwin_orig_dir 518265eef222Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 518365eef222Smrg fi # $darwin_arches 518465eef222Smrg } # !$opt_dry_run 518565eef222Smrg ;; 518665eef222Smrg *) 518765eef222Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 518865eef222Smrg ;; 5189ef981d24Smrg esac 519056957a04Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 519165eef222Smrg done 5192ef981d24Smrg 5193b312a94cSmrg func_extract_archives_result=$my_oldobjs 519465eef222Smrg} 5195ef981d24Smrg 5196ef981d24Smrg 519756957a04Smrg# func_emit_wrapper [arg=no] 519856957a04Smrg# 519956957a04Smrg# Emit a libtool wrapper script on stdout. 520056957a04Smrg# Don't directly open a file because we may want to 520156957a04Smrg# incorporate the script contents within a cygwin/mingw 520256957a04Smrg# wrapper executable. Must ONLY be called from within 520356957a04Smrg# func_mode_link because it depends on a number of variables 520456957a04Smrg# set therein. 520565eef222Smrg# 520656957a04Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 520756957a04Smrg# variable will take. If 'yes', then the emitted script 5208b312a94cSmrg# will assume that the directory where it is stored is 520956957a04Smrg# the $objdir directory. This is a cygwin/mingw-specific 521056957a04Smrg# behavior. 521156957a04Smrgfunc_emit_wrapper () 521265eef222Smrg{ 521356957a04Smrg func_emit_wrapper_arg1=${1-no} 5214ef981d24Smrg 521565eef222Smrg $ECHO "\ 521665eef222Smrg#! $SHELL 5217ef981d24Smrg 521865eef222Smrg# $output - temporary wrapper script for $objdir/$outputname 5219b312a94cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 522065eef222Smrg# 522165eef222Smrg# The $output program cannot be directly executed until all the libtool 522265eef222Smrg# libraries that it depends on are installed. 522365eef222Smrg# 522465eef222Smrg# This wrapper script should never be moved out of the build directory. 522565eef222Smrg# If it is, it will not operate correctly. 5226ef981d24Smrg 522765eef222Smrg# Sed substitution that helps us do robust quoting. It backslashifies 522865eef222Smrg# metacharacters that are still active within double-quoted strings. 522965eef222Smrgsed_quote_subst='$sed_quote_subst' 5230ef981d24Smrg 523165eef222Smrg# Be Bourne compatible 523265eef222Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 523365eef222Smrg emulate sh 523465eef222Smrg NULLCMD=: 523565eef222Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 523665eef222Smrg # is contrary to our usage. Disable this feature. 523765eef222Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 523865eef222Smrg setopt NO_GLOB_SUBST 523965eef222Smrgelse 524065eef222Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 524165eef222Smrgfi 524265eef222SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 524365eef222SmrgDUALCASE=1; export DUALCASE # for MKS sh 5244ef981d24Smrg 524565eef222Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 524665eef222Smrg# if CDPATH is set. 524765eef222Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5248ef981d24Smrg 524965eef222Smrgrelink_command=\"$relink_command\" 5250ef981d24Smrg 525165eef222Smrg# This environment variable determines our operation mode. 525265eef222Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 525365eef222Smrg # install mode needs the following variables: 525465eef222Smrg generated_by_libtool_version='$macro_version' 525565eef222Smrg notinst_deplibs='$notinst_deplibs' 525665eef222Smrgelse 525765eef222Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 525865eef222Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 525956957a04Smrg file=\"\$0\"" 526056957a04Smrg 526156957a04Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 526256957a04Smrg $ECHO "\ 526356957a04Smrg 526456957a04Smrg# A function that is used when there is no print builtin or printf. 526556957a04Smrgfunc_fallback_echo () 526656957a04Smrg{ 526756957a04Smrg eval 'cat <<_LTECHO_EOF 526856957a04Smrg\$1 526956957a04Smrg_LTECHO_EOF' 527056957a04Smrg} 527156957a04Smrg ECHO=\"$qECHO\" 527256957a04Smrg fi 527356957a04Smrg 527456957a04Smrg# Very basic option parsing. These options are (a) specific to 527556957a04Smrg# the libtool wrapper, (b) are identical between the wrapper 5276b312a94cSmrg# /script/ and the wrapper /executable/ that is used only on 527756957a04Smrg# windows platforms, and (c) all begin with the string "--lt-" 5278b312a94cSmrg# (application programs are unlikely to have options that match 527956957a04Smrg# this pattern). 528056957a04Smrg# 528156957a04Smrg# There are only two supported options: --lt-debug and 528256957a04Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 528356957a04Smrg# 528456957a04Smrg# The first argument to this parsing function should be the 528556957a04Smrg# script's $0 value, followed by "$@". 528656957a04Smrglt_option_debug= 528756957a04Smrgfunc_parse_lt_options () 528856957a04Smrg{ 528956957a04Smrg lt_script_arg0=\$0 529056957a04Smrg shift 529156957a04Smrg for lt_opt 529256957a04Smrg do 529356957a04Smrg case \"\$lt_opt\" in 529456957a04Smrg --lt-debug) lt_option_debug=1 ;; 529556957a04Smrg --lt-dump-script) 529656957a04Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 529756957a04Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 529856957a04Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 529956957a04Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 530056957a04Smrg exit 0 530156957a04Smrg ;; 530256957a04Smrg --lt-*) 530356957a04Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 530456957a04Smrg exit 1 530556957a04Smrg ;; 530656957a04Smrg esac 530756957a04Smrg done 530856957a04Smrg 530956957a04Smrg # Print the debug banner immediately: 531056957a04Smrg if test -n \"\$lt_option_debug\"; then 5311b312a94cSmrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 531256957a04Smrg fi 531356957a04Smrg} 531456957a04Smrg 531556957a04Smrg# Used when --lt-debug. Prints its arguments to stdout 531656957a04Smrg# (redirection is the responsibility of the caller) 531756957a04Smrgfunc_lt_dump_args () 531856957a04Smrg{ 531956957a04Smrg lt_dump_args_N=1; 532056957a04Smrg for lt_arg 532156957a04Smrg do 5322b312a94cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 532356957a04Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 532456957a04Smrg done 532556957a04Smrg} 532656957a04Smrg 532756957a04Smrg# Core function for launching the target application 532856957a04Smrgfunc_exec_program_core () 532956957a04Smrg{ 533065eef222Smrg" 533156957a04Smrg case $host in 533256957a04Smrg # Backslashes separate directories on plain windows 533356957a04Smrg *-*-mingw | *-*-os2* | *-cegcc*) 533456957a04Smrg $ECHO "\ 533556957a04Smrg if test -n \"\$lt_option_debug\"; then 5336b312a94cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 533756957a04Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 533856957a04Smrg fi 533956957a04Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 534056957a04Smrg" 534156957a04Smrg ;; 534256957a04Smrg 534356957a04Smrg *) 534456957a04Smrg $ECHO "\ 534556957a04Smrg if test -n \"\$lt_option_debug\"; then 5346b312a94cSmrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 534756957a04Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 534856957a04Smrg fi 534956957a04Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 535056957a04Smrg" 535156957a04Smrg ;; 535256957a04Smrg esac 535356957a04Smrg $ECHO "\ 535456957a04Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 535556957a04Smrg exit 1 535656957a04Smrg} 535756957a04Smrg 535856957a04Smrg# A function to encapsulate launching the target application 535956957a04Smrg# Strips options in the --lt-* namespace from \$@ and 536056957a04Smrg# launches target application with the remaining arguments. 536156957a04Smrgfunc_exec_program () 536256957a04Smrg{ 5363b312a94cSmrg case \" \$* \" in 5364b312a94cSmrg *\\ --lt-*) 5365b312a94cSmrg for lt_wr_arg 5366b312a94cSmrg do 5367b312a94cSmrg case \$lt_wr_arg in 5368b312a94cSmrg --lt-*) ;; 5369b312a94cSmrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5370b312a94cSmrg esac 5371b312a94cSmrg shift 5372b312a94cSmrg done ;; 5373b312a94cSmrg esac 537456957a04Smrg func_exec_program_core \${1+\"\$@\"} 537556957a04Smrg} 537656957a04Smrg 537756957a04Smrg # Parse options 537856957a04Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5379ef981d24Smrg 538065eef222Smrg # Find the directory that this script lives in. 538156957a04Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 538265eef222Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5383ef981d24Smrg 538465eef222Smrg # Follow symbolic links until we get to the real thisdir. 538556957a04Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 538665eef222Smrg while test -n \"\$file\"; do 538756957a04Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5388ef981d24Smrg 538965eef222Smrg # If there was a directory component, then change thisdir. 539065eef222Smrg if test \"x\$destdir\" != \"x\$file\"; then 539165eef222Smrg case \"\$destdir\" in 539265eef222Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 539365eef222Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 539465eef222Smrg esac 539565eef222Smrg fi 5396ef981d24Smrg 539756957a04Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 539856957a04Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 539965eef222Smrg done 5400ef981d24Smrg 540165eef222Smrg # Usually 'no', except on cygwin/mingw when embedded into 540265eef222Smrg # the cwrapper. 540356957a04Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 540465eef222Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 540565eef222Smrg # special case for '.' 540665eef222Smrg if test \"\$thisdir\" = \".\"; then 540765eef222Smrg thisdir=\`pwd\` 540865eef222Smrg fi 540965eef222Smrg # remove .libs from thisdir 541065eef222Smrg case \"\$thisdir\" in 541156957a04Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 541265eef222Smrg $objdir ) thisdir=. ;; 541365eef222Smrg esac 541465eef222Smrg fi 5415ef981d24Smrg 541665eef222Smrg # Try to get the absolute directory name. 541765eef222Smrg absdir=\`cd \"\$thisdir\" && pwd\` 541865eef222Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 541965eef222Smrg" 5420ef981d24Smrg 5421b312a94cSmrg if test yes = "$fast_install"; then 542265eef222Smrg $ECHO "\ 542365eef222Smrg program=lt-'$outputname'$exeext 542465eef222Smrg progdir=\"\$thisdir/$objdir\" 5425ef981d24Smrg 542665eef222Smrg if test ! -f \"\$progdir/\$program\" || 5427b312a94cSmrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 542865eef222Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5429ef981d24Smrg 543065eef222Smrg file=\"\$\$-\$program\" 5431ef981d24Smrg 543265eef222Smrg if test ! -d \"\$progdir\"; then 543365eef222Smrg $MKDIR \"\$progdir\" 543465eef222Smrg else 543565eef222Smrg $RM \"\$progdir/\$file\" 543665eef222Smrg fi" 5437ef981d24Smrg 543865eef222Smrg $ECHO "\ 5439ef981d24Smrg 544065eef222Smrg # relink executable if necessary 544165eef222Smrg if test -n \"\$relink_command\"; then 544265eef222Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 544365eef222Smrg else 5444b312a94cSmrg \$ECHO \"\$relink_command_output\" >&2 544565eef222Smrg $RM \"\$progdir/\$file\" 544665eef222Smrg exit 1 544765eef222Smrg fi 544865eef222Smrg fi 5449ef981d24Smrg 545065eef222Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 545165eef222Smrg { $RM \"\$progdir/\$program\"; 545265eef222Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 545365eef222Smrg $RM \"\$progdir/\$file\" 545465eef222Smrg fi" 545565eef222Smrg else 545665eef222Smrg $ECHO "\ 545765eef222Smrg program='$outputname' 545865eef222Smrg progdir=\"\$thisdir/$objdir\" 545965eef222Smrg" 546065eef222Smrg fi 5461ef981d24Smrg 546265eef222Smrg $ECHO "\ 5463ef981d24Smrg 546465eef222Smrg if test -f \"\$progdir/\$program\"; then" 5465ef981d24Smrg 5466200d7199Smrg # fixup the dll searchpath if we need to. 5467200d7199Smrg # 5468200d7199Smrg # Fix the DLL searchpath if we need to. Do this before prepending 5469200d7199Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 5470200d7199Smrg # libraries must come first. 5471200d7199Smrg if test -n "$dllsearchpath"; then 5472200d7199Smrg $ECHO "\ 5473200d7199Smrg # Add the dll search path components to the executable PATH 5474200d7199Smrg PATH=$dllsearchpath:\$PATH 5475200d7199Smrg" 5476200d7199Smrg fi 5477200d7199Smrg 547865eef222Smrg # Export our shlibpath_var if we have one. 5479b312a94cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 548065eef222Smrg $ECHO "\ 548165eef222Smrg # Add our own library path to $shlibpath_var 548265eef222Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5483ef981d24Smrg 548465eef222Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 548565eef222Smrg # The second colon is a workaround for a bug in BeOS R4 sed 548656957a04Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5487ef981d24Smrg 548865eef222Smrg export $shlibpath_var 548965eef222Smrg" 5490ef981d24Smrg fi 5491ef981d24Smrg 549265eef222Smrg $ECHO "\ 549365eef222Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 549465eef222Smrg # Run the actual program with our arguments. 549556957a04Smrg func_exec_program \${1+\"\$@\"} 549665eef222Smrg fi 549765eef222Smrg else 549865eef222Smrg # The program doesn't exist. 5499b312a94cSmrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 550065eef222Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 550156957a04Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 550265eef222Smrg exit 1 550365eef222Smrg fi 550465eef222Smrgfi\ 550565eef222Smrg" 550665eef222Smrg} 5507ef981d24Smrg 5508ef981d24Smrg 550965eef222Smrg# func_emit_cwrapperexe_src 551065eef222Smrg# emit the source code for a wrapper executable on stdout 551165eef222Smrg# Must ONLY be called from within func_mode_link because 551265eef222Smrg# it depends on a number of variable set therein. 551365eef222Smrgfunc_emit_cwrapperexe_src () 551465eef222Smrg{ 551565eef222Smrg cat <<EOF 5516ef981d24Smrg 551765eef222Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5518b312a94cSmrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5519ef981d24Smrg 552065eef222Smrg The $output program cannot be directly executed until all the libtool 552165eef222Smrg libraries that it depends on are installed. 5522ef981d24Smrg 552365eef222Smrg This wrapper executable should never be moved out of the build directory. 552465eef222Smrg If it is, it will not operate correctly. 552565eef222Smrg*/ 552665eef222SmrgEOF 552765eef222Smrg cat <<"EOF" 552856957a04Smrg#ifdef _MSC_VER 552956957a04Smrg# define _CRT_SECURE_NO_DEPRECATE 1 553056957a04Smrg#endif 553165eef222Smrg#include <stdio.h> 553265eef222Smrg#include <stdlib.h> 553365eef222Smrg#ifdef _MSC_VER 553465eef222Smrg# include <direct.h> 553565eef222Smrg# include <process.h> 553665eef222Smrg# include <io.h> 553765eef222Smrg#else 553865eef222Smrg# include <unistd.h> 553965eef222Smrg# include <stdint.h> 554065eef222Smrg# ifdef __CYGWIN__ 554165eef222Smrg# include <io.h> 554265eef222Smrg# endif 554365eef222Smrg#endif 554465eef222Smrg#include <malloc.h> 554565eef222Smrg#include <stdarg.h> 554665eef222Smrg#include <assert.h> 554765eef222Smrg#include <string.h> 554865eef222Smrg#include <ctype.h> 554965eef222Smrg#include <errno.h> 555065eef222Smrg#include <fcntl.h> 555165eef222Smrg#include <sys/stat.h> 555265eef222Smrg 5553b312a94cSmrg#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5554b312a94cSmrg 555556957a04Smrg/* declarations of non-ANSI functions */ 5556b312a94cSmrg#if defined __MINGW32__ 555756957a04Smrg# ifdef __STRICT_ANSI__ 555856957a04Smrgint _putenv (const char *); 555956957a04Smrg# endif 5560b312a94cSmrg#elif defined __CYGWIN__ 556156957a04Smrg# ifdef __STRICT_ANSI__ 556256957a04Smrgchar *realpath (const char *, char *); 556356957a04Smrgint putenv (char *); 556456957a04Smrgint setenv (const char *, const char *, int); 556556957a04Smrg# endif 5566b312a94cSmrg/* #elif defined other_platform || defined ... */ 556756957a04Smrg#endif 556856957a04Smrg 556956957a04Smrg/* portability defines, excluding path handling macros */ 5570b312a94cSmrg#if defined _MSC_VER 557156957a04Smrg# define setmode _setmode 557256957a04Smrg# define stat _stat 557356957a04Smrg# define chmod _chmod 557456957a04Smrg# define getcwd _getcwd 557556957a04Smrg# define putenv _putenv 557656957a04Smrg# define S_IXUSR _S_IEXEC 5577b312a94cSmrg#elif defined __MINGW32__ 557856957a04Smrg# define setmode _setmode 557956957a04Smrg# define stat _stat 558056957a04Smrg# define chmod _chmod 558156957a04Smrg# define getcwd _getcwd 558256957a04Smrg# define putenv _putenv 5583b312a94cSmrg#elif defined __CYGWIN__ 558456957a04Smrg# define HAVE_SETENV 558556957a04Smrg# define FOPEN_WB "wb" 5586b312a94cSmrg/* #elif defined other platforms ... */ 558756957a04Smrg#endif 558856957a04Smrg 5589b312a94cSmrg#if defined PATH_MAX 559065eef222Smrg# define LT_PATHMAX PATH_MAX 5591b312a94cSmrg#elif defined MAXPATHLEN 559265eef222Smrg# define LT_PATHMAX MAXPATHLEN 559365eef222Smrg#else 559465eef222Smrg# define LT_PATHMAX 1024 559565eef222Smrg#endif 559665eef222Smrg 559765eef222Smrg#ifndef S_IXOTH 559865eef222Smrg# define S_IXOTH 0 559965eef222Smrg#endif 560065eef222Smrg#ifndef S_IXGRP 560165eef222Smrg# define S_IXGRP 0 560265eef222Smrg#endif 560365eef222Smrg 560456957a04Smrg/* path handling portability macros */ 560565eef222Smrg#ifndef DIR_SEPARATOR 560665eef222Smrg# define DIR_SEPARATOR '/' 560765eef222Smrg# define PATH_SEPARATOR ':' 560865eef222Smrg#endif 560965eef222Smrg 5610b312a94cSmrg#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5611b312a94cSmrg defined __OS2__ 561265eef222Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 561365eef222Smrg# define FOPEN_WB "wb" 561465eef222Smrg# ifndef DIR_SEPARATOR_2 561565eef222Smrg# define DIR_SEPARATOR_2 '\\' 561665eef222Smrg# endif 561765eef222Smrg# ifndef PATH_SEPARATOR_2 561865eef222Smrg# define PATH_SEPARATOR_2 ';' 561965eef222Smrg# endif 562065eef222Smrg#endif 562165eef222Smrg 562265eef222Smrg#ifndef DIR_SEPARATOR_2 562365eef222Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 562465eef222Smrg#else /* DIR_SEPARATOR_2 */ 562565eef222Smrg# define IS_DIR_SEPARATOR(ch) \ 562665eef222Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 562765eef222Smrg#endif /* DIR_SEPARATOR_2 */ 562865eef222Smrg 562965eef222Smrg#ifndef PATH_SEPARATOR_2 563065eef222Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 563165eef222Smrg#else /* PATH_SEPARATOR_2 */ 563265eef222Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 563365eef222Smrg#endif /* PATH_SEPARATOR_2 */ 563465eef222Smrg 563565eef222Smrg#ifndef FOPEN_WB 563665eef222Smrg# define FOPEN_WB "w" 563765eef222Smrg#endif 563865eef222Smrg#ifndef _O_BINARY 563965eef222Smrg# define _O_BINARY 0 564065eef222Smrg#endif 564165eef222Smrg 564265eef222Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 564365eef222Smrg#define XFREE(stale) do { \ 5644b312a94cSmrg if (stale) { free (stale); stale = 0; } \ 564565eef222Smrg} while (0) 564665eef222Smrg 5647b312a94cSmrg#if defined LT_DEBUGWRAPPER 564856957a04Smrgstatic int lt_debug = 1; 564965eef222Smrg#else 565056957a04Smrgstatic int lt_debug = 0; 565165eef222Smrg#endif 565265eef222Smrg 565356957a04Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 565465eef222Smrg 565565eef222Smrgvoid *xmalloc (size_t num); 565665eef222Smrgchar *xstrdup (const char *string); 565765eef222Smrgconst char *base_name (const char *name); 565865eef222Smrgchar *find_executable (const char *wrapper); 565965eef222Smrgchar *chase_symlinks (const char *pathspec); 566065eef222Smrgint make_executable (const char *path); 566165eef222Smrgint check_executable (const char *path); 566265eef222Smrgchar *strendzap (char *str, const char *pat); 566356957a04Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 566456957a04Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 566556957a04Smrgstatic const char *nonnull (const char *s); 566656957a04Smrgstatic const char *nonempty (const char *s); 566765eef222Smrgvoid lt_setenv (const char *name, const char *value); 566865eef222Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 566965eef222Smrgvoid lt_update_exe_path (const char *name, const char *value); 567065eef222Smrgvoid lt_update_lib_path (const char *name, const char *value); 567156957a04Smrgchar **prepare_spawn (char **argv); 567256957a04Smrgvoid lt_dump_script (FILE *f); 567365eef222SmrgEOF 567465eef222Smrg 567565eef222Smrg cat <<EOF 5676b312a94cSmrg#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5677b312a94cSmrg# define externally_visible volatile 5678b312a94cSmrg#else 5679b312a94cSmrg# define externally_visible __attribute__((externally_visible)) volatile 5680b312a94cSmrg#endif 5681b312a94cSmrgexternally_visible const char * MAGIC_EXE = "$magic_exe"; 568265eef222Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 568365eef222SmrgEOF 568465eef222Smrg 5685b312a94cSmrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5686200d7199Smrg func_to_host_path "$temp_rpath" 568765eef222Smrg cat <<EOF 5688200d7199Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5689ef981d24SmrgEOF 5690ef981d24Smrg else 569165eef222Smrg cat <<"EOF" 569265eef222Smrgconst char * LIB_PATH_VALUE = ""; 569365eef222SmrgEOF 5694ef981d24Smrg fi 569565eef222Smrg 569665eef222Smrg if test -n "$dllsearchpath"; then 5697200d7199Smrg func_to_host_path "$dllsearchpath:" 569865eef222Smrg cat <<EOF 569965eef222Smrgconst char * EXE_PATH_VARNAME = "PATH"; 5700200d7199Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 570165eef222SmrgEOF 5702ef981d24Smrg else 570365eef222Smrg cat <<"EOF" 570465eef222Smrgconst char * EXE_PATH_VARNAME = ""; 570565eef222Smrgconst char * EXE_PATH_VALUE = ""; 570665eef222SmrgEOF 5707ef981d24Smrg fi 570865eef222Smrg 5709b312a94cSmrg if test yes = "$fast_install"; then 571065eef222Smrg cat <<EOF 571165eef222Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 571265eef222SmrgEOF 5713ef981d24Smrg else 571465eef222Smrg cat <<EOF 571565eef222Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 571665eef222SmrgEOF 5717ef981d24Smrg fi 5718ef981d24Smrg 5719ef981d24Smrg 572065eef222Smrg cat <<"EOF" 5721ef981d24Smrg 572265eef222Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 5723ef981d24Smrg 572465eef222Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 572565eef222Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 572656957a04Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5727ef981d24Smrg 572865eef222Smrgint 572965eef222Smrgmain (int argc, char *argv[]) 573065eef222Smrg{ 573165eef222Smrg char **newargz; 573265eef222Smrg int newargc; 573365eef222Smrg char *tmp_pathspec; 573465eef222Smrg char *actual_cwrapper_path; 573565eef222Smrg char *actual_cwrapper_name; 573665eef222Smrg char *target_name; 573765eef222Smrg char *lt_argv_zero; 5738b312a94cSmrg int rval = 127; 5739ef981d24Smrg 574065eef222Smrg int i; 5741ef981d24Smrg 574265eef222Smrg program_name = (char *) xstrdup (base_name (argv[0])); 5743b312a94cSmrg newargz = XMALLOC (char *, (size_t) argc + 1); 5744ef981d24Smrg 574556957a04Smrg /* very simple arg parsing; don't want to rely on getopt 574656957a04Smrg * also, copy all non cwrapper options to newargz, except 574756957a04Smrg * argz[0], which is handled differently 574856957a04Smrg */ 574956957a04Smrg newargc=0; 575065eef222Smrg for (i = 1; i < argc; i++) 575165eef222Smrg { 5752b312a94cSmrg if (STREQ (argv[i], dumpscript_opt)) 575365eef222Smrg { 575465eef222SmrgEOF 5755b312a94cSmrg case $host in 575665eef222Smrg *mingw* | *cygwin* ) 575765eef222Smrg # make stdout use "unix" line endings 575865eef222Smrg echo " setmode(1,_O_BINARY);" 575965eef222Smrg ;; 576065eef222Smrg esac 5761ef981d24Smrg 576265eef222Smrg cat <<"EOF" 576356957a04Smrg lt_dump_script (stdout); 576465eef222Smrg return 0; 576565eef222Smrg } 5766b312a94cSmrg if (STREQ (argv[i], debug_opt)) 576756957a04Smrg { 576856957a04Smrg lt_debug = 1; 576956957a04Smrg continue; 577056957a04Smrg } 5771b312a94cSmrg if (STREQ (argv[i], ltwrapper_option_prefix)) 577256957a04Smrg { 577356957a04Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 577456957a04Smrg namespace, but it is not one of the ones we know about and 577556957a04Smrg have already dealt with, above (inluding dump-script), then 577656957a04Smrg report an error. Otherwise, targets might begin to believe 577756957a04Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 577856957a04Smrg namespace. The first time any user complains about this, we'll 577956957a04Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 578056957a04Smrg or a configure.ac-settable value. 578156957a04Smrg */ 578256957a04Smrg lt_fatal (__FILE__, __LINE__, 578356957a04Smrg "unrecognized %s option: '%s'", 578456957a04Smrg ltwrapper_option_prefix, argv[i]); 578556957a04Smrg } 578656957a04Smrg /* otherwise ... */ 578756957a04Smrg newargz[++newargc] = xstrdup (argv[i]); 578865eef222Smrg } 578956957a04Smrg newargz[++newargc] = NULL; 579056957a04Smrg 579156957a04SmrgEOF 579256957a04Smrg cat <<EOF 579356957a04Smrg /* The GNU banner must be the first non-error debug message */ 5794b312a94cSmrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 579556957a04SmrgEOF 579656957a04Smrg cat <<"EOF" 579756957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 579856957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 5799ef981d24Smrg 580065eef222Smrg tmp_pathspec = find_executable (argv[0]); 580165eef222Smrg if (tmp_pathspec == NULL) 580256957a04Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 580356957a04Smrg lt_debugprintf (__FILE__, __LINE__, 580456957a04Smrg "(main) found exe (before symlink chase) at: %s\n", 580556957a04Smrg tmp_pathspec); 580665eef222Smrg 580765eef222Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 580856957a04Smrg lt_debugprintf (__FILE__, __LINE__, 580956957a04Smrg "(main) found exe (after symlink chase) at: %s\n", 581056957a04Smrg actual_cwrapper_path); 581165eef222Smrg XFREE (tmp_pathspec); 581265eef222Smrg 581356957a04Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 581465eef222Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 581565eef222Smrg 581665eef222Smrg /* wrapper name transforms */ 581765eef222Smrg strendzap (actual_cwrapper_name, ".exe"); 581865eef222Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 581965eef222Smrg XFREE (actual_cwrapper_name); 582065eef222Smrg actual_cwrapper_name = tmp_pathspec; 582165eef222Smrg tmp_pathspec = 0; 582265eef222Smrg 582365eef222Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 582465eef222Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 582565eef222Smrg strendzap (target_name, ".exe"); 582665eef222Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 582765eef222Smrg XFREE (target_name); 582865eef222Smrg target_name = tmp_pathspec; 582965eef222Smrg tmp_pathspec = 0; 583065eef222Smrg 583156957a04Smrg lt_debugprintf (__FILE__, __LINE__, 583256957a04Smrg "(main) libtool target name: %s\n", 583356957a04Smrg target_name); 583465eef222SmrgEOF 5835ef981d24Smrg 583665eef222Smrg cat <<EOF 583765eef222Smrg newargz[0] = 583865eef222Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 583965eef222Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 584065eef222Smrg strcpy (newargz[0], actual_cwrapper_path); 584165eef222Smrg strcat (newargz[0], "$objdir"); 584265eef222Smrg strcat (newargz[0], "/"); 584365eef222SmrgEOF 5844ef981d24Smrg 584565eef222Smrg cat <<"EOF" 584665eef222Smrg /* stop here, and copy so we don't have to do this twice */ 584765eef222Smrg tmp_pathspec = xstrdup (newargz[0]); 5848ef981d24Smrg 584965eef222Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 585065eef222Smrg strcat (newargz[0], actual_cwrapper_name); 5851ef981d24Smrg 585265eef222Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 585365eef222Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 585465eef222Smrg XFREE (tmp_pathspec); 585565eef222Smrg tmp_pathspec = NULL; 585665eef222SmrgEOF 5857ef981d24Smrg 585865eef222Smrg case $host_os in 585965eef222Smrg mingw*) 586065eef222Smrg cat <<"EOF" 586165eef222Smrg { 586265eef222Smrg char* p; 586365eef222Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 586465eef222Smrg { 586565eef222Smrg *p = '/'; 586665eef222Smrg } 586765eef222Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 586865eef222Smrg { 586965eef222Smrg *p = '/'; 587065eef222Smrg } 587165eef222Smrg } 587265eef222SmrgEOF 587365eef222Smrg ;; 587465eef222Smrg esac 5875ef981d24Smrg 587665eef222Smrg cat <<"EOF" 587765eef222Smrg XFREE (target_name); 587865eef222Smrg XFREE (actual_cwrapper_path); 587965eef222Smrg XFREE (actual_cwrapper_name); 5880ef981d24Smrg 588165eef222Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 588265eef222Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 5883200d7199Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 5884200d7199Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 5885200d7199Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 5886200d7199Smrg libraries must come first. */ 588765eef222Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 5888200d7199Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 5889ef981d24Smrg 589056957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 589156957a04Smrg nonnull (lt_argv_zero)); 589265eef222Smrg for (i = 0; i < newargc; i++) 589365eef222Smrg { 589456957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 589556957a04Smrg i, nonnull (newargz[i])); 589665eef222Smrg } 5897ef981d24Smrg 589865eef222SmrgEOF 5899ef981d24Smrg 590065eef222Smrg case $host_os in 590165eef222Smrg mingw*) 590265eef222Smrg cat <<"EOF" 590365eef222Smrg /* execv doesn't actually work on mingw as expected on unix */ 590456957a04Smrg newargz = prepare_spawn (newargz); 5905b312a94cSmrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 590665eef222Smrg if (rval == -1) 590765eef222Smrg { 590865eef222Smrg /* failed to start process */ 590956957a04Smrg lt_debugprintf (__FILE__, __LINE__, 591056957a04Smrg "(main) failed to launch target \"%s\": %s\n", 591156957a04Smrg lt_argv_zero, nonnull (strerror (errno))); 591265eef222Smrg return 127; 591365eef222Smrg } 591465eef222Smrg return rval; 591565eef222SmrgEOF 591665eef222Smrg ;; 591765eef222Smrg *) 591865eef222Smrg cat <<"EOF" 591965eef222Smrg execv (lt_argv_zero, newargz); 592065eef222Smrg return rval; /* =127, but avoids unused variable warning */ 592165eef222SmrgEOF 592265eef222Smrg ;; 592365eef222Smrg esac 5924ef981d24Smrg 592565eef222Smrg cat <<"EOF" 592665eef222Smrg} 5927ef981d24Smrg 592865eef222Smrgvoid * 592965eef222Smrgxmalloc (size_t num) 593065eef222Smrg{ 593165eef222Smrg void *p = (void *) malloc (num); 593265eef222Smrg if (!p) 593356957a04Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 5934ef981d24Smrg 593565eef222Smrg return p; 593665eef222Smrg} 5937ef981d24Smrg 593865eef222Smrgchar * 593965eef222Smrgxstrdup (const char *string) 594065eef222Smrg{ 594165eef222Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 594265eef222Smrg string) : NULL; 594365eef222Smrg} 5944ef981d24Smrg 594565eef222Smrgconst char * 594665eef222Smrgbase_name (const char *name) 594765eef222Smrg{ 594865eef222Smrg const char *base; 5949ef981d24Smrg 5950b312a94cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 595165eef222Smrg /* Skip over the disk name in MSDOS pathnames. */ 595265eef222Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 595365eef222Smrg name += 2; 595465eef222Smrg#endif 5955ef981d24Smrg 595665eef222Smrg for (base = name; *name; name++) 595765eef222Smrg if (IS_DIR_SEPARATOR (*name)) 595865eef222Smrg base = name + 1; 595965eef222Smrg return base; 596065eef222Smrg} 5961ef981d24Smrg 596265eef222Smrgint 596365eef222Smrgcheck_executable (const char *path) 596465eef222Smrg{ 596565eef222Smrg struct stat st; 5966ef981d24Smrg 596756957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 596856957a04Smrg nonempty (path)); 596965eef222Smrg if ((!path) || (!*path)) 597065eef222Smrg return 0; 5971ef981d24Smrg 597265eef222Smrg if ((stat (path, &st) >= 0) 597365eef222Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 597465eef222Smrg return 1; 597565eef222Smrg else 597665eef222Smrg return 0; 597765eef222Smrg} 5978ef981d24Smrg 597965eef222Smrgint 598065eef222Smrgmake_executable (const char *path) 598165eef222Smrg{ 598265eef222Smrg int rval = 0; 598365eef222Smrg struct stat st; 5984ef981d24Smrg 598556957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 598656957a04Smrg nonempty (path)); 598765eef222Smrg if ((!path) || (!*path)) 598865eef222Smrg return 0; 5989ef981d24Smrg 599065eef222Smrg if (stat (path, &st) >= 0) 599165eef222Smrg { 599265eef222Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 599365eef222Smrg } 599465eef222Smrg return rval; 599565eef222Smrg} 5996ef981d24Smrg 599765eef222Smrg/* Searches for the full path of the wrapper. Returns 599865eef222Smrg newly allocated full path name if found, NULL otherwise 599965eef222Smrg Does not chase symlinks, even on platforms that support them. 600065eef222Smrg*/ 600165eef222Smrgchar * 600265eef222Smrgfind_executable (const char *wrapper) 600365eef222Smrg{ 600465eef222Smrg int has_slash = 0; 600565eef222Smrg const char *p; 600665eef222Smrg const char *p_next; 600765eef222Smrg /* static buffer for getcwd */ 600865eef222Smrg char tmp[LT_PATHMAX + 1]; 6009b312a94cSmrg size_t tmp_len; 601065eef222Smrg char *concat_name; 6011ef981d24Smrg 601256957a04Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 601356957a04Smrg nonempty (wrapper)); 6014ef981d24Smrg 601565eef222Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 601665eef222Smrg return NULL; 6017ef981d24Smrg 601865eef222Smrg /* Absolute path? */ 6019b312a94cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 602065eef222Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 602165eef222Smrg { 602265eef222Smrg concat_name = xstrdup (wrapper); 602365eef222Smrg if (check_executable (concat_name)) 602465eef222Smrg return concat_name; 602565eef222Smrg XFREE (concat_name); 602665eef222Smrg } 602765eef222Smrg else 602865eef222Smrg { 602965eef222Smrg#endif 603065eef222Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 603165eef222Smrg { 603265eef222Smrg concat_name = xstrdup (wrapper); 603365eef222Smrg if (check_executable (concat_name)) 603465eef222Smrg return concat_name; 603565eef222Smrg XFREE (concat_name); 603665eef222Smrg } 6037b312a94cSmrg#if defined HAVE_DOS_BASED_FILE_SYSTEM 603865eef222Smrg } 603965eef222Smrg#endif 6040ef981d24Smrg 604165eef222Smrg for (p = wrapper; *p; p++) 604265eef222Smrg if (*p == '/') 604365eef222Smrg { 604465eef222Smrg has_slash = 1; 604565eef222Smrg break; 604665eef222Smrg } 604765eef222Smrg if (!has_slash) 604865eef222Smrg { 604965eef222Smrg /* no slashes; search PATH */ 605065eef222Smrg const char *path = getenv ("PATH"); 605165eef222Smrg if (path != NULL) 605265eef222Smrg { 605365eef222Smrg for (p = path; *p; p = p_next) 605465eef222Smrg { 605565eef222Smrg const char *q; 605665eef222Smrg size_t p_len; 605765eef222Smrg for (q = p; *q; q++) 605865eef222Smrg if (IS_PATH_SEPARATOR (*q)) 605965eef222Smrg break; 6060b312a94cSmrg p_len = (size_t) (q - p); 606165eef222Smrg p_next = (*q == '\0' ? q : q + 1); 606265eef222Smrg if (p_len == 0) 606365eef222Smrg { 606465eef222Smrg /* empty path: current directory */ 606565eef222Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 606656957a04Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 606756957a04Smrg nonnull (strerror (errno))); 606865eef222Smrg tmp_len = strlen (tmp); 606965eef222Smrg concat_name = 607065eef222Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 607165eef222Smrg memcpy (concat_name, tmp, tmp_len); 607265eef222Smrg concat_name[tmp_len] = '/'; 607365eef222Smrg strcpy (concat_name + tmp_len + 1, wrapper); 607465eef222Smrg } 607565eef222Smrg else 607665eef222Smrg { 607765eef222Smrg concat_name = 607865eef222Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 607965eef222Smrg memcpy (concat_name, p, p_len); 608065eef222Smrg concat_name[p_len] = '/'; 608165eef222Smrg strcpy (concat_name + p_len + 1, wrapper); 608265eef222Smrg } 608365eef222Smrg if (check_executable (concat_name)) 608465eef222Smrg return concat_name; 608565eef222Smrg XFREE (concat_name); 608665eef222Smrg } 608765eef222Smrg } 608865eef222Smrg /* not found in PATH; assume curdir */ 608965eef222Smrg } 609065eef222Smrg /* Relative path | not found in path: prepend cwd */ 609165eef222Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 609256957a04Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 609356957a04Smrg nonnull (strerror (errno))); 609465eef222Smrg tmp_len = strlen (tmp); 609565eef222Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 609665eef222Smrg memcpy (concat_name, tmp, tmp_len); 609765eef222Smrg concat_name[tmp_len] = '/'; 609865eef222Smrg strcpy (concat_name + tmp_len + 1, wrapper); 6099ef981d24Smrg 610065eef222Smrg if (check_executable (concat_name)) 610165eef222Smrg return concat_name; 610265eef222Smrg XFREE (concat_name); 610365eef222Smrg return NULL; 610465eef222Smrg} 6105ef981d24Smrg 610665eef222Smrgchar * 610765eef222Smrgchase_symlinks (const char *pathspec) 610865eef222Smrg{ 610965eef222Smrg#ifndef S_ISLNK 611065eef222Smrg return xstrdup (pathspec); 611165eef222Smrg#else 611265eef222Smrg char buf[LT_PATHMAX]; 611365eef222Smrg struct stat s; 611465eef222Smrg char *tmp_pathspec = xstrdup (pathspec); 611565eef222Smrg char *p; 611665eef222Smrg int has_symlinks = 0; 611765eef222Smrg while (strlen (tmp_pathspec) && !has_symlinks) 611865eef222Smrg { 611956957a04Smrg lt_debugprintf (__FILE__, __LINE__, 612056957a04Smrg "checking path component for symlinks: %s\n", 612156957a04Smrg tmp_pathspec); 612265eef222Smrg if (lstat (tmp_pathspec, &s) == 0) 612365eef222Smrg { 612465eef222Smrg if (S_ISLNK (s.st_mode) != 0) 612565eef222Smrg { 612665eef222Smrg has_symlinks = 1; 612765eef222Smrg break; 612865eef222Smrg } 6129ef981d24Smrg 613065eef222Smrg /* search backwards for last DIR_SEPARATOR */ 613165eef222Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 613265eef222Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 613365eef222Smrg p--; 613465eef222Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 613565eef222Smrg { 613665eef222Smrg /* no more DIR_SEPARATORS left */ 613765eef222Smrg break; 613865eef222Smrg } 613965eef222Smrg *p = '\0'; 614065eef222Smrg } 614165eef222Smrg else 614265eef222Smrg { 614356957a04Smrg lt_fatal (__FILE__, __LINE__, 614456957a04Smrg "error accessing file \"%s\": %s", 614556957a04Smrg tmp_pathspec, nonnull (strerror (errno))); 614665eef222Smrg } 614765eef222Smrg } 614865eef222Smrg XFREE (tmp_pathspec); 6149ef981d24Smrg 615065eef222Smrg if (!has_symlinks) 615165eef222Smrg { 615265eef222Smrg return xstrdup (pathspec); 615365eef222Smrg } 6154ef981d24Smrg 615565eef222Smrg tmp_pathspec = realpath (pathspec, buf); 615665eef222Smrg if (tmp_pathspec == 0) 615765eef222Smrg { 615856957a04Smrg lt_fatal (__FILE__, __LINE__, 615956957a04Smrg "could not follow symlinks for %s", pathspec); 616065eef222Smrg } 616165eef222Smrg return xstrdup (tmp_pathspec); 616265eef222Smrg#endif 616365eef222Smrg} 6164ef981d24Smrg 616565eef222Smrgchar * 616665eef222Smrgstrendzap (char *str, const char *pat) 616765eef222Smrg{ 616865eef222Smrg size_t len, patlen; 6169ef981d24Smrg 617065eef222Smrg assert (str != NULL); 617165eef222Smrg assert (pat != NULL); 6172ef981d24Smrg 617365eef222Smrg len = strlen (str); 617465eef222Smrg patlen = strlen (pat); 6175ef981d24Smrg 617665eef222Smrg if (patlen <= len) 617765eef222Smrg { 617865eef222Smrg str += len - patlen; 6179b312a94cSmrg if (STREQ (str, pat)) 618065eef222Smrg *str = '\0'; 618165eef222Smrg } 618265eef222Smrg return str; 618365eef222Smrg} 6184ef981d24Smrg 618556957a04Smrgvoid 618656957a04Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 618756957a04Smrg{ 618856957a04Smrg va_list args; 618956957a04Smrg if (lt_debug) 619056957a04Smrg { 619156957a04Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 619256957a04Smrg va_start (args, fmt); 619356957a04Smrg (void) vfprintf (stderr, fmt, args); 619456957a04Smrg va_end (args); 619556957a04Smrg } 619656957a04Smrg} 619756957a04Smrg 619865eef222Smrgstatic void 619956957a04Smrglt_error_core (int exit_status, const char *file, 620056957a04Smrg int line, const char *mode, 620165eef222Smrg const char *message, va_list ap) 620265eef222Smrg{ 620356957a04Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 620465eef222Smrg vfprintf (stderr, message, ap); 620565eef222Smrg fprintf (stderr, ".\n"); 6206ef981d24Smrg 620765eef222Smrg if (exit_status >= 0) 620865eef222Smrg exit (exit_status); 620965eef222Smrg} 6210ef981d24Smrg 621165eef222Smrgvoid 621256957a04Smrglt_fatal (const char *file, int line, const char *message, ...) 621365eef222Smrg{ 621465eef222Smrg va_list ap; 621565eef222Smrg va_start (ap, message); 621656957a04Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 621765eef222Smrg va_end (ap); 621865eef222Smrg} 6219ef981d24Smrg 622056957a04Smrgstatic const char * 622156957a04Smrgnonnull (const char *s) 622256957a04Smrg{ 622356957a04Smrg return s ? s : "(null)"; 622456957a04Smrg} 622556957a04Smrg 622656957a04Smrgstatic const char * 622756957a04Smrgnonempty (const char *s) 622856957a04Smrg{ 622956957a04Smrg return (s && !*s) ? "(empty)" : nonnull (s); 623056957a04Smrg} 623156957a04Smrg 623265eef222Smrgvoid 623365eef222Smrglt_setenv (const char *name, const char *value) 623465eef222Smrg{ 623556957a04Smrg lt_debugprintf (__FILE__, __LINE__, 623656957a04Smrg "(lt_setenv) setting '%s' to '%s'\n", 623756957a04Smrg nonnull (name), nonnull (value)); 623865eef222Smrg { 623965eef222Smrg#ifdef HAVE_SETENV 624065eef222Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 624165eef222Smrg char *str = xstrdup (value); 624265eef222Smrg setenv (name, str, 1); 624365eef222Smrg#else 6244b312a94cSmrg size_t len = strlen (name) + 1 + strlen (value) + 1; 624565eef222Smrg char *str = XMALLOC (char, len); 624665eef222Smrg sprintf (str, "%s=%s", name, value); 624765eef222Smrg if (putenv (str) != EXIT_SUCCESS) 624865eef222Smrg { 624965eef222Smrg XFREE (str); 625065eef222Smrg } 625165eef222Smrg#endif 625265eef222Smrg } 625365eef222Smrg} 6254ef981d24Smrg 625565eef222Smrgchar * 625665eef222Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 625765eef222Smrg{ 625865eef222Smrg char *new_value; 625965eef222Smrg if (orig_value && *orig_value) 626065eef222Smrg { 6261b312a94cSmrg size_t orig_value_len = strlen (orig_value); 6262b312a94cSmrg size_t add_len = strlen (add); 626365eef222Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 626465eef222Smrg if (to_end) 626565eef222Smrg { 626665eef222Smrg strcpy (new_value, orig_value); 626765eef222Smrg strcpy (new_value + orig_value_len, add); 626865eef222Smrg } 626965eef222Smrg else 627065eef222Smrg { 627165eef222Smrg strcpy (new_value, add); 627265eef222Smrg strcpy (new_value + add_len, orig_value); 627365eef222Smrg } 627465eef222Smrg } 627565eef222Smrg else 627665eef222Smrg { 627765eef222Smrg new_value = xstrdup (add); 627865eef222Smrg } 627965eef222Smrg return new_value; 628065eef222Smrg} 6281ef981d24Smrg 628265eef222Smrgvoid 628365eef222Smrglt_update_exe_path (const char *name, const char *value) 628465eef222Smrg{ 628556957a04Smrg lt_debugprintf (__FILE__, __LINE__, 628656957a04Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 628756957a04Smrg nonnull (name), nonnull (value)); 6288ef981d24Smrg 628965eef222Smrg if (name && *name && value && *value) 629065eef222Smrg { 629165eef222Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 629265eef222Smrg /* some systems can't cope with a ':'-terminated path #' */ 6293b312a94cSmrg size_t len = strlen (new_value); 6294b312a94cSmrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 629565eef222Smrg { 6296b312a94cSmrg new_value[--len] = '\0'; 629765eef222Smrg } 629865eef222Smrg lt_setenv (name, new_value); 629965eef222Smrg XFREE (new_value); 630065eef222Smrg } 630165eef222Smrg} 6302ef981d24Smrg 630365eef222Smrgvoid 630465eef222Smrglt_update_lib_path (const char *name, const char *value) 630565eef222Smrg{ 630656957a04Smrg lt_debugprintf (__FILE__, __LINE__, 630756957a04Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 630856957a04Smrg nonnull (name), nonnull (value)); 6309ef981d24Smrg 631065eef222Smrg if (name && *name && value && *value) 631165eef222Smrg { 631265eef222Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 631365eef222Smrg lt_setenv (name, new_value); 631465eef222Smrg XFREE (new_value); 631565eef222Smrg } 631665eef222Smrg} 6317ef981d24Smrg 631856957a04SmrgEOF 631956957a04Smrg case $host_os in 632056957a04Smrg mingw*) 632156957a04Smrg cat <<"EOF" 632256957a04Smrg 632356957a04Smrg/* Prepares an argument vector before calling spawn(). 632456957a04Smrg Note that spawn() does not by itself call the command interpreter 632556957a04Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 632656957a04Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 632756957a04Smrg GetVersionEx(&v); 632856957a04Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 632956957a04Smrg }) ? "cmd.exe" : "command.com"). 633056957a04Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 633156957a04Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 633256957a04Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 633356957a04Smrg special way: 633456957a04Smrg - Space and tab are interpreted as delimiters. They are not treated as 633556957a04Smrg delimiters if they are surrounded by double quotes: "...". 633656957a04Smrg - Unescaped double quotes are removed from the input. Their only effect is 633756957a04Smrg that within double quotes, space and tab are treated like normal 633856957a04Smrg characters. 633956957a04Smrg - Backslashes not followed by double quotes are not special. 634056957a04Smrg - But 2*n+1 backslashes followed by a double quote become 634156957a04Smrg n backslashes followed by a double quote (n >= 0): 634256957a04Smrg \" -> " 634356957a04Smrg \\\" -> \" 634456957a04Smrg \\\\\" -> \\" 634556957a04Smrg */ 634656957a04Smrg#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" 634756957a04Smrg#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" 634856957a04Smrgchar ** 634956957a04Smrgprepare_spawn (char **argv) 635056957a04Smrg{ 635156957a04Smrg size_t argc; 635256957a04Smrg char **new_argv; 635356957a04Smrg size_t i; 635456957a04Smrg 635556957a04Smrg /* Count number of arguments. */ 635656957a04Smrg for (argc = 0; argv[argc] != NULL; argc++) 635756957a04Smrg ; 635856957a04Smrg 635956957a04Smrg /* Allocate new argument vector. */ 636056957a04Smrg new_argv = XMALLOC (char *, argc + 1); 636156957a04Smrg 636256957a04Smrg /* Put quoted arguments into the new argument vector. */ 636356957a04Smrg for (i = 0; i < argc; i++) 636456957a04Smrg { 636556957a04Smrg const char *string = argv[i]; 636656957a04Smrg 636756957a04Smrg if (string[0] == '\0') 636856957a04Smrg new_argv[i] = xstrdup ("\"\""); 636956957a04Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 637056957a04Smrg { 637156957a04Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 637256957a04Smrg size_t length; 637356957a04Smrg unsigned int backslashes; 637456957a04Smrg const char *s; 637556957a04Smrg char *quoted_string; 637656957a04Smrg char *p; 637756957a04Smrg 637856957a04Smrg length = 0; 637956957a04Smrg backslashes = 0; 638056957a04Smrg if (quote_around) 638156957a04Smrg length++; 638256957a04Smrg for (s = string; *s != '\0'; s++) 638356957a04Smrg { 638456957a04Smrg char c = *s; 638556957a04Smrg if (c == '"') 638656957a04Smrg length += backslashes + 1; 638756957a04Smrg length++; 638856957a04Smrg if (c == '\\') 638956957a04Smrg backslashes++; 639056957a04Smrg else 639156957a04Smrg backslashes = 0; 639256957a04Smrg } 639356957a04Smrg if (quote_around) 639456957a04Smrg length += backslashes + 1; 639556957a04Smrg 639656957a04Smrg quoted_string = XMALLOC (char, length + 1); 639756957a04Smrg 639856957a04Smrg p = quoted_string; 639956957a04Smrg backslashes = 0; 640056957a04Smrg if (quote_around) 640156957a04Smrg *p++ = '"'; 640256957a04Smrg for (s = string; *s != '\0'; s++) 640356957a04Smrg { 640456957a04Smrg char c = *s; 640556957a04Smrg if (c == '"') 640656957a04Smrg { 640756957a04Smrg unsigned int j; 640856957a04Smrg for (j = backslashes + 1; j > 0; j--) 640956957a04Smrg *p++ = '\\'; 641056957a04Smrg } 641156957a04Smrg *p++ = c; 641256957a04Smrg if (c == '\\') 641356957a04Smrg backslashes++; 641456957a04Smrg else 641556957a04Smrg backslashes = 0; 641656957a04Smrg } 641756957a04Smrg if (quote_around) 641856957a04Smrg { 641956957a04Smrg unsigned int j; 642056957a04Smrg for (j = backslashes; j > 0; j--) 642156957a04Smrg *p++ = '\\'; 642256957a04Smrg *p++ = '"'; 642356957a04Smrg } 642456957a04Smrg *p = '\0'; 642556957a04Smrg 642656957a04Smrg new_argv[i] = quoted_string; 642756957a04Smrg } 642856957a04Smrg else 642956957a04Smrg new_argv[i] = (char *) string; 643056957a04Smrg } 643156957a04Smrg new_argv[argc] = NULL; 643256957a04Smrg 643356957a04Smrg return new_argv; 643456957a04Smrg} 643556957a04SmrgEOF 643656957a04Smrg ;; 643756957a04Smrg esac 643856957a04Smrg 643956957a04Smrg cat <<"EOF" 644056957a04Smrgvoid lt_dump_script (FILE* f) 644156957a04Smrg{ 644256957a04SmrgEOF 644356957a04Smrg func_emit_wrapper yes | 6444b312a94cSmrg $SED -n -e ' 6445b312a94cSmrgs/^\(.\{79\}\)\(..*\)/\1\ 6446b312a94cSmrg\2/ 6447b312a94cSmrgh 6448b312a94cSmrgs/\([\\"]\)/\\\1/g 6449b312a94cSmrgs/$/\\n/ 6450b312a94cSmrgs/\([^\n]*\).*/ fputs ("\1", f);/p 6451b312a94cSmrgg 6452b312a94cSmrgD' 645356957a04Smrg cat <<"EOF" 645456957a04Smrg} 645565eef222SmrgEOF 645665eef222Smrg} 645765eef222Smrg# end: func_emit_cwrapperexe_src 6458ef981d24Smrg 645956957a04Smrg# func_win32_import_lib_p ARG 646056957a04Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 646156957a04Smrgfunc_win32_import_lib_p () 646256957a04Smrg{ 6463b312a94cSmrg $debug_cmd 6464b312a94cSmrg 646556957a04Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 646656957a04Smrg *import*) : ;; 646756957a04Smrg *) false ;; 646856957a04Smrg esac 646956957a04Smrg} 647056957a04Smrg 6471b312a94cSmrg# func_suncc_cstd_abi 6472b312a94cSmrg# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6473b312a94cSmrg# Several compiler flags select an ABI that is incompatible with the 6474b312a94cSmrg# Cstd library. Avoid specifying it if any are in CXXFLAGS. 6475b312a94cSmrgfunc_suncc_cstd_abi () 6476b312a94cSmrg{ 6477b312a94cSmrg $debug_cmd 6478b312a94cSmrg 6479b312a94cSmrg case " $compile_command " in 6480b312a94cSmrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6481b312a94cSmrg suncc_use_cstd_abi=no 6482b312a94cSmrg ;; 6483b312a94cSmrg *) 6484b312a94cSmrg suncc_use_cstd_abi=yes 6485b312a94cSmrg ;; 6486b312a94cSmrg esac 6487b312a94cSmrg} 6488b312a94cSmrg 648965eef222Smrg# func_mode_link arg... 649065eef222Smrgfunc_mode_link () 649165eef222Smrg{ 6492b312a94cSmrg $debug_cmd 6493b312a94cSmrg 649465eef222Smrg case $host in 649565eef222Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 649665eef222Smrg # It is impossible to link a dll without this setting, and 649765eef222Smrg # we shouldn't force the makefile maintainer to figure out 6498b312a94cSmrg # what system we are compiling for in order to pass an extra 649965eef222Smrg # flag for every libtool invocation. 650065eef222Smrg # allow_undefined=no 6501ef981d24Smrg 650265eef222Smrg # FIXME: Unfortunately, there are problems with the above when trying 6503b312a94cSmrg # to make a dll that has undefined symbols, in which case not 650465eef222Smrg # even a static library is built. For now, we need to specify 650565eef222Smrg # -no-undefined on the libtool link line when we can be certain 650665eef222Smrg # that all symbols are satisfied, otherwise we get a static library. 650765eef222Smrg allow_undefined=yes 650865eef222Smrg ;; 650965eef222Smrg *) 651065eef222Smrg allow_undefined=yes 651165eef222Smrg ;; 651265eef222Smrg esac 651365eef222Smrg libtool_args=$nonopt 651465eef222Smrg base_compile="$nonopt $@" 651565eef222Smrg compile_command=$nonopt 651665eef222Smrg finalize_command=$nonopt 6517ef981d24Smrg 651865eef222Smrg compile_rpath= 651965eef222Smrg finalize_rpath= 652065eef222Smrg compile_shlibpath= 652165eef222Smrg finalize_shlibpath= 652265eef222Smrg convenience= 652365eef222Smrg old_convenience= 652465eef222Smrg deplibs= 652565eef222Smrg old_deplibs= 652665eef222Smrg compiler_flags= 652765eef222Smrg linker_flags= 652865eef222Smrg dllsearchpath= 652965eef222Smrg lib_search_path=`pwd` 653065eef222Smrg inst_prefix_dir= 653165eef222Smrg new_inherited_linker_flags= 6532ef981d24Smrg 653365eef222Smrg avoid_version=no 653456957a04Smrg bindir= 653565eef222Smrg dlfiles= 653665eef222Smrg dlprefiles= 653765eef222Smrg dlself=no 653865eef222Smrg export_dynamic=no 653965eef222Smrg export_symbols= 654065eef222Smrg export_symbols_regex= 654165eef222Smrg generated= 654265eef222Smrg libobjs= 654365eef222Smrg ltlibs= 654465eef222Smrg module=no 654565eef222Smrg no_install=no 654665eef222Smrg objs= 6547b312a94cSmrg os2dllname= 654865eef222Smrg non_pic_objects= 654965eef222Smrg precious_files_regex= 655065eef222Smrg prefer_static_libs=no 6551b312a94cSmrg preload=false 655265eef222Smrg prev= 655365eef222Smrg prevarg= 655465eef222Smrg release= 655565eef222Smrg rpath= 655665eef222Smrg xrpath= 655765eef222Smrg perm_rpath= 655865eef222Smrg temp_rpath= 655965eef222Smrg thread_safe=no 656065eef222Smrg vinfo= 656165eef222Smrg vinfo_number=no 656265eef222Smrg weak_libs= 6563b312a94cSmrg single_module=$wl-single_module 656465eef222Smrg func_infer_tag $base_compile 6565ef981d24Smrg 656665eef222Smrg # We need to know -static, to get the right output filenames. 656765eef222Smrg for arg 656865eef222Smrg do 656965eef222Smrg case $arg in 657065eef222Smrg -shared) 6571b312a94cSmrg test yes != "$build_libtool_libs" \ 6572b312a94cSmrg && func_fatal_configuration "cannot build a shared library" 657365eef222Smrg build_old_libs=no 657465eef222Smrg break 657565eef222Smrg ;; 657665eef222Smrg -all-static | -static | -static-libtool-libs) 657765eef222Smrg case $arg in 657865eef222Smrg -all-static) 6579b312a94cSmrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 658065eef222Smrg func_warning "complete static linking is impossible in this configuration" 6581ef981d24Smrg fi 658265eef222Smrg if test -n "$link_static_flag"; then 658365eef222Smrg dlopen_self=$dlopen_self_static 6584ef981d24Smrg fi 658565eef222Smrg prefer_static_libs=yes 6586ef981d24Smrg ;; 658765eef222Smrg -static) 658865eef222Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 658965eef222Smrg dlopen_self=$dlopen_self_static 659065eef222Smrg fi 659165eef222Smrg prefer_static_libs=built 659265eef222Smrg ;; 659365eef222Smrg -static-libtool-libs) 659465eef222Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 659565eef222Smrg dlopen_self=$dlopen_self_static 659665eef222Smrg fi 659765eef222Smrg prefer_static_libs=yes 6598ef981d24Smrg ;; 6599ef981d24Smrg esac 660065eef222Smrg build_libtool_libs=no 660165eef222Smrg build_old_libs=yes 660265eef222Smrg break 660365eef222Smrg ;; 660465eef222Smrg esac 660565eef222Smrg done 6606ef981d24Smrg 660765eef222Smrg # See if our shared archives depend on static archives. 660865eef222Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6609ef981d24Smrg 661065eef222Smrg # Go through the arguments, transforming them on the way. 661165eef222Smrg while test "$#" -gt 0; do 6612b312a94cSmrg arg=$1 661365eef222Smrg shift 661465eef222Smrg func_quote_for_eval "$arg" 661565eef222Smrg qarg=$func_quote_for_eval_unquoted_result 661665eef222Smrg func_append libtool_args " $func_quote_for_eval_result" 6617ef981d24Smrg 661865eef222Smrg # If the previous option needs an argument, assign it. 661965eef222Smrg if test -n "$prev"; then 662065eef222Smrg case $prev in 662165eef222Smrg output) 662265eef222Smrg func_append compile_command " @OUTPUT@" 662365eef222Smrg func_append finalize_command " @OUTPUT@" 662465eef222Smrg ;; 662565eef222Smrg esac 6626ef981d24Smrg 662765eef222Smrg case $prev in 662856957a04Smrg bindir) 6629b312a94cSmrg bindir=$arg 663056957a04Smrg prev= 663156957a04Smrg continue 663256957a04Smrg ;; 663365eef222Smrg dlfiles|dlprefiles) 6634b312a94cSmrg $preload || { 663565eef222Smrg # Add the symbol object into the linking commands. 663665eef222Smrg func_append compile_command " @SYMFILE@" 663765eef222Smrg func_append finalize_command " @SYMFILE@" 6638b312a94cSmrg preload=: 6639b312a94cSmrg } 664065eef222Smrg case $arg in 664165eef222Smrg *.la | *.lo) ;; # We handle these cases below. 664265eef222Smrg force) 6643b312a94cSmrg if test no = "$dlself"; then 664465eef222Smrg dlself=needless 664565eef222Smrg export_dynamic=yes 664665eef222Smrg fi 664765eef222Smrg prev= 664865eef222Smrg continue 664965eef222Smrg ;; 665065eef222Smrg self) 6651b312a94cSmrg if test dlprefiles = "$prev"; then 665265eef222Smrg dlself=yes 6653b312a94cSmrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 665465eef222Smrg dlself=yes 665565eef222Smrg else 665665eef222Smrg dlself=needless 665765eef222Smrg export_dynamic=yes 665865eef222Smrg fi 665965eef222Smrg prev= 666065eef222Smrg continue 6661ef981d24Smrg ;; 6662ef981d24Smrg *) 6663b312a94cSmrg if test dlfiles = "$prev"; then 6664200d7199Smrg func_append dlfiles " $arg" 666565eef222Smrg else 6666200d7199Smrg func_append dlprefiles " $arg" 666765eef222Smrg fi 666865eef222Smrg prev= 666965eef222Smrg continue 6670ef981d24Smrg ;; 6671ef981d24Smrg esac 667265eef222Smrg ;; 667365eef222Smrg expsyms) 6674b312a94cSmrg export_symbols=$arg 667565eef222Smrg test -f "$arg" \ 6676b312a94cSmrg || func_fatal_error "symbol file '$arg' does not exist" 667765eef222Smrg prev= 667865eef222Smrg continue 667965eef222Smrg ;; 668065eef222Smrg expsyms_regex) 6681b312a94cSmrg export_symbols_regex=$arg 668265eef222Smrg prev= 668365eef222Smrg continue 668465eef222Smrg ;; 668565eef222Smrg framework) 668665eef222Smrg case $host in 668765eef222Smrg *-*-darwin*) 668865eef222Smrg case "$deplibs " in 668965eef222Smrg *" $qarg.ltframework "*) ;; 6690200d7199Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 669165eef222Smrg ;; 669265eef222Smrg esac 669365eef222Smrg ;; 669465eef222Smrg esac 669565eef222Smrg prev= 669665eef222Smrg continue 669765eef222Smrg ;; 669865eef222Smrg inst_prefix) 6699b312a94cSmrg inst_prefix_dir=$arg 6700b312a94cSmrg prev= 6701b312a94cSmrg continue 6702b312a94cSmrg ;; 6703b312a94cSmrg mllvm) 6704b312a94cSmrg # Clang does not use LLVM to link, so we can simply discard any 6705b312a94cSmrg # '-mllvm $arg' options when doing the link step. 670665eef222Smrg prev= 670765eef222Smrg continue 670865eef222Smrg ;; 670965eef222Smrg objectlist) 671065eef222Smrg if test -f "$arg"; then 671165eef222Smrg save_arg=$arg 671265eef222Smrg moreargs= 671365eef222Smrg for fil in `cat "$save_arg"` 671465eef222Smrg do 6715200d7199Smrg# func_append moreargs " $fil" 671665eef222Smrg arg=$fil 671765eef222Smrg # A libtool-controlled object. 6718ef981d24Smrg 671965eef222Smrg # Check to see that this really is a libtool object. 672065eef222Smrg if func_lalib_unsafe_p "$arg"; then 672165eef222Smrg pic_object= 672265eef222Smrg non_pic_object= 6723ef981d24Smrg 672465eef222Smrg # Read the .lo file 672565eef222Smrg func_source "$arg" 6726ef981d24Smrg 672765eef222Smrg if test -z "$pic_object" || 672865eef222Smrg test -z "$non_pic_object" || 6729b312a94cSmrg test none = "$pic_object" && 6730b312a94cSmrg test none = "$non_pic_object"; then 6731b312a94cSmrg func_fatal_error "cannot find name of object for '$arg'" 673265eef222Smrg fi 6733ef981d24Smrg 673465eef222Smrg # Extract subdirectory from the argument. 673565eef222Smrg func_dirname "$arg" "/" "" 6736b312a94cSmrg xdir=$func_dirname_result 6737ef981d24Smrg 6738b312a94cSmrg if test none != "$pic_object"; then 673965eef222Smrg # Prepend the subdirectory the object is found in. 6740b312a94cSmrg pic_object=$xdir$pic_object 6741ef981d24Smrg 6742b312a94cSmrg if test dlfiles = "$prev"; then 6743b312a94cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 6744200d7199Smrg func_append dlfiles " $pic_object" 674565eef222Smrg prev= 674665eef222Smrg continue 674765eef222Smrg else 674865eef222Smrg # If libtool objects are unsupported, then we need to preload. 674965eef222Smrg prev=dlprefiles 675065eef222Smrg fi 675165eef222Smrg fi 6752ef981d24Smrg 675365eef222Smrg # CHECK ME: I think I busted this. -Ossama 6754b312a94cSmrg if test dlprefiles = "$prev"; then 675565eef222Smrg # Preload the old-style object. 6756200d7199Smrg func_append dlprefiles " $pic_object" 675765eef222Smrg prev= 675865eef222Smrg fi 6759ef981d24Smrg 676065eef222Smrg # A PIC object. 676165eef222Smrg func_append libobjs " $pic_object" 6762b312a94cSmrg arg=$pic_object 676365eef222Smrg fi 6764ef981d24Smrg 676565eef222Smrg # Non-PIC object. 6766b312a94cSmrg if test none != "$non_pic_object"; then 676765eef222Smrg # Prepend the subdirectory the object is found in. 6768b312a94cSmrg non_pic_object=$xdir$non_pic_object 6769ef981d24Smrg 677065eef222Smrg # A standard non-PIC object 677165eef222Smrg func_append non_pic_objects " $non_pic_object" 6772b312a94cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 6773b312a94cSmrg arg=$non_pic_object 677465eef222Smrg fi 677565eef222Smrg else 677665eef222Smrg # If the PIC object exists, use it instead. 677765eef222Smrg # $xdir was prepended to $pic_object above. 6778b312a94cSmrg non_pic_object=$pic_object 677965eef222Smrg func_append non_pic_objects " $non_pic_object" 678065eef222Smrg fi 678165eef222Smrg else 678265eef222Smrg # Only an error if not doing a dry-run. 678365eef222Smrg if $opt_dry_run; then 678465eef222Smrg # Extract subdirectory from the argument. 678565eef222Smrg func_dirname "$arg" "/" "" 6786b312a94cSmrg xdir=$func_dirname_result 678765eef222Smrg 678865eef222Smrg func_lo2o "$arg" 678965eef222Smrg pic_object=$xdir$objdir/$func_lo2o_result 679065eef222Smrg non_pic_object=$xdir$func_lo2o_result 679165eef222Smrg func_append libobjs " $pic_object" 679265eef222Smrg func_append non_pic_objects " $non_pic_object" 679365eef222Smrg else 6794b312a94cSmrg func_fatal_error "'$arg' is not a valid libtool object" 679565eef222Smrg fi 679665eef222Smrg fi 679765eef222Smrg done 679865eef222Smrg else 6799b312a94cSmrg func_fatal_error "link input file '$arg' does not exist" 680065eef222Smrg fi 680165eef222Smrg arg=$save_arg 680265eef222Smrg prev= 680365eef222Smrg continue 680465eef222Smrg ;; 6805b312a94cSmrg os2dllname) 6806b312a94cSmrg os2dllname=$arg 6807b312a94cSmrg prev= 6808b312a94cSmrg continue 6809b312a94cSmrg ;; 681065eef222Smrg precious_regex) 6811b312a94cSmrg precious_files_regex=$arg 681265eef222Smrg prev= 681365eef222Smrg continue 681465eef222Smrg ;; 681565eef222Smrg release) 6816b312a94cSmrg release=-$arg 681765eef222Smrg prev= 681865eef222Smrg continue 681965eef222Smrg ;; 682065eef222Smrg rpath | xrpath) 682165eef222Smrg # We need an absolute path. 682265eef222Smrg case $arg in 682365eef222Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 682465eef222Smrg *) 682565eef222Smrg func_fatal_error "only absolute run-paths are allowed" 682665eef222Smrg ;; 682765eef222Smrg esac 6828b312a94cSmrg if test rpath = "$prev"; then 682965eef222Smrg case "$rpath " in 683065eef222Smrg *" $arg "*) ;; 6831200d7199Smrg *) func_append rpath " $arg" ;; 683265eef222Smrg esac 683365eef222Smrg else 683465eef222Smrg case "$xrpath " in 683565eef222Smrg *" $arg "*) ;; 6836200d7199Smrg *) func_append xrpath " $arg" ;; 683765eef222Smrg esac 683865eef222Smrg fi 683965eef222Smrg prev= 684065eef222Smrg continue 684165eef222Smrg ;; 684265eef222Smrg shrext) 6843b312a94cSmrg shrext_cmds=$arg 684465eef222Smrg prev= 684565eef222Smrg continue 684665eef222Smrg ;; 684765eef222Smrg weak) 6848200d7199Smrg func_append weak_libs " $arg" 684965eef222Smrg prev= 685065eef222Smrg continue 685165eef222Smrg ;; 685265eef222Smrg xcclinker) 6853200d7199Smrg func_append linker_flags " $qarg" 6854200d7199Smrg func_append compiler_flags " $qarg" 685565eef222Smrg prev= 685665eef222Smrg func_append compile_command " $qarg" 685765eef222Smrg func_append finalize_command " $qarg" 685865eef222Smrg continue 685965eef222Smrg ;; 686065eef222Smrg xcompiler) 6861200d7199Smrg func_append compiler_flags " $qarg" 686265eef222Smrg prev= 686365eef222Smrg func_append compile_command " $qarg" 686465eef222Smrg func_append finalize_command " $qarg" 686565eef222Smrg continue 686665eef222Smrg ;; 686765eef222Smrg xlinker) 6868200d7199Smrg func_append linker_flags " $qarg" 6869200d7199Smrg func_append compiler_flags " $wl$qarg" 687065eef222Smrg prev= 687165eef222Smrg func_append compile_command " $wl$qarg" 687265eef222Smrg func_append finalize_command " $wl$qarg" 687365eef222Smrg continue 687465eef222Smrg ;; 687565eef222Smrg *) 687665eef222Smrg eval "$prev=\"\$arg\"" 687765eef222Smrg prev= 687865eef222Smrg continue 687965eef222Smrg ;; 6880ef981d24Smrg esac 688165eef222Smrg fi # test -n "$prev" 6882ef981d24Smrg 6883b312a94cSmrg prevarg=$arg 6884ef981d24Smrg 688565eef222Smrg case $arg in 688665eef222Smrg -all-static) 688765eef222Smrg if test -n "$link_static_flag"; then 688865eef222Smrg # See comment for -static flag below, for more details. 688965eef222Smrg func_append compile_command " $link_static_flag" 689065eef222Smrg func_append finalize_command " $link_static_flag" 689165eef222Smrg fi 689265eef222Smrg continue 689365eef222Smrg ;; 6894ef981d24Smrg 689565eef222Smrg -allow-undefined) 689665eef222Smrg # FIXME: remove this flag sometime in the future. 6897b312a94cSmrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 689865eef222Smrg ;; 6899ef981d24Smrg 690065eef222Smrg -avoid-version) 690165eef222Smrg avoid_version=yes 690265eef222Smrg continue 690365eef222Smrg ;; 6904ef981d24Smrg 690556957a04Smrg -bindir) 690656957a04Smrg prev=bindir 690756957a04Smrg continue 690856957a04Smrg ;; 690956957a04Smrg 691065eef222Smrg -dlopen) 691165eef222Smrg prev=dlfiles 691265eef222Smrg continue 691365eef222Smrg ;; 6914ef981d24Smrg 691565eef222Smrg -dlpreopen) 691665eef222Smrg prev=dlprefiles 691765eef222Smrg continue 691865eef222Smrg ;; 6919ef981d24Smrg 692065eef222Smrg -export-dynamic) 692165eef222Smrg export_dynamic=yes 692265eef222Smrg continue 692365eef222Smrg ;; 6924ef981d24Smrg 692565eef222Smrg -export-symbols | -export-symbols-regex) 692665eef222Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 692765eef222Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 692865eef222Smrg fi 6929b312a94cSmrg if test X-export-symbols = "X$arg"; then 693065eef222Smrg prev=expsyms 693165eef222Smrg else 693265eef222Smrg prev=expsyms_regex 693365eef222Smrg fi 693465eef222Smrg continue 693565eef222Smrg ;; 6936ef981d24Smrg 693765eef222Smrg -framework) 693865eef222Smrg prev=framework 693965eef222Smrg continue 694065eef222Smrg ;; 6941ef981d24Smrg 694265eef222Smrg -inst-prefix-dir) 694365eef222Smrg prev=inst_prefix 694465eef222Smrg continue 694565eef222Smrg ;; 6946ef981d24Smrg 694765eef222Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 694865eef222Smrg # so, if we see these flags be careful not to treat them like -L 694965eef222Smrg -L[A-Z][A-Z]*:*) 695065eef222Smrg case $with_gcc/$host in 695165eef222Smrg no/*-*-irix* | /*-*-irix*) 695265eef222Smrg func_append compile_command " $arg" 695365eef222Smrg func_append finalize_command " $arg" 695465eef222Smrg ;; 695565eef222Smrg esac 695665eef222Smrg continue 695765eef222Smrg ;; 6958ef981d24Smrg 695965eef222Smrg -L*) 6960200d7199Smrg func_stripname "-L" '' "$arg" 6961200d7199Smrg if test -z "$func_stripname_result"; then 696265eef222Smrg if test "$#" -gt 0; then 6963b312a94cSmrg func_fatal_error "require no space between '-L' and '$1'" 696465eef222Smrg else 6965b312a94cSmrg func_fatal_error "need path for '-L' option" 696665eef222Smrg fi 696765eef222Smrg fi 6968200d7199Smrg func_resolve_sysroot "$func_stripname_result" 6969200d7199Smrg dir=$func_resolve_sysroot_result 697065eef222Smrg # We need an absolute path. 697165eef222Smrg case $dir in 697265eef222Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 697365eef222Smrg *) 697465eef222Smrg absdir=`cd "$dir" && pwd` 697565eef222Smrg test -z "$absdir" && \ 6976b312a94cSmrg func_fatal_error "cannot determine absolute directory name of '$dir'" 6977b312a94cSmrg dir=$absdir 697865eef222Smrg ;; 697965eef222Smrg esac 698065eef222Smrg case "$deplibs " in 6981200d7199Smrg *" -L$dir "* | *" $arg "*) 6982200d7199Smrg # Will only happen for absolute or sysroot arguments 6983200d7199Smrg ;; 698465eef222Smrg *) 6985200d7199Smrg # Preserve sysroot, but never include relative directories 6986200d7199Smrg case $dir in 6987200d7199Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 6988200d7199Smrg *) func_append deplibs " -L$dir" ;; 6989200d7199Smrg esac 6990200d7199Smrg func_append lib_search_path " $dir" 699165eef222Smrg ;; 699265eef222Smrg esac 699365eef222Smrg case $host in 699465eef222Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 699556957a04Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 699665eef222Smrg case :$dllsearchpath: in 699765eef222Smrg *":$dir:"*) ;; 699865eef222Smrg ::) dllsearchpath=$dir;; 6999200d7199Smrg *) func_append dllsearchpath ":$dir";; 700065eef222Smrg esac 700165eef222Smrg case :$dllsearchpath: in 700265eef222Smrg *":$testbindir:"*) ;; 700365eef222Smrg ::) dllsearchpath=$testbindir;; 7004200d7199Smrg *) func_append dllsearchpath ":$testbindir";; 700565eef222Smrg esac 700665eef222Smrg ;; 700765eef222Smrg esac 700865eef222Smrg continue 700965eef222Smrg ;; 7010ef981d24Smrg 701165eef222Smrg -l*) 7012b312a94cSmrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 701365eef222Smrg case $host in 701456957a04Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 701565eef222Smrg # These systems don't actually have a C or math library (as such) 701665eef222Smrg continue 701765eef222Smrg ;; 701865eef222Smrg *-*-os2*) 701965eef222Smrg # These systems don't actually have a C library (as such) 7020b312a94cSmrg test X-lc = "X$arg" && continue 702165eef222Smrg ;; 7022b312a94cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 702365eef222Smrg # Do not include libc due to us having libc/libc_r. 7024b312a94cSmrg test X-lc = "X$arg" && continue 702565eef222Smrg ;; 702665eef222Smrg *-*-rhapsody* | *-*-darwin1.[012]) 702765eef222Smrg # Rhapsody C and math libraries are in the System framework 7028200d7199Smrg func_append deplibs " System.ltframework" 702965eef222Smrg continue 703065eef222Smrg ;; 703165eef222Smrg *-*-sco3.2v5* | *-*-sco5v6*) 703265eef222Smrg # Causes problems with __ctype 7033b312a94cSmrg test X-lc = "X$arg" && continue 703465eef222Smrg ;; 703565eef222Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 703665eef222Smrg # Compiler inserts libc in the correct place for threads to work 7037b312a94cSmrg test X-lc = "X$arg" && continue 703865eef222Smrg ;; 703965eef222Smrg esac 7040b312a94cSmrg elif test X-lc_r = "X$arg"; then 704165eef222Smrg case $host in 7042b312a94cSmrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) 704365eef222Smrg # Do not include libc_r directly, use -pthread flag. 704465eef222Smrg continue 704565eef222Smrg ;; 704665eef222Smrg esac 704765eef222Smrg fi 7048200d7199Smrg func_append deplibs " $arg" 704965eef222Smrg continue 705065eef222Smrg ;; 7051ef981d24Smrg 7052b312a94cSmrg -mllvm) 7053b312a94cSmrg prev=mllvm 7054b312a94cSmrg continue 7055b312a94cSmrg ;; 7056b312a94cSmrg 705765eef222Smrg -module) 705865eef222Smrg module=yes 705965eef222Smrg continue 706065eef222Smrg ;; 7061ef981d24Smrg 706265eef222Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 706365eef222Smrg # classes, name mangling, and exception handling. 706465eef222Smrg # Darwin uses the -arch flag to determine output architecture. 7065200d7199Smrg -model|-arch|-isysroot|--sysroot) 7066200d7199Smrg func_append compiler_flags " $arg" 706765eef222Smrg func_append compile_command " $arg" 706865eef222Smrg func_append finalize_command " $arg" 706965eef222Smrg prev=xcompiler 707065eef222Smrg continue 707165eef222Smrg ;; 7072ef981d24Smrg 7073b312a94cSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7074b312a94cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7075200d7199Smrg func_append compiler_flags " $arg" 707665eef222Smrg func_append compile_command " $arg" 707765eef222Smrg func_append finalize_command " $arg" 707865eef222Smrg case "$new_inherited_linker_flags " in 707965eef222Smrg *" $arg "*) ;; 7080200d7199Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 708165eef222Smrg esac 708265eef222Smrg continue 708365eef222Smrg ;; 7084ef981d24Smrg 708565eef222Smrg -multi_module) 7086b312a94cSmrg single_module=$wl-multi_module 708765eef222Smrg continue 708865eef222Smrg ;; 7089ef981d24Smrg 709065eef222Smrg -no-fast-install) 709165eef222Smrg fast_install=no 709265eef222Smrg continue 709365eef222Smrg ;; 7094ef981d24Smrg 709565eef222Smrg -no-install) 709665eef222Smrg case $host in 709765eef222Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 709865eef222Smrg # The PATH hackery in wrapper scripts is required on Windows 709965eef222Smrg # and Darwin in order for the loader to find any dlls it needs. 7100b312a94cSmrg func_warning "'-no-install' is ignored for $host" 7101b312a94cSmrg func_warning "assuming '-no-fast-install' instead" 710265eef222Smrg fast_install=no 710365eef222Smrg ;; 710465eef222Smrg *) no_install=yes ;; 710565eef222Smrg esac 710665eef222Smrg continue 710765eef222Smrg ;; 7108ef981d24Smrg 710965eef222Smrg -no-undefined) 711065eef222Smrg allow_undefined=no 711165eef222Smrg continue 711265eef222Smrg ;; 7113ef981d24Smrg 711465eef222Smrg -objectlist) 711565eef222Smrg prev=objectlist 711665eef222Smrg continue 711765eef222Smrg ;; 7118ef981d24Smrg 7119b312a94cSmrg -os2dllname) 7120b312a94cSmrg prev=os2dllname 7121b312a94cSmrg continue 7122b312a94cSmrg ;; 7123b312a94cSmrg 712465eef222Smrg -o) prev=output ;; 7125ef981d24Smrg 712665eef222Smrg -precious-files-regex) 712765eef222Smrg prev=precious_regex 712865eef222Smrg continue 712965eef222Smrg ;; 7130ef981d24Smrg 713165eef222Smrg -release) 713265eef222Smrg prev=release 713365eef222Smrg continue 713465eef222Smrg ;; 7135ef981d24Smrg 713665eef222Smrg -rpath) 713765eef222Smrg prev=rpath 713865eef222Smrg continue 713965eef222Smrg ;; 7140ef981d24Smrg 714165eef222Smrg -R) 714265eef222Smrg prev=xrpath 714365eef222Smrg continue 714465eef222Smrg ;; 7145ef981d24Smrg 714665eef222Smrg -R*) 714765eef222Smrg func_stripname '-R' '' "$arg" 714865eef222Smrg dir=$func_stripname_result 714965eef222Smrg # We need an absolute path. 715065eef222Smrg case $dir in 715165eef222Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7152200d7199Smrg =*) 7153200d7199Smrg func_stripname '=' '' "$dir" 7154200d7199Smrg dir=$lt_sysroot$func_stripname_result 7155200d7199Smrg ;; 715665eef222Smrg *) 715765eef222Smrg func_fatal_error "only absolute run-paths are allowed" 715865eef222Smrg ;; 715965eef222Smrg esac 716065eef222Smrg case "$xrpath " in 716165eef222Smrg *" $dir "*) ;; 7162200d7199Smrg *) func_append xrpath " $dir" ;; 716365eef222Smrg esac 716465eef222Smrg continue 716565eef222Smrg ;; 7166ef981d24Smrg 716765eef222Smrg -shared) 716865eef222Smrg # The effects of -shared are defined in a previous loop. 716965eef222Smrg continue 717065eef222Smrg ;; 7171ef981d24Smrg 717265eef222Smrg -shrext) 717365eef222Smrg prev=shrext 717465eef222Smrg continue 717565eef222Smrg ;; 7176ef981d24Smrg 717765eef222Smrg -static | -static-libtool-libs) 717865eef222Smrg # The effects of -static are defined in a previous loop. 717965eef222Smrg # We used to do the same as -all-static on platforms that 718065eef222Smrg # didn't have a PIC flag, but the assumption that the effects 718165eef222Smrg # would be equivalent was wrong. It would break on at least 718265eef222Smrg # Digital Unix and AIX. 718365eef222Smrg continue 718465eef222Smrg ;; 7185ef981d24Smrg 718665eef222Smrg -thread-safe) 718765eef222Smrg thread_safe=yes 718865eef222Smrg continue 718965eef222Smrg ;; 7190ef981d24Smrg 719165eef222Smrg -version-info) 719265eef222Smrg prev=vinfo 719365eef222Smrg continue 719465eef222Smrg ;; 7195ef981d24Smrg 719665eef222Smrg -version-number) 719765eef222Smrg prev=vinfo 719865eef222Smrg vinfo_number=yes 719965eef222Smrg continue 720065eef222Smrg ;; 7201ef981d24Smrg 720265eef222Smrg -weak) 720365eef222Smrg prev=weak 720465eef222Smrg continue 720565eef222Smrg ;; 7206ef981d24Smrg 720765eef222Smrg -Wc,*) 720865eef222Smrg func_stripname '-Wc,' '' "$arg" 720965eef222Smrg args=$func_stripname_result 721065eef222Smrg arg= 7211b312a94cSmrg save_ifs=$IFS; IFS=, 721265eef222Smrg for flag in $args; do 7213b312a94cSmrg IFS=$save_ifs 721465eef222Smrg func_quote_for_eval "$flag" 7215200d7199Smrg func_append arg " $func_quote_for_eval_result" 7216200d7199Smrg func_append compiler_flags " $func_quote_for_eval_result" 721765eef222Smrg done 7218b312a94cSmrg IFS=$save_ifs 721965eef222Smrg func_stripname ' ' '' "$arg" 722065eef222Smrg arg=$func_stripname_result 722165eef222Smrg ;; 7222ef981d24Smrg 722365eef222Smrg -Wl,*) 722465eef222Smrg func_stripname '-Wl,' '' "$arg" 722565eef222Smrg args=$func_stripname_result 722665eef222Smrg arg= 7227b312a94cSmrg save_ifs=$IFS; IFS=, 722865eef222Smrg for flag in $args; do 7229b312a94cSmrg IFS=$save_ifs 723065eef222Smrg func_quote_for_eval "$flag" 7231200d7199Smrg func_append arg " $wl$func_quote_for_eval_result" 7232200d7199Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 7233200d7199Smrg func_append linker_flags " $func_quote_for_eval_result" 723465eef222Smrg done 7235b312a94cSmrg IFS=$save_ifs 723665eef222Smrg func_stripname ' ' '' "$arg" 723765eef222Smrg arg=$func_stripname_result 723865eef222Smrg ;; 7239ef981d24Smrg 724065eef222Smrg -Xcompiler) 724165eef222Smrg prev=xcompiler 724265eef222Smrg continue 724365eef222Smrg ;; 7244ef981d24Smrg 724565eef222Smrg -Xlinker) 724665eef222Smrg prev=xlinker 724765eef222Smrg continue 724865eef222Smrg ;; 7249ef981d24Smrg 725065eef222Smrg -XCClinker) 725165eef222Smrg prev=xcclinker 725265eef222Smrg continue 725365eef222Smrg ;; 7254ef981d24Smrg 725565eef222Smrg # -msg_* for osf cc 725665eef222Smrg -msg_*) 725765eef222Smrg func_quote_for_eval "$arg" 7258b312a94cSmrg arg=$func_quote_for_eval_result 725965eef222Smrg ;; 7260ef981d24Smrg 726156957a04Smrg # Flags to be passed through unchanged, with rationale: 726256957a04Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 726356957a04Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 726456957a04Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 726556957a04Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 726656957a04Smrg # -q* compiler args for the IBM compiler 726756957a04Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 726856957a04Smrg # -F/path path to uninstalled frameworks, gcc on darwin 726956957a04Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7270b312a94cSmrg # -fstack-protector* stack protector flags for GCC 727156957a04Smrg # @file GCC response files 727256957a04Smrg # -tp=* Portland pgcc target processor selection 7273200d7199Smrg # --sysroot=* for sysroot support 7274b312a94cSmrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7275b312a94cSmrg # -specs=* GCC specs files 7276b312a94cSmrg # -stdlib=* select c++ std lib with clang 727765eef222Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7278200d7199Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7279b312a94cSmrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7280b312a94cSmrg -specs=*) 728165eef222Smrg func_quote_for_eval "$arg" 7282b312a94cSmrg arg=$func_quote_for_eval_result 728365eef222Smrg func_append compile_command " $arg" 728465eef222Smrg func_append finalize_command " $arg" 7285200d7199Smrg func_append compiler_flags " $arg" 728665eef222Smrg continue 728765eef222Smrg ;; 7288ef981d24Smrg 7289b312a94cSmrg -Z*) 7290b312a94cSmrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7291b312a94cSmrg # OS/2 uses -Zxxx to specify OS/2-specific options 7292b312a94cSmrg compiler_flags="$compiler_flags $arg" 7293b312a94cSmrg func_append compile_command " $arg" 7294b312a94cSmrg func_append finalize_command " $arg" 7295b312a94cSmrg case $arg in 7296b312a94cSmrg -Zlinker | -Zstack) 7297b312a94cSmrg prev=xcompiler 7298b312a94cSmrg ;; 7299b312a94cSmrg esac 7300b312a94cSmrg continue 7301b312a94cSmrg else 7302b312a94cSmrg # Otherwise treat like 'Some other compiler flag' below 7303b312a94cSmrg func_quote_for_eval "$arg" 7304b312a94cSmrg arg=$func_quote_for_eval_result 7305b312a94cSmrg fi 7306b312a94cSmrg ;; 7307b312a94cSmrg 730865eef222Smrg # Some other compiler flag. 730965eef222Smrg -* | +*) 731065eef222Smrg func_quote_for_eval "$arg" 7311b312a94cSmrg arg=$func_quote_for_eval_result 731265eef222Smrg ;; 7313ef981d24Smrg 731465eef222Smrg *.$objext) 731565eef222Smrg # A standard object. 7316200d7199Smrg func_append objs " $arg" 731765eef222Smrg ;; 731865eef222Smrg 731965eef222Smrg *.lo) 732065eef222Smrg # A libtool-controlled object. 732165eef222Smrg 732265eef222Smrg # Check to see that this really is a libtool object. 732365eef222Smrg if func_lalib_unsafe_p "$arg"; then 732465eef222Smrg pic_object= 732565eef222Smrg non_pic_object= 732665eef222Smrg 732765eef222Smrg # Read the .lo file 732865eef222Smrg func_source "$arg" 732965eef222Smrg 733065eef222Smrg if test -z "$pic_object" || 733165eef222Smrg test -z "$non_pic_object" || 7332b312a94cSmrg test none = "$pic_object" && 7333b312a94cSmrg test none = "$non_pic_object"; then 7334b312a94cSmrg func_fatal_error "cannot find name of object for '$arg'" 733565eef222Smrg fi 733665eef222Smrg 733765eef222Smrg # Extract subdirectory from the argument. 733865eef222Smrg func_dirname "$arg" "/" "" 7339b312a94cSmrg xdir=$func_dirname_result 734065eef222Smrg 7341b312a94cSmrg test none = "$pic_object" || { 734265eef222Smrg # Prepend the subdirectory the object is found in. 7343b312a94cSmrg pic_object=$xdir$pic_object 734465eef222Smrg 7345b312a94cSmrg if test dlfiles = "$prev"; then 7346b312a94cSmrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7347200d7199Smrg func_append dlfiles " $pic_object" 734865eef222Smrg prev= 734965eef222Smrg continue 735065eef222Smrg else 735165eef222Smrg # If libtool objects are unsupported, then we need to preload. 735265eef222Smrg prev=dlprefiles 735365eef222Smrg fi 735465eef222Smrg fi 735565eef222Smrg 735665eef222Smrg # CHECK ME: I think I busted this. -Ossama 7357b312a94cSmrg if test dlprefiles = "$prev"; then 735865eef222Smrg # Preload the old-style object. 7359200d7199Smrg func_append dlprefiles " $pic_object" 736065eef222Smrg prev= 736165eef222Smrg fi 736265eef222Smrg 736365eef222Smrg # A PIC object. 736465eef222Smrg func_append libobjs " $pic_object" 7365b312a94cSmrg arg=$pic_object 7366b312a94cSmrg } 736765eef222Smrg 736865eef222Smrg # Non-PIC object. 7369b312a94cSmrg if test none != "$non_pic_object"; then 737065eef222Smrg # Prepend the subdirectory the object is found in. 7371b312a94cSmrg non_pic_object=$xdir$non_pic_object 737265eef222Smrg 737365eef222Smrg # A standard non-PIC object 737465eef222Smrg func_append non_pic_objects " $non_pic_object" 7375b312a94cSmrg if test -z "$pic_object" || test none = "$pic_object"; then 7376b312a94cSmrg arg=$non_pic_object 737765eef222Smrg fi 737865eef222Smrg else 737965eef222Smrg # If the PIC object exists, use it instead. 738065eef222Smrg # $xdir was prepended to $pic_object above. 7381b312a94cSmrg non_pic_object=$pic_object 738265eef222Smrg func_append non_pic_objects " $non_pic_object" 738365eef222Smrg fi 738465eef222Smrg else 738565eef222Smrg # Only an error if not doing a dry-run. 738665eef222Smrg if $opt_dry_run; then 738765eef222Smrg # Extract subdirectory from the argument. 738865eef222Smrg func_dirname "$arg" "/" "" 7389b312a94cSmrg xdir=$func_dirname_result 739065eef222Smrg 739165eef222Smrg func_lo2o "$arg" 739265eef222Smrg pic_object=$xdir$objdir/$func_lo2o_result 739365eef222Smrg non_pic_object=$xdir$func_lo2o_result 739465eef222Smrg func_append libobjs " $pic_object" 739565eef222Smrg func_append non_pic_objects " $non_pic_object" 739665eef222Smrg else 7397b312a94cSmrg func_fatal_error "'$arg' is not a valid libtool object" 739865eef222Smrg fi 739965eef222Smrg fi 740065eef222Smrg ;; 740165eef222Smrg 740265eef222Smrg *.$libext) 740365eef222Smrg # An archive. 7404200d7199Smrg func_append deplibs " $arg" 7405200d7199Smrg func_append old_deplibs " $arg" 740665eef222Smrg continue 740765eef222Smrg ;; 740865eef222Smrg 740965eef222Smrg *.la) 741065eef222Smrg # A libtool-controlled library. 741165eef222Smrg 7412200d7199Smrg func_resolve_sysroot "$arg" 7413b312a94cSmrg if test dlfiles = "$prev"; then 741465eef222Smrg # This library was specified with -dlopen. 7415200d7199Smrg func_append dlfiles " $func_resolve_sysroot_result" 741665eef222Smrg prev= 7417b312a94cSmrg elif test dlprefiles = "$prev"; then 741865eef222Smrg # The library was specified with -dlpreopen. 7419200d7199Smrg func_append dlprefiles " $func_resolve_sysroot_result" 742065eef222Smrg prev= 742165eef222Smrg else 7422200d7199Smrg func_append deplibs " $func_resolve_sysroot_result" 742365eef222Smrg fi 742465eef222Smrg continue 742565eef222Smrg ;; 742665eef222Smrg 742765eef222Smrg # Some other compiler argument. 742865eef222Smrg *) 742965eef222Smrg # Unknown arguments in both finalize_command and compile_command need 743065eef222Smrg # to be aesthetically quoted because they are evaled later. 743165eef222Smrg func_quote_for_eval "$arg" 7432b312a94cSmrg arg=$func_quote_for_eval_result 743365eef222Smrg ;; 743465eef222Smrg esac # arg 743565eef222Smrg 743665eef222Smrg # Now actually substitute the argument into the commands. 743765eef222Smrg if test -n "$arg"; then 743865eef222Smrg func_append compile_command " $arg" 743965eef222Smrg func_append finalize_command " $arg" 744065eef222Smrg fi 744165eef222Smrg done # argument parsing loop 744265eef222Smrg 744365eef222Smrg test -n "$prev" && \ 7444b312a94cSmrg func_fatal_help "the '$prevarg' option requires an argument" 744565eef222Smrg 7446b312a94cSmrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 744765eef222Smrg eval arg=\"$export_dynamic_flag_spec\" 744865eef222Smrg func_append compile_command " $arg" 744965eef222Smrg func_append finalize_command " $arg" 745065eef222Smrg fi 745165eef222Smrg 745265eef222Smrg oldlibs= 745365eef222Smrg # calculate the name of the file, without its directory 745465eef222Smrg func_basename "$output" 7455b312a94cSmrg outputname=$func_basename_result 7456b312a94cSmrg libobjs_save=$libobjs 745765eef222Smrg 745865eef222Smrg if test -n "$shlibpath_var"; then 745965eef222Smrg # get the directories listed in $shlibpath_var 7460b312a94cSmrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7461ef981d24Smrg else 746265eef222Smrg shlib_search_path= 7463ef981d24Smrg fi 746465eef222Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 746565eef222Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7466ef981d24Smrg 7467b312a94cSmrg # Definition is injected by LT_CONFIG during libtool generation. 7468b312a94cSmrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7469b312a94cSmrg 747065eef222Smrg func_dirname "$output" "/" "" 7471b312a94cSmrg output_objdir=$func_dirname_result$objdir 7472200d7199Smrg func_to_tool_file "$output_objdir/" 7473200d7199Smrg tool_output_objdir=$func_to_tool_file_result 747465eef222Smrg # Create the object directory. 747565eef222Smrg func_mkdir_p "$output_objdir" 7476ef981d24Smrg 747765eef222Smrg # Determine the type of output 747865eef222Smrg case $output in 747965eef222Smrg "") 748065eef222Smrg func_fatal_help "you must specify an output file" 748165eef222Smrg ;; 748265eef222Smrg *.$libext) linkmode=oldlib ;; 748365eef222Smrg *.lo | *.$objext) linkmode=obj ;; 748465eef222Smrg *.la) linkmode=lib ;; 748565eef222Smrg *) linkmode=prog ;; # Anything else should be a program. 748665eef222Smrg esac 748765eef222Smrg 748865eef222Smrg specialdeplibs= 748965eef222Smrg 749065eef222Smrg libs= 749165eef222Smrg # Find all interdependent deplibs by searching for libraries 749265eef222Smrg # that are linked more than once (e.g. -la -lb -la) 749365eef222Smrg for deplib in $deplibs; do 7494b312a94cSmrg if $opt_preserve_dup_deps; then 749565eef222Smrg case "$libs " in 7496200d7199Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 749765eef222Smrg esac 749865eef222Smrg fi 7499200d7199Smrg func_append libs " $deplib" 750065eef222Smrg done 750165eef222Smrg 7502b312a94cSmrg if test lib = "$linkmode"; then 750365eef222Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 750465eef222Smrg 750565eef222Smrg # Compute libraries that are listed more than once in $predeps 750665eef222Smrg # $postdeps and mark them as special (i.e., whose duplicates are 750765eef222Smrg # not to be eliminated). 750865eef222Smrg pre_post_deps= 750965eef222Smrg if $opt_duplicate_compiler_generated_deps; then 751065eef222Smrg for pre_post_dep in $predeps $postdeps; do 751165eef222Smrg case "$pre_post_deps " in 7512200d7199Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 751365eef222Smrg esac 7514200d7199Smrg func_append pre_post_deps " $pre_post_dep" 751565eef222Smrg done 751665eef222Smrg fi 751765eef222Smrg pre_post_deps= 751865eef222Smrg fi 751965eef222Smrg 752065eef222Smrg deplibs= 752165eef222Smrg newdependency_libs= 752265eef222Smrg newlib_search_path= 752365eef222Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 752465eef222Smrg notinst_deplibs= # not-installed libtool libraries 752565eef222Smrg notinst_path= # paths that contain not-installed libtool libraries 752665eef222Smrg 752765eef222Smrg case $linkmode in 752865eef222Smrg lib) 752965eef222Smrg passes="conv dlpreopen link" 753065eef222Smrg for file in $dlfiles $dlprefiles; do 753165eef222Smrg case $file in 753265eef222Smrg *.la) ;; 753365eef222Smrg *) 7534b312a94cSmrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 753565eef222Smrg ;; 753665eef222Smrg esac 753765eef222Smrg done 753865eef222Smrg ;; 753965eef222Smrg prog) 754065eef222Smrg compile_deplibs= 754165eef222Smrg finalize_deplibs= 7542b312a94cSmrg alldeplibs=false 754365eef222Smrg newdlfiles= 754465eef222Smrg newdlprefiles= 754565eef222Smrg passes="conv scan dlopen dlpreopen link" 754665eef222Smrg ;; 754765eef222Smrg *) passes="conv" 754865eef222Smrg ;; 754965eef222Smrg esac 755065eef222Smrg 755165eef222Smrg for pass in $passes; do 755265eef222Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 755365eef222Smrg # so that -L comes before libs that need it for instance... 7554b312a94cSmrg if test lib,link = "$linkmode,$pass"; then 755565eef222Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 755665eef222Smrg ## order, and fix it there properly 755765eef222Smrg tmp_deplibs= 755865eef222Smrg for deplib in $deplibs; do 755965eef222Smrg tmp_deplibs="$deplib $tmp_deplibs" 756065eef222Smrg done 7561b312a94cSmrg deplibs=$tmp_deplibs 756265eef222Smrg fi 756365eef222Smrg 7564b312a94cSmrg if test lib,link = "$linkmode,$pass" || 7565b312a94cSmrg test prog,scan = "$linkmode,$pass"; then 7566b312a94cSmrg libs=$deplibs 756765eef222Smrg deplibs= 756865eef222Smrg fi 7569b312a94cSmrg if test prog = "$linkmode"; then 757065eef222Smrg case $pass in 7571b312a94cSmrg dlopen) libs=$dlfiles ;; 7572b312a94cSmrg dlpreopen) libs=$dlprefiles ;; 757365eef222Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 757465eef222Smrg esac 757565eef222Smrg fi 7576b312a94cSmrg if test lib,dlpreopen = "$linkmode,$pass"; then 757765eef222Smrg # Collect and forward deplibs of preopened libtool libs 757865eef222Smrg for lib in $dlprefiles; do 757965eef222Smrg # Ignore non-libtool-libs 758065eef222Smrg dependency_libs= 7581200d7199Smrg func_resolve_sysroot "$lib" 758265eef222Smrg case $lib in 7583200d7199Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 758465eef222Smrg esac 758565eef222Smrg 758665eef222Smrg # Collect preopened libtool deplibs, except any this library 758765eef222Smrg # has declared as weak libs 758865eef222Smrg for deplib in $dependency_libs; do 758956957a04Smrg func_basename "$deplib" 759056957a04Smrg deplib_base=$func_basename_result 759165eef222Smrg case " $weak_libs " in 759265eef222Smrg *" $deplib_base "*) ;; 7593200d7199Smrg *) func_append deplibs " $deplib" ;; 759465eef222Smrg esac 759565eef222Smrg done 759665eef222Smrg done 7597b312a94cSmrg libs=$dlprefiles 759865eef222Smrg fi 7599b312a94cSmrg if test dlopen = "$pass"; then 760065eef222Smrg # Collect dlpreopened libraries 7601b312a94cSmrg save_deplibs=$deplibs 760265eef222Smrg deplibs= 760365eef222Smrg fi 760465eef222Smrg 760565eef222Smrg for deplib in $libs; do 760665eef222Smrg lib= 7607b312a94cSmrg found=false 760865eef222Smrg case $deplib in 7609b312a94cSmrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7610b312a94cSmrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7611b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 761265eef222Smrg compile_deplibs="$deplib $compile_deplibs" 761365eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 761465eef222Smrg else 7615200d7199Smrg func_append compiler_flags " $deplib" 7616b312a94cSmrg if test lib = "$linkmode"; then 761765eef222Smrg case "$new_inherited_linker_flags " in 761865eef222Smrg *" $deplib "*) ;; 7619200d7199Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 762065eef222Smrg esac 762165eef222Smrg fi 762265eef222Smrg fi 762365eef222Smrg continue 762465eef222Smrg ;; 762565eef222Smrg -l*) 7626b312a94cSmrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7627b312a94cSmrg func_warning "'-l' is ignored for archives/objects" 762865eef222Smrg continue 762965eef222Smrg fi 763065eef222Smrg func_stripname '-l' '' "$deplib" 763165eef222Smrg name=$func_stripname_result 7632b312a94cSmrg if test lib = "$linkmode"; then 763365eef222Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 763465eef222Smrg else 763565eef222Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 763665eef222Smrg fi 763765eef222Smrg for searchdir in $searchdirs; do 763865eef222Smrg for search_ext in .la $std_shrext .so .a; do 763965eef222Smrg # Search the libtool library 7640b312a94cSmrg lib=$searchdir/lib$name$search_ext 764165eef222Smrg if test -f "$lib"; then 7642b312a94cSmrg if test .la = "$search_ext"; then 7643b312a94cSmrg found=: 764465eef222Smrg else 7645b312a94cSmrg found=false 764665eef222Smrg fi 764765eef222Smrg break 2 764865eef222Smrg fi 764965eef222Smrg done 765065eef222Smrg done 7651b312a94cSmrg if $found; then 7652b312a94cSmrg # deplib is a libtool library 765365eef222Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 765465eef222Smrg # We need to do some special things here, and not later. 7655b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 765665eef222Smrg case " $predeps $postdeps " in 765765eef222Smrg *" $deplib "*) 765865eef222Smrg if func_lalib_p "$lib"; then 765965eef222Smrg library_names= 766065eef222Smrg old_library= 766165eef222Smrg func_source "$lib" 766265eef222Smrg for l in $old_library $library_names; do 7663b312a94cSmrg ll=$l 766465eef222Smrg done 7665b312a94cSmrg if test "X$ll" = "X$old_library"; then # only static version available 7666b312a94cSmrg found=false 766765eef222Smrg func_dirname "$lib" "" "." 7668b312a94cSmrg ladir=$func_dirname_result 766965eef222Smrg lib=$ladir/$old_library 7670b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 767165eef222Smrg compile_deplibs="$deplib $compile_deplibs" 767265eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 767365eef222Smrg else 767465eef222Smrg deplibs="$deplib $deplibs" 7675b312a94cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 767665eef222Smrg fi 767765eef222Smrg continue 767865eef222Smrg fi 767965eef222Smrg fi 768065eef222Smrg ;; 768165eef222Smrg *) ;; 768265eef222Smrg esac 768365eef222Smrg fi 7684b312a94cSmrg else 7685b312a94cSmrg # deplib doesn't seem to be a libtool library 7686b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 7687b312a94cSmrg compile_deplibs="$deplib $compile_deplibs" 7688b312a94cSmrg finalize_deplibs="$deplib $finalize_deplibs" 7689b312a94cSmrg else 7690b312a94cSmrg deplibs="$deplib $deplibs" 7691b312a94cSmrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7692b312a94cSmrg fi 7693b312a94cSmrg continue 769465eef222Smrg fi 769565eef222Smrg ;; # -l 769665eef222Smrg *.ltframework) 7697b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 769865eef222Smrg compile_deplibs="$deplib $compile_deplibs" 769965eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 770065eef222Smrg else 770165eef222Smrg deplibs="$deplib $deplibs" 7702b312a94cSmrg if test lib = "$linkmode"; then 770365eef222Smrg case "$new_inherited_linker_flags " in 770465eef222Smrg *" $deplib "*) ;; 7705200d7199Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 770665eef222Smrg esac 770765eef222Smrg fi 770865eef222Smrg fi 770965eef222Smrg continue 771065eef222Smrg ;; 771165eef222Smrg -L*) 771265eef222Smrg case $linkmode in 771365eef222Smrg lib) 771465eef222Smrg deplibs="$deplib $deplibs" 7715b312a94cSmrg test conv = "$pass" && continue 771665eef222Smrg newdependency_libs="$deplib $newdependency_libs" 771765eef222Smrg func_stripname '-L' '' "$deplib" 7718200d7199Smrg func_resolve_sysroot "$func_stripname_result" 7719200d7199Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 772065eef222Smrg ;; 772165eef222Smrg prog) 7722b312a94cSmrg if test conv = "$pass"; then 772365eef222Smrg deplibs="$deplib $deplibs" 772465eef222Smrg continue 772565eef222Smrg fi 7726b312a94cSmrg if test scan = "$pass"; then 772765eef222Smrg deplibs="$deplib $deplibs" 772865eef222Smrg else 772965eef222Smrg compile_deplibs="$deplib $compile_deplibs" 773065eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 773165eef222Smrg fi 773265eef222Smrg func_stripname '-L' '' "$deplib" 7733200d7199Smrg func_resolve_sysroot "$func_stripname_result" 7734200d7199Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 773565eef222Smrg ;; 773665eef222Smrg *) 7737b312a94cSmrg func_warning "'-L' is ignored for archives/objects" 773865eef222Smrg ;; 773965eef222Smrg esac # linkmode 774065eef222Smrg continue 774165eef222Smrg ;; # -L 774265eef222Smrg -R*) 7743b312a94cSmrg if test link = "$pass"; then 774465eef222Smrg func_stripname '-R' '' "$deplib" 7745200d7199Smrg func_resolve_sysroot "$func_stripname_result" 7746200d7199Smrg dir=$func_resolve_sysroot_result 774765eef222Smrg # Make sure the xrpath contains only unique directories. 774865eef222Smrg case "$xrpath " in 774965eef222Smrg *" $dir "*) ;; 7750200d7199Smrg *) func_append xrpath " $dir" ;; 775165eef222Smrg esac 775265eef222Smrg fi 775365eef222Smrg deplibs="$deplib $deplibs" 775465eef222Smrg continue 775565eef222Smrg ;; 7756200d7199Smrg *.la) 7757200d7199Smrg func_resolve_sysroot "$deplib" 7758200d7199Smrg lib=$func_resolve_sysroot_result 7759200d7199Smrg ;; 776065eef222Smrg *.$libext) 7761b312a94cSmrg if test conv = "$pass"; then 776265eef222Smrg deplibs="$deplib $deplibs" 776365eef222Smrg continue 776465eef222Smrg fi 776565eef222Smrg case $linkmode in 776665eef222Smrg lib) 776765eef222Smrg # Linking convenience modules into shared libraries is allowed, 776865eef222Smrg # but linking other static libraries is non-portable. 776965eef222Smrg case " $dlpreconveniencelibs " in 777065eef222Smrg *" $deplib "*) ;; 777165eef222Smrg *) 7772b312a94cSmrg valid_a_lib=false 777365eef222Smrg case $deplibs_check_method in 777465eef222Smrg match_pattern*) 777565eef222Smrg set dummy $deplibs_check_method; shift 777665eef222Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 777756957a04Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 777865eef222Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 7779b312a94cSmrg valid_a_lib=: 778065eef222Smrg fi 778165eef222Smrg ;; 778265eef222Smrg pass_all) 7783b312a94cSmrg valid_a_lib=: 778465eef222Smrg ;; 778565eef222Smrg esac 7786b312a94cSmrg if $valid_a_lib; then 7787b312a94cSmrg echo 7788b312a94cSmrg $ECHO "*** Warning: Linking the shared library $output against the" 7789b312a94cSmrg $ECHO "*** static library $deplib is not portable!" 7790b312a94cSmrg deplibs="$deplib $deplibs" 7791b312a94cSmrg else 779256957a04Smrg echo 779365eef222Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 779456957a04Smrg echo "*** I have the capability to make that library automatically link in when" 779556957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 779656957a04Smrg echo "*** shared version of the library, which you do not appear to have" 779756957a04Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 779856957a04Smrg echo "*** that it is just a static archive that I should not use here." 779965eef222Smrg fi 780065eef222Smrg ;; 780165eef222Smrg esac 780265eef222Smrg continue 780365eef222Smrg ;; 780465eef222Smrg prog) 7805b312a94cSmrg if test link != "$pass"; then 780665eef222Smrg deplibs="$deplib $deplibs" 780765eef222Smrg else 780865eef222Smrg compile_deplibs="$deplib $compile_deplibs" 780965eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 781065eef222Smrg fi 781165eef222Smrg continue 781265eef222Smrg ;; 781365eef222Smrg esac # linkmode 781465eef222Smrg ;; # *.$libext 781565eef222Smrg *.lo | *.$objext) 7816b312a94cSmrg if test conv = "$pass"; then 781765eef222Smrg deplibs="$deplib $deplibs" 7818b312a94cSmrg elif test prog = "$linkmode"; then 7819b312a94cSmrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 782065eef222Smrg # If there is no dlopen support or we're linking statically, 782165eef222Smrg # we need to preload. 7822200d7199Smrg func_append newdlprefiles " $deplib" 782365eef222Smrg compile_deplibs="$deplib $compile_deplibs" 782465eef222Smrg finalize_deplibs="$deplib $finalize_deplibs" 782565eef222Smrg else 7826200d7199Smrg func_append newdlfiles " $deplib" 782765eef222Smrg fi 782865eef222Smrg fi 782965eef222Smrg continue 783065eef222Smrg ;; 783165eef222Smrg %DEPLIBS%) 7832b312a94cSmrg alldeplibs=: 783365eef222Smrg continue 783465eef222Smrg ;; 783565eef222Smrg esac # case $deplib 783665eef222Smrg 7837b312a94cSmrg $found || test -f "$lib" \ 7838b312a94cSmrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 783965eef222Smrg 784065eef222Smrg # Check to see that this really is a libtool archive. 784165eef222Smrg func_lalib_unsafe_p "$lib" \ 7842b312a94cSmrg || func_fatal_error "'$lib' is not a valid libtool archive" 784365eef222Smrg 784465eef222Smrg func_dirname "$lib" "" "." 7845b312a94cSmrg ladir=$func_dirname_result 784665eef222Smrg 784765eef222Smrg dlname= 784865eef222Smrg dlopen= 784965eef222Smrg dlpreopen= 785065eef222Smrg libdir= 785165eef222Smrg library_names= 785265eef222Smrg old_library= 785365eef222Smrg inherited_linker_flags= 785465eef222Smrg # If the library was installed with an old release of libtool, 785565eef222Smrg # it will not redefine variables installed, or shouldnotlink 785665eef222Smrg installed=yes 785765eef222Smrg shouldnotlink=no 785865eef222Smrg avoidtemprpath= 785965eef222Smrg 786065eef222Smrg 786165eef222Smrg # Read the .la file 786265eef222Smrg func_source "$lib" 786365eef222Smrg 786465eef222Smrg # Convert "-framework foo" to "foo.ltframework" 786565eef222Smrg if test -n "$inherited_linker_flags"; then 786656957a04Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 786765eef222Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 786865eef222Smrg case " $new_inherited_linker_flags " in 786965eef222Smrg *" $tmp_inherited_linker_flag "*) ;; 7870200d7199Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 787165eef222Smrg esac 787265eef222Smrg done 787365eef222Smrg fi 787456957a04Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7875b312a94cSmrg if test lib,link = "$linkmode,$pass" || 7876b312a94cSmrg test prog,scan = "$linkmode,$pass" || 7877b312a94cSmrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 7878200d7199Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 7879200d7199Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 788065eef222Smrg fi 788165eef222Smrg 7882b312a94cSmrg if test conv = "$pass"; then 788365eef222Smrg # Only check for convenience libraries 788465eef222Smrg deplibs="$lib $deplibs" 788565eef222Smrg if test -z "$libdir"; then 788665eef222Smrg if test -z "$old_library"; then 7887b312a94cSmrg func_fatal_error "cannot find name of link library for '$lib'" 788865eef222Smrg fi 788965eef222Smrg # It is a libtool convenience library, so add in its objects. 7890200d7199Smrg func_append convenience " $ladir/$objdir/$old_library" 7891200d7199Smrg func_append old_convenience " $ladir/$objdir/$old_library" 7892b312a94cSmrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 7893b312a94cSmrg func_fatal_error "'$lib' is not a convenience library" 789465eef222Smrg fi 789565eef222Smrg tmp_libs= 789665eef222Smrg for deplib in $dependency_libs; do 789765eef222Smrg deplibs="$deplib $deplibs" 7898b312a94cSmrg if $opt_preserve_dup_deps; then 789965eef222Smrg case "$tmp_libs " in 7900200d7199Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 790165eef222Smrg esac 790265eef222Smrg fi 7903200d7199Smrg func_append tmp_libs " $deplib" 790465eef222Smrg done 790565eef222Smrg continue 790665eef222Smrg fi # $pass = conv 790765eef222Smrg 790865eef222Smrg 790965eef222Smrg # Get the name of the library we link against. 791065eef222Smrg linklib= 7911200d7199Smrg if test -n "$old_library" && 7912b312a94cSmrg { test yes = "$prefer_static_libs" || 7913b312a94cSmrg test built,no = "$prefer_static_libs,$installed"; }; then 7914200d7199Smrg linklib=$old_library 7915200d7199Smrg else 7916200d7199Smrg for l in $old_library $library_names; do 7917b312a94cSmrg linklib=$l 7918200d7199Smrg done 7919200d7199Smrg fi 792065eef222Smrg if test -z "$linklib"; then 7921b312a94cSmrg func_fatal_error "cannot find name of link library for '$lib'" 792265eef222Smrg fi 792365eef222Smrg 792465eef222Smrg # This library was specified with -dlopen. 7925b312a94cSmrg if test dlopen = "$pass"; then 7926b312a94cSmrg test -z "$libdir" \ 7927b312a94cSmrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 792865eef222Smrg if test -z "$dlname" || 7929b312a94cSmrg test yes != "$dlopen_support" || 7930b312a94cSmrg test no = "$build_libtool_libs" 7931b312a94cSmrg then 793265eef222Smrg # If there is no dlname, no dlopen support or we're linking 793365eef222Smrg # statically, we need to preload. We also need to preload any 793465eef222Smrg # dependent libraries so libltdl's deplib preloader doesn't 793565eef222Smrg # bomb out in the load deplibs phase. 7936200d7199Smrg func_append dlprefiles " $lib $dependency_libs" 793765eef222Smrg else 7938200d7199Smrg func_append newdlfiles " $lib" 793965eef222Smrg fi 794065eef222Smrg continue 794165eef222Smrg fi # $pass = dlopen 794265eef222Smrg 794365eef222Smrg # We need an absolute path. 794465eef222Smrg case $ladir in 7945b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 794665eef222Smrg *) 794765eef222Smrg abs_ladir=`cd "$ladir" && pwd` 794865eef222Smrg if test -z "$abs_ladir"; then 7949b312a94cSmrg func_warning "cannot determine absolute directory name of '$ladir'" 795065eef222Smrg func_warning "passing it literally to the linker, although it might fail" 7951b312a94cSmrg abs_ladir=$ladir 795265eef222Smrg fi 795365eef222Smrg ;; 795465eef222Smrg esac 795565eef222Smrg func_basename "$lib" 7956b312a94cSmrg laname=$func_basename_result 795765eef222Smrg 795865eef222Smrg # Find the relevant object directory and library name. 7959b312a94cSmrg if test yes = "$installed"; then 7960200d7199Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7961b312a94cSmrg func_warning "library '$lib' was moved." 7962b312a94cSmrg dir=$ladir 7963b312a94cSmrg absdir=$abs_ladir 7964b312a94cSmrg libdir=$abs_ladir 796565eef222Smrg else 7966b312a94cSmrg dir=$lt_sysroot$libdir 7967b312a94cSmrg absdir=$lt_sysroot$libdir 796865eef222Smrg fi 7969b312a94cSmrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 797065eef222Smrg else 797165eef222Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 7972b312a94cSmrg dir=$ladir 7973b312a94cSmrg absdir=$abs_ladir 797465eef222Smrg # Remove this search path later 7975200d7199Smrg func_append notinst_path " $abs_ladir" 797665eef222Smrg else 7977b312a94cSmrg dir=$ladir/$objdir 7978b312a94cSmrg absdir=$abs_ladir/$objdir 797965eef222Smrg # Remove this search path later 7980200d7199Smrg func_append notinst_path " $abs_ladir" 798165eef222Smrg fi 798265eef222Smrg fi # $installed = yes 798365eef222Smrg func_stripname 'lib' '.la' "$laname" 798465eef222Smrg name=$func_stripname_result 798565eef222Smrg 798665eef222Smrg # This library was specified with -dlpreopen. 7987b312a94cSmrg if test dlpreopen = "$pass"; then 7988b312a94cSmrg if test -z "$libdir" && test prog = "$linkmode"; then 7989b312a94cSmrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 799065eef222Smrg fi 7991b312a94cSmrg case $host in 7992200d7199Smrg # special handling for platforms with PE-DLLs. 7993200d7199Smrg *cygwin* | *mingw* | *cegcc* ) 7994200d7199Smrg # Linker will automatically link against shared library if both 7995200d7199Smrg # static and shared are present. Therefore, ensure we extract 7996200d7199Smrg # symbols from the import library if a shared library is present 7997200d7199Smrg # (otherwise, the dlopen module name will be incorrect). We do 7998200d7199Smrg # this by putting the import library name into $newdlprefiles. 7999200d7199Smrg # We recover the dlopen module name by 'saving' the la file 8000200d7199Smrg # name in a special purpose variable, and (later) extracting the 8001200d7199Smrg # dlname from the la file. 8002200d7199Smrg if test -n "$dlname"; then 8003200d7199Smrg func_tr_sh "$dir/$linklib" 8004200d7199Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8005200d7199Smrg func_append newdlprefiles " $dir/$linklib" 8006200d7199Smrg else 8007200d7199Smrg func_append newdlprefiles " $dir/$old_library" 8008200d7199Smrg # Keep a list of preopened convenience libraries to check 8009200d7199Smrg # that they are being used correctly in the link pass. 8010200d7199Smrg test -z "$libdir" && \ 8011200d7199Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8012200d7199Smrg fi 8013200d7199Smrg ;; 8014200d7199Smrg * ) 8015200d7199Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8016200d7199Smrg # are required to link). 8017200d7199Smrg if test -n "$old_library"; then 8018200d7199Smrg func_append newdlprefiles " $dir/$old_library" 8019200d7199Smrg # Keep a list of preopened convenience libraries to check 8020200d7199Smrg # that they are being used correctly in the link pass. 8021200d7199Smrg test -z "$libdir" && \ 8022200d7199Smrg func_append dlpreconveniencelibs " $dir/$old_library" 8023200d7199Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8024200d7199Smrg elif test -n "$dlname"; then 8025200d7199Smrg func_append newdlprefiles " $dir/$dlname" 8026200d7199Smrg else 8027200d7199Smrg func_append newdlprefiles " $dir/$linklib" 8028200d7199Smrg fi 8029200d7199Smrg ;; 8030200d7199Smrg esac 803165eef222Smrg fi # $pass = dlpreopen 803265eef222Smrg 803365eef222Smrg if test -z "$libdir"; then 803465eef222Smrg # Link the convenience library 8035b312a94cSmrg if test lib = "$linkmode"; then 803665eef222Smrg deplibs="$dir/$old_library $deplibs" 8037b312a94cSmrg elif test prog,link = "$linkmode,$pass"; then 803865eef222Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 803965eef222Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 804065eef222Smrg else 804165eef222Smrg deplibs="$lib $deplibs" # used for prog,scan pass 804265eef222Smrg fi 804365eef222Smrg continue 804465eef222Smrg fi 804565eef222Smrg 804665eef222Smrg 8047b312a94cSmrg if test prog = "$linkmode" && test link != "$pass"; then 8048200d7199Smrg func_append newlib_search_path " $ladir" 804965eef222Smrg deplibs="$lib $deplibs" 805065eef222Smrg 8051b312a94cSmrg linkalldeplibs=false 8052b312a94cSmrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8053b312a94cSmrg test no = "$build_libtool_libs"; then 8054b312a94cSmrg linkalldeplibs=: 805565eef222Smrg fi 805665eef222Smrg 805765eef222Smrg tmp_libs= 805865eef222Smrg for deplib in $dependency_libs; do 805965eef222Smrg case $deplib in 806065eef222Smrg -L*) func_stripname '-L' '' "$deplib" 8061200d7199Smrg func_resolve_sysroot "$func_stripname_result" 8062200d7199Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 806365eef222Smrg ;; 806465eef222Smrg esac 806565eef222Smrg # Need to link against all dependency_libs? 8066b312a94cSmrg if $linkalldeplibs; then 806765eef222Smrg deplibs="$deplib $deplibs" 806865eef222Smrg else 806965eef222Smrg # Need to hardcode shared library paths 807065eef222Smrg # or/and link against static libraries 807165eef222Smrg newdependency_libs="$deplib $newdependency_libs" 807265eef222Smrg fi 8073b312a94cSmrg if $opt_preserve_dup_deps; then 807465eef222Smrg case "$tmp_libs " in 8075200d7199Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 807665eef222Smrg esac 807765eef222Smrg fi 8078200d7199Smrg func_append tmp_libs " $deplib" 807965eef222Smrg done # for deplib 808065eef222Smrg continue 808165eef222Smrg fi # $linkmode = prog... 808265eef222Smrg 8083b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 808465eef222Smrg if test -n "$library_names" && 8085b312a94cSmrg { { test no = "$prefer_static_libs" || 8086b312a94cSmrg test built,yes = "$prefer_static_libs,$installed"; } || 808765eef222Smrg test -z "$old_library"; }; then 808865eef222Smrg # We need to hardcode the library path 8089b312a94cSmrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 809065eef222Smrg # Make sure the rpath contains only unique directories. 8091b312a94cSmrg case $temp_rpath: in 809265eef222Smrg *"$absdir:"*) ;; 8093200d7199Smrg *) func_append temp_rpath "$absdir:" ;; 809465eef222Smrg esac 809565eef222Smrg fi 809665eef222Smrg 809765eef222Smrg # Hardcode the library path. 809865eef222Smrg # Skip directories that are in the system default run-time 809965eef222Smrg # search path. 810065eef222Smrg case " $sys_lib_dlsearch_path " in 810165eef222Smrg *" $absdir "*) ;; 810265eef222Smrg *) 810365eef222Smrg case "$compile_rpath " in 810465eef222Smrg *" $absdir "*) ;; 8105200d7199Smrg *) func_append compile_rpath " $absdir" ;; 810665eef222Smrg esac 810765eef222Smrg ;; 810865eef222Smrg esac 810965eef222Smrg case " $sys_lib_dlsearch_path " in 811065eef222Smrg *" $libdir "*) ;; 811165eef222Smrg *) 811265eef222Smrg case "$finalize_rpath " in 811365eef222Smrg *" $libdir "*) ;; 8114200d7199Smrg *) func_append finalize_rpath " $libdir" ;; 811565eef222Smrg esac 811665eef222Smrg ;; 811765eef222Smrg esac 811865eef222Smrg fi # $linkmode,$pass = prog,link... 811965eef222Smrg 8120b312a94cSmrg if $alldeplibs && 8121b312a94cSmrg { test pass_all = "$deplibs_check_method" || 8122b312a94cSmrg { test yes = "$build_libtool_libs" && 812365eef222Smrg test -n "$library_names"; }; }; then 812465eef222Smrg # We only need to search for static libraries 812565eef222Smrg continue 812665eef222Smrg fi 812765eef222Smrg fi 812865eef222Smrg 812965eef222Smrg link_static=no # Whether the deplib will be linked statically 813065eef222Smrg use_static_libs=$prefer_static_libs 8131b312a94cSmrg if test built = "$use_static_libs" && test yes = "$installed"; then 813265eef222Smrg use_static_libs=no 813365eef222Smrg fi 813465eef222Smrg if test -n "$library_names" && 8135b312a94cSmrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 813665eef222Smrg case $host in 8137b312a94cSmrg *cygwin* | *mingw* | *cegcc* | *os2*) 813865eef222Smrg # No point in relinking DLLs because paths are not encoded 8139200d7199Smrg func_append notinst_deplibs " $lib" 814065eef222Smrg need_relink=no 814165eef222Smrg ;; 814265eef222Smrg *) 8143b312a94cSmrg if test no = "$installed"; then 8144200d7199Smrg func_append notinst_deplibs " $lib" 814565eef222Smrg need_relink=yes 814665eef222Smrg fi 814765eef222Smrg ;; 814865eef222Smrg esac 814965eef222Smrg # This is a shared library 815065eef222Smrg 815165eef222Smrg # Warn about portability, can't link against -module's on some 815265eef222Smrg # systems (darwin). Don't bleat about dlopened modules though! 8153b312a94cSmrg dlopenmodule= 815465eef222Smrg for dlpremoduletest in $dlprefiles; do 815565eef222Smrg if test "X$dlpremoduletest" = "X$lib"; then 8156b312a94cSmrg dlopenmodule=$dlpremoduletest 815765eef222Smrg break 815865eef222Smrg fi 815965eef222Smrg done 8160b312a94cSmrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 816156957a04Smrg echo 8162b312a94cSmrg if test prog = "$linkmode"; then 816365eef222Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 816465eef222Smrg else 816565eef222Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 816665eef222Smrg fi 816765eef222Smrg $ECHO "*** $linklib is not portable!" 816865eef222Smrg fi 8169b312a94cSmrg if test lib = "$linkmode" && 8170b312a94cSmrg test yes = "$hardcode_into_libs"; then 817165eef222Smrg # Hardcode the library path. 817265eef222Smrg # Skip directories that are in the system default run-time 817365eef222Smrg # search path. 817465eef222Smrg case " $sys_lib_dlsearch_path " in 817565eef222Smrg *" $absdir "*) ;; 817665eef222Smrg *) 817765eef222Smrg case "$compile_rpath " in 817865eef222Smrg *" $absdir "*) ;; 8179200d7199Smrg *) func_append compile_rpath " $absdir" ;; 818065eef222Smrg esac 818165eef222Smrg ;; 818265eef222Smrg esac 818365eef222Smrg case " $sys_lib_dlsearch_path " in 818465eef222Smrg *" $libdir "*) ;; 818565eef222Smrg *) 818665eef222Smrg case "$finalize_rpath " in 818765eef222Smrg *" $libdir "*) ;; 8188200d7199Smrg *) func_append finalize_rpath " $libdir" ;; 818965eef222Smrg esac 819065eef222Smrg ;; 819165eef222Smrg esac 819265eef222Smrg fi 819365eef222Smrg 819465eef222Smrg if test -n "$old_archive_from_expsyms_cmds"; then 819565eef222Smrg # figure out the soname 819665eef222Smrg set dummy $library_names 819765eef222Smrg shift 8198b312a94cSmrg realname=$1 819965eef222Smrg shift 820065eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 820165eef222Smrg # use dlname if we got it. it's perfectly good, no? 820265eef222Smrg if test -n "$dlname"; then 8203b312a94cSmrg soname=$dlname 820465eef222Smrg elif test -n "$soname_spec"; then 820565eef222Smrg # bleh windows 820665eef222Smrg case $host in 8207b312a94cSmrg *cygwin* | mingw* | *cegcc* | *os2*) 820865eef222Smrg func_arith $current - $age 820965eef222Smrg major=$func_arith_result 8210b312a94cSmrg versuffix=-$major 821165eef222Smrg ;; 821265eef222Smrg esac 821365eef222Smrg eval soname=\"$soname_spec\" 821465eef222Smrg else 8215b312a94cSmrg soname=$realname 821665eef222Smrg fi 821765eef222Smrg 821865eef222Smrg # Make a new name for the extract_expsyms_cmds to use 8219b312a94cSmrg soroot=$soname 822065eef222Smrg func_basename "$soroot" 8221b312a94cSmrg soname=$func_basename_result 822265eef222Smrg func_stripname 'lib' '.dll' "$soname" 822365eef222Smrg newlib=libimp-$func_stripname_result.a 822465eef222Smrg 822565eef222Smrg # If the library has no export list, then create one now 822665eef222Smrg if test -f "$output_objdir/$soname-def"; then : 822765eef222Smrg else 8228b312a94cSmrg func_verbose "extracting exported symbol list from '$soname'" 822965eef222Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 823065eef222Smrg fi 823165eef222Smrg 823265eef222Smrg # Create $newlib 823365eef222Smrg if test -f "$output_objdir/$newlib"; then :; else 8234b312a94cSmrg func_verbose "generating import library for '$soname'" 823565eef222Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 823665eef222Smrg fi 823765eef222Smrg # make sure the library variables are pointing to the new library 823865eef222Smrg dir=$output_objdir 823965eef222Smrg linklib=$newlib 824065eef222Smrg fi # test -n "$old_archive_from_expsyms_cmds" 824165eef222Smrg 8242b312a94cSmrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 824365eef222Smrg add_shlibpath= 824465eef222Smrg add_dir= 824565eef222Smrg add= 824665eef222Smrg lib_linked=yes 824765eef222Smrg case $hardcode_action in 824865eef222Smrg immediate | unsupported) 8249b312a94cSmrg if test no = "$hardcode_direct"; then 8250b312a94cSmrg add=$dir/$linklib 825165eef222Smrg case $host in 8252b312a94cSmrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8253b312a94cSmrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 825465eef222Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8255b312a94cSmrg *-*-unixware7*) add_dir=-L$dir ;; 825665eef222Smrg *-*-darwin* ) 8257b312a94cSmrg # if the lib is a (non-dlopened) module then we cannot 825865eef222Smrg # link against it, someone is ignoring the earlier warnings 825965eef222Smrg if /usr/bin/file -L $add 2> /dev/null | 8260b312a94cSmrg $GREP ": [^:]* bundle" >/dev/null; then 826165eef222Smrg if test "X$dlopenmodule" != "X$lib"; then 826265eef222Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8263b312a94cSmrg if test -z "$old_library"; then 826456957a04Smrg echo 826556957a04Smrg echo "*** And there doesn't seem to be a static archive available" 826656957a04Smrg echo "*** The link will probably fail, sorry" 826765eef222Smrg else 8268b312a94cSmrg add=$dir/$old_library 826965eef222Smrg fi 827065eef222Smrg elif test -n "$old_library"; then 8271b312a94cSmrg add=$dir/$old_library 827265eef222Smrg fi 827365eef222Smrg fi 827465eef222Smrg esac 8275b312a94cSmrg elif test no = "$hardcode_minus_L"; then 827665eef222Smrg case $host in 8277b312a94cSmrg *-*-sunos*) add_shlibpath=$dir ;; 827865eef222Smrg esac 8279b312a94cSmrg add_dir=-L$dir 8280b312a94cSmrg add=-l$name 8281b312a94cSmrg elif test no = "$hardcode_shlibpath_var"; then 8282b312a94cSmrg add_shlibpath=$dir 8283b312a94cSmrg add=-l$name 828465eef222Smrg else 828565eef222Smrg lib_linked=no 828665eef222Smrg fi 828765eef222Smrg ;; 828865eef222Smrg relink) 8289b312a94cSmrg if test yes = "$hardcode_direct" && 8290b312a94cSmrg test no = "$hardcode_direct_absolute"; then 8291b312a94cSmrg add=$dir/$linklib 8292b312a94cSmrg elif test yes = "$hardcode_minus_L"; then 8293b312a94cSmrg add_dir=-L$absdir 829465eef222Smrg # Try looking first in the location we're being installed to. 829565eef222Smrg if test -n "$inst_prefix_dir"; then 829665eef222Smrg case $libdir in 829765eef222Smrg [\\/]*) 8298200d7199Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 829965eef222Smrg ;; 830065eef222Smrg esac 830165eef222Smrg fi 8302b312a94cSmrg add=-l$name 8303b312a94cSmrg elif test yes = "$hardcode_shlibpath_var"; then 8304b312a94cSmrg add_shlibpath=$dir 8305b312a94cSmrg add=-l$name 830665eef222Smrg else 830765eef222Smrg lib_linked=no 830865eef222Smrg fi 830965eef222Smrg ;; 831065eef222Smrg *) lib_linked=no ;; 831165eef222Smrg esac 831265eef222Smrg 8313b312a94cSmrg if test yes != "$lib_linked"; then 831465eef222Smrg func_fatal_configuration "unsupported hardcode properties" 831565eef222Smrg fi 831665eef222Smrg 831765eef222Smrg if test -n "$add_shlibpath"; then 831865eef222Smrg case :$compile_shlibpath: in 831965eef222Smrg *":$add_shlibpath:"*) ;; 8320200d7199Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 832165eef222Smrg esac 832265eef222Smrg fi 8323b312a94cSmrg if test prog = "$linkmode"; then 832465eef222Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 832565eef222Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 832665eef222Smrg else 832765eef222Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 832865eef222Smrg test -n "$add" && deplibs="$add $deplibs" 8329b312a94cSmrg if test yes != "$hardcode_direct" && 8330b312a94cSmrg test yes != "$hardcode_minus_L" && 8331b312a94cSmrg test yes = "$hardcode_shlibpath_var"; then 833265eef222Smrg case :$finalize_shlibpath: in 833365eef222Smrg *":$libdir:"*) ;; 8334200d7199Smrg *) func_append finalize_shlibpath "$libdir:" ;; 833565eef222Smrg esac 833665eef222Smrg fi 833765eef222Smrg fi 833865eef222Smrg fi 833965eef222Smrg 8340b312a94cSmrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 834165eef222Smrg add_shlibpath= 834265eef222Smrg add_dir= 834365eef222Smrg add= 834465eef222Smrg # Finalize command for both is simple: just hardcode it. 8345b312a94cSmrg if test yes = "$hardcode_direct" && 8346b312a94cSmrg test no = "$hardcode_direct_absolute"; then 8347b312a94cSmrg add=$libdir/$linklib 8348b312a94cSmrg elif test yes = "$hardcode_minus_L"; then 8349b312a94cSmrg add_dir=-L$libdir 8350b312a94cSmrg add=-l$name 8351b312a94cSmrg elif test yes = "$hardcode_shlibpath_var"; then 835265eef222Smrg case :$finalize_shlibpath: in 835365eef222Smrg *":$libdir:"*) ;; 8354200d7199Smrg *) func_append finalize_shlibpath "$libdir:" ;; 835565eef222Smrg esac 8356b312a94cSmrg add=-l$name 8357b312a94cSmrg elif test yes = "$hardcode_automatic"; then 835865eef222Smrg if test -n "$inst_prefix_dir" && 8359b312a94cSmrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8360b312a94cSmrg add=$inst_prefix_dir$libdir/$linklib 836165eef222Smrg else 8362b312a94cSmrg add=$libdir/$linklib 836365eef222Smrg fi 836465eef222Smrg else 836565eef222Smrg # We cannot seem to hardcode it, guess we'll fake it. 8366b312a94cSmrg add_dir=-L$libdir 836765eef222Smrg # Try looking first in the location we're being installed to. 836865eef222Smrg if test -n "$inst_prefix_dir"; then 836965eef222Smrg case $libdir in 837065eef222Smrg [\\/]*) 8371200d7199Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 837265eef222Smrg ;; 837365eef222Smrg esac 837465eef222Smrg fi 8375b312a94cSmrg add=-l$name 837665eef222Smrg fi 837765eef222Smrg 8378b312a94cSmrg if test prog = "$linkmode"; then 837965eef222Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 838065eef222Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 838165eef222Smrg else 838265eef222Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 838365eef222Smrg test -n "$add" && deplibs="$add $deplibs" 838465eef222Smrg fi 838565eef222Smrg fi 8386b312a94cSmrg elif test prog = "$linkmode"; then 838765eef222Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 838865eef222Smrg # is not unsupported. This is valid on all known static and 838965eef222Smrg # shared platforms. 8390b312a94cSmrg if test unsupported != "$hardcode_direct"; then 8391b312a94cSmrg test -n "$old_library" && linklib=$old_library 839265eef222Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 839365eef222Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 839465eef222Smrg else 839565eef222Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 839665eef222Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 839765eef222Smrg fi 8398b312a94cSmrg elif test yes = "$build_libtool_libs"; then 839965eef222Smrg # Not a shared library 8400b312a94cSmrg if test pass_all != "$deplibs_check_method"; then 840165eef222Smrg # We're trying link a shared library against a static one 840265eef222Smrg # but the system doesn't support it. 840365eef222Smrg 840465eef222Smrg # Just print a warning and add the library to dependency_libs so 840565eef222Smrg # that the program can be linked against the static library. 840656957a04Smrg echo 8407b312a94cSmrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 840856957a04Smrg echo "*** I have the capability to make that library automatically link in when" 840956957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 841056957a04Smrg echo "*** shared version of the library, which you do not appear to have." 8411b312a94cSmrg if test yes = "$module"; then 841256957a04Smrg echo "*** But as you try to build a module library, libtool will still create " 841356957a04Smrg echo "*** a static module, that should work as long as the dlopening application" 841456957a04Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 841565eef222Smrg if test -z "$global_symbol_pipe"; then 841656957a04Smrg echo 841756957a04Smrg echo "*** However, this would only work if libtool was able to extract symbol" 8418b312a94cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 841956957a04Smrg echo "*** not find such a program. So, this module is probably useless." 8420b312a94cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 842165eef222Smrg fi 8422b312a94cSmrg if test no = "$build_old_libs"; then 842365eef222Smrg build_libtool_libs=module 842465eef222Smrg build_old_libs=yes 842565eef222Smrg else 842665eef222Smrg build_libtool_libs=no 842765eef222Smrg fi 842865eef222Smrg fi 842965eef222Smrg else 843065eef222Smrg deplibs="$dir/$old_library $deplibs" 843165eef222Smrg link_static=yes 843265eef222Smrg fi 843365eef222Smrg fi # link shared/static library? 843465eef222Smrg 8435b312a94cSmrg if test lib = "$linkmode"; then 843665eef222Smrg if test -n "$dependency_libs" && 8437b312a94cSmrg { test yes != "$hardcode_into_libs" || 8438b312a94cSmrg test yes = "$build_old_libs" || 8439b312a94cSmrg test yes = "$link_static"; }; then 844065eef222Smrg # Extract -R from dependency_libs 844165eef222Smrg temp_deplibs= 844265eef222Smrg for libdir in $dependency_libs; do 844365eef222Smrg case $libdir in 844465eef222Smrg -R*) func_stripname '-R' '' "$libdir" 844565eef222Smrg temp_xrpath=$func_stripname_result 844665eef222Smrg case " $xrpath " in 844765eef222Smrg *" $temp_xrpath "*) ;; 8448200d7199Smrg *) func_append xrpath " $temp_xrpath";; 844965eef222Smrg esac;; 8450200d7199Smrg *) func_append temp_deplibs " $libdir";; 845165eef222Smrg esac 845265eef222Smrg done 8453b312a94cSmrg dependency_libs=$temp_deplibs 845465eef222Smrg fi 845565eef222Smrg 8456200d7199Smrg func_append newlib_search_path " $absdir" 845765eef222Smrg # Link against this library 8458b312a94cSmrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 845965eef222Smrg # ... and its dependency_libs 846065eef222Smrg tmp_libs= 846165eef222Smrg for deplib in $dependency_libs; do 846265eef222Smrg newdependency_libs="$deplib $newdependency_libs" 8463200d7199Smrg case $deplib in 8464200d7199Smrg -L*) func_stripname '-L' '' "$deplib" 8465200d7199Smrg func_resolve_sysroot "$func_stripname_result";; 8466200d7199Smrg *) func_resolve_sysroot "$deplib" ;; 8467200d7199Smrg esac 8468b312a94cSmrg if $opt_preserve_dup_deps; then 846965eef222Smrg case "$tmp_libs " in 8470200d7199Smrg *" $func_resolve_sysroot_result "*) 8471200d7199Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 847265eef222Smrg esac 847365eef222Smrg fi 8474200d7199Smrg func_append tmp_libs " $func_resolve_sysroot_result" 847565eef222Smrg done 847665eef222Smrg 8477b312a94cSmrg if test no != "$link_all_deplibs"; then 847865eef222Smrg # Add the search paths of all dependency libraries 847965eef222Smrg for deplib in $dependency_libs; do 848056957a04Smrg path= 848165eef222Smrg case $deplib in 8482b312a94cSmrg -L*) path=$deplib ;; 848365eef222Smrg *.la) 8484200d7199Smrg func_resolve_sysroot "$deplib" 8485200d7199Smrg deplib=$func_resolve_sysroot_result 848665eef222Smrg func_dirname "$deplib" "" "." 8487200d7199Smrg dir=$func_dirname_result 848865eef222Smrg # We need an absolute path. 848965eef222Smrg case $dir in 8490b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 849165eef222Smrg *) 849265eef222Smrg absdir=`cd "$dir" && pwd` 849365eef222Smrg if test -z "$absdir"; then 8494b312a94cSmrg func_warning "cannot determine absolute directory name of '$dir'" 8495b312a94cSmrg absdir=$dir 849665eef222Smrg fi 849765eef222Smrg ;; 849865eef222Smrg esac 849965eef222Smrg if $GREP "^installed=no" $deplib > /dev/null; then 850065eef222Smrg case $host in 850165eef222Smrg *-*-darwin*) 850265eef222Smrg depdepl= 8503b312a94cSmrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8504b312a94cSmrg if test -n "$deplibrary_names"; then 8505b312a94cSmrg for tmp in $deplibrary_names; do 850665eef222Smrg depdepl=$tmp 850765eef222Smrg done 8508b312a94cSmrg if test -f "$absdir/$objdir/$depdepl"; then 8509b312a94cSmrg depdepl=$absdir/$objdir/$depdepl 8510b312a94cSmrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 851165eef222Smrg if test -z "$darwin_install_name"; then 8512b312a94cSmrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 851365eef222Smrg fi 8514b312a94cSmrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8515b312a94cSmrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 851665eef222Smrg path= 851765eef222Smrg fi 851865eef222Smrg fi 851965eef222Smrg ;; 852065eef222Smrg *) 8521b312a94cSmrg path=-L$absdir/$objdir 852265eef222Smrg ;; 852365eef222Smrg esac 852465eef222Smrg else 8525b312a94cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 852665eef222Smrg test -z "$libdir" && \ 8527b312a94cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 852865eef222Smrg test "$absdir" != "$libdir" && \ 8529b312a94cSmrg func_warning "'$deplib' seems to be moved" 853065eef222Smrg 8531b312a94cSmrg path=-L$absdir 853265eef222Smrg fi 853365eef222Smrg ;; 853465eef222Smrg esac 853565eef222Smrg case " $deplibs " in 853665eef222Smrg *" $path "*) ;; 853765eef222Smrg *) deplibs="$path $deplibs" ;; 853865eef222Smrg esac 853965eef222Smrg done 854065eef222Smrg fi # link_all_deplibs != no 854165eef222Smrg fi # linkmode = lib 854265eef222Smrg done # for deplib in $libs 8543b312a94cSmrg if test link = "$pass"; then 8544b312a94cSmrg if test prog = "$linkmode"; then 854565eef222Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 854665eef222Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 854765eef222Smrg else 854856957a04Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 854965eef222Smrg fi 855065eef222Smrg fi 8551b312a94cSmrg dependency_libs=$newdependency_libs 8552b312a94cSmrg if test dlpreopen = "$pass"; then 855365eef222Smrg # Link the dlpreopened libraries before other libraries 855465eef222Smrg for deplib in $save_deplibs; do 855565eef222Smrg deplibs="$deplib $deplibs" 855665eef222Smrg done 855765eef222Smrg fi 8558b312a94cSmrg if test dlopen != "$pass"; then 8559b312a94cSmrg test conv = "$pass" || { 856065eef222Smrg # Make sure lib_search_path contains only unique directories. 856165eef222Smrg lib_search_path= 856265eef222Smrg for dir in $newlib_search_path; do 856365eef222Smrg case "$lib_search_path " in 856465eef222Smrg *" $dir "*) ;; 8565200d7199Smrg *) func_append lib_search_path " $dir" ;; 856665eef222Smrg esac 856765eef222Smrg done 856865eef222Smrg newlib_search_path= 8569b312a94cSmrg } 857065eef222Smrg 8571b312a94cSmrg if test prog,link = "$linkmode,$pass"; then 857265eef222Smrg vars="compile_deplibs finalize_deplibs" 8573b312a94cSmrg else 8574b312a94cSmrg vars=deplibs 857565eef222Smrg fi 857665eef222Smrg for var in $vars dependency_libs; do 857765eef222Smrg # Add libraries to $var in reverse order 857865eef222Smrg eval tmp_libs=\"\$$var\" 857965eef222Smrg new_libs= 858065eef222Smrg for deplib in $tmp_libs; do 858165eef222Smrg # FIXME: Pedantically, this is the right thing to do, so 858265eef222Smrg # that some nasty dependency loop isn't accidentally 858365eef222Smrg # broken: 858465eef222Smrg #new_libs="$deplib $new_libs" 858565eef222Smrg # Pragmatically, this seems to cause very few problems in 858665eef222Smrg # practice: 858765eef222Smrg case $deplib in 858865eef222Smrg -L*) new_libs="$deplib $new_libs" ;; 858965eef222Smrg -R*) ;; 859065eef222Smrg *) 859165eef222Smrg # And here is the reason: when a library appears more 859265eef222Smrg # than once as an explicit dependence of a library, or 859365eef222Smrg # is implicitly linked in more than once by the 859465eef222Smrg # compiler, it is considered special, and multiple 859565eef222Smrg # occurrences thereof are not removed. Compare this 859665eef222Smrg # with having the same library being listed as a 859765eef222Smrg # dependency of multiple other libraries: in this case, 859865eef222Smrg # we know (pedantically, we assume) the library does not 859965eef222Smrg # need to be listed more than once, so we keep only the 860065eef222Smrg # last copy. This is not always right, but it is rare 860165eef222Smrg # enough that we require users that really mean to play 860265eef222Smrg # such unportable linking tricks to link the library 860365eef222Smrg # using -Wl,-lname, so that libtool does not consider it 860465eef222Smrg # for duplicate removal. 860565eef222Smrg case " $specialdeplibs " in 860665eef222Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 860765eef222Smrg *) 860865eef222Smrg case " $new_libs " in 860965eef222Smrg *" $deplib "*) ;; 861065eef222Smrg *) new_libs="$deplib $new_libs" ;; 861165eef222Smrg esac 861265eef222Smrg ;; 861365eef222Smrg esac 861465eef222Smrg ;; 861565eef222Smrg esac 861665eef222Smrg done 861765eef222Smrg tmp_libs= 861865eef222Smrg for deplib in $new_libs; do 861965eef222Smrg case $deplib in 862065eef222Smrg -L*) 862165eef222Smrg case " $tmp_libs " in 862265eef222Smrg *" $deplib "*) ;; 8623200d7199Smrg *) func_append tmp_libs " $deplib" ;; 862465eef222Smrg esac 862565eef222Smrg ;; 8626200d7199Smrg *) func_append tmp_libs " $deplib" ;; 862765eef222Smrg esac 862865eef222Smrg done 862965eef222Smrg eval $var=\"$tmp_libs\" 863065eef222Smrg done # for var 863165eef222Smrg fi 8632b312a94cSmrg 8633b312a94cSmrg # Add Sun CC postdeps if required: 8634b312a94cSmrg test CXX = "$tagname" && { 8635b312a94cSmrg case $host_os in 8636b312a94cSmrg linux*) 8637b312a94cSmrg case `$CC -V 2>&1 | sed 5q` in 8638b312a94cSmrg *Sun\ C*) # Sun C++ 5.9 8639b312a94cSmrg func_suncc_cstd_abi 8640b312a94cSmrg 8641b312a94cSmrg if test no != "$suncc_use_cstd_abi"; then 8642b312a94cSmrg func_append postdeps ' -library=Cstd -library=Crun' 8643b312a94cSmrg fi 8644b312a94cSmrg ;; 8645b312a94cSmrg esac 8646b312a94cSmrg ;; 8647b312a94cSmrg 8648b312a94cSmrg solaris*) 8649b312a94cSmrg func_cc_basename "$CC" 8650b312a94cSmrg case $func_cc_basename_result in 8651b312a94cSmrg CC* | sunCC*) 8652b312a94cSmrg func_suncc_cstd_abi 8653b312a94cSmrg 8654b312a94cSmrg if test no != "$suncc_use_cstd_abi"; then 8655b312a94cSmrg func_append postdeps ' -library=Cstd -library=Crun' 8656b312a94cSmrg fi 8657b312a94cSmrg ;; 8658b312a94cSmrg esac 8659b312a94cSmrg ;; 8660b312a94cSmrg esac 8661b312a94cSmrg } 8662b312a94cSmrg 866365eef222Smrg # Last step: remove runtime libs from dependency_libs 866465eef222Smrg # (they stay in deplibs) 866565eef222Smrg tmp_libs= 8666b312a94cSmrg for i in $dependency_libs; do 866765eef222Smrg case " $predeps $postdeps $compiler_lib_search_path " in 866865eef222Smrg *" $i "*) 8669b312a94cSmrg i= 867065eef222Smrg ;; 867165eef222Smrg esac 8672b312a94cSmrg if test -n "$i"; then 8673200d7199Smrg func_append tmp_libs " $i" 867465eef222Smrg fi 867565eef222Smrg done 867665eef222Smrg dependency_libs=$tmp_libs 867765eef222Smrg done # for pass 8678b312a94cSmrg if test prog = "$linkmode"; then 8679b312a94cSmrg dlfiles=$newdlfiles 868065eef222Smrg fi 8681b312a94cSmrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8682b312a94cSmrg dlprefiles=$newdlprefiles 868365eef222Smrg fi 868465eef222Smrg 868565eef222Smrg case $linkmode in 868665eef222Smrg oldlib) 8687b312a94cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8688b312a94cSmrg func_warning "'-dlopen' is ignored for archives" 868965eef222Smrg fi 869065eef222Smrg 869165eef222Smrg case " $deplibs" in 869265eef222Smrg *\ -l* | *\ -L*) 8693b312a94cSmrg func_warning "'-l' and '-L' are ignored for archives" ;; 869465eef222Smrg esac 869565eef222Smrg 869665eef222Smrg test -n "$rpath" && \ 8697b312a94cSmrg func_warning "'-rpath' is ignored for archives" 869865eef222Smrg 869965eef222Smrg test -n "$xrpath" && \ 8700b312a94cSmrg func_warning "'-R' is ignored for archives" 870165eef222Smrg 870265eef222Smrg test -n "$vinfo" && \ 8703b312a94cSmrg func_warning "'-version-info/-version-number' is ignored for archives" 870465eef222Smrg 870565eef222Smrg test -n "$release" && \ 8706b312a94cSmrg func_warning "'-release' is ignored for archives" 870765eef222Smrg 870865eef222Smrg test -n "$export_symbols$export_symbols_regex" && \ 8709b312a94cSmrg func_warning "'-export-symbols' is ignored for archives" 871065eef222Smrg 871165eef222Smrg # Now set the variables for building old libraries. 871265eef222Smrg build_libtool_libs=no 8713b312a94cSmrg oldlibs=$output 8714200d7199Smrg func_append objs "$old_deplibs" 871565eef222Smrg ;; 871665eef222Smrg 871765eef222Smrg lib) 8718b312a94cSmrg # Make sure we only generate libraries of the form 'libNAME.la'. 871965eef222Smrg case $outputname in 872065eef222Smrg lib*) 872165eef222Smrg func_stripname 'lib' '.la' "$outputname" 872265eef222Smrg name=$func_stripname_result 872365eef222Smrg eval shared_ext=\"$shrext_cmds\" 872465eef222Smrg eval libname=\"$libname_spec\" 872565eef222Smrg ;; 872665eef222Smrg *) 8727b312a94cSmrg test no = "$module" \ 8728b312a94cSmrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 872965eef222Smrg 8730b312a94cSmrg if test no != "$need_lib_prefix"; then 873165eef222Smrg # Add the "lib" prefix for modules if required 873265eef222Smrg func_stripname '' '.la' "$outputname" 873365eef222Smrg name=$func_stripname_result 873465eef222Smrg eval shared_ext=\"$shrext_cmds\" 873565eef222Smrg eval libname=\"$libname_spec\" 873665eef222Smrg else 873765eef222Smrg func_stripname '' '.la' "$outputname" 873865eef222Smrg libname=$func_stripname_result 873965eef222Smrg fi 874065eef222Smrg ;; 874165eef222Smrg esac 874265eef222Smrg 874365eef222Smrg if test -n "$objs"; then 8744b312a94cSmrg if test pass_all != "$deplibs_check_method"; then 8745b312a94cSmrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 874665eef222Smrg else 874756957a04Smrg echo 874865eef222Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 874965eef222Smrg $ECHO "*** objects $objs is not portable!" 8750200d7199Smrg func_append libobjs " $objs" 875165eef222Smrg fi 875265eef222Smrg fi 875365eef222Smrg 8754b312a94cSmrg test no = "$dlself" \ 8755b312a94cSmrg || func_warning "'-dlopen self' is ignored for libtool libraries" 875665eef222Smrg 875765eef222Smrg set dummy $rpath 875865eef222Smrg shift 8759b312a94cSmrg test 1 -lt "$#" \ 8760b312a94cSmrg && func_warning "ignoring multiple '-rpath's for a libtool library" 876165eef222Smrg 8762b312a94cSmrg install_libdir=$1 876365eef222Smrg 876465eef222Smrg oldlibs= 876565eef222Smrg if test -z "$rpath"; then 8766b312a94cSmrg if test yes = "$build_libtool_libs"; then 876765eef222Smrg # Building a libtool convenience library. 8768b312a94cSmrg # Some compilers have problems with a '.al' extension so 876965eef222Smrg # convenience libraries should have the same extension an 877065eef222Smrg # archive normally would. 877165eef222Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 877265eef222Smrg build_libtool_libs=convenience 877365eef222Smrg build_old_libs=yes 877465eef222Smrg fi 877565eef222Smrg 877665eef222Smrg test -n "$vinfo" && \ 8777b312a94cSmrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 877865eef222Smrg 877965eef222Smrg test -n "$release" && \ 8780b312a94cSmrg func_warning "'-release' is ignored for convenience libraries" 878165eef222Smrg else 878265eef222Smrg 878365eef222Smrg # Parse the version information argument. 8784b312a94cSmrg save_ifs=$IFS; IFS=: 878565eef222Smrg set dummy $vinfo 0 0 0 878665eef222Smrg shift 8787b312a94cSmrg IFS=$save_ifs 878865eef222Smrg 878965eef222Smrg test -n "$7" && \ 8790b312a94cSmrg func_fatal_help "too many parameters to '-version-info'" 879165eef222Smrg 879265eef222Smrg # convert absolute version numbers to libtool ages 879365eef222Smrg # this retains compatibility with .la files and attempts 879465eef222Smrg # to make the code below a bit more comprehensible 879565eef222Smrg 879665eef222Smrg case $vinfo_number in 879765eef222Smrg yes) 8798b312a94cSmrg number_major=$1 8799b312a94cSmrg number_minor=$2 8800b312a94cSmrg number_revision=$3 880165eef222Smrg # 880265eef222Smrg # There are really only two kinds -- those that 880365eef222Smrg # use the current revision as the major version 880465eef222Smrg # and those that subtract age and use age as 880565eef222Smrg # a minor version. But, then there is irix 8806b312a94cSmrg # that has an extra 1 added just for fun 880765eef222Smrg # 880865eef222Smrg case $version_type in 8809b312a94cSmrg # correct linux to gnu/linux during the next big refactor 8810b312a94cSmrg darwin|freebsd-elf|linux|osf|windows|none) 881165eef222Smrg func_arith $number_major + $number_minor 881265eef222Smrg current=$func_arith_result 8813b312a94cSmrg age=$number_minor 8814b312a94cSmrg revision=$number_revision 881565eef222Smrg ;; 8816b312a94cSmrg freebsd-aout|qnx|sunos) 8817b312a94cSmrg current=$number_major 8818b312a94cSmrg revision=$number_minor 8819b312a94cSmrg age=0 882065eef222Smrg ;; 882165eef222Smrg irix|nonstopux) 882265eef222Smrg func_arith $number_major + $number_minor 882365eef222Smrg current=$func_arith_result 8824b312a94cSmrg age=$number_minor 8825b312a94cSmrg revision=$number_minor 882665eef222Smrg lt_irix_increment=no 882765eef222Smrg ;; 882865eef222Smrg esac 882965eef222Smrg ;; 883065eef222Smrg no) 8831b312a94cSmrg current=$1 8832b312a94cSmrg revision=$2 8833b312a94cSmrg age=$3 883465eef222Smrg ;; 883565eef222Smrg esac 883665eef222Smrg 883765eef222Smrg # Check that each of the things are valid numbers. 883865eef222Smrg case $current in 883965eef222Smrg 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]) ;; 884065eef222Smrg *) 8841b312a94cSmrg func_error "CURRENT '$current' must be a nonnegative integer" 8842b312a94cSmrg func_fatal_error "'$vinfo' is not valid version information" 884365eef222Smrg ;; 884465eef222Smrg esac 884565eef222Smrg 884665eef222Smrg case $revision in 884765eef222Smrg 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]) ;; 884865eef222Smrg *) 8849b312a94cSmrg func_error "REVISION '$revision' must be a nonnegative integer" 8850b312a94cSmrg func_fatal_error "'$vinfo' is not valid version information" 885165eef222Smrg ;; 885265eef222Smrg esac 885365eef222Smrg 885465eef222Smrg case $age in 885565eef222Smrg 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]) ;; 885665eef222Smrg *) 8857b312a94cSmrg func_error "AGE '$age' must be a nonnegative integer" 8858b312a94cSmrg func_fatal_error "'$vinfo' is not valid version information" 885965eef222Smrg ;; 886065eef222Smrg esac 886165eef222Smrg 886265eef222Smrg if test "$age" -gt "$current"; then 8863b312a94cSmrg func_error "AGE '$age' is greater than the current interface number '$current'" 8864b312a94cSmrg func_fatal_error "'$vinfo' is not valid version information" 886565eef222Smrg fi 886665eef222Smrg 886765eef222Smrg # Calculate the version variables. 886865eef222Smrg major= 886965eef222Smrg versuffix= 887065eef222Smrg verstring= 887165eef222Smrg case $version_type in 887265eef222Smrg none) ;; 887365eef222Smrg 887465eef222Smrg darwin) 887565eef222Smrg # Like Linux, but with the current version available in 887665eef222Smrg # verstring for coding it into the library header 887765eef222Smrg func_arith $current - $age 887865eef222Smrg major=.$func_arith_result 8879b312a94cSmrg versuffix=$major.$age.$revision 888065eef222Smrg # Darwin ld doesn't like 0 for these options... 888165eef222Smrg func_arith $current + 1 888265eef222Smrg minor_current=$func_arith_result 8883b312a94cSmrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 888465eef222Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8885b312a94cSmrg # On Darwin other compilers 8886b312a94cSmrg case $CC in 8887b312a94cSmrg nagfor*) 8888b312a94cSmrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 8889b312a94cSmrg ;; 8890b312a94cSmrg *) 8891b312a94cSmrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 8892b312a94cSmrg ;; 8893b312a94cSmrg esac 889465eef222Smrg ;; 889565eef222Smrg 889665eef222Smrg freebsd-aout) 8897b312a94cSmrg major=.$current 8898b312a94cSmrg versuffix=.$current.$revision 889965eef222Smrg ;; 890065eef222Smrg 890165eef222Smrg freebsd-elf) 8902b312a94cSmrg func_arith $current - $age 8903b312a94cSmrg major=.$func_arith_result 8904b312a94cSmrg versuffix=$major.$age.$revision 890565eef222Smrg ;; 890665eef222Smrg 890765eef222Smrg irix | nonstopux) 8908b312a94cSmrg if test no = "$lt_irix_increment"; then 890965eef222Smrg func_arith $current - $age 891065eef222Smrg else 891165eef222Smrg func_arith $current - $age + 1 891265eef222Smrg fi 891365eef222Smrg major=$func_arith_result 891465eef222Smrg 891565eef222Smrg case $version_type in 891665eef222Smrg nonstopux) verstring_prefix=nonstopux ;; 891765eef222Smrg *) verstring_prefix=sgi ;; 891865eef222Smrg esac 8919b312a94cSmrg verstring=$verstring_prefix$major.$revision 892065eef222Smrg 892165eef222Smrg # Add in all the interfaces that we are compatible with. 892265eef222Smrg loop=$revision 8923b312a94cSmrg while test 0 -ne "$loop"; do 892465eef222Smrg func_arith $revision - $loop 892565eef222Smrg iface=$func_arith_result 892665eef222Smrg func_arith $loop - 1 892765eef222Smrg loop=$func_arith_result 8928b312a94cSmrg verstring=$verstring_prefix$major.$iface:$verstring 892965eef222Smrg done 893065eef222Smrg 8931b312a94cSmrg # Before this point, $major must not contain '.'. 893265eef222Smrg major=.$major 8933b312a94cSmrg versuffix=$major.$revision 893465eef222Smrg ;; 893565eef222Smrg 8936b312a94cSmrg linux) # correct to gnu/linux during the next big refactor 893765eef222Smrg func_arith $current - $age 893865eef222Smrg major=.$func_arith_result 8939b312a94cSmrg versuffix=$major.$age.$revision 894065eef222Smrg ;; 894165eef222Smrg 894265eef222Smrg osf) 894365eef222Smrg func_arith $current - $age 894465eef222Smrg major=.$func_arith_result 8945b312a94cSmrg versuffix=.$current.$age.$revision 8946b312a94cSmrg verstring=$current.$age.$revision 894765eef222Smrg 894865eef222Smrg # Add in all the interfaces that we are compatible with. 894965eef222Smrg loop=$age 8950b312a94cSmrg while test 0 -ne "$loop"; do 895165eef222Smrg func_arith $current - $loop 895265eef222Smrg iface=$func_arith_result 895365eef222Smrg func_arith $loop - 1 895465eef222Smrg loop=$func_arith_result 8955b312a94cSmrg verstring=$verstring:$iface.0 895665eef222Smrg done 895765eef222Smrg 895865eef222Smrg # Make executables depend on our current version. 8959b312a94cSmrg func_append verstring ":$current.0" 896065eef222Smrg ;; 896165eef222Smrg 896265eef222Smrg qnx) 8963b312a94cSmrg major=.$current 8964b312a94cSmrg versuffix=.$current 8965b312a94cSmrg ;; 8966b312a94cSmrg 8967b312a94cSmrg sco) 8968b312a94cSmrg major=.$current 8969b312a94cSmrg versuffix=.$current 897065eef222Smrg ;; 897165eef222Smrg 897265eef222Smrg sunos) 8973b312a94cSmrg major=.$current 8974b312a94cSmrg versuffix=.$current.$revision 897565eef222Smrg ;; 897665eef222Smrg 897765eef222Smrg windows) 897865eef222Smrg # Use '-' rather than '.', since we only want one 8979b312a94cSmrg # extension on DOS 8.3 file systems. 898065eef222Smrg func_arith $current - $age 898165eef222Smrg major=$func_arith_result 8982b312a94cSmrg versuffix=-$major 898365eef222Smrg ;; 898465eef222Smrg 898565eef222Smrg *) 8986b312a94cSmrg func_fatal_configuration "unknown library version type '$version_type'" 898765eef222Smrg ;; 898865eef222Smrg esac 898965eef222Smrg 899065eef222Smrg # Clear the version info if we defaulted, and they specified a release. 899165eef222Smrg if test -z "$vinfo" && test -n "$release"; then 899265eef222Smrg major= 899365eef222Smrg case $version_type in 899465eef222Smrg darwin) 899565eef222Smrg # we can't check for "0.0" in archive_cmds due to quoting 899665eef222Smrg # problems, so we reset it completely 899765eef222Smrg verstring= 899865eef222Smrg ;; 899965eef222Smrg *) 9000b312a94cSmrg verstring=0.0 900165eef222Smrg ;; 900265eef222Smrg esac 9003b312a94cSmrg if test no = "$need_version"; then 900465eef222Smrg versuffix= 900565eef222Smrg else 9006b312a94cSmrg versuffix=.0.0 900765eef222Smrg fi 900865eef222Smrg fi 900965eef222Smrg 901065eef222Smrg # Remove version info from name if versioning should be avoided 9011b312a94cSmrg if test yes,no = "$avoid_version,$need_version"; then 901265eef222Smrg major= 901365eef222Smrg versuffix= 9014b312a94cSmrg verstring= 901565eef222Smrg fi 901665eef222Smrg 901765eef222Smrg # Check to see if the archive will have undefined symbols. 9018b312a94cSmrg if test yes = "$allow_undefined"; then 9019b312a94cSmrg if test unsupported = "$allow_undefined_flag"; then 9020b312a94cSmrg if test yes = "$build_old_libs"; then 9021b312a94cSmrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9022b312a94cSmrg build_libtool_libs=no 9023b312a94cSmrg else 9024b312a94cSmrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9025b312a94cSmrg fi 902665eef222Smrg fi 902765eef222Smrg else 902865eef222Smrg # Don't allow undefined symbols. 9029b312a94cSmrg allow_undefined_flag=$no_undefined_flag 903065eef222Smrg fi 903165eef222Smrg 903265eef222Smrg fi 903365eef222Smrg 9034b312a94cSmrg func_generate_dlsyms "$libname" "$libname" : 9035200d7199Smrg func_append libobjs " $symfileobj" 9036b312a94cSmrg test " " = "$libobjs" && libobjs= 903765eef222Smrg 9038b312a94cSmrg if test relink != "$opt_mode"; then 903965eef222Smrg # Remove our outputs, but don't remove object files since they 904065eef222Smrg # may have been created when compiling PIC objects. 904165eef222Smrg removelist= 904265eef222Smrg tempremovelist=`$ECHO "$output_objdir/*"` 904365eef222Smrg for p in $tempremovelist; do 904465eef222Smrg case $p in 904565eef222Smrg *.$objext | *.gcno) 904665eef222Smrg ;; 9047b312a94cSmrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9048b312a94cSmrg if test -n "$precious_files_regex"; then 904965eef222Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 905065eef222Smrg then 905165eef222Smrg continue 905265eef222Smrg fi 905365eef222Smrg fi 9054200d7199Smrg func_append removelist " $p" 905565eef222Smrg ;; 905665eef222Smrg *) ;; 905765eef222Smrg esac 905865eef222Smrg done 905965eef222Smrg test -n "$removelist" && \ 906065eef222Smrg func_show_eval "${RM}r \$removelist" 906165eef222Smrg fi 906265eef222Smrg 906365eef222Smrg # Now set the variables for building old libraries. 9064b312a94cSmrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9065200d7199Smrg func_append oldlibs " $output_objdir/$libname.$libext" 906665eef222Smrg 906765eef222Smrg # Transform .lo files to .o files. 9068b312a94cSmrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 906965eef222Smrg fi 907065eef222Smrg 907165eef222Smrg # Eliminate all temporary directories. 907265eef222Smrg #for path in $notinst_path; do 907356957a04Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 907456957a04Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 907556957a04Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 907665eef222Smrg #done 907765eef222Smrg 907865eef222Smrg if test -n "$xrpath"; then 907965eef222Smrg # If the user specified any rpath flags, then add them. 908065eef222Smrg temp_xrpath= 908165eef222Smrg for libdir in $xrpath; do 9082200d7199Smrg func_replace_sysroot "$libdir" 9083200d7199Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 908465eef222Smrg case "$finalize_rpath " in 908565eef222Smrg *" $libdir "*) ;; 9086200d7199Smrg *) func_append finalize_rpath " $libdir" ;; 908765eef222Smrg esac 908865eef222Smrg done 9089b312a94cSmrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 909065eef222Smrg dependency_libs="$temp_xrpath $dependency_libs" 909165eef222Smrg fi 909265eef222Smrg fi 909365eef222Smrg 909465eef222Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9095b312a94cSmrg old_dlfiles=$dlfiles 909665eef222Smrg dlfiles= 909765eef222Smrg for lib in $old_dlfiles; do 909865eef222Smrg case " $dlprefiles $dlfiles " in 909965eef222Smrg *" $lib "*) ;; 9100200d7199Smrg *) func_append dlfiles " $lib" ;; 910165eef222Smrg esac 910265eef222Smrg done 910365eef222Smrg 910465eef222Smrg # Make sure dlprefiles contains only unique files 9105b312a94cSmrg old_dlprefiles=$dlprefiles 910665eef222Smrg dlprefiles= 910765eef222Smrg for lib in $old_dlprefiles; do 910865eef222Smrg case "$dlprefiles " in 910965eef222Smrg *" $lib "*) ;; 9110200d7199Smrg *) func_append dlprefiles " $lib" ;; 911165eef222Smrg esac 911265eef222Smrg done 911365eef222Smrg 9114b312a94cSmrg if test yes = "$build_libtool_libs"; then 911565eef222Smrg if test -n "$rpath"; then 911665eef222Smrg case $host in 911756957a04Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 911865eef222Smrg # these systems don't actually have a c library (as such)! 911965eef222Smrg ;; 912065eef222Smrg *-*-rhapsody* | *-*-darwin1.[012]) 912165eef222Smrg # Rhapsody C library is in the System framework 9122200d7199Smrg func_append deplibs " System.ltframework" 912365eef222Smrg ;; 912465eef222Smrg *-*-netbsd*) 912565eef222Smrg # Don't link with libc until the a.out ld.so is fixed. 912665eef222Smrg ;; 912765eef222Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 912865eef222Smrg # Do not include libc due to us having libc/libc_r. 912965eef222Smrg ;; 913065eef222Smrg *-*-sco3.2v5* | *-*-sco5v6*) 913165eef222Smrg # Causes problems with __ctype 913265eef222Smrg ;; 913365eef222Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 913465eef222Smrg # Compiler inserts libc in the correct place for threads to work 913565eef222Smrg ;; 913665eef222Smrg *) 913765eef222Smrg # Add libc to deplibs on all other systems if necessary. 9138b312a94cSmrg if test yes = "$build_libtool_need_lc"; then 9139200d7199Smrg func_append deplibs " -lc" 914065eef222Smrg fi 914165eef222Smrg ;; 914265eef222Smrg esac 914365eef222Smrg fi 914465eef222Smrg 914565eef222Smrg # Transform deplibs into only deplibs that can be linked in shared. 914665eef222Smrg name_save=$name 914765eef222Smrg libname_save=$libname 914865eef222Smrg release_save=$release 914965eef222Smrg versuffix_save=$versuffix 915065eef222Smrg major_save=$major 915165eef222Smrg # I'm not sure if I'm treating the release correctly. I think 915265eef222Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 915365eef222Smrg # add it in twice. Is that correct? 9154b312a94cSmrg release= 9155b312a94cSmrg versuffix= 9156b312a94cSmrg major= 915765eef222Smrg newdeplibs= 915865eef222Smrg droppeddeps=no 915965eef222Smrg case $deplibs_check_method in 916065eef222Smrg pass_all) 916165eef222Smrg # Don't check for shared/static. Everything works. 916265eef222Smrg # This might be a little naive. We might want to check 916365eef222Smrg # whether the library exists or not. But this is on 916465eef222Smrg # osf3 & osf4 and I'm not really sure... Just 916565eef222Smrg # implementing what was already the behavior. 916665eef222Smrg newdeplibs=$deplibs 916765eef222Smrg ;; 916865eef222Smrg test_compile) 916965eef222Smrg # This code stresses the "libraries are programs" paradigm to its 917065eef222Smrg # limits. Maybe even breaks it. We compile a program, linking it 917165eef222Smrg # against the deplibs as a proxy for the library. Then we can check 917265eef222Smrg # whether they linked in statically or dynamically with ldd. 917365eef222Smrg $opt_dry_run || $RM conftest.c 917465eef222Smrg cat > conftest.c <<EOF 917565eef222Smrg int main() { return 0; } 917665eef222SmrgEOF 917765eef222Smrg $opt_dry_run || $RM conftest 917865eef222Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 917965eef222Smrg ldd_output=`ldd conftest` 918065eef222Smrg for i in $deplibs; do 918165eef222Smrg case $i in 918265eef222Smrg -l*) 918365eef222Smrg func_stripname -l '' "$i" 918465eef222Smrg name=$func_stripname_result 9185b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 918665eef222Smrg case " $predeps $postdeps " in 918765eef222Smrg *" $i "*) 9188200d7199Smrg func_append newdeplibs " $i" 9189b312a94cSmrg i= 919065eef222Smrg ;; 919165eef222Smrg esac 919265eef222Smrg fi 9193b312a94cSmrg if test -n "$i"; then 919465eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 919565eef222Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 919665eef222Smrg set dummy $deplib_matches; shift 919765eef222Smrg deplib_match=$1 9198b312a94cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9199200d7199Smrg func_append newdeplibs " $i" 920065eef222Smrg else 920165eef222Smrg droppeddeps=yes 920256957a04Smrg echo 920365eef222Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 920456957a04Smrg echo "*** I have the capability to make that library automatically link in when" 920556957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 920656957a04Smrg echo "*** shared version of the library, which I believe you do not have" 920756957a04Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 920856957a04Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 920965eef222Smrg fi 921065eef222Smrg fi 921165eef222Smrg ;; 921265eef222Smrg *) 9213200d7199Smrg func_append newdeplibs " $i" 921465eef222Smrg ;; 921565eef222Smrg esac 921665eef222Smrg done 921765eef222Smrg else 921865eef222Smrg # Error occurred in the first compile. Let's try to salvage 921965eef222Smrg # the situation: Compile a separate program for each library. 922065eef222Smrg for i in $deplibs; do 922165eef222Smrg case $i in 922265eef222Smrg -l*) 922365eef222Smrg func_stripname -l '' "$i" 922465eef222Smrg name=$func_stripname_result 922565eef222Smrg $opt_dry_run || $RM conftest 922665eef222Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 922765eef222Smrg ldd_output=`ldd conftest` 9228b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 922965eef222Smrg case " $predeps $postdeps " in 923065eef222Smrg *" $i "*) 9231200d7199Smrg func_append newdeplibs " $i" 9232b312a94cSmrg i= 923365eef222Smrg ;; 923465eef222Smrg esac 923565eef222Smrg fi 9236b312a94cSmrg if test -n "$i"; then 923765eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 923865eef222Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 923965eef222Smrg set dummy $deplib_matches; shift 924065eef222Smrg deplib_match=$1 9241b312a94cSmrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9242200d7199Smrg func_append newdeplibs " $i" 924365eef222Smrg else 924465eef222Smrg droppeddeps=yes 924556957a04Smrg echo 924665eef222Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 924756957a04Smrg echo "*** I have the capability to make that library automatically link in when" 924856957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 924956957a04Smrg echo "*** shared version of the library, which you do not appear to have" 925056957a04Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 925156957a04Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 925265eef222Smrg fi 925365eef222Smrg fi 925465eef222Smrg else 925565eef222Smrg droppeddeps=yes 925656957a04Smrg echo 925765eef222Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 925856957a04Smrg echo "*** make it link in! You will probably need to install it or some" 925956957a04Smrg echo "*** library that it depends on before this library will be fully" 926056957a04Smrg echo "*** functional. Installing it before continuing would be even better." 926165eef222Smrg fi 926265eef222Smrg ;; 926365eef222Smrg *) 9264200d7199Smrg func_append newdeplibs " $i" 926565eef222Smrg ;; 926665eef222Smrg esac 926765eef222Smrg done 926865eef222Smrg fi 926965eef222Smrg ;; 927065eef222Smrg file_magic*) 927165eef222Smrg set dummy $deplibs_check_method; shift 927265eef222Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 927365eef222Smrg for a_deplib in $deplibs; do 927465eef222Smrg case $a_deplib in 927565eef222Smrg -l*) 927665eef222Smrg func_stripname -l '' "$a_deplib" 927765eef222Smrg name=$func_stripname_result 9278b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 927965eef222Smrg case " $predeps $postdeps " in 928065eef222Smrg *" $a_deplib "*) 9281200d7199Smrg func_append newdeplibs " $a_deplib" 9282b312a94cSmrg a_deplib= 928365eef222Smrg ;; 928465eef222Smrg esac 928565eef222Smrg fi 9286b312a94cSmrg if test -n "$a_deplib"; then 928765eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 9288200d7199Smrg if test -n "$file_magic_glob"; then 9289200d7199Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9290200d7199Smrg else 9291200d7199Smrg libnameglob=$libname 9292200d7199Smrg fi 9293b312a94cSmrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 929465eef222Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9295b312a94cSmrg if test yes = "$want_nocaseglob"; then 9296200d7199Smrg shopt -s nocaseglob 9297200d7199Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9298200d7199Smrg $nocaseglob 9299200d7199Smrg else 9300200d7199Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9301200d7199Smrg fi 930265eef222Smrg for potent_lib in $potential_libs; do 930365eef222Smrg # Follow soft links. 930465eef222Smrg if ls -lLd "$potent_lib" 2>/dev/null | 930565eef222Smrg $GREP " -> " >/dev/null; then 930665eef222Smrg continue 930765eef222Smrg fi 930865eef222Smrg # The statement above tries to avoid entering an 930965eef222Smrg # endless loop below, in case of cyclic links. 931065eef222Smrg # We might still enter an endless loop, since a link 931165eef222Smrg # loop can be closed while we follow links, 931265eef222Smrg # but so what? 9313b312a94cSmrg potlib=$potent_lib 931465eef222Smrg while test -h "$potlib" 2>/dev/null; do 9315b312a94cSmrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 931665eef222Smrg case $potliblink in 9317b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9318b312a94cSmrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 931965eef222Smrg esac 932065eef222Smrg done 932165eef222Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 932265eef222Smrg $SED -e 10q | 932365eef222Smrg $EGREP "$file_magic_regex" > /dev/null; then 9324200d7199Smrg func_append newdeplibs " $a_deplib" 9325b312a94cSmrg a_deplib= 932665eef222Smrg break 2 932765eef222Smrg fi 932865eef222Smrg done 932965eef222Smrg done 933065eef222Smrg fi 9331b312a94cSmrg if test -n "$a_deplib"; then 933265eef222Smrg droppeddeps=yes 933356957a04Smrg echo 933465eef222Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 933556957a04Smrg echo "*** I have the capability to make that library automatically link in when" 933656957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 933756957a04Smrg echo "*** shared version of the library, which you do not appear to have" 933856957a04Smrg echo "*** because I did check the linker path looking for a file starting" 9339b312a94cSmrg if test -z "$potlib"; then 934065eef222Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 934165eef222Smrg else 934265eef222Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 934365eef222Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 934465eef222Smrg fi 934565eef222Smrg fi 934665eef222Smrg ;; 934765eef222Smrg *) 934865eef222Smrg # Add a -L argument. 9349200d7199Smrg func_append newdeplibs " $a_deplib" 935065eef222Smrg ;; 935165eef222Smrg esac 935265eef222Smrg done # Gone through all deplibs. 935365eef222Smrg ;; 935465eef222Smrg match_pattern*) 935565eef222Smrg set dummy $deplibs_check_method; shift 935665eef222Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 935765eef222Smrg for a_deplib in $deplibs; do 935865eef222Smrg case $a_deplib in 935965eef222Smrg -l*) 936065eef222Smrg func_stripname -l '' "$a_deplib" 936165eef222Smrg name=$func_stripname_result 9362b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 936365eef222Smrg case " $predeps $postdeps " in 936465eef222Smrg *" $a_deplib "*) 9365200d7199Smrg func_append newdeplibs " $a_deplib" 9366b312a94cSmrg a_deplib= 936765eef222Smrg ;; 936865eef222Smrg esac 936965eef222Smrg fi 9370b312a94cSmrg if test -n "$a_deplib"; then 937165eef222Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 937265eef222Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 937365eef222Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 937465eef222Smrg for potent_lib in $potential_libs; do 9375b312a94cSmrg potlib=$potent_lib # see symlink-check above in file_magic test 937656957a04Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 937765eef222Smrg $EGREP "$match_pattern_regex" > /dev/null; then 9378200d7199Smrg func_append newdeplibs " $a_deplib" 9379b312a94cSmrg a_deplib= 938065eef222Smrg break 2 938165eef222Smrg fi 938265eef222Smrg done 938365eef222Smrg done 938465eef222Smrg fi 9385b312a94cSmrg if test -n "$a_deplib"; then 938665eef222Smrg droppeddeps=yes 938756957a04Smrg echo 938865eef222Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 938956957a04Smrg echo "*** I have the capability to make that library automatically link in when" 939056957a04Smrg echo "*** you link to this library. But I can only do this if you have a" 939156957a04Smrg echo "*** shared version of the library, which you do not appear to have" 939256957a04Smrg echo "*** because I did check the linker path looking for a file starting" 9393b312a94cSmrg if test -z "$potlib"; then 939465eef222Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 939565eef222Smrg else 939665eef222Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 939765eef222Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 939865eef222Smrg fi 939965eef222Smrg fi 940065eef222Smrg ;; 940165eef222Smrg *) 940265eef222Smrg # Add a -L argument. 9403200d7199Smrg func_append newdeplibs " $a_deplib" 940465eef222Smrg ;; 940565eef222Smrg esac 940665eef222Smrg done # Gone through all deplibs. 940765eef222Smrg ;; 940865eef222Smrg none | unknown | *) 9409b312a94cSmrg newdeplibs= 941056957a04Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9411b312a94cSmrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9412b312a94cSmrg for i in $predeps $postdeps; do 941365eef222Smrg # can't use Xsed below, because $i might contain '/' 9414b312a94cSmrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 941565eef222Smrg done 941665eef222Smrg fi 941756957a04Smrg case $tmp_deplibs in 941856957a04Smrg *[!\ \ ]*) 941956957a04Smrg echo 9420b312a94cSmrg if test none = "$deplibs_check_method"; then 942156957a04Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 942265eef222Smrg else 942356957a04Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 942465eef222Smrg fi 942556957a04Smrg echo "*** All declared inter-library dependencies are being dropped." 942665eef222Smrg droppeddeps=yes 942756957a04Smrg ;; 942856957a04Smrg esac 942965eef222Smrg ;; 943065eef222Smrg esac 943165eef222Smrg versuffix=$versuffix_save 943265eef222Smrg major=$major_save 943365eef222Smrg release=$release_save 943465eef222Smrg libname=$libname_save 943565eef222Smrg name=$name_save 943665eef222Smrg 943765eef222Smrg case $host in 943865eef222Smrg *-*-rhapsody* | *-*-darwin1.[012]) 943965eef222Smrg # On Rhapsody replace the C library with the System framework 944056957a04Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 944165eef222Smrg ;; 944265eef222Smrg esac 944365eef222Smrg 9444b312a94cSmrg if test yes = "$droppeddeps"; then 9445b312a94cSmrg if test yes = "$module"; then 944656957a04Smrg echo 944756957a04Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 944865eef222Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 944956957a04Smrg echo "*** a static module, that should work as long as the dlopening" 945056957a04Smrg echo "*** application is linked with the -dlopen flag." 945165eef222Smrg if test -z "$global_symbol_pipe"; then 945256957a04Smrg echo 945356957a04Smrg echo "*** However, this would only work if libtool was able to extract symbol" 9454b312a94cSmrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 945556957a04Smrg echo "*** not find such a program. So, this module is probably useless." 9456b312a94cSmrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 945765eef222Smrg fi 9458b312a94cSmrg if test no = "$build_old_libs"; then 9459b312a94cSmrg oldlibs=$output_objdir/$libname.$libext 946065eef222Smrg build_libtool_libs=module 946165eef222Smrg build_old_libs=yes 946265eef222Smrg else 946365eef222Smrg build_libtool_libs=no 946465eef222Smrg fi 946565eef222Smrg else 946656957a04Smrg echo "*** The inter-library dependencies that have been dropped here will be" 946756957a04Smrg echo "*** automatically added whenever a program is linked with this library" 946856957a04Smrg echo "*** or is declared to -dlopen it." 946965eef222Smrg 9470b312a94cSmrg if test no = "$allow_undefined"; then 947156957a04Smrg echo 947256957a04Smrg echo "*** Since this library must not contain undefined symbols," 947356957a04Smrg echo "*** because either the platform does not support them or" 947456957a04Smrg echo "*** it was explicitly requested with -no-undefined," 947556957a04Smrg echo "*** libtool will only create a static version of it." 9476b312a94cSmrg if test no = "$build_old_libs"; then 9477b312a94cSmrg oldlibs=$output_objdir/$libname.$libext 947865eef222Smrg build_libtool_libs=module 947965eef222Smrg build_old_libs=yes 948065eef222Smrg else 948165eef222Smrg build_libtool_libs=no 948265eef222Smrg fi 948365eef222Smrg fi 948465eef222Smrg fi 948565eef222Smrg fi 948665eef222Smrg # Done checking deplibs! 948765eef222Smrg deplibs=$newdeplibs 948865eef222Smrg fi 948965eef222Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 949065eef222Smrg case $host in 949165eef222Smrg *-*-darwin*) 949256957a04Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949356957a04Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949456957a04Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 949565eef222Smrg ;; 949665eef222Smrg esac 949765eef222Smrg 949865eef222Smrg # move library search paths that coincide with paths to not yet 949965eef222Smrg # installed libraries to the beginning of the library search list 950065eef222Smrg new_libs= 950165eef222Smrg for path in $notinst_path; do 950265eef222Smrg case " $new_libs " in 950365eef222Smrg *" -L$path/$objdir "*) ;; 950465eef222Smrg *) 950565eef222Smrg case " $deplibs " in 950665eef222Smrg *" -L$path/$objdir "*) 9507200d7199Smrg func_append new_libs " -L$path/$objdir" ;; 950865eef222Smrg esac 950965eef222Smrg ;; 951065eef222Smrg esac 951165eef222Smrg done 951265eef222Smrg for deplib in $deplibs; do 951365eef222Smrg case $deplib in 951465eef222Smrg -L*) 951565eef222Smrg case " $new_libs " in 951665eef222Smrg *" $deplib "*) ;; 9517200d7199Smrg *) func_append new_libs " $deplib" ;; 951865eef222Smrg esac 951965eef222Smrg ;; 9520200d7199Smrg *) func_append new_libs " $deplib" ;; 952165eef222Smrg esac 952265eef222Smrg done 9523b312a94cSmrg deplibs=$new_libs 952465eef222Smrg 952565eef222Smrg # All the library-specific variables (install_libdir is set above). 952665eef222Smrg library_names= 952765eef222Smrg old_library= 952865eef222Smrg dlname= 952965eef222Smrg 953065eef222Smrg # Test again, we may have decided not to build it any more 9531b312a94cSmrg if test yes = "$build_libtool_libs"; then 9532b312a94cSmrg # Remove $wl instances when linking with ld. 9533b312a94cSmrg # FIXME: should test the right _cmds variable. 9534b312a94cSmrg case $archive_cmds in 9535b312a94cSmrg *\$LD\ *) wl= ;; 9536b312a94cSmrg esac 9537b312a94cSmrg if test yes = "$hardcode_into_libs"; then 953865eef222Smrg # Hardcode the library paths 953965eef222Smrg hardcode_libdirs= 954065eef222Smrg dep_rpath= 9541b312a94cSmrg rpath=$finalize_rpath 9542b312a94cSmrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 954365eef222Smrg for libdir in $rpath; do 954465eef222Smrg if test -n "$hardcode_libdir_flag_spec"; then 954565eef222Smrg if test -n "$hardcode_libdir_separator"; then 9546200d7199Smrg func_replace_sysroot "$libdir" 9547200d7199Smrg libdir=$func_replace_sysroot_result 954865eef222Smrg if test -z "$hardcode_libdirs"; then 9549b312a94cSmrg hardcode_libdirs=$libdir 955065eef222Smrg else 955165eef222Smrg # Just accumulate the unique libdirs. 955265eef222Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 955365eef222Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 955465eef222Smrg ;; 955565eef222Smrg *) 9556200d7199Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 955765eef222Smrg ;; 955865eef222Smrg esac 955965eef222Smrg fi 956065eef222Smrg else 956165eef222Smrg eval flag=\"$hardcode_libdir_flag_spec\" 9562200d7199Smrg func_append dep_rpath " $flag" 956365eef222Smrg fi 956465eef222Smrg elif test -n "$runpath_var"; then 956565eef222Smrg case "$perm_rpath " in 956665eef222Smrg *" $libdir "*) ;; 9567b312a94cSmrg *) func_append perm_rpath " $libdir" ;; 956865eef222Smrg esac 956965eef222Smrg fi 957065eef222Smrg done 957165eef222Smrg # Substitute the hardcoded libdirs into the rpath. 957265eef222Smrg if test -n "$hardcode_libdir_separator" && 957365eef222Smrg test -n "$hardcode_libdirs"; then 9574b312a94cSmrg libdir=$hardcode_libdirs 9575b312a94cSmrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 957665eef222Smrg fi 957765eef222Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 957865eef222Smrg # We should set the runpath_var. 957965eef222Smrg rpath= 958065eef222Smrg for dir in $perm_rpath; do 9581200d7199Smrg func_append rpath "$dir:" 958265eef222Smrg done 958365eef222Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 958465eef222Smrg fi 958565eef222Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 958665eef222Smrg fi 9587ef981d24Smrg 9588b312a94cSmrg shlibpath=$finalize_shlibpath 9589b312a94cSmrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 959065eef222Smrg if test -n "$shlibpath"; then 959165eef222Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 959265eef222Smrg fi 9593ef981d24Smrg 959465eef222Smrg # Get the real and link names of the library. 959565eef222Smrg eval shared_ext=\"$shrext_cmds\" 959665eef222Smrg eval library_names=\"$library_names_spec\" 959765eef222Smrg set dummy $library_names 959865eef222Smrg shift 9599b312a94cSmrg realname=$1 960065eef222Smrg shift 9601ef981d24Smrg 960265eef222Smrg if test -n "$soname_spec"; then 960365eef222Smrg eval soname=\"$soname_spec\" 960465eef222Smrg else 9605b312a94cSmrg soname=$realname 960665eef222Smrg fi 960765eef222Smrg if test -z "$dlname"; then 960865eef222Smrg dlname=$soname 960965eef222Smrg fi 9610ef981d24Smrg 9611b312a94cSmrg lib=$output_objdir/$realname 961265eef222Smrg linknames= 961365eef222Smrg for link 961465eef222Smrg do 9615200d7199Smrg func_append linknames " $link" 961665eef222Smrg done 9617ef981d24Smrg 961865eef222Smrg # Use standard objects if they are pic 961956957a04Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 962065eef222Smrg test "X$libobjs" = "X " && libobjs= 9621ef981d24Smrg 962265eef222Smrg delfiles= 962365eef222Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 962465eef222Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9625b312a94cSmrg export_symbols=$output_objdir/$libname.uexp 9626200d7199Smrg func_append delfiles " $export_symbols" 962765eef222Smrg fi 9628ef981d24Smrg 962965eef222Smrg orig_export_symbols= 963065eef222Smrg case $host_os in 963165eef222Smrg cygwin* | mingw* | cegcc*) 963265eef222Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 963365eef222Smrg # exporting using user supplied symfile 9634b312a94cSmrg func_dll_def_p "$export_symbols" || { 963565eef222Smrg # and it's NOT already a .def file. Must figure out 963665eef222Smrg # which of the given symbols are data symbols and tag 963765eef222Smrg # them as such. So, trigger use of export_symbols_cmds. 963865eef222Smrg # export_symbols gets reassigned inside the "prepare 963965eef222Smrg # the list of exported symbols" if statement, so the 964065eef222Smrg # include_expsyms logic still works. 9641b312a94cSmrg orig_export_symbols=$export_symbols 964265eef222Smrg export_symbols= 964365eef222Smrg always_export_symbols=yes 9644b312a94cSmrg } 964565eef222Smrg fi 964665eef222Smrg ;; 964765eef222Smrg esac 9648ef981d24Smrg 964965eef222Smrg # Prepare the list of exported symbols 965065eef222Smrg if test -z "$export_symbols"; then 9651b312a94cSmrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9652b312a94cSmrg func_verbose "generating symbol list for '$libname.la'" 9653b312a94cSmrg export_symbols=$output_objdir/$libname.exp 965465eef222Smrg $opt_dry_run || $RM $export_symbols 965565eef222Smrg cmds=$export_symbols_cmds 9656b312a94cSmrg save_ifs=$IFS; IFS='~' 9657200d7199Smrg for cmd1 in $cmds; do 9658b312a94cSmrg IFS=$save_ifs 9659200d7199Smrg # Take the normal branch if the nm_file_list_spec branch 9660200d7199Smrg # doesn't work or if tool conversion is not needed. 9661200d7199Smrg case $nm_file_list_spec~$to_tool_file_cmd in 9662200d7199Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9663200d7199Smrg try_normal_branch=yes 9664200d7199Smrg eval cmd=\"$cmd1\" 9665200d7199Smrg func_len " $cmd" 9666200d7199Smrg len=$func_len_result 9667200d7199Smrg ;; 9668200d7199Smrg *) 9669200d7199Smrg try_normal_branch=no 9670200d7199Smrg ;; 9671200d7199Smrg esac 9672b312a94cSmrg if test yes = "$try_normal_branch" \ 9673200d7199Smrg && { test "$len" -lt "$max_cmd_len" \ 9674200d7199Smrg || test "$max_cmd_len" -le -1; } 9675200d7199Smrg then 9676200d7199Smrg func_show_eval "$cmd" 'exit $?' 9677200d7199Smrg skipped_export=false 9678200d7199Smrg elif test -n "$nm_file_list_spec"; then 9679200d7199Smrg func_basename "$output" 9680200d7199Smrg output_la=$func_basename_result 9681200d7199Smrg save_libobjs=$libobjs 9682200d7199Smrg save_output=$output 9683b312a94cSmrg output=$output_objdir/$output_la.nm 9684200d7199Smrg func_to_tool_file "$output" 9685200d7199Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9686200d7199Smrg func_append delfiles " $output" 9687200d7199Smrg func_verbose "creating $NM input file list: $output" 9688200d7199Smrg for obj in $save_libobjs; do 9689200d7199Smrg func_to_tool_file "$obj" 9690200d7199Smrg $ECHO "$func_to_tool_file_result" 9691200d7199Smrg done > "$output" 9692200d7199Smrg eval cmd=\"$cmd1\" 969365eef222Smrg func_show_eval "$cmd" 'exit $?' 9694200d7199Smrg output=$save_output 9695200d7199Smrg libobjs=$save_libobjs 969665eef222Smrg skipped_export=false 969765eef222Smrg else 969865eef222Smrg # The command line is too long to execute in one step. 969965eef222Smrg func_verbose "using reloadable object file for export list..." 970065eef222Smrg skipped_export=: 970165eef222Smrg # Break out early, otherwise skipped_export may be 970265eef222Smrg # set to false by a later but shorter cmd. 970365eef222Smrg break 970465eef222Smrg fi 970565eef222Smrg done 9706b312a94cSmrg IFS=$save_ifs 9707b312a94cSmrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 970865eef222Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 970965eef222Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 971065eef222Smrg fi 971165eef222Smrg fi 971265eef222Smrg fi 9713ef981d24Smrg 971465eef222Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9715b312a94cSmrg tmp_export_symbols=$export_symbols 9716b312a94cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 971756957a04Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 971865eef222Smrg fi 9719ef981d24Smrg 9720b312a94cSmrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 972165eef222Smrg # The given exports_symbols file has to be filtered, so filter it. 9722b312a94cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 972365eef222Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9724b312a94cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 972565eef222Smrg # though. Also, the filter scales superlinearly with the number of 972665eef222Smrg # global variables. join(1) would be nice here, but unfortunately 972765eef222Smrg # isn't a blessed tool. 972865eef222Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9729200d7199Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 973065eef222Smrg export_symbols=$output_objdir/$libname.def 973165eef222Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 9732ef981d24Smrg fi 9733ef981d24Smrg 973465eef222Smrg tmp_deplibs= 973565eef222Smrg for test_deplib in $deplibs; do 973665eef222Smrg case " $convenience " in 973765eef222Smrg *" $test_deplib "*) ;; 973865eef222Smrg *) 9739200d7199Smrg func_append tmp_deplibs " $test_deplib" 974065eef222Smrg ;; 974165eef222Smrg esac 974265eef222Smrg done 9743b312a94cSmrg deplibs=$tmp_deplibs 9744ef981d24Smrg 974565eef222Smrg if test -n "$convenience"; then 974665eef222Smrg if test -n "$whole_archive_flag_spec" && 9747b312a94cSmrg test yes = "$compiler_needs_object" && 974865eef222Smrg test -z "$libobjs"; then 974965eef222Smrg # extract the archives, so we have objects to list. 975065eef222Smrg # TODO: could optimize this to just extract one archive. 975165eef222Smrg whole_archive_flag_spec= 975265eef222Smrg fi 975365eef222Smrg if test -n "$whole_archive_flag_spec"; then 975465eef222Smrg save_libobjs=$libobjs 975565eef222Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 975665eef222Smrg test "X$libobjs" = "X " && libobjs= 975765eef222Smrg else 9758b312a94cSmrg gentop=$output_objdir/${outputname}x 9759200d7199Smrg func_append generated " $gentop" 9760ef981d24Smrg 976165eef222Smrg func_extract_archives $gentop $convenience 9762200d7199Smrg func_append libobjs " $func_extract_archives_result" 976365eef222Smrg test "X$libobjs" = "X " && libobjs= 976465eef222Smrg fi 976565eef222Smrg fi 9766ef981d24Smrg 9767b312a94cSmrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 976865eef222Smrg eval flag=\"$thread_safe_flag_spec\" 9769200d7199Smrg func_append linker_flags " $flag" 977065eef222Smrg fi 9771ef981d24Smrg 977265eef222Smrg # Make a backup of the uninstalled library when relinking 9773b312a94cSmrg if test relink = "$opt_mode"; then 977465eef222Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 9775ef981d24Smrg fi 9776ef981d24Smrg 977765eef222Smrg # Do each of the archive commands. 9778b312a94cSmrg if test yes = "$module" && test -n "$module_cmds"; then 977965eef222Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 978065eef222Smrg eval test_cmds=\"$module_expsym_cmds\" 978165eef222Smrg cmds=$module_expsym_cmds 978265eef222Smrg else 978365eef222Smrg eval test_cmds=\"$module_cmds\" 978465eef222Smrg cmds=$module_cmds 978565eef222Smrg fi 978665eef222Smrg else 978765eef222Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 978865eef222Smrg eval test_cmds=\"$archive_expsym_cmds\" 978965eef222Smrg cmds=$archive_expsym_cmds 979065eef222Smrg else 979165eef222Smrg eval test_cmds=\"$archive_cmds\" 979265eef222Smrg cmds=$archive_cmds 979365eef222Smrg fi 9794ef981d24Smrg fi 9795ef981d24Smrg 9796b312a94cSmrg if test : != "$skipped_export" && 979765eef222Smrg func_len " $test_cmds" && 979865eef222Smrg len=$func_len_result && 979965eef222Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 980065eef222Smrg : 980165eef222Smrg else 980265eef222Smrg # The command line is too long to link in one step, link piecewise 980365eef222Smrg # or, if using GNU ld and skipped_export is not :, use a linker 980465eef222Smrg # script. 9805ef981d24Smrg 980665eef222Smrg # Save the value of $output and $libobjs because we want to 980765eef222Smrg # use them later. If we have whole_archive_flag_spec, we 980865eef222Smrg # want to use save_libobjs as it was before 980965eef222Smrg # whole_archive_flag_spec was expanded, because we can't 981065eef222Smrg # assume the linker understands whole_archive_flag_spec. 981165eef222Smrg # This may have to be revisited, in case too many 981265eef222Smrg # convenience libraries get linked in and end up exceeding 981365eef222Smrg # the spec. 981465eef222Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 981565eef222Smrg save_libobjs=$libobjs 981665eef222Smrg fi 981765eef222Smrg save_output=$output 981856957a04Smrg func_basename "$output" 981956957a04Smrg output_la=$func_basename_result 9820ef981d24Smrg 982165eef222Smrg # Clear the reloadable object creation command queue and 982265eef222Smrg # initialize k to one. 982365eef222Smrg test_cmds= 982465eef222Smrg concat_cmds= 982565eef222Smrg objlist= 982665eef222Smrg last_robj= 982765eef222Smrg k=1 9828ef981d24Smrg 9829b312a94cSmrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 9830b312a94cSmrg output=$output_objdir/$output_la.lnkscript 983165eef222Smrg func_verbose "creating GNU ld script: $output" 983256957a04Smrg echo 'INPUT (' > $output 983365eef222Smrg for obj in $save_libobjs 983465eef222Smrg do 9835200d7199Smrg func_to_tool_file "$obj" 9836200d7199Smrg $ECHO "$func_to_tool_file_result" >> $output 983765eef222Smrg done 983856957a04Smrg echo ')' >> $output 9839200d7199Smrg func_append delfiles " $output" 9840200d7199Smrg func_to_tool_file "$output" 9841200d7199Smrg output=$func_to_tool_file_result 9842b312a94cSmrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 9843b312a94cSmrg output=$output_objdir/$output_la.lnk 984465eef222Smrg func_verbose "creating linker input file list: $output" 984565eef222Smrg : > $output 984665eef222Smrg set x $save_libobjs 984765eef222Smrg shift 984865eef222Smrg firstobj= 9849b312a94cSmrg if test yes = "$compiler_needs_object"; then 985065eef222Smrg firstobj="$1 " 985165eef222Smrg shift 985265eef222Smrg fi 985365eef222Smrg for obj 985465eef222Smrg do 9855200d7199Smrg func_to_tool_file "$obj" 9856200d7199Smrg $ECHO "$func_to_tool_file_result" >> $output 985765eef222Smrg done 9858200d7199Smrg func_append delfiles " $output" 9859200d7199Smrg func_to_tool_file "$output" 9860200d7199Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 986165eef222Smrg else 986265eef222Smrg if test -n "$save_libobjs"; then 986365eef222Smrg func_verbose "creating reloadable object files..." 9864b312a94cSmrg output=$output_objdir/$output_la-$k.$objext 986565eef222Smrg eval test_cmds=\"$reload_cmds\" 986665eef222Smrg func_len " $test_cmds" 986765eef222Smrg len0=$func_len_result 986865eef222Smrg len=$len0 986965eef222Smrg 987065eef222Smrg # Loop over the list of objects to be linked. 987165eef222Smrg for obj in $save_libobjs 987265eef222Smrg do 987365eef222Smrg func_len " $obj" 987465eef222Smrg func_arith $len + $func_len_result 987565eef222Smrg len=$func_arith_result 9876b312a94cSmrg if test -z "$objlist" || 987765eef222Smrg test "$len" -lt "$max_cmd_len"; then 987865eef222Smrg func_append objlist " $obj" 987965eef222Smrg else 988065eef222Smrg # The command $test_cmds is almost too long, add a 988165eef222Smrg # command to the queue. 9882b312a94cSmrg if test 1 -eq "$k"; then 988365eef222Smrg # The first file doesn't have a previous command to add. 988456957a04Smrg reload_objs=$objlist 988556957a04Smrg eval concat_cmds=\"$reload_cmds\" 988665eef222Smrg else 988765eef222Smrg # All subsequent reloadable object files will link in 988865eef222Smrg # the last one created. 988956957a04Smrg reload_objs="$objlist $last_robj" 989056957a04Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 989165eef222Smrg fi 9892b312a94cSmrg last_robj=$output_objdir/$output_la-$k.$objext 989365eef222Smrg func_arith $k + 1 989465eef222Smrg k=$func_arith_result 9895b312a94cSmrg output=$output_objdir/$output_la-$k.$objext 989656957a04Smrg objlist=" $obj" 989765eef222Smrg func_len " $last_robj" 989865eef222Smrg func_arith $len0 + $func_len_result 989965eef222Smrg len=$func_arith_result 990065eef222Smrg fi 990165eef222Smrg done 990265eef222Smrg # Handle the remaining objects by creating one last 990365eef222Smrg # reloadable object file. All subsequent reloadable object 990465eef222Smrg # files will link in the last one created. 990565eef222Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 990656957a04Smrg reload_objs="$objlist $last_robj" 9907b312a94cSmrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 990865eef222Smrg if test -n "$last_robj"; then 9909b312a94cSmrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 991065eef222Smrg fi 9911200d7199Smrg func_append delfiles " $output" 9912ef981d24Smrg 991365eef222Smrg else 991465eef222Smrg output= 991565eef222Smrg fi 9916ef981d24Smrg 9917b312a94cSmrg ${skipped_export-false} && { 9918b312a94cSmrg func_verbose "generating symbol list for '$libname.la'" 9919b312a94cSmrg export_symbols=$output_objdir/$libname.exp 992065eef222Smrg $opt_dry_run || $RM $export_symbols 992165eef222Smrg libobjs=$output 992265eef222Smrg # Append the command to create the export file. 992365eef222Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 992465eef222Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 992565eef222Smrg if test -n "$last_robj"; then 992665eef222Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 992765eef222Smrg fi 9928b312a94cSmrg } 9929ef981d24Smrg 993065eef222Smrg test -n "$save_libobjs" && 993165eef222Smrg func_verbose "creating a temporary reloadable object file: $output" 9932ef981d24Smrg 993365eef222Smrg # Loop through the commands generated above and execute them. 9934b312a94cSmrg save_ifs=$IFS; IFS='~' 993565eef222Smrg for cmd in $concat_cmds; do 9936b312a94cSmrg IFS=$save_ifs 9937b312a94cSmrg $opt_quiet || { 993865eef222Smrg func_quote_for_expand "$cmd" 993965eef222Smrg eval "func_echo $func_quote_for_expand_result" 994065eef222Smrg } 994165eef222Smrg $opt_dry_run || eval "$cmd" || { 994265eef222Smrg lt_exit=$? 994365eef222Smrg 994465eef222Smrg # Restore the uninstalled library and exit 9945b312a94cSmrg if test relink = "$opt_mode"; then 994665eef222Smrg ( cd "$output_objdir" && \ 994765eef222Smrg $RM "${realname}T" && \ 994865eef222Smrg $MV "${realname}U" "$realname" ) 994965eef222Smrg fi 9950ef981d24Smrg 995165eef222Smrg exit $lt_exit 995265eef222Smrg } 995365eef222Smrg done 9954b312a94cSmrg IFS=$save_ifs 995565eef222Smrg 995665eef222Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 995765eef222Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 995865eef222Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9959ef981d24Smrg fi 9960ef981d24Smrg fi 9961ef981d24Smrg 9962b312a94cSmrg ${skipped_export-false} && { 996365eef222Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9964b312a94cSmrg tmp_export_symbols=$export_symbols 9965b312a94cSmrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 996656957a04Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 996765eef222Smrg fi 9968ef981d24Smrg 996965eef222Smrg if test -n "$orig_export_symbols"; then 997065eef222Smrg # The given exports_symbols file has to be filtered, so filter it. 9971b312a94cSmrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 997265eef222Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 9973b312a94cSmrg # 's' commands, which not all seds can handle. GNU sed should be fine 997465eef222Smrg # though. Also, the filter scales superlinearly with the number of 997565eef222Smrg # global variables. join(1) would be nice here, but unfortunately 997665eef222Smrg # isn't a blessed tool. 997765eef222Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 9978200d7199Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 997965eef222Smrg export_symbols=$output_objdir/$libname.def 998065eef222Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 998165eef222Smrg fi 9982b312a94cSmrg } 9983ef981d24Smrg 998465eef222Smrg libobjs=$output 998565eef222Smrg # Restore the value of output. 998665eef222Smrg output=$save_output 9987ef981d24Smrg 998865eef222Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 998965eef222Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 999065eef222Smrg test "X$libobjs" = "X " && libobjs= 999165eef222Smrg fi 999265eef222Smrg # Expand the library linking commands again to reset the 999365eef222Smrg # value of $libobjs for piecewise linking. 999465eef222Smrg 999565eef222Smrg # Do each of the archive commands. 9996b312a94cSmrg if test yes = "$module" && test -n "$module_cmds"; then 999765eef222Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 999865eef222Smrg cmds=$module_expsym_cmds 9999ef981d24Smrg else 1000065eef222Smrg cmds=$module_cmds 10001ef981d24Smrg fi 10002ef981d24Smrg else 1000365eef222Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 1000465eef222Smrg cmds=$archive_expsym_cmds 1000565eef222Smrg else 1000665eef222Smrg cmds=$archive_cmds 1000765eef222Smrg fi 10008ef981d24Smrg fi 10009ef981d24Smrg fi 10010ef981d24Smrg 1001165eef222Smrg if test -n "$delfiles"; then 1001265eef222Smrg # Append the command to remove temporary files to $cmds. 1001365eef222Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 1001465eef222Smrg fi 10015ef981d24Smrg 1001665eef222Smrg # Add any objects from preloaded convenience libraries 1001765eef222Smrg if test -n "$dlprefiles"; then 10018b312a94cSmrg gentop=$output_objdir/${outputname}x 10019200d7199Smrg func_append generated " $gentop" 10020ef981d24Smrg 1002165eef222Smrg func_extract_archives $gentop $dlprefiles 10022200d7199Smrg func_append libobjs " $func_extract_archives_result" 1002365eef222Smrg test "X$libobjs" = "X " && libobjs= 10024ef981d24Smrg fi 10025ef981d24Smrg 10026b312a94cSmrg save_ifs=$IFS; IFS='~' 1002765eef222Smrg for cmd in $cmds; do 10028b312a94cSmrg IFS=$sp$nl 1002965eef222Smrg eval cmd=\"$cmd\" 10030b312a94cSmrg IFS=$save_ifs 10031b312a94cSmrg $opt_quiet || { 1003265eef222Smrg func_quote_for_expand "$cmd" 1003365eef222Smrg eval "func_echo $func_quote_for_expand_result" 1003465eef222Smrg } 1003565eef222Smrg $opt_dry_run || eval "$cmd" || { 1003665eef222Smrg lt_exit=$? 10037ef981d24Smrg 1003865eef222Smrg # Restore the uninstalled library and exit 10039b312a94cSmrg if test relink = "$opt_mode"; then 1004065eef222Smrg ( cd "$output_objdir" && \ 1004165eef222Smrg $RM "${realname}T" && \ 1004265eef222Smrg $MV "${realname}U" "$realname" ) 1004365eef222Smrg fi 1004465eef222Smrg 1004565eef222Smrg exit $lt_exit 1004665eef222Smrg } 1004765eef222Smrg done 10048b312a94cSmrg IFS=$save_ifs 1004965eef222Smrg 1005065eef222Smrg # Restore the uninstalled library and exit 10051b312a94cSmrg if test relink = "$opt_mode"; then 1005265eef222Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 1005365eef222Smrg 1005465eef222Smrg if test -n "$convenience"; then 1005565eef222Smrg if test -z "$whole_archive_flag_spec"; then 1005665eef222Smrg func_show_eval '${RM}r "$gentop"' 10057ef981d24Smrg fi 10058ef981d24Smrg fi 10059ef981d24Smrg 1006065eef222Smrg exit $EXIT_SUCCESS 1006165eef222Smrg fi 10062ef981d24Smrg 1006365eef222Smrg # Create links to the real library. 1006465eef222Smrg for linkname in $linknames; do 1006565eef222Smrg if test "$realname" != "$linkname"; then 1006665eef222Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 1006765eef222Smrg fi 1006865eef222Smrg done 1006965eef222Smrg 1007065eef222Smrg # If -module or -export-dynamic was specified, set the dlname. 10071b312a94cSmrg if test yes = "$module" || test yes = "$export_dynamic"; then 1007265eef222Smrg # On all known operating systems, these are identical. 10073b312a94cSmrg dlname=$soname 1007465eef222Smrg fi 1007565eef222Smrg fi 1007665eef222Smrg ;; 1007765eef222Smrg 1007865eef222Smrg obj) 10079b312a94cSmrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10080b312a94cSmrg func_warning "'-dlopen' is ignored for objects" 1008165eef222Smrg fi 1008265eef222Smrg 1008365eef222Smrg case " $deplibs" in 1008465eef222Smrg *\ -l* | *\ -L*) 10085b312a94cSmrg func_warning "'-l' and '-L' are ignored for objects" ;; 1008665eef222Smrg esac 1008765eef222Smrg 1008865eef222Smrg test -n "$rpath" && \ 10089b312a94cSmrg func_warning "'-rpath' is ignored for objects" 1009065eef222Smrg 1009165eef222Smrg test -n "$xrpath" && \ 10092b312a94cSmrg func_warning "'-R' is ignored for objects" 1009365eef222Smrg 1009465eef222Smrg test -n "$vinfo" && \ 10095b312a94cSmrg func_warning "'-version-info' is ignored for objects" 1009665eef222Smrg 1009765eef222Smrg test -n "$release" && \ 10098b312a94cSmrg func_warning "'-release' is ignored for objects" 1009965eef222Smrg 1010065eef222Smrg case $output in 1010165eef222Smrg *.lo) 1010265eef222Smrg test -n "$objs$old_deplibs" && \ 10103b312a94cSmrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 1010465eef222Smrg 1010565eef222Smrg libobj=$output 1010665eef222Smrg func_lo2o "$libobj" 1010765eef222Smrg obj=$func_lo2o_result 1010865eef222Smrg ;; 1010965eef222Smrg *) 1011065eef222Smrg libobj= 10111b312a94cSmrg obj=$output 1011265eef222Smrg ;; 1011365eef222Smrg esac 1011465eef222Smrg 1011565eef222Smrg # Delete the old objects. 1011665eef222Smrg $opt_dry_run || $RM $obj $libobj 1011765eef222Smrg 1011865eef222Smrg # Objects from convenience libraries. This assumes 1011965eef222Smrg # single-version convenience libraries. Whenever we create 1012065eef222Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 1012165eef222Smrg # the extraction. 1012265eef222Smrg reload_conv_objs= 1012365eef222Smrg gentop= 10124b312a94cSmrg # if reload_cmds runs $LD directly, get rid of -Wl from 10125b312a94cSmrg # whole_archive_flag_spec and hope we can get by with turning comma 10126b312a94cSmrg # into space. 10127b312a94cSmrg case $reload_cmds in 10128b312a94cSmrg *\$LD[\ \$]*) wl= ;; 10129b312a94cSmrg esac 1013065eef222Smrg if test -n "$convenience"; then 1013165eef222Smrg if test -n "$whole_archive_flag_spec"; then 1013265eef222Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10133b312a94cSmrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10134b312a94cSmrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 1013565eef222Smrg else 10136b312a94cSmrg gentop=$output_objdir/${obj}x 10137200d7199Smrg func_append generated " $gentop" 1013865eef222Smrg 1013965eef222Smrg func_extract_archives $gentop $convenience 1014065eef222Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 1014165eef222Smrg fi 1014265eef222Smrg fi 10143ef981d24Smrg 10144200d7199Smrg # If we're not building shared, we need to use non_pic_objs 10145b312a94cSmrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10146200d7199Smrg 1014765eef222Smrg # Create the old-style object. 10148b312a94cSmrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10149ef981d24Smrg 10150b312a94cSmrg output=$obj 1015165eef222Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10152ef981d24Smrg 1015365eef222Smrg # Exit if we aren't doing a library object file. 1015465eef222Smrg if test -z "$libobj"; then 1015565eef222Smrg if test -n "$gentop"; then 1015665eef222Smrg func_show_eval '${RM}r "$gentop"' 1015765eef222Smrg fi 10158ef981d24Smrg 1015965eef222Smrg exit $EXIT_SUCCESS 1016065eef222Smrg fi 10161ef981d24Smrg 10162b312a94cSmrg test yes = "$build_libtool_libs" || { 1016365eef222Smrg if test -n "$gentop"; then 1016465eef222Smrg func_show_eval '${RM}r "$gentop"' 1016565eef222Smrg fi 10166ef981d24Smrg 1016765eef222Smrg # Create an invalid libtool object if no PIC, so that we don't 1016865eef222Smrg # accidentally link it into a program. 1016965eef222Smrg # $show "echo timestamp > $libobj" 1017065eef222Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 1017165eef222Smrg exit $EXIT_SUCCESS 10172b312a94cSmrg } 10173ef981d24Smrg 10174b312a94cSmrg if test -n "$pic_flag" || test default != "$pic_mode"; then 1017565eef222Smrg # Only do commands if we really have different PIC objects. 1017665eef222Smrg reload_objs="$libobjs $reload_conv_objs" 10177b312a94cSmrg output=$libobj 1017865eef222Smrg func_execute_cmds "$reload_cmds" 'exit $?' 10179ef981d24Smrg fi 10180ef981d24Smrg 1018165eef222Smrg if test -n "$gentop"; then 1018265eef222Smrg func_show_eval '${RM}r "$gentop"' 1018365eef222Smrg fi 10184ef981d24Smrg 1018565eef222Smrg exit $EXIT_SUCCESS 1018665eef222Smrg ;; 10187ef981d24Smrg 1018865eef222Smrg prog) 1018965eef222Smrg case $host in 1019065eef222Smrg *cygwin*) func_stripname '' '.exe' "$output" 1019165eef222Smrg output=$func_stripname_result.exe;; 10192ef981d24Smrg esac 1019365eef222Smrg test -n "$vinfo" && \ 10194b312a94cSmrg func_warning "'-version-info' is ignored for programs" 10195ef981d24Smrg 1019665eef222Smrg test -n "$release" && \ 10197b312a94cSmrg func_warning "'-release' is ignored for programs" 10198ef981d24Smrg 10199b312a94cSmrg $preload \ 10200b312a94cSmrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10201b312a94cSmrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10202ef981d24Smrg 1020365eef222Smrg case $host in 1020465eef222Smrg *-*-rhapsody* | *-*-darwin1.[012]) 1020565eef222Smrg # On Rhapsody replace the C library is the System framework 1020656957a04Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 1020756957a04Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10208ef981d24Smrg ;; 10209ef981d24Smrg esac 10210ef981d24Smrg 1021165eef222Smrg case $host in 1021265eef222Smrg *-*-darwin*) 1021365eef222Smrg # Don't allow lazy linking, it breaks C++ global constructors 1021465eef222Smrg # But is supposedly fixed on 10.4 or later (yay!). 10215b312a94cSmrg if test CXX = "$tagname"; then 1021665eef222Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 1021765eef222Smrg 10.[0123]) 10218b312a94cSmrg func_append compile_command " $wl-bind_at_load" 10219b312a94cSmrg func_append finalize_command " $wl-bind_at_load" 1022065eef222Smrg ;; 1022165eef222Smrg esac 1022265eef222Smrg fi 1022365eef222Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 1022456957a04Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 1022556957a04Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10226ef981d24Smrg ;; 10227ef981d24Smrg esac 10228ef981d24Smrg 10229ef981d24Smrg 1023065eef222Smrg # move library search paths that coincide with paths to not yet 1023165eef222Smrg # installed libraries to the beginning of the library search list 1023265eef222Smrg new_libs= 1023365eef222Smrg for path in $notinst_path; do 1023465eef222Smrg case " $new_libs " in 1023565eef222Smrg *" -L$path/$objdir "*) ;; 10236ef981d24Smrg *) 1023765eef222Smrg case " $compile_deplibs " in 1023865eef222Smrg *" -L$path/$objdir "*) 10239200d7199Smrg func_append new_libs " -L$path/$objdir" ;; 1024065eef222Smrg esac 10241ef981d24Smrg ;; 10242ef981d24Smrg esac 10243ef981d24Smrg done 1024465eef222Smrg for deplib in $compile_deplibs; do 1024565eef222Smrg case $deplib in 1024665eef222Smrg -L*) 1024765eef222Smrg case " $new_libs " in 1024865eef222Smrg *" $deplib "*) ;; 10249200d7199Smrg *) func_append new_libs " $deplib" ;; 1025065eef222Smrg esac 1025165eef222Smrg ;; 10252200d7199Smrg *) func_append new_libs " $deplib" ;; 1025365eef222Smrg esac 1025465eef222Smrg done 10255b312a94cSmrg compile_deplibs=$new_libs 10256ef981d24Smrg 10257ef981d24Smrg 10258200d7199Smrg func_append compile_command " $compile_deplibs" 10259200d7199Smrg func_append finalize_command " $finalize_deplibs" 10260ef981d24Smrg 1026165eef222Smrg if test -n "$rpath$xrpath"; then 1026265eef222Smrg # If the user specified any rpath flags, then add them. 1026365eef222Smrg for libdir in $rpath $xrpath; do 1026465eef222Smrg # This is the magic to use -rpath. 1026565eef222Smrg case "$finalize_rpath " in 1026665eef222Smrg *" $libdir "*) ;; 10267200d7199Smrg *) func_append finalize_rpath " $libdir" ;; 1026865eef222Smrg esac 1026965eef222Smrg done 1027065eef222Smrg fi 10271ef981d24Smrg 1027265eef222Smrg # Now hardcode the library paths 1027365eef222Smrg rpath= 1027465eef222Smrg hardcode_libdirs= 1027565eef222Smrg for libdir in $compile_rpath $finalize_rpath; do 1027665eef222Smrg if test -n "$hardcode_libdir_flag_spec"; then 1027765eef222Smrg if test -n "$hardcode_libdir_separator"; then 1027865eef222Smrg if test -z "$hardcode_libdirs"; then 10279b312a94cSmrg hardcode_libdirs=$libdir 1028065eef222Smrg else 1028165eef222Smrg # Just accumulate the unique libdirs. 1028265eef222Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1028365eef222Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1028465eef222Smrg ;; 1028565eef222Smrg *) 10286200d7199Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1028765eef222Smrg ;; 1028865eef222Smrg esac 1028965eef222Smrg fi 1029065eef222Smrg else 1029165eef222Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10292200d7199Smrg func_append rpath " $flag" 1029365eef222Smrg fi 1029465eef222Smrg elif test -n "$runpath_var"; then 1029565eef222Smrg case "$perm_rpath " in 10296ef981d24Smrg *" $libdir "*) ;; 10297200d7199Smrg *) func_append perm_rpath " $libdir" ;; 10298ef981d24Smrg esac 1029965eef222Smrg fi 1030065eef222Smrg case $host in 1030165eef222Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10302b312a94cSmrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 1030365eef222Smrg case :$dllsearchpath: in 1030465eef222Smrg *":$libdir:"*) ;; 1030565eef222Smrg ::) dllsearchpath=$libdir;; 10306200d7199Smrg *) func_append dllsearchpath ":$libdir";; 1030765eef222Smrg esac 1030865eef222Smrg case :$dllsearchpath: in 1030965eef222Smrg *":$testbindir:"*) ;; 1031065eef222Smrg ::) dllsearchpath=$testbindir;; 10311200d7199Smrg *) func_append dllsearchpath ":$testbindir";; 1031265eef222Smrg esac 1031365eef222Smrg ;; 1031465eef222Smrg esac 1031565eef222Smrg done 1031665eef222Smrg # Substitute the hardcoded libdirs into the rpath. 1031765eef222Smrg if test -n "$hardcode_libdir_separator" && 1031865eef222Smrg test -n "$hardcode_libdirs"; then 10319b312a94cSmrg libdir=$hardcode_libdirs 1032065eef222Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1032165eef222Smrg fi 10322b312a94cSmrg compile_rpath=$rpath 1032365eef222Smrg 1032465eef222Smrg rpath= 1032565eef222Smrg hardcode_libdirs= 1032665eef222Smrg for libdir in $finalize_rpath; do 1032765eef222Smrg if test -n "$hardcode_libdir_flag_spec"; then 1032865eef222Smrg if test -n "$hardcode_libdir_separator"; then 1032965eef222Smrg if test -z "$hardcode_libdirs"; then 10330b312a94cSmrg hardcode_libdirs=$libdir 1033165eef222Smrg else 1033265eef222Smrg # Just accumulate the unique libdirs. 1033365eef222Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 1033465eef222Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 1033565eef222Smrg ;; 1033665eef222Smrg *) 10337200d7199Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 1033865eef222Smrg ;; 1033965eef222Smrg esac 1034065eef222Smrg fi 1034165eef222Smrg else 1034265eef222Smrg eval flag=\"$hardcode_libdir_flag_spec\" 10343200d7199Smrg func_append rpath " $flag" 1034465eef222Smrg fi 1034565eef222Smrg elif test -n "$runpath_var"; then 1034665eef222Smrg case "$finalize_perm_rpath " in 10347ef981d24Smrg *" $libdir "*) ;; 10348200d7199Smrg *) func_append finalize_perm_rpath " $libdir" ;; 10349ef981d24Smrg esac 10350ef981d24Smrg fi 1035165eef222Smrg done 1035265eef222Smrg # Substitute the hardcoded libdirs into the rpath. 1035365eef222Smrg if test -n "$hardcode_libdir_separator" && 1035465eef222Smrg test -n "$hardcode_libdirs"; then 10355b312a94cSmrg libdir=$hardcode_libdirs 1035665eef222Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 1035765eef222Smrg fi 10358b312a94cSmrg finalize_rpath=$rpath 10359ef981d24Smrg 10360b312a94cSmrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 1036165eef222Smrg # Transform all the library objects into standard objects. 1036256957a04Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036356957a04Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 1036465eef222Smrg fi 10365ef981d24Smrg 10366b312a94cSmrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10367ef981d24Smrg 1036865eef222Smrg # template prelinking step 1036965eef222Smrg if test -n "$prelink_cmds"; then 1037065eef222Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 1037165eef222Smrg fi 10372ef981d24Smrg 10373b312a94cSmrg wrappers_required=: 1037465eef222Smrg case $host in 1037556957a04Smrg *cegcc* | *mingw32ce*) 1037656957a04Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10377b312a94cSmrg wrappers_required=false 1037856957a04Smrg ;; 1037965eef222Smrg *cygwin* | *mingw* ) 10380b312a94cSmrg test yes = "$build_libtool_libs" || wrappers_required=false 1038165eef222Smrg ;; 1038265eef222Smrg *) 10383b312a94cSmrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10384b312a94cSmrg wrappers_required=false 1038565eef222Smrg fi 1038665eef222Smrg ;; 1038765eef222Smrg esac 10388b312a94cSmrg $wrappers_required || { 1038965eef222Smrg # Replace the output file specification. 1039056957a04Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10391b312a94cSmrg link_command=$compile_command$compile_rpath 10392ef981d24Smrg 1039365eef222Smrg # We have no uninstalled library dependencies, so finalize right now. 1039465eef222Smrg exit_status=0 1039565eef222Smrg func_show_eval "$link_command" 'exit_status=$?' 10396ef981d24Smrg 10397200d7199Smrg if test -n "$postlink_cmds"; then 10398200d7199Smrg func_to_tool_file "$output" 10399200d7199Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10400200d7199Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10401200d7199Smrg fi 10402200d7199Smrg 1040365eef222Smrg # Delete the generated files. 10404b312a94cSmrg if test -f "$output_objdir/${outputname}S.$objext"; then 10405b312a94cSmrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 1040665eef222Smrg fi 10407ef981d24Smrg 1040865eef222Smrg exit $exit_status 10409b312a94cSmrg } 10410ef981d24Smrg 1041165eef222Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 1041265eef222Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 1041365eef222Smrg fi 1041465eef222Smrg if test -n "$finalize_shlibpath"; then 1041565eef222Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 1041665eef222Smrg fi 10417ef981d24Smrg 1041865eef222Smrg compile_var= 1041965eef222Smrg finalize_var= 1042065eef222Smrg if test -n "$runpath_var"; then 1042165eef222Smrg if test -n "$perm_rpath"; then 1042265eef222Smrg # We should set the runpath_var. 1042365eef222Smrg rpath= 1042465eef222Smrg for dir in $perm_rpath; do 10425200d7199Smrg func_append rpath "$dir:" 10426ef981d24Smrg done 1042765eef222Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10428ef981d24Smrg fi 1042965eef222Smrg if test -n "$finalize_perm_rpath"; then 1043065eef222Smrg # We should set the runpath_var. 1043165eef222Smrg rpath= 1043265eef222Smrg for dir in $finalize_perm_rpath; do 10433200d7199Smrg func_append rpath "$dir:" 1043465eef222Smrg done 1043565eef222Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 1043665eef222Smrg fi 1043765eef222Smrg fi 10438ef981d24Smrg 10439b312a94cSmrg if test yes = "$no_install"; then 1044065eef222Smrg # We don't need to create a wrapper script. 10441b312a94cSmrg link_command=$compile_var$compile_command$compile_rpath 1044265eef222Smrg # Replace the output file specification. 1044356957a04Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 1044465eef222Smrg # Delete the old output file. 1044565eef222Smrg $opt_dry_run || $RM $output 1044665eef222Smrg # Link the executable and exit 1044765eef222Smrg func_show_eval "$link_command" 'exit $?' 10448200d7199Smrg 10449200d7199Smrg if test -n "$postlink_cmds"; then 10450200d7199Smrg func_to_tool_file "$output" 10451200d7199Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10452200d7199Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10453200d7199Smrg fi 10454200d7199Smrg 1045565eef222Smrg exit $EXIT_SUCCESS 1045665eef222Smrg fi 10457ef981d24Smrg 10458b312a94cSmrg case $hardcode_action,$fast_install in 10459b312a94cSmrg relink,*) 10460b312a94cSmrg # Fast installation is not supported 10461b312a94cSmrg link_command=$compile_var$compile_command$compile_rpath 10462b312a94cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10463ef981d24Smrg 10464b312a94cSmrg func_warning "this platform does not like uninstalled shared libraries" 10465b312a94cSmrg func_warning "'$output' will be relinked during installation" 10466b312a94cSmrg ;; 10467b312a94cSmrg *,yes) 10468b312a94cSmrg link_command=$finalize_var$compile_command$finalize_rpath 10469b312a94cSmrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10470b312a94cSmrg ;; 10471b312a94cSmrg *,no) 10472b312a94cSmrg link_command=$compile_var$compile_command$compile_rpath 10473b312a94cSmrg relink_command=$finalize_var$finalize_command$finalize_rpath 10474b312a94cSmrg ;; 10475b312a94cSmrg *,needless) 10476b312a94cSmrg link_command=$finalize_var$compile_command$finalize_rpath 10477b312a94cSmrg relink_command= 10478b312a94cSmrg ;; 10479b312a94cSmrg esac 10480ef981d24Smrg 1048165eef222Smrg # Replace the output file specification. 1048256957a04Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10483ef981d24Smrg 1048465eef222Smrg # Delete the old output files. 1048565eef222Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10486ef981d24Smrg 1048765eef222Smrg func_show_eval "$link_command" 'exit $?' 10488ef981d24Smrg 10489200d7199Smrg if test -n "$postlink_cmds"; then 10490200d7199Smrg func_to_tool_file "$output_objdir/$outputname" 10491200d7199Smrg 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'` 10492200d7199Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 10493200d7199Smrg fi 10494200d7199Smrg 1049565eef222Smrg # Now create the wrapper script. 1049665eef222Smrg func_verbose "creating $output" 10497ef981d24Smrg 1049865eef222Smrg # Quote the relink command for shipping. 1049965eef222Smrg if test -n "$relink_command"; then 1050065eef222Smrg # Preserve any variables that may affect compiler behavior 1050165eef222Smrg for var in $variables_saved_for_relink; do 1050265eef222Smrg if eval test -z \"\${$var+set}\"; then 1050365eef222Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1050465eef222Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1050565eef222Smrg relink_command="$var=; export $var; $relink_command" 1050665eef222Smrg else 1050765eef222Smrg func_quote_for_eval "$var_value" 1050865eef222Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 1050965eef222Smrg fi 1051065eef222Smrg done 1051165eef222Smrg relink_command="(cd `pwd`; $relink_command)" 1051256957a04Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 1051365eef222Smrg fi 10514ef981d24Smrg 1051565eef222Smrg # Only actually do things if not in dry run mode. 1051665eef222Smrg $opt_dry_run || { 1051765eef222Smrg # win32 will think the script is a binary if it has 1051865eef222Smrg # a .exe suffix, so we strip it off here. 1051965eef222Smrg case $output in 1052065eef222Smrg *.exe) func_stripname '' '.exe' "$output" 1052165eef222Smrg output=$func_stripname_result ;; 1052265eef222Smrg esac 1052365eef222Smrg # test for cygwin because mv fails w/o .exe extensions 10524ef981d24Smrg case $host in 1052565eef222Smrg *cygwin*) 1052665eef222Smrg exeext=.exe 1052765eef222Smrg func_stripname '' '.exe' "$outputname" 1052865eef222Smrg outputname=$func_stripname_result ;; 1052965eef222Smrg *) exeext= ;; 10530ef981d24Smrg esac 1053165eef222Smrg case $host in 1053265eef222Smrg *cygwin* | *mingw* ) 1053365eef222Smrg func_dirname_and_basename "$output" "" "." 1053465eef222Smrg output_name=$func_basename_result 1053565eef222Smrg output_path=$func_dirname_result 10536b312a94cSmrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10537b312a94cSmrg cwrapper=$output_path/$output_name.exe 1053865eef222Smrg $RM $cwrappersource $cwrapper 1053965eef222Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 1054065eef222Smrg 1054165eef222Smrg func_emit_cwrapperexe_src > $cwrappersource 1054265eef222Smrg 1054365eef222Smrg # The wrapper executable is built using the $host compiler, 1054465eef222Smrg # because it contains $host paths and files. If cross- 1054565eef222Smrg # compiling, it, like the target executable, must be 1054665eef222Smrg # executed on the $host or under an emulation environment. 1054765eef222Smrg $opt_dry_run || { 1054865eef222Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 1054965eef222Smrg $STRIP $cwrapper 1055065eef222Smrg } 10551ef981d24Smrg 1055265eef222Smrg # Now, create the wrapper script for func_source use: 1055365eef222Smrg func_ltwrapper_scriptname $cwrapper 1055465eef222Smrg $RM $func_ltwrapper_scriptname_result 1055565eef222Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 1055665eef222Smrg $opt_dry_run || { 1055765eef222Smrg # note: this script will not be executed, so do not chmod. 10558b312a94cSmrg if test "x$build" = "x$host"; then 1055965eef222Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10560ef981d24Smrg else 1056165eef222Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10562ef981d24Smrg fi 1056365eef222Smrg } 1056465eef222Smrg ;; 1056565eef222Smrg * ) 1056665eef222Smrg $RM $output 1056765eef222Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10568ef981d24Smrg 1056965eef222Smrg func_emit_wrapper no > $output 1057065eef222Smrg chmod +x $output 10571ef981d24Smrg ;; 10572ef981d24Smrg esac 1057365eef222Smrg } 1057465eef222Smrg exit $EXIT_SUCCESS 1057565eef222Smrg ;; 1057665eef222Smrg esac 10577ef981d24Smrg 1057865eef222Smrg # See if we need to build an old-fashioned archive. 1057965eef222Smrg for oldlib in $oldlibs; do 10580ef981d24Smrg 10581b312a94cSmrg case $build_libtool_libs in 10582b312a94cSmrg convenience) 10583b312a94cSmrg oldobjs="$libobjs_save $symfileobj" 10584b312a94cSmrg addlibs=$convenience 1058565eef222Smrg build_libtool_libs=no 10586b312a94cSmrg ;; 10587b312a94cSmrg module) 10588b312a94cSmrg oldobjs=$libobjs_save 10589b312a94cSmrg addlibs=$old_convenience 10590b312a94cSmrg build_libtool_libs=no 10591b312a94cSmrg ;; 10592b312a94cSmrg *) 1059365eef222Smrg oldobjs="$old_deplibs $non_pic_objects" 10594b312a94cSmrg $preload && test -f "$symfileobj" \ 10595b312a94cSmrg && func_append oldobjs " $symfileobj" 10596b312a94cSmrg addlibs=$old_convenience 10597b312a94cSmrg ;; 10598b312a94cSmrg esac 10599ef981d24Smrg 1060065eef222Smrg if test -n "$addlibs"; then 10601b312a94cSmrg gentop=$output_objdir/${outputname}x 10602200d7199Smrg func_append generated " $gentop" 10603ef981d24Smrg 1060465eef222Smrg func_extract_archives $gentop $addlibs 10605200d7199Smrg func_append oldobjs " $func_extract_archives_result" 1060665eef222Smrg fi 10607ef981d24Smrg 1060865eef222Smrg # Do each command in the archive commands. 10609b312a94cSmrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 1061065eef222Smrg cmds=$old_archive_from_new_cmds 1061165eef222Smrg else 10612ef981d24Smrg 1061365eef222Smrg # Add any objects from preloaded convenience libraries 1061465eef222Smrg if test -n "$dlprefiles"; then 10615b312a94cSmrg gentop=$output_objdir/${outputname}x 10616200d7199Smrg func_append generated " $gentop" 10617ef981d24Smrg 1061865eef222Smrg func_extract_archives $gentop $dlprefiles 10619200d7199Smrg func_append oldobjs " $func_extract_archives_result" 1062065eef222Smrg fi 10621ef981d24Smrg 1062265eef222Smrg # POSIX demands no paths to be encoded in archives. We have 1062365eef222Smrg # to avoid creating archives with duplicate basenames if we 1062465eef222Smrg # might have to extract them afterwards, e.g., when creating a 1062565eef222Smrg # static archive out of a convenience library, or when linking 1062665eef222Smrg # the entirety of a libtool archive into another (currently 1062765eef222Smrg # not supported by libtool). 1062865eef222Smrg if (for obj in $oldobjs 1062965eef222Smrg do 1063065eef222Smrg func_basename "$obj" 1063165eef222Smrg $ECHO "$func_basename_result" 1063265eef222Smrg done | sort | sort -uc >/dev/null 2>&1); then 1063365eef222Smrg : 1063465eef222Smrg else 1063556957a04Smrg echo "copying selected object files to avoid basename conflicts..." 10636b312a94cSmrg gentop=$output_objdir/${outputname}x 10637200d7199Smrg func_append generated " $gentop" 1063865eef222Smrg func_mkdir_p "$gentop" 1063965eef222Smrg save_oldobjs=$oldobjs 1064065eef222Smrg oldobjs= 1064165eef222Smrg counter=1 1064265eef222Smrg for obj in $save_oldobjs 1064365eef222Smrg do 1064465eef222Smrg func_basename "$obj" 10645b312a94cSmrg objbase=$func_basename_result 1064665eef222Smrg case " $oldobjs " in 1064765eef222Smrg " ") oldobjs=$obj ;; 1064865eef222Smrg *[\ /]"$objbase "*) 1064965eef222Smrg while :; do 1065065eef222Smrg # Make sure we don't pick an alternate name that also 1065165eef222Smrg # overlaps. 1065265eef222Smrg newobj=lt$counter-$objbase 1065365eef222Smrg func_arith $counter + 1 1065465eef222Smrg counter=$func_arith_result 1065565eef222Smrg case " $oldobjs " in 1065665eef222Smrg *[\ /]"$newobj "*) ;; 1065765eef222Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 1065865eef222Smrg esac 1065965eef222Smrg done 1066065eef222Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10661200d7199Smrg func_append oldobjs " $gentop/$newobj" 1066265eef222Smrg ;; 10663200d7199Smrg *) func_append oldobjs " $obj" ;; 1066465eef222Smrg esac 10665ef981d24Smrg done 10666ef981d24Smrg fi 10667b312a94cSmrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10668b312a94cSmrg tool_oldlib=$func_to_tool_file_result 1066965eef222Smrg eval cmds=\"$old_archive_cmds\" 10670ef981d24Smrg 1067165eef222Smrg func_len " $cmds" 1067265eef222Smrg len=$func_len_result 1067365eef222Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 1067465eef222Smrg cmds=$old_archive_cmds 10675200d7199Smrg elif test -n "$archiver_list_spec"; then 10676200d7199Smrg func_verbose "using command file archive linking..." 10677200d7199Smrg for obj in $oldobjs 10678200d7199Smrg do 10679200d7199Smrg func_to_tool_file "$obj" 10680200d7199Smrg $ECHO "$func_to_tool_file_result" 10681200d7199Smrg done > $output_objdir/$libname.libcmd 10682200d7199Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 10683200d7199Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10684200d7199Smrg cmds=$old_archive_cmds 1068565eef222Smrg else 1068665eef222Smrg # the command line is too long to link in one step, link in parts 1068765eef222Smrg func_verbose "using piecewise archive linking..." 1068865eef222Smrg save_RANLIB=$RANLIB 1068965eef222Smrg RANLIB=: 1069065eef222Smrg objlist= 1069165eef222Smrg concat_cmds= 1069265eef222Smrg save_oldobjs=$oldobjs 1069365eef222Smrg oldobjs= 1069465eef222Smrg # Is there a better way of finding the last object in the list? 1069565eef222Smrg for obj in $save_oldobjs 1069665eef222Smrg do 1069765eef222Smrg last_oldobj=$obj 1069865eef222Smrg done 1069965eef222Smrg eval test_cmds=\"$old_archive_cmds\" 1070065eef222Smrg func_len " $test_cmds" 1070165eef222Smrg len0=$func_len_result 1070265eef222Smrg len=$len0 1070365eef222Smrg for obj in $save_oldobjs 1070465eef222Smrg do 1070565eef222Smrg func_len " $obj" 1070665eef222Smrg func_arith $len + $func_len_result 1070765eef222Smrg len=$func_arith_result 1070865eef222Smrg func_append objlist " $obj" 1070965eef222Smrg if test "$len" -lt "$max_cmd_len"; then 1071065eef222Smrg : 1071165eef222Smrg else 1071265eef222Smrg # the above command should be used before it gets too long 1071365eef222Smrg oldobjs=$objlist 10714b312a94cSmrg if test "$obj" = "$last_oldobj"; then 1071565eef222Smrg RANLIB=$save_RANLIB 1071665eef222Smrg fi 1071765eef222Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10718b312a94cSmrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 1071965eef222Smrg objlist= 1072065eef222Smrg len=$len0 1072165eef222Smrg fi 1072265eef222Smrg done 1072365eef222Smrg RANLIB=$save_RANLIB 1072465eef222Smrg oldobjs=$objlist 10725b312a94cSmrg if test -z "$oldobjs"; then 1072665eef222Smrg eval cmds=\"\$concat_cmds\" 1072765eef222Smrg else 1072865eef222Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 1072965eef222Smrg fi 1073065eef222Smrg fi 1073165eef222Smrg fi 1073265eef222Smrg func_execute_cmds "$cmds" 'exit $?' 10733ef981d24Smrg done 10734ef981d24Smrg 1073565eef222Smrg test -n "$generated" && \ 1073665eef222Smrg func_show_eval "${RM}r$generated" 10737ef981d24Smrg 1073865eef222Smrg # Now create the libtool archive. 1073965eef222Smrg case $output in 1074065eef222Smrg *.la) 1074165eef222Smrg old_library= 10742b312a94cSmrg test yes = "$build_old_libs" && old_library=$libname.$libext 1074365eef222Smrg func_verbose "creating $output" 10744ef981d24Smrg 1074565eef222Smrg # Preserve any variables that may affect compiler behavior 1074665eef222Smrg for var in $variables_saved_for_relink; do 1074765eef222Smrg if eval test -z \"\${$var+set}\"; then 1074865eef222Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 1074965eef222Smrg elif eval var_value=\$$var; test -z "$var_value"; then 1075065eef222Smrg relink_command="$var=; export $var; $relink_command" 10751ef981d24Smrg else 1075265eef222Smrg func_quote_for_eval "$var_value" 1075365eef222Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 10754ef981d24Smrg fi 1075565eef222Smrg done 1075665eef222Smrg # Quote the link command for shipping. 10757b312a94cSmrg relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 1075856957a04Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 10759b312a94cSmrg if test yes = "$hardcode_automatic"; then 1076065eef222Smrg relink_command= 1076165eef222Smrg fi 10762ef981d24Smrg 1076365eef222Smrg # Only create the output if not a dry run. 1076465eef222Smrg $opt_dry_run || { 1076565eef222Smrg for installed in no yes; do 10766b312a94cSmrg if test yes = "$installed"; then 1076765eef222Smrg if test -z "$install_libdir"; then 1076865eef222Smrg break 1076965eef222Smrg fi 10770b312a94cSmrg output=$output_objdir/${outputname}i 1077165eef222Smrg # Replace all uninstalled libtool libraries with the installed ones 1077265eef222Smrg newdependency_libs= 1077365eef222Smrg for deplib in $dependency_libs; do 1077465eef222Smrg case $deplib in 1077565eef222Smrg *.la) 1077665eef222Smrg func_basename "$deplib" 10777b312a94cSmrg name=$func_basename_result 10778b312a94cSmrg func_resolve_sysroot "$deplib" 10779b312a94cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 1078065eef222Smrg test -z "$libdir" && \ 10781b312a94cSmrg func_fatal_error "'$deplib' is not a valid libtool archive" 10782200d7199Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 10783200d7199Smrg ;; 10784200d7199Smrg -L*) 10785200d7199Smrg func_stripname -L '' "$deplib" 10786200d7199Smrg func_replace_sysroot "$func_stripname_result" 10787200d7199Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 10788200d7199Smrg ;; 10789200d7199Smrg -R*) 10790200d7199Smrg func_stripname -R '' "$deplib" 10791200d7199Smrg func_replace_sysroot "$func_stripname_result" 10792200d7199Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 1079365eef222Smrg ;; 10794200d7199Smrg *) func_append newdependency_libs " $deplib" ;; 1079565eef222Smrg esac 1079665eef222Smrg done 10797b312a94cSmrg dependency_libs=$newdependency_libs 1079865eef222Smrg newdlfiles= 1079965eef222Smrg 1080065eef222Smrg for lib in $dlfiles; do 1080165eef222Smrg case $lib in 1080265eef222Smrg *.la) 1080365eef222Smrg func_basename "$lib" 10804b312a94cSmrg name=$func_basename_result 10805b312a94cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1080665eef222Smrg test -z "$libdir" && \ 10807b312a94cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10808200d7199Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 1080965eef222Smrg ;; 10810200d7199Smrg *) func_append newdlfiles " $lib" ;; 1081165eef222Smrg esac 1081265eef222Smrg done 10813b312a94cSmrg dlfiles=$newdlfiles 1081465eef222Smrg newdlprefiles= 1081565eef222Smrg for lib in $dlprefiles; do 1081665eef222Smrg case $lib in 1081765eef222Smrg *.la) 1081865eef222Smrg # Only pass preopened files to the pseudo-archive (for 1081965eef222Smrg # eventual linking with the app. that links it) if we 1082065eef222Smrg # didn't already link the preopened objects directly into 1082165eef222Smrg # the library: 1082265eef222Smrg func_basename "$lib" 10823b312a94cSmrg name=$func_basename_result 10824b312a94cSmrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 1082565eef222Smrg test -z "$libdir" && \ 10826b312a94cSmrg func_fatal_error "'$lib' is not a valid libtool archive" 10827200d7199Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 1082865eef222Smrg ;; 1082965eef222Smrg esac 1083065eef222Smrg done 10831b312a94cSmrg dlprefiles=$newdlprefiles 1083265eef222Smrg else 1083365eef222Smrg newdlfiles= 1083465eef222Smrg for lib in $dlfiles; do 1083565eef222Smrg case $lib in 10836b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1083765eef222Smrg *) abs=`pwd`"/$lib" ;; 1083865eef222Smrg esac 10839200d7199Smrg func_append newdlfiles " $abs" 1084065eef222Smrg done 10841b312a94cSmrg dlfiles=$newdlfiles 1084265eef222Smrg newdlprefiles= 1084365eef222Smrg for lib in $dlprefiles; do 1084465eef222Smrg case $lib in 10845b312a94cSmrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 1084665eef222Smrg *) abs=`pwd`"/$lib" ;; 1084765eef222Smrg esac 10848200d7199Smrg func_append newdlprefiles " $abs" 1084965eef222Smrg done 10850b312a94cSmrg dlprefiles=$newdlprefiles 1085165eef222Smrg fi 1085265eef222Smrg $RM $output 1085365eef222Smrg # place dlname in correct position for cygwin 1085456957a04Smrg # In fact, it would be nice if we could use this code for all target 1085556957a04Smrg # systems that can't hard-code library paths into their executables 1085656957a04Smrg # and that have no shared library path variable independent of PATH, 1085756957a04Smrg # but it turns out we can't easily determine that from inspecting 1085856957a04Smrg # libtool variables, so we have to hard-code the OSs to which it 1085956957a04Smrg # applies here; at the moment, that means platforms that use the PE 1086056957a04Smrg # object format with DLL files. See the long comment at the top of 1086156957a04Smrg # tests/bindir.at for full details. 1086265eef222Smrg tdlname=$dlname 1086365eef222Smrg case $host,$output,$installed,$module,$dlname in 1086456957a04Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 1086556957a04Smrg # If a -bindir argument was supplied, place the dll there. 10866b312a94cSmrg if test -n "$bindir"; then 1086756957a04Smrg func_relative_path "$install_libdir" "$bindir" 10868b312a94cSmrg tdlname=$func_relative_path_result/$dlname 1086956957a04Smrg else 1087056957a04Smrg # Otherwise fall back on heuristic. 1087156957a04Smrg tdlname=../bin/$dlname 1087256957a04Smrg fi 1087356957a04Smrg ;; 1087465eef222Smrg esac 1087565eef222Smrg $ECHO > $output "\ 1087665eef222Smrg# $outputname - a libtool library file 10877b312a94cSmrg# Generated by $PROGRAM (GNU $PACKAGE) $VERSION 1087865eef222Smrg# 1087965eef222Smrg# Please DO NOT delete this file! 1088065eef222Smrg# It is necessary for linking the library. 10881ef981d24Smrg 1088265eef222Smrg# The name that we can dlopen(3). 1088365eef222Smrgdlname='$tdlname' 10884ef981d24Smrg 1088565eef222Smrg# Names of this library. 1088665eef222Smrglibrary_names='$library_names' 10887ef981d24Smrg 1088865eef222Smrg# The name of the static archive. 1088965eef222Smrgold_library='$old_library' 10890ef981d24Smrg 10891b312a94cSmrg# Linker flags that cannot go in dependency_libs. 1089265eef222Smrginherited_linker_flags='$new_inherited_linker_flags' 10893ef981d24Smrg 1089465eef222Smrg# Libraries that this one depends upon. 1089565eef222Smrgdependency_libs='$dependency_libs' 10896ef981d24Smrg 1089765eef222Smrg# Names of additional weak libraries provided by this library 1089865eef222Smrgweak_library_names='$weak_libs' 10899ef981d24Smrg 1090065eef222Smrg# Version information for $libname. 1090165eef222Smrgcurrent=$current 1090265eef222Smrgage=$age 1090365eef222Smrgrevision=$revision 10904ef981d24Smrg 1090565eef222Smrg# Is this an already installed library? 1090665eef222Smrginstalled=$installed 10907ef981d24Smrg 1090865eef222Smrg# Should we warn about portability when linking against -modules? 1090965eef222Smrgshouldnotlink=$module 10910ef981d24Smrg 1091165eef222Smrg# Files to dlopen/dlpreopen 1091265eef222Smrgdlopen='$dlfiles' 1091365eef222Smrgdlpreopen='$dlprefiles' 10914ef981d24Smrg 1091565eef222Smrg# Directory that this library needs to be installed in: 1091665eef222Smrglibdir='$install_libdir'" 10917b312a94cSmrg if test no,yes = "$installed,$need_relink"; then 1091865eef222Smrg $ECHO >> $output "\ 1091965eef222Smrgrelink_command=\"$relink_command\"" 1092065eef222Smrg fi 1092165eef222Smrg done 1092265eef222Smrg } 10923ef981d24Smrg 1092465eef222Smrg # Do a symbolic link so that the libtool archive can be found in 1092565eef222Smrg # LD_LIBRARY_PATH before the program is installed. 1092665eef222Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 1092765eef222Smrg ;; 1092865eef222Smrg esac 1092965eef222Smrg exit $EXIT_SUCCESS 1093065eef222Smrg} 10931ef981d24Smrg 10932b312a94cSmrgif test link = "$opt_mode" || test relink = "$opt_mode"; then 10933b312a94cSmrg func_mode_link ${1+"$@"} 10934b312a94cSmrgfi 10935ef981d24Smrg 10936ef981d24Smrg 1093765eef222Smrg# func_mode_uninstall arg... 1093865eef222Smrgfunc_mode_uninstall () 1093965eef222Smrg{ 10940b312a94cSmrg $debug_cmd 10941b312a94cSmrg 10942b312a94cSmrg RM=$nonopt 10943ef981d24Smrg files= 10944b312a94cSmrg rmforce=false 10945ef981d24Smrg exit_status=0 10946ef981d24Smrg 10947ef981d24Smrg # This variable tells wrapper scripts just to set variables rather 10948ef981d24Smrg # than running their programs. 10949b312a94cSmrg libtool_install_magic=$magic 10950ef981d24Smrg 10951ef981d24Smrg for arg 10952ef981d24Smrg do 10953ef981d24Smrg case $arg in 10954b312a94cSmrg -f) func_append RM " $arg"; rmforce=: ;; 10955200d7199Smrg -*) func_append RM " $arg" ;; 10956200d7199Smrg *) func_append files " $arg" ;; 10957ef981d24Smrg esac 10958ef981d24Smrg done 10959ef981d24Smrg 1096065eef222Smrg test -z "$RM" && \ 1096165eef222Smrg func_fatal_help "you must specify an RM program" 10962ef981d24Smrg 10963ef981d24Smrg rmdirs= 10964ef981d24Smrg 10965ef981d24Smrg for file in $files; do 1096665eef222Smrg func_dirname "$file" "" "." 10967b312a94cSmrg dir=$func_dirname_result 10968b312a94cSmrg if test . = "$dir"; then 10969b312a94cSmrg odir=$objdir 10970ef981d24Smrg else 10971b312a94cSmrg odir=$dir/$objdir 10972ef981d24Smrg fi 1097365eef222Smrg func_basename "$file" 10974b312a94cSmrg name=$func_basename_result 10975b312a94cSmrg test uninstall = "$opt_mode" && odir=$dir 10976ef981d24Smrg 10977200d7199Smrg # Remember odir for removal later, being careful to avoid duplicates 10978b312a94cSmrg if test clean = "$opt_mode"; then 10979ef981d24Smrg case " $rmdirs " in 10980200d7199Smrg *" $odir "*) ;; 10981200d7199Smrg *) func_append rmdirs " $odir" ;; 10982ef981d24Smrg esac 10983ef981d24Smrg fi 10984ef981d24Smrg 10985ef981d24Smrg # Don't error if the file doesn't exist and rm -f was used. 1098665eef222Smrg if { test -L "$file"; } >/dev/null 2>&1 || 1098765eef222Smrg { test -h "$file"; } >/dev/null 2>&1 || 1098865eef222Smrg test -f "$file"; then 10989ef981d24Smrg : 10990ef981d24Smrg elif test -d "$file"; then 10991ef981d24Smrg exit_status=1 10992ef981d24Smrg continue 10993b312a94cSmrg elif $rmforce; then 10994ef981d24Smrg continue 10995ef981d24Smrg fi 10996ef981d24Smrg 10997b312a94cSmrg rmfiles=$file 10998ef981d24Smrg 10999ef981d24Smrg case $name in 11000ef981d24Smrg *.la) 11001ef981d24Smrg # Possibly a libtool archive, so verify it. 1100265eef222Smrg if func_lalib_p "$file"; then 1100365eef222Smrg func_source $dir/$name 11004ef981d24Smrg 11005ef981d24Smrg # Delete the libtool libraries and symlinks. 11006ef981d24Smrg for n in $library_names; do 11007200d7199Smrg func_append rmfiles " $odir/$n" 11008ef981d24Smrg done 11009200d7199Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11010ef981d24Smrg 11011b312a94cSmrg case $opt_mode in 11012ef981d24Smrg clean) 11013200d7199Smrg case " $library_names " in 11014ef981d24Smrg *" $dlname "*) ;; 11015200d7199Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11016ef981d24Smrg esac 11017200d7199Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11018ef981d24Smrg ;; 11019ef981d24Smrg uninstall) 11020ef981d24Smrg if test -n "$library_names"; then 11021ef981d24Smrg # Do each command in the postuninstall commands. 11022b312a94cSmrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11023ef981d24Smrg fi 11024ef981d24Smrg 11025ef981d24Smrg if test -n "$old_library"; then 11026ef981d24Smrg # Do each command in the old_postuninstall commands. 11027b312a94cSmrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11028ef981d24Smrg fi 11029ef981d24Smrg # FIXME: should reinstall the best remaining shared library. 11030ef981d24Smrg ;; 11031ef981d24Smrg esac 11032ef981d24Smrg fi 11033ef981d24Smrg ;; 11034ef981d24Smrg 11035ef981d24Smrg *.lo) 11036ef981d24Smrg # Possibly a libtool object, so verify it. 1103765eef222Smrg if func_lalib_p "$file"; then 11038ef981d24Smrg 11039ef981d24Smrg # Read the .lo file 1104065eef222Smrg func_source $dir/$name 11041ef981d24Smrg 11042ef981d24Smrg # Add PIC object to the list of files to remove. 11043b312a94cSmrg if test -n "$pic_object" && test none != "$pic_object"; then 11044200d7199Smrg func_append rmfiles " $dir/$pic_object" 11045ef981d24Smrg fi 11046ef981d24Smrg 11047ef981d24Smrg # Add non-PIC object to the list of files to remove. 11048b312a94cSmrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11049200d7199Smrg func_append rmfiles " $dir/$non_pic_object" 11050ef981d24Smrg fi 11051ef981d24Smrg fi 11052ef981d24Smrg ;; 11053ef981d24Smrg 11054ef981d24Smrg *) 11055b312a94cSmrg if test clean = "$opt_mode"; then 11056ef981d24Smrg noexename=$name 11057ef981d24Smrg case $file in 11058ef981d24Smrg *.exe) 1105965eef222Smrg func_stripname '' '.exe' "$file" 1106065eef222Smrg file=$func_stripname_result 1106165eef222Smrg func_stripname '' '.exe' "$name" 1106265eef222Smrg noexename=$func_stripname_result 11063ef981d24Smrg # $file with .exe has already been added to rmfiles, 11064ef981d24Smrg # add $file without .exe 11065200d7199Smrg func_append rmfiles " $file" 11066ef981d24Smrg ;; 11067ef981d24Smrg esac 11068ef981d24Smrg # Do a test to see if this is a libtool program. 1106965eef222Smrg if func_ltwrapper_p "$file"; then 1107065eef222Smrg if func_ltwrapper_executable_p "$file"; then 1107165eef222Smrg func_ltwrapper_scriptname "$file" 1107265eef222Smrg relink_command= 1107365eef222Smrg func_source $func_ltwrapper_scriptname_result 11074200d7199Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 1107565eef222Smrg else 1107665eef222Smrg relink_command= 1107765eef222Smrg func_source $dir/$noexename 1107865eef222Smrg fi 11079ef981d24Smrg 11080ef981d24Smrg # note $name still contains .exe if it was in $file originally 11081ef981d24Smrg # as does the version of $file that was added into $rmfiles 11082b312a94cSmrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11083b312a94cSmrg if test yes = "$fast_install" && test -n "$relink_command"; then 11084200d7199Smrg func_append rmfiles " $odir/lt-$name" 11085ef981d24Smrg fi 11086b312a94cSmrg if test "X$noexename" != "X$name"; then 11087b312a94cSmrg func_append rmfiles " $odir/lt-$noexename.c" 11088ef981d24Smrg fi 11089ef981d24Smrg fi 11090ef981d24Smrg fi 11091ef981d24Smrg ;; 11092ef981d24Smrg esac 1109365eef222Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11094ef981d24Smrg done 11095ef981d24Smrg 11096b312a94cSmrg # Try to remove the $objdir's in the directories where we deleted files 11097ef981d24Smrg for dir in $rmdirs; do 11098ef981d24Smrg if test -d "$dir"; then 1109965eef222Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11100ef981d24Smrg fi 11101ef981d24Smrg done 11102ef981d24Smrg 11103ef981d24Smrg exit $exit_status 1110465eef222Smrg} 11105ef981d24Smrg 11106b312a94cSmrgif test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11107b312a94cSmrg func_mode_uninstall ${1+"$@"} 11108b312a94cSmrgfi 11109ef981d24Smrg 11110200d7199Smrgtest -z "$opt_mode" && { 11111b312a94cSmrg help=$generic_help 1111265eef222Smrg func_fatal_help "you must specify a MODE" 1111365eef222Smrg} 1111465eef222Smrg 1111565eef222Smrgtest -z "$exec_cmd" && \ 11116b312a94cSmrg func_fatal_help "invalid operation mode '$opt_mode'" 11117ef981d24Smrg 11118ef981d24Smrgif test -n "$exec_cmd"; then 1111965eef222Smrg eval exec "$exec_cmd" 11120ef981d24Smrg exit $EXIT_FAILURE 11121ef981d24Smrgfi 11122ef981d24Smrg 1112365eef222Smrgexit $exit_status 11124ef981d24Smrg 11125ef981d24Smrg 11126ef981d24Smrg# The TAGs below are defined such that we never get into a situation 11127b312a94cSmrg# where we disable both kinds of libraries. Given conflicting 11128ef981d24Smrg# choices, we go for a static library, that is the most portable, 11129ef981d24Smrg# since we can't tell whether shared libraries were disabled because 11130ef981d24Smrg# the user asked for that or because the platform doesn't support 11131ef981d24Smrg# them. This is particularly important on AIX, because we don't 11132ef981d24Smrg# support having both static and shared libraries enabled at the same 11133ef981d24Smrg# time on that platform, so we default to a shared-only configuration. 11134ef981d24Smrg# If a disable-shared tag is given, we'll fallback to a static-only 11135ef981d24Smrg# configuration. But we'll never go from static-only to shared-only. 11136ef981d24Smrg 11137ef981d24Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 1113865eef222Smrgbuild_libtool_libs=no 1113965eef222Smrgbuild_old_libs=yes 11140ef981d24Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 11141ef981d24Smrg 11142ef981d24Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 1114365eef222Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11144ef981d24Smrg# ### END LIBTOOL TAG CONFIG: disable-static 11145ef981d24Smrg 11146ef981d24Smrg# Local Variables: 11147ef981d24Smrg# mode:shell-script 11148ef981d24Smrg# sh-indentation:2 11149ef981d24Smrg# End: 11150